Updates
This commit is contained in:
parent
b02399c64d
commit
d7cef41552
2
dist/engine/schema-to-typedef.js
vendored
2
dist/engine/schema-to-typedef.js
vendored
@ -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,
|
||||
|
||||
2
dist/index.d.ts
vendored
2
dist/index.d.ts
vendored
@ -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>;
|
||||
|
||||
@ -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>;
|
||||
|
||||
@ -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>;
|
||||
|
||||
2
dist/package-shared/api/user/local-user.d.ts
vendored
2
dist/package-shared/api/user/local-user.d.ts
vendored
@ -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>;
|
||||
|
||||
@ -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>;
|
||||
|
||||
@ -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",
|
||||
};
|
||||
}
|
||||
|
||||
4
dist/package-shared/types/dsql.d.ts
vendored
4
dist/package-shared/types/dsql.d.ts
vendored
@ -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;
|
||||
|
||||
2
dist/package-shared/types/index.d.ts
vendored
2
dist/package-shared/types/index.d.ts
vendored
@ -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
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -6,7 +6,10 @@ import dbSchemaToType from "../package-shared/functions/dsql/db-schema-to-type";
|
||||
import path from "path";
|
||||
import debugLog from "../package-shared/utils/logging/debug-log";
|
||||
import { AppNames } from "../package-shared/dict/app-names";
|
||||
import { APIConnectionOptions } from "../package-shared/types";
|
||||
import {
|
||||
APIConnectionOptions,
|
||||
DSQL_DatabaseSchemaType,
|
||||
} from "../package-shared/types";
|
||||
|
||||
type Config = {
|
||||
database?: string;
|
||||
@ -83,7 +86,9 @@ if (!config.apiConnectionConfig.apiKey) {
|
||||
apiConnectionConfig: config.apiConnectionConfig,
|
||||
});
|
||||
|
||||
const dbSchema = schemaRes.payload;
|
||||
const dbSchema = schemaRes.singleRes as
|
||||
| DSQL_DatabaseSchemaType
|
||||
| undefined;
|
||||
|
||||
if (config.debug) {
|
||||
debugLog({
|
||||
|
||||
@ -1,10 +1,8 @@
|
||||
import path from "path";
|
||||
import fs from "fs";
|
||||
import grabHostNames from "../../utils/grab-host-names";
|
||||
import apiGetUser from "../../functions/api/users/api-get-user";
|
||||
import {
|
||||
APIGetUserFunctionParams,
|
||||
GetUserFunctionReturn,
|
||||
APIResponseObject,
|
||||
GetUserParams,
|
||||
} from "../../types";
|
||||
import grabUserDSQLAPIPath from "../../utils/backend/users/grab-api-path";
|
||||
@ -21,7 +19,7 @@ export default async function getUser({
|
||||
apiVersion = "v1",
|
||||
dbUserId,
|
||||
selectAll,
|
||||
}: GetUserParams): Promise<GetUserFunctionReturn> {
|
||||
}: GetUserParams): Promise<APIResponseObject> {
|
||||
/**
|
||||
* Initialize
|
||||
*/
|
||||
@ -119,5 +117,5 @@ export default async function getUser({
|
||||
httpsRequest.end();
|
||||
});
|
||||
|
||||
return httpResponse as GetUserFunctionReturn;
|
||||
return httpResponse as APIResponseObject;
|
||||
}
|
||||
|
||||
@ -1,11 +1,7 @@
|
||||
import encrypt from "../../functions/dsql/encrypt";
|
||||
import apiLoginUser from "../../functions/api/users/api-login";
|
||||
import getAuthCookieNames from "../../functions/backend/cookies/get-auth-cookie-names";
|
||||
import { writeAuthFile } from "../../functions/backend/auth/write-auth-files";
|
||||
import {
|
||||
APILoginFunctionParams,
|
||||
APIResponseObject,
|
||||
DATASQUIREL_LoggedInUser,
|
||||
LoginUserParam,
|
||||
} from "../../types";
|
||||
import debugLog from "../../utils/logging/debug-log";
|
||||
@ -21,9 +17,7 @@ function debugFn(log: any, label?: string) {
|
||||
/**
|
||||
* # Login A user
|
||||
*/
|
||||
export default async function loginUser<
|
||||
T extends DATASQUIREL_LoggedInUser = DATASQUIREL_LoggedInUser
|
||||
>({
|
||||
export default async function loginUser({
|
||||
apiKey,
|
||||
payload,
|
||||
database,
|
||||
|
||||
@ -137,7 +137,7 @@ export default async function queryDSQLAPI<T = { [k: string]: any }>({
|
||||
response.on("error", (err) => {
|
||||
resolve({
|
||||
success: false,
|
||||
payload: undefined,
|
||||
singleRes: undefined,
|
||||
msg: `An error occurred on the response`,
|
||||
error: err.message,
|
||||
errorData: { requestOptions, grabedHostNames },
|
||||
@ -149,7 +149,7 @@ export default async function queryDSQLAPI<T = { [k: string]: any }>({
|
||||
httpsRequest.on("error", (err) => {
|
||||
resolve({
|
||||
success: false,
|
||||
payload: undefined,
|
||||
singleRes: undefined,
|
||||
msg: `An error occurred while making the request`,
|
||||
error: err.message,
|
||||
errorData: {
|
||||
@ -169,7 +169,7 @@ export default async function queryDSQLAPI<T = { [k: string]: any }>({
|
||||
} catch (error: any) {
|
||||
return {
|
||||
success: false,
|
||||
payload: undefined,
|
||||
singleRes: undefined,
|
||||
msg: `Request Failed`,
|
||||
error: error.message,
|
||||
};
|
||||
|
||||
@ -1,7 +1,4 @@
|
||||
import {
|
||||
APIGetUserFunctionParams,
|
||||
GetUserFunctionReturn,
|
||||
} from "../../../types";
|
||||
import { APIGetUserFunctionParams, APIResponseObject } from "../../../types";
|
||||
import grabDbFullName from "../../../utils/grab-db-full-name";
|
||||
import dbHandler from "../../backend/dbHandler";
|
||||
|
||||
@ -14,7 +11,7 @@ export default async function apiGetUser({
|
||||
userId,
|
||||
dbUserId,
|
||||
selectAll,
|
||||
}: APIGetUserFunctionParams): Promise<GetUserFunctionReturn> {
|
||||
}: APIGetUserFunctionParams): Promise<APIResponseObject> {
|
||||
const finalDbName = grabDbFullName({ dbName: database, userId: dbUserId });
|
||||
|
||||
const selectFields = selectAll ? "*" : fields?.[0] ? fields.join(",") : "*";
|
||||
|
||||
@ -101,7 +101,7 @@ export default async function addDbEntry<
|
||||
if (duplicateValue?.[0] && !update) {
|
||||
return {
|
||||
success: false,
|
||||
payload: undefined,
|
||||
postInsertReturn: undefined,
|
||||
msg: "Duplicate entry found",
|
||||
};
|
||||
} else if (duplicateValue?.[0] && update) {
|
||||
@ -222,7 +222,7 @@ export default async function addDbEntry<
|
||||
|
||||
return {
|
||||
success: Boolean(newInsert?.insertId),
|
||||
payload: newInsert,
|
||||
postInsertReturn: newInsert,
|
||||
queryObject: {
|
||||
sql: query,
|
||||
params: finalQueryValues,
|
||||
@ -275,7 +275,7 @@ export default async function addDbEntry<
|
||||
|
||||
return {
|
||||
success: Boolean(newInsert?.insertId),
|
||||
payload: newInsert,
|
||||
postInsertReturn: newInsert,
|
||||
queryObject: {
|
||||
sql: format(query),
|
||||
params: finalQueryValues,
|
||||
@ -284,7 +284,7 @@ export default async function addDbEntry<
|
||||
} else {
|
||||
return {
|
||||
success: false,
|
||||
payload: undefined,
|
||||
postInsertReturn: undefined,
|
||||
msg: "No data provided",
|
||||
};
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ export default async function updateDbEntry<
|
||||
if (!data || !Object.keys(data).length) {
|
||||
return {
|
||||
success: false,
|
||||
payload: undefined,
|
||||
postInsertReturn: undefined,
|
||||
msg: "No data provided",
|
||||
};
|
||||
}
|
||||
|
||||
@ -128,7 +128,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;
|
||||
@ -153,7 +153,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;
|
||||
|
||||
@ -1687,6 +1687,8 @@ export type APIResponseObject<
|
||||
success: boolean;
|
||||
payload?: T[] | null;
|
||||
singleRes?: T | null;
|
||||
stringRes?: string | null;
|
||||
numberRes?: number | null;
|
||||
postInsertReturn?: PostInsertReturn | null;
|
||||
payloadBase64?: string;
|
||||
payloadThumbnailBase64?: string;
|
||||
|
||||
@ -125,6 +125,13 @@ export default async function <
|
||||
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
|
||||
|
||||
@ -48,7 +48,9 @@ export default async function dsqlCrud<
|
||||
})
|
||||
: undefined;
|
||||
|
||||
const whereClause = queryObject?.string.replace(/^.*?( WHERE )/, "$1");
|
||||
const whereClause = queryObject?.string?.match(/ WHERE /)
|
||||
? queryObject.string.replace(/^.*?( WHERE )/, "$1")
|
||||
: undefined;
|
||||
|
||||
const whereClauseObject = whereClause
|
||||
? {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@moduletrace/datasquirel",
|
||||
"version": "5.5.8",
|
||||
"version": "5.5.9",
|
||||
"description": "Cloud-based SQL data management tool",
|
||||
"main": "dist/index.js",
|
||||
"bin": {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user