@opencrvs/toolkit 1.9.4-rc.793f834 → 1.9.4-rc.f09603b

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 (58) hide show
  1. package/dist/commons/api/router.d.ts +28204 -2149
  2. package/dist/commons/conditionals/conditionals.d.ts +10 -1
  3. package/dist/commons/conditionals/validate.d.ts +11 -4
  4. package/dist/commons/events/ActionConfig.d.ts +23416 -1552
  5. package/dist/commons/events/ActionDocument.d.ts +803 -1856
  6. package/dist/commons/events/ActionInput.d.ts +277 -1073
  7. package/dist/commons/events/ActionType.d.ts +86 -9
  8. package/dist/commons/events/AdvancedSearchConfig.d.ts +228 -1238
  9. package/dist/commons/events/CompositeFieldValue.d.ts +27 -176
  10. package/dist/commons/events/Conditional.d.ts +26 -38
  11. package/dist/commons/events/Constants.d.ts +1 -1
  12. package/dist/commons/events/CountryConfigQueryInput.d.ts +931 -4169
  13. package/dist/commons/events/CreatedAtLocation.d.ts +1 -1
  14. package/dist/commons/events/DeduplicationConfig.d.ts +15 -150
  15. package/dist/commons/events/Draft.d.ts +70 -105
  16. package/dist/commons/events/DynamicFieldValue.d.ts +7 -91
  17. package/dist/commons/events/EventConfig.d.ts +18663 -2120
  18. package/dist/commons/events/EventConfigInput.d.ts +1 -1
  19. package/dist/commons/events/EventDocument.d.ts +320 -1332
  20. package/dist/commons/events/EventIndex.d.ts +197 -967
  21. package/dist/commons/events/EventInput.d.ts +2 -8
  22. package/dist/commons/events/EventMetadata.d.ts +106 -346
  23. package/dist/commons/events/FieldConfig.d.ts +4267 -11782
  24. package/dist/commons/events/FieldType.d.ts +20 -4
  25. package/dist/commons/events/FieldTypeMapping.d.ts +181 -813
  26. package/dist/commons/events/FieldValue.d.ts +83 -356
  27. package/dist/commons/events/Flag.d.ts +70 -0
  28. package/dist/commons/events/FormConfig.d.ts +13140 -721
  29. package/dist/commons/events/PageConfig.d.ts +8780 -319
  30. package/dist/commons/events/SummaryConfig.d.ts +14 -161
  31. package/dist/commons/events/TemplateConfig.d.ts +3 -3
  32. package/dist/commons/events/TranslationConfig.d.ts +2 -2
  33. package/dist/commons/events/WorkqueueColumnConfig.d.ts +74 -37
  34. package/dist/commons/events/WorkqueueConfig.d.ts +1691 -7156
  35. package/dist/commons/events/deduplication.d.ts +3 -3
  36. package/dist/commons/events/defineConfig.d.ts +25626 -150
  37. package/dist/commons/events/event.d.ts +4 -4
  38. package/dist/commons/events/index.d.ts +1 -0
  39. package/dist/commons/events/locations.d.ts +15 -19
  40. package/dist/commons/events/scopes.d.ts +5 -4
  41. package/dist/commons/events/state/availableActions.d.ts +2 -1
  42. package/dist/commons/events/state/flags.d.ts +21 -3
  43. package/dist/commons/events/state/index.d.ts +23 -19
  44. package/dist/commons/events/state/utils.d.ts +130 -112
  45. package/dist/commons/events/test.utils.d.ts +17 -8
  46. package/dist/commons/events/transactions.d.ts +1 -1
  47. package/dist/commons/events/utils.d.ts +51339 -362
  48. package/dist/commons/notification/UserNotifications.d.ts +55 -636
  49. package/dist/conditionals/index.d.ts.map +1 -1
  50. package/dist/conditionals/index.js +38 -5
  51. package/dist/events/deduplication.d.ts +3 -3
  52. package/dist/events/index.js +1810 -1550
  53. package/dist/notification/index.d.ts.map +1 -1
  54. package/dist/notification/index.js +1430 -1412
  55. package/dist/scopes/index.d.ts +167 -132
  56. package/dist/scopes/index.d.ts.map +1 -1
  57. package/dist/scopes/index.js +133 -94
  58. package/package.json +5 -5
@@ -10,7 +10,7 @@ import { WorkqueueColumnKeys, WorkqueueColumnValue } from './WorkqueueColumnConf
10
10
  */
11
11
  declare function eventFn(fieldId: EventFieldIdInput): {
12
12
  range: () => {
13
- fieldId: "event.status" | "event.trackingId" | "event.updatedAt" | "event.legalStatuses.REGISTERED.acceptedAt" | "event.legalStatuses.REGISTERED.createdAtLocation";
13
+ fieldId: "event.status" | "event.trackingId" | "event.updatedAt" | "event.legalStatuses.REGISTERED.acceptedAt" | "event.legalStatuses.REGISTERED.createdAtLocation" | "event.legalStatuses.REGISTERED.registrationNumber";
14
14
  fieldType: "event";
15
15
  } & {
16
16
  config: {
@@ -18,7 +18,7 @@ declare function eventFn(fieldId: EventFieldIdInput): {
18
18
  };
19
19
  };
20
20
  exact: () => {
21
- fieldId: "event.status" | "event.trackingId" | "event.updatedAt" | "event.legalStatuses.REGISTERED.acceptedAt" | "event.legalStatuses.REGISTERED.createdAtLocation";
21
+ fieldId: "event.status" | "event.trackingId" | "event.updatedAt" | "event.legalStatuses.REGISTERED.acceptedAt" | "event.legalStatuses.REGISTERED.createdAtLocation" | "event.legalStatuses.REGISTERED.registrationNumber";
22
22
  fieldType: "event";
23
23
  } & {
24
24
  config: {
@@ -26,7 +26,7 @@ declare function eventFn(fieldId: EventFieldIdInput): {
26
26
  };
27
27
  };
28
28
  fuzzy: () => {
29
- fieldId: "event.status" | "event.trackingId" | "event.updatedAt" | "event.legalStatuses.REGISTERED.acceptedAt" | "event.legalStatuses.REGISTERED.createdAtLocation";
29
+ fieldId: "event.status" | "event.trackingId" | "event.updatedAt" | "event.legalStatuses.REGISTERED.acceptedAt" | "event.legalStatuses.REGISTERED.createdAtLocation" | "event.legalStatuses.REGISTERED.registrationNumber";
30
30
  fieldType: "event";
31
31
  } & {
32
32
  config: {
@@ -34,7 +34,7 @@ declare function eventFn(fieldId: EventFieldIdInput): {
34
34
  };
35
35
  };
36
36
  within: () => {
37
- fieldId: "event.status" | "event.trackingId" | "event.updatedAt" | "event.legalStatuses.REGISTERED.acceptedAt" | "event.legalStatuses.REGISTERED.createdAtLocation";
37
+ fieldId: "event.status" | "event.trackingId" | "event.updatedAt" | "event.legalStatuses.REGISTERED.acceptedAt" | "event.legalStatuses.REGISTERED.createdAtLocation" | "event.legalStatuses.REGISTERED.registrationNumber";
38
38
  fieldType: "event";
39
39
  } & {
40
40
  config: {
@@ -39,6 +39,7 @@ export * from './FileUtils';
39
39
  export * from '../conditionals/conditionals';
40
40
  export * from '../conditionals/validate';
41
41
  export * from './field';
42
+ export * from './Flag';
42
43
  export * from './event';
43
44
  export * from './locations';
44
45
  export { UUID } from '../uuid';
@@ -1,24 +1,20 @@
1
- import { z } from 'zod';
2
- export declare const LocationType: z.ZodEnum<["ADMIN_STRUCTURE", "CRVS_OFFICE", "HEALTH_FACILITY"]>;
1
+ import * as z from 'zod/v4';
2
+ export declare const LocationType: z.ZodEnum<{
3
+ ADMIN_STRUCTURE: "ADMIN_STRUCTURE";
4
+ HEALTH_FACILITY: "HEALTH_FACILITY";
5
+ CRVS_OFFICE: "CRVS_OFFICE";
6
+ }>;
3
7
  export type LocationType = z.infer<typeof LocationType>;
4
8
  export declare const Location: z.ZodObject<{
5
- id: z.ZodBranded<z.ZodString, "UUID">;
9
+ id: z.core.$ZodBranded<z.ZodUUID, "UUID">;
6
10
  name: z.ZodString;
7
- parentId: z.ZodNullable<z.ZodBranded<z.ZodString, "UUID">>;
8
- validUntil: z.ZodNullable<z.ZodString>;
9
- locationType: z.ZodNullable<z.ZodEnum<["ADMIN_STRUCTURE", "CRVS_OFFICE", "HEALTH_FACILITY"]>>;
10
- }, "strip", z.ZodTypeAny, {
11
- id: string & z.BRAND<"UUID">;
12
- name: string;
13
- parentId: (string & z.BRAND<"UUID">) | null;
14
- validUntil: string | null;
15
- locationType: "ADMIN_STRUCTURE" | "HEALTH_FACILITY" | "CRVS_OFFICE" | null;
16
- }, {
17
- id: string;
18
- name: string;
19
- parentId: string | null;
20
- validUntil: string | null;
21
- locationType: "ADMIN_STRUCTURE" | "HEALTH_FACILITY" | "CRVS_OFFICE" | null;
22
- }>;
11
+ parentId: z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID">>;
12
+ validUntil: z.ZodNullable<z.ZodISODateTime>;
13
+ locationType: z.ZodNullable<z.ZodEnum<{
14
+ ADMIN_STRUCTURE: "ADMIN_STRUCTURE";
15
+ HEALTH_FACILITY: "HEALTH_FACILITY";
16
+ CRVS_OFFICE: "CRVS_OFFICE";
17
+ }>>;
18
+ }, z.core.$strip>;
23
19
  export type Location = z.infer<typeof Location>;
24
20
  //# sourceMappingURL=locations.d.ts.map
@@ -5,9 +5,9 @@ export declare const ACTION_SCOPE_MAP: {
5
5
  READ: "record.read"[];
6
6
  CREATE: "record.create"[];
7
7
  NOTIFY: "record.notify"[];
8
- DECLARE: ("record.register" | "record.declare" | "record.declared.validate")[];
8
+ DECLARE: ("record.register" | "record.declare")[];
9
+ EDIT: "record.declared.edit"[];
9
10
  DELETE: "record.declare"[];
10
- VALIDATE: ("record.register" | "record.declared.validate")[];
11
11
  REGISTER: "record.register"[];
12
12
  PRINT_CERTIFICATE: "record.registered.print-certified-copies"[];
13
13
  REQUEST_CORRECTION: ("record.registered.request-correction" | "record.registered.correct")[];
@@ -21,9 +21,10 @@ export declare const ACTION_SCOPE_MAP: {
21
21
  ASSIGN: null;
22
22
  UNASSIGN: null;
23
23
  DUPLICATE_DETECTED: never[];
24
+ CUSTOM: never[];
24
25
  };
25
26
  export declare function hasAnyOfScopes(a: Scope[], b: Scope[]): boolean;
26
- export declare function configurableEventScopeAllowed(scopes: Scope[], allowedConfigurableScopes: ConfigurableScopeType[], eventType: string): boolean;
27
+ export declare function configurableEventScopeAllowed(scopes: Scope[], allowedConfigurableScopes: ConfigurableScopeType[], eventType: string, customActionType?: string): boolean;
27
28
  /**
28
29
  * Checks if a given action is allowed for the provided scopes and event type.
29
30
  *
@@ -36,7 +37,7 @@ export declare function configurableEventScopeAllowed(scopes: Scope[], allowedCo
36
37
  * @param {string} eventType - The type of event for which the action is being checked.
37
38
  * @returns {boolean} True if the action is in scope for the user, otherwise false.
38
39
  */
39
- export declare function isActionInScope(scopes: Scope[], action: DisplayableAction, eventType: string): boolean;
40
+ export declare function isActionInScope(scopes: Scope[], action: DisplayableAction, eventType: string, customActionType?: string): boolean;
40
41
  /**
41
42
  * A shared utility to check if the user can read a record.
42
43
  * This will be removed in 1.10 and implemented by scopes.
@@ -1,6 +1,7 @@
1
1
  import { DisplayableAction } from '../ActionType';
2
2
  import { EventIndex } from '../EventIndex';
3
- import { EventStatus, Flag } from '../EventMetadata';
3
+ import { EventStatus } from '../EventMetadata';
4
+ import { Flag } from '../Flag';
4
5
  export declare function getAvailableActions(status: EventStatus, flags: Flag[]): DisplayableAction[];
5
6
  export declare function getAvailableActionsForEvent(event: EventIndex): DisplayableAction[];
6
7
  //# sourceMappingURL=availableActions.d.ts.map
@@ -1,4 +1,22 @@
1
- import { Action } from '../ActionDocument';
2
- import { Flag } from '../EventMetadata';
3
- export declare function getFlagsFromActions(actions: Action[]): Flag[];
1
+ import { Flag, CustomFlag } from '../Flag';
2
+ import { EventConfig } from '../EventConfig';
3
+ import { EventDocument } from '../EventDocument';
4
+ /**
5
+ * This function resolves custom flags for an event based on its actions.
6
+ * Flags are not stored to the event state or any database directly, instead they are always computed/evaluated from the event actions.
7
+ *
8
+ * Processes accepted actions in chronological order, evaluating flag conditions
9
+ * at each action step. Flags can be added or removed based on action configurations
10
+ * and conditional logic. Duplicate flags are filtered out.
11
+ *
12
+ * @param event - The event document containing actions and metadata
13
+ * @param eventConfiguration - The configuration object for the event type defining action rules and flag behaviors
14
+ * @returns An array of unique custom flag IDs that apply to the event after processing all non-meta actions
15
+ *
16
+ * @example
17
+ * const flags = resolveEventCustomFlags(eventDoc, config);
18
+ * // Returns: ['flag-1', 'flag-3']
19
+ */
20
+ export declare function resolveEventCustomFlags(event: EventDocument, eventConfiguration: EventConfig): CustomFlag[];
21
+ export declare function getEventFlags(event: EventDocument, config: EventConfig): Flag[];
4
22
  //# sourceMappingURL=flags.d.ts.map
@@ -7,7 +7,7 @@ import { Draft } from '../Draft';
7
7
  import { EventConfig } from '../EventConfig';
8
8
  import { UUID } from '../../uuid';
9
9
  import { DocumentPath, FullDocumentPath, FullDocumentUrl } from '../../documents';
10
- export declare function getStatusFromActions(actions: Array<Action>): "ARCHIVED" | "DECLARED" | "REGISTERED" | "VALIDATED" | "CREATED" | "NOTIFIED";
10
+ export declare function getStatusFromActions(actions: Array<Action>): "ARCHIVED" | "DECLARED" | "REGISTERED" | "CREATED" | "NOTIFIED";
11
11
  export declare function getAssignedUserFromActions(actions: Array<ActionDocument>): string | null;
12
12
  export declare function getAssignedUserSignatureFromActions(actions: Array<ActionDocument>): string | null;
13
13
  type NonNullableDeep<T> = T extends [unknown, ...unknown[]] ? {
@@ -28,9 +28,14 @@ export declare const DEFAULT_DATE_OF_EVENT_PROPERTY = "createdAt";
28
28
  export declare function resolveDateOfEvent(eventMetadata: {
29
29
  createdAt: string;
30
30
  }, declaration: EventState, config: EventConfig): string | undefined;
31
+ export declare const DEFAULT_PLACE_OF_EVENT_PROPERTY = "createdAtLocation";
32
+ export declare function resolvePlaceOfEvent(eventMetadata: {
33
+ createdAtLocation?: UUID | undefined | null;
34
+ }, declaration: EventState, config: EventConfig): UUID | undefined | null;
31
35
  export declare function extractPotentialDuplicatesFromActions(actions: Action[]): PotentialDuplicate[];
32
36
  /**
33
37
  * NOTE: This function should not run field validations. It should return the state based on the actions, without considering context (users, roles, permissions, etc).
38
+ createdAtLocation: CreatedAtLocation
34
39
  *
35
40
  * If you update this function, please ensure @EventIndex type is updated accordingly.
36
41
  * In most cases, you won't need to add new parameters to this function. Discuss with the team before doing so.
@@ -38,9 +43,7 @@ export declare function extractPotentialDuplicatesFromActions(actions: Action[])
38
43
  * @returns Calculates a snapshot summary of the event based on the actions taken on it.
39
44
  * @see EventIndex for the description of the returned object.
40
45
  */
41
- export declare function getCurrentEventState(event: EventDocument,
42
- /** @TODO: remove config parameter, it is only used by resolveDateOfEvent. See if it can be achieved in some other way. */
43
- config: EventConfig): EventIndex;
46
+ export declare function getCurrentEventState(event: EventDocument, config: EventConfig): EventIndex;
44
47
  /**
45
48
  * @returns the future state of the event with drafts applied to all fields.
46
49
  *
@@ -62,47 +65,48 @@ export declare function applyDeclarationToEventIndex(eventIndex: EventIndex, dec
62
65
  *
63
66
  */
64
67
  export declare function applyDraftToEventIndex(eventIndex: EventIndex, draft: Draft, eventConfiguration: EventConfig): {
68
+ id: string & import("zod/v4").$brand<"UUID">;
65
69
  type: string;
66
- id: string & import("zod").BRAND<"UUID">;
67
- status: "ARCHIVED" | "DECLARED" | "REGISTERED" | "VALIDATED" | "CREATED" | "NOTIFIED";
68
- createdAt: string;
69
- createdBy: string;
70
- declaration: Record<string, import("..").FieldValue>;
71
- trackingId: string;
72
- updatedAt: string;
70
+ status: "ARCHIVED" | "DECLARED" | "REGISTERED" | "CREATED" | "NOTIFIED";
73
71
  legalStatuses: {
74
72
  DECLARED?: {
75
73
  createdAt: string;
76
74
  createdBy: string;
77
- createdByRole: string;
78
75
  acceptedAt: string;
76
+ createdByRole: string;
77
+ createdAtLocation?: (string & import("zod/v4").$brand<"UUID">) | null | undefined;
79
78
  createdByUserType?: "system" | "user" | null | undefined;
80
79
  createdBySignature?: string | null | undefined;
81
- createdAtLocation?: (string & import("zod").BRAND<"UUID">) | null | undefined;
82
80
  } | null | undefined;
83
81
  REGISTERED?: {
84
82
  createdAt: string;
85
83
  createdBy: string;
84
+ acceptedAt: string;
86
85
  createdByRole: string;
87
86
  registrationNumber: string;
88
- acceptedAt: string;
87
+ createdAtLocation?: (string & import("zod/v4").$brand<"UUID">) | null | undefined;
89
88
  createdByUserType?: "system" | "user" | null | undefined;
90
89
  createdBySignature?: string | null | undefined;
91
- createdAtLocation?: (string & import("zod").BRAND<"UUID">) | null | undefined;
92
90
  } | null | undefined;
93
91
  };
92
+ createdAt: string;
93
+ createdBy: string;
94
94
  updatedByUserRole: string;
95
+ updatedAt: string;
96
+ trackingId: string;
95
97
  potentialDuplicates: {
96
- id: string & import("zod").BRAND<"UUID">;
98
+ id: string & import("zod/v4").$brand<"UUID">;
97
99
  trackingId: string;
98
100
  }[];
99
101
  flags: string[];
102
+ declaration: Record<string, import("..").FieldValue>;
103
+ dateOfEvent?: string | null | undefined;
104
+ placeOfEvent?: (string & import("zod/v4").$brand<"UUID">) | null | undefined;
100
105
  createdByUserType?: "system" | "user" | null | undefined;
106
+ createdAtLocation?: (string & import("zod/v4").$brand<"UUID">) | null | undefined;
101
107
  createdBySignature?: string | null | undefined;
102
- createdAtLocation?: (string & import("zod").BRAND<"UUID">) | null | undefined;
108
+ updatedAtLocation?: (string & import("zod/v4").$brand<"UUID">) | null | undefined;
103
109
  assignedTo?: string | null | undefined;
104
- dateOfEvent?: string | null | undefined;
105
- updatedAtLocation?: (string & import("zod").BRAND<"UUID">) | null | undefined;
106
110
  updatedBy?: string | null | undefined;
107
111
  };
108
112
  /**