@opencrvs/toolkit 1.9.13-rc.1689dc0 → 1.9.13-rc.1d7f578

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.
@@ -69,6 +69,7 @@ __export(events_exports, {
69
69
  CheckboxFieldValue: () => CheckboxFieldValue,
70
70
  Clause: () => Clause,
71
71
  ClientSpecificAction: () => ClientSpecificAction,
72
+ CodeToEvaluate: () => CodeToEvaluate,
72
73
  Conditional: () => Conditional,
73
74
  ConditionalType: () => ConditionalType,
74
75
  ConfirmableActions: () => ConfirmableActions,
@@ -229,6 +230,7 @@ __export(events_exports, {
229
230
  areConditionsMet: () => areConditionsMet,
230
231
  buildFormState: () => buildFormState,
231
232
  canUserReadEvent: () => canUserReadEvent,
233
+ compileClientFunction: () => compileClientFunction,
232
234
  compositeFieldTypes: () => compositeFieldTypes,
233
235
  configurableEventScopeAllowed: () => configurableEventScopeAllowed,
234
236
  createEmptyDraft: () => createEmptyDraft,
@@ -313,6 +315,7 @@ __export(events_exports, {
313
315
  isBulletListFieldType: () => isBulletListFieldType,
314
316
  isButtonFieldType: () => isButtonFieldType,
315
317
  isCheckboxFieldType: () => isCheckboxFieldType,
318
+ isCodeToEvaluate: () => isCodeToEvaluate,
316
319
  isConditionMet: () => isConditionMet,
317
320
  isCountryFieldType: () => isCountryFieldType,
318
321
  isDataFieldType: () => isDataFieldType,
@@ -353,6 +356,7 @@ __export(events_exports, {
353
356
  isQrReaderFieldType: () => isQrReaderFieldType,
354
357
  isQueryParamReaderFieldType: () => isQueryParamReaderFieldType,
355
358
  isRadioGroupFieldType: () => isRadioGroupFieldType,
359
+ isResolvableValueReference: () => isResolvableValueReference,
356
360
  isSearchFieldType: () => isSearchFieldType,
357
361
  isSelectDateRangeFieldType: () => isSelectDateRangeFieldType,
358
362
  isSelectFieldType: () => isSelectFieldType,
@@ -383,6 +387,7 @@ __export(events_exports, {
383
387
  runStructuralValidations: () => runStructuralValidations,
384
388
  safeUnion: () => safeUnion,
385
389
  timePeriodToDateRange: () => timePeriodToDateRange,
390
+ todayISO: () => todayISO,
386
391
  user: () => user,
387
392
  validate: () => validate,
388
393
  validateFieldInput: () => validateFieldInput,
@@ -1987,6 +1992,18 @@ var FieldReference = import_zod17.z.object({
1987
1992
  'If the FieldValue is an object, subfield can be used to refer to e.g. `["foo", "bar"]` in `{ foo: { bar: 3 } }`'
1988
1993
  )
1989
1994
  }).describe("Reference to a field by its ID");
1995
+ var CodeToEvaluate = import_zod17.z.object({
1996
+ $$code: import_zod17.z.string().describe("Serialised client-side function body"),
1997
+ $$field: FieldId.describe(
1998
+ "Field whose value is passed as the first argument"
1999
+ ),
2000
+ $$subfield: import_zod17.z.array(import_zod17.z.string()).optional().default([]).describe("Optional nested path within the field value")
2001
+ }).describe(
2002
+ "Serialised client-side evaluation function. Executed just-in-time on the client only."
2003
+ );
2004
+ function isCodeToEvaluate(v) {
2005
+ return !!v && typeof v === "object" && "$$code" in v;
2006
+ }
1990
2007
  var ValidationConfig = import_zod17.z.object({
1991
2008
  validator: Conditional,
1992
2009
  message: TranslationConfig
@@ -2019,8 +2036,11 @@ var BaseField = import_zod17.z.object({
2019
2036
  uncorrectable: import_zod17.z.boolean().default(false).optional().describe(
2020
2037
  "Indicates whether the field can be modified during record correction."
2021
2038
  ),
2022
- value: FieldReference.or(import_zod17.z.array(FieldReference)).optional().describe(
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."
2039
+ value: FieldReference.or(CodeToEvaluate).or(import_zod17.z.array(FieldReference.or(CodeToEvaluate))).optional().describe(
2040
+ "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. A CodeToEvaluate can be used to compute the value via a custom client-side function."
2041
+ ),
2042
+ evaluatedDefaultValue: CodeToEvaluate.optional().describe(
2043
+ "Custom client-side function used to compute the default value. Executed just-in-time on the client. Takes precedence over defaultValue when set."
2024
2044
  ),
2025
2045
  analytics: import_zod17.z.boolean().default(false).optional().describe(
2026
2046
  "Indicates whether the field is included in analytics. When enabled, its value becomes available in the analytics dashboard."
@@ -2154,12 +2174,10 @@ var ParagraphConfiguration = import_zod17.z.object({
2154
2174
  }).default({});
2155
2175
  var Paragraph = BaseField.extend({
2156
2176
  type: import_zod17.z.literal(FieldType.PARAGRAPH),
2157
- defaultValue: NonEmptyTextValue.optional(),
2158
2177
  configuration: ParagraphConfiguration
2159
2178
  }).describe("A read-only HTML <p> paragraph");
2160
2179
  var PageHeader = BaseField.extend({
2161
- type: import_zod17.z.literal(FieldType.PAGE_HEADER),
2162
- defaultValue: NonEmptyTextValue.optional()
2180
+ type: import_zod17.z.literal(FieldType.PAGE_HEADER)
2163
2181
  }).describe("A read-only header component for form pages");
2164
2182
  var File = BaseField.extend({
2165
2183
  type: import_zod17.z.literal(FieldType.FILE),
@@ -2209,7 +2227,6 @@ var RadioGroup = BaseField.extend({
2209
2227
  }).describe("Grouped radio options");
2210
2228
  var BulletList = BaseField.extend({
2211
2229
  type: import_zod17.z.literal(FieldType.BULLET_LIST),
2212
- defaultValue: TextValue.optional(),
2213
2230
  items: import_zod17.z.array(TranslationConfig).describe("A list of items"),
2214
2231
  configuration: import_zod17.z.object({
2215
2232
  styles: import_zod17.z.object({
@@ -2371,7 +2388,7 @@ var Address = BaseField.extend({
2371
2388
  var StaticDataEntry = import_zod17.z.object({
2372
2389
  id: import_zod17.z.string().describe("ID for the data entry."),
2373
2390
  label: TranslationConfig,
2374
- value: TranslationConfig.or(import_zod17.z.string()).or(FieldReference)
2391
+ value: TranslationConfig.or(import_zod17.z.string()).or(FieldReference).or(CodeToEvaluate)
2375
2392
  }).describe("Static data entry");
2376
2393
  var DataEntry = import_zod17.z.union([StaticDataEntry, import_zod17.z.object({ fieldId: import_zod17.z.string() })]).describe(
2377
2394
  "Data entry can be either a static data entry, or a reference to another field in the current form or the declaration."
@@ -2418,7 +2435,7 @@ var HttpField = BaseField.extend({
2418
2435
  headers: import_zod17.z.record(import_zod17.z.string()).optional(),
2419
2436
  body: import_zod17.z.record(import_zod17.z.any()).optional(),
2420
2437
  errorValue: import_zod17.z.any().optional().describe("Value to set if the request fails"),
2421
- params: import_zod17.z.record(import_zod17.z.string(), import_zod17.z.union([import_zod17.z.string(), FieldReference])).optional(),
2438
+ params: import_zod17.z.record(import_zod17.z.string(), import_zod17.z.union([import_zod17.z.string(), FieldReference, CodeToEvaluate])).optional(),
2422
2439
  timeout: import_zod17.z.number().default(15e3).describe("Request timeout in milliseconds")
2423
2440
  })
2424
2441
  }).describe("HTTP request function triggered by a button click or other event");
@@ -3368,6 +3385,18 @@ function resolveDataPath(rootData, dataPath, instancePath) {
3368
3385
  }
3369
3386
  return current;
3370
3387
  }
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
+ }
3371
3400
  (0, import_ajv_formats.default)(ajv);
3372
3401
  ajv.addKeyword({
3373
3402
  keyword: "daysFromDate",
@@ -3413,12 +3442,24 @@ ajv.addKeyword({
3413
3442
  $data: true,
3414
3443
  errors: true,
3415
3444
  // @ts-ignore -- Force type. We will move this away from AJV next. Parsing the array will take seconds and is only called by core.
3416
- validate(schema, data, _2, dataContext) {
3445
+ validate(_schema, data, _2, dataContext) {
3417
3446
  const locationIdInput = data;
3418
3447
  const locations = dataContext?.rootData.$leafAdminStructureLocationIds ?? [];
3419
3448
  return locations.some((location) => location.id === locationIdInput);
3420
3449
  }
3421
3450
  });
3451
+ function mergeWithBaseFormState(values, context) {
3452
+ return { ...context.baseFormState, ...values };
3453
+ }
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
+ });
3422
3463
  function validate(schema, data) {
3423
3464
  const validator = ajv.getSchema(schema.$id) || ajv.compile(schema);
3424
3465
  if ("$form" in data) {
@@ -3461,7 +3502,7 @@ function isOnline() {
3461
3502
  }
3462
3503
  function isConditionMet(conditional, values, context) {
3463
3504
  return validate(conditional, {
3464
- $form: values,
3505
+ $form: mergeWithBaseFormState(values, context),
3465
3506
  $now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" }),
3466
3507
  $online: isOnline(),
3467
3508
  $user: context.user,
@@ -3488,7 +3529,7 @@ function isFieldConditionMet(field3, form, conditionalType, context) {
3488
3529
  return true;
3489
3530
  }
3490
3531
  const validConditionals = getConditionalActionsForField(field3, {
3491
- $form: form,
3532
+ $form: mergeWithBaseFormState(form, context),
3492
3533
  $now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" }),
3493
3534
  $online: isOnline(),
3494
3535
  $user: context.user,
@@ -3641,7 +3682,7 @@ function runFieldValidations({
3641
3682
  return [];
3642
3683
  }
3643
3684
  const conditionalParameters = {
3644
- $form: form,
3685
+ $form: mergeWithBaseFormState(form, context),
3645
3686
  $now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" }),
3646
3687
  /**
3647
3688
  * In real use cases, there can be hundreds of thousands of locations.
@@ -3873,7 +3914,7 @@ function omitHiddenPaginatedFields(formConfig, values, validatorContext, include
3873
3914
  const visibleFields = formConfig.pages.filter((p) => isPageVisible(p, values, validatorContext)).flatMap((p) => p.fields);
3874
3915
  const hiddenFields = formConfig.pages.filter((p) => !isPageVisible(p, values, validatorContext)).flatMap((p) => p.fields);
3875
3916
  const valuesExceptHiddenPage = (0, import_lodash.omitBy)(values, (_2, fieldId) => {
3876
- return hiddenFields.some((f) => f.id === fieldId);
3917
+ return hiddenFields.some((f) => f.id === fieldId) && !visibleFields.some((f) => f.id === fieldId);
3877
3918
  });
3878
3919
  return omitHiddenFields(
3879
3920
  visibleFields,
@@ -3920,11 +3961,10 @@ function getVisibleVerificationPageIds(pages, annotation, context) {
3920
3961
  }
3921
3962
  function omitHiddenAnnotationFields(actionConfig, declaration, annotation, context) {
3922
3963
  const annotationFields = getActionAnnotationFields(actionConfig);
3923
- return omitHiddenFields(
3924
- annotationFields,
3925
- { ...declaration, ...annotation },
3926
- context
3927
- );
3964
+ return omitHiddenFields(annotationFields, annotation, {
3965
+ ...context,
3966
+ baseFormState: declaration
3967
+ });
3928
3968
  }
3929
3969
  function deepMerge(currentDocument, actionDocument) {
3930
3970
  const currentDocumentClone = (0, import_lodash.cloneDeep)(currentDocument);
@@ -4292,6 +4332,9 @@ function isFieldReference(value) {
4292
4332
  function isEventFieldReference(value) {
4293
4333
  return typeof value === "object" && value !== null && "$$event" in value;
4294
4334
  }
4335
+ function isResolvableValueReference(value) {
4336
+ return isFieldReference(value) || isCodeToEvaluate(value);
4337
+ }
4295
4338
  function getDateRangeToFieldReference(field3, comparedField, clause) {
4296
4339
  return {
4297
4340
  type: "object",
@@ -4726,7 +4769,49 @@ function createFieldConditionals(fieldId) {
4726
4769
  }
4727
4770
  },
4728
4771
  required: [fieldId]
4729
- })
4772
+ }),
4773
+ /**
4774
+ * Custom client-side validator. The provided function is serialised and executed
4775
+ * just-in-time on the client only. External references (e.g. lodash) are not
4776
+ * available inside the function body — all logic must be self-contained.
4777
+ *
4778
+ * @example
4779
+ * field('nid').customClientValidator((value) => {
4780
+ * // LUHN check — all logic must be inline
4781
+ * const digits = String(value).split('').map(Number)
4782
+ * // ...
4783
+ * return isValid
4784
+ * })
4785
+ */
4786
+ customClientValidator(validationFn) {
4787
+ const code = validationFn.toString();
4788
+ return defineFormConditional({
4789
+ type: "object",
4790
+ properties: wrapToPath(
4791
+ { [fieldId]: { customClientValidator: { code } } },
4792
+ this.$$subfield
4793
+ ),
4794
+ required: [fieldId]
4795
+ });
4796
+ },
4797
+ /**
4798
+ * Custom client-side evaluation. Returns a {@link CodeToEvaluate} descriptor
4799
+ * that can be used as `value`, `evaluatedDefaultValue`, or a DATA component entry.
4800
+ * The function is serialised and executed just-in-time on the client only.
4801
+ * External references (e.g. lodash) are not available inside the function body.
4802
+ *
4803
+ * @example
4804
+ * field('a').customClientEvaluation((aValue, ctx) =>
4805
+ * Number(aValue) + Number(ctx.$form.b)
4806
+ * )
4807
+ */
4808
+ customClientEvaluation(computationFn) {
4809
+ return {
4810
+ $$code: computationFn.toString(),
4811
+ $$field: fieldId,
4812
+ $$subfield: this.$$subfield
4813
+ };
4814
+ }
4730
4815
  };
4731
4816
  }
4732
4817
 
@@ -5307,6 +5392,8 @@ var BaseActionInput = import_zod34.z.object({
5307
5392
  originalActionId: UUID.optional(),
5308
5393
  // should not be part of base action.
5309
5394
  keepAssignment: import_zod34.z.boolean().optional(),
5395
+ keepAssignmentIfAccepted: import_zod34.z.boolean().optional(),
5396
+ keepAssignmentIfRejected: import_zod34.z.boolean().optional(),
5310
5397
  // For normal users, the createdAtLocation is resolved on the backend from the user's primaryOfficeId.
5311
5398
  createdAtLocation: CreatedAtLocation.describe(
5312
5399
  "A valid office location ID. This is required for system users performing actions. The provided location must be a leaf-location, i.e. it must not have any children locations."
@@ -1493,6 +1493,15 @@ var FieldReference = import_zod17.z.object({
1493
1493
  'If the FieldValue is an object, subfield can be used to refer to e.g. `["foo", "bar"]` in `{ foo: { bar: 3 } }`'
1494
1494
  )
1495
1495
  }).describe("Reference to a field by its ID");
1496
+ var CodeToEvaluate = import_zod17.z.object({
1497
+ $$code: import_zod17.z.string().describe("Serialised client-side function body"),
1498
+ $$field: FieldId.describe(
1499
+ "Field whose value is passed as the first argument"
1500
+ ),
1501
+ $$subfield: import_zod17.z.array(import_zod17.z.string()).optional().default([]).describe("Optional nested path within the field value")
1502
+ }).describe(
1503
+ "Serialised client-side evaluation function. Executed just-in-time on the client only."
1504
+ );
1496
1505
  var ValidationConfig = import_zod17.z.object({
1497
1506
  validator: Conditional,
1498
1507
  message: TranslationConfig
@@ -1525,8 +1534,11 @@ var BaseField = import_zod17.z.object({
1525
1534
  uncorrectable: import_zod17.z.boolean().default(false).optional().describe(
1526
1535
  "Indicates whether the field can be modified during record correction."
1527
1536
  ),
1528
- value: FieldReference.or(import_zod17.z.array(FieldReference)).optional().describe(
1529
- "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."
1537
+ value: FieldReference.or(CodeToEvaluate).or(import_zod17.z.array(FieldReference.or(CodeToEvaluate))).optional().describe(
1538
+ "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. A CodeToEvaluate can be used to compute the value via a custom client-side function."
1539
+ ),
1540
+ evaluatedDefaultValue: CodeToEvaluate.optional().describe(
1541
+ "Custom client-side function used to compute the default value. Executed just-in-time on the client. Takes precedence over defaultValue when set."
1530
1542
  ),
1531
1543
  analytics: import_zod17.z.boolean().default(false).optional().describe(
1532
1544
  "Indicates whether the field is included in analytics. When enabled, its value becomes available in the analytics dashboard."
@@ -1660,12 +1672,10 @@ var ParagraphConfiguration = import_zod17.z.object({
1660
1672
  }).default({});
1661
1673
  var Paragraph = BaseField.extend({
1662
1674
  type: import_zod17.z.literal(FieldType.PARAGRAPH),
1663
- defaultValue: NonEmptyTextValue.optional(),
1664
1675
  configuration: ParagraphConfiguration
1665
1676
  }).describe("A read-only HTML <p> paragraph");
1666
1677
  var PageHeader = BaseField.extend({
1667
- type: import_zod17.z.literal(FieldType.PAGE_HEADER),
1668
- defaultValue: NonEmptyTextValue.optional()
1678
+ type: import_zod17.z.literal(FieldType.PAGE_HEADER)
1669
1679
  }).describe("A read-only header component for form pages");
1670
1680
  var File = BaseField.extend({
1671
1681
  type: import_zod17.z.literal(FieldType.FILE),
@@ -1715,7 +1725,6 @@ var RadioGroup = BaseField.extend({
1715
1725
  }).describe("Grouped radio options");
1716
1726
  var BulletList = BaseField.extend({
1717
1727
  type: import_zod17.z.literal(FieldType.BULLET_LIST),
1718
- defaultValue: TextValue.optional(),
1719
1728
  items: import_zod17.z.array(TranslationConfig).describe("A list of items"),
1720
1729
  configuration: import_zod17.z.object({
1721
1730
  styles: import_zod17.z.object({
@@ -1877,7 +1886,7 @@ var Address = BaseField.extend({
1877
1886
  var StaticDataEntry = import_zod17.z.object({
1878
1887
  id: import_zod17.z.string().describe("ID for the data entry."),
1879
1888
  label: TranslationConfig,
1880
- value: TranslationConfig.or(import_zod17.z.string()).or(FieldReference)
1889
+ value: TranslationConfig.or(import_zod17.z.string()).or(FieldReference).or(CodeToEvaluate)
1881
1890
  }).describe("Static data entry");
1882
1891
  var DataEntry = import_zod17.z.union([StaticDataEntry, import_zod17.z.object({ fieldId: import_zod17.z.string() })]).describe(
1883
1892
  "Data entry can be either a static data entry, or a reference to another field in the current form or the declaration."
@@ -1924,7 +1933,7 @@ var HttpField = BaseField.extend({
1924
1933
  headers: import_zod17.z.record(import_zod17.z.string()).optional(),
1925
1934
  body: import_zod17.z.record(import_zod17.z.any()).optional(),
1926
1935
  errorValue: import_zod17.z.any().optional().describe("Value to set if the request fails"),
1927
- params: import_zod17.z.record(import_zod17.z.string(), import_zod17.z.union([import_zod17.z.string(), FieldReference])).optional(),
1936
+ params: import_zod17.z.record(import_zod17.z.string(), import_zod17.z.union([import_zod17.z.string(), FieldReference, CodeToEvaluate])).optional(),
1928
1937
  timeout: import_zod17.z.number().default(15e3).describe("Request timeout in milliseconds")
1929
1938
  })
1930
1939
  }).describe("HTTP request function triggered by a button click or other event");
@@ -2559,6 +2568,15 @@ function resolveDataPath(rootData, dataPath, instancePath) {
2559
2568
  }
2560
2569
  return current;
2561
2570
  }
2571
+ var compiledFunctionCache = /* @__PURE__ */ new Map();
2572
+ function compileClientFunction(code) {
2573
+ let fn = compiledFunctionCache.get(code);
2574
+ if (!fn) {
2575
+ fn = new Function(`return (${code})`)();
2576
+ compiledFunctionCache.set(code, fn);
2577
+ }
2578
+ return fn;
2579
+ }
2562
2580
  (0, import_ajv_formats.default)(ajv);
2563
2581
  ajv.addKeyword({
2564
2582
  keyword: "daysFromDate",
@@ -2604,12 +2622,21 @@ ajv.addKeyword({
2604
2622
  $data: true,
2605
2623
  errors: true,
2606
2624
  // @ts-ignore -- Force type. We will move this away from AJV next. Parsing the array will take seconds and is only called by core.
2607
- validate(schema, data, _2, dataContext) {
2625
+ validate(_schema, data, _2, dataContext) {
2608
2626
  const locationIdInput = data;
2609
2627
  const locations = dataContext?.rootData.$leafAdminStructureLocationIds ?? [];
2610
2628
  return locations.some((location) => location.id === locationIdInput);
2611
2629
  }
2612
2630
  });
2631
+ ajv.addKeyword({
2632
+ keyword: "customClientValidator",
2633
+ schemaType: "object",
2634
+ errors: true,
2635
+ // @ts-ignore -- DataContext is not typed in AJV's public API
2636
+ validate(schema, data, _2, dataContext) {
2637
+ return compileClientFunction(schema.code)(data, dataContext?.rootData);
2638
+ }
2639
+ });
2613
2640
 
2614
2641
  // ../commons/src/utils.ts
2615
2642
  var z29 = __toESM(require("zod"));
@@ -3232,7 +3259,49 @@ function createFieldConditionals(fieldId) {
3232
3259
  }
3233
3260
  },
3234
3261
  required: [fieldId]
3235
- })
3262
+ }),
3263
+ /**
3264
+ * Custom client-side validator. The provided function is serialised and executed
3265
+ * just-in-time on the client only. External references (e.g. lodash) are not
3266
+ * available inside the function body — all logic must be self-contained.
3267
+ *
3268
+ * @example
3269
+ * field('nid').customClientValidator((value) => {
3270
+ * // LUHN check — all logic must be inline
3271
+ * const digits = String(value).split('').map(Number)
3272
+ * // ...
3273
+ * return isValid
3274
+ * })
3275
+ */
3276
+ customClientValidator(validationFn) {
3277
+ const code = validationFn.toString();
3278
+ return defineFormConditional({
3279
+ type: "object",
3280
+ properties: wrapToPath(
3281
+ { [fieldId]: { customClientValidator: { code } } },
3282
+ this.$$subfield
3283
+ ),
3284
+ required: [fieldId]
3285
+ });
3286
+ },
3287
+ /**
3288
+ * Custom client-side evaluation. Returns a {@link CodeToEvaluate} descriptor
3289
+ * that can be used as `value`, `evaluatedDefaultValue`, or a DATA component entry.
3290
+ * The function is serialised and executed just-in-time on the client only.
3291
+ * External references (e.g. lodash) are not available inside the function body.
3292
+ *
3293
+ * @example
3294
+ * field('a').customClientEvaluation((aValue, ctx) =>
3295
+ * Number(aValue) + Number(ctx.$form.b)
3296
+ * )
3297
+ */
3298
+ customClientEvaluation(computationFn) {
3299
+ return {
3300
+ $$code: computationFn.toString(),
3301
+ $$field: fieldId,
3302
+ $$subfield: this.$$subfield
3303
+ };
3304
+ }
3236
3305
  };
3237
3306
  }
3238
3307
 
@@ -3804,6 +3873,8 @@ var BaseActionInput = import_zod34.z.object({
3804
3873
  originalActionId: UUID.optional(),
3805
3874
  // should not be part of base action.
3806
3875
  keepAssignment: import_zod34.z.boolean().optional(),
3876
+ keepAssignmentIfAccepted: import_zod34.z.boolean().optional(),
3877
+ keepAssignmentIfRejected: import_zod34.z.boolean().optional(),
3807
3878
  // For normal users, the createdAtLocation is resolved on the backend from the user's primaryOfficeId.
3808
3879
  createdAtLocation: CreatedAtLocation.describe(
3809
3880
  "A valid office location ID. This is required for system users performing actions. The provided location must be a leaf-location, i.e. it must not have any children locations."
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencrvs/toolkit",
3
- "version": "1.9.13-rc.1689dc0",
3
+ "version": "1.9.13-rc.1d7f578",
4
4
  "description": "OpenCRVS toolkit for building country configurations",
5
5
  "license": "MPL-2.0",
6
6
  "exports": {
@@ -17,21 +17,21 @@
17
17
  "build:all": "lerna run build --include-dependencies --scope @opencrvs/toolkit && ./build.sh"
18
18
  },
19
19
  "dependencies": {
20
- "uuid": "^9.0.0",
20
+ "@trpc/client": "11.4.3",
21
+ "@trpc/server": "11.4.3",
21
22
  "ajv": "^8.17.1",
22
23
  "ajv-formats": "^3.0.1",
23
24
  "object-hash": "^3.0.0",
24
25
  "superjson": "1.9.0-0",
25
- "@trpc/client": "11.4.3",
26
- "@trpc/server": "11.4.3",
26
+ "uuid": "^9.0.0",
27
27
  "zod-openapi": "^4.2.4"
28
28
  },
29
29
  "devDependencies": {
30
+ "@opencrvs/events": "^1.9.0",
31
+ "@types/object-hash": "^3.0.6",
30
32
  "@types/uuid": "^9.0.3",
31
33
  "esbuild": "^0.24.0",
32
- "typescript": "^5.6.3",
33
- "@opencrvs/events": "^1.9.0",
34
- "@types/object-hash": "^3.0.6"
34
+ "typescript": "^5.6.3"
35
35
  },
36
36
  "moduleNameMapper": {
37
37
  "@opencrvs/commons/events": "@opencrvs/commons/build/dist/common/events/index.js",