@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/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
- return new OmniApiError(apiError.message ?? `API error (status ${status ?? "unknown"})`, apiError.code ?? "API_ERROR", apiError.details, status);
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)