dsql-admin/dsql-app/.local_dist/server/pages/admin/[user_id]/schema.js
Benjamin Toby a7dfd48284 Updates
2024-12-09 10:39:09 +01:00

1 line
13 KiB
JavaScript

"use strict";(()=>{var e={};e.id=8591,e.ids=[8591],e.modules={30671:(e,t)=>{Object.defineProperty(t,"M",{enumerable:!0,get:function(){return function e(t,a){return a in t?t[a]:"then"in t&&"function"==typeof t.then?t.then(t=>e(t,a)):"function"==typeof t&&"default"===a?t:void 0}}})},23133:(e,t,a)=>{a.a(e,async(e,r)=>{try{a.r(t),a.d(t,{config:()=>x,default:()=>u,getServerSideProps:()=>m,getStaticPaths:()=>p,getStaticProps:()=>h,reportWebVitals:()=>y,routeModule:()=>j,unstable_getServerProps:()=>A,unstable_getServerSideProps:()=>b,unstable_getStaticParams:()=>g,unstable_getStaticPaths:()=>v,unstable_getStaticProps:()=>f});var s=a(63865),n=a(9455),l=a(30671),i=a(49407),c=a(89600),d=a(74094),o=e([d]);d=(o.then?(await o)():o)[0];let u=(0,l.M)(d,"default"),h=(0,l.M)(d,"getStaticProps"),p=(0,l.M)(d,"getStaticPaths"),m=(0,l.M)(d,"getServerSideProps"),x=(0,l.M)(d,"config"),y=(0,l.M)(d,"reportWebVitals"),f=(0,l.M)(d,"unstable_getStaticProps"),v=(0,l.M)(d,"unstable_getStaticPaths"),g=(0,l.M)(d,"unstable_getStaticParams"),A=(0,l.M)(d,"unstable_getServerProps"),b=(0,l.M)(d,"unstable_getServerSideProps"),j=new s.PagesRouteModule({definition:{kind:n.A.PAGES,page:"/admin/[user_id]/schema",pathname:"/admin/[user_id]/schema",bundlePath:"",filename:""},components:{App:c.default,Document:i.default},userland:d});r()}catch(e){r(e)}})},74223:(e,t,a)=>{a.a(e,async(e,r)=>{try{a.d(t,{A:()=>x});var s=a(8732),n=a(82015),l=a.n(n),i=a(58548),c=a(51548),d=a(74094),o=a(40942);a(63715),a(34844);var u=a(89788),h=a(56248),p=a.n(h),m=e([d,o,u]);function x(e){let{dbSchemaData:t,user:a}=l().useContext(d.UserSchemaContext),[r,n]=l().useState(t),[o,h]=l().useState(null),[m,x]=l().useState(null),[y,f]=l().useState(null);return(0,s.jsxs)(l().Fragment,{children:[(0,s.jsxs)("div",{className:"flex-col items-start gap-0 w-full",children:[(0,s.jsx)("div",{className:"",children:(0,s.jsx)("h1",{className:"text-3xl m-0",children:"User Schema"})}),(0,s.jsx)(i.A,{user:a})]}),(0,s.jsx)("section",{className:"paper",children:(0,s.jsxs)("div",{className:"flex-col items-start w-full",children:[(0,s.jsxs)("div",{className:"w-full justify-between",children:[(0,s.jsx)("h2",{className:"text-xl m-0",children:"Database SCHEMA JSON"}),(0,s.jsxs)("div",{children:[(0,s.jsx)(c.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$/)?h(null):h(e.target.value)}}),m&&m[0]&&(0,s.jsx)(c.A,{required:!0,selectOptions:[{title:"All Tables",payload:"none"},...m.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,s.jsx)(u.A,{content:p().stringify(r,null,4),readOnly:!0,options:{wrap:!0},wrapperProps:{className:"h-[60vh]"}})]})})]})}[d,o,u]=m.then?(await m)():m,r()}catch(e){r(e)}})},40942:(e,t,a)=>{a.a(e,async(e,t)=>{try{a(8732),a(82015);var r=a(74094),s=e([r]);r=(s.then?(await s)():s)[0],t()}catch(e){t(e)}})},84759:(e,t,a)=>{a.d(t,{A:()=>r});function r({editorHTMLElementRef:e,fieldObject:t,setRefresh:a,language:r="javascript",entry:s,jsonTextEditors:n,editorRef:l,readOnly:i,initialContent:c,options:d}){try{if(!ace?.edit||!e.current){console.log("Ace Editor not found!"),setTimeout(()=>{a?.(e=>e+1)},1e3);return}let o=ace.edit(e.current);o.setOptions({mode:"ace/mode/"+r,value:c||(t?.defaultValue?t.defaultValue:t?.fieldName&&s?.[t.fieldName]?(()=>{if("json"!==r)return s[t.fieldName];try{return JSON.stringify(JSON.parse(s[t.fieldName]),null,4)}catch(e){return s[t.fieldName]}})():""),placeholder:"json"==r?"{}":"",enableBasicAutocompletion:!0,enableLiveAutocompletion:!0,readOnly:i,...d}),l&&t?.fieldName&&(n?.current.push({fieldName:t.fieldName,ref:l}),l.current=o);try{ace.require("ace/ext/beautify").beautify(o.session)}catch(e){}}catch(e){console.log("JSON Editor ERROR =>",e.message)}}},51548:(e,t,a)=>{a.d(t,{A:()=>n});var r=a(8732),s=a(58526);function n({selectOptions:e,name:t,onChangeHandler:a,required:n,setAlert:l,title:i,defaultValue:c,info:d,id:o}){try{function u(e){if(e.type.match(/enter/i)&&window.innerWidth<1200)return;let t=e.target.closest(".info-wrapper"),a=t.querySelector(".info-dropdown");if(e.type.match(/leave/i)&&!a.classList.contains("hidden")){a.classList.add("hidden");return}if(!(e.type.match(/leave/i)&&a.classList.contains("hidden"))){if(!t){a.classList.add("hidden");return}if(a.classList.contains("hidden")){a.classList.remove("hidden");return}a.classList.add("hidden")}}return(0,r.jsxs)("div",{className:"form-select-block flex items-start flex-col gap-0.5 w-full relative"+(d?" pr-8":""),children:[i&&(0,r.jsxs)("label",{htmlFor:t,children:[i,n?"":" (optional)"]}),(0,r.jsxs)("div",{className:"flex items-center w-full relative",children:[(0,r.jsx)("select",{name:t,id:o||t,className:"w-full bg-white",required:n,onChange:e=>{l&&l(null),e.target.classList.remove("warning"),a&&a(e)},defaultValue:c||void 0,children:e.map((e,t)=>{let{payload:a,title:s}=e;return(0,r.jsx)("option",{value:a,selected:!!e.default,children:s},t+1)})}),(0,r.jsx)(s.A,{className:"absolute right-2 text-base text-slate-500 pointer-events-none",size:20}),d&&(0,r.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:u,onMouseLeave:u,onClick:u,children:[(0,r.jsx)("img",{src:"/images/info-outlined-black.png",alt:"",className:"w-6 h-6 object-contain opacity-60 pointer-events-none"}),(0,r.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,r.jsx)("span",{children:d})}),(0,r.jsx)("div",{className:"absolute -top-2 w-12",style:{height:"45px"}})]})]})]})}catch(e){return console.log("ERROR in FormSelect =>",e),(0,r.jsx)("div",{children:"Form Select Error"})}}a(82015)},89788:(e,t,a)=>{a.a(e,async(e,r)=>{try{a.d(t,{A:()=>d});var s=a(8732);a(63715);var n=a(82015),l=a.n(n);a(84759);var i=a(75979),c=e([i]);function d({editorRef:e,content:t,readOnly:a,language:r="javascript",options:n,wrapperProps:c}){try{let e=l().useRef(),[t,a]=l().useState(0);return(0,s.jsx)("div",{...c,ref:e,className:(0,i.twMerge)("ace-editor-wrapper w-full h-full minimal-scrollbars all-children",c?.className)})}catch(e){return(0,s.jsx)(l().Fragment,{children:(0,s.jsx)("h2",{className:"text-xl m-0",children:"Editor Error"})})}}i=(c.then?(await c)():c)[0],r()}catch(e){r(e)}})},34844:(e,t,a)=>{a.d(t,{A:()=>i});var r=a(8732),s=a(82015),n=a.n(s),l=a(96089);function i({content:e,language:t,style:a,showCopy:s}){let[i,c]=n().useState(!1),d=()=>{c(!0)},o={};return(0,r.jsxs)("pre",{className:`language-${t||"javascript"} w-auto overflow-hidden skip-js code-block relative max-w-4xl flex items-center justify-center`,style:a?{...a,...o}:o,children:[(0,r.jsx)("code",{className:"w-auto px-10",style:{wordBreak:"break-all"},children:e}),(0,r.jsx)("button",{className:"outlined copy-code "+(s?"relative show":" absolute right-2 z-20 hover:opacity-50"),style:{padding:"2px",border:"none"},onClick:t=>{navigator.clipboard.writeText(e).then(()=>{d()})},children:(0,r.jsx)(l.A,{className:"text-white",size:20})})]})}},24671:(e,t,a)=>{a.d(t,{A:()=>s});var r=a(8732);function s(e){return(0,r.jsxs)("a",{href:"/email-verification",className:"card w-full items-center justify-center py-4 gap-2",children:[(0,r.jsx)("img",{src:"/images/warning.png",alt:"Down Arrow",width:25,className:""}),(0,r.jsx)("span",{children:"Your Account is not verified. Please verify your account."})]})}a(82015)},23293:(e,t,a)=>{a.d(t,{A:()=>r});let r=(0,a(82544).A)("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]])},92441:(e,t,a)=>{a.d(t,{A:()=>r});let r=(0,a(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,a)=>{a.d(t,{A:()=>r});let r=(0,a(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,a)=>{a.d(t,{A:()=>r});let r=(0,a(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,a)=>{a.d(t,{A:()=>r});let r=(0,a(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,a)=>{a.d(t,{A:()=>r});let r=(0,a(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,a)=>{a.d(t,{A:()=>r});let r=(0,a(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,a)=>{a.d(t,{A:()=>r});let r=(0,a(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,a)=>{a.d(t,{A:()=>r});let r=(0,a(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,a)=>{a.d(t,{A:()=>r});let r=(0,a(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,a)=>{a.d(t,{A:()=>r});let r=(0,a(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,a){try{return JSON.stringify(e,t,a)}catch(e){return}}}},74094:(e,t,a)=>{a.a(e,async(e,r)=>{try{a.r(t),a.d(t,{UserSchemaContext:()=>f,default:()=>m,getServerSideProps:()=>x});var s=a(8732),n=a(82015),l=a.n(n),i=a(95222),c=a(20048),d=a.n(c),o=a(74223),u=a(24671),h=a(58548),p=e([o]);o=(p.then?(await p)():p)[0];let y=a(29021),f=l().createContext({});function m({user:e,query:t,dbSchemaData:a}){let r=(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("title",{children:"Add Database | Datasquirel"}),(0,s.jsx)("meta",{name:"description",content:"Add a database"})]});return(0,s.jsx)(i.A,{head:r,user:e,aceEditor:!0,children:(0,s.jsx)(f.Provider,{value:{user:e,dbSchemaData:a},children:e?.verification_status?.toString().match(/1/)?(0,s.jsx)(l().Fragment,{children:(0,s.jsx)(o.A,{})}):(0,s.jsxs)(l().Fragment,{children:[(0,s.jsxs)("div",{className:"flex-col items-start gap-0 w-full",children:[(0,s.jsx)("div",{className:"",children:(0,s.jsx)("h1",{className:"text-3xl m-0",children:"User Schema"})}),(0,s.jsx)(h.A,{user:e})]}),(0,s.jsx)(u.A,{})]})})})}async function x({req:e,res:t,query:a}){let r=await d()(e,t);if(!r?.logged_in_status)return{redirect:{destination:"/login",permanent:!1}};let s=`${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${r.id}/main.json`;if(!y.existsSync(s))return{redirect:{destination:"/admin",permanent:!1}};let n=JSON.parse(y.readFileSync(s,"utf-8"));return{props:{user:r,query:a,dbSchemaData:n||[]}}}r()}catch(e){r(e)}})},9455:(e,t)=>{var a;Object.defineProperty(t,"A",{enumerable:!0,get:function(){return a}}),function(e){e.PAGES="PAGES",e.PAGES_API="PAGES_API",e.APP_PAGE="APP_PAGE",e.APP_ROUTE="APP_ROUTE",e.IMAGE="IMAGE"}(a||(a={}))},40361:e=>{e.exports=require("next/dist/compiled/next-server/pages.runtime.prod.js")},27912:e=>{e.exports=require("next/head")},82015:e=>{e.exports=require("react")},22326:e=>{e.exports=require("react-dom")},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 a=e=>t(t.s=e),r=t.X(0,[883,9821,9600,7070],()=>a(23133));module.exports=r})();