@opencrvs/toolkit 1.8.0-rc.fef85f2 → 1.8.0-rc.ff0b26c

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 (32) hide show
  1. package/dist/commons/api/router.d.ts +10585 -4200
  2. package/dist/commons/conditionals/conditionals.d.ts +9 -6
  3. package/dist/commons/events/ActionConfig.d.ts +97080 -1720
  4. package/dist/commons/events/ActionDocument.d.ts +542 -211
  5. package/dist/commons/events/ActionInput.d.ts +248 -240
  6. package/dist/commons/events/AdvancedSearchConfig.d.ts +957 -22
  7. package/dist/commons/events/Draft.d.ts +33 -20
  8. package/dist/commons/events/EventConfig.d.ts +46237 -1398
  9. package/dist/commons/events/EventDocument.d.ts +337 -159
  10. package/dist/commons/events/EventIndex.d.ts +1735 -16
  11. package/dist/commons/events/EventInput.d.ts +13 -0
  12. package/dist/commons/events/EventMetadata.d.ts +274 -14
  13. package/dist/commons/events/FieldConfig.d.ts +4229 -744
  14. package/dist/commons/events/FieldType.d.ts +3 -3
  15. package/dist/commons/events/FieldTypeMapping.d.ts +11 -4
  16. package/dist/commons/events/FieldValue.d.ts +7 -4
  17. package/dist/commons/events/FormConfig.d.ts +43591 -439
  18. package/dist/commons/events/PageConfig.d.ts +10860 -204
  19. package/dist/commons/events/SummaryConfig.d.ts +17 -47
  20. package/dist/commons/events/WorkqueueConfig.d.ts +1549 -19
  21. package/dist/commons/events/defineConfig.d.ts +7199 -27
  22. package/dist/commons/events/event.d.ts +54 -0
  23. package/dist/commons/events/field.d.ts +82 -0
  24. package/dist/commons/events/index.d.ts +2 -0
  25. package/dist/commons/events/scopes.d.ts +21 -1
  26. package/dist/commons/events/test.utils.d.ts +10 -47
  27. package/dist/commons/events/utils.d.ts +3665 -67
  28. package/dist/conditionals/index.js +36 -33
  29. package/dist/events/index.js +1771 -966
  30. package/dist/scopes/index.d.ts +158 -1
  31. package/dist/scopes/index.js +152 -1
  32. package/package.json +3 -2
@@ -1,3 +1,4 @@
1
+ import { z } from 'zod';
1
2
  export declare const SCOPES: {
2
3
  readonly NATLSYSADMIN: "natlsysadmin";
3
4
  readonly BYPASSRATELIMIT: "bypassratelimit";
@@ -18,6 +19,7 @@ export declare const SCOPES: {
18
19
  * @TODO This is a temporary scope to be used for V2 Events custom events declaration
19
20
  */
20
21
  readonly RECORD_DECLARE: "record.declare-birth";
22
+ readonly RECORD_IMPORT: "record.import";
21
23
  readonly RECORD_DECLARE_BIRTH: "record.declare-birth";
22
24
  readonly RECORD_DECLARE_BIRTH_MY_JURISDICTION: "record.declare-birth:my-jurisdiction";
23
25
  readonly RECORD_DECLARE_DEATH: "record.declare-death";
@@ -83,6 +85,161 @@ export declare const SCOPES: {
83
85
  readonly CONFIG_UPDATE_ALL: "config.update:all";
84
86
  readonly USER_DATA_SEEDING: "user.data-seeding";
85
87
  };
86
- export type Scope = (typeof SCOPES)[keyof typeof SCOPES];
88
+ declare const LiteralScopes: z.ZodUnion<[z.ZodLiteral<"natlsysadmin">, z.ZodLiteral<"bypassratelimit">, z.ZodLiteral<"declare">, z.ZodLiteral<"register">, z.ZodLiteral<"validate">, z.ZodLiteral<"demo">, z.ZodLiteral<"certify">, z.ZodLiteral<"performance">, z.ZodLiteral<"sysadmin">, z.ZodLiteral<"teams">, z.ZodLiteral<"config">, z.ZodLiteral<"webhook">, z.ZodLiteral<"nationalId">, z.ZodLiteral<"notification-api">, z.ZodLiteral<"recordsearch">, z.ZodLiteral<"record.import">, 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.ZodLiteral<"record.unassign-others">, 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.export-records">, z.ZodLiteral<"record.declaration-print">, z.ZodLiteral<"record.declaration-print-supporting-documents">, z.ZodLiteral<"record.registration-print">, z.ZodLiteral<"record.registration-print&issue-certified-copies">, z.ZodLiteral<"record.registration-print-certified-copies">, z.ZodLiteral<"record.registration-bulk-print-certified-copies">, z.ZodLiteral<"record.registration-verify-certified-copies">, z.ZodLiteral<"record.registration-request-correction">, z.ZodLiteral<"record.registration-correct">, z.ZodLiteral<"record.registration-request-revocation">, z.ZodLiteral<"record.registration-revoke">, z.ZodLiteral<"record.registration-request-reinstatement">, z.ZodLiteral<"record.registration-reinstate">, z.ZodLiteral<"record.confirm-registration">, z.ZodLiteral<"record.reject-registration">, 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<"record.read-audit">, z.ZodLiteral<"record.read-comments">, z.ZodLiteral<"record.create-comments">, z.ZodLiteral<"profile.update">, z.ZodLiteral<"profile.electronic-signature">, z.ZodLiteral<"performance.read">, z.ZodLiteral<"performance.read-dashboards">, z.ZodLiteral<"performance.vital-statistics-export">, z.ZodLiteral<"organisation.read-locations:all">, z.ZodLiteral<"organisation.read-locations:my-office">, z.ZodLiteral<"organisation.read-locations:my-jurisdiction">, 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">]>;
89
+ declare const ConfigurableScopes: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
90
+ type: z.ZodLiteral<"user.create">;
91
+ options: z.ZodObject<{
92
+ role: z.ZodArray<z.ZodString, "many">;
93
+ }, "strip", z.ZodTypeAny, {
94
+ role: string[];
95
+ }, {
96
+ role: string[];
97
+ }>;
98
+ }, "strip", z.ZodTypeAny, {
99
+ type: "user.create";
100
+ options: {
101
+ role: string[];
102
+ };
103
+ }, {
104
+ type: "user.create";
105
+ options: {
106
+ role: string[];
107
+ };
108
+ }>, z.ZodObject<{
109
+ type: z.ZodLiteral<"user.edit">;
110
+ options: z.ZodObject<{
111
+ role: z.ZodArray<z.ZodString, "many">;
112
+ }, "strip", z.ZodTypeAny, {
113
+ role: string[];
114
+ }, {
115
+ role: string[];
116
+ }>;
117
+ }, "strip", z.ZodTypeAny, {
118
+ type: "user.edit";
119
+ options: {
120
+ role: string[];
121
+ };
122
+ }, {
123
+ type: "user.edit";
124
+ options: {
125
+ role: string[];
126
+ };
127
+ }>, z.ZodObject<{
128
+ type: z.ZodLiteral<"workqueue">;
129
+ options: z.ZodObject<{
130
+ id: z.ZodArray<z.ZodString, "many">;
131
+ }, "strip", z.ZodTypeAny, {
132
+ id: string[];
133
+ }, {
134
+ id: string[];
135
+ }>;
136
+ }, "strip", z.ZodTypeAny, {
137
+ type: "workqueue";
138
+ options: {
139
+ id: string[];
140
+ };
141
+ }, {
142
+ type: "workqueue";
143
+ options: {
144
+ id: string[];
145
+ };
146
+ }>, z.ZodObject<{
147
+ type: z.ZodLiteral<"record.notify">;
148
+ options: z.ZodObject<{
149
+ event: z.ZodArray<z.ZodString, "many">;
150
+ }, "strip", z.ZodTypeAny, {
151
+ event: string[];
152
+ }, {
153
+ event: string[];
154
+ }>;
155
+ }, "strip", z.ZodTypeAny, {
156
+ type: "record.notify";
157
+ options: {
158
+ event: string[];
159
+ };
160
+ }, {
161
+ type: "record.notify";
162
+ options: {
163
+ event: string[];
164
+ };
165
+ }>]>;
166
+ export type ConfigurableScopeType = ConfigurableScopes['type'];
167
+ export type ConfigurableScopes = z.infer<typeof ConfigurableScopes>;
168
+ export declare function findScope<T extends ConfigurableScopeType>(scopes: string[], scopeType: T): Extract<{
169
+ type: "user.create";
170
+ options: {
171
+ role: string[];
172
+ };
173
+ }, {
174
+ type: T;
175
+ }> | Extract<{
176
+ type: "user.edit";
177
+ options: {
178
+ role: string[];
179
+ };
180
+ }, {
181
+ type: T;
182
+ }> | Extract<{
183
+ type: "workqueue";
184
+ options: {
185
+ id: string[];
186
+ };
187
+ }, {
188
+ type: T;
189
+ }> | Extract<{
190
+ type: "record.notify";
191
+ options: {
192
+ event: string[];
193
+ };
194
+ }, {
195
+ type: T;
196
+ }> | undefined;
197
+ /**
198
+ * Parses a configurable scope string into a ConfigurableScopes object.
199
+ * @param {string} scope - The scope string to parse
200
+ * @returns {ConfigurableScopes | undefined} The parsed scope object if valid, undefined otherwise
201
+ * @example
202
+ * parseScope("user.create[role=field-agent|registration-agent]")
203
+ * // Returns: { type: "user.create", options: { role: ["field-agent", "registration-agent"] } }
204
+ */
205
+ export declare function parseScope(scope: string): {
206
+ type: "user.create";
207
+ options: {
208
+ role: string[];
209
+ };
210
+ } | {
211
+ type: "user.edit";
212
+ options: {
213
+ role: string[];
214
+ };
215
+ } | {
216
+ type: "workqueue";
217
+ options: {
218
+ id: string[];
219
+ };
220
+ } | {
221
+ type: "record.notify";
222
+ options: {
223
+ event: string[];
224
+ };
225
+ } | {
226
+ type: "natlsysadmin" | "bypassratelimit" | "declare" | "register" | "validate" | "demo" | "certify" | "performance" | "sysadmin" | "teams" | "config" | "webhook" | "nationalId" | "notification-api" | "recordsearch" | "record.declare-birth" | "record.import" | "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.export-records" | "record.declaration-print" | "record.declaration-print-supporting-documents" | "record.registration-print" | "record.registration-print&issue-certified-copies" | "record.registration-print-certified-copies" | "record.registration-bulk-print-certified-copies" | "record.registration-verify-certified-copies" | "record.registration-request-correction" | "record.registration-correct" | "record.registration-request-revocation" | "record.registration-revoke" | "record.registration-request-reinstatement" | "record.registration-reinstate" | "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" | "record.read-audit" | "record.read-comments" | "record.create-comments" | "profile.update" | "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";
227
+ } | undefined;
228
+ /**
229
+ * Stringifies a ConfigurableScopes object into a scope string.
230
+ * @param {ConfigurableScopes} scope - The scope object to stringify
231
+ * @returns {string} The stringified scope in format "type[key1=value1|value2,key2=value3|value4]"
232
+ * @example
233
+ * stringifyScope({
234
+ * type: "record.notify",
235
+ * options: { event: ["v2.birth", "tennis-club-membership"] }
236
+ * })
237
+ * // Returns: "record.notify[event=v2.birth|tennis-club-membership]"
238
+ */
239
+ export declare function stringifyScope(scope: ConfigurableScopes): string;
87
240
  export declare const scopes: Scope[];
241
+ export type ParsedScopes = NonNullable<ReturnType<typeof parseScope>>;
242
+ export type RawScopes = z.infer<typeof LiteralScopes> | (string & {});
243
+ export type Scope = RawScopes;
244
+ export {};
88
245
  //# sourceMappingURL=scopes.d.ts.map
@@ -21,11 +21,15 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var scopes_exports = {};
22
22
  __export(scopes_exports, {
23
23
  SCOPES: () => SCOPES,
24
- scopes: () => scopes
24
+ findScope: () => findScope,
25
+ parseScope: () => parseScope,
26
+ scopes: () => scopes,
27
+ stringifyScope: () => stringifyScope
25
28
  });
26
29
  module.exports = __toCommonJS(scopes_exports);
27
30
 
28
31
  // ../commons/src/scopes.ts
32
+ var import_zod = require("zod");
29
33
  var SCOPES = {
30
34
  // TODO v1.8 legacy scopes
31
35
  NATLSYSADMIN: "natlsysadmin",
@@ -49,6 +53,8 @@ var SCOPES = {
49
53
  */
50
54
  RECORD_DECLARE: "record.declare-birth",
51
55
  // declare
56
+ RECORD_IMPORT: "record.import",
57
+ // declare
52
58
  RECORD_DECLARE_BIRTH: "record.declare-birth",
53
59
  RECORD_DECLARE_BIRTH_MY_JURISDICTION: "record.declare-birth:my-jurisdiction",
54
60
  RECORD_DECLARE_DEATH: "record.declare-death",
@@ -136,4 +142,149 @@ var SCOPES = {
136
142
  // data seeding
137
143
  USER_DATA_SEEDING: "user.data-seeding"
138
144
  };
145
+ var LiteralScopes = import_zod.z.union([
146
+ import_zod.z.literal(SCOPES.NATLSYSADMIN),
147
+ import_zod.z.literal(SCOPES.BYPASSRATELIMIT),
148
+ import_zod.z.literal(SCOPES.DECLARE),
149
+ import_zod.z.literal(SCOPES.REGISTER),
150
+ import_zod.z.literal(SCOPES.VALIDATE),
151
+ import_zod.z.literal(SCOPES.DEMO),
152
+ import_zod.z.literal(SCOPES.CERTIFY),
153
+ import_zod.z.literal(SCOPES.PERFORMANCE),
154
+ import_zod.z.literal(SCOPES.SYSADMIN),
155
+ import_zod.z.literal(SCOPES.TEAMS),
156
+ import_zod.z.literal(SCOPES.CONFIG),
157
+ import_zod.z.literal(SCOPES.WEBHOOK),
158
+ import_zod.z.literal(SCOPES.NATIONALID),
159
+ import_zod.z.literal(SCOPES.NOTIFICATION_API),
160
+ import_zod.z.literal(SCOPES.RECORDSEARCH),
161
+ import_zod.z.literal(SCOPES.RECORD_IMPORT),
162
+ import_zod.z.literal(SCOPES.RECORD_DECLARE_BIRTH),
163
+ import_zod.z.literal(SCOPES.RECORD_DECLARE_BIRTH_MY_JURISDICTION),
164
+ import_zod.z.literal(SCOPES.RECORD_DECLARE_DEATH),
165
+ import_zod.z.literal(SCOPES.RECORD_DECLARE_DEATH_MY_JURISDICTION),
166
+ import_zod.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE),
167
+ import_zod.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE_MY_JURISDICTION),
168
+ import_zod.z.literal(SCOPES.RECORD_SUBMIT_INCOMPLETE),
169
+ import_zod.z.literal(SCOPES.RECORD_SUBMIT_FOR_REVIEW),
170
+ import_zod.z.literal(SCOPES.RECORD_UNASSIGN_OTHERS),
171
+ import_zod.z.literal(SCOPES.RECORD_SUBMIT_FOR_APPROVAL),
172
+ import_zod.z.literal(SCOPES.RECORD_SUBMIT_FOR_UPDATES),
173
+ import_zod.z.literal(SCOPES.RECORD_DECLARATION_EDIT),
174
+ import_zod.z.literal(SCOPES.RECORD_REVIEW_DUPLICATES),
175
+ import_zod.z.literal(SCOPES.RECORD_DECLARATION_ARCHIVE),
176
+ import_zod.z.literal(SCOPES.RECORD_DECLARATION_REINSTATE),
177
+ import_zod.z.literal(SCOPES.RECORD_REGISTER),
178
+ import_zod.z.literal(SCOPES.RECORD_EXPORT_RECORDS),
179
+ import_zod.z.literal(SCOPES.RECORD_DECLARATION_PRINT),
180
+ import_zod.z.literal(SCOPES.RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS),
181
+ import_zod.z.literal(SCOPES.RECORD_REGISTRATION_PRINT),
182
+ import_zod.z.literal(SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES),
183
+ import_zod.z.literal(SCOPES.RECORD_PRINT_CERTIFIED_COPIES),
184
+ import_zod.z.literal(SCOPES.RECORD_BULK_PRINT_CERTIFIED_COPIES),
185
+ import_zod.z.literal(SCOPES.RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES),
186
+ import_zod.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_CORRECTION),
187
+ import_zod.z.literal(SCOPES.RECORD_REGISTRATION_CORRECT),
188
+ import_zod.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REVOCATION),
189
+ import_zod.z.literal(SCOPES.RECORD_REGISTRATION_REVOKE),
190
+ import_zod.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REINSTATEMENT),
191
+ import_zod.z.literal(SCOPES.RECORD_REGISTRATION_REINSTATE),
192
+ import_zod.z.literal(SCOPES.RECORD_CONFIRM_REGISTRATION),
193
+ import_zod.z.literal(SCOPES.RECORD_REJECT_REGISTRATION),
194
+ import_zod.z.literal(SCOPES.SEARCH_BIRTH_MY_JURISDICTION),
195
+ import_zod.z.literal(SCOPES.SEARCH_BIRTH),
196
+ import_zod.z.literal(SCOPES.SEARCH_DEATH_MY_JURISDICTION),
197
+ import_zod.z.literal(SCOPES.SEARCH_DEATH),
198
+ import_zod.z.literal(SCOPES.SEARCH_MARRIAGE_MY_JURISDICTION),
199
+ import_zod.z.literal(SCOPES.SEARCH_MARRIAGE),
200
+ import_zod.z.literal(SCOPES.RECORD_READ),
201
+ import_zod.z.literal(SCOPES.RECORD_READ_AUDIT),
202
+ import_zod.z.literal(SCOPES.RECORD_READ_COMMENTS),
203
+ import_zod.z.literal(SCOPES.RECORD_CREATE_COMMENTS),
204
+ import_zod.z.literal(SCOPES.PROFILE_UPDATE),
205
+ import_zod.z.literal(SCOPES.PROFILE_ELECTRONIC_SIGNATURE),
206
+ import_zod.z.literal(SCOPES.PERFORMANCE_READ),
207
+ import_zod.z.literal(SCOPES.PERFORMANCE_READ_DASHBOARDS),
208
+ import_zod.z.literal(SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS),
209
+ import_zod.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS),
210
+ import_zod.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_OFFICE),
211
+ import_zod.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_JURISDICTION),
212
+ import_zod.z.literal(SCOPES.USER_READ),
213
+ import_zod.z.literal(SCOPES.USER_READ_MY_OFFICE),
214
+ import_zod.z.literal(SCOPES.USER_READ_MY_JURISDICTION),
215
+ import_zod.z.literal(SCOPES.USER_READ_ONLY_MY_AUDIT),
216
+ import_zod.z.literal(SCOPES.USER_CREATE),
217
+ import_zod.z.literal(SCOPES.USER_CREATE_MY_JURISDICTION),
218
+ import_zod.z.literal(SCOPES.USER_UPDATE),
219
+ import_zod.z.literal(SCOPES.USER_UPDATE_MY_JURISDICTION),
220
+ import_zod.z.literal(SCOPES.CONFIG_UPDATE_ALL),
221
+ import_zod.z.literal(SCOPES.USER_DATA_SEEDING)
222
+ ]);
223
+ var rawConfigurableScopeRegex = /^([a-zA-Z\.]+)\[((?:\w+=[\w.-]+(?:\|[\w.-]+)*)(?:,[\w]+=[\w.-]+(?:\|[\w.-]+)*)*)\]$/;
224
+ var rawConfigurableScope = import_zod.z.string().regex(rawConfigurableScopeRegex);
225
+ var CreateUserScope = import_zod.z.object({
226
+ type: import_zod.z.literal("user.create"),
227
+ options: import_zod.z.object({
228
+ role: import_zod.z.array(import_zod.z.string())
229
+ })
230
+ });
231
+ var EditUserScope = import_zod.z.object({
232
+ type: import_zod.z.literal("user.edit"),
233
+ options: import_zod.z.object({
234
+ role: import_zod.z.array(import_zod.z.string())
235
+ })
236
+ });
237
+ var WorkqueueScope = import_zod.z.object({
238
+ type: import_zod.z.literal("workqueue"),
239
+ options: import_zod.z.object({
240
+ id: import_zod.z.array(import_zod.z.string())
241
+ })
242
+ });
243
+ var NotifyRecordScope = import_zod.z.object({
244
+ type: import_zod.z.literal("record.notify"),
245
+ options: import_zod.z.object({
246
+ event: import_zod.z.array(import_zod.z.string())
247
+ })
248
+ });
249
+ var ConfigurableScopes = import_zod.z.discriminatedUnion("type", [
250
+ CreateUserScope,
251
+ EditUserScope,
252
+ WorkqueueScope,
253
+ NotifyRecordScope
254
+ ]);
255
+ function findScope(scopes2, scopeType) {
256
+ const parsedScopes = scopes2.map((rawScope) => parseScope(rawScope));
257
+ return parsedScopes.find(
258
+ (parsedScope) => parsedScope?.type === scopeType
259
+ );
260
+ }
261
+ function parseScope(scope) {
262
+ const maybeLiteralScope = LiteralScopes.safeParse(scope);
263
+ if (maybeLiteralScope.success) {
264
+ return {
265
+ type: maybeLiteralScope.data
266
+ };
267
+ }
268
+ const maybeConfigurableScope = rawConfigurableScope.safeParse(scope);
269
+ if (!maybeConfigurableScope.success) {
270
+ return;
271
+ }
272
+ const rawScope = maybeConfigurableScope.data;
273
+ const [, type, rawOptions] = rawScope.match(rawConfigurableScopeRegex) ?? [];
274
+ const options = rawOptions.split(",").reduce((acc, option) => {
275
+ const [key, value] = option.split("=");
276
+ acc[key] = value.split("|");
277
+ return acc;
278
+ }, {});
279
+ const parsedScope = {
280
+ type,
281
+ options
282
+ };
283
+ const result = ConfigurableScopes.safeParse(parsedScope);
284
+ return result.success ? result.data : void 0;
285
+ }
286
+ function stringifyScope(scope) {
287
+ const options = Object.entries(scope.options).map(([key, value]) => `${key}=${value.join("|")}`).join(",");
288
+ return `${scope.type}[${options}]`;
289
+ }
139
290
  var scopes = Object.values(SCOPES);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencrvs/toolkit",
3
- "version": "1.8.0-rc.fef85f2",
3
+ "version": "1.8.0-rc.ff0b26c",
4
4
  "description": "OpenCRVS toolkit for building country configurations",
5
5
  "license": "MPL-2.0",
6
6
  "exports": {
@@ -20,7 +20,8 @@
20
20
  "ajv-formats": "^3.0.1",
21
21
  "superjson": "1.9.0-0",
22
22
  "@trpc/client": "^11.0.0-rc.648",
23
- "@trpc/server": "^11.0.0-rc.532"
23
+ "@trpc/server": "^11.0.0-rc.532",
24
+ "zod-openapi": "^4.2.4"
24
25
  },
25
26
  "devDependencies": {
26
27
  "@types/uuid": "^9.0.3",