@nu-art/ts-common 0.202.71 → 0.202.73
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/package.json
CHANGED
package/tools/Replacer.js
CHANGED
|
@@ -92,7 +92,7 @@ class Replacer extends Logger_1.Logger {
|
|
|
92
92
|
loopArray = this.resolveParamValue(iterableProp, runtime);
|
|
93
93
|
}
|
|
94
94
|
catch (e) {
|
|
95
|
-
throw new validator_core_1.ValidationException(`Error while looping on variable for parts: `, iterableProp, this.input, e);
|
|
95
|
+
throw new validator_core_1.ValidationException(`Error while looping on variable for parts: `, iterableProp, JSON.stringify(this.input), e);
|
|
96
96
|
}
|
|
97
97
|
if (!Array.isArray(loopArray))
|
|
98
98
|
this.logWarning(`Loop object is not an array.. found:`, loopArray);
|
|
@@ -125,12 +125,12 @@ class Replacer extends Logger_1.Logger {
|
|
|
125
125
|
}
|
|
126
126
|
catch (e) {
|
|
127
127
|
this.logWarning('input', this.input);
|
|
128
|
-
throw new validator_core_1.ValidationException(`Error while resolving runtime variable for parts ${param}`, param, this.input, e);
|
|
128
|
+
throw new validator_core_1.ValidationException(`Error while resolving runtime variable for parts ${param}`, param, JSON.stringify(this.input), e);
|
|
129
129
|
}
|
|
130
130
|
if (value === undefined) {
|
|
131
131
|
this.logWarning('input', this.input);
|
|
132
132
|
if (this.strictMode)
|
|
133
|
-
throw new validator_core_1.ValidationException(`Cannot resolve runtime variable for parts ${param}`, param, this.input);
|
|
133
|
+
throw new validator_core_1.ValidationException(`Cannot resolve runtime variable for parts ${param}`, param, JSON.stringify(this.input));
|
|
134
134
|
}
|
|
135
135
|
return value;
|
|
136
136
|
// this.logDebug(`Input:`, this.input);
|
package/utils/array-tools.d.ts
CHANGED
|
@@ -112,4 +112,10 @@ export declare function asOptionalArray<T extends any>(toBeArray?: T | T[]): T[]
|
|
|
112
112
|
export declare function lastElement<T extends any>(array: T[] | undefined): T | undefined;
|
|
113
113
|
export declare function firstElement<T extends any>(array?: T[]): T | undefined;
|
|
114
114
|
export declare function arrayIncludesAny<T extends any>(arr1: T[], arr2: T[]): boolean;
|
|
115
|
+
/**
|
|
116
|
+
* Returns true if arr1 returns the entirety of arr2
|
|
117
|
+
* @param arr1
|
|
118
|
+
* @param arr2
|
|
119
|
+
*/
|
|
120
|
+
export declare function arrayIncludesAll<T extends any>(arr1: T[], arr2: T[]): boolean;
|
|
115
121
|
export {};
|
package/utils/array-tools.js
CHANGED
|
@@ -26,7 +26,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
26
26
|
});
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.arrayIncludesAny = exports.firstElement = exports.lastElement = exports.asOptionalArray = exports.asArray = exports.generateArray = exports.toggleInArray = exports.groupArrayBy = exports.filterFlatInstances = exports.flatArray = exports.batchActionParallel = exports.Promise_all_sequentially = exports.batchAction = exports.sortArray = exports.reduceToMap = exports.arrayToMap = exports.filterFalsy = exports.filterInstances = exports.filterDuplicates = exports.findDuplicates = exports.filterAsync = exports.toggleElementInArray = exports.addItemToArrayAtIndex = exports.addItemToArray = exports.removeFromArrayByIndex = exports.removeFromArray = exports.removeItemFromArray = exports.filterInOut = void 0;
|
|
29
|
+
exports.arrayIncludesAll = exports.arrayIncludesAny = exports.firstElement = exports.lastElement = exports.asOptionalArray = exports.asArray = exports.generateArray = exports.toggleInArray = exports.groupArrayBy = exports.filterFlatInstances = exports.flatArray = exports.batchActionParallel = exports.Promise_all_sequentially = exports.batchAction = exports.sortArray = exports.reduceToMap = exports.arrayToMap = exports.filterFalsy = exports.filterInstances = exports.filterDuplicates = exports.findDuplicates = exports.filterAsync = exports.toggleElementInArray = exports.addItemToArrayAtIndex = exports.addItemToArray = exports.removeFromArrayByIndex = exports.removeFromArray = exports.removeItemFromArray = exports.filterInOut = void 0;
|
|
30
30
|
const tools_1 = require("./tools");
|
|
31
31
|
const object_tools_1 = require("./object-tools");
|
|
32
32
|
function filterInOut(input, filter) {
|
|
@@ -302,3 +302,12 @@ function arrayIncludesAny(arr1, arr2) {
|
|
|
302
302
|
return arr1.some(item => arr2.includes(item));
|
|
303
303
|
}
|
|
304
304
|
exports.arrayIncludesAny = arrayIncludesAny;
|
|
305
|
+
/**
|
|
306
|
+
* Returns true if arr1 returns the entirety of arr2
|
|
307
|
+
* @param arr1
|
|
308
|
+
* @param arr2
|
|
309
|
+
*/
|
|
310
|
+
function arrayIncludesAll(arr1, arr2) {
|
|
311
|
+
return arr2.every(item => arr1.includes(item));
|
|
312
|
+
}
|
|
313
|
+
exports.arrayIncludesAll = arrayIncludesAll;
|
|
@@ -21,8 +21,8 @@ export declare const tsValidateRange: (mandatory?: boolean) => Validator<[number
|
|
|
21
21
|
export declare const tsValidateRegexp: (regexp: RegExp, mandatory?: boolean) => Validator<string>;
|
|
22
22
|
export declare const tsValidateTimestamp: (interval?: number, mandatory?: boolean) => Validator<number>;
|
|
23
23
|
export declare const tsValidateAudit: (range?: RangeTimestamp) => (audit?: AuditBy) => any;
|
|
24
|
-
export declare const tsValidateNonMandatoryObject: <T>(validator: ValidatorTypeResolver<T>) => ((input?: T | undefined) => any)[];
|
|
25
|
-
export declare const tsValidateOptionalObject: <T>(validator: ValidatorTypeResolver<T>) => ((input?: T | undefined) => any)[];
|
|
24
|
+
export declare const tsValidateNonMandatoryObject: <T extends object>(validator: ValidatorTypeResolver<T>) => ((input?: T | undefined) => any)[];
|
|
25
|
+
export declare const tsValidateOptionalObject: <T extends object>(validator: ValidatorTypeResolver<T>) => ((input?: T | undefined) => any)[];
|
|
26
26
|
export declare const tsValidator_valueByKey: <T extends unknown>(validatorObject: {
|
|
27
27
|
[k: string]: Validator<any> | import("./validator-core").TypeValidator<any>;
|
|
28
28
|
}, prop?: string) => ValidatorTypeResolver<T>;
|
|
@@ -19,10 +19,10 @@ export type InvalidResultObject<T extends any> = {
|
|
|
19
19
|
};
|
|
20
20
|
export type InvalidResultArray<T extends any> = InvalidResult<T> | undefined;
|
|
21
21
|
export type InvalidResult<T extends any> = T extends object ? InvalidResultObject<T> | string : T extends (infer I)[] ? (InvalidResultArray<I>[]) | string : string;
|
|
22
|
-
export declare class ValidationException extends CustomException {
|
|
23
|
-
input?:
|
|
24
|
-
result?: InvalidResult<
|
|
25
|
-
constructor(debugMessage: string, input?:
|
|
22
|
+
export declare class ValidationException<T extends any> extends CustomException {
|
|
23
|
+
input?: T;
|
|
24
|
+
result?: InvalidResult<T>;
|
|
25
|
+
constructor(debugMessage: string, input?: T, result?: InvalidResult<T>, e?: Error);
|
|
26
26
|
}
|
|
27
27
|
export declare const assertValidateMandatoryProperty: (mandatory: boolean, input?: any) => void;
|
|
28
28
|
export declare const tsValidateExists: (mandatory?: boolean) => ValidatorImpl<any>;
|
|
@@ -71,7 +71,7 @@ const tsValidate = (instance, _validator, strict = true) => {
|
|
|
71
71
|
exports.tsValidate = tsValidate;
|
|
72
72
|
const tsValidateResult = (instance, _validator, key, parentInstance) => {
|
|
73
73
|
if (!_validator)
|
|
74
|
-
return
|
|
74
|
+
return 'No validator provided!';
|
|
75
75
|
const validator = typeof _validator === 'function' ? [_validator] : _validator;
|
|
76
76
|
if (Array.isArray(validator)) {
|
|
77
77
|
const result = validator.reduce((result, __validator) => result === CONST_NO_ERROR ? result : result || __validator(instance, parentInstance), undefined);
|