Remove all 'useLocal' params
This commit is contained in:
parent
16191975f9
commit
7d0f3e12f3
1
dist/index.d.ts
vendored
1
dist/index.d.ts
vendored
@ -3,6 +3,7 @@ declare global {
|
||||
var DSQL_DB_CONN: ServerlessMysql | undefined;
|
||||
var DSQL_READ_ONLY_DB_CONN: ServerlessMysql | undefined;
|
||||
var DSQL_FULL_ACCESS_DB_CONN: ServerlessMysql | undefined;
|
||||
var DSQL_USE_LOCAL: boolean | undefined;
|
||||
}
|
||||
/**
|
||||
* Imports
|
||||
|
@ -8,11 +8,10 @@ type Param = {
|
||||
dbFullName: string;
|
||||
tableName?: string;
|
||||
dbSchema?: import("../../../types").DSQL_DatabaseSchemaType;
|
||||
useLocal?: boolean;
|
||||
debug?: boolean;
|
||||
};
|
||||
/**
|
||||
* # Get Function FOr API
|
||||
*/
|
||||
export default function apiGet({ query, dbFullName, queryValues, tableName, dbSchema, useLocal, debug, }: Param): Promise<import("../../../types").GetReturn>;
|
||||
export default function apiGet({ query, dbFullName, queryValues, tableName, dbSchema, debug, }: Param): Promise<import("../../../types").GetReturn>;
|
||||
export {};
|
||||
|
@ -22,7 +22,7 @@ const grab_query_and_values_1 = __importDefault(require("../../../../utils/get/(
|
||||
* # Get Function FOr API
|
||||
*/
|
||||
function apiGet(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ query, dbFullName, queryValues, tableName, dbSchema, useLocal, debug, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ query, dbFullName, queryValues, tableName, dbSchema, debug, }) {
|
||||
const queryAndValues = (0, grab_query_and_values_1.default)({
|
||||
query,
|
||||
values: queryValues,
|
||||
@ -40,9 +40,8 @@ function apiGet(_a) {
|
||||
readOnly: true,
|
||||
dbSchema,
|
||||
tableName,
|
||||
local: useLocal,
|
||||
});
|
||||
if (debug && useLocal) {
|
||||
if (debug && global.DSQL_USE_LOCAL) {
|
||||
console.log("apiGet:result", result);
|
||||
console.log("apiGet:error", error);
|
||||
}
|
||||
@ -78,7 +77,7 @@ function apiGet(_a) {
|
||||
component: "/api/query/get/lines-85-94",
|
||||
message: error.message,
|
||||
});
|
||||
if (debug && useLocal) {
|
||||
if (debug && global.DSQL_USE_LOCAL) {
|
||||
console.log("apiGet:error", error.message);
|
||||
}
|
||||
return {
|
||||
|
@ -5,10 +5,9 @@ type Param = {
|
||||
dbFullName: string;
|
||||
tableName?: string;
|
||||
dbSchema?: DSQL_DatabaseSchemaType;
|
||||
useLocal?: boolean;
|
||||
};
|
||||
/**
|
||||
* # Post Function For API
|
||||
*/
|
||||
export default function apiPost({ query, dbFullName, queryValues, tableName, dbSchema, useLocal, }: Param): Promise<PostReturn>;
|
||||
export default function apiPost({ query, dbFullName, queryValues, tableName, dbSchema, }: Param): Promise<PostReturn>;
|
||||
export {};
|
||||
|
@ -20,7 +20,7 @@ const runQuery_1 = __importDefault(require("../../backend/db/runQuery"));
|
||||
* # Post Function For API
|
||||
*/
|
||||
function apiPost(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ query, dbFullName, queryValues, tableName, dbSchema, useLocal, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ query, dbFullName, queryValues, tableName, dbSchema, }) {
|
||||
var _b;
|
||||
if (typeof query === "string" && (query === null || query === void 0 ? void 0 : query.match(/^create |^alter |^drop /i))) {
|
||||
return { success: false, msg: "Wrong Input" };
|
||||
@ -43,12 +43,10 @@ function apiPost(_a) {
|
||||
dbSchema: dbSchema,
|
||||
queryValuesArray: queryValues,
|
||||
tableName,
|
||||
local: useLocal,
|
||||
});
|
||||
results = result;
|
||||
if (error)
|
||||
throw error;
|
||||
/** @type {import("../../../types").DSQL_TableSchemaType | undefined} */
|
||||
let tableSchema;
|
||||
if (dbSchema) {
|
||||
const targetTable = dbSchema.tables.find((table) => table.tableName === tableName);
|
||||
|
@ -2,4 +2,4 @@ import { APILoginFunctionReturn, HandleSocialDbFunctionParams } from "../../../t
|
||||
/**
|
||||
* # Handle Social DB
|
||||
*/
|
||||
export default function handleSocialDb({ database, social_id, email, social_platform, payload, invitation, supEmail, additionalFields, useLocal, debug, }: HandleSocialDbFunctionParams): Promise<APILoginFunctionReturn>;
|
||||
export default function handleSocialDb({ database, social_id, email, social_platform, payload, invitation, supEmail, additionalFields, debug, }: HandleSocialDbFunctionParams): Promise<APILoginFunctionReturn>;
|
||||
|
@ -25,14 +25,14 @@ const loginSocialUser_1 = __importDefault(require("./loginSocialUser"));
|
||||
* # Handle Social DB
|
||||
*/
|
||||
function handleSocialDb(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ database, social_id, email, social_platform, payload, invitation, supEmail, additionalFields, useLocal, debug, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ database, social_id, email, social_platform, payload, invitation, supEmail, additionalFields, debug, }) {
|
||||
try {
|
||||
const finalDbName = useLocal
|
||||
const finalDbName = global.DSQL_USE_LOCAL
|
||||
? undefined
|
||||
: database
|
||||
? database
|
||||
: "datasquirel";
|
||||
const dbAppend = useLocal ? "" : `${finalDbName}.`;
|
||||
const dbAppend = global.DSQL_USE_LOCAL ? "" : `${finalDbName}.`;
|
||||
const existingSocialIdUserQuery = `SELECT * FROM ${dbAppend}users WHERE social_id = ? AND social_login='1' AND social_platform = ? `;
|
||||
const existingSocialIdUserValues = [
|
||||
social_id.toString(),
|
||||
@ -46,7 +46,6 @@ function handleSocialDb(_a) {
|
||||
database: finalDbName,
|
||||
queryString: existingSocialIdUserQuery,
|
||||
queryValuesArray: existingSocialIdUserValues,
|
||||
useLocal,
|
||||
debug,
|
||||
});
|
||||
if (debug) {
|
||||
@ -59,7 +58,6 @@ function handleSocialDb(_a) {
|
||||
invitation,
|
||||
database: finalDbName,
|
||||
additionalFields,
|
||||
useLocal,
|
||||
debug,
|
||||
});
|
||||
}
|
||||
@ -78,7 +76,6 @@ function handleSocialDb(_a) {
|
||||
let existingEmailOnly = yield (0, varDatabaseDbHandler_1.default)({
|
||||
database: finalDbName,
|
||||
queryString: existingEmailOnlyQuery,
|
||||
useLocal,
|
||||
debug,
|
||||
});
|
||||
if (debug) {
|
||||
@ -97,7 +94,6 @@ function handleSocialDb(_a) {
|
||||
database: finalDbName,
|
||||
queryString: foundUserQuery,
|
||||
queryValuesArray: foundUserQueryValues,
|
||||
useLocal,
|
||||
debug,
|
||||
});
|
||||
if (foundUser && foundUser[0]) {
|
||||
@ -107,7 +103,6 @@ function handleSocialDb(_a) {
|
||||
invitation,
|
||||
database: finalDbName,
|
||||
additionalFields,
|
||||
useLocal,
|
||||
debug,
|
||||
});
|
||||
}
|
||||
@ -130,20 +125,18 @@ function handleSocialDb(_a) {
|
||||
duplicateColumnName: "email",
|
||||
duplicateColumnValue: finalEmail,
|
||||
data: Object.assign(Object.assign({}, data), { email: finalEmail }),
|
||||
useLocal,
|
||||
});
|
||||
if (newUser === null || newUser === void 0 ? void 0 : newUser.insertId) {
|
||||
if (!database) {
|
||||
/**
|
||||
* Add a Mariadb User for this User
|
||||
*/
|
||||
yield (0, addMariadbUser_1.default)({ userId: newUser.insertId, useLocal });
|
||||
yield (0, addMariadbUser_1.default)({ userId: newUser.insertId });
|
||||
}
|
||||
const newUserQueriedQuery = `SELECT * FROM ${dbAppend}users WHERE id='${newUser.insertId}'`;
|
||||
const newUserQueried = yield (0, varDatabaseDbHandler_1.default)({
|
||||
database: finalDbName,
|
||||
queryString: newUserQueriedQuery,
|
||||
useLocal,
|
||||
debug,
|
||||
});
|
||||
if (!newUserQueried || !newUserQueried[0])
|
||||
@ -202,7 +195,6 @@ function handleSocialDb(_a) {
|
||||
invitation,
|
||||
database: finalDbName,
|
||||
additionalFields,
|
||||
useLocal,
|
||||
debug,
|
||||
});
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ type Param = {
|
||||
invitation?: any;
|
||||
database?: string;
|
||||
additionalFields?: string[];
|
||||
useLocal?: boolean;
|
||||
debug?: boolean;
|
||||
};
|
||||
/**
|
||||
@ -19,5 +18,5 @@ type Param = {
|
||||
* @description This function logs in the user after 'handleSocialDb' function finishes
|
||||
* the user creation or confirmation process
|
||||
*/
|
||||
export default function loginSocialUser({ user, social_platform, invitation, database, additionalFields, useLocal, debug, }: Param): Promise<APILoginFunctionReturn>;
|
||||
export default function loginSocialUser({ user, social_platform, invitation, database, additionalFields, debug, }: Param): Promise<APILoginFunctionReturn>;
|
||||
export {};
|
||||
|
@ -22,7 +22,7 @@ const varDatabaseDbHandler_1 = __importDefault(require("../../backend/varDatabas
|
||||
* the user creation or confirmation process
|
||||
*/
|
||||
function loginSocialUser(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ user, social_platform, invitation, database, additionalFields, useLocal, debug, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ user, social_platform, invitation, database, additionalFields, debug, }) {
|
||||
const finalDbName = database ? database : "datasquirel";
|
||||
const dbAppend = database ? `\`${finalDbName}\`.` : "";
|
||||
const foundUserQuery = `SELECT * FROM ${dbAppend}\`users\` WHERE email=? AND social_id=? AND social_platform=?`;
|
||||
@ -31,7 +31,6 @@ function loginSocialUser(_a) {
|
||||
database: finalDbName,
|
||||
queryString: foundUserQuery,
|
||||
queryValuesArray: foundUserValues,
|
||||
useLocal,
|
||||
debug,
|
||||
});
|
||||
if (!(foundUser === null || foundUser === void 0 ? void 0 : foundUser[0]))
|
||||
@ -68,7 +67,6 @@ function loginSocialUser(_a) {
|
||||
(0, addAdminUserOnLogin_1.default)({
|
||||
query: invitation,
|
||||
user: userPayload,
|
||||
useLocal,
|
||||
});
|
||||
}
|
||||
let result = {
|
||||
|
@ -2,7 +2,7 @@ import { APICreateUserFunctionParams } from "../../../types";
|
||||
/**
|
||||
* # API Create User
|
||||
*/
|
||||
export default function apiCreateUser({ encryptionKey, payload, database, userId, useLocal, }: APICreateUserFunctionParams): Promise<{
|
||||
export default function apiCreateUser({ encryptionKey, payload, database, userId, }: APICreateUserFunctionParams): Promise<{
|
||||
success: boolean;
|
||||
msg: string;
|
||||
payload: null;
|
||||
|
@ -23,7 +23,7 @@ const hashPassword_1 = __importDefault(require("../../dsql/hashPassword"));
|
||||
* # API Create User
|
||||
*/
|
||||
function apiCreateUser(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ encryptionKey, payload, database, userId, useLocal, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ encryptionKey, payload, database, userId, }) {
|
||||
const dbFullName = database;
|
||||
const API_USER_ID = userId || process.env.DSQL_API_USER_ID;
|
||||
const finalEncryptionKey = encryptionKey || process.env.DSQL_ENCRYPTION_PASSWORD;
|
||||
@ -50,19 +50,16 @@ function apiCreateUser(_a) {
|
||||
let fields = yield (0, varDatabaseDbHandler_1.default)({
|
||||
queryString: fieldsQuery,
|
||||
database: dbFullName,
|
||||
useLocal,
|
||||
});
|
||||
if (!(fields === null || fields === void 0 ? void 0 : fields[0])) {
|
||||
const newTable = yield (0, addUsersTableToDb_1.default)({
|
||||
userId: Number(API_USER_ID),
|
||||
database: dbFullName,
|
||||
useLocal,
|
||||
payload: payload,
|
||||
});
|
||||
fields = yield (0, varDatabaseDbHandler_1.default)({
|
||||
queryString: fieldsQuery,
|
||||
database: dbFullName,
|
||||
useLocal,
|
||||
});
|
||||
}
|
||||
if (!(fields === null || fields === void 0 ? void 0 : fields[0])) {
|
||||
@ -99,7 +96,6 @@ function apiCreateUser(_a) {
|
||||
queryString: existingUserQuery,
|
||||
queryValuesArray: existingUserValues,
|
||||
database: dbFullName,
|
||||
useLocal,
|
||||
});
|
||||
if (existingUser === null || existingUser === void 0 ? void 0 : existingUser[0]) {
|
||||
return {
|
||||
@ -116,14 +112,12 @@ function apiCreateUser(_a) {
|
||||
data: Object.assign(Object.assign({}, payload), { image: process.env.DSQL_DEFAULT_USER_IMAGE ||
|
||||
"/images/user-preset.png", image_thumbnail: process.env.DSQL_DEFAULT_USER_IMAGE ||
|
||||
"/images/user-preset-thumbnail.png" }),
|
||||
useLocal,
|
||||
});
|
||||
if (addUser === null || addUser === void 0 ? void 0 : addUser.insertId) {
|
||||
const newlyAddedUserQuery = `SELECT id,first_name,last_name,email,username,phone,image,image_thumbnail,city,state,country,zip_code,address,verification_status,more_user_data FROM ${dbFullName}.users WHERE id='${addUser.insertId}'`;
|
||||
const newlyAddedUser = yield (0, varDatabaseDbHandler_1.default)({
|
||||
queryString: newlyAddedUserQuery,
|
||||
database: dbFullName,
|
||||
useLocal,
|
||||
});
|
||||
return {
|
||||
success: true,
|
||||
|
@ -1,7 +1,6 @@
|
||||
type Param = {
|
||||
dbFullName: string;
|
||||
deletedUserId: string | number;
|
||||
useLocal?: boolean;
|
||||
};
|
||||
type Return = {
|
||||
success: boolean;
|
||||
@ -11,5 +10,5 @@ type Return = {
|
||||
/**
|
||||
* # Update API User Function
|
||||
*/
|
||||
export default function apiDeleteUser({ dbFullName, deletedUserId, useLocal, }: Param): Promise<Return>;
|
||||
export default function apiDeleteUser({ dbFullName, deletedUserId, }: Param): Promise<Return>;
|
||||
export {};
|
||||
|
@ -19,14 +19,13 @@ const varDatabaseDbHandler_1 = __importDefault(require("../../backend/varDatabas
|
||||
* # Update API User Function
|
||||
*/
|
||||
function apiDeleteUser(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ dbFullName, deletedUserId, useLocal, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ dbFullName, deletedUserId, }) {
|
||||
const existingUserQuery = `SELECT * FROM ${dbFullName}.users WHERE id = ?`;
|
||||
const existingUserValues = [deletedUserId];
|
||||
const existingUser = yield (0, varDatabaseDbHandler_1.default)({
|
||||
queryString: existingUserQuery,
|
||||
queryValuesArray: existingUserValues,
|
||||
database: dbFullName,
|
||||
useLocal,
|
||||
});
|
||||
if (!(existingUser === null || existingUser === void 0 ? void 0 : existingUser[0])) {
|
||||
return {
|
||||
@ -41,7 +40,6 @@ function apiDeleteUser(_a) {
|
||||
tableName: "users",
|
||||
identifierColumnName: "id",
|
||||
identifierValue: deletedUserId,
|
||||
useLocal,
|
||||
});
|
||||
return {
|
||||
success: true,
|
||||
|
@ -2,4 +2,4 @@ import { APIGetUserFunctionParams, GetUserFunctionReturn } from "../../../types"
|
||||
/**
|
||||
* # API Get User
|
||||
*/
|
||||
export default function apiGetUser({ fields, dbFullName, userId, useLocal, }: APIGetUserFunctionParams): Promise<GetUserFunctionReturn>;
|
||||
export default function apiGetUser({ fields, dbFullName, userId, }: APIGetUserFunctionParams): Promise<GetUserFunctionReturn>;
|
||||
|
@ -18,7 +18,7 @@ const varDatabaseDbHandler_1 = __importDefault(require("../../backend/varDatabas
|
||||
* # API Get User
|
||||
*/
|
||||
function apiGetUser(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ fields, dbFullName, userId, useLocal, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ fields, dbFullName, userId, }) {
|
||||
const finalDbName = dbFullName.replace(/[^a-z0-9_]/g, "");
|
||||
const query = `SELECT ${fields.join(",")} FROM ${finalDbName}.users WHERE id=?`;
|
||||
const API_USER_ID = userId || process.env.DSQL_API_USER_ID;
|
||||
@ -26,7 +26,6 @@ function apiGetUser(_a) {
|
||||
queryString: query,
|
||||
queryValuesArray: [API_USER_ID],
|
||||
database: finalDbName,
|
||||
useLocal,
|
||||
});
|
||||
if (!foundUser || !foundUser[0]) {
|
||||
return {
|
||||
|
@ -2,4 +2,4 @@ import { APILoginFunctionParams, APILoginFunctionReturn } from "../../../types";
|
||||
/**
|
||||
* # API Login
|
||||
*/
|
||||
export default function apiLoginUser({ encryptionKey, email, username, password, database, additionalFields, email_login, email_login_code, email_login_field, token, skipPassword, social, useLocal, dbUserId, debug, }: APILoginFunctionParams): Promise<APILoginFunctionReturn>;
|
||||
export default function apiLoginUser({ encryptionKey, email, username, password, database, additionalFields, email_login, email_login_code, email_login_field, token, skipPassword, social, dbUserId, debug, }: APILoginFunctionParams): Promise<APILoginFunctionReturn>;
|
||||
|
@ -20,7 +20,7 @@ const hashPassword_1 = __importDefault(require("../../dsql/hashPassword"));
|
||||
* # API Login
|
||||
*/
|
||||
function apiLoginUser(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ encryptionKey, email, username, password, database, additionalFields, email_login, email_login_code, email_login_field, token, skipPassword, social, useLocal, dbUserId, debug, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ encryptionKey, email, username, password, database, additionalFields, email_login, email_login_code, email_login_field, token, skipPassword, social, dbUserId, debug, }) {
|
||||
const dbFullName = (0, grab_db_full_name_1.default)({ dbName: database, userId: dbUserId });
|
||||
/**
|
||||
* Check input validity
|
||||
@ -54,7 +54,6 @@ function apiLoginUser(_a) {
|
||||
queryString: `SELECT * FROM ${dbFullName}.users WHERE email = ? OR username = ?`,
|
||||
queryValuesArray: [email, username],
|
||||
database: dbFullName,
|
||||
useLocal,
|
||||
debug,
|
||||
});
|
||||
if (debug) {
|
||||
@ -116,7 +115,6 @@ function apiLoginUser(_a) {
|
||||
queryString: `UPDATE ${dbFullName}.users SET ${email_login_field} = '' WHERE email = ? OR username = ?`,
|
||||
queryValuesArray: [email, username],
|
||||
database: dbFullName,
|
||||
useLocal,
|
||||
});
|
||||
}
|
||||
let csrfKey = Math.random().toString(36).substring(2) +
|
||||
|
@ -5,10 +5,9 @@ type Param = {
|
||||
};
|
||||
database?: string;
|
||||
additionalFields?: string[];
|
||||
useLocal?: boolean;
|
||||
};
|
||||
/**
|
||||
* # Re-authenticate API user
|
||||
*/
|
||||
export default function apiReauthUser({ existingUser, database, additionalFields, useLocal, }: Param): Promise<APILoginFunctionReturn>;
|
||||
export default function apiReauthUser({ existingUser, database, additionalFields, }: Param): Promise<APILoginFunctionReturn>;
|
||||
export {};
|
||||
|
@ -18,13 +18,12 @@ const varDatabaseDbHandler_1 = __importDefault(require("../../backend/varDatabas
|
||||
* # Re-authenticate API user
|
||||
*/
|
||||
function apiReauthUser(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ existingUser, database, additionalFields, useLocal, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ existingUser, database, additionalFields, }) {
|
||||
let foundUser = (existingUser === null || existingUser === void 0 ? void 0 : existingUser.id) && existingUser.id.toString().match(/./)
|
||||
? yield (0, varDatabaseDbHandler_1.default)({
|
||||
queryString: `SELECT * FROM ${database}.users WHERE id=?`,
|
||||
queryValuesArray: [existingUser.id.toString()],
|
||||
database,
|
||||
useLocal,
|
||||
})
|
||||
: null;
|
||||
if (!foundUser || !foundUser[0])
|
||||
|
@ -10,7 +10,6 @@ type Param = {
|
||||
mail_username?: string;
|
||||
mail_password?: string;
|
||||
html: string;
|
||||
useLocal?: boolean;
|
||||
response?: http.ServerResponse & {
|
||||
[s: string]: any;
|
||||
};
|
||||
@ -19,5 +18,5 @@ type Param = {
|
||||
/**
|
||||
* # Send Email Login Code
|
||||
*/
|
||||
export default function apiSendEmailCode({ email, database, email_login_field, mail_domain, mail_port, sender, mail_username, mail_password, html, useLocal, response, extraCookies, }: Param): Promise<SendOneTimeCodeEmailResponse>;
|
||||
export default function apiSendEmailCode({ email, database, email_login_field, mail_domain, mail_port, sender, mail_username, mail_password, html, response, extraCookies, }: Param): Promise<SendOneTimeCodeEmailResponse>;
|
||||
export {};
|
||||
|
@ -22,7 +22,7 @@ const serialize_cookies_1 = __importDefault(require("../../../utils/serialize-co
|
||||
* # Send Email Login Code
|
||||
*/
|
||||
function apiSendEmailCode(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ email, database, email_login_field, mail_domain, mail_port, sender, mail_username, mail_password, html, useLocal, response, extraCookies, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ email, database, email_login_field, mail_domain, mail_port, sender, mail_username, mail_password, html, response, extraCookies, }) {
|
||||
if (email === null || email === void 0 ? void 0 : email.match(/ /)) {
|
||||
return {
|
||||
success: false,
|
||||
@ -36,7 +36,6 @@ function apiSendEmailCode(_a) {
|
||||
queryString: foundUserQuery,
|
||||
queryValuesArray: foundUserValues,
|
||||
database,
|
||||
useLocal,
|
||||
});
|
||||
////////////////////////////////////////
|
||||
////////////////////////////////////////
|
||||
@ -85,7 +84,6 @@ function apiSendEmailCode(_a) {
|
||||
queryString: setTempCodeQuery,
|
||||
queryValuesArray: setTempCodeValues,
|
||||
database,
|
||||
useLocal,
|
||||
});
|
||||
/** @type {import("../../../types").SendOneTimeCodeEmailResponse} */
|
||||
const resObject = {
|
||||
|
@ -4,7 +4,6 @@ type Param = {
|
||||
};
|
||||
dbFullName: string;
|
||||
updatedUserId: string | number;
|
||||
useLocal?: boolean;
|
||||
dbSchema?: import("../../../types").DSQL_DatabaseSchemaType;
|
||||
};
|
||||
type Return = {
|
||||
@ -15,5 +14,5 @@ type Return = {
|
||||
/**
|
||||
* # Update API User Function
|
||||
*/
|
||||
export default function apiUpdateUser({ payload, dbFullName, updatedUserId, useLocal, dbSchema, }: Param): Promise<Return>;
|
||||
export default function apiUpdateUser({ payload, dbFullName, updatedUserId, dbSchema, }: Param): Promise<Return>;
|
||||
export {};
|
||||
|
@ -22,14 +22,13 @@ const varDatabaseDbHandler_1 = __importDefault(require("../../backend/varDatabas
|
||||
* # Update API User Function
|
||||
*/
|
||||
function apiUpdateUser(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ payload, dbFullName, updatedUserId, useLocal, dbSchema, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ payload, dbFullName, updatedUserId, dbSchema, }) {
|
||||
const existingUserQuery = `SELECT * FROM ${dbFullName}.users WHERE id = ?`;
|
||||
const existingUserValues = [updatedUserId];
|
||||
const existingUser = yield (0, varDatabaseDbHandler_1.default)({
|
||||
queryString: existingUserQuery,
|
||||
queryValuesArray: existingUserValues,
|
||||
database: dbFullName,
|
||||
useLocal,
|
||||
});
|
||||
if (!(existingUser === null || existingUser === void 0 ? void 0 : existingUser[0])) {
|
||||
return {
|
||||
@ -75,7 +74,6 @@ function apiUpdateUser(_a) {
|
||||
identifierColumnName: "id",
|
||||
identifierValue: updatedUserId,
|
||||
data: data,
|
||||
useLocal,
|
||||
});
|
||||
return {
|
||||
success: true,
|
||||
|
@ -9,7 +9,6 @@ type Param = {
|
||||
email: string;
|
||||
encryptionKey?: string;
|
||||
encryptionSalt?: string;
|
||||
useLocal?: boolean;
|
||||
debug?: boolean;
|
||||
apiUserID?: string | number;
|
||||
dbUserId?: string | number;
|
||||
@ -17,7 +16,7 @@ type Param = {
|
||||
/**
|
||||
* # API Login
|
||||
*/
|
||||
export default function apiSendResetPasswordLink({ database, email, apiUserID, dbUserId, debug, encryptionKey, encryptionSalt, key, useLocal, }: Param): Promise<Return>;
|
||||
export default function apiSendResetPasswordLink({ database, email, dbUserId, debug, }: Param): Promise<Return>;
|
||||
export type SendResetPasswordParam = Param;
|
||||
export type SendResetPasswordReturn = Return;
|
||||
export {};
|
||||
|
@ -19,7 +19,7 @@ const varDatabaseDbHandler_1 = __importDefault(require("../../../backend/varData
|
||||
* # API Login
|
||||
*/
|
||||
function apiSendResetPasswordLink(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ database, email, apiUserID, dbUserId, debug, encryptionKey, encryptionSalt, key, useLocal, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ database, email, dbUserId, debug, }) {
|
||||
const dbFullName = (0, grab_db_full_name_1.default)({ dbName: database, userId: dbUserId });
|
||||
/**
|
||||
* Check input validity
|
||||
@ -36,7 +36,6 @@ function apiSendResetPasswordLink(_a) {
|
||||
queryString: `SELECT * FROM ${dbFullName}.users WHERE email = ? OR username = ?`,
|
||||
queryValuesArray: [email, email],
|
||||
database: dbFullName,
|
||||
useLocal,
|
||||
debug,
|
||||
});
|
||||
if (debug) {
|
||||
|
@ -9,10 +9,9 @@ type Param = {
|
||||
[s: string]: string | number;
|
||||
};
|
||||
email?: string;
|
||||
useLocal?: boolean;
|
||||
};
|
||||
/**
|
||||
* # API Login with Github
|
||||
*/
|
||||
export default function apiGithubLogin({ code, clientId, clientSecret, database, additionalFields, email, additionalData, useLocal, }: Param): Promise<APILoginFunctionReturn>;
|
||||
export default function apiGithubLogin({ code, clientId, clientSecret, database, additionalFields, email, additionalData, }: Param): Promise<APILoginFunctionReturn>;
|
||||
export {};
|
||||
|
@ -20,7 +20,7 @@ const camelJoinedtoCamelSpace_1 = __importDefault(require("../../../../utils/cam
|
||||
* # API Login with Github
|
||||
*/
|
||||
function apiGithubLogin(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ code, clientId, clientSecret, database, additionalFields, email, additionalData, useLocal, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ code, clientId, clientSecret, database, additionalFields, email, additionalData, }) {
|
||||
if (!code || !clientId || !clientSecret || !database) {
|
||||
return {
|
||||
success: false,
|
||||
@ -80,7 +80,6 @@ function apiGithubLogin(_a) {
|
||||
social_id: socialId,
|
||||
supEmail: email,
|
||||
additionalFields,
|
||||
useLocal,
|
||||
});
|
||||
////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////
|
||||
|
@ -2,4 +2,4 @@ import { APIGoogleLoginFunctionParams, APILoginFunctionReturn } from "../../../.
|
||||
/**
|
||||
* # API google login
|
||||
*/
|
||||
export default function apiGoogleLogin({ token, database, additionalFields, additionalData, debug, useLocal, }: APIGoogleLoginFunctionParams): Promise<APILoginFunctionReturn>;
|
||||
export default function apiGoogleLogin({ token, database, additionalFields, additionalData, debug, }: APIGoogleLoginFunctionParams): Promise<APILoginFunctionReturn>;
|
||||
|
@ -20,7 +20,7 @@ const ejson_1 = __importDefault(require("../../../../utils/ejson"));
|
||||
* # API google login
|
||||
*/
|
||||
function apiGoogleLogin(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ token, database, additionalFields, additionalData, debug, useLocal, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ token, database, additionalFields, additionalData, debug, }) {
|
||||
try {
|
||||
const gUser = yield new Promise((resolve, reject) => {
|
||||
https_1.default
|
||||
@ -71,7 +71,6 @@ function apiGoogleLogin(_a) {
|
||||
social_id: sub,
|
||||
additionalFields,
|
||||
debug,
|
||||
useLocal,
|
||||
});
|
||||
////////////////////////////////////////
|
||||
////////////////////////////////////////
|
||||
|
@ -6,7 +6,6 @@ type Param = {
|
||||
priviledge: string;
|
||||
email: string;
|
||||
};
|
||||
useLocal?: boolean;
|
||||
user: DATASQUIREL_LoggedInUser;
|
||||
};
|
||||
/**
|
||||
@ -17,5 +16,5 @@ type Param = {
|
||||
* admin user. This fires when the invited user has been logged in or a new account
|
||||
* has been created for the invited user
|
||||
*/
|
||||
export default function addAdminUserOnLogin({ query, user, useLocal, }: Param): Promise<any>;
|
||||
export default function addAdminUserOnLogin({ query, user, }: Param): Promise<any>;
|
||||
export {};
|
||||
|
@ -26,9 +26,11 @@ const LOCAL_DB_HANDLER_1 = __importDefault(require("../../utils/backend/global-d
|
||||
* has been created for the invited user
|
||||
*/
|
||||
function addAdminUserOnLogin(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ query, user, useLocal, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ query, user, }) {
|
||||
try {
|
||||
const finalDbHandler = useLocal ? LOCAL_DB_HANDLER_1.default : DB_HANDLER_1.default;
|
||||
const finalDbHandler = global.DSQL_USE_LOCAL
|
||||
? LOCAL_DB_HANDLER_1.default
|
||||
: DB_HANDLER_1.default;
|
||||
const { invite, database_access, priviledge, email } = query;
|
||||
const lastInviteTimeQuery = `SELECT date_created_code FROM invitations WHERE inviting_user_id=? AND invited_user_email=?`;
|
||||
const lastInviteTimeValues = [invite, email];
|
||||
@ -65,7 +67,6 @@ function addAdminUserOnLogin(_a) {
|
||||
image: user.image,
|
||||
image_thumbnail: user.image_thumbnail,
|
||||
},
|
||||
useLocal,
|
||||
});
|
||||
////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////
|
||||
@ -91,7 +92,6 @@ function addAdminUserOnLogin(_a) {
|
||||
table: table_slug,
|
||||
priviledge: priviledge,
|
||||
},
|
||||
useLocal,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,8 @@
|
||||
type Param = {
|
||||
userId: number | string;
|
||||
useLocal?: boolean;
|
||||
};
|
||||
/**
|
||||
* # Add Mariadb User
|
||||
*/
|
||||
export default function addMariadbUser({ userId, useLocal, }: Param): Promise<any>;
|
||||
export default function addMariadbUser({ userId }: Param): Promise<any>;
|
||||
export {};
|
||||
|
@ -23,7 +23,7 @@ const LOCAL_DB_HANDLER_1 = __importDefault(require("../../utils/backend/global-d
|
||||
* # Add Mariadb User
|
||||
*/
|
||||
function addMariadbUser(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ userId, useLocal, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ userId }) {
|
||||
try {
|
||||
const defaultMariadbUserHost = process.env.DSQL_DB_HOST || "127.0.0.1";
|
||||
const username = `dsql_user_${userId}`;
|
||||
@ -36,7 +36,7 @@ function addMariadbUser(_a) {
|
||||
});
|
||||
const encryptedPassword = (0, encrypt_1.default)({ data: password });
|
||||
const createMariadbUsersQuery = `CREATE USER IF NOT EXISTS '${username}'@'127.0.0.1' IDENTIFIED BY '${password}'`;
|
||||
if (useLocal) {
|
||||
if (global.DSQL_USE_LOCAL) {
|
||||
yield (0, LOCAL_DB_HANDLER_1.default)(createMariadbUsersQuery);
|
||||
}
|
||||
else {
|
||||
@ -44,7 +44,7 @@ function addMariadbUser(_a) {
|
||||
}
|
||||
const updateUserQuery = `UPDATE users SET mariadb_user = ?, mariadb_host = '127.0.0.1', mariadb_pass = ? WHERE id = ?`;
|
||||
const updateUserValues = [username, encryptedPassword, userId];
|
||||
const updateUser = useLocal
|
||||
const updateUser = global.DSQL_USE_LOCAL
|
||||
? yield (0, LOCAL_DB_HANDLER_1.default)(updateUserQuery, updateUserValues)
|
||||
: yield (0, DB_HANDLER_1.default)(updateUserQuery, updateUserValues);
|
||||
const addMariadbUser = yield (0, addDbEntry_1.default)({
|
||||
@ -58,7 +58,6 @@ function addMariadbUser(_a) {
|
||||
grants: '[{"database":"*","table":"*","privileges":["ALL"]}]',
|
||||
},
|
||||
dbContext: "Master",
|
||||
useLocal,
|
||||
});
|
||||
console.log(`User ${userId} SQL credentials successfully added.`);
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
type Param = {
|
||||
userId: number;
|
||||
database: string;
|
||||
useLocal?: boolean;
|
||||
payload?: {
|
||||
[s: string]: any;
|
||||
};
|
||||
@ -9,5 +8,5 @@ type Param = {
|
||||
/**
|
||||
* # Add User Table to Database
|
||||
*/
|
||||
export default function addUsersTableToDb({ userId, database, useLocal, payload, }: Param): Promise<any>;
|
||||
export default function addUsersTableToDb({ userId, database, payload, }: Param): Promise<any>;
|
||||
export {};
|
||||
|
@ -25,7 +25,7 @@ const grabNewUsersTableSchema_1 = __importDefault(require("./grabNewUsersTableSc
|
||||
* # Add User Table to Database
|
||||
*/
|
||||
function addUsersTableToDb(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ userId, database, useLocal, payload, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ userId, database, payload, }) {
|
||||
try {
|
||||
const dbFullName = database;
|
||||
const userPreset = (0, grabNewUsersTableSchema_1.default)({ payload });
|
||||
@ -46,8 +46,7 @@ function addUsersTableToDb(_a) {
|
||||
targetDatabase.tables.push(userPreset);
|
||||
}
|
||||
(0, setUserSchemaData_1.default)({ schemaData: userSchemaData, userId });
|
||||
/** @type {any[] | null} */
|
||||
const targetDb = useLocal
|
||||
const targetDb = global.DSQL_USE_LOCAL
|
||||
? yield (0, LOCAL_DB_HANDLER_1.default)(`SELECT id FROM user_databases WHERE user_id=? AND db_slug=?`, [userId, database])
|
||||
: yield (0, DB_HANDLER_1.default)(`SELECT id FROM user_databases WHERE user_id=? AND db_slug=?`, [userId, database]);
|
||||
if (targetDb === null || targetDb === void 0 ? void 0 : targetDb[0]) {
|
||||
@ -61,7 +60,6 @@ function addUsersTableToDb(_a) {
|
||||
table_name: "Users",
|
||||
table_slug: "users",
|
||||
},
|
||||
useLocal,
|
||||
});
|
||||
}
|
||||
const dbShellUpdate = yield (0, createDbFromSchema_1.default)({
|
||||
|
@ -10,31 +10,9 @@ type Param = {
|
||||
update?: boolean;
|
||||
encryptionKey?: string;
|
||||
encryptionSalt?: string;
|
||||
useLocal?: boolean;
|
||||
};
|
||||
/**
|
||||
* 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
|
||||
* @param {boolean} [params.useLocal]
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export default function addDbEntry({ dbContext, paradigm, dbFullName, tableName, data, tableSchema, duplicateColumnName, duplicateColumnValue, update, encryptionKey, encryptionSalt, useLocal, }: Param): Promise<any>;
|
||||
export default function addDbEntry({ dbContext, paradigm, dbFullName, tableName, data, tableSchema, duplicateColumnName, duplicateColumnValue, update, encryptionKey, encryptionSalt, }: Param): Promise<any>;
|
||||
export {};
|
||||
|
@ -23,35 +23,14 @@ const encrypt_1 = __importDefault(require("../../dsql/encrypt"));
|
||||
const LOCAL_DB_HANDLER_1 = __importDefault(require("../../../utils/backend/global-db/LOCAL_DB_HANDLER"));
|
||||
/**
|
||||
* 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
|
||||
* @param {boolean} [params.useLocal]
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
function addDbEntry(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ dbContext, paradigm, dbFullName, tableName, data, tableSchema, duplicateColumnName, duplicateColumnValue, update, encryptionKey, encryptionSalt, useLocal, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ dbContext, paradigm, dbFullName, tableName, data, tableSchema, duplicateColumnName, duplicateColumnValue, update, encryptionKey, encryptionSalt, }) {
|
||||
var _b, _c;
|
||||
/**
|
||||
* Initialize variables
|
||||
*/
|
||||
const isMaster = useLocal
|
||||
const isMaster = global.DSQL_USE_LOCAL
|
||||
? true
|
||||
: (dbContext === null || dbContext === void 0 ? void 0 : dbContext.match(/dsql.user/i))
|
||||
? false
|
||||
@ -59,7 +38,7 @@ function addDbEntry(_a) {
|
||||
? false
|
||||
: true;
|
||||
/** @type { any } */
|
||||
const dbHandler = useLocal
|
||||
const dbHandler = global.DSQL_USE_LOCAL
|
||||
? LOCAL_DB_HANDLER_1.default
|
||||
: isMaster
|
||||
? DB_HANDLER_1.default
|
||||
|
@ -6,11 +6,10 @@ type Param = {
|
||||
tableSchema?: import("../../../types").DSQL_TableSchemaType;
|
||||
identifierColumnName: string;
|
||||
identifierValue: string | number;
|
||||
useLocal?: boolean;
|
||||
};
|
||||
/**
|
||||
* # Delete DB Entry Function
|
||||
* @description
|
||||
*/
|
||||
export default function deleteDbEntry({ dbContext, paradigm, dbFullName, tableName, identifierColumnName, identifierValue, useLocal, }: Param): Promise<object | null>;
|
||||
export default function deleteDbEntry({ dbContext, paradigm, dbFullName, tableName, identifierColumnName, identifierValue, }: Param): Promise<object | null>;
|
||||
export {};
|
||||
|
@ -21,17 +21,16 @@ const LOCAL_DB_HANDLER_1 = __importDefault(require("../../../utils/backend/globa
|
||||
* @description
|
||||
*/
|
||||
function deleteDbEntry(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ dbContext, paradigm, dbFullName, tableName, identifierColumnName, identifierValue, useLocal, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ dbContext, paradigm, dbFullName, tableName, identifierColumnName, identifierValue, }) {
|
||||
try {
|
||||
const isMaster = useLocal
|
||||
const isMaster = global.DSQL_USE_LOCAL
|
||||
? true
|
||||
: (dbContext === null || dbContext === void 0 ? void 0 : dbContext.match(/dsql.user/i))
|
||||
? false
|
||||
: dbFullName && !dbFullName.match(/^datasquirel$/)
|
||||
? false
|
||||
: true;
|
||||
/** @type { (a1:any, a2?:any) => any } */
|
||||
const dbHandler = useLocal
|
||||
const dbHandler = global.DSQL_USE_LOCAL
|
||||
? LOCAL_DB_HANDLER_1.default
|
||||
: isMaster
|
||||
? DB_HANDLER_1.default
|
||||
|
@ -2,7 +2,6 @@ type Param = {
|
||||
dbFullName: string;
|
||||
query: string | any;
|
||||
readOnly?: boolean;
|
||||
local?: boolean;
|
||||
debug?: boolean;
|
||||
dbSchema?: import("../../../types").DSQL_DatabaseSchemaType;
|
||||
queryValuesArray?: (string | number)[];
|
||||
@ -11,5 +10,5 @@ type Param = {
|
||||
/**
|
||||
* # Run DSQL users queries
|
||||
*/
|
||||
export default function runQuery({ dbFullName, query, readOnly, dbSchema, queryValuesArray, tableName, local, debug, }: Param): Promise<any>;
|
||||
export default function runQuery({ dbFullName, query, readOnly, dbSchema, queryValuesArray, tableName, debug, }: Param): Promise<any>;
|
||||
export {};
|
||||
|
@ -24,7 +24,7 @@ const trim_sql_1 = __importDefault(require("../../../utils/trim-sql"));
|
||||
* # Run DSQL users queries
|
||||
*/
|
||||
function runQuery(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ dbFullName, query, readOnly, dbSchema, queryValuesArray, tableName, local, debug, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ dbFullName, query, readOnly, dbSchema, queryValuesArray, tableName, debug, }) {
|
||||
/**
|
||||
* Declare variables
|
||||
*
|
||||
@ -58,7 +58,7 @@ function runQuery(_a) {
|
||||
try {
|
||||
if (typeof query === "string") {
|
||||
const formattedQuery = (0, trim_sql_1.default)(query);
|
||||
if (debug && local) {
|
||||
if (debug && global.DSQL_USE_LOCAL) {
|
||||
console.log("runQuery:formattedQuery", formattedQuery);
|
||||
}
|
||||
/**
|
||||
@ -75,7 +75,6 @@ function runQuery(_a) {
|
||||
queryString: formattedQuery,
|
||||
queryValuesArray: queryValuesArray === null || queryValuesArray === void 0 ? void 0 : queryValuesArray.map((vl) => String(vl)),
|
||||
tableSchema,
|
||||
useLocal: local,
|
||||
});
|
||||
}
|
||||
else {
|
||||
@ -83,7 +82,6 @@ function runQuery(_a) {
|
||||
queryString: formattedQuery,
|
||||
queryValuesArray: queryValuesArray === null || queryValuesArray === void 0 ? void 0 : queryValuesArray.map((vl) => String(vl)),
|
||||
tableSchema,
|
||||
local,
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -97,7 +95,9 @@ function runQuery(_a) {
|
||||
switch (action.toLowerCase()) {
|
||||
case "insert":
|
||||
result = yield (0, addDbEntry_1.default)({
|
||||
dbContext: local ? "Master" : "Dsql User",
|
||||
dbContext: global.DSQL_USE_LOCAL
|
||||
? "Master"
|
||||
: "Dsql User",
|
||||
paradigm: "Full Access",
|
||||
dbFullName: dbFullName,
|
||||
tableName: table,
|
||||
@ -106,7 +106,6 @@ function runQuery(_a) {
|
||||
duplicateColumnName,
|
||||
duplicateColumnValue,
|
||||
tableSchema,
|
||||
useLocal: local,
|
||||
});
|
||||
if (!(result === null || result === void 0 ? void 0 : result.insertId)) {
|
||||
error = new Error("Couldn't insert data");
|
||||
@ -114,7 +113,9 @@ function runQuery(_a) {
|
||||
break;
|
||||
case "update":
|
||||
result = yield (0, updateDbEntry_1.default)({
|
||||
dbContext: local ? "Master" : "Dsql User",
|
||||
dbContext: global.DSQL_USE_LOCAL
|
||||
? "Master"
|
||||
: "Dsql User",
|
||||
paradigm: "Full Access",
|
||||
dbFullName: dbFullName,
|
||||
tableName: table,
|
||||
@ -122,19 +123,19 @@ function runQuery(_a) {
|
||||
identifierColumnName,
|
||||
identifierValue,
|
||||
tableSchema,
|
||||
useLocal: local,
|
||||
});
|
||||
break;
|
||||
case "delete":
|
||||
result = yield (0, deleteDbEntry_1.default)({
|
||||
dbContext: local ? "Master" : "Dsql User",
|
||||
dbContext: global.DSQL_USE_LOCAL
|
||||
? "Master"
|
||||
: "Dsql User",
|
||||
paradigm: "Full Access",
|
||||
dbFullName: dbFullName,
|
||||
tableName: table,
|
||||
identifierColumnName,
|
||||
identifierValue,
|
||||
tableSchema,
|
||||
useLocal: local,
|
||||
});
|
||||
break;
|
||||
default:
|
||||
@ -148,7 +149,7 @@ function runQuery(_a) {
|
||||
component: "functions/backend/runQuery",
|
||||
message: error.message,
|
||||
});
|
||||
if (debug && local) {
|
||||
if (debug && global.DSQL_USE_LOCAL) {
|
||||
console.log("runQuery:error", error.message);
|
||||
}
|
||||
result = null;
|
||||
|
@ -9,11 +9,10 @@ type Param = {
|
||||
tableSchema?: import("../../../types").DSQL_TableSchemaType;
|
||||
identifierColumnName: string;
|
||||
identifierValue: string | number;
|
||||
useLocal?: boolean;
|
||||
};
|
||||
/**
|
||||
* # Update DB Function
|
||||
* @description
|
||||
*/
|
||||
export default function updateDbEntry({ dbContext, paradigm, dbFullName, tableName, data, tableSchema, identifierColumnName, identifierValue, encryptionKey, encryptionSalt, useLocal, }: Param): Promise<object | null>;
|
||||
export default function updateDbEntry({ dbContext, paradigm, dbFullName, tableName, data, tableSchema, identifierColumnName, identifierValue, encryptionKey, encryptionSalt, }: Param): Promise<object | null>;
|
||||
export {};
|
||||
|
@ -24,14 +24,14 @@ const LOCAL_DB_HANDLER_1 = __importDefault(require("../../../utils/backend/globa
|
||||
* @description
|
||||
*/
|
||||
function updateDbEntry(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ dbContext, paradigm, dbFullName, tableName, data, tableSchema, identifierColumnName, identifierValue, encryptionKey, encryptionSalt, useLocal, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ dbContext, paradigm, dbFullName, tableName, data, tableSchema, identifierColumnName, identifierValue, encryptionKey, encryptionSalt, }) {
|
||||
var _b;
|
||||
/**
|
||||
* Check if data is valid
|
||||
*/
|
||||
if (!data || !Object.keys(data).length)
|
||||
return null;
|
||||
const isMaster = useLocal
|
||||
const isMaster = global.DSQL_USE_LOCAL
|
||||
? true
|
||||
: (dbContext === null || dbContext === void 0 ? void 0 : dbContext.match(/dsql.user/i))
|
||||
? false
|
||||
@ -39,7 +39,7 @@ function updateDbEntry(_a) {
|
||||
? false
|
||||
: true;
|
||||
/** @type {(a1:any, a2?:any)=> any } */
|
||||
const dbHandler = useLocal
|
||||
const dbHandler = global.DSQL_USE_LOCAL
|
||||
? LOCAL_DB_HANDLER_1.default
|
||||
: isMaster
|
||||
? DB_HANDLER_1.default
|
||||
|
@ -1,11 +1,10 @@
|
||||
type Param = {
|
||||
queryString: string;
|
||||
local?: boolean;
|
||||
tableSchema?: import("../../types").DSQL_TableSchemaType | null;
|
||||
queryValuesArray?: string[];
|
||||
};
|
||||
/**
|
||||
* # Full Access Db Handler
|
||||
*/
|
||||
export default function fullAccessDbHandler({ queryString, tableSchema, queryValuesArray, local, }: Param): Promise<any>;
|
||||
export default function fullAccessDbHandler({ queryString, tableSchema, queryValuesArray, }: Param): Promise<any>;
|
||||
export {};
|
||||
|
@ -22,7 +22,7 @@ const serverError_1 = __importDefault(require("./serverError"));
|
||||
* # Full Access Db Handler
|
||||
*/
|
||||
function fullAccessDbHandler(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ queryString, tableSchema, queryValuesArray, local, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ queryString, tableSchema, queryValuesArray, }) {
|
||||
/**
|
||||
* Declare variables
|
||||
*
|
||||
@ -36,7 +36,7 @@ function fullAccessDbHandler(_a) {
|
||||
*/
|
||||
try {
|
||||
/** ********************* Run Query */
|
||||
results = local
|
||||
results = global.DSQL_USE_LOCAL
|
||||
? yield (0, LOCAL_DB_HANDLER_1.default)(queryString, queryValuesArray)
|
||||
: yield (0, DSQL_USER_DB_HANDLER_1.default)({
|
||||
paradigm: "Full Access",
|
||||
|
@ -3,11 +3,10 @@ type Param = {
|
||||
queryValuesArray?: any[];
|
||||
database?: string;
|
||||
tableSchema?: import("../../types").DSQL_TableSchemaType;
|
||||
useLocal?: boolean;
|
||||
debug?: boolean;
|
||||
};
|
||||
/**
|
||||
* # DB handler for specific database
|
||||
*/
|
||||
export default function varDatabaseDbHandler({ queryString, queryValuesArray, database, tableSchema, useLocal, debug, }: Param): Promise<any>;
|
||||
export default function varDatabaseDbHandler({ queryString, queryValuesArray, database, tableSchema, debug, }: Param): Promise<any>;
|
||||
export {};
|
||||
|
@ -21,9 +21,9 @@ const conn_db_handler_1 = __importDefault(require("../../utils/db/conn-db-handle
|
||||
* # DB handler for specific database
|
||||
*/
|
||||
function varDatabaseDbHandler(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ queryString, queryValuesArray, database, tableSchema, useLocal, debug, }) {
|
||||
let CONNECTION = (0, grab_dsql_connection_1.default)({ fa: true, local: useLocal });
|
||||
if (useLocal)
|
||||
return __awaiter(this, arguments, void 0, function* ({ queryString, queryValuesArray, database, tableSchema, debug, }) {
|
||||
let CONNECTION = (0, grab_dsql_connection_1.default)({ fa: true });
|
||||
if (global.DSQL_USE_LOCAL)
|
||||
CONNECTION = (0, grab_dsql_connection_1.default)({ local: true });
|
||||
if (database === null || database === void 0 ? void 0 : database.match(/^datasquirel$/))
|
||||
CONNECTION = (0, grab_dsql_connection_1.default)();
|
||||
|
@ -2,11 +2,10 @@ type Param = {
|
||||
queryString: string;
|
||||
queryValuesArray?: string[];
|
||||
tableSchema?: import("../../types").DSQL_TableSchemaType;
|
||||
useLocal?: boolean;
|
||||
};
|
||||
/**
|
||||
* # Read Only Db Handler with Varaibles
|
||||
* @returns
|
||||
*/
|
||||
export default function varReadOnlyDatabaseDbHandler({ queryString, queryValuesArray, tableSchema, useLocal, }: Param): Promise<any>;
|
||||
export default function varReadOnlyDatabaseDbHandler({ queryString, queryValuesArray, tableSchema, }: Param): Promise<any>;
|
||||
export {};
|
||||
|
@ -23,7 +23,7 @@ const LOCAL_DB_HANDLER_1 = __importDefault(require("../../utils/backend/global-d
|
||||
* @returns
|
||||
*/
|
||||
function varReadOnlyDatabaseDbHandler(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ queryString, queryValuesArray, tableSchema, useLocal, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ queryString, queryValuesArray, tableSchema, }) {
|
||||
/**
|
||||
* Declare variables
|
||||
*
|
||||
@ -36,7 +36,7 @@ function varReadOnlyDatabaseDbHandler(_a) {
|
||||
* @description Fetch data from db if no cache
|
||||
*/
|
||||
try {
|
||||
results = useLocal
|
||||
results = global.DSQL_USE_LOCAL
|
||||
? yield (0, LOCAL_DB_HANDLER_1.default)(queryString, queryValuesArray)
|
||||
: yield (0, DSQL_USER_DB_HANDLER_1.default)({
|
||||
paradigm: "Read Only",
|
||||
|
5
dist/package-shared/types/index.d.ts
vendored
5
dist/package-shared/types/index.d.ts
vendored
@ -1032,7 +1032,6 @@ export type APILoginFunctionParams = {
|
||||
token?: boolean;
|
||||
skipPassword?: boolean;
|
||||
social?: boolean;
|
||||
useLocal?: boolean;
|
||||
dbUserId?: number | string;
|
||||
debug?: boolean;
|
||||
};
|
||||
@ -1051,7 +1050,6 @@ export type APICreateUserFunctionParams = {
|
||||
payload: any;
|
||||
database: string;
|
||||
userId?: string | number;
|
||||
useLocal?: boolean;
|
||||
};
|
||||
export type APICreateUserFunction = (params: APICreateUserFunctionParams) => Promise<AddUserFunctionReturn>;
|
||||
/**
|
||||
@ -1061,7 +1059,6 @@ export type APIGetUserFunctionParams = {
|
||||
fields: string[];
|
||||
dbFullName: string;
|
||||
userId: string | number;
|
||||
useLocal?: boolean;
|
||||
};
|
||||
/**
|
||||
* API Google Login Function
|
||||
@ -1074,7 +1071,6 @@ export type APIGoogleLoginFunctionParams = {
|
||||
[key: string]: string | number;
|
||||
};
|
||||
debug?: boolean;
|
||||
useLocal?: boolean;
|
||||
};
|
||||
export type APIGoogleLoginFunction = (params: APIGoogleLoginFunctionParams) => Promise<APILoginFunctionReturn>;
|
||||
/**
|
||||
@ -1089,7 +1085,6 @@ export type HandleSocialDbFunctionParams = {
|
||||
invitation?: any;
|
||||
supEmail?: string;
|
||||
additionalFields?: string[];
|
||||
useLocal?: boolean;
|
||||
debug?: boolean;
|
||||
};
|
||||
export type HandleSocialDbFunctionReturn = {
|
||||
|
@ -9,7 +9,7 @@ const serverless_mysql_1 = __importDefault(require("serverless-mysql"));
|
||||
* # Grab General CONNECTION for DSQL
|
||||
*/
|
||||
function grabDSQLConnection(param) {
|
||||
if (param === null || param === void 0 ? void 0 : param.local) {
|
||||
if (global.DSQL_USE_LOCAL || (param === null || param === void 0 ? void 0 : param.local)) {
|
||||
return (global.DSQL_DB_CONN ||
|
||||
(0, serverless_mysql_1.default)({
|
||||
config: {
|
||||
|
3
dist/users/add-user.d.ts
vendored
3
dist/users/add-user.d.ts
vendored
@ -7,10 +7,9 @@ type Param = {
|
||||
encryptionSalt?: string;
|
||||
user_id?: string | number;
|
||||
apiUserId?: string | number;
|
||||
useLocal?: boolean;
|
||||
};
|
||||
/**
|
||||
* # Add User to Database
|
||||
*/
|
||||
export default function addUser({ key, payload, database, encryptionKey, user_id, useLocal, apiUserId, }: Param): Promise<AddUserFunctionReturn>;
|
||||
export default function addUser({ key, payload, database, encryptionKey, user_id, apiUserId, }: Param): Promise<AddUserFunctionReturn>;
|
||||
export {};
|
||||
|
5
dist/users/add-user.js
vendored
5
dist/users/add-user.js
vendored
@ -21,7 +21,7 @@ const api_create_user_1 = __importDefault(require("../package-shared/functions/a
|
||||
* # Add User to Database
|
||||
*/
|
||||
function addUser(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ key, payload, database, encryptionKey, user_id, useLocal, apiUserId, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ key, payload, database, encryptionKey, user_id, apiUserId, }) {
|
||||
/**
|
||||
* Check for local DB settings
|
||||
*
|
||||
@ -34,7 +34,7 @@ function addUser(_a) {
|
||||
(DSQL_DB_USERNAME === null || DSQL_DB_USERNAME === void 0 ? void 0 : DSQL_DB_USERNAME.match(/./)) &&
|
||||
(DSQL_DB_PASSWORD === null || DSQL_DB_PASSWORD === void 0 ? void 0 : DSQL_DB_PASSWORD.match(/./)) &&
|
||||
(DSQL_DB_NAME === null || DSQL_DB_NAME === void 0 ? void 0 : DSQL_DB_NAME.match(/./)) &&
|
||||
useLocal) {
|
||||
global.DSQL_USE_LOCAL) {
|
||||
/** @type {import("../package-shared/types").DSQL_DatabaseSchemaType | undefined} */
|
||||
let dbSchema;
|
||||
try {
|
||||
@ -47,7 +47,6 @@ function addUser(_a) {
|
||||
encryptionKey,
|
||||
payload,
|
||||
userId: apiUserId,
|
||||
useLocal,
|
||||
});
|
||||
}
|
||||
/**
|
||||
|
3
dist/users/delete-user.d.ts
vendored
3
dist/users/delete-user.d.ts
vendored
@ -4,10 +4,9 @@ type Param = {
|
||||
database?: string;
|
||||
deletedUserId: string | number;
|
||||
user_id?: boolean;
|
||||
useLocal?: boolean;
|
||||
};
|
||||
/**
|
||||
* # Update User
|
||||
*/
|
||||
export default function deleteUser({ key, database, user_id, useLocal, deletedUserId, }: Param): Promise<UpdateUserFunctionReturn>;
|
||||
export default function deleteUser({ key, database, user_id, deletedUserId, }: Param): Promise<UpdateUserFunctionReturn>;
|
||||
export {};
|
||||
|
5
dist/users/delete-user.js
vendored
5
dist/users/delete-user.js
vendored
@ -21,7 +21,7 @@ const api_delete_user_1 = __importDefault(require("../package-shared/functions/a
|
||||
* # Update User
|
||||
*/
|
||||
function deleteUser(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ key, database, user_id, useLocal, deletedUserId, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ key, database, user_id, deletedUserId, }) {
|
||||
/**
|
||||
* Check for local DB settings
|
||||
*
|
||||
@ -34,7 +34,7 @@ function deleteUser(_a) {
|
||||
(DSQL_DB_USERNAME === null || DSQL_DB_USERNAME === void 0 ? void 0 : DSQL_DB_USERNAME.match(/./)) &&
|
||||
(DSQL_DB_PASSWORD === null || DSQL_DB_PASSWORD === void 0 ? void 0 : DSQL_DB_PASSWORD.match(/./)) &&
|
||||
(DSQL_DB_NAME === null || DSQL_DB_NAME === void 0 ? void 0 : DSQL_DB_NAME.match(/./)) &&
|
||||
useLocal) {
|
||||
global.DSQL_USE_LOCAL) {
|
||||
/** @type {import("../package-shared/types").DSQL_DatabaseSchemaType | undefined} */
|
||||
let dbSchema;
|
||||
try {
|
||||
@ -44,7 +44,6 @@ function deleteUser(_a) {
|
||||
catch (error) { }
|
||||
return yield (0, api_delete_user_1.default)({
|
||||
dbFullName: DSQL_DB_NAME,
|
||||
useLocal,
|
||||
deletedUserId,
|
||||
});
|
||||
}
|
||||
|
3
dist/users/get-token.d.ts
vendored
3
dist/users/get-token.d.ts
vendored
@ -5,7 +5,6 @@ type Param = {
|
||||
encryptionKey: string;
|
||||
encryptionSalt: string;
|
||||
database: string;
|
||||
useLocal?: boolean;
|
||||
};
|
||||
type Return = {
|
||||
key: string | undefined;
|
||||
@ -17,5 +16,5 @@ type Return = {
|
||||
* @description This Function takes in a request object and returns a user token
|
||||
* string and csrf token string
|
||||
*/
|
||||
export default function getToken({ request, encryptionKey, encryptionSalt, database, useLocal, cookieString, }: Param): Return;
|
||||
export default function getToken({ request, encryptionKey, encryptionSalt, cookieString, }: Param): Return;
|
||||
export {};
|
||||
|
2
dist/users/get-token.js
vendored
2
dist/users/get-token.js
vendored
@ -13,7 +13,7 @@ const parseCookies_1 = __importDefault(require("../package-shared/utils/backend/
|
||||
* @description This Function takes in a request object and returns a user token
|
||||
* string and csrf token string
|
||||
*/
|
||||
function getToken({ request, encryptionKey, encryptionSalt, database, useLocal, cookieString, }) {
|
||||
function getToken({ request, encryptionKey, encryptionSalt, cookieString, }) {
|
||||
try {
|
||||
/**
|
||||
* Grab the payload
|
||||
|
3
dist/users/get-user.d.ts
vendored
3
dist/users/get-user.d.ts
vendored
@ -5,10 +5,9 @@ type Param = {
|
||||
userId: number;
|
||||
fields?: string[];
|
||||
apiUserId?: boolean;
|
||||
useLocal?: boolean;
|
||||
};
|
||||
/**
|
||||
* # Get User
|
||||
*/
|
||||
export default function getUser({ key, userId, database, fields, apiUserId, useLocal, }: Param): Promise<GetUserFunctionReturn>;
|
||||
export default function getUser({ key, userId, database, fields, apiUserId, }: Param): Promise<GetUserFunctionReturn>;
|
||||
export {};
|
||||
|
5
dist/users/get-user.js
vendored
5
dist/users/get-user.js
vendored
@ -21,7 +21,7 @@ const api_get_user_1 = __importDefault(require("../package-shared/functions/api/
|
||||
* # Get User
|
||||
*/
|
||||
function getUser(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ key, userId, database, fields, apiUserId, useLocal, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ key, userId, database, fields, apiUserId, }) {
|
||||
/**
|
||||
* Initialize
|
||||
*/
|
||||
@ -59,7 +59,7 @@ function getUser(_a) {
|
||||
(DSQL_DB_USERNAME === null || DSQL_DB_USERNAME === void 0 ? void 0 : DSQL_DB_USERNAME.match(/./)) &&
|
||||
(DSQL_DB_PASSWORD === null || DSQL_DB_PASSWORD === void 0 ? void 0 : DSQL_DB_PASSWORD.match(/./)) &&
|
||||
(DSQL_DB_NAME === null || DSQL_DB_NAME === void 0 ? void 0 : DSQL_DB_NAME.match(/./)) &&
|
||||
useLocal) {
|
||||
global.DSQL_USE_LOCAL) {
|
||||
/** @type {import("../package-shared/types").DSQL_DatabaseSchemaType | undefined} */
|
||||
let dbSchema;
|
||||
try {
|
||||
@ -71,7 +71,6 @@ function getUser(_a) {
|
||||
userId,
|
||||
fields: [...new Set(updatedFields)],
|
||||
dbFullName: DSQL_DB_NAME,
|
||||
useLocal,
|
||||
});
|
||||
}
|
||||
/**
|
||||
|
3
dist/users/login-user.d.ts
vendored
3
dist/users/login-user.d.ts
vendored
@ -20,7 +20,6 @@ type Param = {
|
||||
token?: boolean;
|
||||
user_id?: string | number;
|
||||
skipPassword?: boolean;
|
||||
useLocal?: boolean;
|
||||
debug?: boolean;
|
||||
skipWriteAuthFile?: boolean;
|
||||
apiUserID?: string | number;
|
||||
@ -29,5 +28,5 @@ type Param = {
|
||||
/**
|
||||
* # Login A user
|
||||
*/
|
||||
export default function loginUser({ key, payload, database, additionalFields, response, encryptionKey, encryptionSalt, email_login, email_login_code, temp_code_field, token, user_id, skipPassword, useLocal, apiUserID, skipWriteAuthFile, dbUserId, debug, }: Param): Promise<APILoginFunctionReturn>;
|
||||
export default function loginUser({ key, payload, database, additionalFields, response, encryptionKey, encryptionSalt, email_login, email_login_code, temp_code_field, token, user_id, skipPassword, apiUserID, skipWriteAuthFile, dbUserId, debug, }: Param): Promise<APILoginFunctionReturn>;
|
||||
export {};
|
||||
|
5
dist/users/login-user.js
vendored
5
dist/users/login-user.js
vendored
@ -24,7 +24,7 @@ const write_auth_files_1 = require("../package-shared/functions/backend/auth/wri
|
||||
* # Login A user
|
||||
*/
|
||||
function loginUser(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ key, payload, database, additionalFields, response, encryptionKey, encryptionSalt, email_login, email_login_code, temp_code_field, token, user_id, skipPassword, useLocal, apiUserID, skipWriteAuthFile, dbUserId, debug, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ key, payload, database, additionalFields, response, encryptionKey, encryptionSalt, email_login, email_login_code, temp_code_field, token, user_id, skipPassword, apiUserID, skipWriteAuthFile, dbUserId, debug, }) {
|
||||
var _b;
|
||||
const grabedHostNames = (0, grab_host_names_1.default)({ userId: user_id || apiUserID });
|
||||
const { host, port, scheme } = grabedHostNames;
|
||||
@ -81,7 +81,7 @@ function loginUser(_a) {
|
||||
(DSQL_DB_USERNAME === null || DSQL_DB_USERNAME === void 0 ? void 0 : DSQL_DB_USERNAME.match(/./)) &&
|
||||
(DSQL_DB_PASSWORD === null || DSQL_DB_PASSWORD === void 0 ? void 0 : DSQL_DB_PASSWORD.match(/./)) &&
|
||||
(DSQL_DB_NAME === null || DSQL_DB_NAME === void 0 ? void 0 : DSQL_DB_NAME.match(/./)) &&
|
||||
useLocal) {
|
||||
global.DSQL_USE_LOCAL) {
|
||||
let dbSchema;
|
||||
try {
|
||||
const localDbSchemaPath = path_1.default.resolve(process.cwd(), "dsql.schema.json");
|
||||
@ -100,7 +100,6 @@ function loginUser(_a) {
|
||||
email_login_code,
|
||||
email_login_field: emailLoginTempCodeFieldName,
|
||||
token,
|
||||
useLocal,
|
||||
dbUserId,
|
||||
debug,
|
||||
});
|
||||
|
3
dist/users/reauth-user.d.ts
vendored
3
dist/users/reauth-user.d.ts
vendored
@ -11,10 +11,9 @@ type Param = {
|
||||
additionalFields?: string[];
|
||||
encryptedUserString?: string;
|
||||
user_id?: string | number;
|
||||
useLocal?: boolean;
|
||||
};
|
||||
/**
|
||||
* # Reauthorize User
|
||||
*/
|
||||
export default function reauthUser({ key, database, response, request, level, encryptionKey, encryptionSalt, additionalFields, encryptedUserString, user_id, useLocal, }: Param): Promise<APILoginFunctionReturn>;
|
||||
export default function reauthUser({ key, database, response, request, level, encryptionKey, encryptionSalt, additionalFields, encryptedUserString, user_id, }: Param): Promise<APILoginFunctionReturn>;
|
||||
export {};
|
||||
|
5
dist/users/reauth-user.js
vendored
5
dist/users/reauth-user.js
vendored
@ -25,7 +25,7 @@ const get_auth_cookie_names_1 = __importDefault(require("../package-shared/funct
|
||||
* # Reauthorize User
|
||||
*/
|
||||
function reauthUser(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ key, database, response, request, level, encryptionKey, encryptionSalt, additionalFields, encryptedUserString, user_id, useLocal, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ key, database, response, request, level, encryptionKey, encryptionSalt, additionalFields, encryptedUserString, user_id, }) {
|
||||
var _b, _c;
|
||||
/**
|
||||
* Check Encryption Keys
|
||||
@ -65,7 +65,7 @@ function reauthUser(_a) {
|
||||
(DSQL_DB_USERNAME === null || DSQL_DB_USERNAME === void 0 ? void 0 : DSQL_DB_USERNAME.match(/./)) &&
|
||||
(DSQL_DB_PASSWORD === null || DSQL_DB_PASSWORD === void 0 ? void 0 : DSQL_DB_PASSWORD.match(/./)) &&
|
||||
(DSQL_DB_NAME === null || DSQL_DB_NAME === void 0 ? void 0 : DSQL_DB_NAME.match(/./)) &&
|
||||
useLocal) {
|
||||
global.DSQL_USE_LOCAL) {
|
||||
/** @type {import("../package-shared/types").DSQL_DatabaseSchemaType | undefined} */
|
||||
let dbSchema;
|
||||
try {
|
||||
@ -76,7 +76,6 @@ function reauthUser(_a) {
|
||||
httpResponse = yield (0, api_reauth_user_1.default)({
|
||||
existingUser: existingUser.payload,
|
||||
additionalFields,
|
||||
useLocal,
|
||||
});
|
||||
}
|
||||
else {
|
||||
|
3
dist/users/send-email-code.d.ts
vendored
3
dist/users/send-email-code.d.ts
vendored
@ -14,11 +14,10 @@ type Param = {
|
||||
mail_port?: number;
|
||||
sender?: string;
|
||||
user_id?: boolean;
|
||||
useLocal?: boolean;
|
||||
extraCookies?: import("../package-shared/types").CookieObject[];
|
||||
};
|
||||
/**
|
||||
* # Send Email Code to a User
|
||||
*/
|
||||
export default function sendEmailCode({ key, email, database, temp_code_field_name, mail_domain, mail_password, mail_username, mail_port, sender, user_id, useLocal, response, extraCookies, }: Param): Promise<SendOneTimeCodeEmailResponse>;
|
||||
export default function sendEmailCode({ key, email, database, temp_code_field_name, mail_domain, mail_password, mail_username, mail_port, sender, user_id, response, extraCookies, }: Param): Promise<SendOneTimeCodeEmailResponse>;
|
||||
export {};
|
||||
|
5
dist/users/send-email-code.js
vendored
5
dist/users/send-email-code.js
vendored
@ -21,7 +21,7 @@ const api_send_email_code_1 = __importDefault(require("../package-shared/functio
|
||||
* # Send Email Code to a User
|
||||
*/
|
||||
function sendEmailCode(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ key, email, database, temp_code_field_name, mail_domain, mail_password, mail_username, mail_port, sender, user_id, useLocal, response, extraCookies, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ key, email, database, temp_code_field_name, mail_domain, mail_password, mail_username, mail_port, sender, user_id, response, extraCookies, }) {
|
||||
const grabedHostNames = (0, grab_host_names_1.default)();
|
||||
const { host, port, scheme } = grabedHostNames;
|
||||
const defaultTempLoginFieldName = "temp_login_code";
|
||||
@ -39,7 +39,7 @@ function sendEmailCode(_a) {
|
||||
(DSQL_DB_USERNAME === null || DSQL_DB_USERNAME === void 0 ? void 0 : DSQL_DB_USERNAME.match(/./)) &&
|
||||
(DSQL_DB_PASSWORD === null || DSQL_DB_PASSWORD === void 0 ? void 0 : DSQL_DB_PASSWORD.match(/./)) &&
|
||||
(DSQL_DB_NAME === null || DSQL_DB_NAME === void 0 ? void 0 : DSQL_DB_NAME.match(/./)) &&
|
||||
useLocal) {
|
||||
global.DSQL_USE_LOCAL) {
|
||||
/** @type {import("../package-shared/types").DSQL_DatabaseSchemaType | undefined} */
|
||||
let dbSchema;
|
||||
try {
|
||||
@ -57,7 +57,6 @@ function sendEmailCode(_a) {
|
||||
mail_port,
|
||||
mail_username,
|
||||
sender,
|
||||
useLocal,
|
||||
response,
|
||||
extraCookies,
|
||||
});
|
||||
|
3
dist/users/social/google-auth.d.ts
vendored
3
dist/users/social/google-auth.d.ts
vendored
@ -12,11 +12,10 @@ type Param = {
|
||||
[s: string]: string | number;
|
||||
};
|
||||
apiUserID?: string | number;
|
||||
useLocal?: boolean;
|
||||
debug?: boolean;
|
||||
};
|
||||
/**
|
||||
* # SERVER FUNCTION: Login with google Function
|
||||
*/
|
||||
export default function googleAuth({ key, token, database, response, encryptionKey, encryptionSalt, additionalFields, additionalData, apiUserID, useLocal, debug, }: Param): Promise<APILoginFunctionReturn>;
|
||||
export default function googleAuth({ key, token, database, response, encryptionKey, encryptionSalt, additionalFields, additionalData, apiUserID, debug, }: Param): Promise<APILoginFunctionReturn>;
|
||||
export {};
|
||||
|
5
dist/users/social/google-auth.js
vendored
5
dist/users/social/google-auth.js
vendored
@ -22,7 +22,7 @@ const write_auth_files_1 = require("../../package-shared/functions/backend/auth/
|
||||
* # SERVER FUNCTION: Login with google Function
|
||||
*/
|
||||
function googleAuth(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ key, token, database, response, encryptionKey, encryptionSalt, additionalFields, additionalData, apiUserID, useLocal, debug, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ key, token, database, response, encryptionKey, encryptionSalt, additionalFields, additionalData, apiUserID, debug, }) {
|
||||
var _b;
|
||||
const grabedHostNames = (0, grab_host_names_1.default)();
|
||||
const { host, port, scheme } = grabedHostNames;
|
||||
@ -72,7 +72,7 @@ function googleAuth(_a) {
|
||||
(DSQL_DB_USERNAME === null || DSQL_DB_USERNAME === void 0 ? void 0 : DSQL_DB_USERNAME.match(/./)) &&
|
||||
(DSQL_DB_PASSWORD === null || DSQL_DB_PASSWORD === void 0 ? void 0 : DSQL_DB_PASSWORD.match(/./)) &&
|
||||
(DSQL_DB_NAME === null || DSQL_DB_NAME === void 0 ? void 0 : DSQL_DB_NAME.match(/./)) &&
|
||||
useLocal) {
|
||||
global.DSQL_USE_LOCAL) {
|
||||
if (debug) {
|
||||
console.log(`Google login with Local Paradigm ...`);
|
||||
}
|
||||
@ -81,7 +81,6 @@ function googleAuth(_a) {
|
||||
additionalFields,
|
||||
additionalData,
|
||||
debug,
|
||||
useLocal: true,
|
||||
});
|
||||
}
|
||||
else {
|
||||
|
3
dist/users/update-user.d.ts
vendored
3
dist/users/update-user.d.ts
vendored
@ -7,10 +7,9 @@ type Param = {
|
||||
[s: string]: any;
|
||||
};
|
||||
user_id?: boolean;
|
||||
useLocal?: boolean;
|
||||
};
|
||||
/**
|
||||
* # Update User
|
||||
*/
|
||||
export default function updateUser({ key, payload, database, user_id, useLocal, updatedUserId, }: Param): Promise<UpdateUserFunctionReturn>;
|
||||
export default function updateUser({ key, payload, database, user_id, updatedUserId, }: Param): Promise<UpdateUserFunctionReturn>;
|
||||
export {};
|
||||
|
5
dist/users/update-user.js
vendored
5
dist/users/update-user.js
vendored
@ -21,7 +21,7 @@ const api_update_user_1 = __importDefault(require("../package-shared/functions/a
|
||||
* # Update User
|
||||
*/
|
||||
function updateUser(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ key, payload, database, user_id, useLocal, updatedUserId, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ key, payload, database, user_id, updatedUserId, }) {
|
||||
/**
|
||||
* Check for local DB settings
|
||||
*
|
||||
@ -34,7 +34,7 @@ function updateUser(_a) {
|
||||
(DSQL_DB_USERNAME === null || DSQL_DB_USERNAME === void 0 ? void 0 : DSQL_DB_USERNAME.match(/./)) &&
|
||||
(DSQL_DB_PASSWORD === null || DSQL_DB_PASSWORD === void 0 ? void 0 : DSQL_DB_PASSWORD.match(/./)) &&
|
||||
(DSQL_DB_NAME === null || DSQL_DB_NAME === void 0 ? void 0 : DSQL_DB_NAME.match(/./)) &&
|
||||
useLocal) {
|
||||
global.DSQL_USE_LOCAL) {
|
||||
/** @type {import("../package-shared/types").DSQL_DatabaseSchemaType | undefined} */
|
||||
let dbSchema;
|
||||
try {
|
||||
@ -45,7 +45,6 @@ function updateUser(_a) {
|
||||
return yield (0, api_update_user_1.default)({
|
||||
payload: payload,
|
||||
dbFullName: DSQL_DB_NAME,
|
||||
useLocal,
|
||||
updatedUserId,
|
||||
dbSchema,
|
||||
});
|
||||
|
3
dist/utils/get/index.d.ts
vendored
3
dist/utils/get/index.d.ts
vendored
@ -18,7 +18,6 @@ type Param<T extends {
|
||||
query: string | ApiGetQueryObject<T>;
|
||||
queryValues?: string[];
|
||||
tableName?: string;
|
||||
useLocal?: boolean;
|
||||
user_id?: string | number;
|
||||
debug?: boolean;
|
||||
};
|
||||
@ -30,5 +29,5 @@ export default function get<T extends {
|
||||
[k: string]: any;
|
||||
} = {
|
||||
[k: string]: any;
|
||||
}>({ key, db, query, queryValues, tableName, useLocal, user_id, debug, }: Param<T>): Promise<GetReturn>;
|
||||
}>({ key, db, query, queryValues, tableName, user_id, debug, }: Param<T>): Promise<GetReturn>;
|
||||
export {};
|
||||
|
5
dist/utils/get/index.js
vendored
5
dist/utils/get/index.js
vendored
@ -23,7 +23,7 @@ const grab_query_and_values_1 = __importDefault(require("./(utils)/grab-query-an
|
||||
* # Make a get request to Datasquirel API
|
||||
*/
|
||||
function get(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ key, db, query, queryValues, tableName, useLocal, user_id, debug, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ key, db, query, queryValues, tableName, user_id, debug, }) {
|
||||
const grabedHostNames = (0, grab_host_names_1.default)();
|
||||
const { host, port, scheme } = grabedHostNames;
|
||||
/**
|
||||
@ -36,7 +36,7 @@ function get(_a) {
|
||||
(DSQL_DB_USERNAME === null || DSQL_DB_USERNAME === void 0 ? void 0 : DSQL_DB_USERNAME.match(/./)) &&
|
||||
(DSQL_DB_PASSWORD === null || DSQL_DB_PASSWORD === void 0 ? void 0 : DSQL_DB_PASSWORD.match(/./)) &&
|
||||
(DSQL_DB_NAME === null || DSQL_DB_NAME === void 0 ? void 0 : DSQL_DB_NAME.match(/./)) &&
|
||||
useLocal) {
|
||||
global.DSQL_USE_LOCAL) {
|
||||
let dbSchema;
|
||||
try {
|
||||
const localDbSchemaPath = path_1.default.resolve(process.cwd(), "dsql.schema.json");
|
||||
@ -52,7 +52,6 @@ function get(_a) {
|
||||
queryValues,
|
||||
tableName,
|
||||
dbSchema,
|
||||
useLocal,
|
||||
debug,
|
||||
});
|
||||
}
|
||||
|
3
dist/utils/post.d.ts
vendored
3
dist/utils/post.d.ts
vendored
@ -5,11 +5,10 @@ type Param = {
|
||||
query: string | PostDataPayload;
|
||||
queryValues?: any[];
|
||||
tableName?: string;
|
||||
useLocal?: boolean;
|
||||
user_id?: boolean;
|
||||
};
|
||||
/**
|
||||
* # Make a post request to Datasquirel API
|
||||
*/
|
||||
export default function post({ key, query, queryValues, database, tableName, useLocal, user_id, }: Param): Promise<PostReturn>;
|
||||
export default function post({ key, query, queryValues, database, tableName, user_id, }: Param): Promise<PostReturn>;
|
||||
export {};
|
||||
|
5
dist/utils/post.js
vendored
5
dist/utils/post.js
vendored
@ -22,7 +22,7 @@ const post_1 = __importDefault(require("../package-shared/functions/api/query/po
|
||||
* # Make a post request to Datasquirel API
|
||||
*/
|
||||
function post(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ key, query, queryValues, database, tableName, useLocal, user_id, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ key, query, queryValues, database, tableName, user_id, }) {
|
||||
const grabedHostNames = (0, grab_host_names_1.default)();
|
||||
const { host, port, scheme } = grabedHostNames;
|
||||
/**
|
||||
@ -35,7 +35,7 @@ function post(_a) {
|
||||
(DSQL_DB_USERNAME === null || DSQL_DB_USERNAME === void 0 ? void 0 : DSQL_DB_USERNAME.match(/./)) &&
|
||||
(DSQL_DB_PASSWORD === null || DSQL_DB_PASSWORD === void 0 ? void 0 : DSQL_DB_PASSWORD.match(/./)) &&
|
||||
(DSQL_DB_NAME === null || DSQL_DB_NAME === void 0 ? void 0 : DSQL_DB_NAME.match(/./)) &&
|
||||
useLocal) {
|
||||
global.DSQL_USE_LOCAL) {
|
||||
/** @type {import("../package-shared/types").DSQL_DatabaseSchemaType | undefined} */
|
||||
let dbSchema;
|
||||
try {
|
||||
@ -49,7 +49,6 @@ function post(_a) {
|
||||
dbSchema,
|
||||
queryValues,
|
||||
tableName,
|
||||
useLocal,
|
||||
});
|
||||
}
|
||||
/**
|
||||
|
1
index.ts
1
index.ts
@ -4,6 +4,7 @@ declare global {
|
||||
var DSQL_DB_CONN: ServerlessMysql | undefined;
|
||||
var DSQL_READ_ONLY_DB_CONN: ServerlessMysql | undefined;
|
||||
var DSQL_FULL_ACCESS_DB_CONN: ServerlessMysql | undefined;
|
||||
var DSQL_USE_LOCAL: boolean | undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -21,7 +21,6 @@ type Param = {
|
||||
dbFullName: string;
|
||||
tableName?: string;
|
||||
dbSchema?: import("../../../types").DSQL_DatabaseSchemaType;
|
||||
useLocal?: boolean;
|
||||
debug?: boolean;
|
||||
};
|
||||
|
||||
@ -34,7 +33,6 @@ export default async function apiGet({
|
||||
queryValues,
|
||||
tableName,
|
||||
dbSchema,
|
||||
useLocal,
|
||||
debug,
|
||||
}: Param): Promise<import("../../../types").GetReturn> {
|
||||
const queryAndValues = apiGetGrabQueryAndValues({
|
||||
@ -59,10 +57,9 @@ export default async function apiGet({
|
||||
readOnly: true,
|
||||
dbSchema,
|
||||
tableName,
|
||||
local: useLocal,
|
||||
});
|
||||
|
||||
if (debug && useLocal) {
|
||||
if (debug && global.DSQL_USE_LOCAL) {
|
||||
console.log("apiGet:result", result);
|
||||
console.log("apiGet:error", error);
|
||||
}
|
||||
@ -105,7 +102,7 @@ export default async function apiGet({
|
||||
message: error.message,
|
||||
});
|
||||
|
||||
if (debug && useLocal) {
|
||||
if (debug && global.DSQL_USE_LOCAL) {
|
||||
console.log("apiGet:error", error.message);
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,6 @@ type Param = {
|
||||
dbFullName: string;
|
||||
tableName?: string;
|
||||
dbSchema?: DSQL_DatabaseSchemaType;
|
||||
useLocal?: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -21,7 +20,6 @@ export default async function apiPost({
|
||||
queryValues,
|
||||
tableName,
|
||||
dbSchema,
|
||||
useLocal,
|
||||
}: Param): Promise<PostReturn> {
|
||||
if (typeof query === "string" && query?.match(/^create |^alter |^drop /i)) {
|
||||
return { success: false, msg: "Wrong Input" };
|
||||
@ -49,14 +47,12 @@ export default async function apiPost({
|
||||
dbSchema: dbSchema,
|
||||
queryValuesArray: queryValues,
|
||||
tableName,
|
||||
local: useLocal,
|
||||
});
|
||||
|
||||
results = result;
|
||||
|
||||
if (error) throw error;
|
||||
|
||||
/** @type {import("../../../types").DSQL_TableSchemaType | undefined} */
|
||||
let tableSchema:
|
||||
| import("../../../types").DSQL_TableSchemaType
|
||||
| undefined;
|
||||
|
@ -1,4 +1,4 @@
|
||||
import fs from "fs";
|
||||
import fs, { glob } from "fs";
|
||||
import handleNodemailer from "../../backend/handleNodemailer";
|
||||
import path from "path";
|
||||
import addMariadbUser from "../../backend/addMariadbUser";
|
||||
@ -23,16 +23,15 @@ export default async function handleSocialDb({
|
||||
invitation,
|
||||
supEmail,
|
||||
additionalFields,
|
||||
useLocal,
|
||||
debug,
|
||||
}: HandleSocialDbFunctionParams): Promise<APILoginFunctionReturn> {
|
||||
try {
|
||||
const finalDbName = useLocal
|
||||
const finalDbName = global.DSQL_USE_LOCAL
|
||||
? undefined
|
||||
: database
|
||||
? database
|
||||
: "datasquirel";
|
||||
const dbAppend = useLocal ? "" : `${finalDbName}.`;
|
||||
const dbAppend = global.DSQL_USE_LOCAL ? "" : `${finalDbName}.`;
|
||||
|
||||
const existingSocialIdUserQuery = `SELECT * FROM ${dbAppend}users WHERE social_id = ? AND social_login='1' AND social_platform = ? `;
|
||||
const existingSocialIdUserValues = [
|
||||
@ -55,7 +54,6 @@ export default async function handleSocialDb({
|
||||
database: finalDbName,
|
||||
queryString: existingSocialIdUserQuery,
|
||||
queryValuesArray: existingSocialIdUserValues,
|
||||
useLocal,
|
||||
debug,
|
||||
});
|
||||
|
||||
@ -73,7 +71,6 @@ export default async function handleSocialDb({
|
||||
invitation,
|
||||
database: finalDbName,
|
||||
additionalFields,
|
||||
useLocal,
|
||||
debug,
|
||||
});
|
||||
}
|
||||
@ -100,7 +97,6 @@ export default async function handleSocialDb({
|
||||
let existingEmailOnly = await varDatabaseDbHandler({
|
||||
database: finalDbName,
|
||||
queryString: existingEmailOnlyQuery,
|
||||
useLocal,
|
||||
debug,
|
||||
});
|
||||
|
||||
@ -123,7 +119,6 @@ export default async function handleSocialDb({
|
||||
database: finalDbName,
|
||||
queryString: foundUserQuery,
|
||||
queryValuesArray: foundUserQueryValues,
|
||||
useLocal,
|
||||
debug,
|
||||
});
|
||||
|
||||
@ -134,7 +129,6 @@ export default async function handleSocialDb({
|
||||
invitation,
|
||||
database: finalDbName,
|
||||
additionalFields,
|
||||
useLocal,
|
||||
debug,
|
||||
});
|
||||
}
|
||||
@ -164,7 +158,6 @@ export default async function handleSocialDb({
|
||||
...data,
|
||||
email: finalEmail,
|
||||
},
|
||||
useLocal,
|
||||
});
|
||||
|
||||
if (newUser?.insertId) {
|
||||
@ -172,7 +165,7 @@ export default async function handleSocialDb({
|
||||
/**
|
||||
* Add a Mariadb User for this User
|
||||
*/
|
||||
await addMariadbUser({ userId: newUser.insertId, useLocal });
|
||||
await addMariadbUser({ userId: newUser.insertId });
|
||||
}
|
||||
|
||||
const newUserQueriedQuery = `SELECT * FROM ${dbAppend}users WHERE id='${newUser.insertId}'`;
|
||||
@ -180,7 +173,6 @@ export default async function handleSocialDb({
|
||||
const newUserQueried = await varDatabaseDbHandler({
|
||||
database: finalDbName,
|
||||
queryString: newUserQueriedQuery,
|
||||
useLocal,
|
||||
debug,
|
||||
});
|
||||
|
||||
@ -259,7 +251,6 @@ export default async function handleSocialDb({
|
||||
invitation,
|
||||
database: finalDbName,
|
||||
additionalFields,
|
||||
useLocal,
|
||||
debug,
|
||||
});
|
||||
} else {
|
||||
|
@ -16,7 +16,6 @@ type Param = {
|
||||
invitation?: any;
|
||||
database?: string;
|
||||
additionalFields?: string[];
|
||||
useLocal?: boolean;
|
||||
debug?: boolean;
|
||||
};
|
||||
|
||||
@ -32,7 +31,6 @@ export default async function loginSocialUser({
|
||||
invitation,
|
||||
database,
|
||||
additionalFields,
|
||||
useLocal,
|
||||
debug,
|
||||
}: Param): Promise<APILoginFunctionReturn> {
|
||||
const finalDbName = database ? database : "datasquirel";
|
||||
@ -45,7 +43,6 @@ export default async function loginSocialUser({
|
||||
database: finalDbName,
|
||||
queryString: foundUserQuery,
|
||||
queryValuesArray: foundUserValues,
|
||||
useLocal,
|
||||
debug,
|
||||
});
|
||||
|
||||
@ -88,7 +85,6 @@ export default async function loginSocialUser({
|
||||
addAdminUserOnLogin({
|
||||
query: invitation,
|
||||
user: userPayload,
|
||||
useLocal,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,6 @@ export default async function apiCreateUser({
|
||||
payload,
|
||||
database,
|
||||
userId,
|
||||
useLocal,
|
||||
}: APICreateUserFunctionParams) {
|
||||
const dbFullName = database;
|
||||
const API_USER_ID = userId || process.env.DSQL_API_USER_ID;
|
||||
@ -51,21 +50,19 @@ export default async function apiCreateUser({
|
||||
let fields = await varDatabaseDbHandler({
|
||||
queryString: fieldsQuery,
|
||||
database: dbFullName,
|
||||
useLocal,
|
||||
});
|
||||
|
||||
if (!fields?.[0]) {
|
||||
const newTable = await addUsersTableToDb({
|
||||
userId: Number(API_USER_ID),
|
||||
database: dbFullName,
|
||||
useLocal,
|
||||
|
||||
payload: payload,
|
||||
});
|
||||
|
||||
fields = await varDatabaseDbHandler({
|
||||
queryString: fieldsQuery,
|
||||
database: dbFullName,
|
||||
useLocal,
|
||||
});
|
||||
}
|
||||
|
||||
@ -111,7 +108,6 @@ export default async function apiCreateUser({
|
||||
queryString: existingUserQuery,
|
||||
queryValuesArray: existingUserValues,
|
||||
database: dbFullName,
|
||||
useLocal,
|
||||
});
|
||||
|
||||
if (existingUser?.[0]) {
|
||||
@ -136,7 +132,6 @@ export default async function apiCreateUser({
|
||||
process.env.DSQL_DEFAULT_USER_IMAGE ||
|
||||
"/images/user-preset-thumbnail.png",
|
||||
},
|
||||
useLocal,
|
||||
});
|
||||
|
||||
if (addUser?.insertId) {
|
||||
@ -145,7 +140,6 @@ export default async function apiCreateUser({
|
||||
const newlyAddedUser = await varDatabaseDbHandler({
|
||||
queryString: newlyAddedUserQuery,
|
||||
database: dbFullName,
|
||||
useLocal,
|
||||
});
|
||||
|
||||
return {
|
||||
|
@ -4,7 +4,6 @@ import varDatabaseDbHandler from "../../backend/varDatabaseDbHandler";
|
||||
type Param = {
|
||||
dbFullName: string;
|
||||
deletedUserId: string | number;
|
||||
useLocal?: boolean;
|
||||
};
|
||||
type Return = { success: boolean; result?: any; msg?: string };
|
||||
|
||||
@ -14,7 +13,6 @@ type Return = { success: boolean; result?: any; msg?: string };
|
||||
export default async function apiDeleteUser({
|
||||
dbFullName,
|
||||
deletedUserId,
|
||||
useLocal,
|
||||
}: Param): Promise<Return> {
|
||||
const existingUserQuery = `SELECT * FROM ${dbFullName}.users WHERE id = ?`;
|
||||
const existingUserValues = [deletedUserId];
|
||||
@ -23,7 +21,6 @@ export default async function apiDeleteUser({
|
||||
queryString: existingUserQuery,
|
||||
queryValuesArray: existingUserValues,
|
||||
database: dbFullName,
|
||||
useLocal,
|
||||
});
|
||||
|
||||
if (!existingUser?.[0]) {
|
||||
@ -40,7 +37,6 @@ export default async function apiDeleteUser({
|
||||
tableName: "users",
|
||||
identifierColumnName: "id",
|
||||
identifierValue: deletedUserId,
|
||||
useLocal,
|
||||
});
|
||||
|
||||
return {
|
||||
|
@ -11,7 +11,6 @@ export default async function apiGetUser({
|
||||
fields,
|
||||
dbFullName,
|
||||
userId,
|
||||
useLocal,
|
||||
}: APIGetUserFunctionParams): Promise<GetUserFunctionReturn> {
|
||||
const finalDbName = dbFullName.replace(/[^a-z0-9_]/g, "");
|
||||
|
||||
@ -24,7 +23,6 @@ export default async function apiGetUser({
|
||||
queryString: query,
|
||||
queryValuesArray: [API_USER_ID],
|
||||
database: finalDbName,
|
||||
useLocal,
|
||||
});
|
||||
|
||||
if (!foundUser || !foundUser[0]) {
|
||||
|
@ -23,7 +23,6 @@ export default async function apiLoginUser({
|
||||
token,
|
||||
skipPassword,
|
||||
social,
|
||||
useLocal,
|
||||
dbUserId,
|
||||
debug,
|
||||
}: APILoginFunctionParams): Promise<APILoginFunctionReturn> {
|
||||
@ -66,7 +65,7 @@ export default async function apiLoginUser({
|
||||
queryString: `SELECT * FROM ${dbFullName}.users WHERE email = ? OR username = ?`,
|
||||
queryValuesArray: [email, username],
|
||||
database: dbFullName,
|
||||
useLocal,
|
||||
|
||||
debug,
|
||||
});
|
||||
|
||||
@ -143,7 +142,6 @@ export default async function apiLoginUser({
|
||||
queryString: `UPDATE ${dbFullName}.users SET ${email_login_field} = '' WHERE email = ? OR username = ?`,
|
||||
queryValuesArray: [email, username],
|
||||
database: dbFullName,
|
||||
useLocal,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@ type Param = {
|
||||
existingUser: { [s: string]: any };
|
||||
database?: string;
|
||||
additionalFields?: string[];
|
||||
useLocal?: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -15,7 +14,6 @@ export default async function apiReauthUser({
|
||||
existingUser,
|
||||
database,
|
||||
additionalFields,
|
||||
useLocal,
|
||||
}: Param): Promise<APILoginFunctionReturn> {
|
||||
let foundUser =
|
||||
existingUser?.id && existingUser.id.toString().match(/./)
|
||||
@ -23,7 +21,6 @@ export default async function apiReauthUser({
|
||||
queryString: `SELECT * FROM ${database}.users WHERE id=?`,
|
||||
queryValuesArray: [existingUser.id.toString()],
|
||||
database,
|
||||
useLocal,
|
||||
})
|
||||
: null;
|
||||
|
||||
|
@ -16,7 +16,6 @@ type Param = {
|
||||
mail_username?: string;
|
||||
mail_password?: string;
|
||||
html: string;
|
||||
useLocal?: boolean;
|
||||
response?: http.ServerResponse & { [s: string]: any };
|
||||
extraCookies?: import("../../../../package-shared/types").CookieObject[];
|
||||
};
|
||||
@ -34,7 +33,6 @@ export default async function apiSendEmailCode({
|
||||
mail_username,
|
||||
mail_password,
|
||||
html,
|
||||
useLocal,
|
||||
response,
|
||||
extraCookies,
|
||||
}: Param): Promise<SendOneTimeCodeEmailResponse> {
|
||||
@ -53,7 +51,6 @@ export default async function apiSendEmailCode({
|
||||
queryString: foundUserQuery,
|
||||
queryValuesArray: foundUserValues,
|
||||
database,
|
||||
useLocal,
|
||||
});
|
||||
|
||||
////////////////////////////////////////
|
||||
@ -114,7 +111,6 @@ export default async function apiSendEmailCode({
|
||||
queryString: setTempCodeQuery,
|
||||
queryValuesArray: setTempCodeValues,
|
||||
database,
|
||||
useLocal,
|
||||
});
|
||||
|
||||
/** @type {import("../../../types").SendOneTimeCodeEmailResponse} */
|
||||
|
@ -9,7 +9,6 @@ type Param = {
|
||||
payload: { [s: string]: any };
|
||||
dbFullName: string;
|
||||
updatedUserId: string | number;
|
||||
useLocal?: boolean;
|
||||
dbSchema?: import("../../../types").DSQL_DatabaseSchemaType;
|
||||
};
|
||||
|
||||
@ -22,7 +21,7 @@ export default async function apiUpdateUser({
|
||||
payload,
|
||||
dbFullName,
|
||||
updatedUserId,
|
||||
useLocal,
|
||||
|
||||
dbSchema,
|
||||
}: Param): Promise<Return> {
|
||||
const existingUserQuery = `SELECT * FROM ${dbFullName}.users WHERE id = ?`;
|
||||
@ -32,7 +31,6 @@ export default async function apiUpdateUser({
|
||||
queryString: existingUserQuery,
|
||||
queryValuesArray: existingUserValues,
|
||||
database: dbFullName,
|
||||
useLocal,
|
||||
});
|
||||
|
||||
if (!existingUser?.[0]) {
|
||||
@ -89,7 +87,6 @@ export default async function apiUpdateUser({
|
||||
identifierColumnName: "id",
|
||||
identifierValue: updatedUserId,
|
||||
data: data,
|
||||
useLocal,
|
||||
});
|
||||
|
||||
return {
|
||||
|
@ -14,7 +14,6 @@ type Param = {
|
||||
email: string;
|
||||
encryptionKey?: string;
|
||||
encryptionSalt?: string;
|
||||
useLocal?: boolean;
|
||||
debug?: boolean;
|
||||
apiUserID?: string | number;
|
||||
dbUserId?: string | number;
|
||||
@ -26,13 +25,8 @@ type Param = {
|
||||
export default async function apiSendResetPasswordLink({
|
||||
database,
|
||||
email,
|
||||
apiUserID,
|
||||
dbUserId,
|
||||
debug,
|
||||
encryptionKey,
|
||||
encryptionSalt,
|
||||
key,
|
||||
useLocal,
|
||||
}: Param): Promise<Return> {
|
||||
const dbFullName = grabDbFullName({ dbName: database, userId: dbUserId });
|
||||
|
||||
@ -52,7 +46,6 @@ export default async function apiSendResetPasswordLink({
|
||||
queryString: `SELECT * FROM ${dbFullName}.users WHERE email = ? OR username = ?`,
|
||||
queryValuesArray: [email, email],
|
||||
database: dbFullName,
|
||||
useLocal,
|
||||
debug,
|
||||
});
|
||||
|
||||
|
@ -11,7 +11,6 @@ type Param = {
|
||||
additionalFields?: string[];
|
||||
additionalData?: { [s: string]: string | number };
|
||||
email?: string;
|
||||
useLocal?: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -25,7 +24,6 @@ export default async function apiGithubLogin({
|
||||
additionalFields,
|
||||
email,
|
||||
additionalData,
|
||||
useLocal,
|
||||
}: Param): Promise<APILoginFunctionReturn> {
|
||||
if (!code || !clientId || !clientSecret || !database) {
|
||||
return {
|
||||
@ -95,7 +93,6 @@ export default async function apiGithubLogin({
|
||||
social_id: socialId,
|
||||
supEmail: email,
|
||||
additionalFields,
|
||||
useLocal,
|
||||
});
|
||||
|
||||
////////////////////////////////////////////////
|
||||
|
@ -16,7 +16,6 @@ export default async function apiGoogleLogin({
|
||||
additionalFields,
|
||||
additionalData,
|
||||
debug,
|
||||
useLocal,
|
||||
}: APIGoogleLoginFunctionParams): Promise<APILoginFunctionReturn> {
|
||||
try {
|
||||
const gUser: GoogleOauth2User | undefined = await new Promise(
|
||||
@ -78,7 +77,6 @@ export default async function apiGoogleLogin({
|
||||
social_id: sub,
|
||||
additionalFields,
|
||||
debug,
|
||||
useLocal,
|
||||
});
|
||||
|
||||
////////////////////////////////////////
|
||||
|
@ -11,7 +11,6 @@ type Param = {
|
||||
priviledge: string;
|
||||
email: string;
|
||||
};
|
||||
useLocal?: boolean;
|
||||
user: DATASQUIREL_LoggedInUser;
|
||||
};
|
||||
|
||||
@ -26,10 +25,11 @@ type Param = {
|
||||
export default async function addAdminUserOnLogin({
|
||||
query,
|
||||
user,
|
||||
useLocal,
|
||||
}: Param): Promise<any> {
|
||||
try {
|
||||
const finalDbHandler = useLocal ? LOCAL_DB_HANDLER : DB_HANDLER;
|
||||
const finalDbHandler = global.DSQL_USE_LOCAL
|
||||
? LOCAL_DB_HANDLER
|
||||
: DB_HANDLER;
|
||||
const { invite, database_access, priviledge, email } = query;
|
||||
|
||||
const lastInviteTimeQuery = `SELECT date_created_code FROM invitations WHERE inviting_user_id=? AND invited_user_email=?`;
|
||||
@ -82,7 +82,6 @@ export default async function addAdminUserOnLogin({
|
||||
image: user.image,
|
||||
image_thumbnail: user.image_thumbnail,
|
||||
},
|
||||
useLocal,
|
||||
});
|
||||
|
||||
////////////////////////////////////////////////
|
||||
@ -122,7 +121,6 @@ export default async function addAdminUserOnLogin({
|
||||
table: table_slug,
|
||||
priviledge: priviledge,
|
||||
},
|
||||
useLocal,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -7,16 +7,12 @@ import LOCAL_DB_HANDLER from "../../utils/backend/global-db/LOCAL_DB_HANDLER";
|
||||
|
||||
type Param = {
|
||||
userId: number | string;
|
||||
useLocal?: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
* # Add Mariadb User
|
||||
*/
|
||||
export default async function addMariadbUser({
|
||||
userId,
|
||||
useLocal,
|
||||
}: Param): Promise<any> {
|
||||
export default async function addMariadbUser({ userId }: Param): Promise<any> {
|
||||
try {
|
||||
const defaultMariadbUserHost = process.env.DSQL_DB_HOST || "127.0.0.1";
|
||||
|
||||
@ -32,7 +28,7 @@ export default async function addMariadbUser({
|
||||
|
||||
const createMariadbUsersQuery = `CREATE USER IF NOT EXISTS '${username}'@'127.0.0.1' IDENTIFIED BY '${password}'`;
|
||||
|
||||
if (useLocal) {
|
||||
if (global.DSQL_USE_LOCAL) {
|
||||
await LOCAL_DB_HANDLER(createMariadbUsersQuery);
|
||||
} else {
|
||||
await NO_DB_HANDLER(createMariadbUsersQuery);
|
||||
@ -41,7 +37,7 @@ export default async function addMariadbUser({
|
||||
const updateUserQuery = `UPDATE users SET mariadb_user = ?, mariadb_host = '127.0.0.1', mariadb_pass = ? WHERE id = ?`;
|
||||
const updateUserValues = [username, encryptedPassword, userId];
|
||||
|
||||
const updateUser = useLocal
|
||||
const updateUser = global.DSQL_USE_LOCAL
|
||||
? await LOCAL_DB_HANDLER(updateUserQuery, updateUserValues)
|
||||
: await DB_HANDLER(updateUserQuery, updateUserValues);
|
||||
|
||||
@ -56,7 +52,6 @@ export default async function addMariadbUser({
|
||||
grants: '[{"database":"*","table":"*","privileges":["ALL"]}]',
|
||||
},
|
||||
dbContext: "Master",
|
||||
useLocal,
|
||||
});
|
||||
|
||||
console.log(`User ${userId} SQL credentials successfully added.`);
|
||||
|
@ -10,7 +10,6 @@ import grabNewUsersTableSchema from "./grabNewUsersTableSchema";
|
||||
type Param = {
|
||||
userId: number;
|
||||
database: string;
|
||||
useLocal?: boolean;
|
||||
payload?: { [s: string]: any };
|
||||
};
|
||||
|
||||
@ -20,7 +19,6 @@ type Param = {
|
||||
export default async function addUsersTableToDb({
|
||||
userId,
|
||||
database,
|
||||
useLocal,
|
||||
payload,
|
||||
}: Param): Promise<any> {
|
||||
try {
|
||||
@ -52,8 +50,7 @@ export default async function addUsersTableToDb({
|
||||
|
||||
setUserSchemaData({ schemaData: userSchemaData, userId });
|
||||
|
||||
/** @type {any[] | null} */
|
||||
const targetDb: any[] | null = useLocal
|
||||
const targetDb: any[] | null = global.DSQL_USE_LOCAL
|
||||
? await LOCAL_DB_HANDLER(
|
||||
`SELECT id FROM user_databases WHERE user_id=? AND db_slug=?`,
|
||||
[userId, database]
|
||||
@ -74,7 +71,6 @@ export default async function addUsersTableToDb({
|
||||
table_name: "Users",
|
||||
table_slug: "users",
|
||||
},
|
||||
useLocal,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -21,32 +21,10 @@ type Param = {
|
||||
update?: boolean;
|
||||
encryptionKey?: string;
|
||||
encryptionSalt?: string;
|
||||
useLocal?: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @param {boolean} [params.useLocal]
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export default async function addDbEntry({
|
||||
dbContext,
|
||||
@ -60,12 +38,11 @@ export default async function addDbEntry({
|
||||
update,
|
||||
encryptionKey,
|
||||
encryptionSalt,
|
||||
useLocal,
|
||||
}: Param): Promise<any> {
|
||||
/**
|
||||
* Initialize variables
|
||||
*/
|
||||
const isMaster = useLocal
|
||||
const isMaster = global.DSQL_USE_LOCAL
|
||||
? true
|
||||
: dbContext?.match(/dsql.user/i)
|
||||
? false
|
||||
@ -74,7 +51,7 @@ export default async function addDbEntry({
|
||||
: true;
|
||||
|
||||
/** @type { any } */
|
||||
const dbHandler: any = useLocal
|
||||
const dbHandler: any = global.DSQL_USE_LOCAL
|
||||
? LOCAL_DB_HANDLER
|
||||
: isMaster
|
||||
? DB_HANDLER
|
||||
|
@ -10,7 +10,6 @@ type Param = {
|
||||
tableSchema?: import("../../../types").DSQL_TableSchemaType;
|
||||
identifierColumnName: string;
|
||||
identifierValue: string | number;
|
||||
useLocal?: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -24,10 +23,9 @@ export default async function deleteDbEntry({
|
||||
tableName,
|
||||
identifierColumnName,
|
||||
identifierValue,
|
||||
useLocal,
|
||||
}: Param): Promise<object | null> {
|
||||
try {
|
||||
const isMaster = useLocal
|
||||
const isMaster = global.DSQL_USE_LOCAL
|
||||
? true
|
||||
: dbContext?.match(/dsql.user/i)
|
||||
? false
|
||||
@ -35,8 +33,7 @@ export default async function deleteDbEntry({
|
||||
? false
|
||||
: true;
|
||||
|
||||
/** @type { (a1:any, a2?:any) => any } */
|
||||
const dbHandler: (a1: any, a2?: any) => any = useLocal
|
||||
const dbHandler: (a1: any, a2?: any) => any = global.DSQL_USE_LOCAL
|
||||
? LOCAL_DB_HANDLER
|
||||
: isMaster
|
||||
? DB_HANDLER
|
||||
|
@ -11,7 +11,6 @@ type Param = {
|
||||
dbFullName: string;
|
||||
query: string | any;
|
||||
readOnly?: boolean;
|
||||
local?: boolean;
|
||||
debug?: boolean;
|
||||
dbSchema?: import("../../../types").DSQL_DatabaseSchemaType;
|
||||
queryValuesArray?: (string | number)[];
|
||||
@ -28,7 +27,6 @@ export default async function runQuery({
|
||||
dbSchema,
|
||||
queryValuesArray,
|
||||
tableName,
|
||||
local,
|
||||
debug,
|
||||
}: Param): Promise<any> {
|
||||
/**
|
||||
@ -68,7 +66,7 @@ export default async function runQuery({
|
||||
if (typeof query === "string") {
|
||||
const formattedQuery = trimSql(query);
|
||||
|
||||
if (debug && local) {
|
||||
if (debug && global.DSQL_USE_LOCAL) {
|
||||
console.log("runQuery:formattedQuery", formattedQuery);
|
||||
}
|
||||
|
||||
@ -91,14 +89,12 @@ export default async function runQuery({
|
||||
queryString: formattedQuery,
|
||||
queryValuesArray: queryValuesArray?.map((vl) => String(vl)),
|
||||
tableSchema,
|
||||
useLocal: local,
|
||||
});
|
||||
} else {
|
||||
result = await fullAccessDbHandler({
|
||||
queryString: formattedQuery,
|
||||
queryValuesArray: queryValuesArray?.map((vl) => String(vl)),
|
||||
tableSchema,
|
||||
local,
|
||||
});
|
||||
}
|
||||
} else if (typeof query === "object") {
|
||||
@ -121,7 +117,9 @@ export default async function runQuery({
|
||||
switch (action.toLowerCase()) {
|
||||
case "insert":
|
||||
result = await addDbEntry({
|
||||
dbContext: local ? "Master" : "Dsql User",
|
||||
dbContext: global.DSQL_USE_LOCAL
|
||||
? "Master"
|
||||
: "Dsql User",
|
||||
paradigm: "Full Access",
|
||||
dbFullName: dbFullName,
|
||||
tableName: table,
|
||||
@ -130,7 +128,6 @@ export default async function runQuery({
|
||||
duplicateColumnName,
|
||||
duplicateColumnValue,
|
||||
tableSchema,
|
||||
useLocal: local,
|
||||
});
|
||||
|
||||
if (!result?.insertId) {
|
||||
@ -141,7 +138,9 @@ export default async function runQuery({
|
||||
|
||||
case "update":
|
||||
result = await updateDbEntry({
|
||||
dbContext: local ? "Master" : "Dsql User",
|
||||
dbContext: global.DSQL_USE_LOCAL
|
||||
? "Master"
|
||||
: "Dsql User",
|
||||
paradigm: "Full Access",
|
||||
dbFullName: dbFullName,
|
||||
tableName: table,
|
||||
@ -149,21 +148,21 @@ export default async function runQuery({
|
||||
identifierColumnName,
|
||||
identifierValue,
|
||||
tableSchema,
|
||||
useLocal: local,
|
||||
});
|
||||
|
||||
break;
|
||||
|
||||
case "delete":
|
||||
result = await deleteDbEntry({
|
||||
dbContext: local ? "Master" : "Dsql User",
|
||||
dbContext: global.DSQL_USE_LOCAL
|
||||
? "Master"
|
||||
: "Dsql User",
|
||||
paradigm: "Full Access",
|
||||
dbFullName: dbFullName,
|
||||
tableName: table,
|
||||
identifierColumnName,
|
||||
identifierValue,
|
||||
tableSchema,
|
||||
useLocal: local,
|
||||
});
|
||||
|
||||
break;
|
||||
@ -179,7 +178,7 @@ export default async function runQuery({
|
||||
message: error.message,
|
||||
});
|
||||
|
||||
if (debug && local) {
|
||||
if (debug && global.DSQL_USE_LOCAL) {
|
||||
console.log("runQuery:error", error.message);
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,6 @@ type Param = {
|
||||
tableSchema?: import("../../../types").DSQL_TableSchemaType;
|
||||
identifierColumnName: string;
|
||||
identifierValue: string | number;
|
||||
useLocal?: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -34,14 +33,13 @@ export default async function updateDbEntry({
|
||||
identifierValue,
|
||||
encryptionKey,
|
||||
encryptionSalt,
|
||||
useLocal,
|
||||
}: Param): Promise<object | null> {
|
||||
/**
|
||||
* Check if data is valid
|
||||
*/
|
||||
if (!data || !Object.keys(data).length) return null;
|
||||
|
||||
const isMaster = useLocal
|
||||
const isMaster = global.DSQL_USE_LOCAL
|
||||
? true
|
||||
: dbContext?.match(/dsql.user/i)
|
||||
? false
|
||||
@ -50,7 +48,7 @@ export default async function updateDbEntry({
|
||||
: true;
|
||||
|
||||
/** @type {(a1:any, a2?:any)=> any } */
|
||||
const dbHandler: (a1: any, a2?: any) => any = useLocal
|
||||
const dbHandler: (a1: any, a2?: any) => any = global.DSQL_USE_LOCAL
|
||||
? LOCAL_DB_HANDLER
|
||||
: isMaster
|
||||
? DB_HANDLER
|
||||
|
@ -7,7 +7,6 @@ import serverError from "./serverError";
|
||||
|
||||
type Param = {
|
||||
queryString: string;
|
||||
local?: boolean;
|
||||
tableSchema?: import("../../types").DSQL_TableSchemaType | null;
|
||||
queryValuesArray?: string[];
|
||||
};
|
||||
@ -19,7 +18,6 @@ export default async function fullAccessDbHandler({
|
||||
queryString,
|
||||
tableSchema,
|
||||
queryValuesArray,
|
||||
local,
|
||||
}: Param) {
|
||||
/**
|
||||
* Declare variables
|
||||
@ -36,7 +34,7 @@ export default async function fullAccessDbHandler({
|
||||
try {
|
||||
/** ********************* Run Query */
|
||||
|
||||
results = local
|
||||
results = global.DSQL_USE_LOCAL
|
||||
? await LOCAL_DB_HANDLER(queryString, queryValuesArray)
|
||||
: await DSQL_USER_DB_HANDLER({
|
||||
paradigm: "Full Access",
|
||||
|
@ -8,7 +8,6 @@ type Param = {
|
||||
queryValuesArray?: any[];
|
||||
database?: string;
|
||||
tableSchema?: import("../../types").DSQL_TableSchemaType;
|
||||
useLocal?: boolean;
|
||||
debug?: boolean;
|
||||
};
|
||||
|
||||
@ -20,11 +19,10 @@ export default async function varDatabaseDbHandler({
|
||||
queryValuesArray,
|
||||
database,
|
||||
tableSchema,
|
||||
useLocal,
|
||||
debug,
|
||||
}: Param): Promise<any> {
|
||||
let CONNECTION = grabDSQLConnection({ fa: true, local: useLocal });
|
||||
if (useLocal) CONNECTION = grabDSQLConnection({ local: true });
|
||||
let CONNECTION = grabDSQLConnection({ fa: true });
|
||||
if (global.DSQL_USE_LOCAL) CONNECTION = grabDSQLConnection({ local: true });
|
||||
if (database?.match(/^datasquirel$/)) CONNECTION = grabDSQLConnection();
|
||||
|
||||
if (debug) {
|
||||
|
@ -10,7 +10,6 @@ type Param = {
|
||||
queryString: string;
|
||||
queryValuesArray?: string[];
|
||||
tableSchema?: import("../../types").DSQL_TableSchemaType;
|
||||
useLocal?: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -21,7 +20,6 @@ export default async function varReadOnlyDatabaseDbHandler({
|
||||
queryString,
|
||||
queryValuesArray,
|
||||
tableSchema,
|
||||
useLocal,
|
||||
}: Param) {
|
||||
/**
|
||||
* Declare variables
|
||||
@ -36,7 +34,7 @@ export default async function varReadOnlyDatabaseDbHandler({
|
||||
* @description Fetch data from db if no cache
|
||||
*/
|
||||
try {
|
||||
results = useLocal
|
||||
results = global.DSQL_USE_LOCAL
|
||||
? await LOCAL_DB_HANDLER(queryString, queryValuesArray)
|
||||
: await DSQL_USER_DB_HANDLER({
|
||||
paradigm: "Read Only",
|
||||
|
@ -1212,7 +1212,6 @@ export type APILoginFunctionParams = {
|
||||
token?: boolean;
|
||||
skipPassword?: boolean;
|
||||
social?: boolean;
|
||||
useLocal?: boolean;
|
||||
dbUserId?: number | string;
|
||||
debug?: boolean;
|
||||
};
|
||||
@ -1232,7 +1231,6 @@ export type APICreateUserFunctionParams = {
|
||||
payload: any;
|
||||
database: string;
|
||||
userId?: string | number;
|
||||
useLocal?: boolean;
|
||||
};
|
||||
|
||||
export type APICreateUserFunction = (
|
||||
@ -1246,7 +1244,6 @@ export type APIGetUserFunctionParams = {
|
||||
fields: string[];
|
||||
dbFullName: string;
|
||||
userId: string | number;
|
||||
useLocal?: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -1258,7 +1255,6 @@ export type APIGoogleLoginFunctionParams = {
|
||||
additionalFields?: string[];
|
||||
additionalData?: { [key: string]: string | number };
|
||||
debug?: boolean;
|
||||
useLocal?: boolean;
|
||||
};
|
||||
|
||||
export type APIGoogleLoginFunction = (
|
||||
@ -1277,7 +1273,6 @@ export type HandleSocialDbFunctionParams = {
|
||||
invitation?: any;
|
||||
supEmail?: string;
|
||||
additionalFields?: string[];
|
||||
useLocal?: boolean;
|
||||
debug?: boolean;
|
||||
};
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
import mysql from "serverless-mysql";
|
||||
import grabDSQLConnection from "../../grab-dsql-connection";
|
||||
|
||||
/**
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user