vest 4.4.2-dev-ae93bf → 4.5.0-dev-9b46fb

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.
Files changed (43) hide show
  1. package/dist/cjs/classnames.development.js +13 -36
  2. package/dist/cjs/classnames.production.js +1 -1
  3. package/dist/cjs/enforce/compose.development.js +1 -1
  4. package/dist/cjs/enforce/compose.production.js +1 -1
  5. package/dist/cjs/enforce/compounds.development.js +1 -1
  6. package/dist/cjs/enforce/compounds.production.js +1 -1
  7. package/dist/cjs/enforce/schema.development.js +1 -1
  8. package/dist/cjs/enforce/schema.production.js +1 -1
  9. package/dist/cjs/parser.development.js +13 -36
  10. package/dist/cjs/parser.production.js +1 -1
  11. package/dist/cjs/vest.development.js +113 -118
  12. package/dist/cjs/vest.production.js +1 -1
  13. package/dist/es/classnames.development.js +14 -37
  14. package/dist/es/classnames.production.js +1 -1
  15. package/dist/es/enforce/compose.development.js +1 -1
  16. package/dist/es/enforce/compose.production.js +1 -1
  17. package/dist/es/enforce/compounds.development.js +1 -1
  18. package/dist/es/enforce/compounds.production.js +1 -1
  19. package/dist/es/enforce/schema.development.js +1 -1
  20. package/dist/es/enforce/schema.production.js +1 -1
  21. package/dist/es/parser.development.js +14 -37
  22. package/dist/es/parser.production.js +1 -1
  23. package/dist/es/vest.development.js +114 -120
  24. package/dist/es/vest.production.js +1 -1
  25. package/dist/umd/classnames.development.js +16 -45
  26. package/dist/umd/classnames.production.js +1 -1
  27. package/dist/umd/enforce/compose.development.js +17 -0
  28. package/dist/umd/enforce/compounds.development.js +68 -51
  29. package/dist/umd/enforce/compounds.production.js +1 -1
  30. package/dist/umd/enforce/schema.development.js +17 -0
  31. package/dist/umd/parser.development.js +16 -45
  32. package/dist/umd/parser.production.js +1 -1
  33. package/dist/umd/vest.development.js +131 -119
  34. package/dist/umd/vest.production.js +1 -1
  35. package/package.json +4 -4
  36. package/testUtils/__tests__/partition.test.ts +21 -0
  37. package/testUtils/partition.ts +13 -0
  38. package/types/enforce/compose.d.ts +3 -2
  39. package/types/enforce/compounds.d.ts +3 -2
  40. package/types/enforce/schema.d.ts +3 -2
  41. package/types/parser.d.ts +8 -7
  42. package/types/promisify.d.ts +20 -35
  43. package/types/vest.d.ts +45 -60
@@ -3,6 +3,7 @@ type DropFirst<T extends unknown[]> = T extends [
3
3
  ...infer U
4
4
  ] ? U : never;
5
5
  type Stringable = string | ((...args: any[]) => string);
6
+ type CB = (...args: any[]) => any;
6
7
  type RuleReturn = boolean | {
7
8
  pass: boolean;
8
9
  message?: Stringable;
@@ -97,7 +98,7 @@ declare const baseRules: {
97
98
  shorterThanOrEquals: typeof shorterThanOrEquals;
98
99
  startsWith: typeof startsWith;
99
100
  };
100
- type Rules<E = Record<string, unknown>> = n4s.EnforceCustomMatchers<Rules<E> & E> & Record<string, (...args: Args) => Rules<E> & E> & {
101
+ type Rules<E> = n4s.EnforceCustomMatchers<Rules<E> & E> & Record<string, (...args: Args) => Rules<E> & E> & {
101
102
  [P in KBaseRules]: (...args: DropFirst<Parameters<BaseRules[P]>> | Args) => Rules<E> & E;
102
103
  };
103
104
  /* eslint-disable @typescript-eslint/no-namespace, @typescript-eslint/no-empty-interface */
@@ -111,7 +112,7 @@ type LazyRules = n4s.IRules<LazyRuleMethods>;
111
112
  type Lazy = LazyRules & LazyRuleMethods &
112
113
  // This is a "catch all" hack to make TS happy while not
113
114
  // losing type hints
114
- Record<string, (...args: any[]) => any>;
115
+ Record<string, CB>;
115
116
  type LazyRuleMethods = LazyRuleRunners & {
116
117
  message: (message: LazyMessage) => Lazy;
117
118
  };
package/types/parser.d.ts CHANGED
@@ -17,11 +17,12 @@ type SummaryBase = {
17
17
  warnCount: number;
18
18
  testCount: number;
19
19
  };
20
- declare function parse(res: SuiteSummary): {
21
- valid: (fieldName?: string) => boolean;
22
- tested: (fieldName?: string) => boolean;
23
- invalid: (fieldName?: string) => boolean;
24
- untested: (fieldName?: string) => boolean;
25
- warning: (fieldName?: string) => boolean;
26
- };
20
+ declare function parse(summary: SuiteSummary): ParsedVestObject;
21
+ interface ParsedVestObject {
22
+ valid(fieldName?: string): boolean;
23
+ tested(fieldName?: string): boolean;
24
+ invalid(fieldName?: string): boolean;
25
+ untested(fieldName?: string): boolean;
26
+ warning(fieldName?: string): boolean;
27
+ }
27
28
  export { parse };
@@ -1,7 +1,3 @@
1
- /**
2
- * Reads the testObjects list and gets full validation result from it.
3
- */
4
- declare function genTestsSummary(): SuiteSummary;
5
1
  type SuiteSummary = {
6
2
  groups: Groups;
7
3
  tests: Tests;
@@ -22,37 +18,6 @@ type SummaryBase = {
22
18
  testCount: number;
23
19
  };
24
20
  type FailureMessages = Record<string, string[]>;
25
- declare function getErrors(): FailureMessages;
26
- declare function getErrors(fieldName?: string): string[];
27
- declare function getWarnings(): FailureMessages;
28
- declare function getWarnings(fieldName?: string): string[];
29
- declare function getErrorsByGroup(groupName: string): FailureMessages;
30
- declare function getErrorsByGroup(groupName: string, fieldName: string): string[];
31
- declare function getWarningsByGroup(groupName: string): FailureMessages;
32
- declare function getWarningsByGroup(groupName: string, fieldName: string): string[];
33
- declare function hasErrors(fieldName?: string): boolean;
34
- declare function hasWarnings(fieldName?: string): boolean;
35
- declare function hasErrorsByGroup(groupName: string, fieldName?: string): boolean;
36
- declare function hasWarningsByGroup(groupName: string, fieldName?: string): boolean;
37
- declare function isValid(fieldName?: string): boolean;
38
- declare function isValidByGroup(groupName: string, fieldName?: string): boolean;
39
- type SuiteResult = ReturnType<typeof genTestsSummary> & {
40
- /**
41
- * Returns whether the suite as a whole is valid.
42
- * Determined if there are no errors, and if no
43
- * required fields are skipped.
44
- */
45
- isValid: typeof isValid;
46
- isValidByGroup: typeof isValidByGroup;
47
- hasErrors: typeof hasErrors;
48
- hasWarnings: typeof hasWarnings;
49
- getErrors: typeof getErrors;
50
- getWarnings: typeof getWarnings;
51
- hasErrorsByGroup: typeof hasErrorsByGroup;
52
- hasWarningsByGroup: typeof hasWarningsByGroup;
53
- getErrorsByGroup: typeof getErrorsByGroup;
54
- getWarningsByGroup: typeof getWarningsByGroup;
55
- };
56
21
  type SuiteRunResult = SuiteResult & {
57
22
  done: Done;
58
23
  };
@@ -65,5 +30,25 @@ interface Done {
65
30
  cb: (res: SuiteResult) => void
66
31
  ]): SuiteRunResult;
67
32
  }
33
+ type SuiteName = string | void;
34
+ interface SuiteSelectors {
35
+ getErrors(fieldName: string): string[];
36
+ getErrors(): FailureMessages;
37
+ getWarnings(): FailureMessages;
38
+ getWarnings(fieldName: string): string[];
39
+ getErrorsByGroup(groupName: string, fieldName: string): string[];
40
+ getErrorsByGroup(groupName: string): FailureMessages;
41
+ getWarningsByGroup(groupName: string): FailureMessages;
42
+ getWarningsByGroup(groupName: string, fieldName: string): string[];
43
+ hasErrors(fieldName?: string): boolean;
44
+ hasWarnings(fieldName?: string): boolean;
45
+ hasErrorsByGroup(groupName: string, fieldName?: string): boolean;
46
+ hasWarningsByGroup(groupName: string, fieldName?: string): boolean;
47
+ isValid(fieldName?: string): boolean;
48
+ isValidByGroup(groupName: string, fieldName?: string): boolean;
49
+ }
50
+ type SuiteResult = SuiteSummary & SuiteSelectors & {
51
+ suiteName: SuiteName;
52
+ };
68
53
  declare const promisify: (validatorFn: (...args: any[]) => SuiteRunResult) => (...args: any[]) => Promise<SuiteResult>;
69
54
  export { promisify as default };
package/types/vest.d.ts CHANGED
@@ -1,4 +1,24 @@
1
1
  import { enforce } from 'n4s';
2
+ type SuiteSummary = {
3
+ groups: Groups;
4
+ tests: Tests;
5
+ valid: boolean;
6
+ } & SummaryBase;
7
+ type GroupTestSummary = SingleTestSummary;
8
+ type Groups = Record<string, Group>;
9
+ type Group = Record<string, GroupTestSummary>;
10
+ type Tests = Record<string, SingleTestSummary>;
11
+ type SingleTestSummary = SummaryBase & {
12
+ errors: string[];
13
+ warnings: string[];
14
+ valid: boolean;
15
+ };
16
+ type SummaryBase = {
17
+ errorCount: number;
18
+ warnCount: number;
19
+ testCount: number;
20
+ };
21
+ type FailureMessages = Record<string, string[]>;
2
22
  declare enum TestSeverity {
3
23
  Error = "error",
4
24
  Warning = "warning"
@@ -48,61 +68,27 @@ type AsyncTest = Promise<string | void>;
48
68
  type TestResult = AsyncTest | boolean | void;
49
69
  type TestFn = () => TestResult;
50
70
  type KStatus = "UNTESTED" | "SKIPPED" | "FAILED" | "WARNING" | "PASSING" | "PENDING" | "CANCELED" | "OMITTED";
51
- type CB = (...args: any[]) => void;
52
- /**
53
- * Reads the testObjects list and gets full validation result from it.
54
- */
55
- declare function genTestsSummary(): SuiteSummary;
56
- type SuiteSummary = {
57
- groups: Groups;
58
- tests: Tests;
59
- valid: boolean;
60
- } & SummaryBase;
61
- type GroupTestSummary = SingleTestSummary;
62
- type Groups = Record<string, Group>;
63
- type Group = Record<string, GroupTestSummary>;
64
- type Tests = Record<string, SingleTestSummary>;
65
- type SingleTestSummary = SummaryBase & {
66
- errors: string[];
67
- warnings: string[];
68
- valid: boolean;
69
- };
70
- type SummaryBase = {
71
- errorCount: number;
72
- warnCount: number;
73
- testCount: number;
74
- };
75
- type FailureMessages = Record<string, string[]>;
76
- declare function getErrors(): FailureMessages;
77
- declare function getErrors(fieldName?: string): string[];
78
- declare function getWarnings(): FailureMessages;
79
- declare function getWarnings(fieldName?: string): string[];
80
- declare function getErrorsByGroup(groupName: string): FailureMessages;
81
- declare function getErrorsByGroup(groupName: string, fieldName: string): string[];
82
- declare function getWarningsByGroup(groupName: string): FailureMessages;
83
- declare function getWarningsByGroup(groupName: string, fieldName: string): string[];
84
- declare function hasErrors(fieldName?: string): boolean;
85
- declare function hasWarnings(fieldName?: string): boolean;
86
- declare function hasErrorsByGroup(groupName: string, fieldName?: string): boolean;
87
- declare function hasWarningsByGroup(groupName: string, fieldName?: string): boolean;
88
- declare function isValid(fieldName?: string): boolean;
89
- declare function isValidByGroup(groupName: string, fieldName?: string): boolean;
90
- type SuiteResult = ReturnType<typeof genTestsSummary> & {
91
- /**
92
- * Returns whether the suite as a whole is valid.
93
- * Determined if there are no errors, and if no
94
- * required fields are skipped.
95
- */
96
- isValid: typeof isValid;
97
- isValidByGroup: typeof isValidByGroup;
98
- hasErrors: typeof hasErrors;
99
- hasWarnings: typeof hasWarnings;
100
- getErrors: typeof getErrors;
101
- getWarnings: typeof getWarnings;
102
- hasErrorsByGroup: typeof hasErrorsByGroup;
103
- hasWarningsByGroup: typeof hasWarningsByGroup;
104
- getErrorsByGroup: typeof getErrorsByGroup;
105
- getWarningsByGroup: typeof getWarningsByGroup;
71
+ type CB = (...args: any[]) => any;
72
+ // eslint-disable-next-line max-lines-per-function, max-statements
73
+ declare function suiteSelectors(summary: SuiteSummary): SuiteSelectors;
74
+ interface SuiteSelectors {
75
+ getErrors(fieldName: string): string[];
76
+ getErrors(): FailureMessages;
77
+ getWarnings(): FailureMessages;
78
+ getWarnings(fieldName: string): string[];
79
+ getErrorsByGroup(groupName: string, fieldName: string): string[];
80
+ getErrorsByGroup(groupName: string): FailureMessages;
81
+ getWarningsByGroup(groupName: string): FailureMessages;
82
+ getWarningsByGroup(groupName: string, fieldName: string): string[];
83
+ hasErrors(fieldName?: string): boolean;
84
+ hasWarnings(fieldName?: string): boolean;
85
+ hasErrorsByGroup(groupName: string, fieldName?: string): boolean;
86
+ hasWarningsByGroup(groupName: string, fieldName?: string): boolean;
87
+ isValid(fieldName?: string): boolean;
88
+ isValidByGroup(groupName: string, fieldName?: string): boolean;
89
+ }
90
+ type SuiteResult = SuiteSummary & SuiteSelectors & {
91
+ suiteName: SuiteName;
106
92
  };
107
93
  type SuiteRunResult = SuiteResult & {
108
94
  done: Done;
@@ -136,8 +122,9 @@ type Suite<T extends CB> = {
136
122
  * });
137
123
  * });
138
124
  */
139
- declare function create<T extends CB>(suiteName: string, suiteCallback: T): Suite<T>;
125
+ declare function create<T extends CB>(suiteName: SuiteName, suiteCallback: T): Suite<T>;
140
126
  declare function create<T extends CB>(suiteCallback: T): Suite<T>;
127
+ type SuiteName = string | void;
141
128
  type IsolateCursor = {
142
129
  current: () => number;
143
130
  next: () => void;
@@ -182,7 +169,6 @@ type OptionalFields = Record<string, [
182
169
  rule: (() => boolean) | boolean,
183
170
  isApplied: boolean
184
171
  ]>;
185
- type SuiteName = string | void;
186
172
  type TestCallbacks = {
187
173
  fieldCallbacks: Record<string, Array<(res: SuiteResult) => void>>;
188
174
  doneCallbacks: Array<(res: SuiteResult) => void>;
@@ -219,7 +205,6 @@ type CTXType = {
219
205
  };
220
206
  emit: (event: string, ...args: any[]) => void;
221
207
  };
222
- summary?: SuiteSummary;
223
208
  };
224
209
  declare const context: typeof _default;
225
210
  /**
@@ -349,6 +334,6 @@ declare const test: typeof testBase & {
349
334
  * Sets a running test to warn only mode.
350
335
  */
351
336
  declare function warn(): void;
352
- declare const VERSION = "4.4.2-dev-ae93bf";
353
- export { test, create, each, only, skip, warn, group, optional, skipWhen, omitWhen, enforce, VERSION, context, include, eager };
337
+ declare const VERSION = "4.5.0-dev-9b46fb";
338
+ export { suiteSelectors, test, create, each, only, skip, warn, group, optional, skipWhen, omitWhen, enforce, VERSION, context, include, eager };
354
339
  export type { SuiteResult, SuiteRunResult, SuiteSummary, VestTest, Suite };