av6-core 1.8.5 → 1.8.7

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
@@ -522,19 +522,19 @@ interface CommonServiceResponse {
522
522
  declare const commonService: (serviceDeps: Deps) => CommonServiceResponse;
523
523
 
524
524
  declare enum ApprovalStatus {
525
- PENDING = 0,
526
- PARTIALLY_APPROVED = 1,
527
- APPROVED = 2,
528
- REJECTED = 3,
529
- CANCELLED = 4
525
+ PENDING = "PENDING",
526
+ PARTIALLY_APPROVED = "PARTIALLY_APPROVED",
527
+ APPROVED = "APPROVED",
528
+ REJECTED = "REJECTED",
529
+ CANCELLED = "CANCELLED"
530
530
  }
531
531
  declare enum FlowType {
532
- STATUS = 0,
533
- CO_PAY = 1,
534
- INDIVIDUAL_DISCOUNT = 2,
535
- OVERALL_DISCOUNT = 3,
536
- SPECIAL_DISCOUNT = 4,
537
- REFUND = 5
532
+ STATUS = "STATUS",
533
+ CO_PAY = "CO_PAY",
534
+ INDIVIDUAL_DISCOUNT = "INDIVIDUAL_DISCOUNT",
535
+ OVERALL_DISCOUNT = "OVERALL_DISCOUNT",
536
+ SPECIAL_DISCOUNT = "SPECIAL_DISCOUNT",
537
+ REFUND = "REFUND"
538
538
  }
539
539
  type StepType = "MIN_MAX" | "NORMAL";
540
540
  declare enum ActionMode {
@@ -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
@@ -522,19 +522,19 @@ interface CommonServiceResponse {
522
522
  declare const commonService: (serviceDeps: Deps) => CommonServiceResponse;
523
523
 
524
524
  declare enum ApprovalStatus {
525
- PENDING = 0,
526
- PARTIALLY_APPROVED = 1,
527
- APPROVED = 2,
528
- REJECTED = 3,
529
- CANCELLED = 4
525
+ PENDING = "PENDING",
526
+ PARTIALLY_APPROVED = "PARTIALLY_APPROVED",
527
+ APPROVED = "APPROVED",
528
+ REJECTED = "REJECTED",
529
+ CANCELLED = "CANCELLED"
530
530
  }
531
531
  declare enum FlowType {
532
- STATUS = 0,
533
- CO_PAY = 1,
534
- INDIVIDUAL_DISCOUNT = 2,
535
- OVERALL_DISCOUNT = 3,
536
- SPECIAL_DISCOUNT = 4,
537
- REFUND = 5
532
+ STATUS = "STATUS",
533
+ CO_PAY = "CO_PAY",
534
+ INDIVIDUAL_DISCOUNT = "INDIVIDUAL_DISCOUNT",
535
+ OVERALL_DISCOUNT = "OVERALL_DISCOUNT",
536
+ SPECIAL_DISCOUNT = "SPECIAL_DISCOUNT",
537
+ REFUND = "REFUND"
538
538
  }
539
539
  type StepType = "MIN_MAX" | "NORMAL";
540
540
  declare enum ActionMode {
@@ -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) {
@@ -2307,20 +2320,20 @@ var commonService = (serviceDeps) => {
2307
2320
 
2308
2321
  // src/types/approval.type.ts
2309
2322
  var ApprovalStatus = /* @__PURE__ */ ((ApprovalStatus2) => {
2310
- ApprovalStatus2[ApprovalStatus2["PENDING"] = 0] = "PENDING";
2311
- ApprovalStatus2[ApprovalStatus2["PARTIALLY_APPROVED"] = 1] = "PARTIALLY_APPROVED";
2312
- ApprovalStatus2[ApprovalStatus2["APPROVED"] = 2] = "APPROVED";
2313
- ApprovalStatus2[ApprovalStatus2["REJECTED"] = 3] = "REJECTED";
2314
- ApprovalStatus2[ApprovalStatus2["CANCELLED"] = 4] = "CANCELLED";
2323
+ ApprovalStatus2["PENDING"] = "PENDING";
2324
+ ApprovalStatus2["PARTIALLY_APPROVED"] = "PARTIALLY_APPROVED";
2325
+ ApprovalStatus2["APPROVED"] = "APPROVED";
2326
+ ApprovalStatus2["REJECTED"] = "REJECTED";
2327
+ ApprovalStatus2["CANCELLED"] = "CANCELLED";
2315
2328
  return ApprovalStatus2;
2316
2329
  })(ApprovalStatus || {});
2317
2330
  var FlowType = /* @__PURE__ */ ((FlowType3) => {
2318
- FlowType3[FlowType3["STATUS"] = 0] = "STATUS";
2319
- FlowType3[FlowType3["CO_PAY"] = 1] = "CO_PAY";
2320
- FlowType3[FlowType3["INDIVIDUAL_DISCOUNT"] = 2] = "INDIVIDUAL_DISCOUNT";
2321
- FlowType3[FlowType3["OVERALL_DISCOUNT"] = 3] = "OVERALL_DISCOUNT";
2322
- FlowType3[FlowType3["SPECIAL_DISCOUNT"] = 4] = "SPECIAL_DISCOUNT";
2323
- FlowType3[FlowType3["REFUND"] = 5] = "REFUND";
2331
+ FlowType3["STATUS"] = "STATUS";
2332
+ FlowType3["CO_PAY"] = "CO_PAY";
2333
+ FlowType3["INDIVIDUAL_DISCOUNT"] = "INDIVIDUAL_DISCOUNT";
2334
+ FlowType3["OVERALL_DISCOUNT"] = "OVERALL_DISCOUNT";
2335
+ FlowType3["SPECIAL_DISCOUNT"] = "SPECIAL_DISCOUNT";
2336
+ FlowType3["REFUND"] = "REFUND";
2324
2337
  return FlowType3;
2325
2338
  })(FlowType || {});
2326
2339
  var ActionMode = /* @__PURE__ */ ((ActionMode2) => {
@@ -2372,7 +2385,7 @@ var approvalRepository = (helpers) => {
2372
2385
  startDate,
2373
2386
  endDate,
2374
2387
  searchText = "",
2375
- status = [0 /* PENDING */, 1 /* PARTIALLY_APPROVED */],
2388
+ status = ["PENDING" /* PENDING */, "PARTIALLY_APPROVED" /* PARTIALLY_APPROVED */],
2376
2389
  flowType
2377
2390
  }) {
2378
2391
  const offset = (pageNo - 1) * pageSize;
@@ -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) {
@@ -2541,7 +2569,7 @@ var ApprovalService = class {
2541
2569
  return s.stepType === "NORMAL" || s.stepType === "MIN_MAX" && Number(inst.netTotal) >= Number(s.minAmount) && Number(inst.netTotal) <= Number(s.maxAmount);
2542
2570
  });
2543
2571
  const lastLevel = await this.lastLevel(inst.flow.steps);
2544
- const newStatus = action === "REJECT" ? 3 /* REJECTED */ : step.level === lastLevel ? 2 /* APPROVED */ : 1 /* PARTIALLY_APPROVED */;
2572
+ const newStatus = action === "REJECT" ? "REJECTED" /* REJECTED */ : step.level === lastLevel ? "APPROVED" /* APPROVED */ : "PARTIALLY_APPROVED" /* PARTIALLY_APPROVED */;
2545
2573
  await tx.approvalAction.create({
2546
2574
  data: {
2547
2575
  instanceId,
@@ -2552,7 +2580,7 @@ var ApprovalService = class {
2552
2580
  }
2553
2581
  });
2554
2582
  let newFlow = null;
2555
- if (newStatus === 1 /* PARTIALLY_APPROVED */) {
2583
+ if (newStatus === "PARTIALLY_APPROVED" /* PARTIALLY_APPROVED */) {
2556
2584
  newFlow = await this.approvalRepo.findMatchingFlow(
2557
2585
  tx,
2558
2586
  inst.flow.subjectType,
@@ -2568,7 +2596,7 @@ var ApprovalService = class {
2568
2596
  const updated = await tx.approvalInstance.update({
2569
2597
  where: { id: instanceId },
2570
2598
  data: {
2571
- currentStep: newStatus === 1 /* PARTIALLY_APPROVED */ ? newFlow?.stepId : step.id,
2599
+ currentStep: newStatus === "PARTIALLY_APPROVED" /* PARTIALLY_APPROVED */ ? newFlow?.stepId : step.id,
2572
2600
  status: newStatus
2573
2601
  }
2574
2602
  });
@@ -2589,7 +2617,7 @@ var ApprovalService = class {
2589
2617
  action,
2590
2618
  comment
2591
2619
  });
2592
- if (newStatus === 1 /* PARTIALLY_APPROVED */) {
2620
+ if (newStatus === "PARTIALLY_APPROVED" /* PARTIALLY_APPROVED */) {
2593
2621
  const nextLevel = step.level + 1;
2594
2622
  const approvers = await tx.approverMapping.findMany({
2595
2623
  where: { stepId: updated.currentStep, ccId, isActive: true }
@@ -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
- case 2 /* APPROVED */:
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,
@@ -2703,28 +2732,30 @@ var ApprovalService = class {
2703
2732
  }
2704
2733
  }
2705
2734
  break;
2706
- case 3 /* REJECTED */:
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
- case 1 /* PARTIALLY_APPROVED */:
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) {
@@ -2246,20 +2257,20 @@ var commonService = (serviceDeps) => {
2246
2257
 
2247
2258
  // src/types/approval.type.ts
2248
2259
  var ApprovalStatus = /* @__PURE__ */ ((ApprovalStatus2) => {
2249
- ApprovalStatus2[ApprovalStatus2["PENDING"] = 0] = "PENDING";
2250
- ApprovalStatus2[ApprovalStatus2["PARTIALLY_APPROVED"] = 1] = "PARTIALLY_APPROVED";
2251
- ApprovalStatus2[ApprovalStatus2["APPROVED"] = 2] = "APPROVED";
2252
- ApprovalStatus2[ApprovalStatus2["REJECTED"] = 3] = "REJECTED";
2253
- ApprovalStatus2[ApprovalStatus2["CANCELLED"] = 4] = "CANCELLED";
2260
+ ApprovalStatus2["PENDING"] = "PENDING";
2261
+ ApprovalStatus2["PARTIALLY_APPROVED"] = "PARTIALLY_APPROVED";
2262
+ ApprovalStatus2["APPROVED"] = "APPROVED";
2263
+ ApprovalStatus2["REJECTED"] = "REJECTED";
2264
+ ApprovalStatus2["CANCELLED"] = "CANCELLED";
2254
2265
  return ApprovalStatus2;
2255
2266
  })(ApprovalStatus || {});
2256
2267
  var FlowType = /* @__PURE__ */ ((FlowType3) => {
2257
- FlowType3[FlowType3["STATUS"] = 0] = "STATUS";
2258
- FlowType3[FlowType3["CO_PAY"] = 1] = "CO_PAY";
2259
- FlowType3[FlowType3["INDIVIDUAL_DISCOUNT"] = 2] = "INDIVIDUAL_DISCOUNT";
2260
- FlowType3[FlowType3["OVERALL_DISCOUNT"] = 3] = "OVERALL_DISCOUNT";
2261
- FlowType3[FlowType3["SPECIAL_DISCOUNT"] = 4] = "SPECIAL_DISCOUNT";
2262
- FlowType3[FlowType3["REFUND"] = 5] = "REFUND";
2268
+ FlowType3["STATUS"] = "STATUS";
2269
+ FlowType3["CO_PAY"] = "CO_PAY";
2270
+ FlowType3["INDIVIDUAL_DISCOUNT"] = "INDIVIDUAL_DISCOUNT";
2271
+ FlowType3["OVERALL_DISCOUNT"] = "OVERALL_DISCOUNT";
2272
+ FlowType3["SPECIAL_DISCOUNT"] = "SPECIAL_DISCOUNT";
2273
+ FlowType3["REFUND"] = "REFUND";
2263
2274
  return FlowType3;
2264
2275
  })(FlowType || {});
2265
2276
  var ActionMode = /* @__PURE__ */ ((ActionMode2) => {
@@ -2311,7 +2322,7 @@ var approvalRepository = (helpers) => {
2311
2322
  startDate,
2312
2323
  endDate,
2313
2324
  searchText = "",
2314
- status = [0 /* PENDING */, 1 /* PARTIALLY_APPROVED */],
2325
+ status = ["PENDING" /* PENDING */, "PARTIALLY_APPROVED" /* PARTIALLY_APPROVED */],
2315
2326
  flowType
2316
2327
  }) {
2317
2328
  const offset = (pageNo - 1) * pageSize;
@@ -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) {
@@ -2480,7 +2506,7 @@ var ApprovalService = class {
2480
2506
  return s.stepType === "NORMAL" || s.stepType === "MIN_MAX" && Number(inst.netTotal) >= Number(s.minAmount) && Number(inst.netTotal) <= Number(s.maxAmount);
2481
2507
  });
2482
2508
  const lastLevel = await this.lastLevel(inst.flow.steps);
2483
- const newStatus = action === "REJECT" ? 3 /* REJECTED */ : step.level === lastLevel ? 2 /* APPROVED */ : 1 /* PARTIALLY_APPROVED */;
2509
+ const newStatus = action === "REJECT" ? "REJECTED" /* REJECTED */ : step.level === lastLevel ? "APPROVED" /* APPROVED */ : "PARTIALLY_APPROVED" /* PARTIALLY_APPROVED */;
2484
2510
  await tx.approvalAction.create({
2485
2511
  data: {
2486
2512
  instanceId,
@@ -2491,7 +2517,7 @@ var ApprovalService = class {
2491
2517
  }
2492
2518
  });
2493
2519
  let newFlow = null;
2494
- if (newStatus === 1 /* PARTIALLY_APPROVED */) {
2520
+ if (newStatus === "PARTIALLY_APPROVED" /* PARTIALLY_APPROVED */) {
2495
2521
  newFlow = await this.approvalRepo.findMatchingFlow(
2496
2522
  tx,
2497
2523
  inst.flow.subjectType,
@@ -2507,7 +2533,7 @@ var ApprovalService = class {
2507
2533
  const updated = await tx.approvalInstance.update({
2508
2534
  where: { id: instanceId },
2509
2535
  data: {
2510
- currentStep: newStatus === 1 /* PARTIALLY_APPROVED */ ? newFlow?.stepId : step.id,
2536
+ currentStep: newStatus === "PARTIALLY_APPROVED" /* PARTIALLY_APPROVED */ ? newFlow?.stepId : step.id,
2511
2537
  status: newStatus
2512
2538
  }
2513
2539
  });
@@ -2528,7 +2554,7 @@ var ApprovalService = class {
2528
2554
  action,
2529
2555
  comment
2530
2556
  });
2531
- if (newStatus === 1 /* PARTIALLY_APPROVED */) {
2557
+ if (newStatus === "PARTIALLY_APPROVED" /* PARTIALLY_APPROVED */) {
2532
2558
  const nextLevel = step.level + 1;
2533
2559
  const approvers = await tx.approverMapping.findMany({
2534
2560
  where: { stepId: updated.currentStep, ccId, isActive: true }
@@ -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
- case 2 /* APPROVED */:
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,
@@ -2642,28 +2669,30 @@ var ApprovalService = class {
2642
2669
  }
2643
2670
  }
2644
2671
  break;
2645
- case 3 /* REJECTED */:
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
- case 1 /* PARTIALLY_APPROVED */:
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.5",
3
+ "version": "1.8.7",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",