@opencrvs/toolkit 2.1.0-rc.5135dc7 → 2.1.0-rc.517ffcd

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 (52) hide show
  1. package/build.sh +3 -0
  2. package/create-countryconfig/index.js +114 -66
  3. package/create-countryconfig/node_modules/.bin/degit +21 -0
  4. package/create-countryconfig/package.json +4 -1
  5. package/dist/application-config/index.js +242 -207
  6. package/dist/cli.js +556 -81
  7. package/dist/commons/api/router.d.ts +407 -50
  8. package/dist/commons/conditionals/conditionals.d.ts +6 -6
  9. package/dist/commons/conditionals/validate.d.ts +6 -2
  10. package/dist/commons/events/ActionDocument.d.ts +4 -4
  11. package/dist/commons/events/ActionInput.d.ts +4 -4
  12. package/dist/commons/events/AdvancedSearchConfig.d.ts +12 -0
  13. package/dist/commons/events/EventDocument.d.ts +470 -2
  14. package/dist/commons/events/EventMetadata.d.ts +1 -11
  15. package/dist/commons/events/EventStatus.d.ts +19 -0
  16. package/dist/commons/events/FieldConfig.d.ts +18 -0
  17. package/dist/commons/events/FieldTypeMapping.d.ts +15 -15
  18. package/dist/commons/events/locations.d.ts +59 -10
  19. package/dist/commons/events/test.utils.d.ts +8 -4
  20. package/dist/commons/events/utils.d.ts +2 -2
  21. package/dist/commons/notification/UserNotifications.d.ts +28 -13
  22. package/dist/commons/notification/dispatch.d.ts +15 -0
  23. package/dist/commons/notification/index.d.ts +1 -0
  24. package/dist/conditionals/index.js +77 -55
  25. package/dist/environment/questions.d.ts.map +1 -1
  26. package/dist/environment/questions.js +20 -14
  27. package/dist/environment/setup-environment.js +1 -1
  28. package/dist/events/index.js +839 -775
  29. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +2 -2
  30. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
  31. package/dist/migrations/v2.0/checkout-upstream-files.js +2 -2
  32. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts +3 -0
  33. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts.map +1 -0
  34. package/dist/migrations/v2.1/add-recovery-link-notifications.js +530 -0
  35. package/dist/migrations/v2.1/index.d.ts.map +1 -1
  36. package/dist/migrations/v2.1/index.js +469 -0
  37. package/dist/notification/index.js +911 -1359
  38. package/dist/scopes/index.d.ts +71 -1
  39. package/dist/scopes/index.js +77 -55
  40. package/dist/telemetry/index.d.ts +48 -0
  41. package/dist/telemetry/index.d.ts.map +1 -0
  42. package/dist/telemetry/index.js +42 -0
  43. package/dist/templates/charts-values/opencrvs-services/values.yaml +1 -1
  44. package/dist/templates/charts-values/opentelemetry/values.yaml +22 -0
  45. package/dist/templates/charts-values/traefik/values.yaml +23 -9
  46. package/dist/templates/inventory/inventory.template.yml +1 -3
  47. package/opencrvs-toolkit-2.1.0-rc.517ffcd.tgz +0 -0
  48. package/package.json +2 -1
  49. package/tsconfig.tsbuildinfo +1 -1
  50. package/dist/templates/inventory/production.example.yml +0 -77
  51. package/dist/templates/inventory/qa.example.yml +0 -48
  52. package/opencrvs-toolkit-2.1.0-rc.5135dc7.tgz +0 -0
@@ -58,6 +58,13 @@ declare const AllScopeOptions: z.ZodObject<{
58
58
  declaredBy: z.ZodOptional<z.ZodEnum<{
59
59
  user: "user";
60
60
  }>>;
61
+ status: z.ZodPreprocess<z.ZodOptional<z.ZodArray<z.ZodEnum<{
62
+ ARCHIVED: "ARCHIVED";
63
+ CREATED: "CREATED";
64
+ DECLARED: "DECLARED";
65
+ NOTIFIED: "NOTIFIED";
66
+ REGISTERED: "REGISTERED";
67
+ }>>>>;
61
68
  registeredIn: z.ZodOptional<z.ZodEnum<{
62
69
  administrativeArea: "administrativeArea";
63
70
  all: "all";
@@ -111,6 +118,7 @@ export declare const ScopeOptionKey: z.ZodEnum<{
111
118
  registeredBy: "registeredBy";
112
119
  registeredIn: "registeredIn";
113
120
  role: "role";
121
+ status: "status";
114
122
  }>;
115
123
  export type ScopeOptionKey = z.infer<typeof ScopeOptionKey>;
116
124
  export declare const ScopesWithPlaceEventOptions: z.ZodEnum<{
@@ -179,6 +187,13 @@ export declare const RecordScopeV2: z.ZodDiscriminatedUnion<[z.ZodObject<{
179
187
  declaredBy: z.ZodOptional<z.ZodEnum<{
180
188
  user: "user";
181
189
  }>>;
190
+ status: z.ZodPreprocess<z.ZodOptional<z.ZodArray<z.ZodEnum<{
191
+ ARCHIVED: "ARCHIVED";
192
+ CREATED: "CREATED";
193
+ DECLARED: "DECLARED";
194
+ NOTIFIED: "NOTIFIED";
195
+ REGISTERED: "REGISTERED";
196
+ }>>>>;
182
197
  }, z.core.$strip>>;
183
198
  }, z.core.$strip>, z.ZodObject<{
184
199
  type: z.ZodEnum<{
@@ -211,6 +226,13 @@ export declare const RecordScopeV2: z.ZodDiscriminatedUnion<[z.ZodObject<{
211
226
  declaredBy: z.ZodOptional<z.ZodEnum<{
212
227
  user: "user";
213
228
  }>>;
229
+ status: z.ZodPreprocess<z.ZodOptional<z.ZodArray<z.ZodEnum<{
230
+ ARCHIVED: "ARCHIVED";
231
+ CREATED: "CREATED";
232
+ DECLARED: "DECLARED";
233
+ NOTIFIED: "NOTIFIED";
234
+ REGISTERED: "REGISTERED";
235
+ }>>>>;
214
236
  registeredIn: z.ZodOptional<z.ZodEnum<{
215
237
  administrativeArea: "administrativeArea";
216
238
  all: "all";
@@ -268,6 +290,13 @@ export declare const RecordScopeV2: z.ZodDiscriminatedUnion<[z.ZodObject<{
268
290
  declaredBy: z.ZodOptional<z.ZodEnum<{
269
291
  user: "user";
270
292
  }>>;
293
+ status: z.ZodPreprocess<z.ZodOptional<z.ZodArray<z.ZodEnum<{
294
+ ARCHIVED: "ARCHIVED";
295
+ CREATED: "CREATED";
296
+ DECLARED: "DECLARED";
297
+ NOTIFIED: "NOTIFIED";
298
+ REGISTERED: "REGISTERED";
299
+ }>>>>;
271
300
  registeredIn: z.ZodOptional<z.ZodEnum<{
272
301
  administrativeArea: "administrativeArea";
273
302
  all: "all";
@@ -326,6 +355,13 @@ export declare const RecordScopeV2: z.ZodDiscriminatedUnion<[z.ZodObject<{
326
355
  declaredBy: z.ZodOptional<z.ZodEnum<{
327
356
  user: "user";
328
357
  }>>;
358
+ status: z.ZodPreprocess<z.ZodOptional<z.ZodArray<z.ZodEnum<{
359
+ ARCHIVED: "ARCHIVED";
360
+ CREATED: "CREATED";
361
+ DECLARED: "DECLARED";
362
+ NOTIFIED: "NOTIFIED";
363
+ REGISTERED: "REGISTERED";
364
+ }>>>>;
329
365
  registeredIn: z.ZodOptional<z.ZodEnum<{
330
366
  administrativeArea: "administrativeArea";
331
367
  all: "all";
@@ -535,6 +571,7 @@ export declare const Scope: z.ZodDiscriminatedUnion<[z.ZodObject<{
535
571
  "attachment.upload": "attachment.upload";
536
572
  bypassratelimit: "bypassratelimit";
537
573
  "config.update-all": "config.update-all";
574
+ "integration.audit.read": "integration.audit.read";
538
575
  "integration.create": "integration.create";
539
576
  "location.edit": "location.edit";
540
577
  "performance.read": "performance.read";
@@ -594,6 +631,13 @@ export declare const Scope: z.ZodDiscriminatedUnion<[z.ZodObject<{
594
631
  declaredBy: z.ZodOptional<z.ZodEnum<{
595
632
  user: "user";
596
633
  }>>;
634
+ status: z.ZodPreprocess<z.ZodOptional<z.ZodArray<z.ZodEnum<{
635
+ ARCHIVED: "ARCHIVED";
636
+ CREATED: "CREATED";
637
+ DECLARED: "DECLARED";
638
+ NOTIFIED: "NOTIFIED";
639
+ REGISTERED: "REGISTERED";
640
+ }>>>>;
597
641
  }, z.core.$strip>>;
598
642
  }, z.core.$strip>, z.ZodObject<{
599
643
  type: z.ZodEnum<{
@@ -626,6 +670,13 @@ export declare const Scope: z.ZodDiscriminatedUnion<[z.ZodObject<{
626
670
  declaredBy: z.ZodOptional<z.ZodEnum<{
627
671
  user: "user";
628
672
  }>>;
673
+ status: z.ZodPreprocess<z.ZodOptional<z.ZodArray<z.ZodEnum<{
674
+ ARCHIVED: "ARCHIVED";
675
+ CREATED: "CREATED";
676
+ DECLARED: "DECLARED";
677
+ NOTIFIED: "NOTIFIED";
678
+ REGISTERED: "REGISTERED";
679
+ }>>>>;
629
680
  registeredIn: z.ZodOptional<z.ZodEnum<{
630
681
  administrativeArea: "administrativeArea";
631
682
  all: "all";
@@ -683,6 +734,13 @@ export declare const Scope: z.ZodDiscriminatedUnion<[z.ZodObject<{
683
734
  declaredBy: z.ZodOptional<z.ZodEnum<{
684
735
  user: "user";
685
736
  }>>;
737
+ status: z.ZodPreprocess<z.ZodOptional<z.ZodArray<z.ZodEnum<{
738
+ ARCHIVED: "ARCHIVED";
739
+ CREATED: "CREATED";
740
+ DECLARED: "DECLARED";
741
+ NOTIFIED: "NOTIFIED";
742
+ REGISTERED: "REGISTERED";
743
+ }>>>>;
686
744
  registeredIn: z.ZodOptional<z.ZodEnum<{
687
745
  administrativeArea: "administrativeArea";
688
746
  all: "all";
@@ -741,6 +799,13 @@ export declare const Scope: z.ZodDiscriminatedUnion<[z.ZodObject<{
741
799
  declaredBy: z.ZodOptional<z.ZodEnum<{
742
800
  user: "user";
743
801
  }>>;
802
+ status: z.ZodPreprocess<z.ZodOptional<z.ZodArray<z.ZodEnum<{
803
+ ARCHIVED: "ARCHIVED";
804
+ CREATED: "CREATED";
805
+ DECLARED: "DECLARED";
806
+ NOTIFIED: "NOTIFIED";
807
+ REGISTERED: "REGISTERED";
808
+ }>>>>;
744
809
  registeredIn: z.ZodOptional<z.ZodEnum<{
745
810
  administrativeArea: "administrativeArea";
746
811
  all: "all";
@@ -825,6 +890,7 @@ export declare const ScopeType: z.ZodEnum<{
825
890
  bypassratelimit: "bypassratelimit";
826
891
  "config.update-all": "config.update-all";
827
892
  "dashboard.view": "dashboard.view";
893
+ "integration.audit.read": "integration.audit.read";
828
894
  "integration.create": "integration.create";
829
895
  "location.edit": "location.edit";
830
896
  "organisation.read-locations": "organisation.read-locations";
@@ -896,6 +962,7 @@ export declare const decodeScope: (encodedScope: EncodedScope) => {
896
962
  notifiedBy?: "user" | undefined;
897
963
  declaredIn?: "administrativeArea" | "all" | "location" | undefined;
898
964
  declaredBy?: "user" | undefined;
965
+ status?: ("ARCHIVED" | "CREATED" | "DECLARED" | "NOTIFIED" | "REGISTERED")[] | undefined;
899
966
  } | undefined;
900
967
  } | {
901
968
  type: "record.correct" | "record.read" | "record.request-correction" | "record.search" | "record.unassign-others";
@@ -906,6 +973,7 @@ export declare const decodeScope: (encodedScope: EncodedScope) => {
906
973
  notifiedBy?: "user" | undefined;
907
974
  declaredIn?: "administrativeArea" | "all" | "location" | undefined;
908
975
  declaredBy?: "user" | undefined;
976
+ status?: ("ARCHIVED" | "CREATED" | "DECLARED" | "NOTIFIED" | "REGISTERED")[] | undefined;
909
977
  registeredIn?: "administrativeArea" | "all" | "location" | undefined;
910
978
  registeredBy?: "user" | undefined;
911
979
  flags?: {
@@ -923,6 +991,7 @@ export declare const decodeScope: (encodedScope: EncodedScope) => {
923
991
  notifiedBy?: "user" | undefined;
924
992
  declaredIn?: "administrativeArea" | "all" | "location" | undefined;
925
993
  declaredBy?: "user" | undefined;
994
+ status?: ("ARCHIVED" | "CREATED" | "DECLARED" | "NOTIFIED" | "REGISTERED")[] | undefined;
926
995
  registeredIn?: "administrativeArea" | "all" | "location" | undefined;
927
996
  registeredBy?: "user" | undefined;
928
997
  flags?: {
@@ -941,6 +1010,7 @@ export declare const decodeScope: (encodedScope: EncodedScope) => {
941
1010
  notifiedBy?: "user" | undefined;
942
1011
  declaredIn?: "administrativeArea" | "all" | "location" | undefined;
943
1012
  declaredBy?: "user" | undefined;
1013
+ status?: ("ARCHIVED" | "CREATED" | "DECLARED" | "NOTIFIED" | "REGISTERED")[] | undefined;
944
1014
  registeredIn?: "administrativeArea" | "all" | "location" | undefined;
945
1015
  registeredBy?: "user" | undefined;
946
1016
  flags?: {
@@ -962,7 +1032,7 @@ export declare const decodeScope: (encodedScope: EncodedScope) => {
962
1032
  accessLevel?: "administrativeArea" | "all" | "location" | undefined;
963
1033
  } | undefined;
964
1034
  } | {
965
- type: "attachment.upload" | "bypassratelimit" | "config.update-all" | "integration.create" | "location.edit" | "performance.read" | "performance.read-dashboards" | "performance.vital-statistics-export" | "profile.electronic-signature" | "record.confirm-registration" | "record.import" | "record.reindex" | "record.reject-registration" | "user.data-seeding" | "user.read-only-my-audit";
1035
+ type: "attachment.upload" | "bypassratelimit" | "config.update-all" | "integration.audit.read" | "integration.create" | "location.edit" | "performance.read" | "performance.read-dashboards" | "performance.vital-statistics-export" | "profile.electronic-signature" | "record.confirm-registration" | "record.import" | "record.reindex" | "record.reject-registration" | "user.data-seeding" | "user.read-only-my-audit";
966
1036
  } | {
967
1037
  type: "organisation.read-locations";
968
1038
  options?: {
@@ -59,10 +59,10 @@ __export(scopes_exports, {
59
59
  scopeUsesRoleOptions: () => scopeUsesRoleOptions
60
60
  });
61
61
  module.exports = __toCommonJS(scopes_exports);
62
- var z8 = __toESM(require("zod/v4"));
62
+ var z9 = __toESM(require("zod/v4"));
63
63
 
64
64
  // ../commons/src/scopes.ts
65
- var z7 = __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
@@ -341,12 +341,22 @@ var ActionFlagConfig = z6.object({
341
341
  description: "Add or remove operation applied to a flag when the parent action is accepted. Optionally gated by a conditional."
342
342
  });
343
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
+
344
354
  // ../commons/src/scopes.ts
345
- var JurisdictionFilter = z7.enum(["administrativeArea", "location", "all"]).describe(
355
+ var JurisdictionFilter = z8.enum(["administrativeArea", "location", "all"]).describe(
346
356
  "Filters based on user jurisdiction relative to their office location in hierarchy."
347
357
  );
348
- var UserFilter = z7.enum(["user"]).describe("Filters based on the user. Limits to self.");
349
- var RecordScopeTypeV2 = z7.enum([
358
+ var UserFilter = z8.enum(["user"]).describe("Filters based on the user. Limits to self.");
359
+ var RecordScopeTypeV2 = z8.enum([
350
360
  "record.search",
351
361
  "record.create",
352
362
  "record.read",
@@ -364,12 +374,17 @@ var RecordScopeTypeV2 = z7.enum([
364
374
  "record.unassign-others",
365
375
  "record.custom-action"
366
376
  ]);
367
- var PlainScopeType = z7.enum([
377
+ var PlainScopeType = z8.enum([
368
378
  // Misc. system scopes
369
379
  "bypassratelimit",
370
380
  "record.reindex",
371
381
  "user.data-seeding",
372
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",
373
388
  "record.import",
374
389
  "config.update-all",
375
390
  "location.edit",
@@ -384,15 +399,21 @@ var PlainScopeType = z7.enum([
384
399
  "record.confirm-registration",
385
400
  "record.reject-registration"
386
401
  ]);
387
- var scopeByEvent = z7.preprocess(
402
+ var scopeByEvent = z8.preprocess(
388
403
  (val) => val === void 0 ? void 0 : [val].flat(),
389
- z7.array(z7.string()).optional()
404
+ z8.array(z8.string()).optional()
390
405
  ).describe("Event type, e.g. birth, death");
391
- var userRole = z7.preprocess(
406
+ var scopeByStatus = z8.preprocess(
407
+ (val) => val === void 0 ? void 0 : [val].flat(),
408
+ z8.array(EventStatus).optional()
409
+ ).describe(
410
+ "Restricts the scope to records currently in one of these statuses."
411
+ );
412
+ var userRole = z8.preprocess(
392
413
  (val) => val === void 0 ? void 0 : [val].flat(),
393
- z7.array(z7.string()).optional()
414
+ z8.array(z8.string()).optional()
394
415
  ).describe("User role, e.g. admin, field agent");
395
- var scopeOptionsPlaceEvent = z7.object({
416
+ var scopeOptionsPlaceEvent = z8.object({
396
417
  event: scopeByEvent,
397
418
  placeOfEvent: JurisdictionFilter.optional()
398
419
  }).describe("Options applicable to all record scopes.");
@@ -400,7 +421,8 @@ var scopeOptionsDeclaredOrNotified = scopeOptionsPlaceEvent.extend({
400
421
  notifiedIn: JurisdictionFilter.optional(),
401
422
  notifiedBy: UserFilter.optional(),
402
423
  declaredIn: JurisdictionFilter.optional(),
403
- declaredBy: UserFilter.optional()
424
+ declaredBy: UserFilter.optional(),
425
+ status: scopeByStatus
404
426
  }).describe("Options applicable to actions that may take place after DECLARE");
405
427
  var AllRecordScopeOptions = scopeOptionsDeclaredOrNotified.extend({
406
428
  registeredIn: JurisdictionFilter.optional(),
@@ -410,31 +432,31 @@ var AllRecordScopeOptions = scopeOptionsDeclaredOrNotified.extend({
410
432
  "Options applicable to actions that may take place after REGISTER, with full filtering capabilities."
411
433
  );
412
434
  var CustomActionScopeOptions = AllRecordScopeOptions.extend({
413
- customActionTypes: z7.preprocess(
435
+ customActionTypes: z8.preprocess(
414
436
  (val) => val === void 0 ? void 0 : [val].flat(),
415
- z7.array(z7.string()).optional()
437
+ z8.array(z8.string()).optional()
416
438
  ).describe("Allowed custom action types")
417
439
  });
418
- var AccessLevelOptions = z7.object({
440
+ var AccessLevelOptions = z8.object({
419
441
  accessLevel: JurisdictionFilter.optional()
420
442
  });
421
443
  var AllUserScopeOptions = AccessLevelOptions.extend({
422
444
  role: userRole.optional()
423
445
  });
424
- var WorkqueueOrDashboardOptions = z7.object({
425
- ids: z7.preprocess(
446
+ var WorkqueueOrDashboardOptions = z8.object({
447
+ ids: z8.preprocess(
426
448
  (val) => val === void 0 ? void 0 : [val].flat(),
427
- z7.array(z7.string())
449
+ z8.array(z8.string())
428
450
  ).describe("Must contain a list of workqueue or dashboard ids.")
429
451
  });
430
- var AllScopeOptions = z7.object({
452
+ var AllScopeOptions = z8.object({
431
453
  ...AllRecordScopeOptions.shape,
432
454
  ...AccessLevelOptions.shape,
433
455
  ...AllUserScopeOptions.shape,
434
456
  ...WorkqueueOrDashboardOptions.shape
435
457
  });
436
458
  var ScopeOptionKey = AllScopeOptions.keyof();
437
- var ResolvedScopeOptionsPlaceEvent = z7.object({
459
+ var ResolvedScopeOptionsPlaceEvent = z8.object({
438
460
  event: scopeByEvent,
439
461
  placeOfEvent: UUID.nullish()
440
462
  }).describe(
@@ -442,15 +464,15 @@ var ResolvedScopeOptionsPlaceEvent = z7.object({
442
464
  );
443
465
  var ResolvedScopeOptionsDeclared = ResolvedScopeOptionsPlaceEvent.extend({
444
466
  notifiedIn: UUID.nullish(),
445
- notifiedBy: z7.string().optional(),
467
+ notifiedBy: z8.string().optional(),
446
468
  declaredIn: UUID.nullish(),
447
- declaredBy: z7.string().optional()
469
+ declaredBy: z8.string().optional()
448
470
  }).describe(
449
471
  "Resolved options applicable to actions that may take place after DECLARE, with location ID and user ID instead of filters."
450
472
  );
451
473
  var ResolvedScopeOptionsFull = ResolvedScopeOptionsDeclared.extend({
452
474
  registeredIn: UUID.nullish(),
453
- registeredBy: z7.string().optional(),
475
+ registeredBy: z8.string().optional(),
454
476
  flags: ContainsFlags.optional()
455
477
  }).describe(
456
478
  "Resolved options applicable to actions that may take place after REGISTER, with full filtering capabilities and location/user IDs instead of filters."
@@ -476,38 +498,38 @@ var ScopesWithFullOptions = RecordScopeTypeV2.extract([
476
498
  "record.unassign-others"
477
499
  ]);
478
500
  var ScopeOptionsPrintCertifiedCopies = AllRecordScopeOptions.extend({
479
- templates: z7.preprocess(
501
+ templates: z8.preprocess(
480
502
  (val) => val === void 0 ? void 0 : [val].flat(),
481
- z7.array(z7.string()).optional()
503
+ z8.array(z8.string()).optional()
482
504
  ).describe(
483
505
  "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."
484
506
  )
485
507
  });
486
- var RecordScopeV2 = z7.discriminatedUnion("type", [
487
- z7.object({
508
+ var RecordScopeV2 = z8.discriminatedUnion("type", [
509
+ z8.object({
488
510
  type: ScopesWithPlaceEventOptions,
489
511
  options: scopeOptionsPlaceEvent.optional()
490
512
  }),
491
- z7.object({
513
+ z8.object({
492
514
  type: ScopesWithDeclaredOptions,
493
515
  options: scopeOptionsDeclaredOrNotified.optional()
494
516
  }),
495
- z7.object({
517
+ z8.object({
496
518
  type: ScopesWithFullOptions,
497
519
  options: AllRecordScopeOptions.optional()
498
520
  }),
499
- z7.object({
500
- type: z7.literal("record.custom-action"),
521
+ z8.object({
522
+ type: z8.literal("record.custom-action"),
501
523
  options: CustomActionScopeOptions.optional()
502
524
  }),
503
- z7.object({
504
- type: z7.literal("record.print-certified-copies"),
525
+ z8.object({
526
+ type: z8.literal("record.print-certified-copies"),
505
527
  options: ScopeOptionsPrintCertifiedCopies.optional()
506
528
  })
507
529
  ]).describe(
508
530
  "Scopes used to check user's permission to perform actions on a record."
509
531
  );
510
- var SystemScopeType = z7.enum([
532
+ var SystemScopeType = z8.enum([
511
533
  "organisation.read-locations",
512
534
  "user.read",
513
535
  "user.create",
@@ -521,12 +543,12 @@ var UserScopeType = SystemScopeType.extract([
521
543
  "user.search"
522
544
  ]);
523
545
  var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
524
- var UserScopeV2 = z7.discriminatedUnion("type", [
525
- z7.object({
546
+ var UserScopeV2 = z8.discriminatedUnion("type", [
547
+ z8.object({
526
548
  type: ScopesWithRoleOption,
527
549
  options: AllUserScopeOptions.optional()
528
550
  }),
529
- z7.object({
551
+ z8.object({
530
552
  type: UserScopeType.extract(["user.read", "user.search"]),
531
553
  options: AccessLevelOptions.optional()
532
554
  })
@@ -546,44 +568,44 @@ function scopeUsesPrintCertifiedCopiesOptions(scope) {
546
568
  function isCustomActionScope(scope) {
547
569
  return scope.type === "record.custom-action";
548
570
  }
549
- var ResolvedRecordScopeV2 = z7.discriminatedUnion("type", [
550
- z7.object({
571
+ var ResolvedRecordScopeV2 = z8.discriminatedUnion("type", [
572
+ z8.object({
551
573
  type: ScopesWithPlaceEventOptions,
552
574
  options: ResolvedScopeOptionsPlaceEvent.optional()
553
575
  }),
554
- z7.object({
576
+ z8.object({
555
577
  type: ScopesWithDeclaredOptions,
556
578
  options: ResolvedScopeOptionsDeclared.optional()
557
579
  }),
558
- z7.object({
580
+ z8.object({
559
581
  type: ScopesWithFullOptions,
560
582
  options: ResolvedScopeOptionsFull.optional()
561
583
  }),
562
- z7.object({
563
- type: z7.literal("record.print-certified-copies"),
584
+ z8.object({
585
+ type: z8.literal("record.print-certified-copies"),
564
586
  options: ResolvedScopeOptionsFull.extend({
565
- templates: z7.array(z7.string()).optional()
587
+ templates: z8.array(z8.string()).optional()
566
588
  }).optional()
567
589
  })
568
590
  ]).describe("Resolved scope with location/user IDs instead of filters.");
569
- var Scope2 = z7.discriminatedUnion("type", [
570
- z7.object({ type: PlainScopeType }),
591
+ var Scope2 = z8.discriminatedUnion("type", [
592
+ z8.object({ type: PlainScopeType }),
571
593
  ...RecordScopeV2.options,
572
594
  ...UserScopeV2.options,
573
- z7.object({
574
- type: z7.literal("organisation.read-locations"),
595
+ z8.object({
596
+ type: z8.literal("organisation.read-locations"),
575
597
  options: AccessLevelOptions.optional()
576
598
  }),
577
- z7.object({
578
- type: z7.literal("workqueue"),
599
+ z8.object({
600
+ type: z8.literal("workqueue"),
579
601
  options: WorkqueueOrDashboardOptions
580
602
  }),
581
- z7.object({
582
- type: z7.literal("dashboard.view"),
603
+ z8.object({
604
+ type: z8.literal("dashboard.view"),
583
605
  options: WorkqueueOrDashboardOptions
584
606
  })
585
607
  ]);
586
- var ScopeType2 = z7.enum([
608
+ var ScopeType2 = z8.enum([
587
609
  ...SystemScopeType.options,
588
610
  ...RecordScopeTypeV2.options,
589
611
  ...PlainScopeType.options,
@@ -598,7 +620,7 @@ var unflattenScope = (input) => {
598
620
  const { type, ...options } = input;
599
621
  return { type, options };
600
622
  };
601
- var EncodedScope2 = z7.string().brand("EncodedScope");
623
+ var EncodedScope2 = z8.string().brand("EncodedScope");
602
624
  var encodeScope = (scope) => {
603
625
  const flattened = flattenScope(scope);
604
626
  return qs.stringify(flattened, {
@@ -685,4 +707,4 @@ function defineRoles(roles) {
685
707
  }
686
708
 
687
709
  // src/scopes/index.ts
688
- z8.globalRegistry.clear();
710
+ z9.globalRegistry.clear();
@@ -0,0 +1,48 @@
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
+ * - `skipped` — nothing was sent because the instance is not running in
30
+ * production;
31
+ * - `rejected` — the status service returned a non-2xx response.
32
+ */
33
+ outcome: 'sent' | 'skipped' | 'rejected';
34
+ /** HTTP status of the request; `0` when skipped. */
35
+ status: number;
36
+ /** Response body for a `rejected` outcome. */
37
+ detail?: string;
38
+ }
39
+ /**
40
+ * Sends a telemetry report to the OpenCRVS status service. The endpoint and the
41
+ * schema version are fixed by this version of the toolkit.
42
+ *
43
+ * Only production instances actually report: outside `NODE_ENV=production` the
44
+ * report is never sent (`skipped`), so staging, QA and local instances cannot
45
+ * pollute the status service. Network errors reject.
46
+ */
47
+ export declare function sendTelemetry(report: TelemetryReport): Promise<TelemetryResult>;
48
+ //# 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;;;;;;OAMG;IACH,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,CAAA;IACxC,oDAAoD;IACpD,MAAM,EAAE,MAAM,CAAA;IACd,8CAA8C;IAC9C,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED;;;;;;;GAOG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,eAAe,GACtB,OAAO,CAAC,eAAe,CAAC,CAiB1B"}
@@ -0,0 +1,42 @@
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.dev/v1/telemetry";
27
+ var SCHEMA_VERSION = "1.0";
28
+ async function sendTelemetry(report) {
29
+ if (true) {
30
+ return { outcome: "skipped", status: 0 };
31
+ }
32
+ const response = await fetch(TELEMETRY_URL, {
33
+ method: "POST",
34
+ headers: { "Content-Type": "application/json" },
35
+ body: JSON.stringify({ schema_version: SCHEMA_VERSION, ...report })
36
+ });
37
+ if (response.ok) {
38
+ return { outcome: "sent", status: response.status };
39
+ }
40
+ const detail = await response.text().catch(() => "");
41
+ return { outcome: "rejected", status: response.status, detail };
42
+ }
@@ -27,7 +27,7 @@ env:
27
27
  otel:
28
28
  enabled: true
29
29
  deployment_environment: {{env}}
30
- exporter_otlp_endpoint: "http://opentelemetry-collector.opencrvs-deps-{{env}}.svc.cluster.local:4318"
30
+ exporter_otlp_endpoint: "opentelemetry-collector.opencrvs-deps-{{env}}.svc.cluster.local:4317"
31
31
 
32
32
  elasticsearch:
33
33
  auth_mode: auto
@@ -48,6 +48,27 @@ config:
48
48
  limit_percentage: 80
49
49
  spike_limit_percentage: 25
50
50
 
51
+ transform/traces:
52
+ error_mode: ignore
53
+ trace_statements:
54
+ # Start with the raw path.
55
+ - set(span.attributes["http.route"], span.attributes["url.path"]) where resource.attributes["service.name"] == "traefik" and span.attributes["url.path"] != nil
56
+
57
+ # Match getTracePath(): collapse repeated slashes.
58
+ - replace_pattern(span.attributes["http.route"], "/+", "/") where resource.attributes["service.name"] == "traefik" and span.attributes["http.route"] != nil
59
+
60
+ # Match getTracePath(): replace dynamic-looking segments with "#".
61
+ - replace_pattern(span.attributes["http.route"], "/([^/]*\\.[^/]*|[0-9]+|[0-9a-fA-F]{24}|[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})(/|$)", "/#$$2") where resource.attributes["service.name"] == "traefik" and span.attributes["http.route"] != nil
62
+
63
+ # Concatenate Request method and normalized URL to conform same format as NodeJs.
64
+ - set(span.name, Concat([span.attributes["http.request.method"], span.attributes["http.route"]], " ")) where resource.attributes["service.name"] == "traefik" and span.attributes["http.request.method"] != nil and span.attributes["http.route"] != nil
65
+
66
+ # SDK language to avoid errors in Kibana on APM -> Service Inventory -> Traefik -> Metrics.
67
+ - delete_key(resource.attributes, "telemetry.sdk.language") where resource.attributes["service.name"] == "traefik"
68
+
69
+ # Nginx OTEL module uses older HTTP semantic convention names, so build the span name from http.method and http.route.
70
+ - set(span.name, Concat([span.attributes["http.method"], span.attributes["http.route"]], " ")) where (resource.attributes["service.name"] == "opencrvs_client" or resource.attributes["service.name"] == "opencrvs_login") and span.attributes["http.method"] != nil and span.attributes["http.route"] != nil
71
+
51
72
  service:
52
73
  telemetry:
53
74
  metrics:
@@ -68,6 +89,7 @@ config:
68
89
  - otlp
69
90
  processors:
70
91
  - memory_limiter
92
+ - transform/traces
71
93
  - batch
72
94
  exporters:
73
95
  - otlp/elastic
@@ -9,16 +9,28 @@
9
9
 
10
10
  # Overwriting https://github.com/traefik/traefik-helm-chart/blob/master/traefik/values.yaml
11
11
  namespaceOverride: "traefik"
12
- logs:
13
- general:
14
- # "TRACE", "DEBUG", "INFO", "WARN", "ERROR", "FATAL", "PANIC"
15
- level: "INFO"
16
- # format: "common" # For local environment
17
- format: "json" # For server environment
18
- access:
19
- # -- To enable access logs
12
+ log:
13
+ # "TRACE", "DEBUG", "INFO", "WARN", "ERROR", "FATAL", "PANIC"
14
+ level: "INFO"
15
+ # format: "common" # For local environment
16
+ format: "json" # For server environment
17
+ accessLog:
18
+ # -- To enable access logs
19
+ enabled: true
20
+ format: "json"
21
+
22
+ tracing:
23
+ serviceName: traefik
24
+ resourceAttributes:
25
+ deployment.environment.name: "{{env}}"
26
+ service.namespace: traefik
27
+ otlp:
20
28
  enabled: true
21
- format: "json"
29
+ grpc:
30
+ enabled: true
31
+ endpoint: "opentelemetry-collector.opencrvs-deps-{{env}}.svc.cluster.local:4317"
32
+ insecure: true
33
+
22
34
 
23
35
  ingressRoute:
24
36
  dashboard:
@@ -98,6 +110,8 @@ tlsStore:
98
110
 
99
111
  deployment:
100
112
  hostNetwork: true
113
+ podLabels:
114
+ service_name: traefik
101
115
  {{#if static_ssl}}
102
116
  kind: DaemonSet
103
117
  {{/if}}