@opencrvs/toolkit 2.1.2 → 2.2.0-rc.19ec10b

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (177) hide show
  1. package/build.sh +9 -14
  2. package/create-countryconfig/package.json +1 -1
  3. package/dist/application-config/index.js +57 -14
  4. package/dist/authentication/index.d.ts +2 -1
  5. package/dist/authentication/index.js +34 -14
  6. package/dist/cli.js +1491 -2020
  7. package/dist/commons/api/router.d.ts +1564 -248
  8. package/dist/commons/application-config/index.d.ts +3 -3
  9. package/dist/commons/conditionals/conditionals.d.ts +58 -7
  10. package/dist/commons/conditionals/index.d.ts +1 -0
  11. package/dist/commons/conditionals/validate.d.ts +6 -1
  12. package/dist/commons/events/ActionConfig.d.ts +146 -20
  13. package/dist/commons/events/ActionDocument.d.ts +89 -0
  14. package/dist/commons/events/ActionInput.d.ts +56 -4
  15. package/dist/commons/events/ActionStatus.d.ts +2 -2
  16. package/dist/commons/events/ActionType.d.ts +13 -1
  17. package/dist/commons/events/AdvancedSearchConfig.d.ts +15 -0
  18. package/dist/commons/events/AuditLog.d.ts +4 -0
  19. package/dist/commons/events/CompositeFieldValue.d.ts +5 -1
  20. package/dist/commons/events/CountryConfigQueryInput.d.ts +192 -18
  21. package/dist/commons/events/Draft.d.ts +36 -1
  22. package/dist/commons/events/EventConfig.d.ts +473 -6
  23. package/dist/commons/events/EventDocument.d.ts +90 -0
  24. package/dist/commons/events/EventIndex.d.ts +44 -6
  25. package/dist/commons/events/EventInput.d.ts +1 -0
  26. package/dist/commons/events/EventMetadata.d.ts +24 -1
  27. package/dist/commons/events/EventStatus.d.ts +1 -0
  28. package/dist/commons/events/FieldConfig.d.ts +11 -1
  29. package/dist/commons/events/FieldTypeMapping.d.ts +17 -17
  30. package/dist/commons/events/Flag.d.ts +1 -7
  31. package/dist/commons/events/PlainDate.d.ts +6 -0
  32. package/dist/commons/events/WorkqueueConfig.d.ts +224 -33
  33. package/dist/commons/events/defineConfig.d.ts +7 -2
  34. package/dist/commons/events/event.d.ts +20 -1
  35. package/dist/commons/events/eventConfigValidation.d.ts +26 -1
  36. package/dist/commons/events/field.d.ts +37 -0
  37. package/dist/commons/events/index.d.ts +3 -0
  38. package/dist/commons/events/locations.d.ts +1 -1
  39. package/dist/commons/events/scopes.d.ts +4 -1
  40. package/dist/commons/events/state/flags.d.ts +1 -1
  41. package/dist/commons/events/state/index.d.ts +11 -2
  42. package/dist/commons/events/state/utils.d.ts +11 -1
  43. package/dist/commons/events/test.utils.d.ts +89 -7
  44. package/dist/commons/events/toNotificationForm.d.ts +17 -0
  45. package/dist/commons/events/utils.d.ts +90 -10
  46. package/dist/commons/users/Role.d.ts +23 -0
  47. package/dist/commons/users/User.d.ts +263 -0
  48. package/dist/commons/users/authentication.d.ts +67 -0
  49. package/dist/commons/users/index.d.ts +5 -0
  50. package/dist/commons/users/roleValidations.d.ts +15 -0
  51. package/dist/commons/users/scopes.d.ts +1402 -0
  52. package/dist/commons/users/userReferences.d.ts +176 -0
  53. package/dist/conditionals/index.js +29 -9
  54. package/dist/environment/custom-types.d.ts +1 -0
  55. package/dist/environment/custom-types.d.ts.map +1 -1
  56. package/dist/environment/derived-variables.d.ts +24 -4
  57. package/dist/environment/derived-variables.d.ts.map +1 -1
  58. package/dist/environment/derived-variables.js +27 -4
  59. package/dist/environment/questions.d.ts +42 -9
  60. package/dist/environment/questions.d.ts.map +1 -1
  61. package/dist/environment/questions.js +71 -48
  62. package/dist/environment/registry.d.ts +15 -0
  63. package/dist/environment/registry.d.ts.map +1 -0
  64. package/dist/environment/registry.js +112 -0
  65. package/dist/environment/setup-environment.d.ts.map +1 -1
  66. package/dist/environment/setup-environment.js +165 -35
  67. package/dist/environment/templates.d.ts.map +1 -1
  68. package/dist/events/index.js +2050 -1156
  69. package/dist/migrations/add-notify-config.d.ts +40 -0
  70. package/dist/migrations/add-notify-config.d.ts.map +1 -0
  71. package/dist/migrations/add-notify-config.js +249 -0
  72. package/dist/migrations/index.d.ts +9 -0
  73. package/dist/migrations/index.d.ts.map +1 -0
  74. package/dist/migrations/index.js +1306 -0
  75. package/dist/migrations/move-declaration-to-declare-action.d.ts +38 -0
  76. package/dist/migrations/move-declaration-to-declare-action.d.ts.map +1 -0
  77. package/dist/migrations/move-declaration-to-declare-action.js +260 -0
  78. package/dist/migrations/{v2.1 → persistent}/add-translations.d.ts +7 -1
  79. package/dist/migrations/persistent/add-translations.d.ts.map +1 -0
  80. package/dist/migrations/{v2.1 → persistent}/add-translations.js +14 -12
  81. package/dist/migrations/persistent/check-upgrade-path.d.ts +36 -0
  82. package/dist/migrations/persistent/check-upgrade-path.d.ts.map +1 -0
  83. package/dist/migrations/persistent/check-upgrade-path.js +105 -0
  84. package/dist/migrations/persistent/update-toolkit-dependency.d.ts +7 -0
  85. package/dist/migrations/persistent/update-toolkit-dependency.d.ts.map +1 -0
  86. package/dist/migrations/persistent/update-toolkit-dependency.js +77 -0
  87. package/dist/migrations/read-declaration-through-helper.d.ts +39 -0
  88. package/dist/migrations/read-declaration-through-helper.d.ts.map +1 -0
  89. package/dist/migrations/read-declaration-through-helper.js +199 -0
  90. package/dist/migrations/replace-incomplete-flag.d.ts +26 -0
  91. package/dist/migrations/replace-incomplete-flag.d.ts.map +1 -0
  92. package/dist/migrations/replace-incomplete-flag.js +126 -0
  93. package/dist/migrations/resolve-versioned-event-config.d.ts +56 -0
  94. package/dist/migrations/resolve-versioned-event-config.d.ts.map +1 -0
  95. package/dist/migrations/resolve-versioned-event-config.js +353 -0
  96. package/dist/migrations/utils.d.ts +61 -0
  97. package/dist/migrations/utils.d.ts.map +1 -0
  98. package/dist/migrations/utils.js +218 -0
  99. package/dist/notification/index.js +1081 -209
  100. package/dist/roles/index.d.ts +2 -0
  101. package/dist/roles/index.d.ts.map +1 -0
  102. package/dist/roles/index.js +730 -0
  103. package/dist/scopes/index.d.ts +83 -100
  104. package/dist/scopes/index.js +29 -13
  105. package/dist/templates/charts-values/dependencies/values.yaml +6 -3
  106. package/dist/templates/charts-values/opencrvs-services/values.yaml +5 -10
  107. package/dist/templates/charts-values/traefik/values.yaml +4 -3
  108. package/dist/verify/endpoints.d.ts +11 -0
  109. package/dist/verify/endpoints.d.ts.map +1 -1
  110. package/dist/verify/endpoints.js +21 -27
  111. package/opencrvs-toolkit-2.2.0-rc.19ec10b.tgz +0 -0
  112. package/package.json +5 -3
  113. package/tsconfig.build.tsbuildinfo +1 -1
  114. package/tsconfig.json +3 -5
  115. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts +0 -3
  116. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts.map +0 -1
  117. package/dist/migrations/v2.1/add-explicit-correction-flags.js +0 -234
  118. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts +0 -3
  119. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts.map +0 -1
  120. package/dist/migrations/v2.1/add-recovery-link-notifications.js +0 -511
  121. package/dist/migrations/v2.1/add-translations.d.ts.map +0 -1
  122. package/dist/migrations/v2.1/enable-telemetry.d.ts +0 -3
  123. package/dist/migrations/v2.1/enable-telemetry.d.ts.map +0 -1
  124. package/dist/migrations/v2.1/enable-telemetry.js +0 -455
  125. package/dist/migrations/v2.1/index.d.ts +0 -6
  126. package/dist/migrations/v2.1/index.d.ts.map +0 -1
  127. package/dist/migrations/v2.1/index.js +0 -2170
  128. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts +0 -14
  129. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts.map +0 -1
  130. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.js +0 -348
  131. package/dist/migrations/v2.1/remove-metabase-package-installs.d.ts +0 -2
  132. package/dist/migrations/v2.1/remove-metabase-package-installs.d.ts.map +0 -1
  133. package/dist/migrations/v2.1/remove-metabase-package-installs.js +0 -161
  134. package/dist/migrations/v2.1/remove-sentry.d.ts +0 -3
  135. package/dist/migrations/v2.1/remove-sentry.d.ts.map +0 -1
  136. package/dist/migrations/v2.1/remove-sentry.js +0 -354
  137. package/dist/migrations/v2.1/rename-trigger-paths.d.ts +0 -3
  138. package/dist/migrations/v2.1/rename-trigger-paths.d.ts.map +0 -1
  139. package/dist/migrations/v2.1/rename-trigger-paths.js +0 -216
  140. package/dist/migrations/v2.1/template-files.d.ts +0 -8
  141. package/dist/migrations/v2.1/template-files.d.ts.map +0 -1
  142. package/dist/migrations/v2.1/template-files.js +0 -49
  143. package/dist/migrations/v2.1/upgrade-tilt.d.ts +0 -8
  144. package/dist/migrations/v2.1/upgrade-tilt.d.ts.map +0 -1
  145. package/dist/migrations/v2.1/upgrade-tilt.js +0 -139
  146. package/dist/templates/countryconfig-template/.tiltignore +0 -1
  147. package/dist/templates/countryconfig-template/Dockerfile.assets +0 -7
  148. package/dist/templates/countryconfig-template/Tiltfile +0 -112
  149. package/dist/templates/countryconfig-template/assets/README.md +0 -1
  150. package/dist/templates/countryconfig-template/assets/clear-all-data-dev.sh +0 -61
  151. package/dist/templates/countryconfig-template/assets/deployment/deploy.sh +0 -455
  152. package/dist/templates/countryconfig-template/assets/deployment/reindex.sh +0 -168
  153. package/dist/templates/countryconfig-template/assets/deployment/validate-required-variables-in-compose-files.ts +0 -67
  154. package/dist/templates/countryconfig-template/assets/elasticsearch/reindex.sh +0 -168
  155. package/dist/templates/countryconfig-template/assets/metabase/README.md +0 -34
  156. package/dist/templates/countryconfig-template/assets/metabase/environment-configuration.sql +0 -36
  157. package/dist/templates/countryconfig-template/assets/metabase/initialize-database.sh +0 -46
  158. package/dist/templates/countryconfig-template/assets/metabase/metabase.init.db.sql +0 -27737
  159. package/dist/templates/countryconfig-template/assets/metabase/open-shell.sh +0 -21
  160. package/dist/templates/countryconfig-template/assets/metabase/package.json +0 -13
  161. package/dist/templates/countryconfig-template/assets/metabase/run-dev.sh +0 -108
  162. package/dist/templates/countryconfig-template/assets/metabase/run.sh +0 -120
  163. package/dist/templates/countryconfig-template/assets/metabase/update-database.sh +0 -40
  164. package/dist/templates/countryconfig-template/assets/postgres/setup-analytics.sh +0 -135
  165. package/dist/templates/countryconfig-template/assets/postgres/setup-reference-data.sh +0 -108
  166. package/dist/templates/countryconfig-template/tilt/clear-all-data.ps1 +0 -50
  167. package/dist/templates/countryconfig-template/tilt/clear-all-data.sh +0 -35
  168. package/dist/templates/countryconfig-template/tilt/common.tilt +0 -145
  169. package/dist/templates/countryconfig-template/tilt/examples/dependencies/values.yaml +0 -15
  170. package/dist/templates/countryconfig-template/tilt/examples/opencrvs-services/values.yaml +0 -56
  171. package/dist/templates/countryconfig-template/tilt/examples/traefik/values-minikube.yaml +0 -21
  172. package/dist/templates/countryconfig-template/tilt/examples/traefik/values.yaml +0 -38
  173. package/dist/templates/countryconfig-template/tilt/helm/dependencies/values.yaml +0 -17
  174. package/dist/templates/countryconfig-template/tilt/helm/opencrvs-services/values.yaml +0 -16
  175. package/dist/templates/countryconfig-template/tilt/lib.tilt +0 -95
  176. package/dist/templates/countryconfig-template/tilt/opencrvs.tilt +0 -136
  177. package/opencrvs-toolkit-2.1.2.tgz +0 -0
@@ -1,5 +1,5 @@
1
1
  import { ActionType, DeclarationActionType, DisplayableAction } from './ActionType';
2
- import { EventConfig } from './EventConfig';
2
+ import { EventConfig, VersionedEventConfig } from './EventConfig';
3
3
  import { FieldConfig, FieldReference } from './FieldConfig';
4
4
  import { Action, ActionDocument, ActionUpdate, EventState } from './ActionDocument';
5
5
  import { PageConfig, VerificationPageConfig } from './PageConfig';
@@ -8,11 +8,30 @@ import { Draft } from './Draft';
8
8
  import { EventDocument } from './EventDocument';
9
9
  import { UUID } from '../uuid';
10
10
  import { ActionConfig, ActionConfigTypes } from './ActionConfig';
11
- import { FormConfig } from './FormConfig';
11
+ import { DeclarationFormConfig, FormConfig } from './FormConfig';
12
12
  import { PlainDate, SelectDateRangeValue } from './FieldValue';
13
13
  import { EventIndex } from './EventIndex';
14
14
  export declare function ageToDate(age: number, asOfDate: PlainDate): string & import("zod").$brand<"PlainDate">;
15
- export declare function getDeclarationFields(configuration: EventConfig): FieldConfig[];
15
+ export declare function getDeclaration(configuration: EventConfig): {
16
+ label: {
17
+ id: string;
18
+ defaultMessage: string;
19
+ description: string;
20
+ };
21
+ pages: {
22
+ id: string;
23
+ title: {
24
+ id: string;
25
+ defaultMessage: string;
26
+ description: string;
27
+ };
28
+ requireCompletionToContinue: boolean;
29
+ showClearButton?: boolean | undefined;
30
+ fields: FieldConfig[];
31
+ conditional?: any;
32
+ type: "FORM";
33
+ }[];
34
+ };
16
35
  export declare function getDeclarationPages(configuration: EventConfig): {
17
36
  id: string;
18
37
  title: {
@@ -26,7 +45,29 @@ export declare function getDeclarationPages(configuration: EventConfig): {
26
45
  conditional?: any;
27
46
  type: "FORM";
28
47
  }[];
29
- export declare function getDeclaration(configuration: EventConfig): {
48
+ export declare function getDeclarationFields(configuration: EventConfig): FieldConfig[];
49
+ /**
50
+ * @returns the declaration fields of every version of the event, one per id: what any
51
+ * record of the event can hold, whichever version it was created under. Where versions
52
+ * define an id differently, the newest version's field is kept.
53
+ *
54
+ * Used to build the search index mapping: records of every version share one index per
55
+ * event, so its mapping must hold the fields of all of them. Goes away once each version
56
+ * gets its own index (#14335).
57
+ * Known limitation: a field id must keep its type in every version until #14335.
58
+ */
59
+ export declare function getDeclarationFieldsOfAllVersions(config: VersionedEventConfig): FieldConfig[];
60
+ /**
61
+ * @returns the notification form configured on the NOTIFY action.
62
+ * @throws when the event has no NOTIFY action.
63
+ */
64
+ export declare function getNotificationForm(configuration: EventConfig): DeclarationFormConfig;
65
+ export declare function getNotificationFields(configuration: EventConfig): FieldConfig[];
66
+ /**
67
+ * Form a user fills in to submit the given action:
68
+ * the notification form for NOTIFY, the declaration form for DECLARE.
69
+ */
70
+ export declare function getActionForm(configuration: EventConfig, actionType: typeof ActionType.NOTIFY | typeof ActionType.DECLARE): {
30
71
  label: {
31
72
  id: string;
32
73
  defaultMessage: string;
@@ -55,10 +96,6 @@ export declare function getActionConfig({ eventConfiguration, actionType, custom
55
96
  export declare function getCustomActionFields(eventConfiguration: EventConfig, customActionType: string): FieldConfig[];
56
97
  /**
57
98
  * Returns the fields configured for an action's confirmation dialog.
58
- *
59
- * Unlike review fields and supporting copy, NOTIFY does NOT fall back to the
60
- * DECLARE config here: dialog fields always come from the action's own
61
- * configuration entry.
62
99
  */
63
100
  export declare function getActionFormFields(eventConfiguration: EventConfig, actionType: ActionType, customActionType?: string): FieldConfig[];
64
101
  export declare function getPrintCertificatePages(configuration: EventConfig): ({
@@ -277,6 +314,34 @@ export declare function findLastAssignmentAction(actions: Action[]): {
277
314
  status: "Accepted" | "Rejected" | "Requested";
278
315
  originalActionId?: (string & import("zod").$brand<"UUID">) | null | undefined;
279
316
  type: "UNARCHIVE";
317
+ } | {
318
+ id: string & import("zod").$brand<"UUID">;
319
+ transactionId: string;
320
+ createdByUserType: "system" | "user";
321
+ createdAt: string;
322
+ createdBy: string;
323
+ createdByRole?: string | undefined;
324
+ createdBySignature?: (string & import("zod").$brand<"DocumentPath">) | null | undefined;
325
+ createdAtLocation?: (string & import("zod").$brand<"UUID">) | null | undefined;
326
+ declaration: Record<string, import("./FieldValue").FieldUpdateValue>;
327
+ annotation?: Record<string, import("./FieldValue").FieldUpdateValue> | null | undefined;
328
+ status: "Accepted" | "Rejected" | "Requested";
329
+ originalActionId?: (string & import("zod").$brand<"UUID">) | null | undefined;
330
+ type: "REVOKE_REGISTRATION";
331
+ } | {
332
+ id: string & import("zod").$brand<"UUID">;
333
+ transactionId: string;
334
+ createdByUserType: "system" | "user";
335
+ createdAt: string;
336
+ createdBy: string;
337
+ createdByRole?: string | undefined;
338
+ createdBySignature?: (string & import("zod").$brand<"DocumentPath">) | null | undefined;
339
+ createdAtLocation?: (string & import("zod").$brand<"UUID">) | null | undefined;
340
+ declaration: Record<string, import("./FieldValue").FieldUpdateValue>;
341
+ annotation?: Record<string, import("./FieldValue").FieldUpdateValue> | null | undefined;
342
+ status: "Accepted" | "Rejected" | "Requested";
343
+ originalActionId?: (string & import("zod").$brand<"UUID">) | null | undefined;
344
+ type: "REINSTATE_REGISTRATION";
280
345
  } | {
281
346
  id: string & import("zod").$brand<"UUID">;
282
347
  transactionId: string;
@@ -472,7 +537,7 @@ export declare function findLastAssignmentAction(actions: Action[]): {
472
537
  createdBySignature?: (string & import("zod").$brand<"DocumentPath">) | null | undefined;
473
538
  createdAtLocation?: (string & import("zod").$brand<"UUID">) | null | undefined;
474
539
  originalActionId?: (string & import("zod").$brand<"UUID">) | null | undefined;
475
- type: "APPROVE_CORRECTION" | "ARCHIVE" | "CUSTOM" | "DECLARE" | "EDIT" | "NOTIFY" | "PRINT_CERTIFICATE" | "REGISTER" | "REJECT" | "REJECT_CORRECTION" | "REQUEST_CORRECTION" | "UNARCHIVE";
540
+ type: "APPROVE_CORRECTION" | "ARCHIVE" | "CUSTOM" | "DECLARE" | "EDIT" | "NOTIFY" | "PRINT_CERTIFICATE" | "REGISTER" | "REINSTATE_REGISTRATION" | "REJECT" | "REJECT_CORRECTION" | "REQUEST_CORRECTION" | "REVOKE_REGISTRATION" | "UNARCHIVE";
476
541
  status: "Rejected";
477
542
  } | undefined;
478
543
  /**
@@ -582,7 +647,9 @@ export declare const findAllFields: (config: EventConfig) => FieldConfig[];
582
647
  * @returns the value of the object at the given path.
583
648
  */
584
649
  export declare function getMixedPath<T = unknown>(obj: Record<string, unknown>, path: string, defaultValue?: T | undefined): T | undefined;
585
- export declare function getEventConfigById(eventConfigs: EventConfig[], id: string): EventConfig;
650
+ export declare function getEventConfigById<T extends {
651
+ id: string;
652
+ }>(eventConfigs: T[], id: string): T;
586
653
  export declare function timePeriodToDateRange(value: SelectDateRangeValue): {
587
654
  startDate: string;
588
655
  endDate: string;
@@ -600,6 +667,19 @@ export declare function getCompleteActionAnnotation(event: EventDocument, action
600
667
  export declare function getCompleteActionContent(event: EventDocument, action: ActionDocument): Record<string, unknown> | null | undefined;
601
668
  export declare function getCompleteActionDeclaration<T extends EventState | ActionUpdate>(declaration: T, event: EventDocument, action: ActionDocument): T;
602
669
  export declare function getAcceptedActions(event: EventDocument): ActionDocument[];
670
+ /**
671
+ * Returns the event with each Accepted action completed with the details of
672
+ * its original Requested action: who requested it, where, and the request's
673
+ * declaration, annotation and content (the Accepted action's own values win).
674
+ *
675
+ * `$event` conditionals match Accepted actions only, but an Accepted action
676
+ * does not carry everything its request did. A synchronous confirmation drops
677
+ * the request's annotation; an asynchronous `accept` is created by the system
678
+ * user and carries only what the country configuration sent. Without this,
679
+ * `event.hasAction(...).withTemplate(...)` / `.withFields(...)` would stop
680
+ * matching fields that matched the Requested action.
681
+ */
682
+ export declare function getEventWithCompleteAcceptedActions(event: EventDocument): EventDocument;
603
683
  export declare function aggregateActionDeclarations(event: EventDocument): EventState;
604
684
  /**
605
685
  * Returns the declaration after each of `event.actions`, which must be in chronological order.
@@ -0,0 +1,23 @@
1
+ import { z } from 'zod';
2
+ import { VersionedEventConfig } from '../events/EventConfig';
3
+ export declare const Role: z.ZodObject<{
4
+ id: z.ZodString;
5
+ scopes: z.ZodArray<z.core.$ZodBranded<z.ZodString, "EncodedScope", "out">>;
6
+ }, z.core.$strip>;
7
+ export type Role = z.infer<typeof Role>;
8
+ export declare const Roles: z.ZodArray<z.ZodObject<{
9
+ id: z.ZodString;
10
+ scopes: z.ZodArray<z.core.$ZodBranded<z.ZodString, "EncodedScope", "out">>;
11
+ }, z.core.$strip>>;
12
+ export type Roles = z.infer<typeof Roles>;
13
+ /**
14
+ * Helper for defining user roles. Should be used in country config.
15
+ *
16
+ * @param roles Array of roles in object format.
17
+ * @param eventConfigs Array of event configurations, which are needed to run validations for scopes.
18
+ */
19
+ export declare function defineRoles(roles: Roles, eventConfigs: VersionedEventConfig[]): {
20
+ id: string;
21
+ scopes: (string & z.$brand<"EncodedScope">)[];
22
+ }[];
23
+ //# sourceMappingURL=Role.d.ts.map
@@ -0,0 +1,263 @@
1
+ import * as z from 'zod/v4';
2
+ import { UUID } from '../uuid';
3
+ import { FieldValue } from '../events';
4
+ export declare const REINDEX_USER_ID: UUID;
5
+ /**
6
+ * Subject of the short-lived bootstrap token countryconfig uses to register
7
+ * integrations on startup. Must be a well-formed UUID so it can be resolved as
8
+ * a `SystemContext` by services verifying the token — hence the v4 version and
9
+ * variant nibbles rather than an all-zero sentinel like `REINDEX_USER_ID`.
10
+ */
11
+ export declare const INTEGRATION_CREATOR_USER_ID: UUID;
12
+ export declare const UserName: z.ZodObject<{
13
+ firstname: z.ZodString;
14
+ surname: z.ZodString;
15
+ }, z.core.$strip>;
16
+ export declare const User: z.ZodObject<{
17
+ id: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
18
+ name: z.ZodObject<{
19
+ firstname: z.ZodString;
20
+ surname: z.ZodString;
21
+ }, z.core.$strip>;
22
+ role: z.ZodString;
23
+ avatar: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "DocumentPath", "out">>;
24
+ signature: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodString, "DocumentPath", "out">>>;
25
+ primaryOfficeId: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
26
+ administrativeAreaId: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>>;
27
+ device: z.ZodOptional<z.ZodString>;
28
+ fullHonorificName: z.ZodOptional<z.ZodString>;
29
+ type: z.ZodEnum<{
30
+ user: "user";
31
+ }>;
32
+ mobile: z.ZodOptional<z.ZodString>;
33
+ email: z.ZodOptional<z.ZodEmail>;
34
+ status: z.ZodEnum<{
35
+ active: "active";
36
+ deactivated: "deactivated";
37
+ pending: "pending";
38
+ }>;
39
+ data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<FieldValue, unknown, z.core.$ZodTypeInternals<FieldValue, unknown>>>>;
40
+ }, z.core.$strip>;
41
+ export type User = z.infer<typeof User>;
42
+ export declare const UserSummary: z.ZodObject<{
43
+ id: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
44
+ name: z.ZodObject<{
45
+ firstname: z.ZodString;
46
+ surname: z.ZodString;
47
+ }, z.core.$strip>;
48
+ role: z.ZodString;
49
+ avatar: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "DocumentPath", "out">>;
50
+ primaryOfficeId: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
51
+ administrativeAreaId: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>>;
52
+ fullHonorificName: z.ZodOptional<z.ZodString>;
53
+ type: z.ZodEnum<{
54
+ user: "user";
55
+ }>;
56
+ }, z.core.$strip>;
57
+ export type UserSummary = z.infer<typeof UserSummary>;
58
+ export type UserName = User['name'];
59
+ export declare const CreateUserInput: z.ZodObject<{
60
+ name: z.ZodObject<{
61
+ firstname: z.ZodString;
62
+ surname: z.ZodString;
63
+ }, z.core.$strip>;
64
+ role: z.ZodString;
65
+ primaryOfficeId: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
66
+ device: z.ZodOptional<z.ZodString>;
67
+ fullHonorificName: z.ZodOptional<z.ZodString>;
68
+ mobile: z.ZodOptional<z.ZodString>;
69
+ email: z.ZodOptional<z.ZodEmail>;
70
+ data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<FieldValue, unknown, z.core.$ZodTypeInternals<FieldValue, unknown>>>>;
71
+ username: z.ZodOptional<z.ZodUndefined>;
72
+ password: z.ZodOptional<z.ZodUndefined>;
73
+ signature: z.ZodOptional<z.ZodObject<{
74
+ path: z.core.$ZodBranded<z.ZodString, "DocumentPath", "out">;
75
+ originalFilename: z.ZodString;
76
+ type: z.ZodString;
77
+ }, z.core.$strip>>;
78
+ }, z.core.$strip>;
79
+ export type CreateUserInput = z.infer<typeof CreateUserInput>;
80
+ export declare const UpdateUserInput: z.ZodObject<{
81
+ name: z.ZodOptional<z.ZodObject<{
82
+ firstname: z.ZodString;
83
+ surname: z.ZodString;
84
+ }, z.core.$strip>>;
85
+ role: z.ZodOptional<z.ZodString>;
86
+ primaryOfficeId: z.ZodOptional<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>;
87
+ device: z.ZodOptional<z.ZodOptional<z.ZodString>>;
88
+ fullHonorificName: z.ZodOptional<z.ZodOptional<z.ZodString>>;
89
+ mobile: z.ZodOptional<z.ZodOptional<z.ZodString>>;
90
+ email: z.ZodOptional<z.ZodOptional<z.ZodEmail>>;
91
+ data: z.ZodOptional<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<FieldValue, unknown, z.core.$ZodTypeInternals<FieldValue, unknown>>>>>;
92
+ signature: z.ZodOptional<z.ZodObject<{
93
+ path: z.core.$ZodBranded<z.ZodString, "DocumentPath", "out">;
94
+ originalFilename: z.ZodString;
95
+ type: z.ZodString;
96
+ }, z.core.$strip>>;
97
+ id: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
98
+ status: z.ZodOptional<z.ZodEnum<{
99
+ active: "active";
100
+ deactivated: "deactivated";
101
+ }>>;
102
+ }, z.core.$strip>;
103
+ export type UpdateUserInput = z.infer<typeof UpdateUserInput>;
104
+ export declare const MIN_USERNAME_LENGTH = 5;
105
+ export declare const MAX_USERNAME_LENGTH = 30;
106
+ export declare const CreateUserInputInternal: z.ZodObject<{
107
+ name: z.ZodObject<{
108
+ firstname: z.ZodString;
109
+ surname: z.ZodString;
110
+ }, z.core.$strip>;
111
+ role: z.ZodString;
112
+ primaryOfficeId: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
113
+ mobile: z.ZodOptional<z.ZodString>;
114
+ email: z.ZodOptional<z.ZodEmail>;
115
+ username: z.ZodString;
116
+ status: z.ZodOptional<z.ZodEnum<{
117
+ active: "active";
118
+ }>>;
119
+ password: z.ZodOptional<z.ZodString>;
120
+ }, z.core.$strip>;
121
+ export type CreateUserInputInternal = z.infer<typeof CreateUserInputInternal>;
122
+ export declare const System: z.ZodObject<{
123
+ id: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
124
+ name: z.ZodString;
125
+ type: z.ZodEnum<{
126
+ system: "system";
127
+ }>;
128
+ primaryOfficeId: z.ZodOptional<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>;
129
+ administrativeAreaId: z.ZodOptional<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>;
130
+ signature: z.ZodOptional<z.ZodUndefined>;
131
+ avatar: z.ZodOptional<z.ZodUndefined>;
132
+ fullHonorificName: z.ZodOptional<z.ZodString>;
133
+ legacyId: z.ZodOptional<z.ZodString>;
134
+ status: z.ZodOptional<z.ZodUndefined>;
135
+ }, z.core.$strip>;
136
+ export type System = z.infer<typeof System>;
137
+ export declare const SystemSummary: z.ZodObject<{
138
+ id: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
139
+ name: z.ZodString;
140
+ type: z.ZodEnum<{
141
+ system: "system";
142
+ }>;
143
+ primaryOfficeId: z.ZodOptional<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>;
144
+ administrativeAreaId: z.ZodOptional<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>;
145
+ }, z.core.$strip>;
146
+ export declare const UserOrSystem: z.ZodDiscriminatedUnion<[z.ZodObject<{
147
+ id: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
148
+ name: z.ZodObject<{
149
+ firstname: z.ZodString;
150
+ surname: z.ZodString;
151
+ }, z.core.$strip>;
152
+ role: z.ZodString;
153
+ avatar: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "DocumentPath", "out">>;
154
+ signature: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodString, "DocumentPath", "out">>>;
155
+ primaryOfficeId: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
156
+ administrativeAreaId: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>>;
157
+ device: z.ZodOptional<z.ZodString>;
158
+ fullHonorificName: z.ZodOptional<z.ZodString>;
159
+ type: z.ZodEnum<{
160
+ user: "user";
161
+ }>;
162
+ mobile: z.ZodOptional<z.ZodString>;
163
+ email: z.ZodOptional<z.ZodEmail>;
164
+ status: z.ZodEnum<{
165
+ active: "active";
166
+ deactivated: "deactivated";
167
+ pending: "pending";
168
+ }>;
169
+ data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<FieldValue, unknown, z.core.$ZodTypeInternals<FieldValue, unknown>>>>;
170
+ }, z.core.$strip>, z.ZodObject<{
171
+ id: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
172
+ name: z.ZodString;
173
+ type: z.ZodEnum<{
174
+ system: "system";
175
+ }>;
176
+ primaryOfficeId: z.ZodOptional<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>;
177
+ administrativeAreaId: z.ZodOptional<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>;
178
+ signature: z.ZodOptional<z.ZodUndefined>;
179
+ avatar: z.ZodOptional<z.ZodUndefined>;
180
+ fullHonorificName: z.ZodOptional<z.ZodString>;
181
+ legacyId: z.ZodOptional<z.ZodString>;
182
+ status: z.ZodOptional<z.ZodUndefined>;
183
+ }, z.core.$strip>], "type">;
184
+ export type UserOrSystem = z.infer<typeof UserOrSystem>;
185
+ export declare const UserOrSystemSummary: z.ZodDiscriminatedUnion<[z.ZodObject<{
186
+ id: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
187
+ name: z.ZodObject<{
188
+ firstname: z.ZodString;
189
+ surname: z.ZodString;
190
+ }, z.core.$strip>;
191
+ role: z.ZodString;
192
+ avatar: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "DocumentPath", "out">>;
193
+ primaryOfficeId: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
194
+ administrativeAreaId: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>>;
195
+ fullHonorificName: z.ZodOptional<z.ZodString>;
196
+ type: z.ZodEnum<{
197
+ user: "user";
198
+ }>;
199
+ }, z.core.$strip>, z.ZodObject<{
200
+ id: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
201
+ name: z.ZodString;
202
+ type: z.ZodEnum<{
203
+ system: "system";
204
+ }>;
205
+ primaryOfficeId: z.ZodOptional<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>;
206
+ administrativeAreaId: z.ZodOptional<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>;
207
+ }, z.core.$strip>], "type">;
208
+ export declare const UserOrSystemSummaryWithStatus: z.ZodDiscriminatedUnion<[z.ZodObject<{
209
+ id: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
210
+ name: z.ZodObject<{
211
+ firstname: z.ZodString;
212
+ surname: z.ZodString;
213
+ }, z.core.$strip>;
214
+ role: z.ZodString;
215
+ avatar: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "DocumentPath", "out">>;
216
+ primaryOfficeId: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
217
+ administrativeAreaId: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>>;
218
+ fullHonorificName: z.ZodOptional<z.ZodString>;
219
+ type: z.ZodEnum<{
220
+ user: "user";
221
+ }>;
222
+ status: z.ZodEnum<{
223
+ active: "active";
224
+ deactivated: "deactivated";
225
+ pending: "pending";
226
+ }>;
227
+ }, z.core.$strip>, z.ZodObject<{
228
+ id: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
229
+ name: z.ZodString;
230
+ type: z.ZodEnum<{
231
+ system: "system";
232
+ }>;
233
+ primaryOfficeId: z.ZodOptional<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>;
234
+ administrativeAreaId: z.ZodOptional<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>;
235
+ status: z.ZodOptional<z.ZodEnum<{
236
+ active: "active";
237
+ deactivated: "deactivated";
238
+ pending: "pending";
239
+ }>>;
240
+ }, z.core.$strip>], "type">;
241
+ export type UserOrSystemSummary = z.infer<typeof UserOrSystemSummary>;
242
+ export declare const UserContext: z.ZodObject<{
243
+ id: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
244
+ role: z.ZodString;
245
+ signature: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodString, "DocumentPath", "out">>>;
246
+ primaryOfficeId: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
247
+ administrativeAreaId: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>>;
248
+ type: z.ZodEnum<{
249
+ user: "user";
250
+ }>;
251
+ }, z.core.$strip>;
252
+ export type UserContext = z.infer<typeof UserContext>;
253
+ export declare const SystemContext: z.ZodObject<{
254
+ id: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
255
+ type: z.ZodEnum<{
256
+ system: "system";
257
+ }>;
258
+ primaryOfficeId: z.ZodOptional<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>;
259
+ administrativeAreaId: z.ZodOptional<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>;
260
+ signature: z.ZodOptional<z.ZodUndefined>;
261
+ }, z.core.$strip>;
262
+ export type SystemContext = z.infer<typeof SystemContext>;
263
+ //# sourceMappingURL=User.d.ts.map
@@ -0,0 +1,67 @@
1
+ import { Nominal } from '../nominal';
2
+ import * as z from 'zod/v4';
3
+ import { ScopeType, Scope, EncodedScope } from './scopes';
4
+ export * from './scopes';
5
+ /**
6
+ * Returns an array of accepted scopes from a JWT token, filtered by the given accepted scope types.
7
+ *
8
+ * @param token - The JWT token containing scope definitions.
9
+ * @param acceptedScopes - An array of acceptable scope types to filter by.
10
+ * @returns An array of parsed RecordScopeV2 objects that are found in the token and match the accepted scope types.
11
+ */
12
+ export declare function getAcceptedScopesFromToken<T extends ScopeType>(token: string, acceptedScopes: T[]): Array<Extract<Scope, {
13
+ type: T;
14
+ }>>;
15
+ export declare const TokenUserType: z.ZodEnum<{
16
+ system: "system";
17
+ user: "user";
18
+ }>;
19
+ export type TokenUserType = z.infer<typeof TokenUserType>;
20
+ export interface ITokenPayload {
21
+ sub: string;
22
+ exp: string;
23
+ algorithm: string;
24
+ scope: EncodedScope[];
25
+ role?: string;
26
+ userType: TokenUserType;
27
+ }
28
+ /**
29
+ * Depending on how the API is called, there might or might not be Bearer keyword in the header.
30
+ * To allow for usage with both direct HTTP calls and TRPC, ensure it's present to be able to use shared scope auth functions.
31
+ */
32
+ export declare function setBearerForToken(token: string): string;
33
+ export declare function getScopes(token: string): EncodedScope[];
34
+ export declare const getTokenPayload: (token: string) => ITokenPayload;
35
+ export declare const getUserId: (token: TokenWithBearer) => string;
36
+ /**
37
+ * Extracts the subject (user ID) from a raw JWT string (without Bearer prefix).
38
+ * Returns null if the token cannot be decoded.
39
+ */
40
+ export declare const getUserIdFromToken: (token: string) => string | null;
41
+ /**
42
+ * Fixed subject (`sub`) of the service token that core's auth service mints at `GET /internal/service-token`.
43
+ * Core uses it for service-to-service calls where no user is involved.
44
+ *
45
+ * Must be a well-formed UUID so a service verifying the token can resolve it as
46
+ * a `SystemContext` as with `INTEGRATION_CREATOR_USER_ID` / `REINDEX_USER_ID`.
47
+ *
48
+ * See packages/auth/src/features/serviceToken/handler.ts
49
+ */
50
+ export declare const SERVICE_USER_ID = "00000000-0000-4000-8000-000000000002";
51
+ /**
52
+ * True when a decoded token payload (e.g. Hapi's `request.auth.credentials`)
53
+ * belongs to core's service token, identified by its fixed subject. A country
54
+ * configuration uses this to accept core's own service-to-service calls (e.g.
55
+ * telemetry, all-user broadcasts) while rejecting any logged-in user's token.
56
+ *
57
+ * Accepts `unknown` so loosely-typed framework credentials can be passed
58
+ * directly without a cast; anything that is not an object with the matching
59
+ * `sub` yields `false`.
60
+ */
61
+ export declare function isServiceToken(credentials: unknown): boolean;
62
+ export declare const getUserTypeFromToken: (token: TokenWithBearer) => TokenUserType;
63
+ export declare const TokenWithBearer: z.ZodType<`Bearer ${string}`>;
64
+ export type TokenWithBearer = z.infer<typeof TokenWithBearer>;
65
+ export type Token = Nominal<string, 'TokenWithoutBearer'>;
66
+ export declare function isTokenWithBearer(value: unknown): value is TokenWithBearer;
67
+ //# sourceMappingURL=authentication.d.ts.map
@@ -0,0 +1,5 @@
1
+ export * from './User';
2
+ export * from './userReferences';
3
+ export * from './roleValidations';
4
+ export * from './Role';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,15 @@
1
+ import { VersionedEventConfig } from '../events/EventConfig';
2
+ import { Role, Roles } from './Role';
3
+ /**
4
+ * @returns a message for each rule the role breaks, empty when it is valid.
5
+ */
6
+ export declare function validateRole(role: Role, eventConfigs: VersionedEventConfig[]): string[];
7
+ /**
8
+ * Validates roles, to ensure roles fill certain application requirements.
9
+ *
10
+ * @param roles Array of roles in object format.
11
+ * @param eventConfigs Array of event configurations, which are needed to run validations for scopes.
12
+ * @throws Error if roles are invalid.
13
+ */
14
+ export declare function validateRoles(roles: Roles, eventConfigs: VersionedEventConfig[]): void;
15
+ //# sourceMappingURL=roleValidations.d.ts.map