@opencrvs/toolkit 1.8.0-rc.ff2e7b6 → 1.8.0-rc.ffe8c17

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.
@@ -51,6 +51,7 @@ __export(events_exports, {
51
51
  Clause: () => Clause,
52
52
  Conditional: () => Conditional,
53
53
  ConditionalType: () => ConditionalType,
54
+ DataFieldValue: () => DataFieldValue,
54
55
  DateValue: () => DateValue,
55
56
  DeclareActionInput: () => DeclareActionInput,
56
57
  DeduplicationConfig: () => DeduplicationConfig,
@@ -81,6 +82,8 @@ __export(events_exports, {
81
82
  MarkedAsDuplicateActionInput: () => MarkedAsDuplicateActionInput,
82
83
  NotifyActionInput: () => NotifyActionInput,
83
84
  NumberFieldValue: () => NumberFieldValue,
85
+ PageConfig: () => PageConfig,
86
+ PageType: () => PageType,
84
87
  PrintCertificateActionInput: () => PrintCertificateActionInput,
85
88
  RegisterActionInput: () => RegisterActionInput,
86
89
  RejectCorrectionActionInput: () => RejectCorrectionActionInput,
@@ -97,17 +100,21 @@ __export(events_exports, {
97
100
  UrbanAddressUpdateValue: () => UrbanAddressUpdateValue,
98
101
  UrbanAddressValue: () => UrbanAddressValue,
99
102
  ValidateActionInput: () => ValidateActionInput,
103
+ VerificationPage: () => VerificationPage,
104
+ VerificationPageConfig: () => VerificationPageConfig,
100
105
  WorkqueueConfig: () => WorkqueueConfig,
101
106
  alwaysTrue: () => alwaysTrue,
102
107
  and: () => and,
103
108
  applyDraftsToEventIndex: () => applyDraftsToEventIndex,
104
109
  compositeFieldTypes: () => compositeFieldTypes,
110
+ createEmptyDraft: () => createEmptyDraft,
105
111
  createValidationSchema: () => createValidationSchema,
106
112
  deepDropNulls: () => deepDropNulls,
107
113
  defineConditional: () => defineConditional,
108
114
  defineConfig: () => defineConfig,
109
115
  defineForm: () => defineForm,
110
- defineFormPage: () => defineFormPage,
116
+ definePage: () => definePage,
117
+ errorMessages: () => errorMessages,
111
118
  event: () => event,
112
119
  eventMetadataLabelMap: () => eventMetadataLabelMap,
113
120
  eventPayloadGenerator: () => eventPayloadGenerator,
@@ -119,6 +126,7 @@ __export(events_exports, {
119
126
  findActiveActionForm: () => findActiveActionForm,
120
127
  findActiveActionFormFields: () => findActiveActionFormFields,
121
128
  findActiveActionFormPages: () => findActiveActionFormPages,
129
+ findActiveDrafts: () => findActiveDrafts,
122
130
  findInputPageFields: () => findInputPageFields,
123
131
  findPageFields: () => findPageFields,
124
132
  generateActionDocument: () => generateActionDocument,
@@ -141,6 +149,7 @@ __export(events_exports, {
141
149
  isBulletListFieldType: () => isBulletListFieldType,
142
150
  isCheckboxFieldType: () => isCheckboxFieldType,
143
151
  isCountryFieldType: () => isCountryFieldType,
152
+ isDataFieldType: () => isDataFieldType,
144
153
  isDateFieldType: () => isDateFieldType,
145
154
  isDividerFieldType: () => isDividerFieldType,
146
155
  isEmailFieldType: () => isEmailFieldType,
@@ -164,6 +173,7 @@ __export(events_exports, {
164
173
  isTextAreaFieldType: () => isTextAreaFieldType,
165
174
  isTextFieldType: () => isTextFieldType,
166
175
  isUndeclaredDraft: () => isUndeclaredDraft,
176
+ mapFieldTypeToEmptyValue: () => mapFieldTypeToEmptyValue,
167
177
  mapFieldTypeToMockValue: () => mapFieldTypeToMockValue,
168
178
  mapFieldTypeToZod: () => mapFieldTypeToZod,
169
179
  not: () => not,
@@ -247,7 +257,8 @@ var FieldType = {
247
257
  ADMINISTRATIVE_AREA: "ADMINISTRATIVE_AREA",
248
258
  FACILITY: "FACILITY",
249
259
  OFFICE: "OFFICE",
250
- SIGNATURE: "SIGNATURE"
260
+ SIGNATURE: "SIGNATURE",
261
+ DATA: "DATA"
251
262
  };
252
263
  var fieldTypes = Object.values(FieldType);
253
264
  var compositeFieldTypes = [
@@ -332,6 +343,7 @@ var FieldValue = import_zod4.z.union([
332
343
  UrbanAddressValue,
333
344
  RuralAddressValue
334
345
  ]);
346
+ var DataFieldValue = import_zod4.z.record(import_zod4.z.string(), FieldValue);
335
347
  var FieldUpdateValue = import_zod4.z.union([
336
348
  TextValue,
337
349
  DateValue,
@@ -543,6 +555,14 @@ var Address = BaseField.extend({
543
555
  type: import_zod5.z.literal(FieldType.ADDRESS),
544
556
  defaultValue: AddressFieldValue.optional()
545
557
  }).describe("Address input field \u2013 a combination of location and text fields");
558
+ var Data = BaseField.extend({
559
+ type: import_zod5.z.literal(FieldType.DATA),
560
+ configuration: import_zod5.z.object({
561
+ title: TranslationConfig.optional(),
562
+ subtitle: TranslationConfig.optional(),
563
+ data: import_zod5.z.array(import_zod5.z.object({ fieldId: import_zod5.z.string() }))
564
+ })
565
+ }).describe("Data field for displaying read-only data");
546
566
  var FieldConfig = import_zod5.z.discriminatedUnion("type", [
547
567
  Address,
548
568
  TextField,
@@ -564,15 +584,44 @@ var FieldConfig = import_zod5.z.discriminatedUnion("type", [
564
584
  Office,
565
585
  SignatureField,
566
586
  EmailField,
567
- FileUploadWithOptions
587
+ FileUploadWithOptions,
588
+ Data
568
589
  ]);
569
590
 
570
591
  // ../commons/src/events/FormConfig.ts
592
+ var PageType = /* @__PURE__ */ ((PageType2) => {
593
+ PageType2["FORM"] = "FORM";
594
+ PageType2["VERIFICATION"] = "VERIFICATION";
595
+ return PageType2;
596
+ })(PageType || {});
571
597
  var FormPage = import_zod6.z.object({
572
598
  id: import_zod6.z.string().describe("Unique identifier for the page"),
573
599
  title: TranslationConfig.describe("Header title of the page"),
574
- fields: import_zod6.z.array(FieldConfig).describe("Fields to be rendered on the page")
600
+ fields: import_zod6.z.array(FieldConfig).describe("Fields to be rendered on the page"),
601
+ type: import_zod6.z.literal("FORM" /* FORM */).default("FORM" /* FORM */)
575
602
  });
603
+ var VerificationPageConfig = import_zod6.z.object({
604
+ verify: import_zod6.z.object({ label: TranslationConfig }),
605
+ cancel: import_zod6.z.object({
606
+ label: TranslationConfig,
607
+ confirmation: import_zod6.z.object({
608
+ title: TranslationConfig,
609
+ body: TranslationConfig
610
+ })
611
+ })
612
+ }).describe("Actions available on the verification page");
613
+ var VerificationPage = FormPage.extend({
614
+ type: import_zod6.z.literal("VERIFICATION" /* VERIFICATION */),
615
+ actions: VerificationPageConfig
616
+ });
617
+ var PageConfig = import_zod6.z.preprocess(
618
+ (data) => ({
619
+ type: data.type ?? "FORM" /* FORM */,
620
+ // Default type to "FORM" if not provided
621
+ ...data
622
+ }),
623
+ import_zod6.z.discriminatedUnion("type", [FormPage, VerificationPage])
624
+ );
576
625
  var FormConfig = import_zod6.z.object({
577
626
  label: TranslationConfig.describe("Human readable description of the form"),
578
627
  version: import_zod6.z.object({
@@ -584,7 +633,7 @@ var FormConfig = import_zod6.z.object({
584
633
  )
585
634
  }),
586
635
  active: import_zod6.z.boolean().default(false).describe("Whether the form is active"),
587
- pages: import_zod6.z.array(FormPage),
636
+ pages: import_zod6.z.array(PageConfig),
588
637
  review: import_zod6.z.object({
589
638
  title: TranslationConfig.describe(
590
639
  "Title of the form to show in review page"
@@ -639,23 +688,17 @@ var ValidateConfig = ActionConfigBase.merge(
639
688
  );
640
689
  var RejectDeclarationConfig = ActionConfigBase.merge(
641
690
  import_zod7.z.object({
642
- type: import_zod7.z.literal(ActionType.REJECT),
643
- comment: import_zod7.z.string(),
644
- isDuplicate: import_zod7.z.boolean()
691
+ type: import_zod7.z.literal(ActionType.REJECT)
645
692
  })
646
693
  );
647
694
  var MarkedAsDuplicateConfig = ActionConfigBase.merge(
648
695
  import_zod7.z.object({
649
- type: import_zod7.z.literal(ActionType.MARKED_AS_DUPLICATE),
650
- comment: import_zod7.z.string(),
651
- duplicates: import_zod7.z.array(import_zod7.z.string()).describe("UUIDs of duplicate records")
696
+ type: import_zod7.z.literal(ActionType.MARKED_AS_DUPLICATE)
652
697
  })
653
698
  );
654
699
  var ArchiveConfig = ActionConfigBase.merge(
655
700
  import_zod7.z.object({
656
- type: import_zod7.z.literal(ActionType.ARCHIVE),
657
- comment: import_zod7.z.string(),
658
- isDuplicate: import_zod7.z.boolean()
701
+ type: import_zod7.z.literal(ActionType.ARCHIVE)
659
702
  })
660
703
  );
661
704
  var RegisterConfig = ActionConfigBase.merge(
@@ -676,8 +719,8 @@ var PrintCertificateActionConfig = ActionConfigBase.merge(
676
719
  var RequestCorrectionConfig = ActionConfigBase.merge(
677
720
  import_zod7.z.object({
678
721
  type: import_zod7.z.literal(ActionType.REQUEST_CORRECTION),
679
- onboardingForm: import_zod7.z.array(FormPage),
680
- additionalDetailsForm: import_zod7.z.array(FormPage)
722
+ onboardingForm: import_zod7.z.array(PageConfig),
723
+ additionalDetailsForm: import_zod7.z.array(PageConfig)
681
724
  })
682
725
  );
683
726
  var RejectCorrectionConfig = ActionConfigBase.merge(
@@ -1119,6 +1162,9 @@ function mapFieldTypeToZod(type, required) {
1119
1162
  case FieldType.ADDRESS:
1120
1163
  schema = AddressFieldUpdateValue;
1121
1164
  break;
1165
+ case FieldType.DATA:
1166
+ schema = DataFieldValue;
1167
+ break;
1122
1168
  }
1123
1169
  return required ? schema : schema.nullish();
1124
1170
  }
@@ -1174,6 +1220,53 @@ function mapFieldTypeToMockValue(field2, i) {
1174
1220
  };
1175
1221
  case FieldType.FILE_WITH_OPTIONS:
1176
1222
  return null;
1223
+ case FieldType.DATA:
1224
+ return {};
1225
+ }
1226
+ }
1227
+ function mapFieldTypeToEmptyValue(field2) {
1228
+ switch (field2.type) {
1229
+ case FieldType.DIVIDER:
1230
+ case FieldType.TEXT:
1231
+ case FieldType.TEXTAREA:
1232
+ case FieldType.BULLET_LIST:
1233
+ case FieldType.PAGE_HEADER:
1234
+ case FieldType.LOCATION:
1235
+ case FieldType.SELECT:
1236
+ case FieldType.COUNTRY:
1237
+ case FieldType.RADIO_GROUP:
1238
+ case FieldType.SIGNATURE:
1239
+ case FieldType.PARAGRAPH:
1240
+ case FieldType.ADMINISTRATIVE_AREA:
1241
+ case FieldType.FACILITY:
1242
+ case FieldType.OFFICE:
1243
+ case FieldType.NUMBER:
1244
+ case FieldType.EMAIL:
1245
+ case FieldType.DATE:
1246
+ case FieldType.CHECKBOX:
1247
+ case FieldType.DATA:
1248
+ return null;
1249
+ case FieldType.ADDRESS:
1250
+ return {
1251
+ country: null,
1252
+ province: null,
1253
+ district: null,
1254
+ urbanOrRural: "URBAN",
1255
+ // Default to urban needed for validation
1256
+ town: null,
1257
+ residentialArea: null,
1258
+ street: null,
1259
+ number: null,
1260
+ zipCode: null
1261
+ };
1262
+ case FieldType.FILE:
1263
+ return {
1264
+ filename: "",
1265
+ originalFilename: "",
1266
+ type: ""
1267
+ };
1268
+ case FieldType.FILE_WITH_OPTIONS:
1269
+ return [];
1177
1270
  }
1178
1271
  }
1179
1272
  var isParagraphFieldType = (field2) => {
@@ -1239,6 +1332,9 @@ var isFacilityFieldType = (field2) => {
1239
1332
  var isOfficeFieldType = (field2) => {
1240
1333
  return field2.config.type === FieldType.OFFICE;
1241
1334
  };
1335
+ var isDataFieldType = (field2) => {
1336
+ return field2.config.type === FieldType.DATA;
1337
+ };
1242
1338
 
1243
1339
  // ../commons/src/conditionals/validate.ts
1244
1340
  var ajv = new import_ajv.default({
@@ -1275,49 +1371,66 @@ function isFieldVisible(field2, form) {
1275
1371
  function isFieldEnabled(field2, form) {
1276
1372
  return isFieldConditionMet(field2, form, ConditionalType.ENABLE);
1277
1373
  }
1374
+ var errorMessages = {
1375
+ hiddenField: {
1376
+ id: "v2.error.hidden",
1377
+ defaultMessage: "Hidden or disabled field should not receive a value",
1378
+ description: "Error message when field is hidden or disabled, but a value was received"
1379
+ },
1380
+ invalidDate: {
1381
+ defaultMessage: "Invalid date field",
1382
+ description: "Error message when date field is invalid",
1383
+ id: "v2.error.invalidDate"
1384
+ },
1385
+ invalidEmail: {
1386
+ defaultMessage: "Invalid email address",
1387
+ description: "Error message when email address is invalid",
1388
+ id: "v2.error.invalidEmail"
1389
+ },
1390
+ requiredField: {
1391
+ defaultMessage: "Required for registration",
1392
+ description: "Error message when required field is missing",
1393
+ id: "v2.error.required"
1394
+ },
1395
+ invalidInput: {
1396
+ defaultMessage: "Invalid input",
1397
+ description: "Error message when generic field is invalid",
1398
+ id: "v2.error.invalid"
1399
+ }
1400
+ };
1401
+ var createIntlError = (message) => ({
1402
+ message: {
1403
+ message
1404
+ }
1405
+ });
1278
1406
  var zodToIntlErrorMap = (issue, _ctx) => {
1279
- if (issue.code === "invalid_string" && issue.validation === "date") {
1280
- return {
1281
- message: {
1282
- message: {
1283
- defaultMessage: "Invalid date. Please use the format YYYY-MM-DD",
1284
- description: "This is the error message for invalid date fields",
1285
- id: "v2.error.invalidDate"
1286
- }
1407
+ switch (issue.code) {
1408
+ case "invalid_string": {
1409
+ if (_ctx.data === "") {
1410
+ return createIntlError(errorMessages.requiredField);
1287
1411
  }
1288
- };
1289
- }
1290
- if (issue.code === "invalid_string" && issue.validation === "email") {
1291
- return {
1292
- message: {
1293
- message: {
1294
- defaultMessage: "Invalid email address",
1295
- description: "This is the error message for invalid email fields",
1296
- id: "v2.error.invalidEmail"
1297
- }
1412
+ if (issue.validation === "date") {
1413
+ return createIntlError(errorMessages.invalidDate);
1298
1414
  }
1299
- };
1300
- }
1301
- if (issue.code === "invalid_type" && issue.expected !== issue.received && issue.received === "undefined" || issue.code === "too_small" && issue.message === void 0) {
1302
- return {
1303
- message: {
1304
- message: {
1305
- defaultMessage: "Required for registration",
1306
- description: "This is the error message for required fields",
1307
- id: "v2.error.required"
1308
- }
1415
+ if (issue.validation === "email") {
1416
+ return createIntlError(errorMessages.invalidEmail);
1309
1417
  }
1310
- };
1311
- }
1312
- return {
1313
- message: {
1314
- message: {
1315
- defaultMessage: "Invalid input",
1316
- description: "This is the error message for invalid field value",
1317
- id: "v2.error.invalid"
1418
+ break;
1419
+ }
1420
+ case "invalid_type": {
1421
+ if (issue.expected !== issue.received && issue.received === "undefined") {
1422
+ return createIntlError(errorMessages.requiredField);
1318
1423
  }
1424
+ break;
1319
1425
  }
1320
- };
1426
+ case "too_small": {
1427
+ if (issue.message === void 0) {
1428
+ return createIntlError(errorMessages.requiredField);
1429
+ }
1430
+ break;
1431
+ }
1432
+ }
1433
+ return createIntlError(errorMessages.invalidInput);
1321
1434
  };
1322
1435
  function getFieldValidationErrors({
1323
1436
  field: field2,
@@ -1332,11 +1445,7 @@ function getFieldValidationErrors({
1332
1445
  return {
1333
1446
  errors: [
1334
1447
  {
1335
- message: {
1336
- id: "v2.error.hidden",
1337
- defaultMessage: "Hidden or disabled field should not receive a value",
1338
- description: "Error message when field is hidden or disabled, but a value was received"
1339
- }
1448
+ message: errorMessages.hiddenField
1340
1449
  }
1341
1450
  ]
1342
1451
  };
@@ -1354,8 +1463,8 @@ function getFieldValidationErrors({
1354
1463
  conditionalParameters
1355
1464
  });
1356
1465
  return {
1357
- // Assumes that custom validation errors are more important than field validation errors
1358
- errors: [...customValidationResults, ...fieldValidationResult]
1466
+ // Assumes that custom validation errors are based on the field type, and extend the validation.
1467
+ errors: [...fieldValidationResult, ...customValidationResults]
1359
1468
  };
1360
1469
  }
1361
1470
  function runCustomFieldValidations({
@@ -1388,6 +1497,12 @@ function getOrThrow(x, message) {
1388
1497
  return x;
1389
1498
  }
1390
1499
 
1500
+ // ../commons/src/uuid.ts
1501
+ var import_uuid = require("uuid");
1502
+ function getUUID() {
1503
+ return (0, import_uuid.v4)();
1504
+ }
1505
+
1391
1506
  // ../commons/src/events/utils.ts
1392
1507
  function isMetadataField(field2) {
1393
1508
  return field2 in eventMetadataLabelMap;
@@ -1457,7 +1572,7 @@ function validateWorkqueueConfig(workqueueConfigs) {
1457
1572
  );
1458
1573
  if (!rootWorkqueue) {
1459
1574
  throw new Error(
1460
- `Invalid workqueue configuration: workqueue not found with id: ${workqueue.id}`
1575
+ `Invalid workqueue configuration: workqueue not found with id: ${workqueue.id}`
1461
1576
  );
1462
1577
  }
1463
1578
  });
@@ -1522,6 +1637,27 @@ function stripHiddenFields(fields, data) {
1522
1637
  return !isFieldVisible(field2, data);
1523
1638
  });
1524
1639
  }
1640
+ function findActiveDrafts(event2, drafts) {
1641
+ const actions = event2.actions.slice().sort((a, b) => a.createdAt.localeCompare(b.createdAt));
1642
+ const lastAction = actions[actions.length - 1];
1643
+ return drafts.filter(({ createdAt }) => createdAt >= lastAction.createdAt).filter(({ eventId }) => eventId === event2.id);
1644
+ }
1645
+ function createEmptyDraft(eventId, draftId, actionType) {
1646
+ return {
1647
+ id: draftId,
1648
+ eventId,
1649
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1650
+ transactionId: getUUID(),
1651
+ action: {
1652
+ type: actionType,
1653
+ data: {},
1654
+ metadata: {},
1655
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1656
+ createdBy: "@todo",
1657
+ createdAtLocation: "@todo"
1658
+ }
1659
+ };
1660
+ }
1525
1661
 
1526
1662
  // ../commons/src/events/EventConfig.ts
1527
1663
  var EventConfig = import_zod18.z.object({
@@ -1563,7 +1699,7 @@ var EventConfig = import_zod18.z.object({
1563
1699
 
1564
1700
  // ../commons/src/events/EventConfigInput.ts
1565
1701
  var defineForm = (form) => FormConfig.parse(form);
1566
- var defineFormPage = (formPage) => FormPage.parse(formPage);
1702
+ var definePage = (formPage) => PageConfig.parse(formPage);
1567
1703
 
1568
1704
  // ../commons/src/events/Draft.ts
1569
1705
  var import_zod21 = require("zod");
@@ -1955,9 +2091,8 @@ function getCurrentEventState(event2) {
1955
2091
  });
1956
2092
  }
1957
2093
  function getCurrentEventStateWithDrafts(event2, drafts) {
1958
- const actions = event2.actions.slice().sort();
1959
- const lastAction = actions[actions.length - 1];
1960
- const activeDrafts = drafts.filter(({ eventId }) => eventId === event2.id).filter(({ createdAt }) => createdAt > lastAction.createdAt).map((draft) => draft.action).flatMap((action) => {
2094
+ const actions = event2.actions.slice().sort((a, b) => a.createdAt.localeCompare(b.createdAt));
2095
+ const activeDrafts = findActiveDrafts(event2, drafts).map((draft) => draft.action).flatMap((action) => {
1961
2096
  if (action.type === ActionType.REQUEST_CORRECTION) {
1962
2097
  return [
1963
2098
  action,
@@ -2018,12 +2153,6 @@ var defineConfig = (config) => {
2018
2153
  });
2019
2154
  };
2020
2155
 
2021
- // ../commons/src/uuid.ts
2022
- var import_uuid = require("uuid");
2023
- function getUUID() {
2024
- return (0, import_uuid.v4)();
2025
- }
2026
-
2027
2156
  // ../commons/src/events/transactions.ts
2028
2157
  function generateTransactionId() {
2029
2158
  return getUUID();
@@ -3443,6 +3572,24 @@ var tennisClubMembershipEvent = defineConfig({
3443
3572
  })
3444
3573
  }
3445
3574
  ]
3575
+ },
3576
+ {
3577
+ type: ActionType.ARCHIVE,
3578
+ label: {
3579
+ id: "v2.event.tennis-club-membership.action.archive.label",
3580
+ defaultMessage: "Archive",
3581
+ description: "This is shown as the action name anywhere the user can trigger the action from"
3582
+ },
3583
+ forms: [TENNIS_CLUB_FORM]
3584
+ },
3585
+ {
3586
+ type: ActionType.REJECT,
3587
+ label: {
3588
+ id: "v2.event.tennis-club-membership.action.reject.label",
3589
+ defaultMessage: "Reject",
3590
+ description: "This is shown as the action name anywhere the user can trigger the action from"
3591
+ },
3592
+ forms: [TENNIS_CLUB_FORM]
3446
3593
  }
3447
3594
  ],
3448
3595
  advancedSearch: [
@@ -3525,7 +3672,7 @@ var eventPayloadGenerator = {
3525
3672
  archive: (eventId, input = {}, isDuplicate) => ({
3526
3673
  type: ActionType.ARCHIVE,
3527
3674
  transactionId: input.transactionId ?? getUUID(),
3528
- data: input.data ?? {},
3675
+ data: input.data ?? generateActionInput(tennisClubMembershipEvent, ActionType.ARCHIVE),
3529
3676
  metadata: { isDuplicate: isDuplicate ?? false },
3530
3677
  duplicates: [],
3531
3678
  eventId
@@ -3533,7 +3680,7 @@ var eventPayloadGenerator = {
3533
3680
  reject: (eventId, input = {}) => ({
3534
3681
  type: ActionType.REJECT,
3535
3682
  transactionId: input.transactionId ?? getUUID(),
3536
- data: input.data ?? {},
3683
+ data: input.data ?? generateActionInput(tennisClubMembershipEvent, ActionType.REJECT),
3537
3684
  duplicates: [],
3538
3685
  eventId
3539
3686
  }),
@@ -3592,7 +3739,9 @@ function generateActionDocument({
3592
3739
  defaults = {}
3593
3740
  }) {
3594
3741
  const actionBase = {
3595
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
3742
+ // Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
3743
+ // @TODO: This should be fixed in the future.
3744
+ createdAt: new Date(Date.now() - 500).toISOString(),
3596
3745
  createdBy: getUUID(),
3597
3746
  id: getUUID(),
3598
3747
  createdAtLocation: "TODO",
@@ -3647,9 +3796,13 @@ function generateEventDocument({
3647
3796
  actions: actions.map(
3648
3797
  (action) => generateActionDocument({ configuration, action })
3649
3798
  ),
3650
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
3799
+ // Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
3800
+ // @TODO: This should be fixed in the future.
3801
+ createdAt: new Date(Date.now() - 1e3).toISOString(),
3651
3802
  id: getUUID(),
3652
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
3803
+ // Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
3804
+ // @TODO: This should be fixed in the future.
3805
+ updatedAt: new Date(Date.now() - 1e3).toISOString()
3653
3806
  };
3654
3807
  }
3655
3808
  function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, data = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencrvs/toolkit",
3
- "version": "1.8.0-rc.ff2e7b6",
3
+ "version": "1.8.0-rc.ffe8c17",
4
4
  "description": "OpenCRVS toolkit for building country configurations",
5
5
  "license": "MPL-2.0",
6
6
  "exports": {