dsql-admin/dsql-app/.local_dist/server/pages/admin/[user_id]/schema.js
Benjamin Toby 7a06e83a46 Updates
2024-12-08 20:56:57 +01:00

1 line
16 KiB
JavaScript

"use strict";(()=>{var e={};e.id=8591,e.ids=[636,8591],e.modules={30671:(e,t)=>{Object.defineProperty(t,"M",{enumerable:!0,get:function(){return function e(t,r){return r in t?t[r]:"then"in t&&"function"==typeof t.then?t.then(t=>e(t,r)):"function"==typeof t&&"default"===r?t:void 0}}})},23133:(e,t,r)=>{r.a(e,async(e,s)=>{try{r.r(t),r.d(t,{config:()=>x,default:()=>d,getServerSideProps:()=>h,getStaticPaths:()=>m,getStaticProps:()=>p,reportWebVitals:()=>y,routeModule:()=>A,unstable_getServerProps:()=>b,unstable_getServerSideProps:()=>j,unstable_getStaticParams:()=>v,unstable_getStaticPaths:()=>g,unstable_getStaticProps:()=>f});var a=r(63865),i=r(9455),l=r(30671),n=r(49407),o=r(68268),u=r(74094),c=e([u]);u=(c.then?(await c)():c)[0];let d=(0,l.M)(u,"default"),p=(0,l.M)(u,"getStaticProps"),m=(0,l.M)(u,"getStaticPaths"),h=(0,l.M)(u,"getServerSideProps"),x=(0,l.M)(u,"config"),y=(0,l.M)(u,"reportWebVitals"),f=(0,l.M)(u,"unstable_getStaticProps"),g=(0,l.M)(u,"unstable_getStaticPaths"),v=(0,l.M)(u,"unstable_getStaticParams"),b=(0,l.M)(u,"unstable_getServerProps"),j=(0,l.M)(u,"unstable_getServerSideProps"),A=new a.PagesRouteModule({definition:{kind:i.A.PAGES,page:"/admin/[user_id]/schema",pathname:"/admin/[user_id]/schema",bundlePath:"",filename:""},components:{App:o.default,Document:n.default},userland:u});s()}catch(e){s(e)}})},74223:(e,t,r)=>{r.a(e,async(e,s)=>{try{r.d(t,{A:()=>x});var a=r(8732),i=r(82015),l=r.n(i),n=r(58548),o=r(51548),u=r(74094),c=r(40942);r(63715),r(34844);var d=r(89788),p=r(56248),m=r.n(p),h=e([u,c,d]);function x(e){let{dbSchemaData:t,user:r}=l().useContext(u.UserSchemaContext),[s,i]=l().useState(t),[c,p]=l().useState(null),[h,x]=l().useState(null),[y,f]=l().useState(null);return(0,a.jsxs)(l().Fragment,{children:[(0,a.jsxs)("div",{className:"flex-col items-start gap-0 w-full",children:[(0,a.jsx)("div",{className:"",children:(0,a.jsx)("h1",{className:"text-3xl m-0",children:"User Schema"})}),(0,a.jsx)(n.A,{user:r})]}),(0,a.jsx)("section",{className:"paper",children:(0,a.jsxs)("div",{className:"flex-col items-start w-full",children:[(0,a.jsxs)("div",{className:"w-full justify-between",children:[(0,a.jsx)("h2",{className:"text-xl m-0",children:"Database SCHEMA JSON"}),(0,a.jsxs)("div",{children:[(0,a.jsx)(o.A,{required:!0,selectOptions:[{title:"All Databases",payload:"none"},...t.map((e,t)=>({title:e.dbName,payload:e.dbFullName,name:e.dbFullName}))],name:"databases",onChangeHandler:e=>{e.target.value?.match(/^none$/)?p(null):p(e.target.value)}}),h&&h[0]&&(0,a.jsx)(o.A,{required:!0,selectOptions:[{title:"All Tables",payload:"none"},...h.map((e,t)=>({title:e.tableFullName,payload:e.tableName,name:e.tableName}))],name:"database_tables",onChangeHandler:e=>{e.target.value?.match(/^none$/)?f(null):f(e.target.value)}})]})]}),(0,a.jsx)(d.A,{content:m().stringify(s,null,4),readOnly:!0,options:{wrap:!0},wrapperProps:{className:"h-[60vh]"}})]})})]})}[u,c,d]=h.then?(await h)():h,s()}catch(e){s(e)}})},40942:(e,t,r)=>{r.a(e,async(e,t)=>{try{r(8732),r(82015);var s=r(74094),a=e([s]);s=(a.then?(await a)():a)[0],t()}catch(e){t(e)}})},84759:(e,t,r)=>{r.d(t,{A:()=>s});function s({editorHTMLElementRef:e,fieldObject:t,setRefresh:r,language:s="javascript",entry:a,jsonTextEditors:i,editorRef:l,readOnly:n,initialContent:o,options:u}){try{if(!ace?.edit||!e.current){console.log("Ace Editor not found!"),setTimeout(()=>{r?.(e=>e+1)},1e3);return}let c=ace.edit(e.current);c.setOptions({mode:"ace/mode/"+s,value:o||(t?.defaultValue?t.defaultValue:t?.fieldName&&a?.[t.fieldName]?(()=>{if("json"!==s)return a[t.fieldName];try{return JSON.stringify(JSON.parse(a[t.fieldName]),null,4)}catch(e){return a[t.fieldName]}})():""),placeholder:"json"==s?"{}":"",enableBasicAutocompletion:!0,enableLiveAutocompletion:!0,readOnly:n,...u}),l&&t?.fieldName&&(i?.current.push({fieldName:t.fieldName,ref:l}),l.current=c);try{ace.require("ace/ext/beautify").beautify(c.session)}catch(e){}}catch(e){console.log("JSON Editor ERROR =>",e.message)}}},51548:(e,t,r)=>{r.d(t,{A:()=>i});var s=r(8732),a=r(58526);function i({selectOptions:e,name:t,onChangeHandler:r,required:i,setAlert:l,title:n,defaultValue:o,info:u,id:c}){try{function d(e){if(e.type.match(/enter/i)&&window.innerWidth<1200)return;let t=e.target.closest(".info-wrapper"),r=t.querySelector(".info-dropdown");if(e.type.match(/leave/i)&&!r.classList.contains("hidden")){r.classList.add("hidden");return}if(!(e.type.match(/leave/i)&&r.classList.contains("hidden"))){if(!t){r.classList.add("hidden");return}if(r.classList.contains("hidden")){r.classList.remove("hidden");return}r.classList.add("hidden")}}return(0,s.jsxs)("div",{className:"form-select-block flex items-start flex-col gap-0.5 w-full relative"+(u?" pr-8":""),children:[n&&(0,s.jsxs)("label",{htmlFor:t,children:[n,i?"":" (optional)"]}),(0,s.jsxs)("div",{className:"flex items-center w-full relative",children:[(0,s.jsx)("select",{name:t,id:c||t,className:"w-full bg-white",required:i,onChange:e=>{l&&l(null),e.target.classList.remove("warning"),r&&r(e)},defaultValue:o||void 0,children:e.map((e,t)=>{let{payload:r,title:a}=e;return(0,s.jsx)("option",{value:r,selected:!!e.default,children:a},t+1)})}),(0,s.jsx)(a.A,{className:"absolute right-2 text-base text-slate-500 pointer-events-none",size:20}),u&&(0,s.jsxs)("div",{className:"info-wrapper absolute -right-10 w-8 h-8 rounded-full bg-white flex items-center justify-center z-10",style:{top:"50%",transform:"translate(0,-50%)"},onMouseEnter:d,onMouseLeave:d,onClick:d,children:[(0,s.jsx)("img",{src:"/images/info-outlined-black.png",alt:"",className:"w-6 h-6 object-contain opacity-60 pointer-events-none"}),(0,s.jsx)("div",{className:"info-dropdown absolute top-9 right-0 bg-white w-52 md:w-96 p-2 sm:p-6 shadow-xl rounded hidden text-center border border-slate-300 border-solid",children:(0,s.jsx)("span",{children:u})}),(0,s.jsx)("div",{className:"absolute -top-2 w-12",style:{height:"45px"}})]})]})]})}catch(e){return console.log("ERROR in FormSelect =>",e),(0,s.jsx)("div",{children:"Form Select Error"})}}r(82015)},89788:(e,t,r)=>{r.a(e,async(e,s)=>{try{r.d(t,{A:()=>u});var a=r(8732);r(63715);var i=r(82015),l=r.n(i);r(84759);var n=r(75979),o=e([n]);function u({editorRef:e,content:t,readOnly:r,language:s="javascript",options:i,wrapperProps:o}){try{let e=l().useRef(),[t,r]=l().useState(0);return(0,a.jsx)("div",{...o,ref:e,className:(0,n.twMerge)("ace-editor-wrapper w-full h-full minimal-scrollbars all-children",o?.className)})}catch(e){return(0,a.jsx)(l().Fragment,{children:(0,a.jsx)("h2",{className:"text-xl m-0",children:"Editor Error"})})}}n=(o.then?(await o)():o)[0],s()}catch(e){s(e)}})},34844:(e,t,r)=>{r.d(t,{A:()=>u});var s=r(8732),a=r(82015),i=r.n(a),l=r(11790),n=r.n(l),o=r(96089);function u({content:e,language:t,style:r,showCopy:a}){let[l,u]=i().useState(!1),c=()=>{u(!0)},d=(e,t)=>{"clickaway"!==t&&u(!1)},p=(0,s.jsx)(i().Fragment,{children:(0,s.jsx)("button",{className:"outlined gray",style:{border:"none",padding:"2px",width:"20px",height:"20px",color:"white"},onClick:d,children:"✖"})}),m={};return(0,s.jsxs)("pre",{className:`language-${t||"javascript"} w-auto overflow-hidden skip-js code-block relative max-w-4xl flex items-center justify-center`,style:r?{...r,...m}:m,children:[(0,s.jsx)("code",{className:"w-auto px-10",style:{wordBreak:"break-all"},children:e}),(0,s.jsx)("button",{className:"outlined copy-code "+(a?"relative show":" absolute right-2 z-20 hover:opacity-50"),style:{padding:"2px",border:"none"},onClick:t=>{navigator.clipboard.writeText(e).then(()=>{c()})},children:(0,s.jsx)(o.A,{className:"text-white",size:20})}),(0,s.jsx)(n(),{open:l,autoHideDuration:2e3,onClose:d,children:(0,s.jsxs)("div",{className:"h-full text-white px-4 py-2 justify-between rounded",style:{maxWidth:"250px",width:"250px",backgroundColor:"#0b8862"},children:[(0,s.jsx)("span",{children:"Code Copied!"}),p]})})]})}},24671:(e,t,r)=>{r.d(t,{A:()=>a});var s=r(8732);function a(e){return(0,s.jsxs)("a",{href:"/email-verification",className:"card w-full items-center justify-center py-4 gap-2",children:[(0,s.jsx)("img",{src:"/images/warning.png",alt:"Down Arrow",width:25,className:""}),(0,s.jsx)("span",{children:"Your Account is not verified. Please verify your account."})]})}r(82015)},26406:(e,t,r)=>{var s=r(24994);t.A=void 0;var a=s(r(30887)),i=r(8732);t.A=(0,a.default)([(0,i.jsx)("path",{d:"M22 15c0-1.66-1.34-3-3-3h-1.5v-.5C17.5 8.46 15.04 6 12 6c-.77 0-1.49.17-2.16.46L20.79 17.4c.73-.55 1.21-1.41 1.21-2.4M2 14c0 2.21 1.79 4 4 4h9.73l-8-8H6c-2.21 0-4 1.79-4 4",opacity:".3"},"0"),(0,i.jsx)("path",{d:"M19.35 10.04C18.67 6.59 15.64 4 12 4c-1.33 0-2.57.36-3.65.97l1.49 1.49C10.51 6.17 11.23 6 12 6c3.04 0 5.5 2.46 5.5 5.5v.5H19c1.66 0 3 1.34 3 3 0 .99-.48 1.85-1.21 2.4l1.41 1.41c1.09-.92 1.8-2.27 1.8-3.81 0-2.64-2.05-4.78-4.65-4.96M3 5.27l2.77 2.77h-.42C2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h11.73l2 2 1.41-1.41L4.41 3.86zM7.73 10l8 8H6c-2.21 0-4-1.79-4-4s1.79-4 4-4z"},"1")],"CloudOffTwoTone")},92441:(e,t,r)=>{r.d(t,{A:()=>s});let s=(0,r(82544).A)("BookText",[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H20v20H6.5a2.5 2.5 0 0 1 0-5H20",key:"t4utmx"}],["path",{d:"M8 7h6",key:"1f0q6e"}],["path",{d:"M8 11h8",key:"vwpz6n"}]])},96089:(e,t,r)=>{r.d(t,{A:()=>s});let s=(0,r(82544).A)("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]])},34637:(e,t,r)=>{r.d(t,{A:()=>s});let s=(0,r(82544).A)("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]])},29743:(e,t,r)=>{r.d(t,{A:()=>s});let s=(0,r(82544).A)("FileKey2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v6",key:"rc0qvx"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"4",cy:"16",r:"2",key:"1ehqvc"}],["path",{d:"m10 10-4.5 4.5",key:"7fwrp6"}],["path",{d:"m9 11 1 1",key:"wa6s5q"}]])},10643:(e,t,r)=>{r.d(t,{A:()=>s});let s=(0,r(82544).A)("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]])},66916:(e,t,r)=>{r.d(t,{A:()=>s});let s=(0,r(82544).A)("HardDrive",[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]])},83158:(e,t,r)=>{r.d(t,{A:()=>s});let s=(0,r(82544).A)("Images",[["path",{d:"M18 22H4a2 2 0 0 1-2-2V6",key:"pblm9e"}],["path",{d:"m22 13-1.296-1.296a2.41 2.41 0 0 0-3.408 0L11 18",key:"nf6bnh"}],["circle",{cx:"12",cy:"8",r:"2",key:"1822b1"}],["rect",{width:"16",height:"16",x:"6",y:"2",rx:"2",key:"12espp"}]])},66918:(e,t,r)=>{r.d(t,{A:()=>s});let s=(0,r(82544).A)("RotateCw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]])},10321:(e,t,r)=>{r.d(t,{A:()=>s});let s=(0,r(82544).A)("ShieldEllipsis",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M8 12h.01",key:"czm47f"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M16 12h.01",key:"1l6xoz"}]])},25294:(e,t,r)=>{r.d(t,{A:()=>s});let s=(0,r(82544).A)("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]])},56248:e=>{e.exports={parse:function(e,t){if(e){if("object"==typeof e)return e;if("string"==typeof e)try{return JSON.parse(e,t)}catch(e){return}}},stringify:function(e,t,r){try{return JSON.stringify(e,t,r)}catch(e){return}}}},74094:(e,t,r)=>{r.a(e,async(e,s)=>{try{r.r(t),r.d(t,{UserSchemaContext:()=>f,default:()=>h,getServerSideProps:()=>x});var a=r(8732),i=r(82015),l=r.n(i),n=r(95222),o=r(20048),u=r.n(o),c=r(74223),d=r(24671),p=r(58548),m=e([c]);c=(m.then?(await m)():m)[0];let y=r(29021),f=l().createContext({});function h({user:e,query:t,dbSchemaData:r}){let s=(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("title",{children:"Add Database | Datasquirel"}),(0,a.jsx)("meta",{name:"description",content:"Add a database"})]});return(0,a.jsx)(n.A,{head:s,user:e,aceEditor:!0,children:(0,a.jsx)(f.Provider,{value:{user:e,dbSchemaData:r},children:e?.verification_status?.toString().match(/1/)?(0,a.jsx)(l().Fragment,{children:(0,a.jsx)(c.A,{})}):(0,a.jsxs)(l().Fragment,{children:[(0,a.jsxs)("div",{className:"flex-col items-start gap-0 w-full",children:[(0,a.jsx)("div",{className:"",children:(0,a.jsx)("h1",{className:"text-3xl m-0",children:"User Schema"})}),(0,a.jsx)(p.A,{user:e})]}),(0,a.jsx)(d.A,{})]})})})}async function x({req:e,res:t,query:r}){let s=await u()(e,t);if(!s?.logged_in_status)return{redirect:{destination:"/login",permanent:!1}};let a=`${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${s.id}/main.json`;if(!y.existsSync(a))return{redirect:{destination:"/admin",permanent:!1}};let i=JSON.parse(y.readFileSync(a,"utf-8"));return{props:{user:s,query:r,dbSchemaData:i||[]}}}s()}catch(e){s(e)}})},9455:(e,t)=>{var r;Object.defineProperty(t,"A",{enumerable:!0,get:function(){return r}}),function(e){e.PAGES="PAGES",e.PAGES_API="PAGES_API",e.APP_PAGE="APP_PAGE",e.APP_ROUTE="APP_ROUTE",e.IMAGE="IMAGE"}(r||(r={}))},66099:e=>{e.exports=require("@mui/system")},37616:e=>{e.exports=require("@mui/system/DefaultPropsProvider")},24509:e=>{e.exports=require("@mui/system/InitColorSchemeScript")},84781:e=>{e.exports=require("@mui/system/colorManipulator")},18215:e=>{e.exports=require("@mui/system/createStyled")},59989:e=>{e.exports=require("@mui/system/createTheme")},16670:e=>{e.exports=require("@mui/system/styleFunctionSx")},88698:e=>{e.exports=require("@mui/system/useThemeProps")},76831:e=>{e.exports=require("@mui/utils")},28578:e=>{e.exports=require("@mui/utils/capitalize")},54341:e=>{e.exports=require("@mui/utils/chainPropTypes")},14036:e=>{e.exports=require("@mui/utils/composeClasses")},31112:e=>{e.exports=require("@mui/utils/createChainedFunction")},21763:e=>{e.exports=require("@mui/utils/debounce")},7546:e=>{e.exports=require("@mui/utils/deepmerge")},5928:e=>{e.exports=require("@mui/utils/deprecatedPropType")},30729:e=>{e.exports=require("@mui/utils/elementAcceptingRef")},47822:e=>{e.exports=require("@mui/utils/extractEventHandlers")},20985:e=>{e.exports=require("@mui/utils/formatMuiErrorMessage")},61119:e=>{e.exports=require("@mui/utils/generateUtilityClass")},81699:e=>{e.exports=require("@mui/utils/generateUtilityClasses")},16362:e=>{e.exports=require("@mui/utils/getReactElementRef")},71291:e=>{e.exports=require("@mui/utils/integerPropType")},29823:e=>{e.exports=require("@mui/utils/isMuiElement")},55402:e=>{e.exports=require("@mui/utils/ownerDocument")},46875:e=>{e.exports=require("@mui/utils/ownerWindow")},48080:e=>{e.exports=require("@mui/utils/requirePropFactory")},39597:e=>{e.exports=require("@mui/utils/setRef")},88190:e=>{e.exports=require("@mui/utils/unsupportedProp")},83889:e=>{e.exports=require("@mui/utils/useControlled")},21956:e=>{e.exports=require("@mui/utils/useEnhancedEffect")},4926:e=>{e.exports=require("@mui/utils/useEventCallback")},7376:e=>{e.exports=require("@mui/utils/useForkRef")},63310:e=>{e.exports=require("@mui/utils/useId")},10977:e=>{e.exports=require("@mui/utils/useIsFocusVisible")},10179:e=>{e.exports=require("@mui/utils/useSlotProps")},710:e=>{e.exports=require("@mui/utils/useTimeout")},74956:e=>{e.exports=require("clsx")},40361:e=>{e.exports=require("next/dist/compiled/next-server/pages.runtime.prod.js")},27912:e=>{e.exports=require("next/head")},29825:e=>{e.exports=require("prop-types")},82015:e=>{e.exports=require("react")},22326:e=>{e.exports=require("react-dom")},37727:e=>{e.exports=require("react-transition-group")},8732:e=>{e.exports=require("react/jsx-runtime")},9973:e=>{e.exports=require("serverless-mysql")},79428:e=>{e.exports=require("buffer")},55511:e=>{e.exports=require("crypto")},29021:e=>{e.exports=require("fs")},81630:e=>{e.exports=require("http")},33873:e=>{e.exports=require("path")},75979:e=>{e.exports=import("tailwind-merge")}};var t=require("../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),s=t.X(0,[9764,883,1790,8268,7070],()=>r(23133));module.exports=s})();