@opencrvs/toolkit 1.9.12-rc.c1b103f → 1.9.12-rc.cb552bd

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 (73) hide show
  1. package/build.sh +9 -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/cli.d.ts +2 -0
  7. package/dist/cli.d.ts.map +1 -0
  8. package/dist/cli.js +64 -0
  9. package/dist/commons/api/router.d.ts +3369 -2269
  10. package/dist/commons/application-config/index.d.ts +87 -0
  11. package/dist/commons/conditionals/conditionals.d.ts +27 -3
  12. package/dist/commons/conditionals/validate.d.ts +13 -2
  13. package/dist/commons/events/ActionConfig.d.ts +415 -1555
  14. package/dist/commons/events/ActionDocument.d.ts +889 -1942
  15. package/dist/commons/events/ActionInput.d.ts +277 -1073
  16. package/dist/commons/events/ActionType.d.ts +91 -11
  17. package/dist/commons/events/AdvancedSearchConfig.d.ts +288 -1496
  18. package/dist/commons/events/AuditLog.d.ts +405 -0
  19. package/dist/commons/events/CompositeFieldValue.d.ts +30 -190
  20. package/dist/commons/events/Conditional.d.ts +26 -38
  21. package/dist/commons/events/Constants.d.ts +1 -1
  22. package/dist/commons/events/CountryConfigQueryInput.d.ts +1345 -4495
  23. package/dist/commons/events/DeduplicationConfig.d.ts +15 -171
  24. package/dist/commons/events/Draft.d.ts +73 -108
  25. package/dist/commons/events/DynamicFieldValue.d.ts +7 -91
  26. package/dist/commons/events/EventConfig.d.ts +35 -2420
  27. package/dist/commons/events/EventConfigInput.d.ts +0 -3
  28. package/dist/commons/events/EventDocument.d.ts +354 -1366
  29. package/dist/commons/events/EventIndex.d.ts +208 -1014
  30. package/dist/commons/events/EventInput.d.ts +3 -8
  31. package/dist/commons/events/EventMetadata.d.ts +130 -357
  32. package/dist/commons/events/FieldConfig.d.ts +2779 -12470
  33. package/dist/commons/events/FieldType.d.ts +25 -4
  34. package/dist/commons/events/FieldTypeMapping.d.ts +289 -907
  35. package/dist/commons/events/FieldValue.d.ts +121 -527
  36. package/dist/commons/events/FileUtils.d.ts +2 -2
  37. package/dist/commons/events/Flag.d.ts +67 -0
  38. package/dist/commons/events/FormConfig.d.ts +54 -721
  39. package/dist/commons/events/PageConfig.d.ts +58 -320
  40. package/dist/commons/events/PlainDate.d.ts +1 -1
  41. package/dist/commons/events/SummaryConfig.d.ts +14 -161
  42. package/dist/commons/events/TemplateConfig.d.ts +2 -3
  43. package/dist/commons/events/TranslationConfig.d.ts +2 -2
  44. package/dist/commons/events/WorkqueueColumnConfig.d.ts +74 -37
  45. package/dist/commons/events/WorkqueueConfig.d.ts +2008 -7597
  46. package/dist/commons/events/deduplication.d.ts +3 -3
  47. package/dist/commons/events/defineConfig.d.ts +2 -243
  48. package/dist/commons/events/eventConfigValidation.d.ts +8 -0
  49. package/dist/commons/events/index.d.ts +3 -0
  50. package/dist/commons/events/locations.d.ts +57 -20
  51. package/dist/commons/events/scopes.d.ts +35 -34
  52. package/dist/commons/events/state/availableActions.d.ts +7 -2
  53. package/dist/commons/events/state/flags.d.ts +21 -3
  54. package/dist/commons/events/state/index.d.ts +30 -27
  55. package/dist/commons/events/state/utils.d.ts +191 -173
  56. package/dist/commons/events/test.utils.d.ts +52 -11
  57. package/dist/commons/events/transactions.d.ts +1 -1
  58. package/dist/commons/events/utils.d.ts +413 -310
  59. package/dist/commons/notification/UserNotifications.d.ts +61 -637
  60. package/dist/conditionals/index.d.ts.map +1 -1
  61. package/dist/conditionals/index.js +294 -14
  62. package/dist/events/deduplication.d.ts +3 -3
  63. package/dist/events/index.js +2736 -2099
  64. package/dist/notification/index.d.ts.map +1 -1
  65. package/dist/notification/index.js +2031 -1763
  66. package/dist/scopes/index.d.ts +623 -357
  67. package/dist/scopes/index.d.ts.map +1 -1
  68. package/dist/scopes/index.js +329 -301
  69. package/opencrvs-toolkit-1.9.12-rc.cb552bd.tgz +0 -0
  70. package/package.json +14 -5
  71. package/tsconfig.json +9 -2
  72. package/tsconfig.tsbuildinfo +1 -1
  73. package/dist/commons/events/CreatedAtLocation.d.ts +0 -2
@@ -1,385 +1,651 @@
1
- import { z } from 'zod';
2
- import { SearchScopeAccessLevels } from './events';
3
- export declare const SCOPES: {
4
- readonly BYPASSRATELIMIT: "bypassratelimit";
5
- readonly REGISTER: "register";
6
- readonly DEMO: "demo";
7
- readonly CONFIG: "config";
8
- readonly WEBHOOK: "webhook";
9
- readonly NATIONALID: "nationalId";
10
- readonly NOTIFICATION_API: "notification-api";
11
- readonly RECORDSEARCH: "recordsearch";
12
- readonly RECORD_IMPORT: "record.import";
13
- readonly RECORD_EXPORT: "record.export";
14
- readonly RECORD_REINDEX: "record.reindex";
15
- readonly RECORD_DECLARE_BIRTH: "record.declare-birth";
16
- readonly RECORD_DECLARE_BIRTH_MY_JURISDICTION: "record.declare-birth:my-jurisdiction";
17
- readonly RECORD_DECLARE_DEATH: "record.declare-death";
18
- readonly RECORD_DECLARE_DEATH_MY_JURISDICTION: "record.declare-death:my-jurisdiction";
19
- readonly RECORD_DECLARE_MARRIAGE: "record.declare-marriage";
20
- readonly RECORD_DECLARE_MARRIAGE_MY_JURISDICTION: "record.declare-marriage:my-jurisdiction";
21
- readonly RECORD_SUBMIT_INCOMPLETE: "record.declaration-submit-incomplete";
22
- readonly RECORD_SUBMIT_FOR_REVIEW: "record.declaration-submit-for-review";
23
- readonly RECORD_UNASSIGN_OTHERS: "record.unassign-others";
24
- readonly RECORD_SUBMIT_FOR_APPROVAL: "record.declaration-submit-for-approval";
25
- readonly RECORD_SUBMIT_FOR_UPDATES: "record.declaration-submit-for-updates";
26
- readonly RECORD_DECLARATION_EDIT: "record.declaration-edit";
27
- readonly RECORD_REVIEW_DUPLICATES: "record.review-duplicates";
28
- readonly RECORD_DECLARATION_ARCHIVE: "record.declaration-archive";
29
- readonly RECORD_DECLARATION_REINSTATE: "record.declaration-reinstate";
30
- readonly RECORD_REGISTER: "record.register";
31
- /**
32
- * This scope is used to **print and **issue certified copies of a record
33
- * after it has been registered. Previously Registrars had this permission.
34
- */
35
- readonly RECORD_PRINT_ISSUE_CERTIFIED_COPIES: "record.registration-print&issue-certified-copies";
36
- readonly RECORD_REGISTRATION_REQUEST_CORRECTION: "record.registration-request-correction";
37
- readonly RECORD_REGISTRATION_CORRECT: "record.registration-correct";
38
- readonly RECORD_CONFIRM_REGISTRATION: "record.confirm-registration";
39
- readonly RECORD_REJECT_REGISTRATION: "record.reject-registration";
40
- readonly SEARCH_BIRTH_MY_JURISDICTION: "search.birth:my-jurisdiction";
41
- readonly SEARCH_BIRTH: "search.birth";
42
- readonly SEARCH_DEATH_MY_JURISDICTION: "search.death:my-jurisdiction";
43
- readonly SEARCH_DEATH: "search.death";
44
- readonly SEARCH_MARRIAGE_MY_JURISDICTION: "search.marriage:my-jurisdiction";
45
- readonly SEARCH_MARRIAGE: "search.marriage";
46
- readonly RECORD_READ: "record.read";
47
- readonly PROFILE_ELECTRONIC_SIGNATURE: "profile.electronic-signature";
48
- readonly PERFORMANCE_READ: "performance.read";
49
- readonly PERFORMANCE_READ_DASHBOARDS: "performance.read-dashboards";
50
- readonly PERFORMANCE_EXPORT_VITAL_STATISTICS: "performance.vital-statistics-export";
51
- readonly ORGANISATION_READ_LOCATIONS: "organisation.read-locations:all";
52
- readonly ORGANISATION_READ_LOCATIONS_MY_OFFICE: "organisation.read-locations:my-office";
53
- readonly ORGANISATION_READ_LOCATIONS_MY_JURISDICTION: "organisation.read-locations:my-jurisdiction";
54
- readonly USER_READ: "user.read:all";
55
- readonly USER_READ_MY_OFFICE: "user.read:my-office";
56
- readonly USER_READ_MY_JURISDICTION: "user.read:my-jurisdiction";
57
- readonly USER_READ_ONLY_MY_AUDIT: "user.read:only-my-audit";
58
- readonly USER_CREATE: "user.create:all";
59
- readonly USER_CREATE_MY_JURISDICTION: "user.create:my-jurisdiction";
60
- readonly USER_UPDATE: "user.update:all";
61
- readonly USER_UPDATE_MY_JURISDICTION: "user.update:my-jurisdiction";
62
- readonly CONFIG_UPDATE_ALL: "config.update:all";
63
- readonly USER_DATA_SEEDING: "user.data-seeding";
64
- };
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
- };
1
+ import * as z from 'zod/v4';
2
+ export declare const JurisdictionFilter: z.ZodEnum<{
3
+ administrativeArea: "administrativeArea";
4
+ location: "location";
5
+ all: "all";
91
6
  }>;
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;
7
+ export type JurisdictionFilter = z.infer<typeof JurisdictionFilter>;
8
+ export declare const UserFilter: z.ZodEnum<{
9
+ user: "user";
10
+ }>;
11
+ export type UserFilter = z.infer<typeof UserFilter>;
12
+ /**
13
+ * 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.
14
+ * When adding new scope types, they should be added to the appropriate section based on the options they require.
15
+ *
16
+ * @see scopeOptionsPlaceEvent @see scopeOptionsDeclared @see scopeOptionsFull
17
+ */
18
+ export declare const RecordScopeTypeV2: z.ZodEnum<{
19
+ "record.search": "record.search";
20
+ "record.create": "record.create";
21
+ "record.read": "record.read";
22
+ "record.declare": "record.declare";
23
+ "record.notify": "record.notify";
24
+ "record.edit": "record.edit";
25
+ "record.reject": "record.reject";
26
+ "record.archive": "record.archive";
27
+ "record.review-duplicates": "record.review-duplicates";
28
+ "record.register": "record.register";
29
+ "record.print-certified-copies": "record.print-certified-copies";
30
+ "record.request-correction": "record.request-correction";
31
+ "record.correct": "record.correct";
32
+ "record.unassign-others": "record.unassign-others";
33
+ "record.custom-action": "record.custom-action";
34
+ }>;
35
+ export type RecordScopeTypeV2 = z.infer<typeof RecordScopeTypeV2>;
36
+ declare const AllScopeOptions: z.ZodObject<{
37
+ ids: z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodArray<z.ZodString>>;
38
+ accessLevel: z.ZodOptional<z.ZodEnum<{
39
+ administrativeArea: "administrativeArea";
40
+ location: "location";
41
+ all: "all";
42
+ }>>;
43
+ event: z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>;
44
+ placeOfEvent: z.ZodOptional<z.ZodEnum<{
45
+ administrativeArea: "administrativeArea";
46
+ location: "location";
47
+ all: "all";
48
+ }>>;
49
+ declaredIn: z.ZodOptional<z.ZodEnum<{
50
+ administrativeArea: "administrativeArea";
51
+ location: "location";
52
+ all: "all";
53
+ }>>;
54
+ declaredBy: z.ZodOptional<z.ZodEnum<{
55
+ user: "user";
56
+ }>>;
57
+ registeredIn: z.ZodOptional<z.ZodEnum<{
58
+ administrativeArea: "administrativeArea";
59
+ location: "location";
60
+ all: "all";
61
+ }>>;
62
+ registeredBy: z.ZodOptional<z.ZodEnum<{
63
+ user: "user";
64
+ }>>;
65
+ }, z.core.$strip>;
66
+ type AllScopeOptions = z.infer<typeof AllScopeOptions>;
67
+ export declare const ScopeOptionKey: z.ZodEnum<{
68
+ event: "event";
69
+ placeOfEvent: "placeOfEvent";
70
+ declaredIn: "declaredIn";
71
+ declaredBy: "declaredBy";
72
+ registeredIn: "registeredIn";
73
+ registeredBy: "registeredBy";
74
+ accessLevel: "accessLevel";
75
+ ids: "ids";
76
+ }>;
77
+ export type ScopeOptionKey = z.infer<typeof ScopeOptionKey>;
78
+ export declare const ScopesWithPlaceEventOptions: z.ZodEnum<{
79
+ "record.create": "record.create";
80
+ "record.declare": "record.declare";
81
+ "record.notify": "record.notify";
82
+ }>;
83
+ export declare const ScopesWithDeclaredOptions: z.ZodEnum<{
84
+ "record.edit": "record.edit";
85
+ "record.reject": "record.reject";
86
+ "record.archive": "record.archive";
87
+ "record.review-duplicates": "record.review-duplicates";
88
+ "record.register": "record.register";
89
+ }>;
90
+ export declare const ScopesWithFullOptions: z.ZodEnum<{
91
+ "record.search": "record.search";
92
+ "record.read": "record.read";
93
+ "record.request-correction": "record.request-correction";
94
+ "record.correct": "record.correct";
95
+ "record.unassign-others": "record.unassign-others";
96
+ }>;
97
+ export declare const RecordScopeV2: z.ZodDiscriminatedUnion<[z.ZodObject<{
98
+ type: z.ZodEnum<{
99
+ "record.create": "record.create";
100
+ "record.declare": "record.declare";
101
+ "record.notify": "record.notify";
103
102
  }>;
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
- };
103
+ options: z.ZodOptional<z.ZodObject<{
104
+ event: z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>;
105
+ placeOfEvent: z.ZodOptional<z.ZodEnum<{
106
+ administrativeArea: "administrativeArea";
107
+ location: "location";
108
+ all: "all";
109
+ }>>;
110
+ }, z.core.$strip>>;
111
+ }, z.core.$strip>, z.ZodObject<{
112
+ type: z.ZodEnum<{
113
+ "record.edit": "record.edit";
114
+ "record.reject": "record.reject";
115
+ "record.archive": "record.archive";
116
+ "record.review-duplicates": "record.review-duplicates";
117
+ "record.register": "record.register";
118
+ }>;
119
+ options: z.ZodOptional<z.ZodObject<{
120
+ event: z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>;
121
+ placeOfEvent: z.ZodOptional<z.ZodEnum<{
122
+ administrativeArea: "administrativeArea";
123
+ location: "location";
124
+ all: "all";
125
+ }>>;
126
+ declaredIn: z.ZodOptional<z.ZodEnum<{
127
+ administrativeArea: "administrativeArea";
128
+ location: "location";
129
+ all: "all";
130
+ }>>;
131
+ declaredBy: z.ZodOptional<z.ZodEnum<{
132
+ user: "user";
133
+ }>>;
134
+ }, z.core.$strip>>;
135
+ }, z.core.$strip>, z.ZodObject<{
136
+ type: z.ZodEnum<{
137
+ "record.search": "record.search";
138
+ "record.read": "record.read";
139
+ "record.request-correction": "record.request-correction";
140
+ "record.correct": "record.correct";
141
+ "record.unassign-others": "record.unassign-others";
142
+ }>;
143
+ options: z.ZodOptional<z.ZodObject<{
144
+ event: z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>;
145
+ placeOfEvent: z.ZodOptional<z.ZodEnum<{
146
+ administrativeArea: "administrativeArea";
147
+ location: "location";
148
+ all: "all";
149
+ }>>;
150
+ declaredIn: z.ZodOptional<z.ZodEnum<{
151
+ administrativeArea: "administrativeArea";
152
+ location: "location";
153
+ all: "all";
154
+ }>>;
155
+ declaredBy: z.ZodOptional<z.ZodEnum<{
156
+ user: "user";
157
+ }>>;
158
+ registeredIn: z.ZodOptional<z.ZodEnum<{
159
+ administrativeArea: "administrativeArea";
160
+ location: "location";
161
+ all: "all";
162
+ }>>;
163
+ registeredBy: z.ZodOptional<z.ZodEnum<{
164
+ user: "user";
165
+ }>>;
166
+ }, z.core.$strip>>;
167
+ }, z.core.$strip>, z.ZodObject<{
168
+ type: z.ZodLiteral<"record.custom-action">;
169
+ options: z.ZodOptional<z.ZodObject<{
170
+ event: z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>;
171
+ placeOfEvent: z.ZodOptional<z.ZodEnum<{
172
+ administrativeArea: "administrativeArea";
173
+ location: "location";
174
+ all: "all";
175
+ }>>;
176
+ declaredIn: z.ZodOptional<z.ZodEnum<{
177
+ administrativeArea: "administrativeArea";
178
+ location: "location";
179
+ all: "all";
180
+ }>>;
181
+ declaredBy: z.ZodOptional<z.ZodEnum<{
182
+ user: "user";
183
+ }>>;
184
+ registeredIn: z.ZodOptional<z.ZodEnum<{
185
+ administrativeArea: "administrativeArea";
186
+ location: "location";
187
+ all: "all";
188
+ }>>;
189
+ registeredBy: z.ZodOptional<z.ZodEnum<{
190
+ user: "user";
191
+ }>>;
192
+ customActionTypes: z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>;
193
+ }, z.core.$strip>>;
194
+ }, z.core.$strip>, z.ZodObject<{
195
+ type: z.ZodLiteral<"record.print-certified-copies">;
196
+ options: z.ZodOptional<z.ZodObject<{
197
+ event: z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>;
198
+ placeOfEvent: z.ZodOptional<z.ZodEnum<{
199
+ administrativeArea: "administrativeArea";
200
+ location: "location";
201
+ all: "all";
202
+ }>>;
203
+ declaredIn: z.ZodOptional<z.ZodEnum<{
204
+ administrativeArea: "administrativeArea";
205
+ location: "location";
206
+ all: "all";
207
+ }>>;
208
+ declaredBy: z.ZodOptional<z.ZodEnum<{
209
+ user: "user";
210
+ }>>;
211
+ registeredIn: z.ZodOptional<z.ZodEnum<{
212
+ administrativeArea: "administrativeArea";
213
+ location: "location";
214
+ all: "all";
215
+ }>>;
216
+ registeredBy: z.ZodOptional<z.ZodEnum<{
217
+ user: "user";
218
+ }>>;
219
+ templates: z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>;
220
+ }, z.core.$strip>>;
221
+ }, z.core.$strip>], "type">;
222
+ export declare function scopeUsesDeclaredOptions(scope: Scope): scope is Extract<Scope, {
223
+ type: z.infer<typeof ScopesWithDeclaredOptions>;
116
224
  }>;
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[];
225
+ export declare function scopeUsesFullOptions(scope: Scope): scope is Extract<Scope, {
226
+ type: z.infer<typeof ScopesWithFullOptions>;
227
+ }>;
228
+ export declare function scopeUsesPrintCertifiedCopiesOptions(scope: Scope): scope is Extract<Scope, {
229
+ type: 'record.print-certified-copies';
230
+ }>;
231
+ export declare function isCustomActionScope(scope: Scope): scope is Extract<Scope, {
232
+ type: 'record.custom-action';
233
+ }>;
234
+ export declare const ResolvedRecordScopeV2: z.ZodDiscriminatedUnion<[z.ZodObject<{
235
+ type: z.ZodEnum<{
236
+ "record.create": "record.create";
237
+ "record.declare": "record.declare";
238
+ "record.notify": "record.notify";
129
239
  }>;
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
- };
240
+ options: z.ZodOptional<z.ZodObject<{
241
+ event: z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>;
242
+ placeOfEvent: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID">>>;
243
+ }, z.core.$strip>>;
244
+ }, z.core.$strip>, z.ZodObject<{
245
+ type: z.ZodEnum<{
246
+ "record.edit": "record.edit";
247
+ "record.reject": "record.reject";
248
+ "record.archive": "record.archive";
249
+ "record.review-duplicates": "record.review-duplicates";
250
+ "record.register": "record.register";
251
+ }>;
252
+ options: z.ZodOptional<z.ZodObject<{
253
+ event: z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>;
254
+ placeOfEvent: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID">>>;
255
+ declaredIn: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID">>>;
256
+ declaredBy: z.ZodOptional<z.ZodString>;
257
+ }, z.core.$strip>>;
258
+ }, z.core.$strip>, z.ZodObject<{
259
+ type: z.ZodEnum<{
260
+ "record.search": "record.search";
261
+ "record.read": "record.read";
262
+ "record.request-correction": "record.request-correction";
263
+ "record.correct": "record.correct";
264
+ "record.unassign-others": "record.unassign-others";
265
+ }>;
266
+ options: z.ZodOptional<z.ZodObject<{
267
+ event: z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>;
268
+ placeOfEvent: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID">>>;
269
+ declaredIn: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID">>>;
270
+ declaredBy: z.ZodOptional<z.ZodString>;
271
+ registeredIn: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID">>>;
272
+ registeredBy: z.ZodOptional<z.ZodString>;
273
+ }, z.core.$strip>>;
274
+ }, z.core.$strip>, z.ZodObject<{
275
+ type: z.ZodLiteral<"record.print-certified-copies">;
276
+ options: z.ZodOptional<z.ZodObject<{
277
+ event: z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>;
278
+ placeOfEvent: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID">>>;
279
+ declaredIn: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID">>>;
280
+ declaredBy: z.ZodOptional<z.ZodString>;
281
+ registeredIn: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID">>>;
282
+ registeredBy: z.ZodOptional<z.ZodString>;
283
+ templates: z.ZodOptional<z.ZodArray<z.ZodString>>;
284
+ }, z.core.$strip>>;
285
+ }, z.core.$strip>], "type">;
286
+ export type RecordScopeV2 = z.infer<typeof RecordScopeV2>;
287
+ export type ResolvedRecordScopeV2 = z.infer<typeof ResolvedRecordScopeV2>;
288
+ declare const SystemScopeType: z.ZodEnum<{
289
+ "organisation.read-locations": "organisation.read-locations";
290
+ "user.read": "user.read";
291
+ "user.create": "user.create";
292
+ "user.edit": "user.edit";
140
293
  }>;
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")[];
294
+ export type SystemScopeType = z.infer<typeof SystemScopeType>;
295
+ /** The primary scope schema which gathers all scope types together. All scopes are discriminated by type and options are determined according to the type. */
296
+ export declare const Scope: z.ZodDiscriminatedUnion<[z.ZodObject<{
297
+ type: z.ZodEnum<{
298
+ bypassratelimit: "bypassratelimit";
299
+ "record.reindex": "record.reindex";
300
+ "user.data-seeding": "user.data-seeding";
301
+ "integration.create": "integration.create";
302
+ "record.import": "record.import";
303
+ "config.update-all": "config.update-all";
304
+ "attachment.upload": "attachment.upload";
305
+ "profile.electronic-signature": "profile.electronic-signature";
306
+ "user.read-only-my-audit": "user.read-only-my-audit";
307
+ "performance.read": "performance.read";
308
+ "performance.read-dashboards": "performance.read-dashboards";
309
+ "performance.vital-statistics-export": "performance.vital-statistics-export";
310
+ "record.confirm-registration": "record.confirm-registration";
311
+ "record.reject-registration": "record.reject-registration";
153
312
  }>;
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;
313
+ }, z.core.$strip>, z.ZodObject<{
314
+ type: z.ZodEnum<{
315
+ "record.create": "record.create";
316
+ "record.declare": "record.declare";
317
+ "record.notify": "record.notify";
177
318
  }>;
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[];
319
+ options: z.ZodOptional<z.ZodObject<{
320
+ event: z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>;
321
+ placeOfEvent: z.ZodOptional<z.ZodEnum<{
322
+ administrativeArea: "administrativeArea";
323
+ location: "location";
324
+ all: "all";
325
+ }>>;
326
+ }, z.core.$strip>>;
327
+ }, z.core.$strip>, z.ZodObject<{
328
+ type: z.ZodEnum<{
329
+ "record.edit": "record.edit";
330
+ "record.reject": "record.reject";
331
+ "record.archive": "record.archive";
332
+ "record.review-duplicates": "record.review-duplicates";
333
+ "record.register": "record.register";
198
334
  }>;
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[];
335
+ options: z.ZodOptional<z.ZodObject<{
336
+ event: z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>;
337
+ placeOfEvent: z.ZodOptional<z.ZodEnum<{
338
+ administrativeArea: "administrativeArea";
339
+ location: "location";
340
+ all: "all";
341
+ }>>;
342
+ declaredIn: z.ZodOptional<z.ZodEnum<{
343
+ administrativeArea: "administrativeArea";
344
+ location: "location";
345
+ all: "all";
346
+ }>>;
347
+ declaredBy: z.ZodOptional<z.ZodEnum<{
348
+ user: "user";
349
+ }>>;
350
+ }, z.core.$strip>>;
351
+ }, z.core.$strip>, z.ZodObject<{
352
+ type: z.ZodEnum<{
353
+ "record.search": "record.search";
354
+ "record.read": "record.read";
355
+ "record.request-correction": "record.request-correction";
356
+ "record.correct": "record.correct";
357
+ "record.unassign-others": "record.unassign-others";
217
358
  }>;
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[];
359
+ options: z.ZodOptional<z.ZodObject<{
360
+ event: z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>;
361
+ placeOfEvent: z.ZodOptional<z.ZodEnum<{
362
+ administrativeArea: "administrativeArea";
363
+ location: "location";
364
+ all: "all";
365
+ }>>;
366
+ declaredIn: z.ZodOptional<z.ZodEnum<{
367
+ administrativeArea: "administrativeArea";
368
+ location: "location";
369
+ all: "all";
370
+ }>>;
371
+ declaredBy: z.ZodOptional<z.ZodEnum<{
372
+ user: "user";
373
+ }>>;
374
+ registeredIn: z.ZodOptional<z.ZodEnum<{
375
+ administrativeArea: "administrativeArea";
376
+ location: "location";
377
+ all: "all";
378
+ }>>;
379
+ registeredBy: z.ZodOptional<z.ZodEnum<{
380
+ user: "user";
381
+ }>>;
382
+ }, z.core.$strip>>;
383
+ }, z.core.$strip>, z.ZodObject<{
384
+ type: z.ZodLiteral<"record.custom-action">;
385
+ options: z.ZodOptional<z.ZodObject<{
386
+ event: z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>;
387
+ placeOfEvent: z.ZodOptional<z.ZodEnum<{
388
+ administrativeArea: "administrativeArea";
389
+ location: "location";
390
+ all: "all";
391
+ }>>;
392
+ declaredIn: z.ZodOptional<z.ZodEnum<{
393
+ administrativeArea: "administrativeArea";
394
+ location: "location";
395
+ all: "all";
396
+ }>>;
397
+ declaredBy: z.ZodOptional<z.ZodEnum<{
398
+ user: "user";
399
+ }>>;
400
+ registeredIn: z.ZodOptional<z.ZodEnum<{
401
+ administrativeArea: "administrativeArea";
402
+ location: "location";
403
+ all: "all";
404
+ }>>;
405
+ registeredBy: z.ZodOptional<z.ZodEnum<{
406
+ user: "user";
407
+ }>>;
408
+ customActionTypes: z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>;
409
+ }, z.core.$strip>>;
410
+ }, z.core.$strip>, z.ZodObject<{
411
+ type: z.ZodLiteral<"record.print-certified-copies">;
412
+ options: z.ZodOptional<z.ZodObject<{
413
+ event: z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>;
414
+ placeOfEvent: z.ZodOptional<z.ZodEnum<{
415
+ administrativeArea: "administrativeArea";
416
+ location: "location";
417
+ all: "all";
418
+ }>>;
419
+ declaredIn: z.ZodOptional<z.ZodEnum<{
420
+ administrativeArea: "administrativeArea";
421
+ location: "location";
422
+ all: "all";
423
+ }>>;
424
+ declaredBy: z.ZodOptional<z.ZodEnum<{
425
+ user: "user";
426
+ }>>;
427
+ registeredIn: z.ZodOptional<z.ZodEnum<{
428
+ administrativeArea: "administrativeArea";
429
+ location: "location";
430
+ all: "all";
431
+ }>>;
432
+ registeredBy: z.ZodOptional<z.ZodEnum<{
433
+ user: "user";
434
+ }>>;
435
+ templates: z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>;
436
+ }, z.core.$strip>>;
437
+ }, z.core.$strip>, z.ZodObject<{
438
+ type: z.ZodEnum<{
439
+ "organisation.read-locations": "organisation.read-locations";
440
+ "user.read": "user.read";
441
+ "user.create": "user.create";
442
+ "user.edit": "user.edit";
236
443
  }>;
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"]>;
444
+ options: z.ZodOptional<z.ZodObject<{
445
+ accessLevel: z.ZodOptional<z.ZodEnum<{
446
+ administrativeArea: "administrativeArea";
447
+ location: "location";
448
+ all: "all";
449
+ }>>;
450
+ }, z.core.$strip>>;
451
+ }, z.core.$strip>, z.ZodObject<{
452
+ type: z.ZodLiteral<"workqueue">;
249
453
  options: z.ZodObject<{
250
- event: z.ZodArray<z.ZodString, "many">;
251
- }, "strip", z.ZodTypeAny, {
252
- event: string[];
253
- }, {
254
- event: string[];
255
- }>;
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;
454
+ ids: z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodArray<z.ZodString>>;
455
+ }, z.core.$strip>;
456
+ }, z.core.$strip>], "type">;
457
+ export type Scope = z.infer<typeof Scope>;
458
+ export declare const ScopeType: z.ZodEnum<{
459
+ "record.search": "record.search";
460
+ "record.create": "record.create";
461
+ "record.read": "record.read";
462
+ "record.declare": "record.declare";
463
+ "record.notify": "record.notify";
464
+ "record.edit": "record.edit";
465
+ "record.reject": "record.reject";
466
+ "record.archive": "record.archive";
467
+ "record.review-duplicates": "record.review-duplicates";
468
+ "record.register": "record.register";
469
+ "record.print-certified-copies": "record.print-certified-copies";
470
+ "record.request-correction": "record.request-correction";
471
+ "record.correct": "record.correct";
472
+ "record.unassign-others": "record.unassign-others";
473
+ "record.custom-action": "record.custom-action";
474
+ bypassratelimit: "bypassratelimit";
475
+ "record.reindex": "record.reindex";
476
+ "user.data-seeding": "user.data-seeding";
477
+ "integration.create": "integration.create";
478
+ "record.import": "record.import";
479
+ "config.update-all": "config.update-all";
480
+ "attachment.upload": "attachment.upload";
481
+ "profile.electronic-signature": "profile.electronic-signature";
482
+ "user.read-only-my-audit": "user.read-only-my-audit";
483
+ "performance.read": "performance.read";
484
+ "performance.read-dashboards": "performance.read-dashboards";
485
+ "performance.vital-statistics-export": "performance.vital-statistics-export";
486
+ "record.confirm-registration": "record.confirm-registration";
487
+ "record.reject-registration": "record.reject-registration";
488
+ "organisation.read-locations": "organisation.read-locations";
489
+ "user.read": "user.read";
490
+ "user.create": "user.create";
491
+ "user.edit": "user.edit";
492
+ workqueue: "workqueue";
493
+ }>;
494
+ export type ScopeType = z.infer<typeof ScopeType>;
315
495
  /**
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"] } }
496
+ * Branded encoded scope string, in query string format.
497
+ *
322
498
  */
323
- export declare function parseConfigurableScope(scope: string): {
324
- type: "record.registered.print-certified-copies";
325
- options: {
326
- event: string[];
327
- templates?: string[] | undefined;
328
- };
499
+ export declare const EncodedScope: z.core.$ZodBranded<z.ZodString, "EncodedScope">;
500
+ export type EncodedScope = z.infer<typeof EncodedScope>;
501
+ /**
502
+ * Encodes a scope object into an EncodedScope branded query string.
503
+ *
504
+ *
505
+ * @param scope - The scope object to encode.
506
+ * @returns The encoded scope as a branded string (`EncodedScope`).
507
+ */
508
+ export declare const encodeScope: (scope: Scope) => EncodedScope;
509
+ /**
510
+ * Converts a scope object into an encoded query string representation.
511
+ *
512
+ * @TODO scope param could be defined as EncodedScope instead of string.
513
+ *
514
+ * @param scope - The scope object to encode.
515
+ * @returns The encoded scope as a branded string (`EncodedScope`).
516
+ */
517
+ export declare const decodeScope: (query: EncodedScope) => {
518
+ type: "record.create" | "record.declare" | "record.notify";
519
+ options?: {
520
+ event?: string[] | undefined;
521
+ placeOfEvent?: "administrativeArea" | "location" | "all" | undefined;
522
+ } | undefined;
329
523
  } | {
330
- type: "search";
331
- options: {
332
- event: string[];
333
- access: ("my-jurisdiction" | "all")[];
334
- };
524
+ type: "record.edit" | "record.reject" | "record.archive" | "record.review-duplicates" | "record.register";
525
+ options?: {
526
+ event?: string[] | undefined;
527
+ placeOfEvent?: "administrativeArea" | "location" | "all" | undefined;
528
+ declaredIn?: "administrativeArea" | "location" | "all" | undefined;
529
+ declaredBy?: "user" | undefined;
530
+ } | undefined;
335
531
  } | {
336
- type: "user.create";
337
- options: {
338
- role: string[];
339
- };
532
+ type: "record.search" | "record.read" | "record.request-correction" | "record.correct" | "record.unassign-others";
533
+ options?: {
534
+ event?: string[] | undefined;
535
+ placeOfEvent?: "administrativeArea" | "location" | "all" | undefined;
536
+ declaredIn?: "administrativeArea" | "location" | "all" | undefined;
537
+ declaredBy?: "user" | undefined;
538
+ registeredIn?: "administrativeArea" | "location" | "all" | undefined;
539
+ registeredBy?: "user" | undefined;
540
+ } | undefined;
340
541
  } | {
341
- type: "user.edit";
342
- options: {
343
- role: string[];
344
- };
542
+ type: "record.custom-action";
543
+ options?: {
544
+ event?: string[] | undefined;
545
+ placeOfEvent?: "administrativeArea" | "location" | "all" | undefined;
546
+ declaredIn?: "administrativeArea" | "location" | "all" | undefined;
547
+ declaredBy?: "user" | undefined;
548
+ registeredIn?: "administrativeArea" | "location" | "all" | undefined;
549
+ registeredBy?: "user" | undefined;
550
+ customActionTypes?: string[] | undefined;
551
+ } | undefined;
345
552
  } | {
346
- type: "workqueue";
347
- options: {
348
- id: string[];
349
- };
553
+ type: "record.print-certified-copies";
554
+ options?: {
555
+ event?: string[] | undefined;
556
+ placeOfEvent?: "administrativeArea" | "location" | "all" | undefined;
557
+ declaredIn?: "administrativeArea" | "location" | "all" | undefined;
558
+ declaredBy?: "user" | undefined;
559
+ registeredIn?: "administrativeArea" | "location" | "all" | undefined;
560
+ registeredBy?: "user" | undefined;
561
+ templates?: string[] | undefined;
562
+ } | undefined;
563
+ } | {
564
+ type: "bypassratelimit" | "record.reindex" | "user.data-seeding" | "integration.create" | "record.import" | "config.update-all" | "attachment.upload" | "profile.electronic-signature" | "user.read-only-my-audit" | "performance.read" | "performance.read-dashboards" | "performance.vital-statistics-export" | "record.confirm-registration" | "record.reject-registration";
565
+ } | {
566
+ type: "organisation.read-locations" | "user.read" | "user.create" | "user.edit";
567
+ options?: {
568
+ accessLevel?: "administrativeArea" | "location" | "all" | undefined;
569
+ } | undefined;
350
570
  } | {
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";
571
+ type: "workqueue";
352
572
  options: {
353
- event: string[];
573
+ ids: string[];
354
574
  };
355
575
  } | 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";
358
- } | undefined;
359
576
  /**
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]"
577
+ * Function to get the value of a scope option (aka. scope attribute)
578
+ *
579
+ * @param scope - The scope to get the value of the option from.
580
+ * @param option - The option to get the value of.
581
+ * @returns The value of the scope option. Will return the default value if the option is not set.
582
+ */
583
+ export declare function getScopeOptionValue<T extends ScopeOptionKey>(scope: Scope, option: T): AllScopeOptions[T] | undefined;
584
+ export declare function getAcceptedScopesByType({ acceptedScopes, scopes }: {
585
+ acceptedScopes: ScopeType[];
586
+ scopes: EncodedScope[];
587
+ }): Scope[];
588
+ /**
589
+ * Checks if the provided scopes or token contain any of the accepted scopes.
590
+ *
591
+ * Overloads:
592
+ * - `hasAnyScope(token, scopes)` → extracts scopes from a token
593
+ * - `hasAnyScope(scopes, scopes)` → checks directly from a scope array
594
+ */
595
+ /**
596
+ * Checks if the provided token contains any of the accepted scopes.
597
+ *
598
+ * @param {string} token - The authentication JWT token.
599
+ * @param {ScopeType[]} scopes - An array of scope types to check for.
600
+ * @returns {boolean} True if the token contains at least one of the accepted scopes, false otherwise.
601
+ */
602
+ export declare function hasAnyScope(token: string, scopes: ScopeType[]): boolean;
603
+ /**
604
+ * Checks if the provided array of scopes contains any of the accepted scopes.
605
+ *
606
+ * @param {EncodedScope[]} userScopes - Array of scopes to check.
607
+ * @param {ScopeType[]} scopes - An array of scope types to check for.
608
+ * @returns {boolean} True if the scope list contains at least one of the accepted scopes.
609
+ */
610
+ export declare function hasAnyScope(userScopes: EncodedScope[], scopes: ScopeType[]): boolean;
611
+ /**
612
+ * Checks whether a scope exists either inside a JWT token or
613
+ * within a provided list of scopes.
614
+ *
615
+ * Overloads:
616
+ * - `hasScope(token, scope)` → extracts scopes from a token
617
+ * - `hasScope(scopes, scope)` → checks directly from a scope array
618
+ */
619
+ /**
620
+ * Checks if the provided token contains the given scope.
621
+ *
622
+ * @param token - The authentication JWT token.
623
+ * @param scope - The scope type to check for.
624
+ * @returns True if the token contains the specified scope.
625
+ */
626
+ export declare function hasScope(token: string, scope: ScopeType): boolean;
627
+ /**
628
+ * Checks if the provided list of scopes contains the given scope.
629
+ *
630
+ * @param scopes - Array of scopes to check.
631
+ * @param scope - The scope type to check for.
632
+ * @returns True if the scope list contains the specified scope.
633
+ */
634
+ export declare function hasScope(scopes: EncodedScope[], scope: ScopeType): boolean;
635
+ /**
636
+ * Checks if the given event type is allowed by the accepted scopes. If no specific event types are defined, it returns true.
637
+ *
638
+ * @param {Scope[]} userScopes - The scopes of the user.
639
+ * @param {string} eventType - The event type to check for permission.
640
+ * @returns {boolean} Returns true if the event type is allowed by the scope.
369
641
  */
370
- export declare function stringifyScope(scope: z.infer<typeof ConfigurableRawScopes>): string;
642
+ export declare function canUserCreateEvent(userScopes: EncodedScope[], eventType: string): boolean;
371
643
  /**
372
- * Extracts authorized event identifiers (e.g. birth, death) from the provided configurable scopes.
644
+ * Helper for defining scopes for user roles. Should be used in country config.
373
645
  *
374
- * @param scopes - Array of configurable scopes with options
375
- * @returns Array of authorized event identifiers
646
+ * @param scopes Array of scopes in object format.
647
+ * @returns Array of scopes in string format, encoded for use in JWT tokens.
376
648
  */
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>;
649
+ export declare function defineScopes(scopes: Scope[]): (string & z.core.$brand<"EncodedScope">)[];
384
650
  export {};
385
651
  //# sourceMappingURL=scopes.d.ts.map