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

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 (38) hide show
  1. package/dist/commons/api/router.d.ts +7549 -6145
  2. package/dist/commons/conditionals/conditionals.d.ts +0 -4
  3. package/dist/commons/conditionals/validate.d.ts +0 -6
  4. package/dist/commons/events/ActionConfig.d.ts +20914 -46894
  5. package/dist/commons/events/ActionDocument.d.ts +494 -1997
  6. package/dist/commons/events/ActionInput.d.ts +306 -1506
  7. package/dist/commons/events/ActionType.d.ts +0 -4
  8. package/dist/commons/events/AdvancedSearchConfig.d.ts +3 -279
  9. package/dist/commons/events/CompositeFieldValue.d.ts +0 -28
  10. package/dist/commons/events/Constants.d.ts +0 -1
  11. package/dist/commons/events/CountryConfigQueryInput.d.ts +412 -1160
  12. package/dist/commons/events/CreatedAtLocation.d.ts +2 -1
  13. package/dist/commons/events/Draft.d.ts +40 -141
  14. package/dist/commons/events/EventConfig.d.ts +14286 -29320
  15. package/dist/commons/events/EventDocument.d.ts +355 -1294
  16. package/dist/commons/events/EventIndex.d.ts +191 -849
  17. package/dist/commons/events/EventMetadata.d.ts +64 -73
  18. package/dist/commons/events/FieldConfig.d.ts +888 -1875
  19. package/dist/commons/events/FieldType.d.ts +1 -4
  20. package/dist/commons/events/FieldTypeMapping.d.ts +50 -89
  21. package/dist/commons/events/FieldValue.d.ts +5 -41
  22. package/dist/commons/events/FormConfig.d.ts +2510 -8840
  23. package/dist/commons/events/PageConfig.d.ts +1638 -3184
  24. package/dist/commons/events/SummaryConfig.d.ts +5 -0
  25. package/dist/commons/events/WorkqueueColumnConfig.d.ts +11 -11
  26. package/dist/commons/events/WorkqueueConfig.d.ts +1778 -4553
  27. package/dist/commons/events/defineConfig.d.ts +1440 -4157
  28. package/dist/commons/events/field.d.ts +0 -9
  29. package/dist/commons/events/index.d.ts +0 -1
  30. package/dist/commons/events/scopes.d.ts +3 -2
  31. package/dist/commons/events/test.utils.d.ts +39 -148
  32. package/dist/commons/events/transactions.d.ts +1 -1
  33. package/dist/commons/events/utils.d.ts +19 -10122
  34. package/dist/conditionals/index.js +18 -38
  35. package/dist/events/index.js +1681 -2347
  36. package/dist/scopes/index.d.ts +7 -96
  37. package/dist/scopes/index.js +26 -105
  38. package/package.json +3 -3
@@ -144,6 +144,9 @@ function createEventConditionals() {
144
144
  })
145
145
  };
146
146
  }
147
+ function getDateFromNow(days) {
148
+ return new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString().split("T")[0];
149
+ }
147
150
  function getDateRangeToFieldReference(fieldId, comparedFieldId, clause) {
148
151
  return {
149
152
  type: "object",
@@ -162,20 +165,6 @@ function isFieldReference(value) {
162
165
  return typeof value === "object" && value !== null && "$$field" in value;
163
166
  }
164
167
  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
- });
179
168
  const getDateRange = (date, clause) => ({
180
169
  type: "object",
181
170
  properties: {
@@ -194,8 +183,12 @@ function createFieldConditionals(fieldId) {
194
183
  $$field: fieldId,
195
184
  isAfter: () => ({
196
185
  days: (days) => ({
197
- inPast: () => defineFormConditional(getDayRange(-days, "after")),
198
- inFuture: () => defineFormConditional(getDayRange(days, "after"))
186
+ inPast: () => defineFormConditional(
187
+ getDateRange(getDateFromNow(days), "formatMinimum")
188
+ ),
189
+ inFuture: () => defineFormConditional(
190
+ getDateRange(getDateFromNow(-days), "formatMinimum")
191
+ )
199
192
  }),
200
193
  date: (date) => {
201
194
  if (isFieldReference(date)) {
@@ -210,12 +203,16 @@ function createFieldConditionals(fieldId) {
210
203
  }
211
204
  return defineFormConditional(getDateRange(date, "formatMinimum"));
212
205
  },
213
- now: () => defineFormConditional(getDateRange({ $data: "/$now" }, "formatMinimum"))
206
+ now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMinimum"))
214
207
  }),
215
208
  isBefore: () => ({
216
209
  days: (days) => ({
217
- inPast: () => defineFormConditional(getDayRange(days, "before")),
218
- inFuture: () => defineFormConditional(getDayRange(-days, "before"))
210
+ inPast: () => defineFormConditional(
211
+ getDateRange(getDateFromNow(days), "formatMaximum")
212
+ ),
213
+ inFuture: () => defineFormConditional(
214
+ getDateRange(getDateFromNow(-days), "formatMaximum")
215
+ )
219
216
  }),
220
217
  date: (date) => {
221
218
  if (isFieldReference(date)) {
@@ -230,7 +227,7 @@ function createFieldConditionals(fieldId) {
230
227
  }
231
228
  return defineFormConditional(getDateRange(date, "formatMaximum"));
232
229
  },
233
- now: () => defineFormConditional(getDateRange({ $data: "/$now" }, "formatMaximum"))
230
+ now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMaximum"))
234
231
  }),
235
232
  isEqualTo: (value) => {
236
233
  if (isFieldReference(value)) {
@@ -240,7 +237,7 @@ function createFieldConditionals(fieldId) {
240
237
  properties: {
241
238
  [fieldId]: {
242
239
  type: ["string", "boolean"],
243
- const: { $data: `/$form/${comparedFieldId}` }
240
+ const: { $data: `1/${comparedFieldId}` }
244
241
  },
245
242
  [comparedFieldId]: { type: ["string", "boolean"] }
246
243
  },
@@ -350,23 +347,6 @@ function createFieldConditionals(fieldId) {
350
347
  }
351
348
  },
352
349
  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
350
  })
371
351
  };
372
352
  }