@opencrvs/toolkit 1.9.11 → 1.9.12-rc.8753d72

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.
@@ -122,6 +122,7 @@ __export(events_exports, {
122
122
  FieldConditional: () => FieldConditional,
123
123
  FieldConfig: () => FieldConfig,
124
124
  FieldConfigSchema: () => FieldConfigSchema,
125
+ FieldGroupValue: () => FieldGroupValue,
125
126
  FieldReference: () => FieldReference,
126
127
  FieldType: () => FieldType,
127
128
  FieldTypesToHideInReview: () => FieldTypesToHideInReview,
@@ -226,6 +227,7 @@ __export(events_exports, {
226
227
  applyDraftToEventIndex: () => applyDraftToEventIndex,
227
228
  areCertificateConditionsMet: () => areCertificateConditionsMet,
228
229
  areConditionsMet: () => areConditionsMet,
230
+ buildFormState: () => buildFormState,
229
231
  canUserReadEvent: () => canUserReadEvent,
230
232
  compositeFieldTypes: () => compositeFieldTypes,
231
233
  configurableEventScopeAllowed: () => configurableEventScopeAllowed,
@@ -260,6 +262,8 @@ __export(events_exports, {
260
262
  findAllFields: () => findAllFields,
261
263
  findLastAssignmentAction: () => findLastAssignmentAction,
262
264
  findRecordActionPages: () => findRecordActionPages,
265
+ flattenFieldReference: () => flattenFieldReference,
266
+ flattenFormState: () => flattenFormState,
263
267
  generateActionDeclarationInput: () => generateActionDeclarationInput,
264
268
  generateActionDocument: () => generateActionDocument,
265
269
  generateActionDuplicateDeclarationInput: () => generateActionDuplicateDeclarationInput,
@@ -321,6 +325,7 @@ __export(events_exports, {
321
325
  isFieldConfigDefaultValue: () => isFieldConfigDefaultValue,
322
326
  isFieldDisplayedOnReview: () => isFieldDisplayedOnReview,
323
327
  isFieldEnabled: () => isFieldEnabled,
328
+ isFieldGroupFieldType: () => isFieldGroupFieldType,
324
329
  isFieldReference: () => isFieldReference,
325
330
  isFieldValue: () => isFieldValue,
326
331
  isFieldValueWithoutTemplates: () => isFieldValueWithoutTemplates,
@@ -363,6 +368,7 @@ __export(events_exports, {
363
368
  mandatoryColumns: () => mandatoryColumns,
364
369
  mapFieldTypeToEmptyValue: () => mapFieldTypeToEmptyValue,
365
370
  mapFieldTypeToZod: () => mapFieldTypeToZod,
371
+ mapFormState: () => mapFormState,
366
372
  mergeDrafts: () => mergeDrafts,
367
373
  never: () => never,
368
374
  not: () => not,
@@ -588,6 +594,7 @@ var FieldType = {
588
594
  PARAGRAPH: "PARAGRAPH",
589
595
  PAGE_HEADER: "PAGE_HEADER",
590
596
  RADIO_GROUP: "RADIO_GROUP",
597
+ FIELD_GROUP: "FIELD_GROUP",
591
598
  FILE: "FILE",
592
599
  FILE_WITH_OPTIONS: "FILE_WITH_OPTIONS",
593
600
  BULLET_LIST: "BULLET_LIST",
@@ -794,7 +801,7 @@ var VerificationStatusValue = import_zod8.z.enum([
794
801
  "failed",
795
802
  "pending"
796
803
  ]);
797
- var FieldValuesWithoutDataField = import_zod8.z.union([
804
+ var LeafFieldValues = import_zod8.z.union([
798
805
  AddressFieldValue,
799
806
  TextValue,
800
807
  PlainDate,
@@ -817,12 +824,15 @@ var FieldValuesWithoutDataField = import_zod8.z.union([
817
824
  NumberWithUnitFieldValue,
818
825
  NumberWithUnitFieldUpdateValue
819
826
  ]);
827
+ var FieldGroupValue = import_zod8.z.record(import_zod8.z.string(), LeafFieldValues);
820
828
  var DataFieldValue = import_zod8.z.object({
821
- data: import_zod8.z.record(import_zod8.z.string(), FieldValuesWithoutDataField)
829
+ data: import_zod8.z.record(import_zod8.z.string(), LeafFieldValues)
822
830
  }).nullish();
823
- var FieldValue = import_zod8.z.union(
824
- [FieldValuesWithoutDataField, DataFieldValue]
825
- );
831
+ var FieldValue = import_zod8.z.union([
832
+ LeafFieldValues,
833
+ DataFieldValue,
834
+ FieldGroupValue
835
+ ]);
826
836
  var PRIORITY_ORDER = [
827
837
  "NameFieldUpdateValue",
828
838
  "DateRangeFieldValue",
@@ -837,7 +847,8 @@ var PRIORITY_ORDER = [
837
847
  "NumberWithUnitFieldUpdateValue",
838
848
  "FileFieldValue",
839
849
  "FileFieldWithOptionValue",
840
- "DataFieldValue"
850
+ "DataFieldValue",
851
+ "GroupFieldValue"
841
852
  ];
842
853
  function schemaPriority(schema) {
843
854
  const name = schema._def?.description;
@@ -872,6 +883,7 @@ var FieldUpdateValue = safeUnion([
872
883
  FileFieldValue.describe("FileFieldValue"),
873
884
  FileFieldWithOptionValue.describe("FileFieldWithOptionValue"),
874
885
  DataFieldValue.describe("DataFieldValue"),
886
+ FieldGroupValue.describe("GroupFieldValue"),
875
887
  NameFieldUpdateValue.describe("NameFieldUpdateValue"),
876
888
  HttpFieldUpdateValue.describe("HttpFieldUpdateValue"),
877
889
  QueryParamReaderFieldUpdateValue.describe("QueryParamReaderFieldUpdateValue")
@@ -2281,14 +2293,12 @@ var AdministrativeAreas = import_zod17.z.enum([
2281
2293
  "CRVS_OFFICE"
2282
2294
  ]);
2283
2295
  var AdministrativeAreaConfiguration = import_zod17.z.object({
2284
- partOf: import_zod17.z.object({
2285
- $declaration: import_zod17.z.string()
2286
- }).optional().describe("Parent location"),
2296
+ partOf: FieldReference.optional(),
2287
2297
  type: AdministrativeAreas
2288
2298
  }).describe("Administrative area options");
2289
2299
  var AdministrativeArea = BaseField.extend({
2290
2300
  type: import_zod17.z.literal(FieldType.ADMINISTRATIVE_AREA),
2291
- defaultValue: NonEmptyTextValue.optional(),
2301
+ defaultValue: import_zod17.z.union([NonEmptyTextValue, SerializedUserField]).optional(),
2292
2302
  configuration: AdministrativeAreaConfiguration
2293
2303
  }).describe("Administrative area input field e.g. facility, office");
2294
2304
  var LocationInput = BaseField.extend({
@@ -2368,6 +2378,11 @@ var ButtonField = BaseField.extend({
2368
2378
  text: TranslationConfig.describe("Text to display on the button")
2369
2379
  })
2370
2380
  }).describe("Generic button without any built-in functionality");
2381
+ var FieldGroup = BaseField.extend({
2382
+ type: import_zod17.z.literal(FieldType.FIELD_GROUP),
2383
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
2384
+ fields: import_zod17.z.lazy(() => import_zod17.z.array(FieldConfig))
2385
+ });
2371
2386
  var AlphaPrintButton = BaseField.extend({
2372
2387
  type: import_zod17.z.literal(FieldType.ALPHA_PRINT_BUTTON),
2373
2388
  configuration: import_zod17.z.object({
@@ -2475,6 +2490,7 @@ var LoaderField = BaseField.extend({
2475
2490
  "A non-interactive field that indicates an in progress operation in form"
2476
2491
  );
2477
2492
  var FieldConfig = import_zod17.z.discriminatedUnion("type", [
2493
+ FieldGroup,
2478
2494
  Address,
2479
2495
  TextField,
2480
2496
  NumberField,
@@ -2822,7 +2838,7 @@ var LanguageConfig = import_zod23.z.object({
2822
2838
  });
2823
2839
 
2824
2840
  // ../commons/src/events/EventConfig.ts
2825
- var import_zod28 = require("zod");
2841
+ var import_zod29 = require("zod");
2826
2842
 
2827
2843
  // ../commons/src/events/SummaryConfig.ts
2828
2844
  var import_zod24 = require("zod");
@@ -2979,9 +2995,12 @@ var import_lodash = require("lodash");
2979
2995
  // ../commons/src/conditionals/validate.ts
2980
2996
  var import__ = __toESM(require("ajv/dist/2019"));
2981
2997
  var import_ajv_formats = __toESM(require("ajv-formats"));
2982
- var import_zod27 = require("zod");
2998
+ var import_zod28 = require("zod");
2983
2999
  var import_date_fns = require("date-fns");
2984
3000
 
3001
+ // ../commons/src/events/FieldTypeMapping.ts
3002
+ var import_zod27 = require("zod");
3003
+
2985
3004
  // ../commons/src/events/DynamicFieldValue.ts
2986
3005
  var import_zod26 = require("zod");
2987
3006
  function getDynamicNameValue(field3) {
@@ -3013,6 +3032,15 @@ function getDynamicAddressFieldValue(field3) {
3013
3032
  function mapFieldTypeToZod(field3, actionType) {
3014
3033
  let schema;
3015
3034
  switch (field3.type) {
3035
+ case FieldType.FIELD_GROUP: {
3036
+ schema = import_zod27.z.object(
3037
+ field3.fields.reduce((acc, subfield) => {
3038
+ acc[subfield.id] = mapFieldTypeToZod(subfield, actionType);
3039
+ return acc;
3040
+ }, {})
3041
+ );
3042
+ break;
3043
+ }
3016
3044
  case FieldType.DATE:
3017
3045
  schema = PlainDate;
3018
3046
  break;
@@ -3100,6 +3128,15 @@ function mapFieldTypeToZod(field3, actionType) {
3100
3128
  }
3101
3129
  function mapFieldTypeToEmptyValue(field3) {
3102
3130
  switch (field3.type) {
3131
+ case FieldType.FIELD_GROUP:
3132
+ const nestedEmpty = field3.fields.reduce(
3133
+ (acc, subfield) => ({
3134
+ ...acc,
3135
+ [subfield.id]: mapFieldTypeToEmptyValue(subfield)
3136
+ }),
3137
+ {}
3138
+ );
3139
+ return nestedEmpty;
3103
3140
  case FieldType.DIVIDER:
3104
3141
  case FieldType.TEXT:
3105
3142
  case FieldType.TEXTAREA:
@@ -3227,6 +3264,9 @@ var isCheckboxFieldType = (field3) => {
3227
3264
  var isRadioGroupFieldType = (field3) => {
3228
3265
  return field3.config.type === FieldType.RADIO_GROUP;
3229
3266
  };
3267
+ var isFieldGroupFieldType = (field3) => {
3268
+ return field3.config.type === FieldType.FIELD_GROUP;
3269
+ };
3230
3270
  var isLocationFieldType = (field3) => {
3231
3271
  return field3.config.type === FieldType.LOCATION;
3232
3272
  };
@@ -3286,9 +3326,9 @@ var ajv = new import__.default({
3286
3326
  strict: false
3287
3327
  // Allow minContains and other newer features
3288
3328
  });
3289
- var DataContext = import_zod27.z.object({
3290
- rootData: import_zod27.z.object({
3291
- $leafAdminStructureLocationIds: import_zod27.z.array(import_zod27.z.object({ id: UUID }))
3329
+ var DataContext = import_zod28.z.object({
3330
+ rootData: import_zod28.z.object({
3331
+ $leafAdminStructureLocationIds: import_zod28.z.array(import_zod28.z.object({ id: UUID }))
3292
3332
  })
3293
3333
  });
3294
3334
  function resolveDataPath(rootData, dataPath, instancePath) {
@@ -3575,15 +3615,17 @@ function runStructuralValidations({
3575
3615
  return fieldValidationResult;
3576
3616
  }
3577
3617
  function runFieldValidations({
3578
- field: field3,
3579
- values,
3618
+ field: config,
3619
+ form,
3620
+ value,
3580
3621
  context
3581
3622
  }) {
3582
- if (!isFieldVisible(field3, values, context) || isFieldEmptyAndNotRequired(field3, values)) {
3623
+ const field3 = { config, value };
3624
+ if (!isFieldVisible(field3.config, form, context)) {
3583
3625
  return [];
3584
3626
  }
3585
3627
  const conditionalParameters = {
3586
- $form: values,
3628
+ $form: form,
3587
3629
  $now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" }),
3588
3630
  /**
3589
3631
  * In real use cases, there can be hundreds of thousands of locations.
@@ -3596,12 +3638,33 @@ function runFieldValidations({
3596
3638
  $online: isOnline(),
3597
3639
  $user: context.user
3598
3640
  };
3641
+ if (isFieldGroupFieldType(field3)) {
3642
+ const subfieldErrors = buildFormState(
3643
+ field3.config.fields,
3644
+ (subfield) => runFieldValidations({
3645
+ field: subfield,
3646
+ value: field3.value?.[subfield.id],
3647
+ form,
3648
+ context
3649
+ })
3650
+ );
3651
+ if (flattenFormState(subfieldErrors).length !== 0) {
3652
+ return subfieldErrors;
3653
+ }
3654
+ return runCustomFieldValidations({
3655
+ field: field3.config,
3656
+ conditionalParameters
3657
+ });
3658
+ }
3659
+ if (isFieldEmptyAndNotRequired(field3.config, form)) {
3660
+ return [];
3661
+ }
3599
3662
  const fieldValidationResult = validateFieldInput({
3600
- field: field3,
3601
- value: values[field3.id]
3663
+ field: field3.config,
3664
+ value
3602
3665
  });
3603
3666
  const customValidationResults = runCustomFieldValidations({
3604
- field: field3,
3667
+ field: field3.config,
3605
3668
  conditionalParameters
3606
3669
  });
3607
3670
  return [...fieldValidationResult, ...customValidationResults];
@@ -3656,7 +3719,7 @@ function areCertificateConditionsMet(conditions, values) {
3656
3719
  }
3657
3720
 
3658
3721
  // ../commons/src/utils.ts
3659
- var z28 = __toESM(require("zod"));
3722
+ var z29 = __toESM(require("zod"));
3660
3723
  var _ = __toESM(require("lodash"));
3661
3724
  function getOrThrow(x, message) {
3662
3725
  if (x === void 0 || x === null) {
@@ -3667,11 +3730,11 @@ function getOrThrow(x, message) {
3667
3730
  function joinValues(values, separator = " ") {
3668
3731
  return values.filter((value) => !!value).join(separator).trim();
3669
3732
  }
3670
- var FullNameV1 = z28.array(
3671
- z28.object({
3672
- use: z28.string(),
3673
- family: z28.string(),
3674
- given: z28.array(z28.string())
3733
+ var FullNameV1 = z29.array(
3734
+ z29.object({
3735
+ use: z29.string(),
3736
+ family: z29.string(),
3737
+ given: z29.array(z29.string())
3675
3738
  })
3676
3739
  );
3677
3740
  function omitKeyDeep(obj, keyToRemove) {
@@ -3871,6 +3934,54 @@ function findLastAssignmentAction(actions) {
3871
3934
  ({ type }) => type === ActionType.ASSIGN || type === ActionType.UNASSIGN
3872
3935
  ).reduce((latestAction, action) => !latestAction || action.createdAt > latestAction.createdAt ? action : latestAction, void 0);
3873
3936
  }
3937
+ function buildFormState(fields, mapper) {
3938
+ return fields.reduce(
3939
+ (acc, field3) => {
3940
+ if (field3.type === FieldType.FIELD_GROUP) {
3941
+ const nestedState = buildFormState(field3.fields, mapper);
3942
+ if ((0, import_lodash.isEmpty)(nestedState)) {
3943
+ return acc;
3944
+ }
3945
+ acc[field3.id] = nestedState;
3946
+ return acc;
3947
+ }
3948
+ const mappedValue = mapper(field3);
3949
+ if (mappedValue !== void 0) {
3950
+ acc[field3.id] = mappedValue;
3951
+ }
3952
+ return acc;
3953
+ },
3954
+ {}
3955
+ );
3956
+ }
3957
+ function mapFormState(state, fn) {
3958
+ return Object.entries(state).reduce(
3959
+ (mappedState, [key, value]) => {
3960
+ if (value === void 0) {
3961
+ return mappedState;
3962
+ }
3963
+ if (typeof value === "object" && !Array.isArray(value) && value) {
3964
+ mappedState[key] = mapFormState(value, fn);
3965
+ return mappedState;
3966
+ }
3967
+ mappedState[key] = fn(value);
3968
+ return mappedState;
3969
+ },
3970
+ {}
3971
+ );
3972
+ }
3973
+ function flattenFormState(state, path = []) {
3974
+ if (typeof state === "object" && !Array.isArray(state) && state) {
3975
+ return Object.entries(state).filter((e) => e[1] !== void 0).flatMap((e) => flattenFormState(e[1], [...path, e[0]]));
3976
+ }
3977
+ if (Array.isArray(state) && state.length === 0) {
3978
+ return [];
3979
+ }
3980
+ return [[path, state]];
3981
+ }
3982
+ function flattenFieldReference(ref) {
3983
+ return [ref.$$field, ...ref.$$subfield];
3984
+ }
3874
3985
  function isWriteAction(actionType) {
3875
3986
  return writeActions.safeParse(actionType).success;
3876
3987
  }
@@ -4604,12 +4715,12 @@ function createFieldConditionals(fieldId) {
4604
4715
  }
4605
4716
 
4606
4717
  // ../commons/src/events/EventConfig.ts
4607
- (0, import_zod_openapi10.extendZodWithOpenApi)(import_zod28.z);
4608
- var EventFieldReference = import_zod28.z.object({ $$event: EventMetadataDateFieldIdInput }).describe(
4718
+ (0, import_zod_openapi10.extendZodWithOpenApi)(import_zod29.z);
4719
+ var EventFieldReference = import_zod29.z.object({ $$event: EventMetadataDateFieldIdInput }).describe(
4609
4720
  "Reference to a field defined in the event metadata, using the field id."
4610
4721
  );
4611
- var EventConfig = import_zod28.z.object({
4612
- id: import_zod28.z.string().describe(
4722
+ var EventConfig = import_zod29.z.object({
4723
+ id: import_zod29.z.string().describe(
4613
4724
  'Machine-readable identifier of the event (e.g. "birth", "death").'
4614
4725
  ),
4615
4726
  dateOfEvent: FieldReference.or(EventFieldReference).optional().describe(
@@ -4627,13 +4738,13 @@ var EventConfig = import_zod28.z.object({
4627
4738
  label: TranslationConfig.describe(
4628
4739
  "Human-readable label for the event type."
4629
4740
  ),
4630
- actions: import_zod28.z.array(ActionConfig).describe(
4741
+ actions: import_zod29.z.array(ActionConfig).describe(
4631
4742
  "Configuration of system-defined actions associated with the event."
4632
4743
  ),
4633
4744
  declaration: DeclarationFormConfig.describe(
4634
4745
  "Configuration of the form used to gather event data."
4635
4746
  ),
4636
- advancedSearch: import_zod28.z.array(AdvancedSearchConfig).optional().default([]).describe(
4747
+ advancedSearch: import_zod29.z.array(AdvancedSearchConfig).optional().default([]).describe(
4637
4748
  "Configuration of fields available in the advanced search feature."
4638
4749
  )
4639
4750
  }).superRefine((event2, ctx) => {
@@ -4698,7 +4809,7 @@ var definePage = (page) => PageConfig.parse(page);
4698
4809
  var defineFormPage = (formPage) => FormPageConfig.parse(formPage);
4699
4810
 
4700
4811
  // ../commons/src/events/WorkqueueConfig.ts
4701
- var import_zod32 = require("zod");
4812
+ var import_zod33 = require("zod");
4702
4813
 
4703
4814
  // ../commons/src/searchConfigs.ts
4704
4815
  function createSearchConfig(baseField) {
@@ -4899,17 +5010,17 @@ var event = Object.assign(eventFn, {
4899
5010
  });
4900
5011
 
4901
5012
  // ../commons/src/events/WorkqueueColumnConfig.ts
4902
- var import_zod29 = require("zod");
5013
+ var import_zod30 = require("zod");
4903
5014
  var WorkqueueColumnKeysArray = [
4904
5015
  ...EventMetadataKeysArray,
4905
5016
  "title",
4906
5017
  "outbox"
4907
5018
  ];
4908
- var WorkqueueColumnKeys = import_zod29.z.enum(WorkqueueColumnKeysArray);
4909
- var WorkqueueColumnValue = import_zod29.z.object({
5019
+ var WorkqueueColumnKeys = import_zod30.z.enum(WorkqueueColumnKeysArray);
5020
+ var WorkqueueColumnValue = import_zod30.z.object({
4910
5021
  $event: WorkqueueColumnKeys
4911
5022
  });
4912
- var WorkqueueColumn = import_zod29.z.object({
5023
+ var WorkqueueColumn = import_zod30.z.object({
4913
5024
  label: TranslationConfig,
4914
5025
  value: WorkqueueColumnValue
4915
5026
  });
@@ -4920,58 +5031,58 @@ function defineWorkqueuesColumns(workqueueColumns) {
4920
5031
  }
4921
5032
 
4922
5033
  // ../commons/src/events/CountryConfigQueryInput.ts
4923
- var import_zod30 = require("zod");
4924
- var SerializableExact = import_zod30.z.object({
4925
- type: import_zod30.z.literal("exact"),
4926
- term: import_zod30.z.union([import_zod30.z.string(), SerializedUserField])
5034
+ var import_zod31 = require("zod");
5035
+ var SerializableExact = import_zod31.z.object({
5036
+ type: import_zod31.z.literal("exact"),
5037
+ term: import_zod31.z.union([import_zod31.z.string(), SerializedUserField])
4927
5038
  });
4928
- var SerializableWithin = import_zod30.z.object({
4929
- type: import_zod30.z.literal("within"),
4930
- location: import_zod30.z.union([import_zod30.z.string(), SerializedUserField])
5039
+ var SerializableWithin = import_zod31.z.object({
5040
+ type: import_zod31.z.literal("within"),
5041
+ location: import_zod31.z.union([import_zod31.z.string(), SerializedUserField])
4931
5042
  });
4932
- var SerializedQueryExpression = import_zod30.z.object({
4933
- eventType: import_zod30.z.string(),
4934
- status: import_zod30.z.optional(import_zod30.z.union([AnyOfStatus, ExactStatus])),
4935
- createdAt: import_zod30.z.optional(DateCondition),
4936
- updatedAt: import_zod30.z.optional(DateCondition),
4937
- "legalStatuses.REGISTERED.createdAt": import_zod30.z.optional(DateCondition),
4938
- "legalStatuses.REGISTERED.createdAtLocation": import_zod30.z.optional(
4939
- import_zod30.z.union([Within, Exact])
5043
+ var SerializedQueryExpression = import_zod31.z.object({
5044
+ eventType: import_zod31.z.string(),
5045
+ status: import_zod31.z.optional(import_zod31.z.union([AnyOfStatus, ExactStatus])),
5046
+ createdAt: import_zod31.z.optional(DateCondition),
5047
+ updatedAt: import_zod31.z.optional(DateCondition),
5048
+ "legalStatuses.REGISTERED.createdAt": import_zod31.z.optional(DateCondition),
5049
+ "legalStatuses.REGISTERED.createdAtLocation": import_zod31.z.optional(
5050
+ import_zod31.z.union([Within, Exact])
4940
5051
  ),
4941
- "legalStatuses.REGISTERED.registrationNumber": import_zod30.z.optional(Exact),
4942
- createdAtLocation: import_zod30.z.optional(
4943
- import_zod30.z.union([SerializableWithin, SerializableExact])
5052
+ "legalStatuses.REGISTERED.registrationNumber": import_zod31.z.optional(Exact),
5053
+ createdAtLocation: import_zod31.z.optional(
5054
+ import_zod31.z.union([SerializableWithin, SerializableExact])
4944
5055
  ),
4945
- updatedAtLocation: import_zod30.z.optional(
4946
- import_zod30.z.union([SerializableWithin, SerializableExact])
5056
+ updatedAtLocation: import_zod31.z.optional(
5057
+ import_zod31.z.union([SerializableWithin, SerializableExact])
4947
5058
  ),
4948
- updatedByUserRole: import_zod30.z.optional(SerializableExact),
4949
- assignedTo: import_zod30.z.optional(SerializableExact),
4950
- createdBy: import_zod30.z.optional(SerializableExact),
5059
+ updatedByUserRole: import_zod31.z.optional(SerializableExact),
5060
+ assignedTo: import_zod31.z.optional(SerializableExact),
5061
+ createdBy: import_zod31.z.optional(SerializableExact),
4951
5062
  createdByUserType: ExactUserType,
4952
- updatedBy: import_zod30.z.optional(SerializableExact),
4953
- trackingId: import_zod30.z.optional(Exact),
4954
- flags: import_zod30.z.optional(ContainsFlags),
5063
+ updatedBy: import_zod31.z.optional(SerializableExact),
5064
+ trackingId: import_zod31.z.optional(Exact),
5065
+ flags: import_zod31.z.optional(ContainsFlags),
4955
5066
  data: QueryInput
4956
5067
  }).partial();
4957
- var Or2 = import_zod30.z.object({
4958
- type: import_zod30.z.literal("or"),
4959
- clauses: import_zod30.z.array(SerializedQueryExpression)
5068
+ var Or2 = import_zod31.z.object({
5069
+ type: import_zod31.z.literal("or"),
5070
+ clauses: import_zod31.z.array(SerializedQueryExpression)
4960
5071
  });
4961
- var And2 = import_zod30.z.object({
4962
- type: import_zod30.z.literal("and"),
4963
- clauses: import_zod30.z.array(SerializedQueryExpression)
5072
+ var And2 = import_zod31.z.object({
5073
+ type: import_zod31.z.literal("and"),
5074
+ clauses: import_zod31.z.array(SerializedQueryExpression)
4964
5075
  });
4965
- var CountryConfigQueryType = import_zod30.z.discriminatedUnion("type", [And2, Or2]);
4966
- var CountryConfigQueryInputType = import_zod30.z.union([
5076
+ var CountryConfigQueryType = import_zod31.z.discriminatedUnion("type", [And2, Or2]);
5077
+ var CountryConfigQueryInputType = import_zod31.z.union([
4967
5078
  SerializedQueryExpression,
4968
5079
  And2,
4969
5080
  Or2
4970
5081
  ]);
4971
5082
 
4972
5083
  // ../commons/src/icons.ts
4973
- var import_zod31 = require("zod");
4974
- var AvailableIcons = import_zod31.z.enum([
5084
+ var import_zod32 = require("zod");
5085
+ var AvailableIcons = import_zod32.z.enum([
4975
5086
  "Archived",
4976
5087
  "Assigned",
4977
5088
  "Certified",
@@ -5092,23 +5203,23 @@ var mandatoryColumns = defineWorkqueuesColumns([
5092
5203
  value: event.field("updatedAt")
5093
5204
  }
5094
5205
  ]);
5095
- var WorkqueueActionsWithDefault = import_zod32.z.enum([
5206
+ var WorkqueueActionsWithDefault = import_zod33.z.enum([
5096
5207
  ...workqueueActions.options,
5097
5208
  "DEFAULT"
5098
5209
  ]);
5099
- var WorkqueueConfig = import_zod32.z.object({
5100
- slug: import_zod32.z.string().describe("Determines the url of the workqueue."),
5210
+ var WorkqueueConfig = import_zod33.z.object({
5211
+ slug: import_zod33.z.string().describe("Determines the url of the workqueue."),
5101
5212
  name: TranslationConfig.describe(
5102
5213
  "Title of the workflow (both in navigation and on the page)"
5103
5214
  ),
5104
5215
  query: CountryConfigQueryType,
5105
- actions: import_zod32.z.array(
5106
- import_zod32.z.object({
5216
+ actions: import_zod33.z.array(
5217
+ import_zod33.z.object({
5107
5218
  type: WorkqueueActionsWithDefault,
5108
- conditionals: import_zod32.z.array(Conditional).optional()
5219
+ conditionals: import_zod33.z.array(Conditional).optional()
5109
5220
  })
5110
5221
  ),
5111
- columns: import_zod32.z.array(WorkqueueColumn).default(mandatoryColumns),
5222
+ columns: import_zod33.z.array(WorkqueueColumn).default(mandatoryColumns),
5112
5223
  icon: AvailableIcons,
5113
5224
  emptyMessage: TranslationConfig.optional()
5114
5225
  }).describe("Configuration for workqueue.");
@@ -5116,19 +5227,19 @@ var WorkqueueConfigWithoutQuery = WorkqueueConfig.omit({
5116
5227
  query: true,
5117
5228
  columns: true
5118
5229
  });
5119
- var WorkqueueConfigInput = import_zod32.z.object({
5120
- slug: import_zod32.z.string().describe("Determines the url of the workqueue."),
5230
+ var WorkqueueConfigInput = import_zod33.z.object({
5231
+ slug: import_zod33.z.string().describe("Determines the url of the workqueue."),
5121
5232
  name: TranslationConfig.describe(
5122
5233
  "Title of the workflow (both in navigation and on the page)"
5123
5234
  ),
5124
5235
  query: CountryConfigQueryInputType,
5125
- actions: import_zod32.z.array(
5126
- import_zod32.z.object({
5236
+ actions: import_zod33.z.array(
5237
+ import_zod33.z.object({
5127
5238
  type: WorkqueueActionsWithDefault,
5128
- conditionals: import_zod32.z.array(Conditional).optional()
5239
+ conditionals: import_zod33.z.array(Conditional).optional()
5129
5240
  })
5130
5241
  ),
5131
- columns: import_zod32.z.array(WorkqueueColumn).default(mandatoryColumns),
5242
+ columns: import_zod33.z.array(WorkqueueColumn).default(mandatoryColumns),
5132
5243
  icon: AvailableIcons,
5133
5244
  emptyMessage: TranslationConfig.optional()
5134
5245
  });
@@ -5140,10 +5251,10 @@ function defineWorkqueue(workqueueInput) {
5140
5251
  function defineWorkqueues(workqueues) {
5141
5252
  return workqueues.map((workqueue) => defineWorkqueue(workqueue));
5142
5253
  }
5143
- var WorkqueueCountInput = import_zod32.z.array(
5144
- import_zod32.z.object({ slug: import_zod32.z.string(), query: QueryType })
5254
+ var WorkqueueCountInput = import_zod33.z.array(
5255
+ import_zod33.z.object({ slug: import_zod33.z.string(), query: QueryType })
5145
5256
  );
5146
- var WorkqueueCountOutput = import_zod32.z.record(import_zod32.z.string(), import_zod32.z.number());
5257
+ var WorkqueueCountOutput = import_zod33.z.record(import_zod33.z.string(), import_zod33.z.number());
5147
5258
 
5148
5259
  // ../commons/src/events/workqueueDefaultColumns.ts
5149
5260
  var defaultWorkqueueColumns = [
@@ -5166,45 +5277,45 @@ var defaultWorkqueueColumns = [
5166
5277
  ];
5167
5278
 
5168
5279
  // ../commons/src/events/Draft.ts
5169
- var import_zod34 = require("zod");
5280
+ var import_zod35 = require("zod");
5170
5281
 
5171
5282
  // ../commons/src/events/ActionInput.ts
5172
- var import_zod33 = require("zod");
5283
+ var import_zod34 = require("zod");
5173
5284
  var import_zod_openapi11 = require("zod-openapi");
5174
- (0, import_zod_openapi11.extendZodWithOpenApi)(import_zod33.z);
5175
- var BaseActionInput = import_zod33.z.object({
5285
+ (0, import_zod_openapi11.extendZodWithOpenApi)(import_zod34.z);
5286
+ var BaseActionInput = import_zod34.z.object({
5176
5287
  eventId: UUID,
5177
- transactionId: import_zod33.z.string(),
5288
+ transactionId: import_zod34.z.string(),
5178
5289
  declaration: ActionUpdate.default({}),
5179
5290
  annotation: ActionUpdate.optional(),
5180
5291
  originalActionId: UUID.optional(),
5181
5292
  // should not be part of base action.
5182
- keepAssignment: import_zod33.z.boolean().optional(),
5293
+ keepAssignment: import_zod34.z.boolean().optional(),
5183
5294
  // For normal users, the createdAtLocation is resolved on the backend from the user's primaryOfficeId.
5184
5295
  createdAtLocation: CreatedAtLocation.describe(
5185
5296
  "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."
5186
5297
  )
5187
5298
  });
5188
5299
  var CreateActionInput = BaseActionInput.merge(
5189
- import_zod33.z.object({
5190
- type: import_zod33.z.literal(ActionType.CREATE).default(ActionType.CREATE),
5300
+ import_zod34.z.object({
5301
+ type: import_zod34.z.literal(ActionType.CREATE).default(ActionType.CREATE),
5191
5302
  createdAtLocation: CreatedAtLocation
5192
5303
  })
5193
5304
  );
5194
5305
  var RegisterActionInput = BaseActionInput.merge(
5195
- import_zod33.z.object({
5196
- type: import_zod33.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
5197
- registrationNumber: import_zod33.z.string().optional()
5306
+ import_zod34.z.object({
5307
+ type: import_zod34.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
5308
+ registrationNumber: import_zod34.z.string().optional()
5198
5309
  })
5199
5310
  ).strict();
5200
5311
  var ValidateActionInput = BaseActionInput.merge(
5201
- import_zod33.z.object({
5202
- type: import_zod33.z.literal(ActionType.VALIDATE).default(ActionType.VALIDATE)
5312
+ import_zod34.z.object({
5313
+ type: import_zod34.z.literal(ActionType.VALIDATE).default(ActionType.VALIDATE)
5203
5314
  })
5204
5315
  );
5205
5316
  var NotifyActionInput = BaseActionInput.merge(
5206
- import_zod33.z.object({
5207
- type: import_zod33.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
5317
+ import_zod34.z.object({
5318
+ type: import_zod34.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
5208
5319
  })
5209
5320
  ).openapi({
5210
5321
  default: {
@@ -5216,86 +5327,86 @@ var NotifyActionInput = BaseActionInput.merge(
5216
5327
  }
5217
5328
  });
5218
5329
  var DeclareActionInput = BaseActionInput.merge(
5219
- import_zod33.z.object({
5220
- type: import_zod33.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
5330
+ import_zod34.z.object({
5331
+ type: import_zod34.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
5221
5332
  })
5222
5333
  );
5223
5334
  var PrintCertificateActionInput = BaseActionInput.merge(
5224
- import_zod33.z.object({
5225
- type: import_zod33.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE),
5335
+ import_zod34.z.object({
5336
+ type: import_zod34.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE),
5226
5337
  content: PrintContent.optional()
5227
5338
  })
5228
5339
  );
5229
5340
  var RejectDeclarationActionInput = BaseActionInput.merge(
5230
- import_zod33.z.object({
5231
- type: import_zod33.z.literal(ActionType.REJECT).default(ActionType.REJECT),
5341
+ import_zod34.z.object({
5342
+ type: import_zod34.z.literal(ActionType.REJECT).default(ActionType.REJECT),
5232
5343
  content: ReasonContent
5233
5344
  })
5234
5345
  );
5235
5346
  var DuplicateDetectedActionInput = BaseActionInput.merge(
5236
- import_zod33.z.object({
5237
- type: import_zod33.z.literal(ActionType.DUPLICATE_DETECTED).default(ActionType.DUPLICATE_DETECTED),
5238
- content: import_zod33.z.object({
5239
- duplicates: import_zod33.z.array(PotentialDuplicate)
5347
+ import_zod34.z.object({
5348
+ type: import_zod34.z.literal(ActionType.DUPLICATE_DETECTED).default(ActionType.DUPLICATE_DETECTED),
5349
+ content: import_zod34.z.object({
5350
+ duplicates: import_zod34.z.array(PotentialDuplicate)
5240
5351
  })
5241
5352
  })
5242
5353
  );
5243
5354
  var MarkAsDuplicateActionInput = BaseActionInput.merge(
5244
- import_zod33.z.object({
5245
- type: import_zod33.z.literal(ActionType.MARK_AS_DUPLICATE).default(ActionType.MARK_AS_DUPLICATE),
5246
- content: import_zod33.z.object({
5355
+ import_zod34.z.object({
5356
+ type: import_zod34.z.literal(ActionType.MARK_AS_DUPLICATE).default(ActionType.MARK_AS_DUPLICATE),
5357
+ content: import_zod34.z.object({
5247
5358
  duplicateOf: UUID
5248
5359
  }).optional()
5249
5360
  })
5250
5361
  );
5251
5362
  var MarkNotDuplicateActionInput = BaseActionInput.merge(
5252
- import_zod33.z.object({
5253
- type: import_zod33.z.literal(ActionType.MARK_AS_NOT_DUPLICATE).default(ActionType.MARK_AS_NOT_DUPLICATE)
5363
+ import_zod34.z.object({
5364
+ type: import_zod34.z.literal(ActionType.MARK_AS_NOT_DUPLICATE).default(ActionType.MARK_AS_NOT_DUPLICATE)
5254
5365
  })
5255
5366
  );
5256
5367
  var ArchiveActionInput = BaseActionInput.merge(
5257
- import_zod33.z.object({
5258
- type: import_zod33.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE),
5368
+ import_zod34.z.object({
5369
+ type: import_zod34.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE),
5259
5370
  content: ReasonContent
5260
5371
  })
5261
5372
  );
5262
5373
  var AssignActionInput = BaseActionInput.merge(
5263
- import_zod33.z.object({
5264
- type: import_zod33.z.literal(ActionType.ASSIGN),
5265
- assignedTo: import_zod33.z.string()
5374
+ import_zod34.z.object({
5375
+ type: import_zod34.z.literal(ActionType.ASSIGN),
5376
+ assignedTo: import_zod34.z.string()
5266
5377
  })
5267
5378
  );
5268
5379
  var UnassignActionInput = BaseActionInput.merge(
5269
- import_zod33.z.object({
5270
- type: import_zod33.z.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
5271
- assignedTo: import_zod33.z.literal(null).default(null)
5380
+ import_zod34.z.object({
5381
+ type: import_zod34.z.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
5382
+ assignedTo: import_zod34.z.literal(null).default(null)
5272
5383
  })
5273
5384
  );
5274
5385
  var RequestCorrectionActionInput = BaseActionInput.merge(
5275
- import_zod33.z.object({
5276
- type: import_zod33.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
5386
+ import_zod34.z.object({
5387
+ type: import_zod34.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
5277
5388
  })
5278
5389
  );
5279
5390
  var RejectCorrectionActionInput = BaseActionInput.merge(
5280
- import_zod33.z.object({
5281
- requestId: import_zod33.z.string(),
5282
- type: import_zod33.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION),
5391
+ import_zod34.z.object({
5392
+ requestId: import_zod34.z.string(),
5393
+ type: import_zod34.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION),
5283
5394
  content: ReasonContent
5284
5395
  })
5285
5396
  );
5286
5397
  var ApproveCorrectionActionInput = BaseActionInput.merge(
5287
- import_zod33.z.object({
5288
- requestId: import_zod33.z.string(),
5289
- type: import_zod33.z.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
5398
+ import_zod34.z.object({
5399
+ requestId: import_zod34.z.string(),
5400
+ type: import_zod34.z.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
5290
5401
  })
5291
5402
  );
5292
5403
  var ReadActionInput = BaseActionInput.merge(
5293
- import_zod33.z.object({
5294
- type: import_zod33.z.literal(ActionType.READ).default(ActionType.READ)
5404
+ import_zod34.z.object({
5405
+ type: import_zod34.z.literal(ActionType.READ).default(ActionType.READ)
5295
5406
  })
5296
5407
  );
5297
- var DeleteActionInput = import_zod33.z.object({ eventId: UUID });
5298
- var ActionInput = import_zod33.z.discriminatedUnion("type", [
5408
+ var DeleteActionInput = import_zod34.z.object({ eventId: UUID });
5409
+ var ActionInput = import_zod34.z.discriminatedUnion("type", [
5299
5410
  CreateActionInput.openapi({ ref: "CreateActionInput" }),
5300
5411
  ValidateActionInput.openapi({ ref: "ValidateActionInput" }),
5301
5412
  RegisterActionInput.openapi({ ref: "RegisterActionInput" }),
@@ -5330,11 +5441,11 @@ var ActionInput = import_zod33.z.discriminatedUnion("type", [
5330
5441
  });
5331
5442
 
5332
5443
  // ../commons/src/events/Draft.ts
5333
- var Draft = import_zod34.z.object({
5444
+ var Draft = import_zod35.z.object({
5334
5445
  id: UUID,
5335
5446
  eventId: UUID,
5336
- transactionId: import_zod34.z.string(),
5337
- createdAt: import_zod34.z.string().datetime(),
5447
+ transactionId: import_zod35.z.string(),
5448
+ createdAt: import_zod35.z.string().datetime(),
5338
5449
  action: ActionBase.extend({
5339
5450
  type: ActionTypes.exclude([ActionTypes.Enum.DELETE])
5340
5451
  }).omit({ id: true, createdAtLocation: true })
@@ -5343,7 +5454,7 @@ var Draft = import_zod34.z.object({
5343
5454
  );
5344
5455
  var DraftInput = BaseActionInput.extend({
5345
5456
  type: ActionTypes.exclude([ActionTypes.Enum.DELETE]),
5346
- status: import_zod34.z.enum([
5457
+ status: import_zod35.z.enum([
5347
5458
  ActionStatus.Requested,
5348
5459
  ActionStatus.Accepted,
5349
5460
  ActionStatus.Rejected
@@ -5351,26 +5462,26 @@ var DraftInput = BaseActionInput.extend({
5351
5462
  });
5352
5463
 
5353
5464
  // ../commons/src/events/EventInput.ts
5354
- var import_zod35 = require("zod");
5465
+ var import_zod36 = require("zod");
5355
5466
  var import_uuid10 = require("uuid");
5356
- var EventInput = import_zod35.z.object({
5357
- transactionId: import_zod35.z.string(),
5358
- type: import_zod35.z.string()
5467
+ var EventInput = import_zod36.z.object({
5468
+ transactionId: import_zod36.z.string(),
5469
+ type: import_zod36.z.string()
5359
5470
  }).openapi({ default: { transactionId: (0, import_uuid10.v4)(), type: "birth" } });
5360
5471
 
5361
5472
  // ../commons/src/events/EventDocument.ts
5362
- var import_zod36 = require("zod");
5473
+ var import_zod37 = require("zod");
5363
5474
  var import_zod_openapi12 = require("zod-openapi");
5364
- (0, import_zod_openapi12.extendZodWithOpenApi)(import_zod36.z);
5365
- var EventDocument = import_zod36.z.object({
5475
+ (0, import_zod_openapi12.extendZodWithOpenApi)(import_zod37.z);
5476
+ var EventDocument = import_zod37.z.object({
5366
5477
  id: UUID.describe("Unique identifier of the event."),
5367
- type: import_zod36.z.string().describe("Type of the event (e.g. birth, death, marriage)."),
5368
- createdAt: import_zod36.z.string().datetime().describe("Timestamp indicating when the event was created."),
5369
- updatedAt: import_zod36.z.string().datetime().describe(
5478
+ type: import_zod37.z.string().describe("Type of the event (e.g. birth, death, marriage)."),
5479
+ createdAt: import_zod37.z.string().datetime().describe("Timestamp indicating when the event was created."),
5480
+ updatedAt: import_zod37.z.string().datetime().describe(
5370
5481
  "Timestamp of the last update, excluding changes from actions."
5371
5482
  ),
5372
- actions: import_zod36.z.array(Action).describe("Ordered list of actions associated with the event."),
5373
- trackingId: import_zod36.z.string().describe(
5483
+ actions: import_zod37.z.array(Action).describe("Ordered list of actions associated with the event."),
5484
+ trackingId: import_zod37.z.string().describe(
5374
5485
  "System-generated tracking identifier used to look up the event."
5375
5486
  )
5376
5487
  }).openapi({ ref: "EventDocument" });
@@ -8260,9 +8371,9 @@ var digitalIdentityEvent = defineConfig({
8260
8371
  });
8261
8372
 
8262
8373
  // ../commons/src/events/test.utils.ts
8263
- var import_zod37 = require("zod");
8374
+ var import_zod38 = require("zod");
8264
8375
  var TEST_SYSTEM_IANA_TIMEZONE = "Asia/Dhaka";
8265
- var TestUserRole = import_zod37.z.enum([
8376
+ var TestUserRole = import_zod38.z.enum([
8266
8377
  "FIELD_AGENT",
8267
8378
  "LOCAL_REGISTRAR",
8268
8379
  "LOCAL_SYSTEM_ADMIN",
@@ -8332,6 +8443,20 @@ function generateRandomSignature(rng) {
8332
8443
  }
8333
8444
  function mapFieldTypeToMockValue(field3, i, rng) {
8334
8445
  switch (field3.type) {
8446
+ case FieldType.FIELD_GROUP: {
8447
+ const nestedValue = field3.fields.reduce(
8448
+ (acc, subfield, index) => ({
8449
+ ...acc,
8450
+ [subfield.id]: mapFieldTypeToMockValue(
8451
+ subfield,
8452
+ i * 1e3 + index,
8453
+ rng
8454
+ )
8455
+ }),
8456
+ {}
8457
+ );
8458
+ return nestedValue;
8459
+ }
8335
8460
  case FieldType.DIVIDER:
8336
8461
  case FieldType.TEXT:
8337
8462
  case FieldType.TEXTAREA:
@@ -9312,16 +9437,16 @@ function getFilePathsFromEvent(event2) {
9312
9437
  }
9313
9438
 
9314
9439
  // ../commons/src/events/locations.ts
9315
- var import_zod38 = require("zod");
9316
- var LocationType = import_zod38.z.enum([
9440
+ var import_zod39 = require("zod");
9441
+ var LocationType = import_zod39.z.enum([
9317
9442
  "ADMIN_STRUCTURE",
9318
9443
  "CRVS_OFFICE",
9319
9444
  "HEALTH_FACILITY"
9320
9445
  ]);
9321
- var Location = import_zod38.z.object({
9446
+ var Location = import_zod39.z.object({
9322
9447
  id: UUID,
9323
- name: import_zod38.z.string(),
9448
+ name: import_zod39.z.string(),
9324
9449
  parentId: UUID.nullable(),
9325
- validUntil: import_zod38.z.string().datetime().nullable(),
9450
+ validUntil: import_zod39.z.string().datetime().nullable(),
9326
9451
  locationType: LocationType.nullable()
9327
9452
  });