2024-11-05 11:12:42 +00:00
|
|
|
"use strict";
|
|
|
|
(() => {
|
|
|
|
var exports = {};
|
|
|
|
exports.id = 5957;
|
2024-11-06 12:57:20 +00:00
|
|
|
exports.ids = [5957];
|
2024-11-05 11:12:42 +00:00
|
|
|
exports.modules = {
|
|
|
|
|
|
|
|
/***/ 7947:
|
|
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
|
|
|
|
/* unused harmony export default */
|
|
|
|
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(997);
|
|
|
|
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__);
|
|
|
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6689);
|
|
|
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
|
|
|
|
// @ts-check
|
|
|
|
/**
|
|
|
|
* ==============================================================================
|
|
|
|
* Imports
|
|
|
|
* ==============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
|
|
|
|
* ==============================================================================
|
|
|
|
* Main Component { Functional }
|
|
|
|
* ==============================================================================
|
|
|
|
* @param {{
|
|
|
|
* editorRef: { current: any },
|
|
|
|
* readOnly: boolean,
|
|
|
|
* executeFunction: (editor: AceAjax.Editor) => void,
|
|
|
|
* content: string,
|
|
|
|
* placeholder?: string,
|
|
|
|
* mode?: string,
|
|
|
|
* fontSize?: string,
|
|
|
|
* }} props - React component props including { children }
|
|
|
|
*/ function AceEditor({ editorRef , readOnly , executeFunction , content , placeholder , mode , fontSize , }) {
|
|
|
|
/**
|
|
|
|
* Get Contexts
|
|
|
|
*
|
|
|
|
* @abstract { React.useContext }
|
|
|
|
*/ ////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
try {
|
|
|
|
/**
|
|
|
|
* Javascript Variables
|
|
|
|
*
|
|
|
|
* @abstract Non hook variables and functions
|
|
|
|
*/ ////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
/**
|
|
|
|
* React Hooks
|
|
|
|
*
|
|
|
|
* @abstract { useState, useEffect, useRef, etc ... }
|
|
|
|
*/ /** @type {React.LegacyRef<HTMLDivElement | undefined>} */ const editorElementRef = React.useRef();
|
|
|
|
/** @type {React.MutableRefObject<AceAjax.Editor | undefined>} */ const editorRefInstance = React.useRef();
|
|
|
|
const [loading, setLoading] = React.useState(false);
|
|
|
|
const [refresh, setRefresh] = React.useState(0);
|
|
|
|
React.useEffect(()=>{
|
|
|
|
if (!ace?.edit || !editorElementRef.current) {
|
|
|
|
setTimeout(()=>{
|
|
|
|
setRefresh((prev)=>prev + 1);
|
|
|
|
}, 1000);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const editor = ace.edit(editorElementRef.current);
|
|
|
|
editor.setOptions({
|
|
|
|
mode: `ace/mode/${mode ? mode : "javascript"}`,
|
|
|
|
theme: "ace/theme/nord_dark",
|
|
|
|
// theme: "ace/theme/twilight",
|
|
|
|
value: content,
|
|
|
|
placeholder: placeholder ? placeholder : "",
|
|
|
|
enableBasicAutocompletion: true,
|
|
|
|
enableLiveAutocompletion: true,
|
|
|
|
readOnly: readOnly ? true : false,
|
|
|
|
fontSize: fontSize ? fontSize : null
|
|
|
|
});
|
|
|
|
editor.commands.addCommand({
|
|
|
|
name: "myCommand",
|
|
|
|
bindKey: {
|
|
|
|
win: "Ctrl-Enter",
|
|
|
|
mac: "Command-Enter"
|
|
|
|
},
|
|
|
|
exec: function(editor) {
|
|
|
|
if (executeFunction) executeFunction(editor);
|
|
|
|
},
|
|
|
|
readOnly: true
|
|
|
|
});
|
|
|
|
editorRefInstance.current = editor;
|
|
|
|
if (editorRef) editorRef.current = editor;
|
|
|
|
}, [
|
|
|
|
refresh
|
|
|
|
]);
|
|
|
|
React.useEffect(()=>{
|
|
|
|
if (!editorRefInstance.current) return;
|
|
|
|
editorRefInstance.current.setValue(content, -1);
|
|
|
|
}, [
|
|
|
|
content
|
|
|
|
]);
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
/**
|
|
|
|
* Function Return
|
|
|
|
*
|
|
|
|
* @abstract Main Function Return
|
|
|
|
*/ return /*#__PURE__*/ _jsx(React.Fragment, {
|
|
|
|
children: /*#__PURE__*/ _jsx("div", {
|
|
|
|
className: "p-4 w-full h-full block rounded-md",
|
|
|
|
style: {
|
|
|
|
backgroundColor: "#2e3440"
|
|
|
|
},
|
|
|
|
children: /*#__PURE__*/ _jsx("div", {
|
|
|
|
// @ts-ignore
|
|
|
|
ref: editorElementRef,
|
|
|
|
className: "ace-editor-wrapper w-full h-full minimal-scrollbars all-children"
|
|
|
|
})
|
|
|
|
})
|
|
|
|
});
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
} catch (/** @type {any} */ error) {
|
|
|
|
React.useEffect(()=>{
|
|
|
|
fetchApi("/api/admin/clientError", {
|
|
|
|
method: "post",
|
|
|
|
body: {
|
|
|
|
component: "AceEditor/main-catch-error",
|
|
|
|
message: error.message,
|
|
|
|
user: {}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}, []);
|
|
|
|
return /*#__PURE__*/ _jsx(React.Fragment, {
|
|
|
|
children: /*#__PURE__*/ _jsx("h2", {
|
|
|
|
className: "text-xl m-0",
|
|
|
|
children: "Editor Error"
|
|
|
|
})
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 4458:
|
|
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
|
|
|
|
// ESM COMPAT FLAG
|
|
|
|
__webpack_require__.r(__webpack_exports__);
|
|
|
|
|
|
|
|
// EXPORTS
|
|
|
|
__webpack_require__.d(__webpack_exports__, {
|
|
|
|
"UserSchemaContext": () => (/* binding */ UserSchemaContext),
|
|
|
|
"default": () => (/* binding */ DatabaseSchema),
|
|
|
|
"getServerSideProps": () => (/* binding */ getServerSideProps)
|
|
|
|
});
|
|
|
|
|
|
|
|
// EXTERNAL MODULE: external "react/jsx-runtime"
|
|
|
|
var jsx_runtime_ = __webpack_require__(997);
|
|
|
|
// EXTERNAL MODULE: external "react"
|
|
|
|
var external_react_ = __webpack_require__(6689);
|
|
|
|
var external_react_default = /*#__PURE__*/__webpack_require__.n(external_react_);
|
|
|
|
// EXTERNAL MODULE: ./layouts/AdminLayout.jsx + 2 modules
|
|
|
|
var AdminLayout = __webpack_require__(4858);
|
|
|
|
// EXTERNAL MODULE: ./functions/backend/userAuth.js
|
|
|
|
var userAuth = __webpack_require__(370);
|
|
|
|
var userAuth_default = /*#__PURE__*/__webpack_require__.n(userAuth);
|
|
|
|
// EXTERNAL MODULE: ./components/general/ExtraContentDatabase.jsx
|
|
|
|
var ExtraContentDatabase = __webpack_require__(4941);
|
|
|
|
// EXTERNAL MODULE: ./components/general/BackButton.jsx
|
|
|
|
var BackButton = __webpack_require__(1781);
|
|
|
|
// EXTERNAL MODULE: ./components/general/Breadcrumbs.jsx
|
|
|
|
var Breadcrumbs = __webpack_require__(424);
|
|
|
|
// EXTERNAL MODULE: ./components/form/FormSelect.jsx
|
|
|
|
var FormSelect = __webpack_require__(4114);
|
|
|
|
// EXTERNAL MODULE: ./functions/frontend/fetchApi.js
|
|
|
|
var fetchApi = __webpack_require__(6729);
|
|
|
|
;// CONCATENATED MODULE: ./components/admin/databases/UserSchemaVisualizer.jsx
|
|
|
|
// @ts-check
|
|
|
|
/**
|
|
|
|
* ==============================================================================
|
|
|
|
* Imports
|
|
|
|
* ==============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
|
|
|
|
* ==============================================================================
|
|
|
|
* Main Component { Functional }
|
|
|
|
* ==============================================================================
|
|
|
|
* @param {Object} props - Server props
|
|
|
|
*/ function UserSchemaVisualizer(props) {
|
|
|
|
/**
|
|
|
|
* Get Contexts
|
|
|
|
*
|
|
|
|
* @abstract { React.useContext }
|
|
|
|
*/ const { dbSchemaData , user } = external_react_default().useContext(UserSchemaContext);
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
try {
|
|
|
|
/**
|
|
|
|
* Javascript Variables
|
|
|
|
*
|
|
|
|
* @abstract Non hook variables and functions
|
|
|
|
*/ ////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
/**
|
|
|
|
* React Hooks
|
|
|
|
*
|
|
|
|
* @abstract { useState, useEffect, useRef, etc ... }
|
|
|
|
*/ ////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
/**
|
|
|
|
* Function Return
|
|
|
|
*
|
|
|
|
* @abstract Main Function Return
|
|
|
|
*/ return /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
|
|
|
|
className: "paper p-4 flex-col items-start justify-start gap-14",
|
|
|
|
children: [
|
|
|
|
/*#__PURE__*/ jsx_runtime_.jsx("span", {
|
|
|
|
className: "-mb-2 font-bold text-lg text-slate-400 mt-1",
|
|
|
|
children: "User Schema Map"
|
|
|
|
}),
|
|
|
|
/*#__PURE__*/ jsx_runtime_.jsx("hr", {
|
|
|
|
className: "-my-8"
|
|
|
|
}),
|
|
|
|
dbSchemaData.map((targetDb, rootIndex)=>{
|
|
|
|
return /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
|
|
|
|
className: "flex-col items-start w-full",
|
|
|
|
children: [
|
|
|
|
/*#__PURE__*/ (0,jsx_runtime_.jsxs)("span", {
|
|
|
|
className: "w-full xl:w-auto ml-auto text-lg bg-primary px-3 py-1 rounded text-white font-bold top-0 sticky",
|
|
|
|
children: [
|
|
|
|
targetDb.dbName,
|
|
|
|
" Database Tables"
|
|
|
|
]
|
|
|
|
}),
|
|
|
|
targetDb.tables.map((table, index)=>{
|
|
|
|
return /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
|
|
|
|
className: "flex-col items-start gap-4 left-border pl-6 w-full",
|
|
|
|
children: [
|
|
|
|
/*#__PURE__*/ jsx_runtime_.jsx("span", {
|
|
|
|
className: "font-bold text-base rounded sticky top-10 xl:top-0 px-3 py-1 bg-slate-800 text-white -ml-6 w-full xl:w-auto",
|
|
|
|
children: table.tableFullName
|
|
|
|
}),
|
|
|
|
/*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
|
|
|
|
className: "flex-col items-start w-full",
|
|
|
|
children: [
|
|
|
|
/*#__PURE__*/ jsx_runtime_.jsx("span", {
|
|
|
|
children: "Fields"
|
|
|
|
}),
|
|
|
|
/*#__PURE__*/ jsx_runtime_.jsx("div", {
|
|
|
|
className: "flex-col items-start left-border pl-6 w-full",
|
|
|
|
children: table.fields.map((field, _index)=>{
|
|
|
|
return /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
|
|
|
|
className: "card flex-col items-start gap-1 bg-white p-4 border border-solid border-slate-300 rounded w-full",
|
|
|
|
children: [
|
|
|
|
/*#__PURE__*/ jsx_runtime_.jsx("span", {
|
|
|
|
className: "font-bold",
|
|
|
|
children: field.fieldName
|
|
|
|
}),
|
|
|
|
/*#__PURE__*/ jsx_runtime_.jsx("span", {
|
|
|
|
className: "text-xs",
|
|
|
|
children: field.dataType
|
|
|
|
})
|
|
|
|
]
|
|
|
|
}, _index + 1);
|
|
|
|
})
|
|
|
|
})
|
|
|
|
]
|
|
|
|
}),
|
|
|
|
table.indexes && table.indexes[0] && /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
|
|
|
|
className: "flex-col items-start w-full",
|
|
|
|
children: [
|
|
|
|
/*#__PURE__*/ jsx_runtime_.jsx("span", {
|
|
|
|
children: "Indexes"
|
|
|
|
}),
|
|
|
|
/*#__PURE__*/ jsx_runtime_.jsx("div", {
|
|
|
|
className: "flex-col items-start left-border pl-6 w-full",
|
|
|
|
children: table.indexes.map((index, _index)=>{
|
|
|
|
return /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
|
|
|
|
className: "card flex-col items-start gap-1 bg-white p-4 border border-solid border-slate-300 rounded w-full",
|
|
|
|
children: [
|
|
|
|
/*#__PURE__*/ jsx_runtime_.jsx("span", {
|
|
|
|
className: "font-bold text-secondary",
|
|
|
|
children: index.indexName
|
|
|
|
}),
|
|
|
|
/*#__PURE__*/ jsx_runtime_.jsx("span", {
|
|
|
|
className: "text-xs",
|
|
|
|
children: index.indexType
|
|
|
|
})
|
|
|
|
]
|
|
|
|
}, _index + 1);
|
|
|
|
})
|
|
|
|
})
|
|
|
|
]
|
|
|
|
})
|
|
|
|
]
|
|
|
|
}, index + 1);
|
|
|
|
})
|
|
|
|
]
|
|
|
|
}, rootIndex + 1);
|
|
|
|
})
|
|
|
|
]
|
|
|
|
});
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
} catch (/** @type {any} */ error) {
|
|
|
|
external_react_default().useEffect(()=>{
|
|
|
|
(0,fetchApi/* default */.Z)("/api/admin/clientError", {
|
|
|
|
method: "post",
|
|
|
|
body: {
|
|
|
|
component: "UserSchemaVisualizer/catch-error-return",
|
|
|
|
message: error.message,
|
|
|
|
user: user
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}, []);
|
|
|
|
return /*#__PURE__*/ jsx_runtime_.jsx("div", {
|
|
|
|
children: "Nothing to See here"
|
|
|
|
});
|
|
|
|
}
|
|
|
|
} /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
|
|
|
|
|
|
|
|
// EXTERNAL MODULE: ./components/general/AceEditor.jsx
|
|
|
|
var AceEditor = __webpack_require__(7947);
|
|
|
|
// EXTERNAL MODULE: ./components/general/CodeBlock.jsx
|
|
|
|
var CodeBlock = __webpack_require__(1095);
|
|
|
|
;// CONCATENATED MODULE: ./components/admin/databases/UserSchemaContent.jsx
|
|
|
|
// @ts-check
|
|
|
|
/**
|
|
|
|
* ==============================================================================
|
|
|
|
* Imports
|
|
|
|
* ==============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
|
|
|
|
* ==============================================================================
|
|
|
|
* Main Component { Functional }
|
|
|
|
* ==============================================================================
|
|
|
|
* @param {Object} props - Server props
|
|
|
|
*/ function UserSchemaContent(props) {
|
|
|
|
/**
|
|
|
|
* Get Contexts
|
|
|
|
*
|
|
|
|
* @abstract { React.useContext }
|
|
|
|
*/ const { dbSchemaData , user } = external_react_default().useContext(UserSchemaContext);
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
/**
|
|
|
|
* Javascript Variables
|
|
|
|
*
|
|
|
|
* @abstract Non hook variables and functions
|
|
|
|
*/ ////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
/**
|
|
|
|
* React Hooks
|
|
|
|
*
|
|
|
|
* @abstract { useState, useEffect, useRef, etc ... }
|
|
|
|
*/ /** @type {[ previewObject: any, setPreviewObject: React.Dispatch<React.SetStateAction<any>> ]} */ // @ts-ignore
|
|
|
|
const [previewObject, setPreviewObject] = external_react_default().useState(dbSchemaData);
|
|
|
|
const [targetDb, setTargetDb] = external_react_default().useState(null);
|
|
|
|
/** @type {[ dbTables: import("@/package-shared/types").DSQL_TableSchemaType[], setDbTables: React.Dispatch<React.SetStateAction<import("@/package-shared/types").DSQL_TableSchemaType[] | null>> ]} */ // @ts-ignore
|
|
|
|
const [dbTables, setDbTables] = external_react_default().useState(null);
|
|
|
|
const [targetTable, setTargetTable] = external_react_default().useState(null);
|
|
|
|
external_react_default().useEffect(()=>{
|
|
|
|
if (targetDb) {
|
|
|
|
try {
|
|
|
|
const targetDbSchema = dbSchemaData.filter((db)=>db.dbFullName === targetDb)[0];
|
|
|
|
setPreviewObject(targetDbSchema);
|
|
|
|
setDbTables(targetDbSchema.tables);
|
|
|
|
} catch (/** @type {any} */ error) {
|
|
|
|
(0,fetchApi/* default */.Z)("/api/admin/clientError", {
|
|
|
|
method: "post",
|
|
|
|
body: {
|
|
|
|
component: "UserSchemaContent/lines-64-66",
|
|
|
|
message: error.message,
|
|
|
|
user: user
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
setDbTables(null);
|
|
|
|
setTargetTable(null);
|
|
|
|
setPreviewObject(dbSchemaData);
|
|
|
|
}
|
|
|
|
}, [
|
|
|
|
targetDb
|
|
|
|
]);
|
|
|
|
external_react_default().useEffect(()=>{
|
|
|
|
if (targetTable && dbTables && dbTables[0]) {
|
|
|
|
try {
|
|
|
|
// @ts-ignore
|
|
|
|
const targetTableObject = dbTables.filter((/** @type {any} */ table)=>table.tableName === targetTable)[0];
|
|
|
|
setPreviewObject(targetTableObject);
|
|
|
|
} catch (/** @type {any} */ error) {
|
|
|
|
(0,fetchApi/* default */.Z)("/api/admin/clientError", {
|
|
|
|
method: "post",
|
|
|
|
body: {
|
|
|
|
component: "UserSchemaContent/lines-87-88",
|
|
|
|
message: error.message,
|
|
|
|
user: user
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
} else if (targetDb) {
|
|
|
|
try {
|
|
|
|
const targetDbSchema = dbSchemaData.filter((db)=>db.dbFullName === targetDb)[0];
|
|
|
|
setPreviewObject(targetDbSchema);
|
|
|
|
setDbTables(targetDbSchema.tables);
|
|
|
|
} catch (/** @type {any} */ error1) {
|
|
|
|
(0,fetchApi/* default */.Z)("/api/admin/clientError", {
|
|
|
|
method: "post",
|
|
|
|
body: {
|
|
|
|
component: "UserSchemaContent/lines-100-103",
|
|
|
|
message: error1.message,
|
|
|
|
user: user
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
setDbTables(null);
|
|
|
|
setTargetTable(null);
|
|
|
|
setPreviewObject(dbSchemaData);
|
|
|
|
}
|
|
|
|
}, [
|
|
|
|
targetTable
|
|
|
|
]);
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
/**
|
|
|
|
* Function Return
|
|
|
|
*
|
|
|
|
* @abstract Main Function Return
|
|
|
|
*/ return /*#__PURE__*/ (0,jsx_runtime_.jsxs)((external_react_default()).Fragment, {
|
|
|
|
children: [
|
|
|
|
/*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
|
|
|
|
className: "flex-col items-start gap-0 w-full",
|
|
|
|
children: [
|
|
|
|
/*#__PURE__*/ jsx_runtime_.jsx("div", {
|
|
|
|
className: "",
|
|
|
|
children: /*#__PURE__*/ jsx_runtime_.jsx("h1", {
|
|
|
|
className: "text-3xl m-0",
|
|
|
|
children: "User Schema"
|
|
|
|
})
|
|
|
|
}),
|
|
|
|
/*#__PURE__*/ jsx_runtime_.jsx(Breadcrumbs/* default */.Z, {
|
|
|
|
user: user
|
|
|
|
})
|
|
|
|
]
|
|
|
|
}),
|
|
|
|
/*#__PURE__*/ jsx_runtime_.jsx("section", {
|
|
|
|
className: "paper",
|
|
|
|
children: /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
|
|
|
|
className: "flex-col items-start w-full",
|
|
|
|
children: [
|
|
|
|
/*#__PURE__*/ jsx_runtime_.jsx("h2", {
|
|
|
|
className: "text-xl m-0",
|
|
|
|
children: "Database SCHEMA JSON"
|
|
|
|
}),
|
|
|
|
/*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
|
|
|
|
children: [
|
|
|
|
/*#__PURE__*/ jsx_runtime_.jsx(FormSelect/* default */.Z, {
|
|
|
|
required: true,
|
|
|
|
selectOptions: [
|
|
|
|
{
|
|
|
|
title: "All Databases",
|
|
|
|
payload: "none"
|
|
|
|
},
|
|
|
|
...dbSchemaData.map((db, index)=>{
|
|
|
|
return {
|
|
|
|
title: db.dbName,
|
|
|
|
payload: db.dbFullName,
|
|
|
|
name: db.dbFullName
|
|
|
|
};
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
name: "databases",
|
|
|
|
onChangeHandler: (e)=>{
|
|
|
|
if (e.target.value?.match(/^none$/)) {
|
|
|
|
setTargetDb(null);
|
|
|
|
} else {
|
|
|
|
setTargetDb(e.target.value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
dbTables && dbTables[0] && /*#__PURE__*/ jsx_runtime_.jsx(FormSelect/* default */.Z, {
|
|
|
|
required: true,
|
|
|
|
selectOptions: [
|
|
|
|
{
|
|
|
|
title: "All Tables",
|
|
|
|
payload: "none"
|
|
|
|
},
|
|
|
|
...dbTables.map((table, index)=>{
|
|
|
|
return {
|
|
|
|
title: table.tableFullName,
|
|
|
|
payload: table.tableName,
|
|
|
|
name: table.tableName
|
|
|
|
};
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
name: "database_tables",
|
|
|
|
onChangeHandler: (e)=>{
|
|
|
|
if (e.target.value?.match(/^none$/)) {
|
|
|
|
setTargetTable(null);
|
|
|
|
} else {
|
|
|
|
setTargetTable(e.target.value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
]
|
|
|
|
}),
|
|
|
|
/*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
|
|
|
|
className: "grid grid-cols-1 xl:grid-cols-2 items-stretch w-full",
|
|
|
|
children: [
|
|
|
|
/*#__PURE__*/ jsx_runtime_.jsx("div", {
|
|
|
|
className: "relative w-full block",
|
|
|
|
children: /*#__PURE__*/ jsx_runtime_.jsx(CodeBlock/* default */.Z, {
|
|
|
|
content: JSON.stringify(previewObject, null, 4),
|
|
|
|
language: "javascript"
|
|
|
|
})
|
|
|
|
}),
|
|
|
|
/*#__PURE__*/ jsx_runtime_.jsx(UserSchemaVisualizer, {})
|
|
|
|
]
|
|
|
|
})
|
|
|
|
]
|
|
|
|
})
|
|
|
|
})
|
|
|
|
]
|
|
|
|
});
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
} /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
|
|
|
|
|
|
|
|
// EXTERNAL MODULE: ./components/general/VerificationBanner.jsx
|
|
|
|
var VerificationBanner = __webpack_require__(7946);
|
|
|
|
;// CONCATENATED MODULE: ./pages/admin/[user_id]/schema.jsx
|
|
|
|
// @ts-check
|
|
|
|
/**
|
|
|
|
* ==============================================================================
|
|
|
|
* Imports
|
|
|
|
* ==============================================================================
|
|
|
|
*/
|
|
|
|
const fs = __webpack_require__(7147);
|
|
|
|
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** ****************************************************************************** */ /** @type {import("@/package-shared/types").UserSchemaContextType} */ // @ts-ignore
|
|
|
|
const init = {};
|
|
|
|
const UserSchemaContext = /*#__PURE__*/ external_react_default().createContext(init);
|
|
|
|
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
|
|
|
|
* ==============================================================================
|
|
|
|
* Main Component { Functional }
|
|
|
|
* ==============================================================================
|
|
|
|
* @param {Object} props - Server props
|
|
|
|
* @param {import("@/package-shared/types").UserType} props.user
|
|
|
|
* @param {any} props.query
|
|
|
|
* @param {import("@/package-shared/types").DSQL_DatabaseSchemaType[]} props.dbSchemaData
|
|
|
|
*/ function DatabaseSchema({ user , query , dbSchemaData }) {
|
|
|
|
/**
|
|
|
|
* Get Contexts
|
|
|
|
*
|
|
|
|
* @abstract { React.useContext }
|
|
|
|
*/ ////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
/**
|
|
|
|
* Javascript Variables
|
|
|
|
*
|
|
|
|
* @abstract Non hook variables and functions
|
|
|
|
*/ const pageTitle = "Add Database | Datasquirel";
|
|
|
|
const pageDescription = "Add a database";
|
|
|
|
let head = /*#__PURE__*/ (0,jsx_runtime_.jsxs)(jsx_runtime_.Fragment, {
|
|
|
|
children: [
|
|
|
|
/*#__PURE__*/ jsx_runtime_.jsx("title", {
|
|
|
|
children: pageTitle
|
|
|
|
}),
|
|
|
|
/*#__PURE__*/ jsx_runtime_.jsx("meta", {
|
|
|
|
name: "description",
|
|
|
|
content: pageDescription
|
|
|
|
})
|
|
|
|
]
|
|
|
|
});
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
/**
|
|
|
|
* React Hooks
|
|
|
|
*
|
|
|
|
* @abstract { useState, useEffect, useRef, etc ... }
|
|
|
|
*/ ////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
/**
|
|
|
|
* Function Return
|
|
|
|
*
|
|
|
|
* @abstract Main Function Return
|
|
|
|
*/ return /*#__PURE__*/ jsx_runtime_.jsx(AdminLayout/* default */.Z, {
|
|
|
|
head: head,
|
|
|
|
user: user,
|
|
|
|
aceEditor: true,
|
|
|
|
children: /*#__PURE__*/ jsx_runtime_.jsx(UserSchemaContext.Provider, {
|
|
|
|
value: {
|
|
|
|
user,
|
|
|
|
dbSchemaData
|
|
|
|
},
|
|
|
|
children: user?.verification_status?.toString().match(/1/) ? /*#__PURE__*/ jsx_runtime_.jsx((external_react_default()).Fragment, {
|
|
|
|
children: /*#__PURE__*/ jsx_runtime_.jsx(UserSchemaContent, {})
|
|
|
|
}) : /*#__PURE__*/ (0,jsx_runtime_.jsxs)((external_react_default()).Fragment, {
|
|
|
|
children: [
|
|
|
|
/*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
|
|
|
|
className: "flex-col items-start gap-0 w-full",
|
|
|
|
children: [
|
|
|
|
/*#__PURE__*/ jsx_runtime_.jsx("div", {
|
|
|
|
className: "",
|
|
|
|
children: /*#__PURE__*/ jsx_runtime_.jsx("h1", {
|
|
|
|
className: "text-3xl m-0",
|
|
|
|
children: "User Schema"
|
|
|
|
})
|
|
|
|
}),
|
|
|
|
/*#__PURE__*/ jsx_runtime_.jsx(Breadcrumbs/* default */.Z, {
|
|
|
|
user: user
|
|
|
|
})
|
|
|
|
]
|
|
|
|
}),
|
|
|
|
/*#__PURE__*/ jsx_runtime_.jsx(VerificationBanner/* default */.Z, {})
|
|
|
|
]
|
|
|
|
})
|
|
|
|
})
|
|
|
|
});
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
}
|
|
|
|
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
|
|
|
|
* ==============================================================================
|
|
|
|
* Server Side Props or Static Props
|
|
|
|
* ==============================================================================
|
|
|
|
* @type {import("next").GetServerSideProps}
|
|
|
|
*/ async function getServerSideProps({ req , res , query }) {
|
|
|
|
/**
|
|
|
|
* User Auth
|
|
|
|
*
|
|
|
|
* @description User Auth
|
|
|
|
*/ const user = await userAuth_default()(req, res);
|
|
|
|
if (!user?.logged_in_status) {
|
|
|
|
return {
|
|
|
|
redirect: {
|
|
|
|
destination: "/login",
|
|
|
|
permanent: false
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Page/Site Data Data Fetching
|
|
|
|
*
|
|
|
|
* @description Fetch data on the server before returning
|
2024-11-05 14:18:40 +00:00
|
|
|
*/ const folderPath = `${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${user.id}/main.json`;
|
2024-11-05 11:12:42 +00:00
|
|
|
if (!fs.existsSync(folderPath)) {
|
|
|
|
return {
|
|
|
|
redirect: {
|
|
|
|
destination: "/admin",
|
|
|
|
permanent: false
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
const dbSchemaData = JSON.parse(fs.readFileSync(folderPath, "utf-8"));
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
/**
|
|
|
|
* Server props return
|
|
|
|
*
|
|
|
|
* @description Return data fetched on the server side
|
|
|
|
*/ return {
|
|
|
|
props: {
|
|
|
|
user: user,
|
|
|
|
query,
|
|
|
|
dbSchemaData: dbSchemaData ? dbSchemaData : []
|
|
|
|
}
|
|
|
|
};
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 4003:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("@mui/icons-material/AdminPanelSettingsTwoTone");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 3257:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("@mui/icons-material/ArrowBackIosRounded");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 69:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("@mui/icons-material/CloudOffTwoTone");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 4008:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("@mui/icons-material/CloudQueueRounded");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 3849:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("@mui/icons-material/CodeRounded");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 7306:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("@mui/icons-material/CollectionsTwoTone");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 6843:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("@mui/icons-material/ContentCopy");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 5050:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("@mui/icons-material/CopyAllTwoTone");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 386:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("@mui/icons-material/CottageTwoTone");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 8979:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("@mui/icons-material/DynamicFormTwoTone");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 300:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("@mui/icons-material/LanguageOutlined");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 2814:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("@mui/icons-material/LockTwoTone");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 5557:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("@mui/icons-material/MenuBookTwoTone");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 9806:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("@mui/icons-material/PeopleOutlineTwoTone");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 36:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("@mui/icons-material/RefreshRounded");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 1799:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("@mui/icons-material/SchemaTwoTone");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 6500:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("@mui/icons-material/SendToMobileTwoTone");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 7428:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("@mui/icons-material/SummarizeTwoTone");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 507:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("@mui/icons-material/TipsAndUpdatesTwoTone");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 9174:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("@mui/material/Snackbar");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 2423:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("lucide-react");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 968:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("next/head");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 6689:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("react");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 997:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("react/jsx-runtime");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 2261:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("serverless-mysql");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 4300:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("buffer");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 6113:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("crypto");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 7147:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("fs");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 3685:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("http");
|
|
|
|
|
|
|
|
/***/ })
|
|
|
|
|
|
|
|
};
|
|
|
|
;
|
|
|
|
|
|
|
|
// load runtime
|
|
|
|
var __webpack_require__ = require("../../../webpack-runtime.js");
|
|
|
|
__webpack_require__.C(exports);
|
|
|
|
var __webpack_exec__ = (moduleId) => (__webpack_require__(__webpack_require__.s = moduleId))
|
2024-11-05 14:18:40 +00:00
|
|
|
var __webpack_exports__ = __webpack_require__.X(0, [4017,8313,5264,6729,5449,913,4480,370,424,4858,1781,4941,4114,7946,2434], () => (__webpack_exec__(4458)));
|
2024-11-05 11:12:42 +00:00
|
|
|
module.exports = __webpack_exports__;
|
|
|
|
|
|
|
|
})();
|