@opencrvs/toolkit 1.8.0-rc.f8e4107 → 1.8.0-rc.f8f94b8

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 +5905 -5314
  2. package/dist/commons/conditionals/conditionals.d.ts +7 -76
  3. package/dist/commons/conditionals/validate.d.ts +15 -6
  4. package/dist/commons/events/ActionConfig.d.ts +115347 -1728
  5. package/dist/commons/events/ActionDocument.d.ts +4824 -1375
  6. package/dist/commons/events/ActionInput.d.ts +3205 -1025
  7. package/dist/commons/events/ActionType.d.ts +9 -4
  8. package/dist/commons/events/AdvancedSearchConfig.d.ts +1190 -23
  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 +290 -104
  14. package/dist/commons/events/EventConfig.d.ts +52547 -1394
  15. package/dist/commons/events/EventDocument.d.ts +2720 -913
  16. package/dist/commons/events/EventIndex.d.ts +1696 -239
  17. package/dist/commons/events/EventMetadata.d.ts +340 -45
  18. package/dist/commons/events/FieldConfig.d.ts +6362 -1159
  19. package/dist/commons/events/FieldType.d.ts +7 -3
  20. package/dist/commons/events/FieldTypeMapping.d.ts +154 -73
  21. package/dist/commons/events/FieldValue.d.ts +90 -20
  22. package/dist/commons/events/FormConfig.d.ts +53892 -510
  23. package/dist/commons/events/PageConfig.d.ts +13367 -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 +8255 -86
  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 +46 -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 +14940 -85
  37. package/dist/commons/events/workqueueDefaultColumns.d.ts +3 -0
  38. package/dist/conditionals/index.js +64 -102
  39. package/dist/events/index.js +4576 -1838
  40. package/dist/scopes/index.d.ts +247 -1
  41. package/dist/scopes/index.js +231 -1
  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,11 +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
- eventField: () => eventField,
29
- field: () => field,
30
28
  never: () => never,
31
29
  not: () => not,
32
30
  or: () => or,
@@ -34,6 +32,24 @@ __export(conditionals_exports, {
34
32
  });
35
33
  module.exports = __toCommonJS(conditionals_exports);
36
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
+
37
53
  // ../commons/src/conditionals/conditionals.ts
38
54
  function defineConditional(schema) {
39
55
  return schema;
@@ -75,7 +91,7 @@ function not(condition) {
75
91
  function never() {
76
92
  return not(alwaysTrue());
77
93
  }
78
- var user = {
94
+ var user = Object.assign(userSerializer, {
79
95
  hasScope: (scope) => defineConditional({
80
96
  type: "object",
81
97
  properties: {
@@ -95,36 +111,7 @@ var user = {
95
111
  },
96
112
  required: ["$user"]
97
113
  })
98
- };
99
- var event = {
100
- hasAction: (action) => defineConditional({
101
- type: "object",
102
- properties: {
103
- $event: {
104
- type: "object",
105
- properties: {
106
- actions: {
107
- type: "array",
108
- contains: {
109
- type: "object",
110
- properties: {
111
- type: {
112
- const: action
113
- }
114
- },
115
- required: ["type"]
116
- }
117
- }
118
- },
119
- required: ["actions"]
120
- }
121
- },
122
- required: ["$event"]
123
- })
124
- };
125
- function getDateFromNow(days) {
126
- return new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString().split("T")[0];
127
- }
114
+ });
128
115
  function getDateRangeToFieldReference(fieldId, comparedFieldId, clause) {
129
116
  return {
130
117
  type: "object",
@@ -140,9 +127,23 @@ function getDateRangeToFieldReference(fieldId, comparedFieldId, clause) {
140
127
  };
141
128
  }
142
129
  function isFieldReference(value) {
143
- return typeof value === "object" && value !== null && "_fieldId" in value;
130
+ return typeof value === "object" && value !== null && "$$field" in value;
144
131
  }
145
- 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
+ });
146
147
  const getDateRange = (date, clause) => ({
147
148
  type: "object",
148
149
  properties: {
@@ -158,19 +159,15 @@ function field(fieldId) {
158
159
  /**
159
160
  * @private Internal property used for field reference tracking.
160
161
  */
161
- _fieldId: fieldId,
162
+ $$field: fieldId,
162
163
  isAfter: () => ({
163
164
  days: (days) => ({
164
- inPast: () => defineFormConditional(
165
- getDateRange(getDateFromNow(days), "formatMinimum")
166
- ),
167
- inFuture: () => defineFormConditional(
168
- getDateRange(getDateFromNow(-days), "formatMinimum")
169
- )
165
+ inPast: () => defineFormConditional(getDayRange(-days, "after")),
166
+ inFuture: () => defineFormConditional(getDayRange(days, "after"))
170
167
  }),
171
168
  date: (date) => {
172
169
  if (isFieldReference(date)) {
173
- const comparedFieldId = date._fieldId;
170
+ const comparedFieldId = date.$$field;
174
171
  return defineFormConditional(
175
172
  getDateRangeToFieldReference(
176
173
  fieldId,
@@ -181,20 +178,16 @@ function field(fieldId) {
181
178
  }
182
179
  return defineFormConditional(getDateRange(date, "formatMinimum"));
183
180
  },
184
- now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMinimum"))
181
+ now: () => defineFormConditional(getDateRange({ $data: "/$now" }, "formatMinimum"))
185
182
  }),
186
183
  isBefore: () => ({
187
184
  days: (days) => ({
188
- inPast: () => defineFormConditional(
189
- getDateRange(getDateFromNow(days), "formatMaximum")
190
- ),
191
- inFuture: () => defineFormConditional(
192
- getDateRange(getDateFromNow(-days), "formatMaximum")
193
- )
185
+ inPast: () => defineFormConditional(getDayRange(days, "before")),
186
+ inFuture: () => defineFormConditional(getDayRange(-days, "before"))
194
187
  }),
195
188
  date: (date) => {
196
189
  if (isFieldReference(date)) {
197
- const comparedFieldId = date._fieldId;
190
+ const comparedFieldId = date.$$field;
198
191
  return defineFormConditional(
199
192
  getDateRangeToFieldReference(
200
193
  fieldId,
@@ -205,17 +198,17 @@ function field(fieldId) {
205
198
  }
206
199
  return defineFormConditional(getDateRange(date, "formatMaximum"));
207
200
  },
208
- now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMaximum"))
201
+ now: () => defineFormConditional(getDateRange({ $data: "/$now" }, "formatMaximum"))
209
202
  }),
210
203
  isEqualTo: (value) => {
211
204
  if (isFieldReference(value)) {
212
- const comparedFieldId = value._fieldId;
205
+ const comparedFieldId = value.$$field;
213
206
  return defineFormConditional({
214
207
  type: "object",
215
208
  properties: {
216
209
  [fieldId]: {
217
210
  type: ["string", "boolean"],
218
- const: { $data: `1/${comparedFieldId}` }
211
+ const: { $data: `/$form/${comparedFieldId}` }
219
212
  },
220
213
  [comparedFieldId]: { type: ["string", "boolean"] }
221
214
  },
@@ -326,53 +319,22 @@ function field(fieldId) {
326
319
  },
327
320
  required: [fieldId]
328
321
  }),
329
- /**
330
- * Creates a range configuration for the specified field.
331
- *
332
- * @returns An object containing the field ID and a configuration object with a type of 'RANGE'.
333
- *
334
- * @example field('age').range()
335
- * // {
336
- * // fieldId: 'age',
337
- * // config: { type: 'RANGE' }
338
- * // }
339
- */
340
- range: () => ({
341
- fieldId,
342
- config: { type: "RANGE" }
343
- }),
344
- /**
345
- * Creates a configuration for exact matching of the specified field.
346
- * @returns An object containing the field ID and a configuration object with a type of 'EXACT'.
347
- * @example field('dob').exact()
348
- * // {
349
- * // fieldId: 'dob',
350
- * // config: { type: 'EXACT' }
351
- * // }
352
- */
353
- exact: () => ({
354
- fieldId,
355
- config: { type: "EXACT" }
356
- }),
357
- /**
358
- * Creates a configuration for fuzzy matching of the specified field.
359
- * @returns An object containing the field ID and a configuration object with a type of 'EXACT'.
360
- * @example field('name').fuzzy()
361
- * // {
362
- * // fieldId: 'name',
363
- * // config: { type: 'FUZZY' }
364
- * // }
365
- */
366
- fuzzy: () => ({
367
- fieldId,
368
- config: { type: "FUZZY" }
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]
369
338
  })
370
339
  };
371
340
  }
372
- function eventField(fieldId, options) {
373
- return {
374
- fieldId,
375
- options,
376
- config: { type: "EXACT" }
377
- };
378
- }