@opencrvs/toolkit 2.1.0-rc.1f688f9 → 2.1.0-rc.268cfbe

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 (209) hide show
  1. package/README.md +2 -12
  2. package/build.sh +20 -5
  3. package/create-countryconfig/index.js +164 -4
  4. package/dist/application-config/index.js +36 -25
  5. package/dist/authentication/index.d.ts +66 -0
  6. package/dist/authentication/index.d.ts.map +1 -0
  7. package/dist/authentication/index.js +765 -0
  8. package/dist/cli.js +2829 -1294
  9. package/dist/commons/api/router.d.ts +252 -290
  10. package/dist/commons/application-config/index.d.ts +0 -2
  11. package/dist/commons/conditionals/conditionals.d.ts +6 -6
  12. package/dist/commons/conditionals/validate.d.ts +19 -4
  13. package/dist/commons/events/ActionConfig.d.ts +5 -14
  14. package/dist/commons/events/ActionDocument.d.ts +30 -4
  15. package/dist/commons/events/AdvancedSearchConfig.d.ts +24 -12
  16. package/dist/commons/events/AuditLog.d.ts +1 -0
  17. package/dist/commons/events/Draft.d.ts +1 -21
  18. package/dist/commons/events/EventDocument.d.ts +4 -4
  19. package/dist/commons/events/FieldConfig.d.ts +26 -15
  20. package/dist/commons/events/FieldTypeMapping.d.ts +10 -10
  21. package/dist/commons/events/FieldValue.d.ts +1 -0
  22. package/dist/commons/events/FormConfig.d.ts +6 -0
  23. package/dist/commons/events/PageConfig.d.ts +4 -0
  24. package/dist/commons/events/locations.d.ts +4 -0
  25. package/dist/commons/events/scopes.d.ts +21 -1
  26. package/dist/commons/events/test.utils.d.ts +71 -22
  27. package/dist/commons/events/utils.d.ts +37 -2
  28. package/dist/commons/notification/dispatch.d.ts +1 -6
  29. package/dist/conditionals/index.js +21 -7
  30. package/dist/csv.d.ts +25 -0
  31. package/dist/csv.d.ts.map +1 -0
  32. package/dist/csv.js +120 -0
  33. package/dist/environment/index.d.ts.map +1 -1
  34. package/dist/environment/index.js +2 -1
  35. package/dist/environment/logger.d.ts +3 -0
  36. package/dist/environment/logger.d.ts.map +1 -1
  37. package/dist/environment/manage-users.js +1 -1
  38. package/dist/environment/setup-environment.d.ts +1 -1
  39. package/dist/environment/setup-environment.d.ts.map +1 -1
  40. package/dist/environment/setup-environment.js +593 -562
  41. package/dist/environment/swarm-to-k8s.js +3 -4
  42. package/dist/environment/templates.d.ts +0 -1
  43. package/dist/environment/templates.d.ts.map +1 -1
  44. package/dist/environment/templates.js +3 -8
  45. package/dist/environment/update-workflows.d.ts.map +1 -1
  46. package/dist/environment/update-workflows.js +4 -0
  47. package/dist/environment/utils.d.ts +0 -12
  48. package/dist/environment/utils.d.ts.map +1 -1
  49. package/dist/environment/utils.js +1 -28
  50. package/dist/events/index.js +2115 -1884
  51. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts.map +1 -1
  52. package/dist/migrations/v2.1/add-recovery-link-notifications.js +13 -32
  53. package/dist/migrations/v2.1/add-translations.d.ts +9 -0
  54. package/dist/migrations/v2.1/add-translations.d.ts.map +1 -0
  55. package/dist/migrations/v2.1/add-translations.js +149 -0
  56. package/dist/migrations/v2.1/enable-telemetry.d.ts.map +1 -1
  57. package/dist/migrations/v2.1/enable-telemetry.js +32 -15
  58. package/dist/migrations/v2.1/index.d.ts.map +1 -1
  59. package/dist/migrations/v2.1/index.js +1160 -70
  60. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts +14 -0
  61. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts.map +1 -0
  62. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.js +345 -0
  63. package/dist/migrations/v2.1/remove-metabase-package-installs.d.ts +2 -0
  64. package/dist/migrations/v2.1/remove-metabase-package-installs.d.ts.map +1 -0
  65. package/dist/migrations/v2.1/remove-metabase-package-installs.js +161 -0
  66. package/dist/migrations/{v2.0/migrate-scopes.d.ts → v2.1/remove-sentry.d.ts} +1 -1
  67. package/dist/migrations/v2.1/remove-sentry.d.ts.map +1 -0
  68. package/dist/migrations/v2.1/remove-sentry.js +354 -0
  69. package/dist/migrations/{v2.0/rename-api-paths.d.ts → v2.1/rename-trigger-paths.d.ts} +1 -1
  70. package/dist/migrations/v2.1/rename-trigger-paths.d.ts.map +1 -0
  71. package/dist/migrations/{v2.0/rename-api-paths.js → v2.1/rename-trigger-paths.js} +69 -40
  72. package/dist/migrations/v2.1/template-files.d.ts +8 -0
  73. package/dist/migrations/v2.1/template-files.d.ts.map +1 -0
  74. package/dist/migrations/v2.1/template-files.js +49 -0
  75. package/dist/migrations/v2.1/upgrade-tilt.d.ts +8 -0
  76. package/dist/migrations/v2.1/upgrade-tilt.d.ts.map +1 -0
  77. package/dist/migrations/v2.1/upgrade-tilt.js +139 -0
  78. package/dist/notification/index.js +249 -207
  79. package/dist/scopes/index.d.ts +288 -5
  80. package/dist/scopes/index.js +22 -7
  81. package/dist/telemetry/index.js +5 -1
  82. package/dist/templates/charts-values/dependencies/values.yaml +8 -0
  83. package/dist/templates/charts-values/opencrvs-services/values.yaml +6 -0
  84. package/dist/templates/charts-values/opentelemetry/values.yaml +7 -0
  85. package/dist/templates/countryconfig-template/.tiltignore +1 -0
  86. package/dist/templates/countryconfig-template/Dockerfile.assets +7 -0
  87. package/dist/templates/countryconfig-template/Tiltfile +112 -0
  88. package/dist/templates/countryconfig-template/assets/README.md +1 -0
  89. package/dist/templates/countryconfig-template/assets/clear-all-data-dev.sh +61 -0
  90. package/dist/templates/countryconfig-template/assets/deployment/deploy.sh +455 -0
  91. package/dist/templates/countryconfig-template/assets/deployment/reindex.sh +168 -0
  92. package/dist/templates/countryconfig-template/assets/deployment/validate-required-variables-in-compose-files.ts +67 -0
  93. package/dist/templates/countryconfig-template/assets/elasticsearch/reindex.sh +168 -0
  94. package/dist/templates/countryconfig-template/assets/metabase/README.md +34 -0
  95. package/dist/templates/countryconfig-template/assets/metabase/environment-configuration.sql +36 -0
  96. package/dist/templates/countryconfig-template/assets/metabase/initialize-database.sh +46 -0
  97. package/dist/templates/countryconfig-template/assets/metabase/metabase.init.db.sql +27737 -0
  98. package/dist/templates/countryconfig-template/assets/metabase/open-shell.sh +21 -0
  99. package/dist/templates/countryconfig-template/assets/metabase/package.json +13 -0
  100. package/dist/templates/countryconfig-template/assets/metabase/run-dev.sh +108 -0
  101. package/dist/templates/countryconfig-template/assets/metabase/run.sh +120 -0
  102. package/dist/templates/countryconfig-template/assets/metabase/update-database.sh +40 -0
  103. package/dist/templates/countryconfig-template/assets/postgres/setup-analytics.sh +135 -0
  104. package/dist/templates/countryconfig-template/assets/postgres/setup-reference-data.sh +108 -0
  105. package/dist/templates/countryconfig-template/tilt/clear-all-data.ps1 +50 -0
  106. package/dist/templates/countryconfig-template/tilt/clear-all-data.sh +35 -0
  107. package/dist/templates/countryconfig-template/tilt/common.tilt +145 -0
  108. package/dist/templates/countryconfig-template/tilt/examples/dependencies/values.yaml +15 -0
  109. package/dist/templates/countryconfig-template/tilt/examples/opencrvs-services/values.yaml +56 -0
  110. package/dist/templates/countryconfig-template/tilt/examples/traefik/values-minikube.yaml +21 -0
  111. package/dist/templates/countryconfig-template/tilt/examples/traefik/values.yaml +38 -0
  112. package/dist/templates/countryconfig-template/tilt/helm/dependencies/values.yaml +17 -0
  113. package/dist/templates/countryconfig-template/tilt/helm/opencrvs-services/values.yaml +16 -0
  114. package/dist/templates/countryconfig-template/tilt/lib.tilt +95 -0
  115. package/dist/templates/countryconfig-template/tilt/opencrvs.tilt +136 -0
  116. package/dist/translations/template.d.ts +11 -0
  117. package/dist/translations/template.d.ts.map +1 -0
  118. package/dist/translations/template.js +100 -0
  119. package/dist/verify/endpoints.d.ts +2 -0
  120. package/dist/verify/endpoints.d.ts.map +1 -0
  121. package/dist/verify/endpoints.js +510 -0
  122. package/opencrvs-toolkit-2.1.0-rc.268cfbe.tgz +0 -0
  123. package/package.json +9 -4
  124. package/tsconfig.build.json +11 -0
  125. package/tsconfig.build.tsbuildinfo +1 -0
  126. package/tsconfig.json +3 -0
  127. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts +0 -3
  128. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts.map +0 -1
  129. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.js +0 -429
  130. package/dist/migrations/v2.0/add-resend-invite-notification.d.ts +0 -3
  131. package/dist/migrations/v2.0/add-resend-invite-notification.d.ts.map +0 -1
  132. package/dist/migrations/v2.0/add-resend-invite-notification.js +0 -373
  133. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +0 -22
  134. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +0 -1
  135. package/dist/migrations/v2.0/checkout-upstream-files.js +0 -146
  136. package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts +0 -2
  137. package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts.map +0 -1
  138. package/dist/migrations/v2.0/convert-config-files-to-ts.js +0 -838
  139. package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts +0 -3
  140. package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts.map +0 -1
  141. package/dist/migrations/v2.0/convert-paragraph-to-heading.js +0 -158
  142. package/dist/migrations/v2.0/create-events-index.d.ts +0 -3
  143. package/dist/migrations/v2.0/create-events-index.d.ts.map +0 -1
  144. package/dist/migrations/v2.0/create-events-index.js +0 -325
  145. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts +0 -11
  146. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts.map +0 -1
  147. package/dist/migrations/v2.0/delete-infrastructure-directory.js +0 -123
  148. package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.d.ts +0 -3
  149. package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.d.ts.map +0 -1
  150. package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.js +0 -110
  151. package/dist/migrations/v2.0/index.d.ts +0 -13
  152. package/dist/migrations/v2.0/index.d.ts.map +0 -1
  153. package/dist/migrations/v2.0/index.js +0 -103
  154. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts +0 -3
  155. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts.map +0 -1
  156. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.js +0 -432
  157. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts +0 -13
  158. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts.map +0 -1
  159. package/dist/migrations/v2.0/merge-infrastructure-directory.js +0 -222
  160. package/dist/migrations/v2.0/migrate-application-config-url.d.ts +0 -3
  161. package/dist/migrations/v2.0/migrate-application-config-url.d.ts.map +0 -1
  162. package/dist/migrations/v2.0/migrate-application-config-url.js +0 -343
  163. package/dist/migrations/v2.0/migrate-scopes.d.ts.map +0 -1
  164. package/dist/migrations/v2.0/migrate-scopes.js +0 -305
  165. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts +0 -3
  166. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts.map +0 -1
  167. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.js +0 -267
  168. package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts +0 -3
  169. package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts.map +0 -1
  170. package/dist/migrations/v2.0/migrate-workqueue-configs.js +0 -317
  171. package/dist/migrations/v2.0/remove-delete-actions.d.ts +0 -3
  172. package/dist/migrations/v2.0/remove-delete-actions.d.ts.map +0 -1
  173. package/dist/migrations/v2.0/remove-delete-actions.js +0 -156
  174. package/dist/migrations/v2.0/remove-demo-scope.d.ts +0 -3
  175. package/dist/migrations/v2.0/remove-demo-scope.d.ts.map +0 -1
  176. package/dist/migrations/v2.0/remove-demo-scope.js +0 -74
  177. package/dist/migrations/v2.0/remove-deprecated-imports.d.ts +0 -3
  178. package/dist/migrations/v2.0/remove-deprecated-imports.d.ts.map +0 -1
  179. package/dist/migrations/v2.0/remove-deprecated-imports.js +0 -96
  180. package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts +0 -3
  181. package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts.map +0 -1
  182. package/dist/migrations/v2.0/remove-fhir-url-helpers.js +0 -163
  183. package/dist/migrations/v2.0/remove-hearth-migrations.d.ts +0 -3
  184. package/dist/migrations/v2.0/remove-hearth-migrations.d.ts.map +0 -1
  185. package/dist/migrations/v2.0/remove-hearth-migrations.js +0 -87
  186. package/dist/migrations/v2.0/remove-old-statistics-service.d.ts +0 -3
  187. package/dist/migrations/v2.0/remove-old-statistics-service.d.ts.map +0 -1
  188. package/dist/migrations/v2.0/remove-old-statistics-service.js +0 -356
  189. package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts +0 -3
  190. package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts.map +0 -1
  191. package/dist/migrations/v2.0/remove-pending-certification-flag.js +0 -109
  192. package/dist/migrations/v2.0/remove-review-from-register-action.d.ts +0 -3
  193. package/dist/migrations/v2.0/remove-review-from-register-action.d.ts.map +0 -1
  194. package/dist/migrations/v2.0/remove-review-from-register-action.js +0 -163
  195. package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts +0 -3
  196. package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts.map +0 -1
  197. package/dist/migrations/v2.0/remove-unused-environment-variables.js +0 -186
  198. package/dist/migrations/v2.0/rename-api-paths.d.ts.map +0 -1
  199. package/dist/migrations/v2.0/rename-location-parent-id.d.ts +0 -3
  200. package/dist/migrations/v2.0/rename-location-parent-id.d.ts.map +0 -1
  201. package/dist/migrations/v2.0/rename-location-parent-id.js +0 -180
  202. package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts +0 -3
  203. package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts.map +0 -1
  204. package/dist/migrations/v2.0/simplify-analytics-precalculations.js +0 -195
  205. package/dist/migrations/v2.0/update-package-json.d.ts +0 -3
  206. package/dist/migrations/v2.0/update-package-json.d.ts.map +0 -1
  207. package/dist/migrations/v2.0/update-package-json.js +0 -105
  208. package/opencrvs-toolkit-2.1.0-rc.1f688f9.tgz +0 -0
  209. package/tsconfig.tsbuildinfo +0 -1
@@ -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";
@@ -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,35 @@ 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 declaration after each of `event.actions`, which must be in chronological order.
606
+ * Index `i` equals `aggregateActionDeclarations` of the first `i + 1` actions, in linear time.
607
+ */
608
+ export declare function getDeclarationAfterEachAction(event: EventDocument): EventState[];
609
+ /**
610
+ * Returns the event's declaration state as it will be once the single pending
611
+ * action is accepted — i.e. the aggregate of all accepted declarations with the
612
+ * pending action's changes applied on top.
613
+ *
614
+ * Country configuration confirmation handlers (and notifications) need the
615
+ * up-to-date declaration at confirmation time, before core has accepted the
616
+ * action. Reaching for `aggregateActionDeclarations` alone is not enough for
617
+ * corrections: when confirming an APPROVE_CORRECTION the changed fields live on
618
+ * the linked REQUEST_CORRECTION, not on the pending action's own (empty)
619
+ * declaration. This helper applies the same correction-aware merge that
620
+ * `aggregateActionDeclarations` uses for already-accepted approvals, so callers
621
+ * do not have to reimplement the `requestId`/`originalActionId` resolution.
622
+ */
623
+ export declare function getDeclarationWithPendingAction(event: EventDocument): EventState;
599
624
  export declare function aggregateActionAnnotations(event: EventDocument): EventState;
625
+ /**
626
+ * 2.1. onwards secured fields have accepted conditionals.
627
+ * Secured fields are not present in EventIndex payload.
628
+ * When we derive @see EventIndex from @see EventDocument, we will have all the fields present.
629
+ *
630
+ * To keep the views consistent, and not to change if event.get gets triggered, we need to clean out the secured fields.
631
+ *
632
+ * @returns EventIndex without values that evaluate to secured: true.
633
+ */
634
+ export declare function dropSecuredDeclarationFields(eventConfig: EventConfig, eventIndex: EventIndex, validatorContext: ValidatorContext): EventIndex;
600
635
  //# sourceMappingURL=utils.d.ts.map
@@ -1,10 +1,5 @@
1
1
  import { TriggerEvent, TriggerPayload } from './UserNotifications';
2
- export declare function triggerUserEventNotification(args: {
3
- event: typeof TriggerEvent.ALL_USER_NOTIFICATION;
4
- payload: TriggerPayload[typeof TriggerEvent.ALL_USER_NOTIFICATION];
5
- countryConfigUrl: string;
6
- }): Promise<Response>;
7
- export declare function triggerUserEventNotification<T extends Exclude<TriggerEvent, typeof TriggerEvent.ALL_USER_NOTIFICATION>>(args: {
2
+ export declare function triggerUserEventNotification<T extends TriggerEvent>({ event, payload, countryConfigUrl, authHeader }: {
8
3
  event: T;
9
4
  payload: TriggerPayload[T];
10
5
  countryConfigUrl: string;
@@ -414,7 +414,9 @@ var RecordScopeTypeV2 = z11.enum([
414
414
  "record.request-correction",
415
415
  "record.correct",
416
416
  "record.unassign-others",
417
- "record.custom-action"
417
+ "record.custom-action",
418
+ "record.action.accept",
419
+ "record.action.reject"
418
420
  ]);
419
421
  var PlainScopeType = z11.enum([
420
422
  // Misc. system scopes
@@ -436,10 +438,7 @@ var PlainScopeType = z11.enum([
436
438
  // Performance dashboard
437
439
  "performance.read",
438
440
  "performance.read-dashboards",
439
- "performance.vital-statistics-export",
440
- // Scopes used exclusively by countryconfig integration token
441
- "record.confirm-registration",
442
- "record.reject-registration"
441
+ "performance.vital-statistics-export"
443
442
  ]);
444
443
  var scopeByEvent = z11.preprocess(
445
444
  (val) => val === void 0 ? void 0 : [val].flat(),
@@ -457,7 +456,9 @@ var userRole = z11.preprocess(
457
456
  ).describe("User role, e.g. admin, field agent");
458
457
  var scopeOptionsPlaceEvent = z11.object({
459
458
  event: scopeByEvent,
460
- placeOfEvent: JurisdictionFilter.optional()
459
+ placeOfEvent: JurisdictionFilter.optional(),
460
+ createdBy: UserFilter.optional(),
461
+ createdIn: JurisdictionFilter.optional()
461
462
  }).describe("Options applicable to all record scopes.");
462
463
  var scopeOptionsDeclaredOrNotified = scopeOptionsPlaceEvent.extend({
463
464
  notifiedIn: JurisdictionFilter.optional(),
@@ -500,7 +501,9 @@ var AllScopeOptions = z11.object({
500
501
  var ScopeOptionKey = AllScopeOptions.keyof();
501
502
  var ResolvedScopeOptionsPlaceEvent = z11.object({
502
503
  event: scopeByEvent,
503
- placeOfEvent: UUID.nullish()
504
+ placeOfEvent: UUID.nullish(),
505
+ createdBy: z11.string().optional(),
506
+ createdIn: UUID.nullish()
504
507
  }).describe(
505
508
  "Resolved options applicable to all record scopes, with location ID instead of jurisdiction filter."
506
509
  );
@@ -547,6 +550,13 @@ var ScopeOptionsPrintCertifiedCopies = AllRecordScopeOptions.extend({
547
550
  "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."
548
551
  )
549
552
  });
553
+ var ActionConfirmationScopeType = RecordScopeTypeV2.extract([
554
+ "record.action.accept",
555
+ "record.action.reject"
556
+ ]);
557
+ var ActionConfirmationScopeOptions = AllRecordScopeOptions.describe(
558
+ "Options for confirming (accepting or rejecting) an action."
559
+ );
550
560
  var RecordScopeV2 = z11.discriminatedUnion("type", [
551
561
  z11.object({
552
562
  type: ScopesWithPlaceEventOptions,
@@ -567,6 +577,10 @@ var RecordScopeV2 = z11.discriminatedUnion("type", [
567
577
  z11.object({
568
578
  type: z11.literal("record.print-certified-copies"),
569
579
  options: ScopeOptionsPrintCertifiedCopies.optional()
580
+ }),
581
+ z11.object({
582
+ type: ActionConfirmationScopeType,
583
+ options: ActionConfirmationScopeOptions.optional()
570
584
  })
571
585
  ]).describe(
572
586
  "Scopes used to check user's permission to perform actions on a record."
package/dist/csv.d.ts ADDED
@@ -0,0 +1,25 @@
1
+ export type CsvFile = {
2
+ header: string;
3
+ body: string[];
4
+ /** Preserved so a file written on Windows stays written on Windows. */
5
+ newline: string;
6
+ trailingNewline: boolean;
7
+ };
8
+ export declare function parseCsvLine(line: string): string[];
9
+ export declare function toCsvLine(values: string[]): string;
10
+ /**
11
+ * The id of a row, which is its first column. Translation ids never contain a
12
+ * comma or a quote, so this does not need the parser.
13
+ */
14
+ export declare function idOf(line: string): string;
15
+ export declare function readCsvFile(path: string): CsvFile | undefined;
16
+ export declare function writeCsvFile(path: string, file: CsvFile): void;
17
+ /**
18
+ * Adds the rows the file does not already have an id for, in place. Rows go in
19
+ * sorted position when the file is sorted by id, and at the end when it is not,
20
+ * so a country config that keeps its own order keeps it.
21
+ *
22
+ * Returns the ids that were added.
23
+ */
24
+ export declare function addRows(file: CsvFile, rows: string[]): string[];
25
+ //# sourceMappingURL=csv.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"csv.d.ts","sourceRoot":"","sources":["../src/csv.ts"],"names":[],"mappings":"AAuBA,MAAM,MAAM,OAAO,GAAG;IACpB,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,uEAAuE;IACvE,OAAO,EAAE,MAAM,CAAA;IACf,eAAe,EAAE,OAAO,CAAA;CACzB,CAAA;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAiCnD;AAED,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAMlD;AAED;;;GAGG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKzC;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAe7D;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,CAM9D;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CA4B/D"}
package/dist/csv.js ADDED
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ /*
3
+ * This Source Code Form is subject to the terms of the Mozilla Public
4
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
5
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/.
6
+ *
7
+ * OpenCRVS is also distributed under the terms of the Civil Registration
8
+ * & Healthcare Disclaimer located at http://opencrvs.org/license.
9
+ *
10
+ * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS.
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.parseCsvLine = parseCsvLine;
14
+ exports.toCsvLine = toCsvLine;
15
+ exports.idOf = idOf;
16
+ exports.readCsvFile = readCsvFile;
17
+ exports.writeCsvFile = writeCsvFile;
18
+ exports.addRows = addRows;
19
+ /**
20
+ * Just enough CSV for the translation files codemods edit. They are read and
21
+ * written a line at a time rather than through a parser, so that adding two
22
+ * rows to a file of sixteen hundred produces a diff of two lines instead of a
23
+ * re-quoted rewrite of the whole thing.
24
+ *
25
+ * Rows spanning multiple lines are not supported, and none of the translation
26
+ * files contain any.
27
+ */
28
+ const fs_1 = require("fs");
29
+ function parseCsvLine(line) {
30
+ const values = [];
31
+ let value = '';
32
+ let quoted = false;
33
+ for (let index = 0; index < line.length; index++) {
34
+ const character = line[index];
35
+ if (quoted) {
36
+ if (character !== '"') {
37
+ value += character;
38
+ }
39
+ else if (line[index + 1] === '"') {
40
+ value += '"';
41
+ index++;
42
+ }
43
+ else {
44
+ quoted = false;
45
+ }
46
+ continue;
47
+ }
48
+ if (character === '"') {
49
+ quoted = true;
50
+ }
51
+ else if (character === ',') {
52
+ values.push(value);
53
+ value = '';
54
+ }
55
+ else {
56
+ value += character;
57
+ }
58
+ }
59
+ values.push(value);
60
+ return values;
61
+ }
62
+ function toCsvLine(values) {
63
+ return values
64
+ .map((value) => /["\n,]/.test(value) ? `"${value.replace(/"/g, '""')}"` : value)
65
+ .join(',');
66
+ }
67
+ /**
68
+ * The id of a row, which is its first column. Translation ids never contain a
69
+ * comma or a quote, so this does not need the parser.
70
+ */
71
+ function idOf(line) {
72
+ const comma = line.indexOf(',');
73
+ // No comma: `slice(0, -1)` would eat the last character.
74
+ return comma === -1 ? line : line.slice(0, comma);
75
+ }
76
+ function readCsvFile(path) {
77
+ if (!(0, fs_1.existsSync)(path)) {
78
+ return undefined;
79
+ }
80
+ const contents = (0, fs_1.readFileSync)(path, 'utf8');
81
+ const newline = contents.includes('\r\n') ? '\r\n' : '\n';
82
+ const trailingNewline = /\r?\n$/.test(contents);
83
+ const lines = contents.replace(/\r?\n$/, '').split(/\r?\n/);
84
+ // Trailing blank line leaves an empty entry. It sorts before every id, so
85
+ // the file reads as unsorted.
86
+ const body = lines.slice(1).filter((line) => line !== '');
87
+ return { header: lines[0], body, newline, trailingNewline };
88
+ }
89
+ function writeCsvFile(path, file) {
90
+ (0, fs_1.writeFileSync)(path, [file.header, ...file.body].join(file.newline) +
91
+ (file.trailingNewline ? file.newline : ''));
92
+ }
93
+ /**
94
+ * Adds the rows the file does not already have an id for, in place. Rows go in
95
+ * sorted position when the file is sorted by id, and at the end when it is not,
96
+ * so a country config that keeps its own order keeps it.
97
+ *
98
+ * Returns the ids that were added.
99
+ */
100
+ function addRows(file, rows) {
101
+ const isSorted = file.body.every((line, index) => index === 0 || idOf(file.body[index - 1]) <= idOf(line));
102
+ const added = [];
103
+ for (const row of rows) {
104
+ const id = idOf(row);
105
+ if (file.body.some((line) => idOf(line) === id)) {
106
+ continue;
107
+ }
108
+ const insertAt = isSorted
109
+ ? file.body.findIndex((line) => idOf(line) > id)
110
+ : -1;
111
+ if (insertAt === -1) {
112
+ file.body.push(row);
113
+ }
114
+ else {
115
+ file.body.splice(insertAt, 0, row);
116
+ }
117
+ added.push(id);
118
+ }
119
+ return added;
120
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/environment/index.ts"],"names":[],"mappings":"AAyCA,wBAAsB,kBAAkB,kBAIvC;AAED,wBAAsB,qBAAqB,kBAI1C;AAED,wBAAsB,6BAA6B,kBAIlD;AAED,wBAAsB,mBAAmB,kBAIxC;AAED,wBAAsB,wBAAwB,kBAG7C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/environment/index.ts"],"names":[],"mappings":"AAyCA,wBAAsB,kBAAkB,kBAKvC;AAED,wBAAsB,qBAAqB,kBAI1C;AAED,wBAAsB,6BAA6B,kBAIlD;AAED,wBAAsB,mBAAmB,kBAIxC;AAED,wBAAsB,wBAAwB,kBAG7C"}
@@ -49,7 +49,8 @@ function runEnvironmentInit() {
49
49
  return __awaiter(this, void 0, void 0, function* () {
50
50
  validateRepositoryStructure();
51
51
  (0, paths_1.assertNoOldInventoryLayout)();
52
- yield import('./setup-environment.js');
52
+ const { runSetupEnvironment } = yield import('./setup-environment.js');
53
+ yield runSetupEnvironment();
53
54
  });
54
55
  }
55
56
  function runEnvironmentUpgrade() {
@@ -1,15 +1,18 @@
1
1
  export declare const log: {
2
2
  (message?: any, ...optionalParams: any[]): void;
3
3
  (message?: any, ...optionalParams: any[]): void;
4
+ (message?: any, ...optionalParams: any[]): void;
4
5
  };
5
6
  export declare const warn: {
6
7
  (message?: any, ...optionalParams: any[]): void;
7
8
  (message?: any, ...optionalParams: any[]): void;
9
+ (message?: any, ...optionalParams: any[]): void;
8
10
  };
9
11
  export declare const success: (...args: any[]) => void;
10
12
  export declare const info: {
11
13
  (message?: any, ...optionalParams: any[]): void;
12
14
  (message?: any, ...optionalParams: any[]): void;
15
+ (message?: any, ...optionalParams: any[]): void;
13
16
  };
14
17
  export declare const error: (...args: any[]) => void;
15
18
  //# sourceMappingURL=logger.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/environment/logger.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,GAAG;;;CAAc,CAAA;AAC9B,eAAO,MAAM,IAAI;;;CAAe,CAAA;AAChC,eAAO,MAAM,OAAO,YAAa,GAAG,EAAE,SACI,CAAA;AAC1C,eAAO,MAAM,IAAI;;;CAAe,CAAA;AAChC,eAAO,MAAM,KAAK,YAAa,GAAG,EAAE,SAA2C,CAAA"}
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/environment/logger.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,GAAG;;;;CAAc,CAAA;AAC9B,eAAO,MAAM,IAAI;;;;CAAe,CAAA;AAChC,eAAO,MAAM,OAAO,YAAa,GAAG,EAAE,SACI,CAAA;AAC1C,eAAO,MAAM,IAAI;;;;CAAe,CAAA;AAChC,eAAO,MAAM,KAAK,YAAa,GAAG,EAAE,SAA2C,CAAA"}
@@ -95,7 +95,7 @@ function updateInventoryFile(filePath, users) {
95
95
  function parseInventoryFile(filePath) {
96
96
  try {
97
97
  const data = (0, utils_1.readYamlFile)(filePath);
98
- return (0, templates_1.getUsers)(data);
98
+ return (0, templates_1.extractAndModifyUsers)(data);
99
99
  }
100
100
  catch (_a) {
101
101
  return [];
@@ -1,2 +1,2 @@
1
- export {};
1
+ export declare function runSetupEnvironment(): Promise<void>;
2
2
  //# sourceMappingURL=setup-environment.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"setup-environment.d.ts","sourceRoot":"","sources":["../../src/environment/setup-environment.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"setup-environment.d.ts","sourceRoot":"","sources":["../../src/environment/setup-environment.ts"],"names":[],"mappings":"AAwSA,wBAAsB,mBAAmB,kBAkmCxC"}