@opencrvs/toolkit 1.8.0-rc.f8e4107 → 1.8.0-rc.f8f94b8

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 (42) hide show
  1. package/dist/commons/api/router.d.ts +5905 -5314
  2. package/dist/commons/conditionals/conditionals.d.ts +7 -76
  3. package/dist/commons/conditionals/validate.d.ts +15 -6
  4. package/dist/commons/events/ActionConfig.d.ts +115347 -1728
  5. package/dist/commons/events/ActionDocument.d.ts +4824 -1375
  6. package/dist/commons/events/ActionInput.d.ts +3205 -1025
  7. package/dist/commons/events/ActionType.d.ts +9 -4
  8. package/dist/commons/events/AdvancedSearchConfig.d.ts +1190 -23
  9. package/dist/commons/events/CompositeFieldValue.d.ts +40 -9
  10. package/dist/commons/events/Constants.d.ts +3 -0
  11. package/dist/commons/events/CountryConfigQueryInput.d.ts +4132 -0
  12. package/dist/commons/events/CreatedAtLocation.d.ts +2 -0
  13. package/dist/commons/events/Draft.d.ts +290 -104
  14. package/dist/commons/events/EventConfig.d.ts +52547 -1394
  15. package/dist/commons/events/EventDocument.d.ts +2720 -913
  16. package/dist/commons/events/EventIndex.d.ts +1696 -239
  17. package/dist/commons/events/EventMetadata.d.ts +340 -45
  18. package/dist/commons/events/FieldConfig.d.ts +6362 -1159
  19. package/dist/commons/events/FieldType.d.ts +7 -3
  20. package/dist/commons/events/FieldTypeMapping.d.ts +154 -73
  21. package/dist/commons/events/FieldValue.d.ts +90 -20
  22. package/dist/commons/events/FormConfig.d.ts +53892 -510
  23. package/dist/commons/events/PageConfig.d.ts +13367 -209
  24. package/dist/commons/events/SummaryConfig.d.ts +93 -42
  25. package/dist/commons/events/User.d.ts +34 -2
  26. package/dist/commons/events/WorkqueueColumnConfig.d.ts +53 -0
  27. package/dist/commons/events/WorkqueueConfig.d.ts +8116 -20
  28. package/dist/commons/events/defineConfig.d.ts +8255 -86
  29. package/dist/commons/events/event.d.ts +46 -0
  30. package/dist/commons/events/field.d.ts +94 -0
  31. package/dist/commons/events/index.d.ts +8 -0
  32. package/dist/commons/events/scopes.d.ts +46 -0
  33. package/dist/commons/events/serializer.d.ts +2 -0
  34. package/dist/commons/events/test.utils.d.ts +206 -90
  35. package/dist/commons/events/transactions.d.ts +1 -1
  36. package/dist/commons/events/utils.d.ts +14940 -85
  37. package/dist/commons/events/workqueueDefaultColumns.d.ts +3 -0
  38. package/dist/conditionals/index.js +64 -102
  39. package/dist/events/index.js +4576 -1838
  40. package/dist/scopes/index.d.ts +247 -1
  41. package/dist/scopes/index.js +231 -1
  42. package/package.json +4 -3
@@ -1,10 +1,8 @@
1
1
  import { EventDocument } from '../events/EventDocument';
2
2
  import { EventState } from '../events/ActionDocument';
3
3
  import { ITokenPayload as TokenPayload, Scope } from '../authentication';
4
- import { ActionType } from '../events/ActionType';
5
4
  import { PartialSchema as AjvJSONSchemaType } from 'ajv/dist/types/json-schema';
6
- import { SelectOption } from '../events/FieldConfig';
7
- import { MetadataField } from '../utils';
5
+ import { userSerializer } from '../events/serializers/user/serializer';
8
6
  /** @knipignore */
9
7
  export type JSONSchema = {
10
8
  readonly __nominal__type: 'JSONSchema';
@@ -60,19 +58,11 @@ export declare function never(): JSONSchema;
60
58
  *
61
59
  * Generate conditional rules for user.
62
60
  */
63
- export declare const user: {
61
+ export declare const user: typeof userSerializer & {
64
62
  hasScope: (scope: Scope) => JSONSchema;
65
63
  };
66
- /**
67
- *
68
- * Generate conditional rules for event.
69
- */
70
- export declare const event: {
71
- hasAction: (action: ActionType) => JSONSchema;
72
- };
73
64
  type FieldReference = {
74
- _fieldId: string;
75
- [key: string]: unknown;
65
+ $$field: string;
76
66
  };
77
67
  /**
78
68
  * Generate conditional rules for a form field.
@@ -82,11 +72,11 @@ type FieldReference = {
82
72
  * and(field('foo').isEqualTo('bar'), field('baz').isUndefined())
83
73
  *
84
74
  */
85
- export declare function field(fieldId: string): {
75
+ export declare function createFieldConditionals(fieldId: string): {
86
76
  /**
87
77
  * @private Internal property used for field reference tracking.
88
78
  */
89
- _fieldId: string;
79
+ $$field: string;
90
80
  isAfter: () => {
91
81
  days: (days: number) => {
92
82
  inPast: () => JSONSchema;
@@ -123,69 +113,10 @@ export declare function field(fieldId: string): {
123
113
  */
124
114
  matches: (pattern: string) => JSONSchema;
125
115
  isBetween: (min: number, max: number) => JSONSchema;
126
- /**
127
- * Creates a range configuration for the specified field.
128
- *
129
- * @returns An object containing the field ID and a configuration object with a type of 'RANGE'.
130
- *
131
- * @example field('age').range()
132
- * // {
133
- * // fieldId: 'age',
134
- * // config: { type: 'RANGE' }
135
- * // }
136
- */
137
- range: () => {
138
- fieldId: string;
139
- config: {
140
- type: "RANGE";
141
- };
142
- };
143
- /**
144
- * Creates a configuration for exact matching of the specified field.
145
- * @returns An object containing the field ID and a configuration object with a type of 'EXACT'.
146
- * @example field('dob').exact()
147
- * // {
148
- * // fieldId: 'dob',
149
- * // config: { type: 'EXACT' }
150
- * // }
151
- */
152
- exact: () => {
153
- fieldId: string;
154
- config: {
155
- type: "EXACT";
156
- };
157
- };
158
- /**
159
- * Creates a configuration for fuzzy matching of the specified field.
160
- * @returns An object containing the field ID and a configuration object with a type of 'EXACT'.
161
- * @example field('name').fuzzy()
162
- * // {
163
- * // fieldId: 'name',
164
- * // config: { type: 'FUZZY' }
165
- * // }
166
- */
167
- fuzzy: () => {
116
+ getId: () => {
168
117
  fieldId: string;
169
- config: {
170
- type: "FUZZY";
171
- };
172
- };
173
- };
174
- /**
175
- * @param fieldId - The field ID condition is applied to.
176
- * @param options - The options for the select field.
177
- * @returns An object containing the configuration for the searching the metadata fields of an event.
178
- * @example eventField('status', [{ label: 'Option 1', value: '1' }])
179
- */
180
- export declare function eventField(fieldId: MetadataField, options?: SelectOption[]): {
181
- fieldId: "status" | "trackingId";
182
- options: {
183
- value: string;
184
- label: import("..").TranslationConfig;
185
- }[] | undefined;
186
- config: {
187
- type: "EXACT";
188
118
  };
119
+ object: (options: Record<string, any>) => JSONSchema;
189
120
  };
190
121
  export {};
191
122
  //# sourceMappingURL=conditionals.d.ts.map
@@ -3,7 +3,10 @@ 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;
9
12
  export declare function isFieldDisplayedOnReview(field: FieldConfig, form: ActionUpdate | EventState): boolean;
@@ -33,6 +36,16 @@ export declare const errorMessages: {
33
36
  description: string;
34
37
  id: string;
35
38
  };
39
+ unexpectedField: {
40
+ defaultMessage: string;
41
+ description: string;
42
+ id: string;
43
+ };
44
+ correctionNotAllowed: {
45
+ defaultMessage: string;
46
+ description: string;
47
+ id: string;
48
+ };
36
49
  };
37
50
  /**
38
51
  * Custom error map for Zod to override the default error messages in intl-formik format.
@@ -55,12 +68,7 @@ export declare function validateFieldInput({ field, value }: {
55
68
  }): {
56
69
  message: TranslationConfig;
57
70
  }[];
58
- /**
59
- * Gets applicable validation errors based on its type and custom validators.
60
- *
61
- * @returns an array of error messages for the field
62
- */
63
- export declare function getFieldValidationErrors({ field, values }: {
71
+ export declare function runFieldValidations({ field, values }: {
64
72
  field: FieldConfig;
65
73
  values: ActionUpdate;
66
74
  }): {
@@ -68,4 +76,5 @@ export declare function getFieldValidationErrors({ field, values }: {
68
76
  message: TranslationConfig;
69
77
  }[];
70
78
  };
79
+ export declare function getValidatorsForField(fieldId: FieldConfig['id'], validations: NonNullable<FieldConfig['validation']>): NonNullable<FieldConfig['validation']>;
71
80
  //# sourceMappingURL=validate.d.ts.map