dsql-admin/dsql-app/.local_dist/server/chunks/9901.js

17 lines
36 KiB
JavaScript
Raw Normal View History

2025-01-13 08:00:21 +00:00
"use strict";exports.id=9901,exports.ids=[9901],exports.modules={46083:(e,a,t)=>{t.d(a,{A:()=>c});var l=t(8732),s=t(82015),i=t.n(s),n=t(32251),r=t(36138),d=t(27825),o=t.n(d);function c({targetField:e,fieldIndex:a,tableFields:s,setTableFields:d,refreshFieldsListRef:c,setActiveEdit:u,database:m,currentTable:x,user:p}){let h=e?.dataType?e.dataType.replace(/\d|\(|\)/g,""):null,f=e?.dataType?e.dataType.replace(/[^\d]/g,""):"200",g=t(94327),y=i().useRef(o().cloneDeep(e)),v=i().useRef(),[j,N]=i().useState(e),[w,b]=i().useState(e?.fieldName),[T,_]=i().useState(h),[F,S]=i().useState(f),[C,A]=i().useState("Varchar is simply letters and numbers within the range 0 - 255"),[k,D]=i().useState(e?.richText&&!e?.encrypted?"Yes":"No"),V=!!T?.match(/uuid/i);return(0,l.jsx)("div",{className:"w-full -mt-3 bg-white dark:bg-slate-800 flex-wrap",ref:v,children:(0,l.jsxs)("form",{className:"flex flex-col xl:flex-row items-start gap-4 w-full justify-between border border-solid p-4 border-slate-200 dark:border-slate-600 rounded rounded-t-none focus:shadow-lg shadow-slate-700 dark:shadow-black relative flex-wrap",onSubmit:e=>{e.preventDefault(),d(e=>(e[a]=j,e)),c.current(e=>e+1);let t=e.target;t.closest(".table-field-wrapper")?.querySelector(".edit-table-field-section")?.classList.toggle("hidden")},children:[(0,l.jsxs)("div",{className:"gap-4 flex-wrap w-full md:w-auto flex-col xl:flex-row items-stretch",children:[(0,l.jsxs)("div",{className:"flex flex-col items-start gap-0.5",children:[(0,l.jsx)("label",{htmlFor:"new_field_name",children:"Field Name"}),(0,l.jsx)("input",{type:"text",name:"new_field_name",id:"new_field_name",placeholder:"Eg. post_title",onInput:async e=>{let a=e.target;a.value=a.value.toLowerCase().replace(/ /g,"_"),N(e=>(e.fieldName=a.value,e.updatedField=!0,e.originName||(e.originName=w),e))},required:!0,defaultValue:w})]}),(0,l.jsxs)("div",{className:"flex flex-col items-start gap-4 xl:gap-0.5",children:[(0,l.jsxs)("div",{className:"flex-wrap xl:flex-nowrap w-full md:w-auto",children:[(0,l.jsx)("label",{htmlFor:"new_field_data_type",children:"Data Type"}),(0,l.jsxs)("div",{className:"dropdown-wrapper reversed text-sm items-start",children:[(0,l.jsx)("span",{className:"px-2 bg-slate-200 dark:bg-slate-700 rounded-full hover:bg-slate-100 dark:hover:bg-slate-600 hidden xl:flex",children:"Info"}),(0,l.jsx)("div",{className:"dropdown mt-0 xl:-mt-2",children:(0,l.jsx)("span",{children:C})})]})]}),(0,l.jsxs)("div",{className:"w-auto",children:[(0,l.jsx)("select",{name:"new_field_data_type",id:"new_field_data_type",className:"w-full xl-w-auto",onChange:a=>{let t=a.target;_(t.value),t.childNodes.forEach(e=>{e.value===t.value&&e.dataset.desc&&A(e.dataset.desc),e.value===t.value&&e.dataset.literal?(j.defaultValueLiteral=e.dataset.literal,j.nullValue=!1):delete j.defaultValueLiteral}),e.dataType=t.value+(t.value.match(/VARCHAR/)?`(${F||200})`:"")},defaultValue:T||void 0,children:g.map((e,a)=>e.name.match(/VARCHAR/)?(0,l.jsx)("option",{value:e.name,"data-desc":e.description,children:e.title+"("+(F||200)+")"},a+1):(0,l.jsx)("option",{value:e.name,"data-desc":e.description,"data-literal":e.valueLiteral||void 0,children:e.title},a+1))}),T?.match(/VARCHAR/)&&(0,l.jsx)("input",{type:"number",defaultValue:F||200,className:"px-2",style:{maxWidth:"60px"},max:255,min:5,onChange:a=>{S(a.target.value),e.dataType=T+`(${a.target.value})`}})]})]}),T?.match(/text/i)&&(0,l.jsx)(i().Fragment,{children:(0,l.jsx)(r.A,{targetField:e})}),!e.dataType?.match(/text/i)&&!V&&(0,l.jsxs)("div",{className:"flex flex-col items-start gap-0.5",style:{minWidth:"70px"},children:[(0,l.jsx)("label",{htmlFor:"new_field_required",children:"Required?"}),(0,l.jsxs)("select",{name:"new_field_required",id:"new_field_required",className:"px-2",defaultValue:e?.notNullValue?"Yes":"No",onChange:a=>{console.log(e),"Yes"===a.target.value?e.notNullValue=!0:(e.notNullValue=!1,delete e.notNullValue)},children:[(0,l.jsx)("option",{value:"No",children:"No"}),(0,l.jsx)("option",{value:"Yes",children:"Yes"})]})]}),!V&&(0,l.jsxs)("div",{className:"flex flex-col items-start gap-0.5",children:[(0,l
* @typedef {object} ${s}`),r.forEach(e=>{let a=e.nullValue?"?":e.fieldName?.match(l.A)?"?":"";d.push(` ${e.fieldName}${a}: ${n(e.dataType||"")};`),o.push(` * @property {${n(e.dataType||"")}${a}} ${e.fieldName}`)}),d.push("}"),o.push(" */"),e?.match(/javascript/i)&&(i=o.join("\n")),e?.match(/typescript/i)&&(i=d.join("\n"))}catch(e){console.log(e.message),i=null}return i}},2913:(e,a,t)=>{t.d(a,{A:()=>s});var l=t(8732);function s({name:e,checkBoxValues:a,setAlert:t,labelColor:s,flexRow:i,baseText:n,smallText:r,className:d}){return(0,l.jsx)("div",{className:"flex items-start gap-x-4"+(i?" flex-row flex-wrap gap-y-2 ":" flex-col gap-y-4 ")+(d||""),children:a.map((a,i)=>{let{payload:d,title:o,onChangeHandler:c,fixed:u,jsx:m}=a,x=a.name?`${e}-${a.name}`:d?e+"-"+d:e;return(0,l.jsxs)("div",{className:"flex items-center"+(a.default&&u?" pointer-events-none":"")+(r?" gap-1 ":" gap-2 ")+(a?.className?a.className:""),children:[(0,l.jsx)("input",{className:"m-0"+(r?" w-4 h-4":" w-5 h-5"),type:"checkbox",defaultChecked:!!a.default,name:x,id:x,onChange:e=>{t&&t(null),c&&c(e,a)},value:d,style:{minWidth:"20px"},...a.props}),m||(0,l.jsx)("label",{htmlFor:x,className:"m-0 "+(s||"text-slate-800 dark:text-white/80")+(n||r?" text-base":" text-lg"),children:o})]},i+1)})})}t(82015)},51339:(e,a,t)=>{t.d(a,{A:()=>s});var l=t(8732);function s({collapse:e,setCollapse:a}){return(0,l.jsxs)("div",{className:"collapse-block"+(e?" -mt-16 -mb-6 pt-10":" mt-0 mb-0 p-0"),onClick:t=>{e?a(!1):a(!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")})]})}t(82015)},84483:(e,a,t)=>{t.d(a,{A:()=>s});var l=t(8732);function s({children:e,open:a,setOpen:t,onClose:s,maxWidth:i}){return(0,l.jsx)(l.Fragment,{})}t(82015),t(1976),t(58150)},42960:(e,a,t)=>{t.d(a,{A:()=>l});let l=/^id$|^uuid$|^date_created$|^date_created_code$|^date_created_timestamp$|^date_updated$|^date_updated_code$|^date_updated_timestamp$/},72272:(e,a,t)=>{t.d(a,{A:()=>d});var l=t(77047),s=t(29021),i=t.n(s),n=t(33873),r=t.n(n);function d({userId:e}){try{let a=r().resolve(process.cwd(),`${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${e}/main.json`);return JSON.parse(i().readFileSync(a,"utf-8"))}catch(e){return(0,l.A)({component:"grabUserSchemaData",message:e.message}),null}}},77047:(e,a,t)=>{t.d(a,{A:()=>i});var l=t(29021),s=t.n(l);async function i({user:e,message:a,component:t,noMail:l,req:i}){let n=new Date,r=(()=>{if(!i)return null;try{let e=i.headers["x-forwarded-for"],a=i.headers["x-real-ip"],t=i.headers["cf-connecting-ip"],l=Array.isArray(e)?e[0]:e?.split(",")[0],s=t||l||a||i.socket.remoteAddress;if(!s)return null;return String(s)}catch(e){return null}})();try{let l=`🚀 SERVER ERROR ===========================
Error Message: ${a}
Component: ${t}`;e?.id&&e?.first_name&&e?.last_name&&e?.email&&(l+=`
User Id: ${e?.id}
User Name: ${e?.first_name} ${e?.last_name}
User Email: ${e?.email}`),i?.url&&(l+=`
URL: ${i.url}`),i?.body&&(l+=`
Request Body: ${JSON.stringify(i.body,null,4)}`),r&&(l+=`
IP: ${r}`),l+=`
Date: ${n.toDateString()}
========================================`,s().existsSync("./.tmp/error.log")||s().writeFileSync("./.tmp/error.log","","utf-8");let d=s().readFileSync("./.tmp/error.log","utf-8");s().writeFileSync("./.tmp/error.log",l),s().appendFileSync("./.tmp/error.log",`
${d}`)}catch(e){console.log("Server Error Reporting Error:",e.message)}}},94327:e=>{e.exports=JSON.parse('[{"title":"VARCHAR","name":"VARCHAR","value":"0-255","argument":true,"description":"Varchar is simply letters and numbers within the range 0 - 255","maxValue":255},{"title":"TINYINT","name":"TINYINT","value":"0-100","description":"TINYINT means Integers: 0 to 100","maxValue":127},{"title":"SMALLINT","name":"SMALLINT","value":"0-255","description":"SMALLINT means Integers: 0 to 240933","maxValue":32767},{"title":"MEDIUMINT","name":"MEDIUMINT","value":"0-255","description":"MEDIUMINT means Integers: 0 to 1245568545560","maxValue":8388607},{"title":"INT","name":"INT","value":"0-255","description":"INT means Integers: 0 to 12560","maxValue":2147483647},{"title":"BIGINT","name":"BIGINT","value":"0-255","description":"BIGINT means Integers: 0 to 1245569056767568545560","maxValue":2e+63},{"title":"TINYTEXT","name":"TINYTEXT","value":"0-255","description":"Text with 255 max characters","maxValue":127},{"title":"TEXT","name":"TEXT","value":"0-100","description":"MEDIUMTEXT is just text with max length 16,777,215","maxValue":127},{"title":"MEDIUMTEXT","name":"MEDIUMTEXT","value":"0-255","description":"MEDIUMTEXT is just text with max length 16,777,215","maxValue":127},{"title":"LONGTEXT","name":"LONGTEXT","value":"0-255","description":"LONGTEXT is just text with max length 4,294,967,295","maxValue":127},{"title":"UUID","name":"UUID","valueLiteral":"UUID()","description":"A Unique ID"}]')}};