@opencrvs/toolkit 1.8.1-rc.8c25e85 → 1.8.1-rc.a372970

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 (42) hide show
  1. package/dist/commons/api/router.d.ts +5078 -5910
  2. package/dist/commons/conditionals/conditionals.d.ts +13 -9
  3. package/dist/commons/conditionals/validate.d.ts +6 -15
  4. package/dist/commons/events/ActionConfig.d.ts +1718 -119315
  5. package/dist/commons/events/ActionDocument.d.ts +1325 -4879
  6. package/dist/commons/events/ActionInput.d.ts +1025 -3205
  7. package/dist/commons/events/ActionType.d.ts +1 -10
  8. package/dist/commons/events/AdvancedSearchConfig.d.ts +22 -1282
  9. package/dist/commons/events/CompositeFieldValue.d.ts +9 -40
  10. package/dist/commons/events/Draft.d.ts +97 -288
  11. package/dist/commons/events/EventConfig.d.ts +1359 -54365
  12. package/dist/commons/events/EventDocument.d.ts +833 -2720
  13. package/dist/commons/events/EventIndex.d.ts +29 -2228
  14. package/dist/commons/events/EventMetadata.d.ts +47 -347
  15. package/dist/commons/events/FieldConfig.d.ts +1250 -6746
  16. package/dist/commons/events/FieldType.d.ts +3 -8
  17. package/dist/commons/events/FieldTypeMapping.d.ts +73 -161
  18. package/dist/commons/events/FieldValue.d.ts +20 -91
  19. package/dist/commons/events/FormConfig.d.ts +533 -55781
  20. package/dist/commons/events/PageConfig.d.ts +208 -13824
  21. package/dist/commons/events/SummaryConfig.d.ts +42 -93
  22. package/dist/commons/events/User.d.ts +2 -34
  23. package/dist/commons/events/WorkqueueConfig.d.ts +20 -8116
  24. package/dist/commons/events/defineConfig.d.ts +99 -8551
  25. package/dist/commons/events/index.d.ts +0 -8
  26. package/dist/commons/events/test.utils.d.ts +90 -206
  27. package/dist/commons/events/transactions.d.ts +1 -1
  28. package/dist/commons/events/utils.d.ts +94 -15442
  29. package/dist/conditionals/index.js +56 -66
  30. package/dist/events/index.js +1835 -4707
  31. package/dist/scopes/index.d.ts +7 -184
  32. package/dist/scopes/index.js +40 -140
  33. package/package.json +3 -4
  34. package/dist/commons/events/Constants.d.ts +0 -3
  35. package/dist/commons/events/CountryConfigQueryInput.d.ts +0 -4132
  36. package/dist/commons/events/CreatedAtLocation.d.ts +0 -2
  37. package/dist/commons/events/WorkqueueColumnConfig.d.ts +0 -53
  38. package/dist/commons/events/event.d.ts +0 -46
  39. package/dist/commons/events/field.d.ts +0 -94
  40. package/dist/commons/events/scopes.d.ts +0 -45
  41. package/dist/commons/events/serializer.d.ts +0 -2
  42. package/dist/commons/events/workqueueDefaultColumns.d.ts +0 -3
@@ -22,9 +22,10 @@ var conditionals_exports = {};
22
22
  __export(conditionals_exports, {
23
23
  alwaysTrue: () => alwaysTrue,
24
24
  and: () => and,
25
- createFieldConditionals: () => createFieldConditionals,
26
25
  defineConditional: () => defineConditional,
27
26
  defineFormConditional: () => defineFormConditional,
27
+ event: () => event,
28
+ field: () => field,
28
29
  never: () => never,
29
30
  not: () => not,
30
31
  or: () => or,
@@ -32,24 +33,6 @@ __export(conditionals_exports, {
32
33
  });
33
34
  module.exports = __toCommonJS(conditionals_exports);
34
35
 
35
- // ../commons/src/events/serializers/user/serializer.ts
36
- var import_zod = require("zod");
37
- var SerializedUserField = import_zod.z.object({
38
- $userField: import_zod.z.enum([
39
- "id",
40
- "name",
41
- "role",
42
- "signature",
43
- "avatar",
44
- "primaryOfficeId"
45
- ])
46
- });
47
- function userSerializer(userField) {
48
- return {
49
- $userField: userField
50
- };
51
- }
52
-
53
36
  // ../commons/src/conditionals/conditionals.ts
54
37
  function defineConditional(schema) {
55
38
  return schema;
@@ -91,7 +74,7 @@ function not(condition) {
91
74
  function never() {
92
75
  return not(alwaysTrue());
93
76
  }
94
- var user = Object.assign(userSerializer, {
77
+ var user = {
95
78
  hasScope: (scope) => defineConditional({
96
79
  type: "object",
97
80
  properties: {
@@ -111,7 +94,36 @@ var user = Object.assign(userSerializer, {
111
94
  },
112
95
  required: ["$user"]
113
96
  })
114
- });
97
+ };
98
+ var event = {
99
+ hasAction: (action) => defineConditional({
100
+ type: "object",
101
+ properties: {
102
+ $event: {
103
+ type: "object",
104
+ properties: {
105
+ actions: {
106
+ type: "array",
107
+ contains: {
108
+ type: "object",
109
+ properties: {
110
+ type: {
111
+ const: action
112
+ }
113
+ },
114
+ required: ["type"]
115
+ }
116
+ }
117
+ },
118
+ required: ["actions"]
119
+ }
120
+ },
121
+ required: ["$event"]
122
+ })
123
+ };
124
+ function getDateFromNow(days) {
125
+ return new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString().split("T")[0];
126
+ }
115
127
  function getDateRangeToFieldReference(fieldId, comparedFieldId, clause) {
116
128
  return {
117
129
  type: "object",
@@ -127,23 +139,9 @@ function getDateRangeToFieldReference(fieldId, comparedFieldId, clause) {
127
139
  };
128
140
  }
129
141
  function isFieldReference(value) {
130
- return typeof value === "object" && value !== null && "$$field" in value;
142
+ return typeof value === "object" && value !== null && "_fieldId" in value;
131
143
  }
132
- function createFieldConditionals(fieldId) {
133
- const getDayRange = (days, clause) => ({
134
- type: "object",
135
- properties: {
136
- [fieldId]: {
137
- type: "string",
138
- format: "date",
139
- daysFromNow: {
140
- days,
141
- clause
142
- }
143
- }
144
- },
145
- required: [fieldId]
146
- });
144
+ function field(fieldId) {
147
145
  const getDateRange = (date, clause) => ({
148
146
  type: "object",
149
147
  properties: {
@@ -159,15 +157,19 @@ function createFieldConditionals(fieldId) {
159
157
  /**
160
158
  * @private Internal property used for field reference tracking.
161
159
  */
162
- $$field: fieldId,
160
+ _fieldId: fieldId,
163
161
  isAfter: () => ({
164
162
  days: (days) => ({
165
- inPast: () => defineFormConditional(getDayRange(-days, "after")),
166
- inFuture: () => defineFormConditional(getDayRange(days, "after"))
163
+ inPast: () => defineFormConditional(
164
+ getDateRange(getDateFromNow(days), "formatMinimum")
165
+ ),
166
+ inFuture: () => defineFormConditional(
167
+ getDateRange(getDateFromNow(-days), "formatMinimum")
168
+ )
167
169
  }),
168
170
  date: (date) => {
169
171
  if (isFieldReference(date)) {
170
- const comparedFieldId = date.$$field;
172
+ const comparedFieldId = date._fieldId;
171
173
  return defineFormConditional(
172
174
  getDateRangeToFieldReference(
173
175
  fieldId,
@@ -178,16 +180,20 @@ function createFieldConditionals(fieldId) {
178
180
  }
179
181
  return defineFormConditional(getDateRange(date, "formatMinimum"));
180
182
  },
181
- now: () => defineFormConditional(getDateRange({ $data: "/$now" }, "formatMinimum"))
183
+ now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMinimum"))
182
184
  }),
183
185
  isBefore: () => ({
184
186
  days: (days) => ({
185
- inPast: () => defineFormConditional(getDayRange(days, "before")),
186
- inFuture: () => defineFormConditional(getDayRange(-days, "before"))
187
+ inPast: () => defineFormConditional(
188
+ getDateRange(getDateFromNow(days), "formatMaximum")
189
+ ),
190
+ inFuture: () => defineFormConditional(
191
+ getDateRange(getDateFromNow(-days), "formatMaximum")
192
+ )
187
193
  }),
188
194
  date: (date) => {
189
195
  if (isFieldReference(date)) {
190
- const comparedFieldId = date.$$field;
196
+ const comparedFieldId = date._fieldId;
191
197
  return defineFormConditional(
192
198
  getDateRangeToFieldReference(
193
199
  fieldId,
@@ -198,17 +204,17 @@ function createFieldConditionals(fieldId) {
198
204
  }
199
205
  return defineFormConditional(getDateRange(date, "formatMaximum"));
200
206
  },
201
- now: () => defineFormConditional(getDateRange({ $data: "/$now" }, "formatMaximum"))
207
+ now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMaximum"))
202
208
  }),
203
209
  isEqualTo: (value) => {
204
210
  if (isFieldReference(value)) {
205
- const comparedFieldId = value.$$field;
211
+ const comparedFieldId = value._fieldId;
206
212
  return defineFormConditional({
207
213
  type: "object",
208
214
  properties: {
209
215
  [fieldId]: {
210
216
  type: ["string", "boolean"],
211
- const: { $data: `/$form/${comparedFieldId}` }
217
+ const: { $data: `1/${comparedFieldId}` }
212
218
  },
213
219
  [comparedFieldId]: { type: ["string", "boolean"] }
214
220
  },
@@ -290,7 +296,8 @@ function createFieldConditionals(fieldId) {
290
296
  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'._-]*)*$",
291
297
  description: "Name must contain only letters, numbers, and allowed special characters ('._-). No double spaces."
292
298
  }
293
- }
299
+ },
300
+ required: [fieldId]
294
301
  }),
295
302
  /**
296
303
  * Checks if the field value matches a given regular expression pattern.
@@ -317,23 +324,6 @@ function createFieldConditionals(fieldId) {
317
324
  }
318
325
  },
319
326
  required: [fieldId]
320
- }),
321
- getId: () => ({ fieldId }),
322
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
323
- object: (options) => defineFormConditional({
324
- type: "object",
325
- properties: {
326
- [fieldId]: {
327
- type: "object",
328
- properties: Object.fromEntries(
329
- Object.entries(options).map(([key, value]) => {
330
- return [key, value.properties.$form.properties[key]];
331
- })
332
- ),
333
- required: Object.keys(options)
334
- }
335
- },
336
- required: [fieldId]
337
327
  })
338
328
  };
339
329
  }