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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/build.sh +5 -0
  2. package/dist/api/index.d.ts.map +1 -1
  3. package/dist/application-config/index.d.ts +2 -0
  4. package/dist/application-config/index.d.ts.map +1 -0
  5. package/dist/application-config/index.js +124 -0
  6. package/dist/commons/api/router.d.ts +3163 -2251
  7. package/dist/commons/application-config/index.d.ts +87 -0
  8. package/dist/commons/conditionals/conditionals.d.ts +27 -3
  9. package/dist/commons/conditionals/validate.d.ts +13 -2
  10. package/dist/commons/events/ActionConfig.d.ts +415 -1555
  11. package/dist/commons/events/ActionDocument.d.ts +888 -1941
  12. package/dist/commons/events/ActionInput.d.ts +277 -1073
  13. package/dist/commons/events/ActionType.d.ts +91 -11
  14. package/dist/commons/events/AdvancedSearchConfig.d.ts +288 -1496
  15. package/dist/commons/events/AuditLog.d.ts +223 -0
  16. package/dist/commons/events/CompositeFieldValue.d.ts +30 -190
  17. package/dist/commons/events/Conditional.d.ts +26 -38
  18. package/dist/commons/events/Constants.d.ts +1 -1
  19. package/dist/commons/events/CountryConfigQueryInput.d.ts +1345 -4495
  20. package/dist/commons/events/DeduplicationConfig.d.ts +15 -171
  21. package/dist/commons/events/Draft.d.ts +72 -107
  22. package/dist/commons/events/DynamicFieldValue.d.ts +7 -91
  23. package/dist/commons/events/EventConfig.d.ts +35 -2420
  24. package/dist/commons/events/EventConfigInput.d.ts +0 -3
  25. package/dist/commons/events/EventDocument.d.ts +354 -1366
  26. package/dist/commons/events/EventIndex.d.ts +208 -1014
  27. package/dist/commons/events/EventInput.d.ts +3 -8
  28. package/dist/commons/events/EventMetadata.d.ts +130 -357
  29. package/dist/commons/events/FieldConfig.d.ts +2671 -12896
  30. package/dist/commons/events/FieldType.d.ts +25 -4
  31. package/dist/commons/events/FieldTypeMapping.d.ts +289 -907
  32. package/dist/commons/events/FieldValue.d.ts +121 -527
  33. package/dist/commons/events/FileUtils.d.ts +2 -2
  34. package/dist/commons/events/Flag.d.ts +67 -0
  35. package/dist/commons/events/FormConfig.d.ts +54 -721
  36. package/dist/commons/events/PageConfig.d.ts +58 -320
  37. package/dist/commons/events/PlainDate.d.ts +1 -1
  38. package/dist/commons/events/SummaryConfig.d.ts +14 -161
  39. package/dist/commons/events/TemplateConfig.d.ts +2 -3
  40. package/dist/commons/events/TranslationConfig.d.ts +2 -2
  41. package/dist/commons/events/WorkqueueColumnConfig.d.ts +74 -37
  42. package/dist/commons/events/WorkqueueConfig.d.ts +2008 -7597
  43. package/dist/commons/events/deduplication.d.ts +3 -3
  44. package/dist/commons/events/defineConfig.d.ts +2 -243
  45. package/dist/commons/events/eventConfigValidation.d.ts +8 -0
  46. package/dist/commons/events/index.d.ts +3 -0
  47. package/dist/commons/events/locations.d.ts +57 -20
  48. package/dist/commons/events/scopes.d.ts +33 -33
  49. package/dist/commons/events/state/availableActions.d.ts +7 -2
  50. package/dist/commons/events/state/flags.d.ts +21 -3
  51. package/dist/commons/events/state/index.d.ts +30 -27
  52. package/dist/commons/events/state/utils.d.ts +190 -172
  53. package/dist/commons/events/test.utils.d.ts +52 -11
  54. package/dist/commons/events/transactions.d.ts +1 -1
  55. package/dist/commons/events/utils.d.ts +413 -310
  56. package/dist/commons/notification/UserNotifications.d.ts +55 -636
  57. package/dist/conditionals/index.d.ts.map +1 -1
  58. package/dist/conditionals/index.js +587 -14
  59. package/dist/events/deduplication.d.ts +3 -3
  60. package/dist/events/index.js +2689 -1891
  61. package/dist/notification/index.d.ts.map +1 -1
  62. package/dist/notification/index.js +1987 -1553
  63. package/dist/scopes/index.d.ts +352 -302
  64. package/dist/scopes/index.d.ts.map +1 -1
  65. package/dist/scopes/index.js +444 -210
  66. package/opencrvs-toolkit-1.9.12-rc.ba08187.tgz +0 -0
  67. package/package.json +11 -5
  68. package/tsconfig.json +9 -2
  69. package/tsconfig.tsbuildinfo +1 -1
  70. package/dist/commons/events/CreatedAtLocation.d.ts +0 -2
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/conditionals/index.ts"],"names":[],"mappings":"AAUA,cAAc,gCAAgC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/conditionals/index.ts"],"names":[],"mappings":"AAaA,cAAc,gCAAgC,CAAA"}
@@ -35,23 +35,26 @@ __export(conditionals_exports, {
35
35
  createFieldConditionals: () => createFieldConditionals,
36
36
  defineConditional: () => defineConditional,
37
37
  defineFormConditional: () => defineFormConditional,
38
+ flag: () => flag,
38
39
  isEventFieldReference: () => isEventFieldReference,
39
40
  isFieldReference: () => isFieldReference,
40
41
  never: () => never,
41
42
  not: () => not,
42
43
  now: () => now,
43
44
  or: () => or,
45
+ status: () => status,
44
46
  user: () => user
45
47
  });
46
48
  module.exports = __toCommonJS(conditionals_exports);
49
+ var z9 = __toESM(require("zod/v4"));
47
50
 
48
51
  // ../commons/src/conditionals/conditionals.ts
49
52
  var objectHash = __toESM(require("object-hash"));
50
53
 
51
54
  // ../commons/src/events/serializers/user/serializer.ts
52
- var import_zod = require("zod");
53
- var SerializedUserField = import_zod.z.object({
54
- $userField: import_zod.z.enum([
55
+ var z = __toESM(require("zod/v4"));
56
+ var SerializedUserField = z.object({
57
+ $userField: z.enum([
55
58
  "id",
56
59
  "name",
57
60
  "role",
@@ -60,11 +63,12 @@ var SerializedUserField = import_zod.z.object({
60
63
  "firstname",
61
64
  "middlename",
62
65
  "surname",
63
- "district",
64
- "province",
65
- "primaryOfficeId"
66
+ "signature",
67
+ "avatar",
68
+ "primaryOfficeId",
69
+ "administrativeAreaId"
66
70
  ]),
67
- $location: import_zod.z.string().optional()
71
+ $location: z.string().optional()
68
72
  });
69
73
  function userSerializer(userField) {
70
74
  return {
@@ -84,7 +88,7 @@ function userSerializer(userField) {
84
88
  }
85
89
 
86
90
  // ../commons/src/utils.ts
87
- var z2 = __toESM(require("zod"));
91
+ var z2 = __toESM(require("zod/v4"));
88
92
  var _ = __toESM(require("lodash"));
89
93
  var FullNameV1 = z2.array(
90
94
  z2.object({
@@ -110,14 +114,554 @@ function omitKeyDeep(obj, keyToRemove) {
110
114
  }
111
115
 
112
116
  // ../commons/src/events/serializers/date/serializer.ts
113
- var import_zod2 = require("zod");
114
- var SerializedNowDateTime = import_zod2.z.object({
115
- $$now: import_zod2.z.literal(true)
117
+ var import_zod = require("zod");
118
+ var SerializedNowDateTime = import_zod.z.object({
119
+ $$now: import_zod.z.literal(true)
116
120
  });
117
121
  function todayDateTimeValueSerializer() {
118
122
  return { $$now: true };
119
123
  }
120
124
 
125
+ // ../commons/src/scopes.ts
126
+ var z6 = __toESM(require("zod/v4"));
127
+ var qs = __toESM(require("qs"));
128
+
129
+ // ../commons/src/uuid.ts
130
+ var import_uuid = require("uuid");
131
+ var z4 = __toESM(require("zod/v4"));
132
+ var UUID = z4.uuid().brand("UUID");
133
+
134
+ // ../commons/src/scopes.deprecated.do-not-use.ts
135
+ var z5 = __toESM(require("zod/v4"));
136
+ var rawConfigurableScopeRegex = /^([a-zA-Z][a-zA-Z0-9.-]*(?:\.[a-zA-Z0-9.-]+)*)\[((?:\w+=[\w.-]+(?:\|[\w.-]+)*)(?:,[\w]+=[\w.-]+(?:\|[\w.-]+)*)*)\]$/;
137
+ var rawConfigurableScope = z5.string().regex(rawConfigurableScopeRegex);
138
+ var SearchScope = z5.object({
139
+ type: z5.literal("search"),
140
+ options: z5.object({
141
+ event: z5.array(z5.string()).length(1),
142
+ access: z5.array(z5.enum(["my-jurisdiction", "all"])).length(1)
143
+ })
144
+ });
145
+ var CreateUserScope = z5.object({
146
+ type: z5.literal("user.create"),
147
+ options: z5.object({
148
+ role: z5.array(z5.string())
149
+ })
150
+ });
151
+ var EditUserScope = z5.object({
152
+ type: z5.literal("user.edit"),
153
+ options: z5.object({
154
+ role: z5.array(z5.string())
155
+ })
156
+ });
157
+ var WorkqueueScope = z5.object({
158
+ type: z5.literal("workqueue"),
159
+ options: z5.object({
160
+ id: z5.array(z5.string())
161
+ })
162
+ });
163
+ var PrintCertifiedCopiesScope = z5.object({
164
+ type: z5.literal("record.registered.print-certified-copies"),
165
+ options: z5.object({
166
+ event: z5.array(z5.string()).describe("Event type, e.g. birth, death"),
167
+ templates: z5.array(z5.string()).optional().describe(
168
+ "Template IDs for certified copies. If not provided, all templates will be used."
169
+ )
170
+ })
171
+ });
172
+ var LegacyRecordScope = z5.object({
173
+ type: z5.enum([
174
+ "record.create",
175
+ "record.read",
176
+ "record.declare",
177
+ "record.notify",
178
+ "record.declared.edit",
179
+ "record.declared.validate",
180
+ "record.declared.reject",
181
+ "record.declared.archive",
182
+ "record.declared.review-duplicates",
183
+ "record.register",
184
+ "record.registered.request-correction",
185
+ "record.registered.correct",
186
+ "record.unassign-others"
187
+ ]),
188
+ options: z5.object({
189
+ event: z5.array(z5.string()).describe("Event type, e.g. birth, death")
190
+ })
191
+ }).describe(
192
+ "Scopes used to check user's permission to perform actions on a record."
193
+ );
194
+ var ConfigurableRawScopes = z5.discriminatedUnion("type", [
195
+ SearchScope,
196
+ LegacyRecordScope,
197
+ PrintCertifiedCopiesScope,
198
+ CreateUserScope,
199
+ EditUserScope,
200
+ WorkqueueScope
201
+ ]);
202
+
203
+ // ../commons/src/scopes.ts
204
+ var SCOPES = {
205
+ // TODO v1.8 legacy scopes
206
+ BYPASSRATELIMIT: "bypassratelimit",
207
+ REGISTER: "register",
208
+ DEMO: "demo",
209
+ CONFIG: "config",
210
+ // systems / integrations
211
+ WEBHOOK: "webhook",
212
+ NATIONALID: "nationalId",
213
+ NOTIFICATION_API: "notification-api",
214
+ RECORDSEARCH: "recordsearch",
215
+ RECORD_IMPORT: "record.import",
216
+ RECORD_EXPORT: "record.export",
217
+ RECORD_REINDEX: "record.reindex",
218
+ INTEGRATION_CREATE: "integration.create",
219
+ // declare
220
+ RECORD_DECLARE_BIRTH: "record.declare-birth",
221
+ RECORD_DECLARE_BIRTH_MY_JURISDICTION: "record.declare-birth:my-jurisdiction",
222
+ RECORD_DECLARE_DEATH: "record.declare-death",
223
+ RECORD_DECLARE_DEATH_MY_JURISDICTION: "record.declare-death:my-jurisdiction",
224
+ RECORD_DECLARE_MARRIAGE: "record.declare-marriage",
225
+ RECORD_DECLARE_MARRIAGE_MY_JURISDICTION: "record.declare-marriage:my-jurisdiction",
226
+ RECORD_SUBMIT_INCOMPLETE: "record.declaration-submit-incomplete",
227
+ // @todo: should this record be removed from events v2?
228
+ RECORD_SUBMIT_FOR_REVIEW: "record.declaration-submit-for-review",
229
+ RECORD_UNASSIGN_OTHERS: "record.unassign-others",
230
+ // validate
231
+ RECORD_SUBMIT_FOR_APPROVAL: "record.declaration-submit-for-approval",
232
+ RECORD_SUBMIT_FOR_UPDATES: "record.declaration-submit-for-updates",
233
+ RECORD_DECLARATION_EDIT: "record.declaration-edit",
234
+ RECORD_REVIEW_DUPLICATES: "record.review-duplicates",
235
+ RECORD_DECLARATION_ARCHIVE: "record.declaration-archive",
236
+ RECORD_DECLARATION_REINSTATE: "record.declaration-reinstate",
237
+ // register
238
+ RECORD_REGISTER: "record.register",
239
+ /**
240
+ * This scope is used to **print and **issue certified copies of a record
241
+ * after it has been registered. Previously Registrars had this permission.
242
+ */
243
+ RECORD_PRINT_ISSUE_CERTIFIED_COPIES: "record.registration-print&issue-certified-copies",
244
+ // correct
245
+ RECORD_REGISTRATION_REQUEST_CORRECTION: "record.registration-request-correction",
246
+ RECORD_REGISTRATION_CORRECT: "record.registration-correct",
247
+ RECORD_CONFIRM_REGISTRATION: "record.confirm-registration",
248
+ RECORD_REJECT_REGISTRATION: "record.reject-registration",
249
+ // search
250
+ SEARCH_BIRTH_MY_JURISDICTION: "search.birth:my-jurisdiction",
251
+ SEARCH_BIRTH: "search.birth",
252
+ SEARCH_DEATH_MY_JURISDICTION: "search.death:my-jurisdiction",
253
+ SEARCH_DEATH: "search.death",
254
+ SEARCH_MARRIAGE_MY_JURISDICTION: "search.marriage:my-jurisdiction",
255
+ SEARCH_MARRIAGE: "search.marriage",
256
+ // audit v1.8
257
+ RECORD_READ: "record.read",
258
+ // profile
259
+ PROFILE_ELECTRONIC_SIGNATURE: "profile.electronic-signature",
260
+ // performance
261
+ PERFORMANCE_READ: "performance.read",
262
+ PERFORMANCE_READ_DASHBOARDS: "performance.read-dashboards",
263
+ PERFORMANCE_EXPORT_VITAL_STATISTICS: "performance.vital-statistics-export",
264
+ // organisation
265
+ ORGANISATION_READ_LOCATIONS: "organisation.read-locations:all",
266
+ ORGANISATION_READ_LOCATIONS_MY_OFFICE: "organisation.read-locations:my-office",
267
+ ORGANISATION_READ_LOCATIONS_MY_JURISDICTION: "organisation.read-locations:my-jurisdiction",
268
+ // user
269
+ USER_READ: "user.read:all",
270
+ USER_READ_MY_OFFICE: "user.read:my-office",
271
+ USER_READ_MY_JURISDICTION: "user.read:my-jurisdiction",
272
+ USER_READ_ONLY_MY_AUDIT: "user.read:only-my-audit",
273
+ //v1.8
274
+ USER_CREATE: "user.create:all",
275
+ USER_CREATE_MY_JURISDICTION: "user.create:my-jurisdiction",
276
+ USER_UPDATE: "user.update:all",
277
+ USER_UPDATE_MY_JURISDICTION: "user.update:my-jurisdiction",
278
+ // config
279
+ CONFIG_UPDATE_ALL: "config.update:all",
280
+ // data seeding
281
+ USER_DATA_SEEDING: "user.data-seeding",
282
+ // attachment
283
+ ATTACHMENT_UPLOAD: "attachment.upload"
284
+ };
285
+ var LegacyScopes = z6.union([
286
+ z6.literal(SCOPES.BYPASSRATELIMIT),
287
+ z6.literal(SCOPES.REGISTER),
288
+ z6.literal(SCOPES.DEMO),
289
+ z6.literal(SCOPES.CONFIG)
290
+ ]);
291
+ var IntegrationScopes = z6.union([
292
+ z6.literal(SCOPES.WEBHOOK),
293
+ z6.literal(SCOPES.NATIONALID),
294
+ z6.literal(SCOPES.NOTIFICATION_API),
295
+ z6.literal(SCOPES.RECORDSEARCH),
296
+ z6.literal(SCOPES.INTEGRATION_CREATE)
297
+ ]);
298
+ var InternalOperationsScopes = z6.union([
299
+ z6.literal(SCOPES.RECORD_REINDEX),
300
+ z6.literal(SCOPES.RECORD_IMPORT)
301
+ ]);
302
+ var PerformanceScopes = z6.union([
303
+ z6.literal(SCOPES.PERFORMANCE_READ),
304
+ z6.literal(SCOPES.PERFORMANCE_READ_DASHBOARDS),
305
+ z6.literal(SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS)
306
+ ]);
307
+ var OrganisationScopes = z6.union([
308
+ z6.literal(SCOPES.ORGANISATION_READ_LOCATIONS),
309
+ z6.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_OFFICE),
310
+ z6.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_JURISDICTION)
311
+ ]);
312
+ var UserScopes = z6.union([
313
+ z6.literal(SCOPES.USER_READ),
314
+ z6.literal(SCOPES.USER_READ_MY_OFFICE),
315
+ z6.literal(SCOPES.USER_READ_MY_JURISDICTION),
316
+ z6.literal(SCOPES.USER_READ_ONLY_MY_AUDIT),
317
+ z6.literal(SCOPES.USER_CREATE),
318
+ z6.literal(SCOPES.USER_CREATE_MY_JURISDICTION),
319
+ z6.literal(SCOPES.USER_UPDATE),
320
+ z6.literal(SCOPES.USER_UPDATE_MY_JURISDICTION)
321
+ ]);
322
+ var ConfigScope = z6.literal(SCOPES.CONFIG_UPDATE_ALL);
323
+ var DataSeedingScope = z6.literal(SCOPES.USER_DATA_SEEDING);
324
+ var AttachmentScope = z6.literal(SCOPES.ATTACHMENT_UPLOAD);
325
+ var LiteralScopes = z6.union([
326
+ LegacyScopes,
327
+ IntegrationScopes,
328
+ z6.literal(SCOPES.PROFILE_ELECTRONIC_SIGNATURE),
329
+ z6.literal(SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES),
330
+ PerformanceScopes,
331
+ OrganisationScopes,
332
+ UserScopes,
333
+ ConfigScope,
334
+ DataSeedingScope,
335
+ InternalOperationsScopes,
336
+ AttachmentScope
337
+ ]);
338
+ var JurisdictionFilter = z6.enum(["administrativeArea", "location", "all"]).describe(
339
+ "Filters based on user jurisdiction relative to their office location in hierarchy."
340
+ );
341
+ var UserFilter = z6.enum(["user"]).describe("Filters based on the user. Limits to self.");
342
+ var RecordScopeTypeV2 = z6.enum([
343
+ "record.search",
344
+ "record.create",
345
+ "record.read",
346
+ "record.declare",
347
+ "record.notify",
348
+ "record.edit",
349
+ "record.reject",
350
+ "record.archive",
351
+ "record.review-duplicates",
352
+ "record.register",
353
+ "record.print-certified-copies",
354
+ "record.request-correction",
355
+ "record.correct",
356
+ "record.unassign-others",
357
+ "record.custom-action"
358
+ ]);
359
+ var scopeByEvent = z6.preprocess(
360
+ (val) => val === void 0 ? void 0 : [val].flat(),
361
+ z6.array(z6.string()).optional()
362
+ ).describe("Event type, e.g. birth, death");
363
+ var scopeOptionsPlaceEvent = z6.object({
364
+ event: scopeByEvent,
365
+ placeOfEvent: JurisdictionFilter.optional()
366
+ }).describe("Options applicable to all record scopes.");
367
+ var scopeOptionsDeclared = scopeOptionsPlaceEvent.extend({
368
+ declaredIn: JurisdictionFilter.optional(),
369
+ declaredBy: UserFilter.optional()
370
+ }).describe("Options applicable to actions that may take place after DECLARE");
371
+ var ScopeOptionsFull = scopeOptionsDeclared.extend({
372
+ registeredIn: JurisdictionFilter.optional(),
373
+ registeredBy: UserFilter.optional()
374
+ }).describe(
375
+ "Options applicable to actions that may take place after REGISTER, with full filtering capabilities."
376
+ );
377
+ var CustomActionScopeOptions = ScopeOptionsFull.extend({
378
+ customActionTypes: z6.preprocess(
379
+ (val) => val === void 0 ? void 0 : [val].flat(),
380
+ z6.array(z6.string()).optional()
381
+ ).describe("Allowed custom action types")
382
+ });
383
+ var ScopeOptionKey = ScopeOptionsFull.keyof();
384
+ var ResolvedScopeOptionsPlaceEvent = z6.object({
385
+ event: scopeByEvent,
386
+ placeOfEvent: UUID.nullish()
387
+ }).describe(
388
+ "Resolved options applicable to all record scopes, with location ID instead of jurisdiction filter."
389
+ );
390
+ var ResolvedScopeOptionsDeclared = ResolvedScopeOptionsPlaceEvent.extend({
391
+ declaredIn: UUID.nullish(),
392
+ declaredBy: z6.string().optional()
393
+ }).describe(
394
+ "Resolved options applicable to actions that may take place after DECLARE, with location ID and user ID instead of filters."
395
+ );
396
+ var ResolvedScopeOptionsFull = ResolvedScopeOptionsDeclared.extend({
397
+ registeredIn: UUID.nullish(),
398
+ registeredBy: z6.string().optional()
399
+ }).describe(
400
+ "Resolved options applicable to actions that may take place after REGISTER, with full filtering capabilities and location/user IDs instead of filters."
401
+ );
402
+ var ScopesWithPlaceEventOptions = RecordScopeTypeV2.extract([
403
+ "record.create",
404
+ "record.declare",
405
+ "record.notify"
406
+ ]);
407
+ var ScopesWithDeclaredOptions = RecordScopeTypeV2.extract([
408
+ "record.edit",
409
+ "record.reject",
410
+ "record.archive",
411
+ "record.review-duplicates",
412
+ "record.register"
413
+ ]);
414
+ var ScopesWithFullOptions = RecordScopeTypeV2.extract([
415
+ "record.search",
416
+ "record.read",
417
+ "record.request-correction",
418
+ "record.correct",
419
+ "record.unassign-others"
420
+ ]);
421
+ var ScopeOptionsPrintCertifiedCopies = ScopeOptionsFull.extend({
422
+ templates: z6.preprocess(
423
+ (val) => val === void 0 ? void 0 : [val].flat(),
424
+ z6.array(z6.string()).optional()
425
+ ).describe(
426
+ "Template IDs for certified copies. Controls which certificate templates are returned to the client via the config service. Certificate printing is a client-side operation \u2014 this option is not validated when the printCertificate action is submitted."
427
+ )
428
+ });
429
+ var RecordScopeV2 = z6.discriminatedUnion("type", [
430
+ z6.object({
431
+ type: ScopesWithPlaceEventOptions,
432
+ options: scopeOptionsPlaceEvent.optional()
433
+ }),
434
+ z6.object({
435
+ type: ScopesWithDeclaredOptions,
436
+ options: scopeOptionsDeclared.optional()
437
+ }),
438
+ z6.object({
439
+ type: ScopesWithFullOptions,
440
+ options: ScopeOptionsFull.optional()
441
+ }),
442
+ z6.object({
443
+ type: z6.literal("record.custom-action"),
444
+ options: CustomActionScopeOptions.optional()
445
+ }),
446
+ z6.object({
447
+ type: z6.literal("record.print-certified-copies"),
448
+ options: ScopeOptionsPrintCertifiedCopies.optional()
449
+ })
450
+ ]).describe(
451
+ "Scopes used to check user's permission to perform actions on a record."
452
+ );
453
+ var ResolvedRecordScopeV2 = z6.discriminatedUnion("type", [
454
+ z6.object({
455
+ type: ScopesWithPlaceEventOptions,
456
+ options: ResolvedScopeOptionsPlaceEvent.optional()
457
+ }),
458
+ z6.object({
459
+ type: ScopesWithDeclaredOptions,
460
+ options: ResolvedScopeOptionsDeclared.optional()
461
+ }),
462
+ z6.object({
463
+ type: ScopesWithFullOptions,
464
+ options: ResolvedScopeOptionsFull.optional()
465
+ }),
466
+ z6.object({
467
+ type: z6.literal("record.print-certified-copies"),
468
+ options: ResolvedScopeOptionsFull.extend({
469
+ templates: z6.array(z6.string()).optional()
470
+ }).optional()
471
+ })
472
+ ]).describe("Resolved scope with location/user IDs instead of filters.");
473
+ var flattenScope = (scope) => ({
474
+ type: scope.type,
475
+ ...scope.options
476
+ });
477
+ var encodeScope = (scope) => {
478
+ const flattened = flattenScope(scope);
479
+ return qs.stringify(flattened, {
480
+ arrayFormat: "comma",
481
+ allowDots: true,
482
+ addQueryPrefix: false,
483
+ encode: false
484
+ });
485
+ };
486
+ var DEFAULT_SCOPE_OPTIONS = {
487
+ placeOfEvent: JurisdictionFilter.enum.all
488
+ };
489
+
490
+ // ../commons/src/authentication.ts
491
+ var import_jwt_decode = __toESM(require("jwt-decode"));
492
+ var z7 = __toESM(require("zod/v4"));
493
+ var DEFAULT_ROLES_DEFINITION = [
494
+ {
495
+ id: "FIELD_AGENT",
496
+ label: {
497
+ defaultMessage: "Field Agent",
498
+ description: "Name for user role Field Agent",
499
+ id: "userRole.fieldAgent"
500
+ },
501
+ scopes: [
502
+ encodeScope({
503
+ type: "record.create",
504
+ options: {
505
+ event: ["birth", "death", "tennis-club-membership"]
506
+ }
507
+ }),
508
+ encodeScope({
509
+ type: "record.declare",
510
+ options: {
511
+ event: ["birth", "death", "tennis-club-membership"]
512
+ }
513
+ })
514
+ ]
515
+ },
516
+ {
517
+ id: "REGISTRATION_AGENT",
518
+ label: {
519
+ defaultMessage: "Registration Agent",
520
+ description: "Name for user role Registration Agent",
521
+ id: "userRole.registrationAgent"
522
+ },
523
+ scopes: [
524
+ encodeScope({
525
+ type: "record.create",
526
+ options: {
527
+ event: ["birth", "death", "tennis-club-membership"]
528
+ }
529
+ }),
530
+ encodeScope({
531
+ type: "record.declare",
532
+ options: {
533
+ event: ["birth", "death", "tennis-club-membership"]
534
+ }
535
+ }),
536
+ SCOPES.PERFORMANCE_READ,
537
+ SCOPES.PERFORMANCE_READ_DASHBOARDS,
538
+ SCOPES.ORGANISATION_READ_LOCATIONS,
539
+ SCOPES.ORGANISATION_READ_LOCATIONS_MY_OFFICE
540
+ ]
541
+ },
542
+ {
543
+ id: "LOCAL_REGISTRAR",
544
+ label: {
545
+ defaultMessage: "Local Registrar",
546
+ description: "Name for user role Local Registrar",
547
+ id: "userRole.localRegistrar"
548
+ },
549
+ scopes: [
550
+ encodeScope({
551
+ type: "record.create",
552
+ options: {
553
+ event: ["birth", "death", "tennis-club-membership"]
554
+ }
555
+ }),
556
+ encodeScope({
557
+ type: "record.declare",
558
+ options: {
559
+ event: ["birth", "death", "tennis-club-membership"]
560
+ }
561
+ }),
562
+ encodeScope({
563
+ type: "record.review-duplicates",
564
+ options: {
565
+ event: ["birth", "death", "tennis-club-membership"]
566
+ }
567
+ }),
568
+ SCOPES.PERFORMANCE_READ,
569
+ SCOPES.PERFORMANCE_READ_DASHBOARDS,
570
+ SCOPES.ORGANISATION_READ_LOCATIONS,
571
+ SCOPES.PROFILE_ELECTRONIC_SIGNATURE,
572
+ SCOPES.ORGANISATION_READ_LOCATIONS_MY_OFFICE
573
+ ]
574
+ },
575
+ {
576
+ id: "LOCAL_SYSTEM_ADMIN",
577
+ label: {
578
+ defaultMessage: "Local System Admin",
579
+ description: "Name for user role Local System Admin",
580
+ id: "userRole.localSystemAdmin"
581
+ },
582
+ scopes: [
583
+ SCOPES.USER_READ_MY_OFFICE,
584
+ SCOPES.USER_CREATE_MY_JURISDICTION,
585
+ SCOPES.USER_UPDATE_MY_JURISDICTION,
586
+ SCOPES.ORGANISATION_READ_LOCATIONS,
587
+ SCOPES.PERFORMANCE_READ,
588
+ SCOPES.PERFORMANCE_READ_DASHBOARDS,
589
+ SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS
590
+ ]
591
+ },
592
+ {
593
+ id: "NATIONAL_SYSTEM_ADMIN",
594
+ label: {
595
+ defaultMessage: "National System Admin",
596
+ description: "Name for user role National System Admin",
597
+ id: "userRole.nationalSystemAdmin"
598
+ },
599
+ scopes: [
600
+ SCOPES.USER_CREATE,
601
+ SCOPES.USER_READ,
602
+ SCOPES.USER_UPDATE,
603
+ SCOPES.ORGANISATION_READ_LOCATIONS,
604
+ SCOPES.PERFORMANCE_READ,
605
+ SCOPES.PERFORMANCE_READ_DASHBOARDS,
606
+ SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS
607
+ ]
608
+ },
609
+ {
610
+ id: "PERFORMANCE_MANAGER",
611
+ label: {
612
+ defaultMessage: "Performance Manager",
613
+ description: "Name for user role Performance Manager",
614
+ id: "userRole.performanceManager"
615
+ },
616
+ scopes: [
617
+ SCOPES.PERFORMANCE_READ,
618
+ SCOPES.PERFORMANCE_READ_DASHBOARDS,
619
+ SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS
620
+ ]
621
+ }
622
+ ];
623
+ var TokenUserType = z7.enum(["user", "system"]);
624
+ var TokenWithBearer = z7.string().regex(/^Bearer\s/);
625
+
626
+ // ../commons/src/users/userReferences.ts
627
+ var import_v4 = __toESM(require("zod/v4"));
628
+ var ScopeOptionReference = import_v4.default.object({
629
+ $scope: RecordScopeTypeV2,
630
+ $option: ScopeOptionKey
631
+ });
632
+ var JurisdictionReference = import_v4.default.object({
633
+ $jurisdiction: JurisdictionFilter.or(ScopeOptionReference)
634
+ });
635
+ var userReferenceFunctions = {
636
+ scope: (scope) => ({
637
+ /**
638
+ * user.scope().attribute() is used to create a scope option reference.
639
+ *
640
+ * E.g.: user.scope('record.create').attribute('placeOfEvent')
641
+ *
642
+ * @param option - The option to create a reference for.
643
+ * @returns A scope option reference.
644
+ */
645
+ attribute: (option) => ({
646
+ $scope: scope,
647
+ $option: option
648
+ })
649
+ }),
650
+ /**
651
+ * user.jurisdicton() accepts two different kinds of parameters, either:
652
+ *
653
+ * 1. a plain jurisdiction filter: user.jurisdiction('administrativeArea')
654
+ * 2. a scope option reference: user.jurisdiction(user.scope('record.create').attribute('placeOfEvent'))
655
+ *
656
+ * These will be resolved during runtime.
657
+ *
658
+ * @param jurisdiction - The jurisdiction to resolve.
659
+ */
660
+ jurisdiction: (jurisdiction) => ({
661
+ $jurisdiction: jurisdiction
662
+ })
663
+ };
664
+
121
665
  // ../commons/src/conditionals/conditionals.ts
122
666
  function defineConditional(schema) {
123
667
  const schemaWithooutIDRef = omitKeyDeep(schema, "$id");
@@ -193,6 +737,7 @@ function wrapToPathOptional(condition, path) {
193
737
  }
194
738
  var now = Object.assign(todayDateTimeValueSerializer, {});
195
739
  var user = Object.assign(userSerializer, {
740
+ ...userReferenceFunctions,
196
741
  hasScope: (scope) => defineConditional({
197
742
  type: "object",
198
743
  properties: {
@@ -239,9 +784,7 @@ var user = Object.assign(userSerializer, {
239
784
  required: ["$online"]
240
785
  }),
241
786
  locationLevel: (adminLevelId) => ({
242
- $user: {
243
- $location: adminLevelId
244
- }
787
+ $user: { $location: adminLevelId }
245
788
  })
246
789
  });
247
790
  function isFieldReference(value) {
@@ -334,6 +877,33 @@ function defineComparison(field, value, keyword) {
334
877
  required: [field.$$field]
335
878
  });
336
879
  }
880
+ function flag(flagvalue) {
881
+ return defineConditional({
882
+ type: "object",
883
+ properties: {
884
+ $flags: {
885
+ type: "array",
886
+ contains: {
887
+ type: "string",
888
+ const: flagvalue
889
+ }
890
+ }
891
+ },
892
+ required: ["$flags"]
893
+ });
894
+ }
895
+ function status(statusValue) {
896
+ return defineConditional({
897
+ type: "object",
898
+ properties: {
899
+ $status: {
900
+ type: "string",
901
+ const: statusValue
902
+ }
903
+ },
904
+ required: ["$status"]
905
+ });
906
+ }
337
907
  function createFieldConditionals(fieldId) {
338
908
  const getDayRange = (field, days, clause, referenceDate) => ({
339
909
  type: "object",
@@ -687,3 +1257,6 @@ function createFieldConditionals(fieldId) {
687
1257
  })
688
1258
  };
689
1259
  }
1260
+
1261
+ // src/conditionals/index.ts
1262
+ z9.globalRegistry.clear();
@@ -7,17 +7,17 @@ export declare function field(fieldId: string): {
7
7
  fieldId: string;
8
8
  type: "fuzzy";
9
9
  options: {
10
+ fuzziness?: string | number | undefined;
10
11
  boost?: number | undefined;
11
12
  matchAgainst?: string | undefined;
12
- fuzziness?: string | number | undefined;
13
13
  } | undefined;
14
14
  };
15
15
  strictMatches: (options?: StrictMatcherOptions) => {
16
16
  fieldId: string;
17
17
  type: "strict";
18
18
  options: {
19
- value?: string | undefined;
20
19
  boost?: number | undefined;
20
+ value?: string | undefined;
21
21
  matchAgainst?: string | undefined;
22
22
  } | undefined;
23
23
  };
@@ -60,9 +60,9 @@ export declare function field(fieldId: string): {
60
60
  type: "dateRange";
61
61
  options: {
62
62
  days: number;
63
+ pivot?: number | undefined;
63
64
  boost?: number | undefined;
64
65
  matchAgainst?: string | undefined;
65
- pivot?: number | undefined;
66
66
  };
67
67
  };
68
68
  };