@opencrvs/toolkit 1.9.12-rc.b38f7ff → 1.9.12-rc.ba08187

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 +3163 -2251
  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 +888 -1941
  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 -1496
  15. package/dist/commons/events/AuditLog.d.ts +223 -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 +72 -107
  22. package/dist/commons/events/DynamicFieldValue.d.ts +7 -91
  23. package/dist/commons/events/EventConfig.d.ts +35 -2420
  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 +2673 -12516
  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 -243
  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 +33 -33
  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 +190 -172
  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 -310
  56. package/dist/commons/notification/UserNotifications.d.ts +55 -636
  57. package/dist/conditionals/index.d.ts.map +1 -1
  58. package/dist/conditionals/index.js +587 -14
  59. package/dist/events/deduplication.d.ts +3 -3
  60. package/dist/events/index.js +2701 -1891
  61. package/dist/notification/index.d.ts.map +1 -1
  62. package/dist/notification/index.js +1999 -1553
  63. package/dist/scopes/index.d.ts +352 -302
  64. package/dist/scopes/index.d.ts.map +1 -1
  65. package/dist/scopes/index.js +444 -210
  66. package/opencrvs-toolkit-1.9.12-rc.ba08187.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
@@ -1,5 +1,4 @@
1
- import { z } from 'zod';
2
- import { SearchScopeAccessLevels } from './events';
1
+ import * as z from 'zod/v4';
3
2
  export declare const SCOPES: {
4
3
  readonly BYPASSRATELIMIT: "bypassratelimit";
5
4
  readonly REGISTER: "register";
@@ -12,6 +11,7 @@ export declare const SCOPES: {
12
11
  readonly RECORD_IMPORT: "record.import";
13
12
  readonly RECORD_EXPORT: "record.export";
14
13
  readonly RECORD_REINDEX: "record.reindex";
14
+ readonly INTEGRATION_CREATE: "integration.create";
15
15
  readonly RECORD_DECLARE_BIRTH: "record.declare-birth";
16
16
  readonly RECORD_DECLARE_BIRTH_MY_JURISDICTION: "record.declare-birth:my-jurisdiction";
17
17
  readonly RECORD_DECLARE_DEATH: "record.declare-death";
@@ -61,325 +61,375 @@ export declare const SCOPES: {
61
61
  readonly USER_UPDATE_MY_JURISDICTION: "user.update:my-jurisdiction";
62
62
  readonly CONFIG_UPDATE_ALL: "config.update:all";
63
63
  readonly USER_DATA_SEEDING: "user.data-seeding";
64
+ readonly ATTACHMENT_UPLOAD: "attachment.upload";
64
65
  };
65
- export declare const SearchScopes: z.ZodUnion<[z.ZodLiteral<"search.birth:my-jurisdiction">, z.ZodLiteral<"search.birth">, z.ZodLiteral<"search.death:my-jurisdiction">, z.ZodLiteral<"search.death">, z.ZodLiteral<"search.marriage:my-jurisdiction">, z.ZodLiteral<"search.marriage">]>;
66
- declare const LiteralScopes: z.ZodUnion<[z.ZodUnion<[z.ZodLiteral<"bypassratelimit">, z.ZodLiteral<"register">, z.ZodLiteral<"demo">, z.ZodLiteral<"config">]>, z.ZodUnion<[z.ZodLiteral<"webhook">, z.ZodLiteral<"nationalId">, z.ZodLiteral<"notification-api">, z.ZodLiteral<"recordsearch">]>, z.ZodLiteral<"record.unassign-others">, z.ZodUnion<[z.ZodLiteral<"record.declare-birth">, z.ZodLiteral<"record.declare-birth:my-jurisdiction">, z.ZodLiteral<"record.declare-death">, z.ZodLiteral<"record.declare-death:my-jurisdiction">, z.ZodLiteral<"record.declare-marriage">, z.ZodLiteral<"record.declare-marriage:my-jurisdiction">, z.ZodLiteral<"record.declaration-submit-incomplete">, z.ZodLiteral<"record.declaration-submit-for-review">]>, z.ZodUnion<[z.ZodLiteral<"record.declaration-submit-for-approval">, z.ZodLiteral<"record.declaration-submit-for-updates">, z.ZodLiteral<"record.declaration-edit">, z.ZodLiteral<"record.review-duplicates">, z.ZodLiteral<"record.declaration-archive">, z.ZodLiteral<"record.declaration-reinstate">]>, z.ZodLiteral<"record.register">, z.ZodLiteral<"record.registration-print&issue-certified-copies">, z.ZodUnion<[z.ZodLiteral<"record.registration-request-correction">, z.ZodLiteral<"record.registration-correct">, z.ZodLiteral<"record.confirm-registration">, z.ZodLiteral<"record.reject-registration">]>, z.ZodUnion<[z.ZodLiteral<"search.birth:my-jurisdiction">, z.ZodLiteral<"search.birth">, z.ZodLiteral<"search.death:my-jurisdiction">, z.ZodLiteral<"search.death">, z.ZodLiteral<"search.marriage:my-jurisdiction">, z.ZodLiteral<"search.marriage">]>, z.ZodLiteral<"record.read">, z.ZodLiteral<"profile.electronic-signature">, z.ZodUnion<[z.ZodLiteral<"performance.read">, z.ZodLiteral<"performance.read-dashboards">, z.ZodLiteral<"performance.vital-statistics-export">]>, z.ZodUnion<[z.ZodLiteral<"organisation.read-locations:all">, z.ZodLiteral<"organisation.read-locations:my-office">, z.ZodLiteral<"organisation.read-locations:my-jurisdiction">]>, z.ZodUnion<[z.ZodLiteral<"user.read:all">, z.ZodLiteral<"user.read:my-office">, z.ZodLiteral<"user.read:my-jurisdiction">, z.ZodLiteral<"user.read:only-my-audit">, z.ZodLiteral<"user.create:all">, z.ZodLiteral<"user.create:my-jurisdiction">, z.ZodLiteral<"user.update:all">, z.ZodLiteral<"user.update:my-jurisdiction">]>, z.ZodLiteral<"config.update:all">, z.ZodLiteral<"user.data-seeding">, z.ZodUnion<[z.ZodLiteral<"record.reindex">, z.ZodLiteral<"record.import">]>]>;
67
- declare const SearchScope: z.ZodObject<{
68
- type: z.ZodLiteral<"search">;
69
- options: z.ZodObject<{
70
- event: z.ZodArray<z.ZodString, "many">;
71
- access: z.ZodArray<z.ZodEnum<["my-jurisdiction", "all"]>, "many">;
72
- }, "strip", z.ZodTypeAny, {
73
- event: string[];
74
- access: ("my-jurisdiction" | "all")[];
75
- }, {
76
- event: string[];
77
- access: ("my-jurisdiction" | "all")[];
78
- }>;
79
- }, "strip", z.ZodTypeAny, {
80
- type: "search";
81
- options: {
82
- event: string[];
83
- access: ("my-jurisdiction" | "all")[];
84
- };
85
- }, {
86
- type: "search";
87
- options: {
88
- event: string[];
89
- access: ("my-jurisdiction" | "all")[];
90
- };
66
+ /**
67
+ * @deprecated - will be removed in v2.1.
68
+ */
69
+ export declare function parseLiteralScope(scope: string): {
70
+ type: "bypassratelimit" | "register" | "demo" | "config" | "webhook" | "nationalId" | "notification-api" | "recordsearch" | "record.import" | "record.reindex" | "integration.create" | "record.registration-print&issue-certified-copies" | "profile.electronic-signature" | "performance.read" | "performance.read-dashboards" | "performance.vital-statistics-export" | "organisation.read-locations:all" | "organisation.read-locations:my-office" | "organisation.read-locations:my-jurisdiction" | "user.read:all" | "user.read:my-office" | "user.read:my-jurisdiction" | "user.read:only-my-audit" | "user.create:all" | "user.create:my-jurisdiction" | "user.update:all" | "user.update:my-jurisdiction" | "config.update:all" | "user.data-seeding" | "attachment.upload";
71
+ } | undefined;
72
+ export declare const JurisdictionFilter: z.ZodEnum<{
73
+ all: "all";
74
+ administrativeArea: "administrativeArea";
75
+ location: "location";
91
76
  }>;
92
- declare const PrintCertifiedCopiesScope: z.ZodObject<{
93
- type: z.ZodLiteral<"record.registered.print-certified-copies">;
94
- options: z.ZodObject<{
95
- event: z.ZodArray<z.ZodString, "many">;
96
- templates: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
97
- }, "strip", z.ZodTypeAny, {
98
- event: string[];
99
- templates?: string[] | undefined;
100
- }, {
101
- event: string[];
102
- templates?: string[] | undefined;
103
- }>;
104
- }, "strip", z.ZodTypeAny, {
105
- type: "record.registered.print-certified-copies";
106
- options: {
107
- event: string[];
108
- templates?: string[] | undefined;
109
- };
110
- }, {
111
- type: "record.registered.print-certified-copies";
112
- options: {
113
- event: string[];
114
- templates?: string[] | undefined;
115
- };
77
+ export type JurisdictionFilter = z.infer<typeof JurisdictionFilter>;
78
+ export declare const UserFilter: z.ZodEnum<{
79
+ user: "user";
116
80
  }>;
117
- export type SearchScope = z.infer<typeof SearchScope>;
118
- export type PrintCertifiedCopiesScope = z.infer<typeof PrintCertifiedCopiesScope>;
119
- export declare const RecordScopeType: z.ZodEnum<["record.create", "record.read", "record.declare", "record.notify", "record.declared.validate", "record.declared.reject", "record.declared.archive", "record.declared.review-duplicates", "record.register", "record.registered.request-correction", "record.registered.correct", "record.unassign-others"]>;
120
- export type RecordScopeType = z.infer<typeof RecordScopeType>;
121
- export declare const RecordScope: z.ZodObject<{
122
- type: z.ZodEnum<["record.create", "record.read", "record.declare", "record.notify", "record.declared.validate", "record.declared.reject", "record.declared.archive", "record.declared.review-duplicates", "record.register", "record.registered.request-correction", "record.registered.correct", "record.unassign-others"]>;
123
- options: z.ZodObject<{
124
- event: z.ZodArray<z.ZodString, "many">;
125
- }, "strip", z.ZodTypeAny, {
126
- event: string[];
127
- }, {
128
- event: string[];
129
- }>;
130
- }, "strip", z.ZodTypeAny, {
131
- type: "record.unassign-others" | "record.register" | "record.read" | "record.create" | "record.declare" | "record.notify" | "record.declared.validate" | "record.declared.reject" | "record.declared.archive" | "record.declared.review-duplicates" | "record.registered.request-correction" | "record.registered.correct";
132
- options: {
133
- event: string[];
134
- };
135
- }, {
136
- type: "record.unassign-others" | "record.register" | "record.read" | "record.create" | "record.declare" | "record.notify" | "record.declared.validate" | "record.declared.reject" | "record.declared.archive" | "record.declared.review-duplicates" | "record.registered.request-correction" | "record.registered.correct";
137
- options: {
138
- event: string[];
139
- };
81
+ export type UserFilter = z.infer<typeof UserFilter>;
82
+ /**
83
+ * The different types of scopes that can be used to control access to records. Each type has different options that can be used to further filter the records that the scope applies to.
84
+ * When adding new scope types, they should be added to the appropriate section based on the options they require.
85
+ *
86
+ * @see scopeOptionsPlaceEvent @see scopeOptionsDeclared @see scopeOptionsFull
87
+ */
88
+ export declare const RecordScopeTypeV2: z.ZodEnum<{
89
+ "record.create": "record.create";
90
+ "record.read": "record.read";
91
+ "record.declare": "record.declare";
92
+ "record.notify": "record.notify";
93
+ "record.register": "record.register";
94
+ "record.unassign-others": "record.unassign-others";
95
+ "record.review-duplicates": "record.review-duplicates";
96
+ "record.search": "record.search";
97
+ "record.edit": "record.edit";
98
+ "record.reject": "record.reject";
99
+ "record.archive": "record.archive";
100
+ "record.print-certified-copies": "record.print-certified-copies";
101
+ "record.request-correction": "record.request-correction";
102
+ "record.correct": "record.correct";
103
+ "record.custom-action": "record.custom-action";
104
+ }>;
105
+ export type RecordScopeTypeV2 = z.infer<typeof RecordScopeTypeV2>;
106
+ declare const ScopeOptionsFull: z.ZodObject<{
107
+ event: z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>;
108
+ placeOfEvent: z.ZodOptional<z.ZodEnum<{
109
+ all: "all";
110
+ administrativeArea: "administrativeArea";
111
+ location: "location";
112
+ }>>;
113
+ declaredIn: z.ZodOptional<z.ZodEnum<{
114
+ all: "all";
115
+ administrativeArea: "administrativeArea";
116
+ location: "location";
117
+ }>>;
118
+ declaredBy: z.ZodOptional<z.ZodEnum<{
119
+ user: "user";
120
+ }>>;
121
+ registeredIn: z.ZodOptional<z.ZodEnum<{
122
+ all: "all";
123
+ administrativeArea: "administrativeArea";
124
+ location: "location";
125
+ }>>;
126
+ registeredBy: z.ZodOptional<z.ZodEnum<{
127
+ user: "user";
128
+ }>>;
129
+ }, z.core.$strip>;
130
+ export type ScopeOptionsFull = z.infer<typeof ScopeOptionsFull>;
131
+ export declare const ScopeOptionKey: z.ZodEnum<{
132
+ event: "event";
133
+ placeOfEvent: "placeOfEvent";
134
+ declaredIn: "declaredIn";
135
+ declaredBy: "declaredBy";
136
+ registeredIn: "registeredIn";
137
+ registeredBy: "registeredBy";
138
+ }>;
139
+ export type ScopeOptionKey = z.infer<typeof ScopeOptionKey>;
140
+ export declare const ScopesWithPlaceEventOptions: z.ZodEnum<{
141
+ "record.create": "record.create";
142
+ "record.declare": "record.declare";
143
+ "record.notify": "record.notify";
140
144
  }>;
141
- export type RecordScope = z.infer<typeof RecordScope>;
142
- declare const ConfigurableRawScopes: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
143
- type: z.ZodLiteral<"search">;
144
- options: z.ZodObject<{
145
- event: z.ZodArray<z.ZodString, "many">;
146
- access: z.ZodArray<z.ZodEnum<["my-jurisdiction", "all"]>, "many">;
147
- }, "strip", z.ZodTypeAny, {
148
- event: string[];
149
- access: ("my-jurisdiction" | "all")[];
150
- }, {
151
- event: string[];
152
- access: ("my-jurisdiction" | "all")[];
145
+ export declare const ScopesWithDeclaredOptions: z.ZodEnum<{
146
+ "record.register": "record.register";
147
+ "record.review-duplicates": "record.review-duplicates";
148
+ "record.edit": "record.edit";
149
+ "record.reject": "record.reject";
150
+ "record.archive": "record.archive";
151
+ }>;
152
+ export declare const ScopesWithFullOptions: z.ZodEnum<{
153
+ "record.read": "record.read";
154
+ "record.unassign-others": "record.unassign-others";
155
+ "record.search": "record.search";
156
+ "record.request-correction": "record.request-correction";
157
+ "record.correct": "record.correct";
158
+ }>;
159
+ export declare const RecordScopeV2: z.ZodDiscriminatedUnion<[z.ZodObject<{
160
+ type: z.ZodEnum<{
161
+ "record.create": "record.create";
162
+ "record.declare": "record.declare";
163
+ "record.notify": "record.notify";
153
164
  }>;
154
- }, "strip", z.ZodTypeAny, {
155
- type: "search";
156
- options: {
157
- event: string[];
158
- access: ("my-jurisdiction" | "all")[];
159
- };
160
- }, {
161
- type: "search";
162
- options: {
163
- event: string[];
164
- access: ("my-jurisdiction" | "all")[];
165
- };
166
- }>, z.ZodObject<{
167
- type: z.ZodLiteral<"record.registered.print-certified-copies">;
168
- options: z.ZodObject<{
169
- event: z.ZodArray<z.ZodString, "many">;
170
- templates: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
171
- }, "strip", z.ZodTypeAny, {
172
- event: string[];
173
- templates?: string[] | undefined;
174
- }, {
175
- event: string[];
176
- templates?: string[] | undefined;
165
+ options: z.ZodOptional<z.ZodObject<{
166
+ event: z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>;
167
+ placeOfEvent: z.ZodOptional<z.ZodEnum<{
168
+ all: "all";
169
+ administrativeArea: "administrativeArea";
170
+ location: "location";
171
+ }>>;
172
+ }, z.core.$strip>>;
173
+ }, z.core.$strip>, z.ZodObject<{
174
+ type: z.ZodEnum<{
175
+ "record.register": "record.register";
176
+ "record.review-duplicates": "record.review-duplicates";
177
+ "record.edit": "record.edit";
178
+ "record.reject": "record.reject";
179
+ "record.archive": "record.archive";
177
180
  }>;
178
- }, "strip", z.ZodTypeAny, {
179
- type: "record.registered.print-certified-copies";
180
- options: {
181
- event: string[];
182
- templates?: string[] | undefined;
183
- };
184
- }, {
185
- type: "record.registered.print-certified-copies";
186
- options: {
187
- event: string[];
188
- templates?: string[] | undefined;
189
- };
190
- }>, z.ZodObject<{
191
- type: z.ZodLiteral<"user.create">;
192
- options: z.ZodObject<{
193
- role: z.ZodArray<z.ZodString, "many">;
194
- }, "strip", z.ZodTypeAny, {
195
- role: string[];
196
- }, {
197
- role: string[];
181
+ options: z.ZodOptional<z.ZodObject<{
182
+ event: z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>;
183
+ placeOfEvent: z.ZodOptional<z.ZodEnum<{
184
+ all: "all";
185
+ administrativeArea: "administrativeArea";
186
+ location: "location";
187
+ }>>;
188
+ declaredIn: z.ZodOptional<z.ZodEnum<{
189
+ all: "all";
190
+ administrativeArea: "administrativeArea";
191
+ location: "location";
192
+ }>>;
193
+ declaredBy: z.ZodOptional<z.ZodEnum<{
194
+ user: "user";
195
+ }>>;
196
+ }, z.core.$strip>>;
197
+ }, z.core.$strip>, z.ZodObject<{
198
+ type: z.ZodEnum<{
199
+ "record.read": "record.read";
200
+ "record.unassign-others": "record.unassign-others";
201
+ "record.search": "record.search";
202
+ "record.request-correction": "record.request-correction";
203
+ "record.correct": "record.correct";
198
204
  }>;
199
- }, "strip", z.ZodTypeAny, {
200
- type: "user.create";
201
- options: {
202
- role: string[];
203
- };
204
- }, {
205
- type: "user.create";
206
- options: {
207
- role: string[];
208
- };
209
- }>, z.ZodObject<{
210
- type: z.ZodLiteral<"user.edit">;
211
- options: z.ZodObject<{
212
- role: z.ZodArray<z.ZodString, "many">;
213
- }, "strip", z.ZodTypeAny, {
214
- role: string[];
215
- }, {
216
- role: string[];
205
+ options: z.ZodOptional<z.ZodObject<{
206
+ event: z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>;
207
+ placeOfEvent: z.ZodOptional<z.ZodEnum<{
208
+ all: "all";
209
+ administrativeArea: "administrativeArea";
210
+ location: "location";
211
+ }>>;
212
+ declaredIn: z.ZodOptional<z.ZodEnum<{
213
+ all: "all";
214
+ administrativeArea: "administrativeArea";
215
+ location: "location";
216
+ }>>;
217
+ declaredBy: z.ZodOptional<z.ZodEnum<{
218
+ user: "user";
219
+ }>>;
220
+ registeredIn: z.ZodOptional<z.ZodEnum<{
221
+ all: "all";
222
+ administrativeArea: "administrativeArea";
223
+ location: "location";
224
+ }>>;
225
+ registeredBy: z.ZodOptional<z.ZodEnum<{
226
+ user: "user";
227
+ }>>;
228
+ }, z.core.$strip>>;
229
+ }, z.core.$strip>, z.ZodObject<{
230
+ type: z.ZodLiteral<"record.custom-action">;
231
+ options: z.ZodOptional<z.ZodObject<{
232
+ event: z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>;
233
+ placeOfEvent: z.ZodOptional<z.ZodEnum<{
234
+ all: "all";
235
+ administrativeArea: "administrativeArea";
236
+ location: "location";
237
+ }>>;
238
+ declaredIn: z.ZodOptional<z.ZodEnum<{
239
+ all: "all";
240
+ administrativeArea: "administrativeArea";
241
+ location: "location";
242
+ }>>;
243
+ declaredBy: z.ZodOptional<z.ZodEnum<{
244
+ user: "user";
245
+ }>>;
246
+ registeredIn: z.ZodOptional<z.ZodEnum<{
247
+ all: "all";
248
+ administrativeArea: "administrativeArea";
249
+ location: "location";
250
+ }>>;
251
+ registeredBy: z.ZodOptional<z.ZodEnum<{
252
+ user: "user";
253
+ }>>;
254
+ customActionTypes: z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>;
255
+ }, z.core.$strip>>;
256
+ }, z.core.$strip>, z.ZodObject<{
257
+ type: z.ZodLiteral<"record.print-certified-copies">;
258
+ options: z.ZodOptional<z.ZodObject<{
259
+ event: z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>;
260
+ placeOfEvent: z.ZodOptional<z.ZodEnum<{
261
+ all: "all";
262
+ administrativeArea: "administrativeArea";
263
+ location: "location";
264
+ }>>;
265
+ declaredIn: z.ZodOptional<z.ZodEnum<{
266
+ all: "all";
267
+ administrativeArea: "administrativeArea";
268
+ location: "location";
269
+ }>>;
270
+ declaredBy: z.ZodOptional<z.ZodEnum<{
271
+ user: "user";
272
+ }>>;
273
+ registeredIn: z.ZodOptional<z.ZodEnum<{
274
+ all: "all";
275
+ administrativeArea: "administrativeArea";
276
+ location: "location";
277
+ }>>;
278
+ registeredBy: z.ZodOptional<z.ZodEnum<{
279
+ user: "user";
280
+ }>>;
281
+ templates: z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>;
282
+ }, z.core.$strip>>;
283
+ }, z.core.$strip>], "type">;
284
+ export declare function scopeUsesDeclaredOptions(scope: RecordScopeV2): scope is Extract<RecordScopeV2, {
285
+ type: z.infer<typeof ScopesWithDeclaredOptions>;
286
+ }>;
287
+ export declare function scopeUsesFullOptions(scope: RecordScopeV2): scope is Extract<RecordScopeV2, {
288
+ type: z.infer<typeof ScopesWithFullOptions>;
289
+ }>;
290
+ export declare function scopeUsesPrintCertifiedCopiesOptions(scope: RecordScopeV2): scope is Extract<RecordScopeV2, {
291
+ type: 'record.print-certified-copies';
292
+ }>;
293
+ export declare function isCustomActionScope(scope: RecordScopeV2): scope is Extract<RecordScopeV2, {
294
+ type: 'record.custom-action';
295
+ }>;
296
+ export declare const ResolvedRecordScopeV2: z.ZodDiscriminatedUnion<[z.ZodObject<{
297
+ type: z.ZodEnum<{
298
+ "record.create": "record.create";
299
+ "record.declare": "record.declare";
300
+ "record.notify": "record.notify";
217
301
  }>;
218
- }, "strip", z.ZodTypeAny, {
219
- type: "user.edit";
220
- options: {
221
- role: string[];
222
- };
223
- }, {
224
- type: "user.edit";
225
- options: {
226
- role: string[];
227
- };
228
- }>, z.ZodObject<{
229
- type: z.ZodLiteral<"workqueue">;
230
- options: z.ZodObject<{
231
- id: z.ZodArray<z.ZodString, "many">;
232
- }, "strip", z.ZodTypeAny, {
233
- id: string[];
234
- }, {
235
- id: string[];
302
+ options: z.ZodOptional<z.ZodObject<{
303
+ event: z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>;
304
+ placeOfEvent: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID">>>;
305
+ }, z.core.$strip>>;
306
+ }, z.core.$strip>, z.ZodObject<{
307
+ type: z.ZodEnum<{
308
+ "record.register": "record.register";
309
+ "record.review-duplicates": "record.review-duplicates";
310
+ "record.edit": "record.edit";
311
+ "record.reject": "record.reject";
312
+ "record.archive": "record.archive";
236
313
  }>;
237
- }, "strip", z.ZodTypeAny, {
238
- type: "workqueue";
239
- options: {
240
- id: string[];
241
- };
242
- }, {
243
- type: "workqueue";
244
- options: {
245
- id: string[];
246
- };
247
- }>, z.ZodObject<{
248
- type: z.ZodEnum<["record.create", "record.read", "record.declare", "record.notify", "record.declared.validate", "record.declared.reject", "record.declared.archive", "record.declared.review-duplicates", "record.register", "record.registered.request-correction", "record.registered.correct", "record.unassign-others"]>;
249
- options: z.ZodObject<{
250
- event: z.ZodArray<z.ZodString, "many">;
251
- }, "strip", z.ZodTypeAny, {
252
- event: string[];
253
- }, {
254
- event: string[];
314
+ options: z.ZodOptional<z.ZodObject<{
315
+ event: z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>;
316
+ placeOfEvent: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID">>>;
317
+ declaredIn: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID">>>;
318
+ declaredBy: z.ZodOptional<z.ZodString>;
319
+ }, z.core.$strip>>;
320
+ }, z.core.$strip>, z.ZodObject<{
321
+ type: z.ZodEnum<{
322
+ "record.read": "record.read";
323
+ "record.unassign-others": "record.unassign-others";
324
+ "record.search": "record.search";
325
+ "record.request-correction": "record.request-correction";
326
+ "record.correct": "record.correct";
255
327
  }>;
256
- }, "strip", z.ZodTypeAny, {
257
- type: "record.unassign-others" | "record.register" | "record.read" | "record.create" | "record.declare" | "record.notify" | "record.declared.validate" | "record.declared.reject" | "record.declared.archive" | "record.declared.review-duplicates" | "record.registered.request-correction" | "record.registered.correct";
258
- options: {
259
- event: string[];
260
- };
261
- }, {
262
- type: "record.unassign-others" | "record.register" | "record.read" | "record.create" | "record.declare" | "record.notify" | "record.declared.validate" | "record.declared.reject" | "record.declared.archive" | "record.declared.review-duplicates" | "record.registered.request-correction" | "record.registered.correct";
263
- options: {
264
- event: string[];
265
- };
266
- }>]>;
267
- type ConfigurableRawScopes = z.infer<typeof ConfigurableRawScopes>;
268
- export type ConfigurableScopeType = ConfigurableRawScopes['type'];
269
- type FlattenedSearchScope = {
270
- type: 'search';
271
- options: Record<string, SearchScopeAccessLevels>;
272
- };
273
- export type ConfigurableScopes = Exclude<ConfigurableRawScopes, {
274
- type: 'search';
275
- }> | FlattenedSearchScope;
276
- export declare function findScope<T extends ConfigurableScopeType>(scopes: string[], scopeType: T): Extract<{
277
- type: "record.registered.print-certified-copies";
278
- options: {
279
- event: string[];
280
- templates?: string[] | undefined;
281
- };
282
- }, {
283
- type: T;
284
- }> | Extract<{
285
- type: "user.create";
286
- options: {
287
- role: string[];
288
- };
289
- }, {
290
- type: T;
291
- }> | Extract<{
292
- type: "user.edit";
293
- options: {
294
- role: string[];
295
- };
296
- }, {
297
- type: T;
298
- }> | Extract<{
299
- type: "workqueue";
300
- options: {
301
- id: string[];
302
- };
303
- }, {
304
- type: T;
305
- }> | Extract<{
306
- type: "record.unassign-others" | "record.register" | "record.read" | "record.create" | "record.declare" | "record.notify" | "record.declared.validate" | "record.declared.reject" | "record.declared.archive" | "record.declared.review-duplicates" | "record.registered.request-correction" | "record.registered.correct";
307
- options: {
308
- event: string[];
309
- };
310
- }, {
311
- type: T;
312
- }> | Extract<FlattenedSearchScope, {
313
- type: T;
314
- }> | undefined;
315
- /**
316
- * Parses a configurable scope string into a ConfigurableRawScopes object.
317
- * @param {string} scope - The scope string to parse
318
- * @returns {ConfigurableRawScopes | undefined} The parsed scope object if valid, undefined otherwise
319
- * @example
320
- * parseScope("user.create[role=field-agent|registration-agent]")
321
- * // Returns: { type: "user.create", options: { role: ["field-agent", "registration-agent"] } }
322
- */
323
- export declare function parseConfigurableScope(scope: string): {
324
- type: "record.registered.print-certified-copies";
325
- options: {
326
- event: string[];
327
- templates?: string[] | undefined;
328
- };
329
- } | {
330
- type: "search";
331
- options: {
332
- event: string[];
333
- access: ("my-jurisdiction" | "all")[];
334
- };
328
+ options: z.ZodOptional<z.ZodObject<{
329
+ event: z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>;
330
+ placeOfEvent: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID">>>;
331
+ declaredIn: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID">>>;
332
+ declaredBy: z.ZodOptional<z.ZodString>;
333
+ registeredIn: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID">>>;
334
+ registeredBy: z.ZodOptional<z.ZodString>;
335
+ }, z.core.$strip>>;
336
+ }, z.core.$strip>, z.ZodObject<{
337
+ type: z.ZodLiteral<"record.print-certified-copies">;
338
+ options: z.ZodOptional<z.ZodObject<{
339
+ event: z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>;
340
+ placeOfEvent: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID">>>;
341
+ declaredIn: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID">>>;
342
+ declaredBy: z.ZodOptional<z.ZodString>;
343
+ registeredIn: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID">>>;
344
+ registeredBy: z.ZodOptional<z.ZodString>;
345
+ templates: z.ZodOptional<z.ZodArray<z.ZodString>>;
346
+ }, z.core.$strip>>;
347
+ }, z.core.$strip>], "type">;
348
+ export type RecordScopeV2 = z.infer<typeof RecordScopeV2>;
349
+ export type ResolvedRecordScopeV2 = z.infer<typeof ResolvedRecordScopeV2>;
350
+ export declare const encodeScope: (scope: RecordScopeV2) => string;
351
+ export declare const decodeScope: (query: string) => {
352
+ type: "record.create" | "record.declare" | "record.notify";
353
+ options?: {
354
+ event?: string[] | undefined;
355
+ placeOfEvent?: "all" | "administrativeArea" | "location" | undefined;
356
+ } | undefined;
335
357
  } | {
336
- type: "user.create";
337
- options: {
338
- role: string[];
339
- };
358
+ type: "record.register" | "record.review-duplicates" | "record.edit" | "record.reject" | "record.archive";
359
+ options?: {
360
+ event?: string[] | undefined;
361
+ placeOfEvent?: "all" | "administrativeArea" | "location" | undefined;
362
+ declaredIn?: "all" | "administrativeArea" | "location" | undefined;
363
+ declaredBy?: "user" | undefined;
364
+ } | undefined;
340
365
  } | {
341
- type: "user.edit";
342
- options: {
343
- role: string[];
344
- };
366
+ type: "record.read" | "record.unassign-others" | "record.search" | "record.request-correction" | "record.correct";
367
+ options?: {
368
+ event?: string[] | undefined;
369
+ placeOfEvent?: "all" | "administrativeArea" | "location" | undefined;
370
+ declaredIn?: "all" | "administrativeArea" | "location" | undefined;
371
+ declaredBy?: "user" | undefined;
372
+ registeredIn?: "all" | "administrativeArea" | "location" | undefined;
373
+ registeredBy?: "user" | undefined;
374
+ } | undefined;
345
375
  } | {
346
- type: "workqueue";
347
- options: {
348
- id: string[];
349
- };
376
+ type: "record.custom-action";
377
+ options?: {
378
+ event?: string[] | undefined;
379
+ placeOfEvent?: "all" | "administrativeArea" | "location" | undefined;
380
+ declaredIn?: "all" | "administrativeArea" | "location" | undefined;
381
+ declaredBy?: "user" | undefined;
382
+ registeredIn?: "all" | "administrativeArea" | "location" | undefined;
383
+ registeredBy?: "user" | undefined;
384
+ customActionTypes?: string[] | undefined;
385
+ } | undefined;
350
386
  } | {
351
- type: "record.unassign-others" | "record.register" | "record.read" | "record.create" | "record.declare" | "record.notify" | "record.declared.validate" | "record.declared.reject" | "record.declared.archive" | "record.declared.review-duplicates" | "record.registered.request-correction" | "record.registered.correct";
352
- options: {
353
- event: string[];
354
- };
355
- } | undefined;
356
- export declare function parseLiteralScope(scope: string): {
357
- type: "bypassratelimit" | "register" | "demo" | "config" | "webhook" | "nationalId" | "notification-api" | "recordsearch" | "record.import" | "record.reindex" | "record.declare-birth" | "record.declare-birth:my-jurisdiction" | "record.declare-death" | "record.declare-death:my-jurisdiction" | "record.declare-marriage" | "record.declare-marriage:my-jurisdiction" | "record.declaration-submit-incomplete" | "record.declaration-submit-for-review" | "record.unassign-others" | "record.declaration-submit-for-approval" | "record.declaration-submit-for-updates" | "record.declaration-edit" | "record.review-duplicates" | "record.declaration-archive" | "record.declaration-reinstate" | "record.register" | "record.registration-print&issue-certified-copies" | "record.registration-request-correction" | "record.registration-correct" | "record.confirm-registration" | "record.reject-registration" | "search.birth:my-jurisdiction" | "search.birth" | "search.death:my-jurisdiction" | "search.death" | "search.marriage:my-jurisdiction" | "search.marriage" | "record.read" | "profile.electronic-signature" | "performance.read" | "performance.read-dashboards" | "performance.vital-statistics-export" | "organisation.read-locations:all" | "organisation.read-locations:my-office" | "organisation.read-locations:my-jurisdiction" | "user.read:all" | "user.read:my-office" | "user.read:my-jurisdiction" | "user.read:only-my-audit" | "user.create:all" | "user.create:my-jurisdiction" | "user.update:all" | "user.update:my-jurisdiction" | "config.update:all" | "user.data-seeding";
387
+ type: "record.print-certified-copies";
388
+ options?: {
389
+ event?: string[] | undefined;
390
+ placeOfEvent?: "all" | "administrativeArea" | "location" | undefined;
391
+ declaredIn?: "all" | "administrativeArea" | "location" | undefined;
392
+ declaredBy?: "user" | undefined;
393
+ registeredIn?: "all" | "administrativeArea" | "location" | undefined;
394
+ registeredBy?: "user" | undefined;
395
+ templates?: string[] | undefined;
396
+ } | undefined;
358
397
  } | undefined;
359
398
  /**
360
- * Stringifies a ConfigurableScopes object into a scope string.
361
- * @param {ConfigurableScopes} scope - The scope object to stringify
362
- * @returns {string} The stringified scope in format "type[key1=value1|value2,key2=value3|value4]"
363
- * @example
364
- * stringifyScope({
365
- * type: "record.notify",
366
- * options: { event: ["birth", "tennis-club-membership"] }
367
- * })
368
- * // Returns: "record.notify[event=birth|tennis-club-membership]"
399
+ * Function to get the value of a scope option (aka. scope attribute)
400
+ *
401
+ * @param scope - The scope to get the value of the option from.
402
+ * @param option - The option to get the value of.
403
+ * @returns The value of the scope option. Will return the default value if the option is not set.
404
+ */
405
+ export declare function getScopeOptionValue<T extends ScopeOptionKey>(scope: RecordScopeV2, option: T): ScopeOptionsFull[T] | undefined;
406
+ /**
407
+ * Converts a V1 scope string to a V2 compatible scope string. Used to migrate between 1.9 and 2.0 scopes.
408
+ * @deprecated - This will be removed after migration to V2 scopes is complete. Do not use for new development.
409
+ *
410
+ * NOTE: We are casting intentionally broad with the input and output types to allow for flexibility during migration, without forcing loose types on the rest of the codebase.
411
+ *
412
+ * @param v1Scope e.g. 'record.declared.reject[event=birth|death|tennis-club-membership]',
413
+ * @returns corresponding V2 compatible scope string based on v1 input.
369
414
  */
370
- export declare function stringifyScope(scope: z.infer<typeof ConfigurableRawScopes>): string;
415
+ export declare const v1ScopeToV2Scope: (v1Scope: string) => string;
416
+ export declare function getAcceptedScopesByType({ acceptedScopes, scopes }: {
417
+ acceptedScopes: RecordScopeTypeV2[];
418
+ scopes: string[];
419
+ }): RecordScopeV2[];
420
+ export declare function canUserCreateEvent(acceptedScopes: RecordScopeV2[], eventType: string): boolean;
371
421
  /**
372
- * Extracts authorized event identifiers (e.g. birth, death) from the provided configurable scopes.
422
+ * Helper for defining scopes for user roles.
423
+ * @param scopes Array of scopes in object format.
373
424
  *
374
- * @param scopes - Array of configurable scopes with options
375
- * @returns Array of authorized event identifiers
425
+ * @returns Array of scopes in string format, encoded for use in JWT tokens.
426
+ */
427
+ export declare function defineScopes(scopes: RecordScopeV2[]): string[];
428
+ /**
429
+ * Helper for porting v1 scopes to v2. Intended to be used in the interim during migration, not for new development.
430
+ * @param scopes v1 scopes
431
+ * @returns array of v2 compatible scopes, filtering out the old ones not used anymore.
376
432
  */
377
- export declare function getAuthorizedEventsFromScopes(scopes: ConfigurableScopes[]): string[];
378
- export declare const scopes: Scope[];
379
- export type ParsedScopes = NonNullable<ReturnType<typeof parseConfigurableScope>>;
380
- export type RawScopes = z.infer<typeof LiteralScopes> | (string & {});
381
- export type Scope = RawScopes;
382
- export declare const ActionScopes: z.ZodUnion<[z.ZodUnion<[z.ZodLiteral<"record.declare-birth">, z.ZodLiteral<"record.declare-birth:my-jurisdiction">, z.ZodLiteral<"record.declare-death">, z.ZodLiteral<"record.declare-death:my-jurisdiction">, z.ZodLiteral<"record.declare-marriage">, z.ZodLiteral<"record.declare-marriage:my-jurisdiction">, z.ZodLiteral<"record.declaration-submit-incomplete">, z.ZodLiteral<"record.declaration-submit-for-review">]>, z.ZodUnion<[z.ZodLiteral<"record.declaration-submit-for-approval">, z.ZodLiteral<"record.declaration-submit-for-updates">, z.ZodLiteral<"record.declaration-edit">, z.ZodLiteral<"record.review-duplicates">, z.ZodLiteral<"record.declaration-archive">, z.ZodLiteral<"record.declaration-reinstate">]>, z.ZodLiteral<"record.register">, z.ZodLiteral<"record.registration-print&issue-certified-copies">, z.ZodUnion<[z.ZodLiteral<"record.registration-request-correction">, z.ZodLiteral<"record.registration-correct">, z.ZodLiteral<"record.confirm-registration">, z.ZodLiteral<"record.reject-registration">]>]>;
383
- export type ActionScopes = z.infer<typeof ActionScopes>;
433
+ export declare function migrateV1ScopesToV2(scopes: string[]): string[];
384
434
  export {};
385
435
  //# sourceMappingURL=scopes.d.ts.map