@opencrvs/toolkit 1.9.15-rc.fc1c0fb → 2.0.0-rc.004e65c

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 (161) hide show
  1. package/build.sh +13 -0
  2. package/create-countryconfig/index.js +103 -0
  3. package/create-countryconfig/package.json +21 -0
  4. package/dist/api/index.d.ts.map +1 -1
  5. package/dist/application-config/index.d.ts +2 -0
  6. package/dist/application-config/index.d.ts.map +1 -0
  7. package/dist/application-config/index.js +2304 -0
  8. package/dist/cli.d.ts +2 -0
  9. package/dist/cli.d.ts.map +1 -0
  10. package/dist/cli.js +5244 -0
  11. package/dist/commons/api/router.d.ts +5630 -3673
  12. package/dist/commons/application-config/index.d.ts +97 -0
  13. package/dist/commons/conditionals/conditionals.d.ts +33 -3
  14. package/dist/commons/conditionals/validate.d.ts +20 -1
  15. package/dist/commons/events/ActionConfig.d.ts +415 -1555
  16. package/dist/commons/events/ActionDocument.d.ts +894 -1941
  17. package/dist/commons/events/ActionInput.d.ts +326 -1212
  18. package/dist/commons/events/ActionType.d.ts +91 -11
  19. package/dist/commons/events/AdvancedSearchConfig.d.ts +636 -1496
  20. package/dist/commons/events/AuditLog.d.ts +407 -0
  21. package/dist/commons/events/CompositeFieldValue.d.ts +30 -190
  22. package/dist/commons/events/Conditional.d.ts +26 -38
  23. package/dist/commons/events/Constants.d.ts +1 -1
  24. package/dist/commons/events/CountryConfigQueryInput.d.ts +1592 -4471
  25. package/dist/commons/events/DeduplicationConfig.d.ts +15 -171
  26. package/dist/commons/events/Draft.d.ts +72 -111
  27. package/dist/commons/events/DynamicFieldValue.d.ts +12 -78
  28. package/dist/commons/events/EventConfig.d.ts +37 -2427
  29. package/dist/commons/events/EventConfigInput.d.ts +0 -3
  30. package/dist/commons/events/EventDocument.d.ts +357 -1366
  31. package/dist/commons/events/EventIndex.d.ts +211 -1012
  32. package/dist/commons/events/EventInput.d.ts +3 -8
  33. package/dist/commons/events/EventMetadata.d.ts +129 -363
  34. package/dist/commons/events/FieldConfig.d.ts +3147 -14211
  35. package/dist/commons/events/FieldType.d.ts +26 -4
  36. package/dist/commons/events/FieldTypeMapping.d.ts +314 -906
  37. package/dist/commons/events/FieldValue.d.ts +154 -526
  38. package/dist/commons/events/FileUtils.d.ts +2 -2
  39. package/dist/commons/events/Flag.d.ts +67 -0
  40. package/dist/commons/events/FormConfig.d.ts +54 -721
  41. package/dist/commons/events/PageConfig.d.ts +58 -320
  42. package/dist/commons/events/PlainDate.d.ts +1 -1
  43. package/dist/commons/events/SummaryConfig.d.ts +14 -161
  44. package/dist/commons/events/TemplateConfig.d.ts +2 -3
  45. package/dist/commons/events/TranslationConfig.d.ts +2 -2
  46. package/dist/commons/events/WorkqueueColumnConfig.d.ts +74 -37
  47. package/dist/commons/events/WorkqueueConfig.d.ts +2232 -7577
  48. package/dist/commons/events/deduplication.d.ts +3 -3
  49. package/dist/commons/events/defineConfig.d.ts +2 -248
  50. package/dist/commons/events/eventConfigValidation.d.ts +8 -0
  51. package/dist/commons/events/field.d.ts +6 -0
  52. package/dist/commons/events/index.d.ts +5 -0
  53. package/dist/commons/events/locations.d.ts +93 -19
  54. package/dist/commons/events/mocks.test.utils.d.ts +19 -0
  55. package/dist/commons/events/scopes.d.ts +56 -32
  56. package/dist/commons/events/state/availableActions.d.ts +7 -2
  57. package/dist/commons/events/state/flags.d.ts +37 -3
  58. package/dist/commons/events/state/index.d.ts +29 -30
  59. package/dist/commons/events/state/utils.d.ts +25 -284
  60. package/dist/commons/events/test.utils.d.ts +52 -11
  61. package/dist/commons/events/transactions.d.ts +1 -1
  62. package/dist/commons/events/utils.d.ts +383 -273
  63. package/dist/commons/notification/UserNotifications.d.ts +76 -637
  64. package/dist/conditionals/index.d.ts.map +1 -1
  65. package/dist/conditionals/index.js +338 -14
  66. package/dist/events/deduplication.d.ts +3 -3
  67. package/dist/events/index.js +3700 -2236
  68. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts +3 -0
  69. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts.map +1 -0
  70. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.js +429 -0
  71. package/dist/migrations/v2.0/add-resend-invite-notification.d.ts +3 -0
  72. package/dist/migrations/v2.0/add-resend-invite-notification.d.ts.map +1 -0
  73. package/dist/migrations/v2.0/add-resend-invite-notification.js +373 -0
  74. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +22 -0
  75. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -0
  76. package/dist/migrations/v2.0/checkout-upstream-files.js +146 -0
  77. package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts +2 -0
  78. package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts.map +1 -0
  79. package/dist/migrations/v2.0/convert-config-files-to-ts.js +828 -0
  80. package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts +3 -0
  81. package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts.map +1 -0
  82. package/dist/migrations/v2.0/convert-paragraph-to-heading.js +158 -0
  83. package/dist/migrations/v2.0/create-events-index.d.ts +3 -0
  84. package/dist/migrations/v2.0/create-events-index.d.ts.map +1 -0
  85. package/dist/migrations/v2.0/create-events-index.js +325 -0
  86. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts +11 -0
  87. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts.map +1 -0
  88. package/dist/migrations/v2.0/delete-infrastructure-directory.js +123 -0
  89. package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.d.ts +3 -0
  90. package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.d.ts.map +1 -0
  91. package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.js +110 -0
  92. package/dist/migrations/v2.0/index.d.ts +13 -0
  93. package/dist/migrations/v2.0/index.d.ts.map +1 -0
  94. package/dist/migrations/v2.0/index.js +5154 -0
  95. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts +3 -0
  96. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts.map +1 -0
  97. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.js +432 -0
  98. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts +13 -0
  99. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts.map +1 -0
  100. package/dist/migrations/v2.0/merge-infrastructure-directory.js +222 -0
  101. package/dist/migrations/v2.0/migrate-application-config-url.d.ts +3 -0
  102. package/dist/migrations/v2.0/migrate-application-config-url.d.ts.map +1 -0
  103. package/dist/migrations/v2.0/migrate-application-config-url.js +342 -0
  104. package/dist/migrations/v2.0/migrate-scopes.d.ts +3 -0
  105. package/dist/migrations/v2.0/migrate-scopes.d.ts.map +1 -0
  106. package/dist/migrations/v2.0/migrate-scopes.js +305 -0
  107. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts +3 -0
  108. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts.map +1 -0
  109. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.js +267 -0
  110. package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts +3 -0
  111. package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts.map +1 -0
  112. package/dist/migrations/v2.0/migrate-workqueue-configs.js +317 -0
  113. package/dist/migrations/v2.0/remove-delete-actions.d.ts +3 -0
  114. package/dist/migrations/v2.0/remove-delete-actions.d.ts.map +1 -0
  115. package/dist/migrations/v2.0/remove-delete-actions.js +156 -0
  116. package/dist/migrations/v2.0/remove-demo-scope.d.ts +3 -0
  117. package/dist/migrations/v2.0/remove-demo-scope.d.ts.map +1 -0
  118. package/dist/migrations/v2.0/remove-demo-scope.js +74 -0
  119. package/dist/migrations/v2.0/remove-deprecated-imports.d.ts +3 -0
  120. package/dist/migrations/v2.0/remove-deprecated-imports.d.ts.map +1 -0
  121. package/dist/migrations/v2.0/remove-deprecated-imports.js +96 -0
  122. package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts +3 -0
  123. package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts.map +1 -0
  124. package/dist/migrations/v2.0/remove-fhir-url-helpers.js +163 -0
  125. package/dist/migrations/v2.0/remove-hearth-migrations.d.ts +3 -0
  126. package/dist/migrations/v2.0/remove-hearth-migrations.d.ts.map +1 -0
  127. package/dist/migrations/v2.0/remove-hearth-migrations.js +77 -0
  128. package/dist/migrations/v2.0/remove-old-statistics-service.d.ts +3 -0
  129. package/dist/migrations/v2.0/remove-old-statistics-service.d.ts.map +1 -0
  130. package/dist/migrations/v2.0/remove-old-statistics-service.js +356 -0
  131. package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts +3 -0
  132. package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts.map +1 -0
  133. package/dist/migrations/v2.0/remove-pending-certification-flag.js +109 -0
  134. package/dist/migrations/v2.0/remove-review-from-register-action.d.ts +3 -0
  135. package/dist/migrations/v2.0/remove-review-from-register-action.d.ts.map +1 -0
  136. package/dist/migrations/v2.0/remove-review-from-register-action.js +163 -0
  137. package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts +3 -0
  138. package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts.map +1 -0
  139. package/dist/migrations/v2.0/remove-unused-environment-variables.js +186 -0
  140. package/dist/migrations/v2.0/rename-api-paths.d.ts +3 -0
  141. package/dist/migrations/v2.0/rename-api-paths.d.ts.map +1 -0
  142. package/dist/migrations/v2.0/rename-api-paths.js +187 -0
  143. package/dist/migrations/v2.0/rename-location-parent-id.d.ts +3 -0
  144. package/dist/migrations/v2.0/rename-location-parent-id.d.ts.map +1 -0
  145. package/dist/migrations/v2.0/rename-location-parent-id.js +180 -0
  146. package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts +3 -0
  147. package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts.map +1 -0
  148. package/dist/migrations/v2.0/simplify-analytics-precalculations.js +195 -0
  149. package/dist/migrations/v2.0/update-package-json.d.ts +3 -0
  150. package/dist/migrations/v2.0/update-package-json.d.ts.map +1 -0
  151. package/dist/migrations/v2.0/update-package-json.js +105 -0
  152. package/dist/notification/index.d.ts.map +1 -1
  153. package/dist/notification/index.js +2731 -1849
  154. package/dist/scopes/index.d.ts +714 -352
  155. package/dist/scopes/index.d.ts.map +1 -1
  156. package/dist/scopes/index.js +381 -298
  157. package/opencrvs-toolkit-2.0.0-rc.004e65c.tgz +0 -0
  158. package/package.json +14 -4
  159. package/tsconfig.json +12 -2
  160. package/tsconfig.tsbuildinfo +1 -1
  161. package/dist/commons/events/CreatedAtLocation.d.ts +0 -2
@@ -1,4 +1,38 @@
1
- import { Action } from '../ActionDocument';
2
- import { Flag } from '../EventMetadata';
3
- export declare function getFlagsFromActions(actions: Action[]): Flag[];
1
+ import { Action, RequestedCorrectionAction } from '../ActionDocument';
2
+ import { Flag, CustomFlag } from '../Flag';
3
+ import { EventConfig } from '../EventConfig';
4
+ import { EventDocument } from '../EventDocument';
5
+ export declare function findPendingCorrectionAction(writeActions: Action[]): RequestedCorrectionAction | undefined;
6
+ export declare function isPotentialDuplicate(actions: Action[]): boolean;
7
+ /**
8
+ * This function resolves custom flags for an event based on its actions.
9
+ * Flags are not stored to the event state or any database directly, instead they are always computed/evaluated from the event actions.
10
+ *
11
+ * Processes accepted actions in chronological order, evaluating flag conditions
12
+ * at each action step. Flags can be added or removed based on action configurations
13
+ * and conditional logic. Duplicate flags are filtered out.
14
+ *
15
+ * @param event - The event document containing actions and metadata
16
+ * @param eventConfiguration - The configuration object for the event type defining action rules and flag behaviors
17
+ * @returns An array of unique custom flag IDs that apply to the event after processing all non-meta actions
18
+ *
19
+ * @example
20
+ * const flags = resolveEventCustomFlags(eventDoc, config);
21
+ * // Returns: ['flag-1', 'flag-3']
22
+ */
23
+ export declare function resolveEventCustomFlags(event: EventDocument, eventConfiguration: EventConfig): CustomFlag[];
24
+ /**
25
+ * Computes all flags (inherent, action status, and custom) that should be attached to the given event,
26
+ * based on its actions and event-specific configuration.
27
+ *
28
+ * Flags are determined by combining:
29
+ * - Action status flags (format 'ActionType:ActionStatus')
30
+ * - Inherent flags (e.g. incomplete, rejected, correction requested, potential duplicate, edit in progress)
31
+ * - Event type-specific custom flags defined in the event configuration
32
+ *
33
+ * @param event - The EventDocument containing the action history and payload
34
+ * @param config - The EventConfig providing rules for custom flag evaluation
35
+ * @returns An array of flags currently relevant/applicable to the event
36
+ */
37
+ export declare function getEventFlags(event: EventDocument, config: EventConfig): Flag[];
4
38
  //# sourceMappingURL=flags.d.ts.map
@@ -6,13 +6,12 @@ import { EventStatus } from '../EventMetadata';
6
6
  import { Draft } from '../Draft';
7
7
  import { EventConfig } from '../EventConfig';
8
8
  import { UUID } from '../../uuid';
9
- import { DocumentPath, FullDocumentPath, FullDocumentUrl } from '../../documents';
10
- export declare function getStatusFromActions(actions: Array<Action>): "ARCHIVED" | "DECLARED" | "REGISTERED" | "VALIDATED" | "CREATED" | "NOTIFIED";
9
+ import { DocumentPath } from '../../documents';
10
+ export declare function getStatusFromActions(actions: Array<Action>): "CREATED" | "NOTIFIED" | "DECLARED" | "REGISTERED" | "ARCHIVED";
11
11
  export declare function getAssignedUserFromActions(actions: Array<ActionDocument>): string | null;
12
- export declare function getAssignedUserSignatureFromActions(actions: Array<ActionDocument>): string | null;
13
12
  type NonNullableDeep<T> = T extends [unknown, ...unknown[]] ? {
14
13
  [K in keyof T]: NonNullableDeep<NonNullable<T[K]>>;
15
- } : T extends UUID ? T : T extends FullDocumentPath ? T : T extends DocumentPath ? T : T extends FullDocumentUrl ? T : T extends (infer U)[] ? NonNullableDeep<U>[] : T extends object ? {
14
+ } : T extends UUID ? T : T extends DocumentPath ? T : T extends string ? NonNullable<T> : T extends (infer U)[] ? NonNullableDeep<U>[] : T extends object ? {
16
15
  [K in keyof T]: NonNullableDeep<NonNullable<T[K]>>;
17
16
  } : NonNullable<T>;
18
17
  /**
@@ -26,6 +25,10 @@ export declare function deepDropNulls<T>(obj: T): NonNullableDeep<T>;
26
25
  export declare function isUndeclaredDraft(status: EventStatus): boolean;
27
26
  export declare const DEFAULT_DATE_OF_EVENT_PROPERTY = "createdAt";
28
27
  export declare function resolveDateOfEvent(eventIndex: EventIndex, declaration: EventState, config: EventConfig): string | undefined;
28
+ export declare const DEFAULT_PLACE_OF_EVENT_PROPERTY = "createdAtLocation";
29
+ export declare function resolvePlaceOfEvent(eventMetadata: {
30
+ createdAtLocation?: UUID | undefined | null;
31
+ }, declaration: EventState, config: EventConfig): UUID | undefined | null;
29
32
  export declare function extractPotentialDuplicatesFromActions(actions: Action[]): PotentialDuplicate[];
30
33
  /**
31
34
  * NOTE: This function should not run field validations. It should return the state based on the actions, without considering context (users, roles, permissions, etc).
@@ -36,9 +39,7 @@ export declare function extractPotentialDuplicatesFromActions(actions: Action[])
36
39
  * @returns Calculates a snapshot summary of the event based on the actions taken on it.
37
40
  * @see EventIndex for the description of the returned object.
38
41
  */
39
- export declare function getCurrentEventState(event: EventDocument,
40
- /** @TODO: remove config parameter, it is only used by resolveDateOfEvent. See if it can be achieved in some other way. */
41
- config: EventConfig): EventIndex;
42
+ export declare function getCurrentEventState(event: EventDocument, config: EventConfig): EventIndex;
42
43
  /**
43
44
  * @returns the future state of the event with drafts applied to all fields.
44
45
  *
@@ -60,47 +61,45 @@ export declare function applyDeclarationToEventIndex(eventIndex: EventIndex, dec
60
61
  *
61
62
  */
62
63
  export declare function applyDraftToEventIndex(eventIndex: EventIndex, draft: Draft, eventConfiguration: EventConfig): {
64
+ id: string & import("zod").$brand<"UUID">;
63
65
  type: string;
64
- id: string & import("zod").BRAND<"UUID">;
65
- status: "ARCHIVED" | "DECLARED" | "REGISTERED" | "VALIDATED" | "CREATED" | "NOTIFIED";
66
- createdAt: string;
67
- createdBy: string;
68
- declaration: Record<string, import("..").FieldValue>;
69
- trackingId: string;
70
- updatedAt: string;
66
+ status: "CREATED" | "NOTIFIED" | "DECLARED" | "REGISTERED" | "ARCHIVED";
71
67
  legalStatuses: {
72
68
  DECLARED?: {
73
69
  createdAt: string;
74
70
  createdBy: string;
75
- createdByRole: string;
76
71
  acceptedAt: string;
77
- createdByUserType?: "system" | "user" | null | undefined;
78
- createdBySignature?: string | null | undefined;
79
- createdAtLocation?: (string & import("zod").BRAND<"UUID">) | null | undefined;
72
+ createdAtLocation?: (string & import("zod").$brand<"UUID">) | null | undefined;
73
+ createdByUserType?: "user" | "system" | null | undefined;
74
+ createdByRole?: string | undefined;
80
75
  } | null | undefined;
81
76
  REGISTERED?: {
82
77
  createdAt: string;
83
78
  createdBy: string;
84
- createdByRole: string;
85
- registrationNumber: string;
86
79
  acceptedAt: string;
87
- createdByUserType?: "system" | "user" | null | undefined;
88
- createdBySignature?: string | null | undefined;
89
- createdAtLocation?: (string & import("zod").BRAND<"UUID">) | null | undefined;
80
+ registrationNumber: string;
81
+ createdAtLocation?: (string & import("zod").$brand<"UUID">) | null | undefined;
82
+ createdByUserType?: "user" | "system" | null | undefined;
83
+ createdByRole?: string | undefined;
90
84
  } | null | undefined;
91
85
  };
92
- updatedByUserRole: string;
86
+ createdAt: string;
87
+ createdBy: string;
88
+ updatedAt: string;
89
+ trackingId: string;
93
90
  potentialDuplicates: {
94
- id: string & import("zod").BRAND<"UUID">;
91
+ id: string & import("zod").$brand<"UUID">;
95
92
  trackingId: string;
96
93
  }[];
97
94
  flags: string[];
98
- createdByUserType?: "system" | "user" | null | undefined;
99
- createdBySignature?: string | null | undefined;
100
- createdAtLocation?: (string & import("zod").BRAND<"UUID">) | null | undefined;
101
- assignedTo?: string | null | undefined;
95
+ declaration: Record<string, import("..").FieldValue>;
102
96
  dateOfEvent?: string | null | undefined;
103
- updatedAtLocation?: (string & import("zod").BRAND<"UUID">) | null | undefined;
97
+ placeOfEvent?: (string & import("zod").$brand<"UUID">) | null | undefined;
98
+ createdByUserType?: "user" | "system" | null | undefined;
99
+ updatedByUserRole?: string | null | undefined;
100
+ createdAtLocation?: (string & import("zod").$brand<"UUID">) | null | undefined;
101
+ updatedAtLocation?: (string & import("zod").$brand<"UUID">) | null | undefined;
102
+ assignedTo?: string | null | undefined;
104
103
  updatedBy?: string | null | undefined;
105
104
  };
106
105
  /**
@@ -1,287 +1,30 @@
1
1
  import { Action } from '../ActionDocument';
2
2
  /**
3
- * Given action type and actions, returns the action creation metadata for the event.
4
- * Since we do not consistently store the request action, we need to check if it exists.
5
- * @returns details of last user who triggered **Declaration** action.
6
- * @see EventIndex for the description of the returned object.
3
+ * Returns the creation metadata of the last update action (Requested or Accepted).
4
+ * Requested actions are included so that async flows (202) correctly reflect the
5
+ * metadata of the user who triggered the action before country config accepts it.
7
6
  *
8
- * */
9
- export declare function getActionUpdateMetadata(actions: Action[]): Partial<{
10
- type: "ASSIGN";
11
- id: string & import("zod").BRAND<"UUID">;
12
- status: "Rejected" | "Requested" | "Accepted";
13
- transactionId: string;
14
- createdByUserType: "system" | "user";
15
- createdAt: string;
16
- createdBy: string;
17
- createdByRole: string;
18
- declaration: Record<string, import("..").FieldUpdateValue>;
19
- assignedTo: string;
20
- createdBySignature?: string | null | undefined;
21
- createdAtLocation?: (string & import("zod").BRAND<"UUID">) | null | undefined;
22
- annotation?: Record<string, import("..").FieldUpdateValue> | null | undefined;
23
- originalActionId?: (string & import("zod").BRAND<"UUID">) | null | undefined;
24
- } | {
25
- type: "UNASSIGN";
26
- id: string & import("zod").BRAND<"UUID">;
27
- status: "Rejected" | "Requested" | "Accepted";
28
- transactionId: string;
29
- createdByUserType: "system" | "user";
30
- createdAt: string;
31
- createdBy: string;
32
- createdByRole: string;
33
- declaration: Record<string, import("..").FieldUpdateValue>;
34
- createdBySignature?: string | null | undefined;
35
- createdAtLocation?: (string & import("zod").BRAND<"UUID">) | null | undefined;
36
- annotation?: Record<string, import("..").FieldUpdateValue> | null | undefined;
37
- originalActionId?: (string & import("zod").BRAND<"UUID">) | null | undefined;
38
- } | {
39
- type: "REGISTER";
40
- id: string & import("zod").BRAND<"UUID">;
41
- status: "Rejected" | "Requested" | "Accepted";
42
- transactionId: string;
43
- createdByUserType: "system" | "user";
44
- createdAt: string;
45
- createdBy: string;
46
- createdByRole: string;
47
- declaration: Record<string, import("..").FieldUpdateValue>;
48
- createdBySignature?: string | null | undefined;
49
- createdAtLocation?: (string & import("zod").BRAND<"UUID">) | null | undefined;
50
- annotation?: Record<string, import("..").FieldUpdateValue> | null | undefined;
51
- originalActionId?: (string & import("zod").BRAND<"UUID">) | null | undefined;
52
- registrationNumber?: string | undefined;
53
- } | {
54
- type: "DECLARE";
55
- id: string & import("zod").BRAND<"UUID">;
56
- status: "Rejected" | "Requested" | "Accepted";
57
- transactionId: string;
58
- createdByUserType: "system" | "user";
59
- createdAt: string;
60
- createdBy: string;
61
- createdByRole: string;
62
- declaration: Record<string, import("..").FieldUpdateValue>;
63
- createdBySignature?: string | null | undefined;
64
- createdAtLocation?: (string & import("zod").BRAND<"UUID">) | null | undefined;
65
- annotation?: Record<string, import("..").FieldUpdateValue> | null | undefined;
66
- originalActionId?: (string & import("zod").BRAND<"UUID">) | null | undefined;
67
- } | {
68
- type: "VALIDATE";
69
- id: string & import("zod").BRAND<"UUID">;
70
- status: "Rejected" | "Requested" | "Accepted";
71
- transactionId: string;
72
- createdByUserType: "system" | "user";
73
- createdAt: string;
74
- createdBy: string;
75
- createdByRole: string;
76
- declaration: Record<string, import("..").FieldUpdateValue>;
77
- createdBySignature?: string | null | undefined;
78
- createdAtLocation?: (string & import("zod").BRAND<"UUID">) | null | undefined;
79
- annotation?: Record<string, import("..").FieldUpdateValue> | null | undefined;
80
- originalActionId?: (string & import("zod").BRAND<"UUID">) | null | undefined;
81
- } | {
82
- type: "REJECT";
83
- id: string & import("zod").BRAND<"UUID">;
84
- status: "Rejected" | "Requested" | "Accepted";
85
- content: {
86
- reason: string;
87
- };
88
- transactionId: string;
89
- createdByUserType: "system" | "user";
90
- createdAt: string;
91
- createdBy: string;
92
- createdByRole: string;
93
- declaration: Record<string, import("..").FieldUpdateValue>;
94
- createdBySignature?: string | null | undefined;
95
- createdAtLocation?: (string & import("zod").BRAND<"UUID">) | null | undefined;
96
- annotation?: Record<string, import("..").FieldUpdateValue> | null | undefined;
97
- originalActionId?: (string & import("zod").BRAND<"UUID">) | null | undefined;
98
- } | {
99
- type: "DUPLICATE_DETECTED";
100
- id: string & import("zod").BRAND<"UUID">;
101
- status: "Rejected" | "Requested" | "Accepted";
102
- content: {
103
- duplicates: {
104
- id: string & import("zod").BRAND<"UUID">;
105
- trackingId: string;
106
- }[];
107
- };
108
- transactionId: string;
109
- createdByUserType: "system" | "user";
110
- createdAt: string;
111
- createdBy: string;
112
- createdByRole: string;
113
- declaration: Record<string, import("..").FieldUpdateValue>;
114
- createdBySignature?: string | null | undefined;
115
- createdAtLocation?: (string & import("zod").BRAND<"UUID">) | null | undefined;
116
- annotation?: Record<string, import("..").FieldUpdateValue> | null | undefined;
117
- originalActionId?: (string & import("zod").BRAND<"UUID">) | null | undefined;
118
- } | {
119
- type: "MARK_AS_NOT_DUPLICATE";
120
- id: string & import("zod").BRAND<"UUID">;
121
- status: "Rejected" | "Requested" | "Accepted";
122
- transactionId: string;
123
- createdByUserType: "system" | "user";
124
- createdAt: string;
125
- createdBy: string;
126
- createdByRole: string;
127
- declaration: Record<string, import("..").FieldUpdateValue>;
128
- createdBySignature?: string | null | undefined;
129
- createdAtLocation?: (string & import("zod").BRAND<"UUID">) | null | undefined;
130
- annotation?: Record<string, import("..").FieldUpdateValue> | null | undefined;
131
- originalActionId?: (string & import("zod").BRAND<"UUID">) | null | undefined;
132
- } | {
133
- type: "MARK_AS_DUPLICATE";
134
- id: string & import("zod").BRAND<"UUID">;
135
- status: "Rejected" | "Requested" | "Accepted";
136
- transactionId: string;
137
- createdByUserType: "system" | "user";
138
- createdAt: string;
139
- createdBy: string;
140
- createdByRole: string;
141
- declaration: Record<string, import("..").FieldUpdateValue>;
142
- content?: {
143
- duplicateOf: string & import("zod").BRAND<"UUID">;
144
- } | undefined;
145
- createdBySignature?: string | null | undefined;
146
- createdAtLocation?: (string & import("zod").BRAND<"UUID">) | null | undefined;
147
- annotation?: Record<string, import("..").FieldUpdateValue> | null | undefined;
148
- originalActionId?: (string & import("zod").BRAND<"UUID">) | null | undefined;
149
- } | {
150
- type: "ARCHIVE";
151
- id: string & import("zod").BRAND<"UUID">;
152
- status: "Rejected" | "Requested" | "Accepted";
153
- content: {
154
- reason: string;
155
- };
156
- transactionId: string;
157
- createdByUserType: "system" | "user";
158
- createdAt: string;
159
- createdBy: string;
160
- createdByRole: string;
161
- declaration: Record<string, import("..").FieldUpdateValue>;
162
- createdBySignature?: string | null | undefined;
163
- createdAtLocation?: (string & import("zod").BRAND<"UUID">) | null | undefined;
164
- annotation?: Record<string, import("..").FieldUpdateValue> | null | undefined;
165
- originalActionId?: (string & import("zod").BRAND<"UUID">) | null | undefined;
166
- } | {
167
- type: "CREATE";
168
- id: string & import("zod").BRAND<"UUID">;
169
- status: "Rejected" | "Requested" | "Accepted";
170
- transactionId: string;
171
- createdByUserType: "system" | "user";
172
- createdAt: string;
173
- createdBy: string;
174
- createdByRole: string;
175
- declaration: Record<string, import("..").FieldUpdateValue>;
176
- createdBySignature?: string | null | undefined;
177
- createdAtLocation?: (string & import("zod").BRAND<"UUID">) | null | undefined;
178
- annotation?: Record<string, import("..").FieldUpdateValue> | null | undefined;
179
- originalActionId?: (string & import("zod").BRAND<"UUID">) | null | undefined;
180
- } | {
181
- type: "NOTIFY";
182
- id: string & import("zod").BRAND<"UUID">;
183
- status: "Rejected" | "Requested" | "Accepted";
184
- transactionId: string;
185
- createdByUserType: "system" | "user";
186
- createdAt: string;
187
- createdBy: string;
188
- createdByRole: string;
189
- declaration: Record<string, import("..").FieldUpdateValue>;
190
- createdBySignature?: string | null | undefined;
191
- createdAtLocation?: (string & import("zod").BRAND<"UUID">) | null | undefined;
192
- annotation?: Record<string, import("..").FieldUpdateValue> | null | undefined;
193
- originalActionId?: (string & import("zod").BRAND<"UUID">) | null | undefined;
194
- } | {
195
- type: "PRINT_CERTIFICATE";
196
- id: string & import("zod").BRAND<"UUID">;
197
- status: "Rejected" | "Requested" | "Accepted";
198
- transactionId: string;
199
- createdByUserType: "system" | "user";
200
- createdAt: string;
201
- createdBy: string;
202
- createdByRole: string;
203
- declaration: Record<string, import("..").FieldUpdateValue>;
204
- content?: {
205
- templateId?: string | undefined;
206
- } | null | undefined;
207
- createdBySignature?: string | null | undefined;
208
- createdAtLocation?: (string & import("zod").BRAND<"UUID">) | null | undefined;
209
- annotation?: Record<string, import("..").FieldUpdateValue> | null | undefined;
210
- originalActionId?: (string & import("zod").BRAND<"UUID">) | null | undefined;
211
- } | {
212
- type: "REQUEST_CORRECTION";
213
- id: string & import("zod").BRAND<"UUID">;
214
- status: "Rejected" | "Requested" | "Accepted";
215
- transactionId: string;
216
- createdByUserType: "system" | "user";
217
- createdAt: string;
218
- createdBy: string;
219
- createdByRole: string;
220
- declaration: Record<string, import("..").FieldUpdateValue>;
221
- createdBySignature?: string | null | undefined;
222
- createdAtLocation?: (string & import("zod").BRAND<"UUID">) | null | undefined;
223
- annotation?: Record<string, import("..").FieldUpdateValue> | null | undefined;
224
- originalActionId?: (string & import("zod").BRAND<"UUID">) | null | undefined;
225
- } | {
226
- type: "APPROVE_CORRECTION";
227
- id: string & import("zod").BRAND<"UUID">;
228
- status: "Rejected" | "Requested" | "Accepted";
229
- transactionId: string;
230
- createdByUserType: "system" | "user";
231
- createdAt: string;
232
- createdBy: string;
233
- createdByRole: string;
234
- declaration: Record<string, import("..").FieldUpdateValue>;
235
- requestId: string;
236
- createdBySignature?: string | null | undefined;
237
- createdAtLocation?: (string & import("zod").BRAND<"UUID">) | null | undefined;
238
- annotation?: Record<string, import("..").FieldUpdateValue> | null | undefined;
239
- originalActionId?: (string & import("zod").BRAND<"UUID">) | null | undefined;
240
- } | {
241
- type: "REJECT_CORRECTION";
242
- id: string & import("zod").BRAND<"UUID">;
243
- status: "Rejected" | "Requested" | "Accepted";
244
- content: {
245
- reason: string;
246
- };
247
- transactionId: string;
248
- createdByUserType: "system" | "user";
249
- createdAt: string;
250
- createdBy: string;
251
- createdByRole: string;
252
- declaration: Record<string, import("..").FieldUpdateValue>;
253
- requestId: string;
254
- createdBySignature?: string | null | undefined;
255
- createdAtLocation?: (string & import("zod").BRAND<"UUID">) | null | undefined;
256
- annotation?: Record<string, import("..").FieldUpdateValue> | null | undefined;
257
- originalActionId?: (string & import("zod").BRAND<"UUID">) | null | undefined;
258
- } | {
259
- type: "READ";
260
- id: string & import("zod").BRAND<"UUID">;
261
- status: "Rejected" | "Requested" | "Accepted";
7
+ * When an Accepted action carries an originalActionId, its metadata is sourced from
8
+ * the original Requested action (the human who triggered it), not from the system
9
+ * or 3rd party that accepted it.
10
+ *
11
+ * @returns metadata of the last user who triggered a status-changing action.
12
+ * @see EventIndex for the description of the returned object.
13
+ */
14
+ export declare function getActionUpdateMetadata(actions: Action[]): Pick<{
15
+ id: string & import("zod").$brand<"UUID">;
262
16
  transactionId: string;
263
- createdByUserType: "system" | "user";
17
+ createdByUserType: "user" | "system";
264
18
  createdAt: string;
265
19
  createdBy: string;
266
- createdByRole: string;
267
20
  declaration: Record<string, import("..").FieldUpdateValue>;
268
- createdBySignature?: string | null | undefined;
269
- createdAtLocation?: (string & import("zod").BRAND<"UUID">) | null | undefined;
21
+ status: "Requested" | "Accepted" | "Rejected";
22
+ createdByRole?: string | undefined;
23
+ createdBySignature?: (string & import("zod").$brand<"DocumentPath">) | null | undefined;
24
+ createdAtLocation?: (string & import("zod").$brand<"UUID">) | null | undefined;
270
25
  annotation?: Record<string, import("..").FieldUpdateValue> | null | undefined;
271
- originalActionId?: (string & import("zod").BRAND<"UUID">) | null | undefined;
272
- } | {
273
- type: "NOTIFY" | "DECLARE" | "VALIDATE" | "REGISTER" | "REJECT" | "ARCHIVE" | "PRINT_CERTIFICATE" | "REQUEST_CORRECTION" | "REJECT_CORRECTION" | "APPROVE_CORRECTION";
274
- id: string & import("zod").BRAND<"UUID">;
275
- status: "Rejected";
276
- transactionId: string;
277
- createdByUserType: "system" | "user";
278
- createdAt: string;
279
- createdBy: string;
280
- createdByRole: string;
281
- createdBySignature?: string | null | undefined;
282
- createdAtLocation?: (string & import("zod").BRAND<"UUID">) | null | undefined;
283
- originalActionId?: (string & import("zod").BRAND<"UUID">) | null | undefined;
284
- }>;
26
+ originalActionId?: (string & import("zod").$brand<"UUID">) | null | undefined;
27
+ }, "createdByUserType" | "createdAt" | "createdBy" | "createdByRole" | "createdAtLocation">;
285
28
  /**
286
29
  * @returns the legal statuses of the event. Event is considered legal if it has been accepted.
287
30
  * @see EventIndex for the description of the returned object.
@@ -290,21 +33,19 @@ export declare function getLegalStatuses(actions: Action[]): {
290
33
  DECLARED: {
291
34
  createdAt: string;
292
35
  createdBy: string;
293
- createdByUserType: "system" | "user";
294
- createdAtLocation: (string & import("zod").BRAND<"UUID">) | null | undefined;
36
+ createdByUserType: "user" | "system";
37
+ createdAtLocation: (string & import("zod").$brand<"UUID">) | null | undefined;
295
38
  acceptedAt: string;
296
- createdByRole: string;
297
- createdBySignature: string | null | undefined;
39
+ createdByRole: string | undefined;
298
40
  registrationNumber: string | null | undefined;
299
41
  } | null;
300
42
  REGISTERED: {
301
43
  createdAt: string;
302
44
  createdBy: string;
303
- createdByUserType: "system" | "user";
304
- createdAtLocation: (string & import("zod").BRAND<"UUID">) | null | undefined;
45
+ createdByUserType: "user" | "system";
46
+ createdAtLocation: (string & import("zod").$brand<"UUID">) | null | undefined;
305
47
  acceptedAt: string;
306
- createdByRole: string;
307
- createdBySignature: string | null | undefined;
48
+ createdByRole: string | undefined;
308
49
  registrationNumber: string | null | undefined;
309
50
  } | null;
310
51
  };
@@ -1,6 +1,6 @@
1
1
  import { UUID } from '../uuid';
2
2
  import { ActionDocument, ActionUpdate } from './ActionDocument';
3
- import { ApproveCorrectionActionInput, ArchiveActionInput, AssignActionInput, DeclareActionInput, MarkAsDuplicateActionInput, MarkNotDuplicateActionInput, NotifyActionInput, RegisterActionInput, RejectCorrectionActionInput, RejectDeclarationActionInput, RequestCorrectionActionInput, UnassignActionInput, ValidateActionInput } from './ActionInput';
3
+ import { ApproveCorrectionActionInput, ArchiveActionInput, AssignActionInput, DeclareActionInput, EditActionInput, MarkAsDuplicateActionInput, MarkNotDuplicateActionInput, NotifyActionInput, RegisterActionInput, RejectCorrectionActionInput, RejectDeclarationActionInput, RequestCorrectionActionInput, UnassignActionInput } from './ActionInput';
4
4
  import { ActionType } from './ActionType';
5
5
  import { Draft } from './Draft';
6
6
  import { EventConfig } from './EventConfig';
@@ -9,8 +9,10 @@ import { EventIndex } from './EventIndex';
9
9
  import { EventInput } from './EventInput';
10
10
  import { TranslationConfig } from './TranslationConfig';
11
11
  import { FieldConfig } from './FieldConfig';
12
+ import { Location, AdministrativeArea } from './locations';
12
13
  import { WorkqueueConfig } from './WorkqueueConfig';
13
- import { z } from 'zod';
14
+ import * as z from 'zod/v4';
15
+ import { DocumentPath } from '../documents';
14
16
  /**
15
17
  * IANA timezone used in testing. Used for queries that expect similar results independent of the users location (e.g. when event was registered.)
16
18
  * Since we query by range, providing UTC offset will result to different results when DST changes during the range.
@@ -20,8 +22,19 @@ export declare const TEST_SYSTEM_IANA_TIMEZONE = "Asia/Dhaka";
20
22
  * In real application, the roles are defined in the countryconfig.
21
23
  * These are just for testing purposes to generate realistic mock data.
22
24
  */
23
- export declare const TestUserRole: z.ZodEnum<["FIELD_AGENT", "LOCAL_REGISTRAR", "LOCAL_SYSTEM_ADMIN", "NATIONAL_REGISTRAR", "REGISTRATION_AGENT", "NATIONAL_SYSTEM_ADMIN", "SOCIAL_WORKER"]>;
25
+ export declare const TestUserRole: z.ZodEnum<{
26
+ FIELD_AGENT: "FIELD_AGENT";
27
+ LOCAL_REGISTRAR: "LOCAL_REGISTRAR";
28
+ LOCAL_SYSTEM_ADMIN: "LOCAL_SYSTEM_ADMIN";
29
+ NATIONAL_REGISTRAR: "NATIONAL_REGISTRAR";
30
+ REGISTRATION_AGENT: "REGISTRATION_AGENT";
31
+ NATIONAL_SYSTEM_ADMIN: "NATIONAL_SYSTEM_ADMIN";
32
+ SOCIAL_WORKER: "SOCIAL_WORKER";
33
+ COMMUNITY_LEADER: "COMMUNITY_LEADER";
34
+ PROVINCIAL_REGISTRAR: "PROVINCIAL_REGISTRAR";
35
+ }>;
24
36
  export type TestUserRole = z.infer<typeof TestUserRole>;
37
+ export declare function pickRandom<T>(rng: () => number, items: T[]): T;
25
38
  export declare function generateRandomName(rng: () => number): {
26
39
  firstname: string;
27
40
  surname: string;
@@ -29,9 +42,23 @@ export declare function generateRandomName(rng: () => number): {
29
42
  export declare function generateUuid(rng?: () => number): UUID;
30
43
  export declare function generateTrackingId(rng: () => number): string;
31
44
  export declare function generateRegistrationNumber(rng: () => number): string;
32
- export declare function generateRandomSignature(rng: () => number): string;
33
- export declare function fieldConfigsToActionPayload(fields: FieldConfig[], rng: () => number): ActionUpdate;
34
- export declare function generateActionDeclarationInput(configuration: EventConfig, action: ActionType, rng: () => number, overrides?: ActionUpdate): ActionUpdate;
45
+ export declare function generateRandomSignature(rng: () => number): DocumentPath;
46
+ export declare function fieldConfigsToActionPayload(fields: FieldConfig[], rng: () => number,
47
+ /**
48
+ * Given hierarchy, ensures that related fields (e.g. location and administrative area) have valid values based on the hierarchy.
49
+ */
50
+ administrativeHierarchy?: {
51
+ administrativeAreas: AdministrativeArea[];
52
+ locations: Location[];
53
+ }): ActionUpdate;
54
+ export declare function generateActionDeclarationInput(configuration: EventConfig, action: ActionType, rng: () => number, overrides?: ActionUpdate,
55
+ /**
56
+ * Given hierarchy, ensures that related fields (e.g. location and administrative area) have valid values based on the hierarchy.
57
+ */
58
+ administrativeHierarchy?: {
59
+ administrativeAreas: AdministrativeArea[];
60
+ locations: Location[];
61
+ }): ActionUpdate;
35
62
  export declare function generateActionDuplicateDeclarationInput(...args: Parameters<typeof generateActionDeclarationInput>): ReturnType<typeof generateActionDeclarationInput>;
36
63
  export declare function eventPayloadGenerator(rng: () => number, configuration?: EventConfig): {
37
64
  create: (input?: Partial<EventInput>) => {
@@ -68,13 +95,15 @@ export declare function eventPayloadGenerator(rng: () => number, configuration?:
68
95
  eventId: string;
69
96
  keepAssignment: boolean | undefined;
70
97
  };
71
- validate: (eventId: string, input?: Partial<Pick<ValidateActionInput, "transactionId" | "declaration" | "annotation" | "keepAssignment">>) => {
98
+ edit: (eventId: string, input?: Partial<Pick<EditActionInput, "transactionId" | "declaration" | "annotation" | "keepAssignment">>) => {
72
99
  transactionId: string;
73
100
  declaration: Record<string, import("./FieldValue").FieldUpdateValue>;
74
101
  annotation: {};
75
102
  keepAssignment?: boolean | undefined;
76
- type: "VALIDATE";
77
- duplicates: never[];
103
+ type: "EDIT";
104
+ content: {
105
+ comment: string;
106
+ };
78
107
  eventId: string;
79
108
  };
80
109
  assign: (eventId: string, input?: Partial<Pick<AssignActionInput, "transactionId" | "assignedTo">>) => {
@@ -97,7 +126,6 @@ export declare function eventPayloadGenerator(rng: () => number, configuration?:
97
126
  keepAssignment?: boolean | undefined;
98
127
  type: "ARCHIVE";
99
128
  annotation: {};
100
- duplicates: never[];
101
129
  eventId: string;
102
130
  content: {
103
131
  reason: string;
@@ -109,7 +137,6 @@ export declare function eventPayloadGenerator(rng: () => number, configuration?:
109
137
  keepAssignment?: boolean | undefined;
110
138
  type: "REJECT";
111
139
  declaration: {};
112
- duplicates: never[];
113
140
  eventId: string;
114
141
  content: {
115
142
  reason: string;
@@ -245,4 +272,18 @@ export declare const BearerTokenByUserType: {
245
272
  localRegistrar: string;
246
273
  };
247
274
  export declare const generateWorkqueues: (slug?: string) => WorkqueueConfig[];
275
+ /**
276
+ * Backend focused event config generator for testing fields in a lightweight way.
277
+ *
278
+ * @param id - The unique identifier for the event.
279
+ * @param fields - Field configurations to include in the event declaration. Everything in a single page.
280
+ * @param placeOfEventId - Optional place of event field id.
281
+ * @param dateOfEventId - Optional date of event field id.
282
+ */
283
+ export declare const generateEventConfig: ({ id, fields, placeOfEventId, dateOfEventId }: {
284
+ id: string;
285
+ fields: FieldConfig[];
286
+ placeOfEventId?: string;
287
+ dateOfEventId?: string;
288
+ }) => EventConfig;
248
289
  //# sourceMappingURL=test.utils.d.ts.map
@@ -1,2 +1,2 @@
1
- export declare function generateTransactionId(): string & import("zod").BRAND<"UUID">;
1
+ export declare function generateTransactionId(): string & import("zod").$brand<"UUID">;
2
2
  //# sourceMappingURL=transactions.d.ts.map