@automagik/omni 2.260911.7 → 2.260914.1
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/commands/events.d.ts +2 -0
- package/dist/commands/events.d.ts.map +1 -1
- package/dist/commands/instances.d.ts +1 -0
- package/dist/commands/instances.d.ts.map +1 -1
- package/dist/index.js +65 -20
- package/dist/sdk/client.d.ts +4 -0
- package/dist/sdk/client.d.ts.map +1 -1
- package/dist/sdk/errors.d.ts.map +1 -1
- package/dist/sdk/index.js +11 -1
- package/dist/server/index.js +1287 -1781
- package/package.json +1 -1
package/dist/sdk/index.js
CHANGED
|
@@ -435,7 +435,8 @@ function parseErrorObject(error, status) {
|
|
|
435
435
|
}
|
|
436
436
|
if (rawError && typeof rawError === "object") {
|
|
437
437
|
const apiError = rawError;
|
|
438
|
-
|
|
438
|
+
const issuesMessage = Array.isArray(apiError.issues) ? apiError.issues.map((i) => `${(i.path ?? []).join(".")}: ${i.message}`).join("; ") : undefined;
|
|
439
|
+
return new OmniApiError(apiError.message ?? issuesMessage ?? `API error (status ${status ?? "unknown"})`, apiError.code ?? "API_ERROR", apiError.details, status);
|
|
439
440
|
}
|
|
440
441
|
}
|
|
441
442
|
if ("message" in error) {
|
|
@@ -721,6 +722,15 @@ function createOmniClient(config) {
|
|
|
721
722
|
throw new OmniApiError("Sync job not found", "NOT_FOUND", undefined, 404);
|
|
722
723
|
return json.data;
|
|
723
724
|
},
|
|
725
|
+
async cancelSync(id, jobId) {
|
|
726
|
+
const resp = await apiFetch(`${baseUrl}/api/v2/instances/${id}/sync/${jobId}/cancel`, { method: "POST" });
|
|
727
|
+
const json = await resp.json();
|
|
728
|
+
if (!resp.ok)
|
|
729
|
+
throw OmniApiError.from(json, resp.status);
|
|
730
|
+
if (!json?.data)
|
|
731
|
+
throw new OmniApiError("Sync job not found", "NOT_FOUND", undefined, 404);
|
|
732
|
+
return json.data;
|
|
733
|
+
},
|
|
724
734
|
async listContacts(id, params) {
|
|
725
735
|
const query = new URLSearchParams;
|
|
726
736
|
if (params?.limit)
|