Updates
This commit is contained in:
Vendored
+1
-1
@@ -108,7 +108,7 @@ if (!config.apiConnectionConfig.apiKey) {
|
||||
dbName: config.database || "",
|
||||
apiConnectionConfig: config.apiConnectionConfig,
|
||||
});
|
||||
const dbSchema = schemaRes.payload;
|
||||
const dbSchema = schemaRes.singleRes;
|
||||
if (config.debug) {
|
||||
(0, debug_log_1.default)({
|
||||
log: schemaRes,
|
||||
|
||||
Vendored
+1
-1
@@ -74,7 +74,7 @@ declare const datasquirel: {
|
||||
user: {
|
||||
auth: {
|
||||
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").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>;
|
||||
update: (_: import("./package-shared/types").UpdateUserParams) => Promise<import("./package-shared/types").APIResponseObject>;
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
import { GetUserFunctionReturn, GetUserParams } from "../../types";
|
||||
import { APIResponseObject, GetUserParams } from "../../types";
|
||||
/**
|
||||
* # Get User
|
||||
*/
|
||||
export default function getUser({ apiKey, userId, database, fields, useLocal, apiVersion, dbUserId, selectAll, }: GetUserParams): Promise<GetUserFunctionReturn>;
|
||||
export default function getUser({ apiKey, userId, database, fields, useLocal, apiVersion, dbUserId, selectAll, }: GetUserParams): Promise<APIResponseObject>;
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
import { APIResponseObject, DATASQUIREL_LoggedInUser, LoginUserParam } from "../../types";
|
||||
import { APIResponseObject, LoginUserParam } from "../../types";
|
||||
/**
|
||||
* # 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>;
|
||||
export default function loginUser({ 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
-1
@@ -5,7 +5,7 @@ import { AddUserParams, GetUserParams, GoogleAuthParams, LoginUserParam, ResetPa
|
||||
declare const localUser: {
|
||||
auth: {
|
||||
login: (_: LoginUserParam) => Promise<import("../../types").APIResponseObject>;
|
||||
get: (_: GetUserParams) => Promise<import("../../types").GetUserFunctionReturn>;
|
||||
get: (_: GetUserParams) => Promise<import("../../types").APIResponseObject>;
|
||||
signup: (_: AddUserParams) => Promise<import("../../types").APIResponseObject>;
|
||||
sendEmailCode: (_: SendEmailCodeParams) => Promise<import("../../types").APIResponseObject>;
|
||||
update: (_: UpdateUserParams) => Promise<import("../../types").APIResponseObject>;
|
||||
|
||||
+3
-3
@@ -103,7 +103,7 @@ function queryDSQLAPI(_a) {
|
||||
response.on("error", (err) => {
|
||||
resolve({
|
||||
success: false,
|
||||
payload: undefined,
|
||||
singleRes: undefined,
|
||||
msg: `An error occurred on the response`,
|
||||
error: err.message,
|
||||
errorData: { requestOptions, grabedHostNames },
|
||||
@@ -113,7 +113,7 @@ function queryDSQLAPI(_a) {
|
||||
httpsRequest.on("error", (err) => {
|
||||
resolve({
|
||||
success: false,
|
||||
payload: undefined,
|
||||
singleRes: undefined,
|
||||
msg: `An error occurred while making the request`,
|
||||
error: err.message,
|
||||
errorData: {
|
||||
@@ -132,7 +132,7 @@ function queryDSQLAPI(_a) {
|
||||
catch (error) {
|
||||
return {
|
||||
success: false,
|
||||
payload: undefined,
|
||||
singleRes: undefined,
|
||||
msg: `Request Failed`,
|
||||
error: error.message,
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { APIGetUserFunctionParams, GetUserFunctionReturn } from "../../../types";
|
||||
import { APIGetUserFunctionParams, APIResponseObject } from "../../../types";
|
||||
/**
|
||||
* # API Get User
|
||||
*/
|
||||
export default function apiGetUser({ fields, database, userId, dbUserId, selectAll, }: APIGetUserFunctionParams): Promise<GetUserFunctionReturn>;
|
||||
export default function apiGetUser({ fields, database, userId, dbUserId, selectAll, }: APIGetUserFunctionParams): Promise<APIResponseObject>;
|
||||
|
||||
+4
-4
@@ -55,7 +55,7 @@ function addDbEntry(_a) {
|
||||
if ((duplicateValue === null || duplicateValue === void 0 ? void 0 : duplicateValue[0]) && !update) {
|
||||
return {
|
||||
success: false,
|
||||
payload: undefined,
|
||||
postInsertReturn: undefined,
|
||||
msg: "Duplicate entry found",
|
||||
};
|
||||
}
|
||||
@@ -151,7 +151,7 @@ function addDbEntry(_a) {
|
||||
});
|
||||
return {
|
||||
success: Boolean(newInsert === null || newInsert === void 0 ? void 0 : newInsert.insertId),
|
||||
payload: newInsert,
|
||||
postInsertReturn: newInsert,
|
||||
queryObject: {
|
||||
sql: query,
|
||||
params: finalQueryValues,
|
||||
@@ -190,7 +190,7 @@ function addDbEntry(_a) {
|
||||
}
|
||||
return {
|
||||
success: Boolean(newInsert === null || newInsert === void 0 ? void 0 : newInsert.insertId),
|
||||
payload: newInsert,
|
||||
postInsertReturn: newInsert,
|
||||
queryObject: {
|
||||
sql: (0, sql_formatter_1.format)(query),
|
||||
params: finalQueryValues,
|
||||
@@ -200,7 +200,7 @@ function addDbEntry(_a) {
|
||||
else {
|
||||
return {
|
||||
success: false,
|
||||
payload: undefined,
|
||||
postInsertReturn: undefined,
|
||||
msg: "No data provided",
|
||||
};
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ function updateDbEntry(_a) {
|
||||
if (!data || !Object.keys(data).length) {
|
||||
return {
|
||||
success: false,
|
||||
payload: undefined,
|
||||
postInsertReturn: undefined,
|
||||
msg: "No data provided",
|
||||
};
|
||||
}
|
||||
|
||||
Vendored
+2
-2
@@ -101,7 +101,7 @@ export type DSQL_DATASQUIREL_USER_DATABASES = {
|
||||
active_clone_parent_db?: string;
|
||||
active_clone_parent_db_id?: number;
|
||||
active_data?: number;
|
||||
collation?: string;
|
||||
collation?: "utf8mb4_bin" | "utf8mb4_unicode_520_ci";
|
||||
last_checked_date_code?: number;
|
||||
date_created?: string;
|
||||
date_created_code?: number;
|
||||
@@ -125,7 +125,7 @@ export type DSQL_DATASQUIREL_USER_DATABASE_TABLES = {
|
||||
child_table_parent_database_schema_id?: number;
|
||||
child_table_parent_table_schema_id?: number;
|
||||
active_data?: 0 | 1;
|
||||
collation?: string;
|
||||
collation?: "utf8mb4_bin" | "utf8mb4_unicode_520_ci";
|
||||
last_checked_date_code?: number;
|
||||
date_created?: string;
|
||||
date_created_code?: number;
|
||||
|
||||
Vendored
+2
@@ -1452,6 +1452,8 @@ export type APIResponseObject<T extends {
|
||||
success: boolean;
|
||||
payload?: T[] | null;
|
||||
singleRes?: T | null;
|
||||
stringRes?: string | null;
|
||||
numberRes?: number | null;
|
||||
postInsertReturn?: PostInsertReturn | null;
|
||||
payloadBase64?: string;
|
||||
payloadThumbnailBase64?: string;
|
||||
|
||||
@@ -97,6 +97,13 @@ function default_1(_a) {
|
||||
return {
|
||||
success: isSuccess,
|
||||
payload: isSuccess ? (countOnly ? null : parsedRes) : null,
|
||||
singleRes: isSuccess
|
||||
? countOnly
|
||||
? null
|
||||
: Array.isArray(parsedRes) && parsedRes.length == 1
|
||||
? parsedRes[0]
|
||||
: null
|
||||
: null,
|
||||
batchPayload: isSuccess ? (countOnly ? null : parsedBatchRes) : null,
|
||||
error: isSuccess
|
||||
? undefined
|
||||
|
||||
+4
-1
@@ -23,6 +23,7 @@ const sql_generator_1 = __importDefault(require("../../functions/dsql/sql/sql-ge
|
||||
const deleteDbEntry_1 = __importDefault(require("../../functions/backend/db/deleteDbEntry"));
|
||||
function dsqlCrud(params) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
var _a;
|
||||
const { action, data, table, targetValue, sanitize, targetField, targetId, dbFullName, deleteData, batchData, deleteKeyValues, debug, tableSchema, deleteKeyValuesOperator, dbConfig, query, } = params;
|
||||
const finalData = (sanitize ? sanitize({ data }) : data);
|
||||
const finalBatchData = (sanitize ? sanitize({ batchData }) : batchData);
|
||||
@@ -33,7 +34,9 @@ function dsqlCrud(params) {
|
||||
dbFullName,
|
||||
})
|
||||
: undefined;
|
||||
const whereClause = queryObject === null || queryObject === void 0 ? void 0 : queryObject.string.replace(/^.*?( WHERE )/, "$1");
|
||||
const whereClause = ((_a = queryObject === null || queryObject === void 0 ? void 0 : queryObject.string) === null || _a === void 0 ? void 0 : _a.match(/ WHERE /))
|
||||
? queryObject.string.replace(/^.*?( WHERE )/, "$1")
|
||||
: undefined;
|
||||
const whereClauseObject = whereClause
|
||||
? {
|
||||
clause: whereClause,
|
||||
|
||||
Reference in New Issue
Block a user