@benup/bensdk 1.13.4 → 1.13.5

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.
@@ -1,6 +1,7 @@
1
1
  import z from 'zod';
2
2
  import { EmploymentContracts } from '@benup-dev/benup-api';
3
3
  import { AxiosInstance } from 'axios';
4
+ import pino from 'pino';
4
5
  import { BenefitDefinitionSchema } from '../schemas/benefit-definition.schema';
5
6
  import { LockHelper } from './lib/lock-helper.lib.type';
6
7
  import { TokenHelper } from './lib/token-helper.lib.type';
@@ -35,6 +36,34 @@ export type RateLimitConfig = {
35
36
  maxExecutionsPerWindow: number;
36
37
  windowSeconds: number;
37
38
  };
39
+ export type DeductionSftpHandlerInput = {
40
+ deductionID: string;
41
+ payrollConfigurationID: string;
42
+ accountID: string;
43
+ companyID: string;
44
+ rawLineNumber: number;
45
+ rawLine: string;
46
+ };
47
+ export type DeductionSftpHandlerCtx = {
48
+ logger: pino.Logger;
49
+ benupAPI: AxiosInstance;
50
+ };
51
+ export type DeductionSftpHandlerResult = {
52
+ planResult: 'FAILED';
53
+ reason: string;
54
+ } | {
55
+ planResult: 'SUCCEEDED';
56
+ plannedPayrollDeduction: {
57
+ employmentContractID: string;
58
+ customerID: string;
59
+ externalEmploymentContractID: string;
60
+ value: number;
61
+ date: string;
62
+ isAccumulative: boolean;
63
+ externalPayrollID: string;
64
+ externalEventID: string;
65
+ };
66
+ };
38
67
  export type BenefitDefinition = Omit<Base, 'stateMachine'> & {
39
68
  rateLimit?: RateLimitConfig;
40
69
  /**
@@ -57,7 +86,7 @@ export type BenefitDefinition = Omit<Base, 'stateMachine'> & {
57
86
  } & any;
58
87
  DEDUCTION?: {
59
88
  REQUESTED_DEDUCTION: {
60
- next: 'REQUESTED_PAYROLL_DEDUCTION' | string;
89
+ next: 'DEDUCTION_REQUESTED' | string;
61
90
  };
62
91
  } & any;
63
92
  };
@@ -68,5 +97,10 @@ export type BenefitDefinition = Omit<Base, 'stateMachine'> & {
68
97
  handler: (credentials: any, ctx: any) => Promise<AuthHandlerResult>;
69
98
  credentialsHealthCheckHandler?: (credentials: any) => Promise<CredentialsHealthCheckResult>;
70
99
  };
100
+ deduction?: {
101
+ sftp?: {
102
+ rawLineHandler: (input: DeductionSftpHandlerInput, ctx: DeductionSftpHandlerCtx) => Promise<DeductionSftpHandlerResult>;
103
+ };
104
+ };
71
105
  };
72
106
  export {};
@@ -1,4 +1,6 @@
1
+ import { ActionAfterBeforeRecharge } from '../action.types';
1
2
  export interface ActionHelper {
3
+ findHooksByExecutionID: (executionID: string) => Promise<ActionAfterBeforeRecharge[]>;
2
4
  findByContext: (ctx: any) => Promise<any[]>;
3
5
  findByExecutionID: (executionID: string) => Promise<any[]>;
4
6
  updateOne: (state: string, logs: any, body: any, action: any) => Promise<void>;
@@ -78,6 +78,12 @@ export interface StateHandlerCtx {
78
78
  * Used to notify pc-recharge-api when a RECHARGE action reaches a terminal state.
79
79
  */
80
80
  pcRechargeAPI?: AxiosInstance;
81
+ /**
82
+ * pcDeductionAPI Axios instance
83
+ * Present only when PC_DEDUCTION_API_URL is configured.
84
+ * Used to notify pc-deduction-api when a DEDUCTION action reaches a terminal state.
85
+ */
86
+ pcDeductionAPI?: AxiosInstance;
81
87
  /**
82
88
  * deductionFileIngestionHelper
83
89
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@benup/bensdk",
3
- "version": "1.13.4",
3
+ "version": "1.13.5",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "scripts": {