@opencrvs/toolkit 1.8.0-rc.ff0a1b5 → 1.8.0-rc.ff1f8e0

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 (38) hide show
  1. package/dist/commons/api/router.d.ts +8086 -3911
  2. package/dist/commons/conditionals/conditionals.d.ts +7 -6
  3. package/dist/commons/events/ActionConfig.d.ts +22281 -7289
  4. package/dist/commons/events/ActionDocument.d.ts +533 -346
  5. package/dist/commons/events/ActionInput.d.ts +197 -125
  6. package/dist/commons/events/AdvancedSearchConfig.d.ts +603 -12
  7. package/dist/commons/events/Constants.d.ts +2 -0
  8. package/dist/commons/events/CountryConfigQueryInput.d.ts +2982 -0
  9. package/dist/commons/events/CreatedAtLocation.d.ts +2 -0
  10. package/dist/commons/events/Draft.d.ts +29 -24
  11. package/dist/commons/events/EventConfig.d.ts +17241 -9571
  12. package/dist/commons/events/EventDocument.d.ts +386 -267
  13. package/dist/commons/events/EventIndex.d.ts +343 -466
  14. package/dist/commons/events/EventInput.d.ts +0 -13
  15. package/dist/commons/events/EventMetadata.d.ts +72 -48
  16. package/dist/commons/events/FieldConfig.d.ts +991 -428
  17. package/dist/commons/events/FieldTypeMapping.d.ts +5 -2
  18. package/dist/commons/events/FieldValue.d.ts +2 -0
  19. package/dist/commons/events/FormConfig.d.ts +7190 -3722
  20. package/dist/commons/events/PageConfig.d.ts +1512 -660
  21. package/dist/commons/events/User.d.ts +31 -7
  22. package/dist/commons/events/WorkqueueColumnConfig.d.ts +53 -0
  23. package/dist/commons/events/WorkqueueConfig.d.ts +3506 -239
  24. package/dist/commons/events/defineConfig.d.ts +1632 -574
  25. package/dist/commons/events/event.d.ts +37 -10
  26. package/dist/commons/events/field.d.ts +25 -20
  27. package/dist/commons/events/index.d.ts +4 -0
  28. package/dist/commons/events/scopes.d.ts +20 -1
  29. package/dist/commons/events/serializer.d.ts +2 -0
  30. package/dist/commons/events/test.utils.d.ts +28 -7
  31. package/dist/commons/events/transactions.d.ts +1 -1
  32. package/dist/commons/events/utils.d.ts +443 -291
  33. package/dist/commons/events/workqueueDefaultColumns.d.ts +3 -0
  34. package/dist/conditionals/index.js +28 -8
  35. package/dist/events/index.js +2153 -865
  36. package/dist/scopes/index.d.ts +94 -6
  37. package/dist/scopes/index.js +42 -21
  38. package/package.json +1 -1
@@ -19,6 +19,7 @@ export declare const SCOPES: {
19
19
  * @TODO This is a temporary scope to be used for V2 Events custom events declaration
20
20
  */
21
21
  readonly RECORD_DECLARE: "record.declare-birth";
22
+ readonly RECORD_IMPORT: "record.import";
22
23
  readonly RECORD_DECLARE_BIRTH: "record.declare-birth";
23
24
  readonly RECORD_DECLARE_BIRTH_MY_JURISDICTION: "record.declare-birth:my-jurisdiction";
24
25
  readonly RECORD_DECLARE_DEATH: "record.declare-death";
@@ -84,7 +85,7 @@ export declare const SCOPES: {
84
85
  readonly CONFIG_UPDATE_ALL: "config.update:all";
85
86
  readonly USER_DATA_SEEDING: "user.data-seeding";
86
87
  };
87
- 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.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">]>;
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">]>;
88
89
  declare const ConfigurableScopes: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
89
90
  type: z.ZodLiteral<"user.create">;
90
91
  options: z.ZodObject<{
@@ -123,19 +124,84 @@ declare const ConfigurableScopes: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
123
124
  options: {
124
125
  role: string[];
125
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
+ };
126
165
  }>]>;
127
- type ConfigurableScopes = z.infer<typeof ConfigurableScopes>;
128
- export declare function findScope(scopes: string[], scopeType: ConfigurableScopes['type']): {
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<{
129
169
  type: "user.create";
130
170
  options: {
131
171
  role: string[];
132
172
  };
133
- } | {
173
+ }, {
174
+ type: T;
175
+ }> | Extract<{
134
176
  type: "user.edit";
135
177
  options: {
136
178
  role: string[];
137
179
  };
138
- } | undefined;
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
+ */
139
205
  export declare function parseScope(scope: string): {
140
206
  type: "user.create";
141
207
  options: {
@@ -147,8 +213,30 @@ export declare function parseScope(scope: string): {
147
213
  role: string[];
148
214
  };
149
215
  } | {
150
- type: "natlsysadmin" | "bypassratelimit" | "declare" | "register" | "validate" | "demo" | "certify" | "performance" | "sysadmin" | "teams" | "config" | "webhook" | "nationalId" | "notification-api" | "recordsearch" | "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.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";
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";
151
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;
152
240
  export declare const scopes: Scope[];
153
241
  export type ParsedScopes = NonNullable<ReturnType<typeof parseScope>>;
154
242
  export type RawScopes = z.infer<typeof LiteralScopes> | (string & {});
@@ -23,7 +23,8 @@ __export(scopes_exports, {
23
23
  SCOPES: () => SCOPES,
24
24
  findScope: () => findScope,
25
25
  parseScope: () => parseScope,
26
- scopes: () => scopes
26
+ scopes: () => scopes,
27
+ stringifyScope: () => stringifyScope
27
28
  });
28
29
  module.exports = __toCommonJS(scopes_exports);
29
30
 
@@ -52,6 +53,8 @@ var SCOPES = {
52
53
  */
53
54
  RECORD_DECLARE: "record.declare-birth",
54
55
  // declare
56
+ RECORD_IMPORT: "record.import",
57
+ // declare
55
58
  RECORD_DECLARE_BIRTH: "record.declare-birth",
56
59
  RECORD_DECLARE_BIRTH_MY_JURISDICTION: "record.declare-birth:my-jurisdiction",
57
60
  RECORD_DECLARE_DEATH: "record.declare-death",
@@ -155,6 +158,7 @@ var LiteralScopes = import_zod.z.union([
155
158
  import_zod.z.literal(SCOPES.NATIONALID),
156
159
  import_zod.z.literal(SCOPES.NOTIFICATION_API),
157
160
  import_zod.z.literal(SCOPES.RECORDSEARCH),
161
+ import_zod.z.literal(SCOPES.RECORD_IMPORT),
158
162
  import_zod.z.literal(SCOPES.RECORD_DECLARE_BIRTH),
159
163
  import_zod.z.literal(SCOPES.RECORD_DECLARE_BIRTH_MY_JURISDICTION),
160
164
  import_zod.z.literal(SCOPES.RECORD_DECLARE_DEATH),
@@ -216,7 +220,7 @@ var LiteralScopes = import_zod.z.union([
216
220
  import_zod.z.literal(SCOPES.CONFIG_UPDATE_ALL),
217
221
  import_zod.z.literal(SCOPES.USER_DATA_SEEDING)
218
222
  ]);
219
- var rawConfigurableScopeRegex = /^([a-zA-Z]+\.[a-zA-Z]+)\[((?:\w+=\w+(?:\|\w+)*)(:?,\w+=\w+(?:\|\w+)*)*)\]$/;
223
+ var rawConfigurableScopeRegex = /^([a-zA-Z\.]+)\[((?:\w+=[\w.-]+(?:\|[\w.-]+)*)(?:,[\w]+=[\w.-]+(?:\|[\w.-]+)*)*)\]$/;
220
224
  var rawConfigurableScope = import_zod.z.string().regex(rawConfigurableScopeRegex);
221
225
  var CreateUserScope = import_zod.z.object({
222
226
  type: import_zod.z.literal("user.create"),
@@ -230,12 +234,27 @@ var EditUserScope = import_zod.z.object({
230
234
  role: import_zod.z.array(import_zod.z.string())
231
235
  })
232
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
+ });
233
249
  var ConfigurableScopes = import_zod.z.discriminatedUnion("type", [
234
250
  CreateUserScope,
235
- EditUserScope
251
+ EditUserScope,
252
+ WorkqueueScope,
253
+ NotifyRecordScope
236
254
  ]);
237
255
  function findScope(scopes2, scopeType) {
238
- return scopes2.map((rawScope) => parseScope(rawScope)).find(
256
+ const parsedScopes = scopes2.map((rawScope) => parseScope(rawScope));
257
+ return parsedScopes.find(
239
258
  (parsedScope) => parsedScope?.type === scopeType
240
259
  );
241
260
  }
@@ -247,23 +266,25 @@ function parseScope(scope) {
247
266
  };
248
267
  }
249
268
  const maybeConfigurableScope = rawConfigurableScope.safeParse(scope);
250
- if (maybeConfigurableScope.success) {
251
- const rawScope = maybeConfigurableScope.data;
252
- const [, type, rawOptions] = rawScope.match(rawConfigurableScopeRegex) ?? [];
253
- const options = rawOptions.split(",").reduce((acc, option) => {
254
- const [key, value] = option.split("=");
255
- acc[key] = value.split("|");
256
- return acc;
257
- }, {});
258
- const parsedScope = {
259
- type,
260
- options
261
- };
262
- const result = ConfigurableScopes.safeParse(parsedScope);
263
- if (result.success) {
264
- return result.data;
265
- }
269
+ if (!maybeConfigurableScope.success) {
270
+ return;
266
271
  }
267
- return void 0;
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}]`;
268
289
  }
269
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.ff0a1b5",
3
+ "version": "1.8.0-rc.ff1f8e0",
4
4
  "description": "OpenCRVS toolkit for building country configurations",
5
5
  "license": "MPL-2.0",
6
6
  "exports": {