Updates
This commit is contained in:
parent
cda056311b
commit
7169e467cc
10
dist/package-shared/api-paths/index.js
vendored
10
dist/package-shared/api-paths/index.js
vendored
@ -89,7 +89,15 @@ function apiCrudHandler(params) {
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
yield ((_c = params.postResultsFn) === null || _c === void 0 ? void 0 : _c.call(params, Object.assign(Object.assign({}, crudParams), { res: result })));
|
yield ((_c = params.postResultsFn) === null || _c === void 0 ? void 0 : _c.call(params, Object.assign(Object.assign(Object.assign({}, lodash_1.default.omit(crudParams, [
|
||||||
|
"postResultsFnExtraParameters",
|
||||||
|
"postResultsFn",
|
||||||
|
"deleteMiddleware",
|
||||||
|
"putMiddleware",
|
||||||
|
"postMiddleware",
|
||||||
|
"getMiddleware",
|
||||||
|
"auth",
|
||||||
|
])), { res: result }), (params.postResultsFnExtraParameters || {}))));
|
||||||
if (result) {
|
if (result) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
22
dist/package-shared/types/index.d.ts
vendored
22
dist/package-shared/types/index.d.ts
vendored
@ -2259,6 +2259,9 @@ export type APIPathsParams<T extends {
|
|||||||
putMiddleware?: APIPathsParamsCrudMiddleware<T>;
|
putMiddleware?: APIPathsParamsCrudMiddleware<T>;
|
||||||
deleteMiddleware?: APIPathsParamsCrudMiddleware<T>;
|
deleteMiddleware?: APIPathsParamsCrudMiddleware<T>;
|
||||||
postResultsFn?: APIPathsPostResulstsFn<T>;
|
postResultsFn?: APIPathsPostResulstsFn<T>;
|
||||||
|
postResultsFnExtraParameters?: {
|
||||||
|
[k: string]: any;
|
||||||
|
};
|
||||||
/** Runs For `POST`, `PUT`, and `DELETE` */
|
/** Runs For `POST`, `PUT`, and `DELETE` */
|
||||||
crudMiddleware?: APIPathsParamsCrudMiddleware<T>;
|
crudMiddleware?: APIPathsParamsCrudMiddleware<T>;
|
||||||
method: "GET" | "POST" | "PUT" | "DELETE";
|
method: "GET" | "POST" | "PUT" | "DELETE";
|
||||||
@ -2311,9 +2314,22 @@ export type APIPathsPostResulstsFn<T extends {
|
|||||||
[k: string]: any;
|
[k: string]: any;
|
||||||
} = {
|
} = {
|
||||||
[k: string]: any;
|
[k: string]: any;
|
||||||
}> = (params: APIPathsCrudParams<T> & {
|
}, P extends {
|
||||||
res?: APIResponseObject;
|
[k: string]: any;
|
||||||
}) => Promise<void>;
|
} = {
|
||||||
|
[k: string]: any;
|
||||||
|
}> = (params: APIPathsPostResulstsFnParams<T, P>) => Promise<void>;
|
||||||
|
export type APIPathsPostResulstsFnParams<T extends {
|
||||||
|
[k: string]: any;
|
||||||
|
} = {
|
||||||
|
[k: string]: any;
|
||||||
|
}, P extends {
|
||||||
|
[k: string]: any;
|
||||||
|
} = {
|
||||||
|
[k: string]: any;
|
||||||
|
}> = Omit<APIPathsCrudParams<T>, "postResultsFnExtraParameters" | "postResultsFn" | "deleteMiddleware" | "putMiddleware" | "postMiddleware" | "getMiddleware" | "auth"> & {
|
||||||
|
res?: APIResponseObject<T>;
|
||||||
|
} & P;
|
||||||
export type APIPathsParamsAllowedTable = {
|
export type APIPathsParamsAllowedTable = {
|
||||||
table: string;
|
table: string;
|
||||||
allowedFields?: (string | RegExp)[];
|
allowedFields?: (string | RegExp)[];
|
||||||
|
|||||||
@ -14,7 +14,7 @@ import putResult from "./functions/put-result";
|
|||||||
import deleteResult from "./functions/delete-result";
|
import deleteResult from "./functions/delete-result";
|
||||||
|
|
||||||
export default async function apiCrudHandler<
|
export default async function apiCrudHandler<
|
||||||
T extends { [k: string]: any } = { [k: string]: any }
|
T extends { [k: string]: any } = { [k: string]: any },
|
||||||
>(params: APIPathsParams<T>): Promise<APIResponseObject> {
|
>(params: APIPathsParams<T>): Promise<APIResponseObject> {
|
||||||
try {
|
try {
|
||||||
const { auth, method } = params;
|
const { auth, method } = params;
|
||||||
@ -42,7 +42,7 @@ export default async function apiCrudHandler<
|
|||||||
|
|
||||||
const finalSearchQuery = _.merge(
|
const finalSearchQuery = _.merge(
|
||||||
crudParams.query?.searchQuery,
|
crudParams.query?.searchQuery,
|
||||||
crudParams.body?.searchQuery
|
crudParams.body?.searchQuery,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (finalSearchQuery) {
|
if (finalSearchQuery) {
|
||||||
@ -87,7 +87,7 @@ export default async function apiCrudHandler<
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let result: APIResponseObject | undefined;
|
let result: APIResponseObject<any> | undefined;
|
||||||
|
|
||||||
switch (method) {
|
switch (method) {
|
||||||
case "GET":
|
case "GET":
|
||||||
@ -107,7 +107,19 @@ export default async function apiCrudHandler<
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
await params.postResultsFn?.({ ...crudParams, res: result });
|
await params.postResultsFn?.({
|
||||||
|
..._.omit(crudParams, [
|
||||||
|
"postResultsFnExtraParameters",
|
||||||
|
"postResultsFn",
|
||||||
|
"deleteMiddleware",
|
||||||
|
"putMiddleware",
|
||||||
|
"postMiddleware",
|
||||||
|
"getMiddleware",
|
||||||
|
"auth",
|
||||||
|
]),
|
||||||
|
res: result,
|
||||||
|
...(params.postResultsFnExtraParameters || {}),
|
||||||
|
});
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@ -2933,6 +2933,7 @@ export type APIPathsParams<
|
|||||||
putMiddleware?: APIPathsParamsCrudMiddleware<T>;
|
putMiddleware?: APIPathsParamsCrudMiddleware<T>;
|
||||||
deleteMiddleware?: APIPathsParamsCrudMiddleware<T>;
|
deleteMiddleware?: APIPathsParamsCrudMiddleware<T>;
|
||||||
postResultsFn?: APIPathsPostResulstsFn<T>;
|
postResultsFn?: APIPathsPostResulstsFn<T>;
|
||||||
|
postResultsFnExtraParameters?: { [k: string]: any };
|
||||||
/** Runs For `POST`, `PUT`, and `DELETE` */
|
/** Runs For `POST`, `PUT`, and `DELETE` */
|
||||||
crudMiddleware?: APIPathsParamsCrudMiddleware<T>;
|
crudMiddleware?: APIPathsParamsCrudMiddleware<T>;
|
||||||
method: "GET" | "POST" | "PUT" | "DELETE";
|
method: "GET" | "POST" | "PUT" | "DELETE";
|
||||||
@ -2991,11 +2992,24 @@ export type APIPathsParamsCrudMiddleware<
|
|||||||
|
|
||||||
export type APIPathsPostResulstsFn<
|
export type APIPathsPostResulstsFn<
|
||||||
T extends { [k: string]: any } = { [k: string]: any },
|
T extends { [k: string]: any } = { [k: string]: any },
|
||||||
> = (
|
P extends { [k: string]: any } = { [k: string]: any },
|
||||||
params: APIPathsCrudParams<T> & {
|
> = (params: APIPathsPostResulstsFnParams<T, P>) => Promise<void>;
|
||||||
res?: APIResponseObject;
|
|
||||||
},
|
export type APIPathsPostResulstsFnParams<
|
||||||
) => Promise<void>;
|
T extends { [k: string]: any } = { [k: string]: any },
|
||||||
|
P extends { [k: string]: any } = { [k: string]: any },
|
||||||
|
> = Omit<
|
||||||
|
APIPathsCrudParams<T>,
|
||||||
|
| "postResultsFnExtraParameters"
|
||||||
|
| "postResultsFn"
|
||||||
|
| "deleteMiddleware"
|
||||||
|
| "putMiddleware"
|
||||||
|
| "postMiddleware"
|
||||||
|
| "getMiddleware"
|
||||||
|
| "auth"
|
||||||
|
> & {
|
||||||
|
res?: APIResponseObject<T>;
|
||||||
|
} & P;
|
||||||
|
|
||||||
export type APIPathsParamsAllowedTable = {
|
export type APIPathsParamsAllowedTable = {
|
||||||
table: string;
|
table: string;
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@moduletrace/datasquirel",
|
"name": "@moduletrace/datasquirel",
|
||||||
"version": "5.7.31",
|
"version": "5.7.32",
|
||||||
"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