@opencrvs/toolkit 2.1.0-rc.c3b24ba → 2.1.0-rc.c500a81

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 (119) hide show
  1. package/README.md +3 -12
  2. package/build.sh +12 -4
  3. package/create-countryconfig/index.js +441 -59
  4. package/create-countryconfig/node_modules/.bin/degit +21 -0
  5. package/create-countryconfig/package.json +4 -1
  6. package/dist/application-config/index.js +347 -283
  7. package/dist/authentication/index.d.ts +67 -0
  8. package/dist/authentication/index.d.ts.map +1 -0
  9. package/dist/authentication/index.js +751 -0
  10. package/dist/cli.js +3011 -1226
  11. package/dist/commons/api/router.d.ts +658 -132
  12. package/dist/commons/application-config/index.d.ts +0 -2
  13. package/dist/commons/conditionals/conditionals.d.ts +6 -6
  14. package/dist/commons/conditionals/validate.d.ts +16 -5
  15. package/dist/commons/events/ActionConfig.d.ts +4 -0
  16. package/dist/commons/events/ActionDocument.d.ts +35 -15
  17. package/dist/commons/events/ActionInput.d.ts +4 -4
  18. package/dist/commons/events/ActionStatus.d.ts +14 -0
  19. package/dist/commons/events/AdvancedSearchConfig.d.ts +30 -12
  20. package/dist/commons/events/AuditLog.d.ts +110 -0
  21. package/dist/commons/events/EventConfig.d.ts +3 -0
  22. package/dist/commons/events/EventDocument.d.ts +472 -4
  23. package/dist/commons/events/EventIndex.d.ts +3 -26
  24. package/dist/commons/events/EventMetadata.d.ts +1 -11
  25. package/dist/commons/events/EventStatus.d.ts +19 -0
  26. package/dist/commons/events/FieldConfig.d.ts +94 -63
  27. package/dist/commons/events/FieldTypeMapping.d.ts +27 -27
  28. package/dist/commons/events/FieldValue.d.ts +3 -2
  29. package/dist/commons/events/Flag.d.ts +42 -0
  30. package/dist/commons/events/FormConfig.d.ts +6 -0
  31. package/dist/commons/events/PageConfig.d.ts +4 -0
  32. package/dist/commons/events/PlainDate.d.ts +8 -0
  33. package/dist/commons/events/SummaryConfig.d.ts +249 -0
  34. package/dist/commons/events/WorkqueueConfig.d.ts +17 -14
  35. package/dist/commons/events/event.d.ts +12 -0
  36. package/dist/commons/events/locations.d.ts +162 -26
  37. package/dist/commons/events/mocks.test.utils.d.ts +30 -0
  38. package/dist/commons/events/test.utils.d.ts +73 -18
  39. package/dist/commons/events/utils.d.ts +34 -4
  40. package/dist/commons/notification/UserNotifications.d.ts +28 -13
  41. package/dist/commons/notification/dispatch.d.ts +10 -0
  42. package/dist/commons/notification/index.d.ts +1 -0
  43. package/dist/conditionals/index.js +334 -64
  44. package/dist/csv.d.ts +25 -0
  45. package/dist/csv.d.ts.map +1 -0
  46. package/dist/csv.js +120 -0
  47. package/dist/environment/index.d.ts +1 -0
  48. package/dist/environment/index.d.ts.map +1 -1
  49. package/dist/environment/index.js +12 -1
  50. package/dist/environment/logger.d.ts +15 -3
  51. package/dist/environment/logger.d.ts.map +1 -1
  52. package/dist/environment/manage-users.js +1 -1
  53. package/dist/environment/paths.d.ts +7 -0
  54. package/dist/environment/paths.d.ts.map +1 -0
  55. package/dist/environment/paths.js +72 -0
  56. package/dist/environment/questions.d.ts.map +1 -1
  57. package/dist/environment/questions.js +20 -14
  58. package/dist/environment/setup-environment.d.ts +1 -1
  59. package/dist/environment/setup-environment.d.ts.map +1 -1
  60. package/dist/environment/setup-environment.js +587 -562
  61. package/dist/environment/templates.d.ts +0 -1
  62. package/dist/environment/templates.d.ts.map +1 -1
  63. package/dist/environment/templates.js +5 -9
  64. package/dist/environment/update-workflows.d.ts.map +1 -1
  65. package/dist/environment/update-workflows.js +21 -5
  66. package/dist/environment/upgrade.d.ts +2 -0
  67. package/dist/environment/upgrade.d.ts.map +1 -0
  68. package/dist/environment/upgrade.js +82 -0
  69. package/dist/environment/users.js +11 -13
  70. package/dist/environment/utils.d.ts +0 -12
  71. package/dist/environment/utils.d.ts.map +1 -1
  72. package/dist/environment/utils.js +1 -28
  73. package/dist/events/index.js +7597 -7129
  74. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +2 -2
  75. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
  76. package/dist/migrations/v2.0/checkout-upstream-files.js +2 -2
  77. package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts.map +1 -1
  78. package/dist/migrations/v2.0/convert-config-files-to-ts.js +3 -10
  79. package/dist/migrations/v2.0/merge-infrastructure-directory.js +3 -3
  80. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts +3 -0
  81. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts.map +1 -0
  82. package/dist/migrations/v2.1/add-recovery-link-notifications.js +511 -0
  83. package/dist/migrations/v2.1/add-translations.d.ts +9 -0
  84. package/dist/migrations/v2.1/add-translations.d.ts.map +1 -0
  85. package/dist/migrations/v2.1/add-translations.js +149 -0
  86. package/dist/migrations/v2.1/enable-telemetry.d.ts +3 -0
  87. package/dist/migrations/v2.1/enable-telemetry.d.ts.map +1 -0
  88. package/dist/migrations/v2.1/enable-telemetry.js +455 -0
  89. package/dist/migrations/v2.1/index.d.ts.map +1 -1
  90. package/dist/migrations/v2.1/index.js +1223 -0
  91. package/dist/migrations/v2.1/rename-trigger-paths.d.ts +3 -0
  92. package/dist/migrations/v2.1/rename-trigger-paths.d.ts.map +1 -0
  93. package/dist/migrations/v2.1/rename-trigger-paths.js +216 -0
  94. package/dist/notification/index.js +1800 -1454
  95. package/dist/scopes/index.d.ts +433 -36
  96. package/dist/scopes/index.js +335 -64
  97. package/dist/telemetry/index.d.ts +45 -0
  98. package/dist/telemetry/index.d.ts.map +1 -0
  99. package/dist/telemetry/index.js +43 -0
  100. package/dist/templates/charts-values/dependencies/values.yaml +2 -0
  101. package/dist/templates/charts-values/opencrvs-services/values.yaml +4 -3
  102. package/dist/templates/charts-values/opentelemetry/values.yaml +102 -0
  103. package/dist/templates/charts-values/traefik/values.yaml +23 -9
  104. package/dist/templates/inventory/inventory.template.yml +1 -3
  105. package/dist/translations/template.d.ts +11 -0
  106. package/dist/translations/template.d.ts.map +1 -0
  107. package/dist/translations/template.js +100 -0
  108. package/dist/verify/endpoints.d.ts +2 -0
  109. package/dist/verify/endpoints.d.ts.map +1 -0
  110. package/dist/verify/endpoints.js +510 -0
  111. package/opencrvs-toolkit-2.1.0-rc.c500a81.tgz +0 -0
  112. package/package.json +13 -7
  113. package/tsconfig.build.json +11 -0
  114. package/tsconfig.build.tsbuildinfo +1 -0
  115. package/tsconfig.json +3 -0
  116. package/dist/templates/inventory/production.example.yml +0 -77
  117. package/dist/templates/inventory/qa.example.yml +0 -48
  118. package/opencrvs-toolkit-2.1.0-rc.c3b24ba.tgz +0 -0
  119. package/tsconfig.tsbuildinfo +0 -1
@@ -1,6 +1,8 @@
1
1
  import { NonSearchableEventMetadataTimeFieldIdInput, AdvancedSearchConfig } from '../event-config/event-configuration';
2
2
  import { ActionType } from './ActionType';
3
3
  import { EventFieldIdInput } from './AdvancedSearchConfig';
4
+ import { EventStatus } from './EventMetadata';
5
+ import { Flag } from './Flag';
4
6
  import { WorkqueueColumnKeys, WorkqueueColumnValue } from './WorkqueueColumnConfig';
5
7
  /**
6
8
  * Creates a function that acts like a callable + static method container.
@@ -75,6 +77,16 @@ declare const event: typeof eventFn & {
75
77
  };
76
78
  };
77
79
  field(field: WorkqueueColumnKeys): WorkqueueColumnValue;
80
+ /**
81
+ * Checks if the event currently has the given status.
82
+ * @param eventStatus - The status to check for.
83
+ */
84
+ hasStatus: (eventStatus: EventStatus) => import("../conditionals/conditionals").JSONSchema;
85
+ /**
86
+ * Checks if the event currently carries the given flag.
87
+ * @param flagValue - The flag to check for.
88
+ */
89
+ hasFlag: (flagValue: Flag) => import("../conditionals/conditionals").JSONSchema;
78
90
  };
79
91
  export { event };
80
92
  //# sourceMappingURL=event.d.ts.map
@@ -1,5 +1,6 @@
1
1
  import { UUID } from '../uuid';
2
2
  import * as z from 'zod/v4';
3
+ import { PlainDate } from './PlainDate';
3
4
  import { EventIndex } from './EventIndex';
4
5
  import { ActionCreationMetadata, RegistrationCreationMetadata } from './EventMetadata';
5
6
  import { RecordScopeV2, UserScopeV2 } from '../scopes';
@@ -16,10 +17,16 @@ export declare const LocationStatus: z.ZodEnum<{
16
17
  inactive: "inactive";
17
18
  }>;
18
19
  export type LocationStatus = z.infer<typeof LocationStatus>;
20
+ /** Thrown when a user's assigned office is inactive and must not be allowed to authenticate. */
21
+ export declare class InactiveOfficeError extends Error {
22
+ constructor(message?: string);
23
+ }
19
24
  /**
20
- * A single element of the append-only `versions` history of a location or
21
- * administrative area. Versions are sorted ascending by `effectiveFrom`
22
- * ('0001-01-01' is used as the beginning-of-time sentinel).
25
+ * A single element of the `versions` history of a location or administrative
26
+ * area. Versions are sorted ascending by `effectiveFrom` ('0001-01-01' is used
27
+ * as the beginning-of-time sentinel). Updates only ever append, but a
28
+ * not-yet-effective version can be withdrawn and seeding replaces a history
29
+ * wholesale, so the array is not append-only.
23
30
  */
24
31
  export declare const LocationVersion: z.ZodObject<{
25
32
  versionId: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
@@ -76,8 +83,79 @@ export declare const Location: z.ZodObject<{
76
83
  }, z.core.$strip>;
77
84
  export type Location = z.infer<typeof Location>;
78
85
  /**
79
- * Input payload for the locations `set` mutation. Carries only the seedable
80
- * identity and hierarchy fields — version history is managed by the server.
86
+ * TEMPORARY — client-side view of {@link AdministrativeArea} with the
87
+ * server-flattened `name`, `status` and `externalId` removed, leaving exactly
88
+ * identity + versions. Every name/status read is thereby forced through the
89
+ * anchored resolution utilities ({@link resolveVersion}, {@link resolvePath})
90
+ * at compile time. Delete this type when the contract migration removes the
91
+ * flat fields from the server schema, at which point the wire type itself
92
+ * becomes identity + versions.
93
+ */
94
+ export declare const ClientAdministrativeArea: z.ZodObject<{
95
+ id: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
96
+ parentId: z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>;
97
+ versions: z.ZodArray<z.ZodObject<{
98
+ versionId: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
99
+ effectiveFrom: z.ZodISODate;
100
+ name: z.ZodString;
101
+ externalId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
102
+ status: z.ZodEnum<{
103
+ active: "active";
104
+ inactive: "inactive";
105
+ }>;
106
+ }, z.core.$strip>>;
107
+ }, z.core.$strip>;
108
+ export type ClientAdministrativeArea = z.infer<typeof ClientAdministrativeArea>;
109
+ /**
110
+ * TEMPORARY — client-side view of {@link Location} with the server-flattened
111
+ * `name`, `status` and `externalId` removed, leaving exactly identity +
112
+ * versions. See {@link ClientAdministrativeArea} for the full rationale and
113
+ * deletion condition.
114
+ */
115
+ export declare const ClientLocation: z.ZodObject<{
116
+ id: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
117
+ administrativeAreaId: z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>;
118
+ locationType: z.ZodNullable<z.ZodString>;
119
+ versions: z.ZodArray<z.ZodObject<{
120
+ versionId: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
121
+ effectiveFrom: z.ZodISODate;
122
+ name: z.ZodString;
123
+ externalId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
124
+ status: z.ZodEnum<{
125
+ active: "active";
126
+ inactive: "inactive";
127
+ }>;
128
+ }, z.core.$strip>>;
129
+ }, z.core.$strip>;
130
+ export type ClientLocation = z.infer<typeof ClientLocation>;
131
+ /**
132
+ * Strips the server-flattened fields from a location as it enters the
133
+ * client's cached maps. The wire format keeps the flat fields for
134
+ * compatibility; the cache must not, or devices would keep rendering names
135
+ * flattened before a future-dated version takes effect.
136
+ */
137
+ export declare function toClientLocation(location: Location): ClientLocation;
138
+ /** See {@link toClientLocation}. */
139
+ export declare function toClientAdministrativeArea(area: AdministrativeArea): ClientAdministrativeArea;
140
+ export declare const SeededLocationVersions: z.ZodArray<z.ZodObject<{
141
+ versionId: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
142
+ effectiveFrom: z.ZodISODate;
143
+ name: z.ZodString;
144
+ externalId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
145
+ status: z.ZodEnum<{
146
+ active: "active";
147
+ inactive: "inactive";
148
+ }>;
149
+ }, z.core.$strip>>;
150
+ export type SeededLocationVersions = z.infer<typeof SeededLocationVersions>;
151
+ /**
152
+ * Input payload for the locations `set` mutation. Carries the seedable
153
+ * identity and hierarchy fields, plus an optional pre-built history.
154
+ *
155
+ * Last-write-wins on history: a repeated seed of the same row replaces its
156
+ * stored `versions`, so a caller that means to keep one has to send it every
157
+ * time. Seeding is only reachable while system initialisation is incomplete,
158
+ * so this replaces what an earlier seed attempt wrote, never a live history.
81
159
  */
82
160
  export declare const SetLocationPayload: z.ZodObject<{
83
161
  id: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
@@ -85,18 +163,38 @@ export declare const SetLocationPayload: z.ZodObject<{
85
163
  externalId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
86
164
  administrativeAreaId: z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>;
87
165
  locationType: z.ZodNullable<z.ZodString>;
166
+ versions: z.ZodOptional<z.ZodArray<z.ZodObject<{
167
+ versionId: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
168
+ effectiveFrom: z.ZodISODate;
169
+ name: z.ZodString;
170
+ externalId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
171
+ status: z.ZodEnum<{
172
+ active: "active";
173
+ inactive: "inactive";
174
+ }>;
175
+ }, z.core.$strip>>>;
88
176
  }, z.core.$strip>;
89
177
  export type SetLocationPayload = z.infer<typeof SetLocationPayload>;
90
178
  /**
91
- * Input payload for the administrative areas `set` mutation. Carries only the
92
- * seedable identity and hierarchy fields — version history is managed by the
93
- * server.
179
+ * Input payload for the administrative areas `set` mutation. Twin of
180
+ * {@link SetLocationPayload}, including the optional pre-built `versions`
181
+ * history and the same semantics for omitting it.
94
182
  */
95
183
  export declare const SetAdministrativeAreaPayload: z.ZodObject<{
96
184
  id: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
97
185
  name: z.ZodString;
98
186
  externalId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
99
187
  parentId: z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>;
188
+ versions: z.ZodOptional<z.ZodArray<z.ZodObject<{
189
+ versionId: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
190
+ effectiveFrom: z.ZodISODate;
191
+ name: z.ZodString;
192
+ externalId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
193
+ status: z.ZodEnum<{
194
+ active: "active";
195
+ inactive: "inactive";
196
+ }>;
197
+ }, z.core.$strip>>>;
100
198
  }, z.core.$strip>;
101
199
  export type SetAdministrativeAreaPayload = z.infer<typeof SetAdministrativeAreaPayload>;
102
200
  /**
@@ -111,6 +209,17 @@ export type SetAdministrativeAreaPayload = z.infer<typeof SetAdministrativeAreaP
111
209
  export declare function resolveVersion<T extends {
112
210
  effectiveFrom: string;
113
211
  }>(versions: T[], anchor: string): T;
212
+ /**
213
+ * Whether the entity is selectable at `anchor`: it must already have a
214
+ * version effective by then, and the version that resolves at `anchor` must
215
+ * be active. `resolveVersion` alone is not enough for this — when `anchor`
216
+ * precedes every version it falls back to the earliest one, which would
217
+ * otherwise make a location created after `anchor` look selectable.
218
+ */
219
+ export declare function isSelectableAtAnchor<T extends {
220
+ effectiveFrom: string;
221
+ status: string;
222
+ }>(versions: T[], anchor: string): boolean;
114
223
  /**
115
224
  * Whether the entity holds the given externalId with active status at the
116
225
  * anchor date or at any point after it. Used for point-in-time uniqueness of
@@ -142,7 +251,7 @@ export type EventIndexWithAdministrativeHierarchy = Omit<ToArrayFields<EventInde
142
251
  * Return false early to break out of checks as soon as possible - if any option is not satisfied, the scope does not allow access to the event, so no need to check further options.
143
252
  *
144
253
  */
145
- export declare function canAccessEventWithScope(event: Partial<EventIndexWithAdministrativeHierarchy>, scope: RecordScopeV2, user: UserContext | SystemContext, customActionType?: string): boolean;
254
+ export declare function canAccessEventWithScope(event: EventIndexWithAdministrativeHierarchy, scope: RecordScopeV2, user: UserContext | SystemContext, customActionType?: string): boolean;
146
255
  export type UserWithResolvedHierarchy = {
147
256
  role: string;
148
257
  administrativeHierarchy: UUID[];
@@ -163,21 +272,11 @@ export declare function canAccessOtherUserWithScopes({ scopes, userToAccess, use
163
272
  *
164
273
  * One of the scopes must allow access for the event to be accessible.
165
274
  */
166
- export declare function userCanAccessEventWithScopes(event: Partial<EventIndexWithAdministrativeHierarchy>, scopes: RecordScopeV2[], user: UserContext | SystemContext, customActionType?: string): boolean;
167
- export declare function getAdministrativeAreaHierarchy(administrativeAreaId: string | undefined | null, administrativeAreas: Map<UUID, AdministrativeArea>): {
168
- id: string & z.$brand<"UUID">;
169
- name: string;
170
- externalId?: string | null | undefined;
171
- parentId: (string & z.$brand<"UUID">) | null;
172
- status: "active" | "inactive";
173
- versions: {
174
- versionId: string & z.$brand<"UUID">;
175
- effectiveFrom: string;
176
- name: string;
177
- externalId?: string | null | undefined;
178
- status: "active" | "inactive";
179
- }[];
180
- }[];
275
+ export declare function userCanAccessEventWithScopes(event: EventIndexWithAdministrativeHierarchy, scopes: RecordScopeV2[], user: UserContext | SystemContext, customActionType?: string): boolean;
276
+ export declare function getAdministrativeAreaHierarchy<A extends {
277
+ id: UUID;
278
+ parentId: UUID | null;
279
+ }>(administrativeAreaId: string | undefined | null, administrativeAreas: Map<UUID, A>): A[];
181
280
  /**
182
281
  * Resolves a location or administrative area UUID into a root-first hierarchy of UUIDs.
183
282
  *
@@ -189,8 +288,45 @@ export declare function getAdministrativeAreaHierarchy(administrativeAreaId: str
189
288
  * so the result is reversed to match the root-first convention used by the server.
190
289
  */
191
290
  export declare function getLocationHierarchy(selectedId: UUID, context: {
192
- administrativeAreas: Map<UUID, AdministrativeArea>;
193
- locations: Map<UUID, Location>;
291
+ administrativeAreas: Map<UUID, {
292
+ id: UUID;
293
+ parentId: UUID | null;
294
+ }>;
295
+ locations: Map<UUID, {
296
+ id: UUID;
297
+ administrativeAreaId: UUID | null;
298
+ }>;
194
299
  }): UUID[];
300
+ /**
301
+ * A node of an anchored hierarchy path: the identity id plus the name and
302
+ * status in effect at the anchor date.
303
+ */
304
+ export type ResolvedPathNode = {
305
+ id: UUID;
306
+ name: string;
307
+ status: LocationStatus;
308
+ };
309
+ /**
310
+ * Resolves a location or administrative area id into its root-first
311
+ * hierarchy path — leaf included — with every node's name and status
312
+ * resolved at the anchor date.
313
+ *
314
+ * The parent chain is identity-level and fixed for life, so the chain is
315
+ * constant and only each node's name/status varies with the anchor. Status is
316
+ * returned for callers that filter on it; an inactive node still resolves to
317
+ * its name. Returns an empty array for an unknown id.
318
+ */
319
+ export declare function resolvePath(locationId: UUID, anchor: PlainDate, context: {
320
+ administrativeAreas: Map<UUID, {
321
+ id: UUID;
322
+ parentId: UUID | null;
323
+ versions: LocationVersion[];
324
+ }>;
325
+ locations: Map<UUID, {
326
+ id: UUID;
327
+ administrativeAreaId: UUID | null;
328
+ versions: LocationVersion[];
329
+ }>;
330
+ }): ResolvedPathNode[];
195
331
  export {};
196
332
  //# sourceMappingURL=locations.d.ts.map
@@ -30,4 +30,34 @@ export declare const V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS_MAP: Map<string & impo
30
30
  status: "active" | "inactive";
31
31
  }[];
32
32
  }>;
33
+ /**
34
+ * Stripped view of {@link V2_DEFAULT_MOCK_LOCATIONS_MAP} matching what the
35
+ * client's cached location map actually holds at runtime (identity +
36
+ * versions only). Use this — not the wire-format map above — wherever a test
37
+ * stands in for `useLocations().getLocations.useSuspenseQuery()`.
38
+ */
39
+ export declare const V2_DEFAULT_MOCK_CLIENT_LOCATIONS_MAP: Map<string & import("zod").$brand<"UUID">, {
40
+ id: string & import("zod").$brand<"UUID">;
41
+ administrativeAreaId: (string & import("zod").$brand<"UUID">) | null;
42
+ locationType: string | null;
43
+ versions: {
44
+ versionId: string & import("zod").$brand<"UUID">;
45
+ effectiveFrom: string;
46
+ name: string;
47
+ externalId?: string | null | undefined;
48
+ status: "active" | "inactive";
49
+ }[];
50
+ }>;
51
+ /** See {@link V2_DEFAULT_MOCK_CLIENT_LOCATIONS_MAP}. */
52
+ export declare const V2_DEFAULT_MOCK_CLIENT_ADMINISTRATIVE_AREAS_MAP: Map<string & import("zod").$brand<"UUID">, {
53
+ id: string & import("zod").$brand<"UUID">;
54
+ parentId: (string & import("zod").$brand<"UUID">) | null;
55
+ versions: {
56
+ versionId: string & import("zod").$brand<"UUID">;
57
+ effectiveFrom: string;
58
+ name: string;
59
+ externalId?: string | null | undefined;
60
+ status: "active" | "inactive";
61
+ }[];
62
+ }>;
33
63
  //# sourceMappingURL=mocks.test.utils.d.ts.map
@@ -1,5 +1,6 @@
1
1
  import { UUID } from '../uuid';
2
2
  import { ActionDocument, ActionUpdate } from './ActionDocument';
3
+ import { ValidatorContext } from '../conditionals/validate';
3
4
  import { ApproveCorrectionActionInput, ArchiveActionInput, AssignActionInput, DeclareActionInput, EditActionInput, MarkAsDuplicateActionInput, MarkNotDuplicateActionInput, NotifyActionInput, RegisterActionInput, RejectCorrectionActionInput, RejectDeclarationActionInput, RequestCorrectionActionInput, UnarchiveActionInput, UnassignActionInput } from './ActionInput';
4
5
  import { ActionType } from './ActionType';
5
6
  import { Draft } from './Draft';
@@ -9,7 +10,7 @@ import { EventIndex } from './EventIndex';
9
10
  import { EventInput } from './EventInput';
10
11
  import { TranslationConfig } from './TranslationConfig';
11
12
  import { FieldConfig } from './FieldConfig';
12
- import { SetLocationPayload, SetAdministrativeAreaPayload } from './locations';
13
+ import { LocationVersion, SetLocationPayload, SetAdministrativeAreaPayload, ClientAdministrativeArea } from './locations';
13
14
  import { WorkqueueConfig } from './WorkqueueConfig';
14
15
  import * as z from 'zod/v4';
15
16
  import { DocumentPath } from '../documents';
@@ -43,6 +44,13 @@ export declare function generateUuid(rng?: () => number): UUID;
43
44
  export declare function generateTrackingId(rng: () => number): string;
44
45
  export declare function generateRegistrationNumber(rng: () => number): string;
45
46
  export declare function generateRandomSignature(rng: () => number): DocumentPath;
47
+ /**
48
+ * Builds one element of a location / administrative area `versions` history.
49
+ * Every field is defaulted so a call names only what its assertion is about —
50
+ * an `effectiveFrom`, a `name`, or an explicit `versionId` when the test needs
51
+ * to control version identity.
52
+ */
53
+ export declare function locationVersion(overrides?: Partial<LocationVersion>, rng?: () => number): LocationVersion;
46
54
  export declare function fieldConfigsToActionPayload(fields: FieldConfig[], rng: () => number,
47
55
  /**
48
56
  * Given hierarchy, ensures that related fields (e.g. location and administrative area) have valid values based on the hierarchy.
@@ -77,8 +85,11 @@ export declare function eventPayloadGenerator(rng: () => number, configuration?:
77
85
  omitFields?: string[];
78
86
  }, input?: Partial<Draft>) => Draft;
79
87
  actions: {
80
- declare: (eventId: string, input?: Partial<Pick<DeclareActionInput, 'transactionId' | 'declaration' | 'annotation' | 'keepAssignment'>>) => {
88
+ declare: (eventId: string, input?: Partial<Pick<DeclareActionInput, 'transactionId' | 'declaration' | 'annotation' | 'keepAssignment' | 'keepAssignmentIfAccepted' | 'keepAssignmentIfRejected' | 'waitFor'>>) => {
81
89
  keepAssignment?: boolean | undefined;
90
+ keepAssignmentIfAccepted?: boolean | undefined;
91
+ keepAssignmentIfRejected?: boolean | undefined;
92
+ waitFor?: boolean | undefined;
82
93
  type: "DECLARE";
83
94
  transactionId: string;
84
95
  declaration: Record<string, import("./FieldValue").FieldUpdateValue>;
@@ -88,56 +99,69 @@ export declare function eventPayloadGenerator(rng: () => number, configuration?:
88
99
  /**
89
100
  * Notify allows sending incomplete data. Think it as 'partial declare' for now.
90
101
  */
91
- notify: (eventId: string, input?: Partial<Pick<NotifyActionInput, 'transactionId' | 'declaration' | 'keepAssignment'>>) => {
102
+ notify: (eventId: string, input?: Partial<Pick<NotifyActionInput, 'transactionId' | 'declaration' | 'keepAssignment' | 'keepAssignmentIfRejected' | 'keepAssignmentIfAccepted' | 'waitFor'>>) => {
92
103
  type: "NOTIFY";
93
104
  transactionId: string;
94
105
  declaration: Record<string, import("./FieldValue").FieldUpdateValue>;
95
106
  eventId: string;
96
107
  keepAssignment: boolean | undefined;
108
+ keepAssignmentIfAccepted: boolean | undefined;
109
+ keepAssignmentIfRejected: boolean | undefined;
97
110
  };
98
- edit: (eventId: string, input?: Partial<Pick<EditActionInput, 'transactionId' | 'declaration' | 'annotation' | 'keepAssignment'>>) => {
111
+ edit: (eventId: string, input?: Partial<Pick<EditActionInput, 'transactionId' | 'declaration' | 'annotation' | 'keepAssignment' | 'keepAssignmentIfAccepted' | 'keepAssignmentIfRejected' | 'waitFor'>>) => {
99
112
  keepAssignment?: boolean | undefined;
113
+ keepAssignmentIfAccepted?: boolean | undefined;
114
+ keepAssignmentIfRejected?: boolean | undefined;
115
+ waitFor?: boolean | undefined;
100
116
  type: "EDIT";
101
117
  transactionId: string;
102
118
  declaration: Record<string, import("./FieldValue").FieldUpdateValue>;
103
119
  annotation: {};
104
120
  eventId: string;
105
121
  };
106
- assign: (eventId: string, input?: Partial<Pick<AssignActionInput, 'transactionId' | 'assignedTo'>>) => {
122
+ assign: (eventId: string, input?: Partial<Pick<AssignActionInput, 'transactionId' | 'assignedTo' | 'waitFor'>>) => {
107
123
  type: "ASSIGN";
108
124
  transactionId: string;
109
125
  declaration: {};
110
126
  assignedTo: string;
111
127
  eventId: string;
128
+ waitFor: boolean | undefined;
112
129
  };
113
- unassign: (eventId: string, input?: Partial<Pick<UnassignActionInput, 'transactionId'>>) => {
130
+ unassign: (eventId: string, input?: Partial<Pick<UnassignActionInput, 'transactionId' | 'waitFor'>>) => {
114
131
  type: "UNASSIGN";
115
132
  transactionId: string;
116
133
  declaration: {};
117
134
  assignedTo: null;
118
135
  eventId: string;
136
+ waitFor: boolean | undefined;
119
137
  };
120
- archive: (eventId: string, input?: Partial<Pick<ArchiveActionInput, 'transactionId' | 'declaration' | 'keepAssignment'>>) => {
138
+ archive: (eventId: string, input?: Partial<Pick<ArchiveActionInput, 'transactionId' | 'declaration' | 'keepAssignment' | 'keepAssignmentIfRejected' | 'keepAssignmentIfAccepted' | 'waitFor'>>) => {
121
139
  keepAssignment?: boolean | undefined;
140
+ keepAssignmentIfAccepted?: boolean | undefined;
141
+ keepAssignmentIfRejected?: boolean | undefined;
142
+ waitFor?: boolean | undefined;
122
143
  type: "ARCHIVE";
123
144
  transactionId: string;
124
145
  declaration: {};
125
146
  annotation: {};
126
147
  eventId: string;
127
- content: {
128
- reason: string;
129
- };
130
148
  };
131
- unarchive: (eventId: string, input?: Partial<Pick<UnarchiveActionInput, 'transactionId' | 'declaration' | 'keepAssignment'>>) => {
149
+ unarchive: (eventId: string, input?: Partial<Pick<UnarchiveActionInput, 'transactionId' | 'declaration' | 'keepAssignment' | 'keepAssignmentIfRejected' | 'keepAssignmentIfAccepted' | 'waitFor'>>) => {
132
150
  keepAssignment?: boolean | undefined;
151
+ keepAssignmentIfAccepted?: boolean | undefined;
152
+ keepAssignmentIfRejected?: boolean | undefined;
153
+ waitFor?: boolean | undefined;
133
154
  type: "UNARCHIVE";
134
155
  transactionId: string;
135
156
  declaration: {};
136
157
  annotation: {};
137
158
  eventId: string;
138
159
  };
139
- reject: (eventId: string, input?: Partial<Pick<RejectDeclarationActionInput, 'transactionId' | 'annotation' | 'keepAssignment'>>) => {
160
+ reject: (eventId: string, input?: Partial<Pick<RejectDeclarationActionInput, 'transactionId' | 'annotation' | 'keepAssignment' | 'keepAssignmentIfAccepted' | 'keepAssignmentIfRejected' | 'waitFor'>>) => {
140
161
  keepAssignment?: boolean | undefined;
162
+ keepAssignmentIfAccepted?: boolean | undefined;
163
+ keepAssignmentIfRejected?: boolean | undefined;
164
+ waitFor?: boolean | undefined;
141
165
  type: "REJECT";
142
166
  transactionId: string;
143
167
  declaration: {};
@@ -147,8 +171,11 @@ export declare function eventPayloadGenerator(rng: () => number, configuration?:
147
171
  reason: string;
148
172
  };
149
173
  };
150
- register: (eventId: string, input?: Partial<Pick<RegisterActionInput, 'transactionId' | 'declaration' | 'annotation' | 'keepAssignment' | 'registrationNumber'>>) => {
174
+ register: (eventId: string, input?: Partial<Pick<RegisterActionInput, 'transactionId' | 'declaration' | 'annotation' | 'keepAssignment' | 'registrationNumber' | 'keepAssignmentIfAccepted' | 'keepAssignmentIfRejected' | 'waitFor'>>) => {
151
175
  keepAssignment?: boolean | undefined;
176
+ keepAssignmentIfAccepted?: boolean | undefined;
177
+ keepAssignmentIfRejected?: boolean | undefined;
178
+ waitFor?: boolean | undefined;
152
179
  registrationNumber?: string | undefined;
153
180
  type: "REGISTER";
154
181
  transactionId: string;
@@ -156,8 +183,11 @@ export declare function eventPayloadGenerator(rng: () => number, configuration?:
156
183
  annotation: {};
157
184
  eventId: string;
158
185
  };
159
- printCertificate: (eventId: string, input?: Partial<Pick<RegisterActionInput, 'transactionId' | 'annotation' | 'keepAssignment'>>) => {
186
+ printCertificate: (eventId: string, input?: Partial<Pick<RegisterActionInput, 'transactionId' | 'annotation' | 'keepAssignment' | 'keepAssignmentIfRejected' | 'keepAssignmentIfAccepted' | 'waitFor'>>) => {
160
187
  keepAssignment?: boolean | undefined;
188
+ keepAssignmentIfAccepted?: boolean | undefined;
189
+ keepAssignmentIfRejected?: boolean | undefined;
190
+ waitFor?: boolean | undefined;
161
191
  type: "PRINT_CERTIFICATE";
162
192
  transactionId: string;
163
193
  declaration: {};
@@ -165,15 +195,18 @@ export declare function eventPayloadGenerator(rng: () => number, configuration?:
165
195
  eventId: string;
166
196
  };
167
197
  correction: {
168
- request: (eventId: string, input?: Partial<Pick<RequestCorrectionActionInput, 'transactionId' | 'declaration' | 'annotation' | 'keepAssignment'>>) => {
198
+ request: (eventId: string, input?: Partial<Pick<RequestCorrectionActionInput, 'transactionId' | 'declaration' | 'annotation' | 'keepAssignment' | 'keepAssignmentIfRejected' | 'keepAssignmentIfAccepted' | 'waitFor'>>) => {
169
199
  type: "REQUEST_CORRECTION";
170
200
  transactionId: string;
171
201
  declaration: import("lodash").Omit<Record<string, import("./FieldValue").FieldUpdateValue>, "applicant.email" | "applicant.image">;
172
202
  annotation: {};
173
203
  eventId: string;
174
204
  keepAssignment: boolean | undefined;
205
+ keepAssignmentIfAccepted: boolean | undefined;
206
+ keepAssignmentIfRejected: boolean | undefined;
207
+ waitFor: boolean | undefined;
175
208
  };
176
- approve: (eventId: string, requestId: string, input?: Partial<Pick<ApproveCorrectionActionInput, 'transactionId' | 'annotation' | 'keepAssignment'>>) => {
209
+ approve: (eventId: string, requestId: string, input?: Partial<Pick<ApproveCorrectionActionInput, 'transactionId' | 'annotation' | 'keepAssignment' | 'keepAssignmentIfRejected' | 'keepAssignmentIfAccepted' | 'waitFor'>>) => {
177
210
  type: "APPROVE_CORRECTION";
178
211
  transactionId: string;
179
212
  declaration: {};
@@ -181,18 +214,24 @@ export declare function eventPayloadGenerator(rng: () => number, configuration?:
181
214
  eventId: string;
182
215
  requestId: string;
183
216
  keepAssignment: boolean | undefined;
217
+ keepAssignmentIfAccepted: boolean | undefined;
218
+ keepAssignmentIfRejected: boolean | undefined;
219
+ waitFor: boolean | undefined;
184
220
  };
185
- reject: (eventId: string, requestId: string, input: Partial<Pick<RejectCorrectionActionInput, 'transactionId' | 'annotation' | 'keepAssignment' | 'content'>>) => {
221
+ reject: (eventId: string, requestId: string, input: Partial<Pick<RejectCorrectionActionInput, 'transactionId' | 'annotation' | 'content' | 'keepAssignment' | 'keepAssignmentIfRejected' | 'keepAssignmentIfAccepted' | 'waitFor'>>) => {
186
222
  type: "REJECT_CORRECTION";
187
223
  transactionId: string;
188
224
  declaration: {};
189
225
  annotation: {};
190
226
  eventId: string;
191
227
  requestId: string;
192
- keepAssignment: boolean | undefined;
193
228
  content: {
194
229
  reason: string;
195
230
  };
231
+ keepAssignment: boolean | undefined;
232
+ keepAssignmentIfAccepted: boolean | undefined;
233
+ keepAssignmentIfRejected: boolean | undefined;
234
+ waitFor: boolean | undefined;
196
235
  };
197
236
  };
198
237
  duplicate: {
@@ -291,4 +330,20 @@ export declare const generateEventConfig: ({ id, fields, placeOfEventId, dateOfE
291
330
  placeOfEventId?: string;
292
331
  dateOfEventId?: string;
293
332
  }) => EventConfig;
333
+ /**
334
+ * Get the leaf administrative area IDs from a list of administrative areas.
335
+ *
336
+ * A leaf administrative area is defined as an administrative area that does not have any children in the provided list.
337
+ * AdministrativeArea might have a CRVS_OFFICE as children, but is still considered to be a leaf administrative area.
338
+ *
339
+ * @param administrativeAreas - The list of administrative areas to search.
340
+ * @returns The list of leaf administrative area IDs.
341
+ */
342
+ export declare function getLeafAdministrativeAreaIds(administrativeAreas: Map<UUID, ClientAdministrativeArea>): Array<{
343
+ id: UUID;
344
+ }>;
345
+ export declare function generateTestValidatorContext(userRole?: TestUserRole, eventWithConfig?: {
346
+ event: EventDocument;
347
+ eventConfig: EventConfig;
348
+ }): ValidatorContext;
294
349
  //# sourceMappingURL=test.utils.d.ts.map
@@ -10,6 +10,7 @@ import { UUID } from '../uuid';
10
10
  import { ActionConfig, ActionConfigTypes } from './ActionConfig';
11
11
  import { FormConfig } from './FormConfig';
12
12
  import { PlainDate, SelectDateRangeValue } from './FieldValue';
13
+ import { EventIndex } from './EventIndex';
13
14
  export declare function ageToDate(age: number, asOfDate: PlainDate): string & import("zod").$brand<"PlainDate">;
14
15
  export declare function getDeclarationFields(configuration: EventConfig): FieldConfig[];
15
16
  export declare function getDeclarationPages(configuration: EventConfig): {
@@ -20,6 +21,7 @@ export declare function getDeclarationPages(configuration: EventConfig): {
20
21
  description: string;
21
22
  };
22
23
  requireCompletionToContinue: boolean;
24
+ showClearButton?: boolean | undefined;
23
25
  fields: FieldConfig[];
24
26
  conditional?: any;
25
27
  type: "FORM";
@@ -38,6 +40,7 @@ export declare function getDeclaration(configuration: EventConfig): {
38
40
  description: string;
39
41
  };
40
42
  requireCompletionToContinue: boolean;
43
+ showClearButton?: boolean | undefined;
41
44
  fields: FieldConfig[];
42
45
  conditional?: any;
43
46
  type: "FORM";
@@ -66,6 +69,7 @@ export declare function getPrintCertificatePages(configuration: EventConfig): ({
66
69
  description: string;
67
70
  };
68
71
  requireCompletionToContinue: boolean;
72
+ showClearButton?: boolean | undefined;
69
73
  fields: FieldConfig[];
70
74
  conditional?: any;
71
75
  type: "FORM";
@@ -77,6 +81,7 @@ export declare function getPrintCertificatePages(configuration: EventConfig): ({
77
81
  description: string;
78
82
  };
79
83
  requireCompletionToContinue: boolean;
84
+ showClearButton?: boolean | undefined;
80
85
  fields: FieldConfig[];
81
86
  conditional?: any;
82
87
  type: "VERIFICATION";
@@ -255,9 +260,9 @@ export declare function findLastAssignmentAction(actions: Action[]): {
255
260
  status: "Accepted" | "Rejected" | "Requested";
256
261
  originalActionId?: (string & import("zod").$brand<"UUID">) | null | undefined;
257
262
  type: "ARCHIVE";
258
- content: {
263
+ content?: {
259
264
  reason: string;
260
- };
265
+ } | undefined;
261
266
  } | {
262
267
  id: string & import("zod").$brand<"UUID">;
263
268
  transactionId: string;
@@ -358,7 +363,7 @@ export declare function findLastAssignmentAction(actions: Action[]): {
358
363
  status: "Accepted" | "Rejected" | "Requested";
359
364
  originalActionId?: (string & import("zod").$brand<"UUID">) | null | undefined;
360
365
  type: "APPROVE_CORRECTION";
361
- requestId: string;
366
+ requestId: string & import("zod").$brand<"UUID">;
362
367
  content?: {
363
368
  immediateCorrection?: boolean | undefined;
364
369
  } | undefined;
@@ -376,7 +381,7 @@ export declare function findLastAssignmentAction(actions: Action[]): {
376
381
  status: "Accepted" | "Rejected" | "Requested";
377
382
  originalActionId?: (string & import("zod").$brand<"UUID">) | null | undefined;
378
383
  type: "REJECT_CORRECTION";
379
- requestId: string;
384
+ requestId: string & import("zod").$brand<"UUID">;
380
385
  content: {
381
386
  reason: string;
382
387
  };
@@ -596,5 +601,30 @@ export declare function getCompleteActionContent(event: EventDocument, action: A
596
601
  export declare function getCompleteActionDeclaration<T extends EventState | ActionUpdate>(declaration: T, event: EventDocument, action: ActionDocument): T;
597
602
  export declare function getAcceptedActions(event: EventDocument): ActionDocument[];
598
603
  export declare function aggregateActionDeclarations(event: EventDocument): EventState;
604
+ /**
605
+ * Returns the event's declaration state as it will be once the single pending
606
+ * action is accepted — i.e. the aggregate of all accepted declarations with the
607
+ * pending action's changes applied on top.
608
+ *
609
+ * Country configuration confirmation handlers (and notifications) need the
610
+ * up-to-date declaration at confirmation time, before core has accepted the
611
+ * action. Reaching for `aggregateActionDeclarations` alone is not enough for
612
+ * corrections: when confirming an APPROVE_CORRECTION the changed fields live on
613
+ * the linked REQUEST_CORRECTION, not on the pending action's own (empty)
614
+ * declaration. This helper applies the same correction-aware merge that
615
+ * `aggregateActionDeclarations` uses for already-accepted approvals, so callers
616
+ * do not have to reimplement the `requestId`/`originalActionId` resolution.
617
+ */
618
+ export declare function getDeclarationWithPendingAction(event: EventDocument): EventState;
599
619
  export declare function aggregateActionAnnotations(event: EventDocument): EventState;
620
+ /**
621
+ * 2.1. onwards secured fields have accepted conditionals.
622
+ * Secured fields are not present in EventIndex payload.
623
+ * When we derive @see EventIndex from @see EventDocument, we will have all the fields present.
624
+ *
625
+ * To keep the views consistent, and not to change if event.get gets triggered, we need to clean out the secured fields.
626
+ *
627
+ * @returns EventIndex without values that evaluate to secured: true.
628
+ */
629
+ export declare function dropSecuredDeclarationFields(eventConfig: EventConfig, eventIndex: EventIndex, validatorContext: ValidatorContext): EventIndex;
600
630
  //# sourceMappingURL=utils.d.ts.map