@sdflc/backend-helpers 1.0.95 → 1.0.97
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/BaseCore.js
CHANGED
|
@@ -696,8 +696,11 @@ class BaseCore {
|
|
|
696
696
|
}
|
|
697
697
|
if (!params.orderNo) {
|
|
698
698
|
const lastRecord = await gateway.list({
|
|
699
|
-
|
|
700
|
-
|
|
699
|
+
filter,
|
|
700
|
+
params: {
|
|
701
|
+
pagination: { pageSize: 1 },
|
|
702
|
+
sortBy: [{ name: constants_1.FIELDS.ORDER_NO, order: constants_1.ORDER_BYS.DESC }],
|
|
703
|
+
},
|
|
701
704
|
});
|
|
702
705
|
if (lastRecord.length > 0) {
|
|
703
706
|
const order = new utils_1.StrOrderHelpers({
|
|
@@ -10,7 +10,7 @@ export declare const validateMultipleUuidIds: (args: any, opt: BaseCoreActionsIn
|
|
|
10
10
|
export declare const validateMultipleTextIds: (args: any, opt: BaseCoreActionsInterface) => Promise<OpResult[] | {}[]>;
|
|
11
11
|
export declare const validateList: ({ rules }: CommonValidatorArgs) => (args: any, opt: BaseCoreActionsInterface) => Promise<OpResult[] | {}[]>;
|
|
12
12
|
export declare const validateGet: (args: any, opt: BaseCoreActionsInterface) => Promise<OpResult[] | {}[]>;
|
|
13
|
-
export declare const validateRemove: (args: any, opt: BaseCoreActionsInterface) => Promise<
|
|
13
|
+
export declare const validateRemove: (args: any, opt: BaseCoreActionsInterface) => Promise<{}[] | {}[]>;
|
|
14
14
|
export declare const validateGetMany: (args: any, opt: BaseCoreActionsInterface) => Promise<OpResult[] | {}[]>;
|
|
15
15
|
export declare const validateRemoveMany: (args: any, opt: BaseCoreActionsInterface) => Promise<OpResult[] | {}[]>;
|
|
16
16
|
export declare const validateCreate: ({ rules }: CommonValidatorArgs) => (args: any, opt: BaseCoreActionsInterface) => Promise<{}[] | {}[]>;
|
|
@@ -225,7 +225,35 @@ const validateGet = async (args, opt) => {
|
|
|
225
225
|
return [true, {}];
|
|
226
226
|
};
|
|
227
227
|
exports.validateGet = validateGet;
|
|
228
|
-
|
|
228
|
+
const validateRemove = async (args, opt) => {
|
|
229
|
+
const { where } = args || {};
|
|
230
|
+
const [idCheck] = (0, exports.shouldHaveParams)(where);
|
|
231
|
+
if (idCheck !== true) {
|
|
232
|
+
return [idCheck, {}];
|
|
233
|
+
}
|
|
234
|
+
const idType = opt.core.getIdType();
|
|
235
|
+
let rules = null;
|
|
236
|
+
switch (idType) {
|
|
237
|
+
case constants_1.ID_TYPES.INT:
|
|
238
|
+
rules = rulesSingleIntId;
|
|
239
|
+
break;
|
|
240
|
+
case constants_1.ID_TYPES.UUID:
|
|
241
|
+
rules = rulesSingleUuidId;
|
|
242
|
+
break;
|
|
243
|
+
case constants_1.ID_TYPES.TEXT:
|
|
244
|
+
rules = rulesSingleTextId;
|
|
245
|
+
break;
|
|
246
|
+
}
|
|
247
|
+
if (!rules) {
|
|
248
|
+
return [true, {}];
|
|
249
|
+
}
|
|
250
|
+
const [result] = rules.validateSync(where);
|
|
251
|
+
if (result) {
|
|
252
|
+
return [(0, checkItHelpers_1.createErrorOnCheckError)(result)];
|
|
253
|
+
}
|
|
254
|
+
return [true, {}];
|
|
255
|
+
};
|
|
256
|
+
exports.validateRemove = validateRemove;
|
|
229
257
|
const validateGetMany = async (args, opt) => {
|
|
230
258
|
const idType = opt.core.getIdType();
|
|
231
259
|
let rules = null;
|
package/build/esm/BaseCore.js
CHANGED
|
@@ -690,8 +690,11 @@ class BaseCore {
|
|
|
690
690
|
}
|
|
691
691
|
if (!params.orderNo) {
|
|
692
692
|
const lastRecord = await gateway.list({
|
|
693
|
-
|
|
694
|
-
|
|
693
|
+
filter,
|
|
694
|
+
params: {
|
|
695
|
+
pagination: { pageSize: 1 },
|
|
696
|
+
sortBy: [{ name: FIELDS.ORDER_NO, order: ORDER_BYS.DESC }],
|
|
697
|
+
},
|
|
695
698
|
});
|
|
696
699
|
if (lastRecord.length > 0) {
|
|
697
700
|
const order = new StrOrderHelpers({
|
|
@@ -10,7 +10,7 @@ export declare const validateMultipleUuidIds: (args: any, opt: BaseCoreActionsIn
|
|
|
10
10
|
export declare const validateMultipleTextIds: (args: any, opt: BaseCoreActionsInterface) => Promise<OpResult[] | {}[]>;
|
|
11
11
|
export declare const validateList: ({ rules }: CommonValidatorArgs) => (args: any, opt: BaseCoreActionsInterface) => Promise<OpResult[] | {}[]>;
|
|
12
12
|
export declare const validateGet: (args: any, opt: BaseCoreActionsInterface) => Promise<OpResult[] | {}[]>;
|
|
13
|
-
export declare const validateRemove: (args: any, opt: BaseCoreActionsInterface) => Promise<
|
|
13
|
+
export declare const validateRemove: (args: any, opt: BaseCoreActionsInterface) => Promise<{}[] | {}[]>;
|
|
14
14
|
export declare const validateGetMany: (args: any, opt: BaseCoreActionsInterface) => Promise<OpResult[] | {}[]>;
|
|
15
15
|
export declare const validateRemoveMany: (args: any, opt: BaseCoreActionsInterface) => Promise<OpResult[] | {}[]>;
|
|
16
16
|
export declare const validateCreate: ({ rules }: CommonValidatorArgs) => (args: any, opt: BaseCoreActionsInterface) => Promise<{}[] | {}[]>;
|
|
@@ -209,7 +209,34 @@ export const validateGet = async (args, opt) => {
|
|
|
209
209
|
}
|
|
210
210
|
return [true, {}];
|
|
211
211
|
};
|
|
212
|
-
export const validateRemove =
|
|
212
|
+
export const validateRemove = async (args, opt) => {
|
|
213
|
+
const { where } = args || {};
|
|
214
|
+
const [idCheck] = shouldHaveParams(where);
|
|
215
|
+
if (idCheck !== true) {
|
|
216
|
+
return [idCheck, {}];
|
|
217
|
+
}
|
|
218
|
+
const idType = opt.core.getIdType();
|
|
219
|
+
let rules = null;
|
|
220
|
+
switch (idType) {
|
|
221
|
+
case ID_TYPES.INT:
|
|
222
|
+
rules = rulesSingleIntId;
|
|
223
|
+
break;
|
|
224
|
+
case ID_TYPES.UUID:
|
|
225
|
+
rules = rulesSingleUuidId;
|
|
226
|
+
break;
|
|
227
|
+
case ID_TYPES.TEXT:
|
|
228
|
+
rules = rulesSingleTextId;
|
|
229
|
+
break;
|
|
230
|
+
}
|
|
231
|
+
if (!rules) {
|
|
232
|
+
return [true, {}];
|
|
233
|
+
}
|
|
234
|
+
const [result] = rules.validateSync(where);
|
|
235
|
+
if (result) {
|
|
236
|
+
return [createErrorOnCheckError(result)];
|
|
237
|
+
}
|
|
238
|
+
return [true, {}];
|
|
239
|
+
};
|
|
213
240
|
export const validateGetMany = async (args, opt) => {
|
|
214
241
|
const idType = opt.core.getIdType();
|
|
215
242
|
let rules = null;
|