@opencrvs/toolkit 1.9.13-rc.0f86459 → 1.9.13-rc.1045e45
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 +0 -1
- package/dist/commons/conditionals/conditionals.d.ts +2 -345
- package/dist/commons/conditionals/validate.d.ts +0 -8
- package/dist/commons/events/EventConfig.d.ts +0 -7
- package/dist/commons/events/FieldConfig.d.ts +88 -1489
- package/dist/commons/events/defineConfig.d.ts +0 -1
- package/dist/commons/events/field.d.ts +1 -47
- package/dist/commons/events/utils.d.ts +1 -2
- package/dist/conditionals/index.js +1 -48
- package/dist/events/index.js +44 -139
- package/dist/notification/index.js +35 -112
- package/package.json +1 -1
package/dist/events/index.js
CHANGED
|
@@ -69,7 +69,6 @@ __export(events_exports, {
|
|
|
69
69
|
CheckboxFieldValue: () => CheckboxFieldValue,
|
|
70
70
|
Clause: () => Clause,
|
|
71
71
|
ClientSpecificAction: () => ClientSpecificAction,
|
|
72
|
-
ComputedDefaultValue: () => ComputedDefaultValue,
|
|
73
72
|
Conditional: () => Conditional,
|
|
74
73
|
ConditionalType: () => ConditionalType,
|
|
75
74
|
ConfirmableActions: () => ConfirmableActions,
|
|
@@ -230,7 +229,6 @@ __export(events_exports, {
|
|
|
230
229
|
areConditionsMet: () => areConditionsMet,
|
|
231
230
|
buildFormState: () => buildFormState,
|
|
232
231
|
canUserReadEvent: () => canUserReadEvent,
|
|
233
|
-
compileClientFunction: () => compileClientFunction,
|
|
234
232
|
compositeFieldTypes: () => compositeFieldTypes,
|
|
235
233
|
configurableEventScopeAllowed: () => configurableEventScopeAllowed,
|
|
236
234
|
createEmptyDraft: () => createEmptyDraft,
|
|
@@ -252,7 +250,6 @@ __export(events_exports, {
|
|
|
252
250
|
defineWorkqueuesColumns: () => defineWorkqueuesColumns,
|
|
253
251
|
deserializeQuery: () => deserializeQuery,
|
|
254
252
|
errorMessages: () => errorMessages,
|
|
255
|
-
evaluate: () => evaluate,
|
|
256
253
|
event: () => event,
|
|
257
254
|
eventMetadataLabelMap: () => eventMetadataLabelMap,
|
|
258
255
|
eventPayloadGenerator: () => eventPayloadGenerator,
|
|
@@ -316,7 +313,6 @@ __export(events_exports, {
|
|
|
316
313
|
isBulletListFieldType: () => isBulletListFieldType,
|
|
317
314
|
isButtonFieldType: () => isButtonFieldType,
|
|
318
315
|
isCheckboxFieldType: () => isCheckboxFieldType,
|
|
319
|
-
isCodeToEvaluate: () => isCodeToEvaluate,
|
|
320
316
|
isConditionMet: () => isConditionMet,
|
|
321
317
|
isCountryFieldType: () => isCountryFieldType,
|
|
322
318
|
isDataFieldType: () => isDataFieldType,
|
|
@@ -387,7 +383,6 @@ __export(events_exports, {
|
|
|
387
383
|
runStructuralValidations: () => runStructuralValidations,
|
|
388
384
|
safeUnion: () => safeUnion,
|
|
389
385
|
timePeriodToDateRange: () => timePeriodToDateRange,
|
|
390
|
-
todayISO: () => todayISO,
|
|
391
386
|
user: () => user,
|
|
392
387
|
validate: () => validate,
|
|
393
388
|
validateFieldInput: () => validateFieldInput,
|
|
@@ -1987,26 +1982,11 @@ var FieldId = import_zod17.z.string().refine(
|
|
|
1987
1982
|
})
|
|
1988
1983
|
).describe("Unique identifier for the field");
|
|
1989
1984
|
var FieldReference = import_zod17.z.object({
|
|
1990
|
-
$$field: FieldId
|
|
1991
|
-
"Field whose value is passed as the first argument to the computation"
|
|
1992
|
-
),
|
|
1985
|
+
$$field: FieldId,
|
|
1993
1986
|
$$subfield: import_zod17.z.array(import_zod17.z.string()).optional().default([]).describe(
|
|
1994
1987
|
'If the FieldValue is an object, subfield can be used to refer to e.g. `["foo", "bar"]` in `{ foo: { bar: 3 } }`'
|
|
1995
|
-
),
|
|
1996
|
-
$$code: import_zod17.z.string().optional().describe(
|
|
1997
|
-
"Serialised client-side function body. When present the expression is evaluated rather than dereferenced."
|
|
1998
|
-
)
|
|
1999
|
-
}).describe(
|
|
2000
|
-
"Reference to a field value, with an optional client-side computation applied."
|
|
2001
|
-
);
|
|
2002
|
-
function isCodeToEvaluate(v) {
|
|
2003
|
-
return !!v && typeof v === "object" && "$$code" in v;
|
|
2004
|
-
}
|
|
2005
|
-
var ComputedDefaultValue = import_zod17.z.object({
|
|
2006
|
-
$$code: import_zod17.z.string().describe(
|
|
2007
|
-
"Serialised client-side function body. Receives (undefined, context) where context includes $now, $online, and system variables."
|
|
2008
1988
|
)
|
|
2009
|
-
}).describe("
|
|
1989
|
+
}).describe("Reference to a field by its ID");
|
|
2010
1990
|
var ValidationConfig = import_zod17.z.object({
|
|
2011
1991
|
validator: Conditional,
|
|
2012
1992
|
message: TranslationConfig
|
|
@@ -2040,7 +2020,7 @@ var BaseField = import_zod17.z.object({
|
|
|
2040
2020
|
"Indicates whether the field can be modified during record correction."
|
|
2041
2021
|
),
|
|
2042
2022
|
value: FieldReference.or(import_zod17.z.array(FieldReference)).optional().describe(
|
|
2043
|
-
"Reference to the source field or fields. When a value is defined, it is copied from the parent field when changed. If multiple references are provided, the first truthy value is used.
|
|
2023
|
+
"Reference to the source field or fields. When a value is defined, it is copied from the parent field when changed. If multiple references are provided, the first truthy value is used."
|
|
2044
2024
|
),
|
|
2045
2025
|
analytics: import_zod17.z.boolean().default(false).optional().describe(
|
|
2046
2026
|
"Indicates whether the field is included in analytics. When enabled, its value becomes available in the analytics dashboard."
|
|
@@ -2051,7 +2031,7 @@ var Divider = BaseField.extend({
|
|
|
2051
2031
|
});
|
|
2052
2032
|
var TextField = BaseField.extend({
|
|
2053
2033
|
type: import_zod17.z.literal(FieldType.TEXT),
|
|
2054
|
-
defaultValue: import_zod17.z.union([NonEmptyTextValue, SerializedUserField
|
|
2034
|
+
defaultValue: import_zod17.z.union([NonEmptyTextValue, SerializedUserField]).optional(),
|
|
2055
2035
|
configuration: import_zod17.z.object({
|
|
2056
2036
|
maxLength: import_zod17.z.number().optional().describe("Maximum length of the text"),
|
|
2057
2037
|
type: import_zod17.z.enum(["text", "password"]).optional(),
|
|
@@ -2061,7 +2041,7 @@ var TextField = BaseField.extend({
|
|
|
2061
2041
|
}).describe("Text input");
|
|
2062
2042
|
var NumberField = BaseField.extend({
|
|
2063
2043
|
type: import_zod17.z.literal(FieldType.NUMBER),
|
|
2064
|
-
defaultValue: NumberFieldValue.
|
|
2044
|
+
defaultValue: NumberFieldValue.optional(),
|
|
2065
2045
|
configuration: import_zod17.z.object({
|
|
2066
2046
|
min: import_zod17.z.number().optional().describe("Minimum value"),
|
|
2067
2047
|
max: import_zod17.z.number().optional().describe("Maximum value"),
|
|
@@ -2071,7 +2051,7 @@ var NumberField = BaseField.extend({
|
|
|
2071
2051
|
}).describe("Number input");
|
|
2072
2052
|
var TextAreaField = BaseField.extend({
|
|
2073
2053
|
type: import_zod17.z.literal(FieldType.TEXTAREA),
|
|
2074
|
-
defaultValue: NonEmptyTextValue.
|
|
2054
|
+
defaultValue: NonEmptyTextValue.optional(),
|
|
2075
2055
|
configuration: import_zod17.z.object({
|
|
2076
2056
|
maxLength: import_zod17.z.number().optional().describe("Maximum length of the text"),
|
|
2077
2057
|
rows: import_zod17.z.number().optional().describe("Number of visible text lines"),
|
|
@@ -2102,7 +2082,7 @@ var SignatureField = BaseField.extend({
|
|
|
2102
2082
|
signaturePromptLabel: TranslationConfig.describe(
|
|
2103
2083
|
"Title of the signature modal"
|
|
2104
2084
|
),
|
|
2105
|
-
defaultValue: SignatureFieldValue.
|
|
2085
|
+
defaultValue: SignatureFieldValue.optional(),
|
|
2106
2086
|
configuration: import_zod17.z.object({
|
|
2107
2087
|
maxFileSize: import_zod17.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
|
|
2108
2088
|
acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature")
|
|
@@ -2115,11 +2095,11 @@ var EmailField = BaseField.extend({
|
|
|
2115
2095
|
configuration: import_zod17.z.object({
|
|
2116
2096
|
maxLength: import_zod17.z.number().optional().describe("Maximum length of the text")
|
|
2117
2097
|
}).default({ maxLength: 10 }).optional(),
|
|
2118
|
-
defaultValue: NonEmptyTextValue.
|
|
2098
|
+
defaultValue: NonEmptyTextValue.optional()
|
|
2119
2099
|
});
|
|
2120
2100
|
var DateField = BaseField.extend({
|
|
2121
2101
|
type: import_zod17.z.literal(FieldType.DATE),
|
|
2122
|
-
defaultValue: SerializedNowDateTime.or(PlainDate).
|
|
2102
|
+
defaultValue: SerializedNowDateTime.or(PlainDate).optional().openapi({ effectType: "input", type: "string" }).describe("Default date value(yyyy-MM-dd)"),
|
|
2123
2103
|
configuration: import_zod17.z.object({
|
|
2124
2104
|
notice: TranslationConfig.describe(
|
|
2125
2105
|
"Text to display above the date input"
|
|
@@ -2128,7 +2108,7 @@ var DateField = BaseField.extend({
|
|
|
2128
2108
|
}).describe("A single date input (yyyy-MM-dd)");
|
|
2129
2109
|
var AgeField = BaseField.extend({
|
|
2130
2110
|
type: import_zod17.z.literal(FieldType.AGE),
|
|
2131
|
-
defaultValue: NumberFieldValue.
|
|
2111
|
+
defaultValue: NumberFieldValue.optional(),
|
|
2132
2112
|
configuration: import_zod17.z.object({
|
|
2133
2113
|
asOfDate: FieldReference,
|
|
2134
2114
|
prefix: TranslationConfig.optional(),
|
|
@@ -2137,7 +2117,7 @@ var AgeField = BaseField.extend({
|
|
|
2137
2117
|
}).describe("An age input field which uses the current date as the asOfDate");
|
|
2138
2118
|
var TimeField = BaseField.extend({
|
|
2139
2119
|
type: import_zod17.z.literal(FieldType.TIME),
|
|
2140
|
-
defaultValue: SerializedNowDateTime.or(TimeValue).
|
|
2120
|
+
defaultValue: SerializedNowDateTime.or(TimeValue).optional().openapi({ effectType: "input", type: "object" }).describe("Default time value (HH-mm)"),
|
|
2141
2121
|
configuration: import_zod17.z.object({
|
|
2142
2122
|
use12HourFormat: import_zod17.z.boolean().optional().describe("Whether to use 12-hour format"),
|
|
2143
2123
|
notice: TranslationConfig.describe(
|
|
@@ -2147,7 +2127,7 @@ var TimeField = BaseField.extend({
|
|
|
2147
2127
|
}).describe("A single date input (HH-mm)");
|
|
2148
2128
|
var DateRangeField = BaseField.extend({
|
|
2149
2129
|
type: import_zod17.z.literal(FieldType.DATE_RANGE),
|
|
2150
|
-
defaultValue: DateRangeFieldValue.
|
|
2130
|
+
defaultValue: DateRangeFieldValue.optional(),
|
|
2151
2131
|
configuration: import_zod17.z.object({
|
|
2152
2132
|
notice: TranslationConfig.describe(
|
|
2153
2133
|
"Text to display above the date input"
|
|
@@ -2181,7 +2161,7 @@ var PageHeader = BaseField.extend({
|
|
|
2181
2161
|
}).describe("A read-only header component for form pages");
|
|
2182
2162
|
var File = BaseField.extend({
|
|
2183
2163
|
type: import_zod17.z.literal(FieldType.FILE),
|
|
2184
|
-
defaultValue: FileFieldValue.
|
|
2164
|
+
defaultValue: FileFieldValue.optional(),
|
|
2185
2165
|
configuration: import_zod17.z.object({
|
|
2186
2166
|
maxFileSize: import_zod17.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
|
|
2187
2167
|
acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature"),
|
|
@@ -2205,7 +2185,7 @@ var SelectOption = import_zod17.z.object({
|
|
|
2205
2185
|
});
|
|
2206
2186
|
var NumberWithUnitField = BaseField.extend({
|
|
2207
2187
|
type: import_zod17.z.literal(FieldType.NUMBER_WITH_UNIT),
|
|
2208
|
-
defaultValue: NumberWithUnitFieldValue.
|
|
2188
|
+
defaultValue: NumberWithUnitFieldValue.optional(),
|
|
2209
2189
|
options: import_zod17.z.array(SelectOption).describe("A list of options for the unit select"),
|
|
2210
2190
|
configuration: import_zod17.z.object({
|
|
2211
2191
|
min: import_zod17.z.number().optional().describe("Minimum value of the number field"),
|
|
@@ -2217,7 +2197,7 @@ var NumberWithUnitField = BaseField.extend({
|
|
|
2217
2197
|
}).describe("Number with unit input");
|
|
2218
2198
|
var RadioGroup = BaseField.extend({
|
|
2219
2199
|
type: import_zod17.z.literal(FieldType.RADIO_GROUP),
|
|
2220
|
-
defaultValue: TextValue.
|
|
2200
|
+
defaultValue: TextValue.optional(),
|
|
2221
2201
|
options: import_zod17.z.array(SelectOption).describe("A list of options"),
|
|
2222
2202
|
configuration: import_zod17.z.object({
|
|
2223
2203
|
styles: import_zod17.z.object({
|
|
@@ -2236,7 +2216,7 @@ var BulletList = BaseField.extend({
|
|
|
2236
2216
|
}).describe("A list of bullet points");
|
|
2237
2217
|
var Select = BaseField.extend({
|
|
2238
2218
|
type: import_zod17.z.literal(FieldType.SELECT),
|
|
2239
|
-
defaultValue: TextValue.
|
|
2219
|
+
defaultValue: TextValue.optional(),
|
|
2240
2220
|
options: import_zod17.z.array(SelectOption).describe("A list of options"),
|
|
2241
2221
|
noOptionsMessage: TranslationConfig.optional().describe(
|
|
2242
2222
|
`
|
|
@@ -2255,7 +2235,7 @@ var SelectDateRangeOption = import_zod17.z.object({
|
|
|
2255
2235
|
});
|
|
2256
2236
|
var SelectDateRangeField = BaseField.extend({
|
|
2257
2237
|
type: import_zod17.z.literal(FieldType.SELECT_DATE_RANGE),
|
|
2258
|
-
defaultValue: SelectDateRangeValue.
|
|
2238
|
+
defaultValue: SelectDateRangeValue.optional(),
|
|
2259
2239
|
options: import_zod17.z.array(SelectDateRangeOption).describe("A list of options")
|
|
2260
2240
|
}).describe("Select input with date range options");
|
|
2261
2241
|
var NameConfig = import_zod17.z.object({
|
|
@@ -2269,7 +2249,7 @@ var NameField = BaseField.extend({
|
|
|
2269
2249
|
firstname: SerializedUserField.or(NonEmptyTextValue).optional(),
|
|
2270
2250
|
middlename: SerializedUserField.or(NonEmptyTextValue).optional(),
|
|
2271
2251
|
surname: SerializedUserField.or(NonEmptyTextValue).optional()
|
|
2272
|
-
}).
|
|
2252
|
+
}).optional(),
|
|
2273
2253
|
configuration: import_zod17.z.object({
|
|
2274
2254
|
name: NameConfig.default({
|
|
2275
2255
|
firstname: { required: true },
|
|
@@ -2290,20 +2270,20 @@ var NameField = BaseField.extend({
|
|
|
2290
2270
|
}).optional()
|
|
2291
2271
|
}).describe("Name input field");
|
|
2292
2272
|
var PhoneField = BaseField.extend({
|
|
2293
|
-
defaultValue: NonEmptyTextValue.
|
|
2273
|
+
defaultValue: NonEmptyTextValue.optional(),
|
|
2294
2274
|
type: import_zod17.z.literal(FieldType.PHONE)
|
|
2295
2275
|
}).describe("Phone input field");
|
|
2296
2276
|
var IdField = BaseField.extend({
|
|
2297
|
-
defaultValue: NonEmptyTextValue.
|
|
2277
|
+
defaultValue: NonEmptyTextValue.optional(),
|
|
2298
2278
|
type: import_zod17.z.literal(FieldType.ID)
|
|
2299
2279
|
}).describe("ID input field");
|
|
2300
2280
|
var Checkbox = BaseField.extend({
|
|
2301
2281
|
type: import_zod17.z.literal(FieldType.CHECKBOX),
|
|
2302
|
-
defaultValue: CheckboxFieldValue.
|
|
2282
|
+
defaultValue: CheckboxFieldValue.default(false)
|
|
2303
2283
|
}).describe("Boolean checkbox field");
|
|
2304
2284
|
var Country = BaseField.extend({
|
|
2305
2285
|
type: import_zod17.z.literal(FieldType.COUNTRY),
|
|
2306
|
-
defaultValue: NonEmptyTextValue.
|
|
2286
|
+
defaultValue: NonEmptyTextValue.optional(),
|
|
2307
2287
|
optionOverrides: import_zod17.z.array(SelectOption.omit({ label: true })).optional().describe(
|
|
2308
2288
|
"Conditionals for specific countries. Countries not listed are always shown and enabled."
|
|
2309
2289
|
)
|
|
@@ -2319,12 +2299,12 @@ var AdministrativeAreaConfiguration = import_zod17.z.object({
|
|
|
2319
2299
|
}).describe("Administrative area options");
|
|
2320
2300
|
var AdministrativeArea = BaseField.extend({
|
|
2321
2301
|
type: import_zod17.z.literal(FieldType.ADMINISTRATIVE_AREA),
|
|
2322
|
-
defaultValue: import_zod17.z.union([NonEmptyTextValue, SerializedUserField
|
|
2302
|
+
defaultValue: import_zod17.z.union([NonEmptyTextValue, SerializedUserField]).optional(),
|
|
2323
2303
|
configuration: AdministrativeAreaConfiguration
|
|
2324
2304
|
}).describe("Administrative area input field e.g. facility, office");
|
|
2325
2305
|
var LocationInput = BaseField.extend({
|
|
2326
2306
|
type: import_zod17.z.literal(FieldType.LOCATION),
|
|
2327
|
-
defaultValue: NonEmptyTextValue.
|
|
2307
|
+
defaultValue: NonEmptyTextValue.optional(),
|
|
2328
2308
|
configuration: import_zod17.z.object({
|
|
2329
2309
|
searchableResource: import_zod17.z.array(import_zod17.z.enum(["locations", "facilities", "offices"]))
|
|
2330
2310
|
})
|
|
@@ -2332,7 +2312,7 @@ var LocationInput = BaseField.extend({
|
|
|
2332
2312
|
var FileUploadWithOptions = BaseField.extend({
|
|
2333
2313
|
type: import_zod17.z.literal(FieldType.FILE_WITH_OPTIONS),
|
|
2334
2314
|
options: import_zod17.z.array(SelectOption).describe("A list of options"),
|
|
2335
|
-
defaultValue: FileFieldWithOptionValue.
|
|
2315
|
+
defaultValue: FileFieldWithOptionValue.optional(),
|
|
2336
2316
|
configuration: import_zod17.z.object({
|
|
2337
2317
|
maxFileSize: import_zod17.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
|
|
2338
2318
|
maxImageSize: import_zod17.z.object({
|
|
@@ -2345,11 +2325,11 @@ var FileUploadWithOptions = BaseField.extend({
|
|
|
2345
2325
|
});
|
|
2346
2326
|
var Facility = BaseField.extend({
|
|
2347
2327
|
type: import_zod17.z.literal(FieldType.FACILITY),
|
|
2348
|
-
defaultValue: NonEmptyTextValue.
|
|
2328
|
+
defaultValue: NonEmptyTextValue.optional()
|
|
2349
2329
|
}).describe("Input field for a facility");
|
|
2350
2330
|
var Office = BaseField.extend({
|
|
2351
2331
|
type: import_zod17.z.literal(FieldType.OFFICE),
|
|
2352
|
-
defaultValue: NonEmptyTextValue.
|
|
2332
|
+
defaultValue: NonEmptyTextValue.optional()
|
|
2353
2333
|
}).describe("Input field for an office");
|
|
2354
2334
|
var DefaultAddressFieldValue = DomesticAddressFieldValue.extend({
|
|
2355
2335
|
administrativeArea: import_zod17.z.union([UUID, SerializedUserField]).optional()
|
|
@@ -2383,7 +2363,7 @@ var Address = BaseField.extend({
|
|
|
2383
2363
|
})
|
|
2384
2364
|
).optional()
|
|
2385
2365
|
}).optional(),
|
|
2386
|
-
defaultValue: DefaultAddressFieldValue.
|
|
2366
|
+
defaultValue: DefaultAddressFieldValue.optional()
|
|
2387
2367
|
}).describe("Address input field \u2013 a combination of location and text fields");
|
|
2388
2368
|
var StaticDataEntry = import_zod17.z.object({
|
|
2389
2369
|
id: import_zod17.z.string().describe("ID for the data entry."),
|
|
@@ -2402,7 +2382,7 @@ var DataField = BaseField.extend({
|
|
|
2402
2382
|
}).describe("Data field for displaying read-only data");
|
|
2403
2383
|
var ButtonField = BaseField.extend({
|
|
2404
2384
|
type: import_zod17.z.literal(FieldType.BUTTON),
|
|
2405
|
-
defaultValue: ButtonFieldValue.
|
|
2385
|
+
defaultValue: ButtonFieldValue.optional(),
|
|
2406
2386
|
configuration: import_zod17.z.object({
|
|
2407
2387
|
icon: import_zod17.z.string().optional().describe(
|
|
2408
2388
|
"Icon for the button. You can find icons from OpenCRVS UI-Kit."
|
|
@@ -2427,7 +2407,7 @@ var AlphaPrintButton = BaseField.extend({
|
|
|
2427
2407
|
}).describe("Print button field for printing certificates");
|
|
2428
2408
|
var HttpField = BaseField.extend({
|
|
2429
2409
|
type: import_zod17.z.literal(FieldType.HTTP),
|
|
2430
|
-
defaultValue: HttpFieldValue.
|
|
2410
|
+
defaultValue: HttpFieldValue.optional(),
|
|
2431
2411
|
configuration: import_zod17.z.object({
|
|
2432
2412
|
trigger: FieldReference,
|
|
2433
2413
|
url: import_zod17.z.string().describe("URL to send the HTTP request to"),
|
|
@@ -2482,7 +2462,7 @@ var LinkButtonField = BaseField.extend({
|
|
|
2482
2462
|
}).describe("Button that opens a link");
|
|
2483
2463
|
var VerificationStatus = BaseField.extend({
|
|
2484
2464
|
type: import_zod17.z.literal(FieldType.VERIFICATION_STATUS),
|
|
2485
|
-
defaultValue: VerificationStatusValue.
|
|
2465
|
+
defaultValue: VerificationStatusValue.optional(),
|
|
2486
2466
|
configuration: import_zod17.z.object({
|
|
2487
2467
|
status: TranslationConfig.describe("Text to display on the status pill."),
|
|
2488
2468
|
description: TranslationConfig.describe(
|
|
@@ -2500,7 +2480,7 @@ var QueryParamReaderField = BaseField.extend({
|
|
|
2500
2480
|
);
|
|
2501
2481
|
var QrReaderField = BaseField.extend({
|
|
2502
2482
|
type: import_zod17.z.literal(FieldType.QR_READER),
|
|
2503
|
-
defaultValue: QrReaderFieldValue.
|
|
2483
|
+
defaultValue: QrReaderFieldValue.optional(),
|
|
2504
2484
|
configuration: import_zod17.z.object({
|
|
2505
2485
|
validator: import_zod17.z.custom(
|
|
2506
2486
|
(val) => typeof val === "object" && val !== null
|
|
@@ -2509,7 +2489,7 @@ var QrReaderField = BaseField.extend({
|
|
|
2509
2489
|
});
|
|
2510
2490
|
var IdReaderField = BaseField.extend({
|
|
2511
2491
|
type: import_zod17.z.literal(FieldType.ID_READER),
|
|
2512
|
-
defaultValue: IdReaderFieldValue.
|
|
2492
|
+
defaultValue: IdReaderFieldValue.optional(),
|
|
2513
2493
|
methods: import_zod17.z.array(
|
|
2514
2494
|
import_zod17.z.union([QrReaderField, LinkButtonField]).describe("Methods for reading an ID")
|
|
2515
2495
|
)
|
|
@@ -3385,18 +3365,6 @@ function resolveDataPath(rootData, dataPath, instancePath) {
|
|
|
3385
3365
|
}
|
|
3386
3366
|
return current;
|
|
3387
3367
|
}
|
|
3388
|
-
function todayISO() {
|
|
3389
|
-
return (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" });
|
|
3390
|
-
}
|
|
3391
|
-
var compiledFunctionCache = /* @__PURE__ */ new Map();
|
|
3392
|
-
function compileClientFunction(code) {
|
|
3393
|
-
let fn = compiledFunctionCache.get(code);
|
|
3394
|
-
if (!fn) {
|
|
3395
|
-
fn = new Function(`return (${code})`)();
|
|
3396
|
-
compiledFunctionCache.set(code, fn);
|
|
3397
|
-
}
|
|
3398
|
-
return fn;
|
|
3399
|
-
}
|
|
3400
3368
|
(0, import_ajv_formats.default)(ajv);
|
|
3401
3369
|
ajv.addKeyword({
|
|
3402
3370
|
keyword: "daysFromDate",
|
|
@@ -3442,7 +3410,7 @@ ajv.addKeyword({
|
|
|
3442
3410
|
$data: true,
|
|
3443
3411
|
errors: true,
|
|
3444
3412
|
// @ts-ignore -- Force type. We will move this away from AJV next. Parsing the array will take seconds and is only called by core.
|
|
3445
|
-
validate(
|
|
3413
|
+
validate(schema, data, _2, dataContext) {
|
|
3446
3414
|
const locationIdInput = data;
|
|
3447
3415
|
const locations = dataContext?.rootData.$leafAdminStructureLocationIds ?? [];
|
|
3448
3416
|
return locations.some((location) => location.id === locationIdInput);
|
|
@@ -3451,15 +3419,6 @@ ajv.addKeyword({
|
|
|
3451
3419
|
function mergeWithBaseFormState(values, context) {
|
|
3452
3420
|
return { ...context.baseFormState, ...values };
|
|
3453
3421
|
}
|
|
3454
|
-
ajv.addKeyword({
|
|
3455
|
-
keyword: "customClientValidator",
|
|
3456
|
-
schemaType: "object",
|
|
3457
|
-
errors: true,
|
|
3458
|
-
// @ts-ignore -- DataContext is not typed in AJV's public API
|
|
3459
|
-
validate(schema, data, _2, dataContext) {
|
|
3460
|
-
return compileClientFunction(schema.code)(data, dataContext?.rootData);
|
|
3461
|
-
}
|
|
3462
|
-
});
|
|
3463
3422
|
function validate(schema, data) {
|
|
3464
3423
|
const validator = ajv.getSchema(schema.$id) || ajv.compile(schema);
|
|
3465
3424
|
if ("$form" in data) {
|
|
@@ -3503,7 +3462,7 @@ function isOnline() {
|
|
|
3503
3462
|
function isConditionMet(conditional, values, context) {
|
|
3504
3463
|
return validate(conditional, {
|
|
3505
3464
|
$form: mergeWithBaseFormState(values, context),
|
|
3506
|
-
$now:
|
|
3465
|
+
$now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" }),
|
|
3507
3466
|
$online: isOnline(),
|
|
3508
3467
|
$user: context.user,
|
|
3509
3468
|
$leafAdminStructureLocationIds: context.leafAdminStructureLocationIds ?? [],
|
|
@@ -3530,7 +3489,7 @@ function isFieldConditionMet(field3, form, conditionalType, context) {
|
|
|
3530
3489
|
}
|
|
3531
3490
|
const validConditionals = getConditionalActionsForField(field3, {
|
|
3532
3491
|
$form: mergeWithBaseFormState(form, context),
|
|
3533
|
-
$now:
|
|
3492
|
+
$now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" }),
|
|
3534
3493
|
$online: isOnline(),
|
|
3535
3494
|
$user: context.user,
|
|
3536
3495
|
$leafAdminStructureLocationIds: context.leafAdminStructureLocationIds ?? [],
|
|
@@ -3683,7 +3642,7 @@ function runFieldValidations({
|
|
|
3683
3642
|
}
|
|
3684
3643
|
const conditionalParameters = {
|
|
3685
3644
|
$form: mergeWithBaseFormState(form, context),
|
|
3686
|
-
$now:
|
|
3645
|
+
$now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" }),
|
|
3687
3646
|
/**
|
|
3688
3647
|
* In real use cases, there can be hundreds of thousands of locations.
|
|
3689
3648
|
* Make sure that the context contains only the locations that are needed for validation.
|
|
@@ -4138,20 +4097,16 @@ function getPendingAction(actions) {
|
|
|
4138
4097
|
}
|
|
4139
4098
|
return pendingActions[0];
|
|
4140
4099
|
}
|
|
4141
|
-
function getCompleteActionAnnotation(
|
|
4100
|
+
function getCompleteActionAnnotation(event2, action) {
|
|
4142
4101
|
if (action.originalActionId) {
|
|
4143
4102
|
const originalAction = event2.actions.find(
|
|
4144
4103
|
({ id }) => id === action.originalActionId
|
|
4145
4104
|
);
|
|
4146
|
-
if (originalAction?.status
|
|
4147
|
-
return annotation;
|
|
4105
|
+
if (originalAction?.status === ActionStatus.Requested) {
|
|
4106
|
+
return deepMerge(originalAction.annotation ?? {}, action.annotation ?? {});
|
|
4148
4107
|
}
|
|
4149
|
-
return deepMerge(
|
|
4150
|
-
deepMerge(annotation, originalAction.annotation ?? {}),
|
|
4151
|
-
action.annotation ?? {}
|
|
4152
|
-
);
|
|
4153
4108
|
}
|
|
4154
|
-
return
|
|
4109
|
+
return action.annotation ?? {};
|
|
4155
4110
|
}
|
|
4156
4111
|
function getCompleteActionDeclaration(declaration, event2, action) {
|
|
4157
4112
|
if (action.originalActionId) {
|
|
@@ -4171,7 +4126,7 @@ function getAcceptedActions(event2) {
|
|
|
4171
4126
|
return event2.actions.filter(isAcceptedAction).map((action) => ({
|
|
4172
4127
|
...action,
|
|
4173
4128
|
declaration: getCompleteActionDeclaration({}, event2, action),
|
|
4174
|
-
annotation: getCompleteActionAnnotation(
|
|
4129
|
+
annotation: getCompleteActionAnnotation(event2, action)
|
|
4175
4130
|
}));
|
|
4176
4131
|
}
|
|
4177
4132
|
var EXCLUDED_ACTIONS = [
|
|
@@ -4766,54 +4721,7 @@ function createFieldConditionals(fieldId) {
|
|
|
4766
4721
|
}
|
|
4767
4722
|
},
|
|
4768
4723
|
required: [fieldId]
|
|
4769
|
-
})
|
|
4770
|
-
/**
|
|
4771
|
-
* Custom client-side validator. The provided function is serialised and executed
|
|
4772
|
-
* just-in-time on the client only. External references (e.g. lodash) are not
|
|
4773
|
-
* available inside the function body — all logic must be self-contained.
|
|
4774
|
-
*
|
|
4775
|
-
* @example
|
|
4776
|
-
* field('nid').customClientValidator((value) => {
|
|
4777
|
-
* // LUHN check — all logic must be inline
|
|
4778
|
-
* const digits = String(value).split('').map(Number)
|
|
4779
|
-
* // ...
|
|
4780
|
-
* return isValid
|
|
4781
|
-
* })
|
|
4782
|
-
*/
|
|
4783
|
-
customClientValidator(validationFn) {
|
|
4784
|
-
const code = validationFn.toString();
|
|
4785
|
-
return defineFormConditional({
|
|
4786
|
-
type: "object",
|
|
4787
|
-
properties: wrapToPath(
|
|
4788
|
-
{ [fieldId]: { customClientValidator: { code } } },
|
|
4789
|
-
this.$$subfield
|
|
4790
|
-
),
|
|
4791
|
-
required: [fieldId]
|
|
4792
|
-
});
|
|
4793
|
-
},
|
|
4794
|
-
/**
|
|
4795
|
-
* Custom client-side evaluation. Returns a {@link FieldReference} descriptor
|
|
4796
|
-
* that can be used as the `value` property or a DATA component entry.
|
|
4797
|
-
* The function receives the referenced field's value as the first argument and
|
|
4798
|
-
* the full form context as the second; its return value replaces the field reference.
|
|
4799
|
-
* The function is serialised and executed just-in-time on the client only.
|
|
4800
|
-
* External references (e.g. lodash) are not available inside the function body.
|
|
4801
|
-
*
|
|
4802
|
-
* For computing a default value without referencing a specific field, use
|
|
4803
|
-
* `evaluate(fn)` in the `defaultValue` property instead.
|
|
4804
|
-
*
|
|
4805
|
-
* @example
|
|
4806
|
-
* field('a').customClientEvaluation((aValue, ctx) =>
|
|
4807
|
-
* Number(aValue) + Number(ctx.$form.b)
|
|
4808
|
-
* )
|
|
4809
|
-
*/
|
|
4810
|
-
customClientEvaluation(computationFn) {
|
|
4811
|
-
return {
|
|
4812
|
-
$$code: computationFn.toString(),
|
|
4813
|
-
$$field: fieldId,
|
|
4814
|
-
$$subfield: this.$$subfield
|
|
4815
|
-
};
|
|
4816
|
-
}
|
|
4724
|
+
})
|
|
4817
4725
|
};
|
|
4818
4726
|
}
|
|
4819
4727
|
|
|
@@ -5966,7 +5874,7 @@ function getActionAnnotation({
|
|
|
5966
5874
|
const action = (0, import_lodash3.findLast)(activeActions, (a) => a.type === actionType);
|
|
5967
5875
|
const actionWithCompleteAnnotation = action && {
|
|
5968
5876
|
...action,
|
|
5969
|
-
annotation: getCompleteActionAnnotation(
|
|
5877
|
+
annotation: getCompleteActionAnnotation(event2, action)
|
|
5970
5878
|
};
|
|
5971
5879
|
const matchingDraft = draft?.action.type === actionType ? draft : void 0;
|
|
5972
5880
|
const sortedActions = (0, import_lodash3.orderBy)(
|
|
@@ -6008,9 +5916,6 @@ function createFieldConfig(fieldId, options) {
|
|
|
6008
5916
|
}
|
|
6009
5917
|
|
|
6010
5918
|
// ../commons/src/events/field.ts
|
|
6011
|
-
function evaluate(computationFn) {
|
|
6012
|
-
return { $$code: computationFn.toString() };
|
|
6013
|
-
}
|
|
6014
5919
|
function field(fieldId, options = {}) {
|
|
6015
5920
|
return {
|
|
6016
5921
|
...createFieldConditionals(fieldId),
|