@opencrvs/toolkit 1.9.6 → 1.9.7-rc.03e4d07

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 (59) hide show
  1. package/dist/commons/api/router.d.ts +29431 -2353
  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 +25043 -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 +29 -190
  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 +1195 -4223
  13. package/dist/commons/events/DeduplicationConfig.d.ts +18 -150
  14. package/dist/commons/events/Draft.d.ts +70 -105
  15. package/dist/commons/events/DynamicFieldValue.d.ts +7 -91
  16. package/dist/commons/events/EventConfig.d.ts +19988 -2120
  17. package/dist/commons/events/EventConfigInput.d.ts +1 -1
  18. package/dist/commons/events/EventDocument.d.ts +320 -1332
  19. package/dist/commons/events/EventIndex.d.ts +193 -980
  20. package/dist/commons/events/EventInput.d.ts +3 -8
  21. package/dist/commons/events/EventMetadata.d.ts +106 -347
  22. package/dist/commons/events/FieldConfig.d.ts +4545 -12303
  23. package/dist/commons/events/FieldType.d.ts +20 -4
  24. package/dist/commons/events/FieldTypeMapping.d.ts +193 -897
  25. package/dist/commons/events/FieldValue.d.ts +87 -396
  26. package/dist/commons/events/Flag.d.ts +67 -0
  27. package/dist/commons/events/FormConfig.d.ts +14022 -721
  28. package/dist/commons/events/PageConfig.d.ts +9368 -319
  29. package/dist/commons/events/SummaryConfig.d.ts +14 -161
  30. package/dist/commons/events/TemplateConfig.d.ts +2 -3
  31. package/dist/commons/events/TranslationConfig.d.ts +2 -2
  32. package/dist/commons/events/WorkqueueColumnConfig.d.ts +74 -37
  33. package/dist/commons/events/WorkqueueConfig.d.ts +1865 -7177
  34. package/dist/commons/events/deduplication.d.ts +40 -3
  35. package/dist/commons/events/defineConfig.d.ts +26571 -147
  36. package/dist/commons/events/eventConfigValidation.d.ts +8 -0
  37. package/dist/commons/events/index.d.ts +1 -0
  38. package/dist/commons/events/locations.d.ts +26 -19
  39. package/dist/commons/events/scopes.d.ts +5 -4
  40. package/dist/commons/events/state/availableActions.d.ts +0 -2
  41. package/dist/commons/events/state/flags.d.ts +21 -3
  42. package/dist/commons/events/state/index.d.ts +22 -19
  43. package/dist/commons/events/state/utils.d.ts +130 -112
  44. package/dist/commons/events/test.utils.d.ts +31 -8
  45. package/dist/commons/events/transactions.d.ts +1 -1
  46. package/dist/commons/events/utils.d.ts +53180 -367
  47. package/dist/commons/notification/UserNotifications.d.ts +55 -636
  48. package/dist/conditionals/index.d.ts.map +1 -1
  49. package/dist/conditionals/index.js +45 -11
  50. package/dist/events/deduplication.d.ts +40 -3
  51. package/dist/events/deduplication.js +34 -0
  52. package/dist/events/index.js +2077 -1714
  53. package/dist/notification/index.d.ts.map +1 -1
  54. package/dist/notification/index.js +1677 -1558
  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
  59. package/dist/commons/events/CreatedAtLocation.d.ts +0 -2
@@ -0,0 +1,8 @@
1
+ import * as z from 'zod/v4';
2
+ import { EventConfig } from './EventConfig';
3
+ export declare function validateAdvancedSearchConfig(event: EventConfig, ctx: z.RefinementCtx<EventConfig>): void;
4
+ export declare function validateDateOfEvent(event: EventConfig, ctx: z.RefinementCtx<EventConfig>): void;
5
+ export declare function validatePlaceOfEvent(event: EventConfig, ctx: z.RefinementCtx<EventConfig>): void;
6
+ export declare function validateActionFlags(event: EventConfig, ctx: z.RefinementCtx<EventConfig>): void;
7
+ export declare function validateActionOrder(event: EventConfig, ctx: z.RefinementCtx<EventConfig>): void;
8
+ //# sourceMappingURL=eventConfigValidation.d.ts.map
@@ -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,31 @@
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
+ /** @deprecated */
3
+ export declare const LocationTypeV1: z.ZodEnum<{
4
+ ADMIN_STRUCTURE: "ADMIN_STRUCTURE";
5
+ HEALTH_FACILITY: "HEALTH_FACILITY";
6
+ CRVS_OFFICE: "CRVS_OFFICE";
7
+ }>;
8
+ export type LocationTypeV1 = z.infer<typeof LocationTypeV1>;
9
+ export declare const LocationType: z.ZodEnum<{
10
+ HEALTH_FACILITY: "HEALTH_FACILITY";
11
+ CRVS_OFFICE: "CRVS_OFFICE";
12
+ }>;
3
13
  export type LocationType = z.infer<typeof LocationType>;
14
+ export declare const AdministrativeArea: z.ZodObject<{
15
+ id: z.core.$ZodBranded<z.ZodUUID, "UUID">;
16
+ name: z.ZodString;
17
+ externalId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
18
+ parentId: z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID">>;
19
+ validUntil: z.ZodNullable<z.ZodISODateTime>;
20
+ }, z.core.$strip>;
21
+ export type AdministrativeArea = z.infer<typeof AdministrativeArea>;
4
22
  export declare const Location: z.ZodObject<{
5
- id: z.ZodBranded<z.ZodString, "UUID">;
23
+ id: z.core.$ZodBranded<z.ZodUUID, "UUID">;
6
24
  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
- }>;
25
+ externalId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
26
+ administrativeAreaId: z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID">>;
27
+ validUntil: z.ZodNullable<z.ZodISODateTime>;
28
+ locationType: z.ZodNullable<z.ZodString>;
29
+ }, z.core.$strip>;
23
30
  export type Location = z.infer<typeof Location>;
24
31
  //# 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,4 @@
1
1
  import { DisplayableAction } from '../ActionType';
2
2
  import { EventIndex } from '../EventIndex';
3
- import { EventStatus, Flag } from '../EventMetadata';
4
- export declare function getAvailableActions(status: EventStatus, flags: Flag[]): DisplayableAction[];
5
3
  export declare function getAvailableActionsForEvent(event: EventIndex): DisplayableAction[];
6
4
  //# 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,6 +28,10 @@ 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,9 +42,7 @@ export declare function extractPotentialDuplicatesFromActions(actions: Action[])
38
42
  * @returns Calculates a snapshot summary of the event based on the actions taken on it.
39
43
  * @see EventIndex for the description of the returned object.
40
44
  */
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;
45
+ export declare function getCurrentEventState(event: EventDocument, config: EventConfig): EventIndex;
44
46
  /**
45
47
  * @returns the future state of the event with drafts applied to all fields.
46
48
  *
@@ -62,47 +64,48 @@ export declare function applyDeclarationToEventIndex(eventIndex: EventIndex, dec
62
64
  *
63
65
  */
64
66
  export declare function applyDraftToEventIndex(eventIndex: EventIndex, draft: Draft, eventConfiguration: EventConfig): {
67
+ id: string & import("zod").$brand<"UUID">;
65
68
  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;
69
+ status: "ARCHIVED" | "DECLARED" | "REGISTERED" | "CREATED" | "NOTIFIED";
73
70
  legalStatuses: {
74
71
  DECLARED?: {
75
72
  createdAt: string;
76
73
  createdBy: string;
77
- createdByRole: string;
78
74
  acceptedAt: string;
75
+ createdByRole: string;
76
+ createdAtLocation?: (string & import("zod").$brand<"UUID">) | null | undefined;
79
77
  createdByUserType?: "system" | "user" | null | undefined;
80
78
  createdBySignature?: string | null | undefined;
81
- createdAtLocation?: (string & import("zod").BRAND<"UUID">) | null | undefined;
82
79
  } | null | undefined;
83
80
  REGISTERED?: {
84
81
  createdAt: string;
85
82
  createdBy: string;
83
+ acceptedAt: string;
86
84
  createdByRole: string;
87
85
  registrationNumber: string;
88
- acceptedAt: string;
86
+ createdAtLocation?: (string & import("zod").$brand<"UUID">) | null | undefined;
89
87
  createdByUserType?: "system" | "user" | null | undefined;
90
88
  createdBySignature?: string | null | undefined;
91
- createdAtLocation?: (string & import("zod").BRAND<"UUID">) | null | undefined;
92
89
  } | null | undefined;
93
90
  };
91
+ createdAt: string;
92
+ createdBy: string;
94
93
  updatedByUserRole: string;
94
+ updatedAt: string;
95
+ trackingId: string;
95
96
  potentialDuplicates: {
96
- id: string & import("zod").BRAND<"UUID">;
97
+ id: string & import("zod").$brand<"UUID">;
97
98
  trackingId: string;
98
99
  }[];
99
100
  flags: string[];
101
+ declaration: Record<string, import("..").FieldValue>;
102
+ dateOfEvent?: string | null | undefined;
103
+ placeOfEvent?: (string & import("zod").$brand<"UUID">) | null | undefined;
100
104
  createdByUserType?: "system" | "user" | null | undefined;
105
+ createdAtLocation?: (string & import("zod").$brand<"UUID">) | null | undefined;
101
106
  createdBySignature?: string | null | undefined;
102
- createdAtLocation?: (string & import("zod").BRAND<"UUID">) | null | undefined;
107
+ updatedAtLocation?: (string & import("zod").$brand<"UUID">) | null | undefined;
103
108
  assignedTo?: string | null | undefined;
104
- dateOfEvent?: string | null | undefined;
105
- updatedAtLocation?: (string & import("zod").BRAND<"UUID">) | null | undefined;
106
109
  updatedBy?: string | null | undefined;
107
110
  };
108
111
  /**