@opencrvs/toolkit 1.9.12-rc.ace398e → 1.9.12-rc.ad09474

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 +3369 -2269
  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 +889 -1942
  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 +405 -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 +73 -108
  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 +2776 -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 +35 -34
  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 +191 -173
  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 +61 -637
  57. package/dist/conditionals/index.d.ts.map +1 -1
  58. package/dist/conditionals/index.js +294 -14
  59. package/dist/events/deduplication.d.ts +3 -3
  60. package/dist/events/index.js +2721 -2099
  61. package/dist/notification/index.d.ts.map +1 -1
  62. package/dist/notification/index.js +2016 -1763
  63. package/dist/scopes/index.d.ts +623 -357
  64. package/dist/scopes/index.d.ts.map +1 -1
  65. package/dist/scopes/index.js +329 -301
  66. package/opencrvs-toolkit-1.9.12-rc.ad09474.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 z8 = __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,261 @@ 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/authentication.ts
135
+ var import_jwt_decode = __toESM(require("jwt-decode"));
136
+ var z5 = __toESM(require("zod/v4"));
137
+ var TokenUserType = z5.enum(["user", "system"]);
138
+ var TokenWithBearer = z5.string().regex(/^Bearer\s/);
139
+
140
+ // ../commons/src/scopes.ts
141
+ var JurisdictionFilter = z6.enum(["administrativeArea", "location", "all"]).describe(
142
+ "Filters based on user jurisdiction relative to their office location in hierarchy."
143
+ );
144
+ var UserFilter = z6.enum(["user"]).describe("Filters based on the user. Limits to self.");
145
+ var RecordScopeTypeV2 = z6.enum([
146
+ "record.search",
147
+ "record.create",
148
+ "record.read",
149
+ "record.declare",
150
+ "record.notify",
151
+ "record.edit",
152
+ "record.reject",
153
+ "record.archive",
154
+ "record.review-duplicates",
155
+ "record.register",
156
+ "record.print-certified-copies",
157
+ "record.request-correction",
158
+ "record.correct",
159
+ "record.unassign-others",
160
+ "record.custom-action"
161
+ ]);
162
+ var PlainScopeType = z6.enum([
163
+ // Misc. system scopes
164
+ "bypassratelimit",
165
+ "record.reindex",
166
+ "user.data-seeding",
167
+ "integration.create",
168
+ "record.import",
169
+ "config.update-all",
170
+ "attachment.upload",
171
+ "profile.electronic-signature",
172
+ "user.read-only-my-audit",
173
+ // Performance dashboard
174
+ "performance.read",
175
+ "performance.read-dashboards",
176
+ "performance.vital-statistics-export",
177
+ // Scopes used exclusively by countryconfig integration token
178
+ "record.confirm-registration",
179
+ "record.reject-registration"
180
+ ]);
181
+ var scopeByEvent = z6.preprocess(
182
+ (val) => val === void 0 ? void 0 : [val].flat(),
183
+ z6.array(z6.string()).optional()
184
+ ).describe("Event type, e.g. birth, death");
185
+ var scopeOptionsPlaceEvent = z6.object({
186
+ event: scopeByEvent,
187
+ placeOfEvent: JurisdictionFilter.optional()
188
+ }).describe("Options applicable to all record scopes.");
189
+ var scopeOptionsDeclared = scopeOptionsPlaceEvent.extend({
190
+ declaredIn: JurisdictionFilter.optional(),
191
+ declaredBy: UserFilter.optional()
192
+ }).describe("Options applicable to actions that may take place after DECLARE");
193
+ var AllRecordScopeOptions = scopeOptionsDeclared.extend({
194
+ registeredIn: JurisdictionFilter.optional(),
195
+ registeredBy: UserFilter.optional()
196
+ }).describe(
197
+ "Options applicable to actions that may take place after REGISTER, with full filtering capabilities."
198
+ );
199
+ var CustomActionScopeOptions = AllRecordScopeOptions.extend({
200
+ customActionTypes: z6.preprocess(
201
+ (val) => val === void 0 ? void 0 : [val].flat(),
202
+ z6.array(z6.string()).optional()
203
+ ).describe("Allowed custom action types")
204
+ });
205
+ var AccessLevelOptions = z6.object({
206
+ accessLevel: JurisdictionFilter.optional()
207
+ });
208
+ var WorkqueueOptions = z6.object({
209
+ ids: z6.preprocess(
210
+ (val) => val === void 0 ? void 0 : [val].flat(),
211
+ z6.array(z6.string())
212
+ ).describe("Must contain a list of workqueue ids.")
213
+ });
214
+ var AllScopeOptions = z6.object({
215
+ ...AllRecordScopeOptions.shape,
216
+ ...AccessLevelOptions.shape,
217
+ ...WorkqueueOptions.shape
218
+ });
219
+ var ScopeOptionKey = AllScopeOptions.keyof();
220
+ var ResolvedScopeOptionsPlaceEvent = z6.object({
221
+ event: scopeByEvent,
222
+ placeOfEvent: UUID.nullish()
223
+ }).describe(
224
+ "Resolved options applicable to all record scopes, with location ID instead of jurisdiction filter."
225
+ );
226
+ var ResolvedScopeOptionsDeclared = ResolvedScopeOptionsPlaceEvent.extend({
227
+ declaredIn: UUID.nullish(),
228
+ declaredBy: z6.string().optional()
229
+ }).describe(
230
+ "Resolved options applicable to actions that may take place after DECLARE, with location ID and user ID instead of filters."
231
+ );
232
+ var ResolvedScopeOptionsFull = ResolvedScopeOptionsDeclared.extend({
233
+ registeredIn: UUID.nullish(),
234
+ registeredBy: z6.string().optional()
235
+ }).describe(
236
+ "Resolved options applicable to actions that may take place after REGISTER, with full filtering capabilities and location/user IDs instead of filters."
237
+ );
238
+ var ScopesWithPlaceEventOptions = RecordScopeTypeV2.extract([
239
+ "record.create",
240
+ "record.declare",
241
+ "record.notify"
242
+ ]);
243
+ var ScopesWithDeclaredOptions = RecordScopeTypeV2.extract([
244
+ "record.edit",
245
+ "record.reject",
246
+ "record.archive",
247
+ "record.review-duplicates",
248
+ "record.register"
249
+ ]);
250
+ var ScopesWithFullOptions = RecordScopeTypeV2.extract([
251
+ "record.search",
252
+ "record.read",
253
+ "record.request-correction",
254
+ "record.correct",
255
+ "record.unassign-others"
256
+ ]);
257
+ var ScopeOptionsPrintCertifiedCopies = AllRecordScopeOptions.extend({
258
+ templates: z6.preprocess(
259
+ (val) => val === void 0 ? void 0 : [val].flat(),
260
+ z6.array(z6.string()).optional()
261
+ ).describe(
262
+ "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."
263
+ )
264
+ });
265
+ var RecordScopeV2 = z6.discriminatedUnion("type", [
266
+ z6.object({
267
+ type: ScopesWithPlaceEventOptions,
268
+ options: scopeOptionsPlaceEvent.optional()
269
+ }),
270
+ z6.object({
271
+ type: ScopesWithDeclaredOptions,
272
+ options: scopeOptionsDeclared.optional()
273
+ }),
274
+ z6.object({
275
+ type: ScopesWithFullOptions,
276
+ options: AllRecordScopeOptions.optional()
277
+ }),
278
+ z6.object({
279
+ type: z6.literal("record.custom-action"),
280
+ options: CustomActionScopeOptions.optional()
281
+ }),
282
+ z6.object({
283
+ type: z6.literal("record.print-certified-copies"),
284
+ options: ScopeOptionsPrintCertifiedCopies.optional()
285
+ })
286
+ ]).describe(
287
+ "Scopes used to check user's permission to perform actions on a record."
288
+ );
289
+ var ResolvedRecordScopeV2 = z6.discriminatedUnion("type", [
290
+ z6.object({
291
+ type: ScopesWithPlaceEventOptions,
292
+ options: ResolvedScopeOptionsPlaceEvent.optional()
293
+ }),
294
+ z6.object({
295
+ type: ScopesWithDeclaredOptions,
296
+ options: ResolvedScopeOptionsDeclared.optional()
297
+ }),
298
+ z6.object({
299
+ type: ScopesWithFullOptions,
300
+ options: ResolvedScopeOptionsFull.optional()
301
+ }),
302
+ z6.object({
303
+ type: z6.literal("record.print-certified-copies"),
304
+ options: ResolvedScopeOptionsFull.extend({
305
+ templates: z6.array(z6.string()).optional()
306
+ }).optional()
307
+ })
308
+ ]).describe("Resolved scope with location/user IDs instead of filters.");
309
+ var SystemScopeType = z6.enum([
310
+ "organisation.read-locations",
311
+ "user.read",
312
+ "user.create",
313
+ "user.edit"
314
+ ]);
315
+ var Scope2 = z6.discriminatedUnion("type", [
316
+ z6.object({ type: PlainScopeType }),
317
+ ...RecordScopeV2.options,
318
+ z6.object({ type: SystemScopeType, options: AccessLevelOptions.optional() }),
319
+ z6.object({ type: z6.literal("workqueue"), options: WorkqueueOptions })
320
+ ]);
321
+ var ScopeType2 = z6.enum([
322
+ ...SystemScopeType.options,
323
+ ...RecordScopeTypeV2.options,
324
+ ...PlainScopeType.options,
325
+ "workqueue"
326
+ ]);
327
+ var EncodedScope2 = z6.string().brand("EncodedScope");
328
+ var DEFAULT_SCOPE_OPTIONS = {
329
+ placeOfEvent: JurisdictionFilter.enum.all,
330
+ accessLevel: JurisdictionFilter.enum.all
331
+ };
332
+
333
+ // ../commons/src/users/userReferences.ts
334
+ var import_v4 = __toESM(require("zod/v4"));
335
+ var ScopeOptionReference = import_v4.default.object({
336
+ $scope: ScopeType2,
337
+ $option: ScopeOptionKey
338
+ });
339
+ var JurisdictionReference = import_v4.default.object({
340
+ $jurisdiction: JurisdictionFilter.or(ScopeOptionReference)
341
+ });
342
+ var userReferenceFunctions = {
343
+ scope: (scope) => ({
344
+ /**
345
+ * user.scope().attribute() is used to create a scope option reference.
346
+ *
347
+ * E.g.: user.scope('record.create').attribute('placeOfEvent')
348
+ *
349
+ * @param option - The option to create a reference for.
350
+ * @returns A scope option reference.
351
+ */
352
+ attribute: (option) => ({
353
+ $scope: scope,
354
+ $option: option
355
+ })
356
+ }),
357
+ /**
358
+ * user.jurisdicton() accepts two different kinds of parameters, either:
359
+ *
360
+ * 1. a plain jurisdiction filter: user.jurisdiction('administrativeArea')
361
+ * 2. a scope option reference: user.jurisdiction(user.scope('record.create').attribute('placeOfEvent'))
362
+ *
363
+ * These will be resolved during runtime.
364
+ *
365
+ * @param jurisdiction - The jurisdiction to resolve.
366
+ */
367
+ jurisdiction: (jurisdiction) => ({
368
+ $jurisdiction: jurisdiction
369
+ })
370
+ };
371
+
121
372
  // ../commons/src/conditionals/conditionals.ts
122
373
  function defineConditional(schema) {
123
374
  const schemaWithooutIDRef = omitKeyDeep(schema, "$id");
@@ -193,6 +444,7 @@ function wrapToPathOptional(condition, path) {
193
444
  }
194
445
  var now = Object.assign(todayDateTimeValueSerializer, {});
195
446
  var user = Object.assign(userSerializer, {
447
+ ...userReferenceFunctions,
196
448
  hasScope: (scope) => defineConditional({
197
449
  type: "object",
198
450
  properties: {
@@ -239,9 +491,7 @@ var user = Object.assign(userSerializer, {
239
491
  required: ["$online"]
240
492
  }),
241
493
  locationLevel: (adminLevelId) => ({
242
- $user: {
243
- $location: adminLevelId
244
- }
494
+ $user: { $location: adminLevelId }
245
495
  })
246
496
  });
247
497
  function isFieldReference(value) {
@@ -334,6 +584,33 @@ function defineComparison(field, value, keyword) {
334
584
  required: [field.$$field]
335
585
  });
336
586
  }
587
+ function flag(flagvalue) {
588
+ return defineConditional({
589
+ type: "object",
590
+ properties: {
591
+ $flags: {
592
+ type: "array",
593
+ contains: {
594
+ type: "string",
595
+ const: flagvalue
596
+ }
597
+ }
598
+ },
599
+ required: ["$flags"]
600
+ });
601
+ }
602
+ function status(statusValue) {
603
+ return defineConditional({
604
+ type: "object",
605
+ properties: {
606
+ $status: {
607
+ type: "string",
608
+ const: statusValue
609
+ }
610
+ },
611
+ required: ["$status"]
612
+ });
613
+ }
337
614
  function createFieldConditionals(fieldId) {
338
615
  const getDayRange = (field, days, clause, referenceDate) => ({
339
616
  type: "object",
@@ -687,3 +964,6 @@ function createFieldConditionals(fieldId) {
687
964
  })
688
965
  };
689
966
  }
967
+
968
+ // src/conditionals/index.ts
969
+ z8.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
  };