@opencrvs/toolkit 1.8.1-rc.a372970 → 1.8.1-rc.baeb06c

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 +5910 -5078
  2. package/dist/commons/conditionals/conditionals.d.ts +9 -13
  3. package/dist/commons/conditionals/validate.d.ts +15 -6
  4. package/dist/commons/events/ActionConfig.d.ts +119326 -1729
  5. package/dist/commons/events/ActionDocument.d.ts +4824 -1270
  6. package/dist/commons/events/ActionInput.d.ts +3205 -1025
  7. package/dist/commons/events/ActionType.d.ts +10 -1
  8. package/dist/commons/events/AdvancedSearchConfig.d.ts +1282 -22
  9. package/dist/commons/events/CompositeFieldValue.d.ts +40 -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 +2 -0
  13. package/dist/commons/events/Draft.d.ts +288 -97
  14. package/dist/commons/events/EventConfig.d.ts +54363 -1357
  15. package/dist/commons/events/EventDocument.d.ts +2720 -833
  16. package/dist/commons/events/EventIndex.d.ts +2228 -29
  17. package/dist/commons/events/EventMetadata.d.ts +347 -47
  18. package/dist/commons/events/FieldConfig.d.ts +6756 -1260
  19. package/dist/commons/events/FieldType.d.ts +8 -3
  20. package/dist/commons/events/FieldTypeMapping.d.ts +161 -73
  21. package/dist/commons/events/FieldValue.d.ts +91 -20
  22. package/dist/commons/events/FormConfig.d.ts +55770 -522
  23. package/dist/commons/events/PageConfig.d.ts +13825 -209
  24. package/dist/commons/events/SummaryConfig.d.ts +93 -42
  25. package/dist/commons/events/User.d.ts +34 -2
  26. package/dist/commons/events/WorkqueueColumnConfig.d.ts +53 -0
  27. package/dist/commons/events/WorkqueueConfig.d.ts +8116 -20
  28. package/dist/commons/events/defineConfig.d.ts +8529 -77
  29. package/dist/commons/events/event.d.ts +46 -0
  30. package/dist/commons/events/field.d.ts +94 -0
  31. package/dist/commons/events/index.d.ts +8 -0
  32. package/dist/commons/events/scopes.d.ts +45 -0
  33. package/dist/commons/events/serializer.d.ts +2 -0
  34. package/dist/commons/events/test.utils.d.ts +206 -90
  35. package/dist/commons/events/transactions.d.ts +1 -1
  36. package/dist/commons/events/utils.d.ts +15436 -88
  37. package/dist/commons/events/workqueueDefaultColumns.d.ts +3 -0
  38. package/dist/conditionals/index.js +66 -56
  39. package/dist/events/index.js +4658 -1786
  40. package/dist/scopes/index.d.ts +184 -7
  41. package/dist/scopes/index.js +140 -40
  42. package/package.json +4 -3
@@ -0,0 +1,3 @@
1
+ import { WorkqueueColumn } from './WorkqueueColumnConfig';
2
+ export declare const defaultWorkqueueColumns: WorkqueueColumn[];
3
+ //# sourceMappingURL=workqueueDefaultColumns.d.ts.map
@@ -22,10 +22,9 @@ var conditionals_exports = {};
22
22
  __export(conditionals_exports, {
23
23
  alwaysTrue: () => alwaysTrue,
24
24
  and: () => and,
25
+ createFieldConditionals: () => createFieldConditionals,
25
26
  defineConditional: () => defineConditional,
26
27
  defineFormConditional: () => defineFormConditional,
27
- event: () => event,
28
- field: () => field,
29
28
  never: () => never,
30
29
  not: () => not,
31
30
  or: () => or,
@@ -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,36 +111,7 @@ 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"]
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
- }
114
+ });
127
115
  function getDateRangeToFieldReference(fieldId, comparedFieldId, clause) {
128
116
  return {
129
117
  type: "object",
@@ -139,9 +127,23 @@ function getDateRangeToFieldReference(fieldId, comparedFieldId, clause) {
139
127
  };
140
128
  }
141
129
  function isFieldReference(value) {
142
- return typeof value === "object" && value !== null && "_fieldId" in value;
130
+ return typeof value === "object" && value !== null && "$$field" in value;
143
131
  }
144
- function field(fieldId) {
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
+ });
145
147
  const getDateRange = (date, clause) => ({
146
148
  type: "object",
147
149
  properties: {
@@ -157,19 +159,15 @@ function field(fieldId) {
157
159
  /**
158
160
  * @private Internal property used for field reference tracking.
159
161
  */
160
- _fieldId: fieldId,
162
+ $$field: fieldId,
161
163
  isAfter: () => ({
162
164
  days: (days) => ({
163
- inPast: () => defineFormConditional(
164
- getDateRange(getDateFromNow(days), "formatMinimum")
165
- ),
166
- inFuture: () => defineFormConditional(
167
- getDateRange(getDateFromNow(-days), "formatMinimum")
168
- )
165
+ inPast: () => defineFormConditional(getDayRange(-days, "after")),
166
+ inFuture: () => defineFormConditional(getDayRange(days, "after"))
169
167
  }),
170
168
  date: (date) => {
171
169
  if (isFieldReference(date)) {
172
- const comparedFieldId = date._fieldId;
170
+ const comparedFieldId = date.$$field;
173
171
  return defineFormConditional(
174
172
  getDateRangeToFieldReference(
175
173
  fieldId,
@@ -180,20 +178,16 @@ function field(fieldId) {
180
178
  }
181
179
  return defineFormConditional(getDateRange(date, "formatMinimum"));
182
180
  },
183
- now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMinimum"))
181
+ now: () => defineFormConditional(getDateRange({ $data: "/$now" }, "formatMinimum"))
184
182
  }),
185
183
  isBefore: () => ({
186
184
  days: (days) => ({
187
- inPast: () => defineFormConditional(
188
- getDateRange(getDateFromNow(days), "formatMaximum")
189
- ),
190
- inFuture: () => defineFormConditional(
191
- getDateRange(getDateFromNow(-days), "formatMaximum")
192
- )
185
+ inPast: () => defineFormConditional(getDayRange(days, "before")),
186
+ inFuture: () => defineFormConditional(getDayRange(-days, "before"))
193
187
  }),
194
188
  date: (date) => {
195
189
  if (isFieldReference(date)) {
196
- const comparedFieldId = date._fieldId;
190
+ const comparedFieldId = date.$$field;
197
191
  return defineFormConditional(
198
192
  getDateRangeToFieldReference(
199
193
  fieldId,
@@ -204,17 +198,17 @@ function field(fieldId) {
204
198
  }
205
199
  return defineFormConditional(getDateRange(date, "formatMaximum"));
206
200
  },
207
- now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMaximum"))
201
+ now: () => defineFormConditional(getDateRange({ $data: "/$now" }, "formatMaximum"))
208
202
  }),
209
203
  isEqualTo: (value) => {
210
204
  if (isFieldReference(value)) {
211
- const comparedFieldId = value._fieldId;
205
+ const comparedFieldId = value.$$field;
212
206
  return defineFormConditional({
213
207
  type: "object",
214
208
  properties: {
215
209
  [fieldId]: {
216
210
  type: ["string", "boolean"],
217
- const: { $data: `1/${comparedFieldId}` }
211
+ const: { $data: `/$form/${comparedFieldId}` }
218
212
  },
219
213
  [comparedFieldId]: { type: ["string", "boolean"] }
220
214
  },
@@ -296,8 +290,7 @@ function field(fieldId) {
296
290
  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'._-]*)*$",
297
291
  description: "Name must contain only letters, numbers, and allowed special characters ('._-). No double spaces."
298
292
  }
299
- },
300
- required: [fieldId]
293
+ }
301
294
  }),
302
295
  /**
303
296
  * Checks if the field value matches a given regular expression pattern.
@@ -324,6 +317,23 @@ function field(fieldId) {
324
317
  }
325
318
  },
326
319
  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]
327
337
  })
328
338
  };
329
339
  }