zudello-integration-sdk 1.0.83 → 1.0.85
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 +2 -2
- package/src/sdk/Airwallex.js +1 -7
- package/src/sdk/Base.js +22 -33
- package/src/sdk/BusinessCentral.js +2 -8
- package/src/sdk/Dear.js +1 -7
- package/src/sdk/Dynamics365.js +1 -7
- package/src/sdk/EDI.js +19 -25
- package/src/sdk/Fo.js +1 -7
- package/src/sdk/GP.js +27 -33
- package/src/sdk/InspHire.js +1 -7
- package/src/sdk/Intacct.js +95 -101
- package/src/sdk/JobReady.js +1 -7
- package/src/sdk/JobReadyLive.js +1 -7
- package/src/sdk/MAM.js +19 -25
- package/src/sdk/MSSQL.js +1 -7
- package/src/sdk/MYOBAccountRight.js +1 -7
- package/src/sdk/MYOBAcumatica.js +1 -7
- package/src/sdk/Navision.js +1 -7
- package/src/sdk/Netsuite.js +1 -7
- package/src/sdk/NetsuiteSOAP.js +81 -87
- package/src/sdk/Nexvia.js +1 -7
- package/src/sdk/RetailExpress.js +1 -7
- package/src/sdk/S4.js +9 -22
- package/src/sdk/SAPB1.js +1 -7
- package/src/sdk/SFTP.js +1 -7
- package/src/sdk/Sharepoint.js +1 -7
- package/src/sdk/Skript.js +1 -7
- package/src/sdk/SunSystems.js +1 -7
- package/src/sdk/Sybiz.js +1 -7
- package/src/sdk/X3.js +19 -25
- package/src/sdk/Xero.js +19 -25
- package/src/sdk/Zenoti.js +1 -7
- package/src/sdk/Zudello.js +123 -130
- package/src/sdk/ZudelloAuth.js +2 -6
- package/src/sdk/ZudelloStore.js +7 -12
- package/src/sdk/submodules/jobreadylive/Universal.js +2 -2
- package/src/sdk/submodules/mssql/Universal.js +3 -4
- package/src/utils/ai.js +10 -5
- package/src/utils/apiInstance.js +5 -12
- package/src/utils/bucket.js +20 -11
- package/src/utils/config.js +49 -28
- package/src/utils/context.js +15 -0
- package/src/utils/datasetHelper.js +6 -4
- package/src/utils/ediBucket.js +2 -2
- package/src/utils/fileBucket.js +2 -2
- package/src/utils/formHelper.js +12 -9
- package/src/utils/logger.js +4 -2
- package/src/utils/message.js +10 -5
- package/src/utils/modelHelper.js +6 -4
- package/src/utils/responseHandler.js +23 -23
- package/src/utils/responseHelper.js +10 -7
- package/src/utils/s3Client.js +4 -3
- package/src/utils/trigger.js +10 -5
- package/src/sdk/Auth.js +0 -42
package/src/sdk/Xero.js
CHANGED
|
@@ -1,31 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict'
|
|
2
2
|
|
|
3
|
-
const BaseSDK = require(
|
|
4
|
-
const UniversalModule = require(
|
|
3
|
+
const BaseSDK = require('./Base')
|
|
4
|
+
const UniversalModule = require('./submodules/xero/Universal')
|
|
5
5
|
|
|
6
6
|
class XeroSDK extends BaseSDK {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
apiURL,
|
|
18
|
-
apiVersion,
|
|
19
|
-
appUUIDKey: "xero",
|
|
20
|
-
integrationName: "xero",
|
|
21
|
-
loggerClass,
|
|
22
|
-
});
|
|
7
|
+
/**
|
|
8
|
+
* Constructor.
|
|
9
|
+
* @param {string} connectionUUID The UUID of the Connection we're working on.
|
|
10
|
+
*/
|
|
11
|
+
constructor(connectionUUID) {
|
|
12
|
+
super({
|
|
13
|
+
connectionUUID,
|
|
14
|
+
appUUIDKey: 'xero',
|
|
15
|
+
integrationName: 'xero',
|
|
16
|
+
})
|
|
23
17
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Create submodule instances.
|
|
20
|
+
*/
|
|
21
|
+
this.universal = new UniversalModule(this)
|
|
22
|
+
}
|
|
29
23
|
}
|
|
30
24
|
|
|
31
|
-
module.exports = XeroSDK
|
|
25
|
+
module.exports = XeroSDK
|
package/src/sdk/Zenoti.js
CHANGED
|
@@ -6,19 +6,13 @@ const UniversalModule = require('./submodules/zenoti/Universal')
|
|
|
6
6
|
class ZenotiSDK extends BaseSDK {
|
|
7
7
|
/**
|
|
8
8
|
* Constructor.
|
|
9
|
-
* @param {class} auth Auth class object with authorized api instance.
|
|
10
9
|
* @param {string} connectionUUID The UUID of the Connection we're working on.
|
|
11
10
|
*/
|
|
12
|
-
constructor (
|
|
11
|
+
constructor (connectionUUID) {
|
|
13
12
|
super({
|
|
14
|
-
auth,
|
|
15
13
|
connectionUUID,
|
|
16
|
-
organizationUUID,
|
|
17
|
-
apiURL,
|
|
18
|
-
apiVersion,
|
|
19
14
|
appUUIDKey: 'zenoti',
|
|
20
15
|
integrationName: 'Zenoti',
|
|
21
|
-
loggerClass
|
|
22
16
|
})
|
|
23
17
|
|
|
24
18
|
/**
|
package/src/sdk/Zudello.js
CHANGED
|
@@ -1,135 +1,128 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const _ = require(
|
|
4
|
-
|
|
5
|
-
const BaseSDK = require(
|
|
6
|
-
const AccountModule = require(
|
|
7
|
-
const AccountGroupModule = require(
|
|
8
|
-
const AccountingPeriodModule = require(
|
|
9
|
-
const AmortizationScheduleModule = require(
|
|
10
|
-
const BatchModule = require(
|
|
11
|
-
const BinModule = require(
|
|
12
|
-
const BudgetModule = require(
|
|
13
|
-
const CostCentreModule = require(
|
|
14
|
-
const CostTypeModule = require(
|
|
15
|
-
const CustomerModule = require(
|
|
16
|
-
const CustomerCategoryModule = require(
|
|
17
|
-
const CustomerGroupModule = require(
|
|
18
|
-
const CurrencyModule = require(
|
|
19
|
-
const DepartmentModule = require(
|
|
20
|
-
const EmployeeModule = require(
|
|
21
|
-
const ExpenseCategoryModule = require(
|
|
22
|
-
const SubsidiaryModule = require(
|
|
23
|
-
const LocationModule = require(
|
|
24
|
-
const MileageRateModule = require(
|
|
25
|
-
const TaxRateModule = require(
|
|
26
|
-
const TaxSolutionModule = require(
|
|
27
|
-
const ItemModule = require(
|
|
28
|
-
const ItemCategoryModule = require(
|
|
29
|
-
const ItemGroupModule = require(
|
|
30
|
-
const JournalModule = require(
|
|
31
|
-
const PurchaseOrderModule = require(
|
|
32
|
-
const Payment = require(
|
|
33
|
-
const PaymentTermModule = require(
|
|
34
|
-
const PaymentMethodModule = require(
|
|
35
|
-
const ProjectModule = require(
|
|
36
|
-
const ProjectGroupModule = require(
|
|
37
|
-
const ProjectTaskModule = require(
|
|
38
|
-
const ProjectTypeModule = require(
|
|
39
|
-
const RefundModule = require(
|
|
40
|
-
const SupplierCategoryModule = require(
|
|
41
|
-
const SupplierGroupModule = require(
|
|
42
|
-
const TeamAddressModule = require(
|
|
43
|
-
const UomModule = require(
|
|
44
|
-
const WarehouseModule = require(
|
|
45
|
-
const ZoneModule = require(
|
|
46
|
-
const SupplierModule = require(
|
|
47
|
-
const FixedAssetModule = require(
|
|
48
|
-
const UniversalModule = require(
|
|
49
|
-
const { default: axios } = require(
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const _ = require('lodash')
|
|
4
|
+
|
|
5
|
+
const BaseSDK = require('./Base')
|
|
6
|
+
const AccountModule = require('./submodules/zudello/Account')
|
|
7
|
+
const AccountGroupModule = require('./submodules/zudello/AccountGroup')
|
|
8
|
+
const AccountingPeriodModule = require('./submodules/zudello/AccountingPeriod')
|
|
9
|
+
const AmortizationScheduleModule = require('./submodules/zudello/AmortizationSchedule')
|
|
10
|
+
const BatchModule = require('./submodules/zudello/Batch')
|
|
11
|
+
const BinModule = require('./submodules/zudello/Bin')
|
|
12
|
+
const BudgetModule = require('./submodules/zudello/Budget')
|
|
13
|
+
const CostCentreModule = require('./submodules/zudello/CostCentre')
|
|
14
|
+
const CostTypeModule = require('./submodules/zudello/CostType')
|
|
15
|
+
const CustomerModule = require('./submodules/zudello/Customer')
|
|
16
|
+
const CustomerCategoryModule = require('./submodules/zudello/CustomerCategory')
|
|
17
|
+
const CustomerGroupModule = require('./submodules/zudello/CustomerGroup')
|
|
18
|
+
const CurrencyModule = require('./submodules/zudello/Currency')
|
|
19
|
+
const DepartmentModule = require('./submodules/zudello/Department')
|
|
20
|
+
const EmployeeModule = require('./submodules/zudello/Employee')
|
|
21
|
+
const ExpenseCategoryModule = require('./submodules/zudello/ExpenseCategory')
|
|
22
|
+
const SubsidiaryModule = require('./submodules/zudello/Subsidiary')
|
|
23
|
+
const LocationModule = require('./submodules/zudello/Location')
|
|
24
|
+
const MileageRateModule = require('./submodules/zudello/MileageRate')
|
|
25
|
+
const TaxRateModule = require('./submodules/zudello/tax/Rate')
|
|
26
|
+
const TaxSolutionModule = require('./submodules/zudello/tax/Solution')
|
|
27
|
+
const ItemModule = require('./submodules/zudello/Item')
|
|
28
|
+
const ItemCategoryModule = require('./submodules/zudello/ItemCategory')
|
|
29
|
+
const ItemGroupModule = require('./submodules/zudello/ItemGroup')
|
|
30
|
+
const JournalModule = require('./submodules/zudello/Journal')
|
|
31
|
+
const PurchaseOrderModule = require('./submodules/zudello/PurchaseOrder')
|
|
32
|
+
const Payment = require('./submodules/zudello/Payment')
|
|
33
|
+
const PaymentTermModule = require('./submodules/zudello/PaymentTerm')
|
|
34
|
+
const PaymentMethodModule = require('./submodules/zudello/PaymentMethod')
|
|
35
|
+
const ProjectModule = require('./submodules/zudello/Project')
|
|
36
|
+
const ProjectGroupModule = require('./submodules/zudello/ProjectGroup')
|
|
37
|
+
const ProjectTaskModule = require('./submodules/zudello/ProjectTask')
|
|
38
|
+
const ProjectTypeModule = require('./submodules/zudello/ProjectType')
|
|
39
|
+
const RefundModule = require('./submodules/zudello/Refund')
|
|
40
|
+
const SupplierCategoryModule = require('./submodules/zudello/SupplierCategory')
|
|
41
|
+
const SupplierGroupModule = require('./submodules/zudello/SupplierGroup')
|
|
42
|
+
const TeamAddressModule = require('./submodules/zudello/TeamAddress')
|
|
43
|
+
const UomModule = require('./submodules/zudello/Uom')
|
|
44
|
+
const WarehouseModule = require('./submodules/zudello/Warehouse')
|
|
45
|
+
const ZoneModule = require('./submodules/zudello/Zone')
|
|
46
|
+
const SupplierModule = require('./submodules/zudello/Supplier')
|
|
47
|
+
const FixedAssetModule = require('./submodules/zudello/FixedAsset')
|
|
48
|
+
const UniversalModule = require('./submodules/zudello/Universal')
|
|
49
|
+
const { default: axios } = require('axios')
|
|
50
50
|
|
|
51
51
|
class ZudelloSDK extends BaseSDK {
|
|
52
52
|
/**
|
|
53
53
|
* Constructor.
|
|
54
|
-
* @param {class} auth Auth class object with authorized api instance.
|
|
55
|
-
* @param {string} connectionUUID The UUID of the Connection we're working on.
|
|
56
54
|
*/
|
|
57
|
-
constructor(
|
|
55
|
+
constructor() {
|
|
58
56
|
super({
|
|
59
|
-
auth,
|
|
60
|
-
organizationUUID,
|
|
61
|
-
apiURL,
|
|
62
|
-
apiVersion,
|
|
63
57
|
isExternal: false,
|
|
64
|
-
integrationName:
|
|
65
|
-
|
|
66
|
-
});
|
|
58
|
+
integrationName: 'Zudello',
|
|
59
|
+
})
|
|
67
60
|
|
|
68
61
|
this.staticFieldsForUpdate = {
|
|
69
62
|
enrich: false,
|
|
70
63
|
extractedEvent: false,
|
|
71
64
|
update: true,
|
|
72
|
-
}
|
|
65
|
+
}
|
|
73
66
|
|
|
74
67
|
/**
|
|
75
68
|
* Create submodule instances.
|
|
76
69
|
*/
|
|
77
|
-
this.account = new AccountModule(this)
|
|
78
|
-
this.accountGroup = new AccountGroupModule(this)
|
|
79
|
-
this.accountingPeriod = new AccountingPeriodModule(this)
|
|
80
|
-
this.amortizationSchedule = new AmortizationScheduleModule(this)
|
|
81
|
-
this.batch = new BatchModule(this)
|
|
82
|
-
this.bin = new BinModule(this)
|
|
83
|
-
this.budget = new BudgetModule(this)
|
|
84
|
-
this.costCentre = new CostCentreModule(this)
|
|
85
|
-
this.costType = new CostTypeModule(this)
|
|
86
|
-
this.customer = new CustomerModule(this)
|
|
87
|
-
this.customerCategory = new CustomerCategoryModule(this)
|
|
88
|
-
this.customerGroup = new CustomerGroupModule(this)
|
|
89
|
-
this.currency = new CurrencyModule(this)
|
|
90
|
-
this.department = new DepartmentModule(this)
|
|
91
|
-
this.employee = new EmployeeModule(this)
|
|
92
|
-
this.expenseCategory = new ExpenseCategoryModule(this)
|
|
93
|
-
this.subsidiary = new SubsidiaryModule(this)
|
|
94
|
-
this.location = new LocationModule(this)
|
|
95
|
-
this.mileageRate = new MileageRateModule(this)
|
|
96
|
-
this.item = new ItemModule(this)
|
|
97
|
-
this.itemCategory = new ItemCategoryModule(this)
|
|
98
|
-
this.itemGroup = new ItemGroupModule(this)
|
|
99
|
-
this.journal = new JournalModule(this)
|
|
100
|
-
this.purchaseOrder = new PurchaseOrderModule(this)
|
|
101
|
-
this.payment = new Payment(this)
|
|
102
|
-
this.paymentTerm = new PaymentTermModule(this)
|
|
103
|
-
this.paymentMethod = new PaymentMethodModule(this)
|
|
104
|
-
this.project = new ProjectModule(this)
|
|
105
|
-
this.projectGroup = new ProjectGroupModule(this)
|
|
106
|
-
this.projectTask = new ProjectTaskModule(this)
|
|
107
|
-
this.projectType = new ProjectTypeModule(this)
|
|
108
|
-
this.refund = new RefundModule(this)
|
|
109
|
-
this.supplierCategory = new SupplierCategoryModule(this)
|
|
110
|
-
this.supplierGroup = new SupplierGroupModule(this)
|
|
111
|
-
this.teamAddress = new TeamAddressModule(this)
|
|
112
|
-
this.warehouse = new WarehouseModule(this)
|
|
113
|
-
this.uom = new UomModule(this)
|
|
114
|
-
this.zone = new ZoneModule(this)
|
|
115
|
-
this.supplier = new SupplierModule(this)
|
|
116
|
-
this.fixedAsset = new FixedAssetModule(this)
|
|
117
|
-
this.universal = new UniversalModule(this)
|
|
70
|
+
this.account = new AccountModule(this)
|
|
71
|
+
this.accountGroup = new AccountGroupModule(this)
|
|
72
|
+
this.accountingPeriod = new AccountingPeriodModule(this)
|
|
73
|
+
this.amortizationSchedule = new AmortizationScheduleModule(this)
|
|
74
|
+
this.batch = new BatchModule(this)
|
|
75
|
+
this.bin = new BinModule(this)
|
|
76
|
+
this.budget = new BudgetModule(this)
|
|
77
|
+
this.costCentre = new CostCentreModule(this)
|
|
78
|
+
this.costType = new CostTypeModule(this)
|
|
79
|
+
this.customer = new CustomerModule(this)
|
|
80
|
+
this.customerCategory = new CustomerCategoryModule(this)
|
|
81
|
+
this.customerGroup = new CustomerGroupModule(this)
|
|
82
|
+
this.currency = new CurrencyModule(this)
|
|
83
|
+
this.department = new DepartmentModule(this)
|
|
84
|
+
this.employee = new EmployeeModule(this)
|
|
85
|
+
this.expenseCategory = new ExpenseCategoryModule(this)
|
|
86
|
+
this.subsidiary = new SubsidiaryModule(this)
|
|
87
|
+
this.location = new LocationModule(this)
|
|
88
|
+
this.mileageRate = new MileageRateModule(this)
|
|
89
|
+
this.item = new ItemModule(this)
|
|
90
|
+
this.itemCategory = new ItemCategoryModule(this)
|
|
91
|
+
this.itemGroup = new ItemGroupModule(this)
|
|
92
|
+
this.journal = new JournalModule(this)
|
|
93
|
+
this.purchaseOrder = new PurchaseOrderModule(this)
|
|
94
|
+
this.payment = new Payment(this)
|
|
95
|
+
this.paymentTerm = new PaymentTermModule(this)
|
|
96
|
+
this.paymentMethod = new PaymentMethodModule(this)
|
|
97
|
+
this.project = new ProjectModule(this)
|
|
98
|
+
this.projectGroup = new ProjectGroupModule(this)
|
|
99
|
+
this.projectTask = new ProjectTaskModule(this)
|
|
100
|
+
this.projectType = new ProjectTypeModule(this)
|
|
101
|
+
this.refund = new RefundModule(this)
|
|
102
|
+
this.supplierCategory = new SupplierCategoryModule(this)
|
|
103
|
+
this.supplierGroup = new SupplierGroupModule(this)
|
|
104
|
+
this.teamAddress = new TeamAddressModule(this)
|
|
105
|
+
this.warehouse = new WarehouseModule(this)
|
|
106
|
+
this.uom = new UomModule(this)
|
|
107
|
+
this.zone = new ZoneModule(this)
|
|
108
|
+
this.supplier = new SupplierModule(this)
|
|
109
|
+
this.fixedAsset = new FixedAssetModule(this)
|
|
110
|
+
this.universal = new UniversalModule(this)
|
|
118
111
|
this.tax = {
|
|
119
112
|
rate: new TaxRateModule(this),
|
|
120
113
|
solution: new TaxSolutionModule(this),
|
|
121
|
-
}
|
|
114
|
+
}
|
|
122
115
|
}
|
|
123
116
|
|
|
124
|
-
async search({ model, select, filter = {}, orderBy = [
|
|
125
|
-
const validateIsEmpty = this.validator.isEmpty({ model, select })
|
|
117
|
+
async search({ model, select, filter = {}, orderBy = ['-created_at'], offset = 0, limit = 100 }) {
|
|
118
|
+
const validateIsEmpty = this.validator.isEmpty({ model, select })
|
|
126
119
|
|
|
127
120
|
if (!validateIsEmpty.valid) {
|
|
128
|
-
return this.responseHandler.error(validateIsEmpty.errors)
|
|
121
|
+
return this.responseHandler.error(validateIsEmpty.errors)
|
|
129
122
|
}
|
|
130
123
|
|
|
131
124
|
return await this.makeRequest(
|
|
132
|
-
|
|
125
|
+
'POST',
|
|
133
126
|
`${this.apiURL}/team-data/${this.apiVersion}/resources/search`,
|
|
134
127
|
{
|
|
135
128
|
model,
|
|
@@ -141,50 +134,50 @@ class ZudelloSDK extends BaseSDK {
|
|
|
141
134
|
exclude: {},
|
|
142
135
|
annotate: {},
|
|
143
136
|
}
|
|
144
|
-
)
|
|
137
|
+
)
|
|
145
138
|
}
|
|
146
139
|
|
|
147
140
|
async fetch({ model, uuid, fetchDetails = true, simplified = true }) {
|
|
148
|
-
const validateIsEmpty = this.validator.isEmpty({ model, uuid })
|
|
141
|
+
const validateIsEmpty = this.validator.isEmpty({ model, uuid })
|
|
149
142
|
|
|
150
143
|
if (!validateIsEmpty.valid) {
|
|
151
|
-
return this.responseHandler.error(validateIsEmpty.errors)
|
|
144
|
+
return this.responseHandler.error(validateIsEmpty.errors)
|
|
152
145
|
}
|
|
153
146
|
|
|
154
|
-
return await this.makeRequest(
|
|
147
|
+
return await this.makeRequest('GET', `${this.apiURL}/team-data/${this.apiVersion}/resources`, {
|
|
155
148
|
model,
|
|
156
149
|
uuid,
|
|
157
150
|
fetch_details: fetchDetails,
|
|
158
151
|
simplified,
|
|
159
|
-
})
|
|
152
|
+
})
|
|
160
153
|
}
|
|
161
154
|
|
|
162
155
|
async getFileAttachment({ uuid, type }) {
|
|
163
|
-
const validateIsEmpty = this.validator.isEmpty({ uuid, type })
|
|
156
|
+
const validateIsEmpty = this.validator.isEmpty({ uuid, type })
|
|
164
157
|
|
|
165
158
|
if (!validateIsEmpty.valid) {
|
|
166
|
-
return this.responseHandler.error(validateIsEmpty.errors)
|
|
159
|
+
return this.responseHandler.error(validateIsEmpty.errors)
|
|
167
160
|
}
|
|
168
161
|
|
|
169
162
|
return await this.makeRequest(
|
|
170
|
-
|
|
163
|
+
'GET',
|
|
171
164
|
`${this.apiURL}/team-data/${this.apiVersion}/files/download/Transaction/${uuid}/${type}`,
|
|
172
165
|
{},
|
|
173
166
|
{},
|
|
174
167
|
true
|
|
175
|
-
)
|
|
168
|
+
)
|
|
176
169
|
}
|
|
177
170
|
|
|
178
171
|
async getFileContent({ uuid, type }) {
|
|
179
|
-
const validateIsEmpty = this.validator.isEmpty({ uuid, type })
|
|
172
|
+
const validateIsEmpty = this.validator.isEmpty({ uuid, type })
|
|
180
173
|
|
|
181
174
|
if (!validateIsEmpty.valid) {
|
|
182
|
-
return this.responseHandler.error(validateIsEmpty.errors)
|
|
175
|
+
return this.responseHandler.error(validateIsEmpty.errors)
|
|
183
176
|
}
|
|
184
177
|
|
|
185
|
-
const response = await this.getFileAttachment({ uuid, type })
|
|
178
|
+
const response = await this.getFileAttachment({ uuid, type })
|
|
186
179
|
|
|
187
|
-
return await axios.get(response.data)
|
|
180
|
+
return await axios.get(response.data)
|
|
188
181
|
}
|
|
189
182
|
|
|
190
183
|
async update({
|
|
@@ -198,10 +191,10 @@ class ZudelloSDK extends BaseSDK {
|
|
|
198
191
|
updateStatus = false,
|
|
199
192
|
enrich = false,
|
|
200
193
|
}) {
|
|
201
|
-
const validateIsEmpty = this.validator.isEmpty({ model, data })
|
|
194
|
+
const validateIsEmpty = this.validator.isEmpty({ model, data })
|
|
202
195
|
|
|
203
196
|
if (!validateIsEmpty.valid) {
|
|
204
|
-
return this.responseHandler.error(validateIsEmpty.errors)
|
|
197
|
+
return this.responseHandler.error(validateIsEmpty.errors)
|
|
205
198
|
}
|
|
206
199
|
|
|
207
200
|
data = this.mapUpdateOrCreateData({
|
|
@@ -215,27 +208,27 @@ class ZudelloSDK extends BaseSDK {
|
|
|
215
208
|
},
|
|
216
209
|
submit,
|
|
217
210
|
updateStatus,
|
|
218
|
-
})
|
|
211
|
+
})
|
|
219
212
|
|
|
220
|
-
return await this.updateOrCreate({ data, clearNulls, simplified })
|
|
213
|
+
return await this.updateOrCreate({ data, clearNulls, simplified })
|
|
221
214
|
}
|
|
222
215
|
|
|
223
216
|
async updateOrCreate({ data, clearNulls = true, simplified = false }) {
|
|
224
|
-
const validateIsEmpty = this.validator.isEmpty({ data })
|
|
217
|
+
const validateIsEmpty = this.validator.isEmpty({ data })
|
|
225
218
|
|
|
226
219
|
if (!validateIsEmpty.valid) {
|
|
227
|
-
return this.responseHandler.error(validateIsEmpty.errors)
|
|
220
|
+
return this.responseHandler.error(validateIsEmpty.errors)
|
|
228
221
|
}
|
|
229
222
|
|
|
230
223
|
return await this.makeRequest(
|
|
231
|
-
|
|
224
|
+
'POST',
|
|
232
225
|
`${this.apiURL}/team-data/${this.apiVersion}/resources/update_or_create`,
|
|
233
226
|
{
|
|
234
227
|
simplified,
|
|
235
228
|
clear_nulls: clearNulls,
|
|
236
229
|
data,
|
|
237
230
|
}
|
|
238
|
-
)
|
|
231
|
+
)
|
|
239
232
|
}
|
|
240
233
|
|
|
241
234
|
mapUpdateOrCreateData({ data = [], staticFields = {}, submit = false, updateStatus = false }) {
|
|
@@ -254,9 +247,9 @@ class ZudelloSDK extends BaseSDK {
|
|
|
254
247
|
update_status: updateStatus,
|
|
255
248
|
update: staticFields.update,
|
|
256
249
|
create: staticFields.create,
|
|
257
|
-
}
|
|
258
|
-
})
|
|
250
|
+
}
|
|
251
|
+
})
|
|
259
252
|
}
|
|
260
253
|
}
|
|
261
254
|
|
|
262
|
-
module.exports = ZudelloSDK
|
|
255
|
+
module.exports = ZudelloSDK
|
package/src/sdk/ZudelloAuth.js
CHANGED
|
@@ -7,15 +7,11 @@ class ZudelloAuthSDK extends BaseSDK {
|
|
|
7
7
|
/**
|
|
8
8
|
* Constructor.
|
|
9
9
|
*/
|
|
10
|
-
constructor(
|
|
10
|
+
constructor() {
|
|
11
11
|
super({
|
|
12
|
-
auth,
|
|
13
|
-
organizationUUID,
|
|
14
|
-
apiURL,
|
|
15
|
-
apiVersion,
|
|
16
12
|
isExternal: false,
|
|
13
|
+
useAuthApiUrl: true,
|
|
17
14
|
integrationName: 'ZudelloAuth',
|
|
18
|
-
loggerClass,
|
|
19
15
|
})
|
|
20
16
|
|
|
21
17
|
this.staticFieldsForUpdate = {
|
package/src/sdk/ZudelloStore.js
CHANGED
|
@@ -4,15 +4,10 @@ const _ = require('lodash')
|
|
|
4
4
|
const BaseSDK = require('./Base')
|
|
5
5
|
|
|
6
6
|
class ZudelloStoreSDK extends BaseSDK {
|
|
7
|
-
constructor(
|
|
7
|
+
constructor() {
|
|
8
8
|
super({
|
|
9
|
-
auth,
|
|
10
|
-
organizationUUID,
|
|
11
|
-
apiURL,
|
|
12
|
-
apiVersion,
|
|
13
9
|
isExternal: false,
|
|
14
10
|
integrationName: 'ZudelloStore',
|
|
15
|
-
loggerClass,
|
|
16
11
|
})
|
|
17
12
|
|
|
18
13
|
this.staticFieldsForUpdate = {
|
|
@@ -30,8 +25,8 @@ class ZudelloStoreSDK extends BaseSDK {
|
|
|
30
25
|
}
|
|
31
26
|
|
|
32
27
|
return await this.makeRequest(
|
|
33
|
-
|
|
34
|
-
`${this.apiURL}/general-store/api/${this.apiVersion}/resources/${uuid}${resource_type ? `?resource_type=${resource_type}` :
|
|
28
|
+
'GET',
|
|
29
|
+
`${this.apiURL}/general-store/api/${this.apiVersion}/resources/${uuid}${resource_type ? `?resource_type=${resource_type}` : ''}`,
|
|
35
30
|
{}
|
|
36
31
|
)
|
|
37
32
|
}
|
|
@@ -44,12 +39,12 @@ class ZudelloStoreSDK extends BaseSDK {
|
|
|
44
39
|
}
|
|
45
40
|
|
|
46
41
|
const resource = await this.makeRequest(
|
|
47
|
-
|
|
42
|
+
'GET',
|
|
48
43
|
`${this.apiURL}/general-store/api/${this.apiVersion}/resources/?resource_type=document_type&document_type=${documentType}`,
|
|
49
44
|
{}
|
|
50
45
|
)
|
|
51
46
|
|
|
52
|
-
return _.map(_.get(resource,
|
|
47
|
+
return _.map(_.get(resource, 'data[0].payload.settings.fields', []), 'path')
|
|
53
48
|
}
|
|
54
49
|
|
|
55
50
|
async fetchMetadata({ model }) {
|
|
@@ -60,7 +55,7 @@ class ZudelloStoreSDK extends BaseSDK {
|
|
|
60
55
|
}
|
|
61
56
|
|
|
62
57
|
const fieldMetadata = await this.makeRequest(
|
|
63
|
-
|
|
58
|
+
'GET',
|
|
64
59
|
`${this.apiURL}/general-store/api/${this.apiVersion}/metadata/field-metadata?section=forms&model_name=${model}`,
|
|
65
60
|
{}
|
|
66
61
|
)
|
|
@@ -69,4 +64,4 @@ class ZudelloStoreSDK extends BaseSDK {
|
|
|
69
64
|
}
|
|
70
65
|
}
|
|
71
66
|
|
|
72
|
-
module.exports = ZudelloStoreSDK
|
|
67
|
+
module.exports = ZudelloStoreSDK
|
|
@@ -93,7 +93,7 @@ class UniversalModule {
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
let response = await this.list({ url, method, header, qs, body });
|
|
96
|
-
let currentPageCount = response?.data?.
|
|
96
|
+
let currentPageCount = response?.data?.length;
|
|
97
97
|
|
|
98
98
|
yield response;
|
|
99
99
|
|
|
@@ -102,7 +102,7 @@ class UniversalModule {
|
|
|
102
102
|
qs.page = qs.page + 1;
|
|
103
103
|
|
|
104
104
|
response = await this.list({ url, method, header, qs, body });
|
|
105
|
-
currentPageCount = response?.data?.
|
|
105
|
+
currentPageCount = response?.data?.length;
|
|
106
106
|
|
|
107
107
|
yield response;
|
|
108
108
|
}
|
|
@@ -77,12 +77,12 @@ class UniversalModule {
|
|
|
77
77
|
/**
|
|
78
78
|
* Auto-pagination generator using cursor-based pagination (recommended).
|
|
79
79
|
* @param {string} sql Base SQL Query.
|
|
80
|
-
* @param {object} options Cursor options: { cursorField,
|
|
80
|
+
* @param {object} options Cursor options: { cursorField, limit, orderBy }.
|
|
81
81
|
* @param {object} queryParams Query parameters.
|
|
82
82
|
* @returns {AsyncGenerator} Yields cursor-based responses.
|
|
83
83
|
*/
|
|
84
84
|
async *autoCursorQuery({ sql, options = {}, queryParams = {} }) {
|
|
85
|
-
const { cursorField,
|
|
85
|
+
const { cursorField, limit = 100, orderBy } = options;
|
|
86
86
|
|
|
87
87
|
let cursorValue = null;
|
|
88
88
|
let hasMoreData = true;
|
|
@@ -98,8 +98,7 @@ class UniversalModule {
|
|
|
98
98
|
|
|
99
99
|
const records = response?.data || [];
|
|
100
100
|
if (records.length > 0 && cursorField) {
|
|
101
|
-
|
|
102
|
-
cursorValue = records[records.length - 1][fieldToExtract];
|
|
101
|
+
cursorValue = records[records.length - 1][cursorField];
|
|
103
102
|
}
|
|
104
103
|
|
|
105
104
|
hasMoreData = records.length === limit;
|
package/src/utils/ai.js
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const ApiInstance = require('./apiInstance')
|
|
4
|
+
const config = require('./config')
|
|
5
|
+
|
|
3
6
|
class AI {
|
|
4
|
-
constructor(
|
|
5
|
-
this.apiInstance =
|
|
6
|
-
|
|
7
|
+
constructor() {
|
|
8
|
+
this.apiInstance = new ApiInstance()
|
|
9
|
+
|
|
10
|
+
this.teamUUID = config.envs.TEAM_UUID
|
|
11
|
+
this.apiURL = config.envs.ZUDELLO_API_URL
|
|
7
12
|
}
|
|
8
13
|
|
|
9
14
|
async prompt(data = {}) {
|
|
10
|
-
if (!this.
|
|
15
|
+
if (!this.teamUUID || !this.apiURL) {
|
|
11
16
|
return
|
|
12
17
|
}
|
|
13
18
|
|
|
14
|
-
return await this.apiInstance.post(`${
|
|
19
|
+
return await this.apiInstance.post(`${this.apiURL}/ai/prompt`, data, {
|
|
15
20
|
'x-team': this.teamUUID
|
|
16
21
|
}, {}, () => {}, 0, false)
|
|
17
22
|
}
|
package/src/utils/apiInstance.js
CHANGED
|
@@ -4,13 +4,14 @@ const axios = require('axios')
|
|
|
4
4
|
const https = require('https')
|
|
5
5
|
const CircularJSON = require('circular-json')
|
|
6
6
|
const ResponseHandler = require('./responseHandler')
|
|
7
|
+
const config = require('./config')
|
|
7
8
|
|
|
8
9
|
class ApiInstance {
|
|
9
10
|
/**
|
|
10
11
|
* Constructor.
|
|
11
12
|
*/
|
|
12
13
|
constructor () {
|
|
13
|
-
this.bearerToken =
|
|
14
|
+
this.bearerToken = config.envs.API_AUTH_TOKEN
|
|
14
15
|
this.retryStatuses = [502, 504, 408, 429, 500]
|
|
15
16
|
|
|
16
17
|
this.responseHandler = new ResponseHandler()
|
|
@@ -23,12 +24,12 @@ class ApiInstance {
|
|
|
23
24
|
})
|
|
24
25
|
})
|
|
25
26
|
|
|
26
|
-
this.axiosInstance.interceptors.request.use((
|
|
27
|
+
this.axiosInstance.interceptors.request.use((cfg) => {
|
|
27
28
|
if (this.bearerToken) {
|
|
28
|
-
|
|
29
|
+
cfg.headers.Authorization = `Bearer ${this.bearerToken}`
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
return
|
|
32
|
+
return cfg
|
|
32
33
|
}, (error) => {
|
|
33
34
|
return Promise.reject(error)
|
|
34
35
|
})
|
|
@@ -63,14 +64,6 @@ class ApiInstance {
|
|
|
63
64
|
)
|
|
64
65
|
}
|
|
65
66
|
|
|
66
|
-
/**
|
|
67
|
-
* Setter function for bearer token.
|
|
68
|
-
* @param {string} bearerToken Bearer Auth Token.
|
|
69
|
-
*/
|
|
70
|
-
setBearerToken (bearerToken) {
|
|
71
|
-
this.bearerToken = bearerToken
|
|
72
|
-
}
|
|
73
|
-
|
|
74
67
|
/**
|
|
75
68
|
* Send axios request (method: GET).
|
|
76
69
|
* @param {string} url Request URL.
|