@opencrvs/toolkit 2.2.0-rc.045257f → 2.2.0-rc.19ec10b

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 (84) hide show
  1. package/build.sh +7 -2
  2. package/dist/application-config/index.js +16 -5
  3. package/dist/authentication/index.d.ts +1 -1
  4. package/dist/authentication/index.js +4 -8
  5. package/dist/cli.js +927 -356
  6. package/dist/commons/api/router.d.ts +17 -4
  7. package/dist/commons/application-config/index.d.ts +1 -1
  8. package/dist/commons/conditionals/conditionals.d.ts +55 -4
  9. package/dist/commons/conditionals/validate.d.ts +1 -1
  10. package/dist/commons/events/ActionStatus.d.ts +2 -2
  11. package/dist/commons/events/ActionType.d.ts +2 -0
  12. package/dist/commons/events/AdvancedSearchConfig.d.ts +3 -0
  13. package/dist/commons/events/Draft.d.ts +34 -1
  14. package/dist/commons/events/EventConfig.d.ts +446 -0
  15. package/dist/commons/events/EventDocument.d.ts +2 -0
  16. package/dist/commons/events/EventIndex.d.ts +1 -0
  17. package/dist/commons/events/EventInput.d.ts +1 -0
  18. package/dist/commons/events/EventMetadata.d.ts +1 -0
  19. package/dist/commons/events/FieldTypeMapping.d.ts +19 -19
  20. package/dist/commons/events/PlainDate.d.ts +5 -0
  21. package/dist/commons/events/defineConfig.d.ts +7 -2
  22. package/dist/commons/events/event.d.ts +20 -1
  23. package/dist/commons/events/field.d.ts +37 -0
  24. package/dist/commons/events/locations.d.ts +1 -1
  25. package/dist/commons/events/scopes.d.ts +2 -1
  26. package/dist/commons/events/state/index.d.ts +1 -0
  27. package/dist/commons/events/test.utils.d.ts +59 -6
  28. package/dist/commons/events/utils.d.ts +28 -2
  29. package/dist/commons/users/Role.d.ts +23 -0
  30. package/dist/commons/users/User.d.ts +263 -0
  31. package/dist/commons/users/authentication.d.ts +67 -0
  32. package/dist/commons/users/index.d.ts +5 -0
  33. package/dist/commons/users/roleValidations.d.ts +15 -0
  34. package/dist/commons/users/scopes.d.ts +1402 -0
  35. package/dist/commons/users/userReferences.d.ts +176 -0
  36. package/dist/conditionals/index.js +13 -5
  37. package/dist/environment/custom-types.d.ts +1 -0
  38. package/dist/environment/custom-types.d.ts.map +1 -1
  39. package/dist/environment/derived-variables.d.ts +8 -0
  40. package/dist/environment/derived-variables.d.ts.map +1 -1
  41. package/dist/environment/derived-variables.js +9 -0
  42. package/dist/environment/questions.d.ts +42 -9
  43. package/dist/environment/questions.d.ts.map +1 -1
  44. package/dist/environment/questions.js +70 -47
  45. package/dist/environment/registry.d.ts +15 -0
  46. package/dist/environment/registry.d.ts.map +1 -0
  47. package/dist/environment/registry.js +112 -0
  48. package/dist/environment/setup-environment.d.ts.map +1 -1
  49. package/dist/environment/setup-environment.js +104 -23
  50. package/dist/events/index.js +1627 -1100
  51. package/dist/migrations/add-notify-config.d.ts +40 -0
  52. package/dist/migrations/add-notify-config.d.ts.map +1 -0
  53. package/dist/migrations/add-notify-config.js +249 -0
  54. package/dist/migrations/index.d.ts.map +1 -1
  55. package/dist/migrations/index.js +602 -143
  56. package/dist/migrations/move-declaration-to-declare-action.d.ts.map +1 -1
  57. package/dist/migrations/move-declaration-to-declare-action.js +27 -144
  58. package/dist/migrations/read-declaration-through-helper.d.ts.map +1 -1
  59. package/dist/migrations/read-declaration-through-helper.js +3 -61
  60. package/dist/migrations/resolve-versioned-event-config.d.ts +56 -0
  61. package/dist/migrations/resolve-versioned-event-config.d.ts.map +1 -0
  62. package/dist/migrations/resolve-versioned-event-config.js +353 -0
  63. package/dist/migrations/utils.d.ts +61 -0
  64. package/dist/migrations/utils.d.ts.map +1 -0
  65. package/dist/migrations/utils.js +218 -0
  66. package/dist/notification/index.js +707 -119
  67. package/dist/roles/index.d.ts +2 -0
  68. package/dist/roles/index.d.ts.map +1 -0
  69. package/dist/roles/index.js +730 -0
  70. package/dist/scopes/index.d.ts +0 -10
  71. package/dist/scopes/index.js +3 -7
  72. package/dist/templates/charts-values/dependencies/values.yaml +5 -2
  73. package/dist/templates/charts-values/opencrvs-services/values.yaml +2 -5
  74. package/dist/verify/endpoints.d.ts +11 -0
  75. package/dist/verify/endpoints.d.ts.map +1 -1
  76. package/dist/verify/endpoints.js +21 -27
  77. package/opencrvs-toolkit-2.2.0-rc.19ec10b.tgz +0 -0
  78. package/package.json +4 -2
  79. package/tsconfig.build.tsbuildinfo +1 -1
  80. package/tsconfig.json +3 -5
  81. package/dist/environment/dockerhub.d.ts +0 -15
  82. package/dist/environment/dockerhub.d.ts.map +0 -1
  83. package/dist/environment/dockerhub.js +0 -104
  84. package/opencrvs-toolkit-2.2.0-rc.045257f.tgz +0 -0
@@ -9,6 +9,7 @@ import { FlagConfig } from './Flag';
9
9
  import type { JSONSchema } from '../conditionals/conditionals';
10
10
  import { AvailableIcons } from '../icons';
11
11
  import { ActionType } from './ActionType';
12
+ import { PlainDate } from './PlainDate';
12
13
  export declare const EventFieldReference: z.ZodObject<{
13
14
  $$event: z.ZodEnum<{
14
15
  createdAt: "createdAt";
@@ -65,6 +66,451 @@ export type EventConfigInput = Omit<EventConfigSchemaInput, 'actions'> & {
65
66
  declaration?: DeclarationFormConfigInput;
66
67
  })>;
67
68
  };
69
+ /**
70
+ * Input accepted by `defineConfig` for one version of an event.
71
+ * `declaration` lives only on the DECLARE action.
72
+ */
73
+ export type EventConfigVersionInput = Omit<EventConfigSchemaInput, EventLevelField> & {
74
+ /** Identifier of the version, unique within the event (e.g. "birth-v2"). */
75
+ id: string;
76
+ /** Name of the version, which the UI shows wherever it names the version. For example, `{event.configVersionLabel}` in the event summary. */
77
+ label: TranslationConfig;
78
+ /** Date (YYYY-MM-DD) from which this version is effective. Without one, effective from the beginning of time. */
79
+ effectiveFrom?: string;
80
+ };
81
+ /**
82
+ * Input accepted by `defineConfig` for an event with several versions.
83
+ * `id`, `label` and `advancedSearch` are shared by every version.
84
+ */
85
+ export type VersionedEventConfigInput = Pick<EventConfigInput, EventLevelField> & {
86
+ versions: EventConfigVersionInput[];
87
+ };
88
+ /** Fields shared by every version of an event. */
89
+ declare const eventLevelFields: {
90
+ id: z.ZodString;
91
+ label: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, z.core.$strip>;
92
+ advancedSearch: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
93
+ title: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, z.core.$strip>;
94
+ fields: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
95
+ config: z.ZodObject<{
96
+ type: z.ZodEnum<{
97
+ exact: "exact";
98
+ fuzzy: "fuzzy";
99
+ range: "range";
100
+ within: "within";
101
+ }>;
102
+ searchFields: z.ZodOptional<z.ZodArray<z.ZodString>>;
103
+ }, z.core.$strip>;
104
+ type: z.ZodOptional<z.ZodEnum<{
105
+ readonly NAME: 'NAME';
106
+ readonly PHONE: 'PHONE';
107
+ readonly ID: 'ID';
108
+ readonly ADDRESS: 'ADDRESS';
109
+ readonly TEXT: 'TEXT';
110
+ readonly NUMBER: 'NUMBER';
111
+ readonly NUMBER_WITH_UNIT: 'NUMBER_WITH_UNIT';
112
+ readonly TEXTAREA: 'TEXTAREA';
113
+ readonly EMAIL: 'EMAIL';
114
+ readonly DATE: 'DATE';
115
+ readonly AGE: 'AGE';
116
+ readonly DATE_RANGE: 'DATE_RANGE';
117
+ readonly SELECT_DATE_RANGE: 'SELECT_DATE_RANGE';
118
+ readonly TIME: 'TIME';
119
+ readonly IMAGE_VIEW: 'IMAGE_VIEW';
120
+ readonly PARAGRAPH: 'PARAGRAPH';
121
+ readonly HEADING: 'HEADING';
122
+ readonly PAGE_HEADER: 'PAGE_HEADER';
123
+ readonly RADIO_GROUP: 'RADIO_GROUP';
124
+ readonly FIELD_GROUP: 'FIELD_GROUP';
125
+ readonly FILE: 'FILE';
126
+ readonly FILE_WITH_OPTIONS: 'FILE_WITH_OPTIONS';
127
+ readonly BULLET_LIST: 'BULLET_LIST';
128
+ readonly CHECKBOX: 'CHECKBOX';
129
+ readonly SELECT: 'SELECT';
130
+ readonly COUNTRY: 'COUNTRY';
131
+ readonly LOCATION: 'LOCATION';
132
+ readonly DIVIDER: 'DIVIDER';
133
+ readonly ADMINISTRATIVE_AREA: 'ADMINISTRATIVE_AREA';
134
+ readonly FACILITY: 'FACILITY';
135
+ readonly OFFICE: 'OFFICE';
136
+ readonly SIGNATURE: 'SIGNATURE';
137
+ readonly DATA: 'DATA';
138
+ readonly BUTTON: 'BUTTON';
139
+ readonly AUTOCOMPLETE: 'AUTOCOMPLETE';
140
+ readonly SEARCH: 'SEARCH';
141
+ readonly ALPHA_PRINT_BUTTON: 'ALPHA_PRINT_BUTTON';
142
+ readonly HTTP: 'HTTP';
143
+ readonly LINK_BUTTON: 'LINK_BUTTON';
144
+ readonly VERIFICATION_STATUS: 'VERIFICATION_STATUS';
145
+ readonly QUERY_PARAM_READER: 'QUERY_PARAM_READER';
146
+ readonly QR_READER: 'QR_READER';
147
+ readonly ID_READER: 'ID_READER';
148
+ readonly LOADER: 'LOADER';
149
+ readonly ALPHA_HIDDEN: 'ALPHA_HIDDEN';
150
+ readonly USER_ROLE: 'USER_ROLE';
151
+ readonly _EXPERIMENTAL_CUSTOM: 'CUSTOM';
152
+ }>>;
153
+ label: z.ZodOptional<z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, z.core.$strip>>;
154
+ options: z.ZodOptional<z.ZodArray<z.ZodObject<{
155
+ value: z.ZodString;
156
+ label: z.ZodUnion<readonly [z.ZodString, z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, z.core.$strip>]>;
157
+ conditionals: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
158
+ type: z.ZodLiteral<"SHOW">;
159
+ conditional: z.ZodAny;
160
+ }, z.core.$strip>, z.ZodObject<{
161
+ type: z.ZodLiteral<"ENABLE">;
162
+ conditional: z.ZodAny;
163
+ }, z.core.$strip>], "type">>>>;
164
+ }, z.core.$strip>>>;
165
+ searchCriteriaLabelPrefix: z.ZodOptional<z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, z.core.$strip>>;
166
+ conditionals: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
167
+ type: z.ZodLiteral<"SHOW">;
168
+ conditional: z.ZodAny;
169
+ }, z.core.$strip>, z.ZodObject<{
170
+ type: z.ZodLiteral<"ENABLE">;
171
+ conditional: z.ZodAny;
172
+ }, z.core.$strip>, z.ZodObject<{
173
+ type: z.ZodLiteral<"DISPLAY_ON_REVIEW">;
174
+ conditional: z.ZodAny;
175
+ }, z.core.$strip>], "type">>>;
176
+ validations: z.ZodOptional<z.ZodArray<z.ZodObject<{
177
+ validator: z.ZodAny;
178
+ message: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, z.core.$strip>;
179
+ }, z.core.$strip>>>;
180
+ allowedLocations: z.ZodOptional<z.ZodObject<{
181
+ $jurisdiction: z.ZodUnion<[z.ZodEnum<{
182
+ administrativeArea: "administrativeArea";
183
+ all: "all";
184
+ location: "location";
185
+ }>, z.ZodObject<{
186
+ $scope: z.ZodEnum<{
187
+ "attachment.upload": "attachment.upload";
188
+ bypassratelimit: "bypassratelimit";
189
+ "config.update-all": "config.update-all";
190
+ "dashboard.view": "dashboard.view";
191
+ "integration.audit.read": "integration.audit.read";
192
+ "integration.create": "integration.create";
193
+ "location.edit": "location.edit";
194
+ "organisation.read-locations": "organisation.read-locations";
195
+ "performance.read": "performance.read";
196
+ "performance.read-dashboards": "performance.read-dashboards";
197
+ "performance.vital-statistics-export": "performance.vital-statistics-export";
198
+ "profile.electronic-signature": "profile.electronic-signature";
199
+ "record.action.accept": "record.action.accept";
200
+ "record.action.reject": "record.action.reject";
201
+ "record.archive": "record.archive";
202
+ "record.correct": "record.correct";
203
+ "record.create": "record.create";
204
+ "record.custom-action": "record.custom-action";
205
+ "record.declare": "record.declare";
206
+ "record.edit": "record.edit";
207
+ "record.import": "record.import";
208
+ "record.notify": "record.notify";
209
+ "record.print-certified-copies": "record.print-certified-copies";
210
+ "record.read": "record.read";
211
+ "record.register": "record.register";
212
+ "record.reindex": "record.reindex";
213
+ "record.reinstate-registration": "record.reinstate-registration";
214
+ "record.reject": "record.reject";
215
+ "record.request-correction": "record.request-correction";
216
+ "record.review-duplicates": "record.review-duplicates";
217
+ "record.revoke-registration": "record.revoke-registration";
218
+ "record.search": "record.search";
219
+ "record.unarchive": "record.unarchive";
220
+ "record.unassign-others": "record.unassign-others";
221
+ "user.create": "user.create";
222
+ "user.data-seeding": "user.data-seeding";
223
+ "user.edit": "user.edit";
224
+ "user.read": "user.read";
225
+ "user.read-only-my-audit": "user.read-only-my-audit";
226
+ "user.search": "user.search";
227
+ workqueue: "workqueue";
228
+ }>;
229
+ $option: z.ZodEnum<{
230
+ accessLevel: "accessLevel";
231
+ createdBy: "createdBy";
232
+ createdIn: "createdIn";
233
+ declaredBy: "declaredBy";
234
+ declaredIn: "declaredIn";
235
+ event: "event";
236
+ flags: "flags";
237
+ ids: "ids";
238
+ notifiedBy: "notifiedBy";
239
+ notifiedIn: "notifiedIn";
240
+ placeOfEvent: "placeOfEvent";
241
+ registeredBy: "registeredBy";
242
+ registeredIn: "registeredIn";
243
+ role: "role";
244
+ status: "status";
245
+ }>;
246
+ }, z.core.$strip>]>;
247
+ }, z.core.$strip>>;
248
+ fieldId: z.ZodString;
249
+ fieldType: z.ZodLiteral<"field">;
250
+ defaultValue: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodString, z.ZodNumber]>>;
251
+ }, z.core.$strip>, z.ZodObject<{
252
+ config: z.ZodObject<{
253
+ type: z.ZodEnum<{
254
+ exact: "exact";
255
+ fuzzy: "fuzzy";
256
+ range: "range";
257
+ within: "within";
258
+ }>;
259
+ searchFields: z.ZodOptional<z.ZodArray<z.ZodString>>;
260
+ }, z.core.$strip>;
261
+ type: z.ZodOptional<z.ZodEnum<{
262
+ readonly NAME: 'NAME';
263
+ readonly PHONE: 'PHONE';
264
+ readonly ID: 'ID';
265
+ readonly ADDRESS: 'ADDRESS';
266
+ readonly TEXT: 'TEXT';
267
+ readonly NUMBER: 'NUMBER';
268
+ readonly NUMBER_WITH_UNIT: 'NUMBER_WITH_UNIT';
269
+ readonly TEXTAREA: 'TEXTAREA';
270
+ readonly EMAIL: 'EMAIL';
271
+ readonly DATE: 'DATE';
272
+ readonly AGE: 'AGE';
273
+ readonly DATE_RANGE: 'DATE_RANGE';
274
+ readonly SELECT_DATE_RANGE: 'SELECT_DATE_RANGE';
275
+ readonly TIME: 'TIME';
276
+ readonly IMAGE_VIEW: 'IMAGE_VIEW';
277
+ readonly PARAGRAPH: 'PARAGRAPH';
278
+ readonly HEADING: 'HEADING';
279
+ readonly PAGE_HEADER: 'PAGE_HEADER';
280
+ readonly RADIO_GROUP: 'RADIO_GROUP';
281
+ readonly FIELD_GROUP: 'FIELD_GROUP';
282
+ readonly FILE: 'FILE';
283
+ readonly FILE_WITH_OPTIONS: 'FILE_WITH_OPTIONS';
284
+ readonly BULLET_LIST: 'BULLET_LIST';
285
+ readonly CHECKBOX: 'CHECKBOX';
286
+ readonly SELECT: 'SELECT';
287
+ readonly COUNTRY: 'COUNTRY';
288
+ readonly LOCATION: 'LOCATION';
289
+ readonly DIVIDER: 'DIVIDER';
290
+ readonly ADMINISTRATIVE_AREA: 'ADMINISTRATIVE_AREA';
291
+ readonly FACILITY: 'FACILITY';
292
+ readonly OFFICE: 'OFFICE';
293
+ readonly SIGNATURE: 'SIGNATURE';
294
+ readonly DATA: 'DATA';
295
+ readonly BUTTON: 'BUTTON';
296
+ readonly AUTOCOMPLETE: 'AUTOCOMPLETE';
297
+ readonly SEARCH: 'SEARCH';
298
+ readonly ALPHA_PRINT_BUTTON: 'ALPHA_PRINT_BUTTON';
299
+ readonly HTTP: 'HTTP';
300
+ readonly LINK_BUTTON: 'LINK_BUTTON';
301
+ readonly VERIFICATION_STATUS: 'VERIFICATION_STATUS';
302
+ readonly QUERY_PARAM_READER: 'QUERY_PARAM_READER';
303
+ readonly QR_READER: 'QR_READER';
304
+ readonly ID_READER: 'ID_READER';
305
+ readonly LOADER: 'LOADER';
306
+ readonly ALPHA_HIDDEN: 'ALPHA_HIDDEN';
307
+ readonly USER_ROLE: 'USER_ROLE';
308
+ readonly _EXPERIMENTAL_CUSTOM: 'CUSTOM';
309
+ }>>;
310
+ label: z.ZodOptional<z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, z.core.$strip>>;
311
+ options: z.ZodOptional<z.ZodArray<z.ZodObject<{
312
+ value: z.ZodString;
313
+ label: z.ZodUnion<readonly [z.ZodString, z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, z.core.$strip>]>;
314
+ conditionals: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
315
+ type: z.ZodLiteral<"SHOW">;
316
+ conditional: z.ZodAny;
317
+ }, z.core.$strip>, z.ZodObject<{
318
+ type: z.ZodLiteral<"ENABLE">;
319
+ conditional: z.ZodAny;
320
+ }, z.core.$strip>], "type">>>>;
321
+ }, z.core.$strip>>>;
322
+ searchCriteriaLabelPrefix: z.ZodOptional<z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, z.core.$strip>>;
323
+ conditionals: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
324
+ type: z.ZodLiteral<"SHOW">;
325
+ conditional: z.ZodAny;
326
+ }, z.core.$strip>, z.ZodObject<{
327
+ type: z.ZodLiteral<"ENABLE">;
328
+ conditional: z.ZodAny;
329
+ }, z.core.$strip>, z.ZodObject<{
330
+ type: z.ZodLiteral<"DISPLAY_ON_REVIEW">;
331
+ conditional: z.ZodAny;
332
+ }, z.core.$strip>], "type">>>;
333
+ validations: z.ZodOptional<z.ZodArray<z.ZodObject<{
334
+ validator: z.ZodAny;
335
+ message: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, z.core.$strip>;
336
+ }, z.core.$strip>>>;
337
+ allowedLocations: z.ZodOptional<z.ZodObject<{
338
+ $jurisdiction: z.ZodUnion<[z.ZodEnum<{
339
+ administrativeArea: "administrativeArea";
340
+ all: "all";
341
+ location: "location";
342
+ }>, z.ZodObject<{
343
+ $scope: z.ZodEnum<{
344
+ "attachment.upload": "attachment.upload";
345
+ bypassratelimit: "bypassratelimit";
346
+ "config.update-all": "config.update-all";
347
+ "dashboard.view": "dashboard.view";
348
+ "integration.audit.read": "integration.audit.read";
349
+ "integration.create": "integration.create";
350
+ "location.edit": "location.edit";
351
+ "organisation.read-locations": "organisation.read-locations";
352
+ "performance.read": "performance.read";
353
+ "performance.read-dashboards": "performance.read-dashboards";
354
+ "performance.vital-statistics-export": "performance.vital-statistics-export";
355
+ "profile.electronic-signature": "profile.electronic-signature";
356
+ "record.action.accept": "record.action.accept";
357
+ "record.action.reject": "record.action.reject";
358
+ "record.archive": "record.archive";
359
+ "record.correct": "record.correct";
360
+ "record.create": "record.create";
361
+ "record.custom-action": "record.custom-action";
362
+ "record.declare": "record.declare";
363
+ "record.edit": "record.edit";
364
+ "record.import": "record.import";
365
+ "record.notify": "record.notify";
366
+ "record.print-certified-copies": "record.print-certified-copies";
367
+ "record.read": "record.read";
368
+ "record.register": "record.register";
369
+ "record.reindex": "record.reindex";
370
+ "record.reinstate-registration": "record.reinstate-registration";
371
+ "record.reject": "record.reject";
372
+ "record.request-correction": "record.request-correction";
373
+ "record.review-duplicates": "record.review-duplicates";
374
+ "record.revoke-registration": "record.revoke-registration";
375
+ "record.search": "record.search";
376
+ "record.unarchive": "record.unarchive";
377
+ "record.unassign-others": "record.unassign-others";
378
+ "user.create": "user.create";
379
+ "user.data-seeding": "user.data-seeding";
380
+ "user.edit": "user.edit";
381
+ "user.read": "user.read";
382
+ "user.read-only-my-audit": "user.read-only-my-audit";
383
+ "user.search": "user.search";
384
+ workqueue: "workqueue";
385
+ }>;
386
+ $option: z.ZodEnum<{
387
+ accessLevel: "accessLevel";
388
+ createdBy: "createdBy";
389
+ createdIn: "createdIn";
390
+ declaredBy: "declaredBy";
391
+ declaredIn: "declaredIn";
392
+ event: "event";
393
+ flags: "flags";
394
+ ids: "ids";
395
+ notifiedBy: "notifiedBy";
396
+ notifiedIn: "notifiedIn";
397
+ placeOfEvent: "placeOfEvent";
398
+ registeredBy: "registeredBy";
399
+ registeredIn: "registeredIn";
400
+ role: "role";
401
+ status: "status";
402
+ }>;
403
+ }, z.core.$strip>]>;
404
+ }, z.core.$strip>>;
405
+ fieldId: z.ZodEnum<{
406
+ "event.legalStatuses.REGISTERED.acceptedAt": "event.legalStatuses.REGISTERED.acceptedAt";
407
+ "event.legalStatuses.REGISTERED.createdAtLocation": "event.legalStatuses.REGISTERED.createdAtLocation";
408
+ "event.legalStatuses.REGISTERED.registrationNumber": "event.legalStatuses.REGISTERED.registrationNumber";
409
+ "event.status": "event.status";
410
+ "event.trackingId": "event.trackingId";
411
+ "event.updatedAt": "event.updatedAt";
412
+ }>;
413
+ fieldType: z.ZodLiteral<"event">;
414
+ }, z.core.$strip>], "fieldType">>;
415
+ }, z.core.$strip>>>>;
416
+ };
417
+ /** Validations of one version of an event, read together with the fields shared by every version. */
418
+ export declare function validateEventConfig(event: EventConfig, ctx: z.RefinementCtx<EventConfig>): void;
68
419
  export declare const EventConfig: z.ZodType<EventConfig, EventConfigSchemaInput>;
420
+ type EventLevelField = keyof typeof eventLevelFields;
421
+ /**
422
+ * Id of the version of an event configured without `versions`, i.e. the configuration
423
+ * before versioning. Records created before versioning are stamped with it.
424
+ */
425
+ export declare const INITIAL_EVENT_CONFIG_VERSION_ID = "initial";
426
+ /** `effectiveFrom` of a version configured without one. */
427
+ export declare const DEFAULT_EFFECTIVE_FROM = "0001-01-01";
428
+ /** One version of an event: what the event looks like from `effectiveFrom` on. */
429
+ export type EventConfigVersion = Omit<EventConfig, EventLevelField> & {
430
+ id: string;
431
+ /** Name of the version. A version configured without `versions` has the label of the event. */
432
+ label: TranslationConfig;
433
+ /** Date (YYYY-MM-DD) from which this version is effective. '0001-01-01' when configured without one. */
434
+ effectiveFrom: string;
435
+ };
436
+ /**
437
+ * An event with every version of its configuration. This is what country config serves.
438
+ * Read it through `resolveEventConfig`, which gives the configuration of one version.
439
+ */
440
+ export type VersionedEventConfig = Pick<EventConfig, EventLevelField> & {
441
+ versions: EventConfigVersion[];
442
+ };
443
+ /**
444
+ * @returns the configuration of `version`, together with the fields shared by every
445
+ * version of the event. The same event and version give the same object, so caches
446
+ * keyed on the configuration keep working.
447
+ */
448
+ export declare function toEventConfig(config: VersionedEventConfig, version: EventConfigVersion): EventConfig;
449
+ /** @returns the version with id `versionId`, or undefined when it is not configured. */
450
+ export declare function findConfigVersion(config: VersionedEventConfig, versionId: string): EventConfigVersion | undefined;
451
+ /**
452
+ * @returns the version with id `versionId`.
453
+ * @throws when that version is not configured.
454
+ */
455
+ export declare function getConfigVersion(config: VersionedEventConfig, versionId: string): EventConfigVersion;
456
+ /**
457
+ * @returns the configuration of the version with id `versionId`.
458
+ * @throws when the version is not configured.
459
+ */
460
+ export declare function getEventConfigOfVersion(config: VersionedEventConfig, versionId: string): EventConfig;
461
+ /** Orders versions by `effectiveFrom`, earliest first. */
462
+ export declare function byEffectiveFrom(a: EventConfigVersion, b: EventConfigVersion): number;
463
+ /**
464
+ * @returns the versions that took effect on or before the date of `now` in `timeZone`,
465
+ * the country's time zone.
466
+ * Earliest first, so the last one is the version in effect at `now`.
467
+ */
468
+ export declare function getVersionsInEffect(config: VersionedEventConfig, now: Date, timeZone: string): EventConfigVersion[];
469
+ /**
470
+ * @returns the version in effect at `now`: the one with the latest `effectiveFrom` not
471
+ * after the date of `now` in `timeZone`, the country's time zone, since versions take
472
+ * effect at its midnight. Undefined when every version takes effect later.
473
+ */
474
+ export declare function resolveEffectiveVersion(config: VersionedEventConfig, now: Date, timeZone: string): EventConfigVersion | undefined;
475
+ /**
476
+ * @returns the configuration of the version a record is stamped with, like
477
+ * `getEventConfigForRecord`, or undefined when that version is not configured.
478
+ */
479
+ export declare function findEventConfigForRecord(config: VersionedEventConfig, record: {
480
+ configVersionId: string;
481
+ }): EventConfig | undefined;
482
+ /**
483
+ * @returns the configuration of the version a record is stamped with.
484
+ * @throws when the record's version is no longer configured.
485
+ */
486
+ export declare function getEventConfigForRecord(config: VersionedEventConfig, record: {
487
+ configVersionId: string;
488
+ }): EventConfig;
489
+ /**
490
+ * @returns the configuration of the version in effect on `date`, a date in the
491
+ * country's time zone. For a record, use `getEventConfigForRecord` instead.
492
+ * @throws when no version is in effect on that date, which `defineConfig` rules out.
493
+ */
494
+ export declare function resolveEventConfigOnDate(config: VersionedEventConfig, date: PlainDate): EventConfig;
495
+ /**
496
+ * @returns the configuration of the version in effect on the date of `now` (today by
497
+ * default) in `timeZone`, the country's time zone. For a record, use
498
+ * `getEventConfigForRecord` instead.
499
+ * @throws when no version is in effect on that date, which `defineConfig` rules out.
500
+ */
501
+ export declare function resolveEventConfigInTimeZone(config: VersionedEventConfig, timeZone: string, now?: Date): EventConfig;
502
+ /**
503
+ * @returns the configuration of the version in effect today in UTC. For country config
504
+ * code with no time zone at hand; core code uses `resolveEventConfigInTimeZone`.
505
+ */
506
+ export declare function resolveEventConfig(config: VersionedEventConfig): EventConfig;
507
+ /**
508
+ * Runs `validate` on the configuration of each version (`events[i]` is that of
509
+ * `versions[i]`). Issues on a field of the version are reported under that version.
510
+ * Issues on a field shared by every version (e.g. `advancedSearch`) are reported once,
511
+ * where they are defined.
512
+ */
513
+ export declare function validateEachVersion<E>(ctx: Pick<z.RefinementCtx<unknown>, 'addIssue'>, events: E[], validate: (event: E, versionCtx: z.RefinementCtx<E>) => void): void;
514
+ export declare const VersionedEventConfig: z.ZodType<VersionedEventConfig, VersionedEventConfigInput>;
69
515
  export {};
70
516
  //# sourceMappingURL=EventConfig.d.ts.map
@@ -509,6 +509,7 @@ export declare const EventDocument: z.ZodObject<{
509
509
  status: z.ZodLiteral<"Rejected">;
510
510
  }, z.core.$strip>]>>;
511
511
  trackingId: z.ZodString;
512
+ configVersionId: z.ZodString;
512
513
  }, z.core.$strip>;
513
514
  export type EventDocument = z.infer<typeof EventDocument>;
514
515
  export declare const EventDocumentOnlyLastAction: z.core.$ZodBranded<z.ZodObject<{
@@ -517,6 +518,7 @@ export declare const EventDocumentOnlyLastAction: z.core.$ZodBranded<z.ZodObject
517
518
  createdAt: z.ZodString;
518
519
  updatedAt: z.ZodString;
519
520
  trackingId: z.ZodString;
521
+ configVersionId: z.ZodString;
520
522
  actions: z.ZodArray<z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject<{
521
523
  id: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
522
524
  transactionId: z.ZodString;
@@ -3,6 +3,7 @@ export { ContainsFlags } from './Flag';
3
3
  export declare const EventIndex: z.ZodObject<{
4
4
  id: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
5
5
  type: z.ZodString;
6
+ configVersionId: z.ZodString;
6
7
  status: z.ZodEnum<{
7
8
  ARCHIVED: "ARCHIVED";
8
9
  CREATED: "CREATED";
@@ -3,6 +3,7 @@ export declare const EventInput: z.ZodObject<{
3
3
  transactionId: z.ZodString;
4
4
  type: z.ZodString;
5
5
  createdAtLocation: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>>;
6
+ configVersionId: z.ZodOptional<z.ZodString>;
6
7
  }, z.core.$strip>;
7
8
  export type EventInput = z.infer<typeof EventInput>;
8
9
  //# sourceMappingURL=EventInput.d.ts.map
@@ -83,6 +83,7 @@ export declare const LegalStatuses: z.ZodObject<{
83
83
  export declare const EventMetadata: z.ZodObject<{
84
84
  id: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
85
85
  type: z.ZodString;
86
+ configVersionId: z.ZodString;
86
87
  status: z.ZodEnum<{
87
88
  ARCHIVED: "ARCHIVED";
88
89
  CREATED: "CREATED";
@@ -32,8 +32,8 @@ export declare function mapFieldTypeToZod(field: FieldConfig, actionType?: Actio
32
32
  age: z.ZodNumber;
33
33
  asOfDateRef: z.ZodString;
34
34
  }, z.core.$strip> | z.ZodObject<{
35
- label: z.ZodString;
36
- value: z.ZodString;
35
+ numericValue: z.ZodOptional<z.ZodNumber>;
36
+ unit: z.ZodOptional<z.ZodString>;
37
37
  }, z.core.$strip> | z.ZodObject<{
38
38
  path: z.core.$ZodBranded<z.ZodString, "DocumentPath", "out">;
39
39
  originalFilename: z.ZodString;
@@ -44,8 +44,8 @@ export declare function mapFieldTypeToZod(field: FieldConfig, actionType?: Actio
44
44
  numericValue: z.ZodNumber;
45
45
  unit: z.ZodString;
46
46
  }, z.core.$strip> | z.ZodObject<{
47
- numericValue: z.ZodOptional<z.ZodNumber>;
48
- unit: z.ZodOptional<z.ZodString>;
47
+ label: z.ZodString;
48
+ value: z.ZodString;
49
49
  }, z.core.$strip> | z.ZodObject<{
50
50
  data: z.ZodRecord<z.ZodString, z.ZodString>;
51
51
  }, z.core.$strip> | z.ZodObject<{
@@ -68,8 +68,8 @@ export declare function mapFieldTypeToZod(field: FieldConfig, actionType?: Actio
68
68
  age: z.ZodNumber;
69
69
  asOfDateRef: z.ZodString;
70
70
  }, z.core.$strip>>> | z.ZodOptional<z.ZodNullable<z.ZodObject<{
71
- label: z.ZodString;
72
- value: z.ZodString;
71
+ numericValue: z.ZodOptional<z.ZodNumber>;
72
+ unit: z.ZodOptional<z.ZodString>;
73
73
  }, z.core.$strip>>> | z.ZodOptional<z.ZodNullable<z.ZodObject<{
74
74
  path: z.core.$ZodBranded<z.ZodString, "DocumentPath", "out">;
75
75
  originalFilename: z.ZodString;
@@ -80,8 +80,8 @@ export declare function mapFieldTypeToZod(field: FieldConfig, actionType?: Actio
80
80
  numericValue: z.ZodNumber;
81
81
  unit: z.ZodString;
82
82
  }, z.core.$strip>>> | z.ZodOptional<z.ZodNullable<z.ZodObject<{
83
- numericValue: z.ZodOptional<z.ZodNumber>;
84
- unit: z.ZodOptional<z.ZodString>;
83
+ label: z.ZodString;
84
+ value: z.ZodString;
85
85
  }, z.core.$strip>>> | z.ZodOptional<z.ZodNullable<z.ZodObject<{
86
86
  data: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject<{
87
87
  country: z.ZodString;
@@ -243,15 +243,6 @@ export declare function mapFieldTypeToZod(field: FieldConfig, actionType?: Actio
243
243
  }, z.core.$strip>>>;
244
244
  data: z.ZodOptional<z.ZodNullable<z.ZodAny>>;
245
245
  }, z.core.$strip>, z.ZodNull]>, z.ZodUndefined]>>> | z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUnknown, "CustomFieldValue", "out">>> | z.ZodString | z.ZodType<{
246
- country: string;
247
- streetLevelDetails?: Record<string, string> | undefined;
248
- addressType: "DOMESTIC";
249
- administrativeArea: string;
250
- } | {
251
- country: string;
252
- streetLevelDetails?: Record<string, string> | undefined;
253
- addressType: "INTERNATIONAL";
254
- } | {
255
246
  country?: string | null | undefined;
256
247
  streetLevelDetails?: Record<string, string | null> | null | undefined;
257
248
  addressType: "DOMESTIC";
@@ -260,7 +251,7 @@ export declare function mapFieldTypeToZod(field: FieldConfig, actionType?: Actio
260
251
  country?: string | null | undefined;
261
252
  streetLevelDetails?: Record<string, string | null> | null | undefined;
262
253
  addressType: "INTERNATIONAL";
263
- } | null | undefined, unknown, z.core.$ZodTypeInternals<{
254
+ } | {
264
255
  country: string;
265
256
  streetLevelDetails?: Record<string, string> | undefined;
266
257
  addressType: "DOMESTIC";
@@ -269,7 +260,7 @@ export declare function mapFieldTypeToZod(field: FieldConfig, actionType?: Actio
269
260
  country: string;
270
261
  streetLevelDetails?: Record<string, string> | undefined;
271
262
  addressType: "INTERNATIONAL";
272
- } | {
263
+ } | null | undefined, unknown, z.core.$ZodTypeInternals<{
273
264
  country?: string | null | undefined;
274
265
  streetLevelDetails?: Record<string, string | null> | null | undefined;
275
266
  addressType: "DOMESTIC";
@@ -278,6 +269,15 @@ export declare function mapFieldTypeToZod(field: FieldConfig, actionType?: Actio
278
269
  country?: string | null | undefined;
279
270
  streetLevelDetails?: Record<string, string | null> | null | undefined;
280
271
  addressType: "INTERNATIONAL";
272
+ } | {
273
+ country: string;
274
+ streetLevelDetails?: Record<string, string> | undefined;
275
+ addressType: "DOMESTIC";
276
+ administrativeArea: string;
277
+ } | {
278
+ country: string;
279
+ streetLevelDetails?: Record<string, string> | undefined;
280
+ addressType: "INTERNATIONAL";
281
281
  } | null | undefined, unknown>> | z.ZodUnion<[z.ZodObject<{
282
282
  start: z.core.$ZodBranded<z.ZodString, "PlainDate", "out">;
283
283
  end: z.core.$ZodBranded<z.ZodString, "PlainDate", "out">;
@@ -18,6 +18,11 @@ export declare const isPlainDate: (date: unknown) => date is PlainDate;
18
18
  * YYYY-MM-DD input, as produced by the event metadata and date fields.
19
19
  */
20
20
  export declare function toPlainDate(dateTime: string): PlainDate;
21
+ /**
22
+ * The calendar date of `date` in the IANA `timeZone` (e.g. 'Asia/Dhaka'), as a
23
+ * {@link PlainDate}. Unlike {@link toPlainDate}, which reads the UTC date.
24
+ */
25
+ export declare function toPlainDateInTimeZone(date: Date, timeZone: string): PlainDate;
21
26
  /**
22
27
  * Converts a {@link PlainDate} (YYYY-MM-DD) to a local `Date` at midnight.
23
28
  *
@@ -1,3 +1,8 @@
1
- import { EventConfig, EventConfigInput } from './EventConfig';
2
- export declare const defineConfig: (config: EventConfigInput) => EventConfig;
1
+ import { EventConfigInput, VersionedEventConfig, VersionedEventConfigInput } from './EventConfig';
2
+ /**
3
+ * Validates an event configuration. Accepts an event with `versions`, or, as before
4
+ * versioning, an event without them, which is taken as a single version with id
5
+ * `initial`, effective from the beginning of time.
6
+ */
7
+ export declare const defineConfig: (config: EventConfigInput | VersionedEventConfigInput) => VersionedEventConfig;
3
8
  //# sourceMappingURL=defineConfig.d.ts.map