First Commit

This commit is contained in:
Benjamin Toby
2024-11-05 12:12:42 +01:00
commit 09ae0dd3fe
1078 changed files with 138432 additions and 0 deletions
@@ -0,0 +1,39 @@
"use strict";
exports.id = 1007;
exports.ids = [1007];
exports.modules = {
/***/ 1007:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const fs = __webpack_require__(7147);
const decrypt = __webpack_require__(5425);
/** @type {import("@/package-shared/types").CheckApiCredentialsFn} */ const grabApiCred = ({ key , database , table })=>{
try {
const allowedKeysPath = process.env.DSQL_API_KEYS_PATH;
if (!allowedKeysPath) throw new Error("process.env.DSQL_API_KEYS_PATH variable not found");
const ApiJSON = decrypt(key);
/** @type {import("@/package-shared/types").ApiKeyObject} */ const ApiObject = JSON.parse(ApiJSON || "");
const isApiKeyValid = fs.existsSync(`${allowedKeysPath}/${ApiObject.sign}`);
if (!isApiKeyValid) return null;
if (!ApiObject.target_database) return ApiObject;
if (!database && ApiObject.target_database) return null;
const isDatabaseAllowed = ApiObject.target_database?.split(",").includes(String(database));
if (isDatabaseAllowed && !ApiObject.target_table) return ApiObject;
if (isDatabaseAllowed && !table && ApiObject.target_table) return null;
const isTableAllowed = ApiObject.target_table?.split(",").includes(String(table));
if (isTableAllowed) return ApiObject;
return null;
} catch (error) {
return null;
}
};
module.exports = grabApiCred;
/***/ })
};
;
+182
View File
@@ -0,0 +1,182 @@
"use strict";
exports.id = 1206;
exports.ids = [1206];
exports.modules = {
/***/ 7410:
/***/ ((module) => {
// @ts-check
/**
* Regular expression to match default fields
*
* @description Regular expression to match default fields
*/
const defaultFieldsRegexp = /^id$|^uuid$|^date_created$|^date_created_code$|^date_created_timestamp$|^date_updated$|^date_updated_code$|^date_updated_timestamp$/;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
module.exports = defaultFieldsRegexp;
/***/ }),
/***/ 7432:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const decrypt = __webpack_require__(5304);
const defaultFieldsRegexp = __webpack_require__(7410);
/**
* Parse Database results
* ==============================================================================
* @description this function takes a database results array gotten from a DB handler
* function, decrypts encrypted fields, and returns an updated array with no encrypted
* fields
*
* @param {object} params - Single object params
* @param {any[]} params.unparsedResults - Array of data objects containing Fields(keys)
* and corresponding values of the fields(values)
* @param {import("../../types").DSQL_TableSchemaType} [params.tableSchema] - Table schema
* @returns {Promise<object[]|null>}
*/ module.exports = async function parseDbResults({ unparsedResults , tableSchema , }) {
/**
* Declare variables
*
* @description Declare "results" variable
*/ let parsedResults = [];
try {
/**
* Declare variables
*
* @description Declare "results" variable
*/ for(let pr = 0; pr < unparsedResults.length; pr++){
let result = unparsedResults[pr];
let resultFieldNames = Object.keys(result);
for(let i = 0; i < resultFieldNames.length; i++){
const resultFieldName = resultFieldNames[i];
let resultFieldSchema = tableSchema?.fields[i];
if (resultFieldName?.match(defaultFieldsRegexp)) {
continue;
}
let value = result[resultFieldName];
if (typeof value !== "number" && !value) {
continue;
}
if (resultFieldSchema?.encrypted) {
if (value?.match(/./)) {
result[resultFieldName] = decrypt(value);
}
}
}
parsedResults.push(result);
}
/**
* Declare variables
*
* @description Declare "results" variable
*/ return parsedResults;
} catch (/** @type {any} */ error) {
console.log("ERROR in parseDbResults Function =>", error.message);
return unparsedResults;
}
};
/***/ }),
/***/ 1206:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const fs = __webpack_require__(7147);
const parseDbResults = __webpack_require__(7432);
const serverError = __webpack_require__(7023);
const DB_HANDLER = __webpack_require__(9395);
const DSQL_USER_DB_HANDLER = __webpack_require__(8682);
/**
* DB handler for specific database
* ==============================================================================
* @async
* @param {object} params - Single object params
* @param {string} params.queryString - SQL string
* @param {*[]} [params.queryValuesArray] - Values Array
* @param {string} [params.database] - Database name
* @param {import("../../types").DSQL_TableSchemaType} [params.tableSchema] - Table schema
* @returns {Promise<any>}
*/ module.exports = async function varDatabaseDbHandler({ queryString , queryValuesArray , database , tableSchema , }) {
/**
* Declare variables
*
* @description Declare "results" variable
*/ const isMaster = database?.match(/^datasquirel$/) ? true : false;
/** @type {any} */ const FINAL_DB_HANDLER = isMaster ? DB_HANDLER : DSQL_USER_DB_HANDLER;
let results;
/**
* Fetch from db
*
* @description Fetch data from db if no cache
*/ try {
if (queryString && queryValuesArray && Array.isArray(queryValuesArray) && queryValuesArray[0]) {
results = isMaster ? await FINAL_DB_HANDLER(queryString, queryValuesArray) : await FINAL_DB_HANDLER({
paradigm: "Full Access",
database,
queryString,
queryValues: queryValuesArray
});
} else {
results = isMaster ? await FINAL_DB_HANDLER(queryString) : await FINAL_DB_HANDLER({
paradigm: "Full Access",
database,
queryString
});
}
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
} catch (/** @type {any} */ error) {
serverError({
component: "varDatabaseDbHandler/lines-29-32",
message: error.message
});
}
/**
* Return results
*
* @description Return results add to cache if "req" param is passed
*/ if (results && tableSchema) {
try {
const unparsedResults = results;
const parsedResults = await parseDbResults({
unparsedResults: unparsedResults,
tableSchema: tableSchema
});
return parsedResults;
} catch (/** @type {any} */ error1) {
console.log("\x1b[31mvarDatabaseDbHandler ERROR\x1b[0m =>", database, error1);
serverError({
component: "varDatabaseDbHandler/lines-52-53",
message: error1.message
});
return null;
}
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
} else if (results) {
return results;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
} else {
return null;
}
};
/***/ })
};
;
@@ -0,0 +1,99 @@
"use strict";
exports.id = 1311;
exports.ids = [1311];
exports.modules = {
/***/ 1311:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const fs = __webpack_require__(7147);
const parseDbResults = __webpack_require__(8326);
const serverError = __webpack_require__(3017);
const DB_HANDLER = __webpack_require__(2224);
const DSQL_USER_DB_HANDLER = __webpack_require__(3403);
/**
* DB handler for specific database
* ==============================================================================
* @async
* @param {object} params - Single object params
* @param {string} params.queryString - SQL string
* @param {*[]} [params.queryValuesArray] - Values Array
* @param {string} [params.database] - Database name
* @param {import("../../types").DSQL_TableSchemaType} [params.tableSchema] - Table schema
* @returns {Promise<any>}
*/ module.exports = async function varDatabaseDbHandler({ queryString , queryValuesArray , database , tableSchema , }) {
/**
* Declare variables
*
* @description Declare "results" variable
*/ const isMaster = database?.match(/^datasquirel$/) ? true : false;
/** @type {any} */ const FINAL_DB_HANDLER = isMaster ? DB_HANDLER : DSQL_USER_DB_HANDLER;
let results;
/**
* Fetch from db
*
* @description Fetch data from db if no cache
*/ try {
if (queryString && queryValuesArray && Array.isArray(queryValuesArray) && queryValuesArray[0]) {
results = isMaster ? await FINAL_DB_HANDLER(queryString, queryValuesArray) : await FINAL_DB_HANDLER({
paradigm: "Full Access",
database,
queryString,
queryValues: queryValuesArray
});
} else {
results = isMaster ? await FINAL_DB_HANDLER(queryString) : await FINAL_DB_HANDLER({
paradigm: "Full Access",
database,
queryString
});
}
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
} catch (/** @type {any} */ error) {
serverError({
component: "varDatabaseDbHandler/lines-29-32",
message: error.message
});
}
/**
* Return results
*
* @description Return results add to cache if "req" param is passed
*/ if (results && tableSchema) {
try {
const unparsedResults = results;
const parsedResults = await parseDbResults({
unparsedResults: unparsedResults,
tableSchema: tableSchema
});
return parsedResults;
} catch (/** @type {any} */ error1) {
console.log("\x1b[31mvarDatabaseDbHandler ERROR\x1b[0m =>", database, error1);
serverError({
component: "varDatabaseDbHandler/lines-52-53",
message: error1.message
});
return null;
}
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
} else if (results) {
return results;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
} else {
return null;
}
};
/***/ })
};
;
+158
View File
@@ -0,0 +1,158 @@
"use strict";
exports.id = 1336;
exports.ids = [1336];
exports.modules = {
/***/ 1336:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Z": () => (/* binding */ UserCard)
/* 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 {import("@/package-shared/types").UserType} props.userObject
* @param {boolean} [props.userPage]
*/ function UserCard({ userObject , userPage }) {
/**
* Get Contexts
*
* @abstract { React.useContext }
*/ ////////////////////////////////////////////////
////////////////////////////////////////////////
////////////////////////////////////////////////
/**
* Javascript Variables
*
* @abstract Non hook variables and functions
*/ const userTitles = Object.keys(userObject);
////////////////////////////////////////////////
////////////////////////////////////////////////
////////////////////////////////////////////////
/**
* React Hooks
*
* @abstract { useState, useEffect, useRef, etc ... }
*/ const [loading, setLoading] = react__WEBPACK_IMPORTED_MODULE_1___default().useState(false);
const [refresh, setRefresh] = react__WEBPACK_IMPORTED_MODULE_1___default().useState(0);
const [collapsed, setCollapsed] = react__WEBPACK_IMPORTED_MODULE_1___default().useState(userPage ? false : true);
////////////////////////////////////////////////
////////////////////////////////////////////////
////////////////////////////////////////////////
/**
* Function Return
*
* @description Main Function Return
*/ return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
className: "card col green w-full overflow-hidden" + (collapsed ? userPage ? " h-[100px]" : " h-[85px]" : " "),
children: [
/*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
className: "items-center w-full",
children: [
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("img", {
src: userObject["image_thumbnail"],
alt: "",
className: "rounded-full object-cover" + (userPage ? " w-16 h-16" : " w-12 h-12")
}),
!userPage && /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("h3", {
className: "m-0 text-xl",
children: [
userObject["first_name"],
" ",
userObject["last_name"],
" "
]
}),
/*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
className: "ml-auto",
children: [
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("button", {
className: "outlined gray small-text",
onClick: (e)=>{
if (collapsed) {
setCollapsed(false);
} else {
setCollapsed(true);
}
},
children: collapsed ? "More Details" : "Collapse"
}),
!userPage && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("a", {
href: `/su/users/${userObject.id}`,
className: "button outlined gray small-text",
children: "View User"
})
]
})
]
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
className: "card no-hover col w-full light-gray-bg",
children: userTitles.map((userTitle, utIndex)=>{
return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)((react__WEBPACK_IMPORTED_MODULE_1___default().Fragment), {
children: [
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
children: /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("span", {
style: {
wordBreak: "break-all"
},
children: [
userTitle,
":",
" ",
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("b", {
children: // @ts-ignore
userObject[userTitle]
})
]
})
}),
utIndex < userTitles.length - 1 && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("hr", {})
]
}, utIndex + 1);
})
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("button", {
className: "outlined gray small-text w-full",
onClick: (e)=>{
setCollapsed(true);
},
children: "Collapse"
})
]
});
////////////////////////////////////////////////
////////////////////////////////////////////////
////////////////////////////////////////////////
} //////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
/***/ })
};
;
@@ -0,0 +1,99 @@
"use strict";
exports.id = 1352;
exports.ids = [1352];
exports.modules = {
/***/ 1352:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
/**
* ==============================================================================
* Imports
* ==============================================================================
*/
const http = __webpack_require__(3685);
const decrypt = __webpack_require__(5425);
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
* @typedef {object} grabDelegatedUserFromCookieReturn
* @property {number} dbUserId
* @property {number} [dbUserId]
* @property {number} [rootUserId]
* @property {string} [rootUserName]
* @property {string} [rootUserEmail]
* @property {string} [rootUserImage]
* @property {string} [databaseFullName]
* @property {string} [databaseSlug]
* @property {string[]} [allowedTables]
* @property {string} [priviledges]
* @property {string} [database]
* @property {boolean} [delegated]
*/ /**
* @param {object} params - user id
* @param {import("next").NextApiRequest | http.IncomingMessage & { cookies: Partial<{ [key: string]: string; }>}} params.request - HTTPS request object
* @param {string | string[]} params.databaseSlug - Database name slug
* @param {{ id: number, first_name: string, last_name: string }} params.user
* @param {any} params.query - query params
*
* @returns {Promise<grabDelegatedUserFromCookieReturn | null>} new user auth object payload
*/ module.exports = async function grabDelegatedUserFromCookie({ request , databaseSlug , user , query , }) {
try {
/**
* Fetch user
*
* @description Fetch user from db
*/ let dbUserId = user.id;
let delegatedUserObject = null;
if (!query?.delegated) return {
dbUserId
};
const rootUserId = query.dbUserId;
const dbFullName = `${process.env.DSQL_USER_DB_PREFIX}${rootUserId}_${databaseSlug}`;
const tokenName = `${process.env.DSQL_USER_DELEGATED_DB_COOKIE_PREFIX}${dbFullName}`;
try {
if (!request.cookies?.[tokenName]) throw new Error("Cookie not present");
// @ts-ignore
const decryptedToken = decrypt(request.cookies[tokenName]);
if (!decryptedToken) throw new Error("Invalid Token");
delegatedUserObject = JSON.parse(decryptedToken);
if (delegatedUserObject.databaseSlug === databaseSlug) {
dbUserId = delegatedUserObject.rootUserId;
return {
dbUserId: dbUserId,
rootUserId: delegatedUserObject.rootUserId,
rootUserName: delegatedUserObject.rootUserName,
rootUserEmail: delegatedUserObject.rootUserEmail,
rootUserImage: delegatedUserObject.rootUserImage,
databaseFullName: delegatedUserObject.databaseFullName,
databaseSlug: delegatedUserObject.databaseSlug,
allowedTables: delegatedUserObject.allowedTables,
priviledges: delegatedUserObject.priviledges,
database: delegatedUserObject.databaseSlug,
delegated: true
};
}
} catch (error) {
// serverError({
// component: "grabDelegatedUserFromCookie",
// message: error.message,
// user: user,
// });
}
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
return {
dbUserId
};
} catch (error1) {
return null;
}
}; ////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/***/ })
};
;
+124
View File
@@ -0,0 +1,124 @@
"use strict";
exports.id = 1500;
exports.ids = [1500];
exports.modules = {
/***/ 5012:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Z": () => (/* binding */ DeleteDatabaseConfirmationPopup)
/* 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__);
/* harmony import */ var _functions_frontend_fetchApi__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(6729);
/* harmony import */ var _general_GeneralPopup__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(5472);
/* harmony import */ var _general_LoadingBlock__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(5264);
// @ts-check
/**
* ==============================================================================
* Imports
* ==============================================================================
*/
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
* ==============================================================================
* Main Component { Functional }
* ==============================================================================
* @param {Object} props - Server props
* @param {DSQL_MYSQL_user_databases_Type | undefined} props.targetDatabase
*/ function DeleteDatabaseConfirmationPopup({ targetDatabase }) {
/**
* Get Contexts
*
* @abstract { React.useContext }
*/ ////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Javascript Variables
*
* @abstract Non hook variables and functions
*/ ////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* React Hooks
*
* @abstract { useState, useEffect, useRef, etc ... }
*/ const [loading, setLoading] = react__WEBPACK_IMPORTED_MODULE_1___default().useState(false);
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Function Return
*
* @abstract Main Function Return
*/ return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_general_GeneralPopup__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .ZP, {
title: "delete-database-confirmation",
children: [
loading && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_general_LoadingBlock__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z, {
width: "20px"
}),
/*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("h4", {
className: "m-0",
children: [
"Delete '",
targetDatabase?.db_name ? targetDatabase.db_name : "This Database",
"' database?"
]
}),
/*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
children: [
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("button", {
className: "outlined" + (loading ? " pointer-events-none opacity-40" : ""),
onClick: (e)=>{
if (!targetDatabase) {
alert("No Target Database Selected!");
return;
}
setLoading(true);
if (window.confirm(`Note that you will loose all data in this database. Continue?`)) {
(0,_functions_frontend_fetchApi__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Z)("/api/deleteUserDatabase", {
method: "post",
body: targetDatabase
}, true).then((res)=>{
if (res.success) {
window.location.reload();
}
});
} else {
setLoading(false);
}
},
children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("span", {
children: "Yes"
})
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("button", {
onClick: (e)=>{
(0,_general_GeneralPopup__WEBPACK_IMPORTED_MODULE_2__/* .closePopup */ .j4)();
},
children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("span", {
children: "Cancel"
})
})
]
})
]
});
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
} /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
/***/ })
};
;
@@ -0,0 +1,37 @@
"use strict";
exports.id = 1503;
exports.ids = [1503];
exports.modules = {
/***/ 1503:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const { IncomingMessage } = __webpack_require__(3685);
const decrypt = __webpack_require__(5304);
/**
* @async
* @param {import("next").NextApiRequest | IncomingMessage & { cookies: Partial<{ [key: string]: string; }>} } req - https request object
*
* @returns {Promise<({ email: string, password: string, authKey: string, logged_in_status: boolean, date: number } | null)>}
*/ module.exports = async function(req) {
/** ********************* Check for existence of required cookie */ if (!req.cookies?.datasquirelSuAdminUserAuthKey) {
return null;
}
/** ********************* Grab the payload */ let userPayload = decrypt(req.cookies.datasquirelSuAdminUserAuthKey);
/** ********************* Return if no payload */ if (!userPayload) return null;
/** ********************* Parse the payload */ let userObject = JSON.parse(userPayload);
if (userObject.password !== process.env.DSQL_USER_KEY) return null;
if (userObject.authKey !== process.env.DSQL_SPECIAL_KEY) return null;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/** ********************* return user object */ return userObject;
};
/***/ })
};
;
+122
View File
@@ -0,0 +1,122 @@
"use strict";
exports.id = 1674;
exports.ids = [1674];
exports.modules = {
/***/ 1674:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Z": () => (/* binding */ DeleteTableConfirmationPopup)
/* 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__);
/* harmony import */ var _functions_frontend_fetchApi__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(6729);
/* harmony import */ var _general_Breadcrumbs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(424);
/* harmony import */ var _general_GeneralPopup__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(5472);
/* harmony import */ var _components_general_LoadingBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(5264);
// @ts-check
/**
* ==============================================================================
* Imports
* ==============================================================================
*/
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
* ==============================================================================
* Main Component { Functional }
* ==============================================================================
* @param {Object} props - Server props
* @param {import("@/package-shared/types").DSQL_MYSQL_user_databases_Type} props.database
* @param {import("@/package-shared/types").MYSQL_user_database_tables_table_def | null} [props.targetTable]
*/ function DeleteTableConfirmationPopup({ targetTable , database , }) {
/**
* Get Contexts
*
* @abstract { React.useContext }
*/ ////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Javascript Variables
*
* @abstract Non hook variables and functions
*/ ////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* React Hooks
*
* @abstract { useState, useEffect, useRef, etc ... }
*/ const [loading, setLoading] = react__WEBPACK_IMPORTED_MODULE_1___default().useState(false);
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Function Return
*
* @abstract Main Function Return
*/ return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_general_GeneralPopup__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .ZP, {
title: "delete-table-confirmation",
children: [
loading && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_components_general_LoadingBlock__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Z, {
width: "20px"
}),
/*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("h4", {
className: "m-0",
children: [
"Delete '",
targetTable?.table_name ? targetTable.table_name : "This Database",
"' Table?"
]
}),
/*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
children: [
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("button", {
className: "outlined" + (loading ? " pointer-events-none opacity-40" : ""),
onClick: (e)=>{
setLoading(true);
(0,_functions_frontend_fetchApi__WEBPACK_IMPORTED_MODULE_5__/* ["default"] */ .Z)("/api/deleteUserTable", {
method: "post",
body: {
database: database,
table: targetTable
}
}, true).then((res)=>{
if (res.success) {
window.location.reload();
}
});
},
children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("span", {
children: "Yes"
})
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("button", {
onClick: (e)=>{
(0,_general_GeneralPopup__WEBPACK_IMPORTED_MODULE_3__/* .closePopup */ .j4)();
},
children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("span", {
children: "Cancel"
})
})
]
})
]
});
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
} /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
/***/ })
};
;
@@ -0,0 +1,46 @@
"use strict";
exports.id = 1781;
exports.ids = [1781];
exports.modules = {
/***/ 1781:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Z": () => (/* binding */ BackButton)
/* 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__);
/* harmony import */ var _mui_icons_material_ArrowBackIosRounded__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(3257);
/* harmony import */ var _mui_icons_material_ArrowBackIosRounded__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_mui_icons_material_ArrowBackIosRounded__WEBPACK_IMPORTED_MODULE_2__);
// @ts-check
/**
* Imports
* ==============================================================================
*/
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
* Main Component { Functional }
* ==============================================================================
*/ function BackButton() {
return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("button", {
className: "outlined gray p-2 w-9 h-9 flex items-center justify-center rounded-full",
onClick: (e)=>{
window.history.back();
},
children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx((_mui_icons_material_ArrowBackIosRounded__WEBPACK_IMPORTED_MODULE_2___default()), {
color: "inherit",
className: "opacity-50 text-black",
fontSize: "small"
})
});
}
/***/ })
};
;
+309
View File
@@ -0,0 +1,309 @@
"use strict";
exports.id = 1926;
exports.ids = [1926];
exports.modules = {
/***/ 1926:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Z": () => (/* binding */ DbCreateDbUserForm)
/* 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__);
/* harmony import */ var _functions_frontend_fetchApi__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(6729);
/* harmony import */ var _general_FormAlertBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7037);
/* harmony import */ var _general_LoadingBlock__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(5264);
/* harmony import */ var _form_FormInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(7901);
/* harmony import */ var _UserImage__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(2733);
// @ts-check
/**
* ==============================================================================
* Imports
* ==============================================================================
*/
////////////////////////////////////////
////////////////////////////////////////
/** @type {any} */ let timeout;
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
* ==============================================================================
* Main Component { Functional }
* ==============================================================================
* @param {Object} props - Server props
* @param {string} props.targetDb
* @param {import("@/package-shared/types").DSQL_MYSQL_user_databases_Type} [props.database]
* @param {import("@/package-shared/types").UserType} [props.user]
* @param {any} props.userImage
* @param {React.Dispatch<React.SetStateAction<any>>} props.setUserImage
*/ function DbCreateDbUserForm({ targetDb , database , user , userImage , setUserImage , }) {
/**
* Get Contexts
*
* @abstract { React.useContext }
*/ ////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Javascript Variables
*
* @abstract Non hook variables and functions
*/ ////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* React Hooks
*
* @abstract { useState, useEffect, useRef, etc ... }
*/ /** @type {[ alert: string | null, setAlert: React.Dispatch<React.SetStateAction<string | null>> ]} */ // @ts-ignore
const [alert, setAlert] = react__WEBPACK_IMPORTED_MODULE_1___default().useState(null);
const [loading, setLoading] = react__WEBPACK_IMPORTED_MODULE_1___default().useState(false);
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Function Return
*
* @abstract Main Function Return
*/ return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)((react__WEBPACK_IMPORTED_MODULE_1___default().Fragment), {
children: [
loading && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_general_LoadingBlock__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z, {}),
alert && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_general_FormAlertBlock__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .Z, {
message: alert
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("h3", {
className: "m-0 text-lg font-semibold mb-1 text-slate-600 mt-4",
children: "User information"
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
className: "flex flex-col items-start gap-0.5 w-full",
children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_form_FormInput__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Z, {
title: "First Name",
inputType: "text",
name: "first_name",
autoComplete: "given-name",
onInputHandler: (e)=>{
/** @type {HTMLInputElement} */ // @ts-ignore
const inputEl = e.target;
if (inputEl.value.match(/./)) {
inputEl.classList.remove("warning");
setAlert(null);
} else {
inputEl.classList.add("warning");
}
},
required: true
})
}),
/*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
className: "flex flex-col items-start gap-0.5 w-full",
children: [
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("label", {
htmlFor: "last_name",
children: "Last Name"
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("input", {
type: "text",
name: "last_name",
id: "last_name",
placeholder: "Last Name",
autoComplete: "family-name",
onInput: (e)=>{
/** @type {HTMLInputElement} */ // @ts-ignore
const inputEl = e.target;
if (inputEl.value.match(/./)) {
inputEl.classList.remove("warning");
setAlert(null);
} else {
inputEl.classList.add("warning");
}
},
required: true
})
]
}),
/*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
className: "flex flex-col items-start gap-0.5 w-full",
children: [
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("label", {
htmlFor: "username",
children: "Username"
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("input", {
type: "text",
name: "username",
id: "username",
placeholder: "Username",
autoComplete: "username",
onInput: (e)=>{
/** @type {HTMLInputElement} */ // @ts-ignore
const inputEl = e.target;
if (inputEl.value.match(/./)) {
inputEl.classList.remove("warning");
setAlert(null);
} else {
inputEl.classList.add("warning");
}
window.clearTimeout(timeout);
timeout = setTimeout(()=>{
(0,_functions_frontend_fetchApi__WEBPACK_IMPORTED_MODULE_6__/* ["default"] */ .Z)(`/api/checkDuplicateData?type=username&value=${inputEl.value}&tableName=users&dbFullName=${targetDb}`).then((res)=>{
// console.log(res);
if (res?.result) {
setAlert("Username Already Exists");
inputEl.classList.add("warning");
} else {
setAlert(null);
inputEl.classList.remove("warning");
}
});
}, 300);
}
})
]
}),
/*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
className: "flex flex-col items-start gap-0.5 w-full",
children: [
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("label", {
htmlFor: "email_address",
children: "Email Address"
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("input", {
type: "email",
name: "email_address",
id: "email_address",
placeholder: "Email Address",
autoComplete: "email",
onInput: (e)=>{
window.clearTimeout(timeout);
/** @type {HTMLInputElement} */ // @ts-ignore
const inputEl = e.target;
timeout = setTimeout(()=>{
(0,_functions_frontend_fetchApi__WEBPACK_IMPORTED_MODULE_6__/* ["default"] */ .Z)(`/api/checkDuplicateData?type=email&value=${inputEl.value}&tableName=users&dbFullName=${targetDb}`).then((res)=>{
// console.log(res);
if (res?.result) {
setAlert("Email Already Exists");
inputEl.classList.add("warning");
} else {
setAlert(null);
inputEl.classList.remove("warning");
}
});
}, 300);
},
required: true
})
]
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_form_FormInput__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Z, {
title: "Phone Number",
inputType: "text",
name: "phone",
autoComplete: "tel"
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_form_FormInput__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Z, {
title: "Address",
name: "address",
autoComplete: "address"
}),
/*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
className: "flex-wrap xl:flex-nowrap",
children: [
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_form_FormInput__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Z, {
title: "City",
name: "city",
autoComplete: "city"
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_form_FormInput__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Z, {
title: "State",
name: "state",
autoComplete: "state"
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_form_FormInput__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Z, {
title: "Country",
name: "country",
autoComplete: "country"
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_form_FormInput__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Z, {
title: "Zip Code",
name: "zip_code",
autoComplete: "zip_code"
})
]
}),
/*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
className: "flex flex-col items-start gap-0.5 w-full",
children: [
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("label", {
htmlFor: "password",
children: "Password"
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("input", {
type: "password",
name: "password",
id: "password",
placeholder: "Password",
required: true
})
]
}),
/*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
className: "flex flex-col items-start gap-0.5 w-full",
children: [
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("label", {
htmlFor: "confirm_password",
children: "Confirm Password"
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("input", {
type: "password",
name: "confirm_password",
id: "confirm_password",
placeholder: "Confirm Password",
onInput: (e)=>{
/** @type {HTMLInputElement} */ // @ts-ignore
const inputEl = e.target;
let passwordInput = inputEl.closest("form")?.["password"].value;
let passwordRepeatInput = inputEl.value;
if (passwordInput === passwordRepeatInput) {
inputEl.classList.remove("warning");
} else {
inputEl.classList.add("warning");
}
},
required: true
})
]
}),
/*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
className: "paper",
children: [
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("h3", {
className: "m-0 text-lg font-semibold mb-1 text-slate-600",
children: "User Image"
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_UserImage__WEBPACK_IMPORTED_MODULE_5__/* ["default"] */ .Z, {
userImage: userImage,
setUserImage: setUserImage,
className: "w-full"
})
]
})
]
});
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
} /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
/***/ })
};
;
@@ -0,0 +1,53 @@
"use strict";
exports.id = 2163;
exports.ids = [2163];
exports.modules = {
/***/ 2163:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
/**
* ==============================================================================
* Imports
* ==============================================================================
*/
const fs = __webpack_require__(7147);
// const handleNodemailer = require("./handleNodemailer");
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
* ==============================================================================
* Main Function
* ==============================================================================
* @param {{
* user?: { id?: number | string, first_name?: string, last_name?: string, email?: string } & *,
* message: string,
* component?: string,
* noMail?: boolean,
* }} params - user id
*
* @returns {Promise<void>}
*/ module.exports = async function serverError({ user , message , component , noMail , }) {
const log = `🚀 SERVER ERROR ===========================\nUser Id: ${user?.id}\nUser Name: ${user?.first_name} ${user?.last_name}\nUser Email: ${user?.email}\nError Message: ${message}\nComponent: ${component}\nDate: ${Date()}\n========================================`;
if (!fs.existsSync(`./.tmp/error.log`)) {
fs.writeFileSync(`./.tmp/error.log`, "", "utf-8");
}
const initialText = fs.readFileSync(`./.tmp/error.log`, "utf-8");
fs.writeFileSync(`./.tmp/error.log`, log);
fs.appendFileSync(`./.tmp/error.log`, `\n\n\n\n\n${initialText}`);
// if (process.env.NODE_ENV?.match(/production/) && !noMail) {
// handleNodemailer({
// to: "benoti.san@gmail.com",
// subject: "SERVER Error in Datasquirel Application",
// text: "An Error occured in Datasquirel Application Server Side",
// html: log,
// });
// }
}; ////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/***/ })
};
;
@@ -0,0 +1,51 @@
"use strict";
exports.id = 2186;
exports.ids = [2186];
exports.modules = {
/***/ 2186:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Z": () => (/* binding */ FormSuccessBlock)
/* 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 - React component props
* @param {string} props.message - Message
* @param {string} [props.className] - Additional Class Names
*/ function FormSuccessBlock({ message , className }) {
return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
className: "info green" + (className ? " " + className : ""),
children: [
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("img", {
src: "/images/checkmark.svg",
alt: "Warning Image Icon",
width: 22,
className: "-my-2"
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("span", {
children: message
})
]
});
} /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
/***/ })
};
;
@@ -0,0 +1,55 @@
"use strict";
exports.id = 2224;
exports.ids = [2224];
exports.modules = {
/***/ 2224:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const fs = __webpack_require__(7147);
const path = __webpack_require__(1017);
const mysql = __webpack_require__(2261);
const SSL_DIR = "/app/ssl";
const MASTER = mysql({
config: {
host: process.env.DSQL_DB_HOST,
user: process.env.DSQL_DB_USERNAME,
password: process.env.DSQL_DB_PASSWORD,
database: process.env.DSQL_DB_NAME,
port: process.env.DB_PORT ? Number(process.env.DB_PORT) : undefined,
charset: "utf8mb4",
ssl: {
ca: fs.readFileSync(`${SSL_DIR}/ca-cert.pem`)
}
}
});
/**
* DSQL user read-only DB handler
* @param {object} params
* @param {string} params.paradigm
* @param {string} params.database
* @param {string} params.queryString
* @param {string[]} [params.queryValues]
*/ // @ts-ignore
async function DB_HANDLER(...args) {
try {
const results = await MASTER.query(...args);
/** ********************* Clean up */ await MASTER.end();
return JSON.parse(JSON.stringify(results));
} catch (/** @type {any} */ error) {
console.log("DB Error =>", error);
return {
success: false,
error: error.message
};
}
}
module.exports = DB_HANDLER;
/***/ })
};
;
@@ -0,0 +1,53 @@
"use strict";
exports.id = 2317;
exports.ids = [2317];
exports.modules = {
/***/ 2317:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
/**
* ==============================================================================
* Imports
* ==============================================================================
*/
const fs = __webpack_require__(7147);
// const handleNodemailer = require("./handleNodemailer");
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
* ==============================================================================
* Main Function
* ==============================================================================
* @param {{
* user?: { id?: number | string, first_name?: string, last_name?: string, email?: string } & *,
* message: string,
* component?: string,
* noMail?: boolean,
* }} params - user id
*
* @returns {Promise<void>}
*/ module.exports = async function serverError({ user , message , component , noMail , }) {
const log = `🚀 SERVER ERROR ===========================\nUser Id: ${user?.id}\nUser Name: ${user?.first_name} ${user?.last_name}\nUser Email: ${user?.email}\nError Message: ${message}\nComponent: ${component}\nDate: ${Date()}\n========================================`;
if (!fs.existsSync(`./.tmp/error.log`)) {
fs.writeFileSync(`./.tmp/error.log`, "", "utf-8");
}
const initialText = fs.readFileSync(`./.tmp/error.log`, "utf-8");
fs.writeFileSync(`./.tmp/error.log`, log);
fs.appendFileSync(`./.tmp/error.log`, `\n\n\n\n\n${initialText}`);
// if (process.env.NODE_ENV?.match(/production/) && !noMail) {
// handleNodemailer({
// to: "benoti.san@gmail.com",
// subject: "SERVER Error in Datasquirel Application",
// text: "An Error occured in Datasquirel Application Server Side",
// html: log,
// });
// }
}; ////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/***/ })
};
;
+118
View File
@@ -0,0 +1,118 @@
"use strict";
exports.id = 2348;
exports.ids = [2348];
exports.modules = {
/***/ 2348:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Z": () => (/* binding */ FormRadios)
/* 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 {{
* title: string,
* payload: string | boolean,
* default?: boolean,
* jsx?: React.ReactNode,
* onChangeHandler?: (e: any) => void,
* }[]} props.radioValues - array of objects
* @param {string} props.name - form radios collective name
* @param {(e: any) => void} [props.onChangeHandler] - when radios change
* @param {React.Dispatch<React.SetStateAction<any>>} [props.setAlert] - set an external alert dispatch
* @param {boolean} [props.flexRow] - if the radio and label are stacked on each other or side-by-side
* @param {string} [props.labelColor] - Label color using tailwind syntax
* @param {boolean} [props.baseText] - Font size regular
* @param {boolean} [props.smallText] - Font size smaller
* @param {string} [props.className] - Additional class names for the wrapper
*/ function FormRadios({ radioValues , name , onChangeHandler , setAlert , flexRow , labelColor , baseText , smallText , className , }) {
try {
/**
* 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__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
className: "flex items-start gap-4 flex-wrap " + (flexRow ? "" : " flex-col ") + (className ? className : ""),
children: radioValues.map((value, index)=>{
const { payload , title , jsx } = value;
const radioPayload = payload === false ? payload : payload ? payload : title ? title : null;
return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
className: "flex items-center gap-2",
children: [
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("input", {
className: "m-0" + (baseText ? " w-5 h-5" : smallText ? " w-4 h-4" : " w-6 h-6"),
type: "radio",
defaultChecked: value.default ? true : false,
name: name,
id: name + "_" + radioPayload,
onChange: (e)=>{
if (setAlert) setAlert(null);
if (value.onChangeHandler) {
value.onChangeHandler(e);
} else if (onChangeHandler) {
onChangeHandler(e);
}
},
value: typeof radioPayload == "string" ? radioPayload : undefined
}),
jsx ? jsx : /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("label", {
htmlFor: name + "_" + radioPayload,
className: "text-lg m-0 " + (labelColor ? labelColor : "text-slate-800") + (baseText ? " text-base" : smallText ? " text-sm" : " text-lg"),
children: title
})
]
}, index + 1);
})
});
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
} catch (error) {
console.log("ERROR in FormRadio =>", error);
return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
children: "Form Radio Error"
});
}
} /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
/***/ })
};
;
File diff suppressed because it is too large Load Diff
+151
View File
@@ -0,0 +1,151 @@
"use strict";
exports.id = 2434;
exports.ids = [2434];
exports.modules = {
/***/ 1095:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Z": () => (/* binding */ CodeBlock)
/* 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__);
/* harmony import */ var _mui_icons_material_ContentCopy__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6843);
/* harmony import */ var _mui_icons_material_ContentCopy__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_mui_icons_material_ContentCopy__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _mui_material_Snackbar__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(9174);
/* harmony import */ var _mui_material_Snackbar__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_mui_material_Snackbar__WEBPACK_IMPORTED_MODULE_3__);
// @ts-check
/**
* ==============================================================================
* Imports
* ==============================================================================
*/
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
* ==============================================================================
* Main Component { Functional }
* ==============================================================================
* @param {{
* content: string,
* language: string,
* style?: React.CSSProperties,
* }} props - React component props including { children }
*/ function CodeBlock({ content , language , style }) {
/**
* Get Contexts
*
* @abstract { React.useContext }
*/ ////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Javascript Variables
*
* @abstract Non hook variables and functions
*/ const [open, setOpen] = react__WEBPACK_IMPORTED_MODULE_1___default().useState(false);
const handleClick = ()=>{
setOpen(true);
};
/**
* ## Handle Close
* @param {*} event
* @param {*} reason
* @returns
*/ const handleClose = (event, reason)=>{
if (reason === "clickaway") {
return;
}
setOpen(false);
};
const action = /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx((react__WEBPACK_IMPORTED_MODULE_1___default().Fragment), {
children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("button", {
className: "outlined gray",
style: {
border: "none",
padding: "2px",
width: "20px",
height: "20px",
color: "white"
},
// @ts-ignore
onClick: handleClose,
children: "✖"
})
});
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* React Hooks
*
* @abstract { useState, useEffect, useRef, etc ... }
*/ ////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Function Return
*
* @abstract Main Function Return
*/ return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("pre", {
className: `language-${language ? language : "javascript"} w-full overflow-hidden code-block relative max-w-4xl`,
style: style ? style : {},
children: [
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("code", {
className: `w-full`,
style: {
wordBreak: "break-all"
},
children: content
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("button", {
className: "outlined absolute top-2 right-2 z-20 copy-code hover:opacity-50",
style: {
padding: "2px",
border: "none"
},
onClick: (/** @type {any} */ e)=>{
navigator.clipboard.writeText(content).then(()=>{
handleClick();
});
},
children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx((_mui_icons_material_ContentCopy__WEBPACK_IMPORTED_MODULE_2___default()), {
fontSize: "small",
color: "action"
})
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx((_mui_material_Snackbar__WEBPACK_IMPORTED_MODULE_3___default()), {
open: open,
autoHideDuration: 2000,
onClose: handleClose,
children: /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
className: "h-full text-white px-4 py-2 justify-between rounded",
style: {
maxWidth: "250px",
width: "250px",
backgroundColor: "#0b8862"
},
children: [
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("span", {
children: "Code Copied!"
}),
action
]
})
})
]
});
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
}
/***/ })
};
;
+348
View File
@@ -0,0 +1,348 @@
"use strict";
exports.id = 2435;
exports.ids = [2435];
exports.modules = {
/***/ 2435:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
// EXPORTS
__webpack_require__.d(__webpack_exports__, {
"Z": () => (/* binding */ SuDocsPageListContent)
});
// 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: external "@mui/icons-material/ArticleTwoTone"
var ArticleTwoTone_ = __webpack_require__(1891);
var ArticleTwoTone_default = /*#__PURE__*/__webpack_require__.n(ArticleTwoTone_);
// EXTERNAL MODULE: ./functions/frontend/fetchApi.js
var fetchApi = __webpack_require__(6729);
// EXTERNAL MODULE: ./components/general/LoadingBlock.jsx
var LoadingBlock = __webpack_require__(5264);
// EXTERNAL MODULE: external "@mui/icons-material/AccountTreeTwoTone"
var AccountTreeTwoTone_ = __webpack_require__(4118);
var AccountTreeTwoTone_default = /*#__PURE__*/__webpack_require__.n(AccountTreeTwoTone_);
;// CONCATENATED MODULE: ./components/su/components/PageCard.jsx
// @ts-check
/**
* ==============================================================================
* Imports
* ==============================================================================
*/
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
/**
* ==============================================================================
* Main Component { Functional }
* ==============================================================================
* @param {object} props - Server props
* @param {import("@/package-shared/types").MYSQL_docs_pages_table_def} props.docPageObject
*/ function PageCard({ docPageObject }) {
/**
* Get Contexts
*
* @abstract { React.useContext }
*/ ////////////////////////////////////////////////
////////////////////////////////////////////////
////////////////////////////////////////////////
/**
* Javascript Variables
*
* @abstract Non hook variables and functions
*/ ////////////////////////////////////////////////
////////////////////////////////////////////////
////////////////////////////////////////////////
/**
* React Hooks
*
* @abstract { useState, useEffect, useRef, etc ... }
*/ const [loading, setLoading] = external_react_default().useState(false);
/** @type {[ childPages: import("@/package-shared/types").MYSQL_docs_pages_table_def[], setChildPages: React.Dispatch<React.SetStateAction<import("@/package-shared/types").MYSQL_docs_pages_table_def[]>> ]} */ // @ts-ignore
const [childPages, setChildPages] = external_react_default().useState([]);
external_react_default().useEffect(()=>{
(0,fetchApi/* default */.Z)("/api/admin/docs/get-child-pages", {
method: "post",
body: {
pageId: docPageObject.id
}
}).then((res)=>{
if (res.success) {
setChildPages(res.result);
}
});
}, []);
////////////////////////////////////////////////
////////////////////////////////////////////////
////////////////////////////////////////////////
/**
* Function Return
*
* @description Main Function Return
*/ return /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
className: "card col relative cursor-pointer",
onClick: (e)=>{
// @ts-ignore
if (e.target?.closest(".cancel-link")) {
e.preventDefault();
} else {
window.location.pathname = `/su/docs/pages/${docPageObject.id}`;
}
},
children: [
loading && /*#__PURE__*/ jsx_runtime_.jsx(LoadingBlock/* default */.Z, {
width: "20px"
}),
/*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
className: "w-full items-start",
children: [
/*#__PURE__*/ jsx_runtime_.jsx((ArticleTwoTone_default()), {
color: "inherit",
className: "opacity-40 text-gray-600"
}),
/*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
className: "flex-col items-start gap-0 relative z-10",
children: [
/*#__PURE__*/ jsx_runtime_.jsx("span", {
className: "title",
children: docPageObject.title
}),
/*#__PURE__*/ jsx_runtime_.jsx("span", {
className: "-my-3",
dangerouslySetInnerHTML: {
__html: docPageObject.description || ""
}
})
]
}),
/*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
className: "ml-auto cancel-link",
children: [
/*#__PURE__*/ jsx_runtime_.jsx("button", {
onClick: ()=>{
window.location.href = `/su/docs/edit-page?id=${docPageObject.id}`;
},
className: "outlined small-text light-gray",
children: "Edit Page"
}),
/*#__PURE__*/ jsx_runtime_.jsx("button", {
onClick: ()=>{
if (window.confirm("Delete this page?")) {
setLoading(true);
(0,fetchApi/* default */.Z)("/api/admin/docs/delete-page", {
method: "post",
body: docPageObject
}).then((res)=>{
if (res.success) {
window.location.reload();
} else {}
setTimeout(()=>{
setLoading(false);
}, 1000);
});
}
},
className: "outlined small-text light-gray",
children: "Delete Page"
})
]
})
]
}),
childPages && /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
className: "-mt-[40px] pt-[40px] ml-[10px] pl-[20px] border-0 border-l border-slate-200 border-solid w-full flex-col items-start cancel-link",
children: [
/*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
children: [
/*#__PURE__*/ jsx_runtime_.jsx((AccountTreeTwoTone_default()), {
className: "opacity-20",
fontSize: "small"
}),
/*#__PURE__*/ jsx_runtime_.jsx("span", {
className: "text-slate-300 font-semibold",
children: "Children Pages"
})
]
}),
childPages.map((childPage, index)=>{
return /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
className: "card w-full",
onClick: ()=>{
window.location.pathname = `/su/docs/pages/${childPage.id}`;
},
children: [
/*#__PURE__*/ jsx_runtime_.jsx((ArticleTwoTone_default()), {
color: "inherit",
className: "opacity-40 text-gray-500"
}),
/*#__PURE__*/ jsx_runtime_.jsx("span", {
children: childPage.title
})
]
}, index);
})
]
})
]
});
////////////////////////////////////////////////
////////////////////////////////////////////////
////////////////////////////////////////////////
} //////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
// EXTERNAL MODULE: ./components/general/ui/ButtonGroup.jsx
var ButtonGroup = __webpack_require__(5449);
;// CONCATENATED MODULE: ./components/su/docs/SuDocsPageListContent.jsx
// @ts-check
/**
* ==============================================================================
* Imports
* ==============================================================================
*/
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
* Super User Page List Component
* ==============================================================================
* @param {Object} props - Server props
* @param {any} props.data
*/ function SuDocsPageListContent({ data }) {
/**
* Get Contexts
*
* @abstract { React.useContext }
*/ const { env } = data;
/** @type {import("@/package-shared/types").MYSQL_docs_pages_table_def[]} */ const docPages = data.docPages;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Javascript Variables
*
* @abstract Non hook variables and functions
*/ ////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* React Hooks
*
* @abstract { useState, useEffect, useRef, etc ... }
*/ const [loading, setLoading] = external_react_default().useState(false);
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* ## Persist Function
* @param {boolean} pull
*/ function persist(pull) {
if (window.confirm(pull ? "Update Docs DB from JSON file?" : "Update docs json file?")) {
setLoading(true);
(0,fetchApi/* default */.Z)("/api/admin/docs/persist", {
method: "post",
body: {
pull
}
}).then((res)=>{
if (res.success) {
window.alert(pull ? "Docs database table Updated Sucessfully!" : "JSON data written Successfully!");
} else {
window.alert("Operation failed!");
}
setTimeout(()=>{
setLoading(false);
}, 1000);
}).catch((err)=>{
setTimeout(()=>{
setLoading(false);
}, 1000);
});
}
}
////////////////////////////////////////
/**
* Function Return
*
* @abstract Main Function Return
*/ return /*#__PURE__*/ (0,jsx_runtime_.jsxs)((external_react_default()).Fragment, {
children: [
loading && /*#__PURE__*/ jsx_runtime_.jsx(LoadingBlock/* default */.Z, {}),
/*#__PURE__*/ (0,jsx_runtime_.jsxs)("section", {
className: "items-start justify-start p-6",
children: [
/*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
className: "flex items-center justify-between w-full mb-6",
children: [
/*#__PURE__*/ jsx_runtime_.jsx("h2", {
className: "text-xl m-0",
children: "Documentation Pages"
}),
/*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
children: [
/*#__PURE__*/ jsx_runtime_.jsx("a", {
href: `/su/docs/create-page`,
className: "button",
children: "Create Page"
}),
/*#__PURE__*/ (0,jsx_runtime_.jsxs)(ButtonGroup/* default */.Z, {
children: [
/*#__PURE__*/ jsx_runtime_.jsx("button", {
className: "outlined gray",
onClick: ()=>{
persist(false);
},
children: "Push"
}),
/*#__PURE__*/ jsx_runtime_.jsx("button", {
className: "outlined gray",
onClick: ()=>{
persist(true);
},
children: "Pull"
})
]
})
]
})
]
}),
/*#__PURE__*/ jsx_runtime_.jsx("div", {
className: "paper flex-col items-stretch gap-10 w-full",
children: docPages.map((docPageObject, index)=>/*#__PURE__*/ jsx_runtime_.jsx(PageCard, {
docPageObject: docPageObject
}, index))
})
]
})
]
});
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
} /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
/***/ })
};
;
@@ -0,0 +1,77 @@
"use strict";
exports.id = 2630;
exports.ids = [2630];
exports.modules = {
/***/ 2630:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Z": () => (/* binding */ importExportTableDataFn)
/* harmony export */ });
/* harmony import */ var _package_shared_functions_backend_db_addDbEntry__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5338);
/* harmony import */ var _package_shared_functions_backend_db_addDbEntry__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_package_shared_functions_backend_db_addDbEntry__WEBPACK_IMPORTED_MODULE_0__);
// @ts-check
const serverError = __webpack_require__(2163);
const DB_HANDLER = __webpack_require__(2224);
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
* @typedef {object} ExportTableDataFnReturn
* @property {any} [tableData]
*/ /**
* ==============================================================================
* @param {Object} params - Single object parameter
* @param {"export" | "import"} params.paradigm
* @param {string | number} params.userId
* @param {string} params.dbName
* @param {string} params.tableName
* @param {any} params.payload
* @param {"JSON" | "base64" | "object"} params.payloadType
* @return {Promise<ExportTableDataFnReturn | null>}
*/ async function importExportTableDataFn({ paradigm , userId , dbName , tableName , payload , payloadType , }) {
/** @type {ExportTableDataFnReturn} */ let returnObject = {};
try {
const dbFullName = `${process.env.DSQL_USER_DB_PREFIX}${userId}_${dbName.replace(/ /g, "")}`;
switch(paradigm){
case "export":
const tableData = await DB_HANDLER(`SELECT * FROM \`${dbFullName}\`.\`${tableName}\``);
returnObject["tableData"] = tableData;
break;
case "import":
const jsonData = payloadType == "base64" ? Buffer.from(payload, "base64").toString() : payloadType == "JSON" ? payload : payload;
const writeData = payloadType === "object" ? payload : JSON.parse(jsonData);
for(let i = 0; i < writeData.length; i++){
const dataToWrite = writeData[i];
const newEntry = await _package_shared_functions_backend_db_addDbEntry__WEBPACK_IMPORTED_MODULE_0___default()({
data: dataToWrite,
dbFullName: dbFullName,
tableName: tableName,
dbContext: "Dsql User",
paradigm: "Full Access",
duplicateColumnName: "id",
duplicateColumnValue: dataToWrite?.id,
update: true
});
if (newEntry.error) {
throw new Error(newEntry.error);
}
}
break;
default:
return null;
}
return returnObject;
} catch (/** @type {any} */ error) {
serverError({
component: "/functions/backend/importExportTableDataFn",
message: error.message
});
return null;
}
} /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
/***/ })
};
;
+118
View File
@@ -0,0 +1,118 @@
"use strict";
exports.id = 2733;
exports.ids = [2733];
exports.modules = {
/***/ 2733:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Z": () => (/* binding */ UserImage)
/* 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__);
/* harmony import */ var _functions_frontend_imageInputFileToBase64__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(6718);
/* harmony import */ var _general_GeneralPopup__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(5472);
// @ts-check
/**
* ==============================================================================
* Imports
* ==============================================================================
*/
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ let timeout;
/** ****************************************************************************** */ /**
* ==============================================================================
* Main Component { Functional }
* ==============================================================================
* @param {Object} props - Server props
* @param {import("@/package-shared/types").UserType} [props.user]
* @param {string | import("@/package-shared/types").ImageObjectType} props.userImage
* @param {React.Dispatch<React.SetStateAction<string | import("@/package-shared/types").ImageObjectType>>} props.setUserImage
* @param {Object} [props.database]
* @param {Object} [props.className]
*/ function UserImage({ user , userImage , setUserImage , database , className , }) {
/**
* Get Contexts
*
* @abstract { React.useContext }
*/ ////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Javascript Variables
*
* @abstract Non hook variables and functions
*/ ////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* React Hooks
*
* @abstract { useState, useEffect, useRef, etc ... }
*/ const imagePreviewRef = react__WEBPACK_IMPORTED_MODULE_1___default().useRef();
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Function Return
*
* @abstract Main Function Return
*/ return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
className: "card no-hover col" + (className ? " " + className : ""),
children: [
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
className: "bg-white rounded-full overflow-hidden w-24 h-24",
children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("img", {
src: userImage ? typeof userImage === "string" ? userImage : userImage.imageBase64Full : "/images/user_images/user-preset.png",
alt: "Database Image",
width: 100,
className: "w-full h-full object-cover",
// @ts-ignore
ref: imagePreviewRef,
"data-imagepreview": "image"
})
}),
/*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
className: "w-full flex-col image-selector-wrapper",
children: [
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
className: "button outlined secondary w-full whitespace-normal",
onClick: (e)=>{
e.target// @ts-ignore
.closest(".image-selector-wrapper").querySelector("input").click();
},
children: "Upload Image"
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("input", {
type: "file",
accept: ".png,.jpg,.jpeg,.webp",
placeholder: "Choose Database Image",
className: "hidden",
onChange: async (e)=>{
let imageData = await (0,_functions_frontend_imageInputFileToBase64__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z)({
// @ts-ignore
imageInputFile: e.target.files[0],
maxWidth: 400
});
setUserImage(imageData);
}
})
]
})
]
});
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
} /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
/***/ })
};
;
+241
View File
@@ -0,0 +1,241 @@
"use strict";
exports.id = 2896;
exports.ids = [2896];
exports.modules = {
/***/ 9350:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Z": () => (/* binding */ DocsGenereicHero)
/* 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 {string} props.title
* @param {string} props.description
*/ function DocsGenereicHero({ title , description }) {
/**
* 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)("section", {
className: "py-14",
children: [
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
className: "w-full gap-10 justify-between items-start flex-col lg:flex-row relative z-10",
children: /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
className: "flex-col items-start max-w-[740px] text-left",
style: {
minWidth: "45%"
},
children: [
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("h1", {
className: "m-0 leading-tight",
children: title
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("span", {
className: "font-normal text-xl -my-4",
dangerouslySetInnerHTML: {
__html: description
}
})
]
})
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("img", {
src: "/images/grid.webp",
alt: "Dotted image background",
className: "absolute top-0 left-0 w-full h-full object-cover opacity-5 z-0"
})
]
});
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
} /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
/***/ }),
/***/ 1273:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const fs = __webpack_require__(7147);
const serverError = __webpack_require__(7023);
const mysql = __webpack_require__(2261);
const path = __webpack_require__(1017);
const SSL_DIR = "/app/ssl";
const connection = mysql({
config: {
host: process.env.DSQL_DB_HOST,
user: process.env.DSQL_DB_USERNAME,
password: process.env.DSQL_DB_PASSWORD,
database: process.env.DSQL_DB_NAME,
charset: "utf8mb4",
ssl: {
ca: fs.readFileSync(`${SSL_DIR}/ca-cert.pem`)
}
}
});
// const connection = mysql.createConnection({
// host: process.env.DSQL_DB_HOST,
// user: process.env.DSQL_DB_USERNAME,
// password: process.env.DSQL_DB_PASSWORD,
// database: process.env.DSQL_DB_NAME,
// charset: "utf8mb4",
// });
// connection.on("error", (err) => {
// console.log("CONNECTION STATE: ", connection.state);
// console.log(err.message);
// });
// connection.on("connect", () => {
// console.log("CONNECTION ACTIVE: ", connection.state);
// });
// connection.on("end", () => {
// console.log("CONNECTION DISCONNECTED: ", connection.state);
// });
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
/**
* Main DB Handler Function
* ==============================================================================
* @async
*
* @param {any} args
* @returns {Promise<object|null>}
*/ module.exports = async function dbHandler(...args) {
"production"?.match(/dev/) && fs.appendFileSync("./.tmp/sqlQuery.sql", args[0] + "\n" + Date() + "\n\n\n", "utf8");
/**
* Declare variables
*
* @description Declare "results" variable
*/ let results;
/**
* Fetch from db
*
* @description Fetch data from db if no cache
*/ try {
results = await new Promise((resolve, reject)=>{
// @ts-ignore
connection.query(...args, (error, result, fields)=>{
if (error) {
resolve({
error: error.message
});
} else {
resolve(result);
}
});
// connection.on("error", (err) => {
// console.log("CONNECTION STATE: ", connection.state);
// console.log(err.message);
// });
// connection.on("connect", () => {
// console.log("CONNECTION ACTIVE: ", connection.state);
// });
// connection.on("end", () => {
// console.log("CONNECTION DISCONNECTED: ", connection.state);
// });
/** ********************* Clean up */ });
await connection.end();
// connection.query(...args, (error, result, fields) => {
// if (error) {
// resolve({ error: error.message });
// } else {
// resolve(result);
// }
// connection.end()
// });
// connectionPool.query(...args, (error, result, fields) => {
// if (error) {
// resolve({ error: error.message });
// } else {
// resolve(result);
// }
// });
// connectionPool.getConnection(function (err, connection) {
// if (err) {
// resolve({ error: err.message });
// connection.release();
// return;
// }
// connection.query(...args, (error, result, fields) => {
// if (error) {
// resolve({ error: error.message });
// } else {
// resolve(result);
// }
// connection.release();
// });
// });
} catch (/** @type {any} */ error) {
fs.appendFileSync("./.tmp/dbErrorLogs.txt", JSON.stringify(error, null, 4) + "\n" + Date() + "\n\n\n", "utf8");
results = null;
serverError({
component: "dbHandler",
message: error.message
});
// try {
// connection.end();
// } catch (error) {
// console.log("ERROR in dbHandler Function =>", error.message);
// }
}
/**
* Return results
*
* @description Return results add to cache if "req" param is passed
*/ if (results) {
return JSON.parse(JSON.stringify(results));
} else {
return null;
}
};
/***/ })
};
;
@@ -0,0 +1,53 @@
"use strict";
exports.id = 3017;
exports.ids = [3017];
exports.modules = {
/***/ 3017:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
/**
* ==============================================================================
* Imports
* ==============================================================================
*/
const fs = __webpack_require__(7147);
// const handleNodemailer = require("./handleNodemailer");
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
* ==============================================================================
* Main Function
* ==============================================================================
* @param {{
* user?: { id?: number | string, first_name?: string, last_name?: string, email?: string } & *,
* message: string,
* component?: string,
* noMail?: boolean,
* }} params - user id
*
* @returns {Promise<void>}
*/ module.exports = async function serverError({ user , message , component , noMail , }) {
const log = `🚀 SERVER ERROR ===========================\nUser Id: ${user?.id}\nUser Name: ${user?.first_name} ${user?.last_name}\nUser Email: ${user?.email}\nError Message: ${message}\nComponent: ${component}\nDate: ${Date()}\n========================================`;
if (!fs.existsSync(`./.tmp/error.log`)) {
fs.writeFileSync(`./.tmp/error.log`, "", "utf-8");
}
const initialText = fs.readFileSync(`./.tmp/error.log`, "utf-8");
fs.writeFileSync(`./.tmp/error.log`, log);
fs.appendFileSync(`./.tmp/error.log`, `\n\n\n\n\n${initialText}`);
// if (process.env.NODE_ENV?.match(/production/) && !noMail) {
// handleNodemailer({
// to: "benoti.san@gmail.com",
// subject: "SERVER Error in Datasquirel Application",
// text: "An Error occured in Datasquirel Application Server Side",
// html: log,
// });
// }
}; ////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/***/ })
};
;
@@ -0,0 +1,39 @@
"use strict";
exports.id = 3314;
exports.ids = [3314];
exports.modules = {
/***/ 2527:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Z": () => (/* binding */ grabUserSchemaData)
/* harmony export */ });
// @ts-check
const serverError = __webpack_require__(2317);
const fs = __webpack_require__(7147);
const path = __webpack_require__(1017);
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
* ==============================================================================
* @param {Object} params
* @param {string | number} params.userId
* @returns {DSQL_DatabaseSchemaType[] | null}
*/ function grabUserSchemaData({ userId }) {
try {
const userSchemaFilePath = path.resolve(process.cwd(), `./jsonData/dbSchemas/users/user-${userId}/main.json`);
const userSchemaData = JSON.parse(fs.readFileSync(userSchemaFilePath, "utf-8"));
return userSchemaData;
} catch (/** @type {any} */ error) {
serverError({
component: "/functions/backend/grabUserSchemaData",
message: error.message
});
return null;
}
} /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
/***/ })
};
;
+109
View File
@@ -0,0 +1,109 @@
"use strict";
exports.id = 3403;
exports.ids = [3403];
exports.modules = {
/***/ 3403:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const fs = __webpack_require__(7147);
const path = __webpack_require__(1017);
const mysql = __webpack_require__(2261);
const SSL_DIR = "/app/ssl";
let DSQL_USER = mysql({
config: {
host: process.env.DSQL_DB_HOST,
user: process.env.DSQL_DB_READ_ONLY_USERNAME,
password: process.env.DSQL_DB_READ_ONLY_PASSWORD,
charset: "utf8mb4",
ssl: {
ca: fs.readFileSync(`${SSL_DIR}/ca-cert.pem`)
}
}
});
/**
* DSQL user read-only DB handler
* @param {object} params
* @param {"Full Access" | "FA" | "Read Only"} params.paradigm
* @param {string} params.database
* @param {string} params.queryString
* @param {string[]} [params.queryValues]
*/ function DSQL_USER_DB_HANDLER({ paradigm , database , queryString , queryValues , }) {
try {
return new Promise((resolve, reject)=>{
const fullAccess = paradigm?.match(/full.access|^fa$/i) ? true : false;
try {
if (fullAccess) {
DSQL_USER = mysql({
config: {
host: process.env.DSQL_DB_HOST,
user: process.env.DSQL_DB_FULL_ACCESS_USERNAME,
password: process.env.DSQL_DB_FULL_ACCESS_PASSWORD,
database: database,
ssl: {
ca: fs.readFileSync(`${SSL_DIR}/ca-cert.pem`)
}
}
});
} else {
DSQL_USER = mysql({
config: {
host: process.env.DSQL_DB_HOST,
user: process.env.DSQL_DB_READ_ONLY_USERNAME,
password: process.env.DSQL_DB_READ_ONLY_PASSWORD,
database: database,
ssl: {
ca: fs.readFileSync(`${SSL_DIR}/ca-cert.pem`)
}
}
});
}
/**
* ### Run query Function
* @param {any} results
*/ function runQuery(results) {
DSQL_USER.end();
resolve(JSON.parse(JSON.stringify(results)));
}
/**
* ### Query Error
* @param {any} err
*/ function queryError(err) {
DSQL_USER.end();
resolve({
error: err.message,
queryStringGenerated: queryString,
queryValuesGenerated: queryValues,
sql: err.sql
});
}
if (queryValues && Array.isArray(queryValues) && queryValues[0]) {
DSQL_USER.query(queryString, queryValues).then(runQuery).catch(queryError);
} else {
DSQL_USER.query(queryString).then(runQuery).catch(queryError);
}
////////////////////////////////////////
} catch (/** @type {any} */ error) {
////////////////////////////////////////
fs.appendFileSync("./.tmp/dbErrorLogs.txt", error.message + "\n" + Date() + "\n\n\n", "utf8");
resolve({
error: error.message
});
}
});
} catch (/** @type {any} */ error) {
return {
success: false,
error: error.message
};
}
}
module.exports = DSQL_USER_DB_HANDLER;
/***/ })
};
;
+86
View File
@@ -0,0 +1,86 @@
"use strict";
exports.id = 370;
exports.ids = [370];
exports.modules = {
/***/ 370:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const http = __webpack_require__(3685);
const DB_HANDLER = __webpack_require__(9395);
const decrypt = __webpack_require__(5304);
const fs = __webpack_require__(7147);
const EXPIRY_TIME = 1000 * 60 * 60 * 24 * 1 * 7; // 7 days
/**
* @async
* @param {import("next").NextApiRequest | http.IncomingMessage & { cookies: Partial<{ [key: string]: string; }>;
}} req - https request object
* @param {import("next").NextApiResponse | http.ServerResponse} res - https response object
* @param {boolean | null} [csrf] - csrf key
* @param {any} [query] - query object
*
* @returns {Promise<(import("@/package-shared/types").UserType | null)>}
*/ module.exports = async function userAuth(req, res, csrf, query) {
/** ********************* Check for existence of required cookie */ if (!req.cookies?.datasquirelAuthKey?.match(/./)) {
// console.log("No datasquirel key cookie present");
return null;
}
/** ********************* Grab the payload */ let userPayload = decrypt(req.cookies.datasquirelAuthKey);
/** ********************* Return if no payload */ if (!userPayload) {
// console.log("Couldn't Decrypt cookie");
return null;
}
/** ********************* Parse the payload */ let userObject = JSON.parse(userPayload);
const { user_type } = userObject;
if (!userObject.csrf_k) {
// console.log("No CSRF_K in decrypted payload");
return null;
}
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
if (csrf && // @ts-ignore
!req.headers["x-csrf-auth"]?.match(new RegExp(`${userObject.csrf_k}`))) {
// console.log("CSRF_K requested but does not match payload");
return null;
}
const allowedAuthKeysPath = process.env.DSQL_USER_LOGIN_KEYS_PATH;
if (!allowedAuthKeysPath) {
console.log(`DSQL_USER_LOGIN_KEYS_PATH env variable not found. Please set this variable.`);
return null;
}
if (csrf && !fs.existsSync(`${allowedAuthKeysPath}/${userObject.csrf_k}`)) {
return null;
}
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/** ********************* check user verification */ if (userObject.verification_status == 0 && !csrf) {
let currentVerificationStatus = await DB_HANDLER(`SELECT verification_status FROM users WHERE id='${userObject.id}'`);
if (currentVerificationStatus && currentVerificationStatus[0] && currentVerificationStatus[0].verification_status == 1) {
// userObject = await reAuthUser({ userId: userObject.id, res });
res.setHeader("Set-Cookie", [
`user_refresh=1`
]);
}
}
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
if (userObject?.date && Date.now() - userObject.date > EXPIRY_TIME) {
// console.log("Cookie expired");
return null;
}
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/** ********************* return user object */ return userObject;
};
/***/ })
};
;
+157
View File
@@ -0,0 +1,157 @@
"use strict";
exports.id = 3863;
exports.ids = [3863];
exports.modules = {
/***/ 3863:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Z": () => (/* binding */ UserListCard)
/* 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__);
/* harmony import */ var _general_GeneralPopup__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(5472);
/* harmony import */ var _functions_frontend_fetchApi__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(6729);
/* harmony import */ var _general_LoadingBlock__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(5264);
/* harmony import */ var _general_ui_ButtonGroup__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(5449);
// @ts-check
/**
* ==============================================================================
* Imports
* ==============================================================================
*/
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
* ==============================================================================
* Main Component { Functional }
* ==============================================================================
* @param {Object} props - Server props
* @param {import("@/package-shared/types").MYSQL_user_users_table_def} props.userObject
* @param {React.Dispatch<React.SetStateAction<import("@/package-shared/types").MYSQL_user_users_table_def | null>>} props.setTargetUser
* @param {string} [props.paradigm]
*/ function UserListCard({ userObject , setTargetUser , paradigm }) {
/**
* Get Contexts
*
* @abstract { React.useContext }
*/ ////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Javascript Variables
*
* @abstract Non hook variables and functions
*/ const userName = (()=>{
if (paradigm?.match(/invited/)) {
return `${userObject.inviteeFirstName} ${userObject.inviteeLastName} (${userObject.inviteeEmail})`;
}
return `${userObject.first_name} ${userObject.last_name} (${userObject.email})`;
})();
const userImage = (()=>{
if (paradigm?.match(/invited/)) {
return `${userObject.inviteeImage}`;
}
return `${userObject.image_thumbnail}`;
})();
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* React Hooks
*
* @abstract { useState, useEffect, useRef, etc ... }
*/ const [loading, setLoading] = react__WEBPACK_IMPORTED_MODULE_1___default().useState(false);
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Function Return
*
* @abstract Main Function Return
*/ return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
className: "card no-hover items-center " + (paradigm?.match(/invited/) ? " green green-bg" : " primary"),
children: [
loading && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_general_LoadingBlock__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z, {}),
/*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
className: "w-full",
children: [
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("img", {
src: userImage,
className: "w-8 h-8 rounded-full object-cover bg-slate-200",
onError: (e)=>{
// @ts-ignore
e.target.src = "/images/user_images/user-preset-thumbnail.png";
}
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("span", {
className: "text-sm font-semibold",
children: userName
}),
userObject?.user_priviledge?.match(/./) && /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("span", {
className: "text-sm ml-auto text-slate-900/50",
children: [
"Priviledges:",
" ",
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("span", {
className: "text-slate-600 font-semibold",
children: userObject.user_priviledge.split("|").join(" | ")
})
]
}),
!paradigm?.match(/invited/) && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx((react__WEBPACK_IMPORTED_MODULE_1___default().Fragment), {
children: /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_general_ui_ButtonGroup__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Z, {
children: [
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("button", {
className: "outlined text-xs px-3 py-1",
onClick: (e)=>{
setTargetUser(userObject);
setTimeout(()=>{
(0,_general_GeneralPopup__WEBPACK_IMPORTED_MODULE_2__/* .openPopup */ .Mw)("target-user-popup");
}, 200);
},
children: "Edit User Access"
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("button", {
className: "outlined text-xs px-3 py-1",
onClick: (e)=>{
setLoading(true);
if (window.confirm("Delete this user")) {
(0,_functions_frontend_fetchApi__WEBPACK_IMPORTED_MODULE_5__/* ["default"] */ .Z)("/api/deleteUserUser", {
method: "post",
body: {
...userObject
}
}, true).then((res)=>{
setTimeout(()=>{
setLoading(false);
}, 500);
window.location.reload();
});
}
},
children: "Delete User"
})
]
})
})
]
})
]
});
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
} /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
/***/ })
};
;
File diff suppressed because it is too large Load Diff
+120
View File
@@ -0,0 +1,120 @@
"use strict";
exports.id = 4017;
exports.ids = [4017];
exports.modules = {
/***/ 4017:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Z": () => (/* binding */ Logo)
/* 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__);
/* harmony import */ var _mui_icons_material_MenuBookTwoTone__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(5557);
/* harmony import */ var _mui_icons_material_MenuBookTwoTone__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_mui_icons_material_MenuBookTwoTone__WEBPACK_IMPORTED_MODULE_2__);
// @ts-check
/**
* ==============================================================================
* Imports
* ==============================================================================
*/
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
* Main Component { Functional }
* ==============================================================================
* @param {{
* size?: string,
* adminAside?: boolean,
* collapseAsideMobile?: boolean,
* setCollapseAsideMobile?: React.Dispatch<React.SetStateAction<boolean>>,
* }} props - React component props
*/ function Logo({ size , adminAside , collapseAsideMobile , setCollapseAsideMobile , }) {
/**
* 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)("a", {
href: "/",
className: "logo",
onClick: (e)=>{
/** @type {*} */ const targetElement = e.target;
if (targetElement?.closest("button")) {
return e.preventDefault();
}
},
children: [
adminAside && /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("button", {
className: "flex lg:hidden small-text mr-2 primary-light",
onClick: (e)=>{
if (collapseAsideMobile && setCollapseAsideMobile) {
setCollapseAsideMobile(false);
} else if (setCollapseAsideMobile) {
setCollapseAsideMobile(true);
}
},
children: [
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
className: "-mt-0.5",
children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx((_mui_icons_material_MenuBookTwoTone__WEBPACK_IMPORTED_MODULE_2___default()), {
color: "action"
})
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("span", {
className: "dark:text-white",
children: "Menu"
})
]
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("img", {
src: "/images/logo-icon-alt-2.webp",
alt: "Datasquirel Logo",
width: 35,
className: "dark:hidden -mt-1.5 -mr-1.5"
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("img", {
src: "/images/logo-icon-alt-2.webp",
alt: "Datasquirel Logo",
width: 35,
className: "hidden dark:flex -mt-1.5 -mr-1.5"
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("span", {
className: "text-slate-800 dark:text-white text-[20px] font-bold hidden sm:flex -mt-[1px]",
children: "Datasquirel"
})
]
});
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
}
/***/ })
};
;
+106
View File
@@ -0,0 +1,106 @@
"use strict";
exports.id = 4097;
exports.ids = [4097];
exports.modules = {
/***/ 4097:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Z": () => (/* binding */ PageHeadTags)
/* 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 {string} props.pageTitle
* @param {string} props.pageDescription
* @param {string} props.pagePathname
* @param {boolean} [props.aceEditor]
*/ function PageHeadTags({ pageTitle , pageDescription , pagePathname , aceEditor , }) {
/**
* Function Return
*
* @abstract Main Function Return
*/ return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)((react__WEBPACK_IMPORTED_MODULE_1___default().Fragment), {
children: [
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("link", {
rel: "canonical",
href: "http://localhost:7070" + pagePathname
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("meta", {
property: "og:url",
content: "http://localhost:7070" + pagePathname
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("meta", {
itemProp: "url",
content: "http://localhost:7070" + pagePathname
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("meta", {
name: "twitter:url",
content: "http://localhost:7070" + pagePathname
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("meta", {
property: "og:title",
content: pageTitle
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("meta", {
property: "og:description",
content: pageDescription
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("meta", {
itemProp: "name",
content: pageTitle
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("meta", {
itemProp: "description",
content: pageDescription
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("meta", {
name: "twitter:title",
content: pageTitle
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("meta", {
name: "twitter:description",
content: pageDescription
}),
aceEditor && /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)((react__WEBPACK_IMPORTED_MODULE_1___default().Fragment), {
children: [
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("script", {
src: "https://cdnjs.cloudflare.com/ajax/libs/ace/1.22.0/ace.min.js",
integrity: "sha512-q6CTB0jS+VuJnSct82rVcWlI06LGzNjaG3CWenHWVUncRvc4UQMFkA3a5Ip880xr+lBx38FcHDclOxPdSg+sBw==",
crossOrigin: "anonymous",
referrerPolicy: "no-referrer"
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("script", {
src: "https://cdnjs.cloudflare.com/ajax/libs/ace/1.22.0/ext-language_tools.min.js",
integrity: "sha512-6g6cvocV7eT/J8L44lL8gJKqq9onqQeYGgJO0DmrsYFcCfRl6wYkYA/KHS768r4QVTB4JxsCcMQ9gIezxpTCZw==",
crossOrigin: "anonymous",
referrerPolicy: "no-referrer"
})
]
})
]
});
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
} /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
/***/ })
};
;
@@ -0,0 +1,54 @@
"use strict";
exports.id = 4105;
exports.ids = [4105];
exports.modules = {
/***/ 4105:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Z": () => (/* binding */ checkUniqueField)
/* harmony export */ });
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(6405);
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_dom__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _fetchApi__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6729);
// @ts-check
/**
* ==============================================================================
* Imports
* ==============================================================================
*/
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
let timeout;
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
* ==============================================================================
* Main Component { Functional }
* ==============================================================================
* @param {Object} params
* @param {string} params.tableName
* @param {string} params.columnName
* @param {string} params.value
* @param {string} [params.dbFullName]
* @param {any} [params.dispatch]
* @param {number} [params.userId]
* @param {number} [params.dbId]
*/ async function checkUniqueField({ tableName , columnName , value , dbFullName , dispatch , userId , dbId , }) {
/**
* Javascript Variables
*
* @abstract Non hook variables and functions
*/ const duplicate = await (0,_fetchApi__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .Z)(`/api/checkDuplicateData?tableName=${tableName}&type=${columnName}&value=${value}${dbFullName ? "&dbFullName=" + dbFullName : ""}${userId ? "&userId=" + userId : ""}${dbId ? "&dbId=" + dbId : ""}`);
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
return duplicate;
} /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
/***/ })
};
;
+179
View File
@@ -0,0 +1,179 @@
"use strict";
exports.id = 4114;
exports.ids = [4114];
exports.modules = {
/***/ 4114:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Z": () => (/* binding */ FormSelect)
/* 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 lucide_react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2423);
/* harmony import */ var lucide_react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(lucide_react__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6689);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_2__);
// @ts-check
/**
* ==============================================================================
* Imports
* ==============================================================================
*/
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
* @typedef {object} OptionObject
* @property {string} title
* @property {string} payload
* @property {boolean} [default]
*/ /**
* ==============================================================================
* Main Component { Functional }
* ==============================================================================
* @param {Object} props - Server props
* @param {OptionObject[]} props.selectOptions - array of option objects
* @param {string} [props.name]
* @param {(e:any) => void} [props.onChangeHandler]
* @param {boolean} [props.required]
* @param {React.Dispatch<React.SetStateAction<any>>} [props.setAlert]
* @param {string | React.ReactNode} [props.title]
* @param {string} [props.defaultValue]
* @param {string} [props.info]
* @param {string} [props.id]
*/ function FormSelect({ selectOptions , name , onChangeHandler , required , setAlert , title , defaultValue , info , id , }) {
try {
/**
* Get Contexts
*
* @abstract { React.useContext }
*/ ////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Javascript Variables
*
* @abstract Non hook variables and functions
*/ function toggleDropdown(/** @type {any} */ e) {
if (e.type.match(/enter/i) && window.innerWidth < 1200) {
return;
}
const infoWrapper = e.target.closest(".info-wrapper");
const dropdown = infoWrapper.querySelector(".info-dropdown");
if (e.type.match(/leave/i) && !dropdown.classList.contains("hidden")) {
dropdown.classList.add("hidden");
return;
} else if (e.type.match(/leave/i) && dropdown.classList.contains("hidden")) {
return;
}
if (!infoWrapper) {
dropdown.classList.add("hidden");
return;
}
if (dropdown.classList.contains("hidden")) {
dropdown.classList.remove("hidden");
return;
}
dropdown.classList.add("hidden");
}
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* 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: "form-select-block flex items-start flex-col gap-0.5 w-full relative" + (info ? " pr-8" : ""),
children: [
title && /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("label", {
htmlFor: name,
children: [
title,
required ? "" : " (optional)"
]
}),
/*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
className: "flex items-center w-full relative",
children: [
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("select", {
name: name,
id: id ? id : name,
className: "w-full bg-white",
required: required,
onChange: (/** @type {any} */ e)=>{
if (setAlert) setAlert(null);
e.target.classList.remove("warning");
if (onChangeHandler) onChangeHandler(e);
},
defaultValue: defaultValue ? defaultValue : undefined,
children: selectOptions.map((value, index)=>{
const { payload , title } = value;
return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("option", {
value: payload,
selected: value.default ? true : false,
children: title
}, index + 1);
})
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(lucide_react__WEBPACK_IMPORTED_MODULE_1__.ChevronDown, {
className: "absolute right-2 text-base text-slate-500 pointer-events-none",
size: 20
}),
info && /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.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: toggleDropdown,
onMouseLeave: toggleDropdown,
onClick: toggleDropdown,
children: [
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("img", {
src: "/images/info-outlined-black.png",
alt: "",
className: "w-6 h-6 object-contain opacity-60 pointer-events-none"
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.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: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("span", {
children: info
})
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
className: "absolute -top-2 w-12",
style: {
height: "45px"
}
})
]
})
]
})
]
});
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
} catch (error) {
console.log("ERROR in FormSelect =>", error);
return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
children: "Form Select Error"
});
}
} /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
/***/ })
};
;
+166
View File
@@ -0,0 +1,166 @@
"use strict";
exports.id = 4187;
exports.ids = [4187];
exports.modules = {
/***/ 4187:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Z": () => (/* binding */ SuDashboardContent)
/* 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__);
/* harmony import */ var _functions_frontend_fetchApi__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(6729);
/* harmony import */ var _general_LoadingBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(5264);
/* harmony import */ var _components_UserCard__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1336);
// @ts-check
/**
* ==============================================================================
* Imports
* ==============================================================================
*/
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
* ==============================================================================
* Main Component { Functional }
* ==============================================================================
* @param {Object} props - Server props
* @param {any} props.data
*/ function SuDashboardContent({ data }) {
/**
* Get Contexts
*
* @abstract { React.useContext }
*/ ////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Javascript Variables
*
* @abstract Non hook variables and functions
*/ const userTitles = Object.keys(data.users[0]);
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* React Hooks
*
* @abstract { useState, useEffect, useRef, etc ... }
*/ /** @type {[ errorLog: string | null, setErrorLog: React.Dispatch<React.SetStateAction<string | null>> ]} */ // @ts-ignore
const [errorLog, setErrorLog] = react__WEBPACK_IMPORTED_MODULE_1___default().useState(null);
const [refresh, setRefresh] = react__WEBPACK_IMPORTED_MODULE_1___default().useState(0);
const [clearErrorLogLoading, setClearErrorLogLoading] = react__WEBPACK_IMPORTED_MODULE_1___default().useState(false);
function fetchErrorLogs() {
(0,_functions_frontend_fetchApi__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Z)("/api/admin/grabErrorLogs").then((res)=>{
if (res?.log && typeof res.log === "string" && !res.log?.match(/./)) {
setErrorLog("No Logs Yet");
return;
} else if (res?.log) {
setErrorLog("No Logs");
}
setErrorLog(res.log.replace(/\n|\r|\n\r|\\n/gm, "<br/>"));
});
}
console.log(typeof errorLog);
react__WEBPACK_IMPORTED_MODULE_1___default().useEffect(()=>{
fetchErrorLogs();
if (refresh === 0) {
setInterval(()=>{
fetchErrorLogs();
}, 10000);
}
}, [
refresh
]);
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Function Return
*
* @abstract Main Function Return
*/ return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx((react__WEBPACK_IMPORTED_MODULE_1___default().Fragment), {
children: /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
className: "items-stretch gap-10 w-full",
children: [
/*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("section", {
className: "paper w-full",
children: [
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("h2", {
className: "text-xl m-0 mb-6",
children: "Users"
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
className: "flex-col items-stretch gap-10",
children: data.users.map((/** @type {any} */ userObject, /** @type {number} */ index)=>{
return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_components_UserCard__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z, {
userObject: userObject
}, index + 1);
})
})
]
}),
/*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("section", {
className: "paper",
children: [
/*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
className: "w-full justify-between",
children: [
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("h2", {
className: "text-xl m-0",
children: "Error Logs"
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
children: /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("button", {
onClick: (e)=>{
if (window.confirm("Clear Error Logs?")) {
setClearErrorLogLoading(true);
(0,_functions_frontend_fetchApi__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Z)("/api/admin/clearErrorLogs", "post").then((res)=>{
setRefresh((prev)=>prev + 1);
});
setTimeout(()=>{
setClearErrorLogLoading(false);
}, 2000);
}
},
className: "outlined gray relative",
children: [
clearErrorLogLoading && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_general_LoadingBlock__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .Z, {
width: "20px"
}),
"Clear Error Log"
]
})
})
]
}),
errorLog && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("p", {
dangerouslySetInnerHTML: {
__html: errorLog ? errorLog : "No Log"
}
}),
typeof errorLog !== "string" && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_general_LoadingBlock__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .Z, {
position: "relative",
width: "25px"
})
]
})
]
})
});
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
} /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
/***/ })
};
;
@@ -0,0 +1,66 @@
"use strict";
exports.id = 4194;
exports.ids = [4194];
exports.modules = {
/***/ 4194:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const fs = __webpack_require__(7147);
const os = __webpack_require__(2037);
const { execSync } = __webpack_require__(2081);
const serverError = __webpack_require__(2163);
const { ServerResponse } = __webpack_require__(3685);
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
* ==============================================================================
* Main Function
* ==============================================================================
* @param {Object} params - Single object parameter
* @param {string} params.dbName - Database Full Name
* @param {import("@/package-shared/types").UserType} params.user - Database Full Name
* @param {ServerResponse} params.res - Http response object
*/ module.exports = async function exportDb({ dbName , user , res }) {
const mysqlDumpPath = os.platform().match(/win/i) ? "'" + "C:\\Program Files\\MySQL\\MySQL Server 8.0\\bin\\mysqldump.exe" + "'" : "mysqldump";
try {
/** @type {import("child_process").ExecSyncOptions} */ let execSyncOptions = {
cwd: process.cwd()
};
const filePath = `./jsonData/dbSchemas/users/user-${user.id}/export.sql`;
if (os.platform().match(/win/i)) execSyncOptions.shell = "bash.exe";
const exe = `${mysqlDumpPath} -u ${process.env.DSQL_DB_USERNAME} -h ${process.env.DSQL_DB_HOST} -p${process.env.DSQL_DB_PASSWORD} ${dbName} > ${filePath}`;
console.log(`exportDb.js exe => ${exe}`);
const dumpDb = execSync(exe, execSyncOptions);
// const file = fs.createWriteStream(filePath);
res.setHeader("Content-Type", "application/zip");
res.setHeader("Content-Disposition", `attachment; filename=export.sql`);
const fileStream = fs.createReadStream(filePath);
/** ********************* Write response header */ fileStream.pipe(res);
// res.pipe(file);
// res.writeHead(200);
// await new Promise((resolve, reject) => {
// file.on("finish", () => {
// // res.pipe(file);
// resolve(true);
// });
// });
// return fs.readFileSync(filePath, "utf-8");
// return file;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
} catch (/** @type {any} */ error) {
serverError({
component: "/functions/backend/exportDb/lines-30-46",
message: error.message,
user: user
});
}
}; /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
/***/ })
};
;
+137
View File
@@ -0,0 +1,137 @@
"use strict";
exports.id = 424;
exports.ids = [424];
exports.modules = {
/***/ 424:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Z": () => (/* binding */ Breadcrumbs)
/* 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 {any} [props.confirmedDelegetedUser]
* @param {any} [props.linksArray]
* @param {import("@/package-shared/types").UserType} [props.user]
*/ function Breadcrumbs({ confirmedDelegetedUser , linksArray , user , }) {
/**
* Get Contexts
*
* @abstract { React.useContext }
*/ ////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Javascript Variables
*
* @abstract Non hook variables and functions
*/ const isDelegated = confirmedDelegetedUser?.delegated;
const isTableEditable = confirmedDelegetedUser?.priviledges?.match(/Edit Tables/i);
const isTableDeletable = confirmedDelegetedUser?.priviledges?.match(/Delete Tables/i);
const isTableCreatable = confirmedDelegetedUser?.priviledges?.match(/Create Tables/i);
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* React Hooks
*
* @abstract { useState, useEffect, useRef, etc ... }
*/ /** @type {any} */ const linksState = react__WEBPACK_IMPORTED_MODULE_1___default().useState(linksArray ? linksArray : null);
/** @type { [ links:any[], setLinks: React.Dispatch<React.SetStateAction<any[]>> ] } */ const [links, setLinks] = linksState;
react__WEBPACK_IMPORTED_MODULE_1___default().useEffect(()=>{
if (linksArray) return;
let pathname = window.location.pathname;
let pathLinks = pathname.split("/");
let validPathLinks = [];
validPathLinks.push({
title: "Home",
path: pathname.match(/admin/) ? "/admin" : "/"
});
const isDelegated = window.location.search?.match(/delegated=true/);
pathLinks.forEach((linkText, index, array)=>{
if (!linkText?.match(/./) || index == 1) {
return;
}
if (linkText.match(/^\d+$/) && user) {
// validPathLinks.push({
// title: user.first_name,
// path: `/admin/${linkText}`,
// });
return;
}
validPathLinks.push({
title: linkText,
path: (()=>{
let path = "";
for(let i = 0; i < array.length; i++){
const lnText = array[i];
if (i > index || !lnText.match(/./)) continue;
path += `/${lnText}`;
}
return path;
})()
});
});
setLinks(validPathLinks);
}, []);
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Function Return
*
* @abstract Main Function Return
*/ if (!links || !links[1]) {
return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx((react__WEBPACK_IMPORTED_MODULE_1___default().Fragment), {});
}
return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
className: "text-sm mt-2 flex-wrap",
children: links.map((linkObject, index, array)=>{
if (index === links.length - 1) {
return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("a", {
href: linkObject.path,
className: "text-slate-400 dark:text-slate-500 pointer-events-none",
children: linkObject.title
}, index);
} else {
return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)((react__WEBPACK_IMPORTED_MODULE_1___default().Fragment), {
children: [
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("a", {
href: linkObject.path,
className: "query-url",
children: linkObject.title
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("span", {
className: "opacity-20",
children: "|"
})
]
}, index);
}
})
});
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
} /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
/***/ })
};
;
@@ -0,0 +1,67 @@
"use strict";
exports.id = 4294;
exports.ids = [4294];
exports.modules = {
/***/ 4294:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const generator = __webpack_require__(3785);
const DB_HANDLER = __webpack_require__(2224);
const NO_DB_HANDLER = __webpack_require__(7487);
const encrypt = __webpack_require__(7547);
const addDbEntry = __webpack_require__(5338);
/**
* # Add Mariadb User
*
* @description this function adds a Mariadb user to the database server
*
* @param {object} params - parameters object *
* @param {number | string} params.userId - invited user object
*
* @returns {Promise<any>} new user auth object payload
*/ module.exports = async function addMariadbUser({ userId }) {
try {
const defaultMariadbUserHost = process.env.DSQL_DB_HOST || "127.0.0.1";
const username = `dsql_user_${userId}`;
const password = generator.generate({
length: 16,
numbers: true,
symbols: true,
uppercase: true,
exclude: "*#.'`\""
});
const encryptedPassword = encrypt(password);
await NO_DB_HANDLER(`CREATE USER IF NOT EXISTS '${username}'@'127.0.0.1' IDENTIFIED BY '${password}' REQUIRE SSL`);
const updateUser = await DB_HANDLER(`UPDATE users SET mariadb_user = ?, mariadb_host = '127.0.0.1', mariadb_pass = ? WHERE id = ?`, [
username,
encryptedPassword,
userId
]);
const addMariadbUser1 = await addDbEntry({
tableName: "mariadb_users",
data: {
user_id: userId,
username,
host: defaultMariadbUserHost,
password: encryptedPassword,
primary: "1",
grants: '[{"database":"*","table":"*","privileges":["ALL"]}]'
},
dbContext: "Master"
});
console.log(`User ${userId} SQL credentials successfully added.`);
} catch (/** @type {any} */ error) {
console.log(`Error in adding SQL user in 'addMariadbUser' function =>`, error.message);
}
}; ////////////////////////////////////////////////
////////////////////////////////////////////////
////////////////////////////////////////////////
/***/ })
};
;
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,37 @@
"use strict";
exports.id = 4432;
exports.ids = [4432];
exports.modules = {
/***/ 4432:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const { IncomingMessage } = __webpack_require__(3685);
const decrypt = __webpack_require__(5425);
/**
* @async
* @param {import("next").NextApiRequest | IncomingMessage & { cookies: Partial<{ [key: string]: string; }>} } req - https request object
*
* @returns {Promise<({ email: string, password: string, authKey: string, logged_in_status: boolean, date: number } | null)>}
*/ module.exports = async function(req) {
/** ********************* Check for existence of required cookie */ if (!req.cookies?.datasquirelSuAdminUserAuthKey) {
return null;
}
/** ********************* Grab the payload */ let userPayload = decrypt(req.cookies.datasquirelSuAdminUserAuthKey);
/** ********************* Return if no payload */ if (!userPayload) return null;
/** ********************* Parse the payload */ let userObject = JSON.parse(userPayload);
if (userObject.password !== process.env.DSQL_USER_KEY) return null;
if (userObject.authKey !== process.env.DSQL_SPECIAL_KEY) return null;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/** ********************* return user object */ return userObject;
};
/***/ })
};
;
@@ -0,0 +1,89 @@
"use strict";
exports.id = 4598;
exports.ids = [4598];
exports.modules = {
/***/ 4598:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Z": () => (/* binding */ FadedImage)
/* 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 {{
* src: string,
* alt?: string,
* className?: string,
* fadeHeight?: string,
* width?: number,
* height?: number,
* opacity?: number
* }} props - Server props
*/ function FadedImage({ src , alt , className , fadeHeight , width , height , opacity , }) {
/**
* 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: "overflow-hidden z-0" + (className ? " " + className : ""),
children: [
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("img", {
src: src,
alt: alt,
className: "w-full h-full object-cover",
width: width,
height: height
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
className: "fade-side",
style: {
height: fadeHeight
}
})
]
});
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
} /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
/***/ })
};
;
+172
View File
@@ -0,0 +1,172 @@
"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);
/***/ })
};
;
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,86 @@
"use strict";
exports.id = 4986;
exports.ids = [4986];
exports.modules = {
/***/ 4986:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Z": () => (/* binding */ ActiveCloneDbBanner)
/* 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
* @param {object} props.database
* @param {string} props.database.active_clone_parent_db
* @param {import("@/package-shared/types").UserType} props.user
*/ function ActiveCloneDbBanner({ database , user }) {
/**
* Get Contexts
*
* @abstract { React.useContext }
*/ ////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Javascript Variables
*
* @abstract Non hook variables and functions
*/ ////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* React Hooks
*
* @abstract { useState, useEffect, useRef, etc ... }
*/ const parentDbSlug = database.active_clone_parent_db?.replace(/datasquirel_user_\d+_/, "");
const targetDbUrl = `/admin/${user?.id}/databases/${parentDbSlug}`;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Function Return
*
* @abstract Main Function Return
*/ return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
className: "info green",
children: /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("span", {
className: "text font-normal",
children: [
"This database is an active clone of",
" ",
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("b", {
children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("a", {
href: targetDbUrl,
target: "_blank",
className: "query-url",
children: parentDbSlug
})
})
]
})
});
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
} /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
/***/ })
};
;
+424
View File
@@ -0,0 +1,424 @@
"use strict";
exports.id = 5114;
exports.ids = [5114];
exports.modules = {
/***/ 5114:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
// EXPORTS
__webpack_require__.d(__webpack_exports__, {
"Z": () => (/* binding */ CreateAccountForm)
});
// 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: ./functions/frontend/fetchApi.js
var fetchApi = __webpack_require__(6729);
;// CONCATENATED MODULE: ./functions/frontend/submitNewUserForm.js
// @ts-check
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
* # Submit New Image Form
* @param {object} param0
* @param {*} param0.e
* @param {React.Dispatch<React.SetStateAction<boolean>>} param0.setLoading
* @param {import("@/package-shared/types").UserType} [param0.user]
* @param {*} [param0.image]
* @param {*} [param0.query]
*/ async function submitNewUserForm({ e , setLoading , user , image , query , }) {
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
setLoading(true);
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
let formBody = {
first_name: e.target["first_name"].value,
last_name: e.target["last_name"].value,
email: user ? null : e.target["email_address"].value,
username: user ? null : e.target["username"].value,
password: user ? null : e.target["password"].value,
image: image ? image : null
};
// @ts-ignore
if (query?.invite) formBody["inviteObject"] = query;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
const apiRoute = user ? "/api/updateUser" : "/api/registerUser";
(0,fetchApi/* default */.Z)(apiRoute, {
method: "post",
body: formBody
}, user ? true : false).then((res)=>{
console.log(res);
if (!user && res?.insertId) {
localStorage.setItem("id", res.insertId);
(0,fetchApi/* default */.Z)("/api/loginUser", {
method: "post",
body: {
email: formBody.email,
password: formBody.password
}
}).then((_res)=>{
console.log(_res);
localStorage.setItem("csrf", _res.user.csrf_k);
localStorage.setItem("stripe_id", _res.user.stripe_id);
localStorage.setItem("user", JSON.stringify(_res.userPayload));
window.location.href = "/admin";
});
} else if (user && res?.user) {
// fetchApi("/api/reauthUser")
window.location.reload();
} else if (res?.msg) {
alert(res.msg);
}
}).catch((err)=>{
console.log(err);
}).finally(()=>{
setTimeout(()=>{
setLoading(false);
}, 2000);
});
} /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
// EXTERNAL MODULE: ./components/general/FormAlertBlock.jsx
var FormAlertBlock = __webpack_require__(7037);
// EXTERNAL MODULE: ./components/general/LoadingBlock.jsx
var LoadingBlock = __webpack_require__(5264);
// EXTERNAL MODULE: ./components/pages/login/SocialLogin.jsx + 3 modules
var SocialLogin = __webpack_require__(8374);
;// CONCATENATED MODULE: ./components/pages/create-account/CreateAccountForm.jsx
// @ts-check
/**
* ==============================================================================
* Imports
* ==============================================================================
*/
////////////////////////////////////////
////////////////////////////////////////
/** @type {any} */ let timeout;
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
* ==============================================================================
* Main Component { Functional }
* ==============================================================================
* @param {Object} props - Server props
* @param {import("@/package-shared/types").UserType} [props.user]
* @param {import("@/package-shared/types").CreateAccountQueryType} [props.query]
* @param {any} [props.image]
*/ function CreateAccountForm({ user , query , image }) {
/**
* Get Contexts
*
* @abstract { React.useContext }
*/ ////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Javascript Variables
*
* @abstract Non hook variables and functions
*/ const defaultEmail = query?.email ? query.email : user?.email ? user.email : "";
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* React Hooks
*
* @abstract { useState, useEffect, useRef, etc ... }
*/ /** @type {[ alert: string | null, setAlert: React.Dispatch<React.SetStateAction<string | null>> ]} */ // @ts-ignore
const [alert, setAlert] = external_react_default().useState(null);
const [loading, setLoading] = external_react_default().useState(false);
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Function Return
*
* @abstract Main Function Return
*/ return /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
className: "relative w-full max-w-2xl flex-col items-start",
children: [
loading && /*#__PURE__*/ jsx_runtime_.jsx(LoadingBlock/* default */.Z, {}),
!user && /*#__PURE__*/ (0,jsx_runtime_.jsxs)((external_react_default()).Fragment, {
children: [
/*#__PURE__*/ jsx_runtime_.jsx("hr", {
className: "opacity-0"
}),
/*#__PURE__*/ jsx_runtime_.jsx(SocialLogin/* default */.Z, {
user: null,
userType: "admin",
setLoading: setLoading
}),
/*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
className: "w-full justify-center relative",
children: [
/*#__PURE__*/ jsx_runtime_.jsx("span", {
className: "bg-white dark:bg-slate-800 px-3 relative z-10",
children: "OR"
}),
/*#__PURE__*/ jsx_runtime_.jsx("hr", {
className: "absolute"
})
]
})
]
}),
/*#__PURE__*/ (0,jsx_runtime_.jsxs)("form", {
className: "w-full flex flex-col items-start gap-4 relative",
onSubmit: (e)=>{
e.preventDefault();
submitNewUserForm({
e,
setLoading,
user,
image,
query
});
},
children: [
alert && /*#__PURE__*/ jsx_runtime_.jsx(FormAlertBlock/* default */.Z, {
message: alert
}),
/*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
className: "flex flex-col items-start gap-0.5 w-full",
children: [
/*#__PURE__*/ jsx_runtime_.jsx("label", {
htmlFor: "first_name",
children: "First Name"
}),
/*#__PURE__*/ jsx_runtime_.jsx("input", {
type: "text",
name: "first_name",
id: "first_name",
placeholder: "First Name",
autoComplete: "given-name",
onInput: (e)=>{
/** @type {HTMLInputElement} */ // @ts-ignore
const inputEl = e.target;
if (inputEl.value.match(/./)) {
inputEl.classList.remove("warning");
setAlert(null);
} else {
inputEl.classList.add("warning");
}
},
defaultValue: user ? user.first_name : "",
required: true
})
]
}),
/*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
className: "flex flex-col items-start gap-0.5 w-full",
children: [
/*#__PURE__*/ jsx_runtime_.jsx("label", {
htmlFor: "last_name",
children: "Last Name"
}),
/*#__PURE__*/ jsx_runtime_.jsx("input", {
type: "text",
name: "last_name",
id: "last_name",
placeholder: "Last Name",
autoComplete: "family-name",
onInput: (e)=>{
/** @type {HTMLInputElement} */ // @ts-ignore
const inputEl = e.target;
if (inputEl.value.match(/./)) {
inputEl.classList.remove("warning");
setAlert(null);
} else {
inputEl.classList.add("warning");
}
},
defaultValue: user ? user.last_name : "",
required: true
})
]
}),
/*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
className: "flex flex-col items-start gap-0.5 w-full",
children: [
/*#__PURE__*/ jsx_runtime_.jsx("label", {
htmlFor: "username",
children: "Username"
}),
/*#__PURE__*/ jsx_runtime_.jsx("input", {
type: "text",
name: "username",
id: "username",
placeholder: "Username",
autoComplete: "username",
onInput: (e)=>{
/** @type {HTMLInputElement} */ // @ts-ignore
const inputEl = e.target;
if (inputEl.value.match(/./)) {
inputEl.classList.remove("warning");
setAlert(null);
} else {
inputEl.classList.add("warning");
}
window.clearTimeout(timeout);
timeout = setTimeout(()=>{
(0,fetchApi/* default */.Z)(`/api/checkDuplicateData?type=username&value=${inputEl.value}&tableName=users`).then((res)=>{
console.log(res);
if (res?.result) {
setAlert("Username Already Exists");
inputEl.classList.add("warning");
} else {
setAlert(null);
inputEl.classList.remove("warning");
}
});
}, 300);
},
defaultValue: user ? user.username : "",
required: user ? false : true,
readOnly: user ? true : false
})
]
}),
/*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
className: "flex flex-col items-start gap-0.5 w-full",
children: [
/*#__PURE__*/ jsx_runtime_.jsx("label", {
htmlFor: "email_address",
children: "Email Address"
}),
/*#__PURE__*/ jsx_runtime_.jsx("input", {
type: "email",
name: "email_address",
id: "email_address",
placeholder: "Email Address",
autoComplete: "email",
onInput: (e)=>{
/** @type {HTMLInputElement} */ // @ts-ignore
const inputEl = e.target;
window.clearTimeout(timeout);
timeout = setTimeout(()=>{
(0,fetchApi/* default */.Z)(`/api/checkDuplicateData?type=email&value=${inputEl.value}&tableName=users`).then((res)=>{
console.log(res);
if (res?.result) {
setAlert("Email Already Exists");
inputEl.classList.add("warning");
} else {
setAlert(null);
inputEl.classList.remove("warning");
}
});
}, 300);
},
defaultValue: defaultEmail,
required: true,
readOnly: user ? true : false
})
]
}),
!user && /*#__PURE__*/ (0,jsx_runtime_.jsxs)((external_react_default()).Fragment, {
children: [
/*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
className: "flex flex-col items-start gap-0.5 w-full",
children: [
/*#__PURE__*/ jsx_runtime_.jsx("label", {
htmlFor: "password",
children: "Password"
}),
/*#__PURE__*/ jsx_runtime_.jsx("input", {
type: "password",
name: "password",
id: "password",
placeholder: "Password",
required: true
})
]
}),
/*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
className: "flex flex-col items-start gap-0.5 w-full",
children: [
/*#__PURE__*/ jsx_runtime_.jsx("label", {
htmlFor: "confirm_password",
children: "Confirm Password"
}),
/*#__PURE__*/ jsx_runtime_.jsx("input", {
type: "password",
name: "confirm_password",
id: "confirm_password",
placeholder: "Confirm Password",
onInput: (e)=>{
/** @type {HTMLInputElement} */ // @ts-ignore
const inputEl = e.target;
let passwordInput = inputEl.closest("form")?.["password"].value;
let passwordRepeatInput = inputEl.value;
if (passwordInput === passwordRepeatInput) {
inputEl.classList.remove("warning");
} else {
inputEl.classList.add("warning");
}
},
required: true
})
]
}),
/*#__PURE__*/ (0,jsx_runtime_.jsxs)("span", {
className: "text-sm",
children: [
'By clicking "Create Account" you agree to our',
" ",
/*#__PURE__*/ jsx_runtime_.jsx("a", {
href: "/terms",
target: "_blank",
className: "font-bold",
children: "Terms and Conditions"
})
]
})
]
}),
/*#__PURE__*/ jsx_runtime_.jsx("button", {
type: "submit",
className: "w-full",
children: user ? /*#__PURE__*/ jsx_runtime_.jsx("span", {
children: "Update Account Info"
}) : /*#__PURE__*/ jsx_runtime_.jsx("span", {
children: "Create Account"
})
}),
!user && /*#__PURE__*/ jsx_runtime_.jsx((external_react_default()).Fragment, {
children: /*#__PURE__*/ (0,jsx_runtime_.jsxs)("span", {
className: "text-sm",
children: [
"Already Have an Account?",
" ",
/*#__PURE__*/ jsx_runtime_.jsx("a", {
href: "/login",
className: "font-bold",
children: "Login"
})
]
})
})
]
})
]
});
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
} /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
/***/ })
};
;
@@ -0,0 +1,99 @@
"use strict";
exports.id = 5116;
exports.ids = [5116];
exports.modules = {
/***/ 5116:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
/**
* ==============================================================================
* Imports
* ==============================================================================
*/
const http = __webpack_require__(3685);
const decrypt = __webpack_require__(5304);
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
* @typedef {object} grabDelegatedUserFromCookieReturn
* @property {number} dbUserId
* @property {number} [dbUserId]
* @property {number} [rootUserId]
* @property {string} [rootUserName]
* @property {string} [rootUserEmail]
* @property {string} [rootUserImage]
* @property {string} [databaseFullName]
* @property {string} [databaseSlug]
* @property {string[]} [allowedTables]
* @property {string} [priviledges]
* @property {string} [database]
* @property {boolean} [delegated]
*/ /**
* @param {object} params - user id
* @param {import("next").NextApiRequest | http.IncomingMessage & { cookies: Partial<{ [key: string]: string; }>}} params.request - HTTPS request object
* @param {string | string[]} params.databaseSlug - Database name slug
* @param {{ id: number, first_name: string, last_name: string }} params.user
* @param {any} params.query - query params
*
* @returns {Promise<grabDelegatedUserFromCookieReturn | null>} new user auth object payload
*/ module.exports = async function grabDelegatedUserFromCookie({ request , databaseSlug , user , query , }) {
try {
/**
* Fetch user
*
* @description Fetch user from db
*/ let dbUserId = user.id;
let delegatedUserObject = null;
if (!query?.delegated) return {
dbUserId
};
const rootUserId = query.dbUserId;
const dbFullName = `${process.env.DSQL_USER_DB_PREFIX}${rootUserId}_${databaseSlug}`;
const tokenName = `${process.env.DSQL_USER_DELEGATED_DB_COOKIE_PREFIX}${dbFullName}`;
try {
if (!request.cookies?.[tokenName]) throw new Error("Cookie not present");
// @ts-ignore
const decryptedToken = decrypt(request.cookies[tokenName]);
if (!decryptedToken) throw new Error("Invalid Token");
delegatedUserObject = JSON.parse(decryptedToken);
if (delegatedUserObject.databaseSlug === databaseSlug) {
dbUserId = delegatedUserObject.rootUserId;
return {
dbUserId: dbUserId,
rootUserId: delegatedUserObject.rootUserId,
rootUserName: delegatedUserObject.rootUserName,
rootUserEmail: delegatedUserObject.rootUserEmail,
rootUserImage: delegatedUserObject.rootUserImage,
databaseFullName: delegatedUserObject.databaseFullName,
databaseSlug: delegatedUserObject.databaseSlug,
allowedTables: delegatedUserObject.allowedTables,
priviledges: delegatedUserObject.priviledges,
database: delegatedUserObject.databaseSlug,
delegated: true
};
}
} catch (error) {
// serverError({
// component: "grabDelegatedUserFromCookie",
// message: error.message,
// user: user,
// });
}
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
return {
dbUserId
};
} catch (error1) {
return null;
}
}; ////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/***/ })
};
;
@@ -0,0 +1,63 @@
"use strict";
exports.id = 5264;
exports.ids = [5264];
exports.modules = {
/***/ 5264:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Z": () => (/* binding */ LoadingBlock)
/* 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
* ==============================================================================
*/
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
* Loading Block Functional Component
* ==============================================================================
* @param {{
* width?: string,
* position?: *,
* style?: import("react").CSSProperties,
* borderWidth?: string,
* screen?: boolean,
* title?: string,
* }} props - React Component Props
*/ function LoadingBlock({ width , position , style , borderWidth , screen , title , }) {
return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
className: " top-0 left-0 w-full h-full flex items-center justify-center gap-4 bg-white/80 dark:bg-slate-800/80 z-50" + (screen ? " fixed" : " absolute"),
style: {
...style,
position: position,
zIndex: 20000
},
children: [
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("span", {
className: "general_loader",
style: width ? {
width: width,
height: width,
minWidth: width,
borderWidth: borderWidth ? borderWidth : "4px"
} : {}
}),
title ? /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("span", {
children: title
}) : /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx((react__WEBPACK_IMPORTED_MODULE_1___default().Fragment), {})
]
});
} /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
/***/ })
};
;
@@ -0,0 +1,46 @@
"use strict";
exports.id = 5304;
exports.ids = [5304];
exports.modules = {
/***/ 5304:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const { scryptSync , createDecipheriv } = __webpack_require__(6113);
const { Buffer } = __webpack_require__(4300);
// const serverError = require("./serverError");
/**
* @param {string} encryptedString
* @returns {string | null}
*/ const decrypt = (encryptedString)=>{
// /** @type {import("crypto").CipherCCMTypes} */
const algorithm = "aes-192-cbc";
const password = process.env.DSQL_ENCRYPTION_PASSWORD || "";
const salt = process.env.DSQL_ENCRYPTION_SALT || "";
// /** @type {import("crypto").CipherKey} */
let key = scryptSync(password, salt, 24);
let iv = Buffer.alloc(16, 0);
// @ts-ignore
const decipher = createDecipheriv(algorithm, key, iv);
/** ********************* Decrypt String */ try {
let decrypted = decipher.update(encryptedString, "hex", "utf8");
decrypted += decipher.final("utf8");
return decrypted;
} catch (error) {
// serverError({
// component: "decrypt",
// message: error.message,
// user: {},
// });
return null;
}
};
module.exports = decrypt;
/***/ })
};
;
File diff suppressed because it is too large Load Diff
+176
View File
@@ -0,0 +1,176 @@
"use strict";
exports.id = 5338;
exports.ids = [5338];
exports.modules = {
/***/ 5338:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
/**
* Imports: Handle imports
*/
const encrypt = __webpack_require__(7547);
const sanitizeHtml = __webpack_require__(6109);
const sanitizeHtmlOptions = __webpack_require__(9544);
const updateDb = __webpack_require__(5886);
const updateDbEntry = __webpack_require__(5886);
const _ = __webpack_require__(6517);
const DB_HANDLER = __webpack_require__(2224);
const DSQL_USER_DB_HANDLER = __webpack_require__(3403);
/**
* Add a db Entry Function
* ==============================================================================
* @description Description
* @async
*
* @param {object} params - An object containing the function parameters.
* @param {("Master" | "Dsql User")} [params.dbContext] - What is the database context? "Master"
* or "Dsql User". Defaults to "Master"
* @param {("Read Only" | "Full Access")} [params.paradigm] - What is the paradigm for "Dsql User"?
* "Read only" or "Full Access"? Defaults to "Read Only"
* @param {string} [params.dbFullName] - Database full name
* @param {string} params.tableName - Table name
* @param {any} params.data - Data to add
* @param {import("../../../types").DSQL_TableSchemaType} [params.tableSchema] - Table schema
* @param {string} [params.duplicateColumnName] - Duplicate column name
* @param {string} [params.duplicateColumnValue] - Duplicate column value
* @param {boolean} [params.update] - Update this row if it exists
* @param {string} [params.encryptionKey] - Update this row if it exists
* @param {string} [params.encryptionSalt] - Update this row if it exists
*
* @returns {Promise<any>}
*/ async function addDbEntry({ dbContext , paradigm , dbFullName , tableName , data , tableSchema , duplicateColumnName , duplicateColumnValue , update , encryptionKey , encryptionSalt , }) {
/**
* Initialize variables
*/ const isMaster = dbContext?.match(/dsql.user/i) ? false : dbFullName && !dbFullName.match(/^datasquirel$/) ? false : true;
/** @type { any } */ const dbHandler = isMaster ? DB_HANDLER : DSQL_USER_DB_HANDLER;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
if (data?.["date_created_timestamp"]) delete data["date_created_timestamp"];
if (data?.["date_updated_timestamp"]) delete data["date_updated_timestamp"];
if (data?.["date_updated"]) delete data["date_updated"];
if (data?.["date_updated_code"]) delete data["date_updated_code"];
if (data?.["date_created"]) delete data["date_created"];
if (data?.["date_created_code"]) delete data["date_created_code"];
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Handle function logic
*/ if (duplicateColumnName && typeof duplicateColumnName === "string") {
const duplicateValue = isMaster ? await dbHandler(`SELECT * FROM \`${tableName}\` WHERE \`${duplicateColumnName}\`=?`, [
duplicateColumnValue
]) : await dbHandler({
paradigm: "Read Only",
database: dbFullName,
queryString: `SELECT * FROM \`${tableName}\` WHERE \`${duplicateColumnName}\`=?`,
queryValues: [
duplicateColumnValue
]
});
if (duplicateValue?.[0] && !update) {
return null;
} else if (duplicateValue && duplicateValue[0] && update) {
return await updateDbEntry({
dbContext,
paradigm,
dbFullName,
tableName,
data,
tableSchema,
encryptionKey,
encryptionSalt,
identifierColumnName: duplicateColumnName,
identifierValue: duplicateColumnValue || ""
});
}
}
/**
* Declare variables
*
* @description Declare "results" variable
*/ const dataKeys = Object.keys(data);
let insertKeysArray = [];
let insertValuesArray = [];
for(let i = 0; i < dataKeys.length; i++){
try {
const dataKey = dataKeys[i];
// @ts-ignore
let value = data?.[dataKey];
const targetFieldSchemaArray = tableSchema ? tableSchema?.fields?.filter((field)=>field.fieldName == dataKey) : null;
const targetFieldSchema = targetFieldSchemaArray && targetFieldSchemaArray[0] ? targetFieldSchemaArray[0] : null;
if (value == null || value == undefined) continue;
if (targetFieldSchema?.encrypted) {
value = encrypt(value, encryptionKey, encryptionSalt);
console.log("DSQL: Encrypted value =>", value);
}
if (targetFieldSchema?.richText) {
value = sanitizeHtml(value, sanitizeHtmlOptions);
}
if (targetFieldSchema?.pattern) {
const pattern = new RegExp(targetFieldSchema.pattern, targetFieldSchema.patternFlags || "");
if (!pattern.test(value)) {
console.log("DSQL: Pattern not matched =>", value);
value = "";
}
}
insertKeysArray.push("`" + dataKey + "`");
if (typeof value === "object") {
value = JSON.stringify(value);
}
if (typeof value == "number") {
insertValuesArray.push(String(value));
} else {
insertValuesArray.push(value);
}
} catch (/** @type {any} */ error) {
console.log("DSQL: Error in parsing data keys =>", error.message);
continue;
}
}
////////////////////////////////////////
if (!data?.["date_created"]) {
insertKeysArray.push("`date_created`");
insertValuesArray.push(Date());
}
if (!data?.["date_created_code"]) {
insertKeysArray.push("`date_created_code`");
insertValuesArray.push(Date.now());
}
////////////////////////////////////////
if (!data?.["date_updated"]) {
insertKeysArray.push("`date_updated`");
insertValuesArray.push(Date());
}
if (!data?.["date_updated_code"]) {
insertKeysArray.push("`date_updated_code`");
insertValuesArray.push(Date.now());
}
////////////////////////////////////////
const query = `INSERT INTO \`${tableName}\` (${insertKeysArray.join(",")}) VALUES (${insertValuesArray.map(()=>"?").join(",")})`;
const queryValuesArray = insertValuesArray;
const newInsert = isMaster ? await dbHandler(query, queryValuesArray) : await dbHandler({
paradigm,
database: dbFullName,
queryString: query,
queryValues: queryValuesArray
});
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Return statement
*/ return newInsert;
}
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
module.exports = addDbEntry;
/***/ })
};
;
@@ -0,0 +1,46 @@
"use strict";
exports.id = 5425;
exports.ids = [5425];
exports.modules = {
/***/ 5425:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const { scryptSync , createDecipheriv } = __webpack_require__(6113);
const { Buffer } = __webpack_require__(4300);
// const serverError = require("./serverError");
/**
* @param {string} encryptedString
* @returns {string | null}
*/ const decrypt = (encryptedString)=>{
// /** @type {import("crypto").CipherCCMTypes} */
const algorithm = "aes-192-cbc";
const password = process.env.DSQL_ENCRYPTION_PASSWORD || "";
const salt = process.env.DSQL_ENCRYPTION_SALT || "";
// /** @type {import("crypto").CipherKey} */
let key = scryptSync(password, salt, 24);
let iv = Buffer.alloc(16, 0);
// @ts-ignore
const decipher = createDecipheriv(algorithm, key, iv);
/** ********************* Decrypt String */ try {
let decrypted = decipher.update(encryptedString, "hex", "utf8");
decrypted += decipher.final("utf8");
return decrypted;
} catch (error) {
// serverError({
// component: "decrypt",
// message: error.message,
// user: {},
// });
return null;
}
};
module.exports = decrypt;
/***/ })
};
;
+105
View File
@@ -0,0 +1,105 @@
"use strict";
exports.id = 5449;
exports.ids = [5449];
exports.modules = {
/***/ 5449:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Z": () => (/* binding */ ButtonGroup)
/* 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 {{
* children: React.ReactNode,
* column?: boolean,
* className?: string,
* }} props - React component props including { children }
*/ function ButtonGroup({ children , column , className }) {
/**
* Get Contexts
*
* @abstract { React.useContext }
*/ ////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Javascript Variables
*
* @abstract Non hook variables and functions
*/ ////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* React Hooks
*
* @abstract { useState, useEffect, useRef, etc ... }
*/ const btnGroupRef = react__WEBPACK_IMPORTED_MODULE_1___default().useRef();
react__WEBPACK_IMPORTED_MODULE_1___default().useEffect(()=>{
try {
/** @type {HTMLDivElement & *} */ const buttonGroupWrapper = btnGroupRef.current;
/** @type {any} */ const children = buttonGroupWrapper.childNodes;
const allAvailableBtns = Array.from(children);
if (allAvailableBtns?.length === 1) return;
allAvailableBtns.forEach((btn, index)=>{
let targetElement = btn;
if (targetElement.classList.contains("dropdown-wrapper")) {
const targetClild = Array.from(btn.childNodes).filter((node)=>node?.nodeName?.match(/button/i) || node.classList.contains("button"));
if (targetClild && targetClild[0]) {
targetElement = targetClild[0];
}
}
const targetBorderSide = column ? "borderTop" : "borderLeft";
const targetBorderRadiusStart = column ? "borderBottomRightRadius" : "borderTopRightRadius";
const targetBorderRadiusEnd = column ? "borderBottomLeftRadius" : "borderBottomRightRadius";
const targetBorderOppositeRadiusStart = column ? "borderTopRightRadius" : "borderTopLeftRadius";
const targetBorderOppositeRadiusEnd = column ? "borderTopLeftRadius" : "borderBottomLeftRadius";
if (index < allAvailableBtns.length - 1) {
targetElement.style[targetBorderRadiusStart] = 0;
targetElement.style[targetBorderRadiusEnd] = 0;
}
if (index > 0) {
targetElement.style[targetBorderSide] = "none";
targetElement.style[targetBorderOppositeRadiusStart] = 0;
targetElement.style[targetBorderOppositeRadiusEnd] = 0;
}
});
} catch (/** @type {any} */ error) {
console.log(error.message);
}
}, []);
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Function Return
*
* @abstract Main Function Return
*/ return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
className: "items-stretch gap-0" + (column ? " flex-col" : " flex-wrap xl:flex-nowrap") + (className ? " " + className : ""),
// @ts-ignore
ref: btnGroupRef,
children: children
});
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
}
/***/ })
};
;
+184
View File
@@ -0,0 +1,184 @@
"use strict";
exports.id = 5472;
exports.ids = [5472];
exports.modules = {
/***/ 5472:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Mw": () => (/* binding */ openPopup),
/* harmony export */ "ZP": () => (/* binding */ GeneralPopup),
/* harmony export */ "j4": () => (/* binding */ closePopup)
/* 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 lucide_react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2423);
/* harmony import */ var lucide_react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(lucide_react__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6689);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_2__);
// @ts-check
/**
* ==============================================================================
* Imports
* ==============================================================================
*/
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
* ==============================================================================
* Main Component { Functional }
* ==============================================================================
* @param {Object} props - React component props including { children }
* @param {React.ReactNode} props.children - React children
* @param {string} props.title - Popup title
* @param {Object} [props.data] - data to pass in the "data-data" attribute as JSON
* @param {boolean} [props.fullPage] - If the popup will span the full screen
* @param {string} [props.wrapperClasses] - Popup wrapper additional class names
* @param {() => void} [props.closePopupDispatch] - Function to run when popup is closed
* @param {React.CSSProperties} [props.wrapperStyle] - React styles for the popup wrapper
* @param {boolean} [props.noContainer] - If no container should be provided
*/ function GeneralPopup({ children , title , data , fullPage , wrapperClasses , closePopupDispatch , wrapperStyle , noContainer , }) {
/**
* Get Contexts
*
* @description { React.useContext }
*/ ////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Javascript Variables
*
* @description Non hook variables and functions
*/ ////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* React Hooks
*
* @description { useState, useEffect, useRef, etc ... }
*/ ////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Function Return
*
* @description Main Function Return
*/ if (fullPage) {
return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
className: "popup-bg overflow-hidden " + (wrapperClasses ? wrapperClasses : ""),
"data-popupid": title ? title : null,
style: wrapperStyle,
children: [
noContainer ? /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx((react__WEBPACK_IMPORTED_MODULE_2___default().Fragment), {
children: children
}) : /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
className: "relative w-full h-full z-50",
"data-data": data ? JSON.stringify(data) : "",
children: children
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("button", {
className: "popup-cancel-button fixed outlined gray",
onClick: (e)=>{
closePopup();
if (closePopupDispatch) closePopupDispatch();
},
children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(lucide_react__WEBPACK_IMPORTED_MODULE_1__.X, {
color: "white",
size: 20
})
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
className: "popup-canceller",
onClick: (e)=>{
closePopup();
closePopupDispatch && closePopupDispatch();
}
})
]
});
}
////////////////////////////////////////
return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
className: "popup-bg",
"data-popupid": title ? title : null,
children: [
noContainer ? /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx((react__WEBPACK_IMPORTED_MODULE_2___default().Fragment), {
children: children
}) : /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
className: "popup-content-container minimal-scrollbars",
"data-data": data ? JSON.stringify(data) : "",
children: [
children,
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("button", {
className: "outlined gray popup-cancel-button",
onClick: (e)=>{
closePopup();
closePopupDispatch && closePopupDispatch();
},
children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("span", {
className: "font-normal",
children: "✖"
})
})
]
}),
noContainer && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("button", {
className: "gray popup-cancel-button",
onClick: (e)=>{
closePopup();
closePopupDispatch && closePopupDispatch();
},
children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("span", {
className: "font-normal",
children: "✖"
})
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
className: "popup-canceller",
onClick: (e)=>{
closePopup();
closePopupDispatch && closePopupDispatch();
}
})
]
});
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
}
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
* ==============================================================================
* Open Popup Function
* ==============================================================================
* @param {string} popupId - popup id
* @param {(popup?: Element) => void} [openPopupDispatch] - Function to run on popup open
*/ function openPopup(popupId, openPopupDispatch) {
let popup = document.querySelector(`[data-popupid='${popupId}']`);
if (popup) {
// @ts-ignore
popup.style.display = "flex";
openPopupDispatch && openPopupDispatch(popup);
}
}
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
* ==============================================================================
* Close Popup Function
* ==============================================================================
* @param {() => void} [closePopupDispatch] - Function to run on popup open
*/ function closePopup(closePopupDispatch) {
document.querySelectorAll(`[data-popupid]`).forEach((popup)=>{
// @ts-ignore
popup.style.display = "none";
});
closePopupDispatch && closePopupDispatch();
}
/***/ })
};
;
+191
View File
@@ -0,0 +1,191 @@
"use strict";
exports.id = 5886;
exports.ids = [5886];
exports.modules = {
/***/ 5886:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
/**
* Imports: Handle imports
*/
const encrypt = __webpack_require__(7547);
const sanitizeHtml = __webpack_require__(6109);
const sanitizeHtmlOptions = __webpack_require__(9544);
const DB_HANDLER = __webpack_require__(2224);
const DSQL_USER_DB_HANDLER = __webpack_require__(3403);
/**
* Update DB Function
* ==============================================================================
* @description Description
* @async
*
* @param {object} params - An object containing the function parameters.
* @param {("Master" | "Dsql User")} [params.dbContext] - What is the database context? "Master"
* or "Dsql User". Defaults to "Master"
* @param {("Read Only" | "Full Access")} [params.paradigm] - What is the paradigm for "Dsql User"?
* "Read only" or "Full Access"? Defaults to "Read Only"
* @param {string} [params.dbFullName] - Database full name
* @param {string} params.tableName - Table name
* @param {string} [params.encryptionKey]
* @param {string} [params.encryptionSalt]
* @param {any} params.data - Data to add
* @param {import("../../../types").DSQL_TableSchemaType} [params.tableSchema] - Table schema
* @param {string} params.identifierColumnName - Update row identifier column name
* @param {string | number} params.identifierValue - Update row identifier column value
*
* @returns {Promise<object|null>}
*/ async function updateDbEntry({ dbContext , paradigm , dbFullName , tableName , data , tableSchema , identifierColumnName , identifierValue , encryptionKey , encryptionSalt , }) {
/**
* Check if data is valid
*/ if (!data || !Object.keys(data).length) return null;
const isMaster = dbContext?.match(/dsql.user/i) ? false : dbFullName && !dbFullName.match(/^datasquirel$/) ? false : true;
/** @type {(a1:any, a2?:any)=> any } */ const dbHandler = isMaster ? DB_HANDLER : DSQL_USER_DB_HANDLER;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Declare variables
*
* @description Declare "results" variable
*/ const dataKeys = Object.keys(data);
let updateKeyValueArray = [];
let updateValues = [];
for(let i = 0; i < dataKeys.length; i++){
try {
const dataKey = dataKeys[i];
// @ts-ignore
let value = data[dataKey];
const targetFieldSchemaArray = tableSchema ? tableSchema?.fields?.filter((field)=>field.fieldName === dataKey) : null;
const targetFieldSchema = targetFieldSchemaArray && targetFieldSchemaArray[0] ? targetFieldSchemaArray[0] : null;
if (value == null || value == undefined) continue;
if (targetFieldSchema?.richText) {
value = sanitizeHtml(value, sanitizeHtmlOptions);
}
if (targetFieldSchema?.encrypted) {
value = encrypt(value, encryptionKey, encryptionSalt);
}
if (typeof value === "object") {
value = JSON.stringify(value);
}
if (targetFieldSchema?.pattern) {
const pattern = new RegExp(targetFieldSchema.pattern, targetFieldSchema.patternFlags || "");
if (!pattern.test(value)) {
console.log("DSQL: Pattern not matched =>", value);
value = "";
}
}
if (typeof value === "string" && value.match(/^null$/i)) {
value = {
toSqlString: function() {
return "NULL";
}
};
}
if (typeof value === "string" && !value.match(/./i)) {
value = {
toSqlString: function() {
return "NULL";
}
};
}
updateKeyValueArray.push(`\`${dataKey}\`=?`);
if (typeof value == "number") {
updateValues.push(String(value));
} else {
updateValues.push(value);
}
////////////////////////////////////////
////////////////////////////////////////
} catch (/** @type {any} */ error) {
////////////////////////////////////////
////////////////////////////////////////
console.log("DSQL: Error in parsing data keys in update function =>", error.message);
continue;
}
}
////////////////////////////////////////
////////////////////////////////////////
updateKeyValueArray.push(`date_updated='${Date()}'`);
updateKeyValueArray.push(`date_updated_code='${Date.now()}'`);
////////////////////////////////////////
////////////////////////////////////////
const query = `UPDATE ${tableName} SET ${updateKeyValueArray.join(",")} WHERE \`${identifierColumnName}\`=?`;
updateValues.push(identifierValue);
const updatedEntry = isMaster ? await dbHandler(query, updateValues) : await dbHandler({
paradigm,
database: dbFullName,
queryString: query,
queryValues: updateValues
});
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Return statement
*/ return updatedEntry;
}
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
module.exports = updateDbEntry;
/***/ }),
/***/ 9544:
/***/ ((module) => {
// @ts-check
const sanitizeHtmlOptions = {
allowedTags: [
"b",
"i",
"em",
"strong",
"a",
"p",
"span",
"ul",
"ol",
"li",
"h1",
"h2",
"h3",
"h4",
"h5",
"h6",
"img",
"div",
"button",
"pre",
"code",
"br"
],
allowedAttributes: {
a: [
"href"
],
img: [
"src",
"alt",
"width",
"height",
"class",
"style"
],
"*": [
"style",
"class"
]
}
};
module.exports = sanitizeHtmlOptions;
/***/ })
};
;
+130
View File
@@ -0,0 +1,130 @@
"use strict";
exports.id = 5910;
exports.ids = [5910];
exports.modules = {
/***/ 5910:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const sharp = __webpack_require__(7441);
const serverError = __webpack_require__(2163);
const grabPaths = __webpack_require__(6715);
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
*
* @param {object} params
* @param {string} params.imageSourceBase64
* @param {string} params.imageName
* @param {any} params.user
* @param {string} [params.mimeType]
* @param {number} [params.thumbnailSize]
* @param {string} [params.folder]
* @param {boolean} [params.isPrivate]
* @returns {Promise<{ urlPath: string, urlThumbnailPath: string, urlRelativePath: string, urlThumbnailRelativePath: string } | undefined | null>}
*/ module.exports = async function fsWriteImageToDiskFromBase64({ imageSourceBase64 , imageName , user , mimeType , thumbnailSize , folder , isPrivate , }) {
try {
const buffer = Buffer.from(imageSourceBase64, "base64");
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
const MAX_SIZE = 1800;
const MAX_SIZE_THUMBNAIL = thumbnailSize ? parseInt(thumbnailSize.toString()) : 400;
// const sharpImage = sharp(imagePath);
const sharpImageRaw = sharp(buffer);
const sharpImageThumbnailRaw = sharp(buffer);
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Construct root paths
*/ const grabedPaths = grabPaths({
isPrivate: isPrivate,
user: user,
folder: folder
});
if (!grabedPaths) {
return null;
}
const { fileRootPath , urlRootPath , relativePath } = grabedPaths;
const imageRootPath = fileRootPath;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Main Image
*
* @description Main Image
*/ let imageMetadataRaw = await sharpImageRaw.metadata();
let { width , height , format } = imageMetadataRaw;
/** @type {keyof import("sharp").FormatEnum} */ // @ts-ignore
const finalFormat = mimeType ? mimeType : format;
if (width && height && width > MAX_SIZE) {
let resizeRatio = MAX_SIZE / width;
sharpImageRaw.resize(MAX_SIZE, Math.round(height * resizeRatio), {
fit: "cover"
});
}
sharpImageRaw.toFormat(finalFormat, {
quality: 80
});
////////////////////////////////////////
let newImageMetadataRaw = await sharpImageRaw.metadata();
////////////////////////////////////////
let imageFullName = `${imageName}.${finalFormat}`;
let imagePath = imageRootPath + imageFullName;
const urlPath = urlRootPath + imageFullName;
const urlRelativePath = relativePath + imageFullName;
await sharpImageRaw.toFile(imagePath);
/**
* Thumbnail
*
* @description Thumbnail
*/ if (width && height && width > MAX_SIZE_THUMBNAIL) {
let resizeRatio1 = MAX_SIZE_THUMBNAIL / width;
sharpImageThumbnailRaw.resize(MAX_SIZE_THUMBNAIL, Math.round(height * resizeRatio1), {
fit: "cover"
});
} else if (width && height) {
const LOWER_THUMBNAIL_SIZE = 150;
let resizeRatio2 = LOWER_THUMBNAIL_SIZE / width;
sharpImageThumbnailRaw.resize(LOWER_THUMBNAIL_SIZE, Math.round(height * resizeRatio2), {
fit: "cover"
});
}
sharpImageThumbnailRaw.toFormat(finalFormat, {
quality: 80
});
////////////////////////////////////////
let imageThumbnailFullName = `${imageName}_thumbnail.${finalFormat}`;
let imageThumbnailPath = imageRootPath + imageThumbnailFullName;
const urlThumbnailPath = urlRootPath + imageThumbnailFullName;
const urlThumbnailRelativePath = relativePath + imageThumbnailFullName;
await sharpImageThumbnailRaw.toFile(imageThumbnailPath);
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
return {
urlPath,
urlThumbnailPath,
urlRelativePath,
urlThumbnailRelativePath
};
// console.log("====================================");
// console.log("Complete!!!");
// console.log("====================================");
} catch (/** @type {any} */ error) {
console.log("Write Image to Disk error =>", error.message);
serverError({
component: "functions/backend/fsWriteImageToDiskFromBase64",
message: error.message
});
return null;
}
}; /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
/***/ })
};
;
+115
View File
@@ -0,0 +1,115 @@
"use strict";
exports.id = 6000;
exports.ids = [6000];
exports.modules = {
/***/ 6000:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Z": () => (/* binding */ DocsAside)
/* 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 {import("@/package-shared/types").DocsAsidePageObject[]} props.pages
*/ function DocsAside({ pages }) {
/**
* Get Contexts
*
* @abstract { React.useContext }
*/ if (!pages || !pages[0]) return null;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Javascript Variables
*
* @abstract Non hook variables and functions
*/ const topLevelPages = pages?.filter((page)=>page.level == 1);
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* React Hooks
*
* @abstract { useState, useEffect, useRef, etc ... }
*/ react__WEBPACK_IMPORTED_MODULE_1___default().useEffect(()=>{
////////////////////////////////////////
/** @type {NodeListOf<HTMLAnchorElement>} */ let asideLinks = document.querySelectorAll("aside a");
if (asideLinks && asideLinks[0]) {
asideLinks.forEach((link)=>{
if (link.pathname === window.location.pathname) {
link.classList.add("active");
}
});
}
}, []);
////////////////////////////////////////
/**
* ## Generate List Function
* @param {import("@/package-shared/types").DocsAsidePageObject[]} cPages
* @param {string} baseUrl
* @returns
*/ function generateList(cPages, baseUrl) {
return cPages.map((page, index)=>{
const url = `${baseUrl}/${page.slug}`;
const childrenPages = pages.filter((pg)=>pg.level == 2 && pg.parent_id == page.id);
return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("li", {
children: [
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("a", {
href: url,
className: page?.level == 1 ? "font-semibold" : "text-slate-600",
children: page.title
}),
childrenPages && childrenPages[0] && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("ul", {
className: "pl-4 gap-2 flex flex-col items-start text-sm mt-2",
children: generateList(childrenPages, url)
})
]
}, index);
});
}
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Function Return
*
* @abstract Main Function Return
*/ return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("aside", {
className: "w-full lg:w-80 p-10 bg-slate-100 dark:bg-slate-800 sticky top-0 overflow-y-auto max-h-max lg:max-h-screen transition-all",
children: [
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("span", {
className: "text-2xl m-0 mb-4 text-left font-semibold",
children: "Docs"
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("ul", {
className: "pl-4 gap-4 flex flex-col items-start",
children: generateList(topLevelPages, "/docs")
})
]
});
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
} /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
/***/ })
};
;
+184
View File
@@ -0,0 +1,184 @@
"use strict";
exports.id = 613;
exports.ids = [613];
exports.modules = {
/***/ 613:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
/**
* ==============================================================================
* Imports
* ==============================================================================
*/
const fs = __webpack_require__(7147);
////////////////////////////////////////////////
////////////////////////////////////////////////
////////////////////////////////////////////////
const datasquirel = __webpack_require__(9538);
const serverError = __webpack_require__(2163);
const DB_HANDLER = __webpack_require__(2224);
const addDbEntry = __webpack_require__(5338);
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
* Add Admin User on Login
* ==============================================================================
*
* @description this function handles admin users that have been invited by another
* admin user. This fires when the invited user has been logged in or a new account
* has been created for the invited user
*
* @param {object} params - parameters object
*
* @param {object} params.query - query object
* @param {number} params.query.invite - Invitation user id
* @param {string} params.query.database_access - String containing authorized databases
* @param {string} params.query.priviledge - String containing databases priviledges
* @param {string} params.query.email - Inviting user email address
*
* @param {import("@/package-shared/types").UserType} params.user - invited user object
*
* @returns {Promise<any>} new user auth object payload
*/ module.exports = async function addAdminUserOnLogin({ query , user }) {
try {
/**
* Fetch user
*
* @description Fetch user from db
*/ // @ts-ignore
const { invite , database_access , priviledge , email } = query;
const lastInviteTimeArray = await DB_HANDLER(`SELECT date_created_code FROM invitations WHERE inviting_user_id=? AND invited_user_email=?`, [
invite,
email
]);
// if (lastInviteTimeArray && lastInviteTimeArray[0]?.date_created_code) {
// const timeSinceLastInvite = Date.now() - parseInt(lastInviteTimeArray[0].date_created_code);
// if (timeSinceLastInvite > 21600000) {
// throw new Error("Invitation expired");
// }
// } else if (!lastInviteTimeArray || !lastInviteTimeArray[0]) {
// throw new Error("No Invitation Found");
// }
if (!lastInviteTimeArray || !lastInviteTimeArray[0]) {
throw new Error("No Invitation Found");
}
////////////////////////////////////////////////
////////////////////////////////////////////////
////////////////////////////////////////////////
// @ts-ignore
const invitingUserDb = await DB_HANDLER(`SELECT first_name,last_name,email FROM users WHERE id=?`, [
invite
]);
if (invitingUserDb?.[0]) {
const existingUserUser = await DB_HANDLER(`SELECT email FROM user_users WHERE user_id=? AND invited_user_id=? AND user_type='admin' AND email=?`, [
invite,
user.id,
email
]);
if (existingUserUser?.[0]) {
console.log("User already added");
} else {
// const newUserUser = await DB_HANDLER(
// `INSERT IGNORE INTO user_users
// (user_id, invited_user_id, database_access, first_name, last_name, phone, email, username, user_type, user_priviledge)
// VALUES
// (?,?,?,?,?,?,?,?,?,?)
// )`,
// [
// invite,
// user.id,
// database_access,
// user.first_name,
// user.last_name,
// user.phone,
// user.email,
// user.username,
// "admin",
// priviledge,
// ]
// );
addDbEntry({
dbFullName: "datasquirel",
tableName: "user_users",
data: {
user_id: invite,
invited_user_id: user.id,
database_access: database_access,
first_name: user.first_name,
last_name: user.last_name,
phone: user.phone,
email: user.email,
username: user.username,
user_type: "admin",
user_priviledge: priviledge,
image: user.image,
image_thumbnail: user.image_thumbnail
}
});
////////////////////////////////////////////////
////////////////////////////////////////////////
////////////////////////////////////////////////
// @ts-ignore
const dbTableData = await DB_HANDLER(`SELECT db_tables_data FROM invitations WHERE inviting_user_id=? AND invited_user_email=?`, [
invite,
email
]);
// @ts-ignore
const clearEntries = await DB_HANDLER(`DELETE FROM delegated_user_tables WHERE root_user_id=? AND delegated_user_id=?`, [
invite,
user.id
]);
////////////////////////////////////////////////
////////////////////////////////////////////////
////////////////////////////////////////////////
if (dbTableData && dbTableData[0]) {
const dbTableEntries = dbTableData[0].db_tables_data.split("|");
for(let i = 0; i < dbTableEntries.length; i++){
const dbTableEntry = dbTableEntries[i];
const dbTableEntryArray = dbTableEntry.split("-");
const [db_slug, table_slug] = dbTableEntryArray;
const newEntry = await addDbEntry({
dbFullName: "datasquirel",
tableName: "delegated_user_tables",
data: {
delegated_user_id: user.id,
root_user_id: invite,
database: db_slug,
table: table_slug,
priviledge: priviledge
}
});
}
}
////////////////////////////////////////////////
////////////////////////////////////////////////
////////////////////////////////////////////////
}
// @ts-ignore
const inviteAccepted = await DB_HANDLER(`UPDATE invitations SET invitation_status='Accepted' WHERE inviting_user_id=? AND invited_user_email=?`, [
invite,
email
]);
}
////////////////////////////////////////////////
////////////////////////////////////////////////
////////////////////////////////////////////////
} catch (/** @type {any} */ error) {
////////////////////////////////////////////////
////////////////////////////////////////////////
////////////////////////////////////////////////
serverError({
component: "addAdminUserOnLogin",
message: error.message,
user: user
});
}
}; ////////////////////////////////////////////////
////////////////////////////////////////////////
////////////////////////////////////////////////
/***/ })
};
;
@@ -0,0 +1,82 @@
"use strict";
exports.id = 6147;
exports.ids = [6147];
exports.modules = {
/***/ 6147:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const DB_HANDLER = __webpack_require__(2224);
const DSQL_USER_DB_HANDLER = __webpack_require__(3403);
/**
* Imports: Handle imports
*/ /**
* Delete DB Entry Function
* ==============================================================================
* @description Description
* @async
*
* @param {object} params - An object containing the function parameters.
* @param {string} [params.dbContext] - What is the database context? "Master"
* or "Dsql User". Defaults to "Master"
* @param {("Read Only" | "Full Access")} [params.paradigm] - What is the paradigm for "Dsql User"?
* "Read only" or "Full Access"? Defaults to "Read Only"
* @param {string} params.dbFullName - Database full name
* @param {string} params.tableName - Table name
* @param {import("../../../types").DSQL_TableSchemaType} [params.tableSchema] - Table schema
* @param {string} params.identifierColumnName - Update row identifier column name
* @param {string|number} params.identifierValue - Update row identifier column value
*
* @returns {Promise<object|null>}
*/ async function deleteDbEntry({ dbContext , paradigm , dbFullName , tableName , identifierColumnName , identifierValue , }) {
try {
/**
* Check if data is valid
*/ const isMaster = dbContext?.match(/dsql.user/i) ? false : dbFullName && !dbFullName.match(/^datasquirel$/) ? false : true;
/** @type { (a1:any, a2?:any) => any } */ const dbHandler = isMaster ? DB_HANDLER : DSQL_USER_DB_HANDLER;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Execution
*
* @description
*/ const query = `DELETE FROM ${tableName} WHERE \`${identifierColumnName}\`=?`;
const deletedEntry = isMaster ? await dbHandler(query, [
identifierValue
]) : await dbHandler({
paradigm,
queryString: query,
database: dbFullName,
queryValues: [
identifierValue
]
});
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Return statement
*/ return deletedEntry;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
} catch (error) {
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
return null;
}
}
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
module.exports = deleteDbEntry;
/***/ })
};
;
+163
View File
@@ -0,0 +1,163 @@
"use strict";
exports.id = 6217;
exports.ids = [6217];
exports.modules = {
/***/ 6217:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
// EXPORTS
__webpack_require__.d(__webpack_exports__, {
"Z": () => (/* binding */ GeneralLayout)
});
// 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: external "next/head"
var head_ = __webpack_require__(968);
var head_default = /*#__PURE__*/__webpack_require__.n(head_);
// EXTERNAL MODULE: ./functions/frontend/updateNavLinks.js
var updateNavLinks = __webpack_require__(9678);
// EXTERNAL MODULE: ./layouts/components/GeneralLayout/Header.jsx
var Header = __webpack_require__(7108);
// EXTERNAL MODULE: ./layouts/components/GeneralLayout/Footer.jsx
var Footer = __webpack_require__(5281);
;// CONCATENATED MODULE: ./layouts/components/GeneralLayout/ProductionHeadComponent.jsx
// @ts-check
/**
* ==============================================================================
* Imports
* ==============================================================================
*/
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
* ==============================================================================
* Main Component { Functional }
* ==============================================================================
* @param {object} props - React component props
* @param {*} props.head
* @param {*} props.productionEnvironment
*/ function ProductionHeadComponent(props) {
/**
* 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__*/ jsx_runtime_.jsx((external_react_default()).Fragment, {});
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
}
// EXTERNAL MODULE: ./layouts/components/GeneralLayout/ScrollToTopButton.jsx
var ScrollToTopButton = __webpack_require__(9360);
;// CONCATENATED MODULE: ./layouts/GeneralLayout.jsx
// @ts-check
/**
* ==============================================================================
* Imports
* ==============================================================================
*/
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
* ==============================================================================
* Main Component { Functional }
* ==============================================================================
* @param {object} props - React Component Props
* @param {React.ReactNode} props.children - children component
* @param {React.ReactNode} props.head - head Items
* @param {import("@/package-shared/types").UserType | null} [props.user] - user object
* @param {*} [props.productionEnvironment]
* @param {boolean} [props.darkBgHeader]
* @param {boolean} [props.transparentHeader]
*/ function GeneralLayout({ children , head , user , productionEnvironment , darkBgHeader , transparentHeader , }) {
/**
* Get Contexts
*
* @abstract { React.useContext }
*/ ////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Javascript Variables
*
* @abstract Non hook variables and functions
*/ ////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* React Hooks
*
* @abstract { useState, useEffect, useRef, etc ... }
*/ external_react_default().useEffect(()=>{
(0,updateNavLinks/* default */.Z)({});
}, []);
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Function Return
*
* @abstract Main Function Return
*/ return /*#__PURE__*/ (0,jsx_runtime_.jsxs)((external_react_default()).Fragment, {
children: [
/*#__PURE__*/ jsx_runtime_.jsx((head_default()), {
children: head
}),
/*#__PURE__*/ jsx_runtime_.jsx(ProductionHeadComponent, {
head: head,
productionEnvironment: productionEnvironment
}),
/*#__PURE__*/ jsx_runtime_.jsx(Header/* default */.Z, {
user: user,
darkBg: darkBgHeader,
transparent: transparentHeader
}),
children,
/*#__PURE__*/ jsx_runtime_.jsx(Footer/* default */.Z, {}),
/*#__PURE__*/ jsx_runtime_.jsx(ScrollToTopButton/* default */.Z, {})
]
});
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
}
/***/ })
};
;
+142
View File
@@ -0,0 +1,142 @@
"use strict";
exports.id = 6251;
exports.ids = [6251];
exports.modules = {
/***/ 6251:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Z": () => (/* binding */ SuErrorLogsContent)
/* 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__);
/* harmony import */ var _functions_frontend_fetchApi__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(6729);
/* harmony import */ var _general_LoadingBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(5264);
// @ts-check
/**
* ==============================================================================
* Imports
* ==============================================================================
*/
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
* ==============================================================================
* Main Component { Functional }
* ==============================================================================
* @param {Object} props - Server props
*/ function SuErrorLogsContent(props) {
/**
* Get Contexts
*
* @abstract { React.useContext }
*/ ////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Javascript Variables
*
* @abstract Non hook variables and functions
*/ ////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* React Hooks
*
* @abstract { useState, useEffect, useRef, etc ... }
*/ /** @type {[ errorLog: string | null, setErrorLog: React.Dispatch<React.SetStateAction<string | null>> ]} */ // @ts-ignore
const [errorLog, setErrorLog] = react__WEBPACK_IMPORTED_MODULE_1___default().useState(null);
const [loading, setLoading] = react__WEBPACK_IMPORTED_MODULE_1___default().useState(false);
const [refresh, setRefresh] = react__WEBPACK_IMPORTED_MODULE_1___default().useState(0);
function fetchErrorLogs() {
(0,_functions_frontend_fetchApi__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z)("/api/admin/grabErrorLogs").then((res)=>{
if (typeof res.log === "string" && !res.log?.match(/./)) {
setErrorLog("No Logs Yet");
return;
} else {
setErrorLog("");
}
setErrorLog(res.log.replace(/\n|\r|\n\r|\\n/gm, "<br/>"));
});
}
react__WEBPACK_IMPORTED_MODULE_1___default().useEffect(()=>{
fetchErrorLogs();
if (refresh === 0) {
setInterval(()=>{
fetchErrorLogs();
}, 10000);
}
}, [
refresh
]);
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Function Return
*
* @abstract Main Function Return
*/ return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)((react__WEBPACK_IMPORTED_MODULE_1___default().Fragment), {
children: [
/*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
className: "w-full justify-between",
children: [
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("h2", {
className: "text-xl m-0",
children: "Error Logs"
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
children: /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("button", {
onClick: (e)=>{
if (window.confirm("Clear Error Logs?")) {
setLoading(true);
(0,_functions_frontend_fetchApi__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z)("/api/admin/clearErrorLogs", "post").then((res)=>{
console.log(res);
setRefresh((prev)=>prev + 1);
});
setTimeout(()=>{
setLoading(false);
}, 2000);
}
},
className: "outlined gray relative",
children: [
loading && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_general_LoadingBlock__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .Z, {
width: "20px"
}),
"Clear Error Log"
]
})
})
]
}),
/*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("section", {
className: "paper",
children: [
errorLog && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("p", {
dangerouslySetInnerHTML: {
__html: errorLog ? errorLog : "No Log"
}
}),
!errorLog && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_general_LoadingBlock__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .Z, {
position: "relative",
width: "25px"
})
]
})
]
});
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
} /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
/***/ })
};
;
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,90 @@
"use strict";
exports.id = 6478;
exports.ids = [6478];
exports.modules = {
/***/ 6478:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Z": () => (/* binding */ LoadingScreen)
/* 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__);
/* harmony import */ var _mui_icons_material_ContentCopy__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6843);
/* harmony import */ var _mui_icons_material_ContentCopy__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_mui_icons_material_ContentCopy__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _mui_material_Snackbar__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(9174);
/* harmony import */ var _mui_material_Snackbar__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_mui_material_Snackbar__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var _LoadingBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(5264);
// @ts-check
/**
* ==============================================================================
* Imports
* ==============================================================================
*/
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
* ==============================================================================
* Main Component { Functional }
* ==============================================================================
*/ function LoadingScreen() {
/**
* 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__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
className: "flex flex-col gap-4 items-center justify-center w-full h-screen p-6 bg-slate-100",
children: /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
className: "flex flex-col items-center justify-center gap-4 px-6 py-20 bg-white rounded shadow-sm max-w-2xl w-full",
children: [
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("img", {
src: "/images/logo-icon-alt-2.webp",
alt: "Datasquirel Logo",
width: 60
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
className: "w-10 h-10 flex flex-col items-center justify-center",
children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_LoadingBlock__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Z, {
width: "25px",
position: "relative"
})
})
]
})
});
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
}
/***/ })
};
;
@@ -0,0 +1,67 @@
"use strict";
exports.id = 6715;
exports.ids = [6715];
exports.modules = {
/***/ 6715:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const fs = __webpack_require__(7147);
const path = __webpack_require__(1017);
/**
* Imports: Handle imports
*/ /**
* Grab Paths Function
* ==============================================================================
* @description Description
*
* @param {object} params - An object containing the function parameters.
* @param {boolean} [params.isPrivate] - Is this file private or not?
* @param {any} params.user - User object
* @param {string} [params.folder] - Folder, if available
* @param {boolean} [params.video] - Video, if available
* @param {boolean} [params.pathOnly] - Just generate the directories' paths
*
* @returns {{ fileRootPath: string, urlRootPath: string, relativePath: string } | null}
*/ module.exports = function grabPaths({ isPrivate , user , folder , video , pathOnly , }) {
/**
* Initialize variables
*/ const isProduction = "production".match(/production/);
const userId = user?.id || user?.user_id;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Handle function logic
*/ const STATIC_ROOT = process.env.DSQL_STATIC_SERVER_DIR;
if (!STATIC_ROOT) {
console.log("Static File ENV not Found!");
return null;
}
const relativePath = isPrivate ? `@/${video ? "videos" : "media"}/${folder ? folder + "/" : ""}` : video ? `/videos/user-videos/user-${userId}/${folder ? folder + "/" : ""}` : `/images/user-images/user-${userId}/${folder ? folder + "/" : ""}`;
const fileRootPath = isPrivate ? `./jsonData/dbSchemas/users/user-${userId}/media/${folder ? folder + "/" : ""}` : path.join(STATIC_ROOT, relativePath);
if (!fs.existsSync(fileRootPath) && !pathOnly) {
fs.mkdirSync(fileRootPath, {
recursive: true
});
}
const urlRootPath = isPrivate ? `@/media/${folder ? folder + "/" : ""}` : `${process.env.DSQL_STATIC_HOST}${relativePath}`;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Return statement
*/ return {
fileRootPath: fileRootPath,
urlRootPath: urlRootPath,
relativePath
};
};
/***/ })
};
;
@@ -0,0 +1,82 @@
"use strict";
exports.id = 6718;
exports.ids = [6718];
exports.modules = {
/***/ 6718:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Z": () => (/* binding */ imageInputFileToBase64)
/* harmony export */ });
// @ts-check
/**
* Upload Image function
* ------------------------------------------------------------------------------
* @param {object} params
* @param {File} params.imageInputFile image input file
* @param {number} [params.maxWidth] optional maximum width
* @requires Image {imagePreviewNode} - optional image dispatch node
* @return object containing image data in base 64 and image name
*/ async function imageInputFileToBase64({ imageInputFile , maxWidth , }) {
/**
* Initialize
* ------------------------------------------------------------------------------
*/ /** ********************* Variables */ let imagePreviewNode = document.querySelector(`[data-imagepreview='image']`);
let imageName = imageInputFile.name.replace(/\..*/, "");
let imageDataBase64;
let imageSize;
let canvas = document.createElement("canvas");
const MIME_TYPE = imageInputFile.type;
const QUALITY = 0.95;
const MAX_WIDTH = maxWidth ? maxWidth : null;
const MAX_HEIGHT = null;
const file = imageInputFile; // get the file
const blobURL = URL.createObjectURL(file);
const img = new Image();
/** ********************* Add source to new image */ img.src = blobURL;
imageDataBase64 = await new Promise((res, rej)=>{
/** ********************* Handle Errors in loading image */ img.onerror = function() {
URL.revokeObjectURL(this.src);
console.log("Cannot load image");
};
/** ********************* Handle new image when loaded */ img.onload = function() {
// @ts-ignore
URL.revokeObjectURL(this.src);
if (MAX_WIDTH) {
const scaleSize = MAX_WIDTH / img.naturalWidth;
canvas.width = img.naturalWidth < MAX_WIDTH ? img.naturalWidth : MAX_WIDTH;
canvas.height = img.naturalWidth < MAX_WIDTH ? img.naturalHeight : img.naturalHeight * scaleSize;
} else {
canvas.width = img.naturalWidth;
canvas.height = img.naturalHeight;
}
const ctx = canvas.getContext("2d");
ctx?.drawImage(img, 0, 0, canvas.width, canvas.height);
const srcEncoded = canvas.toDataURL(MIME_TYPE, QUALITY);
if (imagePreviewNode) {
document.querySelectorAll(`[data-imagepreview='image']`).forEach((/** @type {any} */ img)=>{
img.src = srcEncoded;
});
}
res(srcEncoded);
};
});
imageSize = await new Promise((res, rej)=>{
canvas.toBlob((blob)=>{
res(blob?.size);
}, MIME_TYPE, QUALITY);
});
return {
imageBase64: imageDataBase64.replace(/.*?base64,/, ""),
imageBase64Full: imageDataBase64,
imageName: imageName,
imageSize: imageSize
};
}
/***/ })
};
;
+124
View File
@@ -0,0 +1,124 @@
"use strict";
exports.id = 6729;
exports.ids = [6729];
exports.modules = {
/***/ 6729:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Z": () => (/* binding */ fetchApi)
/* harmony export */ });
// @ts-check
/**
* ==============================================================================
* Fetch Function
* ==============================================================================
* @async
*
* @param {string} url - Admin or Site page
* @param {{
* method: "POST" | "GET" | "DELETE" | "PUT" | "PATCH" | "post" | "get" | "delete" | "put" | "patch",
* body: object | string,
* headers?: HeadersInit,
* } | string} [options] - options object or string: **optional
* @param {boolean} [csrf] - Add CSRF?
*
* @returns {Promise<*>}
*/ async function fetchApi(url, options, csrf) {
/** ********************* Initialize data variable */ let data;
const finalUrl = url.match(/\?/) ? url : url + window.location.search;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
if (typeof options === "string") {
try {
let fetchData;
switch(options){
case "post":
fetchData = await fetch(finalUrl, {
method: options,
// @ts-ignore
headers: {
"Content-Type": "application/json",
"x-csrf-auth": csrf ? localStorage.getItem("csrf") : ""
}
});
data = fetchData.json();
break;
default:
fetchData = await fetch(finalUrl);
data = fetchData.json();
break;
}
} catch (error) {
data = null;
}
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
} else if (typeof options === "object") {
try {
let fetchData1;
/** ********************* Convert body to JSON if not JSON */ if (options.body && typeof options.body === "object") {
let oldOptionsBody = options.body;
options.body = JSON.stringify(oldOptionsBody);
}
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
if (options.headers) {
////////////////////////////////////////
// @ts-ignore
options.headers["x-csrf-auth"] = csrf ? localStorage.getItem("csrf") : "";
/** @type {any} */ const finalOptions = {
...options
};
fetchData1 = await fetch(finalUrl, finalOptions);
////////////////////////////////////////
} else {
fetchData1 = await fetch(finalUrl, {
...options,
// @ts-ignore
headers: {
"Content-Type": "application/json",
"x-csrf-auth": csrf ? localStorage.getItem("csrf") : ""
}
});
}
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
data = fetchData1.json();
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
} catch (error1) {
data = null;
}
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
} else {
try {
let fetchData2 = await fetch(finalUrl);
data = fetchData2.json();
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
} catch (error2) {
data = null;
}
}
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
return data;
}
var FETCH = fetchApi;
/***/ })
};
;
@@ -0,0 +1,86 @@
"use strict";
exports.id = 6825;
exports.ids = [6825];
exports.modules = {
/***/ 6825:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const http = __webpack_require__(3685);
const DB_HANDLER = __webpack_require__(2224);
const decrypt = __webpack_require__(5425);
const fs = __webpack_require__(7147);
const EXPIRY_TIME = 1000 * 60 * 60 * 24 * 1 * 7; // 7 days
/**
* @async
* @param {import("next").NextApiRequest | http.IncomingMessage & { cookies: Partial<{ [key: string]: string; }>;
}} req - https request object
* @param {import("next").NextApiResponse | http.ServerResponse} res - https response object
* @param {boolean | null} [csrf] - csrf key
* @param {any} [query] - query object
*
* @returns {Promise<(import("@/package-shared/types").UserType | null)>}
*/ module.exports = async function userAuth(req, res, csrf, query) {
/** ********************* Check for existence of required cookie */ if (!req.cookies?.datasquirelAuthKey?.match(/./)) {
// console.log("No datasquirel key cookie present");
return null;
}
/** ********************* Grab the payload */ let userPayload = decrypt(req.cookies.datasquirelAuthKey);
/** ********************* Return if no payload */ if (!userPayload) {
// console.log("Couldn't Decrypt cookie");
return null;
}
/** ********************* Parse the payload */ let userObject = JSON.parse(userPayload);
const { user_type } = userObject;
if (!userObject.csrf_k) {
// console.log("No CSRF_K in decrypted payload");
return null;
}
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
if (csrf && // @ts-ignore
!req.headers["x-csrf-auth"]?.match(new RegExp(`${userObject.csrf_k}`))) {
// console.log("CSRF_K requested but does not match payload");
return null;
}
const allowedAuthKeysPath = process.env.DSQL_USER_LOGIN_KEYS_PATH;
if (!allowedAuthKeysPath) {
console.log(`DSQL_USER_LOGIN_KEYS_PATH env variable not found. Please set this variable.`);
return null;
}
if (csrf && !fs.existsSync(`${allowedAuthKeysPath}/${userObject.csrf_k}`)) {
return null;
}
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/** ********************* check user verification */ if (userObject.verification_status == 0 && !csrf) {
let currentVerificationStatus = await DB_HANDLER(`SELECT verification_status FROM users WHERE id='${userObject.id}'`);
if (currentVerificationStatus && currentVerificationStatus[0] && currentVerificationStatus[0].verification_status == 1) {
// userObject = await reAuthUser({ userId: userObject.id, res });
res.setHeader("Set-Cookie", [
`user_refresh=1`
]);
}
}
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
if (userObject?.date && Date.now() - userObject.date > EXPIRY_TIME) {
// console.log("Cookie expired");
return null;
}
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/** ********************* return user object */ return userObject;
};
/***/ })
};
;
File diff suppressed because it is too large Load Diff
+100
View File
@@ -0,0 +1,100 @@
"use strict";
exports.id = 6926;
exports.ids = [6926];
exports.modules = {
/***/ 6926:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
/**
* Imports
* ==============================================================================
*/
const fs = __webpack_require__(7147);
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
const nodemailer = __webpack_require__(5184);
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
let transporter = nodemailer.createTransport({
host: process.env.DSQL_MAIL_HOST,
port: 465,
secure: true,
auth: {
user: process.env.DSQL_MAIL_EMAIL,
pass: process.env.DSQL_MAIL_PASSWORD
}
});
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
* # Handle mails
* @param {object} mailObject - Mail Object with params
* @param {string} [mailObject.to] - who is recieving this email? Comma separated for multiple recipients
* @param {string} [mailObject.subject] - Mail Subject
* @param {string} [mailObject.text] - Mail text
* @param {string} [mailObject.html] - Mail HTML
* @param {string | null} [mailObject.alias] - Sender alias: "support" or null
*
* @returns {Promise<any>} mail object
*/ module.exports = async function handleNodemailer({ to , subject , text , html , alias , }) {
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
if (!process.env.DSQL_MAIL_HOST || !process.env.DSQL_MAIL_EMAIL || !process.env.DSQL_MAIL_PASSWORD) {
return null;
}
const sender = (()=>{
if (alias?.match(/support/i)) return process.env.DSQL_MAIL_EMAIL;
return process.env.DSQL_MAIL_EMAIL;
})();
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
let sentMessage;
if (!fs.existsSync("./email/index.html")) {
return;
}
let mailRoot = fs.readFileSync("./email/index.html", "utf8");
let finalHtml = mailRoot.replace(/{{email_body}}/, html ? html : "").replace(/{{issue_date}}/, Date().substring(0, 24));
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
try {
let mailObject = {};
mailObject["from"] = `"Datasquirel" <${sender}>`;
mailObject["sender"] = sender;
if (alias) mailObject["replyTo "] = sender;
// mailObject["priority"] = "high";
mailObject["to"] = to;
mailObject["subject"] = subject;
mailObject["text"] = text;
mailObject["html"] = finalHtml;
// send mail with defined transport object
let info = await transporter.sendMail(mailObject);
sentMessage = info;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
} catch (/** @type {any} */ error) {
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
console.log("ERROR in handleNodemailer Function =>", error.message);
// serverError({
// component: "handleNodemailer",
// message: error.message,
// user: { email: to },
// });
}
return sentMessage;
}; ////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/***/ })
};
;
@@ -0,0 +1,53 @@
"use strict";
exports.id = 7023;
exports.ids = [7023];
exports.modules = {
/***/ 7023:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
/**
* ==============================================================================
* Imports
* ==============================================================================
*/
const fs = __webpack_require__(7147);
// const handleNodemailer = require("./handleNodemailer");
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
* ==============================================================================
* Main Function
* ==============================================================================
* @param {{
* user?: { id?: number | string, first_name?: string, last_name?: string, email?: string } & *,
* message: string,
* component?: string,
* noMail?: boolean,
* }} params - user id
*
* @returns {Promise<void>}
*/ module.exports = async function serverError({ user , message , component , noMail , }) {
const log = `🚀 SERVER ERROR ===========================\nUser Id: ${user?.id}\nUser Name: ${user?.first_name} ${user?.last_name}\nUser Email: ${user?.email}\nError Message: ${message}\nComponent: ${component}\nDate: ${Date()}\n========================================`;
if (!fs.existsSync(`./.tmp/error.log`)) {
fs.writeFileSync(`./.tmp/error.log`, "", "utf-8");
}
const initialText = fs.readFileSync(`./.tmp/error.log`, "utf-8");
fs.writeFileSync(`./.tmp/error.log`, log);
fs.appendFileSync(`./.tmp/error.log`, `\n\n\n\n\n${initialText}`);
// if (process.env.NODE_ENV?.match(/production/) && !noMail) {
// handleNodemailer({
// to: "benoti.san@gmail.com",
// subject: "SERVER Error in Datasquirel Application",
// text: "An Error occured in Datasquirel Application Server Side",
// html: log,
// });
// }
}; ////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/***/ })
};
;
@@ -0,0 +1,50 @@
"use strict";
exports.id = 7037;
exports.ids = [7037];
exports.modules = {
/***/ 7037:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Z": () => (/* binding */ FormAlertBlock)
/* 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 {string | undefined | null} props.message
*/ function FormAlertBlock({ message }) {
return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
className: "p-2 bg-orange-50 w-full justify-center rounded text-sm text-orange-700 border border-orange-400 border-solid",
children: [
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("img", {
src: "/images/warning.png",
alt: "Warning Image Icon",
width: 22,
className: "-my-2"
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("span", {
children: message
})
]
});
} /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
/***/ })
};
;
@@ -0,0 +1,73 @@
"use strict";
exports.id = 7192;
exports.ids = [7192];
exports.modules = {
/***/ 7192:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
/**
* ==============================================================================
* Imports
* ==============================================================================
*/
const generator = __webpack_require__(3785);
const DB_HANDLER = __webpack_require__(2224);
const NO_DB_HANDLER = __webpack_require__(7487);
const encrypt = __webpack_require__(7547);
const addDbEntry = __webpack_require__(5338);
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
* Add Mariadb User
* ==============================================================================
*
* @description this function adds a Mariadb user to the database server
*
* @param {object} params - parameters object *
* @param {number | string} params.userId - invited user object
*
* @returns {Promise<any>} new user auth object payload
*/ module.exports = async function addMariadbUser({ userId }) {
try {
const defaultMariadbUserHost = process.env.DSQL_DB_HOST || "127.0.0.1";
const username = `dsql_user_${userId}`;
const password = generator.generate({
length: 16,
numbers: true,
symbols: true,
uppercase: true,
exclude: "*#.'`\""
});
const encryptedPassword = encrypt(password);
await NO_DB_HANDLER(`CREATE USER IF NOT EXISTS '${username}'@'127.0.0.1' IDENTIFIED BY '${password}' REQUIRE SSL`);
const updateUser = await DB_HANDLER(`UPDATE users SET mariadb_user = ?, mariadb_host = '127.0.0.1', mariadb_pass = ? WHERE id = ?`, [
username,
encryptedPassword,
userId
]);
const addMariadbUser1 = await addDbEntry({
tableName: "mariadb_users",
data: {
user_id: userId,
username,
host: defaultMariadbUserHost,
password: encryptedPassword,
primary: "1",
grants: '[{"database":"*","table":"*","privileges":["ALL"]}]'
},
dbContext: "Master"
});
console.log("addMariadbUser =>", addMariadbUser1);
console.log(`User ${userId} SQL credentials successfully added.`);
} catch (/** @type {any} */ error) {
console.log(`Error in adding SQL user in 'addMariadbUser' function =>`, error.message);
}
}; ////////////////////////////////////////////////
////////////////////////////////////////////////
////////////////////////////////////////////////
/***/ })
};
;
+101
View File
@@ -0,0 +1,101 @@
"use strict";
exports.id = 722;
exports.ids = [722];
exports.modules = {
/***/ 722:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
/**
* Imports
* ==============================================================================
*/
const https = __webpack_require__(5687);
const http = __webpack_require__(3685);
const { URL } = __webpack_require__(7310);
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
/**
* Main Function
* ==============================================================================
* @param {{
* scheme?: string,
* url?: string,
* method?: string,
* hostname?: string,
* path?: string,
* port?: number | string,
* headers?: object,
* body?: object,
* }} params - params
*/ module.exports = function httpsRequest({ url , method , hostname , path , headers , body , port , scheme , }) {
const reqPayloadString = body ? JSON.stringify(body) : null;
const PARSED_URL = url ? new URL(url) : null;
////////////////////////////////////////////////
////////////////////////////////////////////////
////////////////////////////////////////////////
/** @type {any} */ let requestOptions = {
method: method || "GET",
hostname: PARSED_URL ? PARSED_URL.hostname : hostname,
port: scheme?.match(/https/i) ? 443 : PARSED_URL ? PARSED_URL.protocol?.match(/https/i) ? 443 : PARSED_URL.port : port ? Number(port) : 80,
headers: {}
};
if (path) requestOptions.path = path;
// if (href) requestOptions.href = href;
if (headers) requestOptions.headers = headers;
if (body) {
requestOptions.headers["Content-Type"] = "application/json";
requestOptions.headers["Content-Length"] = reqPayloadString ? Buffer.from(reqPayloadString).length : undefined;
}
////////////////////////////////////////////////
////////////////////////////////////////////////
////////////////////////////////////////////////
return new Promise((res, rej)=>{
const httpsRequest = (scheme?.match(/https/i) ? https : PARSED_URL?.protocol?.match(/https/i) ? https : http).request(/* ====== Request Options object ====== */ requestOptions, ////////////////////////////////////////////////
////////////////////////////////////////////////
////////////////////////////////////////////////
/* ====== Callback function ====== */ (response)=>{
var str = "";
// ## another chunk of data has been received, so append it to `str`
response.on("data", function(chunk) {
str += chunk;
});
// ## the whole response has been received, so we just print it out here
response.on("end", function() {
res(str);
});
response.on("error", (error)=>{
console.log("HTTP response error =>", error.message);
rej(`HTTP response error =>, ${error.message}`);
});
response.on("close", ()=>{
console.log("HTTP(S) Response Closed Successfully");
});
});
if (body) httpsRequest.write(reqPayloadString);
httpsRequest.on("error", (error)=>{
console.log("HTTPS request ERROR =>", error.message);
rej(`HTTP request error =>, ${error.message}`);
});
httpsRequest.end();
////////////////////////////////////////////////
////////////////////////////////////////////////
////////////////////////////////////////////////
});
}; //////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
/***/ })
};
;
@@ -0,0 +1,68 @@
"use strict";
exports.id = 7487;
exports.ids = [7487];
exports.modules = {
/***/ 7487:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const fs = __webpack_require__(7147);
const path = __webpack_require__(1017);
// const mysql = require("mysql");
// const NO_DB = mysql.createConnection({
// host: process.env.DSQL_DB_HOST,
// user: process.env.DSQL_DB_USERNAME,
// password: process.env.DSQL_DB_PASSWORD,
// charset: "utf8mb4",
// });
const mysql = __webpack_require__(2261);
const SSL_DIR = "/app/ssl";
let NO_DB = mysql({
config: {
host: process.env.DSQL_DB_HOST,
user: process.env.DSQL_DB_USERNAME,
password: process.env.DSQL_DB_PASSWORD,
charset: "utf8mb4",
ssl: {
ca: fs.readFileSync(`${SSL_DIR}/ca-cert.pem`)
}
}
});
/**
* DSQL user read-only DB handler
* @param {object} params
* @param {string} params.paradigm
* @param {string} params.database
* @param {string} params.queryString
* @param {string[]} [params.queryValues]
*/ // @ts-ignore
function NO_DB_HANDLER(...args) {
try {
return new Promise((resolve, reject)=>{
NO_DB.query(...args).then((results)=>{
NO_DB.end();
resolve(JSON.parse(JSON.stringify(results)));
}).catch((err)=>{
NO_DB.end();
resolve({
error: err.message,
sql: err.sql
});
});
});
} catch (/** @type {any} */ error) {
return {
success: false,
error: error.message
};
}
}
module.exports = NO_DB_HANDLER;
/***/ })
};
;
+61
View File
@@ -0,0 +1,61 @@
"use strict";
exports.id = 75;
exports.ids = [75];
exports.modules = {
/***/ 4739:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Z": () => (/* binding */ DatabaseSlugCopy)
/* 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__);
/* harmony import */ var _mui_icons_material_CopyAllTwoTone__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(5050);
/* harmony import */ var _mui_icons_material_CopyAllTwoTone__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_mui_icons_material_CopyAllTwoTone__WEBPACK_IMPORTED_MODULE_2__);
// @ts-check
/**
* Imports
* ==============================================================================
*/
// import DifferenceOutlinedIcon from "@mui/icons-material/DifferenceOutlined";
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
* Main Component { Functional }
* ==============================================================================
* @param {{
* slugText: string,
* smaller?: boolean,
* outlined?: boolean,
* }} props - React component props including { children }
*/ function DatabaseSlugCopy({ slugText , smaller , outlined }) {
return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("span", {
className: "button " + (outlined ? " outlined gray" : "light-gray") + (smaller ? " small-text" : ""),
onClick: (e)=>{
navigator.clipboard.writeText(slugText).then(()=>{
alert(`Database Slug "${slugText}" Copied to Clipboard. Use this as the database name when querying data`);
});
},
children: [
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx((_mui_icons_material_CopyAllTwoTone__WEBPACK_IMPORTED_MODULE_2___default()), {
color: "action",
sx: {
opacity: 0.5,
fontSize: 15
}
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("span", {
children: slugText
})
]
});
}
/***/ })
};
;
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,46 @@
"use strict";
exports.id = 7547;
exports.ids = [7547];
exports.modules = {
/***/ 7547:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const { scryptSync , createCipheriv } = __webpack_require__(6113);
const { Buffer } = __webpack_require__(4300);
const serverError = __webpack_require__(3017);
/**
* @async
* @param {string} data
* @param {string} [encryptionKey]
* @param {string} [encryptionSalt]
* @returns {string | null}
*/ const encrypt = (data, encryptionKey, encryptionSalt)=>{
const algorithm = "aes-192-cbc";
const password = encryptionKey ? encryptionKey : process.env.DSQL_ENCRYPTION_PASSWORD || "";
/** ********************* Generate key */ const salt = encryptionSalt ? encryptionSalt : process.env.DSQL_ENCRYPTION_SALT || "";
let key = scryptSync(password, salt, 24);
let iv = Buffer.alloc(16, 0);
// @ts-ignore
const cipher = createCipheriv(algorithm, key, iv);
/** ********************* Encrypt data */ try {
let encrypted = cipher.update(data, "utf8", "hex");
encrypted += cipher.final("hex");
return encrypted;
} catch (/** @type {any} */ error) {
serverError({
component: "encrypt",
message: error.message
});
return null;
}
};
module.exports = encrypt;
/***/ })
};
;
@@ -0,0 +1,41 @@
"use strict";
exports.id = 7638;
exports.ids = [7638];
exports.modules = {
/***/ 7638:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (/* binding */ setUserSchemaData)
/* harmony export */ });
// @ts-check
const serverError = __webpack_require__(2163);
const fs = __webpack_require__(7147);
const path = __webpack_require__(1017);
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
* ==============================================================================
* @param {Object} params
* @param {string | number} params.userId
* @param {DSQL_DatabaseSchemaType[]} params.schemaData
* @returns {boolean}
*/ function setUserSchemaData({ userId , schemaData }) {
try {
const userSchemaFilePath = path.resolve(process.cwd(), `./jsonData/dbSchemas/users/user-${userId}/main.json`);
fs.writeFileSync(userSchemaFilePath, JSON.stringify(schemaData), "utf8");
return true;
} catch (/** @type {any} */ error) {
serverError({
component: "/functions/backend/setUserSchemaData",
message: error.message
});
return false;
}
} /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
/***/ })
};
;
+55
View File
@@ -0,0 +1,55 @@
"use strict";
exports.id = 766;
exports.ids = [766];
exports.modules = {
/***/ 766:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const DSQL_USER_DB_HANDLER = __webpack_require__(3403);
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
* Handle Table Entries Order
* =================================================================
* @param {object} param0
* @param {string} param0.dbName
* @param {string} param0.tableName
* @param {number} param0.entryId
* @param {string} param0.entryOrder
* @param {import("@/package-shared/types").DSQL_TableSchemaType} param0.tableSchema
*/ module.exports = async function handleTableEntryOrder({ dbName , entryId , entryOrder , tableName , tableSchema , }) {
try {
const isOrderField = Boolean(tableSchema.fields.find((fld)=>Boolean(fld.fieldName?.match(/^order$/i))));
if (isOrderField && entryOrder) {
const existingOrder = await DSQL_USER_DB_HANDLER({
database: dbName,
paradigm: "Full Access",
queryString: `SELECT * FROM ${tableName} WHERE \`order\` = '${entryOrder}' AND id != ?`,
queryValues: [
String(entryId)
]
});
if (!existingOrder?.[0]) throw new Error("No Existing Order");
await DSQL_USER_DB_HANDLER({
database: dbName,
paradigm: "Full Access",
queryString: `UPDATE ${tableName} SET \`order\` = \`order\` + 1 WHERE \`order\` >= ${entryOrder} AND id != ?`,
queryValues: [
String(entryId)
]
});
}
return true;
} catch (/** @type {any} */ error) {
return false;
}
}; ////////////////////////////////////////////////
////////////////////////////////////////////////
////////////////////////////////////////////////
/***/ })
};
;
+350
View File
@@ -0,0 +1,350 @@
"use strict";
exports.id = 7839;
exports.ids = [7839];
exports.modules = {
/***/ 7839:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
/**
* ==============================================================================
* Imports
* ==============================================================================
*/
const fs = __webpack_require__(7147);
////////////////////////////////////////////////
////////////////////////////////////////////////
////////////////////////////////////////////////
const addAdminUserOnLogin = __webpack_require__(613);
const handleNodemailer = __webpack_require__(6926);
const { ServerResponse } = __webpack_require__(3685);
const path = __webpack_require__(1017);
const addMariadbUser = __webpack_require__(4294);
const varDatabaseDbHandler = __webpack_require__(1311);
const encrypt = __webpack_require__(7547);
const addDbEntry = __webpack_require__(5338);
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
/**
* @typedef {object} FunctionReturn
* @property {boolean} success - Did the operation complete successfully or not?
* @property {{
* id: number,
* first_name: string,
* last_name: string,
* }|null} user - User payload object: or "null"
*/ /**
* Handle Social User Auth on Datasquirel Database
* ==============================================================================
*
* @description This function handles all social login logic after the social user
* has been authenticated and userpayload is present. The payload MUST contain the
* specified fields because this funciton will create a new user if the authenticated
* user does not exist.
*
* @param {{
* database?: string,
* social_id: string|number,
* email: string,
* social_platform: string,
* payload: any,
* res?: ServerResponse,
* invitation?: any,
* supEmail?: string,
* additionalFields?: object,
* }} params - function parameters inside an object
*
* @returns {Promise<any>} - Response object
*/ module.exports = async function handleSocialDb({ database , social_id , email , social_platform , payload , res , invitation , supEmail , additionalFields , }) {
////////////////////////////////////////////////
////////////////////////////////////////////////
////////////////////////////////////////////////
try {
////////////////////////////////////////////////
////////////////////////////////////////////////
////////////////////////////////////////////////
let existingSocialIdUser = await varDatabaseDbHandler({
database: database ? database : "datasquirel",
queryString: `SELECT * FROM users WHERE social_id = ? AND social_login='1' AND social_platform = ? `,
queryValuesArray: [
social_id.toString(),
social_platform
]
});
if (existingSocialIdUser && existingSocialIdUser[0]) {
return await loginSocialUser({
user: existingSocialIdUser[0],
social_platform,
res,
invitation,
database,
additionalFields
});
}
////////////////////////////////////////////////
////////////////////////////////////////////////
////////////////////////////////////////////////
const finalEmail = email ? email : supEmail ? supEmail : null;
if (!finalEmail) {
return {
success: false,
user: null,
msg: "No Email Present",
social_id,
social_platform,
payload
};
}
////////////////////////////////////////////////
////////////////////////////////////////////////
////////////////////////////////////////////////
let existingEmailOnly = await varDatabaseDbHandler({
database: database ? database : "datasquirel",
queryString: `SELECT * FROM users WHERE email='${finalEmail}'`
});
if (existingEmailOnly && existingEmailOnly[0]) {
return {
user: null,
msg: "This Email is already taken",
alert: true
};
}
////////////////////////////////////////////////
////////////////////////////////////////////////
////////////////////////////////////////////////
const foundUser = await varDatabaseDbHandler({
database: database ? database : "datasquirel",
queryString: `SELECT * FROM users WHERE email='${finalEmail}' AND social_login='1' AND social_platform='${social_platform}' AND social_id='${social_id}'`
});
if (foundUser && foundUser[0]) {
return await loginSocialUser({
user: payload,
social_platform,
res,
invitation,
database,
additionalFields
});
}
////////////////////////////////////////////////
////////////////////////////////////////////////
////////////////////////////////////////////////
const socialHashedPassword = encrypt(social_id.toString());
/** @type {any} */ const data = {
social_login: "1",
verification_status: supEmail ? "0" : "1",
password: socialHashedPassword
};
Object.keys(payload).forEach((key)=>{
data[key] = payload[key];
});
/** @type {any} */ const newUser = await addDbEntry({
dbContext: database ? "Dsql User" : undefined,
paradigm: database ? "Full Access" : undefined,
dbFullName: database ? database : "datasquirel",
tableName: "users",
duplicateColumnName: "email",
duplicateColumnValue: finalEmail,
data: {
...data,
email: finalEmail
}
});
if (newUser?.insertId) {
if (!database) {
/**
* Add a Mariadb User for this User
*/ await addMariadbUser({
userId: newUser.insertId
});
}
const newUserQueried = await varDatabaseDbHandler({
database: database ? database : "datasquirel",
queryString: `SELECT * FROM users WHERE id='${newUser.insertId}'`
});
if (!newUserQueried || !newUserQueried[0]) return {
user: null,
msg: "User Insertion Failed!"
};
////////////////////////////////////////////////
////////////////////////////////////////////////
////////////////////////////////////////////////
if (supEmail && database?.match(/^datasquirel$/)) {
/**
* Send email Verification
*
* @description Send verification email to newly created agent
*/ let generatedToken = encrypt(JSON.stringify({
id: newUser.insertId,
email: supEmail,
dateCode: Date.now()
}));
handleNodemailer({
to: supEmail,
subject: "Verify Email Address",
text: "Please click the link to verify your email address",
html: fs.readFileSync("./email/send-email-verification-link.html", "utf8").replace(/{{host}}/, process.env.DSQL_HOST || "").replace(/{{token}}/, generatedToken || "")
}).then((mail)=>{});
}
////////////////////////////////////////////////
////////////////////////////////////////////////
////////////////////////////////////////////////
const STATIC_ROOT = process.env.DSQL_STATIC_SERVER_DIR;
if (!STATIC_ROOT) {
console.log("Static File ENV not Found!");
return null;
}
/**
* Create new user folder and file
*
* @description Create new user folder and file
*/ if (!database || database?.match(/^datasquirel$/)) {
let newUserSchemaFolderPath = `./jsonData/dbSchemas/users/user-${newUser.insertId}`;
let newUserMediaFolderPath = path.join(STATIC_ROOT, `images/user-images/user-${newUser.insertId}`);
fs.mkdirSync(newUserSchemaFolderPath);
fs.mkdirSync(newUserMediaFolderPath);
fs.writeFileSync(`${newUserSchemaFolderPath}/main.json`, JSON.stringify([]), "utf8");
}
////////////////////////////////////////////////
////////////////////////////////////////////////
////////////////////////////////////////////////
return await loginSocialUser({
user: newUserQueried[0],
social_platform,
res,
invitation,
database,
additionalFields
});
////////////////////////////////////////////////
////////////////////////////////////////////////
////////////////////////////////////////////////
} else {
console.log("Social User Failed to insert in 'handleSocialDb.js' backend function =>", newUser);
return {
success: false,
user: null,
msg: "Social User Failed to insert in 'handleSocialDb.js' backend function => ",
newUser: newUser
};
}
////////////////////////////////////////////////
////////////////////////////////////////////////
////////////////////////////////////////////////
} catch (/** @type {any} */ error) {
console.log("ERROR in 'handleSocialDb.js' backend function =>", error.message);
return {
success: false,
user: null,
error: error.message
};
// serverError({
// component: "/functions/backend/social-login/handleSocialDb.js - main-catch-error",
// message: error.message,
// user: { first_name, last_name },
// });
}
////////////////////////////////////////////////
////////////////////////////////////////////////
////////////////////////////////////////////////
return {
user: null,
msg: "User Login Failed!"
};
};
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
/**
* Function to login social user
* ==============================================================================
* @description This function logs in the user after 'handleSocialDb' function finishes
* the user creation or confirmation process
*
* @async
*
* @param {object} params - function parameters inside an object
* @param {{
* first_name: string,
* last_name: string,
* email: string,
* social_id: string|number,
* }} params.user - user object
* @param {string} params.social_platform - Whether its "google" or "facebook" or "github"
* @param {ServerResponse} [params.res] - Https response object
* @param {any} [params.invitation] - A query object if user was invited
* @param {string} [params.database] - Target Database
* @param {object} [params.additionalFields] - Additional fields to be added to the user payload
*
* @returns {Promise<any>}
*/ async function loginSocialUser({ user , social_platform , res , invitation , database , additionalFields , }) {
const foundUser = await varDatabaseDbHandler({
database: database ? database : "datasquirel",
queryString: `SELECT * FROM users WHERE email='${user.email}' AND social_id='${user.social_id}' AND social_platform='${social_platform}'`
});
if (!foundUser?.[0]) return {
success: false,
user: null
};
let csrfKey = Math.random().toString(36).substring(2) + "-" + Math.random().toString(36).substring(2);
/** @type {any} */ let userPayload = {
id: foundUser[0].id,
type: foundUser[0].type || "",
stripe_id: foundUser[0].stripe_id || "",
first_name: foundUser[0].first_name,
last_name: foundUser[0].last_name,
username: foundUser[0].username,
email: foundUser[0].email,
social_id: foundUser[0].social_id,
image: foundUser[0].image,
image_thumbnail: foundUser[0].image_thumbnail,
verification_status: foundUser[0].verification_status,
social_login: foundUser[0].social_login,
social_platform: foundUser[0].social_platform,
csrf_k: csrfKey,
logged_in_status: true,
date: Date.now()
};
if (additionalFields && Object.keys(additionalFields).length > 0) {
Object.keys(additionalFields).forEach((key)=>{
userPayload[key] = foundUser[0][key];
});
}
let encryptedPayload = encrypt(JSON.stringify(userPayload));
if (res?.setHeader) {
res.setHeader("Set-Cookie", [
`datasquirelAuthKey=${encryptedPayload};samesite=strict;path=/;HttpOnly=true;Secure=true`,
`csrf=${csrfKey};samesite=strict;path=/;HttpOnly=true`,
]);
}
////////////////////////////////////////////////
////////////////////////////////////////////////
////////////////////////////////////////////////
if (invitation && (!database || database?.match(/^datasquirel$/))) {
addAdminUserOnLogin({
query: invitation,
user: userPayload
});
}
////////////////////////////////////////////////
////////////////////////////////////////////////
////////////////////////////////////////////////
return {
success: true,
user: userPayload
};
}
/***/ })
};
;
+429
View File
@@ -0,0 +1,429 @@
"use strict";
exports.id = 7901;
exports.ids = [7901];
exports.modules = {
/***/ 7901:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
// EXPORTS
__webpack_require__.d(__webpack_exports__, {
"Z": () => (/* binding */ FormInput)
});
// 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_);
;// CONCATENATED MODULE: ./functions/frontend/numberFormat.js
// @ts-check
/**
* @param {object} param0
* @param {string | number} param0.value
* @param {"string" | "raw"} [param0.format]
*/ function numberFormat({ value , format }) {
let finalValue;
if (!value) return 0;
try {
switch(format){
case "string":
finalValue = value.toString().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",");
break;
case "raw":
finalValue = parseInt(value.toString().replace(/\D/g, ""));
break;
default:
finalValue = parseInt(value.toString().replace(/\D/g, ""));
break;
}
} catch (error) {
finalValue = 0;
console.log(error);
}
return finalValue;
}
;// CONCATENATED MODULE: ./functions/frontend/numberFormatFloat.js
// @ts-check
/**
* @param {object} param0
* @param {string | number} param0.value
* @param {"string" | "raw"} [param0.format]
* @param {number} [param0.decimals]
*/ function numberFormatFloat({ value , format , decimals }) {
let finalValue;
const negativeValuePrefix = value?.toString()?.match(/^\-/) ? "-" : "";
try {
switch(format){
case "string":
const finalValueSidesArray = value.toString().split(".");
finalValue = negativeValuePrefix + finalValueSidesArray[0].toString().replace(/[^0-9\.]/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",") + (finalValueSidesArray[1] ? decimals ? `.${finalValueSidesArray[1].substring(0, decimals)}` : `.${finalValueSidesArray[1].substring(0, 2)}` : "");
break;
case "raw":
finalValue = parseFloat(negativeValuePrefix + value.toString().replace(/[^0-9\.]/g, ""));
break;
default:
finalValue = parseFloat(negativeValuePrefix + value.toString().replace(/[^0-9\.]/g, ""));
break;
}
} catch (error) {
finalValue = 0;
console.log(error);
}
return finalValue;
}
;// CONCATENATED MODULE: ./components/form/FormInput.jsx
// @ts-check
/**
* ==============================================================================
* Imports
* ==============================================================================
*/
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ let /** @type {any} */ incrementTimeout, /** @type {any} */ incrementInterval;
/**
* Form Input
* ==============================================================================
* @param {Object} props - Server props
* @param {string} [props.title]
* @param {string} [props.name]
* @param {string} [props.defaultValue]
* @param {string} [props.placeholder]
* @param {string} [props.autoComplete]
* @param {(e: Event) => void} [props.onInputHandler]
* @param {boolean} [props.required]
* @param {string} [props.inputType]
* @param {React.Dispatch<React.SetStateAction<any>>} [props.setAlert]
* @param {React.Dispatch<React.SetStateAction<string | number>>} [props.setValue] - A react state dispatch function to set
* the current number value
* @param {string} [props.prefix]
* @param {number} [props.minValue]
* @param {number} [props.maxValue]
* @param {boolean?} [props.encrypted]
* @param {boolean?} [props.numberText]
* @param {string} [props.appendCurrency]
* @param {{current: *}} [props.elementRef]
* @param {(e: Event) => void} [props.onChangeHandler]
* @param {string} [props.value]
* @param {number} [props.step]
* @param {boolean} [props.decimal]
* @param {string} [props.pattern]
* @param {string} [props.info]
* @param {string} [props.id]
* @param {string} [props.fontSize] - Eg. "20px"
* @param {string} [props.maxWidth] - Eg. "200px"
*/ function FormInput(props) {
try {
/**
* Destructure Props
*
* @abstract Destructure Props
*/ const { title , name , defaultValue , placeholder , autoComplete , onInputHandler , required , inputType , setAlert , prefix , minValue , maxValue , encrypted , numberText , appendCurrency , elementRef , onChangeHandler , value , step , decimal , pattern , info , fontSize , maxWidth , setValue , id , } = props;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Get Contexts
*
* @abstract { React.useContext }
*/ ////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Javascript Variables
*
* @abstract Non hook variables and functions
*/ function inputChangeHangler(/** @type {any} */ e) {
if (e.target.value.match(/./)) {
e.target.classList.remove("warning");
setAlert && setAlert(null);
} else if (e.target.required) {
e.target.classList.add("warning");
}
if (numberText) {
e.target.value = e.target.value.toString().match(/^0+$/) ? "0" : e.target.value.toString().replace(decimal ? /[^0-9\.]/g : /\D/g, "").replace(/^0*/, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
if (onInputHandler) onInputHandler(e);
if (onChangeHandler) onChangeHandler(e);
}
function toggleDropdown(/** @type {any} */ e) {
if (e.type.match(/enter/i) && window.innerWidth < 1200) {
return;
}
const infoWrapper = e.target.closest(".info-wrapper");
const dropdown = infoWrapper.querySelector(".info-dropdown");
if (e.type.match(/leave/i) && !dropdown.classList.contains("hidden")) {
dropdown.classList.add("hidden");
return;
} else if (e.type.match(/leave/i) && dropdown.classList.contains("hidden")) {
return;
}
if (!infoWrapper) {
dropdown.classList.add("hidden");
return;
}
if (dropdown.classList.contains("hidden")) {
dropdown.classList.remove("hidden");
return;
}
dropdown.classList.add("hidden");
}
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* React Hooks
*
* @abstract { useState, useEffect, useRef, etc ... }
*/ /** @type {React.MutableRefObject<HTMLInputElement>} */ const currentElementRef = elementRef ? elementRef : external_react_default().useRef();
////////////////////////////////////////
function decrementNumber(/** @type {any} */ e) {
const newValue = decimal ? parseFloat(numberFormatFloat({
value: currentElementRef.current?.value || 0
}).toString()) - (step ? parseFloat(step.toString()) : 20) : parseInt(numberFormat({
value: currentElementRef.current.value
}).toString()) - (step ? step : 20);
const currentNumberValue = decimal ? numberFormatFloat({
value: newValue,
format: "raw"
}) : numberFormat({
value: newValue,
format: "raw"
});
if (minValue && typeof currentNumberValue == "number" && currentNumberValue < minValue) return;
currentElementRef.current.value = decimal ? parseFloat(numberFormatFloat({
value: newValue,
format: "raw"
}).toString()).toFixed(typeof decimal === "number" ? decimal : 2) : numberFormat({
value: newValue,
format: "string"
}).toString();
if (setValue) setValue(currentElementRef.current.value);
}
function incrementNumber(/** @type {any} */ e) {
const newValue = decimal ? parseFloat(numberFormatFloat({
value: currentElementRef.current.value
}).toString()) + (step ? parseFloat(step.toString()) : 20) : parseInt(numberFormat({
value: currentElementRef.current.value
}).toString()) + (step ? step : 20);
const newFormattedValue = decimal ? parseFloat(numberFormatFloat({
value: newValue,
format: "raw"
}).toString()).toFixed(typeof decimal === "number" ? decimal : 2) : numberFormat({
value: newValue,
format: "string"
});
const currentNumberValue = decimal ? parseFloat(numberFormatFloat({
value: newFormattedValue,
format: "raw"
}).toString()) : parseInt(numberFormat({
value: newFormattedValue,
format: "raw"
}).toString());
if (maxValue && currentNumberValue > maxValue) return;
currentElementRef.current.value = newFormattedValue.toString();
if (setValue) setValue(currentElementRef.current.value);
}
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Function Return
*
* @abstract Main Function Return
*/ return /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
className: "form-input-wrapper flex flex-col items-start gap-0.5 w-full relative",
style: {
...maxWidth ? {
maxWidth: maxWidth
} : {}
},
children: [
title && /*#__PURE__*/ jsx_runtime_.jsx("label", {
htmlFor: name,
children: title
}),
/*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
className: "flex items-center w-full relative",
children: [
prefix && /*#__PURE__*/ jsx_runtime_.jsx("div", {
className: "absolute left-4 bottom-2 text-lg",
children: prefix
}),
/*#__PURE__*/ jsx_runtime_.jsx("input", {
type: inputType ? inputType : "text",
name: name,
id: id ? id : name,
ref: currentElementRef,
placeholder: placeholder ? placeholder : title ? title : "",
autoComplete: autoComplete,
onInput: (e)=>{
// if (!onInputHandler) return;
inputChangeHangler(e);
},
onChange: (e)=>{
// if (!onChangeHandler) return;
inputChangeHangler(e);
},
value: value ? value : undefined,
defaultValue: value ? undefined : defaultValue ? defaultValue : undefined,
pattern: pattern ? pattern.toString() : undefined,
required: required ? required : false,
style: {
...fontSize ? {
fontSize: fontSize
} : {},
...prefix ? {
paddingLeft: "35px"
} : {}
},
min: minValue,
max: maxValue,
"data-encrypted": encrypted ? encrypted : null,
"data-appendcurrency": appendCurrency ? appendCurrency : null,
className: "bg-white" + (info ? " pr-16" : "")
}),
numberText && /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
className: "absolute gap-1" + (info ? " right-12" : " right-4"),
style: {
top: "50%",
transform: "translate(0,-50%)"
},
children: [
/*#__PURE__*/ jsx_runtime_.jsx("span", {
className: "number-text-button w-10 md:w-8 h-10 md:h-8 rounded-full bg-slate-100 dark:bg-slate-800 flex items-center justify-center cursor-pointer hover:bg-slate-200 text-2xl font-semibold touch-none",
onMouseDown: (e)=>{
e.preventDefault();
if (window.innerWidth < 1200) return;
decrementNumber(e);
incrementTimeout = setTimeout(()=>{
incrementInterval = setInterval(()=>{
decrementNumber(e);
}, 50);
}, 200);
},
onTouchStart: (e)=>{
e.preventDefault();
if (window.innerWidth >= 1200) return;
decrementNumber(e);
incrementTimeout = setTimeout(()=>{
incrementInterval = setInterval(()=>{
decrementNumber(e);
}, 50);
}, 200);
},
onMouseUp: (e)=>{
window.clearTimeout(incrementTimeout);
window.clearInterval(incrementInterval);
},
onTouchEnd: (e)=>{
window.clearTimeout(incrementTimeout);
window.clearInterval(incrementInterval);
},
onMouseLeave: (e)=>{
window.clearTimeout(incrementTimeout);
window.clearInterval(incrementInterval);
},
onTouchMove: (e)=>{
e.preventDefault();
},
children: /*#__PURE__*/ jsx_runtime_.jsx("span", {
className: "pointer-events-none",
children: "-"
})
}),
/*#__PURE__*/ jsx_runtime_.jsx("span", {
className: "number-text-button w-10 md:w-8 h-10 md:h-8 rounded-full bg-slate-100 dark:bg-slate-800 flex items-center justify-center cursor-pointer hover:bg-slate-200 text-2xl font-semibold touch-none",
onMouseDown: (e)=>{
e.preventDefault();
if (window.innerWidth < 1200) return;
incrementNumber(e);
incrementTimeout = setTimeout(()=>{
incrementInterval = setInterval(()=>{
incrementNumber(e);
}, 50);
}, 200);
},
onTouchStart: (e)=>{
e.preventDefault();
if (window.innerWidth >= 1200) return;
incrementNumber(e);
incrementTimeout = setTimeout(()=>{
incrementInterval = setInterval(()=>{
incrementNumber(e);
}, 50);
}, 200);
},
onMouseUp: (e)=>{
window.clearTimeout(incrementTimeout);
window.clearInterval(incrementInterval);
},
onTouchEnd: (e)=>{
window.clearTimeout(incrementTimeout);
window.clearInterval(incrementInterval);
},
onMouseLeave: (e)=>{
window.clearTimeout(incrementTimeout);
window.clearInterval(incrementInterval);
},
children: /*#__PURE__*/ jsx_runtime_.jsx("span", {
className: "pointer-events-none",
children: "+"
})
})
]
}),
info && /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
className: "info-wrapper absolute right-2 w-8 h-8 rounded-full bg-white flex items-center justify-center z-10",
style: {
top: "50%",
transform: "translate(0,-50%)"
},
onMouseEnter: toggleDropdown,
onMouseLeave: toggleDropdown,
onClick: toggleDropdown,
children: [
/*#__PURE__*/ jsx_runtime_.jsx("img", {
src: "/images/info-outlined-black.png",
alt: "",
className: "w-6 h-6 object-contain opacity-60 pointer-events-none"
}),
/*#__PURE__*/ jsx_runtime_.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: /*#__PURE__*/ jsx_runtime_.jsx("span", {
children: info
})
}),
/*#__PURE__*/ jsx_runtime_.jsx("div", {
className: "absolute -top-2 w-12",
style: {
height: "45px"
}
})
]
})
]
})
]
});
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
} catch (error) {
console.log("ERROR in FormInput =>", error);
return /*#__PURE__*/ jsx_runtime_.jsx("div", {
children: "Form Input Error"
});
}
} /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
/***/ })
};
;
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,78 @@
"use strict";
exports.id = 7946;
exports.ids = [7946];
exports.modules = {
/***/ 7946:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Z": () => (/* binding */ VerificationBanner)
/* 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
*/ function VerificationBanner(props) {
/**
* 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)("a", {
href: "/email-verification",
className: "card w-full items-center justify-center py-4 gap-2",
children: [
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("img", {
src: "/images/warning.png",
alt: "Down Arrow",
width: 25,
className: ""
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("span", {
children: "Your Account is not verified. Please verify your account."
})
]
});
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
} /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
/***/ })
};
;
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,40 @@
"use strict";
exports.id = 8164;
exports.ids = [8164];
exports.modules = {
/***/ 8164:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (/* binding */ grabUserSchemaData)
/* harmony export */ });
// @ts-check
const serverError = __webpack_require__(2163);
const fs = __webpack_require__(7147);
const path = __webpack_require__(1017);
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
* ==============================================================================
* @param {Object} params
* @param {string | number} params.userId
* @returns {DSQL_DatabaseSchemaType[] | null}
*/ function grabUserSchemaData({ userId }) {
try {
const userSchemaFilePath = path.resolve(process.cwd(), `./jsonData/dbSchemas/users/user-${userId}/main.json`);
const userSchemaData = JSON.parse(fs.readFileSync(userSchemaFilePath, "utf-8"));
return userSchemaData;
} catch (/** @type {any} */ error) {
serverError({
component: "/functions/backend/grabUserSchemaData",
message: error.message
});
return null;
}
} /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
/***/ })
};
;
File diff suppressed because it is too large Load Diff
+175
View File
@@ -0,0 +1,175 @@
"use strict";
exports.id = 8313;
exports.ids = [8313];
exports.modules = {
/***/ 4981:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Z": () => (/* binding */ ThemeSelector)
/* 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 - React component props
*/ function ThemeSelector(props) {
/**
* Get Contexts
*
* @abstract { React.useContext }
*/ ////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Javascript Variables
*
* @abstract Non hook variables and functions
*/ ////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* React Hooks
*
* @abstract { useState, useEffect, useRef, etc ... }
*/ const [theme, setTheme] = react__WEBPACK_IMPORTED_MODULE_1___default().useState("Light Mode");
react__WEBPACK_IMPORTED_MODULE_1___default().useEffect(()=>{
let existingTheme = localStorage.getItem("theme");
if (existingTheme?.match(/dark/)) {
setTheme("Dark Mode");
}
}, []);
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Function Return
*
* @abstract Main Function Return
*/ return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
className: "",
id: "theme-selector-wrapper",
onClick: ()=>{
const graphicWrapper = document.getElementById("theme-selector-graphic-wrapper");
let existingTheme = localStorage.getItem("theme");
const sunIcon = graphicWrapper?.querySelector("img.sun");
const moonIcon = graphicWrapper?.querySelector("img.moon");
////////////////////////////////////////
if (!existingTheme || existingTheme?.match(/light/)) {
document.documentElement.className = "dark";
localStorage.setItem("theme", "dark");
existingTheme = "dark";
////////////////////////////////////////
sunIcon?.classList.add("hidden");
moonIcon?.classList.remove("hidden");
// @ts-ignore
graphicWrapper?.firstChild?.classList.add("ml-auto");
////////////////////////////////////////
setTheme("Dark Mode");
////////////////////////////////////////
} else if (existingTheme?.match(/dark/)) {
document.documentElement.className = "light";
localStorage.setItem("theme", "light");
existingTheme = "light";
////////////////////////////////////////
moonIcon?.classList.add("hidden");
sunIcon?.classList.remove("hidden");
// @ts-ignore
graphicWrapper?.firstChild?.classList.remove("ml-auto");
////////////////////////////////////////
setTheme("Light Mode");
////////////////////////////////////////
}
////////////////////////////////////////
},
children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
className: "p-1 rounded-full w-12 transition-all",
id: "theme-selector-graphic-wrapper",
children: /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
className: "pointer-events-none transition-all dark:ml-auto",
children: [
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("img", {
src: "/images/sun.png",
alt: "Sun Icon",
width: 18,
className: "sun dark:hidden"
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("img", {
src: "/images/new-moon.png",
alt: "Sun Icon",
width: 18,
className: "moon hidden dark:flex"
})
]
})
})
});
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
}
/***/ }),
/***/ 9678:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Z": () => (/* binding */ updateNavLinks)
/* harmony export */ });
// @ts-check
/**
* ==============================================================================
* Imports
* ==============================================================================
*/ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
*
* @param {object} param0
* @param {HTMLAnchorElement[] | NodeListOf<HTMLAnchorElement>} [param0.links]
*/ async function updateNavLinks({ links }) {
/** @type {NodeListOf<HTMLAnchorElement> | HTMLAnchorElement[]} */ let navLinks = links ? links : document.querySelectorAll("nav a");
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
if (navLinks) {
navLinks.forEach((link)=>{
if (link.dataset.currentlink === window.location.pathname) {
link.classList.add("active");
} else if (window.location.pathname.match(new RegExp(`${link.dataset.currentlink}\\/.*`)) && !link.dataset.strictlink) {
link.classList.add("active");
}
});
}
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
const isDbPathValid = window.location.pathname.match(/\/databases\/.*/);
if (isDbPathValid) {
const links1 = document.querySelectorAll("a");
if (links1 && window.location.search.match(/delegated=true/)) {
links1.forEach((link, index)=>{
if (!link?.pathname?.match(/databases/)) return;
link.href = link.pathname + window.location.search;
});
}
}
} /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
/***/ })
};
;
@@ -0,0 +1,90 @@
"use strict";
exports.id = 8326;
exports.ids = [8326];
exports.modules = {
/***/ 9046:
/***/ ((module) => {
// @ts-check
/**
* Regular expression to match default fields
*
* @description Regular expression to match default fields
*/
const defaultFieldsRegexp = /^id$|^uuid$|^date_created$|^date_created_code$|^date_created_timestamp$|^date_updated$|^date_updated_code$|^date_updated_timestamp$/;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
module.exports = defaultFieldsRegexp;
/***/ }),
/***/ 8326:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const decrypt = __webpack_require__(5425);
const defaultFieldsRegexp = __webpack_require__(9046);
/**
* Parse Database results
* ==============================================================================
* @description this function takes a database results array gotten from a DB handler
* function, decrypts encrypted fields, and returns an updated array with no encrypted
* fields
*
* @param {object} params - Single object params
* @param {any[]} params.unparsedResults - Array of data objects containing Fields(keys)
* and corresponding values of the fields(values)
* @param {import("../../types").DSQL_TableSchemaType} [params.tableSchema] - Table schema
* @returns {Promise<object[]|null>}
*/ module.exports = async function parseDbResults({ unparsedResults , tableSchema , }) {
/**
* Declare variables
*
* @description Declare "results" variable
*/ let parsedResults = [];
try {
/**
* Declare variables
*
* @description Declare "results" variable
*/ for(let pr = 0; pr < unparsedResults.length; pr++){
let result = unparsedResults[pr];
let resultFieldNames = Object.keys(result);
for(let i = 0; i < resultFieldNames.length; i++){
const resultFieldName = resultFieldNames[i];
let resultFieldSchema = tableSchema?.fields[i];
if (resultFieldName?.match(defaultFieldsRegexp)) {
continue;
}
let value = result[resultFieldName];
if (typeof value !== "number" && !value) {
continue;
}
if (resultFieldSchema?.encrypted) {
if (value?.match(/./)) {
result[resultFieldName] = decrypt(value);
}
}
}
parsedResults.push(result);
}
/**
* Declare variables
*
* @description Declare "results" variable
*/ return parsedResults;
} catch (/** @type {any} */ error) {
console.log("ERROR in parseDbResults Function =>", error.message);
return unparsedResults;
}
};
/***/ })
};
;
@@ -0,0 +1,90 @@
"use strict";
exports.id = 8345;
exports.ids = [8345];
exports.modules = {
/***/ 3314:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Z": () => (/* binding */ inputFileToBase64)
/* harmony export */ });
// @ts-check
/**
* @typedef {{
* fileBase64: string | null,
* fileBase64Full: string | null,
* fileName: string | null,
* fileSize: number | null,
* fileType: string | null,
* }} FunctionReturn
*/ /**
* Upload a file
* ==============================================================================
* @async
*
* @param {{
* inputFile: File,
* }} params - Single object passed
*
* @description This function takes in a *SINGLE* input file from a HTML file input element.
* HTML file input elements usually return an array of input objects, so be sure to select the target
* file from the array.
*
* @returns { Promise<FunctionReturn> } - Return Object
*/ async function inputFileToBase64({ inputFile }) {
/**
* == Initialize
*
* @description Initialize
*/ // const allowedTypesRegex = /image\/*|\/pdf/;
// if (!inputFile?.type?.match(allowedTypesRegex)) {
// window.alert(`We currently don't support ${inputFile.type} file types. Support is coming soon. For now we support only images and PDFs.`);
// return {
// fileBase64: null,
// fileBase64Full: null,
// fileName: inputFile.name,
// fileSize: null,
// fileType: null,
// };
// }
try {
/**
* == Process File
*/ let fileName = inputFile.name.replace(/\..*/, "");
/** Add source to new file **/ const fileData = await new Promise((resolve, reject)=>{
var reader = new FileReader();
reader.readAsDataURL(inputFile);
reader.onload = function() {
resolve(reader.result);
};
reader.onerror = function(/** @type {any} */ error) {
console.log("Error: ", error.message);
};
});
return {
fileBase64: fileData.replace(/.*?base64,/, ""),
fileBase64Full: fileData,
fileName: fileName,
fileSize: inputFile.size,
fileType: inputFile.type
};
} catch (/** @type {any} */ error) {
console.log("Image Processing Error! =>", error.message);
return {
fileBase64: null,
fileBase64Full: null,
fileName: inputFile.name,
fileSize: null,
fileType: null
};
}
} ////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/***/ })
};
;
File diff suppressed because it is too large Load Diff
+284
View File
@@ -0,0 +1,284 @@
"use strict";
exports.id = 8499;
exports.ids = [8499];
exports.modules = {
/***/ 8499:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/** # MODULE TRACE
======================================================================
* Detected 3 files that call this module. The files are listed below:
======================================================================
* `import` Statement Found in [get.js] => file:///d:\GitHub\datasquirel\pages\api\query\get.js
* `import` Statement Found in [post.js] => file:///d:\GitHub\datasquirel\pages\api\query\post.js
* `import` Statement Found in [add-user.js] => file:///d:\GitHub\datasquirel\pages\api\user\add-user.js
==== MODULE TRACE END ==== */ // @ts-check
const fs = __webpack_require__(7147);
const fullAccessDbHandler = __webpack_require__(8539);
const varReadOnlyDatabaseDbHandler = __webpack_require__(3118);
const serverError = __webpack_require__(3017);
const addDbEntry = __webpack_require__(5338);
const updateDbEntry = __webpack_require__(5886);
const deleteDbEntry = __webpack_require__(6147);
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
* Run DSQL users queries
* ==============================================================================
* @param {object} params - An object containing the function parameters.
* @param {string} params.dbFullName - Database full name. Eg. "datasquire_user_2_test"
* @param {string|any} params.query - Query string or object
* @param {boolean} [params.readOnly] - Is this operation read only?
* @param {import("../../../types").DSQL_DatabaseSchemaType} [params.dbSchema] - Database schema
* @param {string[]} [params.queryValuesArray] - An optional array of query values if "?" is used in the query string
* @param {string} [params.tableName] - Table Name
*
* @return {Promise<any>}
*/ async function runQuery({ dbFullName , query , readOnly , dbSchema , queryValuesArray , tableName , }) {
/**
* Declare variables
*
* @description Declare "results" variable
*/ /** @type {any} */ let result;
/** @type {any} */ let error;
/** @type {import("../../../types").DSQL_TableSchemaType | undefined} */ let tableSchema;
if (dbSchema) {
try {
const table = tableName ? tableName : typeof query == "string" ? null : query ? query?.table : null;
if (!table) throw new Error("No table name provided");
tableSchema = dbSchema.tables.filter((tb)=>tb?.tableName === table)[0];
} catch (_err) {
// console.log("ERROR getting tableSchema: ", _err.message);
}
}
/**
* Declare variables
*
* @description Declare "results" variable
*/ try {
if (typeof query === "string") {
if (readOnly) {
result = await varReadOnlyDatabaseDbHandler({
queryString: query,
queryValuesArray,
database: dbFullName,
tableSchema
});
} else {
result = await fullAccessDbHandler({
queryString: query,
queryValuesArray,
database: dbFullName,
tableSchema
});
}
} else if (typeof query === "object") {
/**
* Declare variables
*
* @description Declare "results" variable
*/ const { data , action , table: table1 , identifierColumnName , identifierValue , update , duplicateColumnName , duplicateColumnValue , } = query;
switch(action.toLowerCase()){
case "insert":
result = await addDbEntry({
dbContext: "Dsql User",
paradigm: "Full Access",
dbFullName: dbFullName,
tableName: table1,
data: data,
update,
duplicateColumnName,
duplicateColumnValue,
tableSchema
});
if (!result?.insertId) {
error = new Error("Couldn't insert data");
}
break;
case "update":
result = await updateDbEntry({
dbContext: "Dsql User",
paradigm: "Full Access",
dbFullName: dbFullName,
tableName: table1,
data: data,
identifierColumnName,
identifierValue,
tableSchema
});
break;
case "delete":
result = await deleteDbEntry({
dbContext: "Dsql User",
paradigm: "Full Access",
dbFullName: dbFullName,
tableName: table1,
identifierColumnName,
identifierValue,
tableSchema
});
break;
default:
result = null;
break;
}
}
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
} catch (/** @type {any} */ error1) {
serverError({
component: "functions/backend/runQuery",
message: error1.message
});
result = null;
error1 = error1.message;
}
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
return {
result,
error
};
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
}
module.exports = runQuery;
/***/ }),
/***/ 8539:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const DSQL_USER_DB_HANDLER = __webpack_require__(3403);
const parseDbResults = __webpack_require__(8326);
const serverError = __webpack_require__(3017);
/**
*
* @param {object} param0
* @param {string} param0.queryString
* @param {string} param0.database
* @param {import("../../types").DSQL_TableSchemaType | null} [param0.tableSchema]
* @param {string[]} [param0.queryValuesArray]
* @returns
*/ module.exports = async function fullAccessDbHandler({ queryString , database , tableSchema , queryValuesArray , }) {
/**
* Declare variables
*
* @description Declare "results" variable
*/ let results;
/**
* Fetch from db
*
* @description Fetch data from db if no cache
*/ try {
/** ********************* Run Query */ results = await DSQL_USER_DB_HANDLER({
paradigm: "Full Access",
database,
queryString,
queryValues: queryValuesArray
});
////////////////////////////////////////
} catch (/** @type {any} */ error) {
////////////////////////////////////////
serverError({
component: "fullAccessDbHandler",
message: error.message
});
/**
* Return error
*/ return error.message;
}
/**
* Return results
*
* @description Return results add to cache if "req" param is passed
*/ if (results && tableSchema) {
const unparsedResults = results;
const parsedResults = await parseDbResults({
unparsedResults: unparsedResults,
tableSchema: tableSchema
});
return parsedResults;
} else if (results) {
return results;
} else {
return null;
}
};
/***/ }),
/***/ 3118:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const fs = __webpack_require__(7147);
const serverError = __webpack_require__(3017);
const parseDbResults = __webpack_require__(8326);
const DSQL_USER_DB_HANDLER = __webpack_require__(3403);
/**
*
* @param {object} param0
* @param {string} param0.queryString
* @param {string} param0.database
* @param {string[]} [param0.queryValuesArray]
* @param {import("../../types").DSQL_TableSchemaType} [param0.tableSchema]
* @returns
*/ module.exports = async function varReadOnlyDatabaseDbHandler({ queryString , database , queryValuesArray , tableSchema , }) {
/**
* Declare variables
*
* @description Declare "results" variable
*/ let results;
/**
* Fetch from db
*
* @description Fetch data from db if no cache
*/ try {
results = await DSQL_USER_DB_HANDLER({
paradigm: "Read Only",
database,
queryString,
queryValues: queryValuesArray
});
////////////////////////////////////////
} catch (/** @type {any} */ error) {
////////////////////////////////////////
serverError({
component: "varReadOnlyDatabaseDbHandler",
message: error.message,
noMail: true
});
/**
* Return error
*/ return error.message;
}
/**
* Return results
*
* @description Return results add to cache if "req" param is passed
*/ if (results) {
const unparsedResults = results;
const parsedResults = await parseDbResults({
unparsedResults: unparsedResults,
tableSchema: tableSchema
});
return parsedResults;
} else {
return null;
}
};
/***/ })
};
;
+109
View File
@@ -0,0 +1,109 @@
"use strict";
exports.id = 8682;
exports.ids = [8682];
exports.modules = {
/***/ 8682:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const fs = __webpack_require__(7147);
const path = __webpack_require__(1017);
const mysql = __webpack_require__(2261);
const SSL_DIR = "/app/ssl";
let DSQL_USER = mysql({
config: {
host: process.env.DSQL_DB_HOST,
user: process.env.DSQL_DB_READ_ONLY_USERNAME,
password: process.env.DSQL_DB_READ_ONLY_PASSWORD,
charset: "utf8mb4",
ssl: {
ca: fs.readFileSync(`${SSL_DIR}/ca-cert.pem`)
}
}
});
/**
* DSQL user read-only DB handler
* @param {object} params
* @param {"Full Access" | "FA" | "Read Only"} params.paradigm
* @param {string} params.database
* @param {string} params.queryString
* @param {string[]} [params.queryValues]
*/ function DSQL_USER_DB_HANDLER({ paradigm , database , queryString , queryValues , }) {
try {
return new Promise((resolve, reject)=>{
const fullAccess = paradigm?.match(/full.access|^fa$/i) ? true : false;
try {
if (fullAccess) {
DSQL_USER = mysql({
config: {
host: process.env.DSQL_DB_HOST,
user: process.env.DSQL_DB_FULL_ACCESS_USERNAME,
password: process.env.DSQL_DB_FULL_ACCESS_PASSWORD,
database: database,
ssl: {
ca: fs.readFileSync(`${SSL_DIR}/ca-cert.pem`)
}
}
});
} else {
DSQL_USER = mysql({
config: {
host: process.env.DSQL_DB_HOST,
user: process.env.DSQL_DB_READ_ONLY_USERNAME,
password: process.env.DSQL_DB_READ_ONLY_PASSWORD,
database: database,
ssl: {
ca: fs.readFileSync(`${SSL_DIR}/ca-cert.pem`)
}
}
});
}
/**
* ### Run query Function
* @param {any} results
*/ function runQuery(results) {
DSQL_USER.end();
resolve(JSON.parse(JSON.stringify(results)));
}
/**
* ### Query Error
* @param {any} err
*/ function queryError(err) {
DSQL_USER.end();
resolve({
error: err.message,
queryStringGenerated: queryString,
queryValuesGenerated: queryValues,
sql: err.sql
});
}
if (queryValues && Array.isArray(queryValues) && queryValues[0]) {
DSQL_USER.query(queryString, queryValues).then(runQuery).catch(queryError);
} else {
DSQL_USER.query(queryString).then(runQuery).catch(queryError);
}
////////////////////////////////////////
} catch (/** @type {any} */ error) {
////////////////////////////////////////
fs.appendFileSync("./.tmp/dbErrorLogs.txt", error.message + "\n" + Date() + "\n\n\n", "utf8");
resolve({
error: error.message
});
}
});
} catch (/** @type {any} */ error) {
return {
success: false,
error: error.message
};
}
}
module.exports = DSQL_USER_DB_HANDLER;
/***/ })
};
;
@@ -0,0 +1,85 @@
"use strict";
exports.id = 8999;
exports.ids = [8999];
exports.modules = {
/***/ 8999:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
/**
* ==============================================================================
* Imports
* ==============================================================================
*/
const DB_HANDLER = __webpack_require__(2224);
const serverError = __webpack_require__(2163);
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
* ==============================================================================
* Main Function
* ==============================================================================
* @async
*
* @param {{
* user: {id:number},
* confirmedDelegetedUser: any,
* database: string,
* table: string,
* priviledgeRegex: RegExp,
* dbId: number,
* }} params - parameters
*
* @returns {Promise<boolean>} does user have the rights for this operation? true if yes, false if no
*/ module.exports = async function checkUserRights({ user , confirmedDelegetedUser , database , table , priviledgeRegex , dbId , }) {
/**
* Fetch user
*
* @description Fetch user from db
*/ let userConfirmation, priviledge;
try {
if (confirmedDelegetedUser?.delegated) {
userConfirmation = await DB_HANDLER(`SELECT priviledge FROM delegated_user_tables WHERE root_user_id=? AND delegated_user_id=? AND \`database\`=? AND \`table\`=?`, [
confirmedDelegetedUser.rootUserId,
user.id,
database,
table
]);
priviledge = userConfirmation[0]?.priviledge?.match(priviledgeRegex);
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
} else {
userConfirmation = await DB_HANDLER(`SELECT table_slug FROM user_database_tables WHERE user_id=? AND table_slug=? AND db_id=?`, [
user.id,
table,
dbId
]);
priviledge = true;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
}
} catch (/** @type {any} */ error) {
serverError({
component: "checkUserRights",
message: error.message,
user: user
});
}
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
if (userConfirmation && userConfirmation[0] && priviledge) {
return true;
} else {
return false;
}
}; ////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/***/ })
};
;
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,57 @@
"use strict";
exports.id = 9132;
exports.ids = [9132];
exports.modules = {
/***/ 9132:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const fs = __webpack_require__(7147);
const serverError = __webpack_require__(3017);
const NO_DB_HANDLER = __webpack_require__(7487);
/**
* Create database from Schema Function
* ==============================================================================
* @param {string} queryString - Query String
* @returns {Promise<any>}
*/ module.exports = async function noDatabaseDbHandler(queryString) {
"production"?.match(/dev/) && fs.appendFileSync("./.tmp/sqlQuery.sql", queryString + "\n" + Date() + "\n\n\n", "utf8");
/**
* Declare variables
*
* @description Declare "results" variable
*/ let results;
/**
* Fetch from db
*
* @description Fetch data from db if no cache
*/ try {
/** ********************* Run Query */ results = await NO_DB_HANDLER(queryString);
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
} catch (/** @type {any} */ error) {
serverError({
component: "noDatabaseDbHandler",
message: error.message
});
console.log("ERROR in noDatabaseDbHandler =>", error.message);
}
/**
* Return results
*
* @description Return results add to cache if "req" param is passed
*/ if (results) {
return results;
} else {
return null;
}
};
/***/ })
};
;
@@ -0,0 +1,14 @@
"use strict";
exports.id = 9258;
exports.ids = [9258];
exports.modules = {
/***/ 9258:
/***/ ((module) => {
module.exports = JSON.parse('{"tableName":"users","tableFullName":"Users","fields":[{"fieldName":"first_name","dataType":"VARCHAR(100)","notNullValue":true},{"fieldName":"last_name","dataType":"VARCHAR(100)","notNullValue":true},{"fieldName":"email","dataType":"VARCHAR(200)","notNullValue":true},{"fieldName":"phone","dataType":"VARCHAR(50)"},{"fieldName":"user_type","dataType":"VARCHAR(20)","defaultValue":"default"},{"fieldName":"username","dataType":"VARCHAR(100)","nullValue":true},{"fieldName":"password","dataType":"VARCHAR(250)","notNullValue":true},{"fieldName":"image","dataType":"VARCHAR(250)","defaultValue":"/images/user_images/user-preset.png"},{"fieldName":"image_thumbnail","dataType":"VARCHAR(250)","defaultValue":"/images/user_images/user-preset-thumbnail.png"},{"fieldName":"address","dataType":"VARCHAR(255)"},{"fieldName":"city","dataType":"VARCHAR(50)"},{"fieldName":"state","dataType":"VARCHAR(50)"},{"fieldName":"country","dataType":"VARCHAR(50)"},{"fieldName":"zip_code","dataType":"VARCHAR(50)"},{"fieldName":"social_login","dataType":"TINYINT","defaultValue":"0"},{"fieldName":"social_platform","dataType":"VARCHAR(50)","nullValue":true},{"fieldName":"social_id","dataType":"VARCHAR(250)","nullValue":true},{"fieldName":"more_user_data","dataType":"BIGINT","defaultValue":"0"},{"fieldName":"verification_status","dataType":"TINYINT","defaultValue":"0"},{"fieldName":"temp_login_code","dataType":"VARCHAR(50)","nullValue":true}]}');
/***/ })
};
;
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,97 @@
"use strict";
exports.id = 9360;
exports.ids = [9360];
exports.modules = {
/***/ 9360:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Z": () => (/* binding */ ScrollToTopButton)
/* 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 lucide_react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2423);
/* harmony import */ var lucide_react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(lucide_react__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6689);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_2__);
// @ts-check
/**
* ==============================================================================
* Imports
* ==============================================================================
*/
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
* ==============================================================================
* Main Component { Functional }
* ==============================================================================
* @param {object} props
* @param {boolean} [props.snug]
*/ function ScrollToTopButton({ snug }) {
/**
* Get Contexts
*
* @abstract { React.useContext }
*/ ////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Javascript Variables
*
* @abstract Non hook variables and functions
*/ ////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* React Hooks
*
* @abstract { useState, useEffect, useRef, etc ... }
*/ const [isVisible, setIsVisible] = react__WEBPACK_IMPORTED_MODULE_2___default().useState(false);
react__WEBPACK_IMPORTED_MODULE_2___default().useEffect(()=>{
window.addEventListener("scroll", (e)=>{
if (window.scrollY > 600) {
setIsVisible(true);
} else {
setIsVisible(false);
}
});
}, []);
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Function Return
*
* @abstract Main Function Return
*/ return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx((react__WEBPACK_IMPORTED_MODULE_2___default().Fragment), {
children: isVisible && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("button", {
className: "fixed z-40 w-12 h-12 p-2 rounded-full bg-white dark:bg-slate-600 shadow-xl flex items-center justify-center hover:bg-slate-800 dark:hover:bg-slate-800 text-slate-500 dark:text-slate-200 outline-slate-300 dark:outline-transparent" + (snug ? " bottom-6 right-4" : " bottom-4 md:bottom-10 right-4 md:right-10"),
style: {
outlineStyle: "solid",
outlineWidth: "1px",
zIndex: 2000
},
onClick: (e)=>{
window.scrollTo({
top: 0,
left: 0,
behavior: "smooth"
});
},
children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(lucide_react__WEBPACK_IMPORTED_MODULE_1__.ChevronUp, {
size: 20
})
})
});
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
}
/***/ })
};
;
@@ -0,0 +1,55 @@
"use strict";
exports.id = 9395;
exports.ids = [9395];
exports.modules = {
/***/ 9395:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const fs = __webpack_require__(7147);
const path = __webpack_require__(1017);
const mysql = __webpack_require__(2261);
const SSL_DIR = "/app/ssl";
const MASTER = mysql({
config: {
host: process.env.DSQL_DB_HOST,
user: process.env.DSQL_DB_USERNAME,
password: process.env.DSQL_DB_PASSWORD,
database: process.env.DSQL_DB_NAME,
port: process.env.DB_PORT ? Number(process.env.DB_PORT) : undefined,
charset: "utf8mb4",
ssl: {
ca: fs.readFileSync(`${SSL_DIR}/ca-cert.pem`)
}
}
});
/**
* DSQL user read-only DB handler
* @param {object} params
* @param {string} params.paradigm
* @param {string} params.database
* @param {string} params.queryString
* @param {string[]} [params.queryValues]
*/ // @ts-ignore
async function DB_HANDLER(...args) {
try {
const results = await MASTER.query(...args);
/** ********************* Clean up */ await MASTER.end();
return JSON.parse(JSON.stringify(results));
} catch (/** @type {any} */ error) {
console.log("DB Error =>", error);
return {
success: false,
error: error.message
};
}
}
module.exports = DB_HANDLER;
/***/ })
};
;
+344
View File
@@ -0,0 +1,344 @@
"use strict";
exports.id = 9417;
exports.ids = [9417];
exports.modules = {
/***/ 9417:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Z": () => (/* binding */ TargetUserPreviewPopup)
/* 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__);
/* harmony import */ var _functions_frontend_fetchApi__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(6729);
/* harmony import */ var _general_GeneralPopup__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(5472);
/* harmony import */ var _general_LoadingBlock__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(5264);
/* harmony import */ var _form_FormCheckboxes__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(9486);
/* harmony import */ var _form_FormSelect__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(4114);
// @ts-check
/**
* ==============================================================================
* Imports
* ==============================================================================
*/
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
* ==============================================================================
* Main Component { Functional }
* ==============================================================================
* @param {Object} props
* @param {import("@/package-shared/types").MYSQL_user_users_table_def | null} props.targetUser
* @param {React.Dispatch<React.SetStateAction<import("@/package-shared/types").MYSQL_user_users_table_def | null>>} props.setTargetUser
* @param {import("@/package-shared/types").UserType} props.user
*/ function TargetUserPreviewPopup({ targetUser , user , setTargetUser , }) {
/**
* Get Contexts
*
* @abstract { React.useContext }
*/ ////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Javascript Variables
*
* @abstract Non hook variables and functions
*/ const userPriviledges = __webpack_require__(9169);
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
if (!targetUser) {
return null;
}
/**
* React Hooks
*
* @abstract { useState, useEffect, useRef, etc ... }
*/ const [loading, setLoading] = react__WEBPACK_IMPORTED_MODULE_1___default().useState(true);
/** @type {any} */ const databasesState = react__WEBPACK_IMPORTED_MODULE_1___default().useState([]);
/** @type {[ dbTables: import("@/package-shared/types").DSQL_MYSQL_user_databases_Type[], setDbTables: React.Dispatch<React.SetStateAction<import("@/package-shared/types").DSQL_MYSQL_user_databases_Type[]>> ]} */ const [databases, setDatabases] = databasesState;
const [allDbSelected, setAllDbSelected] = react__WEBPACK_IMPORTED_MODULE_1___default().useState(false);
/** @type {any} */ const priviledgesState = react__WEBPACK_IMPORTED_MODULE_1___default().useState(targetUser ? targetUser.user_priviledge?.split("|") : []);
/** @type {[ dbTables: string[], setDbTables: React.Dispatch<React.SetStateAction<string[]>> ]} */ const [priviledges, setPriviledges] = priviledgesState;
const [databasesAccess, setDatabasesAccess] = react__WEBPACK_IMPORTED_MODULE_1___default().useState(targetUser?.database_access ? targetUser.database_access.split("|") : []);
/** @type {any} */ const targetDbsState = react__WEBPACK_IMPORTED_MODULE_1___default().useState(targetUser ? targetUser.database_access?.split("|")[0] : null);
/** @type {[ dbTables: string | null, setDbTables: React.Dispatch<React.SetStateAction<string | null>> ]} */ const [targetDb, setTargetDb] = targetDbsState;
/** @type {any} */ const dbTablesState = react__WEBPACK_IMPORTED_MODULE_1___default().useState([]);
/** @type {[ dbTables: import("@/package-shared/types").MYSQL_user_database_tables_table_def[] | null, setDbTables: React.Dispatch<React.SetStateAction<import("@/package-shared/types").MYSQL_user_database_tables_table_def[] | null>> ]} */ const [dbTables, setDbTables] = dbTablesState;
/** @type {any} */ const selectedDbTablesState = react__WEBPACK_IMPORTED_MODULE_1___default().useState([]);
/** @type {[ dbTables: string[], setDbTables: React.Dispatch<React.SetStateAction<string[]>> ]} */ const [selectedDbTables, setSlectedDbTables] = selectedDbTablesState;
react__WEBPACK_IMPORTED_MODULE_1___default().useEffect(()=>{
(0,_functions_frontend_fetchApi__WEBPACK_IMPORTED_MODULE_6__/* ["default"] */ .Z)("/api/getUserDatabases").then((res)=>{
if (res.success) {
setDatabases(res.databases);
}
});
}, []);
react__WEBPACK_IMPORTED_MODULE_1___default().useEffect(()=>{
if (!targetUser) return;
if (!targetDb) {
setTargetDb(targetUser.database_access?.split("|")[0] || null);
} else {
(0,_functions_frontend_fetchApi__WEBPACK_IMPORTED_MODULE_6__/* ["default"] */ .Z)(`/api/getDatabaseTables?dbSlug=${targetDb}&dbOwnerId=${user.id}&delegatedUserId=${targetUser.invited_user_id}`).then((res)=>{
if (res.success) {
setDbTables(null);
setTimeout(()=>{
setDbTables([
...res.tables
]);
}, 200);
}
if (res.accessed_tables && res.accessed_tables[0] && !selectedDbTables[0]) {
setSlectedDbTables(res.accessed_tables.map((/** @type {any} */ acTb)=>`${acTb.database}-${acTb.table}`));
}
});
}
}, [
targetDb
]);
react__WEBPACK_IMPORTED_MODULE_1___default().useEffect(()=>{
setLoading(true);
if (targetUser) {
setPriviledges(targetUser.user_priviledge?.split("|") || []);
setDatabasesAccess(targetUser.database_access?.split("|") || []);
}
setTimeout(()=>{
setLoading(false);
}, 500);
}, [
targetUser
]);
react__WEBPACK_IMPORTED_MODULE_1___default().useEffect(()=>{
setTargetDb(databasesAccess?.[0] || null);
}, [
databasesAccess
]);
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Function Return
*
* @abstract Main Function Return
*/ return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_general_GeneralPopup__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .ZP, {
title: "target-user-popup",
closePopupDispatch: ()=>{
setTargetUser(null);
},
children: [
loading && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_general_LoadingBlock__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z, {
position: "relative"
}),
!loading && targetUser && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx((react__WEBPACK_IMPORTED_MODULE_1___default().Fragment), {
children: /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
className: "flex-col w-full items-start p-4",
children: [
/*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("h4", {
className: "m-0",
children: [
"Edit ",
targetUser.first_name,
" ",
targetUser.last_name,
"'s Access"
]
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("hr", {}),
/*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("form", {
className: "flex flex-col items-start w-full",
onSubmit: (e)=>{
e.preventDefault();
setLoading(true);
(0,_functions_frontend_fetchApi__WEBPACK_IMPORTED_MODULE_6__/* ["default"] */ .Z)("/api/updateAdminUserAccess", {
method: "post",
body: {
userObject: targetUser,
user_priviledge: priviledges.join("|"),
database_access: databasesAccess?.join("|"),
db_tables: databasesAccess && databasesAccess[0] ? selectedDbTables.join("|") : "",
inv_user_id: targetUser.invited_user_id
}
}, true).then((res)=>{
window.location.reload();
setTimeout(()=>{
setLoading(false);
}, 500);
});
},
children: [
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("h3", {
className: "m-0 text-lg font-semibold mb-1 text-slate-600",
children: "User Priviledges"
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_form_FormCheckboxes__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Z, {
checkBoxValues: userPriviledges.map((userPriviledge)=>{
return {
title: userPriviledge,
name: userPriviledge,
default: priviledges.includes(userPriviledge) ? true : false,
onChangeHandler: (e)=>{
if (priviledges.includes(userPriviledge)) {
let newArray = priviledges.filter((priv)=>priv != userPriviledge);
setPriviledges([
...newArray,
]);
} else {
setPriviledges((prev)=>[
...prev,
userPriviledge,
]);
}
}
};
}),
smallText: true,
flexRow: true
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("hr", {
className: "my-6"
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("h3", {
className: "m-0 text-lg font-semibold mb-2 text-slate-600",
children: "Databases Access"
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("span", {
className: "button outlined gray px-4 py-1 -mt-1 mb-1.5",
onClick: (e)=>{
if (allDbSelected) {
databases.forEach((db)=>{
setTimeout(()=>{
/** @type {HTMLInputElement} */ // @ts-ignore
const elt = document.getElementById(db.db_slug);
if (elt?.checked) elt.click();
}, 200);
});
setAllDbSelected(false);
} else {
databases.forEach((db)=>{
setTimeout(()=>{
/** @type {HTMLInputElement} */ // @ts-ignore
const elt = document.getElementById(db.db_slug);
if (!elt.checked) elt.click();
}, 200);
});
setAllDbSelected(true);
}
},
children: allDbSelected ? "Deselect All" : "Select All"
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_form_FormCheckboxes__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Z, {
checkBoxValues: databases.map((db)=>{
return {
title: db.db_name,
name: db.db_slug,
onChangeHandler: (e)=>{
if (databasesAccess.includes(db.db_slug)) {
let newArray = databasesAccess.filter((_db)=>_db != db.db_slug);
setDatabasesAccess([
...newArray,
]);
} else {
setDatabasesAccess((prev)=>[
...prev,
db.db_slug,
]);
}
if (databasesAccess.length === databases.length) {
setAllDbSelected(true);
} else {
setAllDbSelected(false);
}
},
default: databasesAccess.includes(db.db_slug) ? true : false
};
}),
smallText: true,
flexRow: true
}),
databasesAccess && databasesAccess[0] && /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)((react__WEBPACK_IMPORTED_MODULE_1___default().Fragment), {
children: [
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("hr", {
className: "my-6"
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("h3", {
className: "m-0 text-lg font-semibold mb-2 text-slate-600",
children: "Database Tables"
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_form_FormSelect__WEBPACK_IMPORTED_MODULE_5__/* ["default"] */ .Z, {
required: true,
selectOptions: databases.filter((db)=>databasesAccess.includes(db.db_slug)).map((db)=>{
return {
title: db.db_name,
payload: db.db_slug
};
}),
name: "databases",
onChangeHandler: (e)=>{
setTargetDb(e.target.value);
}
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
className: "h-2"
}),
dbTables && dbTables[0] && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_form_FormCheckboxes__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Z, {
checkBoxValues: dbTables.map((dbTable)=>{
return {
title: dbTable.table_name,
name: dbTable.table_slug,
onChangeHandler: (e)=>{
if (selectedDbTables.includes(`${targetDb}-${dbTable.table_slug}`)) {
let newArray = selectedDbTables.filter((table)=>table != `${targetDb}-${dbTable.table_slug}`);
setSlectedDbTables([
...newArray,
]);
} else {
setSlectedDbTables((prev)=>[
...prev,
`${targetDb}-${dbTable.table_slug}`,
]);
}
},
default: selectedDbTables.includes(`${targetDb}-${dbTable.table_slug}`) ? true : false
};
}),
smallText: true,
flexRow: true
})
]
}),
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("button", {
className: "mt-4 w-full",
children: "Update User Access"
})
]
})
]
})
})
]
});
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
} /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
/***/ }),
/***/ 9169:
/***/ ((module) => {
module.exports = JSON.parse('["Edit Tables","Update Entries","Create Table","Delete Entries","Delete Tables"]');
/***/ })
};
;
+161
View File
@@ -0,0 +1,161 @@
"use strict";
exports.id = 9471;
exports.ids = [9471];
exports.modules = {
/***/ 9471:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Z": () => (/* binding */ Modal)
/* 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__);
/* harmony import */ var react_dom_client__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7849);
/* harmony import */ var react_dom_client__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react_dom_client__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var lucide_react__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(2423);
/* harmony import */ var lucide_react__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(lucide_react__WEBPACK_IMPORTED_MODULE_3__);
// @ts-check
/**
* ==============================================================================
* Imports
* ==============================================================================
*/
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
* ==============================================================================
* Main Component { Functional }
* ==============================================================================
* @param {Object} props - React component props including { children }
* @param {React.ReactNode} props.children - React children
* @param {boolean} props.open
* @param {React.Dispatch<React.SetStateAction<boolean>>} [props.setOpen]
* @param {()=>void} [props.onClose]
* @param {string} [props.maxWidth] - Ex "500px"
*/ function Modal({ children , open , setOpen , onClose , maxWidth }) {
/**
* Get Contexts
*
* @description { React.useContext }
*/ ////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Javascript Variables
*
* @description Non hook variables and functions
*/ ////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* React Hooks
*
* @description { useState, useEffect, useRef, etc ... }
*/ react__WEBPACK_IMPORTED_MODULE_1___default().useEffect(()=>{
if (open) {
const modalWrapper = document.createElement("div");
modalWrapper.className = "modal-wrapper";
const domNode = (0,react_dom_client__WEBPACK_IMPORTED_MODULE_2__.createRoot)(modalWrapper);
domNode.render(/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(ModalComponent, {
onClose: onClose,
maxWidth: maxWidth,
children: children
}));
document.body.appendChild(modalWrapper);
} else {
document.querySelectorAll(".modal-wrapper").forEach((modalEl)=>{
modalEl.parentElement?.removeChild(modalEl);
});
}
}, [
open
]);
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/**
* Function Return
*
* @description Main Function Return
*/ ////////////////////////////////////////
return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.Fragment, {});
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
}
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
* @param {Object} props - React component props including { children }
* @param {React.ReactNode} props.children - React children
* @param {()=>void} [props.onClose]
* @param {string} [props.maxWidth]
* @param {boolean} [props.open]
*/ function ModalComponent({ children , onClose , maxWidth , open }) {
/** @type {React.Ref<HTMLDivElement>} */ // @ts-ignore
const modalRef = react__WEBPACK_IMPORTED_MODULE_1___default().useRef();
// React.useEffect(() => {
// if (!open) {
// /** @type {HTMLDivElement} */ // @ts-ignore
// const modalEl = modalRef.current?.closest(".modal-wrapper");
// closeModal({ modalEl });
// }
// }, [open]);
return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)((react__WEBPACK_IMPORTED_MODULE_1___default().Fragment), {
children: [
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
className: "modal-cancel",
onClick: (e)=>{
/** @type {HTMLDivElement} */ // @ts-ignore
const modalEl = e.target.closest(".modal-wrapper");
closeModal({
modalEl,
closeFn: onClose
});
}
}),
/*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
className: "modal-content",
style: {
maxWidth: maxWidth || undefined
},
ref: modalRef,
children: [
children,
" ",
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("button", {
className: "ghost modal-cancel-button",
onClick: (e)=>{
/** @type {HTMLDivElement} */ // @ts-ignore
const modalEl = e.target.closest(".modal-wrapper");
closeModal({
modalEl,
closeFn: onClose
});
},
children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(lucide_react__WEBPACK_IMPORTED_MODULE_3__.X, {})
})
]
})
]
});
}
/**
* @param {object} param0
* @param {HTMLElement} param0.modalEl
* @param {()=>void} [param0.closeFn]
*/ function closeModal({ modalEl , closeFn }) {
if (closeFn) closeFn();
modalEl.parentElement?.removeChild(modalEl);
}
/***/ })
};
;

Some files were not shown because too many files have changed in this diff Show More