@benup/bensdk 1.13.5 → 1.13.9

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,16 +1,20 @@
1
1
  import z from 'zod';
2
- import { EmploymentContracts } from '@benup-dev/benup-api';
2
+ import { PayrollConfiguration } from '@benup-dev/benup-api';
3
3
  import { AxiosInstance } from 'axios';
4
4
  import pino from 'pino';
5
+ import { EmploymentContractSchema } from '../schemas/action.schema';
5
6
  import { BenefitDefinitionSchema } from '../schemas/benefit-definition.schema';
6
7
  import { LockHelper } from './lib/lock-helper.lib.type';
7
8
  import { TokenHelper } from './lib/token-helper.lib.type';
8
9
  import { StateHandlerCtx, WebhookRequest, WebhookResponse } from './state-handler.types';
9
10
  type Base = z.infer<typeof BenefitDefinitionSchema>;
11
+ type PayrollConfigurationType = z.infer<typeof PayrollConfiguration.default.collection.v3.PayrollConfigurationSchema>;
12
+ type BenefitGeneralOptions = NonNullable<NonNullable<PayrollConfigurationType['dataMapping']['eligibility']>[number]['options']>;
10
13
  export type AuthHandlerCtx = {
11
14
  tokenHelper: TokenHelper;
12
15
  lockHelper: LockHelper;
13
- employmentContract: z.infer<typeof EmploymentContracts.default.collection.default>;
16
+ employmentContract: z.infer<typeof EmploymentContractSchema>;
17
+ benefitGeneralOptions?: BenefitGeneralOptions;
14
18
  };
15
19
  export type AuthHandlerResult = {
16
20
  outcome: 'FAILED';
@@ -48,7 +52,19 @@ export type DeductionSftpHandlerCtx = {
48
52
  logger: pino.Logger;
49
53
  benupAPI: AxiosInstance;
50
54
  };
51
- export type DeductionSftpHandlerResult = {
55
+ export type DeductionEmploymentContractHandlerInput = {
56
+ deductionID: string;
57
+ payrollConfigurationID: string;
58
+ accountID: string;
59
+ companyID: string;
60
+ employmentContractID: string;
61
+ };
62
+ export type DeductionEmploymentContractHandlerCtx = {
63
+ logger: pino.Logger;
64
+ benupAPI: AxiosInstance;
65
+ benefitPartnerAPI?: AxiosInstance;
66
+ };
67
+ export type DeductionPlanResult = {
52
68
  planResult: 'FAILED';
53
69
  reason: string;
54
70
  } | {
@@ -94,12 +110,15 @@ export type BenefitDefinition = Omit<Base, 'stateMachine'> & {
94
110
  handler: (request: WebhookRequest<any>, ctx: StateHandlerCtx) => Promise<WebhookResponse>;
95
111
  };
96
112
  auth?: {
97
- handler: (credentials: any, ctx: any) => Promise<AuthHandlerResult>;
113
+ handler: (credentials: any[], ctx: any) => Promise<AuthHandlerResult>;
98
114
  credentialsHealthCheckHandler?: (credentials: any) => Promise<CredentialsHealthCheckResult>;
99
115
  };
100
116
  deduction?: {
101
117
  sftp?: {
102
- rawLineHandler: (input: DeductionSftpHandlerInput, ctx: DeductionSftpHandlerCtx) => Promise<DeductionSftpHandlerResult>;
118
+ rawLineHandler: (input: DeductionSftpHandlerInput, ctx: DeductionSftpHandlerCtx) => Promise<DeductionPlanResult>;
119
+ };
120
+ employmentContract?: {
121
+ handler: (input: DeductionEmploymentContractHandlerInput, ctx: DeductionEmploymentContractHandlerCtx) => Promise<DeductionPlanResult>;
103
122
  };
104
123
  };
105
124
  };
@@ -1,6 +1,6 @@
1
1
  import { ActionAfterBeforeRecharge } from '../action.types';
2
2
  export interface ActionHelper {
3
- findHooksByExecutionID: (executionID: string) => Promise<ActionAfterBeforeRecharge[]>;
3
+ findHooksByBatchID: (batchID: string) => Promise<ActionAfterBeforeRecharge[]>;
4
4
  findByContext: (ctx: any) => Promise<any[]>;
5
5
  findByExecutionID: (executionID: string) => Promise<any[]>;
6
6
  updateOne: (state: string, logs: any, body: any, action: any) => Promise<void>;
@@ -1,11 +1,13 @@
1
1
  type GetTokenParameters = {
2
2
  accountID: string;
3
3
  companyID: string;
4
+ cnpj?: string;
4
5
  benefitID: string;
5
6
  };
6
7
  type SetTokenParameters = {
7
8
  accountID: string;
8
9
  companyID: string;
10
+ cnpj?: string;
9
11
  benefitID: string;
10
12
  valueToBeStored: string;
11
13
  storeForSeconds: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@benup/bensdk",
3
- "version": "1.13.5",
3
+ "version": "1.13.9",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "scripts": {