@opencrvs/toolkit 1.8.0-rc.fcd89ec → 1.8.0-rc.fcf7cb3

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 (48) hide show
  1. package/dist/commons/api/router.d.ts +8046 -8610
  2. package/dist/commons/conditionals/conditionals.d.ts +8 -15
  3. package/dist/commons/conditionals/validate.d.ts +14 -0
  4. package/dist/commons/events/ActionConfig.d.ts +68541 -36072
  5. package/dist/commons/events/ActionDocument.d.ts +3961 -1227
  6. package/dist/commons/events/ActionInput.d.ts +3138 -966
  7. package/dist/commons/events/ActionType.d.ts +4 -0
  8. package/dist/commons/events/AdvancedSearchConfig.d.ts +414 -71
  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 +4132 -0
  12. package/dist/commons/events/CreatedAtLocation.d.ts +1 -2
  13. package/dist/commons/events/Draft.d.ts +271 -93
  14. package/dist/commons/events/EventConfig.d.ts +33783 -18386
  15. package/dist/commons/events/EventDocument.d.ts +2522 -816
  16. package/dist/commons/events/EventIndex.d.ts +1411 -313
  17. package/dist/commons/events/EventInput.d.ts +0 -13
  18. package/dist/commons/events/EventMetadata.d.ts +113 -76
  19. package/dist/commons/events/FieldConfig.d.ts +4017 -1558
  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 +18663 -8055
  24. package/dist/commons/events/PageConfig.d.ts +4601 -1945
  25. package/dist/commons/events/SummaryConfig.d.ts +0 -5
  26. package/dist/commons/events/User.d.ts +34 -7
  27. package/dist/commons/events/WorkqueueColumnConfig.d.ts +53 -0
  28. package/dist/commons/events/WorkqueueConfig.d.ts +7802 -308
  29. package/dist/commons/events/defineConfig.d.ts +3535 -860
  30. package/dist/commons/events/event.d.ts +21 -21
  31. package/dist/commons/events/field.d.ts +36 -10
  32. package/dist/commons/events/index.d.ts +5 -0
  33. package/dist/commons/events/scopes.d.ts +1 -2
  34. package/dist/commons/events/serializer.d.ts +2 -0
  35. package/dist/commons/events/test.utils.d.ts +206 -52
  36. package/dist/commons/events/transactions.d.ts +1 -1
  37. package/dist/commons/events/utils.d.ts +14324 -1570
  38. package/dist/commons/events/workqueueDefaultColumns.d.ts +3 -0
  39. package/dist/conditionals/index.js +70 -62
  40. package/dist/events/index.js +3527 -1656
  41. package/dist/scopes/index.d.ts +96 -7
  42. package/dist/scopes/index.js +105 -26
  43. package/package.json +3 -3
  44. package/tsconfig.json +1 -1
  45. package/dist/commons/conditionals/conditionals.test.d.ts +0 -2
  46. package/dist/commons/conditionals/validate-address.test.d.ts +0 -2
  47. package/dist/commons/conditionals/validate.test.d.ts +0 -2
  48. package/dist/commons/events/utils.test.d.ts +0 -2
@@ -0,0 +1,3 @@
1
+ import { WorkqueueColumn } from './WorkqueueColumnConfig';
2
+ export declare const defaultWorkqueueColumns: WorkqueueColumn[];
3
+ //# sourceMappingURL=workqueueDefaultColumns.d.ts.map
@@ -22,7 +22,6 @@ var conditionals_exports = {};
22
22
  __export(conditionals_exports, {
23
23
  alwaysTrue: () => alwaysTrue,
24
24
  and: () => and,
25
- createEventConditionals: () => createEventConditionals,
26
25
  createFieldConditionals: () => createFieldConditionals,
27
26
  defineConditional: () => defineConditional,
28
27
  defineFormConditional: () => defineFormConditional,
@@ -33,6 +32,24 @@ __export(conditionals_exports, {
33
32
  });
34
33
  module.exports = __toCommonJS(conditionals_exports);
35
34
 
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
+
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,42 +111,7 @@ var user = {
94
111
  },
95
112
  required: ["$user"]
96
113
  })
97
- };
98
- function createEventConditionals() {
99
- return {
100
- /**
101
- * Checks if the event contains a specific action type.
102
- * @param action - The action type to check for.
103
- */
104
- hasAction: (action) => defineConditional({
105
- type: "object",
106
- properties: {
107
- $event: {
108
- type: "object",
109
- properties: {
110
- actions: {
111
- type: "array",
112
- contains: {
113
- type: "object",
114
- properties: {
115
- type: {
116
- const: action
117
- }
118
- },
119
- required: ["type"]
120
- }
121
- }
122
- },
123
- required: ["actions"]
124
- }
125
- },
126
- required: ["$event"]
127
- })
128
- };
129
- }
130
- function getDateFromNow(days) {
131
- return new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString().split("T")[0];
132
- }
114
+ });
133
115
  function getDateRangeToFieldReference(fieldId, comparedFieldId, clause) {
134
116
  return {
135
117
  type: "object",
@@ -145,9 +127,23 @@ function getDateRangeToFieldReference(fieldId, comparedFieldId, clause) {
145
127
  };
146
128
  }
147
129
  function isFieldReference(value) {
148
- return typeof value === "object" && value !== null && "_fieldId" in value;
130
+ return typeof value === "object" && value !== null && "$$field" in value;
149
131
  }
150
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
+ });
151
147
  const getDateRange = (date, clause) => ({
152
148
  type: "object",
153
149
  properties: {
@@ -160,18 +156,18 @@ function createFieldConditionals(fieldId) {
160
156
  required: [fieldId]
161
157
  });
162
158
  return {
159
+ /**
160
+ * @private Internal property used for field reference tracking.
161
+ */
162
+ $$field: fieldId,
163
163
  isAfter: () => ({
164
164
  days: (days) => ({
165
- inPast: () => defineFormConditional(
166
- getDateRange(getDateFromNow(days), "formatMinimum")
167
- ),
168
- inFuture: () => defineFormConditional(
169
- getDateRange(getDateFromNow(-days), "formatMinimum")
170
- )
165
+ inPast: () => defineFormConditional(getDayRange(-days, "after")),
166
+ inFuture: () => defineFormConditional(getDayRange(days, "after"))
171
167
  }),
172
168
  date: (date) => {
173
169
  if (isFieldReference(date)) {
174
- const comparedFieldId = date._fieldId;
170
+ const comparedFieldId = date.$$field;
175
171
  return defineFormConditional(
176
172
  getDateRangeToFieldReference(
177
173
  fieldId,
@@ -182,20 +178,16 @@ function createFieldConditionals(fieldId) {
182
178
  }
183
179
  return defineFormConditional(getDateRange(date, "formatMinimum"));
184
180
  },
185
- now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMinimum"))
181
+ now: () => defineFormConditional(getDateRange({ $data: "/$now" }, "formatMinimum"))
186
182
  }),
187
183
  isBefore: () => ({
188
184
  days: (days) => ({
189
- inPast: () => defineFormConditional(
190
- getDateRange(getDateFromNow(days), "formatMaximum")
191
- ),
192
- inFuture: () => defineFormConditional(
193
- getDateRange(getDateFromNow(-days), "formatMaximum")
194
- )
185
+ inPast: () => defineFormConditional(getDayRange(days, "before")),
186
+ inFuture: () => defineFormConditional(getDayRange(-days, "before"))
195
187
  }),
196
188
  date: (date) => {
197
189
  if (isFieldReference(date)) {
198
- const comparedFieldId = date._fieldId;
190
+ const comparedFieldId = date.$$field;
199
191
  return defineFormConditional(
200
192
  getDateRangeToFieldReference(
201
193
  fieldId,
@@ -206,17 +198,17 @@ function createFieldConditionals(fieldId) {
206
198
  }
207
199
  return defineFormConditional(getDateRange(date, "formatMaximum"));
208
200
  },
209
- now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMaximum"))
201
+ now: () => defineFormConditional(getDateRange({ $data: "/$now" }, "formatMaximum"))
210
202
  }),
211
203
  isEqualTo: (value) => {
212
204
  if (isFieldReference(value)) {
213
- const comparedFieldId = value._fieldId;
205
+ const comparedFieldId = value.$$field;
214
206
  return defineFormConditional({
215
207
  type: "object",
216
208
  properties: {
217
209
  [fieldId]: {
218
210
  type: ["string", "boolean"],
219
- const: { $data: `1/${comparedFieldId}` }
211
+ const: { $data: `/$form/${comparedFieldId}` }
220
212
  },
221
213
  [comparedFieldId]: { type: ["string", "boolean"] }
222
214
  },
@@ -295,11 +287,11 @@ function createFieldConditionals(fieldId) {
295
287
  properties: {
296
288
  [fieldId]: {
297
289
  type: "string",
298
- 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'._-]*)*$",
299
- description: "Name must contain only letters, numbers, and allowed special characters ('._-). No double spaces."
290
+ minLength: 1,
291
+ 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'.-]*)*$",
292
+ description: "Name must contain only letters, numbers, and allowed special characters ('.-). No double spaces."
300
293
  }
301
- },
302
- required: [fieldId]
294
+ }
303
295
  }),
304
296
  /**
305
297
  * Checks if the field value matches a given regular expression pattern.
@@ -327,6 +319,22 @@ function createFieldConditionals(fieldId) {
327
319
  },
328
320
  required: [fieldId]
329
321
  }),
330
- getId: () => ({ fieldId })
322
+ getId: () => ({ fieldId }),
323
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
324
+ object: (options) => defineFormConditional({
325
+ type: "object",
326
+ properties: {
327
+ [fieldId]: {
328
+ type: "object",
329
+ properties: Object.fromEntries(
330
+ Object.entries(options).map(([key, value]) => {
331
+ return [key, value.properties.$form.properties[key]];
332
+ })
333
+ ),
334
+ required: Object.keys(options)
335
+ }
336
+ },
337
+ required: [fieldId]
338
+ })
331
339
  };
332
340
  }