Updates
This commit is contained in:
parent
98aaa94b80
commit
b02399c64d
6
dist/index.d.ts
vendored
6
dist/index.d.ts
vendored
@ -73,12 +73,12 @@ declare const datasquirel: {
|
|||||||
post: typeof post;
|
post: typeof post;
|
||||||
user: {
|
user: {
|
||||||
auth: {
|
auth: {
|
||||||
login: (_: import("./package-shared/types").LoginUserParam) => Promise<import("./package-shared/types").APIResponseObject<import("./package-shared/types").DATASQUIREL_LoggedInUser | null>>;
|
login: (_: import("./package-shared/types").LoginUserParam) => Promise<import("./package-shared/types").APIResponseObject>;
|
||||||
get: (_: import("./package-shared/types").GetUserParams) => Promise<import("./package-shared/types").GetUserFunctionReturn>;
|
get: (_: import("./package-shared/types").GetUserParams) => Promise<import("./package-shared/types").GetUserFunctionReturn>;
|
||||||
signup: (_: import("./package-shared/types").AddUserParams) => Promise<import("./package-shared/types").APIResponseObject>;
|
signup: (_: import("./package-shared/types").AddUserParams) => Promise<import("./package-shared/types").APIResponseObject>;
|
||||||
sendEmailCode: (_: import("./package-shared/types").SendEmailCodeParams) => Promise<import("./package-shared/types").APIResponseObject>;
|
sendEmailCode: (_: import("./package-shared/types").SendEmailCodeParams) => Promise<import("./package-shared/types").APIResponseObject>;
|
||||||
update: (_: import("./package-shared/types").UpdateUserParams) => Promise<import("./package-shared/types").UpdateUserFunctionReturn>;
|
update: (_: import("./package-shared/types").UpdateUserParams) => Promise<import("./package-shared/types").APIResponseObject>;
|
||||||
resetPassword: (_: import("./package-shared/types").ResetPasswordParams) => Promise<import("./package-shared/types").UpdateUserFunctionReturn>;
|
resetPassword: (_: import("./package-shared/types").ResetPasswordParams) => Promise<import("./package-shared/types").APIResponseObject>;
|
||||||
googleLogin: (_: import("./package-shared/types").GoogleAuthParams) => Promise<import("./package-shared/types").APIResponseObject>;
|
googleLogin: (_: import("./package-shared/types").GoogleAuthParams) => Promise<import("./package-shared/types").APIResponseObject>;
|
||||||
logout: typeof import("./package-shared/actions/users/logout-user").default;
|
logout: typeof import("./package-shared/actions/users/logout-user").default;
|
||||||
auth: typeof import("./package-shared/actions/users/user-auth").default;
|
auth: typeof import("./package-shared/actions/users/user-auth").default;
|
||||||
|
|||||||
2
dist/package-shared/actions/get.d.ts
vendored
2
dist/package-shared/actions/get.d.ts
vendored
@ -20,5 +20,5 @@ export default function get<T extends {
|
|||||||
[k: string]: any;
|
[k: string]: any;
|
||||||
} = {
|
} = {
|
||||||
[k: string]: any;
|
[k: string]: any;
|
||||||
}, R extends any = any>({ key, database, query, table, debug, useLocal, apiVersion, }: Param<T>): Promise<APIResponseObject<R>>;
|
}>({ key, database, query, table, debug, useLocal, apiVersion, }: Param<T>): Promise<APIResponseObject>;
|
||||||
export {};
|
export {};
|
||||||
|
|||||||
@ -2,4 +2,4 @@ import { APIResponseObject, DATASQUIREL_LoggedInUser, LoginUserParam } from "../
|
|||||||
/**
|
/**
|
||||||
* # Login A user
|
* # Login A user
|
||||||
*/
|
*/
|
||||||
export default function loginUser<T extends DATASQUIREL_LoggedInUser = DATASQUIREL_LoggedInUser>({ apiKey, payload, database, additionalFields, response, encryptionKey, encryptionSalt, email_login, email_login_code, temp_code_field, token, skipPassword, apiUserID, skipWriteAuthFile, dbUserId, debug, cleanupTokens, secureCookie, useLocal, apiVersion, }: LoginUserParam): Promise<APIResponseObject<T | null>>;
|
export default function loginUser<T extends DATASQUIREL_LoggedInUser = DATASQUIREL_LoggedInUser>({ apiKey, payload, database, additionalFields, response, encryptionKey, encryptionSalt, email_login, email_login_code, temp_code_field, token, skipPassword, apiUserID, skipWriteAuthFile, dbUserId, debug, cleanupTokens, secureCookie, useLocal, apiVersion, }: LoginUserParam): Promise<APIResponseObject>;
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { ResetPasswordParams, UpdateUserFunctionReturn } from "../../types";
|
import { APIResponseObject, ResetPasswordParams } from "../../types";
|
||||||
/**
|
/**
|
||||||
* # Reset User Password
|
* # Reset User Password
|
||||||
*/
|
*/
|
||||||
export default function resetPassword(params: ResetPasswordParams): Promise<UpdateUserFunctionReturn>;
|
export default function resetPassword(params: ResetPasswordParams): Promise<APIResponseObject>;
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
import { UpdateUserFunctionReturn, UpdateUserParams } from "../../types";
|
import { APIResponseObject, UpdateUserParams } from "../../types";
|
||||||
import { DSQL_DATASQUIREL_USERS } from "../../types/dsql";
|
import { DSQL_DATASQUIREL_USERS } from "../../types/dsql";
|
||||||
/**
|
/**
|
||||||
* # Update User
|
* # Update User
|
||||||
*/
|
*/
|
||||||
export default function updateUser<T extends DSQL_DATASQUIREL_USERS = DSQL_DATASQUIREL_USERS & {
|
export default function updateUser<T extends DSQL_DATASQUIREL_USERS = DSQL_DATASQUIREL_USERS & {
|
||||||
[k: string]: any;
|
[k: string]: any;
|
||||||
}>({ payload, database, updatedUserId, useLocal, apiKey, apiVersion, dbUserId, }: UpdateUserParams<T>): Promise<UpdateUserFunctionReturn>;
|
}>({ payload, database, updatedUserId, useLocal, apiKey, apiVersion, dbUserId, }: UpdateUserParams<T>): Promise<APIResponseObject>;
|
||||||
|
|||||||
4
dist/package-shared/api/crud/delete.d.ts
vendored
4
dist/package-shared/api/crud/delete.d.ts
vendored
@ -20,7 +20,5 @@ export default function apiCrudDELETE<T extends {
|
|||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
} = {
|
} = {
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
}>({ dbName, tableName, deleteSpec, targetID, apiKey, useDefault }: Params<T>): Promise<import("../../types").APIResponseObject<{
|
}>({ dbName, tableName, deleteSpec, targetID, apiKey, useDefault }: Params<T>): Promise<import("../../types").APIResponseObject>;
|
||||||
[k: string]: any;
|
|
||||||
}>>;
|
|
||||||
export {};
|
export {};
|
||||||
|
|||||||
2
dist/package-shared/api/schema/get.d.ts
vendored
2
dist/package-shared/api/schema/get.d.ts
vendored
@ -9,5 +9,5 @@ type Params = {
|
|||||||
grabbedHostnames?: GrabHostNamesReturn;
|
grabbedHostnames?: GrabHostNamesReturn;
|
||||||
useDefault?: boolean;
|
useDefault?: boolean;
|
||||||
};
|
};
|
||||||
export default function <T extends DSQL_DatabaseSchemaType | DSQL_TableSchemaType | DSQL_FieldSchemaType = DSQL_DatabaseSchemaType>({ dbName, tableName, apiKey, useDefault, fieldName, apiConnectionConfig, grabbedHostnames, }: Params): Promise<APIResponseObject<T>>;
|
export default function <T extends DSQL_DatabaseSchemaType | DSQL_TableSchemaType | DSQL_FieldSchemaType = DSQL_DatabaseSchemaType>({ dbName, tableName, apiKey, useDefault, fieldName, apiConnectionConfig, grabbedHostnames, }: Params): Promise<APIResponseObject>;
|
||||||
export {};
|
export {};
|
||||||
|
|||||||
6
dist/package-shared/api/user/local-user.d.ts
vendored
6
dist/package-shared/api/user/local-user.d.ts
vendored
@ -4,12 +4,12 @@ import validateTempEmailCode from "../../actions/users/validate-temp-email-code"
|
|||||||
import { AddUserParams, GetUserParams, GoogleAuthParams, LoginUserParam, ResetPasswordParams, SendEmailCodeParams, UpdateUserParams } from "../../types";
|
import { AddUserParams, GetUserParams, GoogleAuthParams, LoginUserParam, ResetPasswordParams, SendEmailCodeParams, UpdateUserParams } from "../../types";
|
||||||
declare const localUser: {
|
declare const localUser: {
|
||||||
auth: {
|
auth: {
|
||||||
login: (_: LoginUserParam) => Promise<import("../../types").APIResponseObject<import("../../types").DATASQUIREL_LoggedInUser | null>>;
|
login: (_: LoginUserParam) => Promise<import("../../types").APIResponseObject>;
|
||||||
get: (_: GetUserParams) => Promise<import("../../types").GetUserFunctionReturn>;
|
get: (_: GetUserParams) => Promise<import("../../types").GetUserFunctionReturn>;
|
||||||
signup: (_: AddUserParams) => Promise<import("../../types").APIResponseObject>;
|
signup: (_: AddUserParams) => Promise<import("../../types").APIResponseObject>;
|
||||||
sendEmailCode: (_: SendEmailCodeParams) => Promise<import("../../types").APIResponseObject>;
|
sendEmailCode: (_: SendEmailCodeParams) => Promise<import("../../types").APIResponseObject>;
|
||||||
update: (_: UpdateUserParams) => Promise<import("../../types").UpdateUserFunctionReturn>;
|
update: (_: UpdateUserParams) => Promise<import("../../types").APIResponseObject>;
|
||||||
resetPassword: (_: ResetPasswordParams) => Promise<import("../../types").UpdateUserFunctionReturn>;
|
resetPassword: (_: ResetPasswordParams) => Promise<import("../../types").APIResponseObject>;
|
||||||
googleLogin: (_: GoogleAuthParams) => Promise<import("../../types").APIResponseObject>;
|
googleLogin: (_: GoogleAuthParams) => Promise<import("../../types").APIResponseObject>;
|
||||||
logout: typeof logoutUser;
|
logout: typeof logoutUser;
|
||||||
auth: typeof userAuth;
|
auth: typeof userAuth;
|
||||||
|
|||||||
@ -17,7 +17,5 @@ type Param<T = {
|
|||||||
*/
|
*/
|
||||||
export default function queryDSQLAPI<T = {
|
export default function queryDSQLAPI<T = {
|
||||||
[k: string]: any;
|
[k: string]: any;
|
||||||
}, P = {
|
}>({ body, query, useDefault, path: passedPath, method, apiKey, apiConnectionConfig, grabbedHostnames, }: Param<T>): Promise<APIResponseObject>;
|
||||||
[k: string]: any;
|
|
||||||
}>({ body, query, useDefault, path: passedPath, method, apiKey, apiConnectionConfig, grabbedHostnames, }: Param<T>): Promise<APIResponseObject<P>>;
|
|
||||||
export {};
|
export {};
|
||||||
|
|||||||
@ -121,8 +121,8 @@ function handleSocialDb(_a) {
|
|||||||
duplicateColumnValue: finalEmail,
|
duplicateColumnValue: finalEmail,
|
||||||
data: Object.assign(Object.assign({}, data), { email: finalEmail }),
|
data: Object.assign(Object.assign({}, data), { email: finalEmail }),
|
||||||
});
|
});
|
||||||
if ((_b = newUser === null || newUser === void 0 ? void 0 : newUser.payload) === null || _b === void 0 ? void 0 : _b.insertId) {
|
if ((_b = newUser === null || newUser === void 0 ? void 0 : newUser.postInsertReturn) === null || _b === void 0 ? void 0 : _b.insertId) {
|
||||||
const newUserQueriedQuery = `SELECT * FROM users WHERE id='${newUser.payload.insertId}'`;
|
const newUserQueriedQuery = `SELECT * FROM users WHERE id='${newUser.postInsertReturn.insertId}'`;
|
||||||
const newUserQueried = (yield (0, dbHandler_1.default)({
|
const newUserQueried = (yield (0, dbHandler_1.default)({
|
||||||
database: finalDbName,
|
database: finalDbName,
|
||||||
query: newUserQueriedQuery,
|
query: newUserQueriedQuery,
|
||||||
@ -141,7 +141,7 @@ function handleSocialDb(_a) {
|
|||||||
*/
|
*/
|
||||||
let generatedToken = (0, encrypt_1.default)({
|
let generatedToken = (0, encrypt_1.default)({
|
||||||
data: JSON.stringify({
|
data: JSON.stringify({
|
||||||
id: newUser.payload.insertId,
|
id: newUser.postInsertReturn.insertId,
|
||||||
email: supEmail,
|
email: supEmail,
|
||||||
dateCode: Date.now(),
|
dateCode: Date.now(),
|
||||||
}),
|
}),
|
||||||
|
|||||||
@ -138,8 +138,8 @@ function apiCreateUser(_a) {
|
|||||||
"/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", verification_status: verify ? 1 : 0 }),
|
"/images/user-preset-thumbnail.png", verification_status: verify ? 1 : 0 }),
|
||||||
});
|
});
|
||||||
if ((_b = addUser === null || addUser === void 0 ? void 0 : addUser.payload) === null || _b === void 0 ? void 0 : _b.insertId) {
|
if ((_b = addUser === null || addUser === void 0 ? void 0 : addUser.postInsertReturn) === null || _b === void 0 ? void 0 : _b.insertId) {
|
||||||
const newlyAddedUserQuery = `SELECT id,uuid,first_name,last_name,email,username,image,image_thumbnail,verification_status FROM ${dbFullName}.users WHERE id='${addUser.payload.insertId}'`;
|
const newlyAddedUserQuery = `SELECT id,uuid,first_name,last_name,email,username,image,image_thumbnail,verification_status FROM ${dbFullName}.users WHERE id='${addUser.postInsertReturn.insertId}'`;
|
||||||
const newlyAddedUser = (yield (0, dbHandler_1.default)({
|
const newlyAddedUser = (yield (0, dbHandler_1.default)({
|
||||||
query: newlyAddedUserQuery,
|
query: newlyAddedUserQuery,
|
||||||
values: [],
|
values: [],
|
||||||
|
|||||||
@ -153,7 +153,7 @@ function apiLoginUser(_a) {
|
|||||||
const resposeObject = {
|
const resposeObject = {
|
||||||
success: true,
|
success: true,
|
||||||
msg: "Login Successful",
|
msg: "Login Successful",
|
||||||
payload: userPayload,
|
singleRes: userPayload,
|
||||||
userId: foundUser[0].id,
|
userId: foundUser[0].id,
|
||||||
csrf: csrfKey,
|
csrf: csrfKey,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -49,7 +49,7 @@ function apiResetUserPassword(_a) {
|
|||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
payload: updateUser,
|
singleRes: updateUser,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -75,7 +75,7 @@ function apiUpdateUser(_a) {
|
|||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
payload: updateUser,
|
singleRes: updateUser,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { APILoginFunctionReturn } from "../../../../types";
|
import { APIResponseObject } from "../../../../types";
|
||||||
type Param = {
|
type Param = {
|
||||||
code?: string;
|
code?: string;
|
||||||
clientId?: string;
|
clientId?: string;
|
||||||
@ -13,5 +13,5 @@ type Param = {
|
|||||||
/**
|
/**
|
||||||
* # API Login with Github
|
* # API Login with Github
|
||||||
*/
|
*/
|
||||||
export default function apiGithubLogin({ code, clientId, clientSecret, database, additionalFields, email, additionalData, }: Param): Promise<APILoginFunctionReturn>;
|
export default function apiGithubLogin({ code, clientId, clientSecret, database, additionalFields, email, additionalData, }: Param): Promise<APIResponseObject>;
|
||||||
export {};
|
export {};
|
||||||
|
|||||||
@ -20,7 +20,7 @@ function postLoginResponseHandler({ database, httpResponse, response, encryption
|
|||||||
const COOKIE_EXPIRY_DATE = (0, grab_cookie_expirt_date_1.default)();
|
const COOKIE_EXPIRY_DATE = (0, grab_cookie_expirt_date_1.default)();
|
||||||
if (httpResponse === null || httpResponse === void 0 ? void 0 : httpResponse.success) {
|
if (httpResponse === null || httpResponse === void 0 ? void 0 : httpResponse.success) {
|
||||||
let encryptedPayload = (0, encrypt_1.default)({
|
let encryptedPayload = (0, encrypt_1.default)({
|
||||||
data: JSON.stringify(httpResponse.payload),
|
data: JSON.stringify(httpResponse.singleRes),
|
||||||
encryptionKey,
|
encryptionKey,
|
||||||
encryptionSalt,
|
encryptionSalt,
|
||||||
});
|
});
|
||||||
@ -35,8 +35,8 @@ function postLoginResponseHandler({ database, httpResponse, response, encryption
|
|||||||
database,
|
database,
|
||||||
});
|
});
|
||||||
if (httpResponse.csrf && !skipWriteAuthFile) {
|
if (httpResponse.csrf && !skipWriteAuthFile) {
|
||||||
(0, write_auth_files_1.writeAuthFile)(httpResponse.csrf, JSON.stringify(httpResponse.payload), cleanupTokens && ((_a = httpResponse.payload) === null || _a === void 0 ? void 0 : _a.id)
|
(0, write_auth_files_1.writeAuthFile)(httpResponse.csrf, JSON.stringify(httpResponse.singleRes), cleanupTokens && ((_a = httpResponse.singleRes) === null || _a === void 0 ? void 0 : _a.id)
|
||||||
? { userId: httpResponse.payload.id }
|
? { userId: httpResponse.singleRes.id }
|
||||||
: undefined);
|
: undefined);
|
||||||
}
|
}
|
||||||
httpResponse["cookieNames"] = cookieNames;
|
httpResponse["cookieNames"] = cookieNames;
|
||||||
@ -50,7 +50,7 @@ function postLoginResponseHandler({ database, httpResponse, response, encryption
|
|||||||
}
|
}
|
||||||
response === null || response === void 0 ? void 0 : response.setHeader("Set-Cookie", [
|
response === null || response === void 0 ? void 0 : response.setHeader("Set-Cookie", [
|
||||||
`${authKeyName}=${encryptedPayload};samesite=strict;path=/;HttpOnly=true;Expires=${COOKIE_EXPIRY_DATE}${secureCookie ? ";Secure=true" : ""}`,
|
`${authKeyName}=${encryptedPayload};samesite=strict;path=/;HttpOnly=true;Expires=${COOKIE_EXPIRY_DATE}${secureCookie ? ";Secure=true" : ""}`,
|
||||||
`${csrfName}=${(_b = httpResponse.payload) === null || _b === void 0 ? void 0 : _b.csrf_k};samesite=strict;path=/;HttpOnly=true;Expires=${COOKIE_EXPIRY_DATE}`,
|
`${csrfName}=${(_b = httpResponse.singleRes) === null || _b === void 0 ? void 0 : _b.csrf_k};samesite=strict;path=/;HttpOnly=true;Expires=${COOKIE_EXPIRY_DATE}`,
|
||||||
]);
|
]);
|
||||||
if (debug) {
|
if (debug) {
|
||||||
debugFn("Response Sent!");
|
debugFn("Response Sent!");
|
||||||
|
|||||||
@ -38,7 +38,7 @@ function suAddBackup(_a) {
|
|||||||
tableName: "backups",
|
tableName: "backups",
|
||||||
data: newBackup,
|
data: newBackup,
|
||||||
});
|
});
|
||||||
if (!((_b = newBackupEntry === null || newBackupEntry === void 0 ? void 0 : newBackupEntry.payload) === null || _b === void 0 ? void 0 : _b.insertId)) {
|
if (!((_b = newBackupEntry === null || newBackupEntry === void 0 ? void 0 : newBackupEntry.postInsertReturn) === null || _b === void 0 ? void 0 : _b.insertId)) {
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
msg: `Couldn't create new backup entry`,
|
msg: `Couldn't create new backup entry`,
|
||||||
@ -46,7 +46,7 @@ function suAddBackup(_a) {
|
|||||||
}
|
}
|
||||||
const { single: newlyAddedBackup } = yield (0, grab_user_resource_1.default)({
|
const { single: newlyAddedBackup } = yield (0, grab_user_resource_1.default)({
|
||||||
tableName: "backups",
|
tableName: "backups",
|
||||||
targetID: (_c = newBackupEntry.payload) === null || _c === void 0 ? void 0 : _c.insertId,
|
targetID: (_c = newBackupEntry.postInsertReturn) === null || _c === void 0 ? void 0 : _c.insertId,
|
||||||
isSuperUser: true,
|
isSuperUser: true,
|
||||||
});
|
});
|
||||||
if (!(newlyAddedBackup === null || newlyAddedBackup === void 0 ? void 0 : newlyAddedBackup.id)) {
|
if (!(newlyAddedBackup === null || newlyAddedBackup === void 0 ? void 0 : newlyAddedBackup.id)) {
|
||||||
|
|||||||
@ -53,7 +53,7 @@ function deleteDbEntry(_a) {
|
|||||||
*/
|
*/
|
||||||
return {
|
return {
|
||||||
success: Boolean(deletedEntry.affectedRows),
|
success: Boolean(deletedEntry.affectedRows),
|
||||||
payload: deletedEntry,
|
postInsertReturn: deletedEntry,
|
||||||
queryObject: {
|
queryObject: {
|
||||||
sql: (0, sql_formatter_1.format)(query),
|
sql: (0, sql_formatter_1.format)(query),
|
||||||
params: values,
|
params: values,
|
||||||
|
|||||||
@ -115,7 +115,7 @@ function updateDbEntry(_a) {
|
|||||||
*/
|
*/
|
||||||
return {
|
return {
|
||||||
success: Boolean(updatedEntry === null || updatedEntry === void 0 ? void 0 : updatedEntry.affectedRows),
|
success: Boolean(updatedEntry === null || updatedEntry === void 0 ? void 0 : updatedEntry.affectedRows),
|
||||||
payload: updatedEntry,
|
postInsertReturn: updatedEntry,
|
||||||
queryObject: {
|
queryObject: {
|
||||||
sql: (0, sql_formatter_1.format)(query),
|
sql: (0, sql_formatter_1.format)(query),
|
||||||
params: updateValues,
|
params: updateValues,
|
||||||
|
|||||||
@ -61,7 +61,9 @@ function handleMariadbUserRecord(_a) {
|
|||||||
query: {
|
query: {
|
||||||
query: {
|
query: {
|
||||||
id: {
|
id: {
|
||||||
value: String((existingRecord === null || existingRecord === void 0 ? void 0 : existingRecord.id) || ((_d = record === null || record === void 0 ? void 0 : record.payload) === null || _d === void 0 ? void 0 : _d.insertId) || 0),
|
value: String((existingRecord === null || existingRecord === void 0 ? void 0 : existingRecord.id) ||
|
||||||
|
((_d = record === null || record === void 0 ? void 0 : record.postInsertReturn) === null || _d === void 0 ? void 0 : _d.insertId) ||
|
||||||
|
0),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@ -52,7 +52,7 @@ function checkDbRecordCreateDbSchema(_a) {
|
|||||||
tableName: "user_databases",
|
tableName: "user_databases",
|
||||||
forceLocal: true,
|
forceLocal: true,
|
||||||
});
|
});
|
||||||
if ((_b = newDbEntry.payload) === null || _b === void 0 ? void 0 : _b.insertId) {
|
if ((_b = newDbEntry.postInsertReturn) === null || _b === void 0 ? void 0 : _b.insertId) {
|
||||||
recordedDbEntryArray = (yield (0, dbHandler_1.default)({
|
recordedDbEntryArray = (yield (0, dbHandler_1.default)({
|
||||||
query: `SELECT * FROM datasquirel.user_databases WHERE db_full_name = ?`,
|
query: `SELECT * FROM datasquirel.user_databases WHERE db_full_name = ?`,
|
||||||
values: [dbFullName || "NULL"],
|
values: [dbFullName || "NULL"],
|
||||||
|
|||||||
@ -74,7 +74,7 @@ function checkTableRecordCreateDbSchema(_a) {
|
|||||||
dbContext: "Master",
|
dbContext: "Master",
|
||||||
forceLocal: true,
|
forceLocal: true,
|
||||||
});
|
});
|
||||||
if ((_b = newTableRecordEntry.payload) === null || _b === void 0 ? void 0 : _b.insertId) {
|
if ((_b = newTableRecordEntry.postInsertReturn) === null || _b === void 0 ? void 0 : _b.insertId) {
|
||||||
recordedTableEntryArray = (yield (0, dbHandler_1.default)({
|
recordedTableEntryArray = (yield (0, dbHandler_1.default)({
|
||||||
query: (queryObj === null || queryObj === void 0 ? void 0 : queryObj.string) || "",
|
query: (queryObj === null || queryObj === void 0 ? void 0 : queryObj.string) || "",
|
||||||
values: queryObj === null || queryObj === void 0 ? void 0 : queryObj.values,
|
values: queryObj === null || queryObj === void 0 ? void 0 : queryObj.values,
|
||||||
|
|||||||
@ -78,7 +78,7 @@ function createUser() {
|
|||||||
tableName: "users",
|
tableName: "users",
|
||||||
data: Object.assign(Object.assign({}, userObj), { password: hashedPassword }),
|
data: Object.assign(Object.assign({}, userObj), { password: hashedPassword }),
|
||||||
});
|
});
|
||||||
if (!((_a = newUser === null || newUser === void 0 ? void 0 : newUser.payload) === null || _a === void 0 ? void 0 : _a.insertId))
|
if (!((_a = newUser === null || newUser === void 0 ? void 0 : newUser.postInsertReturn) === null || _a === void 0 ? void 0 : _a.insertId))
|
||||||
return false;
|
return false;
|
||||||
const { STATIC_ROOT } = (0, grab_dir_names_1.default)();
|
const { STATIC_ROOT } = (0, grab_dir_names_1.default)();
|
||||||
if (!STATIC_ROOT) {
|
if (!STATIC_ROOT) {
|
||||||
@ -90,17 +90,17 @@ function createUser() {
|
|||||||
*
|
*
|
||||||
* @description Create new user folder and file
|
* @description Create new user folder and file
|
||||||
*/
|
*/
|
||||||
let newUserSchemaFolderPath = `${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${newUser.payload.insertId}`;
|
let newUserSchemaFolderPath = `${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${newUser.postInsertReturn.insertId}`;
|
||||||
let newUserMediaFolderPath = path_1.default.join(STATIC_ROOT, `images/user-images/user-${newUser.payload.insertId}`);
|
let newUserMediaFolderPath = path_1.default.join(STATIC_ROOT, `images/user-images/user-${newUser.postInsertReturn.insertId}`);
|
||||||
fs_1.default.mkdirSync(newUserSchemaFolderPath, { recursive: true });
|
fs_1.default.mkdirSync(newUserSchemaFolderPath, { recursive: true });
|
||||||
fs_1.default.mkdirSync(newUserMediaFolderPath, { recursive: true });
|
fs_1.default.mkdirSync(newUserMediaFolderPath, { recursive: true });
|
||||||
fs_1.default.writeFileSync(`${newUserSchemaFolderPath}/main.json`, JSON.stringify([]), "utf8");
|
fs_1.default.writeFileSync(`${newUserSchemaFolderPath}/main.json`, JSON.stringify([]), "utf8");
|
||||||
const imageBasePath = path_1.default.join(STATIC_ROOT, `images/user-images/user-${newUser.payload.insertId}`);
|
const imageBasePath = path_1.default.join(STATIC_ROOT, `images/user-images/user-${newUser.postInsertReturn.insertId}`);
|
||||||
if (!fs_1.default.existsSync(imageBasePath)) {
|
if (!fs_1.default.existsSync(imageBasePath)) {
|
||||||
fs_1.default.mkdirSync(imageBasePath, { recursive: true });
|
fs_1.default.mkdirSync(imageBasePath, { recursive: true });
|
||||||
}
|
}
|
||||||
let imagePath = path_1.default.join(STATIC_ROOT, `images/user-images/user-${newUser.payload.insertId}/user-${newUser.payload.insertId}-profile.jpg`);
|
let imagePath = path_1.default.join(STATIC_ROOT, `images/user-images/user-${newUser.postInsertReturn.insertId}/user-${newUser.postInsertReturn.insertId}-profile.jpg`);
|
||||||
let imageThumbnailPath = path_1.default.join(STATIC_ROOT, `images/user-images/user-${newUser.payload.insertId}/user-${newUser.payload.insertId}-profile-thumbnail.jpg`);
|
let imageThumbnailPath = path_1.default.join(STATIC_ROOT, `images/user-images/user-${newUser.postInsertReturn.insertId}/user-${newUser.postInsertReturn.insertId}-profile-thumbnail.jpg`);
|
||||||
let prodImageUrl = imagePath.replace(STATIC_ROOT, process.env.DSQL_STATIC_HOST || "");
|
let prodImageUrl = imagePath.replace(STATIC_ROOT, process.env.DSQL_STATIC_HOST || "");
|
||||||
let prodImageThumbnailUrl = imageThumbnailPath.replace(STATIC_ROOT, process.env.DSQL_STATIC_HOST || "");
|
let prodImageThumbnailUrl = imageThumbnailPath.replace(STATIC_ROOT, process.env.DSQL_STATIC_HOST || "");
|
||||||
fs_1.default.copyFileSync(path_1.default.join(ROOT_DIR, "/public/images/user-preset.png"), imagePath);
|
fs_1.default.copyFileSync(path_1.default.join(ROOT_DIR, "/public/images/user-preset.png"), imagePath);
|
||||||
@ -110,7 +110,7 @@ function createUser() {
|
|||||||
dbFullName: "datasquirel",
|
dbFullName: "datasquirel",
|
||||||
tableName: "users",
|
tableName: "users",
|
||||||
identifierColumnName: "id",
|
identifierColumnName: "id",
|
||||||
identifierValue: newUser.payload.insertId,
|
identifierValue: newUser.postInsertReturn.insertId,
|
||||||
data: {
|
data: {
|
||||||
image: prodImageUrl,
|
image: prodImageUrl,
|
||||||
image_thumbnail: prodImageThumbnailUrl,
|
image_thumbnail: prodImageThumbnailUrl,
|
||||||
|
|||||||
@ -85,8 +85,8 @@ function default_1(_a) {
|
|||||||
tableName: targetTableName,
|
tableName: targetTableName,
|
||||||
dbFullName: targetDatabase,
|
dbFullName: targetDatabase,
|
||||||
});
|
});
|
||||||
if ((_b = newTableEntryRes === null || newTableEntryRes === void 0 ? void 0 : newTableEntryRes.payload) === null || _b === void 0 ? void 0 : _b.insertId) {
|
if ((_b = newTableEntryRes === null || newTableEntryRes === void 0 ? void 0 : newTableEntryRes.postInsertReturn) === null || _b === void 0 ? void 0 : _b.insertId) {
|
||||||
tableId = newTableEntryRes.payload.insertId;
|
tableId = newTableEntryRes.postInsertReturn.insertId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (newTableSchema.tableNameOld) {
|
if (newTableSchema.tableNameOld) {
|
||||||
|
|||||||
10
dist/package-shared/types/index.d.ts
vendored
10
dist/package-shared/types/index.d.ts
vendored
@ -1444,9 +1444,15 @@ export type ResponseQueryObject = {
|
|||||||
sql?: string;
|
sql?: string;
|
||||||
params?: (string | number)[];
|
params?: (string | number)[];
|
||||||
};
|
};
|
||||||
export type APIResponseObject<T extends any = any> = {
|
export type APIResponseObject<T extends {
|
||||||
|
[k: string]: any;
|
||||||
|
} = {
|
||||||
|
[k: string]: any;
|
||||||
|
}> = {
|
||||||
success: boolean;
|
success: boolean;
|
||||||
payload?: T;
|
payload?: T[] | null;
|
||||||
|
singleRes?: T | null;
|
||||||
|
postInsertReturn?: PostInsertReturn | null;
|
||||||
payloadBase64?: string;
|
payloadBase64?: string;
|
||||||
payloadThumbnailBase64?: string;
|
payloadThumbnailBase64?: string;
|
||||||
payloadURL?: string;
|
payloadURL?: string;
|
||||||
|
|||||||
@ -99,7 +99,7 @@ function dsqlCrud(params) {
|
|||||||
}));
|
}));
|
||||||
return {
|
return {
|
||||||
success: Boolean(res.affectedRows),
|
success: Boolean(res.affectedRows),
|
||||||
payload: res,
|
postInsertReturn: res,
|
||||||
queryObject: {
|
queryObject: {
|
||||||
sql: (0, sql_formatter_1.format)((deleteQuery === null || deleteQuery === void 0 ? void 0 : deleteQuery.query) || ""),
|
sql: (0, sql_formatter_1.format)((deleteQuery === null || deleteQuery === void 0 ? void 0 : deleteQuery.query) || ""),
|
||||||
params: (deleteQuery === null || deleteQuery === void 0 ? void 0 : deleteQuery.values) || [],
|
params: (deleteQuery === null || deleteQuery === void 0 ? void 0 : deleteQuery.values) || [],
|
||||||
|
|||||||
@ -22,8 +22,7 @@ export type ApiGetParams = Param;
|
|||||||
* # Make a get request to Datasquirel API
|
* # Make a get request to Datasquirel API
|
||||||
*/
|
*/
|
||||||
export default async function get<
|
export default async function get<
|
||||||
T extends { [k: string]: any } = { [k: string]: any },
|
T extends { [k: string]: any } = { [k: string]: any }
|
||||||
R extends any = any
|
|
||||||
>({
|
>({
|
||||||
key,
|
key,
|
||||||
database,
|
database,
|
||||||
@ -32,7 +31,7 @@ export default async function get<
|
|||||||
debug,
|
debug,
|
||||||
useLocal,
|
useLocal,
|
||||||
apiVersion = "v1",
|
apiVersion = "v1",
|
||||||
}: Param<T>): Promise<APIResponseObject<R>> {
|
}: Param<T>): Promise<APIResponseObject> {
|
||||||
const grabedHostNames = grabHostNames();
|
const grabedHostNames = grabHostNames();
|
||||||
const { host, port, scheme } = grabedHostNames;
|
const { host, port, scheme } = grabedHostNames;
|
||||||
|
|
||||||
@ -122,5 +121,5 @@ export default async function get<
|
|||||||
.end();
|
.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
return httpResponse as APIResponseObject<R>;
|
return httpResponse as APIResponseObject;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -44,7 +44,7 @@ export default async function loginUser<
|
|||||||
secureCookie,
|
secureCookie,
|
||||||
useLocal,
|
useLocal,
|
||||||
apiVersion = "v1",
|
apiVersion = "v1",
|
||||||
}: LoginUserParam): Promise<APIResponseObject<T | null>> {
|
}: LoginUserParam): Promise<APIResponseObject> {
|
||||||
const COOKIE_EXPIRY_DATE = grabCookieExpiryDate();
|
const COOKIE_EXPIRY_DATE = grabCookieExpiryDate();
|
||||||
|
|
||||||
const defaultTempLoginFieldName = "temp_login_code";
|
const defaultTempLoginFieldName = "temp_login_code";
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { ResetPasswordParams, UpdateUserFunctionReturn } from "../../types";
|
import { APIResponseObject, ResetPasswordParams } from "../../types";
|
||||||
import queryDSQLAPI from "../../functions/api/query-dsql-api";
|
import queryDSQLAPI from "../../functions/api/query-dsql-api";
|
||||||
import grabUserDSQLAPIPath from "../../utils/backend/users/grab-api-path";
|
import grabUserDSQLAPIPath from "../../utils/backend/users/grab-api-path";
|
||||||
import apiResetUserPassword from "../../functions/api/users/api-reset-user-password";
|
import apiResetUserPassword from "../../functions/api/users/api-reset-user-password";
|
||||||
@ -8,7 +8,7 @@ import apiResetUserPassword from "../../functions/api/users/api-reset-user-passw
|
|||||||
*/
|
*/
|
||||||
export default async function resetPassword(
|
export default async function resetPassword(
|
||||||
params: ResetPasswordParams
|
params: ResetPasswordParams
|
||||||
): Promise<UpdateUserFunctionReturn> {
|
): Promise<APIResponseObject> {
|
||||||
if (params.useLocal) {
|
if (params.useLocal) {
|
||||||
return await apiResetUserPassword(params);
|
return await apiResetUserPassword(params);
|
||||||
}
|
}
|
||||||
@ -25,5 +25,5 @@ export default async function resetPassword(
|
|||||||
method: "POST",
|
method: "POST",
|
||||||
});
|
});
|
||||||
|
|
||||||
return httpResponse as UpdateUserFunctionReturn;
|
return httpResponse as APIResponseObject;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import apiUpdateUser from "../../functions/api/users/api-update-user";
|
import apiUpdateUser from "../../functions/api/users/api-update-user";
|
||||||
import {
|
import {
|
||||||
|
APIResponseObject,
|
||||||
ApiUpdateUserParams,
|
ApiUpdateUserParams,
|
||||||
UpdateUserFunctionReturn,
|
UpdateUserFunctionReturn,
|
||||||
UpdateUserParams,
|
UpdateUserParams,
|
||||||
@ -23,7 +24,7 @@ export default async function updateUser<
|
|||||||
apiKey,
|
apiKey,
|
||||||
apiVersion,
|
apiVersion,
|
||||||
dbUserId,
|
dbUserId,
|
||||||
}: UpdateUserParams<T>): Promise<UpdateUserFunctionReturn> {
|
}: UpdateUserParams<T>): Promise<APIResponseObject> {
|
||||||
const updateUserParams: ApiUpdateUserParams = {
|
const updateUserParams: ApiUpdateUserParams = {
|
||||||
payload: payload,
|
payload: payload,
|
||||||
database,
|
database,
|
||||||
@ -52,5 +53,5 @@ export default async function updateUser<
|
|||||||
method: "POST",
|
method: "POST",
|
||||||
});
|
});
|
||||||
|
|
||||||
return httpResponse as UpdateUserFunctionReturn;
|
return httpResponse as APIResponseObject;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,7 +33,7 @@ export default async function <
|
|||||||
fieldName,
|
fieldName,
|
||||||
apiConnectionConfig,
|
apiConnectionConfig,
|
||||||
grabbedHostnames,
|
grabbedHostnames,
|
||||||
}: Params): Promise<APIResponseObject<T>> {
|
}: Params): Promise<APIResponseObject> {
|
||||||
const basePath = grabAPIBasePath({ paradigm: "schema" });
|
const basePath = grabAPIBasePath({ paradigm: "schema" });
|
||||||
|
|
||||||
const finalPath = path.join(
|
const finalPath = path.join(
|
||||||
@ -43,7 +43,7 @@ export default async function <
|
|||||||
fieldName || ""
|
fieldName || ""
|
||||||
);
|
);
|
||||||
|
|
||||||
const GET_RES = await queryDSQLAPI<any, T>({
|
const GET_RES = await queryDSQLAPI<T>({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
path: finalPath,
|
path: finalPath,
|
||||||
apiKey,
|
apiKey,
|
||||||
|
|||||||
@ -30,10 +30,7 @@ type Param<T = { [k: string]: any }> = {
|
|||||||
/**
|
/**
|
||||||
* # Query DSQL API
|
* # Query DSQL API
|
||||||
*/
|
*/
|
||||||
export default async function queryDSQLAPI<
|
export default async function queryDSQLAPI<T = { [k: string]: any }>({
|
||||||
T = { [k: string]: any },
|
|
||||||
P = { [k: string]: any }
|
|
||||||
>({
|
|
||||||
body,
|
body,
|
||||||
query,
|
query,
|
||||||
useDefault,
|
useDefault,
|
||||||
@ -42,7 +39,7 @@ export default async function queryDSQLAPI<
|
|||||||
apiKey,
|
apiKey,
|
||||||
apiConnectionConfig,
|
apiConnectionConfig,
|
||||||
grabbedHostnames,
|
grabbedHostnames,
|
||||||
}: Param<T>): Promise<APIResponseObject<P>> {
|
}: Param<T>): Promise<APIResponseObject> {
|
||||||
const grabedHostNames =
|
const grabedHostNames =
|
||||||
grabbedHostnames || grabHostNames({ useDefault, apiConnectionConfig });
|
grabbedHostnames || grabHostNames({ useDefault, apiConnectionConfig });
|
||||||
const { host, port, scheme } = grabedHostNames;
|
const { host, port, scheme } = grabedHostNames;
|
||||||
@ -168,7 +165,7 @@ export default async function queryDSQLAPI<
|
|||||||
httpsRequest.end();
|
httpsRequest.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
return httpResponse as APIResponseObject<P>;
|
return httpResponse as APIResponseObject;
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
|
|||||||
@ -152,8 +152,8 @@ export default async function handleSocialDb({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (newUser?.payload?.insertId) {
|
if (newUser?.postInsertReturn?.insertId) {
|
||||||
const newUserQueriedQuery = `SELECT * FROM users WHERE id='${newUser.payload.insertId}'`;
|
const newUserQueriedQuery = `SELECT * FROM users WHERE id='${newUser.postInsertReturn.insertId}'`;
|
||||||
|
|
||||||
const newUserQueried = (await dbHandler({
|
const newUserQueried = (await dbHandler({
|
||||||
database: finalDbName,
|
database: finalDbName,
|
||||||
@ -175,7 +175,7 @@ export default async function handleSocialDb({
|
|||||||
*/
|
*/
|
||||||
let generatedToken = encrypt({
|
let generatedToken = encrypt({
|
||||||
data: JSON.stringify({
|
data: JSON.stringify({
|
||||||
id: newUser.payload.insertId,
|
id: newUser.postInsertReturn.insertId,
|
||||||
email: supEmail,
|
email: supEmail,
|
||||||
dateCode: Date.now(),
|
dateCode: Date.now(),
|
||||||
}),
|
}),
|
||||||
|
|||||||
@ -163,8 +163,8 @@ export default async function apiCreateUser({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (addUser?.payload?.insertId) {
|
if (addUser?.postInsertReturn?.insertId) {
|
||||||
const newlyAddedUserQuery = `SELECT id,uuid,first_name,last_name,email,username,image,image_thumbnail,verification_status FROM ${dbFullName}.users WHERE id='${addUser.payload.insertId}'`;
|
const newlyAddedUserQuery = `SELECT id,uuid,first_name,last_name,email,username,image,image_thumbnail,verification_status FROM ${dbFullName}.users WHERE id='${addUser.postInsertReturn.insertId}'`;
|
||||||
|
|
||||||
const newlyAddedUser = (await dbHandler({
|
const newlyAddedUser = (await dbHandler({
|
||||||
query: newlyAddedUserQuery,
|
query: newlyAddedUserQuery,
|
||||||
|
|||||||
@ -184,7 +184,7 @@ export default async function apiLoginUser({
|
|||||||
const resposeObject: APIResponseObject = {
|
const resposeObject: APIResponseObject = {
|
||||||
success: true,
|
success: true,
|
||||||
msg: "Login Successful",
|
msg: "Login Successful",
|
||||||
payload: userPayload,
|
singleRes: userPayload,
|
||||||
userId: foundUser[0].id,
|
userId: foundUser[0].id,
|
||||||
csrf: csrfKey,
|
csrf: csrfKey,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -48,6 +48,6 @@ export default async function apiResetUserPassword({
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
payload: updateUser,
|
singleRes: updateUser,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -81,6 +81,6 @@ export default async function apiUpdateUser({
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
payload: updateUser,
|
singleRes: updateUser,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import handleSocialDb from "../../social-login/handleSocialDb";
|
import handleSocialDb from "../../social-login/handleSocialDb";
|
||||||
import githubLogin from "../../social-login/githubLogin";
|
import githubLogin from "../../social-login/githubLogin";
|
||||||
import camelJoinedtoCamelSpace from "../../../../utils/camelJoinedtoCamelSpace";
|
import camelJoinedtoCamelSpace from "../../../../utils/camelJoinedtoCamelSpace";
|
||||||
import { APILoginFunctionReturn } from "../../../../types";
|
import { APILoginFunctionReturn, APIResponseObject } from "../../../../types";
|
||||||
|
|
||||||
type Param = {
|
type Param = {
|
||||||
code?: string;
|
code?: string;
|
||||||
@ -24,7 +24,7 @@ export default async function apiGithubLogin({
|
|||||||
additionalFields,
|
additionalFields,
|
||||||
email,
|
email,
|
||||||
additionalData,
|
additionalData,
|
||||||
}: Param): Promise<APILoginFunctionReturn> {
|
}: Param): Promise<APIResponseObject> {
|
||||||
if (!code || !clientId || !clientSecret || !database) {
|
if (!code || !clientId || !clientSecret || !database) {
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
|
|||||||
@ -42,7 +42,7 @@ export default function postLoginResponseHandler({
|
|||||||
|
|
||||||
if (httpResponse?.success) {
|
if (httpResponse?.success) {
|
||||||
let encryptedPayload = encrypt({
|
let encryptedPayload = encrypt({
|
||||||
data: JSON.stringify(httpResponse.payload),
|
data: JSON.stringify(httpResponse.singleRes),
|
||||||
encryptionKey,
|
encryptionKey,
|
||||||
encryptionSalt,
|
encryptionSalt,
|
||||||
});
|
});
|
||||||
@ -61,9 +61,9 @@ export default function postLoginResponseHandler({
|
|||||||
if (httpResponse.csrf && !skipWriteAuthFile) {
|
if (httpResponse.csrf && !skipWriteAuthFile) {
|
||||||
writeAuthFile(
|
writeAuthFile(
|
||||||
httpResponse.csrf,
|
httpResponse.csrf,
|
||||||
JSON.stringify(httpResponse.payload),
|
JSON.stringify(httpResponse.singleRes),
|
||||||
cleanupTokens && httpResponse.payload?.id
|
cleanupTokens && httpResponse.singleRes?.id
|
||||||
? { userId: httpResponse.payload.id }
|
? { userId: httpResponse.singleRes.id }
|
||||||
: undefined
|
: undefined
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -84,7 +84,7 @@ export default function postLoginResponseHandler({
|
|||||||
`${authKeyName}=${encryptedPayload};samesite=strict;path=/;HttpOnly=true;Expires=${COOKIE_EXPIRY_DATE}${
|
`${authKeyName}=${encryptedPayload};samesite=strict;path=/;HttpOnly=true;Expires=${COOKIE_EXPIRY_DATE}${
|
||||||
secureCookie ? ";Secure=true" : ""
|
secureCookie ? ";Secure=true" : ""
|
||||||
}`,
|
}`,
|
||||||
`${csrfName}=${httpResponse.payload?.csrf_k};samesite=strict;path=/;HttpOnly=true;Expires=${COOKIE_EXPIRY_DATE}`,
|
`${csrfName}=${httpResponse.singleRes?.csrf_k};samesite=strict;path=/;HttpOnly=true;Expires=${COOKIE_EXPIRY_DATE}`,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (debug) {
|
if (debug) {
|
||||||
|
|||||||
@ -43,7 +43,7 @@ export default async function suAddBackup({
|
|||||||
data: newBackup,
|
data: newBackup,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!newBackupEntry?.payload?.insertId) {
|
if (!newBackupEntry?.postInsertReturn?.insertId) {
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
msg: `Couldn't create new backup entry`,
|
msg: `Couldn't create new backup entry`,
|
||||||
@ -53,7 +53,7 @@ export default async function suAddBackup({
|
|||||||
const { single: newlyAddedBackup } =
|
const { single: newlyAddedBackup } =
|
||||||
await dbGrabUserResource<DSQL_DATASQUIREL_BACKUPS>({
|
await dbGrabUserResource<DSQL_DATASQUIREL_BACKUPS>({
|
||||||
tableName: "backups",
|
tableName: "backups",
|
||||||
targetID: newBackupEntry.payload?.insertId,
|
targetID: newBackupEntry.postInsertReturn?.insertId,
|
||||||
isSuperUser: true,
|
isSuperUser: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -74,7 +74,7 @@ export default async function deleteDbEntry<
|
|||||||
*/
|
*/
|
||||||
return {
|
return {
|
||||||
success: Boolean(deletedEntry.affectedRows),
|
success: Boolean(deletedEntry.affectedRows),
|
||||||
payload: deletedEntry,
|
postInsertReturn: deletedEntry,
|
||||||
queryObject: {
|
queryObject: {
|
||||||
sql: format(query),
|
sql: format(query),
|
||||||
params: values,
|
params: values,
|
||||||
|
|||||||
@ -161,7 +161,7 @@ export default async function updateDbEntry<
|
|||||||
*/
|
*/
|
||||||
return {
|
return {
|
||||||
success: Boolean(updatedEntry?.affectedRows),
|
success: Boolean(updatedEntry?.affectedRows),
|
||||||
payload: updatedEntry,
|
postInsertReturn: updatedEntry,
|
||||||
queryObject: {
|
queryObject: {
|
||||||
sql: format(query),
|
sql: format(query),
|
||||||
params: updateValues,
|
params: updateValues,
|
||||||
|
|||||||
@ -78,7 +78,9 @@ export default async function handleMariadbUserRecord({
|
|||||||
query: {
|
query: {
|
||||||
id: {
|
id: {
|
||||||
value: String(
|
value: String(
|
||||||
existingRecord?.id || record?.payload?.insertId || 0
|
existingRecord?.id ||
|
||||||
|
record?.postInsertReturn?.insertId ||
|
||||||
|
0
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@ -64,7 +64,7 @@ export default async function checkDbRecordCreateDbSchema({
|
|||||||
forceLocal: true,
|
forceLocal: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (newDbEntry.payload?.insertId) {
|
if (newDbEntry.postInsertReturn?.insertId) {
|
||||||
recordedDbEntryArray = (await dbHandler({
|
recordedDbEntryArray = (await dbHandler({
|
||||||
query: `SELECT * FROM datasquirel.user_databases WHERE db_full_name = ?`,
|
query: `SELECT * FROM datasquirel.user_databases WHERE db_full_name = ?`,
|
||||||
values: [dbFullName || "NULL"],
|
values: [dbFullName || "NULL"],
|
||||||
|
|||||||
@ -97,7 +97,7 @@ export default async function checkTableRecordCreateDbSchema({
|
|||||||
forceLocal: true,
|
forceLocal: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (newTableRecordEntry.payload?.insertId) {
|
if (newTableRecordEntry.postInsertReturn?.insertId) {
|
||||||
recordedTableEntryArray = (await dbHandler({
|
recordedTableEntryArray = (await dbHandler({
|
||||||
query: queryObj?.string || "",
|
query: queryObj?.string || "",
|
||||||
values: queryObj?.values,
|
values: queryObj?.values,
|
||||||
|
|||||||
@ -77,7 +77,7 @@ async function createUser() {
|
|||||||
data: { ...userObj, password: hashedPassword },
|
data: { ...userObj, password: hashedPassword },
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!newUser?.payload?.insertId) return false;
|
if (!newUser?.postInsertReturn?.insertId) return false;
|
||||||
|
|
||||||
const { STATIC_ROOT } = grabDirNames();
|
const { STATIC_ROOT } = grabDirNames();
|
||||||
|
|
||||||
@ -91,10 +91,10 @@ async function createUser() {
|
|||||||
*
|
*
|
||||||
* @description Create new user folder and file
|
* @description Create new user folder and file
|
||||||
*/
|
*/
|
||||||
let newUserSchemaFolderPath = `${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${newUser.payload.insertId}`;
|
let newUserSchemaFolderPath = `${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${newUser.postInsertReturn.insertId}`;
|
||||||
let newUserMediaFolderPath = path.join(
|
let newUserMediaFolderPath = path.join(
|
||||||
STATIC_ROOT,
|
STATIC_ROOT,
|
||||||
`images/user-images/user-${newUser.payload.insertId}`
|
`images/user-images/user-${newUser.postInsertReturn.insertId}`
|
||||||
);
|
);
|
||||||
|
|
||||||
fs.mkdirSync(newUserSchemaFolderPath, { recursive: true });
|
fs.mkdirSync(newUserSchemaFolderPath, { recursive: true });
|
||||||
@ -108,7 +108,7 @@ async function createUser() {
|
|||||||
|
|
||||||
const imageBasePath = path.join(
|
const imageBasePath = path.join(
|
||||||
STATIC_ROOT,
|
STATIC_ROOT,
|
||||||
`images/user-images/user-${newUser.payload.insertId}`
|
`images/user-images/user-${newUser.postInsertReturn.insertId}`
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!fs.existsSync(imageBasePath)) {
|
if (!fs.existsSync(imageBasePath)) {
|
||||||
@ -117,12 +117,12 @@ async function createUser() {
|
|||||||
|
|
||||||
let imagePath = path.join(
|
let imagePath = path.join(
|
||||||
STATIC_ROOT,
|
STATIC_ROOT,
|
||||||
`images/user-images/user-${newUser.payload.insertId}/user-${newUser.payload.insertId}-profile.jpg`
|
`images/user-images/user-${newUser.postInsertReturn.insertId}/user-${newUser.postInsertReturn.insertId}-profile.jpg`
|
||||||
);
|
);
|
||||||
|
|
||||||
let imageThumbnailPath = path.join(
|
let imageThumbnailPath = path.join(
|
||||||
STATIC_ROOT,
|
STATIC_ROOT,
|
||||||
`images/user-images/user-${newUser.payload.insertId}/user-${newUser.payload.insertId}-profile-thumbnail.jpg`
|
`images/user-images/user-${newUser.postInsertReturn.insertId}/user-${newUser.postInsertReturn.insertId}-profile-thumbnail.jpg`
|
||||||
);
|
);
|
||||||
|
|
||||||
let prodImageUrl = imagePath.replace(
|
let prodImageUrl = imagePath.replace(
|
||||||
@ -149,7 +149,7 @@ async function createUser() {
|
|||||||
dbFullName: "datasquirel",
|
dbFullName: "datasquirel",
|
||||||
tableName: "users",
|
tableName: "users",
|
||||||
identifierColumnName: "id",
|
identifierColumnName: "id",
|
||||||
identifierValue: newUser.payload.insertId,
|
identifierValue: newUser.postInsertReturn.insertId,
|
||||||
data: {
|
data: {
|
||||||
image: prodImageUrl,
|
image: prodImageUrl,
|
||||||
image_thumbnail: prodImageThumbnailUrl,
|
image_thumbnail: prodImageThumbnailUrl,
|
||||||
|
|||||||
@ -97,8 +97,8 @@ export default async function ({
|
|||||||
dbFullName: targetDatabase,
|
dbFullName: targetDatabase,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (newTableEntryRes?.payload?.insertId) {
|
if (newTableEntryRes?.postInsertReturn?.insertId) {
|
||||||
tableId = newTableEntryRes.payload.insertId;
|
tableId = newTableEntryRes.postInsertReturn.insertId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1681,9 +1681,13 @@ export type ResponseQueryObject = {
|
|||||||
params?: (string | number)[];
|
params?: (string | number)[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type APIResponseObject<T extends any = any> = {
|
export type APIResponseObject<
|
||||||
|
T extends { [k: string]: any } = { [k: string]: any }
|
||||||
|
> = {
|
||||||
success: boolean;
|
success: boolean;
|
||||||
payload?: T;
|
payload?: T[] | null;
|
||||||
|
singleRes?: T | null;
|
||||||
|
postInsertReturn?: PostInsertReturn | null;
|
||||||
payloadBase64?: string;
|
payloadBase64?: string;
|
||||||
payloadThumbnailBase64?: string;
|
payloadThumbnailBase64?: string;
|
||||||
payloadURL?: string;
|
payloadURL?: string;
|
||||||
|
|||||||
@ -127,7 +127,7 @@ export default async function dsqlCrud<
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
success: Boolean(res.affectedRows),
|
success: Boolean(res.affectedRows),
|
||||||
payload: res,
|
postInsertReturn: res,
|
||||||
queryObject: {
|
queryObject: {
|
||||||
sql: format(deleteQuery?.query || ""),
|
sql: format(deleteQuery?.query || ""),
|
||||||
params: deleteQuery?.values || [],
|
params: deleteQuery?.values || [],
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@moduletrace/datasquirel",
|
"name": "@moduletrace/datasquirel",
|
||||||
"version": "5.5.7",
|
"version": "5.5.8",
|
||||||
"description": "Cloud-based SQL data management tool",
|
"description": "Cloud-based SQL data management tool",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user