@opencrvs/toolkit 1.8.0-rc.f97f8f2 → 1.8.0-rc.f988670

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 (46) hide show
  1. package/dist/commons/api/router.d.ts +10613 -8753
  2. package/dist/commons/conditionals/conditionals.d.ts +7 -14
  3. package/dist/commons/conditionals/validate.d.ts +14 -0
  4. package/dist/commons/events/ActionConfig.d.ts +82300 -42816
  5. package/dist/commons/events/ActionDocument.d.ts +3996 -1262
  6. package/dist/commons/events/ActionInput.d.ts +3139 -967
  7. package/dist/commons/events/ActionType.d.ts +4 -0
  8. package/dist/commons/events/AdvancedSearchConfig.d.ts +981 -47
  9. package/dist/commons/events/CompositeFieldValue.d.ts +37 -9
  10. package/dist/commons/events/Constants.d.ts +3 -0
  11. package/dist/commons/events/CountryConfigQueryInput.d.ts +3069 -443
  12. package/dist/commons/events/CreatedAtLocation.d.ts +2 -0
  13. package/dist/commons/events/Draft.d.ts +273 -95
  14. package/dist/commons/events/EventConfig.d.ts +33357 -14451
  15. package/dist/commons/events/EventDocument.d.ts +2554 -848
  16. package/dist/commons/events/EventIndex.d.ts +1281 -495
  17. package/dist/commons/events/EventInput.d.ts +0 -13
  18. package/dist/commons/events/EventMetadata.d.ts +126 -92
  19. package/dist/commons/events/FieldConfig.d.ts +4564 -1588
  20. package/dist/commons/events/FieldType.d.ts +10 -1
  21. package/dist/commons/events/FieldTypeMapping.d.ts +149 -75
  22. package/dist/commons/events/FieldValue.d.ts +87 -20
  23. package/dist/commons/events/FormConfig.d.ts +22178 -8396
  24. package/dist/commons/events/PageConfig.d.ts +5525 -2087
  25. package/dist/commons/events/SummaryConfig.d.ts +0 -5
  26. package/dist/commons/events/User.d.ts +6 -3
  27. package/dist/commons/events/WorkqueueColumnConfig.d.ts +18 -7
  28. package/dist/commons/events/WorkqueueConfig.d.ts +6406 -1001
  29. package/dist/commons/events/defineConfig.d.ts +3797 -870
  30. package/dist/commons/events/event.d.ts +41 -14
  31. package/dist/commons/events/field.d.ts +55 -15
  32. package/dist/commons/events/index.d.ts +2 -0
  33. package/dist/commons/events/scopes.d.ts +21 -3
  34. package/dist/commons/events/test.utils.d.ts +208 -54
  35. package/dist/commons/events/transactions.d.ts +1 -1
  36. package/dist/commons/events/utils.d.ts +14039 -1170
  37. package/dist/conditionals/index.js +69 -62
  38. package/dist/events/index.js +3836 -1956
  39. package/dist/scopes/index.d.ts +147 -5
  40. package/dist/scopes/index.js +133 -43
  41. package/package.json +3 -3
  42. package/tsconfig.json +1 -1
  43. package/dist/commons/conditionals/conditionals.test.d.ts +0 -2
  44. package/dist/commons/conditionals/validate-address.test.d.ts +0 -2
  45. package/dist/commons/conditionals/validate.test.d.ts +0 -2
  46. package/dist/commons/events/utils.test.d.ts +0 -2
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
 
20
30
  // src/conditionals/index.ts
@@ -22,7 +32,6 @@ var conditionals_exports = {};
22
32
  __export(conditionals_exports, {
23
33
  alwaysTrue: () => alwaysTrue,
24
34
  and: () => and,
25
- createEventConditionals: () => createEventConditionals,
26
35
  createFieldConditionals: () => createFieldConditionals,
27
36
  defineConditional: () => defineConditional,
28
37
  defineFormConditional: () => defineFormConditional,
@@ -33,6 +42,9 @@ __export(conditionals_exports, {
33
42
  });
34
43
  module.exports = __toCommonJS(conditionals_exports);
35
44
 
45
+ // ../commons/src/conditionals/conditionals.ts
46
+ var objectHash = __toESM(require("object-hash"));
47
+
36
48
  // ../commons/src/events/serializers/user/serializer.ts
37
49
  var import_zod = require("zod");
38
50
  var SerializedUserField = import_zod.z.object({
@@ -40,7 +52,8 @@ var SerializedUserField = import_zod.z.object({
40
52
  "id",
41
53
  "name",
42
54
  "role",
43
- "signatureFilename",
55
+ "signature",
56
+ "avatar",
44
57
  "primaryOfficeId"
45
58
  ])
46
59
  });
@@ -52,7 +65,10 @@ function userSerializer(userField) {
52
65
 
53
66
  // ../commons/src/conditionals/conditionals.ts
54
67
  function defineConditional(schema) {
55
- return schema;
68
+ return {
69
+ $id: `https://opencrvs.org/conditionals/${objectHash.sha1(schema)}`,
70
+ ...schema
71
+ };
56
72
  }
57
73
  function defineFormConditional(schema) {
58
74
  const schemaWithForm = {
@@ -112,41 +128,6 @@ var user = Object.assign(userSerializer, {
112
128
  required: ["$user"]
113
129
  })
114
130
  });
115
- function createEventConditionals() {
116
- return {
117
- /**
118
- * Checks if the event contains a specific action type.
119
- * @param action - The action type to check for.
120
- */
121
- hasAction: (action) => defineConditional({
122
- type: "object",
123
- properties: {
124
- $event: {
125
- type: "object",
126
- properties: {
127
- actions: {
128
- type: "array",
129
- contains: {
130
- type: "object",
131
- properties: {
132
- type: {
133
- const: action
134
- }
135
- },
136
- required: ["type"]
137
- }
138
- }
139
- },
140
- required: ["actions"]
141
- }
142
- },
143
- required: ["$event"]
144
- })
145
- };
146
- }
147
- function getDateFromNow(days) {
148
- return new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString().split("T")[0];
149
- }
150
131
  function getDateRangeToFieldReference(fieldId, comparedFieldId, clause) {
151
132
  return {
152
133
  type: "object",
@@ -162,9 +143,23 @@ function getDateRangeToFieldReference(fieldId, comparedFieldId, clause) {
162
143
  };
163
144
  }
164
145
  function isFieldReference(value) {
165
- return typeof value === "object" && value !== null && "_fieldId" in value;
146
+ return typeof value === "object" && value !== null && "$$field" in value;
166
147
  }
167
148
  function createFieldConditionals(fieldId) {
149
+ const getDayRange = (days, clause) => ({
150
+ type: "object",
151
+ properties: {
152
+ [fieldId]: {
153
+ type: "string",
154
+ format: "date",
155
+ daysFromNow: {
156
+ days,
157
+ clause
158
+ }
159
+ }
160
+ },
161
+ required: [fieldId]
162
+ });
168
163
  const getDateRange = (date, clause) => ({
169
164
  type: "object",
170
165
  properties: {
@@ -177,18 +172,18 @@ function createFieldConditionals(fieldId) {
177
172
  required: [fieldId]
178
173
  });
179
174
  return {
175
+ /**
176
+ * @private Internal property used for field reference tracking.
177
+ */
178
+ $$field: fieldId,
180
179
  isAfter: () => ({
181
180
  days: (days) => ({
182
- inPast: () => defineFormConditional(
183
- getDateRange(getDateFromNow(days), "formatMinimum")
184
- ),
185
- inFuture: () => defineFormConditional(
186
- getDateRange(getDateFromNow(-days), "formatMinimum")
187
- )
181
+ inPast: () => defineFormConditional(getDayRange(-days, "after")),
182
+ inFuture: () => defineFormConditional(getDayRange(days, "after"))
188
183
  }),
189
184
  date: (date) => {
190
185
  if (isFieldReference(date)) {
191
- const comparedFieldId = date._fieldId;
186
+ const comparedFieldId = date.$$field;
192
187
  return defineFormConditional(
193
188
  getDateRangeToFieldReference(
194
189
  fieldId,
@@ -199,20 +194,16 @@ function createFieldConditionals(fieldId) {
199
194
  }
200
195
  return defineFormConditional(getDateRange(date, "formatMinimum"));
201
196
  },
202
- now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMinimum"))
197
+ now: () => defineFormConditional(getDateRange({ $data: "/$now" }, "formatMinimum"))
203
198
  }),
204
199
  isBefore: () => ({
205
200
  days: (days) => ({
206
- inPast: () => defineFormConditional(
207
- getDateRange(getDateFromNow(days), "formatMaximum")
208
- ),
209
- inFuture: () => defineFormConditional(
210
- getDateRange(getDateFromNow(-days), "formatMaximum")
211
- )
201
+ inPast: () => defineFormConditional(getDayRange(days, "before")),
202
+ inFuture: () => defineFormConditional(getDayRange(-days, "before"))
212
203
  }),
213
204
  date: (date) => {
214
205
  if (isFieldReference(date)) {
215
- const comparedFieldId = date._fieldId;
206
+ const comparedFieldId = date.$$field;
216
207
  return defineFormConditional(
217
208
  getDateRangeToFieldReference(
218
209
  fieldId,
@@ -223,17 +214,17 @@ function createFieldConditionals(fieldId) {
223
214
  }
224
215
  return defineFormConditional(getDateRange(date, "formatMaximum"));
225
216
  },
226
- now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMaximum"))
217
+ now: () => defineFormConditional(getDateRange({ $data: "/$now" }, "formatMaximum"))
227
218
  }),
228
219
  isEqualTo: (value) => {
229
220
  if (isFieldReference(value)) {
230
- const comparedFieldId = value._fieldId;
221
+ const comparedFieldId = value.$$field;
231
222
  return defineFormConditional({
232
223
  type: "object",
233
224
  properties: {
234
225
  [fieldId]: {
235
226
  type: ["string", "boolean"],
236
- const: { $data: `1/${comparedFieldId}` }
227
+ const: { $data: `/$form/${comparedFieldId}` }
237
228
  },
238
229
  [comparedFieldId]: { type: ["string", "boolean"] }
239
230
  },
@@ -312,11 +303,11 @@ function createFieldConditionals(fieldId) {
312
303
  properties: {
313
304
  [fieldId]: {
314
305
  type: "string",
315
- pattern: "^[\\p{Script=Latin}0-9'._-]*(\\([\\p{Script=Latin}0-9'._-]+\\))?[\\p{Script=Latin}0-9'._-]*( [\\p{Script=Latin}0-9'._-]*(\\([\\p{Script=Latin}0-9'._-]+\\))?[\\p{Script=Latin}0-9'._-]*)*$",
316
- description: "Name must contain only letters, numbers, and allowed special characters ('._-). No double spaces."
306
+ minLength: 1,
307
+ pattern: "^[\\p{Script=Latin}0-9'.-]*(\\([\\p{Script=Latin}0-9'.-]+\\))?[\\p{Script=Latin}0-9'.-]*( [\\p{Script=Latin}0-9'.-]*(\\([\\p{Script=Latin}0-9'.-]+\\))?[\\p{Script=Latin}0-9'.-]*)*$",
308
+ description: "Name must contain only letters, numbers, and allowed special characters ('.-). No double spaces."
317
309
  }
318
- },
319
- required: [fieldId]
310
+ }
320
311
  }),
321
312
  /**
322
313
  * Checks if the field value matches a given regular expression pattern.
@@ -344,6 +335,22 @@ function createFieldConditionals(fieldId) {
344
335
  },
345
336
  required: [fieldId]
346
337
  }),
347
- getId: () => ({ fieldId })
338
+ getId: () => ({ fieldId }),
339
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
340
+ object: (options) => defineFormConditional({
341
+ type: "object",
342
+ properties: {
343
+ [fieldId]: {
344
+ type: "object",
345
+ properties: Object.fromEntries(
346
+ Object.entries(options).map(([key, value]) => {
347
+ return [key, value.properties.$form.properties[key]];
348
+ })
349
+ ),
350
+ required: Object.keys(options)
351
+ }
352
+ },
353
+ required: [fieldId]
354
+ })
348
355
  };
349
356
  }