vest 5.0.0-dev-781e21 → 5.0.0-dev-ec989a
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/LICENSE +2 -2
- package/README.md +2 -57
- package/dist/cjs/classnames.development.js +37 -17
- package/dist/cjs/classnames.production.js +1 -1
- package/dist/cjs/enforce/compose.development.js +1 -54
- package/dist/cjs/enforce/compose.production.js +1 -1
- package/dist/cjs/enforce/compounds.development.js +18 -84
- package/dist/cjs/enforce/compounds.production.js +1 -1
- package/dist/cjs/enforce/schema.development.js +18 -84
- package/dist/cjs/enforce/schema.production.js +1 -1
- package/dist/cjs/parser.development.js +30 -11
- package/dist/cjs/parser.production.js +1 -1
- package/dist/cjs/promisify.development.js +21 -9
- package/dist/cjs/promisify.production.js +1 -1
- package/dist/cjs/vest.development.js +1324 -1294
- package/dist/cjs/vest.production.js +1 -1
- package/dist/es/classnames.development.js +39 -19
- package/dist/es/classnames.production.js +1 -1
- package/dist/es/enforce/compose.development.js +1 -58
- package/dist/es/enforce/compose.production.js +1 -1
- package/dist/es/enforce/compounds.development.js +2 -90
- package/dist/es/enforce/compounds.production.js +1 -1
- package/dist/es/enforce/schema.development.js +2 -88
- package/dist/es/enforce/schema.production.js +1 -1
- package/dist/es/parser.development.js +31 -10
- package/dist/es/parser.production.js +1 -1
- package/dist/es/promisify.development.js +22 -10
- package/dist/es/promisify.production.js +1 -1
- package/dist/es/vest.development.js +1321 -1286
- package/dist/es/vest.production.js +1 -1
- package/dist/umd/classnames.development.js +40 -20
- package/dist/umd/classnames.production.js +1 -1
- package/dist/umd/enforce/compose.development.js +6 -60
- package/dist/umd/enforce/compose.production.js +1 -1
- package/dist/umd/enforce/compounds.development.js +29 -94
- package/dist/umd/enforce/compounds.production.js +1 -1
- package/dist/umd/enforce/schema.development.js +29 -94
- package/dist/umd/enforce/schema.production.js +1 -1
- package/dist/umd/parser.development.js +33 -14
- package/dist/umd/parser.production.js +1 -1
- package/dist/umd/promisify.development.js +24 -12
- package/dist/umd/promisify.production.js +1 -1
- package/dist/umd/vest.development.js +1327 -1298
- package/dist/umd/vest.production.js +1 -1
- package/package.json +144 -147
- package/testUtils/TVestMock.ts +7 -0
- package/testUtils/__tests__/partition.test.ts +4 -4
- package/testUtils/asVestTest.ts +9 -0
- package/testUtils/mockThrowError.ts +4 -2
- package/testUtils/suiteDummy.ts +4 -1
- package/testUtils/testDummy.ts +12 -10
- package/testUtils/testPromise.ts +3 -0
- package/types/classnames.d.ts +141 -12
- package/types/classnames.d.ts.map +1 -0
- package/types/enforce/compose.d.ts +2 -126
- package/types/enforce/compose.d.ts.map +1 -0
- package/types/enforce/compounds.d.ts +2 -136
- package/types/enforce/compounds.d.ts.map +1 -0
- package/types/enforce/schema.d.ts +2 -144
- package/types/enforce/schema.d.ts.map +1 -0
- package/types/parser.d.ts +147 -18
- package/types/parser.d.ts.map +1 -0
- package/types/promisify.d.ts +139 -43
- package/types/promisify.d.ts.map +1 -0
- package/types/vest.d.ts +257 -242
- package/types/vest.d.ts.map +1 -0
- package/CHANGELOG.md +0 -87
- package/testUtils/expandStateRef.ts +0 -8
- package/testUtils/runCreateRef.ts +0 -10
- package/testUtils/testObjects.ts +0 -6
- package/tsconfig.json +0 -8
package/types/classnames.d.ts
CHANGED
|
@@ -1,26 +1,154 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { Isolate, IsolateKey } from "vest-runtime";
|
|
2
|
+
import { CB } from "vest-utils";
|
|
3
|
+
declare enum Severity {
|
|
4
|
+
WARNINGS = "warnings",
|
|
5
|
+
ERRORS = "errors"
|
|
6
|
+
}
|
|
7
|
+
declare enum TestSeverity {
|
|
8
|
+
Error = "error",
|
|
9
|
+
Warning = "warning"
|
|
10
|
+
}
|
|
11
|
+
// @vx-allow use-use
|
|
12
|
+
declare function IsolateTestReconciler(currentNode: Isolate, historyNode: Isolate | null): Isolate;
|
|
13
|
+
declare enum TestStatus {
|
|
14
|
+
UNTESTED = "UNTESTED",
|
|
15
|
+
SKIPPED = "SKIPPED",
|
|
16
|
+
FAILED = "FAILED",
|
|
17
|
+
WARNING = "WARNING",
|
|
18
|
+
PASSING = "PASSING",
|
|
19
|
+
PENDING = "PENDING",
|
|
20
|
+
CANCELED = "CANCELED",
|
|
21
|
+
OMITTED = "OMITTED"
|
|
22
|
+
}
|
|
23
|
+
type TestFn = () => TestResult;
|
|
24
|
+
type AsyncTest = Promise<string | void | false>;
|
|
25
|
+
type TestResult = AsyncTest | boolean | void;
|
|
26
|
+
type WithFieldName<F extends TFieldName = TFieldName> = {
|
|
27
|
+
fieldName: F;
|
|
28
|
+
};
|
|
29
|
+
type IsolateTestInput = {
|
|
30
|
+
message?: string;
|
|
31
|
+
groupName?: string;
|
|
32
|
+
fieldName: TFieldName;
|
|
33
|
+
testFn: TestFn;
|
|
34
|
+
key?: IsolateKey;
|
|
35
|
+
};
|
|
36
|
+
declare class IsolateTest<F extends TFieldName = TFieldName, G extends TGroupName = TGroupName> extends Isolate {
|
|
37
|
+
children: null;
|
|
38
|
+
fieldName: F;
|
|
39
|
+
testFn: TestFn;
|
|
40
|
+
groupName?: G;
|
|
41
|
+
message?: string;
|
|
42
|
+
asyncTest?: AsyncTest;
|
|
43
|
+
id: string;
|
|
44
|
+
severity: TestSeverity;
|
|
45
|
+
private stateMachine;
|
|
46
|
+
static reconciler: typeof IsolateTestReconciler;
|
|
47
|
+
constructor({ fieldName, testFn, message, groupName, key }: IsolateTestInput);
|
|
48
|
+
static create<Callback extends CB = CB>(callback: Callback, data: IsolateTestInput): IsolateTest;
|
|
49
|
+
static cast<F extends TFieldName = TFieldName, G extends TGroupName = TGroupName>(isolate: Isolate): IsolateTest<F, G>;
|
|
50
|
+
get status(): TestStatus;
|
|
51
|
+
setStatus(status: TestStatus, payload?: any): void;
|
|
52
|
+
run(): TestResult;
|
|
53
|
+
// Selectors
|
|
54
|
+
warns(): boolean;
|
|
55
|
+
isPending(): boolean;
|
|
56
|
+
isOmitted(): boolean;
|
|
57
|
+
isUntested(): boolean;
|
|
58
|
+
isFailing(): boolean;
|
|
59
|
+
isCanceled(): boolean;
|
|
60
|
+
isSkipped(): boolean;
|
|
61
|
+
isPassing(): boolean;
|
|
62
|
+
isWarning(): boolean;
|
|
63
|
+
hasFailures(): boolean;
|
|
64
|
+
isNonActionable(): boolean;
|
|
65
|
+
isTested(): boolean;
|
|
66
|
+
awaitsResolution(): boolean;
|
|
67
|
+
statusEquals(status: TestStatus): boolean;
|
|
68
|
+
// State modifiers
|
|
69
|
+
setPending(): void;
|
|
70
|
+
fail(): void;
|
|
71
|
+
pass(): void;
|
|
72
|
+
warn(): void;
|
|
73
|
+
skip(force?: boolean): void;
|
|
74
|
+
cancel(): void;
|
|
75
|
+
reset(): void;
|
|
76
|
+
omit(): void;
|
|
77
|
+
valueOf(): boolean;
|
|
78
|
+
isAsyncTest(): boolean;
|
|
79
|
+
static is(value: any): value is IsolateTest;
|
|
80
|
+
static isX(value: any): asserts value is IsolateTest;
|
|
81
|
+
}
|
|
82
|
+
declare class SummaryFailure<F extends TFieldName, G extends TGroupName> implements WithFieldName<F> {
|
|
83
|
+
fieldName: F;
|
|
84
|
+
message: string | undefined;
|
|
85
|
+
groupName: G | undefined;
|
|
86
|
+
constructor(fieldName: F, message: string | undefined, groupName: G | undefined);
|
|
87
|
+
static fromTestObject<F extends TFieldName, G extends TGroupName>(testObject: IsolateTest<F, G>): SummaryFailure<F, G>;
|
|
88
|
+
toString(): string;
|
|
89
|
+
}
|
|
90
|
+
interface Done<F extends TFieldName, G extends TGroupName> {
|
|
91
|
+
(...args: [
|
|
92
|
+
cb: (res: SuiteResult<F, G>) => void
|
|
93
|
+
]): SuiteRunResult<F, G>;
|
|
94
|
+
(...args: [
|
|
95
|
+
fieldName: F,
|
|
96
|
+
cb: (res: SuiteResult<F, G>) => void
|
|
97
|
+
]): SuiteRunResult<F, G>;
|
|
98
|
+
}
|
|
99
|
+
interface SuiteSelectors<F extends TFieldName, G extends TGroupName> {
|
|
100
|
+
getWarning(fieldName?: F): void | string | SummaryFailure<F, G>;
|
|
101
|
+
getError(fieldName?: F): void | string | SummaryFailure<F, G>;
|
|
102
|
+
getErrors(fieldName: F): string[];
|
|
103
|
+
getErrors(): FailureMessages;
|
|
104
|
+
getWarnings(): FailureMessages;
|
|
105
|
+
getWarnings(fieldName: F): string[];
|
|
106
|
+
getErrorsByGroup(groupName: G, fieldName: F): string[];
|
|
107
|
+
getErrorsByGroup(groupName: G): FailureMessages;
|
|
108
|
+
getWarningsByGroup(groupName: G): FailureMessages;
|
|
109
|
+
getWarningsByGroup(groupName: G, fieldName: F): string[];
|
|
110
|
+
hasErrors(fieldName?: F): boolean;
|
|
111
|
+
hasWarnings(fieldName?: F): boolean;
|
|
112
|
+
hasErrorsByGroup(groupName: G, fieldName?: F): boolean;
|
|
113
|
+
hasWarningsByGroup(groupName: G, fieldName?: F): boolean;
|
|
114
|
+
isValid(fieldName?: F): boolean;
|
|
115
|
+
isValidByGroup(groupName: G, fieldName?: F): boolean;
|
|
116
|
+
}
|
|
117
|
+
declare class SummaryBase {
|
|
118
|
+
errorCount: number;
|
|
119
|
+
warnCount: number;
|
|
120
|
+
testCount: number;
|
|
121
|
+
}
|
|
122
|
+
declare class SuiteSummary<F extends TFieldName, G extends TGroupName> extends SummaryBase {
|
|
123
|
+
[Severity.ERRORS]: SummaryFailure<F, G>[];
|
|
124
|
+
[Severity.WARNINGS]: SummaryFailure<F, G>[];
|
|
125
|
+
groups: Groups<G, F>;
|
|
126
|
+
tests: Tests<F>;
|
|
4
127
|
valid: boolean;
|
|
5
|
-
}
|
|
128
|
+
}
|
|
6
129
|
type GroupTestSummary = SingleTestSummary;
|
|
7
|
-
type Groups = Record<
|
|
8
|
-
type Group = Record<
|
|
9
|
-
type Tests = Record<
|
|
130
|
+
type Groups<G extends TGroupName, F extends TFieldName> = Record<G, Group<F>>;
|
|
131
|
+
type Group<F extends TFieldName> = Record<F, GroupTestSummary>;
|
|
132
|
+
type Tests<F extends TFieldName> = Record<F, SingleTestSummary>;
|
|
10
133
|
type SingleTestSummary = SummaryBase & {
|
|
11
134
|
errors: string[];
|
|
12
135
|
warnings: string[];
|
|
13
136
|
valid: boolean;
|
|
14
137
|
};
|
|
15
|
-
type
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
138
|
+
type FailureMessages = Record<string, string[]>;
|
|
139
|
+
type SuiteResult<F extends TFieldName, G extends TGroupName> = SuiteSummary<F, G> & SuiteSelectors<F, G> & {
|
|
140
|
+
suiteName: SuiteName;
|
|
141
|
+
};
|
|
142
|
+
type SuiteRunResult<F extends TFieldName, G extends TGroupName> = SuiteResult<F, G> & {
|
|
143
|
+
done: Done<F, G>;
|
|
19
144
|
};
|
|
145
|
+
type SuiteName = string | undefined;
|
|
146
|
+
type TFieldName<T extends string = string> = T;
|
|
147
|
+
type TGroupName<G extends string = string> = G;
|
|
20
148
|
/**
|
|
21
149
|
* Creates a function that returns class names that match the validation result
|
|
22
150
|
*/
|
|
23
|
-
declare function classnames(res: SuiteSummary, classes?: SupportedClasses): (fieldName:
|
|
151
|
+
declare function classnames<F extends TFieldName, G extends TGroupName>(res: SuiteSummary<F, G>, classes?: SupportedClasses): (fieldName: F) => string;
|
|
24
152
|
type SupportedClasses = {
|
|
25
153
|
valid?: string;
|
|
26
154
|
tested?: string;
|
|
@@ -29,3 +157,4 @@ type SupportedClasses = {
|
|
|
29
157
|
untested?: string;
|
|
30
158
|
};
|
|
31
159
|
export { classnames as default };
|
|
160
|
+
//# sourceMappingURL=classnames.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classnames.d.ts","sourceRoot":"","sources":["../src/exports/classnames.ts","../src/suiteResult/Severity.ts","../src/errors/ErrorStrings.ts","../src/core/test/TestTypes.ts","../src/core/test/helpers/matchingFieldName.ts","../src/core/isolate/IsolateTest/isSameProfileTest.ts","../src/core/isolate/IsolateTest/cancelOverriddenPendingTest.ts","../src/hooks/optional/OptionalTypes.ts","../src/core/isolate/IsolateSuite/IsolateSuite.ts","../src/hooks/optional/optional.ts","../src/core/isolate/IsolateTest/TestWalker.ts","../src/core/test/helpers/matchingGroupName.ts","../src/core/test/helpers/nonMatchingSeverityProfile.ts","../src/suiteResult/selectors/hasFailuresByTestObjects.ts","../src/hooks/mode.ts","../src/core/context/SuiteContext.ts","../src/core/Runtime.ts","../src/suiteResult/selectors/shouldAddValidProperty.ts","../src/suiteResult/selectors/produceSuiteSummary.ts","../src/suiteResult/selectors/collectFailures.ts","../src/suiteResult/selectors/suiteSelectors.ts","../src/suiteResult/suiteResult.ts","../src/isolates/skipWhen.ts","../src/hooks/exclusive.ts","../src/isolates/omitWhen.ts","../src/core/test/testLevelFlowControl/verifyTestRun.ts","../src/core/isolate/IsolateTest/IsolateTestReconciler.ts","../src/core/isolate/IsolateTest/IsolateTestStateMachine.ts","../src/core/test/helpers/shouldUseErrorMessage.ts","../src/core/isolate/IsolateTest/IsolateTest.ts","../src/suiteResult/SummaryFailure.ts","../src/suiteResult/done/deferDoneCallback.ts","../src/suiteResult/done/shouldSkipDoneRegistration.ts","../src/suiteResult/suiteRunResult.ts","../src/suiteResult/SuiteResultTypes.ts","../src/exports/parser.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA;;GAEG;AACH,iBAAwB,UAAU,CAAC,CAAC,SAAS,UAAU,EAAE,CAAC,SAAS,UAAU,EAC3E,GAAG,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,EACvB,OAAO,GAAE,gBAAqB,GAC7B,CAAC,SAAS,EAAE,CAAC,KAAK,MAAM,CAe1B;AAED,KAAK,gBAAgB,GAAG;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC"}
|
|
@@ -1,126 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
...infer U
|
|
4
|
-
] ? U : never;
|
|
5
|
-
type Stringable = string | ((...args: any[]) => string);
|
|
6
|
-
type CB = (...args: any[]) => any;
|
|
7
|
-
type RuleReturn = boolean | {
|
|
8
|
-
pass: boolean;
|
|
9
|
-
message?: Stringable;
|
|
10
|
-
};
|
|
11
|
-
type RuleDetailedResult = {
|
|
12
|
-
pass: boolean;
|
|
13
|
-
message?: string;
|
|
14
|
-
};
|
|
15
|
-
type Args = any[];
|
|
16
|
-
type BaseRules = typeof baseRules;
|
|
17
|
-
type KBaseRules = keyof BaseRules;
|
|
18
|
-
declare function condition(value: any, callback: (value: any) => RuleReturn): RuleReturn;
|
|
19
|
-
declare function endsWith(value: string, arg1: string): boolean;
|
|
20
|
-
declare function equals(value: unknown, arg1: unknown): boolean;
|
|
21
|
-
declare function greaterThanOrEquals(value: string | number, gte: string | number): boolean;
|
|
22
|
-
declare function inside(value: unknown, arg1: string | unknown[]): boolean;
|
|
23
|
-
declare function isBetween(value: number | string, min: number | string, max: number | string): boolean;
|
|
24
|
-
declare function isBlank(value: unknown): boolean;
|
|
25
|
-
declare function isKeyOf(key: string | symbol | number, obj: any): boolean;
|
|
26
|
-
declare function isNaN(value: unknown): boolean;
|
|
27
|
-
declare function isNegative(value: number | string): boolean;
|
|
28
|
-
declare function isNumber(value: unknown): value is number;
|
|
29
|
-
declare function isTruthy(value: unknown): boolean;
|
|
30
|
-
declare function isValueOf(value: any, objectToCheck: any): boolean;
|
|
31
|
-
declare function lessThan(value: string | number, lt: string | number): boolean;
|
|
32
|
-
declare function lessThanOrEquals(value: string | number, lte: string | number): boolean;
|
|
33
|
-
declare function longerThanOrEquals(value: string | unknown[], arg1: string | number): boolean;
|
|
34
|
-
declare function matches(value: string, regex: RegExp | string): boolean;
|
|
35
|
-
declare function shorterThan(value: string | unknown[], arg1: string | number): boolean;
|
|
36
|
-
declare function shorterThanOrEquals(value: string | unknown[], arg1: string | number): boolean;
|
|
37
|
-
declare function startsWith(value: string, arg1: string): boolean;
|
|
38
|
-
declare const baseRules: {
|
|
39
|
-
condition: typeof condition;
|
|
40
|
-
doesNotEndWith: (value: string, arg1: string) => boolean;
|
|
41
|
-
doesNotStartWith: (value: string, arg1: string) => boolean;
|
|
42
|
-
endsWith: typeof endsWith;
|
|
43
|
-
equals: typeof equals;
|
|
44
|
-
greaterThan: typeof import("packages/vest-utils/types/vest-utils").greaterThan;
|
|
45
|
-
greaterThanOrEquals: typeof greaterThanOrEquals;
|
|
46
|
-
gt: typeof import("packages/vest-utils/types/vest-utils").greaterThan;
|
|
47
|
-
gte: typeof greaterThanOrEquals;
|
|
48
|
-
inside: typeof inside;
|
|
49
|
-
isArray: typeof import("packages/vest-utils/types/vest-utils").isArray;
|
|
50
|
-
isBetween: typeof isBetween;
|
|
51
|
-
isBlank: typeof isBlank;
|
|
52
|
-
isBoolean: typeof import("packages/vest-utils/types/vest-utils").isBoolean;
|
|
53
|
-
isEmpty: typeof import("packages/vest-utils/types/vest-utils").isEmpty;
|
|
54
|
-
isEven: (value: any) => boolean;
|
|
55
|
-
isFalsy: (value: unknown) => boolean;
|
|
56
|
-
isKeyOf: typeof isKeyOf;
|
|
57
|
-
isNaN: typeof isNaN;
|
|
58
|
-
isNegative: typeof isNegative;
|
|
59
|
-
isNotArray: (value: unknown) => boolean;
|
|
60
|
-
isNotBetween: (value: string | number, min: string | number, max: string | number) => boolean;
|
|
61
|
-
isNotBlank: (value: unknown) => boolean;
|
|
62
|
-
isNotBoolean: (value: unknown) => boolean;
|
|
63
|
-
isNotEmpty: (value: unknown) => boolean;
|
|
64
|
-
isNotKeyOf: (key: string | number | symbol, obj: any) => boolean;
|
|
65
|
-
isNotNaN: (value: unknown) => boolean;
|
|
66
|
-
isNotNull: (value: unknown) => boolean;
|
|
67
|
-
isNotNullish: (value: any) => boolean;
|
|
68
|
-
isNotNumber: (value: unknown) => boolean;
|
|
69
|
-
isNotNumeric: (value: string | number) => boolean;
|
|
70
|
-
isNotString: (v: unknown) => boolean;
|
|
71
|
-
isNotUndefined: (value?: unknown) => boolean;
|
|
72
|
-
isNotValueOf: (value: any, objectToCheck: any) => boolean;
|
|
73
|
-
isNull: typeof import("packages/vest-utils/types/vest-utils").isNull;
|
|
74
|
-
isNullish: typeof import("packages/vest-utils/types/vest-utils").isNullish;
|
|
75
|
-
isNumber: typeof isNumber;
|
|
76
|
-
isNumeric: typeof import("packages/vest-utils/types/vest-utils").isNumeric;
|
|
77
|
-
isOdd: (value: any) => boolean;
|
|
78
|
-
isPositive: typeof import("packages/vest-utils/types/vest-utils").isPositive;
|
|
79
|
-
isString: typeof import("packages/vest-utils/types/vest-utils").isStringValue;
|
|
80
|
-
isTruthy: typeof isTruthy;
|
|
81
|
-
isUndefined: typeof import("packages/vest-utils/types/vest-utils").isUndefined;
|
|
82
|
-
isValueOf: typeof isValueOf;
|
|
83
|
-
lengthEquals: typeof import("packages/vest-utils/types/vest-utils").lengthEquals;
|
|
84
|
-
lengthNotEquals: (value: string | unknown[], arg1: string | number) => boolean;
|
|
85
|
-
lessThan: typeof lessThan;
|
|
86
|
-
lessThanOrEquals: typeof lessThanOrEquals;
|
|
87
|
-
longerThan: typeof import("packages/vest-utils/types/vest-utils").longerThan;
|
|
88
|
-
longerThanOrEquals: typeof longerThanOrEquals;
|
|
89
|
-
lt: typeof lessThan;
|
|
90
|
-
lte: typeof lessThanOrEquals;
|
|
91
|
-
matches: typeof matches;
|
|
92
|
-
notEquals: (value: unknown, arg1: unknown) => boolean;
|
|
93
|
-
notInside: (value: unknown, arg1: string | unknown[]) => boolean;
|
|
94
|
-
notMatches: (value: string, regex: string | RegExp) => boolean;
|
|
95
|
-
numberEquals: typeof import("packages/vest-utils/types/vest-utils").numberEquals;
|
|
96
|
-
numberNotEquals: (value: string | number, eq: string | number) => boolean;
|
|
97
|
-
shorterThan: typeof shorterThan;
|
|
98
|
-
shorterThanOrEquals: typeof shorterThanOrEquals;
|
|
99
|
-
startsWith: typeof startsWith;
|
|
100
|
-
};
|
|
101
|
-
type Rules<E> = n4s.EnforceCustomMatchers<Rules<E> & E> & Record<string, (...args: Args) => Rules<E> & E> & {
|
|
102
|
-
[P in KBaseRules]: (...args: DropFirst<Parameters<BaseRules[P]>> | Args) => Rules<E> & E;
|
|
103
|
-
};
|
|
104
|
-
/* eslint-disable @typescript-eslint/no-namespace, @typescript-eslint/no-empty-interface */
|
|
105
|
-
declare global {
|
|
106
|
-
namespace n4s {
|
|
107
|
-
interface IRules<E> extends Rules<E> {
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
type LazyRules = n4s.IRules<LazyRuleMethods>;
|
|
112
|
-
type Lazy = LazyRules & LazyRuleMethods &
|
|
113
|
-
// This is a "catch all" hack to make TS happy while not
|
|
114
|
-
// losing type hints
|
|
115
|
-
Record<string, CB>;
|
|
116
|
-
type LazyRuleMethods = LazyRuleRunners & {
|
|
117
|
-
message: (message: LazyMessage) => Lazy;
|
|
118
|
-
};
|
|
119
|
-
type LazyRuleRunners = {
|
|
120
|
-
test: (value: unknown) => boolean;
|
|
121
|
-
run: (value: unknown) => RuleDetailedResult;
|
|
122
|
-
};
|
|
123
|
-
type ComposeResult = LazyRuleRunners & ((value: any) => void);
|
|
124
|
-
type LazyMessage = string | ((value: unknown, originalMessage?: Stringable) => string);
|
|
125
|
-
declare function compose(...composites: LazyRuleRunners[]): ComposeResult;
|
|
126
|
-
export { compose as default };
|
|
1
|
+
export { default } from 'n4s/compose';
|
|
2
|
+
//# sourceMappingURL=compose.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compose.d.ts","sourceRoot":"","sources":["../../src/exports/enforce@compose.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,aAAa,CAAC"}
|
|
@@ -1,136 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
...infer U
|
|
4
|
-
] ? U : never;
|
|
5
|
-
type Stringable = string | ((...args: any[]) => string);
|
|
6
|
-
type CB = (...args: any[]) => any;
|
|
7
|
-
type EnforceCustomMatcher<F extends CB, R> = (...args: DropFirst<Parameters<F>>) => R;
|
|
8
|
-
type RuleReturn = boolean | {
|
|
9
|
-
pass: boolean;
|
|
10
|
-
message?: Stringable;
|
|
11
|
-
};
|
|
12
|
-
type RuleDetailedResult = {
|
|
13
|
-
pass: boolean;
|
|
14
|
-
message?: string;
|
|
15
|
-
};
|
|
16
|
-
type Args = any[];
|
|
17
|
-
type BaseRules = typeof baseRules;
|
|
18
|
-
type KBaseRules = keyof BaseRules;
|
|
19
|
-
declare function condition(value: any, callback: (value: any) => RuleReturn): RuleReturn;
|
|
20
|
-
declare function endsWith(value: string, arg1: string): boolean;
|
|
21
|
-
declare function equals(value: unknown, arg1: unknown): boolean;
|
|
22
|
-
declare function greaterThanOrEquals(value: string | number, gte: string | number): boolean;
|
|
23
|
-
declare function inside(value: unknown, arg1: string | unknown[]): boolean;
|
|
24
|
-
declare function isBetween(value: number | string, min: number | string, max: number | string): boolean;
|
|
25
|
-
declare function isBlank(value: unknown): boolean;
|
|
26
|
-
declare function isKeyOf(key: string | symbol | number, obj: any): boolean;
|
|
27
|
-
declare function isNaN(value: unknown): boolean;
|
|
28
|
-
declare function isNegative(value: number | string): boolean;
|
|
29
|
-
declare function isNumber(value: unknown): value is number;
|
|
30
|
-
declare function isTruthy(value: unknown): boolean;
|
|
31
|
-
declare function isValueOf(value: any, objectToCheck: any): boolean;
|
|
32
|
-
declare function lessThan(value: string | number, lt: string | number): boolean;
|
|
33
|
-
declare function lessThanOrEquals(value: string | number, lte: string | number): boolean;
|
|
34
|
-
declare function longerThanOrEquals(value: string | unknown[], arg1: string | number): boolean;
|
|
35
|
-
declare function matches(value: string, regex: RegExp | string): boolean;
|
|
36
|
-
declare function shorterThan(value: string | unknown[], arg1: string | number): boolean;
|
|
37
|
-
declare function shorterThanOrEquals(value: string | unknown[], arg1: string | number): boolean;
|
|
38
|
-
declare function startsWith(value: string, arg1: string): boolean;
|
|
39
|
-
declare const baseRules: {
|
|
40
|
-
condition: typeof condition;
|
|
41
|
-
doesNotEndWith: (value: string, arg1: string) => boolean;
|
|
42
|
-
doesNotStartWith: (value: string, arg1: string) => boolean;
|
|
43
|
-
endsWith: typeof endsWith;
|
|
44
|
-
equals: typeof equals;
|
|
45
|
-
greaterThan: typeof import("packages/vest-utils/types/vest-utils").greaterThan;
|
|
46
|
-
greaterThanOrEquals: typeof greaterThanOrEquals;
|
|
47
|
-
gt: typeof import("packages/vest-utils/types/vest-utils").greaterThan;
|
|
48
|
-
gte: typeof greaterThanOrEquals;
|
|
49
|
-
inside: typeof inside;
|
|
50
|
-
isArray: typeof import("packages/vest-utils/types/vest-utils").isArray;
|
|
51
|
-
isBetween: typeof isBetween;
|
|
52
|
-
isBlank: typeof isBlank;
|
|
53
|
-
isBoolean: typeof import("packages/vest-utils/types/vest-utils").isBoolean;
|
|
54
|
-
isEmpty: typeof import("packages/vest-utils/types/vest-utils").isEmpty;
|
|
55
|
-
isEven: (value: any) => boolean;
|
|
56
|
-
isFalsy: (value: unknown) => boolean;
|
|
57
|
-
isKeyOf: typeof isKeyOf;
|
|
58
|
-
isNaN: typeof isNaN;
|
|
59
|
-
isNegative: typeof isNegative;
|
|
60
|
-
isNotArray: (value: unknown) => boolean;
|
|
61
|
-
isNotBetween: (value: string | number, min: string | number, max: string | number) => boolean;
|
|
62
|
-
isNotBlank: (value: unknown) => boolean;
|
|
63
|
-
isNotBoolean: (value: unknown) => boolean;
|
|
64
|
-
isNotEmpty: (value: unknown) => boolean;
|
|
65
|
-
isNotKeyOf: (key: string | number | symbol, obj: any) => boolean;
|
|
66
|
-
isNotNaN: (value: unknown) => boolean;
|
|
67
|
-
isNotNull: (value: unknown) => boolean;
|
|
68
|
-
isNotNullish: (value: any) => boolean;
|
|
69
|
-
isNotNumber: (value: unknown) => boolean;
|
|
70
|
-
isNotNumeric: (value: string | number) => boolean;
|
|
71
|
-
isNotString: (v: unknown) => boolean;
|
|
72
|
-
isNotUndefined: (value?: unknown) => boolean;
|
|
73
|
-
isNotValueOf: (value: any, objectToCheck: any) => boolean;
|
|
74
|
-
isNull: typeof import("packages/vest-utils/types/vest-utils").isNull;
|
|
75
|
-
isNullish: typeof import("packages/vest-utils/types/vest-utils").isNullish;
|
|
76
|
-
isNumber: typeof isNumber;
|
|
77
|
-
isNumeric: typeof import("packages/vest-utils/types/vest-utils").isNumeric;
|
|
78
|
-
isOdd: (value: any) => boolean;
|
|
79
|
-
isPositive: typeof import("packages/vest-utils/types/vest-utils").isPositive;
|
|
80
|
-
isString: typeof import("packages/vest-utils/types/vest-utils").isStringValue;
|
|
81
|
-
isTruthy: typeof isTruthy;
|
|
82
|
-
isUndefined: typeof import("packages/vest-utils/types/vest-utils").isUndefined;
|
|
83
|
-
isValueOf: typeof isValueOf;
|
|
84
|
-
lengthEquals: typeof import("packages/vest-utils/types/vest-utils").lengthEquals;
|
|
85
|
-
lengthNotEquals: (value: string | unknown[], arg1: string | number) => boolean;
|
|
86
|
-
lessThan: typeof lessThan;
|
|
87
|
-
lessThanOrEquals: typeof lessThanOrEquals;
|
|
88
|
-
longerThan: typeof import("packages/vest-utils/types/vest-utils").longerThan;
|
|
89
|
-
longerThanOrEquals: typeof longerThanOrEquals;
|
|
90
|
-
lt: typeof lessThan;
|
|
91
|
-
lte: typeof lessThanOrEquals;
|
|
92
|
-
matches: typeof matches;
|
|
93
|
-
notEquals: (value: unknown, arg1: unknown) => boolean;
|
|
94
|
-
notInside: (value: unknown, arg1: string | unknown[]) => boolean;
|
|
95
|
-
notMatches: (value: string, regex: string | RegExp) => boolean;
|
|
96
|
-
numberEquals: typeof import("packages/vest-utils/types/vest-utils").numberEquals;
|
|
97
|
-
numberNotEquals: (value: string | number, eq: string | number) => boolean;
|
|
98
|
-
shorterThan: typeof shorterThan;
|
|
99
|
-
shorterThanOrEquals: typeof shorterThanOrEquals;
|
|
100
|
-
startsWith: typeof startsWith;
|
|
101
|
-
};
|
|
102
|
-
type Rules<E> = n4s.EnforceCustomMatchers<Rules<E> & E> & Record<string, (...args: Args) => Rules<E> & E> & {
|
|
103
|
-
[P in KBaseRules]: (...args: DropFirst<Parameters<BaseRules[P]>> | Args) => Rules<E> & E;
|
|
104
|
-
};
|
|
105
|
-
/* eslint-disable @typescript-eslint/no-namespace, @typescript-eslint/no-empty-interface */
|
|
106
|
-
declare global {
|
|
107
|
-
namespace n4s {
|
|
108
|
-
interface IRules<E> extends Rules<E> {
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
type LazyRules = n4s.IRules<LazyRuleMethods>;
|
|
113
|
-
type Lazy = LazyRules & LazyRuleMethods &
|
|
114
|
-
// This is a "catch all" hack to make TS happy while not
|
|
115
|
-
// losing type hints
|
|
116
|
-
Record<string, CB>;
|
|
117
|
-
type LazyRuleMethods = LazyRuleRunners & {
|
|
118
|
-
message: (message: LazyMessage) => Lazy;
|
|
119
|
-
};
|
|
120
|
-
type LazyRuleRunners = {
|
|
121
|
-
test: (value: unknown) => boolean;
|
|
122
|
-
run: (value: unknown) => RuleDetailedResult;
|
|
123
|
-
};
|
|
124
|
-
type LazyMessage = string | ((value: unknown, originalMessage?: Stringable) => string);
|
|
125
|
-
type EnforceCompoundRule = (value: unknown, ...rules: Lazy[]) => RuleDetailedResult;
|
|
126
|
-
declare global {
|
|
127
|
-
namespace n4s {
|
|
128
|
-
interface EnforceCustomMatchers<R> {
|
|
129
|
-
allOf: EnforceCustomMatcher<EnforceCompoundRule, R>;
|
|
130
|
-
anyOf: EnforceCustomMatcher<EnforceCompoundRule, R>;
|
|
131
|
-
noneOf: EnforceCustomMatcher<EnforceCompoundRule, R>;
|
|
132
|
-
oneOf: EnforceCustomMatcher<EnforceCompoundRule, R>;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
export {};
|
|
1
|
+
export * as compounds from 'n4s/compounds';
|
|
2
|
+
//# sourceMappingURL=compounds.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compounds.d.ts","sourceRoot":"","sources":["../../src/exports/enforce@compounds.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,eAAe,CAAC"}
|
|
@@ -1,144 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
...infer U
|
|
4
|
-
] ? U : never;
|
|
5
|
-
type Stringable = string | ((...args: any[]) => string);
|
|
6
|
-
type CB = (...args: any[]) => any;
|
|
7
|
-
type EnforceCustomMatcher<F extends CB, R> = (...args: DropFirst<Parameters<F>>) => R;
|
|
8
|
-
type RuleReturn = boolean | {
|
|
9
|
-
pass: boolean;
|
|
10
|
-
message?: Stringable;
|
|
11
|
-
};
|
|
12
|
-
type RuleDetailedResult = {
|
|
13
|
-
pass: boolean;
|
|
14
|
-
message?: string;
|
|
15
|
-
};
|
|
16
|
-
type Args = any[];
|
|
17
|
-
type BaseRules = typeof baseRules;
|
|
18
|
-
type KBaseRules = keyof BaseRules;
|
|
19
|
-
declare function condition(value: any, callback: (value: any) => RuleReturn): RuleReturn;
|
|
20
|
-
declare function endsWith(value: string, arg1: string): boolean;
|
|
21
|
-
declare function equals(value: unknown, arg1: unknown): boolean;
|
|
22
|
-
declare function greaterThanOrEquals(value: string | number, gte: string | number): boolean;
|
|
23
|
-
declare function inside(value: unknown, arg1: string | unknown[]): boolean;
|
|
24
|
-
declare function isBetween(value: number | string, min: number | string, max: number | string): boolean;
|
|
25
|
-
declare function isBlank(value: unknown): boolean;
|
|
26
|
-
declare function isKeyOf(key: string | symbol | number, obj: any): boolean;
|
|
27
|
-
declare function isNaN(value: unknown): boolean;
|
|
28
|
-
declare function isNegative(value: number | string): boolean;
|
|
29
|
-
declare function isNumber(value: unknown): value is number;
|
|
30
|
-
declare function isTruthy(value: unknown): boolean;
|
|
31
|
-
declare function isValueOf(value: any, objectToCheck: any): boolean;
|
|
32
|
-
declare function lessThan(value: string | number, lt: string | number): boolean;
|
|
33
|
-
declare function lessThanOrEquals(value: string | number, lte: string | number): boolean;
|
|
34
|
-
declare function longerThanOrEquals(value: string | unknown[], arg1: string | number): boolean;
|
|
35
|
-
declare function matches(value: string, regex: RegExp | string): boolean;
|
|
36
|
-
declare function shorterThan(value: string | unknown[], arg1: string | number): boolean;
|
|
37
|
-
declare function shorterThanOrEquals(value: string | unknown[], arg1: string | number): boolean;
|
|
38
|
-
declare function startsWith(value: string, arg1: string): boolean;
|
|
39
|
-
declare const baseRules: {
|
|
40
|
-
condition: typeof condition;
|
|
41
|
-
doesNotEndWith: (value: string, arg1: string) => boolean;
|
|
42
|
-
doesNotStartWith: (value: string, arg1: string) => boolean;
|
|
43
|
-
endsWith: typeof endsWith;
|
|
44
|
-
equals: typeof equals;
|
|
45
|
-
greaterThan: typeof import("packages/vest-utils/types/vest-utils").greaterThan;
|
|
46
|
-
greaterThanOrEquals: typeof greaterThanOrEquals;
|
|
47
|
-
gt: typeof import("packages/vest-utils/types/vest-utils").greaterThan;
|
|
48
|
-
gte: typeof greaterThanOrEquals;
|
|
49
|
-
inside: typeof inside;
|
|
50
|
-
isArray: typeof import("packages/vest-utils/types/vest-utils").isArray;
|
|
51
|
-
isBetween: typeof isBetween;
|
|
52
|
-
isBlank: typeof isBlank;
|
|
53
|
-
isBoolean: typeof import("packages/vest-utils/types/vest-utils").isBoolean;
|
|
54
|
-
isEmpty: typeof import("packages/vest-utils/types/vest-utils").isEmpty;
|
|
55
|
-
isEven: (value: any) => boolean;
|
|
56
|
-
isFalsy: (value: unknown) => boolean;
|
|
57
|
-
isKeyOf: typeof isKeyOf;
|
|
58
|
-
isNaN: typeof isNaN;
|
|
59
|
-
isNegative: typeof isNegative;
|
|
60
|
-
isNotArray: (value: unknown) => boolean;
|
|
61
|
-
isNotBetween: (value: string | number, min: string | number, max: string | number) => boolean;
|
|
62
|
-
isNotBlank: (value: unknown) => boolean;
|
|
63
|
-
isNotBoolean: (value: unknown) => boolean;
|
|
64
|
-
isNotEmpty: (value: unknown) => boolean;
|
|
65
|
-
isNotKeyOf: (key: string | number | symbol, obj: any) => boolean;
|
|
66
|
-
isNotNaN: (value: unknown) => boolean;
|
|
67
|
-
isNotNull: (value: unknown) => boolean;
|
|
68
|
-
isNotNullish: (value: any) => boolean;
|
|
69
|
-
isNotNumber: (value: unknown) => boolean;
|
|
70
|
-
isNotNumeric: (value: string | number) => boolean;
|
|
71
|
-
isNotString: (v: unknown) => boolean;
|
|
72
|
-
isNotUndefined: (value?: unknown) => boolean;
|
|
73
|
-
isNotValueOf: (value: any, objectToCheck: any) => boolean;
|
|
74
|
-
isNull: typeof import("packages/vest-utils/types/vest-utils").isNull;
|
|
75
|
-
isNullish: typeof import("packages/vest-utils/types/vest-utils").isNullish;
|
|
76
|
-
isNumber: typeof isNumber;
|
|
77
|
-
isNumeric: typeof import("packages/vest-utils/types/vest-utils").isNumeric;
|
|
78
|
-
isOdd: (value: any) => boolean;
|
|
79
|
-
isPositive: typeof import("packages/vest-utils/types/vest-utils").isPositive;
|
|
80
|
-
isString: typeof import("packages/vest-utils/types/vest-utils").isStringValue;
|
|
81
|
-
isTruthy: typeof isTruthy;
|
|
82
|
-
isUndefined: typeof import("packages/vest-utils/types/vest-utils").isUndefined;
|
|
83
|
-
isValueOf: typeof isValueOf;
|
|
84
|
-
lengthEquals: typeof import("packages/vest-utils/types/vest-utils").lengthEquals;
|
|
85
|
-
lengthNotEquals: (value: string | unknown[], arg1: string | number) => boolean;
|
|
86
|
-
lessThan: typeof lessThan;
|
|
87
|
-
lessThanOrEquals: typeof lessThanOrEquals;
|
|
88
|
-
longerThan: typeof import("packages/vest-utils/types/vest-utils").longerThan;
|
|
89
|
-
longerThanOrEquals: typeof longerThanOrEquals;
|
|
90
|
-
lt: typeof lessThan;
|
|
91
|
-
lte: typeof lessThanOrEquals;
|
|
92
|
-
matches: typeof matches;
|
|
93
|
-
notEquals: (value: unknown, arg1: unknown) => boolean;
|
|
94
|
-
notInside: (value: unknown, arg1: string | unknown[]) => boolean;
|
|
95
|
-
notMatches: (value: string, regex: string | RegExp) => boolean;
|
|
96
|
-
numberEquals: typeof import("packages/vest-utils/types/vest-utils").numberEquals;
|
|
97
|
-
numberNotEquals: (value: string | number, eq: string | number) => boolean;
|
|
98
|
-
shorterThan: typeof shorterThan;
|
|
99
|
-
shorterThanOrEquals: typeof shorterThanOrEquals;
|
|
100
|
-
startsWith: typeof startsWith;
|
|
101
|
-
};
|
|
102
|
-
type Rules<E> = n4s.EnforceCustomMatchers<Rules<E> & E> & Record<string, (...args: Args) => Rules<E> & E> & {
|
|
103
|
-
[P in KBaseRules]: (...args: DropFirst<Parameters<BaseRules[P]>> | Args) => Rules<E> & E;
|
|
104
|
-
};
|
|
105
|
-
/* eslint-disable @typescript-eslint/no-namespace, @typescript-eslint/no-empty-interface */
|
|
106
|
-
declare global {
|
|
107
|
-
namespace n4s {
|
|
108
|
-
interface IRules<E> extends Rules<E> {
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
type LazyRules = n4s.IRules<LazyRuleMethods>;
|
|
113
|
-
type Lazy = LazyRules & LazyRuleMethods &
|
|
114
|
-
// This is a "catch all" hack to make TS happy while not
|
|
115
|
-
// losing type hints
|
|
116
|
-
Record<string, CB>;
|
|
117
|
-
type LazyRuleMethods = LazyRuleRunners & {
|
|
118
|
-
message: (message: LazyMessage) => Lazy;
|
|
119
|
-
};
|
|
120
|
-
type LazyRuleRunners = {
|
|
121
|
-
test: (value: unknown) => boolean;
|
|
122
|
-
run: (value: unknown) => RuleDetailedResult;
|
|
123
|
-
};
|
|
124
|
-
type LazyMessage = string | ((value: unknown, originalMessage?: Stringable) => string);
|
|
125
|
-
declare function isArrayOf(inputArray: any[], currentRule: LazyRuleRunners): RuleDetailedResult;
|
|
126
|
-
interface ShapeObject extends Record<string, any>, Record<string, LazyRuleRunners> {
|
|
127
|
-
}
|
|
128
|
-
declare function loose(inputObject: Record<string, any>, shapeObject: ShapeObject): RuleDetailedResult;
|
|
129
|
-
declare function optional(value: any, ruleChain: Lazy): RuleDetailedResult;
|
|
130
|
-
declare function shape(inputObject: Record<string, any>, shapeObject: ShapeObject): RuleDetailedResult;
|
|
131
|
-
// Help needed improving the typings of this file.
|
|
132
|
-
// Ideally, we'd be able to extend ShapeObject, but that's not possible.
|
|
133
|
-
declare function partial<T extends Record<any, any>>(shapeObject: T): T;
|
|
134
|
-
declare global {
|
|
135
|
-
namespace n4s {
|
|
136
|
-
interface EnforceCustomMatchers<R> {
|
|
137
|
-
isArrayOf: EnforceCustomMatcher<typeof isArrayOf, R>;
|
|
138
|
-
loose: EnforceCustomMatcher<typeof loose, R>;
|
|
139
|
-
shape: EnforceCustomMatcher<typeof shape, R>;
|
|
140
|
-
optional: EnforceCustomMatcher<typeof optional, R>;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
export { partial };
|
|
1
|
+
export * as schema from 'n4s/schema';
|
|
2
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/exports/enforce@schema.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,YAAY,CAAC"}
|