Updates
This commit is contained in:
parent
ebf3618667
commit
483ea16d4d
39
dist/package-shared/types/index.d.ts
vendored
39
dist/package-shared/types/index.d.ts
vendored
@ -1285,4 +1285,43 @@ export type ApiGetQueryObject<T extends {
|
|||||||
table: string;
|
table: string;
|
||||||
dbFullName?: string;
|
dbFullName?: string;
|
||||||
};
|
};
|
||||||
|
export declare const DataCrudRequestMethods: readonly ["GET", "POST", "PUT", "DELETE"];
|
||||||
|
export type DsqlMethodCrudParam<T extends {
|
||||||
|
[key: string]: any;
|
||||||
|
} = {
|
||||||
|
[key: string]: any;
|
||||||
|
}> = {
|
||||||
|
method: (typeof DataCrudRequestMethods)[number];
|
||||||
|
body?: T;
|
||||||
|
query?: string | T;
|
||||||
|
tableName: string;
|
||||||
|
addUser?: {
|
||||||
|
field: string;
|
||||||
|
};
|
||||||
|
user?: DATASQUIREL_LoggedInUser;
|
||||||
|
extraData?: T;
|
||||||
|
transform?: ({ data, existingData, user, }: {
|
||||||
|
user?: DATASQUIREL_LoggedInUser;
|
||||||
|
data: T;
|
||||||
|
existingData?: T;
|
||||||
|
reqMethod: (typeof DataCrudRequestMethods)[number];
|
||||||
|
}) => Promise<T>;
|
||||||
|
existingData?: T;
|
||||||
|
};
|
||||||
|
export declare const DsqlCrudActions: readonly ["insert", "update", "delete", "get"];
|
||||||
|
export type DsqlCrudQueryObject<T extends object = {
|
||||||
|
[key: string]: any;
|
||||||
|
}> = ServerQueryParam & {
|
||||||
|
query: ServerQueryQueryObject<T>;
|
||||||
|
};
|
||||||
|
export type DsqlCrudParam<T extends object = {
|
||||||
|
[key: string]: any;
|
||||||
|
}> = {
|
||||||
|
action: (typeof DsqlCrudActions)[number];
|
||||||
|
table: string;
|
||||||
|
data?: T;
|
||||||
|
targetId?: string | number;
|
||||||
|
query?: DsqlCrudQueryObject<T>;
|
||||||
|
sanitize?: (data?: T) => T;
|
||||||
|
};
|
||||||
export {};
|
export {};
|
||||||
|
4
dist/package-shared/types/index.js
vendored
4
dist/package-shared/types/index.js
vendored
@ -1,6 +1,6 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.ServerQueryEqualities = exports.ServerQueryOperators = exports.TextFieldTypesArray = void 0;
|
exports.DsqlCrudActions = exports.DataCrudRequestMethods = exports.ServerQueryEqualities = exports.ServerQueryOperators = exports.TextFieldTypesArray = void 0;
|
||||||
exports.TextFieldTypesArray = [
|
exports.TextFieldTypesArray = [
|
||||||
{ title: "Plain Text", value: "plain" },
|
{ title: "Plain Text", value: "plain" },
|
||||||
{ title: "Rich Text", value: "richText" },
|
{ title: "Rich Text", value: "richText" },
|
||||||
@ -12,3 +12,5 @@ exports.TextFieldTypesArray = [
|
|||||||
];
|
];
|
||||||
exports.ServerQueryOperators = ["AND", "OR"];
|
exports.ServerQueryOperators = ["AND", "OR"];
|
||||||
exports.ServerQueryEqualities = ["EQUAL", "LIKE", "NOT EQUAL"];
|
exports.ServerQueryEqualities = ["EQUAL", "LIKE", "NOT EQUAL"];
|
||||||
|
exports.DataCrudRequestMethods = ["GET", "POST", "PUT", "DELETE"];
|
||||||
|
exports.DsqlCrudActions = ["insert", "update", "delete", "get"];
|
||||||
|
@ -1,25 +1,9 @@
|
|||||||
import sqlGenerator from "../../functions/dsql/sql/sql-generator";
|
import sqlGenerator from "../../functions/dsql/sql/sql-generator";
|
||||||
import { PostReturn, ServerQueryParam, ServerQueryQueryObject } from "../../types";
|
import { DsqlCrudParam, PostReturn } from "../../types";
|
||||||
export declare const DsqlCrudActions: readonly ["insert", "update", "delete", "get"];
|
|
||||||
export type CrudQueryObject<T extends object = {
|
|
||||||
[key: string]: any;
|
|
||||||
}> = ServerQueryParam & {
|
|
||||||
query: ServerQueryQueryObject<T>;
|
|
||||||
};
|
|
||||||
export type CrudParam<T extends object = {
|
|
||||||
[key: string]: any;
|
|
||||||
}> = {
|
|
||||||
action: (typeof DsqlCrudActions)[number];
|
|
||||||
table: string;
|
|
||||||
data?: T;
|
|
||||||
targetId?: string | number;
|
|
||||||
query?: CrudQueryObject<T>;
|
|
||||||
sanitize?: (data?: T) => T;
|
|
||||||
};
|
|
||||||
export default function dsqlCrud<T extends {
|
export default function dsqlCrud<T extends {
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
} = {
|
} = {
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
}>({ action, data, table, targetId, query, sanitize, }: CrudParam<T>): Promise<(PostReturn & {
|
}>({ action, data, table, targetId, query, sanitize, }: DsqlCrudParam<T>): Promise<(PostReturn & {
|
||||||
queryObject?: ReturnType<Awaited<typeof sqlGenerator>>;
|
queryObject?: ReturnType<Awaited<typeof sqlGenerator>>;
|
||||||
}) | null>;
|
}) | null>;
|
||||||
|
@ -12,12 +12,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.DsqlCrudActions = void 0;
|
|
||||||
exports.default = dsqlCrud;
|
exports.default = dsqlCrud;
|
||||||
const get_1 = __importDefault(require("../../actions/get"));
|
const get_1 = __importDefault(require("../../actions/get"));
|
||||||
const post_1 = __importDefault(require("../../actions/post"));
|
const post_1 = __importDefault(require("../../actions/post"));
|
||||||
const sql_generator_1 = __importDefault(require("../../functions/dsql/sql/sql-generator"));
|
const sql_generator_1 = __importDefault(require("../../functions/dsql/sql/sql-generator"));
|
||||||
exports.DsqlCrudActions = ["insert", "update", "delete", "get"];
|
|
||||||
function dsqlCrud(_a) {
|
function dsqlCrud(_a) {
|
||||||
return __awaiter(this, arguments, void 0, function* ({ action, data, table, targetId, query, sanitize, }) {
|
return __awaiter(this, arguments, void 0, function* ({ action, data, table, targetId, query, sanitize, }) {
|
||||||
const finalData = sanitize ? sanitize(data) : data;
|
const finalData = sanitize ? sanitize(data) : data;
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { DATASQUIREL_LoggedInUser, ServerQueryParam } from "../../types";
|
import { DsqlMethodCrudParam, ServerQueryParam } from "../../types";
|
||||||
export declare const DataCrudRequestMethods: readonly ["GET", "POST", "PUT", "DELETE"];
|
|
||||||
export type APIDataCrudQuery = ServerQueryParam & {
|
export type APIDataCrudQuery = ServerQueryParam & {
|
||||||
page?: number;
|
page?: number;
|
||||||
};
|
};
|
||||||
@ -9,28 +8,6 @@ export type CRUDResponseObject<P extends any = any> = {
|
|||||||
msg?: string;
|
msg?: string;
|
||||||
error?: string;
|
error?: string;
|
||||||
};
|
};
|
||||||
export type DsqlMethodCrudParam<T extends {
|
|
||||||
[key: string]: any;
|
|
||||||
} = {
|
|
||||||
[key: string]: any;
|
|
||||||
}> = {
|
|
||||||
method: (typeof DataCrudRequestMethods)[number];
|
|
||||||
body?: T;
|
|
||||||
query?: string | T;
|
|
||||||
tableName: string;
|
|
||||||
addUser?: {
|
|
||||||
field: string;
|
|
||||||
};
|
|
||||||
user?: DATASQUIREL_LoggedInUser;
|
|
||||||
extraData?: T;
|
|
||||||
transform?: ({ data, existingData, user, }: {
|
|
||||||
user?: DATASQUIREL_LoggedInUser;
|
|
||||||
data: T;
|
|
||||||
existingData?: T;
|
|
||||||
reqMethod: (typeof DataCrudRequestMethods)[number];
|
|
||||||
}) => Promise<T>;
|
|
||||||
existingData?: T;
|
|
||||||
};
|
|
||||||
export default function dsqlMethodCrud<T extends {
|
export default function dsqlMethodCrud<T extends {
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
} = {
|
} = {
|
||||||
|
@ -12,11 +12,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.DataCrudRequestMethods = void 0;
|
|
||||||
exports.default = dsqlMethodCrud;
|
exports.default = dsqlMethodCrud;
|
||||||
const ejson_1 = __importDefault(require("../ejson"));
|
const ejson_1 = __importDefault(require("../ejson"));
|
||||||
const crud_1 = __importDefault(require("./crud"));
|
const crud_1 = __importDefault(require("./crud"));
|
||||||
exports.DataCrudRequestMethods = ["GET", "POST", "PUT", "DELETE"];
|
|
||||||
function dsqlMethodCrud(_a) {
|
function dsqlMethodCrud(_a) {
|
||||||
return __awaiter(this, arguments, void 0, function* ({ method, tableName, addUser, user, extraData, transform, existingData, body, query, }) {
|
return __awaiter(this, arguments, void 0, function* ({ method, tableName, addUser, user, extraData, transform, existingData, body, query, }) {
|
||||||
let result = {
|
let result = {
|
||||||
|
@ -1462,3 +1462,46 @@ export type ApiGetQueryObject<
|
|||||||
table: string;
|
table: string;
|
||||||
dbFullName?: string;
|
dbFullName?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const DataCrudRequestMethods = ["GET", "POST", "PUT", "DELETE"] as const;
|
||||||
|
|
||||||
|
export type DsqlMethodCrudParam<
|
||||||
|
T extends { [key: string]: any } = { [key: string]: any }
|
||||||
|
> = {
|
||||||
|
method: (typeof DataCrudRequestMethods)[number];
|
||||||
|
body?: T;
|
||||||
|
query?: string | T;
|
||||||
|
tableName: string;
|
||||||
|
addUser?: {
|
||||||
|
field: string;
|
||||||
|
};
|
||||||
|
user?: DATASQUIREL_LoggedInUser;
|
||||||
|
extraData?: T;
|
||||||
|
transform?: ({
|
||||||
|
data,
|
||||||
|
existingData,
|
||||||
|
user,
|
||||||
|
}: {
|
||||||
|
user?: DATASQUIREL_LoggedInUser;
|
||||||
|
data: T;
|
||||||
|
existingData?: T;
|
||||||
|
reqMethod: (typeof DataCrudRequestMethods)[number];
|
||||||
|
}) => Promise<T>;
|
||||||
|
existingData?: T;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const DsqlCrudActions = ["insert", "update", "delete", "get"] as const;
|
||||||
|
|
||||||
|
export type DsqlCrudQueryObject<T extends object = { [key: string]: any }> =
|
||||||
|
ServerQueryParam & {
|
||||||
|
query: ServerQueryQueryObject<T>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type DsqlCrudParam<T extends object = { [key: string]: any }> = {
|
||||||
|
action: (typeof DsqlCrudActions)[number];
|
||||||
|
table: string;
|
||||||
|
data?: T;
|
||||||
|
targetId?: string | number;
|
||||||
|
query?: DsqlCrudQueryObject<T>;
|
||||||
|
sanitize?: (data?: T) => T;
|
||||||
|
};
|
||||||
|
@ -1,28 +1,7 @@
|
|||||||
import get from "../../actions/get";
|
import get from "../../actions/get";
|
||||||
import post from "../../actions/post";
|
import post from "../../actions/post";
|
||||||
import sqlGenerator from "../../functions/dsql/sql/sql-generator";
|
import sqlGenerator from "../../functions/dsql/sql/sql-generator";
|
||||||
import {
|
import { DsqlCrudParam, PostReturn } from "../../types";
|
||||||
PostReturn,
|
|
||||||
ServerQueryParam,
|
|
||||||
ServerQueryQueryObject,
|
|
||||||
} from "../../types";
|
|
||||||
import numberfy from "../numberfy";
|
|
||||||
|
|
||||||
export const DsqlCrudActions = ["insert", "update", "delete", "get"] as const;
|
|
||||||
|
|
||||||
export type CrudQueryObject<T extends object = { [key: string]: any }> =
|
|
||||||
ServerQueryParam & {
|
|
||||||
query: ServerQueryQueryObject<T>;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type CrudParam<T extends object = { [key: string]: any }> = {
|
|
||||||
action: (typeof DsqlCrudActions)[number];
|
|
||||||
table: string;
|
|
||||||
data?: T;
|
|
||||||
targetId?: string | number;
|
|
||||||
query?: CrudQueryObject<T>;
|
|
||||||
sanitize?: (data?: T) => T;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default async function dsqlCrud<
|
export default async function dsqlCrud<
|
||||||
T extends { [key: string]: any } = { [key: string]: any }
|
T extends { [key: string]: any } = { [key: string]: any }
|
||||||
@ -33,7 +12,7 @@ export default async function dsqlCrud<
|
|||||||
targetId,
|
targetId,
|
||||||
query,
|
query,
|
||||||
sanitize,
|
sanitize,
|
||||||
}: CrudParam<T>): Promise<
|
}: DsqlCrudParam<T>): Promise<
|
||||||
| (PostReturn & {
|
| (PostReturn & {
|
||||||
queryObject?: ReturnType<Awaited<typeof sqlGenerator>>;
|
queryObject?: ReturnType<Awaited<typeof sqlGenerator>>;
|
||||||
})
|
})
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
import { DATASQUIREL_LoggedInUser, ServerQueryParam } from "../../types";
|
import { DsqlMethodCrudParam, ServerQueryParam } from "../../types";
|
||||||
import EJSON from "../ejson";
|
import EJSON from "../ejson";
|
||||||
import dsqlCrud from "./crud";
|
import dsqlCrud from "./crud";
|
||||||
|
|
||||||
export const DataCrudRequestMethods = ["GET", "POST", "PUT", "DELETE"] as const;
|
|
||||||
|
|
||||||
export type APIDataCrudQuery = ServerQueryParam & {
|
export type APIDataCrudQuery = ServerQueryParam & {
|
||||||
page?: number;
|
page?: number;
|
||||||
};
|
};
|
||||||
@ -15,31 +13,6 @@ export type CRUDResponseObject<P extends any = any> = {
|
|||||||
error?: string;
|
error?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type DsqlMethodCrudParam<
|
|
||||||
T extends { [key: string]: any } = { [key: string]: any }
|
|
||||||
> = {
|
|
||||||
method: (typeof DataCrudRequestMethods)[number];
|
|
||||||
body?: T;
|
|
||||||
query?: string | T;
|
|
||||||
tableName: string;
|
|
||||||
addUser?: {
|
|
||||||
field: string;
|
|
||||||
};
|
|
||||||
user?: DATASQUIREL_LoggedInUser;
|
|
||||||
extraData?: T;
|
|
||||||
transform?: ({
|
|
||||||
data,
|
|
||||||
existingData,
|
|
||||||
user,
|
|
||||||
}: {
|
|
||||||
user?: DATASQUIREL_LoggedInUser;
|
|
||||||
data: T;
|
|
||||||
existingData?: T;
|
|
||||||
reqMethod: (typeof DataCrudRequestMethods)[number];
|
|
||||||
}) => Promise<T>;
|
|
||||||
existingData?: T;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default async function dsqlMethodCrud<
|
export default async function dsqlMethodCrud<
|
||||||
T extends { [key: string]: any } = { [key: string]: any },
|
T extends { [key: string]: any } = { [key: string]: any },
|
||||||
P extends { [key: string]: any } = { [key: string]: any }
|
P extends { [key: string]: any } = { [key: string]: any }
|
||||||
@ -96,7 +69,7 @@ export default async function dsqlMethodCrud<
|
|||||||
data: finalData,
|
data: finalData,
|
||||||
existingData: existingData,
|
existingData: existingData,
|
||||||
user,
|
user,
|
||||||
reqMethod: method as (typeof DataCrudRequestMethods)[number],
|
reqMethod: method,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@moduletrace/datasquirel",
|
"name": "@moduletrace/datasquirel",
|
||||||
"version": "3.8.6",
|
"version": "3.8.7",
|
||||||
"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