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