@sdflc/backend-helpers 1.0.112 → 1.0.113
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/README.md +1422 -146
- package/build/BaseController.d.ts +20 -0
- package/build/BaseController.js +64 -0
- package/build/BaseCore.d.ts +470 -33
- package/build/BaseCore.js +608 -127
- package/build/BaseExternalApiGateway.d.ts +16 -0
- package/build/BaseExternalApiGateway.js +54 -0
- package/build/BaseGateway.d.ts +455 -17
- package/build/BaseGateway.js +502 -56
- package/build/BaseRestApiCrudController.d.ts +37 -0
- package/build/BaseRestApiCrudController.js +134 -0
- package/build/DataCache.d.ts +116 -5
- package/build/DataCache.js +144 -22
- package/build/Database.d.ts +165 -4
- package/build/Database.js +224 -51
- package/build/DbMigratorAndSeeder.d.ts +127 -26
- package/build/DbMigratorAndSeeder.js +180 -69
- package/build/RedisDataLoader.d.ts +144 -21
- package/build/RedisDataLoader.js +178 -49
- package/build/apiContext.d.ts +0 -8
- package/build/apiContext.js +12 -27
- package/build/checkItHelpers.d.ts +32 -0
- package/build/checkItHelpers.js +73 -7
- package/build/commonValidators.d.ts +107 -16
- package/build/commonValidators.js +211 -106
- package/build/configBuilder.d.ts +23 -0
- package/build/configBuilder.js +73 -0
- package/build/constants.d.ts +134 -17
- package/build/constants.js +95 -15
- package/build/dbHelpers.d.ts +89 -29
- package/build/dbHelpers.js +175 -86
- package/build/dbSeeder.d.ts +10 -1
- package/build/dbSeeder.js +80 -15
- package/build/dbTableHelpers.d.ts +122 -5
- package/build/dbTableHelpers.js +151 -13
- package/build/downloadHelpers.d.ts +24 -1
- package/build/downloadHelpers.js +51 -21
- package/build/esm/BaseController.d.ts +20 -0
- package/build/esm/BaseController.js +58 -0
- package/build/esm/BaseCore.d.ts +470 -33
- package/build/esm/BaseCore.js +599 -118
- package/build/esm/BaseExternalApiGateway.d.ts +16 -0
- package/build/esm/BaseExternalApiGateway.js +48 -0
- package/build/esm/BaseGateway.d.ts +455 -17
- package/build/esm/BaseGateway.js +503 -57
- package/build/esm/BaseRestApiCrudController.d.ts +37 -0
- package/build/esm/BaseRestApiCrudController.js +131 -0
- package/build/esm/DataCache.d.ts +116 -5
- package/build/esm/DataCache.js +142 -20
- package/build/esm/Database.d.ts +165 -4
- package/build/esm/Database.js +224 -51
- package/build/esm/DbMigratorAndSeeder.d.ts +127 -26
- package/build/esm/DbMigratorAndSeeder.js +184 -71
- package/build/esm/RedisDataLoader.d.ts +144 -21
- package/build/esm/RedisDataLoader.js +179 -50
- package/build/esm/apiContext.d.ts +0 -8
- package/build/esm/apiContext.js +12 -27
- package/build/esm/checkItHelpers.d.ts +32 -0
- package/build/esm/checkItHelpers.js +73 -7
- package/build/esm/commonValidators.d.ts +107 -16
- package/build/esm/commonValidators.js +209 -105
- package/build/esm/configBuilder.d.ts +23 -0
- package/build/esm/configBuilder.js +69 -0
- package/build/esm/constants.d.ts +134 -17
- package/build/esm/constants.js +94 -14
- package/build/esm/dbHelpers.d.ts +89 -29
- package/build/esm/dbHelpers.js +171 -81
- package/build/esm/dbSeeder.d.ts +10 -1
- package/build/esm/dbSeeder.js +81 -16
- package/build/esm/dbTableHelpers.d.ts +122 -5
- package/build/esm/dbTableHelpers.js +152 -14
- package/build/esm/downloadHelpers.d.ts +24 -1
- package/build/esm/downloadHelpers.js +51 -21
- package/build/esm/index.d.ts +5 -2
- package/build/esm/index.js +5 -2
- package/build/esm/interfaces/ApiContext.d.ts +7 -3
- package/build/esm/interfaces/ApiContextInterface.d.ts +1 -1
- package/build/esm/interfaces/BaseControllerPropsInterface.d.ts +5 -0
- package/build/esm/interfaces/BaseControllerPropsInterface.js +1 -0
- package/build/esm/interfaces/BaseCoreDoAuthOnActionInterface.d.ts +1 -0
- package/build/esm/interfaces/BaseCoreDoingWhatInterface.d.ts +11 -11
- package/build/esm/interfaces/BaseCorePropsInterface.d.ts +87 -9
- package/build/esm/interfaces/BaseCorePropsInterface.js +1 -0
- package/build/esm/interfaces/BaseExternalApiGatewayPropsInterface.d.ts +19 -0
- package/build/esm/interfaces/BaseExternalApiGatewayPropsInterface.js +2 -0
- package/build/esm/interfaces/BaseGatewayPropsInterface.d.ts +78 -3
- package/build/esm/interfaces/BaseGatewayPropsInterface.js +1 -0
- package/build/esm/interfaces/BaseRestApiCrudControllerPropsInterface.d.ts +28 -0
- package/build/esm/interfaces/BaseRestApiCrudControllerPropsInterface.js +2 -0
- package/build/esm/interfaces/BuildConfigOptions.d.ts +18 -0
- package/build/esm/interfaces/BuildConfigOptions.js +1 -0
- package/build/esm/interfaces/BuildListQueryArgsInterface.d.ts +22 -4
- package/build/esm/interfaces/BuildListQueryArgsInterface.js +1 -0
- package/build/esm/interfaces/CacheInterface.d.ts +18 -1
- package/build/esm/interfaces/CacheInterface.js +1 -0
- package/build/esm/interfaces/CoreActionInterface.d.ts +20 -0
- package/build/esm/interfaces/CreateUserTokenArgs.d.ts +38 -4
- package/build/esm/interfaces/CreateUserTokenArgs.js +1 -0
- package/build/esm/interfaces/DataCachePropsInterface.d.ts +21 -0
- package/build/esm/interfaces/DataCachePropsInterface.js +2 -0
- package/build/esm/interfaces/DatabaseOptions.d.ts +24 -10
- package/build/esm/interfaces/DatabaseOptions.js +1 -0
- package/build/esm/interfaces/DatabaseReadInterface.d.ts +58 -3
- package/build/esm/interfaces/DatabaseReadInterface.js +1 -0
- package/build/esm/interfaces/DbFieldAddDefaultInterface.d.ts +35 -4
- package/build/esm/interfaces/DbFieldAddDefaultInterface.js +1 -0
- package/build/esm/interfaces/DownloadFileArgs.d.ts +21 -2
- package/build/esm/interfaces/ExtractCredentialsArgs.d.ts +15 -4
- package/build/esm/interfaces/ExtractCredentialsArgs.js +1 -0
- package/build/esm/interfaces/ListArgsInterface.d.ts +18 -0
- package/build/esm/interfaces/ListArgsInterface.js +1 -0
- package/build/esm/interfaces/LoaderInterface.d.ts +36 -1
- package/build/esm/interfaces/LoaderInterface.js +1 -0
- package/build/esm/interfaces/UserTokenParams.d.ts +23 -5
- package/build/esm/interfaces/UserTokenParams.js +1 -0
- package/build/esm/interfaces/VerifyUserTokenArgs.d.ts +42 -2
- package/build/esm/interfaces/VerifyUserTokenArgs.js +1 -0
- package/build/esm/interfaces/index.d.ts +4 -0
- package/build/esm/interfaces/index.js +4 -0
- package/build/esm/knexConfigBuilder.d.ts +25 -0
- package/build/esm/knexConfigBuilder.js +100 -36
- package/build/esm/parseIds.d.ts +6 -0
- package/build/esm/parseIds.js +13 -0
- package/build/esm/passwordHelpers.d.ts +22 -0
- package/build/esm/passwordHelpers.js +40 -8
- package/build/esm/redisClient.d.ts +57 -4
- package/build/esm/redisClient.js +40 -54
- package/build/esm/resolveClientIp.d.ts +15 -0
- package/build/esm/resolveClientIp.js +34 -0
- package/build/esm/resolversHelpers.d.ts +21 -1
- package/build/esm/resolversHelpers.js +48 -26
- package/build/esm/userToken.d.ts +50 -1
- package/build/esm/userToken.js +85 -20
- package/build/esm/utils.d.ts +20 -2
- package/build/esm/utils.js +23 -13
- package/build/index.d.ts +5 -2
- package/build/index.js +5 -2
- package/build/interfaces/ApiContext.d.ts +7 -3
- package/build/interfaces/ApiContextInterface.d.ts +1 -1
- package/build/interfaces/BaseControllerPropsInterface.d.ts +5 -0
- package/build/interfaces/BaseControllerPropsInterface.js +2 -0
- package/build/interfaces/BaseCoreDoAuthOnActionInterface.d.ts +1 -0
- package/build/interfaces/BaseCoreDoingWhatInterface.d.ts +11 -11
- package/build/interfaces/BaseCorePropsInterface.d.ts +87 -9
- package/build/interfaces/BaseCorePropsInterface.js +1 -0
- package/build/interfaces/BaseExternalApiGatewayPropsInterface.d.ts +19 -0
- package/build/interfaces/BaseExternalApiGatewayPropsInterface.js +3 -0
- package/build/interfaces/BaseGatewayPropsInterface.d.ts +78 -3
- package/build/interfaces/BaseGatewayPropsInterface.js +1 -0
- package/build/interfaces/BaseRestApiCrudControllerPropsInterface.d.ts +28 -0
- package/build/interfaces/BaseRestApiCrudControllerPropsInterface.js +3 -0
- package/build/interfaces/BuildConfigOptions.d.ts +18 -0
- package/build/interfaces/BuildConfigOptions.js +1 -0
- package/build/interfaces/BuildListQueryArgsInterface.d.ts +22 -4
- package/build/interfaces/BuildListQueryArgsInterface.js +1 -0
- package/build/interfaces/CacheInterface.d.ts +18 -1
- package/build/interfaces/CacheInterface.js +1 -0
- package/build/interfaces/CoreActionInterface.d.ts +20 -0
- package/build/interfaces/CreateUserTokenArgs.d.ts +38 -4
- package/build/interfaces/CreateUserTokenArgs.js +1 -0
- package/build/interfaces/DataCachePropsInterface.d.ts +21 -0
- package/build/interfaces/DataCachePropsInterface.js +3 -0
- package/build/interfaces/DatabaseOptions.d.ts +24 -10
- package/build/interfaces/DatabaseOptions.js +1 -0
- package/build/interfaces/DatabaseReadInterface.d.ts +58 -3
- package/build/interfaces/DatabaseReadInterface.js +1 -0
- package/build/interfaces/DbFieldAddDefaultInterface.d.ts +35 -4
- package/build/interfaces/DbFieldAddDefaultInterface.js +1 -0
- package/build/interfaces/DownloadFileArgs.d.ts +21 -2
- package/build/interfaces/ExtractCredentialsArgs.d.ts +15 -4
- package/build/interfaces/ExtractCredentialsArgs.js +1 -0
- package/build/interfaces/ListArgsInterface.d.ts +18 -0
- package/build/interfaces/ListArgsInterface.js +1 -0
- package/build/interfaces/LoaderInterface.d.ts +36 -1
- package/build/interfaces/LoaderInterface.js +1 -0
- package/build/interfaces/UserTokenParams.d.ts +23 -5
- package/build/interfaces/UserTokenParams.js +1 -0
- package/build/interfaces/VerifyUserTokenArgs.d.ts +42 -2
- package/build/interfaces/VerifyUserTokenArgs.js +1 -0
- package/build/interfaces/index.d.ts +4 -0
- package/build/interfaces/index.js +4 -0
- package/build/knexConfigBuilder.d.ts +25 -0
- package/build/knexConfigBuilder.js +99 -35
- package/build/parseIds.d.ts +6 -0
- package/build/parseIds.js +17 -0
- package/build/passwordHelpers.d.ts +22 -0
- package/build/passwordHelpers.js +40 -8
- package/build/redisClient.d.ts +57 -4
- package/build/redisClient.js +40 -54
- package/build/resolveClientIp.d.ts +15 -0
- package/build/resolveClientIp.js +38 -0
- package/build/resolversHelpers.d.ts +21 -1
- package/build/resolversHelpers.js +48 -26
- package/build/userToken.d.ts +50 -1
- package/build/userToken.js +85 -20
- package/build/utils.d.ts +20 -2
- package/build/utils.js +24 -16
- package/package.json +19 -18
- package/build/baseController.d.ts +0 -17
- package/build/baseController.js +0 -64
- package/build/configBulder.d.ts +0 -2
- package/build/configBulder.js +0 -36
- package/build/esm/baseController.d.ts +0 -17
- package/build/esm/baseController.js +0 -58
- package/build/esm/configBulder.d.ts +0 -2
- package/build/esm/configBulder.js +0 -32
|
@@ -1,3 +1,35 @@
|
|
|
1
1
|
import { OpResult } from '@sdflc/api-helpers';
|
|
2
|
+
/**
|
|
3
|
+
* Validates each item in an array using a checkit-style validator and
|
|
4
|
+
* accumulates all field errors into a single OpResult.
|
|
5
|
+
*
|
|
6
|
+
* Returns the OpResult immediately with a top-level error if `arr` is not
|
|
7
|
+
* an array. Otherwise runs `validator.validateSync(item)` on each element
|
|
8
|
+
* and collects any field-level errors, prefixed with the item's index.
|
|
9
|
+
*
|
|
10
|
+
* Error key format: `[prefix][idx].fieldName`
|
|
11
|
+
* e.g. for prefix "items" and index 2: "items[2].email"
|
|
12
|
+
*
|
|
13
|
+
* Supports both single-message errors (`{ message }`) and multi-rule
|
|
14
|
+
* failures (`{ errors: [{ message }, ...] }`) from the checkit library,
|
|
15
|
+
* consistent with the handling in BaseCore.validationFailure().
|
|
16
|
+
*
|
|
17
|
+
* @param arr The array to validate
|
|
18
|
+
* @param validator A checkit-style validator with a `validateSync` method
|
|
19
|
+
* @param prefix Optional key prefix for error paths (e.g. "items", "params")
|
|
20
|
+
*/
|
|
2
21
|
export declare const checkArray: (arr: any, validator: any, prefix?: string) => OpResult;
|
|
22
|
+
/**
|
|
23
|
+
* Converts a checkit validation error object into a VALIDATION_FAILED OpResult.
|
|
24
|
+
*
|
|
25
|
+
* Iterates `checkItResult.errors` and adds each field's error message(s)
|
|
26
|
+
* to the result. Supports both single-message errors (`{ message }`) and
|
|
27
|
+
* multi-rule failures (`{ errors: [{ message }, ...] }`) from the checkit
|
|
28
|
+
* library, consistent with BaseCore.validationFailure().
|
|
29
|
+
*
|
|
30
|
+
* Returns an empty VALIDATION_FAILED result if `checkItResult` is null,
|
|
31
|
+
* undefined, or has no errors, rather than throwing.
|
|
32
|
+
*
|
|
33
|
+
* @param checkItResult A checkit validation error object
|
|
34
|
+
*/
|
|
3
35
|
export declare const createErrorOnCheckError: (checkItResult: any) => OpResult;
|
package/build/checkItHelpers.js
CHANGED
|
@@ -1,27 +1,93 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// ./src/checkItHelpers.ts
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
4
|
exports.createErrorOnCheckError = exports.checkArray = void 0;
|
|
4
5
|
const api_helpers_1 = require("@sdflc/api-helpers");
|
|
6
|
+
/**
|
|
7
|
+
* Validates each item in an array using a checkit-style validator and
|
|
8
|
+
* accumulates all field errors into a single OpResult.
|
|
9
|
+
*
|
|
10
|
+
* Returns the OpResult immediately with a top-level error if `arr` is not
|
|
11
|
+
* an array. Otherwise runs `validator.validateSync(item)` on each element
|
|
12
|
+
* and collects any field-level errors, prefixed with the item's index.
|
|
13
|
+
*
|
|
14
|
+
* Error key format: `[prefix][idx].fieldName`
|
|
15
|
+
* e.g. for prefix "items" and index 2: "items[2].email"
|
|
16
|
+
*
|
|
17
|
+
* Supports both single-message errors (`{ message }`) and multi-rule
|
|
18
|
+
* failures (`{ errors: [{ message }, ...] }`) from the checkit library,
|
|
19
|
+
* consistent with the handling in BaseCore.validationFailure().
|
|
20
|
+
*
|
|
21
|
+
* @param arr The array to validate
|
|
22
|
+
* @param validator A checkit-style validator with a `validateSync` method
|
|
23
|
+
* @param prefix Optional key prefix for error paths (e.g. "items", "params")
|
|
24
|
+
*/
|
|
5
25
|
const checkArray = (arr, validator, prefix) => {
|
|
6
26
|
const result = new api_helpers_1.OpResult();
|
|
7
27
|
if (!Array.isArray(arr)) {
|
|
8
|
-
|
|
28
|
+
result.addError(prefix || '', 'The value should be an array');
|
|
29
|
+
return result;
|
|
9
30
|
}
|
|
10
31
|
arr.forEach((item, idx) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
32
|
+
try {
|
|
33
|
+
const [itemResult] = validator.validateSync(item);
|
|
34
|
+
if (itemResult?.errors) {
|
|
35
|
+
Object.keys(itemResult.errors).forEach((key) => {
|
|
36
|
+
const fieldError = itemResult.errors[key];
|
|
37
|
+
const keyPath = `${prefix || ''}[${idx}].${key}`;
|
|
38
|
+
// Support both multi-rule failures ({ errors: [...] }) and
|
|
39
|
+
// single-message errors ({ message }) from the checkit library,
|
|
40
|
+
// consistent with BaseCore.validationFailure()
|
|
41
|
+
if (Array.isArray(fieldError.errors)) {
|
|
42
|
+
fieldError.errors.forEach((err) => {
|
|
43
|
+
result.addError(keyPath, err.message);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
result.addError(keyPath, fieldError.message);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
catch (ex) {
|
|
53
|
+
// If the validator itself throws, add a descriptive error for that
|
|
54
|
+
// index rather than crashing the whole validation pass
|
|
55
|
+
result.addError(`${prefix || ''}[${idx}]`, `Validation failed unexpectedly: ${ex?.message ?? String(ex)}`);
|
|
16
56
|
}
|
|
17
57
|
});
|
|
18
58
|
return result;
|
|
19
59
|
};
|
|
20
60
|
exports.checkArray = checkArray;
|
|
61
|
+
/**
|
|
62
|
+
* Converts a checkit validation error object into a VALIDATION_FAILED OpResult.
|
|
63
|
+
*
|
|
64
|
+
* Iterates `checkItResult.errors` and adds each field's error message(s)
|
|
65
|
+
* to the result. Supports both single-message errors (`{ message }`) and
|
|
66
|
+
* multi-rule failures (`{ errors: [{ message }, ...] }`) from the checkit
|
|
67
|
+
* library, consistent with BaseCore.validationFailure().
|
|
68
|
+
*
|
|
69
|
+
* Returns an empty VALIDATION_FAILED result if `checkItResult` is null,
|
|
70
|
+
* undefined, or has no errors, rather than throwing.
|
|
71
|
+
*
|
|
72
|
+
* @param checkItResult A checkit validation error object
|
|
73
|
+
*/
|
|
21
74
|
const createErrorOnCheckError = (checkItResult) => {
|
|
22
75
|
const result = new api_helpers_1.OpResult({ code: api_helpers_1.OP_RESULT_CODES.VALIDATION_FAILED });
|
|
76
|
+
if (!checkItResult?.errors) {
|
|
77
|
+
return result;
|
|
78
|
+
}
|
|
23
79
|
Object.keys(checkItResult.errors).forEach((key) => {
|
|
24
|
-
|
|
80
|
+
const fieldError = checkItResult.errors[key];
|
|
81
|
+
// Support both multi-rule failures ({ errors: [...] }) and
|
|
82
|
+
// single-message errors ({ message }) from the checkit library
|
|
83
|
+
if (Array.isArray(fieldError.errors)) {
|
|
84
|
+
fieldError.errors.forEach((err) => {
|
|
85
|
+
result.addError(key, err.message);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
result.addError(key, fieldError.message);
|
|
90
|
+
}
|
|
25
91
|
});
|
|
26
92
|
return result;
|
|
27
93
|
};
|
|
@@ -1,18 +1,109 @@
|
|
|
1
1
|
import { OpResult } from '@sdflc/api-helpers';
|
|
2
2
|
import { BaseCoreActionsInterface, CommonValidatorArgs } from './interfaces';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export declare const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Guards that `args` is a non-empty plain object.
|
|
5
|
+
* Returns `[result]` where result is a failed OpResult if the check fails,
|
|
6
|
+
* or `[true]` if it passes.
|
|
7
|
+
*
|
|
8
|
+
* Fix: added explicit object type check before Object.keys() to correctly
|
|
9
|
+
* reject non-objects (null, numbers, strings) rather than treating them
|
|
10
|
+
* as empty objects.
|
|
11
|
+
*/
|
|
12
|
+
export declare const shouldHaveParams: (args: any) => [OpResult | true];
|
|
13
|
+
/**
|
|
14
|
+
* Guards that `id` is a non-null, non-empty value.
|
|
15
|
+
* Returns `[result]` where result is a failed OpResult if the check fails,
|
|
16
|
+
* or `[true]` if it passes.
|
|
17
|
+
*
|
|
18
|
+
* Fix: replaced falsy check `!id` with explicit null/empty-string check
|
|
19
|
+
* so that `id = 0` (a valid integer id) is not incorrectly rejected.
|
|
20
|
+
*/
|
|
21
|
+
export declare const shouldHaveId: (id: any) => [OpResult | true];
|
|
22
|
+
/**
|
|
23
|
+
* Validates that `args.id` is a present integer.
|
|
24
|
+
*/
|
|
25
|
+
export declare const validateSingleIntId: (args: any, _opt: BaseCoreActionsInterface) => Promise<any[]>;
|
|
26
|
+
/**
|
|
27
|
+
* Validates that `args.id` is a present UUID v4.
|
|
28
|
+
*/
|
|
29
|
+
export declare const validateSingleUuidId: (args: any, _opt: BaseCoreActionsInterface) => Promise<any[]>;
|
|
30
|
+
/**
|
|
31
|
+
* Validates that `args.id` is a present non-empty string.
|
|
32
|
+
*/
|
|
33
|
+
export declare const validateSingleTextId: (args: any, _opt: BaseCoreActionsInterface) => Promise<any[]>;
|
|
34
|
+
/**
|
|
35
|
+
* Validates that `args.ids` is a present array of integers.
|
|
36
|
+
*/
|
|
37
|
+
export declare const validateMultipleIntIds: (args: any, _opt: BaseCoreActionsInterface) => Promise<any[]>;
|
|
38
|
+
/**
|
|
39
|
+
* Validates that `args.ids` is a present array of UUID v4 values.
|
|
40
|
+
*/
|
|
41
|
+
export declare const validateMultipleUuidIds: (args: any, _opt: BaseCoreActionsInterface) => Promise<any[]>;
|
|
42
|
+
/**
|
|
43
|
+
* Validates that `args.ids` is a present array of non-empty strings.
|
|
44
|
+
*/
|
|
45
|
+
export declare const validateMultipleTextIds: (args: any, _opt: BaseCoreActionsInterface) => Promise<any[]>;
|
|
46
|
+
/**
|
|
47
|
+
* Validates list filter args using caller-provided rules.
|
|
48
|
+
* Validates `args.filter` rather than `args` directly.
|
|
49
|
+
*
|
|
50
|
+
* Returns a factory function — call with `{ rules }` to get the validator:
|
|
51
|
+
* `validate: validateList({ rules: myCheckitRules })`
|
|
52
|
+
*/
|
|
53
|
+
export declare const validateList: ({ rules }: CommonValidatorArgs) => (args: any, _opt: BaseCoreActionsInterface) => Promise<any[]>;
|
|
54
|
+
/**
|
|
55
|
+
* Validates `args` for a get() call using the core's configured idType.
|
|
56
|
+
* Selects the appropriate single-id rule set (int, UUID, or text).
|
|
57
|
+
* Returns `[true, {}]` immediately if idType is ID_TYPES.UNKNOWN or not set,
|
|
58
|
+
* allowing untyped cores to skip id validation.
|
|
59
|
+
*/
|
|
60
|
+
export declare const validateGet: (args: any, opt: BaseCoreActionsInterface) => Promise<any[]>;
|
|
61
|
+
/**
|
|
62
|
+
* Validates `args.where` for a remove() call using the core's configured idType.
|
|
63
|
+
* First checks that `where` is a non-empty object via `shouldHaveParams`,
|
|
64
|
+
* then applies the appropriate single-id rule set.
|
|
65
|
+
* Returns `[true, {}]` if idType is ID_TYPES.UNKNOWN or not set.
|
|
66
|
+
*/
|
|
67
|
+
export declare const validateRemove: (args: any, opt: BaseCoreActionsInterface) => Promise<any[]>;
|
|
68
|
+
/**
|
|
69
|
+
* Validates `args` for a getMany() call using the core's configured idType.
|
|
70
|
+
* Selects the appropriate multi-id rule set (int, UUID, or text).
|
|
71
|
+
* Returns `[true, {}]` immediately if idType is ID_TYPES.UNKNOWN or not set.
|
|
72
|
+
*/
|
|
73
|
+
export declare const validateGetMany: (args: any, opt: BaseCoreActionsInterface) => Promise<any[]>;
|
|
74
|
+
/**
|
|
75
|
+
* Validates `args.where` for a removeMany() call using the core's configured idType.
|
|
76
|
+
*
|
|
77
|
+
* Fix: removeMany() passes `args = { where: [...] }` to its validator, so we
|
|
78
|
+
* must validate `args.where` rather than `args` directly.
|
|
79
|
+
* Previously this was an alias of validateGetMany which validated `args.ids`
|
|
80
|
+
* directly — that worked only when idType was UNKNOWN (rules were skipped),
|
|
81
|
+
* but would fail silently for typed cores since `args.ids` would be undefined.
|
|
82
|
+
*/
|
|
83
|
+
export declare const validateRemoveMany: (args: any, opt: BaseCoreActionsInterface) => Promise<any[]>;
|
|
84
|
+
/**
|
|
85
|
+
* Validates `args.params` for a create() call using caller-provided rules.
|
|
86
|
+
* First checks that `params` is a non-empty object, then applies the rules.
|
|
87
|
+
*
|
|
88
|
+
* Returns a factory function — call with `{ rules }` to get the validator:
|
|
89
|
+
* `validate: validateCreate({ rules: myCheckitRules })`
|
|
90
|
+
*/
|
|
91
|
+
export declare const validateCreate: ({ rules }: CommonValidatorArgs) => (args: any, _opt: BaseCoreActionsInterface) => Promise<any[]>;
|
|
92
|
+
/**
|
|
93
|
+
* Validates `args.where` and `args.params` for an update() call using
|
|
94
|
+
* caller-provided rules.
|
|
95
|
+
* Checks that both `where` and `params` are non-empty objects, then
|
|
96
|
+
* applies the rules to `params`.
|
|
97
|
+
*
|
|
98
|
+
* Returns a factory function — call with `{ rules }` to get the validator:
|
|
99
|
+
* `validate: validateUpdate({ rules: myCheckitRules })`
|
|
100
|
+
*/
|
|
101
|
+
export declare const validateUpdate: ({ rules }: CommonValidatorArgs) => (args: any, _opt: BaseCoreActionsInterface) => Promise<any[]>;
|
|
102
|
+
/**
|
|
103
|
+
* Validates `args.params` for a set() (upsert) call using caller-provided rules.
|
|
104
|
+
* Checks that `params` is a non-empty object, then applies the rules.
|
|
105
|
+
*
|
|
106
|
+
* Returns a factory function — call with `{ rules }` to get the validator:
|
|
107
|
+
* `validate: validateSet({ rules: myCheckitRules })`
|
|
108
|
+
*/
|
|
109
|
+
export declare const validateSet: ({ rules }: CommonValidatorArgs) => (args: any, _opt: BaseCoreActionsInterface) => Promise<any[]>;
|