@opencrvs/toolkit 2.1.0-rc.c498f10 → 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 (121) 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 +348 -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 +758 -128
  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 +36 -12
  20. package/dist/commons/events/AuditLog.d.ts +147 -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 +99 -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/index.d.ts +1 -0
  37. package/dist/commons/events/locationPayloads.d.ts +95 -0
  38. package/dist/commons/events/locations.d.ts +246 -13
  39. package/dist/commons/events/mocks.test.utils.d.ts +46 -2
  40. package/dist/commons/events/test.utils.d.ts +77 -22
  41. package/dist/commons/events/utils.d.ts +34 -4
  42. package/dist/commons/notification/UserNotifications.d.ts +28 -13
  43. package/dist/commons/notification/dispatch.d.ts +10 -0
  44. package/dist/commons/notification/index.d.ts +1 -0
  45. package/dist/conditionals/index.js +335 -64
  46. package/dist/csv.d.ts +25 -0
  47. package/dist/csv.d.ts.map +1 -0
  48. package/dist/csv.js +120 -0
  49. package/dist/environment/index.d.ts +1 -0
  50. package/dist/environment/index.d.ts.map +1 -1
  51. package/dist/environment/index.js +12 -1
  52. package/dist/environment/logger.d.ts +15 -3
  53. package/dist/environment/logger.d.ts.map +1 -1
  54. package/dist/environment/manage-users.js +1 -1
  55. package/dist/environment/paths.d.ts +7 -0
  56. package/dist/environment/paths.d.ts.map +1 -0
  57. package/dist/environment/paths.js +72 -0
  58. package/dist/environment/questions.d.ts.map +1 -1
  59. package/dist/environment/questions.js +20 -14
  60. package/dist/environment/setup-environment.d.ts +1 -1
  61. package/dist/environment/setup-environment.d.ts.map +1 -1
  62. package/dist/environment/setup-environment.js +587 -562
  63. package/dist/environment/templates.d.ts +0 -1
  64. package/dist/environment/templates.d.ts.map +1 -1
  65. package/dist/environment/templates.js +5 -9
  66. package/dist/environment/update-workflows.d.ts.map +1 -1
  67. package/dist/environment/update-workflows.js +21 -5
  68. package/dist/environment/upgrade.d.ts +2 -0
  69. package/dist/environment/upgrade.d.ts.map +1 -0
  70. package/dist/environment/upgrade.js +82 -0
  71. package/dist/environment/users.js +11 -13
  72. package/dist/environment/utils.d.ts +0 -12
  73. package/dist/environment/utils.d.ts.map +1 -1
  74. package/dist/environment/utils.js +1 -28
  75. package/dist/events/index.js +7709 -7146
  76. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +2 -2
  77. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
  78. package/dist/migrations/v2.0/checkout-upstream-files.js +2 -2
  79. package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts.map +1 -1
  80. package/dist/migrations/v2.0/convert-config-files-to-ts.js +3 -10
  81. package/dist/migrations/v2.0/merge-infrastructure-directory.js +3 -3
  82. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts +3 -0
  83. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts.map +1 -0
  84. package/dist/migrations/v2.1/add-recovery-link-notifications.js +511 -0
  85. package/dist/migrations/v2.1/add-translations.d.ts +9 -0
  86. package/dist/migrations/v2.1/add-translations.d.ts.map +1 -0
  87. package/dist/migrations/v2.1/add-translations.js +149 -0
  88. package/dist/migrations/v2.1/enable-telemetry.d.ts +3 -0
  89. package/dist/migrations/v2.1/enable-telemetry.d.ts.map +1 -0
  90. package/dist/migrations/v2.1/enable-telemetry.js +455 -0
  91. package/dist/migrations/v2.1/index.d.ts.map +1 -1
  92. package/dist/migrations/v2.1/index.js +1223 -0
  93. package/dist/migrations/v2.1/rename-trigger-paths.d.ts +3 -0
  94. package/dist/migrations/v2.1/rename-trigger-paths.d.ts.map +1 -0
  95. package/dist/migrations/v2.1/rename-trigger-paths.js +216 -0
  96. package/dist/notification/index.js +1878 -1465
  97. package/dist/scopes/index.d.ts +435 -36
  98. package/dist/scopes/index.js +336 -64
  99. package/dist/telemetry/index.d.ts +45 -0
  100. package/dist/telemetry/index.d.ts.map +1 -0
  101. package/dist/telemetry/index.js +43 -0
  102. package/dist/templates/charts-values/dependencies/values.yaml +2 -0
  103. package/dist/templates/charts-values/opencrvs-services/values.yaml +4 -3
  104. package/dist/templates/charts-values/opentelemetry/values.yaml +102 -0
  105. package/dist/templates/charts-values/traefik/values.yaml +23 -9
  106. package/dist/templates/inventory/inventory.template.yml +1 -3
  107. package/dist/translations/template.d.ts +11 -0
  108. package/dist/translations/template.d.ts.map +1 -0
  109. package/dist/translations/template.js +100 -0
  110. package/dist/verify/endpoints.d.ts +2 -0
  111. package/dist/verify/endpoints.d.ts.map +1 -0
  112. package/dist/verify/endpoints.js +510 -0
  113. package/opencrvs-toolkit-2.1.0-rc.c500a81.tgz +0 -0
  114. package/package.json +13 -6
  115. package/tsconfig.build.json +11 -0
  116. package/tsconfig.build.tsbuildinfo +1 -0
  117. package/tsconfig.json +3 -0
  118. package/dist/templates/inventory/production.example.yml +0 -77
  119. package/dist/templates/inventory/qa.example.yml +0 -48
  120. package/opencrvs-toolkit-2.1.0-rc.c498f10.tgz +0 -0
  121. package/tsconfig.tsbuildinfo +0 -1
@@ -59,10 +59,10 @@ __export(scopes_exports, {
59
59
  scopeUsesRoleOptions: () => scopeUsesRoleOptions
60
60
  });
61
61
  module.exports = __toCommonJS(scopes_exports);
62
- var z4 = __toESM(require("zod/v4"));
62
+ var z9 = __toESM(require("zod/v4"));
63
63
 
64
64
  // ../commons/src/scopes.ts
65
- var z3 = __toESM(require("zod/v4"));
65
+ var z8 = __toESM(require("zod/v4"));
66
66
  var qs = __toESM(require("qs"));
67
67
 
68
68
  // ../commons/src/uuid.ts
@@ -96,12 +96,267 @@ var getTokenPayload = (token) => {
96
96
  };
97
97
  var TokenWithBearer = z2.string().regex(/^Bearer\s/);
98
98
 
99
+ // ../commons/src/events/ActionType.ts
100
+ var z3 = __toESM(require("zod/v4"));
101
+ var ActionType = {
102
+ // Pre-declaration actions
103
+ DELETE: "DELETE",
104
+ CREATE: "CREATE",
105
+ NOTIFY: "NOTIFY",
106
+ // Declaration actions
107
+ DECLARE: "DECLARE",
108
+ REGISTER: "REGISTER",
109
+ EDIT: "EDIT",
110
+ // Declaration system actions. Non-configurable.
111
+ DUPLICATE_DETECTED: "DUPLICATE_DETECTED",
112
+ REJECT: "REJECT",
113
+ // REJECT_DECLARATION
114
+ MARK_AS_DUPLICATE: "MARK_AS_DUPLICATE",
115
+ MARK_AS_NOT_DUPLICATE: "MARK_AS_NOT_DUPLICATE",
116
+ ARCHIVE: "ARCHIVE",
117
+ UNARCHIVE: "UNARCHIVE",
118
+ // Record actions
119
+ PRINT_CERTIFICATE: "PRINT_CERTIFICATE",
120
+ REQUEST_CORRECTION: "REQUEST_CORRECTION",
121
+ REJECT_CORRECTION: "REJECT_CORRECTION",
122
+ APPROVE_CORRECTION: "APPROVE_CORRECTION",
123
+ // General actions
124
+ READ: "READ",
125
+ ASSIGN: "ASSIGN",
126
+ UNASSIGN: "UNASSIGN",
127
+ // Custom action
128
+ CUSTOM: "CUSTOM"
129
+ };
130
+ var ConfirmableActions = [
131
+ ActionType.NOTIFY,
132
+ ActionType.DECLARE,
133
+ ActionType.EDIT,
134
+ ActionType.REGISTER,
135
+ ActionType.REJECT,
136
+ ActionType.ARCHIVE,
137
+ ActionType.UNARCHIVE,
138
+ ActionType.PRINT_CERTIFICATE,
139
+ ActionType.REQUEST_CORRECTION,
140
+ ActionType.APPROVE_CORRECTION,
141
+ ActionType.REJECT_CORRECTION,
142
+ ActionType.CUSTOM
143
+ ];
144
+ var ActionTypes = z3.enum([
145
+ "DELETE",
146
+ "CREATE",
147
+ "NOTIFY",
148
+ "DECLARE",
149
+ "EDIT",
150
+ "REGISTER",
151
+ "DUPLICATE_DETECTED",
152
+ "REJECT",
153
+ "MARK_AS_DUPLICATE",
154
+ "MARK_AS_NOT_DUPLICATE",
155
+ "ARCHIVE",
156
+ "UNARCHIVE",
157
+ "PRINT_CERTIFICATE",
158
+ "REQUEST_CORRECTION",
159
+ "REJECT_CORRECTION",
160
+ "APPROVE_CORRECTION",
161
+ "READ",
162
+ "ASSIGN",
163
+ "UNASSIGN",
164
+ "CUSTOM"
165
+ ]);
166
+ var declarationActionValues = [
167
+ ActionTypes.enum.DECLARE,
168
+ ActionTypes.enum.EDIT,
169
+ ActionTypes.enum.REGISTER,
170
+ ActionTypes.enum.NOTIFY,
171
+ ActionTypes.enum.DUPLICATE_DETECTED
172
+ ];
173
+ var DeclarationActions = ActionTypes.extract(declarationActionValues);
174
+ var declarationUpdateActionValues = [
175
+ ...declarationActionValues,
176
+ ActionTypes.enum.REQUEST_CORRECTION
177
+ ];
178
+ var DeclarationUpdateActions = ActionTypes.extract(
179
+ declarationUpdateActionValues
180
+ );
181
+ var annotationActions = ActionTypes.exclude(declarationActionValues);
182
+ var writeActions = ActionTypes.exclude([
183
+ ActionType.CREATE,
184
+ ActionType.READ,
185
+ ActionType.ASSIGN,
186
+ ActionType.UNASSIGN
187
+ ]);
188
+ var WorkqueueActionType = ActionTypes.extract([
189
+ ActionType.READ,
190
+ ActionType.DELETE,
191
+ ActionType.DECLARE,
192
+ ActionType.REGISTER,
193
+ ActionType.EDIT,
194
+ ActionType.REJECT,
195
+ ActionType.MARK_AS_DUPLICATE,
196
+ ActionType.ARCHIVE,
197
+ ActionType.UNARCHIVE,
198
+ ActionType.PRINT_CERTIFICATE,
199
+ ActionType.REQUEST_CORRECTION
200
+ ]);
201
+ var META_ACTIONS = [
202
+ ActionType.ASSIGN,
203
+ ActionType.UNASSIGN,
204
+ ActionType.READ
205
+ ];
206
+
207
+ // ../commons/src/events/ActionStatus.ts
208
+ var ActionStatus = {
209
+ Requested: "Requested",
210
+ Accepted: "Accepted",
211
+ Rejected: "Rejected"
212
+ };
213
+
214
+ // ../commons/src/events/Flag.ts
215
+ var z6 = __toESM(require("zod/v4"));
216
+
217
+ // ../commons/src/events/TranslationConfig.ts
218
+ var z4 = __toESM(require("zod/v4"));
219
+ var TranslationConfig = z4.object({
220
+ id: z4.string().describe(
221
+ "The identifier of the translation referred in translation CSV files"
222
+ ),
223
+ defaultMessage: z4.string().describe("Default translation message"),
224
+ description: z4.string().describe(
225
+ "Describe the translation for a translator to be able to identify it."
226
+ )
227
+ }).meta({
228
+ description: "Translation configuration",
229
+ id: "TranslationConfig"
230
+ });
231
+
232
+ // ../commons/src/events/Conditional.ts
233
+ var z5 = __toESM(require("zod/v4"));
234
+ var Conditional = z5.any().describe("JSONSchema").meta({
235
+ description: "JSON schema conditional configuration",
236
+ id: "Conditional"
237
+ });
238
+ var ConditionalType = {
239
+ SHOW: "SHOW",
240
+ ENABLE: "ENABLE",
241
+ DISPLAY_ON_REVIEW: "DISPLAY_ON_REVIEW"
242
+ };
243
+ var ShowConditional = z5.object({
244
+ type: z5.literal(ConditionalType.SHOW),
245
+ conditional: Conditional
246
+ }).describe(
247
+ "If 'SHOW' conditional is defined, the component is shown to the user only if the condition is met"
248
+ );
249
+ var EnableConditional = z5.object({
250
+ type: z5.literal(ConditionalType.ENABLE),
251
+ conditional: Conditional
252
+ }).describe(
253
+ "If 'ENABLE' conditional is defined, the component is enabled only if the condition is met"
254
+ );
255
+ var ActionConditional = z5.discriminatedUnion("type", [
256
+ // Action can be shown / hidden
257
+ ShowConditional,
258
+ // Action can be shown to the user in the list but as disabled
259
+ EnableConditional
260
+ ]).meta({
261
+ id: "ActionConditional",
262
+ description: "Conditional gating whether an action is shown (SHOW) or enabled (ENABLE). When omitted from an action, the action is shown and enabled for everyone."
263
+ });
264
+ var DisplayOnReviewConditional = z5.object({
265
+ type: z5.literal(ConditionalType.DISPLAY_ON_REVIEW),
266
+ conditional: Conditional
267
+ }).describe(
268
+ "If 'DISPLAY_ON_REVIEW' conditional is defined, the component is shown on the review page only if both the 'DISPLAY_ON_REVIEW' and 'SHOW' conditions are met. This should only be used for fields within declaration forms, as they are the only ones with review pages."
269
+ );
270
+ var FieldConditional = z5.discriminatedUnion("type", [
271
+ // Field input can be shown / hidden
272
+ ShowConditional,
273
+ // Field input can be shown to the user but as disabled
274
+ EnableConditional,
275
+ // Field output can be shown / hidden on the review page
276
+ DisplayOnReviewConditional
277
+ ]).meta({
278
+ id: "FieldConditional",
279
+ description: "Conditional gating whether a form field is shown (SHOW), enabled (ENABLE), or displayed on the review page (DISPLAY_ON_REVIEW). When omitted, the field is shown and enabled for everyone, and is displayed on review whenever it has a value."
280
+ });
281
+
282
+ // ../commons/src/events/Flag.ts
283
+ var InherentFlags = {
284
+ INCOMPLETE: "incomplete",
285
+ REJECTED: "rejected",
286
+ CORRECTION_REQUESTED: "correction-requested",
287
+ POTENTIAL_DUPLICATE: "potential-duplicate",
288
+ /**
289
+ * This flag is set by the Edit-action and removed after the declaration or registration.
290
+ * A record should never stay with the EDIT_IN_PROGRESS flag, since it should always be declared or registered right after.
291
+ *
292
+ * We only use this flag to determine that a NOTIFY, DECLARE or REGISTER action is allowed next.
293
+ */
294
+ EDIT_IN_PROGRESS: "edit-in-progress"
295
+ };
296
+ var actionFlagPattern;
297
+ function getActionFlagPattern() {
298
+ actionFlagPattern ??= new RegExp(
299
+ `^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(
300
+ ActionStatus
301
+ ).join("|").toLowerCase()})$`
302
+ );
303
+ return actionFlagPattern;
304
+ }
305
+ var ActionFlag = z6.string().refine((value) => getActionFlagPattern().test(value), {
306
+ message: "Flag must be in the format ActionType:ActionStatus (lowerCase)"
307
+ });
308
+ var CustomFlag = z6.string().refine((val) => !Object.values(InherentFlags).includes(val), {
309
+ message: `Custom flag cannot be one of the inherent flags: ${Object.values(
310
+ InherentFlags
311
+ ).join(", ")}`
312
+ }).refine((val) => !ActionFlag.safeParse(val).success, {
313
+ message: "Custom flag cannot match the ActionFlag pattern (ActionType:ActionStatus)."
314
+ }).describe("Custom flag identifier defined by the country config.");
315
+ var Flag = ActionFlag.or(z6.enum(InherentFlags)).or(CustomFlag);
316
+ var ContainsFlags = z6.object({
317
+ anyOf: z6.array(Flag).optional(),
318
+ noneOf: z6.array(Flag).optional(),
319
+ allOf: z6.array(Flag).optional()
320
+ }).meta({
321
+ id: "ContainsFlags"
322
+ });
323
+ var FlagConfig = z6.object({
324
+ id: CustomFlag,
325
+ requiresAction: z6.boolean().describe(
326
+ "Indicates if this flag expects an action to be performed to be cleared."
327
+ ),
328
+ label: TranslationConfig.describe("Human readable label of the flag.")
329
+ }).meta({
330
+ id: "FlagConfig",
331
+ description: "Configuration for a custom flag that can be added to or removed from records by event actions."
332
+ });
333
+ var ActionFlagConfig = z6.object({
334
+ id: Flag,
335
+ operation: z6.enum(["add", "remove"]).describe("Operation to perform on the flag."),
336
+ conditional: Conditional.optional().describe(
337
+ "When conditional is met, the operation is performed on the flag. If not provided, the operation is performed unconditionally."
338
+ )
339
+ }).meta({
340
+ id: "ActionFlagConfig",
341
+ description: "Add or remove operation applied to a flag when the parent action is accepted. Optionally gated by a conditional."
342
+ });
343
+
344
+ // ../commons/src/events/EventStatus.ts
345
+ var z7 = __toESM(require("zod/v4"));
346
+ var EventStatus = z7.enum([
347
+ "CREATED",
348
+ "NOTIFIED",
349
+ "DECLARED",
350
+ "REGISTERED",
351
+ "ARCHIVED"
352
+ ]);
353
+
99
354
  // ../commons/src/scopes.ts
100
- var JurisdictionFilter = z3.enum(["administrativeArea", "location", "all"]).describe(
355
+ var JurisdictionFilter = z8.enum(["administrativeArea", "location", "all"]).describe(
101
356
  "Filters based on user jurisdiction relative to their office location in hierarchy."
102
357
  );
103
- var UserFilter = z3.enum(["user"]).describe("Filters based on the user. Limits to self.");
104
- var RecordScopeTypeV2 = z3.enum([
358
+ var UserFilter = z8.enum(["user"]).describe("Filters based on the user. Limits to self.");
359
+ var RecordScopeTypeV2 = z8.enum([
105
360
  "record.search",
106
361
  "record.create",
107
362
  "record.read",
@@ -119,91 +374,107 @@ var RecordScopeTypeV2 = z3.enum([
119
374
  "record.unassign-others",
120
375
  "record.custom-action"
121
376
  ]);
122
- var PlainScopeType = z3.enum([
377
+ var PlainScopeType = z8.enum([
123
378
  // Misc. system scopes
124
379
  "bypassratelimit",
125
380
  "record.reindex",
126
381
  "user.data-seeding",
127
382
  "integration.create",
383
+ // Reading an integration's audit log. Deliberately separate from
384
+ // 'integration.create' so read-only oversight can be granted on its own, and
385
+ // deliberately option-less: system clients have no office and no
386
+ // administrative area, so jurisdiction options would have nothing to bind to.
387
+ "integration.audit.read",
128
388
  "record.import",
129
389
  "config.update-all",
390
+ "location.edit",
130
391
  "attachment.upload",
131
392
  "profile.electronic-signature",
132
393
  "user.read-only-my-audit",
133
394
  // Performance dashboard
134
395
  "performance.read",
135
396
  "performance.read-dashboards",
136
- "performance.vital-statistics-export",
137
- // Scopes used exclusively by countryconfig integration token
138
- "record.confirm-registration",
139
- "record.reject-registration"
397
+ "performance.vital-statistics-export"
140
398
  ]);
141
- var scopeByEvent = z3.preprocess(
399
+ var scopeByEvent = z8.preprocess(
142
400
  (val) => val === void 0 ? void 0 : [val].flat(),
143
- z3.array(z3.string()).optional()
401
+ z8.array(z8.string()).optional()
144
402
  ).describe("Event type, e.g. birth, death");
145
- var userRole = z3.preprocess(
403
+ var scopeByStatus = z8.preprocess(
404
+ (val) => val === void 0 ? void 0 : [val].flat(),
405
+ z8.array(EventStatus).optional()
406
+ ).describe(
407
+ "Restricts the scope to records currently in one of these statuses."
408
+ );
409
+ var userRole = z8.preprocess(
146
410
  (val) => val === void 0 ? void 0 : [val].flat(),
147
- z3.array(z3.string()).optional()
411
+ z8.array(z8.string()).optional()
148
412
  ).describe("User role, e.g. admin, field agent");
149
- var scopeOptionsPlaceEvent = z3.object({
413
+ var scopeOptionsPlaceEvent = z8.object({
150
414
  event: scopeByEvent,
151
- placeOfEvent: JurisdictionFilter.optional()
415
+ placeOfEvent: JurisdictionFilter.optional(),
416
+ createdBy: UserFilter.optional(),
417
+ createdIn: JurisdictionFilter.optional()
152
418
  }).describe("Options applicable to all record scopes.");
153
419
  var scopeOptionsDeclaredOrNotified = scopeOptionsPlaceEvent.extend({
154
420
  notifiedIn: JurisdictionFilter.optional(),
155
421
  notifiedBy: UserFilter.optional(),
156
422
  declaredIn: JurisdictionFilter.optional(),
157
- declaredBy: UserFilter.optional()
423
+ declaredBy: UserFilter.optional(),
424
+ status: scopeByStatus
158
425
  }).describe("Options applicable to actions that may take place after DECLARE");
159
426
  var AllRecordScopeOptions = scopeOptionsDeclaredOrNotified.extend({
160
427
  registeredIn: JurisdictionFilter.optional(),
161
- registeredBy: UserFilter.optional()
428
+ registeredBy: UserFilter.optional(),
429
+ flags: ContainsFlags.optional()
162
430
  }).describe(
163
431
  "Options applicable to actions that may take place after REGISTER, with full filtering capabilities."
164
432
  );
165
433
  var CustomActionScopeOptions = AllRecordScopeOptions.extend({
166
- customActionTypes: z3.preprocess(
434
+ customActionTypes: z8.preprocess(
167
435
  (val) => val === void 0 ? void 0 : [val].flat(),
168
- z3.array(z3.string()).optional()
436
+ z8.array(z8.string()).optional()
169
437
  ).describe("Allowed custom action types")
170
438
  });
171
- var AccessLevelOptions = z3.object({
439
+ var AccessLevelOptions = z8.object({
172
440
  accessLevel: JurisdictionFilter.optional()
173
441
  });
174
442
  var AllUserScopeOptions = AccessLevelOptions.extend({
175
443
  role: userRole.optional()
176
444
  });
177
- var WorkqueueOrDashboardOptions = z3.object({
178
- ids: z3.preprocess(
445
+ var WorkqueueOrDashboardOptions = z8.object({
446
+ ids: z8.preprocess(
179
447
  (val) => val === void 0 ? void 0 : [val].flat(),
180
- z3.array(z3.string())
448
+ z8.array(z8.string())
181
449
  ).describe("Must contain a list of workqueue or dashboard ids.")
182
450
  });
183
- var AllScopeOptions = z3.object({
451
+ var AllScopeOptions = z8.object({
184
452
  ...AllRecordScopeOptions.shape,
185
453
  ...AccessLevelOptions.shape,
186
454
  ...AllUserScopeOptions.shape,
187
455
  ...WorkqueueOrDashboardOptions.shape
188
456
  });
189
457
  var ScopeOptionKey = AllScopeOptions.keyof();
190
- var ResolvedScopeOptionsPlaceEvent = z3.object({
458
+ var ResolvedScopeOptionsPlaceEvent = z8.object({
191
459
  event: scopeByEvent,
192
- placeOfEvent: UUID.nullish()
460
+ placeOfEvent: UUID.nullish(),
461
+ createdBy: z8.string().optional(),
462
+ createdIn: UUID.nullish()
193
463
  }).describe(
194
464
  "Resolved options applicable to all record scopes, with location ID instead of jurisdiction filter."
195
465
  );
196
466
  var ResolvedScopeOptionsDeclared = ResolvedScopeOptionsPlaceEvent.extend({
197
467
  notifiedIn: UUID.nullish(),
198
- notifiedBy: z3.string().optional(),
468
+ notifiedBy: z8.string().optional(),
199
469
  declaredIn: UUID.nullish(),
200
- declaredBy: z3.string().optional()
470
+ declaredBy: z8.string().optional()
201
471
  }).describe(
202
472
  "Resolved options applicable to actions that may take place after DECLARE, with location ID and user ID instead of filters."
203
473
  );
204
474
  var ResolvedScopeOptionsFull = ResolvedScopeOptionsDeclared.extend({
205
475
  registeredIn: UUID.nullish(),
206
- registeredBy: z3.string().optional()
476
+ registeredBy: z8.string().optional(),
477
+ flags: ContainsFlags.optional()
207
478
  }).describe(
208
479
  "Resolved options applicable to actions that may take place after REGISTER, with full filtering capabilities and location/user IDs instead of filters."
209
480
  );
@@ -217,7 +488,6 @@ var ScopesWithDeclaredOptions = RecordScopeTypeV2.extract([
217
488
  "record.reject",
218
489
  "record.archive",
219
490
  "record.unarchive",
220
- "record.review-duplicates",
221
491
  "record.register"
222
492
  ]);
223
493
  var ScopesWithFullOptions = RecordScopeTypeV2.extract([
@@ -225,41 +495,42 @@ var ScopesWithFullOptions = RecordScopeTypeV2.extract([
225
495
  "record.read",
226
496
  "record.request-correction",
227
497
  "record.correct",
228
- "record.unassign-others"
498
+ "record.unassign-others",
499
+ "record.review-duplicates"
229
500
  ]);
230
501
  var ScopeOptionsPrintCertifiedCopies = AllRecordScopeOptions.extend({
231
- templates: z3.preprocess(
502
+ templates: z8.preprocess(
232
503
  (val) => val === void 0 ? void 0 : [val].flat(),
233
- z3.array(z3.string()).optional()
504
+ z8.array(z8.string()).optional()
234
505
  ).describe(
235
506
  "Template IDs for certified copies. Controls which certificate templates are returned to the client via the config service. Certificate printing is a client-side operation \u2014 this option is not validated when the printCertificate action is submitted."
236
507
  )
237
508
  });
238
- var RecordScopeV2 = z3.discriminatedUnion("type", [
239
- z3.object({
509
+ var RecordScopeV2 = z8.discriminatedUnion("type", [
510
+ z8.object({
240
511
  type: ScopesWithPlaceEventOptions,
241
512
  options: scopeOptionsPlaceEvent.optional()
242
513
  }),
243
- z3.object({
514
+ z8.object({
244
515
  type: ScopesWithDeclaredOptions,
245
516
  options: scopeOptionsDeclaredOrNotified.optional()
246
517
  }),
247
- z3.object({
518
+ z8.object({
248
519
  type: ScopesWithFullOptions,
249
520
  options: AllRecordScopeOptions.optional()
250
521
  }),
251
- z3.object({
252
- type: z3.literal("record.custom-action"),
522
+ z8.object({
523
+ type: z8.literal("record.custom-action"),
253
524
  options: CustomActionScopeOptions.optional()
254
525
  }),
255
- z3.object({
256
- type: z3.literal("record.print-certified-copies"),
526
+ z8.object({
527
+ type: z8.literal("record.print-certified-copies"),
257
528
  options: ScopeOptionsPrintCertifiedCopies.optional()
258
529
  })
259
530
  ]).describe(
260
531
  "Scopes used to check user's permission to perform actions on a record."
261
532
  );
262
- var SystemScopeType = z3.enum([
533
+ var SystemScopeType = z8.enum([
263
534
  "organisation.read-locations",
264
535
  "user.read",
265
536
  "user.create",
@@ -273,12 +544,12 @@ var UserScopeType = SystemScopeType.extract([
273
544
  "user.search"
274
545
  ]);
275
546
  var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
276
- var UserScopeV2 = z3.discriminatedUnion("type", [
277
- z3.object({
547
+ var UserScopeV2 = z8.discriminatedUnion("type", [
548
+ z8.object({
278
549
  type: ScopesWithRoleOption,
279
550
  options: AllUserScopeOptions.optional()
280
551
  }),
281
- z3.object({
552
+ z8.object({
282
553
  type: UserScopeType.extract(["user.read", "user.search"]),
283
554
  options: AccessLevelOptions.optional()
284
555
  })
@@ -298,44 +569,44 @@ function scopeUsesPrintCertifiedCopiesOptions(scope) {
298
569
  function isCustomActionScope(scope) {
299
570
  return scope.type === "record.custom-action";
300
571
  }
301
- var ResolvedRecordScopeV2 = z3.discriminatedUnion("type", [
302
- z3.object({
572
+ var ResolvedRecordScopeV2 = z8.discriminatedUnion("type", [
573
+ z8.object({
303
574
  type: ScopesWithPlaceEventOptions,
304
575
  options: ResolvedScopeOptionsPlaceEvent.optional()
305
576
  }),
306
- z3.object({
577
+ z8.object({
307
578
  type: ScopesWithDeclaredOptions,
308
579
  options: ResolvedScopeOptionsDeclared.optional()
309
580
  }),
310
- z3.object({
581
+ z8.object({
311
582
  type: ScopesWithFullOptions,
312
583
  options: ResolvedScopeOptionsFull.optional()
313
584
  }),
314
- z3.object({
315
- type: z3.literal("record.print-certified-copies"),
585
+ z8.object({
586
+ type: z8.literal("record.print-certified-copies"),
316
587
  options: ResolvedScopeOptionsFull.extend({
317
- templates: z3.array(z3.string()).optional()
588
+ templates: z8.array(z8.string()).optional()
318
589
  }).optional()
319
590
  })
320
591
  ]).describe("Resolved scope with location/user IDs instead of filters.");
321
- var Scope2 = z3.discriminatedUnion("type", [
322
- z3.object({ type: PlainScopeType }),
592
+ var Scope2 = z8.discriminatedUnion("type", [
593
+ z8.object({ type: PlainScopeType }),
323
594
  ...RecordScopeV2.options,
324
595
  ...UserScopeV2.options,
325
- z3.object({
326
- type: z3.literal("organisation.read-locations"),
596
+ z8.object({
597
+ type: z8.literal("organisation.read-locations"),
327
598
  options: AccessLevelOptions.optional()
328
599
  }),
329
- z3.object({
330
- type: z3.literal("workqueue"),
600
+ z8.object({
601
+ type: z8.literal("workqueue"),
331
602
  options: WorkqueueOrDashboardOptions
332
603
  }),
333
- z3.object({
334
- type: z3.literal("dashboard.view"),
604
+ z8.object({
605
+ type: z8.literal("dashboard.view"),
335
606
  options: WorkqueueOrDashboardOptions
336
607
  })
337
608
  ]);
338
- var ScopeType2 = z3.enum([
609
+ var ScopeType2 = z8.enum([
339
610
  ...SystemScopeType.options,
340
611
  ...RecordScopeTypeV2.options,
341
612
  ...PlainScopeType.options,
@@ -350,11 +621,12 @@ var unflattenScope = (input) => {
350
621
  const { type, ...options } = input;
351
622
  return { type, options };
352
623
  };
353
- var EncodedScope2 = z3.string().brand("EncodedScope");
624
+ var EncodedScope2 = z8.string().brand("EncodedScope");
354
625
  var encodeScope = (scope) => {
355
626
  const flattened = flattenScope(scope);
356
627
  return qs.stringify(flattened, {
357
628
  arrayFormat: "comma",
629
+ commaRoundTrip: true,
358
630
  allowDots: true,
359
631
  addQueryPrefix: false,
360
632
  encode: false
@@ -436,4 +708,4 @@ function defineRoles(roles) {
436
708
  }
437
709
 
438
710
  // src/scopes/index.ts
439
- z4.globalRegistry.clear();
711
+ z9.globalRegistry.clear();
@@ -0,0 +1,45 @@
1
+ /** A single telemetry metric value. */
2
+ export type TelemetryMetricValue = number | string | boolean;
3
+ /**
4
+ * The telemetry report a country configuration hands to {@link sendTelemetry}.
5
+ * `schema_version` is stamped by `sendTelemetry`, not by the caller.
6
+ */
7
+ export interface TelemetryReport {
8
+ /** Client clock, ISO 8601. Kept stable across retries of the same report. */
9
+ reported_at: string;
10
+ /** ISO-style country code of the instance. */
11
+ country_code: string;
12
+ /** Organisation running the instance. Empty string when unset. */
13
+ organisation: string;
14
+ /** Public domain of the instance, or `null`. */
15
+ domain: string | null;
16
+ instance: {
17
+ application_name: string;
18
+ environment: string;
19
+ app_version?: string;
20
+ };
21
+ /** Flat map of dotted metric keys to primitive values. */
22
+ metrics: Record<string, TelemetryMetricValue>;
23
+ }
24
+ /** Outcome of a {@link sendTelemetry} call. */
25
+ export interface TelemetryResult {
26
+ /**
27
+ * How the send resolved:
28
+ * - `sent` — the status service accepted the report (2xx);
29
+ * - `rejected` — the status service returned a non-2xx response.
30
+ */
31
+ outcome: 'sent' | 'rejected';
32
+ /** HTTP status of the request. */
33
+ status: number;
34
+ /** Response body for a `rejected` outcome. */
35
+ detail?: string;
36
+ }
37
+ /**
38
+ * Sends a telemetry report to the OpenCRVS status service. The endpoint and the
39
+ * schema version are fixed by this version of the toolkit.
40
+ *
41
+ * This always attempts the send; deciding *whether* to report (e.g. only from
42
+ * production instances) is the caller's responsibility. Network errors reject.
43
+ */
44
+ export declare function sendTelemetry(report: TelemetryReport): Promise<TelemetryResult>;
45
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/telemetry/index.ts"],"names":[],"mappings":"AAuBA,uCAAuC;AACvC,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;AAE5D;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,6EAA6E;IAC7E,WAAW,EAAE,MAAM,CAAA;IACnB,8CAA8C;IAC9C,YAAY,EAAE,MAAM,CAAA;IACpB,kEAAkE;IAClE,YAAY,EAAE,MAAM,CAAA;IACpB,gDAAgD;IAChD,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,QAAQ,EAAE;QACR,gBAAgB,EAAE,MAAM,CAAA;QACxB,WAAW,EAAE,MAAM,CAAA;QACnB,WAAW,CAAC,EAAE,MAAM,CAAA;KACrB,CAAA;IACD,0DAA0D;IAC1D,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAA;CAC9C;AAED,+CAA+C;AAC/C,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,OAAO,EAAE,MAAM,GAAG,UAAU,CAAA;IAC5B,kCAAkC;IAClC,MAAM,EAAE,MAAM,CAAA;IACd,8CAA8C;IAC9C,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED;;;;;;GAMG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,eAAe,GACtB,OAAO,CAAC,eAAe,CAAC,CAa1B"}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/telemetry/index.ts
21
+ var telemetry_exports = {};
22
+ __export(telemetry_exports, {
23
+ sendTelemetry: () => sendTelemetry
24
+ });
25
+ module.exports = __toCommonJS(telemetry_exports);
26
+ var TELEMETRY_URL = "https://status.opencrvs.org/v1/telemetry";
27
+ var SCHEMA_VERSION = "1.0";
28
+ async function sendTelemetry(report) {
29
+ const response = await fetch(TELEMETRY_URL, {
30
+ method: "POST",
31
+ headers: { "Content-Type": "application/json" },
32
+ body: JSON.stringify({ schema_version: SCHEMA_VERSION, ...report })
33
+ });
34
+ if (response.ok) {
35
+ return { outcome: "sent", status: response.status };
36
+ }
37
+ const detail = await response.text().catch(() => "");
38
+ return { outcome: "rejected", status: response.status, detail };
39
+ }
40
+ // Annotate the CommonJS export names for ESM import in node:
41
+ 0 && (module.exports = {
42
+ sendTelemetry
43
+ });
@@ -69,6 +69,7 @@ backup:
69
69
  schedule: "0 1 * * *"
70
70
  backup_server_secret: backup-server-ssh-credentials
71
71
  backup_server_dir: /home/backup/{{env}}
72
+ host: {{backup_host}}
72
73
 
73
74
 
74
75
  # Restore configuration
@@ -78,3 +79,4 @@ restore:
78
79
  backup_server_secret: backup-server-ssh-credentials
79
80
  backup_server_dir: /home/backup/{{restore_environment_name}}
80
81
  backup_encryption_secret: restore-encryption-secret
82
+ host: {{restore_host}}