@konversi/konversi-client 1.4.9 → 1.4.10
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/dist/index.js +7 -2
- package/dist/index.mjs +7 -2
- package/index.ts +6 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -406,7 +406,7 @@ function deleteObject(entity, id) {
|
|
|
406
406
|
}
|
|
407
407
|
function runScript(scriptNameOrId, input, sync = false) {
|
|
408
408
|
return __async(this, null, function* () {
|
|
409
|
-
var _a2, _b;
|
|
409
|
+
var _a2, _b, _c, _d, _e;
|
|
410
410
|
try {
|
|
411
411
|
if (sync) {
|
|
412
412
|
const response2 = yield axiosAPI_default.post(`/automation/script/${scriptNameOrId}/run?mode=sync`, { input });
|
|
@@ -415,7 +415,12 @@ function runScript(scriptNameOrId, input, sync = false) {
|
|
|
415
415
|
const response = yield axiosAPI_default.post(`/automation/script/${scriptNameOrId}/run`, { input });
|
|
416
416
|
return response.data;
|
|
417
417
|
} catch (e) {
|
|
418
|
-
|
|
418
|
+
let errorMessage = e.message;
|
|
419
|
+
errorMessage = ((_b = (_a2 = e == null ? void 0 : e.response) == null ? void 0 : _a2.data) == null ? void 0 : _b.message) || errorMessage;
|
|
420
|
+
if (((_c = e.response) == null ? void 0 : _c.status) === 422) {
|
|
421
|
+
errorMessage = (_e = (_d = e.response) == null ? void 0 : _d.data) == null ? void 0 : _e.errorMessage;
|
|
422
|
+
}
|
|
423
|
+
throw new KonversiError(errorMessage, e);
|
|
419
424
|
}
|
|
420
425
|
});
|
|
421
426
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -374,7 +374,7 @@ function deleteObject(entity, id) {
|
|
|
374
374
|
}
|
|
375
375
|
function runScript(scriptNameOrId, input, sync = false) {
|
|
376
376
|
return __async(this, null, function* () {
|
|
377
|
-
var _a2, _b;
|
|
377
|
+
var _a2, _b, _c, _d, _e;
|
|
378
378
|
try {
|
|
379
379
|
if (sync) {
|
|
380
380
|
const response2 = yield axiosAPI_default.post(`/automation/script/${scriptNameOrId}/run?mode=sync`, { input });
|
|
@@ -383,7 +383,12 @@ function runScript(scriptNameOrId, input, sync = false) {
|
|
|
383
383
|
const response = yield axiosAPI_default.post(`/automation/script/${scriptNameOrId}/run`, { input });
|
|
384
384
|
return response.data;
|
|
385
385
|
} catch (e) {
|
|
386
|
-
|
|
386
|
+
let errorMessage = e.message;
|
|
387
|
+
errorMessage = ((_b = (_a2 = e == null ? void 0 : e.response) == null ? void 0 : _a2.data) == null ? void 0 : _b.message) || errorMessage;
|
|
388
|
+
if (((_c = e.response) == null ? void 0 : _c.status) === 422) {
|
|
389
|
+
errorMessage = (_e = (_d = e.response) == null ? void 0 : _d.data) == null ? void 0 : _e.errorMessage;
|
|
390
|
+
}
|
|
391
|
+
throw new KonversiError(errorMessage, e);
|
|
387
392
|
}
|
|
388
393
|
});
|
|
389
394
|
}
|
package/index.ts
CHANGED
|
@@ -138,7 +138,12 @@ export async function runScript(scriptNameOrId: string, input: any, sync= false)
|
|
|
138
138
|
|
|
139
139
|
return response.data;
|
|
140
140
|
} catch (e: any) {
|
|
141
|
-
|
|
141
|
+
let errorMessage = e.message;
|
|
142
|
+
errorMessage = e?.response?.data?.message || errorMessage;
|
|
143
|
+
if (e.response?.status === 422) {
|
|
144
|
+
errorMessage = e.response?.data?.errorMessage;
|
|
145
|
+
}
|
|
146
|
+
throw new KonversiError(errorMessage, e);
|
|
142
147
|
}
|
|
143
148
|
}
|
|
144
149
|
|