zudello-integration-sdk 1.0.46 → 1.0.48
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/package.json +1 -1
- package/src/index.js +12 -0
- package/src/sdk/Dynamics365.js +31 -0
- package/src/sdk/MAM.js +31 -0
- package/src/sdk/SFTP.js +31 -0
- package/src/sdk/Sharepoint.js +31 -0
- package/src/sdk/submodules/bc/Universal.js +39 -0
- package/src/sdk/submodules/dynamics365/Universal.js +169 -0
- package/src/sdk/submodules/fo/Universal.js +40 -0
- package/src/sdk/submodules/mam/Create.js +64 -0
- package/src/sdk/submodules/myobAcumatica/Universal.js +6 -6
- package/src/sdk/submodules/sap-b1/Universal.js +40 -0
- package/src/sdk/submodules/sftp/Universal.js +110 -0
- package/src/sdk/submodules/sharepoint/Universal.js +153 -0
- package/src/utils/bucket.js +118 -0
- package/src/utils/config.js +4 -0
- package/src/utils/ediBucket.js +11 -0
- package/src/utils/fileBucket.js +11 -0
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -23,8 +23,14 @@ const SAPB1SDK = require('./sdk/SAPB1')
|
|
|
23
23
|
const GPSDK = require('./sdk/GP')
|
|
24
24
|
const EDISDK = require('./sdk/EDI')
|
|
25
25
|
const SunSystemsSDK = require('./sdk/SunSystems')
|
|
26
|
+
const MAMSDK = require('./sdk/MAM')
|
|
27
|
+
const Dynamics365SDK = require('./sdk/Dynamics365')
|
|
28
|
+
const SharepointSDK = require('./sdk/Sharepoint')
|
|
29
|
+
const SFTPSDK = require('./sdk/SFTP')
|
|
26
30
|
|
|
27
31
|
const AI = require('./utils/ai')
|
|
32
|
+
const FileBucket = require('./utils/fileBucket')
|
|
33
|
+
const EDIBucket = require('./utils/ediBucket')
|
|
28
34
|
const Logger = require('./utils/logger')
|
|
29
35
|
const Metadata = require('./utils/metadata')
|
|
30
36
|
const Message = require('./utils/message')
|
|
@@ -57,12 +63,15 @@ const S3Client = {
|
|
|
57
63
|
module.exports = {
|
|
58
64
|
Auth,
|
|
59
65
|
AI,
|
|
66
|
+
FileBucket,
|
|
67
|
+
EDIBucket,
|
|
60
68
|
ZudelloSDK,
|
|
61
69
|
ZudelloAuthSDK,
|
|
62
70
|
NetsuiteSDK,
|
|
63
71
|
NetsuiteSoapSDK,
|
|
64
72
|
IntacctSDK,
|
|
65
73
|
BusinessCentralSDK,
|
|
74
|
+
Dynamic365SDK,
|
|
66
75
|
ZenotiSDK,
|
|
67
76
|
DearSDK,
|
|
68
77
|
NexviaSDK,
|
|
@@ -75,8 +84,11 @@ module.exports = {
|
|
|
75
84
|
RetailExpressSDK,
|
|
76
85
|
MYOBAcumaticaSDK,
|
|
77
86
|
MYOBAccountRightSDK,
|
|
87
|
+
MAMSDK,
|
|
78
88
|
SybizSDK,
|
|
79
89
|
SunSystemsSDK,
|
|
90
|
+
SharepointSDK,
|
|
91
|
+
SFTPSDK,
|
|
80
92
|
XeroSDK,
|
|
81
93
|
JobReadySDK,
|
|
82
94
|
Logger,
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const BaseSDK = require('./Base')
|
|
4
|
+
const UniversalModule = require('./submodules/dynamics365/Universal')
|
|
5
|
+
|
|
6
|
+
class Dynamic365SDK extends BaseSDK {
|
|
7
|
+
/**
|
|
8
|
+
* Constructor.
|
|
9
|
+
* @param {class} auth Auth class object with authorized api instance.
|
|
10
|
+
* @param {string} connectionUUID The UUID of the Connection we're working on.
|
|
11
|
+
*/
|
|
12
|
+
constructor (auth, connectionUUID, organizationUUID, apiURL, apiVersion, loggerClass = null) {
|
|
13
|
+
super({
|
|
14
|
+
auth,
|
|
15
|
+
connectionUUID,
|
|
16
|
+
organizationUUID,
|
|
17
|
+
apiURL,
|
|
18
|
+
apiVersion,
|
|
19
|
+
appUUIDKey: 'dynamics365',
|
|
20
|
+
integrationName: 'Dynamics365',
|
|
21
|
+
loggerClass
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Create submodule instances.
|
|
26
|
+
*/
|
|
27
|
+
this.universal = new UniversalModule(this)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
module.exports = Dynamic365SDK
|
package/src/sdk/MAM.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const BaseSDK = require("./Base");
|
|
4
|
+
const CreateModule = require("./submodules/mam/Create");
|
|
5
|
+
|
|
6
|
+
class MAMSDK extends BaseSDK {
|
|
7
|
+
/**
|
|
8
|
+
* Constructor.
|
|
9
|
+
* @param {class} auth Auth class object with authorized api instance.
|
|
10
|
+
* @param {string} connectionUUID The UUID of the Connection we're working on.
|
|
11
|
+
*/
|
|
12
|
+
constructor(auth, connectionUUID, organizationUUID, apiURL, apiVersion, loggerClass = null) {
|
|
13
|
+
super({
|
|
14
|
+
auth,
|
|
15
|
+
connectionUUID,
|
|
16
|
+
organizationUUID,
|
|
17
|
+
apiURL,
|
|
18
|
+
apiVersion,
|
|
19
|
+
appUUIDKey: "mam",
|
|
20
|
+
integrationName: "MAM",
|
|
21
|
+
loggerClass,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Create submodule instances.
|
|
26
|
+
*/
|
|
27
|
+
this.create = new CreateModule(this);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
module.exports = MAMSDK;
|
package/src/sdk/SFTP.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const BaseSDK = require('./Base')
|
|
4
|
+
const UniversalModule = require('./submodules/sftp/Universal')
|
|
5
|
+
|
|
6
|
+
class SharepointSDK extends BaseSDK {
|
|
7
|
+
/**
|
|
8
|
+
* Constructor.
|
|
9
|
+
* @param {class} auth Auth class object with authorized api instance.
|
|
10
|
+
* @param {string} connectionUUID The UUID of the Connection we're working on.
|
|
11
|
+
*/
|
|
12
|
+
constructor (auth, connectionUUID, organizationUUID, apiURL, apiVersion, loggerClass = null) {
|
|
13
|
+
super({
|
|
14
|
+
auth,
|
|
15
|
+
connectionUUID,
|
|
16
|
+
organizationUUID,
|
|
17
|
+
apiURL,
|
|
18
|
+
apiVersion,
|
|
19
|
+
appUUIDKey: 'sftp',
|
|
20
|
+
integrationName: 'SFTP',
|
|
21
|
+
loggerClass
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Create submodule instances.
|
|
26
|
+
*/
|
|
27
|
+
this.universal = new UniversalModule(this)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
module.exports = SharepointSDK
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const BaseSDK = require('./Base')
|
|
4
|
+
const UniversalModule = require('./submodules/sharepoint/Universal')
|
|
5
|
+
|
|
6
|
+
class SharepointSDK extends BaseSDK {
|
|
7
|
+
/**
|
|
8
|
+
* Constructor.
|
|
9
|
+
* @param {class} auth Auth class object with authorized api instance.
|
|
10
|
+
* @param {string} connectionUUID The UUID of the Connection we're working on.
|
|
11
|
+
*/
|
|
12
|
+
constructor (auth, connectionUUID, organizationUUID, apiURL, apiVersion, loggerClass = null) {
|
|
13
|
+
super({
|
|
14
|
+
auth,
|
|
15
|
+
connectionUUID,
|
|
16
|
+
organizationUUID,
|
|
17
|
+
apiURL,
|
|
18
|
+
apiVersion,
|
|
19
|
+
appUUIDKey: 'sharepoint',
|
|
20
|
+
integrationName: 'Sharepoint',
|
|
21
|
+
loggerClass
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Create submodule instances.
|
|
26
|
+
*/
|
|
27
|
+
this.universal = new UniversalModule(this)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
module.exports = SharepointSDK
|
|
@@ -60,6 +60,45 @@ class UniversalModule {
|
|
|
60
60
|
})
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
/**
|
|
64
|
+
* Attach a File to Business Central.
|
|
65
|
+
* @param {string} fileURL URL of the file to be attached.
|
|
66
|
+
* @param {string} url URL of request.
|
|
67
|
+
* @returns {object} Universal Request Response.
|
|
68
|
+
*/
|
|
69
|
+
async attach ({ fileURL, url, apiProvider = null, apiGroup = null }) {
|
|
70
|
+
const validateIsEmpty = this.module.validator.isEmpty({ url, fileURL })
|
|
71
|
+
|
|
72
|
+
if (!validateIsEmpty.valid) {
|
|
73
|
+
return this.module.responseHandler.error(validateIsEmpty.errors)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const mappableParams = {
|
|
77
|
+
url: {
|
|
78
|
+
value: url
|
|
79
|
+
},
|
|
80
|
+
fileURL: {
|
|
81
|
+
value: fileURL
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (apiProvider) {
|
|
86
|
+
mappableParams.apiProvider = {
|
|
87
|
+
value: apiProvider
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (apiGroup) {
|
|
92
|
+
mappableParams.apiGroup = {
|
|
93
|
+
value: apiGroup
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return await this.module.makeRequest('POST', `${this.module.apiURL}/zintegrations/action/ee6f62f5-9dda-48aa-bb8d-44c8b8455472`, {
|
|
98
|
+
mappable_parameters: mappableParams
|
|
99
|
+
})
|
|
100
|
+
}
|
|
101
|
+
|
|
63
102
|
/**
|
|
64
103
|
* Universal List By URL and Method.
|
|
65
104
|
* @param {string} url URL of listed data.
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
class UniversalModule {
|
|
4
|
+
/**
|
|
5
|
+
* Constructor.
|
|
6
|
+
* @param {class} parentModule Object of BusinessCentral class.
|
|
7
|
+
*/
|
|
8
|
+
constructor (parentModule) {
|
|
9
|
+
this.module = parentModule
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Universal Request By URL and Method.
|
|
14
|
+
* @param {string} url URL of request.
|
|
15
|
+
* @param {string} method Method of request.
|
|
16
|
+
* @param {object} qs Some available filters inside: $top, $skip, $filter, $extend.
|
|
17
|
+
* @param {object} body Some available data inside.
|
|
18
|
+
* @param {string} apiProvider API Provider.
|
|
19
|
+
* @param {string} apiGroup API Group.
|
|
20
|
+
* @returns {object} Universal Request Response.
|
|
21
|
+
*/
|
|
22
|
+
async request ({ url, method, qs = {}, body = {}, apiProvider = null, apiGroup = null }) {
|
|
23
|
+
const validateIsEmpty = this.module.validator.isEmpty({ url, method })
|
|
24
|
+
|
|
25
|
+
if (!validateIsEmpty.valid) {
|
|
26
|
+
return this.module.responseHandler.error(validateIsEmpty.errors)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const mappableParams = {
|
|
30
|
+
url: {
|
|
31
|
+
value: url
|
|
32
|
+
},
|
|
33
|
+
method: {
|
|
34
|
+
value: method
|
|
35
|
+
},
|
|
36
|
+
qs: {
|
|
37
|
+
isMap: true,
|
|
38
|
+
value: JSON.stringify(qs)
|
|
39
|
+
},
|
|
40
|
+
body: {
|
|
41
|
+
isMap: true,
|
|
42
|
+
value: JSON.stringify(body)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (apiProvider) {
|
|
47
|
+
mappableParams.apiProvider = {
|
|
48
|
+
value: apiProvider
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (apiGroup) {
|
|
53
|
+
mappableParams.apiGroup = {
|
|
54
|
+
value: apiGroup
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return await this.module.makeRequest('POST', `${this.module.apiURL}/zintegrations/action/6867a1bb-c6a3-428f-a5de-5cd1fdb7dd5d`, {
|
|
59
|
+
mappable_parameters: mappableParams
|
|
60
|
+
})
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Attach a File to Business Central.
|
|
65
|
+
* @param {string} fileURL URL of the file to be attached.
|
|
66
|
+
* @param {string} url URL of request.
|
|
67
|
+
* @returns {object} Universal Request Response.
|
|
68
|
+
*/
|
|
69
|
+
async attach ({ fileURL, url, apiProvider = null, apiGroup = null }) {
|
|
70
|
+
const validateIsEmpty = this.module.validator.isEmpty({ url, fileURL })
|
|
71
|
+
|
|
72
|
+
if (!validateIsEmpty.valid) {
|
|
73
|
+
return this.module.responseHandler.error(validateIsEmpty.errors)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const mappableParams = {
|
|
77
|
+
url: {
|
|
78
|
+
value: url
|
|
79
|
+
},
|
|
80
|
+
fileURL: {
|
|
81
|
+
value: fileURL
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (apiProvider) {
|
|
86
|
+
mappableParams.apiProvider = {
|
|
87
|
+
value: apiProvider
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (apiGroup) {
|
|
92
|
+
mappableParams.apiGroup = {
|
|
93
|
+
value: apiGroup
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return await this.module.makeRequest('POST', `${this.module.apiURL}/zintegrations/action/bafcc247-6936-4876-86e9-c84e919de101`, {
|
|
98
|
+
mappable_parameters: mappableParams
|
|
99
|
+
})
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Universal List By URL and Method.
|
|
104
|
+
* @param {string} url URL of listed data.
|
|
105
|
+
* @param {string} method Method of listed data.
|
|
106
|
+
* @param {object} qs Some available filters inside: $top, $skip, $filter, $extend.
|
|
107
|
+
* @param {string} apiProvider API Provider.
|
|
108
|
+
* @param {string} apiGroup API Group.
|
|
109
|
+
* @returns {object} Universal List Response.
|
|
110
|
+
*/
|
|
111
|
+
async list ({ url, method, qs = {}, apiProvider = null, apiGroup = null }) {
|
|
112
|
+
const validateIsEmpty = this.module.validator.isEmpty({ url, method })
|
|
113
|
+
|
|
114
|
+
if (!validateIsEmpty.valid) {
|
|
115
|
+
return this.module.responseHandler.error(validateIsEmpty.errors)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (!qs.$skip) {
|
|
119
|
+
qs.$skip = 0
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (!qs.$top) {
|
|
123
|
+
qs.$top = 100
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return await this.request({ url, method, qs, apiProvider, apiGroup })
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Universal Auto Pagination Listing By URL and Method.
|
|
131
|
+
* @param {string} url URL of listed data.
|
|
132
|
+
* @param {string} method Method of listed data.
|
|
133
|
+
* @param {object} qs Some available filters inside: $top, $skip, $filter, $extend.
|
|
134
|
+
* @param {string} apiProvider API Provider.
|
|
135
|
+
* @param {string} apiGroup API Group.
|
|
136
|
+
* @returns {object} Auto Pagination responses.
|
|
137
|
+
*/
|
|
138
|
+
async * autoPaginationList ({ url, method, qs = {}, apiProvider = null, apiGroup = null }) {
|
|
139
|
+
if (!qs.$skip) {
|
|
140
|
+
qs.$skip = 0
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (!qs.$top) {
|
|
144
|
+
qs.$top = 100
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
let response = await this.list({ url, method, qs, apiProvider, apiGroup })
|
|
148
|
+
let currentPageCount = response?.data?.value?.length
|
|
149
|
+
let currentOffset = qs.$skip
|
|
150
|
+
|
|
151
|
+
yield response
|
|
152
|
+
|
|
153
|
+
if (currentPageCount && currentPageCount === qs.$top) {
|
|
154
|
+
while (currentPageCount === qs.$top) {
|
|
155
|
+
currentOffset = currentOffset + qs.$top
|
|
156
|
+
|
|
157
|
+
qs.$skip = currentOffset
|
|
158
|
+
|
|
159
|
+
response = await this.list({ url, method, qs, apiProvider, apiGroup })
|
|
160
|
+
currentPageCount = response?.data?.value?.length
|
|
161
|
+
|
|
162
|
+
yield response
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
module.exports = UniversalModule
|
|
@@ -44,6 +44,46 @@ class UniversalModule {
|
|
|
44
44
|
})
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
/**
|
|
48
|
+
* Attach and Upload File.
|
|
49
|
+
* @param {string} dataAreaId Data Area ID.
|
|
50
|
+
* @param {string} headerReference Header Reference.
|
|
51
|
+
* @param {string} notes Notes.
|
|
52
|
+
* @param {string} fileName File Name.
|
|
53
|
+
* @param {string} fileType File Type.
|
|
54
|
+
* @returns {object} Universal Request Response.
|
|
55
|
+
*/
|
|
56
|
+
async attach ({ url, dataAreaId, headerReference, notes, fileName, fileType }) {
|
|
57
|
+
const validateIsEmpty = this.module.validator.isEmpty({ url, dataAreaId, headerReference, notes, fileName, fileType })
|
|
58
|
+
|
|
59
|
+
if (!validateIsEmpty.valid) {
|
|
60
|
+
return this.module.responseHandler.error(validateIsEmpty.errors)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return await this.module.makeRequest('POST', `${this.module.apiURL}/zintegrations/action/e9ef2f1f-e3d4-4f5e-bfe7-79aec4bb9b3f`, {
|
|
64
|
+
mappable_parameters: {
|
|
65
|
+
url: {
|
|
66
|
+
value: url
|
|
67
|
+
},
|
|
68
|
+
dataAreaId: {
|
|
69
|
+
value: dataAreaId
|
|
70
|
+
},
|
|
71
|
+
headerReference: {
|
|
72
|
+
value: headerReference
|
|
73
|
+
},
|
|
74
|
+
notes: {
|
|
75
|
+
value: notes
|
|
76
|
+
},
|
|
77
|
+
fileName: {
|
|
78
|
+
value: fileName
|
|
79
|
+
},
|
|
80
|
+
fileType: {
|
|
81
|
+
value: fileType
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
}
|
|
86
|
+
|
|
47
87
|
/**
|
|
48
88
|
* Universal List By URL and Method.
|
|
49
89
|
* @param {string} url URL of listed data.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
class UniversalModule {
|
|
4
|
+
/**
|
|
5
|
+
* Constructor.
|
|
6
|
+
* @param {class} parentModule Object of MAM class.
|
|
7
|
+
*/
|
|
8
|
+
constructor (parentModule) {
|
|
9
|
+
this.module = parentModule
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Create XML File in MAM.
|
|
14
|
+
* @param {object} path Path of XML file.
|
|
15
|
+
* @param {object} data Data of XML file.
|
|
16
|
+
* @returns {object} Response.
|
|
17
|
+
*/
|
|
18
|
+
async xml ({ path, data }) {
|
|
19
|
+
const validateIsEmpty = this.module.validator.isEmpty({ path, data })
|
|
20
|
+
|
|
21
|
+
if (!validateIsEmpty.valid) {
|
|
22
|
+
return this.module.responseHandler.error(validateIsEmpty.errors)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return await this.module.makeRequest('POST', `${this.module.apiURL}/zintegrations/action/d1ef7870-834b-42d5-a82b-8d0d1e09f0ee`, {
|
|
26
|
+
mappable_parameters: {
|
|
27
|
+
path: {
|
|
28
|
+
value: path
|
|
29
|
+
},
|
|
30
|
+
data: {
|
|
31
|
+
value: data
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Create CSV File in MAM.
|
|
39
|
+
* @param {object} path Path of CSV file.
|
|
40
|
+
* @param {object} data Data of CSV file.
|
|
41
|
+
* @returns {object} Response.
|
|
42
|
+
*/
|
|
43
|
+
async csv ({ path, data }) {
|
|
44
|
+
const validateIsEmpty = this.module.validator.isEmpty({ path, data })
|
|
45
|
+
|
|
46
|
+
if (!validateIsEmpty.valid) {
|
|
47
|
+
return this.module.responseHandler.error(validateIsEmpty.errors)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return await this.module.makeRequest('POST', `${this.module.apiURL}/zintegrations/action/f08a461d-b1eb-4342-b5f8-aeec1c78f810`, {
|
|
51
|
+
mappable_parameters: {
|
|
52
|
+
path: {
|
|
53
|
+
value: path
|
|
54
|
+
},
|
|
55
|
+
data: {
|
|
56
|
+
value: data
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
module.exports = UniversalModule
|
|
@@ -110,13 +110,13 @@ class UniversalModule {
|
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
/**
|
|
113
|
-
*
|
|
113
|
+
* Attach file to Record.
|
|
114
114
|
* @param {string} url URL of request.
|
|
115
|
-
* @param {string}
|
|
115
|
+
* @param {string} fileURL URL of file.
|
|
116
116
|
* @returns {object} Universal Request Response.
|
|
117
117
|
*/
|
|
118
|
-
async attach({ url,
|
|
119
|
-
const validateIsEmpty = this.module.validator.isEmpty({ url,
|
|
118
|
+
async attach({ url, fileURL }) {
|
|
119
|
+
const validateIsEmpty = this.module.validator.isEmpty({ url, fileURL });
|
|
120
120
|
|
|
121
121
|
if (!validateIsEmpty.valid) {
|
|
122
122
|
return this.module.responseHandler.error(validateIsEmpty.errors);
|
|
@@ -130,8 +130,8 @@ class UniversalModule {
|
|
|
130
130
|
url: {
|
|
131
131
|
value: url,
|
|
132
132
|
},
|
|
133
|
-
|
|
134
|
-
value:
|
|
133
|
+
fileURL: {
|
|
134
|
+
value: fileURL,
|
|
135
135
|
},
|
|
136
136
|
},
|
|
137
137
|
}
|
|
@@ -66,6 +66,46 @@ class UniversalModule {
|
|
|
66
66
|
|
|
67
67
|
return await this.request({ command, qs, body })
|
|
68
68
|
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Attach file to SAP B1.
|
|
72
|
+
* @param {string} fileName File name.
|
|
73
|
+
* @param {string} url URL of orignal file.
|
|
74
|
+
* @param {string} type Type of transaction.
|
|
75
|
+
* @param {number} number Number of transaction.
|
|
76
|
+
* @returns {object} Universal Request Response.
|
|
77
|
+
*/
|
|
78
|
+
async attach({ url, fileName, type, number }) {
|
|
79
|
+
const validateIsEmpty = this.module.validator.isEmpty({ fileURL, fileName, type, number })
|
|
80
|
+
|
|
81
|
+
if (!validateIsEmpty.valid) {
|
|
82
|
+
return this.module.responseHandler.error(validateIsEmpty.errors)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return await this.module.makeRequest(
|
|
86
|
+
'POST',
|
|
87
|
+
`${this.module.apiURL}/zintegrations/action/981fd907-2037-4e4c-8244-3124cecc4e45`,
|
|
88
|
+
{
|
|
89
|
+
mappable_parameters: {
|
|
90
|
+
url: {
|
|
91
|
+
value: fileURL
|
|
92
|
+
},
|
|
93
|
+
fileName: {
|
|
94
|
+
value: fileName
|
|
95
|
+
},
|
|
96
|
+
type: {
|
|
97
|
+
value: type
|
|
98
|
+
},
|
|
99
|
+
number: {
|
|
100
|
+
value: number
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
_debug: true
|
|
106
|
+
}
|
|
107
|
+
)
|
|
108
|
+
}
|
|
69
109
|
}
|
|
70
110
|
|
|
71
111
|
module.exports = UniversalModule
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
class UniversalModule {
|
|
4
|
+
/**
|
|
5
|
+
* Constructor.
|
|
6
|
+
* @param {class} parentModule Object of BusinessCentral class.
|
|
7
|
+
*/
|
|
8
|
+
constructor (parentModule) {
|
|
9
|
+
this.module = parentModule
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* List Files in SFTP.
|
|
14
|
+
* @param {string} path Path of SFTP.
|
|
15
|
+
* @returns {object} Universal Request Response.
|
|
16
|
+
*/
|
|
17
|
+
async list ({ path }) {
|
|
18
|
+
const validateIsEmpty = this.module.validator.isEmpty({ path })
|
|
19
|
+
|
|
20
|
+
if (!validateIsEmpty.valid) {
|
|
21
|
+
return this.module.responseHandler.error(validateIsEmpty.errors)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const mappableParams = {
|
|
25
|
+
path: {
|
|
26
|
+
value: path
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return await this.module.makeRequest('POST', `${this.module.apiURL}/zintegrations/action/d9b6bd51-ef34-4671-a8ae-7a88630ceb79`, {
|
|
31
|
+
mappable_parameters: mappableParams
|
|
32
|
+
})
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Get File from SFTP.
|
|
37
|
+
* @param {string} path Path of file.
|
|
38
|
+
* @returns {object} Universal Request Response.
|
|
39
|
+
*/
|
|
40
|
+
async list ({ path }) {
|
|
41
|
+
const validateIsEmpty = this.module.validator.isEmpty({ path })
|
|
42
|
+
|
|
43
|
+
if (!validateIsEmpty.valid) {
|
|
44
|
+
return this.module.responseHandler.error(validateIsEmpty.errors)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const mappableParams = {
|
|
48
|
+
path: {
|
|
49
|
+
value: path
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return await this.module.makeRequest('POST', `${this.module.apiURL}/zintegrations/action/db1b1ae3-a028-44bf-9b64-ba8fad2ad1d4`, {
|
|
54
|
+
mappable_parameters: mappableParams
|
|
55
|
+
})
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Put File in SFTP.
|
|
60
|
+
* @param {string} path Path of file.
|
|
61
|
+
* @param {object} data Data of file.
|
|
62
|
+
* @returns {object} Universal Request Response.
|
|
63
|
+
*/
|
|
64
|
+
async list ({ path, data }) {
|
|
65
|
+
const validateIsEmpty = this.module.validator.isEmpty({ path, data })
|
|
66
|
+
|
|
67
|
+
if (!validateIsEmpty.valid) {
|
|
68
|
+
return this.module.responseHandler.error(validateIsEmpty.errors)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const mappableParams = {
|
|
72
|
+
path: {
|
|
73
|
+
value: path
|
|
74
|
+
},
|
|
75
|
+
data: {
|
|
76
|
+
value: data
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return await this.module.makeRequest('POST', `${this.module.apiURL}/zintegrations/action/e0fbebc4-1ae1-4e87-b139-4feb4569ecb6`, {
|
|
81
|
+
mappable_parameters: mappableParams
|
|
82
|
+
})
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Delete File from SFTP.
|
|
87
|
+
* @param {string} path Path of file.
|
|
88
|
+
* @returns {object} Universal Request Response.
|
|
89
|
+
*/
|
|
90
|
+
async delete ({ path }) {
|
|
91
|
+
const validateIsEmpty = this.module.validator.isEmpty({ path })
|
|
92
|
+
|
|
93
|
+
if (!validateIsEmpty.valid) {
|
|
94
|
+
return this.module.responseHandler.error(validateIsEmpty.errors)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const mappableParams = {
|
|
98
|
+
path: {
|
|
99
|
+
value: path
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return await this.module.makeRequest('POST', `${this.module.apiURL}/zintegrations/action/0f22f5ae-a06d-497c-aeda-1671e5bbc1a9`, {
|
|
104
|
+
mappable_parameters: mappableParams
|
|
105
|
+
})
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
module.exports = UniversalModule
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
class UniversalModule {
|
|
4
|
+
/**
|
|
5
|
+
* Constructor.
|
|
6
|
+
* @param {class} parentModule Object of BusinessCentral class.
|
|
7
|
+
*/
|
|
8
|
+
constructor (parentModule) {
|
|
9
|
+
this.module = parentModule
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Universal Request By URL and Method.
|
|
14
|
+
* @param {string} url URL of request.
|
|
15
|
+
* @param {string} method Method of request.
|
|
16
|
+
* @param {object} qs Some available filters inside: $top, $skip, $filter, $extend.
|
|
17
|
+
* @param {object} body Some available data inside.
|
|
18
|
+
* @param {string} apiProvider API Provider.
|
|
19
|
+
* @param {string} apiGroup API Group.
|
|
20
|
+
* @returns {object} Universal Request Response.
|
|
21
|
+
*/
|
|
22
|
+
async request ({ url, method, qs = {}, body = {} }) {
|
|
23
|
+
const validateIsEmpty = this.module.validator.isEmpty({ url, method })
|
|
24
|
+
|
|
25
|
+
if (!validateIsEmpty.valid) {
|
|
26
|
+
return this.module.responseHandler.error(validateIsEmpty.errors)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const mappableParams = {
|
|
30
|
+
url: {
|
|
31
|
+
value: url
|
|
32
|
+
},
|
|
33
|
+
method: {
|
|
34
|
+
value: method
|
|
35
|
+
},
|
|
36
|
+
qs: {
|
|
37
|
+
isMap: true,
|
|
38
|
+
value: JSON.stringify(qs)
|
|
39
|
+
},
|
|
40
|
+
body: {
|
|
41
|
+
isMap: true,
|
|
42
|
+
value: JSON.stringify(body)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return await this.module.makeRequest('POST', `${this.module.apiURL}/zintegrations/action/838d55d9-5ddb-470b-a346-7cfea19b3798`, {
|
|
47
|
+
mappable_parameters: mappableParams
|
|
48
|
+
})
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Attach a File to Business Central.
|
|
53
|
+
* @param {string} fileURL URL of the file to be attached.
|
|
54
|
+
* @param {string} url URL of request.
|
|
55
|
+
* @returns {object} Universal Request Response.
|
|
56
|
+
*/
|
|
57
|
+
async attach ({ driveID, folderID, url, fileName, mimeType }) {
|
|
58
|
+
const validateIsEmpty = this.module.validator.isEmpty({ url, fileURL })
|
|
59
|
+
|
|
60
|
+
if (!validateIsEmpty.valid) {
|
|
61
|
+
return this.module.responseHandler.error(validateIsEmpty.errors)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const mappableParams = {
|
|
65
|
+
driveID: {
|
|
66
|
+
value: driveID
|
|
67
|
+
},
|
|
68
|
+
folderID: {
|
|
69
|
+
value: folderID
|
|
70
|
+
},
|
|
71
|
+
url: {
|
|
72
|
+
value: url
|
|
73
|
+
},
|
|
74
|
+
fileName: {
|
|
75
|
+
value: fileName
|
|
76
|
+
},
|
|
77
|
+
mimeType: {
|
|
78
|
+
value: mimeType
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return await this.module.makeRequest('POST', `${this.module.apiURL}/zintegrations/action/644f4323-df65-4579-bce0-e9aee0389d3a`, {
|
|
83
|
+
mappable_parameters: mappableParams
|
|
84
|
+
})
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Universal List By URL and Method.
|
|
89
|
+
* @param {string} url URL of listed data.
|
|
90
|
+
* @param {string} method Method of listed data.
|
|
91
|
+
* @param {object} qs Some available filters inside: $top, $skip, $filter, $extend.
|
|
92
|
+
* @param {string} apiProvider API Provider.
|
|
93
|
+
* @param {string} apiGroup API Group.
|
|
94
|
+
* @returns {object} Universal List Response.
|
|
95
|
+
*/
|
|
96
|
+
async list ({ url, method, qs = {}, apiProvider = null, apiGroup = null }) {
|
|
97
|
+
const validateIsEmpty = this.module.validator.isEmpty({ url, method })
|
|
98
|
+
|
|
99
|
+
if (!validateIsEmpty.valid) {
|
|
100
|
+
return this.module.responseHandler.error(validateIsEmpty.errors)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (!qs.$skip) {
|
|
104
|
+
qs.$skip = 0
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (!qs.$top) {
|
|
108
|
+
qs.$top = 100
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return await this.request({ url, method, qs, apiProvider, apiGroup })
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Universal Auto Pagination Listing By URL and Method.
|
|
116
|
+
* @param {string} url URL of listed data.
|
|
117
|
+
* @param {string} method Method of listed data.
|
|
118
|
+
* @param {object} qs Some available filters inside: $top, $skip, $filter, $extend.
|
|
119
|
+
* @param {string} apiProvider API Provider.
|
|
120
|
+
* @param {string} apiGroup API Group.
|
|
121
|
+
* @returns {object} Auto Pagination responses.
|
|
122
|
+
*/
|
|
123
|
+
async * autoPaginationList ({ url, method, qs = {}, apiProvider = null, apiGroup = null }) {
|
|
124
|
+
if (!qs.$skip) {
|
|
125
|
+
qs.$skip = 0
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (!qs.$top) {
|
|
129
|
+
qs.$top = 100
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
let response = await this.list({ url, method, qs, apiProvider, apiGroup })
|
|
133
|
+
let currentPageCount = response?.data?.value?.length
|
|
134
|
+
let currentOffset = qs.$skip
|
|
135
|
+
|
|
136
|
+
yield response
|
|
137
|
+
|
|
138
|
+
if (currentPageCount && currentPageCount === qs.$top) {
|
|
139
|
+
while (currentPageCount === qs.$top) {
|
|
140
|
+
currentOffset = currentOffset + qs.$top
|
|
141
|
+
|
|
142
|
+
qs.$skip = currentOffset
|
|
143
|
+
|
|
144
|
+
response = await this.list({ url, method, qs, apiProvider, apiGroup })
|
|
145
|
+
currentPageCount = response?.data?.value?.length
|
|
146
|
+
|
|
147
|
+
yield response
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
module.exports = UniversalModule
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
class Bucket {
|
|
4
|
+
constructor(apiInstance = null, teamUUID = null, type = null) {
|
|
5
|
+
this.apiInstance = apiInstance
|
|
6
|
+
this.teamUUID = teamUUID
|
|
7
|
+
this.type = type
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
async list(path, recursive = false, page = 1, limit = 1000) {
|
|
11
|
+
if (!this._canPerformOperation()) {
|
|
12
|
+
return
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return await this.apiInstance.post(`${process.env.ZUDELLO_API_URL}/s3/${this.type}/list`, {
|
|
16
|
+
path,
|
|
17
|
+
recursive,
|
|
18
|
+
page,
|
|
19
|
+
limit
|
|
20
|
+
}, {
|
|
21
|
+
'x-team': this.teamUUID
|
|
22
|
+
})
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async get(path, fileName) {
|
|
26
|
+
if (!this._canPerformOperation()) {
|
|
27
|
+
return
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return await this.apiInstance.post(`${process.env.ZUDELLO_API_URL}/s3/${this.type}/get`, {
|
|
31
|
+
path,
|
|
32
|
+
fileName
|
|
33
|
+
}, {
|
|
34
|
+
'x-team': this.teamUUID
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async getSignedUrl(path, fileName, expiresIn = 300) {
|
|
39
|
+
if (!this._canPerformOperation()) {
|
|
40
|
+
return
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return await this.apiInstance.post(`${process.env.ZUDELLO_API_URL}/s3/${this.type}/signed`, {
|
|
44
|
+
path,
|
|
45
|
+
fileName,
|
|
46
|
+
expiresIn
|
|
47
|
+
}, {
|
|
48
|
+
'x-team': this.teamUUID
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async create(path, fileName, contents, contentType, overwrite = false) {
|
|
53
|
+
if (!this._canPerformOperation()) {
|
|
54
|
+
return
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return await this.apiInstance.post(`${process.env.ZUDELLO_API_URL}/s3/${this.type}/create`, {
|
|
58
|
+
path,
|
|
59
|
+
fileName,
|
|
60
|
+
contents,
|
|
61
|
+
contentType,
|
|
62
|
+
overwrite
|
|
63
|
+
}, {
|
|
64
|
+
'x-team': this.teamUUID
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async update(path, fileName, contents, contentType = null) {
|
|
69
|
+
if (!this._canPerformOperation()) {
|
|
70
|
+
return
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
let data = {
|
|
74
|
+
path,
|
|
75
|
+
fileName,
|
|
76
|
+
contents
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (contentType) {
|
|
80
|
+
data.contentType = contentType
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return await this.apiInstance.post(`${process.env.ZUDELLO_API_URL}/s3/${this.type}/update`, data, {
|
|
84
|
+
'x-team': this.teamUUID
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async deleteFolder(path) {
|
|
89
|
+
if (!this._canPerformOperation()) {
|
|
90
|
+
return
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return await this.apiInstance.post(`${process.env.ZUDELLO_API_URL}/s3/${this.type}/delete-folder`, {
|
|
94
|
+
path
|
|
95
|
+
}, {
|
|
96
|
+
'x-team': this.teamUUID
|
|
97
|
+
})
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async deleteFile(path, fileName) {
|
|
101
|
+
if (!this._canPerformOperation()) {
|
|
102
|
+
return
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return await this.apiInstance.post(`${process.env.ZUDELLO_API_URL}/s3/${this.type}/delete-file`, {
|
|
106
|
+
path,
|
|
107
|
+
fileName
|
|
108
|
+
}, {
|
|
109
|
+
'x-team': this.teamUUID
|
|
110
|
+
})
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
_canPerformOperation() {
|
|
114
|
+
return this.apiInstance && this.teamUUID && process.env.ZUDELLO_API_URL && this.type
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
module.exports = Bucket
|
package/src/utils/config.js
CHANGED
|
@@ -6,6 +6,7 @@ module.exports = {
|
|
|
6
6
|
netsuite: "010d0262-fa01-43eb-9e35-1b49e131c1ba",
|
|
7
7
|
intacct: "a8bbbc60-2409-49e8-adfb-72fc79658dd6",
|
|
8
8
|
bc: "ee6f62f5-9dda-48aa-bb8d-44c8b8455472",
|
|
9
|
+
dynamics365: "0d4161d5-5803-4cf9-8669-4d415a9be9f0",
|
|
9
10
|
zenoti: "967a0844-6a9d-4979-a298-427259eafad8",
|
|
10
11
|
dear: "0e456359-fe0d-4b01-9662-08bba1bdce63",
|
|
11
12
|
nexvia: "5f693545-3be0-4798-bb3b-3af0b7ee2e96",
|
|
@@ -13,6 +14,8 @@ module.exports = {
|
|
|
13
14
|
navision: "",
|
|
14
15
|
retailExpress: "49584664-65a5-4b76-ba62-a73f7b7b3885",
|
|
15
16
|
myobAcumatica: "8fd5015c-a200-4675-9e03-2047807c5693",
|
|
17
|
+
sharepoint: "30e57b25-4aa3-4b4e-9d9a-edc8932108da",
|
|
18
|
+
sftp: "506bd61e-54b2-4f4d-9641-907ec679afc6",
|
|
16
19
|
myobAccountRight: "",
|
|
17
20
|
sybiz: "ead57add-301e-4b29-881b-1bc331c101a5",
|
|
18
21
|
xero: "71648f29-7867-40d8-ac68-651b53cb3c49",
|
|
@@ -21,6 +24,7 @@ module.exports = {
|
|
|
21
24
|
sapb1: "de1ee5bd-d3ec-41cf-83f9-dcd2f51fcccd",
|
|
22
25
|
gp: "c1fb133b-73f6-4b85-9362-59c7c2d9017f",
|
|
23
26
|
edi: "6b3a284f-ca06-435c-bdf1-ad59c577a6a7",
|
|
27
|
+
mam: "acb7938a-06ba-4c6e-80e4-2bde7b0145a3",
|
|
24
28
|
sunsystems: "",
|
|
25
29
|
},
|
|
26
30
|
};
|