@opencrvs/toolkit 1.8.0-rc.f876361 → 1.8.0-rc.f89fbcb

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 (45) hide show
  1. package/dist/commons/api/router.d.ts +8398 -831
  2. package/dist/commons/conditionals/conditionals.d.ts +26 -11
  3. package/dist/commons/conditionals/validate.d.ts +18 -17
  4. package/dist/commons/events/ActionConfig.d.ts +120018 -1729
  5. package/dist/commons/events/ActionDocument.d.ts +2581 -554
  6. package/dist/commons/events/ActionInput.d.ts +2674 -499
  7. package/dist/commons/events/ActionType.d.ts +9 -3
  8. package/dist/commons/events/AdvancedSearchConfig.d.ts +1255 -22
  9. package/dist/commons/events/CompositeFieldValue.d.ts +31 -0
  10. package/dist/commons/events/Conditional.d.ts +21 -5
  11. package/dist/commons/events/Constants.d.ts +3 -0
  12. package/dist/commons/events/CountryConfigQueryInput.d.ts +3730 -0
  13. package/dist/commons/events/CreatedAtLocation.d.ts +2 -0
  14. package/dist/commons/events/Draft.d.ts +172 -46
  15. package/dist/commons/events/EventConfig.d.ts +57845 -1354
  16. package/dist/commons/events/EventDocument.d.ts +1635 -391
  17. package/dist/commons/events/EventIndex.d.ts +2007 -27
  18. package/dist/commons/events/EventMetadata.d.ts +343 -45
  19. package/dist/commons/events/FieldConfig.d.ts +5780 -1066
  20. package/dist/commons/events/FieldType.d.ts +6 -3
  21. package/dist/commons/events/FieldTypeMapping.d.ts +103 -54
  22. package/dist/commons/events/FieldValue.d.ts +49 -8
  23. package/dist/commons/events/FormConfig.d.ts +50248 -514
  24. package/dist/commons/events/PageConfig.d.ts +12472 -234
  25. package/dist/commons/events/SummaryConfig.d.ts +93 -42
  26. package/dist/commons/events/TemplateConfig.d.ts +5 -5
  27. package/dist/commons/events/User.d.ts +31 -2
  28. package/dist/commons/events/WorkqueueColumnConfig.d.ts +53 -0
  29. package/dist/commons/events/WorkqueueConfig.d.ts +7300 -20
  30. package/dist/commons/events/defineConfig.d.ts +9289 -58
  31. package/dist/commons/events/event.d.ts +54 -0
  32. package/dist/commons/events/field.d.ts +94 -0
  33. package/dist/commons/events/index.d.ts +8 -0
  34. package/dist/commons/events/scopes.d.ts +44 -0
  35. package/dist/commons/events/serializer.d.ts +2 -0
  36. package/dist/commons/events/test.utils.d.ts +157 -157
  37. package/dist/commons/events/transactions.d.ts +1 -1
  38. package/dist/commons/events/utils.d.ts +13799 -78
  39. package/dist/commons/events/utils.test.d.ts +2 -0
  40. package/dist/commons/events/workqueueDefaultColumns.d.ts +3 -0
  41. package/dist/conditionals/index.js +208 -185
  42. package/dist/events/index.js +4843 -2050
  43. package/dist/scopes/index.d.ts +161 -1
  44. package/dist/scopes/index.js +202 -1
  45. package/package.json +4 -3
@@ -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,17 +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): {
73
88
  /**
74
89
  * @private Internal property used for field reference tracking.
75
90
  */
76
- _returning: string;
91
+ $$field: string;
77
92
  isAfter: () => {
78
93
  days: (days: number) => {
79
94
  inPast: () => JSONSchema;
80
95
  inFuture: () => JSONSchema;
81
96
  };
82
- date: (date: string) => JSONSchema;
97
+ date: (date: string | FieldReference) => JSONSchema;
83
98
  now: () => JSONSchema;
84
99
  };
85
100
  isBefore: () => {
@@ -87,13 +102,10 @@ export declare function field(fieldId: string): {
87
102
  inPast: () => JSONSchema;
88
103
  inFuture: () => JSONSchema;
89
104
  };
90
- date: (date: string) => JSONSchema;
105
+ date: (date: string | FieldReference) => JSONSchema;
91
106
  now: () => JSONSchema;
92
107
  };
93
- isEqualTo: (value: string | boolean | {
94
- _returning: string;
95
- [key: string]: unknown;
96
- }) => JSONSchema;
108
+ isEqualTo: (value: string | boolean | FieldReference) => JSONSchema;
97
109
  /**
98
110
  * Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
99
111
  * @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
@@ -106,7 +118,6 @@ export declare function field(fieldId: string): {
106
118
  isUndefined: () => JSONSchema;
107
119
  inArray: (values: string[]) => JSONSchema;
108
120
  isValidEnglishName: () => JSONSchema;
109
- isValidNationalId: () => JSONSchema;
110
121
  /**
111
122
  * Checks if the field value matches a given regular expression pattern.
112
123
  * @param pattern - The regular expression pattern to match the field value against.
@@ -114,6 +125,10 @@ export declare function field(fieldId: string): {
114
125
  */
115
126
  matches: (pattern: string) => JSONSchema;
116
127
  isBetween: (min: number, max: number) => JSONSchema;
128
+ getId: () => {
129
+ fieldId: string;
130
+ };
131
+ object: (options: Record<string, any>) => JSONSchema;
117
132
  };
118
133
  export {};
119
134
  //# sourceMappingURL=conditionals.d.ts.map
@@ -3,9 +3,13 @@ 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;
9
13
  export declare const errorMessages: {
10
14
  hiddenField: {
11
15
  id: string;
@@ -32,6 +36,11 @@ export declare const errorMessages: {
32
36
  description: string;
33
37
  id: string;
34
38
  };
39
+ unexpectedField: {
40
+ defaultMessage: string;
41
+ description: string;
42
+ id: string;
43
+ };
35
44
  };
36
45
  /**
37
46
  * Custom error map for Zod to override the default error messages in intl-formik format.
@@ -43,23 +52,6 @@ export type CustomZodToIntlErrorMap = {
43
52
  message: TranslationConfig;
44
53
  };
45
54
  };
46
- /**
47
- * Checks if a field has validation errors based on its type and custom conditionals.
48
- *
49
- * @returns an array of error messages for the field
50
- */
51
- export declare function getFieldValidationErrors({ field, values }: {
52
- field: FieldConfig;
53
- values: ActionUpdate;
54
- }): {
55
- errors: {
56
- message: {
57
- id: string;
58
- defaultMessage: string;
59
- description: string;
60
- };
61
- }[];
62
- };
63
55
  /**
64
56
  * Validates primitive fields defined by the FieldConfig type.
65
57
  * e.g. email is proper format, date is a valid date, etc.
@@ -71,4 +63,13 @@ export declare function validateFieldInput({ field, value }: {
71
63
  }): {
72
64
  message: TranslationConfig;
73
65
  }[];
66
+ export declare function runFieldValidations({ field, values }: {
67
+ field: FieldConfig;
68
+ values: ActionUpdate;
69
+ }): {
70
+ errors: {
71
+ message: TranslationConfig;
72
+ }[];
73
+ };
74
+ export declare function getValidatorsForField(fieldId: FieldConfig['id'], validations: NonNullable<FieldConfig['validation']>): NonNullable<FieldConfig['validation']>;
74
75
  //# sourceMappingURL=validate.d.ts.map