@opencrvs/toolkit 1.8.0-rc.fe799b0 → 1.8.0-rc.fe87a15

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 (49) hide show
  1. package/README.md +1 -1
  2. package/dist/commons/api/router.d.ts +15282 -10293
  3. package/dist/commons/conditionals/conditionals.d.ts +33 -6
  4. package/dist/commons/conditionals/validate-address.test.d.ts +2 -0
  5. package/dist/commons/conditionals/validate.d.ts +39 -17
  6. package/dist/commons/conditionals/validate.test.d.ts +2 -0
  7. package/dist/commons/events/ActionConfig.d.ts +104405 -2019
  8. package/dist/commons/events/ActionDocument.d.ts +10075 -381
  9. package/dist/commons/events/ActionInput.d.ts +5486 -633
  10. package/dist/commons/events/ActionType.d.ts +27 -12
  11. package/dist/commons/events/AdvancedSearchConfig.d.ts +957 -22
  12. package/dist/commons/events/CompositeFieldValue.d.ts +155 -2
  13. package/dist/commons/events/Conditional.d.ts +21 -5
  14. package/dist/commons/events/Constants.d.ts +2 -0
  15. package/dist/commons/events/CountryConfigQueryInput.d.ts +2982 -0
  16. package/dist/commons/events/CreatedAtLocation.d.ts +2 -0
  17. package/dist/commons/events/Draft.d.ts +384 -66
  18. package/dist/commons/events/EventConfig.d.ts +50285 -1826
  19. package/dist/commons/events/EventConfigInput.d.ts +6 -3
  20. package/dist/commons/events/EventDocument.d.ts +3738 -522
  21. package/dist/commons/events/EventIndex.d.ts +1344 -15
  22. package/dist/commons/events/EventMetadata.d.ts +302 -13
  23. package/dist/commons/events/FieldConfig.d.ts +4831 -806
  24. package/dist/commons/events/FieldType.d.ts +7 -2
  25. package/dist/commons/events/FieldTypeMapping.d.ts +169 -8
  26. package/dist/commons/events/FieldValue.d.ts +84 -5
  27. package/dist/commons/events/FormConfig.d.ts +44104 -73
  28. package/dist/commons/events/PageConfig.d.ts +11061 -0
  29. package/dist/commons/events/SummaryConfig.d.ts +95 -39
  30. package/dist/commons/events/TemplateConfig.d.ts +38 -0
  31. package/dist/commons/events/User.d.ts +31 -2
  32. package/dist/commons/events/WorkqueueColumnConfig.d.ts +53 -0
  33. package/dist/commons/events/WorkqueueConfig.d.ts +4525 -20
  34. package/dist/commons/events/defineConfig.d.ts +8087 -229
  35. package/dist/commons/events/event.d.ts +54 -0
  36. package/dist/commons/events/field.d.ts +73 -0
  37. package/dist/commons/events/index.d.ts +10 -1
  38. package/dist/commons/events/scopes.d.ts +45 -0
  39. package/dist/commons/events/serializer.d.ts +2 -0
  40. package/dist/commons/events/test.utils.d.ts +154 -243
  41. package/dist/commons/events/transactions.d.ts +1 -1
  42. package/dist/commons/events/utils.d.ts +3831 -69
  43. package/dist/commons/events/utils.test.d.ts +2 -0
  44. package/dist/commons/events/workqueueDefaultColumns.d.ts +3 -0
  45. package/dist/conditionals/index.js +217 -109
  46. package/dist/events/index.js +4558 -1865
  47. package/dist/scopes/index.d.ts +158 -1
  48. package/dist/scopes/index.js +152 -1
  49. package/package.json +3 -2
@@ -3,11 +3,13 @@ import { EventState } from '../events/ActionDocument';
3
3
  import { ITokenPayload as TokenPayload, Scope } from '../authentication';
4
4
  import { ActionType } from '../events/ActionType';
5
5
  import { PartialSchema as AjvJSONSchemaType } from 'ajv/dist/types/json-schema';
6
+ import { userSerializer } from '../events/serializers/user/serializer';
6
7
  /** @knipignore */
7
8
  export type JSONSchema = {
8
9
  readonly __nominal__type: 'JSONSchema';
9
10
  };
10
11
  export declare function defineConditional(schema: any): JSONSchema;
12
+ export declare function defineFormConditional(schema: Record<string, unknown>): JSONSchema;
11
13
  export type UserConditionalParameters = {
12
14
  $now: string;
13
15
  $user: TokenPayload;
@@ -47,20 +49,33 @@ export declare function or(...conditions: AjvJSONSchema[]): JSONSchema;
47
49
  * @example not(field('foo').isEqualTo('bar'))
48
50
  */
49
51
  export declare function not(condition: AjvJSONSchema): JSONSchema;
52
+ /**
53
+ * Returns an JSON Schema object, which is treated as always invalid.
54
+ *
55
+ * @returns {JSONSchema} An schema object that always evaluates to false.
56
+ */
57
+ export declare function never(): JSONSchema;
50
58
  /**
51
59
  *
52
60
  * Generate conditional rules for user.
53
61
  */
54
- export declare const user: {
62
+ export declare const user: typeof userSerializer & {
55
63
  hasScope: (scope: Scope) => JSONSchema;
56
64
  };
57
65
  /**
58
66
  *
59
67
  * Generate conditional rules for event.
60
68
  */
61
- export declare const event: {
69
+ export declare function createEventConditionals(): {
70
+ /**
71
+ * Checks if the event contains a specific action type.
72
+ * @param action - The action type to check for.
73
+ */
62
74
  hasAction: (action: ActionType) => JSONSchema;
63
75
  };
76
+ type FieldReference = {
77
+ $$field: string;
78
+ };
64
79
  /**
65
80
  * Generate conditional rules for a form field.
66
81
  *
@@ -69,13 +84,17 @@ export declare const event: {
69
84
  * and(field('foo').isEqualTo('bar'), field('baz').isUndefined())
70
85
  *
71
86
  */
72
- export declare function field(fieldId: string): {
87
+ export declare function createFieldConditionals(fieldId: string): {
88
+ /**
89
+ * @private Internal property used for field reference tracking.
90
+ */
91
+ $$field: string;
73
92
  isAfter: () => {
74
93
  days: (days: number) => {
75
94
  inPast: () => JSONSchema;
76
95
  inFuture: () => JSONSchema;
77
96
  };
78
- date: (date: string) => JSONSchema;
97
+ date: (date: string | FieldReference) => JSONSchema;
79
98
  now: () => JSONSchema;
80
99
  };
81
100
  isBefore: () => {
@@ -83,10 +102,10 @@ export declare function field(fieldId: string): {
83
102
  inPast: () => JSONSchema;
84
103
  inFuture: () => JSONSchema;
85
104
  };
86
- date: (date: string) => JSONSchema;
105
+ date: (date: string | FieldReference) => JSONSchema;
87
106
  now: () => JSONSchema;
88
107
  };
89
- isEqualTo: (value: string | boolean) => JSONSchema;
108
+ isEqualTo: (value: string | boolean | FieldReference) => JSONSchema;
90
109
  /**
91
110
  * Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
92
111
  * @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
@@ -98,6 +117,14 @@ export declare function field(fieldId: string): {
98
117
  isFalsy: () => JSONSchema;
99
118
  isUndefined: () => JSONSchema;
100
119
  inArray: (values: string[]) => JSONSchema;
120
+ isValidEnglishName: () => JSONSchema;
121
+ /**
122
+ * Checks if the field value matches a given regular expression pattern.
123
+ * @param pattern - The regular expression pattern to match the field value against.
124
+ * @returns A JSONSchema conditional that validates the field value against the pattern.
125
+ */
126
+ matches: (pattern: string) => JSONSchema;
127
+ isBetween: (min: number, max: number) => JSONSchema;
101
128
  };
102
129
  export {};
103
130
  //# sourceMappingURL=conditionals.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=validate-address.test.d.ts.map
@@ -3,9 +3,40 @@ import { EventState, ActionUpdate } from '../events/ActionDocument';
3
3
  import { FieldConfig } from '../events/FieldConfig';
4
4
  import { FieldUpdateValue } from '../events/FieldValue';
5
5
  import { TranslationConfig } from '../events/TranslationConfig';
6
+ import { FieldConditional } from '../events/Conditional';
6
7
  export declare function validate(schema: JSONSchema, data: ConditionalParameters): boolean;
8
+ export declare function isConditionMet(conditional: JSONSchema, values: Record<string, unknown>): boolean;
9
+ export declare function areConditionsMet(conditions: FieldConditional[], values: Record<string, unknown>): boolean;
7
10
  export declare function isFieldVisible(field: FieldConfig, form: ActionUpdate | EventState): boolean;
8
11
  export declare function isFieldEnabled(field: FieldConfig, form: ActionUpdate | EventState): boolean;
12
+ export declare function isFieldDisplayedOnReview(field: FieldConfig, form: ActionUpdate | EventState): boolean;
13
+ export declare const errorMessages: {
14
+ hiddenField: {
15
+ id: string;
16
+ defaultMessage: string;
17
+ description: string;
18
+ };
19
+ invalidDate: {
20
+ defaultMessage: string;
21
+ description: string;
22
+ id: string;
23
+ };
24
+ invalidEmail: {
25
+ defaultMessage: string;
26
+ description: string;
27
+ id: string;
28
+ };
29
+ requiredField: {
30
+ defaultMessage: string;
31
+ description: string;
32
+ id: string;
33
+ };
34
+ invalidInput: {
35
+ defaultMessage: string;
36
+ description: string;
37
+ id: string;
38
+ };
39
+ };
9
40
  /**
10
41
  * Custom error map for Zod to override the default error messages in intl-formik format.
11
42
  */
@@ -16,23 +47,6 @@ export type CustomZodToIntlErrorMap = {
16
47
  message: TranslationConfig;
17
48
  };
18
49
  };
19
- /**
20
- * Checks if a field has validation errors based on its type and custom conditionals.
21
- *
22
- * @returns an array of error messages for the field
23
- */
24
- export declare function getFieldValidationErrors({ field, values }: {
25
- field: FieldConfig;
26
- values: ActionUpdate;
27
- }): {
28
- errors: {
29
- message: {
30
- id: string;
31
- defaultMessage: string;
32
- description: string;
33
- };
34
- }[];
35
- };
36
50
  /**
37
51
  * Validates primitive fields defined by the FieldConfig type.
38
52
  * e.g. email is proper format, date is a valid date, etc.
@@ -44,4 +58,12 @@ export declare function validateFieldInput({ field, value }: {
44
58
  }): {
45
59
  message: TranslationConfig;
46
60
  }[];
61
+ export declare function runFieldValidations({ field, values }: {
62
+ field: FieldConfig;
63
+ values: ActionUpdate;
64
+ }): {
65
+ errors: {
66
+ message: TranslationConfig;
67
+ }[];
68
+ };
47
69
  //# sourceMappingURL=validate.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=validate.test.d.ts.map