172 lines
7.6 KiB
JavaScript
172 lines
7.6 KiB
JavaScript
|
"use strict";
|
||
|
exports.id = 464;
|
||
|
exports.ids = [464];
|
||
|
exports.modules = {
|
||
|
|
||
|
/***/ 5753:
|
||
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
||
|
|
||
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||
|
/* harmony export */ "Z": () => (/* binding */ generateTypeDefinition)
|
||
|
/* harmony export */ });
|
||
|
/* harmony import */ var _functions_frontend_defaultFieldsRegexp__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3907);
|
||
|
// @ts-check
|
||
|
|
||
|
/**
|
||
|
* Generate a type definition for a query
|
||
|
* ==============================================================================
|
||
|
* @param {object} param0
|
||
|
* @param {"JavaScript" | "TypeScript" | undefined} param0.paradigm
|
||
|
* @param {import("@/package-shared/types").DSQL_TableSchemaType} param0.table
|
||
|
* @param {any} param0.query
|
||
|
* @param {import("@/package-shared/types").UserType} [param0.user]
|
||
|
|
||
|
* @returns {string | null}
|
||
|
*/ function generateTypeDefinition({ paradigm , table , query , user , }) {
|
||
|
/** @type {string | null} */ let typeDefinition = ``;
|
||
|
try {
|
||
|
const tdName = `DSQL_${query.single}_${query.single_table}`.toUpperCase();
|
||
|
const fields = table.fields;
|
||
|
function typeMap(/** @type {string} */ type) {
|
||
|
if (type?.match(/int/i)) {
|
||
|
return "number";
|
||
|
}
|
||
|
if (type?.match(/text|varchar|timestamp/i)) {
|
||
|
return "string";
|
||
|
}
|
||
|
return "string";
|
||
|
}
|
||
|
const typesArrayTypeScript = [];
|
||
|
const typesArrayJavascript = [];
|
||
|
typesArrayTypeScript.push(`type ${tdName} = {`);
|
||
|
typesArrayJavascript.push(`/**\n * @typedef {object} ${tdName}`);
|
||
|
fields.forEach((field)=>{
|
||
|
const nullValue = field.nullValue ? "?" : field.fieldName?.match(_functions_frontend_defaultFieldsRegexp__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z) ? "?" : "";
|
||
|
typesArrayTypeScript.push(` ${field.fieldName}${nullValue}: ${typeMap(field.dataType || "")};`);
|
||
|
typesArrayJavascript.push(` * @property {${typeMap(field.dataType || "")}${nullValue}} ${field.fieldName}`);
|
||
|
});
|
||
|
typesArrayTypeScript.push(`}`);
|
||
|
typesArrayJavascript.push(` */`);
|
||
|
if (paradigm?.match(/javascript/i)) {
|
||
|
typeDefinition = typesArrayJavascript.join("\n");
|
||
|
}
|
||
|
if (paradigm?.match(/typescript/i)) {
|
||
|
typeDefinition = typesArrayTypeScript.join("\n");
|
||
|
}
|
||
|
} catch (/** @type {any} */ error) {
|
||
|
console.log(error.message);
|
||
|
typeDefinition = null;
|
||
|
}
|
||
|
return typeDefinition;
|
||
|
}
|
||
|
|
||
|
|
||
|
/***/ }),
|
||
|
|
||
|
/***/ 6169:
|
||
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
||
|
|
||
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||
|
/* harmony export */ "Z": () => (/* binding */ ExpandBlock)
|
||
|
/* harmony export */ });
|
||
|
/* 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 {Object} props - Server props
|
||
|
* @param {boolean} props.collapse
|
||
|
* @param {React.Dispatch<React.SetStateAction<boolean>>} props.setCollapse
|
||
|
*/ function ExpandBlock({ collapse , setCollapse }) {
|
||
|
/**
|
||
|
* Get Contexts
|
||
|
*
|
||
|
* @abstract { React.useContext }
|
||
|
*/ ////////////////////////////////////////
|
||
|
////////////////////////////////////////
|
||
|
////////////////////////////////////////
|
||
|
/**
|
||
|
* Javascript Variables
|
||
|
*
|
||
|
* @abstract Non hook variables and functions
|
||
|
*/ ////////////////////////////////////////
|
||
|
////////////////////////////////////////
|
||
|
////////////////////////////////////////
|
||
|
/**
|
||
|
* React Hooks
|
||
|
*
|
||
|
* @abstract { useState, useEffect, useRef, etc ... }
|
||
|
*/ ////////////////////////////////////////
|
||
|
////////////////////////////////////////
|
||
|
////////////////////////////////////////
|
||
|
/**
|
||
|
* Function Return
|
||
|
*
|
||
|
* @abstract Main Function Return
|
||
|
*/ return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
|
||
|
className: "collapse-block" + (collapse ? " -mt-16 -mb-6 pt-10" : " mt-0 mb-0 p-0"),
|
||
|
onClick: (e)=>{
|
||
|
if (collapse) {
|
||
|
setCollapse(false);
|
||
|
} else {
|
||
|
setCollapse(true);
|
||
|
}
|
||
|
},
|
||
|
children: [
|
||
|
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("span", {
|
||
|
children: collapse ? "Expand" : "Collapse"
|
||
|
}),
|
||
|
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("img", {
|
||
|
src: "/images/down-arrow-dark.svg",
|
||
|
alt: "Down Arrow",
|
||
|
width: 16,
|
||
|
className: "dark:hidden opacity-30 " + (collapse ? "" : "rotate-180")
|
||
|
}),
|
||
|
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("img", {
|
||
|
src: "/images/down-arrow-white.svg",
|
||
|
alt: "Down Arrow",
|
||
|
width: 16,
|
||
|
className: "opacity-30 hidden dark:flex " + (collapse ? "" : "rotate-180")
|
||
|
})
|
||
|
]
|
||
|
});
|
||
|
////////////////////////////////////////
|
||
|
////////////////////////////////////////
|
||
|
////////////////////////////////////////
|
||
|
} /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
|
||
|
|
||
|
|
||
|
/***/ }),
|
||
|
|
||
|
/***/ 3907:
|
||
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
||
|
|
||
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||
|
/* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
|
||
|
/* harmony export */ });
|
||
|
// @ts-check
|
||
|
/**
|
||
|
* Check for user in local storage
|
||
|
*
|
||
|
* @description Preventdefault, declare variables
|
||
|
*/ const defaultFieldsRegexp = /^id$|^uuid$|^date_created$|^date_created_code$|^date_created_timestamp$|^date_updated$|^date_updated_code$|^date_updated_timestamp$/;
|
||
|
////////////////////////////////////////
|
||
|
////////////////////////////////////////
|
||
|
////////////////////////////////////////
|
||
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (defaultFieldsRegexp);
|
||
|
|
||
|
|
||
|
/***/ })
|
||
|
|
||
|
};
|
||
|
;
|