av6-core 1.8.6 → 1.8.8

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
@@ -846,6 +846,8 @@ declare const getPattern: {
846
846
  declare const interpolate: (template: string, vars: Record<string, unknown>) => string;
847
847
  declare const fromTimestampToSqlDatetime: (date: string) => string;
848
848
  declare function formatDatesDeep<T>(data: T, format?: string): T;
849
+ declare function generateMd5(text: string): string;
850
+ declare const generateHashForAuth: (randomNum: string) => string;
849
851
 
850
852
  interface CreateTransaction {
851
853
  field: string;
@@ -1024,4 +1026,4 @@ declare class AuditProxy<Module extends string = "OPD" | "PROCEDURE" | "GENERAL_
1024
1026
  createAuditedService<T extends object>(serviceName: string, service: T): T;
1025
1027
  }
1026
1028
 
1027
- export { type ActInput, ActionMode, type ApprovalAction, type ApprovalActionDto, type ApprovalDeps, type ApprovalFlow, type ApprovalInstance, type ApprovalInstanceByUser, ApprovalService, ApprovalStatus, type ApprovalStep, type ApproverMapping, type AuditContext, type AuditContextProvider, AuditCore, type AuditLogPayload, AuditLogger, AuditProxy, type BulkAtomicResult, type BulkConfig, type BulkConflictConfig, type BulkOnConflict, type CacheAdapter, type CalculationRes, type ColValue, type CommonApproveReq, type CommonCreateRequestRepository, type CommonExcelRequest, type CommonFilterRequest, type CommonFilterWithDate, type CommonGetApprovalActionReq, type CommonServiceResponse, type CommonUpdateRequestRepository, type Config, type Context, type CreateApprovalFlow, 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 EventInstance, type ExcelConfig, type ExportExcel, type ExportExcelRequestService, type FetchRequest, type FetchRequestRepository, type FieldConfig, type FieldRules, type FieldType, type FixedMap, type FixedSearchRequest, type FixedSearchRequestService, FlowType, type FlowWithSelectedStepResponse, type FlowWithStepsResponse, type GetMyApprovalFlow, type GetPendingApprovalReq, type Helpers, type IApprovalStep, type IChildConfigData, type IChildConfigJSON, type ICommonApprovalUpdate, type IParentConfigData, type IParentConfigJSON, type ImportExcel, type ImportExcelRequestService, type LevelDoneEvt, type LevelReadyEvt, type LockUnlockParams, type LockUnlockRequestRepository, type LogicNode, type Mapper, type MergeAll, type NewFixedSearchRequest, type NewFixedSearchRequestService, type NewSearchRequest, NotificationEmitter, type NotificationEvent, type Op, type PaginatedResponse, type PathToSelectWithSelect, type PathValue, type PathsToSelectWithSelect, type Presence, type PrismaTransactionClient, type RawFlowWithSelectedStepResponse, type Recipient, type RelationConfig, type RelationStrategy, type RelationWriteConfig, type SearchRequest, type SearchRequestService, type ServiceCacheAdapter, type SingleValidationMapping, type SourcePath, type StartFlowReq, type StepType, 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 UpdateApprovalFlow, type UpdateConfigByCodeInput, type UpdateStatusRequestRepository, type UpdateUINConfigRequest, type ValidationErrorItem, approvalRepository, commonService, convertArrayPatternToEachBlocksGeneric, customOmit, findDifferences, formatDatesDeep, fromTimestampToSqlDatetime, getDynamicValue, getNestedValue, getNestedValueV2, getPattern, interpolate, objectTo2DArray, renderEmailTemplate, renderTemplate, toNumberOrNull, toUINConfigDTO, uinConfigService, type updateStatusParams };
1029
+ export { type ActInput, ActionMode, type ApprovalAction, type ApprovalActionDto, type ApprovalDeps, type ApprovalFlow, type ApprovalInstance, type ApprovalInstanceByUser, ApprovalService, ApprovalStatus, type ApprovalStep, type ApproverMapping, type AuditContext, type AuditContextProvider, AuditCore, type AuditLogPayload, AuditLogger, AuditProxy, type BulkAtomicResult, type BulkConfig, type BulkConflictConfig, type BulkOnConflict, type CacheAdapter, type CalculationRes, type ColValue, type CommonApproveReq, type CommonCreateRequestRepository, type CommonExcelRequest, type CommonFilterRequest, type CommonFilterWithDate, type CommonGetApprovalActionReq, type CommonServiceResponse, type CommonUpdateRequestRepository, type Config, type Context, type CreateApprovalFlow, 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 EventInstance, type ExcelConfig, type ExportExcel, type ExportExcelRequestService, type FetchRequest, type FetchRequestRepository, type FieldConfig, type FieldRules, type FieldType, type FixedMap, type FixedSearchRequest, type FixedSearchRequestService, FlowType, type FlowWithSelectedStepResponse, type FlowWithStepsResponse, type GetMyApprovalFlow, type GetPendingApprovalReq, type Helpers, type IApprovalStep, type IChildConfigData, type IChildConfigJSON, type ICommonApprovalUpdate, type IParentConfigData, type IParentConfigJSON, type ImportExcel, type ImportExcelRequestService, type LevelDoneEvt, type LevelReadyEvt, type LockUnlockParams, type LockUnlockRequestRepository, type LogicNode, type Mapper, type MergeAll, type NewFixedSearchRequest, type NewFixedSearchRequestService, type NewSearchRequest, NotificationEmitter, type NotificationEvent, type Op, type PaginatedResponse, type PathToSelectWithSelect, type PathValue, type PathsToSelectWithSelect, type Presence, type PrismaTransactionClient, type RawFlowWithSelectedStepResponse, type Recipient, type RelationConfig, type RelationStrategy, type RelationWriteConfig, type SearchRequest, type SearchRequestService, type ServiceCacheAdapter, type SingleValidationMapping, type SourcePath, type StartFlowReq, type StepType, 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 UpdateApprovalFlow, type UpdateConfigByCodeInput, type UpdateStatusRequestRepository, type UpdateUINConfigRequest, type ValidationErrorItem, approvalRepository, commonService, convertArrayPatternToEachBlocksGeneric, customOmit, findDifferences, formatDatesDeep, fromTimestampToSqlDatetime, generateHashForAuth, generateMd5, getDynamicValue, getNestedValue, getNestedValueV2, getPattern, interpolate, objectTo2DArray, renderEmailTemplate, renderTemplate, toNumberOrNull, toUINConfigDTO, uinConfigService, type updateStatusParams };
package/dist/index.d.ts CHANGED
@@ -846,6 +846,8 @@ declare const getPattern: {
846
846
  declare const interpolate: (template: string, vars: Record<string, unknown>) => string;
847
847
  declare const fromTimestampToSqlDatetime: (date: string) => string;
848
848
  declare function formatDatesDeep<T>(data: T, format?: string): T;
849
+ declare function generateMd5(text: string): string;
850
+ declare const generateHashForAuth: (randomNum: string) => string;
849
851
 
850
852
  interface CreateTransaction {
851
853
  field: string;
@@ -1024,4 +1026,4 @@ declare class AuditProxy<Module extends string = "OPD" | "PROCEDURE" | "GENERAL_
1024
1026
  createAuditedService<T extends object>(serviceName: string, service: T): T;
1025
1027
  }
1026
1028
 
1027
- export { type ActInput, ActionMode, type ApprovalAction, type ApprovalActionDto, type ApprovalDeps, type ApprovalFlow, type ApprovalInstance, type ApprovalInstanceByUser, ApprovalService, ApprovalStatus, type ApprovalStep, type ApproverMapping, type AuditContext, type AuditContextProvider, AuditCore, type AuditLogPayload, AuditLogger, AuditProxy, type BulkAtomicResult, type BulkConfig, type BulkConflictConfig, type BulkOnConflict, type CacheAdapter, type CalculationRes, type ColValue, type CommonApproveReq, type CommonCreateRequestRepository, type CommonExcelRequest, type CommonFilterRequest, type CommonFilterWithDate, type CommonGetApprovalActionReq, type CommonServiceResponse, type CommonUpdateRequestRepository, type Config, type Context, type CreateApprovalFlow, 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 EventInstance, type ExcelConfig, type ExportExcel, type ExportExcelRequestService, type FetchRequest, type FetchRequestRepository, type FieldConfig, type FieldRules, type FieldType, type FixedMap, type FixedSearchRequest, type FixedSearchRequestService, FlowType, type FlowWithSelectedStepResponse, type FlowWithStepsResponse, type GetMyApprovalFlow, type GetPendingApprovalReq, type Helpers, type IApprovalStep, type IChildConfigData, type IChildConfigJSON, type ICommonApprovalUpdate, type IParentConfigData, type IParentConfigJSON, type ImportExcel, type ImportExcelRequestService, type LevelDoneEvt, type LevelReadyEvt, type LockUnlockParams, type LockUnlockRequestRepository, type LogicNode, type Mapper, type MergeAll, type NewFixedSearchRequest, type NewFixedSearchRequestService, type NewSearchRequest, NotificationEmitter, type NotificationEvent, type Op, type PaginatedResponse, type PathToSelectWithSelect, type PathValue, type PathsToSelectWithSelect, type Presence, type PrismaTransactionClient, type RawFlowWithSelectedStepResponse, type Recipient, type RelationConfig, type RelationStrategy, type RelationWriteConfig, type SearchRequest, type SearchRequestService, type ServiceCacheAdapter, type SingleValidationMapping, type SourcePath, type StartFlowReq, type StepType, 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 UpdateApprovalFlow, type UpdateConfigByCodeInput, type UpdateStatusRequestRepository, type UpdateUINConfigRequest, type ValidationErrorItem, approvalRepository, commonService, convertArrayPatternToEachBlocksGeneric, customOmit, findDifferences, formatDatesDeep, fromTimestampToSqlDatetime, getDynamicValue, getNestedValue, getNestedValueV2, getPattern, interpolate, objectTo2DArray, renderEmailTemplate, renderTemplate, toNumberOrNull, toUINConfigDTO, uinConfigService, type updateStatusParams };
1029
+ export { type ActInput, ActionMode, type ApprovalAction, type ApprovalActionDto, type ApprovalDeps, type ApprovalFlow, type ApprovalInstance, type ApprovalInstanceByUser, ApprovalService, ApprovalStatus, type ApprovalStep, type ApproverMapping, type AuditContext, type AuditContextProvider, AuditCore, type AuditLogPayload, AuditLogger, AuditProxy, type BulkAtomicResult, type BulkConfig, type BulkConflictConfig, type BulkOnConflict, type CacheAdapter, type CalculationRes, type ColValue, type CommonApproveReq, type CommonCreateRequestRepository, type CommonExcelRequest, type CommonFilterRequest, type CommonFilterWithDate, type CommonGetApprovalActionReq, type CommonServiceResponse, type CommonUpdateRequestRepository, type Config, type Context, type CreateApprovalFlow, 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 EventInstance, type ExcelConfig, type ExportExcel, type ExportExcelRequestService, type FetchRequest, type FetchRequestRepository, type FieldConfig, type FieldRules, type FieldType, type FixedMap, type FixedSearchRequest, type FixedSearchRequestService, FlowType, type FlowWithSelectedStepResponse, type FlowWithStepsResponse, type GetMyApprovalFlow, type GetPendingApprovalReq, type Helpers, type IApprovalStep, type IChildConfigData, type IChildConfigJSON, type ICommonApprovalUpdate, type IParentConfigData, type IParentConfigJSON, type ImportExcel, type ImportExcelRequestService, type LevelDoneEvt, type LevelReadyEvt, type LockUnlockParams, type LockUnlockRequestRepository, type LogicNode, type Mapper, type MergeAll, type NewFixedSearchRequest, type NewFixedSearchRequestService, type NewSearchRequest, NotificationEmitter, type NotificationEvent, type Op, type PaginatedResponse, type PathToSelectWithSelect, type PathValue, type PathsToSelectWithSelect, type Presence, type PrismaTransactionClient, type RawFlowWithSelectedStepResponse, type Recipient, type RelationConfig, type RelationStrategy, type RelationWriteConfig, type SearchRequest, type SearchRequestService, type ServiceCacheAdapter, type SingleValidationMapping, type SourcePath, type StartFlowReq, type StepType, 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 UpdateApprovalFlow, type UpdateConfigByCodeInput, type UpdateStatusRequestRepository, type UpdateUINConfigRequest, type ValidationErrorItem, approvalRepository, commonService, convertArrayPatternToEachBlocksGeneric, customOmit, findDifferences, formatDatesDeep, fromTimestampToSqlDatetime, generateHashForAuth, generateMd5, getDynamicValue, getNestedValue, getNestedValueV2, getPattern, interpolate, objectTo2DArray, renderEmailTemplate, renderTemplate, toNumberOrNull, toUINConfigDTO, uinConfigService, type updateStatusParams };
package/dist/index.js CHANGED
@@ -45,6 +45,8 @@ __export(index_exports, {
45
45
  findDifferences: () => findDifferences,
46
46
  formatDatesDeep: () => formatDatesDeep,
47
47
  fromTimestampToSqlDatetime: () => fromTimestampToSqlDatetime,
48
+ generateHashForAuth: () => generateHashForAuth,
49
+ generateMd5: () => generateMd5,
48
50
  getDynamicValue: () => getDynamicValue,
49
51
  getNestedValue: () => getNestedValue,
50
52
  getNestedValueV2: () => getNestedValueV2,
@@ -1320,8 +1322,12 @@ var commonCreateUpdateRepository = (serviceDeps) => {
1320
1322
  var import_joi = __toESM(require("joi"));
1321
1323
  var import_dayjs2 = __toESM(require("dayjs"));
1322
1324
 
1325
+ // src/enums/message.enums.ts
1326
+ var CLIENT_ID = "xexwkrdRDH9A4ASgkknZ";
1327
+
1323
1328
  // src/utils/helper.utils.ts
1324
1329
  var import_dayjs = __toESM(require("dayjs"));
1330
+ var import_crypto = __toESM(require("crypto"));
1325
1331
  function customOmit(obj, keys) {
1326
1332
  const rest = { ...obj };
1327
1333
  const omitted = {};
@@ -1486,6 +1492,13 @@ function formatDatesDeep(data, format = "YYYY-MM-DD") {
1486
1492
  }
1487
1493
  return data;
1488
1494
  }
1495
+ function generateMd5(text) {
1496
+ return import_crypto.default.createHash("md5").update(text).digest("hex");
1497
+ }
1498
+ var generateHashForAuth = (randomNum) => {
1499
+ const firstHash = generateMd5(CLIENT_ID);
1500
+ return generateMd5(firstHash + randomNum);
1501
+ };
1489
1502
 
1490
1503
  // src/utils/dynamicJoiBuilder.utils.ts
1491
1504
  function applyNumberCompare(schema, op, ref) {
@@ -2471,6 +2484,21 @@ var approvalRepository = (helpers) => {
2471
2484
  };
2472
2485
  };
2473
2486
 
2487
+ // src/config/axiosClient.config.ts
2488
+ var import_axios2 = __toESM(require("axios"));
2489
+ var externalInterceptor = () => {
2490
+ const randomNumber = Math.floor(Math.random() * 1e6);
2491
+ const hash = generateHashForAuth(randomNumber.toString());
2492
+ return import_axios2.default.create({
2493
+ headers: {
2494
+ "Content-Type": "application/json",
2495
+ "client-key": hash,
2496
+ "client-id": randomNumber.toString()
2497
+ },
2498
+ validateStatus: () => true
2499
+ });
2500
+ };
2501
+
2474
2502
  // src/services/approval.service.ts
2475
2503
  var ApprovalService = class {
2476
2504
  constructor(deps) {
@@ -2573,7 +2601,7 @@ var ApprovalService = class {
2573
2601
  }
2574
2602
  });
2575
2603
  setImmediate(
2576
- () => this.emitEvents({
2604
+ async () => await this.emitEvents({
2577
2605
  instance: updated,
2578
2606
  flowType: inst.flow?.flowType,
2579
2607
  approverId,
@@ -2684,17 +2712,18 @@ var ApprovalService = class {
2684
2712
  service: instance.service
2685
2713
  });
2686
2714
  } else {
2715
+ const client = externalInterceptor();
2687
2716
  switch (instance.status) {
2688
2717
  case "APPROVED" /* APPROVED */:
2689
2718
  if (approvalFlow.approveActionUrl) {
2690
- const res = await fetch(approvalFlow.approveActionUrl, {
2691
- method: "POST",
2692
- headers: {
2693
- "Content-Type": "application/json"
2694
- },
2695
- body: JSON.stringify({ id: instance.id, subjectId: instance.subjectId })
2696
- });
2697
- if (!res.ok) {
2719
+ const res = await client.post(
2720
+ approvalFlow.approveActionUrl,
2721
+ { id: instance.id, subjectId: instance.subjectId },
2722
+ {
2723
+ validateStatus: (s) => s === 200 || s === 404
2724
+ }
2725
+ );
2726
+ if (res.status !== 200) {
2698
2727
  this.deps.logger.error(
2699
2728
  "[Approval Service] Approve action URL webhook failed",
2700
2729
  res.status,
@@ -2705,26 +2734,28 @@ var ApprovalService = class {
2705
2734
  break;
2706
2735
  case "REJECTED" /* REJECTED */:
2707
2736
  if (approvalFlow.rejectActionUrl) {
2708
- const res = await fetch(approvalFlow.rejectActionUrl, {
2709
- method: "POST",
2710
- headers: {
2711
- "Content-Type": "application/json"
2737
+ const res = await client.post(
2738
+ approvalFlow.rejectActionUrl,
2739
+ { id: instance.id, subjectId: instance.subjectId },
2740
+ {
2741
+ validateStatus: (s) => s === 200 || s === 404
2712
2742
  }
2713
- });
2714
- if (!res.ok) {
2743
+ );
2744
+ if (res.status !== 200) {
2715
2745
  this.deps.logger.error("[Approval Service] Reject action URL webhook failed", res.status, res.statusText);
2716
2746
  }
2717
2747
  }
2718
2748
  break;
2719
2749
  case "PARTIALLY_APPROVED" /* PARTIALLY_APPROVED */:
2720
2750
  if (approvalFlow.partiallyApproveActionUrl) {
2721
- const res = await fetch(approvalFlow.partiallyApproveActionUrl, {
2722
- method: "POST",
2723
- headers: {
2724
- "Content-Type": "application/json"
2751
+ const res = await client.post(
2752
+ approvalFlow.partiallyApproveActionUrl,
2753
+ { id: instance.id, subjectId: instance.subjectId },
2754
+ {
2755
+ validateStatus: (s) => s === 200 || s === 404
2725
2756
  }
2726
- });
2727
- if (!res.ok) {
2757
+ );
2758
+ if (res.status !== 200) {
2728
2759
  this.deps.logger.error(
2729
2760
  "[Approval Service] Partially approve action URL webhook failed",
2730
2761
  res.status,
@@ -3322,7 +3353,7 @@ var EmailProvider = class {
3322
3353
  };
3323
3354
 
3324
3355
  // src/providers/sms.provider.ts
3325
- var import_axios2 = __toESM(require("axios"));
3356
+ var import_axios3 = __toESM(require("axios"));
3326
3357
  var import_node_https = __toESM(require("https"));
3327
3358
  var import_promises = __toESM(require("dns/promises"));
3328
3359
  var import_node_url = require("url");
@@ -3428,7 +3459,7 @@ var SmsProvider = class {
3428
3459
  servername: host
3429
3460
  // ✅ TLS SNI
3430
3461
  });
3431
- return import_axios2.default.post(ipUrl, payload, {
3462
+ return import_axios3.default.post(ipUrl, payload, {
3432
3463
  timeout: 15e3,
3433
3464
  httpsAgent,
3434
3465
  headers: {
@@ -3515,7 +3546,7 @@ var WebNotificationProvider = class {
3515
3546
  };
3516
3547
 
3517
3548
  // src/providers/whatsapp.provider.ts
3518
- var import_axios3 = __toESM(require("axios"));
3549
+ var import_axios4 = __toESM(require("axios"));
3519
3550
 
3520
3551
  // src/utils/notification.utils.ts
3521
3552
  function defaultValueField(t) {
@@ -3895,7 +3926,7 @@ var WhatsAppProvider = class {
3895
3926
  }
3896
3927
  try {
3897
3928
  const { requestBody, headers } = this.buildRequest(to, inp);
3898
- const response = await import_axios3.default.post(this.apiUrl, requestBody, { headers });
3929
+ const response = await import_axios4.default.post(this.apiUrl, requestBody, { headers });
3899
3930
  const data = response.data;
3900
3931
  return {
3901
3932
  ok: true,
@@ -3953,7 +3984,7 @@ var WhatsAppProvider = class {
3953
3984
  const items = await mapWithConcurrency(recipients, concurrency, async (recipient) => {
3954
3985
  try {
3955
3986
  const { requestBody, headers } = this.buildRequest(recipient, baseInp);
3956
- const response = await import_axios3.default.post(this.apiUrl, requestBody, { headers });
3987
+ const response = await import_axios4.default.post(this.apiUrl, requestBody, { headers });
3957
3988
  const data = response.data;
3958
3989
  return {
3959
3990
  recipient,
@@ -4818,6 +4849,8 @@ var AuditProxy = class {
4818
4849
  findDifferences,
4819
4850
  formatDatesDeep,
4820
4851
  fromTimestampToSqlDatetime,
4852
+ generateHashForAuth,
4853
+ generateMd5,
4821
4854
  getDynamicValue,
4822
4855
  getNestedValue,
4823
4856
  getNestedValueV2,
package/dist/index.mjs CHANGED
@@ -1259,8 +1259,12 @@ var commonCreateUpdateRepository = (serviceDeps) => {
1259
1259
  import Joi from "joi";
1260
1260
  import dayjs2 from "dayjs";
1261
1261
 
1262
+ // src/enums/message.enums.ts
1263
+ var CLIENT_ID = "xexwkrdRDH9A4ASgkknZ";
1264
+
1262
1265
  // src/utils/helper.utils.ts
1263
1266
  import dayjs from "dayjs";
1267
+ import crypto from "crypto";
1264
1268
  function customOmit(obj, keys) {
1265
1269
  const rest = { ...obj };
1266
1270
  const omitted = {};
@@ -1425,6 +1429,13 @@ function formatDatesDeep(data, format = "YYYY-MM-DD") {
1425
1429
  }
1426
1430
  return data;
1427
1431
  }
1432
+ function generateMd5(text) {
1433
+ return crypto.createHash("md5").update(text).digest("hex");
1434
+ }
1435
+ var generateHashForAuth = (randomNum) => {
1436
+ const firstHash = generateMd5(CLIENT_ID);
1437
+ return generateMd5(firstHash + randomNum);
1438
+ };
1428
1439
 
1429
1440
  // src/utils/dynamicJoiBuilder.utils.ts
1430
1441
  function applyNumberCompare(schema, op, ref) {
@@ -2410,6 +2421,21 @@ var approvalRepository = (helpers) => {
2410
2421
  };
2411
2422
  };
2412
2423
 
2424
+ // src/config/axiosClient.config.ts
2425
+ import axios2 from "axios";
2426
+ var externalInterceptor = () => {
2427
+ const randomNumber = Math.floor(Math.random() * 1e6);
2428
+ const hash = generateHashForAuth(randomNumber.toString());
2429
+ return axios2.create({
2430
+ headers: {
2431
+ "Content-Type": "application/json",
2432
+ "client-key": hash,
2433
+ "client-id": randomNumber.toString()
2434
+ },
2435
+ validateStatus: () => true
2436
+ });
2437
+ };
2438
+
2413
2439
  // src/services/approval.service.ts
2414
2440
  var ApprovalService = class {
2415
2441
  constructor(deps) {
@@ -2512,7 +2538,7 @@ var ApprovalService = class {
2512
2538
  }
2513
2539
  });
2514
2540
  setImmediate(
2515
- () => this.emitEvents({
2541
+ async () => await this.emitEvents({
2516
2542
  instance: updated,
2517
2543
  flowType: inst.flow?.flowType,
2518
2544
  approverId,
@@ -2623,17 +2649,18 @@ var ApprovalService = class {
2623
2649
  service: instance.service
2624
2650
  });
2625
2651
  } else {
2652
+ const client = externalInterceptor();
2626
2653
  switch (instance.status) {
2627
2654
  case "APPROVED" /* APPROVED */:
2628
2655
  if (approvalFlow.approveActionUrl) {
2629
- const res = await fetch(approvalFlow.approveActionUrl, {
2630
- method: "POST",
2631
- headers: {
2632
- "Content-Type": "application/json"
2633
- },
2634
- body: JSON.stringify({ id: instance.id, subjectId: instance.subjectId })
2635
- });
2636
- if (!res.ok) {
2656
+ const res = await client.post(
2657
+ approvalFlow.approveActionUrl,
2658
+ { id: instance.id, subjectId: instance.subjectId },
2659
+ {
2660
+ validateStatus: (s) => s === 200 || s === 404
2661
+ }
2662
+ );
2663
+ if (res.status !== 200) {
2637
2664
  this.deps.logger.error(
2638
2665
  "[Approval Service] Approve action URL webhook failed",
2639
2666
  res.status,
@@ -2644,26 +2671,28 @@ var ApprovalService = class {
2644
2671
  break;
2645
2672
  case "REJECTED" /* REJECTED */:
2646
2673
  if (approvalFlow.rejectActionUrl) {
2647
- const res = await fetch(approvalFlow.rejectActionUrl, {
2648
- method: "POST",
2649
- headers: {
2650
- "Content-Type": "application/json"
2674
+ const res = await client.post(
2675
+ approvalFlow.rejectActionUrl,
2676
+ { id: instance.id, subjectId: instance.subjectId },
2677
+ {
2678
+ validateStatus: (s) => s === 200 || s === 404
2651
2679
  }
2652
- });
2653
- if (!res.ok) {
2680
+ );
2681
+ if (res.status !== 200) {
2654
2682
  this.deps.logger.error("[Approval Service] Reject action URL webhook failed", res.status, res.statusText);
2655
2683
  }
2656
2684
  }
2657
2685
  break;
2658
2686
  case "PARTIALLY_APPROVED" /* PARTIALLY_APPROVED */:
2659
2687
  if (approvalFlow.partiallyApproveActionUrl) {
2660
- const res = await fetch(approvalFlow.partiallyApproveActionUrl, {
2661
- method: "POST",
2662
- headers: {
2663
- "Content-Type": "application/json"
2688
+ const res = await client.post(
2689
+ approvalFlow.partiallyApproveActionUrl,
2690
+ { id: instance.id, subjectId: instance.subjectId },
2691
+ {
2692
+ validateStatus: (s) => s === 200 || s === 404
2664
2693
  }
2665
- });
2666
- if (!res.ok) {
2694
+ );
2695
+ if (res.status !== 200) {
2667
2696
  this.deps.logger.error(
2668
2697
  "[Approval Service] Partially approve action URL webhook failed",
2669
2698
  res.status,
@@ -3261,7 +3290,7 @@ var EmailProvider = class {
3261
3290
  };
3262
3291
 
3263
3292
  // src/providers/sms.provider.ts
3264
- import axios2 from "axios";
3293
+ import axios3 from "axios";
3265
3294
  import https from "https";
3266
3295
  import dns from "dns/promises";
3267
3296
  import { URL } from "url";
@@ -3367,7 +3396,7 @@ var SmsProvider = class {
3367
3396
  servername: host
3368
3397
  // ✅ TLS SNI
3369
3398
  });
3370
- return axios2.post(ipUrl, payload, {
3399
+ return axios3.post(ipUrl, payload, {
3371
3400
  timeout: 15e3,
3372
3401
  httpsAgent,
3373
3402
  headers: {
@@ -3454,7 +3483,7 @@ var WebNotificationProvider = class {
3454
3483
  };
3455
3484
 
3456
3485
  // src/providers/whatsapp.provider.ts
3457
- import axios3 from "axios";
3486
+ import axios4 from "axios";
3458
3487
 
3459
3488
  // src/utils/notification.utils.ts
3460
3489
  function defaultValueField(t) {
@@ -3834,7 +3863,7 @@ var WhatsAppProvider = class {
3834
3863
  }
3835
3864
  try {
3836
3865
  const { requestBody, headers } = this.buildRequest(to, inp);
3837
- const response = await axios3.post(this.apiUrl, requestBody, { headers });
3866
+ const response = await axios4.post(this.apiUrl, requestBody, { headers });
3838
3867
  const data = response.data;
3839
3868
  return {
3840
3869
  ok: true,
@@ -3892,7 +3921,7 @@ var WhatsAppProvider = class {
3892
3921
  const items = await mapWithConcurrency(recipients, concurrency, async (recipient) => {
3893
3922
  try {
3894
3923
  const { requestBody, headers } = this.buildRequest(recipient, baseInp);
3895
- const response = await axios3.post(this.apiUrl, requestBody, { headers });
3924
+ const response = await axios4.post(this.apiUrl, requestBody, { headers });
3896
3925
  const data = response.data;
3897
3926
  return {
3898
3927
  recipient,
@@ -4756,6 +4785,8 @@ export {
4756
4785
  findDifferences,
4757
4786
  formatDatesDeep,
4758
4787
  fromTimestampToSqlDatetime,
4788
+ generateHashForAuth,
4789
+ generateMd5,
4759
4790
  getDynamicValue,
4760
4791
  getNestedValue,
4761
4792
  getNestedValueV2,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "av6-core",
3
- "version": "1.8.6",
3
+ "version": "1.8.8",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",