av6-core 1.7.2 → 1.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -533,6 +533,7 @@ declare const getPattern: {
533
533
  };
534
534
  declare const interpolate: (template: string, vars: Record<string, unknown>) => string;
535
535
  declare const fromTimestampToSqlDatetime: (date: string) => string;
536
+ declare function formatDatesDeep(data: any, format?: string): any;
536
537
 
537
538
  interface CreateTransaction {
538
539
  field: string;
@@ -700,4 +701,4 @@ declare class AuditProxy<Module extends string = "OPD" | "PROCEDURE" | "GENERAL_
700
701
  createAuditedService<T extends object>(serviceName: string, service: T): T;
701
702
  }
702
703
 
703
- export { type AuditContext, type AuditContextProvider, AuditCore, type AuditLogPayload, AuditLogger, AuditProxy, type BulkAtomicResult, type BulkConfig, type BulkConflictConfig, type BulkOnConflict, type CacheAdapter, type CalculationRes, type ColValue, type CommonCreateRequestRepository, type CommonExcelRequest, type CommonFilterRequest, type CommonFilterWithDate, type CommonServiceResponse, type CommonUpdateRequestRepository, type Config, type Context, type CreateUINConfigRequest, type CrudContext, type CrudDelegate, type DataType, type DeepMerge, type DeleteParams, type DeleteRequestRepository, type Deps, type DropdownRequest, type DropdownRequestService, type DtoFromMapping, type DtoNullOnMissing, type DynamicCreateInput, type DynamicCrudConfig, type DynamicShortCode, type DynamicUpdateInput, type EmitPayload, type EmployeeCache, type ExcelConfig, type ExportExcel, type ExportExcelRequestService, type FetchRequest, type FetchRequestRepository, type FieldConfig, type FieldRules, type FieldType, type FixedMap, type FixedSearchRequest, type FixedSearchRequestService, type Helpers, type ImportExcel, type ImportExcelRequestService, type LockUnlockParams, type LockUnlockRequestRepository, type LogicNode, type Mapper, type MergeAll, type NewFixedSearchRequest, type NewFixedSearchRequestService, type NewSearchRequest, NotificationEmitter, type Op, type PaginatedResponse, type PathToSelectWithSelect, type PathValue, type PathsToSelectWithSelect, type Presence, type Recipient, type RelationConfig, type RelationStrategy, type RelationWriteConfig, type SearchRequest, type SearchRequestService, type ServiceCacheAdapter, type SingleValidationMapping, type SourcePath, type Store, type ToggleActive, type TxClient, type UINConfigDTO, type UINPreviewRequest, type UINSegment, type UINSegmentType, type UIN_RESET_POLICY, type UinDeps, type UnionToIntersection, type UniqueConfig, type UpdateConfigByCodeInput, type UpdateStatusRequestRepository, type UpdateUINConfigRequest, type ValidationErrorItem, commonService, customOmit, findDifferences, fromTimestampToSqlDatetime, getDynamicValue, getNestedValue, getPattern, interpolate, objectTo2DArray, toNumberOrNull, toUINConfigDTO, uinConfigService, type updateStatusParams };
704
+ export { type AuditContext, type AuditContextProvider, AuditCore, type AuditLogPayload, AuditLogger, AuditProxy, type BulkAtomicResult, type BulkConfig, type BulkConflictConfig, type BulkOnConflict, type CacheAdapter, type CalculationRes, type ColValue, type CommonCreateRequestRepository, type CommonExcelRequest, type CommonFilterRequest, type CommonFilterWithDate, type CommonServiceResponse, type CommonUpdateRequestRepository, type Config, type Context, type CreateUINConfigRequest, type CrudContext, type CrudDelegate, type DataType, type DeepMerge, type DeleteParams, type DeleteRequestRepository, type Deps, type DropdownRequest, type DropdownRequestService, type DtoFromMapping, type DtoNullOnMissing, type DynamicCreateInput, type DynamicCrudConfig, type DynamicShortCode, type DynamicUpdateInput, type EmitPayload, type EmployeeCache, type ExcelConfig, type ExportExcel, type ExportExcelRequestService, type FetchRequest, type FetchRequestRepository, type FieldConfig, type FieldRules, type FieldType, type FixedMap, type FixedSearchRequest, type FixedSearchRequestService, type Helpers, type ImportExcel, type ImportExcelRequestService, type LockUnlockParams, type LockUnlockRequestRepository, type LogicNode, type Mapper, type MergeAll, type NewFixedSearchRequest, type NewFixedSearchRequestService, type NewSearchRequest, NotificationEmitter, type Op, type PaginatedResponse, type PathToSelectWithSelect, type PathValue, type PathsToSelectWithSelect, type Presence, type Recipient, type RelationConfig, type RelationStrategy, type RelationWriteConfig, type SearchRequest, type SearchRequestService, type ServiceCacheAdapter, type SingleValidationMapping, type SourcePath, type Store, type ToggleActive, type TxClient, type UINConfigDTO, type UINPreviewRequest, type UINSegment, type UINSegmentType, type UIN_RESET_POLICY, type UinDeps, type UnionToIntersection, type UniqueConfig, type UpdateConfigByCodeInput, type UpdateStatusRequestRepository, type UpdateUINConfigRequest, type ValidationErrorItem, commonService, customOmit, findDifferences, formatDatesDeep, fromTimestampToSqlDatetime, getDynamicValue, getNestedValue, getPattern, interpolate, objectTo2DArray, toNumberOrNull, toUINConfigDTO, uinConfigService, type updateStatusParams };
package/dist/index.d.ts CHANGED
@@ -533,6 +533,7 @@ declare const getPattern: {
533
533
  };
534
534
  declare const interpolate: (template: string, vars: Record<string, unknown>) => string;
535
535
  declare const fromTimestampToSqlDatetime: (date: string) => string;
536
+ declare function formatDatesDeep(data: any, format?: string): any;
536
537
 
537
538
  interface CreateTransaction {
538
539
  field: string;
@@ -700,4 +701,4 @@ declare class AuditProxy<Module extends string = "OPD" | "PROCEDURE" | "GENERAL_
700
701
  createAuditedService<T extends object>(serviceName: string, service: T): T;
701
702
  }
702
703
 
703
- export { type AuditContext, type AuditContextProvider, AuditCore, type AuditLogPayload, AuditLogger, AuditProxy, type BulkAtomicResult, type BulkConfig, type BulkConflictConfig, type BulkOnConflict, type CacheAdapter, type CalculationRes, type ColValue, type CommonCreateRequestRepository, type CommonExcelRequest, type CommonFilterRequest, type CommonFilterWithDate, type CommonServiceResponse, type CommonUpdateRequestRepository, type Config, type Context, type CreateUINConfigRequest, type CrudContext, type CrudDelegate, type DataType, type DeepMerge, type DeleteParams, type DeleteRequestRepository, type Deps, type DropdownRequest, type DropdownRequestService, type DtoFromMapping, type DtoNullOnMissing, type DynamicCreateInput, type DynamicCrudConfig, type DynamicShortCode, type DynamicUpdateInput, type EmitPayload, type EmployeeCache, type ExcelConfig, type ExportExcel, type ExportExcelRequestService, type FetchRequest, type FetchRequestRepository, type FieldConfig, type FieldRules, type FieldType, type FixedMap, type FixedSearchRequest, type FixedSearchRequestService, type Helpers, type ImportExcel, type ImportExcelRequestService, type LockUnlockParams, type LockUnlockRequestRepository, type LogicNode, type Mapper, type MergeAll, type NewFixedSearchRequest, type NewFixedSearchRequestService, type NewSearchRequest, NotificationEmitter, type Op, type PaginatedResponse, type PathToSelectWithSelect, type PathValue, type PathsToSelectWithSelect, type Presence, type Recipient, type RelationConfig, type RelationStrategy, type RelationWriteConfig, type SearchRequest, type SearchRequestService, type ServiceCacheAdapter, type SingleValidationMapping, type SourcePath, type Store, type ToggleActive, type TxClient, type UINConfigDTO, type UINPreviewRequest, type UINSegment, type UINSegmentType, type UIN_RESET_POLICY, type UinDeps, type UnionToIntersection, type UniqueConfig, type UpdateConfigByCodeInput, type UpdateStatusRequestRepository, type UpdateUINConfigRequest, type ValidationErrorItem, commonService, customOmit, findDifferences, fromTimestampToSqlDatetime, getDynamicValue, getNestedValue, getPattern, interpolate, objectTo2DArray, toNumberOrNull, toUINConfigDTO, uinConfigService, type updateStatusParams };
704
+ export { type AuditContext, type AuditContextProvider, AuditCore, type AuditLogPayload, AuditLogger, AuditProxy, type BulkAtomicResult, type BulkConfig, type BulkConflictConfig, type BulkOnConflict, type CacheAdapter, type CalculationRes, type ColValue, type CommonCreateRequestRepository, type CommonExcelRequest, type CommonFilterRequest, type CommonFilterWithDate, type CommonServiceResponse, type CommonUpdateRequestRepository, type Config, type Context, type CreateUINConfigRequest, type CrudContext, type CrudDelegate, type DataType, type DeepMerge, type DeleteParams, type DeleteRequestRepository, type Deps, type DropdownRequest, type DropdownRequestService, type DtoFromMapping, type DtoNullOnMissing, type DynamicCreateInput, type DynamicCrudConfig, type DynamicShortCode, type DynamicUpdateInput, type EmitPayload, type EmployeeCache, type ExcelConfig, type ExportExcel, type ExportExcelRequestService, type FetchRequest, type FetchRequestRepository, type FieldConfig, type FieldRules, type FieldType, type FixedMap, type FixedSearchRequest, type FixedSearchRequestService, type Helpers, type ImportExcel, type ImportExcelRequestService, type LockUnlockParams, type LockUnlockRequestRepository, type LogicNode, type Mapper, type MergeAll, type NewFixedSearchRequest, type NewFixedSearchRequestService, type NewSearchRequest, NotificationEmitter, type Op, type PaginatedResponse, type PathToSelectWithSelect, type PathValue, type PathsToSelectWithSelect, type Presence, type Recipient, type RelationConfig, type RelationStrategy, type RelationWriteConfig, type SearchRequest, type SearchRequestService, type ServiceCacheAdapter, type SingleValidationMapping, type SourcePath, type Store, type ToggleActive, type TxClient, type UINConfigDTO, type UINPreviewRequest, type UINSegment, type UINSegmentType, type UIN_RESET_POLICY, type UinDeps, type UnionToIntersection, type UniqueConfig, type UpdateConfigByCodeInput, type UpdateStatusRequestRepository, type UpdateUINConfigRequest, type ValidationErrorItem, commonService, customOmit, findDifferences, formatDatesDeep, fromTimestampToSqlDatetime, getDynamicValue, getNestedValue, getPattern, interpolate, objectTo2DArray, toNumberOrNull, toUINConfigDTO, uinConfigService, type updateStatusParams };
package/dist/index.js CHANGED
@@ -37,6 +37,7 @@ __export(index_exports, {
37
37
  commonService: () => commonService,
38
38
  customOmit: () => customOmit,
39
39
  findDifferences: () => findDifferences,
40
+ formatDatesDeep: () => formatDatesDeep,
40
41
  fromTimestampToSqlDatetime: () => fromTimestampToSqlDatetime,
41
42
  getDynamicValue: () => getDynamicValue,
42
43
  getNestedValue: () => getNestedValue,
@@ -1308,9 +1309,10 @@ var commonCreateUpdateRepository = (serviceDeps) => {
1308
1309
 
1309
1310
  // src/utils/dynamicJoiBuilder.utils.ts
1310
1311
  var import_joi = __toESM(require("joi"));
1311
- var import_dayjs = __toESM(require("dayjs"));
1312
+ var import_dayjs2 = __toESM(require("dayjs"));
1312
1313
 
1313
1314
  // src/utils/helper.utils.ts
1315
+ var import_dayjs = __toESM(require("dayjs"));
1314
1316
  function customOmit(obj, keys) {
1315
1317
  const rest = { ...obj };
1316
1318
  const omitted = {};
@@ -1435,6 +1437,27 @@ var interpolate = (template, vars) => {
1435
1437
  });
1436
1438
  };
1437
1439
  var fromTimestampToSqlDatetime = (date) => date.replace("T", " ").replace("Z", "");
1440
+ function formatDatesDeep(data, format = "YYYY-MM-DD") {
1441
+ if (data === null || data === void 0) return data;
1442
+ if (Array.isArray(data)) {
1443
+ return data.map((item) => formatDatesDeep(item, format));
1444
+ }
1445
+ if (typeof data === "object") {
1446
+ const result = {};
1447
+ for (const key in data) {
1448
+ const value = data[key];
1449
+ if (value instanceof Date || (0, import_dayjs.default)(value).isValid()) {
1450
+ result[key] = (0, import_dayjs.default)(value).format(format);
1451
+ } else if (Array.isArray(value) || typeof value === "object") {
1452
+ result[key] = formatDatesDeep(value, format);
1453
+ } else {
1454
+ result[key] = value;
1455
+ }
1456
+ }
1457
+ return result;
1458
+ }
1459
+ return data;
1460
+ }
1438
1461
 
1439
1462
  // src/utils/dynamicJoiBuilder.utils.ts
1440
1463
  function applyNumberCompare(schema, op, ref) {
@@ -1467,13 +1490,13 @@ function resolvePrecision(rule, ctx) {
1467
1490
  function resolveMinDate(rule) {
1468
1491
  if (!rule.minDate) return void 0;
1469
1492
  if (rule.minDate === "now") return /* @__PURE__ */ new Date();
1470
- if (rule.minDate === "today") return (0, import_dayjs.default)().startOf("day").toDate();
1493
+ if (rule.minDate === "today") return (0, import_dayjs2.default)().startOf("day").toDate();
1471
1494
  return void 0;
1472
1495
  }
1473
1496
  function resolveMaxDate(rule) {
1474
1497
  if (!rule.maxDate) return void 0;
1475
1498
  if (rule.maxDate === "now") return /* @__PURE__ */ new Date();
1476
- if (rule.maxDate === "today") return (0, import_dayjs.default)().startOf("day").toDate();
1499
+ if (rule.maxDate === "today") return (0, import_dayjs2.default)().startOf("day").toDate();
1477
1500
  return void 0;
1478
1501
  }
1479
1502
  var buildScalar = (f, ctx, op) => {
@@ -2450,7 +2473,7 @@ var uinConfigServiceValidation = (uinDeps) => {
2450
2473
  };
2451
2474
 
2452
2475
  // src/services/uinConfig.service.ts
2453
- var import_dayjs2 = __toESM(require("dayjs"));
2476
+ var import_dayjs3 = __toESM(require("dayjs"));
2454
2477
  var import_node_cron = __toESM(require("node-cron"));
2455
2478
  var MS_IN_A_DAY = 24 * 36e5;
2456
2479
  function buildFromSegments(segments, seqValue) {
@@ -2464,7 +2487,7 @@ function buildFromSegments(segments, seqValue) {
2464
2487
  break;
2465
2488
  case "dateFormat":
2466
2489
  try {
2467
- out += (0, import_dayjs2.default)(/* @__PURE__ */ new Date()).format(seg.value);
2490
+ out += (0, import_dayjs3.default)(/* @__PURE__ */ new Date()).format(seg.value);
2468
2491
  } catch {
2469
2492
  console.error("Invalid dateFormat:", seg.value);
2470
2493
  }
@@ -3446,6 +3469,7 @@ var NotificationService = class {
3446
3469
  * Creates parent EventDelivery and one child EventDeliveryItem per attempt.
3447
3470
  */
3448
3471
  async handleEvent(evt) {
3472
+ evt.data = formatDatesDeep(evt.data);
3449
3473
  const cfg = await this.loadEventConfigOrThrow(evt);
3450
3474
  const delivery = await this.createDeliveryParent(cfg, evt);
3451
3475
  const tasks = [];
@@ -3512,7 +3536,7 @@ var NotificationService = class {
3512
3536
  return cfg;
3513
3537
  }
3514
3538
  async createDeliveryParent(cfg, evt) {
3515
- const defaultValues = cfg.eventConfigKeys?.map((x) => ({ [x.key]: x.defaultValue })) ?? {};
3539
+ const defaultValues = cfg.eventConfigKeys?.reduce((acc, x) => ({ ...acc, [x.key]: x.defaultValue }), {}) ?? {};
3516
3540
  const mergedData = (0, import_lodash.default)({}, defaultValues, evt.data ?? {});
3517
3541
  return this.prisma.eventDelivery.create({
3518
3542
  data: {
@@ -3582,7 +3606,7 @@ var NotificationService = class {
3582
3606
  this.logger.info("[NotificationService] Email: no recipients resolved");
3583
3607
  return;
3584
3608
  }
3585
- const defaultValues = cfg.eventConfigKeys?.map((x) => ({ [x.key]: x.defaultValue })) ?? {};
3609
+ const defaultValues = cfg.eventConfigKeys?.reduce((acc, x) => ({ ...acc, [x.key]: x.defaultValue }), {}) ?? {};
3586
3610
  const mergedData = (0, import_lodash.default)({}, defaultValues, evt.data ?? {});
3587
3611
  const msg = renderEmailTemplate({ body: tpl.bodyHtml ?? "", subject: tpl.subject ?? "" }, mergedData);
3588
3612
  const provider = new EmailProvider(this.prisma, this.logger, cfg.serviceEvent.serviceDomain);
@@ -3614,7 +3638,7 @@ var NotificationService = class {
3614
3638
  this.logger.info("[NotificationService] SMS: no recipients resolved");
3615
3639
  return;
3616
3640
  }
3617
- const defaultValues = cfg.eventConfigKeys?.map((x) => ({ [x.key]: x.defaultValue })) ?? {};
3641
+ const defaultValues = cfg.eventConfigKeys?.reduce((acc, x) => ({ ...acc, [x.key]: x.defaultValue }), {}) ?? {};
3618
3642
  const mergedData = (0, import_lodash.default)({}, defaultValues, evt.data ?? {});
3619
3643
  const body = renderTemplate(tpl.bodyText ?? "", mergedData);
3620
3644
  const provider = new SmsProvider(this.logger, {
@@ -3695,7 +3719,7 @@ var NotificationService = class {
3695
3719
  this.logger.info("[NotificationService] APP: no userIds resolved");
3696
3720
  return;
3697
3721
  }
3698
- const defaultValues = cfg.eventConfigKeys?.map((x) => ({ [x.key]: x.defaultValue })) ?? {};
3722
+ const defaultValues = cfg.eventConfigKeys?.reduce((acc, x) => ({ ...acc, [x.key]: x.defaultValue }), {}) ?? {};
3699
3723
  const mergedData = (0, import_lodash.default)({}, defaultValues, evt.data ?? {});
3700
3724
  const title = renderTemplate(tpl.subject ?? "", mergedData);
3701
3725
  const body = renderTemplate(tpl.bodyText ?? "", mergedData);
@@ -3791,7 +3815,7 @@ var NotificationService = class {
3791
3815
  this.logger.error("[NotificationService] WEB: no recipients resolved");
3792
3816
  return;
3793
3817
  }
3794
- const defaultValues = cfg.eventConfigKeys?.map((x) => ({ [x.key]: x.defaultValue })) ?? {};
3818
+ const defaultValues = cfg.eventConfigKeys?.reduce((acc, x) => ({ ...acc, [x.key]: x.defaultValue }), {}) ?? {};
3795
3819
  const mergedData = (0, import_lodash.default)({}, defaultValues, evt.data ?? {});
3796
3820
  const message = renderTemplate(webTpl.bodyText ?? "", mergedData);
3797
3821
  const link = webUrlTpl ? renderTemplate(webUrlTpl ?? "", mergedData) : null;
@@ -3851,7 +3875,7 @@ var NotificationService = class {
3851
3875
  this.logger.info("[NotificationService] WhatsApp: no recipients resolved");
3852
3876
  return;
3853
3877
  }
3854
- const defaultValues = cfg.eventConfigKeys?.map((x) => ({ [x.key]: x.defaultValue })) ?? {};
3878
+ const defaultValues = cfg.eventConfigKeys?.reduce((acc, x) => ({ ...acc, [x.key]: x.defaultValue }), {}) ?? {};
3855
3879
  const mergedData = (0, import_lodash.default)({}, defaultValues, evt.data ?? {});
3856
3880
  const message = renderTemplate(tpl.bodyText ?? "", mergedData);
3857
3881
  const dataWp = tpl.extra?.bodyValues?.map((x) => getNestedValue(mergedData, x));
@@ -3907,7 +3931,7 @@ var NotificationService = class {
3907
3931
  // Recipient resolution
3908
3932
  // --------------------------------------------------------------------------------------
3909
3933
  async getRecipients(eventConfig, evt) {
3910
- const defaultValues = eventConfig.eventConfigKeys?.map((x) => ({ [x.key]: x.defaultValue })) ?? {};
3934
+ const defaultValues = eventConfig.eventConfigKeys?.reduce((acc, x) => ({ ...acc, [x.key]: x.defaultValue }), {}) ?? {};
3911
3935
  const mergedData = (0, import_lodash.default)({}, defaultValues, evt.data ?? {});
3912
3936
  const recipients = await resolveAllRecipients({
3913
3937
  prisma: this.prisma,
@@ -4193,6 +4217,7 @@ var AuditProxy = class {
4193
4217
  commonService,
4194
4218
  customOmit,
4195
4219
  findDifferences,
4220
+ formatDatesDeep,
4196
4221
  fromTimestampToSqlDatetime,
4197
4222
  getDynamicValue,
4198
4223
  getNestedValue,
package/dist/index.mjs CHANGED
@@ -1257,9 +1257,10 @@ var commonCreateUpdateRepository = (serviceDeps) => {
1257
1257
 
1258
1258
  // src/utils/dynamicJoiBuilder.utils.ts
1259
1259
  import Joi from "joi";
1260
- import dayjs from "dayjs";
1260
+ import dayjs2 from "dayjs";
1261
1261
 
1262
1262
  // src/utils/helper.utils.ts
1263
+ import dayjs from "dayjs";
1263
1264
  function customOmit(obj, keys) {
1264
1265
  const rest = { ...obj };
1265
1266
  const omitted = {};
@@ -1384,6 +1385,27 @@ var interpolate = (template, vars) => {
1384
1385
  });
1385
1386
  };
1386
1387
  var fromTimestampToSqlDatetime = (date) => date.replace("T", " ").replace("Z", "");
1388
+ function formatDatesDeep(data, format = "YYYY-MM-DD") {
1389
+ if (data === null || data === void 0) return data;
1390
+ if (Array.isArray(data)) {
1391
+ return data.map((item) => formatDatesDeep(item, format));
1392
+ }
1393
+ if (typeof data === "object") {
1394
+ const result = {};
1395
+ for (const key in data) {
1396
+ const value = data[key];
1397
+ if (value instanceof Date || dayjs(value).isValid()) {
1398
+ result[key] = dayjs(value).format(format);
1399
+ } else if (Array.isArray(value) || typeof value === "object") {
1400
+ result[key] = formatDatesDeep(value, format);
1401
+ } else {
1402
+ result[key] = value;
1403
+ }
1404
+ }
1405
+ return result;
1406
+ }
1407
+ return data;
1408
+ }
1387
1409
 
1388
1410
  // src/utils/dynamicJoiBuilder.utils.ts
1389
1411
  function applyNumberCompare(schema, op, ref) {
@@ -1416,13 +1438,13 @@ function resolvePrecision(rule, ctx) {
1416
1438
  function resolveMinDate(rule) {
1417
1439
  if (!rule.minDate) return void 0;
1418
1440
  if (rule.minDate === "now") return /* @__PURE__ */ new Date();
1419
- if (rule.minDate === "today") return dayjs().startOf("day").toDate();
1441
+ if (rule.minDate === "today") return dayjs2().startOf("day").toDate();
1420
1442
  return void 0;
1421
1443
  }
1422
1444
  function resolveMaxDate(rule) {
1423
1445
  if (!rule.maxDate) return void 0;
1424
1446
  if (rule.maxDate === "now") return /* @__PURE__ */ new Date();
1425
- if (rule.maxDate === "today") return dayjs().startOf("day").toDate();
1447
+ if (rule.maxDate === "today") return dayjs2().startOf("day").toDate();
1426
1448
  return void 0;
1427
1449
  }
1428
1450
  var buildScalar = (f, ctx, op) => {
@@ -2399,7 +2421,7 @@ var uinConfigServiceValidation = (uinDeps) => {
2399
2421
  };
2400
2422
 
2401
2423
  // src/services/uinConfig.service.ts
2402
- import dayjs2 from "dayjs";
2424
+ import dayjs3 from "dayjs";
2403
2425
  import cron from "node-cron";
2404
2426
  var MS_IN_A_DAY = 24 * 36e5;
2405
2427
  function buildFromSegments(segments, seqValue) {
@@ -2413,7 +2435,7 @@ function buildFromSegments(segments, seqValue) {
2413
2435
  break;
2414
2436
  case "dateFormat":
2415
2437
  try {
2416
- out += dayjs2(/* @__PURE__ */ new Date()).format(seg.value);
2438
+ out += dayjs3(/* @__PURE__ */ new Date()).format(seg.value);
2417
2439
  } catch {
2418
2440
  console.error("Invalid dateFormat:", seg.value);
2419
2441
  }
@@ -3395,6 +3417,7 @@ var NotificationService = class {
3395
3417
  * Creates parent EventDelivery and one child EventDeliveryItem per attempt.
3396
3418
  */
3397
3419
  async handleEvent(evt) {
3420
+ evt.data = formatDatesDeep(evt.data);
3398
3421
  const cfg = await this.loadEventConfigOrThrow(evt);
3399
3422
  const delivery = await this.createDeliveryParent(cfg, evt);
3400
3423
  const tasks = [];
@@ -3461,7 +3484,7 @@ var NotificationService = class {
3461
3484
  return cfg;
3462
3485
  }
3463
3486
  async createDeliveryParent(cfg, evt) {
3464
- const defaultValues = cfg.eventConfigKeys?.map((x) => ({ [x.key]: x.defaultValue })) ?? {};
3487
+ const defaultValues = cfg.eventConfigKeys?.reduce((acc, x) => ({ ...acc, [x.key]: x.defaultValue }), {}) ?? {};
3465
3488
  const mergedData = merge({}, defaultValues, evt.data ?? {});
3466
3489
  return this.prisma.eventDelivery.create({
3467
3490
  data: {
@@ -3531,7 +3554,7 @@ var NotificationService = class {
3531
3554
  this.logger.info("[NotificationService] Email: no recipients resolved");
3532
3555
  return;
3533
3556
  }
3534
- const defaultValues = cfg.eventConfigKeys?.map((x) => ({ [x.key]: x.defaultValue })) ?? {};
3557
+ const defaultValues = cfg.eventConfigKeys?.reduce((acc, x) => ({ ...acc, [x.key]: x.defaultValue }), {}) ?? {};
3535
3558
  const mergedData = merge({}, defaultValues, evt.data ?? {});
3536
3559
  const msg = renderEmailTemplate({ body: tpl.bodyHtml ?? "", subject: tpl.subject ?? "" }, mergedData);
3537
3560
  const provider = new EmailProvider(this.prisma, this.logger, cfg.serviceEvent.serviceDomain);
@@ -3563,7 +3586,7 @@ var NotificationService = class {
3563
3586
  this.logger.info("[NotificationService] SMS: no recipients resolved");
3564
3587
  return;
3565
3588
  }
3566
- const defaultValues = cfg.eventConfigKeys?.map((x) => ({ [x.key]: x.defaultValue })) ?? {};
3589
+ const defaultValues = cfg.eventConfigKeys?.reduce((acc, x) => ({ ...acc, [x.key]: x.defaultValue }), {}) ?? {};
3567
3590
  const mergedData = merge({}, defaultValues, evt.data ?? {});
3568
3591
  const body = renderTemplate(tpl.bodyText ?? "", mergedData);
3569
3592
  const provider = new SmsProvider(this.logger, {
@@ -3644,7 +3667,7 @@ var NotificationService = class {
3644
3667
  this.logger.info("[NotificationService] APP: no userIds resolved");
3645
3668
  return;
3646
3669
  }
3647
- const defaultValues = cfg.eventConfigKeys?.map((x) => ({ [x.key]: x.defaultValue })) ?? {};
3670
+ const defaultValues = cfg.eventConfigKeys?.reduce((acc, x) => ({ ...acc, [x.key]: x.defaultValue }), {}) ?? {};
3648
3671
  const mergedData = merge({}, defaultValues, evt.data ?? {});
3649
3672
  const title = renderTemplate(tpl.subject ?? "", mergedData);
3650
3673
  const body = renderTemplate(tpl.bodyText ?? "", mergedData);
@@ -3740,7 +3763,7 @@ var NotificationService = class {
3740
3763
  this.logger.error("[NotificationService] WEB: no recipients resolved");
3741
3764
  return;
3742
3765
  }
3743
- const defaultValues = cfg.eventConfigKeys?.map((x) => ({ [x.key]: x.defaultValue })) ?? {};
3766
+ const defaultValues = cfg.eventConfigKeys?.reduce((acc, x) => ({ ...acc, [x.key]: x.defaultValue }), {}) ?? {};
3744
3767
  const mergedData = merge({}, defaultValues, evt.data ?? {});
3745
3768
  const message = renderTemplate(webTpl.bodyText ?? "", mergedData);
3746
3769
  const link = webUrlTpl ? renderTemplate(webUrlTpl ?? "", mergedData) : null;
@@ -3800,7 +3823,7 @@ var NotificationService = class {
3800
3823
  this.logger.info("[NotificationService] WhatsApp: no recipients resolved");
3801
3824
  return;
3802
3825
  }
3803
- const defaultValues = cfg.eventConfigKeys?.map((x) => ({ [x.key]: x.defaultValue })) ?? {};
3826
+ const defaultValues = cfg.eventConfigKeys?.reduce((acc, x) => ({ ...acc, [x.key]: x.defaultValue }), {}) ?? {};
3804
3827
  const mergedData = merge({}, defaultValues, evt.data ?? {});
3805
3828
  const message = renderTemplate(tpl.bodyText ?? "", mergedData);
3806
3829
  const dataWp = tpl.extra?.bodyValues?.map((x) => getNestedValue(mergedData, x));
@@ -3856,7 +3879,7 @@ var NotificationService = class {
3856
3879
  // Recipient resolution
3857
3880
  // --------------------------------------------------------------------------------------
3858
3881
  async getRecipients(eventConfig, evt) {
3859
- const defaultValues = eventConfig.eventConfigKeys?.map((x) => ({ [x.key]: x.defaultValue })) ?? {};
3882
+ const defaultValues = eventConfig.eventConfigKeys?.reduce((acc, x) => ({ ...acc, [x.key]: x.defaultValue }), {}) ?? {};
3860
3883
  const mergedData = merge({}, defaultValues, evt.data ?? {});
3861
3884
  const recipients = await resolveAllRecipients({
3862
3885
  prisma: this.prisma,
@@ -4141,6 +4164,7 @@ export {
4141
4164
  commonService,
4142
4165
  customOmit,
4143
4166
  findDifferences,
4167
+ formatDatesDeep,
4144
4168
  fromTimestampToSqlDatetime,
4145
4169
  getDynamicValue,
4146
4170
  getNestedValue,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "av6-core",
3
- "version": "1.7.2",
3
+ "version": "1.7.4",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
@@ -26,6 +26,7 @@
26
26
  "dependencies": {
27
27
  "av6-utils": "^1.0.4",
28
28
  "axios": "^1.11.0",
29
+ "dayjs": "^1.11.19",
29
30
  "exceljs": "^4.4.0",
30
31
  "handlebars": "^4.7.8",
31
32
  "joi": "^17.13.3",