@opencrvs/toolkit 1.9.12-rc.fd4afc3 → 1.9.12-rc.fdea6df

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 (70) hide show
  1. package/build.sh +5 -0
  2. package/dist/api/index.d.ts.map +1 -1
  3. package/dist/application-config/index.d.ts +2 -0
  4. package/dist/application-config/index.d.ts.map +1 -0
  5. package/dist/application-config/index.js +124 -0
  6. package/dist/commons/api/router.d.ts +3369 -2255
  7. package/dist/commons/application-config/index.d.ts +87 -0
  8. package/dist/commons/conditionals/conditionals.d.ts +27 -3
  9. package/dist/commons/conditionals/validate.d.ts +13 -2
  10. package/dist/commons/events/ActionConfig.d.ts +415 -1555
  11. package/dist/commons/events/ActionDocument.d.ts +889 -1942
  12. package/dist/commons/events/ActionInput.d.ts +277 -1073
  13. package/dist/commons/events/ActionType.d.ts +91 -11
  14. package/dist/commons/events/AdvancedSearchConfig.d.ts +288 -1238
  15. package/dist/commons/events/AuditLog.d.ts +405 -0
  16. package/dist/commons/events/CompositeFieldValue.d.ts +30 -190
  17. package/dist/commons/events/Conditional.d.ts +26 -38
  18. package/dist/commons/events/Constants.d.ts +1 -1
  19. package/dist/commons/events/CountryConfigQueryInput.d.ts +1345 -4495
  20. package/dist/commons/events/DeduplicationConfig.d.ts +15 -171
  21. package/dist/commons/events/Draft.d.ts +73 -108
  22. package/dist/commons/events/DynamicFieldValue.d.ts +7 -91
  23. package/dist/commons/events/EventConfig.d.ts +35 -2250
  24. package/dist/commons/events/EventConfigInput.d.ts +0 -3
  25. package/dist/commons/events/EventDocument.d.ts +354 -1366
  26. package/dist/commons/events/EventIndex.d.ts +208 -1014
  27. package/dist/commons/events/EventInput.d.ts +3 -8
  28. package/dist/commons/events/EventMetadata.d.ts +130 -357
  29. package/dist/commons/events/FieldConfig.d.ts +2779 -12544
  30. package/dist/commons/events/FieldType.d.ts +25 -4
  31. package/dist/commons/events/FieldTypeMapping.d.ts +289 -907
  32. package/dist/commons/events/FieldValue.d.ts +121 -527
  33. package/dist/commons/events/FileUtils.d.ts +2 -2
  34. package/dist/commons/events/Flag.d.ts +67 -0
  35. package/dist/commons/events/FormConfig.d.ts +54 -721
  36. package/dist/commons/events/PageConfig.d.ts +58 -320
  37. package/dist/commons/events/PlainDate.d.ts +1 -1
  38. package/dist/commons/events/SummaryConfig.d.ts +14 -161
  39. package/dist/commons/events/TemplateConfig.d.ts +2 -3
  40. package/dist/commons/events/TranslationConfig.d.ts +2 -2
  41. package/dist/commons/events/WorkqueueColumnConfig.d.ts +74 -37
  42. package/dist/commons/events/WorkqueueConfig.d.ts +2008 -7597
  43. package/dist/commons/events/deduplication.d.ts +3 -3
  44. package/dist/commons/events/defineConfig.d.ts +2 -229
  45. package/dist/commons/events/eventConfigValidation.d.ts +8 -0
  46. package/dist/commons/events/index.d.ts +3 -0
  47. package/dist/commons/events/locations.d.ts +57 -20
  48. package/dist/commons/events/scopes.d.ts +35 -34
  49. package/dist/commons/events/state/availableActions.d.ts +7 -2
  50. package/dist/commons/events/state/flags.d.ts +21 -3
  51. package/dist/commons/events/state/index.d.ts +30 -27
  52. package/dist/commons/events/state/utils.d.ts +191 -173
  53. package/dist/commons/events/test.utils.d.ts +52 -11
  54. package/dist/commons/events/transactions.d.ts +1 -1
  55. package/dist/commons/events/utils.d.ts +413 -296
  56. package/dist/commons/notification/UserNotifications.d.ts +61 -637
  57. package/dist/conditionals/index.d.ts.map +1 -1
  58. package/dist/conditionals/index.js +294 -14
  59. package/dist/events/deduplication.d.ts +3 -3
  60. package/dist/events/index.js +2736 -2119
  61. package/dist/notification/index.d.ts.map +1 -1
  62. package/dist/notification/index.js +2031 -1783
  63. package/dist/scopes/index.d.ts +623 -357
  64. package/dist/scopes/index.d.ts.map +1 -1
  65. package/dist/scopes/index.js +329 -301
  66. package/opencrvs-toolkit-1.9.12-rc.fdea6df.tgz +0 -0
  67. package/package.json +11 -5
  68. package/tsconfig.json +9 -2
  69. package/tsconfig.tsbuildinfo +1 -1
  70. package/dist/commons/events/CreatedAtLocation.d.ts +0 -2
@@ -7,17 +7,17 @@ export declare function field(fieldId: string): {
7
7
  fieldId: string;
8
8
  type: "fuzzy";
9
9
  options: {
10
+ fuzziness?: string | number | undefined;
10
11
  boost?: number | undefined;
11
12
  matchAgainst?: string | undefined;
12
- fuzziness?: string | number | undefined;
13
13
  } | undefined;
14
14
  };
15
15
  strictMatches: (options?: StrictMatcherOptions) => {
16
16
  fieldId: string;
17
17
  type: "strict";
18
18
  options: {
19
- value?: string | undefined;
20
19
  boost?: number | undefined;
20
+ value?: string | undefined;
21
21
  matchAgainst?: string | undefined;
22
22
  } | undefined;
23
23
  };
@@ -60,9 +60,9 @@ export declare function field(fieldId: string): {
60
60
  type: "dateRange";
61
61
  options: {
62
62
  days: number;
63
+ pivot?: number | undefined;
63
64
  boost?: number | undefined;
64
65
  matchAgainst?: string | undefined;
65
- pivot?: number | undefined;
66
66
  };
67
67
  };
68
68
  };
@@ -1,234 +1,7 @@
1
- import { EventConfigInput } from './EventConfigInput';
1
+ import { EventConfig, EventConfigInput } from './EventConfig';
2
2
  /**
3
3
  * Builds a validated configuration for an event
4
4
  * @param config - Event specific configuration
5
5
  */
6
- export declare const defineConfig: (config: EventConfigInput) => {
7
- id: string;
8
- title: import("./TranslationConfig").TranslationConfig;
9
- declaration: {
10
- label: import("./TranslationConfig").TranslationConfig;
11
- pages: {
12
- type: "FORM";
13
- id: string;
14
- title: import("./TranslationConfig").TranslationConfig;
15
- fields: import("./FieldConfig").FieldConfig[];
16
- requireCompletionToContinue: boolean;
17
- conditional?: import(".").JSONSchema | undefined;
18
- }[];
19
- };
20
- actions: ({
21
- type: "READ";
22
- label: import("./TranslationConfig").TranslationConfig;
23
- review: {
24
- title: import("./TranslationConfig").TranslationConfig;
25
- fields: import("./FieldConfig").FieldConfig[];
26
- };
27
- } | {
28
- type: "DECLARE";
29
- label: import("./TranslationConfig").TranslationConfig;
30
- review: {
31
- title: import("./TranslationConfig").TranslationConfig;
32
- fields: import("./FieldConfig").FieldConfig[];
33
- };
34
- deduplication?: {
35
- id: string;
36
- query: import("./DeduplicationConfig").ClauseOutput;
37
- label: import("./TranslationConfig").TranslationConfig;
38
- } | undefined;
39
- } | {
40
- type: "VALIDATE";
41
- label: import("./TranslationConfig").TranslationConfig;
42
- review: {
43
- title: import("./TranslationConfig").TranslationConfig;
44
- fields: import("./FieldConfig").FieldConfig[];
45
- };
46
- deduplication?: {
47
- id: string;
48
- query: import("./DeduplicationConfig").ClauseOutput;
49
- label: import("./TranslationConfig").TranslationConfig;
50
- } | undefined;
51
- } | {
52
- type: "REJECT";
53
- label: import("./TranslationConfig").TranslationConfig;
54
- } | {
55
- type: "ARCHIVE";
56
- label: import("./TranslationConfig").TranslationConfig;
57
- } | {
58
- type: "REGISTER";
59
- label: import("./TranslationConfig").TranslationConfig;
60
- review: {
61
- title: import("./TranslationConfig").TranslationConfig;
62
- fields: import("./FieldConfig").FieldConfig[];
63
- };
64
- deduplication?: {
65
- id: string;
66
- query: import("./DeduplicationConfig").ClauseOutput;
67
- label: import("./TranslationConfig").TranslationConfig;
68
- } | undefined;
69
- } | {
70
- type: "DELETE";
71
- label: import("./TranslationConfig").TranslationConfig;
72
- } | {
73
- type: "PRINT_CERTIFICATE";
74
- label: import("./TranslationConfig").TranslationConfig;
75
- printForm: {
76
- label: import("./TranslationConfig").TranslationConfig;
77
- pages: ({
78
- type: "FORM";
79
- id: string;
80
- title: import("./TranslationConfig").TranslationConfig;
81
- fields: import("./FieldConfig").FieldConfig[];
82
- requireCompletionToContinue: boolean;
83
- conditional?: import(".").JSONSchema | undefined;
84
- } | {
85
- type: "VERIFICATION";
86
- id: string;
87
- title: import("./TranslationConfig").TranslationConfig;
88
- actions: {
89
- cancel: {
90
- label: import("./TranslationConfig").TranslationConfig;
91
- confirmation: {
92
- title: import("./TranslationConfig").TranslationConfig;
93
- body: import("./TranslationConfig").TranslationConfig;
94
- };
95
- };
96
- verify: {
97
- label: import("./TranslationConfig").TranslationConfig;
98
- };
99
- };
100
- fields: import("./FieldConfig").FieldConfig[];
101
- requireCompletionToContinue: boolean;
102
- conditional?: import(".").JSONSchema | undefined;
103
- })[];
104
- };
105
- } | {
106
- type: "REQUEST_CORRECTION";
107
- label: import("./TranslationConfig").TranslationConfig;
108
- correctionForm: {
109
- label: import("./TranslationConfig").TranslationConfig;
110
- pages: ({
111
- type: "FORM";
112
- id: string;
113
- title: import("./TranslationConfig").TranslationConfig;
114
- fields: import("./FieldConfig").FieldConfig[];
115
- requireCompletionToContinue: boolean;
116
- conditional?: import(".").JSONSchema | undefined;
117
- } | {
118
- type: "VERIFICATION";
119
- id: string;
120
- title: import("./TranslationConfig").TranslationConfig;
121
- actions: {
122
- cancel: {
123
- label: import("./TranslationConfig").TranslationConfig;
124
- confirmation: {
125
- title: import("./TranslationConfig").TranslationConfig;
126
- body: import("./TranslationConfig").TranslationConfig;
127
- };
128
- };
129
- verify: {
130
- label: import("./TranslationConfig").TranslationConfig;
131
- };
132
- };
133
- fields: import("./FieldConfig").FieldConfig[];
134
- requireCompletionToContinue: boolean;
135
- conditional?: import(".").JSONSchema | undefined;
136
- })[];
137
- };
138
- } | {
139
- type: "REJECT_CORRECTION";
140
- label: import("./TranslationConfig").TranslationConfig;
141
- } | {
142
- type: "APPROVE_CORRECTION";
143
- label: import("./TranslationConfig").TranslationConfig;
144
- })[];
145
- label: import("./TranslationConfig").TranslationConfig;
146
- summary: {
147
- fields: ({
148
- fieldId: string;
149
- label?: import("./TranslationConfig").TranslationConfig | undefined;
150
- conditionals?: {
151
- type: "SHOW";
152
- conditional: import(".").JSONSchema;
153
- }[] | undefined;
154
- emptyValueMessage?: import("./TranslationConfig").TranslationConfig | undefined;
155
- } | {
156
- id: string;
157
- value: import("./TranslationConfig").TranslationConfig;
158
- label: import("./TranslationConfig").TranslationConfig;
159
- conditionals?: {
160
- type: "SHOW";
161
- conditional: import(".").JSONSchema;
162
- }[] | undefined;
163
- emptyValueMessage?: import("./TranslationConfig").TranslationConfig | undefined;
164
- })[];
165
- };
166
- advancedSearch: {
167
- title: import("./TranslationConfig").TranslationConfig;
168
- fields: ({
169
- config: {
170
- type: "exact" | "fuzzy" | "range" | "within";
171
- searchFields?: string[] | undefined;
172
- };
173
- fieldId: string;
174
- fieldType: "field";
175
- type?: "NAME" | "PHONE" | "ID" | "ADDRESS" | "TEXT" | "NUMBER" | "NUMBER_WITH_UNIT" | "TEXTAREA" | "EMAIL" | "DATE" | "AGE" | "DATE_RANGE" | "SELECT_DATE_RANGE" | "TIME" | "PARAGRAPH" | "PAGE_HEADER" | "RADIO_GROUP" | "FIELD_GROUP" | "FILE" | "FILE_WITH_OPTIONS" | "BULLET_LIST" | "CHECKBOX" | "SELECT" | "COUNTRY" | "LOCATION" | "DIVIDER" | "ADMINISTRATIVE_AREA" | "FACILITY" | "OFFICE" | "SIGNATURE" | "DATA" | "BUTTON" | "SEARCH" | "ALPHA_PRINT_BUTTON" | "HTTP" | "LINK_BUTTON" | "VERIFICATION_STATUS" | "QUERY_PARAM_READER" | "QR_READER" | "ID_READER" | "LOADER" | undefined;
176
- options?: {
177
- value: string;
178
- label: string | import("./TranslationConfig").TranslationConfig;
179
- }[] | undefined;
180
- label?: import("./TranslationConfig").TranslationConfig | undefined;
181
- conditionals?: ({
182
- type: "SHOW";
183
- conditional: import(".").JSONSchema;
184
- } | {
185
- type: "ENABLE";
186
- conditional: import(".").JSONSchema;
187
- } | {
188
- type: "DISPLAY_ON_REVIEW";
189
- conditional: import(".").JSONSchema;
190
- })[] | undefined;
191
- searchCriteriaLabelPrefix?: import("./TranslationConfig").TranslationConfig | undefined;
192
- validations?: {
193
- message: import("./TranslationConfig").TranslationConfig;
194
- validator: import(".").JSONSchema;
195
- }[] | undefined;
196
- } | {
197
- config: {
198
- type: "exact" | "fuzzy" | "range" | "within";
199
- searchFields?: string[] | undefined;
200
- };
201
- fieldId: "event.status" | "event.trackingId" | "event.updatedAt" | "event.legalStatuses.REGISTERED.acceptedAt" | "event.legalStatuses.REGISTERED.createdAtLocation" | "event.legalStatuses.REGISTERED.registrationNumber";
202
- fieldType: "event";
203
- type?: "NAME" | "PHONE" | "ID" | "ADDRESS" | "TEXT" | "NUMBER" | "NUMBER_WITH_UNIT" | "TEXTAREA" | "EMAIL" | "DATE" | "AGE" | "DATE_RANGE" | "SELECT_DATE_RANGE" | "TIME" | "PARAGRAPH" | "PAGE_HEADER" | "RADIO_GROUP" | "FIELD_GROUP" | "FILE" | "FILE_WITH_OPTIONS" | "BULLET_LIST" | "CHECKBOX" | "SELECT" | "COUNTRY" | "LOCATION" | "DIVIDER" | "ADMINISTRATIVE_AREA" | "FACILITY" | "OFFICE" | "SIGNATURE" | "DATA" | "BUTTON" | "SEARCH" | "ALPHA_PRINT_BUTTON" | "HTTP" | "LINK_BUTTON" | "VERIFICATION_STATUS" | "QUERY_PARAM_READER" | "QR_READER" | "ID_READER" | "LOADER" | undefined;
204
- options?: {
205
- value: string;
206
- label: string | import("./TranslationConfig").TranslationConfig;
207
- }[] | undefined;
208
- label?: import("./TranslationConfig").TranslationConfig | undefined;
209
- conditionals?: ({
210
- type: "SHOW";
211
- conditional: import(".").JSONSchema;
212
- } | {
213
- type: "ENABLE";
214
- conditional: import(".").JSONSchema;
215
- } | {
216
- type: "DISPLAY_ON_REVIEW";
217
- conditional: import(".").JSONSchema;
218
- })[] | undefined;
219
- searchCriteriaLabelPrefix?: import("./TranslationConfig").TranslationConfig | undefined;
220
- validations?: {
221
- message: import("./TranslationConfig").TranslationConfig;
222
- validator: import(".").JSONSchema;
223
- }[] | undefined;
224
- })[];
225
- }[];
226
- dateOfEvent?: {
227
- $$field: string;
228
- $$subfield: string[];
229
- } | {
230
- $$event: "createdAt" | "updatedAt" | "legalStatuses.DECLARED.createdAt" | "legalStatuses.DECLARED.acceptedAt" | "legalStatuses.REGISTERED.createdAt" | "legalStatuses.REGISTERED.acceptedAt";
231
- } | undefined;
232
- fallbackTitle?: import("./TranslationConfig").TranslationConfig | undefined;
233
- };
6
+ export declare const defineConfig: (config: EventConfigInput) => EventConfig;
234
7
  //# sourceMappingURL=defineConfig.d.ts.map
@@ -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
@@ -1,3 +1,4 @@
1
+ export * from './AuditLog';
1
2
  export * from './Constants';
2
3
  export * from './ActionConfig';
3
4
  export * from './offline';
@@ -39,7 +40,9 @@ export * from './FileUtils';
39
40
  export * from '../conditionals/conditionals';
40
41
  export * from '../conditionals/validate';
41
42
  export * from './field';
43
+ export * from './Flag';
42
44
  export * from './event';
43
45
  export * from './locations';
44
46
  export { UUID } from '../uuid';
47
+ export { DocumentPath } from '../documents';
45
48
  //# sourceMappingURL=index.d.ts.map
@@ -1,24 +1,61 @@
1
- import { z } from 'zod';
2
- export declare const LocationType: z.ZodEnum<["ADMIN_STRUCTURE", "CRVS_OFFICE", "HEALTH_FACILITY"]>;
3
- export type LocationType = z.infer<typeof LocationType>;
1
+ import * as z from 'zod/v4';
2
+ import { EventIndex } from './EventIndex';
3
+ import { ActionCreationMetadata, RegistrationCreationMetadata } from './EventMetadata';
4
+ import { RecordScopeV2 } from '../scopes';
5
+ import { SystemContext, UserContext } from '../users/User';
6
+ /** @deprecated Moving on, location types are arbitrary and defined by the country config. */
7
+ export declare const LocationTypeV1: z.ZodEnum<{
8
+ ADMIN_STRUCTURE: "ADMIN_STRUCTURE";
9
+ HEALTH_FACILITY: "HEALTH_FACILITY";
10
+ CRVS_OFFICE: "CRVS_OFFICE";
11
+ }>;
12
+ export type LocationTypeV1 = z.infer<typeof LocationTypeV1>;
13
+ export declare const AdministrativeArea: z.ZodObject<{
14
+ id: z.core.$ZodBranded<z.ZodUUID, "UUID">;
15
+ name: z.ZodString;
16
+ externalId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
17
+ parentId: z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID">>;
18
+ validUntil: z.ZodNullable<z.ZodISODateTime>;
19
+ }, z.core.$strip>;
20
+ export type AdministrativeArea = z.infer<typeof AdministrativeArea>;
4
21
  export declare const Location: z.ZodObject<{
5
- id: z.ZodBranded<z.ZodString, "UUID">;
22
+ id: z.core.$ZodBranded<z.ZodUUID, "UUID">;
6
23
  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
- }>;
24
+ externalId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
25
+ administrativeAreaId: z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID">>;
26
+ validUntil: z.ZodNullable<z.ZodISODateTime>;
27
+ locationType: z.ZodNullable<z.ZodString>;
28
+ }, z.core.$strip>;
23
29
  export type Location = z.infer<typeof Location>;
30
+ type WrapArrayPreserveNullish<V> = V extends readonly any[] ? V : NonNullable<V>[] | Extract<V, null | undefined>;
31
+ /**
32
+ * For type T, convert fields K to arrays. If field is string, convert to string[].
33
+ */
34
+ type ToArrayFields<T, K extends PropertyKey> = T extends unknown ? T extends object ? {
35
+ [P in keyof T]: P extends K ? WrapArrayPreserveNullish<T[P]> : T[P];
36
+ } : T : never;
37
+ /**
38
+ * Event index type where all location fields are arrays representing full location hierarchy.
39
+ */
40
+ export type EventIndexWithAdministrativeHierarchy = Omit<ToArrayFields<EventIndex, 'createdAtLocation' | 'updatedAtLocation' | 'placeOfEvent'>, 'legalStatuses'> & {
41
+ legalStatuses: {
42
+ DECLARED: ToArrayFields<ActionCreationMetadata, 'createdAtLocation'> | undefined;
43
+ REGISTERED: ToArrayFields<RegistrationCreationMetadata, 'createdAtLocation'> | undefined;
44
+ };
45
+ };
46
+ /**
47
+ * Given indexed event and resolved scope, determine if the scope allows access to the event.
48
+ *
49
+ * All of the options within the scope must be satisfied for access to be granted.
50
+ * Return false early to break out of checks as soon as possible - if any option is not satisfied, the scope does not allow access to the event, so no need to check further options.
51
+ *
52
+ */
53
+ export declare function canAccessEventWithScope(event: Partial<EventIndexWithAdministrativeHierarchy>, scope: RecordScopeV2, user: UserContext | SystemContext, customActionType?: string): boolean;
54
+ /**
55
+ * Given indexed event and list of resolved scopes, determine if any of the scopes allow access to the event.
56
+ *
57
+ * One of the scopes must allow access for the event to be accessible.
58
+ */
59
+ export declare function userCanAccessEventWithScopes(event: Partial<EventIndexWithAdministrativeHierarchy>, scopes: RecordScopeV2[], user: UserContext | SystemContext, customActionType?: string): boolean;
60
+ export {};
24
61
  //# sourceMappingURL=locations.d.ts.map
@@ -1,55 +1,56 @@
1
- import { ConfigurableScopeType, Scope } from '../scopes';
2
1
  import { DisplayableAction } from './ActionType';
2
+ import { EncodedScope } from '../scopes';
3
+ import { EventIndexWithAdministrativeHierarchy } from './locations';
4
+ import { UserContext } from '../users/User';
3
5
  import { EventIndex } from './EventIndex';
4
6
  export declare const ACTION_SCOPE_MAP: {
5
7
  READ: "record.read"[];
6
8
  CREATE: "record.create"[];
7
9
  NOTIFY: "record.notify"[];
8
- DECLARE: ("record.register" | "record.declare" | "record.declared.validate")[];
10
+ DECLARE: ("record.declare" | "record.register")[];
11
+ EDIT: "record.edit"[];
9
12
  DELETE: "record.declare"[];
10
- VALIDATE: ("record.register" | "record.declared.validate")[];
11
13
  REGISTER: "record.register"[];
12
- PRINT_CERTIFICATE: "record.registered.print-certified-copies"[];
13
- REQUEST_CORRECTION: ("record.registered.request-correction" | "record.registered.correct")[];
14
- REVIEW_CORRECTION_REQUEST: "record.registered.correct"[];
15
- REJECT_CORRECTION: "record.registered.correct"[];
16
- APPROVE_CORRECTION: "record.registered.correct"[];
17
- MARK_AS_DUPLICATE: "record.declared.review-duplicates"[];
18
- MARK_AS_NOT_DUPLICATE: "record.declared.review-duplicates"[];
19
- ARCHIVE: "record.declared.archive"[];
20
- REJECT: "record.declared.reject"[];
14
+ PRINT_CERTIFICATE: "record.print-certified-copies"[];
15
+ REQUEST_CORRECTION: ("record.request-correction" | "record.correct")[];
16
+ REVIEW_CORRECTION_REQUEST: "record.correct"[];
17
+ REJECT_CORRECTION: "record.correct"[];
18
+ APPROVE_CORRECTION: "record.correct"[];
19
+ MARK_AS_DUPLICATE: "record.review-duplicates"[];
20
+ MARK_AS_NOT_DUPLICATE: "record.review-duplicates"[];
21
+ ARCHIVE: "record.archive"[];
22
+ REJECT: "record.reject"[];
21
23
  ASSIGN: null;
22
24
  UNASSIGN: null;
23
25
  DUPLICATE_DETECTED: never[];
26
+ CUSTOM: never[];
24
27
  };
25
- export declare function hasAnyOfScopes(a: Scope[], b: Scope[]): boolean;
26
- export declare function configurableEventScopeAllowed(scopes: Scope[], allowedConfigurableScopes: ConfigurableScopeType[], eventType: string): boolean;
28
+ export declare function hasAnyOfScopes(a: string[], b: string[]): boolean;
29
+ export declare const AssignmentStatus: {
30
+ readonly ASSIGNED_TO_SELF: "ASSIGNED_TO_SELF";
31
+ readonly ASSIGNED_TO_OTHERS: "ASSIGNED_TO_OTHERS";
32
+ readonly UNASSIGNED: "UNASSIGNED";
33
+ };
34
+ export type AssignmentStatus = (typeof AssignmentStatus)[keyof typeof AssignmentStatus];
35
+ export declare function getAssignmentStatus(eventState: EventIndex | EventIndexWithAdministrativeHierarchy, userId: string): AssignmentStatus;
27
36
  /**
28
- * Checks if a given action is allowed for the provided scopes and event type.
37
+ * Checks if a given action is allowed for the provided scopes, event, and user context.
29
38
  *
30
39
  * This function determines whether the user, with the given set of scopes, is authorized
31
- * to perform the specified action on an event of the given type. It checks both "plain" scopes
32
- * (hardcoded, non-configurable) and "configurable" scopes (which may be tied to specific event types).
40
+ * to perform the specified action on the given event. It checks both legacy V1 scopes
41
+ * (hardcoded, non-configurable) and V2 scopes, which validate event type, jurisdiction,
42
+ * and user context via {@link userCanAccessEventWithScopes}.
33
43
  *
34
- * @param {Scope[]} scopes - The list of scopes the user possesses.
44
+ * @param {EncodedScope[]} scopes - The raw encoded scope strings the user possesses (from JWT).
35
45
  * @param {DisplayableAction} action - The action to check authorization for.
36
- * @param {string} eventType - The type of event for which the action is being checked.
46
+ * @param {EventIndexWithAdministrativeHierarchy} event - The event with resolved administrative hierarchy.
47
+ * @param {UserContext} currentUser - The current user's context used for V2 scope validation.
37
48
  * @returns {boolean} True if the action is in scope for the user, otherwise false.
38
49
  */
39
- export declare function isActionInScope(scopes: Scope[], action: DisplayableAction, eventType: string): boolean;
40
- /**
41
- * A shared utility to check if the user can read a record.
42
- * This will be removed in 1.10 and implemented by scopes.
43
- *
44
- * In order for us to limit the usage of 'record.read' scope, we allow users to view records they have created on system-level.
45
- *
46
- * @deprecated - Will be removed in 1.10
47
- */
48
- export declare function canUserReadEvent(event: EventIndex | {
49
- createdBy: string;
50
- type: string;
51
- }, { userId, scopes }: {
52
- userId: string;
53
- scopes: string[];
50
+ export declare function isActionInScope({ scopes, action, event, currentUser }: {
51
+ scopes: EncodedScope[];
52
+ action: DisplayableAction;
53
+ event: EventIndexWithAdministrativeHierarchy;
54
+ currentUser: UserContext;
54
55
  }): boolean;
55
56
  //# sourceMappingURL=scopes.d.ts.map
@@ -1,6 +1,11 @@
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[];
3
+ import { Flag } from '../Flag';
4
+ /**
5
+ * Filters actions based on flags
6
+ * Some actions can be performed only if certain flags are
7
+ * present and others only if certain flags are absent
8
+ */
9
+ export declare function filterActionsByFlags(actions: DisplayableAction[], flags: Flag[]): DisplayableAction[];
5
10
  export declare function getAvailableActionsForEvent(event: EventIndex): DisplayableAction[];
6
11
  //# 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
@@ -6,13 +6,13 @@ 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>): "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[]] ? {
14
14
  [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 ? {
15
+ } : T extends UUID ? T : T extends DocumentPath ? T : T extends string ? NonNullable<T> : T extends (infer U)[] ? NonNullableDeep<U>[] : T extends object ? {
16
16
  [K in keyof T]: NonNullableDeep<NonNullable<T[K]>>;
17
17
  } : NonNullable<T>;
18
18
  /**
@@ -26,6 +26,10 @@ export declare function deepDropNulls<T>(obj: T): NonNullableDeep<T>;
26
26
  export declare function isUndeclaredDraft(status: EventStatus): boolean;
27
27
  export declare const DEFAULT_DATE_OF_EVENT_PROPERTY = "createdAt";
28
28
  export declare function resolveDateOfEvent(eventIndex: EventIndex, declaration: EventState, config: EventConfig): string | undefined;
29
+ export declare const DEFAULT_PLACE_OF_EVENT_PROPERTY = "createdAtLocation";
30
+ export declare function resolvePlaceOfEvent(eventMetadata: {
31
+ createdAtLocation?: UUID | undefined | null;
32
+ }, declaration: EventState, config: EventConfig): UUID | undefined | null;
29
33
  export declare function extractPotentialDuplicatesFromActions(actions: Action[]): PotentialDuplicate[];
30
34
  /**
31
35
  * 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 +40,7 @@ export declare function extractPotentialDuplicatesFromActions(actions: Action[])
36
40
  * @returns Calculates a snapshot summary of the event based on the actions taken on it.
37
41
  * @see EventIndex for the description of the returned object.
38
42
  */
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;
43
+ export declare function getCurrentEventState(event: EventDocument, config: EventConfig): EventIndex;
42
44
  /**
43
45
  * @returns the future state of the event with drafts applied to all fields.
44
46
  *
@@ -60,47 +62,48 @@ export declare function applyDeclarationToEventIndex(eventIndex: EventIndex, dec
60
62
  *
61
63
  */
62
64
  export declare function applyDraftToEventIndex(eventIndex: EventIndex, draft: Draft, eventConfiguration: EventConfig): {
65
+ id: string & import("zod").$brand<"UUID">;
63
66
  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;
67
+ status: "ARCHIVED" | "DECLARED" | "REGISTERED" | "CREATED" | "NOTIFIED";
71
68
  legalStatuses: {
72
69
  DECLARED?: {
73
70
  createdAt: string;
74
71
  createdBy: string;
75
- createdByRole: string;
76
72
  acceptedAt: string;
77
- createdByUserType?: "system" | "user" | null | undefined;
73
+ createdAtLocation?: (string & import("zod").$brand<"UUID">) | null | undefined;
74
+ createdByUserType?: "user" | "system" | null | undefined;
75
+ createdByRole?: string | undefined;
78
76
  createdBySignature?: string | null | undefined;
79
- createdAtLocation?: (string & import("zod").BRAND<"UUID">) | null | undefined;
80
77
  } | null | undefined;
81
78
  REGISTERED?: {
82
79
  createdAt: string;
83
80
  createdBy: string;
84
- createdByRole: string;
85
- registrationNumber: string;
86
81
  acceptedAt: string;
87
- createdByUserType?: "system" | "user" | null | undefined;
82
+ registrationNumber: string;
83
+ createdAtLocation?: (string & import("zod").$brand<"UUID">) | null | undefined;
84
+ createdByUserType?: "user" | "system" | null | undefined;
85
+ createdByRole?: string | undefined;
88
86
  createdBySignature?: string | null | undefined;
89
- createdAtLocation?: (string & import("zod").BRAND<"UUID">) | null | undefined;
90
87
  } | null | undefined;
91
88
  };
92
- updatedByUserRole: string;
89
+ createdAt: string;
90
+ createdBy: string;
91
+ updatedAt: string;
92
+ trackingId: string;
93
93
  potentialDuplicates: {
94
- id: string & import("zod").BRAND<"UUID">;
94
+ id: string & import("zod").$brand<"UUID">;
95
95
  trackingId: string;
96
96
  }[];
97
97
  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;
98
+ declaration: Record<string, import("..").FieldValue>;
102
99
  dateOfEvent?: string | null | undefined;
103
- updatedAtLocation?: (string & import("zod").BRAND<"UUID">) | null | undefined;
100
+ placeOfEvent?: (string & import("zod").$brand<"UUID">) | null | undefined;
101
+ createdByUserType?: "user" | "system" | null | undefined;
102
+ updatedByUserRole?: string | null | undefined;
103
+ createdAtLocation?: (string & import("zod").$brand<"UUID">) | null | undefined;
104
+ createdBySignature?: (string & import("zod").$brand<"DocumentPath">) | null | undefined;
105
+ updatedAtLocation?: (string & import("zod").$brand<"UUID">) | null | undefined;
106
+ assignedTo?: string | null | undefined;
104
107
  updatedBy?: string | null | undefined;
105
108
  };
106
109
  /**