@benup/bensdk 1.3.1 → 1.4.0

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.
@@ -11,7 +11,6 @@ const __filename = fileURLToPath(import.meta.url);
11
11
  const __dirname = path.dirname(__filename);
12
12
  const templatesDir = path.join(__dirname, 'templates');
13
13
  const benefitDefinitionTemplate = fs.readFileSync(path.join(templatesDir, 'benefit-definition.template.ts'), 'utf-8');
14
- const benefitDefinitionTypesTemplate = fs.readFileSync(path.join(templatesDir, 'benefit-definition.types.template.ts'), 'utf-8');
15
14
  const staticFiles = fs.readdirSync(path.join(templatesDir, 'bensdk-base'));
16
15
  export default async function (benefitID) {
17
16
  const availableActions = ['GRANT', 'REVOKE'];
@@ -30,35 +29,27 @@ export default async function (benefitID) {
30
29
  packageTemplate.name = benefitID;
31
30
  let benefitDefinition = benefitDefinitionTemplate.replace(/benefitID: '.*'/, `benefitID: "${benefitID.toUpperCase()}"`);
32
31
  benefitDefinition = benefitDefinition.replace(/availableActions: \[\].*/, `availableActions: [${actions.join(', ')}],`);
33
- let benefitDefinitionTypes = benefitDefinitionTypesTemplate;
34
32
  if (!customAvailableActions.includes('RECHARGE')) {
35
33
  benefitDefinition = benefitDefinition.replace(/\/\*\* <recharge> \*\/[\s\S]*?\/\*\* <\/recharge> \*\//g, '');
36
- benefitDefinitionTypes = benefitDefinitionTypes.replace(/\/\*\* <recharge> \*\/[\s\S]*?\/\*\* <\/recharge> \*\//g, '');
37
34
  }
38
35
  else {
39
36
  // If RECHARGE is selected, just remove the recharge comment markers
40
37
  benefitDefinition = benefitDefinition.replace(/\/\*\* <recharge> \*\/\n?/g, '');
41
38
  benefitDefinition = benefitDefinition.replace(/\/\*\* <\/recharge> \*\/\n?/g, '');
42
- benefitDefinitionTypes = benefitDefinitionTypes.replace(/\/\*\* <recharge> \*\/\n?/g, '');
43
- benefitDefinitionTypes = benefitDefinitionTypes.replace(/\/\*\* <\/recharge> \*\/\n?/g, '');
44
39
  }
45
40
  if (!customAvailableActions.includes('GRANT_DEPENDENT') &&
46
41
  !customAvailableActions.includes('REVOKE_DEPENDENT')) {
47
42
  benefitDefinition = benefitDefinition.replace(/\/\*\* <dependent> \*\/[\s\S]*?\/\*\* <\/dependent> \*\//g, '');
48
- benefitDefinitionTypes = benefitDefinitionTypes.replace(/\/\*\* <dependent> \*\/[\s\S]*?\/\*\* <\/dependent> \*\//g, '');
49
43
  }
50
44
  else {
51
45
  // If RECHARGE is selected, just remove the recharge comment markers
52
46
  benefitDefinition = benefitDefinition.replace(/\/\*\* <dependent> \*\/\n?/g, '');
53
47
  benefitDefinition = benefitDefinition.replace(/\/\*\* <\/dependent> \*\/\n?/g, '');
54
- benefitDefinitionTypes = benefitDefinitionTypes.replace(/\/\*\* <dependent> \*\/\n?/g, '');
55
- benefitDefinitionTypes = benefitDefinitionTypes.replace(/\/\*\* <\/dependent> \*\/\n?/g, '');
56
48
  }
57
49
  const currentDirectory = process.cwd();
58
50
  const appDirectory = `${currentDirectory}/${benefitID}`;
59
51
  fs.mkdirSync(`${appDirectory}/src`, { recursive: true });
60
52
  fs.writeFileSync(`${appDirectory}/src/benefit-definition.ts`, benefitDefinition);
61
- fs.writeFileSync(`${appDirectory}/src/benefit-definition.types.ts`, benefitDefinitionTypes);
62
53
  fs.mkdirSync(`${appDirectory}/src/lib`, { recursive: true });
63
54
  fs.cpSync(path.join(templatesDir, 'bensdk-lib'), `${appDirectory}/src/lib`, { recursive: true });
64
55
  fs.mkdirSync(`${appDirectory}/bin/server`, { recursive: true });
@@ -79,7 +70,7 @@ export default async function (benefitID) {
79
70
  console.log(chalk.green('✔ Project created'));
80
71
  spinner.text = 'Building benSDK app';
81
72
  spinner.start();
82
- exec(`cd ${appDirectory} && npm install > /dev/null && npm run format > /dev/null && cd bin/viewer && npx vite build > /dev/null`, (error, stdout, stderr) => {
73
+ exec(`cd ${appDirectory} && npm install > /dev/null && npm install @benup/bensdk > /dev/null && npm run format > /dev/null && cd bin/viewer && npx vite build > /dev/null`, (error, stdout, stderr) => {
83
74
  if (error || stderr) {
84
75
  console.log(error, stderr);
85
76
  console.log(chalk.red('Something was wrong during Building benSDK app'));
@@ -1 +1 @@
1
- {"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/cli/init.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,eAAe,MAAM,mCAAmC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAEtF,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AAC3C,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;AAEvD,MAAM,yBAAyB,GAAG,EAAE,CAAC,YAAY,CAC/C,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,gCAAgC,CAAC,EACzD,OAAO,CACR,CAAC;AAEF,MAAM,8BAA8B,GAAG,EAAE,CAAC,YAAY,CACpD,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,sCAAsC,CAAC,EAC/D,OAAO,CACR,CAAC;AACF,MAAM,WAAW,GAAG,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC,CAAC;AAE3E,MAAM,CAAC,OAAO,CAAC,KAAK,WAAW,SAAiB;IAC9C,MAAM,gBAAgB,GAAG,CAA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types/benefit-definition.types';
1
2
  import z from 'zod';
2
3
 
3
4
  const benefitDefinition = {
@@ -165,6 +166,6 @@ const benefitDefinition = {
165
166
  /** </recharge> */
166
167
  }
167
168
  }
168
- };
169
+ } satisfies BenefitDefinition;
169
170
 
170
171
  export default benefitDefinition;
@@ -34,10 +34,21 @@ async function main() {
34
34
 
35
35
  const fileName = `${state.toLocaleLowerCase()}.handler.ts`;
36
36
  let stateHandler = stateHandlerTemplate;
37
- const actionInCamelCase = action
38
- .split('_')
39
- .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
37
+ const actionSize = action
38
+ .split('_')
39
+ let actionInCamelCase = '';
40
+ if(actionSize.length === 1){
41
+ actionInCamelCase = action.split('')
42
+ .map((word, index) => index === 0 ? word.toUpperCase() : word.toLowerCase())
40
43
  .join('');
44
+ } else {
45
+ actionInCamelCase = action
46
+ .split('_')[1]
47
+ .split('')
48
+ .map((word, index) => index === 0 ? word.toUpperCase() : word.toLowerCase())
49
+ .join('');
50
+ }
51
+
41
52
 
42
53
  stateHandler = stateHandler.replace(
43
54
  '// StateMachine,',
@@ -49,18 +60,28 @@ async function main() {
49
60
  `import benefitDefinition from '../benefit-definition';`
50
61
  );
51
62
 
63
+ if(action === 'GRANT' || action === 'REVOKE'){
64
+ stateHandler = stateHandler.replace(
65
+ '// import {Action}',
66
+ `import { ActionBaseGrantRevoke as Action} from '@benup/bensdk/bin/lib/types/action.types'`
67
+ );
68
+ } else {
52
69
  stateHandler = stateHandler.replace(
53
- '// import {Action}',
54
- `import { ActionCtx, Action${actionInCamelCase}, ActionLog${actionInCamelCase} } `
55
- );
56
-
57
- stateHandler = stateHandler.replace('// Action,', `Action${actionInCamelCase},`);
70
+ '// import {Action}',
71
+ `import { ActionBase${actionInCamelCase} as Action} from '@benup/bensdk/bin/lib/types/action.types'`
72
+ );
73
+ }
58
74
 
59
75
  stateHandler = stateHandler.replace(
60
76
  '// ActionLog[""],',
61
77
  `ActionLog${actionInCamelCase}["${state}"],`
62
78
  );
63
79
 
80
+ stateHandler = stateHandler.replace(
81
+ '// ActionLogType',
82
+ `export type ActionLog${actionInCamelCase} = z.infer<typeof benefitDefinition.actions.log.${action}>;`
83
+ );
84
+
64
85
  const handlersDir = `${process.cwd()}/src/handlers`;
65
86
  if (!fs.existsSync(handlersDir)) {
66
87
  fs.mkdirSync(handlersDir, { recursive: true });
@@ -1,7 +1,8 @@
1
1
  /* eslint-disable jsdoc/require-jsdoc */
2
2
  // import benefitDefinition from '../benefit-definition';
3
- // import {Action} from "../benefit-definition.types.js";
4
- import { StateHandler } from '../lib/types/state.handler.type';
3
+ // import {Action}
4
+ import { StateHandler } from '@benup/bensdk/bin/lib/types/state-handler.types';
5
+ import z from 'zod';
5
6
  import { getLogsFromResponse } from '../lib/utils/logs';
6
7
 
7
8
  export interface BenefitResponse {
@@ -14,8 +15,11 @@ export const options = {
14
15
  maxRetries: 10
15
16
  };
16
17
 
18
+ // ActionLogType
19
+ type ActionCtx = z.infer<typeof benefitDefinition.actions.ctx>;
20
+
17
21
  const handler: StateHandler<
18
- // Action,
22
+ Action,
19
23
  // ActionLog[""],
20
24
  ActionCtx
21
25
  > = async (message, action, ctx) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@benup/bensdk",
3
- "version": "1.3.1",
3
+ "version": "1.4.0",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -1,66 +0,0 @@
1
- import z from 'zod';
2
- import benefitDefinition from './benefit-definition';
3
- import {
4
- ActionBaseDependent,
5
- ActionBaseGrantRevoke,
6
- ActionBaseRecharge
7
- } from './lib/types/action.types';
8
-
9
- type ActionEligibilityOptionsGrant = z.infer<
10
- typeof benefitDefinition.actions.eligibilityOptions.GRANT
11
- >;
12
- /** <recharge> */
13
- type ActionEligibilityOptionsRecharge = z.infer<
14
- typeof benefitDefinition.actions.eligibilityOptions.RECHARGE
15
- >;
16
- /** </recharge> */
17
- /** <dependent> */
18
- type ActionEligibilityOptionsDependent = z.infer<
19
- typeof benefitDefinition.actions.eligibilityOptions.GRANT_DEPENDENT
20
- >;
21
- /** </dependent> */
22
- export type ActionCtx = z.infer<typeof benefitDefinition.actions.ctx>;
23
-
24
- export type ActionLogGrant = z.infer<typeof benefitDefinition.actions.log.GRANT>;
25
-
26
- export type ActionLogRevoke = z.infer<typeof benefitDefinition.actions.log.REVOKE>;
27
- /** <recharge> */
28
- export type ActionLogRecharge = z.infer<typeof benefitDefinition.actions.log.RECHARGE>;
29
- /** </recharge> */
30
- /** <dependent> */
31
- export type ActionLogGrantDependent = z.infer<typeof benefitDefinition.actions.log.GRANT_DEPENDENT>;
32
- export type ActionLogRevokeDependent = z.infer<
33
- typeof benefitDefinition.actions.log.REVOKE_DEPENDENT
34
- >;
35
- /** </dependent> */
36
- export type ActionGrant = ActionBaseGrantRevoke & {
37
- ctx: ActionCtx;
38
- eligibilityOptions: ActionEligibilityOptionsGrant;
39
- logs: ActionLogGrant;
40
- };
41
-
42
- export type ActionRevoke = ActionBaseGrantRevoke & {
43
- ctx: ActionCtx;
44
- eligibilityOptions: ActionEligibilityOptionsGrant;
45
- logs: ActionLogRevoke;
46
- };
47
-
48
- /** <recharge> */
49
- export type ActionRecharge = ActionBaseRecharge & {
50
- ctx: ActionCtx;
51
- eligibilityOptions: ActionEligibilityOptionsRecharge;
52
- logs: ActionLogRecharge;
53
- };
54
- /** </recharge> */
55
- /** <dependent> */
56
- export type ActionGrantDependent = ActionBaseDependent & {
57
- ctx: ActionCtx;
58
- eligibilityOptions: ActionEligibilityOptionsDependent;
59
- logs: ActionLogGrantDependent;
60
- };
61
- export type ActionRevokeDependent = ActionBaseDependent & {
62
- ctx: ActionCtx;
63
- eligibilityOptions: ActionEligibilityOptionsDependent;
64
- logs: ActionLogRevokeDependent;
65
- };
66
- /** </dependent> */
@@ -1,197 +0,0 @@
1
- export type ActionBase = {
2
- _id: string;
3
- batchID?: string | undefined;
4
- parentActionID?: string | undefined;
5
- fingerprint?: string | undefined;
6
- benefitID: string;
7
- action: 'GRANT' | 'REVOKE' | 'DEDUCTION' | 'RECHARGE' | 'GRANT_DEPENDENT' | 'REVOKE_DEPENDENT';
8
- state: string;
9
- target: {
10
- dependent: {
11
- externalDependentID: string;
12
- externalDependentCode: string;
13
- name: string;
14
- /** CPF in format 000.000.000-00 */
15
- cpf: string;
16
- birthDate: string;
17
- sex: 'M' | 'F';
18
- relationshipType: string;
19
- maritalStatus: string;
20
- benefits: {
21
- [x: string]: {
22
- value: boolean;
23
- options?: {} | undefined;
24
- };
25
- };
26
- status: 'LINKED' | 'UNLINKED';
27
- };
28
- employee: {
29
- _id: string;
30
- name: string;
31
- /** CPF in format 000.000.000-00 */
32
- cpf: string;
33
- birthdate: string;
34
- address: {
35
- street: string;
36
- number: string;
37
- complement?: string | undefined;
38
- neighborhood: string;
39
- city: string;
40
- state: string;
41
- zipCode: string;
42
- country: string;
43
- };
44
- email?: string | undefined;
45
- createdAt: string;
46
- updatedAt?: string | undefined;
47
- };
48
- employmentContract: {
49
- _id: string;
50
- companyID: string;
51
- customerID: string;
52
- accountID: string;
53
- admissionDate: string;
54
- externalEmploymentContractID: string;
55
- position: {
56
- code: number;
57
- description: string;
58
- };
59
- establishment: {
60
- code: number;
61
- description: string;
62
- };
63
- startDateOfCurrentSituation: string;
64
- situation: {
65
- code: number;
66
- description: string;
67
- };
68
- benefits: {
69
- [x: string]: {
70
- value: boolean;
71
- options?: {} | undefined;
72
- };
73
- };
74
- status: 'ADMITTED' | 'DISMISSED' | 'SUSPENDED' | 'IGNORED';
75
- fingerprint: string;
76
- createdAt: string;
77
- isDeleted?: boolean;
78
- };
79
- company: {
80
- _id: string;
81
- accountID: string;
82
- externalCompanyID: string;
83
- cnpj: string;
84
- /** razao social */
85
- businessName: string;
86
- /** nome fantasia */
87
- tradeName: string;
88
- address?:
89
- | {
90
- street: string;
91
- number: string;
92
- complement?: string | undefined;
93
- neighborhood: string;
94
- city: string;
95
- state: string;
96
- zipCode: string;
97
- country: string;
98
- }
99
- | undefined;
100
- createdAt: string;
101
- updatedAt?: string | undefined;
102
- };
103
- payrollConfiguration: {
104
- _id: string;
105
- accountID: string;
106
- companyID: string;
107
- payrollSystem: 'LG_ONPREMISE_VLI' | 'LG_CLOUD' | 'LG_ONPREMISE_AMBEV';
108
- eligibilitySource: 'BENEFIT_MODULE' | 'ADDITIONAL_ATTRIBUTE';
109
- productToggle?: {
110
- isOcherstratorActive?: boolean;
111
- isIntegratorActive?: boolean;
112
- };
113
- cutoffDay: number;
114
- modifiedContractsWindowInDays: number;
115
- dataMapping: {
116
- eligibility?:
117
- | {
118
- benefitID: string;
119
- eligibilityType: 'BENEFIT' | 'ATTRIBUTE' | 'ELIGIBLE_TO_ALL';
120
- eligibilityCode?: (number | string) | undefined;
121
- eligibilityMap?:
122
- | {
123
- eligibilityValue: (boolean | number) | string;
124
- isEligible: boolean;
125
- options: {};
126
- }[]
127
- | undefined;
128
- }[]
129
- | undefined;
130
- deduction?:
131
- | {
132
- benefitID: string;
133
- deduction: {
134
- externalPayrollID: number;
135
- externalPayrollEventID: number;
136
- };
137
- refund?:
138
- | {
139
- externalPayrollID: number;
140
- externalPayrollEventID: number;
141
- }
142
- | undefined;
143
- meta?: {} | undefined;
144
- }[]
145
- | undefined;
146
- recharge?:
147
- | {
148
- rechargeID: string;
149
- label?: string | undefined;
150
- eventID: number;
151
- sheetID: number;
152
- benefitID: string;
153
- productID?: string | undefined;
154
- executionCron: string;
155
- rechargeDate?: number | undefined;
156
- }[]
157
- | undefined;
158
- situation?:
159
- | {
160
- code: number;
161
- value: 'ADMITTED' | 'DISMISSED' | 'SUSPENDED' | 'IGNORED';
162
- }[]
163
- | undefined;
164
- };
165
- version: 2;
166
- isDeleted?: boolean;
167
- createdAt: string;
168
- updatedAt?: string | undefined;
169
- deletedAt?: string | undefined;
170
- };
171
- };
172
- eligibilityOptions: {};
173
- ctx?: {} | undefined;
174
- log?: {} | undefined;
175
- origin: string;
176
- rechargeInput?:
177
- | {
178
- externalSheetID: string;
179
- externalEventID: string;
180
- date: string;
181
- value: number;
182
- }
183
- | undefined;
184
- deductionInput?:
185
- | {
186
- payrollSystem: string;
187
- externalSheetID: string;
188
- externalEventID: string;
189
- externalSituationID: number;
190
- isAccumulative: boolean;
191
- date: string;
192
- value: number;
193
- }
194
- | undefined;
195
- createdAt: string;
196
- updatedAt?: string | undefined;
197
- };
@@ -1,13 +0,0 @@
1
- import { ActionBase } from './action-base.type';
2
- import { ActionBaseDeduction } from './base-deduction.type';
3
- import { ActionBaseDependent } from './base-dependent.type';
4
- import { ActionBaseRecharge } from './base-recharge.type';
5
- import { ActionBaseGrantRevoke } from './grant-revoke.type';
6
-
7
- export {
8
- ActionBase,
9
- ActionBaseDeduction,
10
- ActionBaseDependent,
11
- ActionBaseGrantRevoke,
12
- ActionBaseRecharge
13
- };
@@ -1,169 +0,0 @@
1
- export type ActionBaseDeduction = {
2
- _id: string;
3
- batchID?: string | undefined;
4
- parentActionID?: string | undefined;
5
- fingerprint?: string | undefined;
6
- benefitID: string;
7
- action: 'DEDUCTION';
8
- state: string;
9
- target: {
10
- employee: {
11
- _id: string;
12
- name: string;
13
- /** CPF in format 000.000.000-00 */
14
- cpf: string;
15
- birthdate: string;
16
- address: {
17
- street: string;
18
- number: string;
19
- complement?: string | undefined;
20
- neighborhood: string;
21
- city: string;
22
- state: string;
23
- zipCode: string;
24
- country: string;
25
- };
26
- email?: string | undefined;
27
- createdAt: string;
28
- updatedAt?: string | undefined;
29
- };
30
- employmentContract: {
31
- _id: string;
32
- companyID: string;
33
- customerID: string;
34
- accountID: string;
35
- admissionDate: string;
36
- externalEmploymentContractID: string;
37
- position: {
38
- code: number;
39
- description: string;
40
- };
41
- establishment: {
42
- code: number;
43
- description: string;
44
- };
45
- startDateOfCurrentSituation: string;
46
- situation: {
47
- code: number;
48
- description: string;
49
- };
50
- benefits: {
51
- [x: string]: {
52
- value: boolean;
53
- options?: {} | undefined;
54
- };
55
- };
56
- status: 'ADMITTED' | 'DISMISSED' | 'SUSPENDED' | 'IGNORED';
57
- fingerprint: string;
58
- createdAt: string;
59
- isDeleted?: boolean;
60
- };
61
- company: {
62
- _id: string;
63
- accountID: string;
64
- externalCompanyID: string;
65
- cnpj: string;
66
- /** razao social */
67
- businessName: string;
68
- /** nome fantasia */
69
- tradeName: string;
70
- address?:
71
- | {
72
- street: string;
73
- number: string;
74
- complement?: string | undefined;
75
- neighborhood: string;
76
- city: string;
77
- state: string;
78
- zipCode: string;
79
- country: string;
80
- }
81
- | undefined;
82
- createdAt: string;
83
- updatedAt?: string | undefined;
84
- };
85
- payrollConfiguration: {
86
- _id: string;
87
- accountID: string;
88
- companyID: string;
89
- payrollSystem: 'LG_ONPREMISE_VLI' | 'LG_CLOUD' | 'LG_ONPREMISE_AMBEV';
90
- eligibilitySource: 'BENEFIT_MODULE' | 'ADDITIONAL_ATTRIBUTE';
91
- productToggle?: {
92
- isOcherstratorActive?: boolean;
93
- isIntegratorActive?: boolean;
94
- };
95
- cutoffDay: number;
96
- modifiedContractsWindowInDays: number;
97
- dataMapping: {
98
- eligibility?:
99
- | {
100
- benefitID: string;
101
- eligibilityType: 'BENEFIT' | 'ATTRIBUTE' | 'ELIGIBLE_TO_ALL';
102
- eligibilityCode?: (number | string) | undefined;
103
- eligibilityMap?:
104
- | {
105
- eligibilityValue: (boolean | number) | string;
106
- isEligible: boolean;
107
- options: {};
108
- }[]
109
- | undefined;
110
- }[]
111
- | undefined;
112
- deduction?:
113
- | {
114
- benefitID: string;
115
- deduction: {
116
- externalPayrollID: number;
117
- externalPayrollEventID: number;
118
- };
119
- refund?:
120
- | {
121
- externalPayrollID: number;
122
- externalPayrollEventID: number;
123
- }
124
- | undefined;
125
- meta?: {} | undefined;
126
- }[]
127
- | undefined;
128
- recharge?:
129
- | {
130
- rechargeID: string;
131
- label?: string | undefined;
132
- eventID: number;
133
- sheetID: number;
134
- benefitID: string;
135
- productID?: string | undefined;
136
- executionCron: string;
137
- rechargeDate?: number | undefined;
138
- }[]
139
- | undefined;
140
- situation?:
141
- | {
142
- code: number;
143
- value: 'ADMITTED' | 'DISMISSED' | 'SUSPENDED' | 'IGNORED';
144
- }[]
145
- | undefined;
146
- };
147
- version: 2;
148
- isDeleted?: boolean;
149
- createdAt: string;
150
- updatedAt?: string | undefined;
151
- deletedAt?: string | undefined;
152
- };
153
- };
154
- eligibilityOptions: {};
155
- ctx?: {} | undefined;
156
- log?: {} | undefined;
157
- origin: string;
158
- createdAt: string;
159
- updatedAt?: string | undefined;
160
- deductionInput: {
161
- payrollSystem: string;
162
- externalSheetID: string;
163
- externalEventID: string;
164
- externalSituationID: number;
165
- isAccumulative: boolean;
166
- date: string;
167
- value: number;
168
- };
169
- };
@@ -1,178 +0,0 @@
1
- export type ActionBaseDependent = {
2
- _id: string;
3
- batchID?: string | undefined;
4
- parentActionID?: string | undefined;
5
- fingerprint?: string | undefined;
6
- benefitID: string;
7
- action: 'GRANT_DEPENDENT' | 'REVOKE_DEPENDENT';
8
- state: string;
9
- target: {
10
- dependent: {
11
- externalDependentID: string;
12
- externalDependentCode: string;
13
- name: string;
14
- /** CPF in format 000.000.000-00 */
15
- cpf: string;
16
- birthDate: string;
17
- sex: 'M' | 'F';
18
- relationshipType: string;
19
- maritalStatus: string;
20
- benefits: {
21
- [x: string]: {
22
- value: boolean;
23
- options?: {} | undefined;
24
- };
25
- };
26
- status: 'LINKED' | 'UNLINKED';
27
- };
28
- employee: {
29
- _id: string;
30
- name: string;
31
- /** CPF in format 000.000.000-00 */
32
- cpf: string;
33
- birthdate: string;
34
- address: {
35
- street: string;
36
- number: string;
37
- complement?: string | undefined;
38
- neighborhood: string;
39
- city: string;
40
- state: string;
41
- zipCode: string;
42
- country: string;
43
- };
44
- email?: string | undefined;
45
- createdAt: string;
46
- updatedAt?: string | undefined;
47
- };
48
- employmentContract: {
49
- _id: string;
50
- companyID: string;
51
- customerID: string;
52
- accountID: string;
53
- admissionDate: string;
54
- externalEmploymentContractID: string;
55
- position: {
56
- code: number;
57
- description: string;
58
- };
59
- establishment: {
60
- code: number;
61
- description: string;
62
- };
63
- startDateOfCurrentSituation: string;
64
- situation: {
65
- code: number;
66
- description: string;
67
- };
68
- benefits: {
69
- [x: string]: {
70
- value: boolean;
71
- options?: {} | undefined;
72
- };
73
- };
74
- status: 'ADMITTED' | 'DISMISSED' | 'SUSPENDED' | 'IGNORED';
75
- fingerprint: string;
76
- createdAt: string;
77
- isDeleted?: boolean;
78
- };
79
- company: {
80
- _id: string;
81
- accountID: string;
82
- externalCompanyID: string;
83
- cnpj: string;
84
- /** razao social */
85
- businessName: string;
86
- /** nome fantasia */
87
- tradeName: string;
88
- address?:
89
- | {
90
- street: string;
91
- number: string;
92
- complement?: string | undefined;
93
- neighborhood: string;
94
- city: string;
95
- state: string;
96
- zipCode: string;
97
- country: string;
98
- }
99
- | undefined;
100
- createdAt: string;
101
- updatedAt?: string | undefined;
102
- };
103
- payrollConfiguration: {
104
- _id: string;
105
- accountID: string;
106
- companyID: string;
107
- payrollSystem: 'LG_ONPREMISE_VLI' | 'LG_CLOUD' | 'LG_ONPREMISE_AMBEV';
108
- eligibilitySource: 'BENEFIT_MODULE' | 'ADDITIONAL_ATTRIBUTE';
109
- productToggle?: {
110
- isOcherstratorActive?: boolean;
111
- isIntegratorActive?: boolean;
112
- };
113
- cutoffDay: number;
114
- modifiedContractsWindowInDays: number;
115
- dataMapping: {
116
- eligibility?:
117
- | {
118
- benefitID: string;
119
- eligibilityType: 'BENEFIT' | 'ATTRIBUTE' | 'ELIGIBLE_TO_ALL';
120
- eligibilityCode?: (number | string) | undefined;
121
- eligibilityMap?:
122
- | {
123
- eligibilityValue: (boolean | number) | string;
124
- isEligible: boolean;
125
- options: {};
126
- }[]
127
- | undefined;
128
- }[]
129
- | undefined;
130
- deduction?:
131
- | {
132
- benefitID: string;
133
- deduction: {
134
- externalPayrollID: number;
135
- externalPayrollEventID: number;
136
- };
137
- refund?:
138
- | {
139
- externalPayrollID: number;
140
- externalPayrollEventID: number;
141
- }
142
- | undefined;
143
- meta?: {} | undefined;
144
- }[]
145
- | undefined;
146
- recharge?:
147
- | {
148
- rechargeID: string;
149
- label?: string | undefined;
150
- eventID: number;
151
- sheetID: number;
152
- benefitID: string;
153
- productID?: string | undefined;
154
- executionCron: string;
155
- rechargeDate?: number | undefined;
156
- }[]
157
- | undefined;
158
- situation?:
159
- | {
160
- code: number;
161
- value: 'ADMITTED' | 'DISMISSED' | 'SUSPENDED' | 'IGNORED';
162
- }[]
163
- | undefined;
164
- };
165
- version: 2;
166
- isDeleted?: boolean;
167
- createdAt: string;
168
- updatedAt?: string | undefined;
169
- deletedAt?: string | undefined;
170
- };
171
- };
172
- eligibilityOptions: {};
173
- ctx?: {} | undefined;
174
- log?: {} | undefined;
175
- origin: string;
176
- createdAt: string;
177
- updatedAt?: string | undefined;
178
- };
@@ -1,166 +0,0 @@
1
- export type ActionBaseRecharge = {
2
- _id: string;
3
- batchID?: string | undefined;
4
- parentActionID?: string | undefined;
5
- fingerprint?: string | undefined;
6
- benefitID: string;
7
- action: 'RECHARGE';
8
- state: string;
9
- target: {
10
- employee: {
11
- _id: string;
12
- name: string;
13
- /** CPF in format 000.000.000-00 */
14
- cpf: string;
15
- birthdate: string;
16
- address: {
17
- street: string;
18
- number: string;
19
- complement?: string | undefined;
20
- neighborhood: string;
21
- city: string;
22
- state: string;
23
- zipCode: string;
24
- country: string;
25
- };
26
- email?: string | undefined;
27
- createdAt: string;
28
- updatedAt?: string | undefined;
29
- };
30
- employmentContract: {
31
- _id: string;
32
- companyID: string;
33
- customerID: string;
34
- accountID: string;
35
- admissionDate: string;
36
- externalEmploymentContractID: string;
37
- position: {
38
- code: number;
39
- description: string;
40
- };
41
- establishment: {
42
- code: number;
43
- description: string;
44
- };
45
- startDateOfCurrentSituation: string;
46
- situation: {
47
- code: number;
48
- description: string;
49
- };
50
- benefits: {
51
- [x: string]: {
52
- value: boolean;
53
- options?: {} | undefined;
54
- };
55
- };
56
- status: 'ADMITTED' | 'DISMISSED' | 'SUSPENDED' | 'IGNORED';
57
- fingerprint: string;
58
- createdAt: string;
59
- isDeleted?: boolean;
60
- };
61
- company: {
62
- _id: string;
63
- accountID: string;
64
- externalCompanyID: string;
65
- cnpj: string;
66
- /** razao social */
67
- businessName: string;
68
- /** nome fantasia */
69
- tradeName: string;
70
- address?:
71
- | {
72
- street: string;
73
- number: string;
74
- complement?: string | undefined;
75
- neighborhood: string;
76
- city: string;
77
- state: string;
78
- zipCode: string;
79
- country: string;
80
- }
81
- | undefined;
82
- createdAt: string;
83
- updatedAt?: string | undefined;
84
- };
85
- payrollConfiguration: {
86
- _id: string;
87
- accountID: string;
88
- companyID: string;
89
- payrollSystem: 'LG_ONPREMISE_VLI' | 'LG_CLOUD' | 'LG_ONPREMISE_AMBEV';
90
- eligibilitySource: 'BENEFIT_MODULE' | 'ADDITIONAL_ATTRIBUTE';
91
- productToggle?: {
92
- isOcherstratorActive?: boolean;
93
- isIntegratorActive?: boolean;
94
- };
95
- cutoffDay: number;
96
- modifiedContractsWindowInDays: number;
97
- dataMapping: {
98
- eligibility?:
99
- | {
100
- benefitID: string;
101
- eligibilityType: 'BENEFIT' | 'ATTRIBUTE' | 'ELIGIBLE_TO_ALL';
102
- eligibilityCode?: (number | string) | undefined;
103
- eligibilityMap?:
104
- | {
105
- eligibilityValue: (boolean | number) | string;
106
- isEligible: boolean;
107
- options: {};
108
- }[]
109
- | undefined;
110
- }[]
111
- | undefined;
112
- deduction?:
113
- | {
114
- benefitID: string;
115
- deduction: {
116
- externalPayrollID: number;
117
- externalPayrollEventID: number;
118
- };
119
- refund?:
120
- | {
121
- externalPayrollID: number;
122
- externalPayrollEventID: number;
123
- }
124
- | undefined;
125
- meta?: {} | undefined;
126
- }[]
127
- | undefined;
128
- recharge?:
129
- | {
130
- rechargeID: string;
131
- label?: string | undefined;
132
- eventID: number;
133
- sheetID: number;
134
- benefitID: string;
135
- productID?: string | undefined;
136
- executionCron: string;
137
- rechargeDate?: number | undefined;
138
- }[]
139
- | undefined;
140
- situation?:
141
- | {
142
- code: number;
143
- value: 'ADMITTED' | 'DISMISSED' | 'SUSPENDED' | 'IGNORED';
144
- }[]
145
- | undefined;
146
- };
147
- version: 2;
148
- isDeleted?: boolean;
149
- createdAt: string;
150
- updatedAt?: string | undefined;
151
- deletedAt?: string | undefined;
152
- };
153
- };
154
- eligibilityOptions: {};
155
- ctx?: {} | undefined;
156
- log?: {} | undefined;
157
- origin: string;
158
- createdAt: string;
159
- updatedAt?: string | undefined;
160
- rechargeInput: {
161
- externalSheetID: string;
162
- externalEventID: string;
163
- date: string;
164
- value: number;
165
- };
166
- };
@@ -1,59 +0,0 @@
1
- export type BenefitDefinition = {
2
- benefitID: string;
3
- availableActions: Array<
4
- 'GRANT' | 'REVOKE' | 'RECHARGE' | 'DEDUCTION' | 'GRANT_DEPENDENT' | 'REVOKE_DEPENDENT'
5
- >;
6
- stateMachine: {
7
- GRANT: {
8
- REQUESTED_GRANT: {
9
- next: string;
10
- };
11
- [key: string]: unknown;
12
- };
13
- REVOKE: {
14
- REQUESTED_REVOKE: {
15
- next: string;
16
- };
17
- [key: string]: unknown;
18
- };
19
- RECHARGE?: {
20
- REQUESTED_RECHARGE: {
21
- next: string;
22
- };
23
- [key: string]: unknown;
24
- };
25
- DEDUCTION?: {
26
- REQUESTED_DEDUCTION: {
27
- next: string;
28
- };
29
- [key: string]: unknown;
30
- };
31
- GRANT_DEPENDENT?: {
32
- REQUESTED_GRANT_DEPENDENT: {
33
- next: string;
34
- };
35
- [key: string]: unknown;
36
- };
37
- REVOKE_DEPENDENT?: {
38
- REQUESTED_REVOKE_DEPENDENT: {
39
- next: string;
40
- };
41
- [key: string]: unknown;
42
- };
43
- };
44
- actions: {
45
- eligibilityOptions: {
46
- GRANT: Record<string, unknown>;
47
- RECHARGE?: Record<string, unknown>;
48
- };
49
- ctx: Record<string, unknown>;
50
- log: {
51
- GRANT: Record<string, unknown>;
52
- REVOKE: Record<string, unknown>;
53
- RECHARGE?: Record<string, unknown>;
54
- DEDUCTION?: Record<string, unknown>;
55
- GRANT_DEPENDENT?: Record<string, unknown>;
56
- REVOKE_DEPENDENT?: Record<string, unknown>;
57
- };
58
- };
59
- };
@@ -1,160 +0,0 @@
1
- export type ActionBaseGrantRevoke = {
2
- _id: string;
3
- batchID?: string | undefined;
4
- parentActionID?: string | undefined;
5
- fingerprint?: string | undefined;
6
- benefitID: string;
7
- action: 'GRANT' | 'REVOKE';
8
- state: string;
9
- target: {
10
- employee: {
11
- _id: string;
12
- name: string;
13
- /** CPF in format 000.000.000-00 */
14
- cpf: string;
15
- birthdate: string;
16
- address: {
17
- street: string;
18
- number: string;
19
- complement?: string | undefined;
20
- neighborhood: string;
21
- city: string;
22
- state: string;
23
- zipCode: string;
24
- country: string;
25
- };
26
- email?: string | undefined;
27
- createdAt: string;
28
- updatedAt?: string | undefined;
29
- };
30
- employmentContract: {
31
- _id: string;
32
- companyID: string;
33
- customerID: string;
34
- accountID: string;
35
- admissionDate: string;
36
- externalEmploymentContractID: string;
37
- position: {
38
- code: number;
39
- description: string;
40
- };
41
- establishment: {
42
- code: number;
43
- description: string;
44
- };
45
- startDateOfCurrentSituation: string;
46
- situation: {
47
- code: number;
48
- description: string;
49
- };
50
- benefits: {
51
- [x: string]: {
52
- value: boolean;
53
- options?: {} | undefined;
54
- };
55
- };
56
- status: 'ADMITTED' | 'DISMISSED' | 'SUSPENDED' | 'IGNORED';
57
- fingerprint: string;
58
- createdAt: string;
59
- isDeleted?: boolean;
60
- };
61
- company: {
62
- _id: string;
63
- accountID: string;
64
- externalCompanyID: string;
65
- cnpj: string;
66
- /** razao social */
67
- businessName: string;
68
- /** nome fantasia */
69
- tradeName: string;
70
- address?:
71
- | {
72
- street: string;
73
- number: string;
74
- complement?: string | undefined;
75
- neighborhood: string;
76
- city: string;
77
- state: string;
78
- zipCode: string;
79
- country: string;
80
- }
81
- | undefined;
82
- createdAt: string;
83
- updatedAt?: string | undefined;
84
- };
85
- payrollConfiguration: {
86
- _id: string;
87
- accountID: string;
88
- companyID: string;
89
- payrollSystem: 'LG_ONPREMISE_VLI' | 'LG_CLOUD' | 'LG_ONPREMISE_AMBEV';
90
- eligibilitySource: 'BENEFIT_MODULE' | 'ADDITIONAL_ATTRIBUTE';
91
- productToggle?: {
92
- isOcherstratorActive?: boolean;
93
- isIntegratorActive?: boolean;
94
- };
95
- cutoffDay: number;
96
- modifiedContractsWindowInDays: number;
97
- dataMapping: {
98
- eligibility?:
99
- | {
100
- benefitID: string;
101
- eligibilityType: 'BENEFIT' | 'ATTRIBUTE' | 'ELIGIBLE_TO_ALL';
102
- eligibilityCode?: (number | string) | undefined;
103
- eligibilityMap?:
104
- | {
105
- eligibilityValue: (boolean | number) | string;
106
- isEligible: boolean;
107
- options: {};
108
- }[]
109
- | undefined;
110
- }[]
111
- | undefined;
112
- deduction?:
113
- | {
114
- benefitID: string;
115
- deduction: {
116
- externalPayrollID: number;
117
- externalPayrollEventID: number;
118
- };
119
- refund?:
120
- | {
121
- externalPayrollID: number;
122
- externalPayrollEventID: number;
123
- }
124
- | undefined;
125
- meta?: {} | undefined;
126
- }[]
127
- | undefined;
128
- recharge?:
129
- | {
130
- rechargeID: string;
131
- label?: string | undefined;
132
- eventID: number;
133
- sheetID: number;
134
- benefitID: string;
135
- productID?: string | undefined;
136
- executionCron: string;
137
- rechargeDate?: number | undefined;
138
- }[]
139
- | undefined;
140
- situation?:
141
- | {
142
- code: number;
143
- value: 'ADMITTED' | 'DISMISSED' | 'SUSPENDED' | 'IGNORED';
144
- }[]
145
- | undefined;
146
- };
147
- version: 2;
148
- isDeleted?: boolean;
149
- createdAt: string;
150
- updatedAt?: string | undefined;
151
- deletedAt?: string | undefined;
152
- };
153
- };
154
- eligibilityOptions: {};
155
- ctx?: {} | undefined;
156
- log?: {} | undefined;
157
- origin: string;
158
- createdAt: string;
159
- updatedAt?: string | undefined;
160
- };
@@ -1,88 +0,0 @@
1
- import { AxiosInstance } from 'axios';
2
- import pino from 'pino';
3
- import { BenefitDefinition } from './benefits-definition.type';
4
-
5
- export type HandlerMessageResponse = 'ACK' | 'UNACK' | 'DLQ';
6
-
7
- export interface HandlerResponse {
8
- response: HandlerMessageResponse;
9
- options?: {
10
- maxRetries?: number; // min 1
11
- delayBetweenRetries?: number; // in seconds
12
- delayMode?: 'fixed' | 'exponential';
13
- };
14
- }
15
-
16
- export type MessageBody = {
17
- version: number;
18
- data: {
19
- actionID: string;
20
- };
21
- meta?: Record<string, unknown>;
22
- };
23
-
24
- export interface StateHandlerResponse<TLogs, TCtx> {
25
- handlerResponse?: HandlerResponse;
26
- action?: {
27
- state?: string;
28
- logs: TLogs;
29
- ctx?: TCtx;
30
- };
31
- }
32
-
33
- export interface StateHandlerCtx {
34
- /**
35
- * The raw message object received from sqs
36
- */
37
- rawMessage: any;
38
-
39
- /**
40
- * Instace of pino.Logger with the execution context
41
- */
42
- logger: pino.Logger;
43
-
44
- /**
45
- * Correlation IDs captured in message attributes
46
- */
47
- correlationIDs: Record<string, string>;
48
-
49
- /**
50
- * benefitsAPI Axios instance
51
- */
52
-
53
- benefitsAPI: AxiosInstance;
54
-
55
- /**
56
- * lgProxy Axios instance
57
- */
58
-
59
- lgProxyAPI: AxiosInstance;
60
-
61
- /**
62
- * apiBenup Axios instance
63
- */
64
- benupAPI: AxiosInstance;
65
-
66
- /**
67
- * benefitDefinition
68
- */
69
- benefitDefinition: BenefitDefinition;
70
- }
71
-
72
- /**
73
- * State Handler
74
- * @param TAction - Action type
75
- * @param TLogs - Logs type
76
- * @param TCtx - Context type
77
- */
78
- export type StateHandler<TAction, TLogs, TCtx> = (
79
- message: MessageBody,
80
- action: TAction,
81
- ctx: StateHandlerCtx
82
- ) => Promise<StateHandlerResponse<TLogs, TCtx>>;
83
-
84
- export type StateHandlerConfig = {
85
- maxRetries: number;
86
- delayBetweenRetries: number;
87
- delayMode: 'fixed' | 'exponential';
88
- };