zudello-integration-sdk 1.0.44 → 1.0.46
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
CHANGED
package/src/index.js
CHANGED
|
@@ -24,6 +24,7 @@ const GPSDK = require('./sdk/GP')
|
|
|
24
24
|
const EDISDK = require('./sdk/EDI')
|
|
25
25
|
const SunSystemsSDK = require('./sdk/SunSystems')
|
|
26
26
|
|
|
27
|
+
const AI = require('./utils/ai')
|
|
27
28
|
const Logger = require('./utils/logger')
|
|
28
29
|
const Metadata = require('./utils/metadata')
|
|
29
30
|
const Message = require('./utils/message')
|
|
@@ -55,6 +56,7 @@ const S3Client = {
|
|
|
55
56
|
|
|
56
57
|
module.exports = {
|
|
57
58
|
Auth,
|
|
59
|
+
AI,
|
|
58
60
|
ZudelloSDK,
|
|
59
61
|
ZudelloAuthSDK,
|
|
60
62
|
NetsuiteSDK,
|
|
@@ -11,7 +11,7 @@ class AttachmentModule {
|
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Create attachment.
|
|
14
|
-
* @param {object} body Body of attachment.
|
|
14
|
+
* @param {object} body Body of attachment. And should contain the following fields: record_type, record_id, folder_id, s3_signed_url, file_name
|
|
15
15
|
* @returns {object} Response.
|
|
16
16
|
*/
|
|
17
17
|
async create({ body }) {
|
package/src/utils/ai.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
class AI {
|
|
4
|
+
constructor(apiInstance = null, teamUUID = null) {
|
|
5
|
+
this.apiInstance = apiInstance
|
|
6
|
+
this.teamUUID = teamUUID
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
async prompt(data = {}) {
|
|
10
|
+
if (!this.apiInstance || !this.teamUUID || !process.env.ZUDELLO_API_URL) {
|
|
11
|
+
return
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return await this.apiInstance.post(`${process.env.ZUDELLO_API_URL}/ai/prompt`, data, {
|
|
15
|
+
'x-team': this.teamUUID
|
|
16
|
+
}, {}, () => {}, 0, false)
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
module.exports = AI
|
package/src/utils/apiInstance.js
CHANGED
|
@@ -144,7 +144,7 @@ class ApiInstance {
|
|
|
144
144
|
* @param {object} params Request Params.
|
|
145
145
|
* @returns {object} Response Data.
|
|
146
146
|
*/
|
|
147
|
-
async post (url, data, headers, params = {}, callback = () => {}, retryCount = 0) {
|
|
147
|
+
async post (url, data, headers, params = {}, callback = () => {}, retryCount = 0, handleResponse = true) {
|
|
148
148
|
try {
|
|
149
149
|
const response = await this.axiosInstance.post(url, data, { headers, params })
|
|
150
150
|
|
|
@@ -156,6 +156,10 @@ class ApiInstance {
|
|
|
156
156
|
body: data
|
|
157
157
|
})
|
|
158
158
|
|
|
159
|
+
if (!handleResponse) {
|
|
160
|
+
return response?.data
|
|
161
|
+
}
|
|
162
|
+
|
|
159
163
|
if (Object.prototype.hasOwnProperty.call(params, '_debug') && params._debug) {
|
|
160
164
|
return this.responseHandler.success(response?.data?.data || null)
|
|
161
165
|
}
|
|
@@ -175,7 +179,11 @@ class ApiInstance {
|
|
|
175
179
|
|
|
176
180
|
if (this.shouldRetry(error) && retryCount === 0) {
|
|
177
181
|
await this.sleep(20000)
|
|
178
|
-
return await this.post(url, data, headers, params, callback, retryCount + 1)
|
|
182
|
+
return await this.post(url, data, headers, params, callback, retryCount + 1, handleResponse)
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (!handleResponse) {
|
|
186
|
+
return error?.response?.data
|
|
179
187
|
}
|
|
180
188
|
|
|
181
189
|
if (error?.response?.status === 500) {
|