@opencrvs/toolkit 1.8.0-rc.fb5b9fe → 1.8.0-rc.fb8e005
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.
- package/dist/commons/api/router.d.ts +5924 -8783
- package/dist/commons/conditionals/conditionals.d.ts +4 -0
- package/dist/commons/conditionals/validate.d.ts +6 -0
- package/dist/commons/events/ActionConfig.d.ts +21534 -6326
- package/dist/commons/events/ActionDocument.d.ts +1783 -280
- package/dist/commons/events/ActionInput.d.ts +1382 -182
- package/dist/commons/events/ActionType.d.ts +4 -0
- package/dist/commons/events/AdvancedSearchConfig.d.ts +279 -3
- package/dist/commons/events/CompositeFieldValue.d.ts +28 -0
- package/dist/commons/events/Constants.d.ts +1 -0
- package/dist/commons/events/CountryConfigQueryInput.d.ts +1161 -413
- package/dist/commons/events/Draft.d.ts +118 -17
- package/dist/commons/events/EventConfig.d.ts +11557 -4116
- package/dist/commons/events/EventDocument.d.ts +1144 -205
- package/dist/commons/events/EventIndex.d.ts +839 -185
- package/dist/commons/events/EventMetadata.d.ts +52 -40
- package/dist/commons/events/FieldConfig.d.ts +1896 -872
- package/dist/commons/events/FieldType.d.ts +4 -1
- package/dist/commons/events/FieldTypeMapping.d.ts +89 -50
- package/dist/commons/events/FieldValue.d.ts +41 -5
- package/dist/commons/events/FormConfig.d.ts +8840 -2444
- package/dist/commons/events/PageConfig.d.ts +3104 -1540
- package/dist/commons/events/SummaryConfig.d.ts +0 -5
- package/dist/commons/events/WorkqueueColumnConfig.d.ts +11 -11
- package/dist/commons/events/WorkqueueConfig.d.ts +4460 -1685
- package/dist/commons/events/defineConfig.d.ts +1279 -17
- package/dist/commons/events/field.d.ts +9 -0
- package/dist/commons/events/index.d.ts +1 -0
- package/dist/commons/events/scopes.d.ts +1 -2
- package/dist/commons/events/test.utils.d.ts +146 -38
- package/dist/commons/events/utils.d.ts +10117 -10
- package/dist/conditionals/index.js +38 -18
- package/dist/events/index.js +1718 -1057
- package/dist/scopes/index.d.ts +4 -1
- package/dist/scopes/index.js +67 -17
- package/package.json +3 -3
@@ -144,9 +144,6 @@ function createEventConditionals() {
|
|
144
144
|
})
|
145
145
|
};
|
146
146
|
}
|
147
|
-
function getDateFromNow(days) {
|
148
|
-
return new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString().split("T")[0];
|
149
|
-
}
|
150
147
|
function getDateRangeToFieldReference(fieldId, comparedFieldId, clause) {
|
151
148
|
return {
|
152
149
|
type: "object",
|
@@ -165,6 +162,20 @@ function isFieldReference(value) {
|
|
165
162
|
return typeof value === "object" && value !== null && "$$field" in value;
|
166
163
|
}
|
167
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
|
+
});
|
168
179
|
const getDateRange = (date, clause) => ({
|
169
180
|
type: "object",
|
170
181
|
properties: {
|
@@ -183,12 +194,8 @@ function createFieldConditionals(fieldId) {
|
|
183
194
|
$$field: fieldId,
|
184
195
|
isAfter: () => ({
|
185
196
|
days: (days) => ({
|
186
|
-
inPast: () => defineFormConditional(
|
187
|
-
|
188
|
-
),
|
189
|
-
inFuture: () => defineFormConditional(
|
190
|
-
getDateRange(getDateFromNow(-days), "formatMinimum")
|
191
|
-
)
|
197
|
+
inPast: () => defineFormConditional(getDayRange(-days, "after")),
|
198
|
+
inFuture: () => defineFormConditional(getDayRange(days, "after"))
|
192
199
|
}),
|
193
200
|
date: (date) => {
|
194
201
|
if (isFieldReference(date)) {
|
@@ -203,16 +210,12 @@ function createFieldConditionals(fieldId) {
|
|
203
210
|
}
|
204
211
|
return defineFormConditional(getDateRange(date, "formatMinimum"));
|
205
212
|
},
|
206
|
-
now: () => defineFormConditional(getDateRange(
|
213
|
+
now: () => defineFormConditional(getDateRange({ $data: "/$now" }, "formatMinimum"))
|
207
214
|
}),
|
208
215
|
isBefore: () => ({
|
209
216
|
days: (days) => ({
|
210
|
-
inPast: () => defineFormConditional(
|
211
|
-
|
212
|
-
),
|
213
|
-
inFuture: () => defineFormConditional(
|
214
|
-
getDateRange(getDateFromNow(-days), "formatMaximum")
|
215
|
-
)
|
217
|
+
inPast: () => defineFormConditional(getDayRange(days, "before")),
|
218
|
+
inFuture: () => defineFormConditional(getDayRange(-days, "before"))
|
216
219
|
}),
|
217
220
|
date: (date) => {
|
218
221
|
if (isFieldReference(date)) {
|
@@ -227,7 +230,7 @@ function createFieldConditionals(fieldId) {
|
|
227
230
|
}
|
228
231
|
return defineFormConditional(getDateRange(date, "formatMaximum"));
|
229
232
|
},
|
230
|
-
now: () => defineFormConditional(getDateRange(
|
233
|
+
now: () => defineFormConditional(getDateRange({ $data: "/$now" }, "formatMaximum"))
|
231
234
|
}),
|
232
235
|
isEqualTo: (value) => {
|
233
236
|
if (isFieldReference(value)) {
|
@@ -237,7 +240,7 @@ function createFieldConditionals(fieldId) {
|
|
237
240
|
properties: {
|
238
241
|
[fieldId]: {
|
239
242
|
type: ["string", "boolean"],
|
240
|
-
const: { $data:
|
243
|
+
const: { $data: `/$form/${comparedFieldId}` }
|
241
244
|
},
|
242
245
|
[comparedFieldId]: { type: ["string", "boolean"] }
|
243
246
|
},
|
@@ -347,6 +350,23 @@ function createFieldConditionals(fieldId) {
|
|
347
350
|
}
|
348
351
|
},
|
349
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]
|
350
370
|
})
|
351
371
|
};
|
352
372
|
}
|