17 lines
19 KiB
JavaScript
17 lines
19 KiB
JavaScript
|
"use strict";exports.id=7318,exports.ids=[7318],exports.modules={77802:(e,t,a)=>{a.d(t,{A:()=>F});var l=a(8732),s=a(82015),i=a.n(s);function r({tableFields:e,setTableFields:t,setRefresh:a,setPageRefresh:l,refreshFieldsListRef:s}){let i=e.findIndex(e=>"date_created"===e.fieldName);e.splice(i,0,{newTempField:!0}),t(e),s?.current&&s.current(e=>e+1)}a(80255);var d=a(39897),n=a(32415),o=a(64030),c=a(27825),m=a.n(c);function u({tableFields:e,setTableFields:t,refreshFieldsListRef:a,order:l,field:s,e:i}){let r=m().cloneDeep(e),d=r.findIndex(e=>e.fieldName===s.fieldName);if(d<0)return;let n=r[d];if("up"===l&&d&&d<=1){console.log("Min Reached =>",d);return}if("down"===l&&d&&d>=r.length-7){console.log("Max Reached =>",d);return}try{let e;let t=i.target.closest(".table-field-wrapper"),a=t.previousElementSibling,s=t.nextElementSibling,r=window.DSQL.Flip,d=r.getState(t);"up"===l?(e=r.getState(a),t.parentNode?.insertBefore(t,a)):s?.nextElementSibling&&(e=r.getState(s),t.parentNode?.insertBefore(t,s.nextElementSibling)),r.from(d,{duration:.3,ease:"power1.inOut"}),r.from(e,{duration:.3,ease:"power1.inOut"})}catch(e){console.log("Error =>",e.message)}if(!d){console.log("No target Field Index =>",d);return}r.splice(d,1),"up"===l?r.splice(d-1,0,n):r.splice(d+1,0,n),setTimeout(()=>{t([...r]),a.current&&a.current(e=>e+1)},500)}var p=a(64417),x=a(12097),h=a(63715);function f({field:e,setTargetField:t,fieldIndex:a,tableFields:s,setTableFields:r,refreshFieldsListRef:d,database:n,currentTable:c,user:m,isDelegated:u,setLoading:p}){let[f,g]=i().useState(e),[y,w]=i().useState(!1);return(0,l.jsxs)("div",{className:"flex-col w-full table-field-wrapper"+(y?" shadow-2xl shadow-slate-700/40 relative z-50":""),children:[(0,l.jsxs)("div",{className:"card no-hover items-center w-full py-4"+(y?" rounded-t":" rounded")+(f.fieldName?.match(o.A)?" text-slate-400 pointer-events-none border-slate-200 border":" light-gray"),children:[(0,l.jsx)("span",{className:"font-bold"+(f.fieldName?.match(o.A)?" dark:text-slate-500":" dark:text-white"),children:f.fieldName}),(0,l.jsx)("span",{className:"text-xs py-1 px-2 bg-slate-100 dark:bg-slate-700 dark:text-slate-200 rounded ",children:f.dataType}),f?.foreignKey&&(0,l.jsxs)("div",{className:"text-xs bg-primary text-white px-2 py-0.5 rounded-full",children:[(0,l.jsx)("span",{children:"Foreign Key: "}),(0,l.jsxs)("span",{children:[f.foreignKey.destinationTableName," ("," ",(0,l.jsx)("b",{children:f.foreignKey.destinationTableColumnName})," ",")"]})]}),f.fieldName?.match(o.A)&&(0,l.jsx)("span",{className:"text-slate-300 text-sm font-semibold ml-0 md:ml-auto",children:"Default Field"}),!(!u&&!f.fieldName?.match(o.A)&&f.dataType?.match(/INT/))||f.foreignKey||n?.active_clone?.toString()?.match(/1/)?!u&&!f.fieldName?.match(o.A)&&f.dataType?.match(/INT/)&&!n?.active_clone?.toString()?.match(/1/)?(0,l.jsx)("div",{className:"ml-0 md:ml-auto flex-wrap",children:(0,l.jsx)("div",{className:"button py-1 text-xs light-gray",onClick:t=>{window.confirm("Delete this foreign Key?")&&(delete e.foreignKey,p(!0),(0,h.A)("/api/updateClonedTableForeignKeys",{method:"post",body:{tableData:c,database:n.db_full_name,dbSlug:n.db_slug,delegated:!!window.location?.search?.match(/delegated=true/i)}},!0).then(e=>{e.success?window.location.reload():window.alert("Update Failed, Please Try again.")}))},style:{color:"var(--slate-500)"},children:"Delete Foreign Key"})}):(0,l.jsx)(i().Fragment,{}):(0,l.jsx)("div",{className:"ml-0 md:ml-auto flex-wrap",children:(0,l.jsx)("div",{className:"button outlined py-1 text-xs gray",onClick:e=>{y?w(!1):w(!0)},style:{color:"var(--slate-500)"},children:"Add Foreign Key"})})]}),y&&!u&&(0,l.jsx)("div",{className:"card col w-full -mt-5 pt-0 no-hover",children:(0,l.jsx)(x.A,{targetField:e,setFieldData:g,tableFields:s,setTableFields:r,database:n,currentTable:c,user:m,setActiveEdit:w,activeClonedTable:!0})})]})}var g=a(65388),y=a(84896);function w({fieldIndex:e,setTableFields:t,database:s,user:r,isNewField:d,setLiteralValue:n,tempFieldData:o,setTempFieldData:c,dataTypeValue:m,setDataTypeValue:u,dataType:p,setDataType:x,dataType
|
||
|
* @typedef {object} ${s}`),d.forEach(e=>{let t=e.nullValue?"?":e.fieldName?.match(l.A)?"?":"";n.push(` ${e.fieldName}${t}: ${r(e.dataType||"")};`),o.push(` * @property {${r(e.dataType||"")}${t}} ${e.fieldName}`)}),n.push("}"),o.push(" */"),e?.match(/javascript/i)&&(i=o.join("\n")),e?.match(/typescript/i)&&(i=n.join("\n"))}catch(e){console.log(e.message),i=null}return i}},39897:(e,t,a)=>{a.d(t,{A:()=>s});var l=a(8732);function s({collapse:e,setCollapse:t}){return(0,l.jsxs)("div",{className:"collapse-block"+(e?" -mt-16 -mb-6 pt-10":" mt-0 mb-0 p-0"),onClick:a=>{e?t(!1):t(!0)},children:[(0,l.jsx)("span",{children:e?"Expand":"Collapse"}),(0,l.jsx)("img",{src:"/images/down-arrow-dark.svg",alt:"Down Arrow",width:16,className:"dark:hidden opacity-30 "+(e?"":"rotate-180")}),(0,l.jsx)("img",{src:"/images/down-arrow-white.svg",alt:"Down Arrow",width:16,className:"opacity-30 hidden dark:flex "+(e?"":"rotate-180")})]})}a(82015)},43479:(e,t,a)=>{a.d(t,{A:()=>r});let l=a(68942),s=a(29021),i=a(33873);function r({userId:e}){try{let t=i.resolve(process.cwd(),`${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${e}/main.json`);return JSON.parse(s.readFileSync(t,"utf-8"))}catch(e){return l({component:"/functions/backend/grabUserSchemaData",message:e.message}),null}}},68942:(e,t,a)=>{let l=a(29021),{IncomingMessage:s}=a(81630);e.exports=async function({user:e,message:t,component:a,noMail:s,req:i}){let r=new Date,d=(()=>{if(!i)return null;try{let e=i.headers["x-forwarded-for"],t=i.headers["x-real-ip"],a=i.headers["cf-connecting-ip"],l=Array.isArray(e)?e[0]:e?.split(",")[0],s=a||l||t||i.socket.remoteAddress;if(!s)return null;return String(s)}catch(e){return null}})();try{let s=`🚀 SERVER ERROR ===========================
|
||
|
Error Message: ${t}
|
||
|
Component: ${a}`;e?.id&&e?.first_name&&e?.last_name&&e?.email&&(s+=`
|
||
|
User Id: ${e?.id}
|
||
|
User Name: ${e?.first_name} ${e?.last_name}
|
||
|
User Email: ${e?.email}`),i?.url&&(s+=`
|
||
|
URL: ${i.url}`),i?.body&&(s+=`
|
||
|
Request Body: ${JSON.stringify(i.body,null,4)}`),d&&(s+=`
|
||
|
IP: ${d}`),s+=`
|
||
|
Date: ${r.toDateString()}
|
||
|
========================================`,l.existsSync("./.tmp/error.log")||l.writeFileSync("./.tmp/error.log","","utf-8");let n=l.readFileSync("./.tmp/error.log","utf-8");l.writeFileSync("./.tmp/error.log",s),l.appendFileSync("./.tmp/error.log",`
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
${n}`)}catch(e){console.log("Server Error Reporting Error:",e.message)}}},64030:(e,t,a)=>{a.d(t,{A:()=>l});let l=/^id$|^uuid$|^date_created$|^date_created_code$|^date_created_timestamp$|^date_updated$|^date_updated_code$|^date_updated_timestamp$/}};
|