@opencrvs/toolkit 2.0.0-rc.1237a55 → 2.0.0-rc.1239696

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 (109) hide show
  1. package/README.md +15 -0
  2. package/build.sh +5 -4
  3. package/create-countryconfig/index.js +50 -20
  4. package/dist/application-config/index.js +70 -40
  5. package/dist/cli.js +3186 -4915
  6. package/dist/commons/api/router.d.ts +102 -17
  7. package/dist/commons/application-config/index.d.ts +1 -0
  8. package/dist/commons/conditionals/conditionals.d.ts +357 -7
  9. package/dist/commons/conditionals/validate.d.ts +51 -2
  10. package/dist/commons/events/ActionConfig.d.ts +211 -2
  11. package/dist/commons/events/ActionDocument.d.ts +6 -0
  12. package/dist/commons/events/ActionInput.d.ts +6 -0
  13. package/dist/commons/events/AdvancedSearchConfig.d.ts +354 -0
  14. package/dist/commons/events/CountryConfigQueryInput.d.ts +42 -0
  15. package/dist/commons/events/EventConfig.d.ts +2 -0
  16. package/dist/commons/events/EventDocument.d.ts +3 -0
  17. package/dist/commons/events/EventIndex.d.ts +25 -0
  18. package/dist/commons/events/EventMetadata.d.ts +26 -0
  19. package/dist/commons/events/FieldConfig.d.ts +388 -50
  20. package/dist/commons/events/FieldType.d.ts +1 -0
  21. package/dist/commons/events/FieldTypeMapping.d.ts +1 -1
  22. package/dist/commons/events/FieldValue.d.ts +6 -0
  23. package/dist/commons/events/WorkqueueConfig.d.ts +39 -0
  24. package/dist/commons/events/field.d.ts +53 -1
  25. package/dist/commons/events/index.d.ts +1 -0
  26. package/dist/commons/events/locations.d.ts +1 -0
  27. package/dist/commons/events/state/flags.d.ts +16 -0
  28. package/dist/commons/events/state/index.d.ts +8 -0
  29. package/dist/commons/events/state/utils.d.ts +21 -287
  30. package/dist/commons/events/utils.d.ts +20 -1
  31. package/dist/conditionals/index.js +62 -6
  32. package/dist/environment/custom-types.d.ts +33 -0
  33. package/dist/environment/custom-types.d.ts.map +1 -0
  34. package/dist/environment/custom-types.js +12 -0
  35. package/dist/environment/derived-variables.d.ts +134 -0
  36. package/dist/environment/derived-variables.d.ts.map +1 -0
  37. package/dist/environment/derived-variables.js +169 -0
  38. package/dist/environment/editor-questions.d.ts +4 -0
  39. package/dist/environment/editor-questions.d.ts.map +1 -0
  40. package/dist/environment/editor-questions.js +67 -0
  41. package/dist/environment/git.d.ts +5 -0
  42. package/dist/environment/git.d.ts.map +1 -0
  43. package/dist/environment/git.js +38 -0
  44. package/dist/environment/github.d.ts +26 -0
  45. package/dist/environment/github.d.ts.map +1 -0
  46. package/dist/environment/github.js +247 -0
  47. package/dist/environment/index.d.ts +5 -0
  48. package/dist/environment/index.d.ts.map +1 -0
  49. package/dist/environment/index.js +71 -0
  50. package/dist/environment/logger.d.ts +15 -0
  51. package/dist/environment/logger.d.ts.map +1 -0
  52. package/dist/environment/logger.js +25 -0
  53. package/dist/environment/manage-users.d.ts +11 -0
  54. package/dist/environment/manage-users.d.ts.map +1 -0
  55. package/dist/environment/manage-users.js +497 -0
  56. package/dist/environment/questions-helper.d.ts +15 -0
  57. package/dist/environment/questions-helper.d.ts.map +1 -0
  58. package/dist/environment/questions-helper.js +70 -0
  59. package/dist/environment/questions.d.ts +199 -0
  60. package/dist/environment/questions.d.ts.map +1 -0
  61. package/dist/environment/questions.js +412 -0
  62. package/dist/environment/setup-environment.d.ts +2 -0
  63. package/dist/environment/setup-environment.d.ts.map +1 -0
  64. package/dist/environment/setup-environment.js +794 -0
  65. package/dist/environment/ssh-keygen.d.ts +5 -0
  66. package/dist/environment/ssh-keygen.d.ts.map +1 -0
  67. package/dist/environment/ssh-keygen.js +21 -0
  68. package/dist/environment/swarm-to-k8s.d.ts +2 -0
  69. package/dist/environment/swarm-to-k8s.d.ts.map +1 -0
  70. package/dist/environment/swarm-to-k8s.js +173 -0
  71. package/dist/environment/templates.d.ts +27 -0
  72. package/dist/environment/templates.d.ts.map +1 -0
  73. package/dist/environment/templates.js +163 -0
  74. package/dist/environment/update-workflows.d.ts +2 -0
  75. package/dist/environment/update-workflows.d.ts.map +1 -0
  76. package/dist/environment/update-workflows.js +169 -0
  77. package/dist/environment/users.d.ts +2 -0
  78. package/dist/environment/users.d.ts.map +1 -0
  79. package/dist/environment/users.js +112 -0
  80. package/dist/environment/utils.d.ts +18 -0
  81. package/dist/environment/utils.d.ts.map +1 -0
  82. package/dist/environment/utils.js +100 -0
  83. package/dist/events/index.js +569 -164
  84. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +1 -1
  85. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
  86. package/dist/migrations/v2.0/checkout-upstream-files.js +1 -1
  87. package/dist/migrations/v2.0/index.js +88 -5133
  88. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts +3 -0
  89. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts.map +1 -0
  90. package/dist/migrations/v2.1/add-explicit-correction-flags.js +234 -0
  91. package/dist/migrations/v2.1/index.d.ts +6 -0
  92. package/dist/migrations/v2.1/index.d.ts.map +1 -0
  93. package/dist/migrations/v2.1/index.js +218 -0
  94. package/dist/notification/index.js +369 -57
  95. package/dist/scopes/index.d.ts +93 -7
  96. package/dist/scopes/index.js +19 -8
  97. package/dist/templates/charts-values/dependencies/values.override.yaml +4 -0
  98. package/dist/templates/charts-values/dependencies/values.yaml +83 -0
  99. package/dist/templates/charts-values/opencrvs-services/values.override.yaml +4 -0
  100. package/dist/templates/charts-values/opencrvs-services/values.yaml +81 -0
  101. package/dist/templates/charts-values/traefik/values.override.yaml +4 -0
  102. package/dist/templates/charts-values/traefik/values.yaml +115 -0
  103. package/dist/templates/inventory/inventory.template.yml +100 -0
  104. package/dist/templates/inventory/production.example.yml +77 -0
  105. package/dist/templates/inventory/qa.example.yml +48 -0
  106. package/opencrvs-toolkit-2.0.0-rc.1239696.tgz +0 -0
  107. package/package.json +16 -2
  108. package/tsconfig.tsbuildinfo +1 -1
  109. package/opencrvs-toolkit-2.0.0-rc.1237a55.tgz +0 -0
@@ -75,6 +75,7 @@ __export(events_exports, {
75
75
  CheckboxFieldValue: () => CheckboxFieldValue,
76
76
  Clause: () => Clause,
77
77
  ClientSpecificAction: () => ClientSpecificAction,
78
+ ComputedDefaultValue: () => ComputedDefaultValue,
78
79
  Conditional: () => Conditional,
79
80
  ConditionalType: () => ConditionalType,
80
81
  ConfirmableActions: () => ConfirmableActions,
@@ -150,6 +151,7 @@ __export(events_exports, {
150
151
  FormPageConfig: () => FormPageConfig,
151
152
  Fuzzy: () => Fuzzy,
152
153
  GeographicalArea: () => GeographicalArea,
154
+ HiddenFieldTypes: () => HiddenFieldTypes,
153
155
  HiddenFieldValue: () => HiddenFieldValue,
154
156
  HttpFieldUpdateValue: () => HttpFieldUpdateValue,
155
157
  HttpFieldValue: () => HttpFieldValue,
@@ -200,6 +202,7 @@ __export(events_exports, {
200
202
  SelectDateRangeValue: () => SelectDateRangeValue,
201
203
  SelectOption: () => SelectOption,
202
204
  ShowConditional: () => ShowConditional,
205
+ SignatureFieldValue: () => SignatureFieldValue,
203
206
  StaticDataEntry: () => StaticDataEntry,
204
207
  StreetLevelDetailsUpdateValue: () => StreetLevelDetailsUpdateValue,
205
208
  SummaryConfig: () => SummaryConfig,
@@ -238,6 +241,7 @@ __export(events_exports, {
238
241
  ageToDate: () => ageToDate,
239
242
  aggregateActionAnnotations: () => aggregateActionAnnotations,
240
243
  aggregateActionDeclarations: () => aggregateActionDeclarations,
244
+ always: () => always,
241
245
  alwaysTrue: () => alwaysTrue,
242
246
  and: () => and,
243
247
  annotationActions: () => annotationActions,
@@ -245,10 +249,12 @@ __export(events_exports, {
245
249
  applyDraftToEventIndex: () => applyDraftToEventIndex,
246
250
  areCertificateConditionsMet: () => areCertificateConditionsMet,
247
251
  areConditionsMet: () => areConditionsMet,
252
+ buildClientFunctionContext: () => buildClientFunctionContext,
248
253
  buildFormState: () => buildFormState,
249
254
  canAccessEventWithScope: () => canAccessEventWithScope,
250
255
  canAccessOtherUserWithScopes: () => canAccessOtherUserWithScopes,
251
256
  canAccessUserWithScope: () => canAccessUserWithScope,
257
+ compileClientFunction: () => compileClientFunction,
252
258
  compositeFieldTypes: () => compositeFieldTypes,
253
259
  createEmptyDraft: () => createEmptyDraft,
254
260
  createFieldConditionals: () => createFieldConditionals,
@@ -269,6 +275,7 @@ __export(events_exports, {
269
275
  defineWorkqueuesColumns: () => defineWorkqueuesColumns,
270
276
  deserializeQuery: () => deserializeQuery,
271
277
  errorMessages: () => errorMessages,
278
+ evaluate: () => evaluate,
272
279
  event: () => event,
273
280
  eventMetadataLabelMap: () => eventMetadataLabelMap,
274
281
  eventPayloadGenerator: () => eventPayloadGenerator,
@@ -281,6 +288,7 @@ __export(events_exports, {
281
288
  findActiveDraftForEvent: () => findActiveDraftForEvent,
282
289
  findAllFields: () => findAllFields,
283
290
  findLastAssignmentAction: () => findLastAssignmentAction,
291
+ findPendingCorrectionAction: () => findPendingCorrectionAction,
284
292
  findRecordActionPages: () => findRecordActionPages,
285
293
  flag: () => flag,
286
294
  flattenFieldReference: () => flattenFieldReference,
@@ -304,6 +312,7 @@ __export(events_exports, {
304
312
  getActionAnnotation: () => getActionAnnotation,
305
313
  getActionAnnotationFields: () => getActionAnnotationFields,
306
314
  getActionConfig: () => getActionConfig,
315
+ getActionFormFields: () => getActionFormFields,
307
316
  getActionReview: () => getActionReview,
308
317
  getActionReviewFields: () => getActionReviewFields,
309
318
  getAdministrativeAreaHierarchy: () => getAdministrativeAreaHierarchy,
@@ -314,6 +323,7 @@ __export(events_exports, {
314
323
  getAvailableActionsForEvent: () => getAvailableActionsForEvent,
315
324
  getAvailableRolesForUserUpdatePayload: () => getAvailableRolesForUserUpdatePayload,
316
325
  getCompleteActionAnnotation: () => getCompleteActionAnnotation,
326
+ getCompleteActionContent: () => getCompleteActionContent,
317
327
  getCompleteActionDeclaration: () => getCompleteActionDeclaration,
318
328
  getCurrentEventState: () => getCurrentEventState,
319
329
  getCustomActionFields: () => getCustomActionFields,
@@ -322,6 +332,7 @@ __export(events_exports, {
322
332
  getDeclarationFields: () => getDeclarationFields,
323
333
  getDeclarationPages: () => getDeclarationPages,
324
334
  getEventConfigById: () => getEventConfigById,
335
+ getEventFlags: () => getEventFlags,
325
336
  getFilePathsFromEvent: () => getFilePathsFromEvent,
326
337
  getLocationHierarchy: () => getLocationHierarchy,
327
338
  getMixedPath: () => getMixedPath,
@@ -344,6 +355,7 @@ __export(events_exports, {
344
355
  isBulletListFieldType: () => isBulletListFieldType,
345
356
  isButtonFieldType: () => isButtonFieldType,
346
357
  isCheckboxFieldType: () => isCheckboxFieldType,
358
+ isCodeToEvaluate: () => isCodeToEvaluate,
347
359
  isConditionMet: () => isConditionMet,
348
360
  isCountryFieldType: () => isCountryFieldType,
349
361
  isCustomFieldType: () => isCustomFieldType,
@@ -384,6 +396,7 @@ __export(events_exports, {
384
396
  isPageVisible: () => isPageVisible,
385
397
  isParagraphFieldType: () => isParagraphFieldType,
386
398
  isPhoneFieldType: () => isPhoneFieldType,
399
+ isPotentialDuplicate: () => isPotentialDuplicate,
387
400
  isPrintButtonFieldType: () => isPrintButtonFieldType,
388
401
  isQrReaderFieldType: () => isQrReaderFieldType,
389
402
  isQueryParamReaderFieldType: () => isQueryParamReaderFieldType,
@@ -417,12 +430,15 @@ __export(events_exports, {
417
430
  plainDateToLocalDate: () => plainDateToLocalDate,
418
431
  precompileActionSchemas: () => precompileActionSchemas,
419
432
  resolveDateOfEvent: () => resolveDateOfEvent,
433
+ resolveEventCustomFlags: () => resolveEventCustomFlags,
420
434
  resolvePlaceOfEvent: () => resolvePlaceOfEvent,
435
+ runClientFunction: () => runClientFunction,
421
436
  runFieldValidations: () => runFieldValidations,
422
437
  runStructuralValidations: () => runStructuralValidations,
423
438
  safeUnion: () => safeUnion,
424
439
  status: () => status,
425
440
  timePeriodToDateRange: () => timePeriodToDateRange,
441
+ todayISO: () => todayISO,
426
442
  user: () => user,
427
443
  userCanAccessEventWithScopes: () => userCanAccessEventWithScopes,
428
444
  validate: () => validate,
@@ -505,11 +521,13 @@ var scopeOptionsPlaceEvent = z2.object({
505
521
  event: scopeByEvent,
506
522
  placeOfEvent: JurisdictionFilter.optional()
507
523
  }).describe("Options applicable to all record scopes.");
508
- var scopeOptionsDeclared = scopeOptionsPlaceEvent.extend({
524
+ var scopeOptionsDeclaredOrNotified = scopeOptionsPlaceEvent.extend({
525
+ notifiedIn: JurisdictionFilter.optional(),
526
+ notifiedBy: UserFilter.optional(),
509
527
  declaredIn: JurisdictionFilter.optional(),
510
528
  declaredBy: UserFilter.optional()
511
529
  }).describe("Options applicable to actions that may take place after DECLARE");
512
- var AllRecordScopeOptions = scopeOptionsDeclared.extend({
530
+ var AllRecordScopeOptions = scopeOptionsDeclaredOrNotified.extend({
513
531
  registeredIn: JurisdictionFilter.optional(),
514
532
  registeredBy: UserFilter.optional()
515
533
  }).describe(
@@ -547,6 +565,8 @@ var ResolvedScopeOptionsPlaceEvent = z2.object({
547
565
  "Resolved options applicable to all record scopes, with location ID instead of jurisdiction filter."
548
566
  );
549
567
  var ResolvedScopeOptionsDeclared = ResolvedScopeOptionsPlaceEvent.extend({
568
+ notifiedIn: UUID.nullish(),
569
+ notifiedBy: z2.string().optional(),
550
570
  declaredIn: UUID.nullish(),
551
571
  declaredBy: z2.string().optional()
552
572
  }).describe(
@@ -592,7 +612,7 @@ var RecordScopeV2 = z2.discriminatedUnion("type", [
592
612
  }),
593
613
  z2.object({
594
614
  type: ScopesWithDeclaredOptions,
595
- options: scopeOptionsDeclared.optional()
615
+ options: scopeOptionsDeclaredOrNotified.optional()
596
616
  }),
597
617
  z2.object({
598
618
  type: ScopesWithFullOptions,
@@ -697,20 +717,27 @@ var unflattenScope = (input) => {
697
717
  return { type, options };
698
718
  };
699
719
  var EncodedScope = z2.string().brand("EncodedScope");
700
- var decodeScope = (query) => {
701
- const scope = qs.parse(query, {
720
+ var decodedScopeCache = /* @__PURE__ */ new Map();
721
+ var decodeScope = (encodedScope) => {
722
+ if (decodedScopeCache.has(encodedScope)) {
723
+ return decodedScopeCache.get(encodedScope);
724
+ }
725
+ const scope = qs.parse(encodedScope, {
702
726
  ignoreQueryPrefix: true,
703
727
  comma: true,
704
728
  allowDots: true
705
729
  });
706
730
  const unflattenedScope = unflattenScope(scope);
707
- return Scope.safeParse(unflattenedScope)?.data;
731
+ const result = Scope.safeParse(unflattenedScope)?.data;
732
+ decodedScopeCache.set(encodedScope, result);
733
+ return result;
708
734
  };
709
735
  var DEFAULT_SCOPE_OPTIONS = {
710
736
  placeOfEvent: JurisdictionFilter.enum.all,
711
737
  accessLevel: JurisdictionFilter.enum.all,
712
- registeredIn: JurisdictionFilter.enum.all,
713
- declaredIn: JurisdictionFilter.enum.all
738
+ notifiedIn: JurisdictionFilter.enum.all,
739
+ declaredIn: JurisdictionFilter.enum.all,
740
+ registeredIn: JurisdictionFilter.enum.all
714
741
  };
715
742
  function getAcceptedScopesByType({
716
743
  acceptedScopes,
@@ -1199,6 +1226,11 @@ var FieldTypesToHideInReview = [
1199
1226
  FieldType.ALPHA_PRINT_BUTTON,
1200
1227
  FieldType.ALPHA_HIDDEN
1201
1228
  ];
1229
+ var HiddenFieldTypes = [
1230
+ FieldType.HTTP,
1231
+ FieldType.QUERY_PARAM_READER,
1232
+ FieldType.ALPHA_HIDDEN
1233
+ ];
1202
1234
 
1203
1235
  // ../commons/src/events/FieldValue.ts
1204
1236
  var z12 = __toESM(require("zod/v4"));
@@ -1325,7 +1357,7 @@ function plainDateToLocalDate(date) {
1325
1357
  // ../commons/src/events/FieldValue.ts
1326
1358
  var TextValue = z12.string();
1327
1359
  var HiddenFieldValue = z12.string();
1328
- var NonEmptyTextValue = TextValue.min(1);
1360
+ var NonEmptyTextValue = z12.string().trim().min(1);
1329
1361
  var DateValue = z12.iso.date().describe("Date in the format YYYY-MM-DD");
1330
1362
  var AgeValue = z12.object({
1331
1363
  age: z12.number(),
@@ -1354,6 +1386,7 @@ var DateRangeFieldValue = z12.object({
1354
1386
  var EmailValue = z12.email();
1355
1387
  var CheckboxFieldValue = z12.boolean();
1356
1388
  var NumberFieldValue = z12.number();
1389
+ var SignatureFieldValue = FileFieldValue;
1357
1390
  var ButtonFieldValue = z12.number();
1358
1391
  var VerificationStatusValue = z12.enum([
1359
1392
  "verified",
@@ -1652,8 +1685,9 @@ var RequestedCorrectionAction = ActionBase.extend(
1652
1685
  var ApprovedCorrectionAction = ActionBase.extend(
1653
1686
  z14.object({
1654
1687
  type: z14.literal(ActionType.APPROVE_CORRECTION),
1655
- requestId: z14.string()
1688
+ requestId: z14.string(),
1656
1689
  // TODO move into 'content' property
1690
+ content: z14.object({ immediateCorrection: z14.boolean().optional() }).optional()
1657
1691
  }).shape
1658
1692
  );
1659
1693
  var RejectedCorrectionAction = ActionBase.extend(
@@ -1787,6 +1821,7 @@ var RegistrationCreationMetadata = ActionCreationMetadata.extend({
1787
1821
  )
1788
1822
  });
1789
1823
  var LegalStatuses = z16.object({
1824
+ [EventStatus.enum.NOTIFIED]: ActionCreationMetadata.nullish(),
1790
1825
  [EventStatus.enum.DECLARED]: ActionCreationMetadata.nullish(),
1791
1826
  [EventStatus.enum.REGISTERED]: RegistrationCreationMetadata.nullish()
1792
1827
  });
@@ -1928,6 +1963,8 @@ var eventMetadataLabelMap = {
1928
1963
  var EventMetadataDateFieldIdInput = z16.enum([
1929
1964
  "createdAt",
1930
1965
  "updatedAt",
1966
+ "legalStatuses.NOTIFIED.createdAt",
1967
+ "legalStatuses.NOTIFIED.acceptedAt",
1931
1968
  "legalStatuses.DECLARED.createdAt",
1932
1969
  "legalStatuses.DECLARED.acceptedAt",
1933
1970
  "legalStatuses.REGISTERED.createdAt",
@@ -1936,6 +1973,8 @@ var EventMetadataDateFieldIdInput = z16.enum([
1936
1973
  var EventMetadataDateFieldId = z16.enum([
1937
1974
  "event.createdAt",
1938
1975
  "event.updatedAt",
1976
+ "event.legalStatuses.NOTIFIED.createdAt",
1977
+ "event.legalStatuses.NOTIFIED.acceptedAt",
1939
1978
  "event.legalStatuses.DECLARED.createdAt",
1940
1979
  "event.legalStatuses.DECLARED.acceptedAt",
1941
1980
  "event.legalStatuses.REGISTERED.createdAt",
@@ -1995,7 +2034,8 @@ var Range = import_v4.z.object({
1995
2034
  });
1996
2035
  var ContainsFlags = import_v4.z.object({
1997
2036
  anyOf: import_v4.z.array(Flag).optional(),
1998
- noneOf: import_v4.z.array(Flag).optional()
2037
+ noneOf: import_v4.z.array(Flag).optional(),
2038
+ allOf: import_v4.z.array(Flag).optional()
1999
2039
  }).meta({
2000
2040
  id: "ContainsFlags"
2001
2041
  });
@@ -2184,8 +2224,21 @@ var FieldReference = import_v43.default.object({
2184
2224
  $$field: FieldId.describe("Id of the field to reference"),
2185
2225
  $$subfield: import_v43.default.array(import_v43.default.string()).optional().default([]).describe(
2186
2226
  'If the FieldValue is an object, subfield can be used to refer to e.g. `["foo", "bar"]` in `{ foo: { bar: 3 } }`'
2227
+ ),
2228
+ $$code: import_v43.default.string().optional().describe(
2229
+ "Serialised client-side function body. When present the expression is evaluated rather than dereferenced."
2187
2230
  )
2188
- }).describe("Reference to a field by its ID");
2231
+ }).describe(
2232
+ "Reference to a field value, with an optional client-side computation applied."
2233
+ );
2234
+ function isCodeToEvaluate(v) {
2235
+ return !!v && typeof v === "object" && "$$code" in v;
2236
+ }
2237
+ var ComputedDefaultValue = import_v43.default.object({
2238
+ $$code: import_v43.default.string().describe(
2239
+ "Serialised client-side function body. Receives (undefined, context) where context includes $now, $online, and system variables."
2240
+ )
2241
+ }).describe("A context-only computation used as a field default value.");
2189
2242
  var ValidationConfig = import_v43.default.object({
2190
2243
  validator: Conditional.describe(
2191
2244
  "Conditional expression that must hold for the field value to be considered valid."
@@ -2226,7 +2279,7 @@ var BaseField = import_v43.default.object({
2226
2279
  "Indicates whether the field can be modified during record correction."
2227
2280
  ),
2228
2281
  value: FieldReference.or(import_v43.default.array(FieldReference)).optional().describe(
2229
- "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."
2282
+ "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 FieldReference with $$code computes the value via a custom client-side function."
2230
2283
  ),
2231
2284
  analytics: import_v43.default.boolean().default(false).optional().describe(
2232
2285
  "Indicates whether the field is included in analytics. When enabled, its value becomes available in the analytics dashboard."
@@ -2240,7 +2293,7 @@ var Divider = BaseField.extend({
2240
2293
  });
2241
2294
  var TextField = BaseField.extend({
2242
2295
  type: import_v43.default.literal(FieldType.TEXT),
2243
- defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField]).optional(),
2296
+ defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField, ComputedDefaultValue]).optional(),
2244
2297
  configuration: import_v43.default.object({
2245
2298
  maxLength: import_v43.default.number().optional().describe("Maximum length of the text"),
2246
2299
  type: import_v43.default.enum(["text", "password"]).optional(),
@@ -2253,10 +2306,11 @@ var TextField = BaseField.extend({
2253
2306
  });
2254
2307
  var NumberField = BaseField.extend({
2255
2308
  type: import_v43.default.literal(FieldType.NUMBER),
2256
- defaultValue: NumberFieldValue.optional(),
2309
+ defaultValue: NumberFieldValue.or(ComputedDefaultValue).optional(),
2257
2310
  configuration: import_v43.default.object({
2258
2311
  min: import_v43.default.number().optional().describe("Minimum value"),
2259
2312
  max: import_v43.default.number().optional().describe("Maximum value"),
2313
+ integer: import_v43.default.boolean().optional().describe("When true, only whole numbers are allowed"),
2260
2314
  prefix: TranslationConfig.optional(),
2261
2315
  postfix: TranslationConfig.optional()
2262
2316
  }).optional()
@@ -2266,7 +2320,7 @@ var NumberField = BaseField.extend({
2266
2320
  });
2267
2321
  var TextAreaField = BaseField.extend({
2268
2322
  type: import_v43.default.literal(FieldType.TEXTAREA),
2269
- defaultValue: NonEmptyTextValue.optional(),
2323
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2270
2324
  configuration: import_v43.default.object({
2271
2325
  maxLength: import_v43.default.number().optional().describe("Maximum length of the text"),
2272
2326
  rows: import_v43.default.number().optional().describe("Number of visible text lines"),
@@ -2300,7 +2354,7 @@ var SignatureField = BaseField.extend({
2300
2354
  signaturePromptLabel: TranslationConfig.describe(
2301
2355
  "Title of the signature modal"
2302
2356
  ),
2303
- defaultValue: FieldValue.optional(),
2357
+ defaultValue: SignatureFieldValue.or(ComputedDefaultValue).optional(),
2304
2358
  configuration: import_v43.default.object({
2305
2359
  maxFileSize: import_v43.default.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
2306
2360
  acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature")
@@ -2316,14 +2370,14 @@ var EmailField = BaseField.extend({
2316
2370
  configuration: import_v43.default.object({
2317
2371
  maxLength: import_v43.default.number().optional().describe("Maximum length of the text")
2318
2372
  }).default({ maxLength: 255 }).optional(),
2319
- defaultValue: NonEmptyTextValue.optional()
2373
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional()
2320
2374
  }).meta({
2321
2375
  description: "An email input field",
2322
2376
  id: "EmailField"
2323
2377
  });
2324
2378
  var DateField = BaseField.extend({
2325
2379
  type: import_v43.default.literal(FieldType.DATE),
2326
- defaultValue: SerializedNowDateTime.or(PlainDate).optional().describe("Default date value(yyyy-MM-dd)"),
2380
+ defaultValue: SerializedNowDateTime.or(PlainDate).or(ComputedDefaultValue).optional().describe("Default date value(yyyy-MM-dd)"),
2327
2381
  configuration: import_v43.default.object({
2328
2382
  notice: TranslationConfig.describe(
2329
2383
  "Text to display above the date input"
@@ -2335,7 +2389,7 @@ var DateField = BaseField.extend({
2335
2389
  });
2336
2390
  var AgeField = BaseField.extend({
2337
2391
  type: import_v43.default.literal(FieldType.AGE),
2338
- defaultValue: NumberFieldValue.optional(),
2392
+ defaultValue: NumberFieldValue.or(ComputedDefaultValue).optional(),
2339
2393
  configuration: import_v43.default.object({
2340
2394
  asOfDate: FieldReference,
2341
2395
  prefix: TranslationConfig.optional(),
@@ -2347,7 +2401,7 @@ var AgeField = BaseField.extend({
2347
2401
  });
2348
2402
  var TimeField = BaseField.extend({
2349
2403
  type: import_v43.default.literal(FieldType.TIME),
2350
- defaultValue: SerializedNowDateTime.or(TimeValue).optional().describe("Default time value (HH-mm)"),
2404
+ defaultValue: SerializedNowDateTime.or(TimeValue).or(ComputedDefaultValue).optional().describe("Default time value (HH-mm)"),
2351
2405
  configuration: import_v43.default.object({
2352
2406
  use12HourFormat: import_v43.default.boolean().optional().describe("Whether to use 12-hour format"),
2353
2407
  notice: TranslationConfig.describe(
@@ -2360,7 +2414,7 @@ var TimeField = BaseField.extend({
2360
2414
  });
2361
2415
  var DateRangeField = BaseField.extend({
2362
2416
  type: import_v43.default.literal(FieldType.DATE_RANGE),
2363
- defaultValue: DateRangeFieldValue.optional(),
2417
+ defaultValue: DateRangeFieldValue.or(ComputedDefaultValue).optional(),
2364
2418
  configuration: import_v43.default.object({
2365
2419
  notice: TranslationConfig.describe(
2366
2420
  "Text to display above the date input"
@@ -2439,7 +2493,7 @@ var PageHeader = BaseField.extend({
2439
2493
  });
2440
2494
  var File = BaseField.extend({
2441
2495
  type: import_v43.default.literal(FieldType.FILE),
2442
- defaultValue: FileFieldValue.optional(),
2496
+ defaultValue: FileFieldValue.or(ComputedDefaultValue).optional(),
2443
2497
  configuration: import_v43.default.object({
2444
2498
  maxFileSize: import_v43.default.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
2445
2499
  acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature"),
@@ -2466,7 +2520,7 @@ var SelectOption = import_v43.default.object({
2466
2520
  });
2467
2521
  var NumberWithUnitField = BaseField.extend({
2468
2522
  type: import_v43.default.literal(FieldType.NUMBER_WITH_UNIT),
2469
- defaultValue: NumberWithUnitFieldValue.optional(),
2523
+ defaultValue: NumberWithUnitFieldValue.or(ComputedDefaultValue).optional(),
2470
2524
  options: import_v43.default.array(SelectOption).describe("A list of options for the unit select"),
2471
2525
  configuration: import_v43.default.object({
2472
2526
  min: import_v43.default.number().optional().describe("Minimum value of the number field"),
@@ -2481,7 +2535,7 @@ var NumberWithUnitField = BaseField.extend({
2481
2535
  });
2482
2536
  var RadioGroup = BaseField.extend({
2483
2537
  type: import_v43.default.literal(FieldType.RADIO_GROUP),
2484
- defaultValue: TextValue.optional(),
2538
+ defaultValue: TextValue.or(ComputedDefaultValue).optional(),
2485
2539
  options: import_v43.default.array(SelectOption).describe("A list of options"),
2486
2540
  configuration: import_v43.default.object({
2487
2541
  styles: import_v43.default.object({
@@ -2506,7 +2560,7 @@ var BulletList = BaseField.extend({
2506
2560
  });
2507
2561
  var Select = BaseField.extend({
2508
2562
  type: import_v43.default.literal(FieldType.SELECT),
2509
- defaultValue: TextValue.optional(),
2563
+ defaultValue: TextValue.or(ComputedDefaultValue).optional(),
2510
2564
  options: import_v43.default.array(SelectOption).describe("A list of options"),
2511
2565
  noOptionsMessage: TranslationConfig.optional().describe(
2512
2566
  `
@@ -2528,7 +2582,7 @@ var SelectDateRangeOption = import_v43.default.object({
2528
2582
  });
2529
2583
  var SelectDateRangeField = BaseField.extend({
2530
2584
  type: import_v43.default.literal(FieldType.SELECT_DATE_RANGE),
2531
- defaultValue: SelectDateRangeValue.optional(),
2585
+ defaultValue: SelectDateRangeValue.or(ComputedDefaultValue).optional(),
2532
2586
  options: import_v43.default.array(SelectDateRangeOption).describe("A list of options")
2533
2587
  }).meta({
2534
2588
  description: "A date range selection field",
@@ -2545,7 +2599,7 @@ var NameField = BaseField.extend({
2545
2599
  firstname: SerializedUserField.or(NonEmptyTextValue).optional(),
2546
2600
  middlename: SerializedUserField.or(NonEmptyTextValue).optional(),
2547
2601
  surname: SerializedUserField.or(NonEmptyTextValue).optional()
2548
- }).optional(),
2602
+ }).or(ComputedDefaultValue).optional(),
2549
2603
  configuration: import_v43.default.object({
2550
2604
  name: NameConfig.default({
2551
2605
  firstname: { required: true },
@@ -2569,14 +2623,14 @@ var NameField = BaseField.extend({
2569
2623
  id: "NameField"
2570
2624
  });
2571
2625
  var PhoneField = BaseField.extend({
2572
- defaultValue: NonEmptyTextValue.optional(),
2626
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2573
2627
  type: import_v43.default.literal(FieldType.PHONE)
2574
2628
  }).meta({
2575
2629
  description: "A field for entering a phone number",
2576
2630
  id: "PhoneField"
2577
2631
  });
2578
2632
  var IdField = BaseField.extend({
2579
- defaultValue: NonEmptyTextValue.optional(),
2633
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2580
2634
  type: import_v43.default.literal(FieldType.ID)
2581
2635
  }).meta({
2582
2636
  description: "A field for entering an ID",
@@ -2584,14 +2638,14 @@ var IdField = BaseField.extend({
2584
2638
  });
2585
2639
  var Checkbox = BaseField.extend({
2586
2640
  type: import_v43.default.literal(FieldType.CHECKBOX),
2587
- defaultValue: CheckboxFieldValue.default(false)
2641
+ defaultValue: CheckboxFieldValue.or(ComputedDefaultValue).default(false)
2588
2642
  }).meta({
2589
2643
  description: "A boolean checkbox field",
2590
2644
  id: "Checkbox"
2591
2645
  });
2592
2646
  var Country = BaseField.extend({
2593
2647
  type: import_v43.default.literal(FieldType.COUNTRY),
2594
- defaultValue: NonEmptyTextValue.optional(),
2648
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2595
2649
  optionOverrides: import_v43.default.array(SelectOption.omit({ label: true })).optional().describe(
2596
2650
  "Conditionals for specific countries. Countries not listed are always shown and enabled."
2597
2651
  )
@@ -2609,7 +2663,7 @@ var AdministrativeAreas = import_v43.default.enum([
2609
2663
  ]);
2610
2664
  var AdministrativeAreaField = BaseField.extend({
2611
2665
  type: import_v43.default.literal(FieldType.ADMINISTRATIVE_AREA),
2612
- defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField]).optional(),
2666
+ defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField, ComputedDefaultValue]).optional(),
2613
2667
  configuration: import_v43.default.object({
2614
2668
  partOf: FieldReference.optional().describe("Parent location"),
2615
2669
  type: AdministrativeAreas,
@@ -2621,7 +2675,7 @@ var AdministrativeAreaField = BaseField.extend({
2621
2675
  });
2622
2676
  var LocationInput = BaseField.extend({
2623
2677
  type: import_v43.default.literal(FieldType.LOCATION),
2624
- defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField]).optional(),
2678
+ defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField, ComputedDefaultValue]).optional(),
2625
2679
  configuration: import_v43.default.object({
2626
2680
  locationTypes: import_v43.default.array(import_v43.default.string()).optional().describe("Types of the locations that are available for selection."),
2627
2681
  allowedLocations: AllowedLocations
@@ -2633,7 +2687,7 @@ var LocationInput = BaseField.extend({
2633
2687
  var FileUploadWithOptions = BaseField.extend({
2634
2688
  type: import_v43.default.literal(FieldType.FILE_WITH_OPTIONS),
2635
2689
  options: import_v43.default.array(SelectOption).describe("A list of options"),
2636
- defaultValue: FileFieldWithOptionValue.optional(),
2690
+ defaultValue: FileFieldWithOptionValue.or(ComputedDefaultValue).optional(),
2637
2691
  configuration: import_v43.default.object({
2638
2692
  maxFileSize: import_v43.default.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
2639
2693
  maxImageSize: import_v43.default.object({
@@ -2649,12 +2703,12 @@ var FileUploadWithOptions = BaseField.extend({
2649
2703
  });
2650
2704
  var Facility = BaseField.extend({
2651
2705
  type: import_v43.default.literal(FieldType.FACILITY),
2652
- defaultValue: NonEmptyTextValue.optional(),
2706
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2653
2707
  configuration: import_v43.default.object({ allowedLocations: AllowedLocations }).optional()
2654
2708
  }).describe("Input field for a facility");
2655
2709
  var Office = BaseField.extend({
2656
2710
  type: import_v43.default.literal(FieldType.OFFICE),
2657
- defaultValue: NonEmptyTextValue.optional(),
2711
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2658
2712
  configuration: import_v43.default.object({ allowedLocations: AllowedLocations }).optional()
2659
2713
  }).describe("Input field for an office");
2660
2714
  var DefaultAddressFieldValue = DomesticAddressFieldValue.extend({
@@ -2690,7 +2744,7 @@ var Address = BaseField.extend({
2690
2744
  ).optional(),
2691
2745
  allowedLocations: AllowedLocations
2692
2746
  }).optional(),
2693
- defaultValue: DefaultAddressFieldValue.optional()
2747
+ defaultValue: DefaultAddressFieldValue.or(ComputedDefaultValue).optional()
2694
2748
  }).meta({
2695
2749
  description: "Address input field \u2013 a combination of location and text fields",
2696
2750
  id: "Address"
@@ -2737,7 +2791,7 @@ var ButtonConfiguration = import_v43.default.object({
2737
2791
  });
2738
2792
  var ButtonField = BaseField.extend({
2739
2793
  type: import_v43.default.literal(FieldType.BUTTON),
2740
- defaultValue: ButtonFieldValue.optional(),
2794
+ defaultValue: ButtonFieldValue.or(ComputedDefaultValue).optional(),
2741
2795
  configuration: ButtonConfiguration
2742
2796
  }).meta({
2743
2797
  description: "A generic button that can be used to trigger an action",
@@ -2765,7 +2819,7 @@ var AlphaPrintButton = BaseField.extend({
2765
2819
  });
2766
2820
  var HttpField = BaseField.extend({
2767
2821
  type: import_v43.default.literal(FieldType.HTTP),
2768
- defaultValue: HttpFieldValue.optional(),
2822
+ defaultValue: HttpFieldValue.or(ComputedDefaultValue).optional(),
2769
2823
  configuration: import_v43.default.object({
2770
2824
  trigger: FieldReference.optional().describe(
2771
2825
  "Reference to the field that triggers the HTTP request when its value changes. If not provided, the HTTP request is triggered once on component mount."
@@ -2851,7 +2905,7 @@ var LinkButtonField = BaseField.extend({
2851
2905
  });
2852
2906
  var VerificationStatus = BaseField.extend({
2853
2907
  type: import_v43.default.literal(FieldType.VERIFICATION_STATUS),
2854
- defaultValue: VerificationStatusValue.optional(),
2908
+ defaultValue: VerificationStatusValue.or(ComputedDefaultValue).optional(),
2855
2909
  configuration: import_v43.default.object({
2856
2910
  status: TranslationConfig.describe("Text to display on the status pill."),
2857
2911
  description: TranslationConfig.describe(
@@ -2873,7 +2927,7 @@ var QueryParamReaderField = BaseField.extend({
2873
2927
  });
2874
2928
  var QrReaderField = BaseField.extend({
2875
2929
  type: import_v43.default.literal(FieldType.QR_READER),
2876
- defaultValue: QrReaderFieldValue.optional(),
2930
+ defaultValue: QrReaderFieldValue.or(ComputedDefaultValue).optional(),
2877
2931
  configuration: import_v43.default.object({
2878
2932
  validator: import_v43.default.any().meta({
2879
2933
  description: "JSON Schema to validate the scanned QR code data against before populating the form fields.",
@@ -2886,7 +2940,7 @@ var QrReaderField = BaseField.extend({
2886
2940
  });
2887
2941
  var IdReaderField = BaseField.extend({
2888
2942
  type: import_v43.default.literal(FieldType.ID_READER),
2889
- defaultValue: IdReaderFieldValue.optional(),
2943
+ defaultValue: IdReaderFieldValue.or(ComputedDefaultValue).optional(),
2890
2944
  methods: import_v43.default.array(
2891
2945
  import_v43.default.union([QrReaderField, LinkButtonField]).describe("Methods for reading an ID")
2892
2946
  )
@@ -3171,6 +3225,9 @@ var ActionConfigBase = z24.object({
3171
3225
  var DeclarationActionBase = ActionConfigBase.extend({
3172
3226
  deduplication: DeduplicationConfig.optional()
3173
3227
  });
3228
+ var actionConfirmationForm = z24.array(FieldConfig).optional().describe(
3229
+ "Fields rendered on the action confirmation dialog. Submitted values are stored in the action annotation and shown in the audit history."
3230
+ );
3174
3231
  var ReadActionConfig = ActionConfigBase.extend(
3175
3232
  z24.object({
3176
3233
  type: z24.literal(ActionType.READ),
@@ -3180,12 +3237,65 @@ var ReadActionConfig = ActionConfigBase.extend(
3180
3237
  conditionals: z24.never().optional().describe("Read-action can not be disabled or hidden with conditionals.")
3181
3238
  }).shape
3182
3239
  );
3240
+ var NotifyConfig = ActionConfigBase.extend(
3241
+ z24.object({
3242
+ type: z24.literal(ActionType.NOTIFY),
3243
+ form: actionConfirmationForm
3244
+ }).shape
3245
+ );
3246
+ var DuplicateDetectedConfig = ActionConfigBase.extend(
3247
+ z24.object({
3248
+ type: z24.literal(ActionType.DUPLICATE_DETECTED),
3249
+ label: z24.never().optional().describe(
3250
+ "DUPLICATE_DETECTED is system-generated and never shown as a button, so it has no label."
3251
+ ),
3252
+ supportingCopy: z24.never().optional(),
3253
+ icon: z24.never().optional().describe(
3254
+ "DUPLICATE_DETECTED is system-generated and never shown as a button, so it has no icon."
3255
+ ),
3256
+ conditionals: z24.never().optional().describe(
3257
+ "DUPLICATE_DETECTED is system-generated and never shown as a button, so it cannot be disabled or hidden with conditionals."
3258
+ )
3259
+ }).shape
3260
+ );
3261
+ var MarkAsDuplicateConfig = ActionConfigBase.extend(
3262
+ z24.object({
3263
+ type: z24.literal(ActionType.MARK_AS_DUPLICATE)
3264
+ }).shape
3265
+ );
3266
+ var MarkAsNotDuplicateConfig = ActionConfigBase.extend(
3267
+ z24.object({
3268
+ type: z24.literal(ActionType.MARK_AS_NOT_DUPLICATE)
3269
+ }).shape
3270
+ );
3271
+ var AssignConfig = ActionConfigBase.extend(
3272
+ z24.object({
3273
+ type: z24.literal(ActionType.ASSIGN),
3274
+ flags: z24.never().optional().describe(
3275
+ "ASSIGN is a meta action excluded from flag resolution, so flags configured here would never apply."
3276
+ )
3277
+ }).shape
3278
+ );
3279
+ var UnassignConfig = ActionConfigBase.extend(
3280
+ z24.object({
3281
+ type: z24.literal(ActionType.UNASSIGN),
3282
+ flags: z24.never().optional().describe(
3283
+ "UNASSIGN is a meta action excluded from flag resolution, so flags configured here would never apply."
3284
+ )
3285
+ }).shape
3286
+ );
3287
+ var DeleteConfig = ActionConfigBase.extend(
3288
+ z24.object({
3289
+ type: z24.literal(ActionType.DELETE)
3290
+ }).shape
3291
+ );
3183
3292
  var DeclareConfig = DeclarationActionBase.extend(
3184
3293
  z24.object({
3185
3294
  type: z24.literal(ActionType.DECLARE),
3186
3295
  review: DeclarationReviewConfig.describe(
3187
3296
  "Configuration of the review page fields."
3188
3297
  ),
3298
+ form: actionConfirmationForm,
3189
3299
  dialogCopy: z24.object({
3190
3300
  notify: TranslationConfig.describe(
3191
3301
  "Confirmation text for the notify action"
@@ -3201,7 +3311,8 @@ var DeclareConfig = DeclarationActionBase.extend(
3201
3311
  );
3202
3312
  var ArchiveConfig = ActionConfigBase.extend(
3203
3313
  z24.object({
3204
- type: z24.literal(ActionType.ARCHIVE)
3314
+ type: z24.literal(ActionType.ARCHIVE),
3315
+ form: actionConfirmationForm
3205
3316
  }).shape
3206
3317
  );
3207
3318
  var EditActionConfig = ActionConfigBase.extend(
@@ -3222,12 +3333,14 @@ var EditActionConfig = ActionConfigBase.extend(
3222
3333
  );
3223
3334
  var RejectConfig = ActionConfigBase.extend(
3224
3335
  z24.object({
3225
- type: z24.literal(ActionType.REJECT)
3336
+ type: z24.literal(ActionType.REJECT),
3337
+ form: actionConfirmationForm
3226
3338
  }).shape
3227
3339
  );
3228
3340
  var RegisterConfig = DeclarationActionBase.extend(
3229
3341
  z24.object({
3230
- type: z24.literal(ActionType.REGISTER)
3342
+ type: z24.literal(ActionType.REGISTER),
3343
+ form: actionConfirmationForm
3231
3344
  }).shape
3232
3345
  );
3233
3346
  var PrintCertificateActionConfig = ActionConfigBase.extend(
@@ -3242,7 +3355,17 @@ var RequestCorrectionConfig = ActionConfigBase.extend(
3242
3355
  correctionForm: ActionFormConfig
3243
3356
  }).shape
3244
3357
  );
3245
- var CustomActionConfig = ActionConfigBase.merge(
3358
+ var ApproveCorrectionConfig = ActionConfigBase.extend(
3359
+ z24.object({
3360
+ type: z24.literal(ActionType.APPROVE_CORRECTION)
3361
+ }).shape
3362
+ );
3363
+ var RejectCorrectionConfig = ActionConfigBase.extend(
3364
+ z24.object({
3365
+ type: z24.literal(ActionType.REJECT_CORRECTION)
3366
+ }).shape
3367
+ );
3368
+ var CustomActionConfig = ActionConfigBase.extend(
3246
3369
  z24.object({
3247
3370
  type: z24.literal(ActionType.CUSTOM),
3248
3371
  customActionType: z24.string().describe("Type identifier of the custom action."),
@@ -3253,7 +3376,7 @@ var CustomActionConfig = ActionConfigBase.merge(
3253
3376
  auditHistoryLabel: TranslationConfig.describe(
3254
3377
  'The label to show in audit history for this action. For example "Approved".'
3255
3378
  )
3256
- })
3379
+ }).shape
3257
3380
  );
3258
3381
  var ActionConfig = z24.discriminatedUnion("type", [
3259
3382
  /*
@@ -3264,9 +3387,37 @@ var ActionConfig = z24.discriminatedUnion("type", [
3264
3387
  id: "ReadActionConfig",
3265
3388
  description: "Configuration for the read action \u2014 defines the record-tab content displayed on the event overview page."
3266
3389
  }),
3390
+ AssignConfig.meta({
3391
+ id: "AssignActionConfig",
3392
+ description: "Configuration for assigning a record to the current user."
3393
+ }),
3394
+ UnassignConfig.meta({
3395
+ id: "UnassignActionConfig",
3396
+ description: "Configuration for unassigning a record from its current assignee."
3397
+ }),
3398
+ DeleteConfig.meta({
3399
+ id: "DeleteActionConfig",
3400
+ description: "Configuration for deleting a draft record."
3401
+ }),
3402
+ NotifyConfig.meta({
3403
+ id: "NotifyActionConfig",
3404
+ description: "Configuration for the notify action. When present, NOTIFY uses this config independently from DECLARE. When absent, NOTIFY falls back to the DeclareActionConfig."
3405
+ }),
3267
3406
  DeclareConfig.meta({
3268
3407
  id: "DeclareActionConfig",
3269
- description: "Configuration for the declare action. Includes review-page fields. Shared with the notify action (ActionType.NOTIFY)."
3408
+ description: "Configuration for the declare action. Includes review-page fields. NOTIFY falls back to this config when no dedicated NotifyActionConfig is provided."
3409
+ }),
3410
+ DuplicateDetectedConfig.meta({
3411
+ id: "DuplicateDetectedActionConfig",
3412
+ description: "Configuration for the system-generated duplicate-detection action. Never shown as a button, so it only supports flags \u2014 not label, icon, or conditionals."
3413
+ }),
3414
+ MarkAsDuplicateConfig.meta({
3415
+ id: "MarkAsDuplicateActionConfig",
3416
+ description: "Configuration for marking a record as a duplicate."
3417
+ }),
3418
+ MarkAsNotDuplicateConfig.meta({
3419
+ id: "MarkAsNotDuplicateActionConfig",
3420
+ description: "Configuration for marking a record as not a duplicate, after it was previously flagged as one."
3270
3421
  }),
3271
3422
  RejectConfig.meta({
3272
3423
  id: "RejectActionConfig",
@@ -3284,6 +3435,14 @@ var ActionConfig = z24.discriminatedUnion("type", [
3284
3435
  id: "RequestCorrectionActionConfig",
3285
3436
  description: "Configuration for requesting a correction on a registered record."
3286
3437
  }),
3438
+ ApproveCorrectionConfig.meta({
3439
+ id: "ApproveCorrectionActionConfig",
3440
+ description: "Configuration for approving a requested correction."
3441
+ }),
3442
+ RejectCorrectionConfig.meta({
3443
+ id: "RejectCorrectionActionConfig",
3444
+ description: "Configuration for rejecting a requested correction."
3445
+ }),
3287
3446
  EditActionConfig.meta({
3288
3447
  id: "EditActionConfig",
3289
3448
  description: "Configuration for editing a record before registration."
@@ -3445,6 +3604,9 @@ var BaseField3 = z28.object({
3445
3604
  ),
3446
3605
  validations: z28.array(ValidationConfig).optional().describe(
3447
3606
  `Option for overriding the field validations specifically for advanced search form.`
3607
+ ),
3608
+ allowedLocations: JurisdictionReference.optional().describe(
3609
+ `Override the allowedLocations for a location field in advanced search. Use this when the declaration form's allowedLocations references a scope (e.g. record.create) that search-only users don't have \u2014 specify record.search scope instead.`
3448
3610
  )
3449
3611
  });
3450
3612
  var SearchQueryParams = z28.object({
@@ -3519,9 +3681,11 @@ var z30 = __toESM(require("zod/v4"));
3519
3681
  var z29 = __toESM(require("zod/v4"));
3520
3682
  function getDynamicNameValue(field3) {
3521
3683
  const nameConfiguration = field3.configuration?.name;
3684
+ const firstnameRequired = nameConfiguration?.firstname?.required ?? field3.required;
3685
+ const surnameRequired = nameConfiguration?.surname?.required ?? field3.required;
3522
3686
  return z29.object({
3523
- firstname: nameConfiguration?.firstname?.required ? NonEmptyTextValue : TextValue,
3524
- surname: nameConfiguration?.surname?.required ? NonEmptyTextValue : TextValue,
3687
+ firstname: firstnameRequired ? NonEmptyTextValue : TextValue,
3688
+ surname: surnameRequired ? NonEmptyTextValue : TextValue,
3525
3689
  middlename: nameConfiguration?.middlename?.required ? NonEmptyTextValue : TextValue.optional()
3526
3690
  });
3527
3691
  }
@@ -3868,7 +4032,7 @@ var isHiddenFieldType = (field3) => {
3868
4032
  return field3.config.type === FieldType.ALPHA_HIDDEN;
3869
4033
  };
3870
4034
  var isNonInteractiveFieldType = (field3) => {
3871
- return field3.type === FieldType.DIVIDER || field3.type === FieldType.PAGE_HEADER || field3.type === FieldType.PARAGRAPH || field3.type === FieldType.HEADING || field3.type === FieldType.BULLET_LIST || field3.type === FieldType.DATA || field3.type === FieldType.ALPHA_PRINT_BUTTON || field3.type === FieldType.HTTP || field3.type === FieldType.LINK_BUTTON || field3.type === FieldType.QUERY_PARAM_READER || field3.type === FieldType.LOADER;
4035
+ return field3.type === FieldType.DIVIDER || field3.type === FieldType.PAGE_HEADER || field3.type === FieldType.PARAGRAPH || field3.type === FieldType.HEADING || field3.type === FieldType.BULLET_LIST || field3.type === FieldType.DATA || field3.type === FieldType.ALPHA_PRINT_BUTTON || field3.type === FieldType.LINK_BUTTON || field3.type === FieldType.LOADER;
3872
4036
  };
3873
4037
 
3874
4038
  // ../commons/src/conditionals/validate.ts
@@ -3904,7 +4068,37 @@ function resolveDataPath(rootData, dataPath, instancePath) {
3904
4068
  }
3905
4069
  return current;
3906
4070
  }
4071
+ function todayISO() {
4072
+ return (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" });
4073
+ }
4074
+ var compiledFunctionCache = /* @__PURE__ */ new Map();
4075
+ function compileClientFunction(code) {
4076
+ let fn = compiledFunctionCache.get(code);
4077
+ if (!fn) {
4078
+ fn = new Function(`return (${code})`)();
4079
+ compiledFunctionCache.set(code, fn);
4080
+ }
4081
+ return fn;
4082
+ }
3907
4083
  (0, import_ajv_formats.default)(ajv);
4084
+ function buildClientFunctionContext(input) {
4085
+ return {
4086
+ $form: input.form,
4087
+ $now: todayISO(),
4088
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
4089
+ $online: isOnline(),
4090
+ $user: input.validatorContext?.user,
4091
+ $event: input.validatorContext?.event,
4092
+ $leafAdminStructureLocationIds: input.validatorContext?.leafAdminStructureLocationIds ?? [],
4093
+ user: input.systemVariables?.user,
4094
+ $window: input.systemVariables?.$window,
4095
+ locations: input.locations,
4096
+ adminLevelIds: input.adminLevelIds
4097
+ };
4098
+ }
4099
+ function runClientFunction(code, data, context) {
4100
+ return compileClientFunction(code)(data, context);
4101
+ }
3908
4102
  ajv.addKeyword({
3909
4103
  keyword: "daysFromDate",
3910
4104
  type: "string",
@@ -3949,7 +4143,7 @@ ajv.addKeyword({
3949
4143
  $data: true,
3950
4144
  errors: true,
3951
4145
  // @ts-ignore -- Force type. We will move this away from AJV next. Parsing the array will take seconds and is only called by core.
3952
- validate(schema, data, _2, dataContext) {
4146
+ validate(_schema, data, _2, dataContext) {
3953
4147
  const locationIdInput = data;
3954
4148
  const locations = dataContext?.rootData.$leafAdminStructureLocationIds ?? [];
3955
4149
  return locations.some((location) => location.id === locationIdInput);
@@ -3980,6 +4174,23 @@ function isAgeValue(value) {
3980
4174
  function mergeWithBaseFormState(values, context) {
3981
4175
  return { ...context.baseFormState, ...values };
3982
4176
  }
4177
+ ajv.addKeyword({
4178
+ keyword: "customClientValidator",
4179
+ schemaType: "object",
4180
+ errors: true,
4181
+ // @ts-expect-error -- AJV's public types don't expose `rootData`. All
4182
+ // `validate()` callers build root data via `buildClientFunctionContext`,
4183
+ // so the cast holds.
4184
+ validate(schema, data, _2, dataContext) {
4185
+ return Boolean(
4186
+ runClientFunction(
4187
+ schema.code,
4188
+ data,
4189
+ dataContext?.rootData ?? buildClientFunctionContext({ form: {} })
4190
+ )
4191
+ );
4192
+ }
4193
+ });
3983
4194
  function validate(schema, data) {
3984
4195
  const validator = ajv.getSchema(schema.$id) || ajv.compile(schema);
3985
4196
  if ("$form" in data) {
@@ -4016,17 +4227,14 @@ function isOnline() {
4016
4227
  }
4017
4228
  return true;
4018
4229
  }
4019
- function isConditionMet(conditional, values, context, eventIndex) {
4020
- return validate(conditional, {
4021
- $form: mergeWithBaseFormState(values, context),
4022
- $now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" }),
4023
- $online: isOnline(),
4024
- $user: context.user,
4025
- $leafAdminStructureLocationIds: context.leafAdminStructureLocationIds ?? [],
4026
- $flags: eventIndex?.flags ?? [],
4027
- $status: eventIndex?.status,
4028
- $event: context.event
4029
- });
4230
+ function isConditionMet(conditional, values, context) {
4231
+ return validate(
4232
+ conditional,
4233
+ buildClientFunctionContext({
4234
+ form: mergeWithBaseFormState(values, context),
4235
+ validatorContext: context
4236
+ })
4237
+ );
4030
4238
  }
4031
4239
  function getConditionalActionsForField(field3, values) {
4032
4240
  if (!field3.conditionals) {
@@ -4034,9 +4242,9 @@ function getConditionalActionsForField(field3, values) {
4034
4242
  }
4035
4243
  return field3.conditionals.filter((conditional) => validate(conditional.conditional, values)).map((conditional) => conditional.type);
4036
4244
  }
4037
- function areConditionsMet(conditions, values, context, event2) {
4245
+ function areConditionsMet(conditions, values, context, _event) {
4038
4246
  return conditions.every(
4039
- (condition) => isConditionMet(condition.conditional, values, context, event2)
4247
+ (condition) => isConditionMet(condition.conditional, values, context)
4040
4248
  );
4041
4249
  }
4042
4250
  function isFieldConditionMet(field3, form, conditionalType, context) {
@@ -4046,14 +4254,13 @@ function isFieldConditionMet(field3, form, conditionalType, context) {
4046
4254
  if (!hasRule) {
4047
4255
  return true;
4048
4256
  }
4049
- const validConditionals = getConditionalActionsForField(field3, {
4050
- $form: mergeWithBaseFormState(form, context),
4051
- $now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" }),
4052
- $online: isOnline(),
4053
- $user: context.user,
4054
- $leafAdminStructureLocationIds: context.leafAdminStructureLocationIds ?? [],
4055
- $event: context.event
4056
- });
4257
+ const validConditionals = getConditionalActionsForField(
4258
+ field3,
4259
+ buildClientFunctionContext({
4260
+ form: mergeWithBaseFormState(form, context),
4261
+ validatorContext: context
4262
+ })
4263
+ );
4057
4264
  return validConditionals.includes(conditionalType);
4058
4265
  }
4059
4266
  function isFieldVisible(field3, form, context) {
@@ -4079,7 +4286,14 @@ function isActionConditionMet(actionConfig, event2, context, conditionalType) {
4079
4286
  if (!rule) {
4080
4287
  return true;
4081
4288
  }
4082
- return isConditionMet(rule.conditional, event2.declaration, context, event2);
4289
+ return validate(rule.conditional, {
4290
+ ...buildClientFunctionContext({
4291
+ form: mergeWithBaseFormState(event2.declaration, context),
4292
+ validatorContext: context
4293
+ }),
4294
+ $flags: event2.flags,
4295
+ $status: event2.status
4296
+ });
4083
4297
  }
4084
4298
  function isActionEnabled(actionConfig, event2, context) {
4085
4299
  return isActionConditionMet(
@@ -4238,19 +4452,10 @@ function runFieldValidations({
4238
4452
  if (!isFieldVisible(field3.config, form, context)) {
4239
4453
  return [];
4240
4454
  }
4241
- const conditionalParameters = {
4242
- $form: mergeWithBaseFormState(form, context),
4243
- $now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" }),
4244
- /**
4245
- * In real use cases, there can be hundreds of thousands of locations.
4246
- * Make sure that the context contains only the locations that are needed for validation.
4247
- * E.g. if the user is a leaf admin, only the leaf locations under their admin structure are needed.
4248
- * Loading few megabytes of locations to memory just for validation is not efficient and will choke the application.
4249
- */
4250
- $leafAdminStructureLocationIds: context.leafAdminStructureLocationIds ?? [],
4251
- $online: isOnline(),
4252
- $user: context.user
4253
- };
4455
+ const conditionalParameters = buildClientFunctionContext({
4456
+ form: mergeWithBaseFormState(form, context),
4457
+ validatorContext: context
4458
+ });
4254
4459
  if (isFieldGroupFieldType(field3)) {
4255
4460
  const subfieldErrors = buildFormState(
4256
4461
  field3.config.fields,
@@ -4389,16 +4594,13 @@ function getActionConfig({
4389
4594
  actionType,
4390
4595
  customActionType
4391
4596
  }) {
4597
+ if (actionType === ActionType.NOTIFY) {
4598
+ return eventConfiguration.actions.find((a) => a.type === ActionType.NOTIFY) ?? eventConfiguration.actions.find((a) => a.type === ActionType.DECLARE);
4599
+ }
4392
4600
  return eventConfiguration.actions.find((a) => {
4393
4601
  if (a.type === ActionType.CUSTOM && customActionType) {
4394
4602
  return a.customActionType === customActionType;
4395
4603
  }
4396
- if (actionType === ActionType.NOTIFY) {
4397
- return a.type === ActionType.DECLARE;
4398
- }
4399
- if (actionType === ActionType.APPROVE_CORRECTION || actionType === ActionType.REJECT_CORRECTION) {
4400
- return a.type === ActionType.REQUEST_CORRECTION;
4401
- }
4402
4604
  return a.type === actionType;
4403
4605
  });
4404
4606
  }
@@ -4408,7 +4610,19 @@ function getCustomActionFields(eventConfiguration, customActionType) {
4408
4610
  customActionType,
4409
4611
  actionType: ActionType.CUSTOM
4410
4612
  });
4411
- if (!actionConfig || !("form" in actionConfig)) {
4613
+ if (!actionConfig || actionConfig.type !== ActionType.CUSTOM) {
4614
+ return [];
4615
+ }
4616
+ return actionConfig.form;
4617
+ }
4618
+ function getActionFormFields(eventConfiguration, actionType, customActionType) {
4619
+ const actionConfig = eventConfiguration.actions.find((a) => {
4620
+ if (a.type === ActionType.CUSTOM && customActionType) {
4621
+ return a.customActionType === customActionType;
4622
+ }
4623
+ return a.type === actionType;
4624
+ });
4625
+ if (!actionConfig || !("form" in actionConfig) || actionConfig.form == null) {
4412
4626
  return [];
4413
4627
  }
4414
4628
  return actionConfig.form;
@@ -4429,13 +4643,9 @@ var getActionAnnotationFields = (actionConfig) => {
4429
4643
  if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
4430
4644
  return actionConfig.printForm.pages.flatMap(({ fields }) => fields);
4431
4645
  }
4432
- if (actionConfig.type === ActionType.CUSTOM) {
4433
- return actionConfig.form;
4434
- }
4435
- if ("review" in actionConfig) {
4436
- return actionConfig.review.fields;
4437
- }
4438
- return [];
4646
+ const reviewFields = "review" in actionConfig && actionConfig.review != null ? actionConfig.review.fields : [];
4647
+ const formFields = "form" in actionConfig && actionConfig.form != null ? actionConfig.form : [];
4648
+ return [...reviewFields, ...formFields];
4439
4649
  };
4440
4650
  function getAllAnnotationFields(config) {
4441
4651
  return (0, import_lodash.flattenDeep)(config.actions.map(getActionAnnotationFields));
@@ -4734,19 +4944,32 @@ function getPendingAction(actions) {
4734
4944
  }
4735
4945
  return pendingActions[0];
4736
4946
  }
4737
- function getCompleteActionAnnotation(annotation, event2, action) {
4947
+ function getCompleteActionAnnotation(event2, action) {
4738
4948
  if (action.originalActionId) {
4739
4949
  const originalAction = event2.actions.find(
4740
4950
  ({ id }) => id === action.originalActionId
4741
4951
  );
4742
4952
  if (originalAction?.status === ActionStatus.Requested) {
4743
- return deepMerge(
4744
- deepMerge(annotation, originalAction.annotation ?? {}),
4745
- action.annotation ?? {}
4746
- );
4953
+ return deepMerge(originalAction.annotation ?? {}, action.annotation ?? {});
4747
4954
  }
4748
4955
  }
4749
- return deepMerge(annotation, action.annotation ?? {});
4956
+ return action.annotation ?? {};
4957
+ }
4958
+ function getCompleteActionContent(event2, action) {
4959
+ const currentContent = "content" in action ? action.content : void 0;
4960
+ if (!action.originalActionId) {
4961
+ return currentContent;
4962
+ }
4963
+ const originalAction = event2.actions.find(
4964
+ ({ id }) => id === action.originalActionId
4965
+ );
4966
+ if (originalAction && "content" in originalAction && originalAction.content) {
4967
+ return {
4968
+ ...originalAction.content,
4969
+ ...currentContent ?? {}
4970
+ };
4971
+ }
4972
+ return currentContent;
4750
4973
  }
4751
4974
  function getCompleteActionDeclaration(declaration, event2, action) {
4752
4975
  if (action.originalActionId) {
@@ -4766,7 +4989,7 @@ function getAcceptedActions(event2) {
4766
4989
  return event2.actions.filter(isAcceptedAction).map((action) => ({
4767
4990
  ...action,
4768
4991
  declaration: getCompleteActionDeclaration({}, event2, action),
4769
- annotation: getCompleteActionAnnotation({}, event2, action)
4992
+ annotation: getCompleteActionAnnotation(event2, action)
4770
4993
  }));
4771
4994
  }
4772
4995
  var EXCLUDED_ACTIONS = [
@@ -4854,6 +5077,9 @@ function not(condition) {
4854
5077
  function never2() {
4855
5078
  return not(alwaysTrue());
4856
5079
  }
5080
+ function always() {
5081
+ return defineConditional(alwaysTrue());
5082
+ }
4857
5083
  function jsonFieldPath(field3) {
4858
5084
  return [field3.$$field, ...field3.$$subfield].join("/");
4859
5085
  }
@@ -5401,7 +5627,54 @@ function createFieldConditionals(fieldId) {
5401
5627
  }
5402
5628
  },
5403
5629
  required: [fieldId]
5404
- })
5630
+ }),
5631
+ /**
5632
+ * Custom client-side validator. The provided function is serialised and executed
5633
+ * just-in-time on the client only. External references (e.g. lodash) are not
5634
+ * available inside the function body — all logic must be self-contained.
5635
+ *
5636
+ * @example
5637
+ * field('nid').customClientValidator((value) => {
5638
+ * // LUHN check — all logic must be inline
5639
+ * const digits = String(value).split('').map(Number)
5640
+ * // ...
5641
+ * return isValid
5642
+ * })
5643
+ */
5644
+ customClientValidator(validationFn) {
5645
+ const code = validationFn.toString();
5646
+ return defineFormConditional({
5647
+ type: "object",
5648
+ properties: wrapToPath(
5649
+ { [fieldId]: { customClientValidator: { code } } },
5650
+ this.$$subfield
5651
+ ),
5652
+ required: [fieldId]
5653
+ });
5654
+ },
5655
+ /**
5656
+ * Custom client-side evaluation. Returns a {@link FieldReference} descriptor
5657
+ * that can be used as the `value` property or a DATA component entry.
5658
+ * The function receives the referenced field's value as the first argument and
5659
+ * the full form context as the second; its return value replaces the field reference.
5660
+ * The function is serialised and executed just-in-time on the client only.
5661
+ * External references (e.g. lodash) are not available inside the function body.
5662
+ *
5663
+ * For computing a default value without referencing a specific field, use
5664
+ * `evaluate(fn)` in the `defaultValue` property instead.
5665
+ *
5666
+ * @example
5667
+ * field('a').customClientEvaluation((aValue, ctx) =>
5668
+ * Number(aValue) + Number(ctx.$form.b)
5669
+ * )
5670
+ */
5671
+ customClientEvaluation(computationFn) {
5672
+ return {
5673
+ $$code: computationFn.toString(),
5674
+ $$field: fieldId,
5675
+ $$subfield: this.$$subfield
5676
+ };
5677
+ }
5405
5678
  };
5406
5679
  }
5407
5680
 
@@ -5489,7 +5762,7 @@ function validateActionFlags(event2, ctx) {
5489
5762
  const isInherentFlag = (value) => Object.values(InherentFlags).includes(value);
5490
5763
  const configuredFlagIds = event2.flags.map((flag2) => flag2.id);
5491
5764
  const actionFlagIds = event2.actions.flatMap(
5492
- (action) => action.flags.map((flag2) => flag2.id)
5765
+ (action) => (action.flags ?? []).map((flag2) => flag2.id)
5493
5766
  );
5494
5767
  for (const actionFlagId of actionFlagIds) {
5495
5768
  const isConfigured = configuredFlagIds.includes(actionFlagId);
@@ -6191,7 +6464,8 @@ var RejectCorrectionActionInput = BaseActionInput.extend(
6191
6464
  var ApproveCorrectionActionInput = BaseActionInput.extend(
6192
6465
  z38.object({
6193
6466
  requestId: z38.string(),
6194
- type: z38.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
6467
+ type: z38.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION),
6468
+ content: z38.object({ immediateCorrection: z38.boolean().optional() }).optional()
6195
6469
  }).shape
6196
6470
  );
6197
6471
  var ReadActionInput = BaseActionInput.extend(
@@ -6340,6 +6614,8 @@ var updateActions = ActionTypes.extract([
6340
6614
  ActionType.ARCHIVE,
6341
6615
  ActionType.PRINT_CERTIFICATE,
6342
6616
  ActionType.REQUEST_CORRECTION,
6617
+ ActionType.APPROVE_CORRECTION,
6618
+ ActionType.REJECT_CORRECTION,
6343
6619
  ActionType.CUSTOM
6344
6620
  ]);
6345
6621
  function getActionUpdateMetadata(actions) {
@@ -6354,7 +6630,7 @@ function getActionUpdateMetadata(actions) {
6354
6630
  "createdAtLocation",
6355
6631
  "createdByRole"
6356
6632
  ];
6357
- return actions.filter(({ type }) => updateActions.safeParse(type).success).filter(({ status: status2 }) => status2 === ActionStatus.Accepted).reduce(
6633
+ return actions.filter(({ type }) => updateActions.safeParse(type).success).reduce(
6358
6634
  (_2, action) => {
6359
6635
  if (action.originalActionId) {
6360
6636
  const originalAction = actions.find(({ id }) => id === action.originalActionId) ?? action;
@@ -6367,6 +6643,10 @@ function getActionUpdateMetadata(actions) {
6367
6643
  }
6368
6644
  function getLegalStatuses(actions) {
6369
6645
  return {
6646
+ [EventStatus.enum.NOTIFIED]: getDeclarationActionCreationMetadata(
6647
+ ActionType.NOTIFY,
6648
+ actions
6649
+ ),
6370
6650
  [EventStatus.enum.DECLARED]: getDeclarationActionCreationMetadata(
6371
6651
  ActionType.DECLARE,
6372
6652
  actions
@@ -6381,28 +6661,19 @@ function getLegalStatuses(actions) {
6381
6661
  // ../commons/src/events/state/flags.ts
6382
6662
  var import_lodash3 = require("lodash");
6383
6663
  var import_date_fns3 = require("date-fns");
6384
- function isEditInProgress(actions) {
6385
- return actions.at(-1)?.type === ActionType.EDIT;
6386
- }
6387
- function isCorrectionRequested(actions) {
6388
- return actions.reduce((prev, { type }) => {
6389
- if (type === ActionType.REQUEST_CORRECTION) {
6390
- return true;
6391
- }
6392
- if (type === ActionType.APPROVE_CORRECTION) {
6393
- return false;
6664
+ function findPendingCorrectionAction(writeActions2) {
6665
+ let correctionRequestAction;
6666
+ for (let i = writeActions2.length - 1; i >= 0; i--) {
6667
+ const action = writeActions2[i];
6668
+ if (action.type === ActionType.APPROVE_CORRECTION || action.type === ActionType.REJECT_CORRECTION) {
6669
+ break;
6394
6670
  }
6395
- if (type === ActionType.REJECT_CORRECTION) {
6396
- return false;
6671
+ if (action.type === ActionType.REQUEST_CORRECTION) {
6672
+ correctionRequestAction = action;
6673
+ break;
6397
6674
  }
6398
- return prev;
6399
- }, false);
6400
- }
6401
- function isDeclarationIncomplete(actions) {
6402
- return getStatusFromActions(actions) === EventStatus.enum.NOTIFIED;
6403
- }
6404
- function isRejected(actions) {
6405
- return actions.at(-1)?.type === ActionType.REJECT;
6675
+ }
6676
+ return correctionRequestAction;
6406
6677
  }
6407
6678
  function isPotentialDuplicate(actions) {
6408
6679
  return actions.reduce((prev, { type }) => {
@@ -6431,6 +6702,88 @@ function isFlagConditionMet(conditional, form, action) {
6431
6702
  }
6432
6703
  });
6433
6704
  }
6705
+ function actionConfigRemovesFlag(action, flagId, actionsUpToAndIncluding, event2, eventConfiguration) {
6706
+ if (!isActionConfigType(action.type)) {
6707
+ return false;
6708
+ }
6709
+ const actionConfig = getActionConfig({
6710
+ eventConfiguration,
6711
+ actionType: action.type,
6712
+ customActionType: "customActionType" in action ? action.customActionType : void 0
6713
+ });
6714
+ const removeOperations = (actionConfig?.flags ?? []).filter(
6715
+ ({ id, operation }) => id === flagId && operation === "remove"
6716
+ );
6717
+ if (removeOperations.length === 0) {
6718
+ return false;
6719
+ }
6720
+ const eventUpToThisAction = { ...event2, actions: actionsUpToAndIncluding };
6721
+ const declaration = aggregateActionDeclarations(eventUpToThisAction);
6722
+ const annotation = aggregateActionAnnotations(eventUpToThisAction);
6723
+ const form = { ...declaration, ...annotation };
6724
+ return removeOperations.some(
6725
+ ({ conditional }) => conditional ? isFlagConditionMet(conditional, form, action) : true
6726
+ );
6727
+ }
6728
+ var INHERENT_FLAG_RULES = [
6729
+ {
6730
+ flag: InherentFlags.CORRECTION_REQUESTED,
6731
+ setOn: [ActionType.REQUEST_CORRECTION],
6732
+ resetOn: [ActionType.APPROVE_CORRECTION, ActionType.REJECT_CORRECTION]
6733
+ },
6734
+ {
6735
+ // INCOMPLETE mirrors the NOTIFIED status: set by NOTIFY, cleared by any
6736
+ // other status-changing action (see getStatusFromActions).
6737
+ flag: InherentFlags.INCOMPLETE,
6738
+ setOn: [ActionType.NOTIFY],
6739
+ resetOn: [
6740
+ ActionType.CREATE,
6741
+ ActionType.DECLARE,
6742
+ ActionType.REGISTER,
6743
+ ActionType.ARCHIVE
6744
+ ]
6745
+ },
6746
+ {
6747
+ flag: InherentFlags.REJECTED,
6748
+ setOn: [ActionType.REJECT],
6749
+ resetOn: [
6750
+ ActionType.NOTIFY,
6751
+ ActionType.DECLARE,
6752
+ ActionType.EDIT,
6753
+ ActionType.REGISTER
6754
+ ]
6755
+ },
6756
+ {
6757
+ flag: InherentFlags.POTENTIAL_DUPLICATE,
6758
+ setOn: [ActionType.DUPLICATE_DETECTED],
6759
+ resetOn: [ActionType.MARK_AS_DUPLICATE, ActionType.MARK_AS_NOT_DUPLICATE]
6760
+ },
6761
+ {
6762
+ flag: InherentFlags.EDIT_IN_PROGRESS,
6763
+ setOn: [ActionType.EDIT],
6764
+ resetOnAnyOtherAction: true
6765
+ }
6766
+ ];
6767
+ function resolveInherentFlag(rule, acceptedActions, event2, eventConfiguration) {
6768
+ return acceptedActions.reduce((present, action, idx) => {
6769
+ if (rule.setOn.includes(action.type)) {
6770
+ return true;
6771
+ }
6772
+ if (rule.resetOnAnyOtherAction || (rule.resetOn ?? []).includes(action.type)) {
6773
+ return false;
6774
+ }
6775
+ if (actionConfigRemovesFlag(
6776
+ action,
6777
+ rule.flag,
6778
+ acceptedActions.slice(0, idx + 1),
6779
+ event2,
6780
+ eventConfiguration
6781
+ )) {
6782
+ return false;
6783
+ }
6784
+ return present;
6785
+ }, false);
6786
+ }
6434
6787
  function resolveEventCustomFlags(event2, eventConfiguration) {
6435
6788
  const actions = getAcceptedActions(event2).filter(({ type }) => !isMetaAction(type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
6436
6789
  return actions.reduce((acc, action, idx) => {
@@ -6452,7 +6805,7 @@ function resolveEventCustomFlags(event2, eventConfiguration) {
6452
6805
  const declaration = aggregateActionDeclarations(eventUpToThisAction);
6453
6806
  const annotation = aggregateActionAnnotations(eventUpToThisAction);
6454
6807
  const form = { ...declaration, ...annotation };
6455
- const flagsWithMetConditions = actionConfig.flags.filter(
6808
+ const flagsWithMetConditions = (actionConfig.flags ?? []).filter(
6456
6809
  ({ conditional }) => (
6457
6810
  // If conditional is not provided, the flag is resolved
6458
6811
  conditional ? isFlagConditionMet(conditional, form, action) : true
@@ -6466,8 +6819,7 @@ function resolveEventCustomFlags(event2, eventConfiguration) {
6466
6819
  return (0, import_lodash3.uniq)(flags);
6467
6820
  }, []);
6468
6821
  }
6469
- function getEventFlags(event2, config) {
6470
- const sortedActions = event2.actions.filter(({ type }) => !isMetaAction(type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
6822
+ function getActionStatusFlags(sortedActions) {
6471
6823
  const actionStatus = sortedActions.reduce(
6472
6824
  (actionStatuses, { type, status: status2 }) => ({
6473
6825
  ...actionStatuses,
@@ -6475,26 +6827,26 @@ function getEventFlags(event2, config) {
6475
6827
  }),
6476
6828
  {}
6477
6829
  );
6478
- const flags = Object.entries(actionStatus).filter(([, status2]) => status2 !== ActionStatus.Accepted).map(([type, status2]) => {
6830
+ return Object.entries(actionStatus).filter(([, status2]) => status2 !== ActionStatus.Accepted).map(([type, status2]) => {
6479
6831
  const flag2 = joinValues([type, status2], ":").toLowerCase();
6480
6832
  return flag2;
6481
6833
  });
6482
- if (isCorrectionRequested(sortedActions)) {
6483
- flags.push(InherentFlags.CORRECTION_REQUESTED);
6484
- }
6485
- if (isDeclarationIncomplete(sortedActions)) {
6486
- flags.push(InherentFlags.INCOMPLETE);
6487
- }
6488
- if (isRejected(sortedActions)) {
6489
- flags.push(InherentFlags.REJECTED);
6490
- }
6491
- if (isPotentialDuplicate(sortedActions)) {
6492
- flags.push(InherentFlags.POTENTIAL_DUPLICATE);
6493
- }
6494
- if (isEditInProgress(sortedActions)) {
6495
- flags.push(InherentFlags.EDIT_IN_PROGRESS);
6496
- }
6497
- return [...flags, ...resolveEventCustomFlags(event2, config)];
6834
+ }
6835
+ function getInherentFlags(sortedActions, event2, eventConfiguration) {
6836
+ const acceptedActions = sortedActions.filter(
6837
+ ({ status: status2 }) => status2 === ActionStatus.Accepted
6838
+ );
6839
+ return INHERENT_FLAG_RULES.filter(
6840
+ (rule) => resolveInherentFlag(rule, acceptedActions, event2, eventConfiguration)
6841
+ ).map(({ flag: flag2 }) => flag2);
6842
+ }
6843
+ function getEventFlags(event2, config) {
6844
+ const sortedActions = event2.actions.filter(({ type }) => !isMetaAction(type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
6845
+ return [
6846
+ ...getActionStatusFlags(sortedActions),
6847
+ ...getInherentFlags(sortedActions, event2, config),
6848
+ ...resolveEventCustomFlags(event2, config)
6849
+ ];
6498
6850
  }
6499
6851
 
6500
6852
  // ../commons/src/events/state/index.ts
@@ -6729,7 +7081,7 @@ function getActionAnnotation({
6729
7081
  const action = (0, import_lodash4.findLast)(activeActions, (a) => a.type === actionType);
6730
7082
  const actionWithCompleteAnnotation = action && {
6731
7083
  ...action,
6732
- annotation: getCompleteActionAnnotation({}, event2, action)
7084
+ annotation: getCompleteActionAnnotation(event2, action)
6733
7085
  };
6734
7086
  const matchingDraft = draft?.action.type === actionType ? draft : void 0;
6735
7087
  const sortedActions = (0, import_lodash4.orderBy)(
@@ -6801,6 +7153,9 @@ function createFieldConfig(fieldId, options) {
6801
7153
  }
6802
7154
 
6803
7155
  // ../commons/src/events/field.ts
7156
+ function evaluate(computationFn) {
7157
+ return { $$code: computationFn.toString() };
7158
+ }
6804
7159
  function field(fieldId, options = {}) {
6805
7160
  return {
6806
7161
  ...createFieldConditionals(fieldId),
@@ -7494,6 +7849,11 @@ var TENNIS_CLUB_DECLARATION_REVIEW = {
7494
7849
  id: "signature.upload.modal.title",
7495
7850
  defaultMessage: "Draw signature",
7496
7851
  description: "Title for the modal to draw signature"
7852
+ },
7853
+ // Zod applies the schema default at parse time, but this fixture bypasses
7854
+ // parsing — GeneratedInputField accesses configuration.maxFileSize directly.
7855
+ configuration: {
7856
+ maxFileSize: 5 * 1024 * 1024
7497
7857
  }
7498
7858
  }
7499
7859
  ]
@@ -8050,6 +8410,20 @@ var tennisClubMembershipEvent = defineConfig({
8050
8410
  },
8051
8411
  review: TENNIS_CLUB_DECLARATION_REVIEW
8052
8412
  },
8413
+ {
8414
+ type: ActionType.NOTIFY,
8415
+ label: {
8416
+ defaultMessage: "Notify health worker",
8417
+ description: "This is shown as the action name anywhere the user can trigger the action from",
8418
+ id: "event.tennis-club-membership.action.notify.label"
8419
+ },
8420
+ flags: [
8421
+ {
8422
+ id: "health-worker-notified",
8423
+ operation: "add"
8424
+ }
8425
+ ]
8426
+ },
8053
8427
  {
8054
8428
  type: ActionType.REJECT,
8055
8429
  label: {
@@ -8292,6 +8666,17 @@ var tennisClubMembershipEvent = defineConfig({
8292
8666
  }
8293
8667
  }
8294
8668
  ],
8669
+ flags: [
8670
+ {
8671
+ id: "health-worker-notified",
8672
+ requiresAction: false,
8673
+ label: {
8674
+ id: "event.tennis-club-membership.flag.health-worker-notified.label",
8675
+ defaultMessage: "Health worker notified",
8676
+ description: "Label for the health-worker-notified flag"
8677
+ }
8678
+ }
8679
+ ],
8295
8680
  advancedSearch: [
8296
8681
  {
8297
8682
  title: {
@@ -10050,7 +10435,7 @@ function matchesJurisdictionFilter(locationIds, filter, user2) {
10050
10435
  return locationIds.some((id) => id === user2.primaryOfficeId);
10051
10436
  }
10052
10437
  if (filter === JurisdictionFilter.enum.administrativeArea) {
10053
- return user2.administrativeAreaId === null || locationIds.some((id) => id === user2.administrativeAreaId);
10438
+ return !user2.administrativeAreaId || locationIds.some((id) => id === user2.administrativeAreaId);
10054
10439
  }
10055
10440
  return true;
10056
10441
  }
@@ -10077,6 +10462,25 @@ function canAccessEventWithScope(event2, scope, user2, customActionType) {
10077
10462
  }
10078
10463
  if (scopeUsesDeclaredOptions(scope)) {
10079
10464
  const { options } = scope;
10465
+ if (options?.notifiedBy === UserFilter.enum.user) {
10466
+ if (event2.legalStatuses?.NOTIFIED?.createdBy !== user2.id) {
10467
+ return false;
10468
+ }
10469
+ }
10470
+ if (options?.notifiedIn === JurisdictionFilter.enum.location && !matchesJurisdictionFilter(
10471
+ event2.legalStatuses?.NOTIFIED?.createdAtLocation,
10472
+ JurisdictionFilter.enum.location,
10473
+ user2
10474
+ )) {
10475
+ return false;
10476
+ }
10477
+ if (options?.notifiedIn === JurisdictionFilter.enum.administrativeArea && !matchesJurisdictionFilter(
10478
+ event2.legalStatuses?.NOTIFIED?.createdAtLocation,
10479
+ JurisdictionFilter.enum.administrativeArea,
10480
+ user2
10481
+ )) {
10482
+ return false;
10483
+ }
10080
10484
  if (options?.declaredBy === UserFilter.enum.user) {
10081
10485
  if (event2.legalStatuses?.DECLARED?.createdBy !== user2.id) {
10082
10486
  return false;
@@ -10139,7 +10543,7 @@ function canAccessUserWithScope({
10139
10543
  }
10140
10544
  const hasAdministrativeAreaInHierarchy = userToAccess.administrativeHierarchy.some(
10141
10545
  (id) => user2.administrativeAreaId === id
10142
- ) || user2.administrativeAreaId === null;
10546
+ ) || !user2.administrativeAreaId;
10143
10547
  if (opts?.accessLevel === JurisdictionFilter.enum.administrativeArea && !hasAdministrativeAreaInHierarchy) {
10144
10548
  return false;
10145
10549
  }
@@ -10445,18 +10849,19 @@ var ACTION_FILTERS = {
10445
10849
  function filterActionsByFlags(actions, flags) {
10446
10850
  return actions.filter((action) => ACTION_FILTERS[action]?.(flags) ?? true);
10447
10851
  }
10852
+ var REJECTED_ACTIONS = [
10853
+ ActionType.READ,
10854
+ ActionType.NOTIFY,
10855
+ ActionType.CUSTOM,
10856
+ ActionType.EDIT,
10857
+ ActionType.ARCHIVE
10858
+ ];
10448
10859
  function getAvailableActionsWithoutFlagFilters(status2, flags) {
10449
10860
  if (flags.includes(InherentFlags.EDIT_IN_PROGRESS)) {
10450
10861
  return [ActionType.NOTIFY, ActionType.DECLARE, ActionType.REGISTER];
10451
10862
  }
10452
- if (flags.includes(InherentFlags.REJECTED)) {
10453
- return [
10454
- ActionType.READ,
10455
- ActionType.NOTIFY,
10456
- ActionType.CUSTOM,
10457
- ActionType.EDIT,
10458
- ActionType.ARCHIVE
10459
- ];
10863
+ if (flags.includes(InherentFlags.REJECTED) && status2 !== EventStatus.enum.ARCHIVED) {
10864
+ return REJECTED_ACTIONS;
10460
10865
  }
10461
10866
  return AVAILABLE_ACTIONS_BY_EVENT_STATUS[status2];
10462
10867
  }