@opencrvs/toolkit 2.2.0-rc.045257f → 2.2.0-rc.25c3c81

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 (156) hide show
  1. package/build.sh +15 -2
  2. package/dist/application-config/index.js +16 -5
  3. package/dist/authentication/index.d.ts +1 -1
  4. package/dist/authentication/index.js +4 -8
  5. package/dist/cli.js +2197 -544
  6. package/dist/commons/api/router.d.ts +17 -4
  7. package/dist/commons/application-config/index.d.ts +1 -1
  8. package/dist/commons/conditionals/conditionals.d.ts +4 -4
  9. package/dist/commons/conditionals/validate.d.ts +1 -1
  10. package/dist/commons/events/ActionStatus.d.ts +2 -2
  11. package/dist/commons/events/ActionType.d.ts +2 -0
  12. package/dist/commons/events/AdvancedSearchConfig.d.ts +3 -0
  13. package/dist/commons/events/Draft.d.ts +34 -1
  14. package/dist/commons/events/EventConfig.d.ts +446 -0
  15. package/dist/commons/events/EventDocument.d.ts +2 -0
  16. package/dist/commons/events/EventIndex.d.ts +1 -0
  17. package/dist/commons/events/EventInput.d.ts +1 -0
  18. package/dist/commons/events/EventMetadata.d.ts +1 -0
  19. package/dist/commons/events/FieldTypeMapping.d.ts +19 -19
  20. package/dist/commons/events/PlainDate.d.ts +5 -0
  21. package/dist/commons/events/defineConfig.d.ts +7 -2
  22. package/dist/commons/events/event.d.ts +4 -1
  23. package/dist/commons/events/field.d.ts +5 -0
  24. package/dist/commons/events/locations.d.ts +1 -1
  25. package/dist/commons/events/scopes.d.ts +2 -1
  26. package/dist/commons/events/state/index.d.ts +1 -0
  27. package/dist/commons/events/test.utils.d.ts +59 -6
  28. package/dist/commons/events/utils.d.ts +28 -2
  29. package/dist/commons/users/Role.d.ts +23 -0
  30. package/dist/commons/users/User.d.ts +263 -0
  31. package/dist/commons/users/authentication.d.ts +67 -0
  32. package/dist/commons/users/index.d.ts +5 -0
  33. package/dist/commons/users/roleValidations.d.ts +15 -0
  34. package/dist/commons/users/scopes.d.ts +1402 -0
  35. package/dist/commons/users/userReferences.d.ts +176 -0
  36. package/dist/conditionals/index.js +3 -3
  37. package/dist/configurator/index.d.ts +24 -0
  38. package/dist/configurator/index.d.ts.map +1 -0
  39. package/dist/configurator/index.js +161 -0
  40. package/dist/configurator/layout.d.ts +28 -0
  41. package/dist/configurator/layout.d.ts.map +1 -0
  42. package/dist/configurator/layout.js +78 -0
  43. package/dist/configurator/paths.d.ts +13 -0
  44. package/dist/configurator/paths.d.ts.map +1 -0
  45. package/dist/configurator/paths.js +48 -0
  46. package/dist/configurator/server/environments.d.ts +20 -0
  47. package/dist/configurator/server/environments.d.ts.map +1 -0
  48. package/dist/configurator/server/environments.js +143 -0
  49. package/dist/configurator/server/files.d.ts +11 -0
  50. package/dist/configurator/server/files.d.ts.map +1 -0
  51. package/dist/configurator/server/files.js +67 -0
  52. package/dist/configurator/server/github.d.ts +56 -0
  53. package/dist/configurator/server/github.d.ts.map +1 -0
  54. package/dist/configurator/server/github.js +239 -0
  55. package/dist/configurator/server/plugin.d.ts +39 -0
  56. package/dist/configurator/server/plugin.d.ts.map +1 -0
  57. package/dist/configurator/server/plugin.js +298 -0
  58. package/dist/configurator/server/seal.d.ts +2 -0
  59. package/dist/configurator/server/seal.d.ts.map +1 -0
  60. package/dist/configurator/server/seal.js +36 -0
  61. package/dist/configurator/server/sshKeys.d.ts +5 -0
  62. package/dist/configurator/server/sshKeys.d.ts.map +1 -0
  63. package/dist/configurator/server/sshKeys.js +28 -0
  64. package/dist/configurator/server/start.d.ts +12 -0
  65. package/dist/configurator/server/start.d.ts.map +1 -0
  66. package/dist/configurator/server/start.js +91 -0
  67. package/dist/configurator/testing.d.ts +11 -0
  68. package/dist/configurator/testing.d.ts.map +1 -0
  69. package/dist/configurator/testing.js +74 -0
  70. package/dist/configurator/ui/bindings/bindings.d.ts +35 -0
  71. package/dist/configurator/ui/bindings/bindings.d.ts.map +1 -0
  72. package/dist/configurator/ui/bindings/bindings.js +5 -0
  73. package/dist/configurator/ui/bindings/parsers.d.ts +7 -0
  74. package/dist/configurator/ui/bindings/parsers.d.ts.map +1 -0
  75. package/dist/configurator/ui/bindings/parsers.js +85 -0
  76. package/dist/configurator/ui/form/users.d.ts +11 -0
  77. package/dist/configurator/ui/form/users.d.ts.map +1 -0
  78. package/dist/configurator/ui/form/users.js +33 -0
  79. package/dist/configurator/ui/plan/dependencyHosts.d.ts +2 -0
  80. package/dist/configurator/ui/plan/dependencyHosts.d.ts.map +1 -0
  81. package/dist/configurator/ui/plan/dependencyHosts.js +36 -0
  82. package/dist/configurator/ui/plan/templateValues.d.ts +11 -0
  83. package/dist/configurator/ui/plan/templateValues.d.ts.map +1 -0
  84. package/dist/configurator/ui/plan/templateValues.js +70 -0
  85. package/dist/configurator/workflows.d.ts +53 -0
  86. package/dist/configurator/workflows.d.ts.map +1 -0
  87. package/dist/configurator/workflows.js +161 -0
  88. package/dist/configurator-assets/forms/bindings.yml +263 -0
  89. package/dist/configurator-assets/templates/README.md +18 -0
  90. package/dist/configurator-assets/templates/charts-values/dependencies/values.override.yaml +4 -0
  91. package/dist/configurator-assets/templates/charts-values/dependencies/values.yaml +99 -0
  92. package/dist/configurator-assets/templates/charts-values/opencrvs-services/values.override.yaml +4 -0
  93. package/dist/configurator-assets/templates/charts-values/opencrvs-services/values.yaml +83 -0
  94. package/dist/configurator-assets/templates/charts-values/opentelemetry/values.yaml +102 -0
  95. package/dist/configurator-assets/templates/charts-values/traefik/values.override.yaml +4 -0
  96. package/dist/configurator-assets/templates/charts-values/traefik/values.yaml +130 -0
  97. package/dist/configurator-assets/templates/inventory/inventory.template.yml +98 -0
  98. package/dist/configurator-assets/ui/apple-touch-icon.png +0 -0
  99. package/dist/configurator-assets/ui/assets/index-Bf3eC7uO.js +169 -0
  100. package/dist/configurator-assets/ui/assets/index-CaqYFJUk.css +6 -0
  101. package/dist/configurator-assets/ui/assets/opencrvs-logo-sIjz08HT.svg +1 -0
  102. package/dist/configurator-assets/ui/assets/poppins-400-BwTUGeWf.woff2 +0 -0
  103. package/dist/configurator-assets/ui/assets/poppins-500-CWICHMj6.woff2 +0 -0
  104. package/dist/configurator-assets/ui/assets/poppins-600-DJVo7c07.woff2 +0 -0
  105. package/dist/configurator-assets/ui/assets/poppins-700-g9MkRaG0.woff2 +0 -0
  106. package/dist/configurator-assets/ui/favicon-32x32.png +0 -0
  107. package/dist/configurator-assets/ui/index.html +25 -0
  108. package/dist/environment/custom-types.d.ts +1 -0
  109. package/dist/environment/custom-types.d.ts.map +1 -1
  110. package/dist/environment/derived-variables.d.ts +8 -0
  111. package/dist/environment/derived-variables.d.ts.map +1 -1
  112. package/dist/environment/derived-variables.js +9 -0
  113. package/dist/environment/questions.d.ts +42 -9
  114. package/dist/environment/questions.d.ts.map +1 -1
  115. package/dist/environment/questions.js +70 -47
  116. package/dist/environment/registry.d.ts +15 -0
  117. package/dist/environment/registry.d.ts.map +1 -0
  118. package/dist/environment/registry.js +112 -0
  119. package/dist/environment/setup-environment.d.ts.map +1 -1
  120. package/dist/environment/setup-environment.js +104 -23
  121. package/dist/events/index.js +635 -149
  122. package/dist/migrations/add-notify-config.d.ts +40 -0
  123. package/dist/migrations/add-notify-config.d.ts.map +1 -0
  124. package/dist/migrations/add-notify-config.js +249 -0
  125. package/dist/migrations/index.d.ts.map +1 -1
  126. package/dist/migrations/index.js +602 -143
  127. package/dist/migrations/move-declaration-to-declare-action.d.ts.map +1 -1
  128. package/dist/migrations/move-declaration-to-declare-action.js +27 -144
  129. package/dist/migrations/read-declaration-through-helper.d.ts.map +1 -1
  130. package/dist/migrations/read-declaration-through-helper.js +3 -61
  131. package/dist/migrations/resolve-versioned-event-config.d.ts +56 -0
  132. package/dist/migrations/resolve-versioned-event-config.d.ts.map +1 -0
  133. package/dist/migrations/resolve-versioned-event-config.js +353 -0
  134. package/dist/migrations/utils.d.ts +61 -0
  135. package/dist/migrations/utils.d.ts.map +1 -0
  136. package/dist/migrations/utils.js +218 -0
  137. package/dist/notification/index.js +616 -66
  138. package/dist/roles/index.d.ts +2 -0
  139. package/dist/roles/index.d.ts.map +1 -0
  140. package/dist/roles/index.js +730 -0
  141. package/dist/scopes/index.d.ts +0 -10
  142. package/dist/scopes/index.js +3 -7
  143. package/dist/templates/charts-values/dependencies/values.yaml +4 -1
  144. package/dist/templates/charts-values/opencrvs-services/values.yaml +2 -2
  145. package/dist/verify/endpoints.d.ts +11 -0
  146. package/dist/verify/endpoints.d.ts.map +1 -1
  147. package/dist/verify/endpoints.js +21 -27
  148. package/opencrvs-toolkit-2.2.0-rc.25c3c81.tgz +0 -0
  149. package/package.json +16 -3
  150. package/tsconfig.build.json +11 -1
  151. package/tsconfig.build.tsbuildinfo +1 -1
  152. package/tsconfig.json +15 -6
  153. package/dist/environment/dockerhub.d.ts +0 -15
  154. package/dist/environment/dockerhub.d.ts.map +0 -1
  155. package/dist/environment/dockerhub.js +0 -104
  156. package/opencrvs-toolkit-2.2.0-rc.045257f.tgz +0 -0
@@ -37,6 +37,7 @@ export declare function field(fieldId: string, options?: {
37
37
  validations?: ValidationConfig[];
38
38
  searchCriteriaLabelPrefix?: TranslationConfig;
39
39
  allowedLocations?: JurisdictionReference;
40
+ defaultValue?: boolean | string | number;
40
41
  }): {
41
42
  $$field: string;
42
43
  $$subfield: string[];
@@ -387,6 +388,7 @@ export declare function field(fieldId: string, options?: {
387
388
  validations?: ValidationConfig[];
388
389
  searchCriteriaLabelPrefix?: TranslationConfig;
389
390
  allowedLocations?: JurisdictionReference;
391
+ defaultValue?: boolean | string | number;
390
392
  fieldId: string;
391
393
  fieldType: 'field';
392
394
  } & {
@@ -400,6 +402,7 @@ export declare function field(fieldId: string, options?: {
400
402
  validations?: ValidationConfig[];
401
403
  searchCriteriaLabelPrefix?: TranslationConfig;
402
404
  allowedLocations?: JurisdictionReference;
405
+ defaultValue?: boolean | string | number;
403
406
  fieldId: string;
404
407
  fieldType: 'field';
405
408
  } & {
@@ -413,6 +416,7 @@ export declare function field(fieldId: string, options?: {
413
416
  validations?: ValidationConfig[];
414
417
  searchCriteriaLabelPrefix?: TranslationConfig;
415
418
  allowedLocations?: JurisdictionReference;
419
+ defaultValue?: boolean | string | number;
416
420
  fieldId: string;
417
421
  fieldType: 'field';
418
422
  } & {
@@ -426,6 +430,7 @@ export declare function field(fieldId: string, options?: {
426
430
  validations?: ValidationConfig[];
427
431
  searchCriteriaLabelPrefix?: TranslationConfig;
428
432
  allowedLocations?: JurisdictionReference;
433
+ defaultValue?: boolean | string | number;
429
434
  fieldId: string;
430
435
  fieldType: 'field';
431
436
  } & {
@@ -3,7 +3,7 @@ import * as z from 'zod/v4';
3
3
  import { PlainDate } from './PlainDate';
4
4
  import { EventIndex } from './EventIndex';
5
5
  import { ActionCreationMetadata, RegistrationCreationMetadata } from './EventMetadata';
6
- import { RecordScopeV2, UserScopeV2 } from '../scopes';
6
+ import { RecordScopeV2, UserScopeV2 } from '../users/scopes';
7
7
  import { SystemContext, UserContext } from '../users/User';
8
8
  /** @deprecated Moving on, location types are arbitrary and defined by the country config. */
9
9
  export declare const LocationTypeV1: z.ZodEnum<{
@@ -1,5 +1,5 @@
1
1
  import { DisplayableAction } from './ActionType';
2
- import { EncodedScope, RecordScopeTypeV2, ScopeType, UserScopeV2 } from '../scopes';
2
+ import { EncodedScope, RecordScopeTypeV2, ScopeType, UserScopeV2 } from '../users/scopes';
3
3
  import { EventIndexWithAdministrativeHierarchy } from './locations';
4
4
  import { UserContext } from '../users/User';
5
5
  import { EventIndex } from './EventIndex';
@@ -15,6 +15,7 @@ export declare const ACTION_SCOPE_MAP: {
15
15
  PRINT_CERTIFICATE: "record.print-certified-copies"[];
16
16
  REQUEST_CORRECTION: ("record.correct" | "record.request-correction")[];
17
17
  REVIEW_CORRECTION_REQUEST: "record.correct"[];
18
+ CONTINUE_DRAFT: never[];
18
19
  REJECT_CORRECTION: "record.correct"[];
19
20
  APPROVE_CORRECTION: "record.correct"[];
20
21
  REVOKE_REGISTRATION: "record.revoke-registration"[];
@@ -63,6 +63,7 @@ export declare function applyDeclarationToEventIndex(eventIndex: EventIndex, dec
63
63
  export declare function applyDraftToEventIndex(eventIndex: EventIndex, draft: Draft, eventConfiguration: EventConfig): {
64
64
  id: string & import("zod").$brand<"UUID">;
65
65
  type: string;
66
+ configVersionId: string;
66
67
  status: "ARCHIVED" | "CREATED" | "DECLARED" | "NOTIFIED" | "REGISTERED" | "REVOKED";
67
68
  legalStatuses: {
68
69
  NOTIFIED?: {
@@ -1,10 +1,10 @@
1
1
  import { UUID } from '../uuid';
2
- import { ActionDocument, ActionUpdate } from './ActionDocument';
2
+ import { Action, ActionBase, ActionDocument, ActionStatus, ActionUpdate } from './ActionDocument';
3
3
  import { ValidatorContext } from '../conditionals/validate';
4
4
  import { ApproveCorrectionActionInput, ArchiveActionInput, AssignActionInput, DeclareActionInput, EditActionInput, MarkAsDuplicateActionInput, MarkNotDuplicateActionInput, NotifyActionInput, RegisterActionInput, RejectCorrectionActionInput, RejectDeclarationActionInput, RequestCorrectionActionInput, UnarchiveActionInput, UnassignActionInput, RevokeRegistrationActionInput, ReinstateRegistrationActionInput } from './ActionInput';
5
5
  import { ActionType } from './ActionType';
6
- import { Draft } from './Draft';
7
- import { EventConfig, EventConfigInput } from './EventConfig';
6
+ import { Draft, DraftInput, RemoteDraft } from './Draft';
7
+ import { EventConfig, EventConfigInput, VersionedEventConfig } from './EventConfig';
8
8
  import { EventDocument } from './EventDocument';
9
9
  import { EventIndex } from './EventIndex';
10
10
  import { EventInput } from './EventInput';
@@ -98,7 +98,8 @@ export declare function eventPayloadGenerator(rng: () => number, configuration?:
98
98
  eventId: string;
99
99
  };
100
100
  /**
101
- * Notify allows sending incomplete data. Think it as 'partial declare' for now.
101
+ * NOTIFY submits the values of the notification form, and the record can stay incomplete.
102
+ * When `declaration` is not given, string values are left out of the generated declaration to make it incomplete.
102
103
  */
103
104
  notify: (eventId: string, input?: Partial<Pick<NotifyActionInput, 'transactionId' | 'declaration' | 'keepAssignment' | 'keepAssignmentIfRejected' | 'keepAssignmentIfAccepted' | 'waitFor'>>) => {
104
105
  type: "NOTIFY";
@@ -278,6 +279,13 @@ export declare function eventPayloadGenerator(rng: () => number, configuration?:
278
279
  };
279
280
  };
280
281
  };
282
+ /**
283
+ * Generates a single action document with exactly the given status (Accepted by default).
284
+ *
285
+ * For realistic data use `generateActionDocuments`, which also creates the Requested
286
+ * action the events service stores for a confirmable action. Use this one for edge
287
+ * cases, such as pending or rejected requests, or actions without an original request.
288
+ */
281
289
  export declare function generateActionDocument<T extends ActionType>({ configuration, action, rng, defaults, declarationOverrides }: {
282
290
  configuration: EventConfig;
283
291
  action: T;
@@ -287,6 +295,45 @@ export declare function generateActionDocument<T extends ActionType>({ configura
287
295
  }>>;
288
296
  declarationOverrides?: ActionUpdate;
289
297
  }): ActionDocument;
298
+ type GenerateActionDocumentsArgs<T extends ActionType> = Parameters<typeof generateActionDocument<T>>[0];
299
+ type ActionConfirmation<S extends ActionStatus> = {
300
+ status: S;
301
+ defaults?: Partial<ActionBase>;
302
+ };
303
+ /**
304
+ * Generates the action documents the events service stores for a single action.
305
+ *
306
+ * Mirrors the events service: a confirmable action is first stored as Requested,
307
+ * carrying the declaration and annotation, and then confirmed by a separate
308
+ * Accepted (or Rejected) action that points back to it through originalActionId.
309
+ * Other actions are stored once, as Accepted.
310
+ *
311
+ * `confirmation.status` picks the outcome of a confirmable action:
312
+ * - Accepted (default): [Requested, Accepted]
313
+ * - Rejected: [Requested, Rejected]
314
+ * - Requested: [Requested], i.e. still waiting for confirmation
315
+ *
316
+ * By default the request is confirmed synchronously, so both actions share the
317
+ * `transactionId`. `confirmation.defaults` apply to the confirming action only,
318
+ * e.g. a system user and a `transactionId` of its own for an asynchronous confirmation.
319
+ *
320
+ * The confirming action keeps the generated (or given) `id`, since references such
321
+ * as `requestId` of APPROVE_CORRECTION point to the accepted action.
322
+ *
323
+ * Use `generateActionDocument` instead to build a single action with an explicit status.
324
+ *
325
+ * Only a rejection yields an AsyncRejectActionDocument, so the result is typed
326
+ * as `ActionDocument[]` when `confirmation.status` is known not to be Rejected.
327
+ */
328
+ export declare function generateActionDocuments<T extends ActionType>(args: GenerateActionDocumentsArgs<T> & {
329
+ confirmation: ActionConfirmation<typeof ActionStatus.Rejected>;
330
+ }): Action[];
331
+ export declare function generateActionDocuments<T extends ActionType>(args: GenerateActionDocumentsArgs<T> & {
332
+ confirmation?: Partial<ActionConfirmation<typeof ActionStatus.Accepted | typeof ActionStatus.Requested>>;
333
+ }): ActionDocument[];
334
+ export declare function generateActionDocuments<T extends ActionType>(args: GenerateActionDocumentsArgs<T> & {
335
+ confirmation?: Partial<ActionConfirmation<ActionStatus>>;
336
+ }): Action[];
290
337
  export declare function generateRandomDatetime(rng: () => number, start: Date, end: Date): string;
291
338
  export declare function getRandomDate(rng: () => number, start: string, end: string): string;
292
339
  export declare function generateEventDocument({ configuration, actions, rng, defaults }: {
@@ -310,11 +357,11 @@ export declare function generateEventDocument({ configuration, actions, rng, def
310
357
  }): EventDocument;
311
358
  export declare function generateEventDraftDocument({ eventId, actionType, rng, declaration }: {
312
359
  eventId: UUID;
313
- actionType: ActionType;
360
+ actionType: DraftInput['type'];
314
361
  rng?: () => number;
315
362
  declaration?: ActionUpdate;
316
363
  annotation?: ActionUpdate;
317
- }): Draft;
364
+ }): RemoteDraft;
318
365
  /**
319
366
  * Useful for testing when we need deterministic outcome.
320
367
  * @param seed - Seed value for the pseudo-random number generator
@@ -373,4 +420,10 @@ export declare function generateTestValidatorContext(userRole?: TestUserRole, ev
373
420
  event: EventDocument;
374
421
  eventConfig: EventConfig;
375
422
  }): ValidatorContext;
423
+ /**
424
+ * Serves `config` as country config does: as the only version of its event.
425
+ * For mocking `/config/events` and `event.config.get` with a configuration built in a test.
426
+ */
427
+ export declare function toVersionedEventConfig({ id, label, advancedSearch, ...version }: EventConfig): VersionedEventConfig;
428
+ export {};
376
429
  //# sourceMappingURL=test.utils.d.ts.map
@@ -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';
@@ -46,6 +46,17 @@ export declare function getDeclarationPages(configuration: EventConfig): {
46
46
  type: "FORM";
47
47
  }[];
48
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[];
49
60
  /**
50
61
  * @returns the notification form configured on the NOTIFY action.
51
62
  * @throws when the event has no NOTIFY action.
@@ -636,7 +647,9 @@ export declare const findAllFields: (config: EventConfig) => FieldConfig[];
636
647
  * @returns the value of the object at the given path.
637
648
  */
638
649
  export declare function getMixedPath<T = unknown>(obj: Record<string, unknown>, path: string, defaultValue?: T | undefined): T | undefined;
639
- 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;
640
653
  export declare function timePeriodToDateRange(value: SelectDateRangeValue): {
641
654
  startDate: string;
642
655
  endDate: string;
@@ -654,6 +667,19 @@ export declare function getCompleteActionAnnotation(event: EventDocument, action
654
667
  export declare function getCompleteActionContent(event: EventDocument, action: ActionDocument): Record<string, unknown> | null | undefined;
655
668
  export declare function getCompleteActionDeclaration<T extends EventState | ActionUpdate>(declaration: T, event: EventDocument, action: ActionDocument): T;
656
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;
657
683
  export declare function aggregateActionDeclarations(event: EventDocument): EventState;
658
684
  /**
659
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