@opencrvs/toolkit 1.8.0-rc.fd071dc → 1.8.0-rc.fd1df48

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 (43) hide show
  1. package/dist/commons/api/router.d.ts +5768 -950
  2. package/dist/commons/conditionals/conditionals.d.ts +14 -6
  3. package/dist/commons/conditionals/validate.d.ts +11 -11
  4. package/dist/commons/events/ActionConfig.d.ts +120018 -1729
  5. package/dist/commons/events/ActionDocument.d.ts +2581 -554
  6. package/dist/commons/events/ActionInput.d.ts +1795 -425
  7. package/dist/commons/events/ActionType.d.ts +6 -0
  8. package/dist/commons/events/AdvancedSearchConfig.d.ts +1233 -22
  9. package/dist/commons/events/CompositeFieldValue.d.ts +31 -0
  10. package/dist/commons/events/Constants.d.ts +3 -0
  11. package/dist/commons/events/CountryConfigQueryInput.d.ts +3730 -0
  12. package/dist/commons/events/CreatedAtLocation.d.ts +2 -0
  13. package/dist/commons/events/Draft.d.ts +165 -43
  14. package/dist/commons/events/EventConfig.d.ts +57827 -1354
  15. package/dist/commons/events/EventDocument.d.ts +1635 -391
  16. package/dist/commons/events/EventIndex.d.ts +2007 -27
  17. package/dist/commons/events/EventMetadata.d.ts +343 -45
  18. package/dist/commons/events/FieldConfig.d.ts +5609 -1033
  19. package/dist/commons/events/FieldType.d.ts +6 -3
  20. package/dist/commons/events/FieldTypeMapping.d.ts +103 -54
  21. package/dist/commons/events/FieldValue.d.ts +49 -8
  22. package/dist/commons/events/FormConfig.d.ts +50248 -514
  23. package/dist/commons/events/PageConfig.d.ts +12466 -204
  24. package/dist/commons/events/SummaryConfig.d.ts +93 -42
  25. package/dist/commons/events/User.d.ts +31 -3
  26. package/dist/commons/events/WorkqueueColumnConfig.d.ts +53 -0
  27. package/dist/commons/events/WorkqueueConfig.d.ts +7300 -20
  28. package/dist/commons/events/defineConfig.d.ts +9287 -58
  29. package/dist/commons/events/event.d.ts +54 -0
  30. package/dist/commons/events/field.d.ts +82 -0
  31. package/dist/commons/events/index.d.ts +8 -0
  32. package/dist/commons/events/scopes.d.ts +44 -0
  33. package/dist/commons/events/serializer.d.ts +2 -0
  34. package/dist/commons/events/test.utils.d.ts +171 -79
  35. package/dist/commons/events/transactions.d.ts +1 -1
  36. package/dist/commons/events/utils.d.ts +13791 -73
  37. package/dist/commons/events/utils.test.d.ts +2 -0
  38. package/dist/commons/events/workqueueDefaultColumns.d.ts +3 -0
  39. package/dist/conditionals/index.js +95 -52
  40. package/dist/events/index.js +4658 -1943
  41. package/dist/scopes/index.d.ts +161 -1
  42. package/dist/scopes/index.js +202 -1
  43. package/package.json +4 -3
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=utils.test.d.ts.map
@@ -0,0 +1,3 @@
1
+ import { WorkqueueColumn } from './WorkqueueColumnConfig';
2
+ export declare const defaultWorkqueueColumns: WorkqueueColumn[];
3
+ //# sourceMappingURL=workqueueDefaultColumns.d.ts.map
@@ -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,
25
27
  defineConditional: () => defineConditional,
26
28
  defineFormConditional: () => defineFormConditional,
27
- event: () => event,
28
- field: () => field,
29
29
  never: () => never,
30
30
  not: () => not,
31
31
  or: () => or,
@@ -33,6 +33,23 @@ __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
+
36
53
  // ../commons/src/conditionals/conditionals.ts
37
54
  function defineConditional(schema) {
38
55
  return schema;
@@ -74,7 +91,7 @@ function not(condition) {
74
91
  function never() {
75
92
  return not(alwaysTrue());
76
93
  }
77
- var user = {
94
+ var user = Object.assign(userSerializer, {
78
95
  hasScope: (scope) => defineConditional({
79
96
  type: "object",
80
97
  properties: {
@@ -94,35 +111,38 @@ var user = {
94
111
  },
95
112
  required: ["$user"]
96
113
  })
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"]
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
+ }
115
138
  }
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];
139
+ },
140
+ required: ["actions"]
141
+ }
142
+ },
143
+ required: ["$event"]
144
+ })
145
+ };
126
146
  }
127
147
  function getDateRangeToFieldReference(fieldId, comparedFieldId, clause) {
128
148
  return {
@@ -139,9 +159,23 @@ function getDateRangeToFieldReference(fieldId, comparedFieldId, clause) {
139
159
  };
140
160
  }
141
161
  function isFieldReference(value) {
142
- return typeof value === "object" && value !== null && "_fieldId" in value;
162
+ return typeof value === "object" && value !== null && "$$field" in value;
143
163
  }
144
- function field(fieldId) {
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
+ });
145
179
  const getDateRange = (date, clause) => ({
146
180
  type: "object",
147
181
  properties: {
@@ -157,19 +191,15 @@ function field(fieldId) {
157
191
  /**
158
192
  * @private Internal property used for field reference tracking.
159
193
  */
160
- _fieldId: fieldId,
194
+ $$field: fieldId,
161
195
  isAfter: () => ({
162
196
  days: (days) => ({
163
- inPast: () => defineFormConditional(
164
- getDateRange(getDateFromNow(days), "formatMinimum")
165
- ),
166
- inFuture: () => defineFormConditional(
167
- getDateRange(getDateFromNow(-days), "formatMinimum")
168
- )
197
+ inPast: () => defineFormConditional(getDayRange(-days, "after")),
198
+ inFuture: () => defineFormConditional(getDayRange(days, "after"))
169
199
  }),
170
200
  date: (date) => {
171
201
  if (isFieldReference(date)) {
172
- const comparedFieldId = date._fieldId;
202
+ const comparedFieldId = date.$$field;
173
203
  return defineFormConditional(
174
204
  getDateRangeToFieldReference(
175
205
  fieldId,
@@ -180,20 +210,16 @@ function field(fieldId) {
180
210
  }
181
211
  return defineFormConditional(getDateRange(date, "formatMinimum"));
182
212
  },
183
- now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMinimum"))
213
+ now: () => defineFormConditional(getDateRange({ $data: "/$now" }, "formatMinimum"))
184
214
  }),
185
215
  isBefore: () => ({
186
216
  days: (days) => ({
187
- inPast: () => defineFormConditional(
188
- getDateRange(getDateFromNow(days), "formatMaximum")
189
- ),
190
- inFuture: () => defineFormConditional(
191
- getDateRange(getDateFromNow(-days), "formatMaximum")
192
- )
217
+ inPast: () => defineFormConditional(getDayRange(days, "before")),
218
+ inFuture: () => defineFormConditional(getDayRange(-days, "before"))
193
219
  }),
194
220
  date: (date) => {
195
221
  if (isFieldReference(date)) {
196
- const comparedFieldId = date._fieldId;
222
+ const comparedFieldId = date.$$field;
197
223
  return defineFormConditional(
198
224
  getDateRangeToFieldReference(
199
225
  fieldId,
@@ -204,17 +230,17 @@ function field(fieldId) {
204
230
  }
205
231
  return defineFormConditional(getDateRange(date, "formatMaximum"));
206
232
  },
207
- now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMaximum"))
233
+ now: () => defineFormConditional(getDateRange({ $data: "/$now" }, "formatMaximum"))
208
234
  }),
209
235
  isEqualTo: (value) => {
210
236
  if (isFieldReference(value)) {
211
- const comparedFieldId = value._fieldId;
237
+ const comparedFieldId = value.$$field;
212
238
  return defineFormConditional({
213
239
  type: "object",
214
240
  properties: {
215
241
  [fieldId]: {
216
242
  type: ["string", "boolean"],
217
- const: { $data: `1/${comparedFieldId}` }
243
+ const: { $data: `/$form/${comparedFieldId}` }
218
244
  },
219
245
  [comparedFieldId]: { type: ["string", "boolean"] }
220
246
  },
@@ -324,6 +350,23 @@ function field(fieldId) {
324
350
  }
325
351
  },
326
352
  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]
327
370
  })
328
371
  };
329
372
  }