@opencrvs/toolkit 1.8.0-rc.f8aa0c5 → 1.8.0-rc.f8b1f33

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 +978 -5785
  2. package/dist/commons/conditionals/conditionals.d.ts +6 -14
  3. package/dist/commons/conditionals/validate.d.ts +6 -10
  4. package/dist/commons/events/ActionConfig.d.ts +1726 -120271
  5. package/dist/commons/events/ActionDocument.d.ts +564 -2585
  6. package/dist/commons/events/ActionInput.d.ts +425 -1705
  7. package/dist/commons/events/ActionType.d.ts +0 -4
  8. package/dist/commons/events/AdvancedSearchConfig.d.ts +22 -1233
  9. package/dist/commons/events/CompositeFieldValue.d.ts +0 -31
  10. package/dist/commons/events/Draft.d.ts +49 -168
  11. package/dist/commons/events/EventConfig.d.ts +1362 -57941
  12. package/dist/commons/events/EventDocument.d.ts +400 -1639
  13. package/dist/commons/events/EventIndex.d.ts +27 -2012
  14. package/dist/commons/events/EventMetadata.d.ts +45 -343
  15. package/dist/commons/events/FieldConfig.d.ts +1059 -5655
  16. package/dist/commons/events/FieldType.d.ts +3 -6
  17. package/dist/commons/events/FieldTypeMapping.d.ts +54 -103
  18. package/dist/commons/events/FieldValue.d.ts +8 -49
  19. package/dist/commons/events/FormConfig.d.ts +524 -50366
  20. package/dist/commons/events/PageConfig.d.ts +208 -12498
  21. package/dist/commons/events/SummaryConfig.d.ts +42 -93
  22. package/dist/commons/events/User.d.ts +2 -31
  23. package/dist/commons/events/WorkqueueConfig.d.ts +20 -7300
  24. package/dist/commons/events/defineConfig.d.ts +75 -9326
  25. package/dist/commons/events/index.d.ts +0 -8
  26. package/dist/commons/events/test.utils.d.ts +79 -171
  27. package/dist/commons/events/transactions.d.ts +1 -1
  28. package/dist/commons/events/utils.d.ts +72 -13814
  29. package/dist/conditionals/index.js +52 -95
  30. package/dist/events/index.js +1522 -4190
  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 -3730
  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 -54
  39. package/dist/commons/events/field.d.ts +0 -82
  40. package/dist/commons/events/scopes.d.ts +0 -44
  41. package/dist/commons/events/serializer.d.ts +0 -2
  42. package/dist/commons/events/workqueueDefaultColumns.d.ts +0 -3
@@ -22,10 +22,10 @@ var conditionals_exports = {};
22
22
  __export(conditionals_exports, {
23
23
  alwaysTrue: () => alwaysTrue,
24
24
  and: () => and,
25
- createEventConditionals: () => createEventConditionals,
26
- createFieldConditionals: () => createFieldConditionals,
27
25
  defineConditional: () => defineConditional,
28
26
  defineFormConditional: () => defineFormConditional,
27
+ event: () => event,
28
+ field: () => field,
29
29
  never: () => never,
30
30
  not: () => not,
31
31
  or: () => or,
@@ -33,23 +33,6 @@ __export(conditionals_exports, {
33
33
  });
34
34
  module.exports = __toCommonJS(conditionals_exports);
35
35
 
36
- // ../commons/src/events/serializers/user/serializer.ts
37
- var import_zod = require("zod");
38
- var SerializedUserField = import_zod.z.object({
39
- $userField: import_zod.z.enum([
40
- "id",
41
- "name",
42
- "role",
43
- "signatureFilename",
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,38 +94,35 @@ var user = Object.assign(userSerializer, {
111
94
  },
112
95
  required: ["$user"]
113
96
  })
114
- });
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
- }
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"]
138
115
  }
139
- },
140
- required: ["actions"]
141
- }
142
- },
143
- required: ["$event"]
144
- })
145
- };
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];
146
126
  }
147
127
  function getDateRangeToFieldReference(fieldId, comparedFieldId, clause) {
148
128
  return {
@@ -159,23 +139,9 @@ function getDateRangeToFieldReference(fieldId, comparedFieldId, clause) {
159
139
  };
160
140
  }
161
141
  function isFieldReference(value) {
162
- return typeof value === "object" && value !== null && "$$field" in value;
142
+ return typeof value === "object" && value !== null && "_fieldId" in value;
163
143
  }
164
- function createFieldConditionals(fieldId) {
165
- const getDayRange = (days, clause) => ({
166
- type: "object",
167
- properties: {
168
- [fieldId]: {
169
- type: "string",
170
- format: "date",
171
- daysFromNow: {
172
- days,
173
- clause
174
- }
175
- }
176
- },
177
- required: [fieldId]
178
- });
144
+ function field(fieldId) {
179
145
  const getDateRange = (date, clause) => ({
180
146
  type: "object",
181
147
  properties: {
@@ -191,15 +157,19 @@ function createFieldConditionals(fieldId) {
191
157
  /**
192
158
  * @private Internal property used for field reference tracking.
193
159
  */
194
- $$field: fieldId,
160
+ _fieldId: fieldId,
195
161
  isAfter: () => ({
196
162
  days: (days) => ({
197
- inPast: () => defineFormConditional(getDayRange(-days, "after")),
198
- inFuture: () => defineFormConditional(getDayRange(days, "after"))
163
+ inPast: () => defineFormConditional(
164
+ getDateRange(getDateFromNow(days), "formatMinimum")
165
+ ),
166
+ inFuture: () => defineFormConditional(
167
+ getDateRange(getDateFromNow(-days), "formatMinimum")
168
+ )
199
169
  }),
200
170
  date: (date) => {
201
171
  if (isFieldReference(date)) {
202
- const comparedFieldId = date.$$field;
172
+ const comparedFieldId = date._fieldId;
203
173
  return defineFormConditional(
204
174
  getDateRangeToFieldReference(
205
175
  fieldId,
@@ -210,16 +180,20 @@ function createFieldConditionals(fieldId) {
210
180
  }
211
181
  return defineFormConditional(getDateRange(date, "formatMinimum"));
212
182
  },
213
- now: () => defineFormConditional(getDateRange({ $data: "/$now" }, "formatMinimum"))
183
+ now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMinimum"))
214
184
  }),
215
185
  isBefore: () => ({
216
186
  days: (days) => ({
217
- inPast: () => defineFormConditional(getDayRange(days, "before")),
218
- inFuture: () => defineFormConditional(getDayRange(-days, "before"))
187
+ inPast: () => defineFormConditional(
188
+ getDateRange(getDateFromNow(days), "formatMaximum")
189
+ ),
190
+ inFuture: () => defineFormConditional(
191
+ getDateRange(getDateFromNow(-days), "formatMaximum")
192
+ )
219
193
  }),
220
194
  date: (date) => {
221
195
  if (isFieldReference(date)) {
222
- const comparedFieldId = date.$$field;
196
+ const comparedFieldId = date._fieldId;
223
197
  return defineFormConditional(
224
198
  getDateRangeToFieldReference(
225
199
  fieldId,
@@ -230,17 +204,17 @@ function createFieldConditionals(fieldId) {
230
204
  }
231
205
  return defineFormConditional(getDateRange(date, "formatMaximum"));
232
206
  },
233
- now: () => defineFormConditional(getDateRange({ $data: "/$now" }, "formatMaximum"))
207
+ now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMaximum"))
234
208
  }),
235
209
  isEqualTo: (value) => {
236
210
  if (isFieldReference(value)) {
237
- const comparedFieldId = value.$$field;
211
+ const comparedFieldId = value._fieldId;
238
212
  return defineFormConditional({
239
213
  type: "object",
240
214
  properties: {
241
215
  [fieldId]: {
242
216
  type: ["string", "boolean"],
243
- const: { $data: `/$form/${comparedFieldId}` }
217
+ const: { $data: `1/${comparedFieldId}` }
244
218
  },
245
219
  [comparedFieldId]: { type: ["string", "boolean"] }
246
220
  },
@@ -350,23 +324,6 @@ function createFieldConditionals(fieldId) {
350
324
  }
351
325
  },
352
326
  required: [fieldId]
353
- }),
354
- getId: () => ({ fieldId }),
355
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
356
- object: (options) => defineFormConditional({
357
- type: "object",
358
- properties: {
359
- [fieldId]: {
360
- type: "object",
361
- properties: Object.fromEntries(
362
- Object.entries(options).map(([key, value]) => {
363
- return [key, value.properties.$form.properties[key]];
364
- })
365
- ),
366
- required: Object.keys(options)
367
- }
368
- },
369
- required: [fieldId]
370
327
  })
371
328
  };
372
329
  }