@opencrvs/toolkit 1.8.0-rc.fb4793a → 1.8.0-rc.fb5f1af

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 +8079 -8795
  2. package/dist/commons/conditionals/conditionals.d.ts +8 -15
  3. package/dist/commons/conditionals/validate.d.ts +6 -0
  4. package/dist/commons/events/ActionConfig.d.ts +62278 -34245
  5. package/dist/commons/events/ActionDocument.d.ts +3996 -1262
  6. package/dist/commons/events/ActionInput.d.ts +3139 -967
  7. package/dist/commons/events/ActionType.d.ts +4 -0
  8. package/dist/commons/events/AdvancedSearchConfig.d.ts +339 -36
  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 +2 -0
  13. package/dist/commons/events/Draft.d.ts +271 -93
  14. package/dist/commons/events/EventConfig.d.ts +31580 -17702
  15. package/dist/commons/events/EventDocument.d.ts +2554 -848
  16. package/dist/commons/events/EventIndex.d.ts +1037 -560
  17. package/dist/commons/events/EventInput.d.ts +0 -13
  18. package/dist/commons/events/EventMetadata.d.ts +122 -87
  19. package/dist/commons/events/FieldConfig.d.ts +2665 -1242
  20. package/dist/commons/events/FieldType.d.ts +5 -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 +13677 -4947
  24. package/dist/commons/events/PageConfig.d.ts +3999 -1861
  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 +7098 -532
  29. package/dist/commons/events/defineConfig.d.ts +3336 -894
  30. package/dist/commons/events/event.d.ts +12 -20
  31. package/dist/commons/events/field.d.ts +10 -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 +13978 -1510
  38. package/dist/commons/events/workqueueDefaultColumns.d.ts +3 -0
  39. package/dist/conditionals/index.js +66 -58
  40. package/dist/events/index.js +3673 -1888
  41. package/dist/scopes/index.d.ts +96 -7
  42. package/dist/scopes/index.js +105 -26
  43. package/package.json +3 -3
@@ -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
  },
@@ -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
  }