@konversi/konversi-client 1.4.2 → 1.4.3
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/KonversiError.ts +14 -0
- package/dist/index.js +107 -49
- package/dist/index.mjs +107 -49
- package/index.ts +45 -0
- package/package.json +1 -1
- package/test/createCustomObject.ts +1 -0
package/KonversiError.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { isAxiosError } from "axios";
|
|
2
|
+
|
|
3
|
+
export default class KonversiError extends Error {
|
|
4
|
+
constructor(error: Error) {
|
|
5
|
+
if (isAxiosError(error)) {
|
|
6
|
+
super(`Konversi API Error ${error.response?.status || 'unknown'}: ${error.response?.data || error.message}`);
|
|
7
|
+
} else {
|
|
8
|
+
super(`Konversi Error: ${error.message}`);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// Set the prototype explicitly.
|
|
12
|
+
Object.setPrototypeOf(this, KonversiError.prototype);
|
|
13
|
+
}
|
|
14
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -244,6 +244,20 @@ var IDENTIFIER_TOKEN = "identifier/identifier-token";
|
|
|
244
244
|
var INCOMING_SHIPMENT = "shipment/incoming-shipment";
|
|
245
245
|
var OUTGOING_SHIPMENT = "shipment/outgoing-shipment";
|
|
246
246
|
|
|
247
|
+
// KonversiError.ts
|
|
248
|
+
var import_axios2 = require("axios");
|
|
249
|
+
var KonversiError = class _KonversiError extends Error {
|
|
250
|
+
constructor(error) {
|
|
251
|
+
var _a2, _b;
|
|
252
|
+
if ((0, import_axios2.isAxiosError)(error)) {
|
|
253
|
+
super(`Konversi API Error ${((_a2 = error.response) == null ? void 0 : _a2.status) || "unknown"}: ${((_b = error.response) == null ? void 0 : _b.data) || error.message}`);
|
|
254
|
+
} else {
|
|
255
|
+
super(`Konversi Error: ${error.message}`);
|
|
256
|
+
}
|
|
257
|
+
Object.setPrototypeOf(this, _KonversiError.prototype);
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
|
|
247
261
|
// index.ts
|
|
248
262
|
function call(axiosRequest) {
|
|
249
263
|
return __async(this, null, function* () {
|
|
@@ -252,96 +266,140 @@ function call(axiosRequest) {
|
|
|
252
266
|
}
|
|
253
267
|
function getAllCustomObjects(_0) {
|
|
254
268
|
return __async(this, arguments, function* (schemaName, queryParams = {}) {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
269
|
+
try {
|
|
270
|
+
const response = yield axiosAPI_default.request({
|
|
271
|
+
method: "get",
|
|
272
|
+
url: `custom-entity/${schemaName}`,
|
|
273
|
+
params: queryParams
|
|
274
|
+
});
|
|
275
|
+
return response.data;
|
|
276
|
+
} catch (e) {
|
|
277
|
+
throw new KonversiError(e);
|
|
278
|
+
}
|
|
261
279
|
});
|
|
262
280
|
}
|
|
263
281
|
function getCustomObjectById(schemaName, id) {
|
|
264
282
|
return __async(this, null, function* () {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
283
|
+
try {
|
|
284
|
+
const response = yield axiosAPI_default.request({
|
|
285
|
+
method: "get",
|
|
286
|
+
url: `custom-entity/${schemaName}/${id}`
|
|
287
|
+
});
|
|
288
|
+
return response.data;
|
|
289
|
+
} catch (e) {
|
|
290
|
+
throw new KonversiError(e);
|
|
291
|
+
}
|
|
270
292
|
});
|
|
271
293
|
}
|
|
272
294
|
function updateCustomObject(schemaName, id, newData) {
|
|
273
295
|
return __async(this, null, function* () {
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
296
|
+
try {
|
|
297
|
+
const response = yield axiosAPI_default.request({
|
|
298
|
+
method: "put",
|
|
299
|
+
url: `custom-entity/${schemaName}/${id}`,
|
|
300
|
+
headers: {
|
|
301
|
+
"Content-Type": "application/json"
|
|
302
|
+
},
|
|
303
|
+
data: JSON.stringify(newData)
|
|
304
|
+
});
|
|
305
|
+
return response.data;
|
|
306
|
+
} catch (e) {
|
|
307
|
+
throw new KonversiError(e);
|
|
308
|
+
}
|
|
283
309
|
});
|
|
284
310
|
}
|
|
285
311
|
function createCustomObject(schemaName, data) {
|
|
286
312
|
return __async(this, null, function* () {
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
313
|
+
try {
|
|
314
|
+
const response = yield axiosAPI_default.request({
|
|
315
|
+
method: "post",
|
|
316
|
+
url: `custom-entity/${schemaName}`,
|
|
317
|
+
data
|
|
318
|
+
});
|
|
319
|
+
return response.data;
|
|
320
|
+
} catch (e) {
|
|
321
|
+
throw new KonversiError(e);
|
|
322
|
+
}
|
|
293
323
|
});
|
|
294
324
|
}
|
|
295
325
|
function deleteCustomObject(schemaName, id) {
|
|
296
326
|
return __async(this, null, function* () {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
327
|
+
try {
|
|
328
|
+
const response = yield axiosAPI_default.request({
|
|
329
|
+
method: "delete",
|
|
330
|
+
maxBodyLength: Infinity,
|
|
331
|
+
url: `custom-entity/${schemaName}/${id}`
|
|
332
|
+
});
|
|
333
|
+
return response.data;
|
|
334
|
+
} catch (e) {
|
|
335
|
+
throw new KonversiError(e);
|
|
336
|
+
}
|
|
303
337
|
});
|
|
304
338
|
}
|
|
305
339
|
function getAllObjects(_0) {
|
|
306
340
|
return __async(this, arguments, function* (entity, queryParams = {}) {
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
341
|
+
try {
|
|
342
|
+
const response = yield axiosAPI_default.get(`${entity}`, {
|
|
343
|
+
params: queryParams
|
|
344
|
+
});
|
|
345
|
+
return response.data;
|
|
346
|
+
} catch (e) {
|
|
347
|
+
throw new KonversiError(e);
|
|
348
|
+
}
|
|
311
349
|
});
|
|
312
350
|
}
|
|
313
351
|
function getObjectById(entity, id) {
|
|
314
352
|
return __async(this, null, function* () {
|
|
315
|
-
|
|
316
|
-
|
|
353
|
+
try {
|
|
354
|
+
const response = yield axiosAPI_default.get(`${entity}/${id}`);
|
|
355
|
+
return response.data;
|
|
356
|
+
} catch (e) {
|
|
357
|
+
throw new KonversiError(e);
|
|
358
|
+
}
|
|
317
359
|
});
|
|
318
360
|
}
|
|
319
361
|
function updateObject(entity, id, newData) {
|
|
320
362
|
return __async(this, null, function* () {
|
|
321
|
-
|
|
322
|
-
|
|
363
|
+
try {
|
|
364
|
+
const response = yield axiosAPI_default.put(`${entity}/${id}`, newData);
|
|
365
|
+
return response.data;
|
|
366
|
+
} catch (e) {
|
|
367
|
+
throw new KonversiError(e);
|
|
368
|
+
}
|
|
323
369
|
});
|
|
324
370
|
}
|
|
325
371
|
function createObject(entity, data) {
|
|
326
372
|
return __async(this, null, function* () {
|
|
327
|
-
|
|
328
|
-
|
|
373
|
+
try {
|
|
374
|
+
const response = yield axiosAPI_default.post(`${entity}`, data);
|
|
375
|
+
return response.data;
|
|
376
|
+
} catch (e) {
|
|
377
|
+
throw new KonversiError(e);
|
|
378
|
+
}
|
|
329
379
|
});
|
|
330
380
|
}
|
|
331
381
|
function deleteObject(entity, id) {
|
|
332
382
|
return __async(this, null, function* () {
|
|
333
|
-
|
|
334
|
-
|
|
383
|
+
try {
|
|
384
|
+
const response = yield axiosAPI_default.delete(`${entity}/${id}`);
|
|
385
|
+
return response.data;
|
|
386
|
+
} catch (e) {
|
|
387
|
+
throw new KonversiError(e);
|
|
388
|
+
}
|
|
335
389
|
});
|
|
336
390
|
}
|
|
337
391
|
function runScript(scriptNameOrId, input, sync = false) {
|
|
338
392
|
return __async(this, null, function* () {
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
393
|
+
try {
|
|
394
|
+
if (sync) {
|
|
395
|
+
const response2 = yield axiosAPI_default.post(`/automation/script/${scriptNameOrId}/run?mode=sync`, { input });
|
|
396
|
+
return response2.data;
|
|
397
|
+
}
|
|
398
|
+
const response = yield axiosAPI_default.post(`/automation/script/${scriptNameOrId}/run`, { input });
|
|
399
|
+
return response.data;
|
|
400
|
+
} catch (e) {
|
|
401
|
+
throw new KonversiError(e);
|
|
342
402
|
}
|
|
343
|
-
const response = yield axiosAPI_default.post(`/automation/script/${scriptNameOrId}/run`, { input });
|
|
344
|
-
return response.data;
|
|
345
403
|
});
|
|
346
404
|
}
|
|
347
405
|
var _a;
|
package/dist/index.mjs
CHANGED
|
@@ -212,6 +212,20 @@ var IDENTIFIER_TOKEN = "identifier/identifier-token";
|
|
|
212
212
|
var INCOMING_SHIPMENT = "shipment/incoming-shipment";
|
|
213
213
|
var OUTGOING_SHIPMENT = "shipment/outgoing-shipment";
|
|
214
214
|
|
|
215
|
+
// KonversiError.ts
|
|
216
|
+
import { isAxiosError } from "axios";
|
|
217
|
+
var KonversiError = class _KonversiError extends Error {
|
|
218
|
+
constructor(error) {
|
|
219
|
+
var _a2, _b;
|
|
220
|
+
if (isAxiosError(error)) {
|
|
221
|
+
super(`Konversi API Error ${((_a2 = error.response) == null ? void 0 : _a2.status) || "unknown"}: ${((_b = error.response) == null ? void 0 : _b.data) || error.message}`);
|
|
222
|
+
} else {
|
|
223
|
+
super(`Konversi Error: ${error.message}`);
|
|
224
|
+
}
|
|
225
|
+
Object.setPrototypeOf(this, _KonversiError.prototype);
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
|
|
215
229
|
// index.ts
|
|
216
230
|
function call(axiosRequest) {
|
|
217
231
|
return __async(this, null, function* () {
|
|
@@ -220,96 +234,140 @@ function call(axiosRequest) {
|
|
|
220
234
|
}
|
|
221
235
|
function getAllCustomObjects(_0) {
|
|
222
236
|
return __async(this, arguments, function* (schemaName, queryParams = {}) {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
237
|
+
try {
|
|
238
|
+
const response = yield axiosAPI_default.request({
|
|
239
|
+
method: "get",
|
|
240
|
+
url: `custom-entity/${schemaName}`,
|
|
241
|
+
params: queryParams
|
|
242
|
+
});
|
|
243
|
+
return response.data;
|
|
244
|
+
} catch (e) {
|
|
245
|
+
throw new KonversiError(e);
|
|
246
|
+
}
|
|
229
247
|
});
|
|
230
248
|
}
|
|
231
249
|
function getCustomObjectById(schemaName, id) {
|
|
232
250
|
return __async(this, null, function* () {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
251
|
+
try {
|
|
252
|
+
const response = yield axiosAPI_default.request({
|
|
253
|
+
method: "get",
|
|
254
|
+
url: `custom-entity/${schemaName}/${id}`
|
|
255
|
+
});
|
|
256
|
+
return response.data;
|
|
257
|
+
} catch (e) {
|
|
258
|
+
throw new KonversiError(e);
|
|
259
|
+
}
|
|
238
260
|
});
|
|
239
261
|
}
|
|
240
262
|
function updateCustomObject(schemaName, id, newData) {
|
|
241
263
|
return __async(this, null, function* () {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
264
|
+
try {
|
|
265
|
+
const response = yield axiosAPI_default.request({
|
|
266
|
+
method: "put",
|
|
267
|
+
url: `custom-entity/${schemaName}/${id}`,
|
|
268
|
+
headers: {
|
|
269
|
+
"Content-Type": "application/json"
|
|
270
|
+
},
|
|
271
|
+
data: JSON.stringify(newData)
|
|
272
|
+
});
|
|
273
|
+
return response.data;
|
|
274
|
+
} catch (e) {
|
|
275
|
+
throw new KonversiError(e);
|
|
276
|
+
}
|
|
251
277
|
});
|
|
252
278
|
}
|
|
253
279
|
function createCustomObject(schemaName, data) {
|
|
254
280
|
return __async(this, null, function* () {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
281
|
+
try {
|
|
282
|
+
const response = yield axiosAPI_default.request({
|
|
283
|
+
method: "post",
|
|
284
|
+
url: `custom-entity/${schemaName}`,
|
|
285
|
+
data
|
|
286
|
+
});
|
|
287
|
+
return response.data;
|
|
288
|
+
} catch (e) {
|
|
289
|
+
throw new KonversiError(e);
|
|
290
|
+
}
|
|
261
291
|
});
|
|
262
292
|
}
|
|
263
293
|
function deleteCustomObject(schemaName, id) {
|
|
264
294
|
return __async(this, null, function* () {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
295
|
+
try {
|
|
296
|
+
const response = yield axiosAPI_default.request({
|
|
297
|
+
method: "delete",
|
|
298
|
+
maxBodyLength: Infinity,
|
|
299
|
+
url: `custom-entity/${schemaName}/${id}`
|
|
300
|
+
});
|
|
301
|
+
return response.data;
|
|
302
|
+
} catch (e) {
|
|
303
|
+
throw new KonversiError(e);
|
|
304
|
+
}
|
|
271
305
|
});
|
|
272
306
|
}
|
|
273
307
|
function getAllObjects(_0) {
|
|
274
308
|
return __async(this, arguments, function* (entity, queryParams = {}) {
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
309
|
+
try {
|
|
310
|
+
const response = yield axiosAPI_default.get(`${entity}`, {
|
|
311
|
+
params: queryParams
|
|
312
|
+
});
|
|
313
|
+
return response.data;
|
|
314
|
+
} catch (e) {
|
|
315
|
+
throw new KonversiError(e);
|
|
316
|
+
}
|
|
279
317
|
});
|
|
280
318
|
}
|
|
281
319
|
function getObjectById(entity, id) {
|
|
282
320
|
return __async(this, null, function* () {
|
|
283
|
-
|
|
284
|
-
|
|
321
|
+
try {
|
|
322
|
+
const response = yield axiosAPI_default.get(`${entity}/${id}`);
|
|
323
|
+
return response.data;
|
|
324
|
+
} catch (e) {
|
|
325
|
+
throw new KonversiError(e);
|
|
326
|
+
}
|
|
285
327
|
});
|
|
286
328
|
}
|
|
287
329
|
function updateObject(entity, id, newData) {
|
|
288
330
|
return __async(this, null, function* () {
|
|
289
|
-
|
|
290
|
-
|
|
331
|
+
try {
|
|
332
|
+
const response = yield axiosAPI_default.put(`${entity}/${id}`, newData);
|
|
333
|
+
return response.data;
|
|
334
|
+
} catch (e) {
|
|
335
|
+
throw new KonversiError(e);
|
|
336
|
+
}
|
|
291
337
|
});
|
|
292
338
|
}
|
|
293
339
|
function createObject(entity, data) {
|
|
294
340
|
return __async(this, null, function* () {
|
|
295
|
-
|
|
296
|
-
|
|
341
|
+
try {
|
|
342
|
+
const response = yield axiosAPI_default.post(`${entity}`, data);
|
|
343
|
+
return response.data;
|
|
344
|
+
} catch (e) {
|
|
345
|
+
throw new KonversiError(e);
|
|
346
|
+
}
|
|
297
347
|
});
|
|
298
348
|
}
|
|
299
349
|
function deleteObject(entity, id) {
|
|
300
350
|
return __async(this, null, function* () {
|
|
301
|
-
|
|
302
|
-
|
|
351
|
+
try {
|
|
352
|
+
const response = yield axiosAPI_default.delete(`${entity}/${id}`);
|
|
353
|
+
return response.data;
|
|
354
|
+
} catch (e) {
|
|
355
|
+
throw new KonversiError(e);
|
|
356
|
+
}
|
|
303
357
|
});
|
|
304
358
|
}
|
|
305
359
|
function runScript(scriptNameOrId, input, sync = false) {
|
|
306
360
|
return __async(this, null, function* () {
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
361
|
+
try {
|
|
362
|
+
if (sync) {
|
|
363
|
+
const response2 = yield axiosAPI_default.post(`/automation/script/${scriptNameOrId}/run?mode=sync`, { input });
|
|
364
|
+
return response2.data;
|
|
365
|
+
}
|
|
366
|
+
const response = yield axiosAPI_default.post(`/automation/script/${scriptNameOrId}/run`, { input });
|
|
367
|
+
return response.data;
|
|
368
|
+
} catch (e) {
|
|
369
|
+
throw new KonversiError(e);
|
|
310
370
|
}
|
|
311
|
-
const response = yield axiosAPI_default.post(`/automation/script/${scriptNameOrId}/run`, { input });
|
|
312
|
-
return response.data;
|
|
313
371
|
});
|
|
314
372
|
}
|
|
315
373
|
var _a;
|
package/index.ts
CHANGED
|
@@ -2,29 +2,39 @@ import { Axios, AxiosRequestConfig } from "axios";
|
|
|
2
2
|
import axiosAPI, { setAuthToken, setBaseUrl, setCompanyId } from "./axiosAPI";
|
|
3
3
|
|
|
4
4
|
import * as crudEndpoints from "./crudEndpoints";
|
|
5
|
+
import KonversiError from "./KonversiError";
|
|
5
6
|
|
|
6
7
|
async function call(axiosRequest: AxiosRequestConfig) {
|
|
7
8
|
return await axiosAPI.request(axiosRequest);
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
async function getAllCustomObjects(schemaName: string, queryParams: any = {}) {
|
|
12
|
+
try {
|
|
11
13
|
const response = await axiosAPI.request({
|
|
12
14
|
method: 'get',
|
|
13
15
|
url: `custom-entity/${schemaName}`,
|
|
14
16
|
params: queryParams
|
|
15
17
|
})
|
|
16
18
|
return response.data;
|
|
19
|
+
} catch (e: any) {
|
|
20
|
+
throw new KonversiError(e);
|
|
21
|
+
}
|
|
17
22
|
}
|
|
18
23
|
|
|
19
24
|
async function getCustomObjectById(schemaName: string, id: string) {
|
|
25
|
+
try {
|
|
20
26
|
const response = await axiosAPI.request({
|
|
21
27
|
method: 'get',
|
|
22
28
|
url: `custom-entity/${schemaName}/${id}`,
|
|
23
29
|
})
|
|
24
30
|
return response.data;
|
|
31
|
+
} catch (e: any) {
|
|
32
|
+
throw new KonversiError(e);
|
|
33
|
+
}
|
|
25
34
|
}
|
|
26
35
|
|
|
27
36
|
async function updateCustomObject(schemaName: string, id: string, newData: any) {
|
|
37
|
+
try {
|
|
28
38
|
const response = await axiosAPI.request({
|
|
29
39
|
method: 'put',
|
|
30
40
|
url: `custom-entity/${schemaName}/${id}`,
|
|
@@ -34,9 +44,13 @@ async function updateCustomObject(schemaName: string, id: string, newData: any)
|
|
|
34
44
|
data: JSON.stringify(newData)
|
|
35
45
|
})
|
|
36
46
|
return response.data;
|
|
47
|
+
} catch (e: any) {
|
|
48
|
+
throw new KonversiError(e);
|
|
49
|
+
}
|
|
37
50
|
}
|
|
38
51
|
|
|
39
52
|
async function createCustomObject(schemaName: string, data: any) {
|
|
53
|
+
try {
|
|
40
54
|
const response = await axiosAPI.request({
|
|
41
55
|
method: 'post',
|
|
42
56
|
url: `custom-entity/${schemaName}`,
|
|
@@ -44,50 +58,78 @@ async function createCustomObject(schemaName: string, data: any) {
|
|
|
44
58
|
});
|
|
45
59
|
|
|
46
60
|
return response.data;
|
|
61
|
+
} catch (e: any) {
|
|
62
|
+
throw new KonversiError(e);
|
|
63
|
+
}
|
|
47
64
|
}
|
|
48
65
|
|
|
49
66
|
async function deleteCustomObject(schemaName: string, id: string) {
|
|
67
|
+
try {
|
|
50
68
|
const response = await axiosAPI.request({
|
|
51
69
|
method: 'delete',
|
|
52
70
|
maxBodyLength: Infinity,
|
|
53
71
|
url: `custom-entity/${schemaName}/${id}`,
|
|
54
72
|
})
|
|
55
73
|
return response.data;
|
|
74
|
+
} catch (e: any) {
|
|
75
|
+
throw new KonversiError(e);
|
|
76
|
+
}
|
|
56
77
|
}
|
|
57
78
|
|
|
58
79
|
|
|
59
80
|
// CRUD Base Objects
|
|
60
81
|
async function getAllObjects(entity: any, queryParams: any = {}) {
|
|
82
|
+
try {
|
|
61
83
|
const response = await axiosAPI.get(`${entity}`, {
|
|
62
84
|
params: queryParams
|
|
63
85
|
})
|
|
64
86
|
return response.data;
|
|
87
|
+
} catch (e: any) {
|
|
88
|
+
throw new KonversiError(e);
|
|
89
|
+
}
|
|
65
90
|
}
|
|
66
91
|
|
|
67
92
|
async function getObjectById(entity: any, id: string) {
|
|
93
|
+
try {
|
|
68
94
|
const response = await axiosAPI.get(`${entity}/${id}`)
|
|
69
95
|
return response.data;
|
|
96
|
+
} catch (e: any) {
|
|
97
|
+
throw new KonversiError(e);
|
|
98
|
+
}
|
|
70
99
|
}
|
|
71
100
|
|
|
72
101
|
async function updateObject(entity: any, id: string, newData: any) {
|
|
102
|
+
try {
|
|
73
103
|
const response = await axiosAPI.put(`${entity}/${id}`, newData)
|
|
74
104
|
return response.data;
|
|
105
|
+
} catch (e: any) {
|
|
106
|
+
throw new KonversiError(e);
|
|
107
|
+
}
|
|
75
108
|
}
|
|
76
109
|
|
|
77
110
|
async function createObject(entity: any, data: any) {
|
|
111
|
+
try {
|
|
78
112
|
const response = await axiosAPI.post(`${entity}`, data)
|
|
79
113
|
|
|
80
114
|
return response.data;
|
|
115
|
+
} catch (e: any) {
|
|
116
|
+
throw new KonversiError(e);
|
|
117
|
+
}
|
|
81
118
|
}
|
|
82
119
|
|
|
83
120
|
async function deleteObject(entity: any, id: string) {
|
|
121
|
+
try {
|
|
84
122
|
const response = await axiosAPI.delete(`${entity}/${id}`)
|
|
85
123
|
|
|
86
124
|
return response.data;
|
|
125
|
+
} catch (e: any) {
|
|
126
|
+
throw new KonversiError(e);
|
|
127
|
+
}
|
|
87
128
|
}
|
|
88
129
|
|
|
89
130
|
|
|
90
131
|
export async function runScript(scriptNameOrId: string, input: any, sync= false) {
|
|
132
|
+
try {
|
|
91
133
|
if (sync) {
|
|
92
134
|
const response = await axiosAPI.post(`/automation/script/${scriptNameOrId}/run?mode=sync`, {input})
|
|
93
135
|
return response.data;
|
|
@@ -95,6 +137,9 @@ export async function runScript(scriptNameOrId: string, input: any, sync= false)
|
|
|
95
137
|
const response = await axiosAPI.post(`/automation/script/${scriptNameOrId}/run`, {input})
|
|
96
138
|
|
|
97
139
|
return response.data;
|
|
140
|
+
} catch (e: any) {
|
|
141
|
+
throw new KonversiError(e);
|
|
142
|
+
}
|
|
98
143
|
}
|
|
99
144
|
|
|
100
145
|
const konversiAPI = {
|
package/package.json
CHANGED