@orchesty/connector-nutshell 1.0.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.
Files changed (60) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/LICENSE +190 -0
  3. package/coverage/clover.xml +129 -0
  4. package/coverage/coverage-final.json +7 -0
  5. package/coverage/lcov-report/base.css +224 -0
  6. package/coverage/lcov-report/block-navigation.js +87 -0
  7. package/coverage/lcov-report/favicon.png +0 -0
  8. package/coverage/lcov-report/index.html +146 -0
  9. package/coverage/lcov-report/prettify.css +1 -0
  10. package/coverage/lcov-report/prettify.js +2 -0
  11. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  12. package/coverage/lcov-report/sorter.js +210 -0
  13. package/coverage/lcov-report/src/Connector/NutshellGetAccountConnector.ts.html +532 -0
  14. package/coverage/lcov-report/src/Connector/NutshellNewAccountConnector.ts.html +754 -0
  15. package/coverage/lcov-report/src/Connector/NutshellNewLeadConnector.ts.html +802 -0
  16. package/coverage/lcov-report/src/Connector/NutshellNewTaskConnector.ts.html +406 -0
  17. package/coverage/lcov-report/src/Connector/index.html +161 -0
  18. package/coverage/lcov-report/src/NutshellApplication.ts.html +304 -0
  19. package/coverage/lcov-report/src/index.html +116 -0
  20. package/coverage/lcov-report/test/dataProvider.ts.html +235 -0
  21. package/coverage/lcov-report/test/index.html +116 -0
  22. package/coverage/lcov.info +184 -0
  23. package/dist/Connector/NutshellGetAccountConnector.d.ts +108 -0
  24. package/dist/Connector/NutshellGetAccountConnector.js +29 -0
  25. package/dist/Connector/NutshellNewAccountConnector.d.ts +179 -0
  26. package/dist/Connector/NutshellNewAccountConnector.js +29 -0
  27. package/dist/Connector/NutshellNewLeadConnector.d.ts +205 -0
  28. package/dist/Connector/NutshellNewLeadConnector.js +29 -0
  29. package/dist/Connector/NutshellNewTaskConnector.d.ts +67 -0
  30. package/dist/Connector/NutshellNewTaskConnector.js +29 -0
  31. package/dist/NutshellApplication.d.ts +16 -0
  32. package/dist/NutshellApplication.js +85 -0
  33. package/dist/package.json +22 -0
  34. package/jest.config.js +13 -0
  35. package/package.json +22 -0
  36. package/src/Connector/NutshellGetAccountConnector.ts +149 -0
  37. package/src/Connector/NutshellNewAccountConnector.ts +223 -0
  38. package/src/Connector/NutshellNewLeadConnector.ts +239 -0
  39. package/src/Connector/NutshellNewTaskConnector.ts +107 -0
  40. package/src/Connector/__tests__/Data/NutshellGetAccountConnector/input.json +8 -0
  41. package/src/Connector/__tests__/Data/NutshellGetAccountConnector/mock.json +37 -0
  42. package/src/Connector/__tests__/Data/NutshellGetAccountConnector/output.json +34 -0
  43. package/src/Connector/__tests__/Data/NutshellNewAccountConnector/input.json +10 -0
  44. package/src/Connector/__tests__/Data/NutshellNewAccountConnector/mock.json +34 -0
  45. package/src/Connector/__tests__/Data/NutshellNewAccountConnector/output.json +30 -0
  46. package/src/Connector/__tests__/Data/NutshellNewLeadConnector/input.json +10 -0
  47. package/src/Connector/__tests__/Data/NutshellNewLeadConnector/mock.json +77 -0
  48. package/src/Connector/__tests__/Data/NutshellNewLeadConnector/output.json +74 -0
  49. package/src/Connector/__tests__/Data/NutshellNewTaskConnector/input.json +11 -0
  50. package/src/Connector/__tests__/Data/NutshellNewTaskConnector/mock.json +22 -0
  51. package/src/Connector/__tests__/Data/NutshellNewTaskConnector/output.json +19 -0
  52. package/src/Connector/__tests__/NutshellGetAccountConnector.ts +17 -0
  53. package/src/Connector/__tests__/NutshellNewAccountConnector.ts +17 -0
  54. package/src/Connector/__tests__/NutshellNewLeadConnector.ts +17 -0
  55. package/src/Connector/__tests__/NutshellNewTaskConnector.ts +17 -0
  56. package/src/NutshellApplication.ts +73 -0
  57. package/test/dataProvider.ts +50 -0
  58. package/tsconfig.json +8 -0
  59. package/tsconfig.prod.json +13 -0
  60. package/tsconfig.prod.tsbuildinfo +1 -0
package/package.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "@orchesty/connector-nutshell",
3
+ "description": "",
4
+ "version": "1.0.0",
5
+ "license": "Apache-2.0",
6
+ "url": "https://github.com/Orchesty/orchesty-nodejs-connectors",
7
+ "repository": "https://github.com/Orchesty/orchesty-nodejs-connectors",
8
+ "keywords": [],
9
+ "author": "info@hanaboso.com",
10
+ "dependencies": {
11
+ "@orchesty/nodejs-sdk": "^4.3.6"
12
+ },
13
+ "engines": {
14
+ "node": ">=24"
15
+ },
16
+ "scripts": {
17
+ "build": "rm -rf dist && rm -rf tsconfig.prod.tsbuildinfo && tsc -d -p tsconfig.prod.json && cp package.json ./dist/package.json",
18
+ "test": "jest --coverage --forceExit --passWithNoTests",
19
+ "lint": "eslint src test --fix",
20
+ "lint-ci": "eslint src test"
21
+ }
22
+ }
@@ -0,0 +1,149 @@
1
+ import AConnector from '@orchesty/nodejs-sdk/dist/lib/Connector/AConnector';
2
+ import { HttpMethods } from '@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods';
3
+ import ProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/ProcessDto';
4
+ import crypto from 'crypto';
5
+
6
+ export const NAME = 'nutshell-get-account-connector';
7
+
8
+ export default class NutshellGetAccountConnector extends AConnector {
9
+
10
+ public getName(): string {
11
+ return NAME;
12
+ }
13
+
14
+ public async processAction(dto: ProcessDto<IInput>): Promise<ProcessDto<IOutput>> {
15
+ const appInstall = await this.getApplicationInstallFromProcess(dto);
16
+
17
+ const data = {
18
+ jsonrpc: '2.0',
19
+ method: 'getAccount',
20
+ params: dto.getJsonData(),
21
+ id: crypto.randomBytes(4).toString('hex'),
22
+ };
23
+ const req = await this.getApplication().getRequestDto(
24
+ dto,
25
+ appInstall,
26
+ HttpMethods.POST,
27
+ undefined,
28
+ data,
29
+ );
30
+
31
+ const resp = await this.getSender().send<IResponse>(req, [200]);
32
+ const response = resp.getJsonBody();
33
+
34
+ return dto.setNewJsonData(response.result);
35
+ }
36
+
37
+ }
38
+
39
+ /* eslint-disable @typescript-eslint/naming-convention */
40
+ interface IResponse {
41
+ result: IOutput;
42
+ id: string;
43
+ jsonrpc: string;
44
+ }
45
+
46
+ export interface IInput {
47
+ accountId: number;
48
+ }
49
+
50
+ export interface IOutput {
51
+ id: number;
52
+ entityType: string;
53
+ rev: string;
54
+ modifiedTime: string;
55
+ createdTime: string;
56
+ name: string;
57
+ htmlUrl: string;
58
+ htmlUrlPath: string;
59
+ avatarUrl: string;
60
+ accountType: {
61
+ id: number;
62
+ name: string;
63
+ };
64
+ industry: {
65
+ stub: boolean;
66
+ id: number;
67
+ rev: string;
68
+ entityType: string;
69
+ name: string;
70
+ };
71
+ tags: [];
72
+ lastContactedDate: string;
73
+ contacts: [
74
+ {
75
+ stub: true;
76
+ id: number;
77
+ rev: string;
78
+ entityType: string;
79
+ modifiedTime: string;
80
+ createdTime: string;
81
+ name: string;
82
+ jobTitle: string;
83
+ relationship: null;
84
+ },
85
+ ];
86
+ description: null;
87
+ legacyId: null;
88
+ address: {
89
+ main: {
90
+ name: null;
91
+ location: {
92
+ longitude: number;
93
+ latitude: number;
94
+ };
95
+ locationAccuracy: string;
96
+ address_1: string;
97
+ address_2: null;
98
+ address_3: null;
99
+ city: string;
100
+ state: string;
101
+ postalCode: string;
102
+ country: string;
103
+ timezone: null;
104
+ };
105
+ primary: {
106
+ name: null;
107
+ location: {
108
+ longitude: number;
109
+ latitude: number;
110
+ };
111
+ locationAccuracy: string;
112
+ address_1: string;
113
+ address_2: null;
114
+ address_3: null;
115
+ city: string;
116
+ state: string;
117
+ postalCode: string;
118
+ country: string;
119
+ timezone: null;
120
+ };
121
+ };
122
+ notes: [];
123
+ leads: [
124
+ {
125
+ stub: boolean;
126
+ id: number;
127
+ rev: string;
128
+ entityType: string;
129
+ modifiedTime: string;
130
+ createdTime: string;
131
+ name: string;
132
+ description: string;
133
+ status: number;
134
+ completion: number;
135
+ value: {
136
+ currency: string;
137
+ amount: number;
138
+ };
139
+ primaryAccountName: string;
140
+ primaryContactName: string;
141
+ isOverdue: false;
142
+ lastContactedDate: string;
143
+ dueTime: string;
144
+ closedTime: string;
145
+ },
146
+ ];
147
+ }
148
+
149
+ /* eslint-enable @typescript-eslint/naming-convention */
@@ -0,0 +1,223 @@
1
+ import AConnector from '@orchesty/nodejs-sdk/dist/lib/Connector/AConnector';
2
+ import { HttpMethods } from '@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods';
3
+ import ProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/ProcessDto';
4
+ import crypto from 'crypto';
5
+
6
+ export const NAME = 'nutshell-new-account-connector';
7
+
8
+ export default class NutshellNewAccountConnector extends AConnector {
9
+
10
+ public getName(): string {
11
+ return NAME;
12
+ }
13
+
14
+ public async processAction(dto: ProcessDto<IInput>): Promise<ProcessDto<IOutput>> {
15
+ const appInstall = await this.getApplicationInstallFromProcess(dto);
16
+
17
+ const data = {
18
+ jsonrpc: '2.0',
19
+ method: 'newAccount',
20
+ params: dto.getJsonData(),
21
+ id: crypto.randomBytes(4).toString('hex'),
22
+ };
23
+
24
+ const req = await this.getApplication().getRequestDto(
25
+ dto,
26
+ appInstall,
27
+ HttpMethods.POST,
28
+ undefined,
29
+ data,
30
+ );
31
+
32
+ const resp = await this.getSender().send<IResponse>(req, [200]);
33
+ const response = resp.getJsonBody();
34
+
35
+ return dto.setNewJsonData(response.result);
36
+ }
37
+
38
+ }
39
+
40
+ /* eslint-disable @typescript-eslint/naming-convention */
41
+
42
+ interface IResponse {
43
+ result: IOutput;
44
+ id: string;
45
+ jsonrpc: string;
46
+
47
+ }
48
+
49
+ export interface IInput {
50
+ account: {
51
+ name: string;
52
+ owner?: {
53
+ entityType?: string;
54
+ id?: number;
55
+ };
56
+ industryId?: string;
57
+ accountTypeId?: string;
58
+ territoryId?: string;
59
+ url?: string[];
60
+ phone?: string[];
61
+ leads?: [
62
+ {
63
+ relationship?: string;
64
+ id?: number;
65
+ },
66
+ ];
67
+ contacts?: [
68
+ {
69
+ relationship?: string;
70
+ id?: number;
71
+ },
72
+ ];
73
+ address?: [
74
+ {
75
+ address_1?: string;
76
+ address_2?: string;
77
+ address_3?: string;
78
+ city?: string;
79
+ state?: string;
80
+ postalCode?: string;
81
+ country?: string;
82
+ },
83
+ ];
84
+ customFields?: {
85
+ Number_of_Employees?: string;
86
+ };
87
+
88
+ };
89
+ }
90
+
91
+ export interface IOutput {
92
+ id: number;
93
+ entityType: string;
94
+ rev: string;
95
+ modifiedTime: string;
96
+ createdTime: string;
97
+ name: string;
98
+ htmlUrl: string;
99
+ htmlUrlPath: string;
100
+ avatarUrl: string;
101
+ accountType: {
102
+ id: number;
103
+ name: string;
104
+ };
105
+ industry: {
106
+ stub: boolean;
107
+ id: number;
108
+ rev: string;
109
+ entityType: string;
110
+ name: string;
111
+ };
112
+ creator: {
113
+ stub: boolean;
114
+ id: number;
115
+ rev: string;
116
+ entityType: string;
117
+ modifiedTime: string;
118
+ createdTime: string;
119
+ name: string;
120
+ emails: string[];
121
+ isEnabled: boolean;
122
+ isAdministrator: boolean;
123
+ };
124
+ owner: {
125
+ stub: boolean;
126
+ id: number;
127
+ rev: string;
128
+ entityType: string;
129
+ modifiedTime: string;
130
+ createdTime: string;
131
+ name: string;
132
+ emails: string[];
133
+ isEnabled: boolean;
134
+ isAdministrator: boolean;
135
+ };
136
+ tags: [];
137
+ lastContactedDate: string;
138
+ contacts: [
139
+ {
140
+ stub: boolean;
141
+ id: number;
142
+ rev: string;
143
+ entityType: string;
144
+ modifiedTime: string;
145
+ createdTime: string;
146
+ name: string;
147
+ jobTitle: string;
148
+ relationship: string;
149
+ }];
150
+ description: null;
151
+ legacyId: null;
152
+ phone: {
153
+ '0': {
154
+ countryCode: string;
155
+ number: string;
156
+ extension: null;
157
+ numberFormatted: string;
158
+ E164: string;
159
+ countryCodeAndNumber: string;
160
+ };
161
+ '1': {
162
+ countryCode: string;
163
+ number: string;
164
+ extension: null;
165
+ numberFormatted: string;
166
+ E164: string;
167
+ countryCodeAndNumber: string;
168
+ };
169
+ '2': {
170
+ countryCode: string;
171
+ number: string;
172
+ extension: null;
173
+ numberFormatted: string;
174
+ E164: string;
175
+ countryCodeAndNumber: string;
176
+ };
177
+ '--primary': {
178
+ countryCode: string;
179
+ number: string;
180
+ extension: null;
181
+ numberFormatted: string;
182
+ E164: string;
183
+ countryCodeAndNumber: string;
184
+ };
185
+ };
186
+ url: {
187
+ '0': string;
188
+ '1': string;
189
+ '--primary': string;
190
+ };
191
+ address: {
192
+ '0': {
193
+ name: null;
194
+ location: null;
195
+ locationAccuracy: null;
196
+ address_1: string;
197
+ address_2: string;
198
+ address_3: string;
199
+ city: string;
200
+ state: string;
201
+ postalCode: string;
202
+ country: string;
203
+ timezone: null;
204
+ };
205
+ '--primary': {
206
+ name: null;
207
+ location: null;
208
+ locationAccuracy: null;
209
+ address_1: string;
210
+ address_2: string;
211
+ address_3: string;
212
+ city: string;
213
+ state: string;
214
+ postalCode: string;
215
+ country: string;
216
+ timezone: null;
217
+ };
218
+ };
219
+ notes: [];
220
+ leads: [];
221
+ }
222
+
223
+ /* eslint-enable @typescript-eslint/naming-convention */
@@ -0,0 +1,239 @@
1
+ import AConnector from '@orchesty/nodejs-sdk/dist/lib/Connector/AConnector';
2
+ import { HttpMethods } from '@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods';
3
+ import ProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/ProcessDto';
4
+ import crypto from 'crypto';
5
+
6
+ export const NAME = 'nutshell-new-lead-connector';
7
+
8
+ export default class NutshellNewLeadConnector extends AConnector {
9
+
10
+ public getName(): string {
11
+ return NAME;
12
+ }
13
+
14
+ public async processAction(dto: ProcessDto<IInput>): Promise<ProcessDto<IOutput>> {
15
+ const appInstall = await this.getApplicationInstallFromProcess(dto);
16
+
17
+ const data = {
18
+ jsonrpc: '2.0',
19
+ method: 'newLead',
20
+ params: dto.getJsonData(),
21
+ id: crypto.randomBytes(4).toString('hex'),
22
+ };
23
+ const req = await this.getApplication().getRequestDto(
24
+ dto,
25
+ appInstall,
26
+ HttpMethods.POST,
27
+ undefined,
28
+ data,
29
+ );
30
+
31
+ const resp = await this.getSender().send<IResponse>(req, [200]);
32
+ const response = resp.getJsonBody();
33
+
34
+ return dto.setNewJsonData(response.result);
35
+ }
36
+
37
+ }
38
+
39
+ /* eslint-disable @typescript-eslint/naming-convention */
40
+
41
+ interface IResponse {
42
+ result: IOutput;
43
+ id: string;
44
+ jsonrpc: string;
45
+ }
46
+
47
+ export interface IOutput {
48
+ id: number;
49
+ entityType: string;
50
+ rev: string;
51
+ modifiedTime: string;
52
+ createdTime: string;
53
+ name: string;
54
+ description: string;
55
+ htmlUrl: string;
56
+ htmlUrlPath: string;
57
+ avatarUrl: string;
58
+ creator: {
59
+ stub: boolean;
60
+ id: number;
61
+ rev: string;
62
+ entityType: string;
63
+ modifiedTime: string;
64
+ createdTime: string;
65
+ name: string;
66
+ emails: string[];
67
+ isEnabled: boolean;
68
+ isAdministrator: boolean;
69
+ };
70
+ primaryAccount: {
71
+ stub: boolean;
72
+ id: number;
73
+ rev: string;
74
+ entityType: string;
75
+ modifiedTime: string;
76
+ createdTime: string;
77
+ name: string;
78
+ regions: string[];
79
+ relationship: null;
80
+ description: null;
81
+ };
82
+ milestone: null;
83
+ stageset: {
84
+ stub: boolean;
85
+ id: number;
86
+ entityType: string;
87
+ modifiedTime: string;
88
+ name: string;
89
+ };
90
+ activitiesCount: {
91
+ '0': number;
92
+ '1': number;
93
+ '2': number;
94
+ '-1': number;
95
+ };
96
+ status: number;
97
+ confidence: number;
98
+ completion: number;
99
+ urgency: string;
100
+ isOverdue: boolean;
101
+ lastContactedDate: null;
102
+ market: {
103
+ stub: boolean;
104
+ id: number;
105
+ rev: string;
106
+ entityType: string;
107
+ name: string;
108
+ };
109
+ assignee: {
110
+ stub: boolean;
111
+ id: number;
112
+ rev: string;
113
+ entityType: string;
114
+ modifiedTime: string;
115
+ createdTime: string;
116
+ name: string;
117
+ emails: string[];
118
+ isEnabled: boolean;
119
+ isAdministrator: boolean;
120
+ };
121
+ sources: [];
122
+ competitors: [];
123
+ products: [
124
+ {
125
+ stub: boolean;
126
+ id: number;
127
+ rev: string;
128
+ entityType: string;
129
+ modifiedTime: string;
130
+ createdTime: string;
131
+ name: string;
132
+ relationship: string;
133
+ price: {
134
+ currency: string;
135
+ amount: number;
136
+ };
137
+ quantity: number;
138
+ }];
139
+ contacts: [];
140
+ accounts: [];
141
+ tags: string[];
142
+ priority: number;
143
+ dueTime: string;
144
+ value: {
145
+ currency: string;
146
+ amount: number;
147
+ };
148
+ normalizedValue: {
149
+ currency: string;
150
+ amount: number;
151
+ };
152
+ processes: [];
153
+ notes: [
154
+ {
155
+ stub: number;
156
+ id: number;
157
+ rev: string;
158
+ entityType: string;
159
+ createdTime: string;
160
+ note: string;
161
+ noteMarkup: string;
162
+ noteHtml: string;
163
+ user: {
164
+ stub: boolean;
165
+ id: number;
166
+ rev: string;
167
+ entityType: string;
168
+ modifiedTim: string;
169
+ createdTime: string;
170
+ name: string;
171
+ emails: string[];
172
+ isEnabled: boolean;
173
+ isAdministrator: boolean;
174
+ };
175
+ originId: number;
176
+ date: string;
177
+ }];
178
+ estimatedValue: {
179
+ currency: string;
180
+ amount: number;
181
+ };
182
+ }
183
+
184
+ export interface IInput {
185
+ lead: {
186
+ primaryAccount?: { id: string };
187
+ dueTime?: string;
188
+ market?: { id: string };
189
+ tags?: string[];
190
+ description?: string;
191
+ accounts?: [
192
+ {
193
+ id?: number;
194
+ },
195
+ ];
196
+ contacts?: [
197
+ {
198
+ id?: number;
199
+ },
200
+ ];
201
+ products?: [
202
+ {
203
+ relationship?: string;
204
+ quantity?: number;
205
+ price?: {
206
+ currency_shortname?: string;
207
+ amount?: string;
208
+ };
209
+ id?: number;
210
+ },
211
+ ];
212
+ competitors?: [
213
+ {
214
+ status?: number;
215
+ relationship?: string;
216
+ id?: number;
217
+ },
218
+ ];
219
+ sources?: [
220
+ { id?: number },
221
+ ];
222
+ confidence?: number;
223
+ assignee?: {
224
+ entityType?: string;
225
+ id?: number;
226
+ };
227
+ customFields?: {
228
+ 'Tracking #'?: string;
229
+ Discount?: {
230
+ currency_shortname?: string;
231
+ amount?: string;
232
+ };
233
+ };
234
+ note?: string[];
235
+ priority?: number;
236
+ };
237
+ }
238
+
239
+ /* eslint-enable @typescript-eslint/naming-convention */