@voltro/api-client 0.89.2 → 0.91.0

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/client.js CHANGED
@@ -1,24 +1,24 @@
1
- import { splitTag as e } from "./manifest.js";
2
- import { makeRestCore as t } from "./rest.js";
3
- import { openLiveQueries as n } from "./live.js";
4
- import { apiRoleEndpointUrl as r, captureApiRoleEndpoints as i, selectApiRoleEndpoint as a } from "./apiRoleEndpoints.js";
1
+ import { apiRoleEndpointUrl as e, captureApiRoleEndpoints as t, selectApiRoleEndpoint as n } from "./apiRoleEndpoints.js";
2
+ import { openLiveQueries as r } from "./live.js";
3
+ import { splitTag as i } from "./manifest.js";
4
+ import { makeRestCore as a } from "./rest.js";
5
5
  // src/client.ts
6
- var o = (t) => {
7
- let n = {};
8
- for (let r of t.manifest.projections) {
9
- let i = Object.assign((e, n) => t.call(r.tag, e, n), {
10
- pages: (e, n) => t.pages(r.tag, e, n),
11
- subscribe: (e) => t.subscribe(r.tag, e),
12
- tag: r.tag
13
- }), { namespace: a, method: o } = e(r.tag);
6
+ var o = (e) => {
7
+ let t = {};
8
+ for (let n of e.manifest.projections) {
9
+ let r = Object.assign((t, r) => e.call(n.tag, t, r), {
10
+ pages: (t, r) => e.pages(n.tag, t, r),
11
+ subscribe: (t) => e.subscribe(n.tag, t),
12
+ tag: n.tag
13
+ }), { namespace: a, method: o } = i(n.tag);
14
14
  if (a === void 0) {
15
- n[o] = i;
15
+ t[o] = r;
16
16
  continue;
17
17
  }
18
- let s = n[a] ?? {};
19
- s[o] = i, n[a] = s;
18
+ let s = t[a] ?? {};
19
+ s[o] = r, t[a] = s;
20
20
  }
21
- return n;
21
+ return t;
22
22
  }, s = (e, t, n, r) => ({ async *[Symbol.asyncIterator]() {
23
23
  let i;
24
24
  for (;;) {
@@ -29,23 +29,23 @@ var o = (t) => {
29
29
  if (yield a.value, a.nextCursor === void 0) return;
30
30
  i = a.nextCursor;
31
31
  }
32
- } }), c = (e, o = {}) => {
33
- let c = t(e.manifest, e.errors, o), l = e.manifest.profile.cursorParam, u = o.roleEndpoints === void 0 ? void 0 : i(o.roleEndpoints);
32
+ } }), c = (i, o = {}) => {
33
+ let c = a(i.manifest, i.errors, o), l = i.manifest.profile.cursorParam, u = o.roleEndpoints === void 0 ? void 0 : t(o.roleEndpoints);
34
34
  if (u && o.subscriptions?.wsUrl !== void 0) throw Error("Role endpoints and a fixed subscription URL are mutually exclusive");
35
35
  let d = /* @__PURE__ */ new Map(), f = !1, p = (t) => {
36
36
  if (f) throw Error("API client is closed");
37
- let i = u && a(u, t, "subscriptions"), s = i?.role ?? "default", l = d.get(s);
38
- return l || (l = n(e.manifest, e.errors, c.baseUrl, {
37
+ let a = u && n(u, t, "subscriptions"), s = a?.role ?? "default", l = d.get(s);
38
+ return l || (l = r(i.manifest, i.errors, c.baseUrl, {
39
39
  token: o.token,
40
40
  tenant: o.tenant,
41
41
  headers: o.headers,
42
42
  ...o.subscriptions ?? {},
43
- ...i ? { wsUrl: r(c.baseUrl, i, "websocket") } : {}
43
+ ...a ? { wsUrl: e(c.baseUrl, a, "websocket") } : {}
44
44
  }), d.set(s, l)), l;
45
45
  };
46
46
  return {
47
- manifest: e.manifest,
48
- errors: e.errors,
47
+ manifest: i.manifest,
48
+ errors: i.errors,
49
49
  call: async (e, t = {}, n) => (await c.call(e, t, n)).value,
50
50
  callRaw: (e, t = {}, n) => c.call(e, t, n),
51
51
  pages: (e, t = {}, n) => s((t, n) => c.call(e, t, n), l, t, n),
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { projectionOf as e, splitTag as t } from "./manifest.js";
2
2
  import { decodeWire as n, encodeWire as r, hasRequiredField as i, rpcCodec as a, toSnakeCase as o } from "./wire.js";
3
- import { ApiClientError as s, ApiHttpError as c, DeclaredError as l, InputEncodeError as u, ProfileMismatchError as d, RateLimitedError as f, TransportError as p, defineError as m } from "./errors.js";
4
- import { cursorFromLink as h, declaredErrorOf as g, makeRestCore as _, uuidV7 as v } from "./rest.js";
5
- import { applyRowPatch as y, pathToId as b } from "./rowPatch.js";
6
- import { openLiveQueries as x, wsUrlFromBase as S } from "./live.js";
7
- import { apiRoleEndpointUrl as C, apiRoleProxyBasePath as w, captureApiRoleEndpoints as T, selectApiRoleEndpoint as E } from "./apiRoleEndpoints.js";
8
- import { buildNamespaces as D, createClient as O, createPromiseClient as k, pagesOf as A } from "./client.js";
9
- import { createMockClient as j } from "./mock.js";
10
- export { s as ApiClientError, c as ApiHttpError, l as DeclaredError, u as InputEncodeError, d as ProfileMismatchError, f as RateLimitedError, p as TransportError, C as apiRoleEndpointUrl, w as apiRoleProxyBasePath, y as applyRowPatch, D as buildNamespaces, T as captureApiRoleEndpoints, O as createClient, j as createMockClient, k as createPromiseClient, h as cursorFromLink, g as declaredErrorOf, n as decodeWire, m as defineError, r as encodeWire, i as hasRequiredField, _ as makeRestCore, x as openLiveQueries, A as pagesOf, b as pathToId, e as projectionOf, a as rpcCodec, E as selectApiRoleEndpoint, t as splitTag, o as toSnakeCase, v as uuidV7, S as wsUrlFromBase };
3
+ import { openLiveQueries as s, wsUrlFromBase as c } from "./live.js";
4
+ import { applyRowPatch as l, pathToId as u } from "./rowPatch.js";
5
+ import { cursorFromLink as d, declaredErrorOf as f, makeRestCore as p, uuidV7 as m } from "./rest.js";
6
+ import { ApiClientError as h, ApiHttpError as g, DeclaredError as _, InputEncodeError as v, ProfileMismatchError as y, RateLimitedError as b, TransportError as x, defineError as S } from "./errors.js";
7
+ import { buildNamespaces as C, createClient as w, createPromiseClient as T, pagesOf as E } from "./client.js";
8
+ import { createMockClient as D } from "./mock.js";
9
+ import { apiRoleEndpointUrl as O, apiRoleProxyBasePath as k, captureApiRoleEndpoints as A, selectApiRoleEndpoint as j } from "./apiRoleEndpoints.js";
10
+ export { h as ApiClientError, g as ApiHttpError, _ as DeclaredError, v as InputEncodeError, y as ProfileMismatchError, b as RateLimitedError, x as TransportError, O as apiRoleEndpointUrl, k as apiRoleProxyBasePath, l as applyRowPatch, C as buildNamespaces, A as captureApiRoleEndpoints, w as createClient, D as createMockClient, T as createPromiseClient, d as cursorFromLink, f as declaredErrorOf, n as decodeWire, S as defineError, r as encodeWire, i as hasRequiredField, p as makeRestCore, s as openLiveQueries, E as pagesOf, u as pathToId, e as projectionOf, a as rpcCodec, j as selectApiRoleEndpoint, t as splitTag, o as toSnakeCase, m as uuidV7, c as wsUrlFromBase };
package/dist/live.js CHANGED
@@ -1,8 +1,8 @@
1
- import { projectionOf as e } from "./manifest.js";
2
- import { decodeWire as t, encodeWire as n, rpcCodec as r } from "./wire.js";
3
- import { TransportError as i } from "./errors.js";
4
- import { declaredErrorOf as a } from "./rest.js";
5
- import { createRowPatchApplier as o } from "./rowPatch.js";
1
+ import { TransportError as e } from "./errors.js";
2
+ import { projectionOf as t } from "./manifest.js";
3
+ import { declaredErrorOf as n } from "./rest.js";
4
+ import { createRowPatchApplier as r } from "./rowPatch.js";
5
+ import { decodeWire as i, encodeWire as a, rpcCodec as o } from "./wire.js";
6
6
  // src/live.ts
7
7
  var s = (e) => {
8
8
  let t = new URL(e);
@@ -17,27 +17,27 @@ var s = (e) => {
17
17
  defect: t.defect
18
18
  };
19
19
  }, l = (l, u, d, f = {}) => {
20
- let p = f.wsUrl ?? s(d), m = f.webSocketConstructor ?? ((e) => new globalThis.WebSocket(e)), h = f.pingIntervalMs ?? 1e4, g = f.reconnect?.initialMs ?? 500, _ = f.reconnect?.maxMs ?? 5e3, v = r(l.wire.models), y = /* @__PURE__ */ new Set(), b = /* @__PURE__ */ new Map(), x, S = !1, C = !1, w = !1, T = 0, E = 1, D, O, k = !0, A = (e) => {
20
+ let p = f.wsUrl ?? s(d), m = f.webSocketConstructor ?? ((e) => new globalThis.WebSocket(e)), h = f.pingIntervalMs ?? 1e4, g = f.reconnect?.initialMs ?? 500, _ = f.reconnect?.maxMs ?? 5e3, v = o(l.wire.models), y = /* @__PURE__ */ new Set(), b = /* @__PURE__ */ new Map(), x, S = !1, C = !1, w = !1, T = 0, E = 1, D, O, k = !0, A = (e) => {
21
21
  x !== void 0 && C && x.send(JSON.stringify(e));
22
22
  }, j = async () => {
23
23
  let e = typeof f.token == "function" ? await f.token() : f.token, t = Object.entries(f.headers ?? {});
24
24
  return e !== void 0 && t.push(["authorization", `Bearer ${e}`]), f.tenant !== void 0 && t.push(["x-tenant", f.tenant]), t;
25
- }, M = (e, t) => {
26
- if (typeof t == "object" && t && "_tag" in t && typeof t._tag == "string") {
27
- let { _tag: n, ...r } = t;
28
- if (u[n] !== void 0) return a(l, u, e.tag, n, r, {
25
+ }, M = (t, r) => {
26
+ if (typeof r == "object" && r && "_tag" in r && typeof r._tag == "string") {
27
+ let { _tag: e, ...i } = r;
28
+ if (u[e] !== void 0) return n(l, u, t.tag, e, i, {
29
29
  status: 0,
30
30
  requestId: void 0,
31
- detail: typeof r.message == "string" ? r.message : void 0,
32
- body: t
31
+ detail: typeof i.message == "string" ? i.message : void 0,
32
+ body: r
33
33
  });
34
34
  }
35
- let n = typeof t == "object" && t && typeof t.message == "string" ? t.message : String(t);
36
- return new i({
37
- tag: e.tag,
35
+ let i = typeof r == "object" && r && typeof r.message == "string" ? r.message : String(r);
36
+ return new e({
37
+ tag: t.tag,
38
38
  reason: "network",
39
- message: n,
40
- cause: t
39
+ message: i,
40
+ cause: r
41
41
  });
42
42
  }, N = (e, t) => {
43
43
  if (e.waiting !== void 0) {
@@ -45,9 +45,9 @@ var s = (e) => {
45
45
  e.waiting = void 0, n(t);
46
46
  } else t.done || e.queue.push(t.value);
47
47
  }, P = (e) => {
48
- let n = l.wire.procedures[e.tag]?.output;
48
+ let t = l.wire.procedures[e.tag]?.output;
49
49
  N(e, {
50
- value: t(n, e.rawBase, v),
50
+ value: i(t, e.rawBase, v),
51
51
  done: !1
52
52
  });
53
53
  }, F = (e, t) => {
@@ -63,38 +63,38 @@ var s = (e) => {
63
63
  }, L = (e, t) => {
64
64
  if (typeof t != "object" || !t) return;
65
65
  let n = t;
66
- n._tag === "snapshot" ? (e.patchApplier?.reset(), e.rawBase = n.data, typeof n.revision == "number" && (e.revision = n.revision), P(e)) : n._tag === "delta" ? (Array.isArray(e.rawBase) && (e.patchApplier ??= o(), e.rawBase = e.patchApplier.apply(e.rawBase, n.patch)), typeof n.revision == "number" && (e.revision = n.revision), e.rawBase !== void 0 && P(e)) : n._tag === "error" && F(e, M(e, n.error));
67
- }, R = (e, t) => {
68
- if (t._tag === "Success") {
69
- I(e);
66
+ n._tag === "snapshot" ? (e.patchApplier?.reset(), e.rawBase = n.data, typeof n.revision == "number" && (e.revision = n.revision), P(e)) : n._tag === "delta" ? (Array.isArray(e.rawBase) && (e.patchApplier ??= r(), e.rawBase = e.patchApplier.apply(e.rawBase, n.patch)), typeof n.revision == "number" && (e.revision = n.revision), e.rawBase !== void 0 && P(e)) : n._tag === "error" && F(e, M(e, n.error));
67
+ }, R = (t, n) => {
68
+ if (n._tag === "Success") {
69
+ I(t);
70
70
  return;
71
71
  }
72
- let n = c(t.cause);
73
- n === void 0 ? I(e) : F(e, n.kind === "fail" ? M(e, n.error) : new i({
74
- tag: e.tag,
72
+ let r = c(n.cause);
73
+ r === void 0 ? I(t) : F(t, r.kind === "fail" ? M(t, r.error) : new e({
74
+ tag: t.tag,
75
75
  reason: "network",
76
- message: `the subscription died on the server: ${String(n.defect?.message ?? n.defect)}`,
77
- cause: n.defect
76
+ message: `the subscription died on the server: ${String(r.defect?.message ?? r.defect)}`,
77
+ cause: r.defect
78
78
  }));
79
79
  }, z = async (e) => {
80
80
  let t = await j();
81
81
  e.revision >= 0 && t.push(["voltro-resume-from", String(e.revision)]);
82
- let r = String(E++);
83
- e.requestId = r, b.set(r, e);
84
- let i = l.wire.procedures[e.tag]?.input;
82
+ let n = String(E++);
83
+ e.requestId = n, b.set(n, e);
84
+ let r = l.wire.procedures[e.tag]?.input;
85
85
  A({
86
86
  _tag: "Request",
87
- id: r,
87
+ id: n,
88
88
  tag: e.tag,
89
- payload: n(i, e.input ?? {}, v) ?? {},
89
+ payload: a(r, e.input ?? {}, v) ?? {},
90
90
  headers: t
91
91
  });
92
- }, B = (e, t) => {
93
- for (let n of [...y]) F(n, new i({
94
- tag: n.tag,
92
+ }, B = (t, n) => {
93
+ for (let r of [...y]) F(r, new e({
94
+ tag: r.tag,
95
95
  reason: "network",
96
- message: e,
97
- cause: t
96
+ message: t,
97
+ cause: n
98
98
  }));
99
99
  }, V = (e) => {
100
100
  let t;
@@ -166,10 +166,10 @@ var s = (e) => {
166
166
  });
167
167
  };
168
168
  return {
169
- subscribe: (t, n = {}) => ({ [Symbol.asyncIterator]: () => {
170
- e(l, t);
169
+ subscribe: (e, n = {}) => ({ [Symbol.asyncIterator]: () => {
170
+ t(l, e);
171
171
  let r = {
172
- tag: t,
172
+ tag: e,
173
173
  input: n,
174
174
  requestId: void 0,
175
175
  rawBase: void 0,
package/dist/rest.js CHANGED
@@ -1,6 +1,6 @@
1
- import { projectionOf as e } from "./manifest.js";
2
- import { decodeWire as t, encodeWire as n } from "./wire.js";
3
- import { ApiHttpError as r, InputEncodeError as i, ProfileMismatchError as a, RateLimitedError as o, TransportError as s } from "./errors.js";
1
+ import { ApiHttpError as e, InputEncodeError as t, ProfileMismatchError as n, RateLimitedError as r, TransportError as i } from "./errors.js";
2
+ import { projectionOf as a } from "./manifest.js";
3
+ import { decodeWire as o, encodeWire as s } from "./wire.js";
4
4
  // src/rest.ts
5
5
  var c = (e = Date.now()) => {
6
6
  let t = /* @__PURE__ */ new Uint8Array(16);
@@ -52,50 +52,50 @@ var c = (e = Date.now()) => {
52
52
  console.warn(`[@voltro/api-client] ${e.tag} (${e.path}) is deprecated${t}${e.deprecated === void 0 ? "" : `: ${e.deprecated}`}`);
53
53
  }, h = (e) => new Promise((t) => {
54
54
  setTimeout(t, e);
55
- }), g = (e, n, i, a, o, s) => {
56
- if (a !== void 0) {
57
- let r = n[a], c = e.wire.procedures[i]?.errors?.[a];
58
- if (r !== void 0) {
59
- let n = t(c, o, {
60
- dates: e.profile.dates,
61
- naming: e.profile.naming,
62
- models: e.wire.models
55
+ }), g = (t, n, r, i, a, s) => {
56
+ if (i !== void 0) {
57
+ let e = n[i], c = t.wire.procedures[r]?.errors?.[i];
58
+ if (e !== void 0) {
59
+ let n = o(c, a, {
60
+ dates: t.profile.dates,
61
+ naming: t.profile.naming,
62
+ models: t.wire.models
63
63
  });
64
- return new r(typeof n == "object" && n ? n : {}, {
64
+ return new e(typeof n == "object" && n ? n : {}, {
65
65
  status: s.status,
66
66
  requestId: s.requestId,
67
67
  detail: s.detail
68
68
  });
69
69
  }
70
70
  }
71
- return new r({
72
- tag: i,
71
+ return new e({
72
+ tag: r,
73
73
  status: s.status,
74
- errorTag: a,
74
+ errorTag: i,
75
75
  detail: s.detail,
76
76
  body: s.body,
77
77
  requestId: s.requestId
78
78
  });
79
- }, _ = (r, _, v = {}) => {
80
- let y = r.profile, b = (v.baseUrl ?? r.servers[0]?.url ?? "").replace(/\/+$/, "");
79
+ }, _ = (e, _, v = {}) => {
80
+ let y = e.profile, b = (v.baseUrl ?? e.servers[0]?.url ?? "").replace(/\/+$/, "");
81
81
  if (b === "") throw Error("@voltro/api-client: no baseUrl — pass one, or generate the client with `--base-url` or `servers`");
82
- let x = v.fetch ?? globalThis.fetch, S = v.clock ?? (() => Date.now()), C = v.sleep ?? h, w = v.etagCache ?? y.etag, T = /* @__PURE__ */ new Map(), E = /* @__PURE__ */ new Set(), D = v.onSunset ?? m, O = !1, k = v.userAgent ?? (r.name === void 0 ? void 0 : `${r.name}/${r.version ?? "0.0.0"} (${r.generatedBy})`), A = {
82
+ let x = v.fetch ?? globalThis.fetch, S = v.clock ?? (() => Date.now()), C = v.sleep ?? h, w = v.etagCache ?? y.etag, T = /* @__PURE__ */ new Map(), E = /* @__PURE__ */ new Set(), D = v.onSunset ?? m, O = !1, k = v.userAgent ?? (e.name === void 0 ? void 0 : `${e.name}/${e.version ?? "0.0.0"} (${e.generatedBy})`), A = {
83
83
  dates: y.dates,
84
84
  naming: y.naming,
85
- models: r.wire.models
86
- }, j = async () => typeof v.token == "function" ? await v.token() : v.token, M = (e, t) => {
87
- let a = r.wire.procedures[e.tag]?.input;
85
+ models: e.wire.models
86
+ }, j = async () => typeof v.token == "function" ? await v.token() : v.token, M = (n, r) => {
87
+ let i = e.wire.procedures[n.tag]?.input;
88
88
  try {
89
- let e = n(a, t ?? {}, A);
89
+ let e = s(i, r ?? {}, A);
90
90
  return typeof e == "object" && e ? e : {};
91
- } catch (t) {
92
- throw new i({
93
- tag: e.tag,
94
- message: String(t instanceof Error ? t.message.split("\n")[0] : t)
91
+ } catch (e) {
92
+ throw new t({
93
+ tag: n.tag,
94
+ message: String(e instanceof Error ? e.message.split("\n")[0] : e)
95
95
  });
96
96
  }
97
- }, N = (e, t, n, i) => {
98
- let a = typeof n == "object" && n ? n : {}, o, s, c;
97
+ }, N = (t, n, r, i) => {
98
+ let a = typeof r == "object" && r ? r : {}, o, s, c;
99
99
  if (y.errors === "problem-details" && y.envelope !== "jsonapi") {
100
100
  o = l(a.type);
101
101
  let { type: e, title: t, status: n, detail: r, ...i } = a;
@@ -107,17 +107,17 @@ var c = (e = Date.now()) => {
107
107
  let { error: e, ...t } = a;
108
108
  o = typeof e == "string" ? e : void 0, s = t, c = typeof e == "string" ? e : void 0;
109
109
  }
110
- return g(r, _, e.tag, o, s, {
111
- status: t,
110
+ return g(e, _, t.tag, o, s, {
111
+ status: n,
112
112
  requestId: i,
113
113
  detail: c,
114
- body: n
114
+ body: r
115
115
  });
116
116
  };
117
117
  return {
118
- manifest: r,
119
- call: async (n, i, l = {}) => {
120
- let m = e(r, n), h = M(m, i), g = m.path, _ = { ...h };
118
+ manifest: e,
119
+ call: async (t, s, l = {}) => {
120
+ let m = a(e, t), h = M(m, s), g = m.path, _ = { ...h };
121
121
  for (let e of m.pathParams) {
122
122
  let t = _[e];
123
123
  delete _[e], g = g.replace(`:${e}`, encodeURIComponent(t === void 0 ? "" : String(t)));
@@ -132,45 +132,45 @@ var c = (e = Date.now()) => {
132
132
  z !== void 0 && (R.traceparent = z), P || (R["content-type"] = "application/json"), P || m.idempotent !== !0 && l.idempotencyKey === void 0 || (R["idempotency-key"] = l.idempotencyKey ?? c(S()));
133
133
  let B = P && w ? T.get(I) : void 0;
134
134
  B !== void 0 && (R["if-none-match"] = B.etag);
135
- let V = async (e) => {
136
- let i;
135
+ let V = async (a) => {
136
+ let s;
137
137
  try {
138
- i = await x(I, {
138
+ s = await x(I, {
139
139
  method: m.method,
140
140
  headers: R,
141
141
  ...P ? {} : { body: JSON.stringify(_) },
142
142
  ...l.signal === void 0 ? {} : { signal: l.signal }
143
143
  });
144
144
  } catch (e) {
145
- throw new s({
146
- tag: n,
145
+ throw new i({
146
+ tag: t,
147
147
  reason: l.signal?.aborted ? "aborted" : "network",
148
148
  message: String(e instanceof Error ? e.message : e),
149
149
  cause: e
150
150
  });
151
151
  }
152
- let c = i.headers.get("x-request-id") ?? void 0, f = i.headers.get("x-voltro-rest-profile");
153
- if (!O && f !== null && (O = !0, f !== y.name)) throw new a({
152
+ let c = s.headers.get("x-request-id") ?? void 0, f = s.headers.get("x-voltro-rest-profile");
153
+ if (!O && f !== null && (O = !0, f !== y.name)) throw new n({
154
154
  expected: y.name,
155
155
  actual: f
156
156
  });
157
- let h = i.headers.get("sunset"), g = i.headers.get("deprecation");
158
- if (h === null && g === null || E.has(n) || (E.add(n), D({
159
- tag: n,
157
+ let h = s.headers.get("sunset"), g = s.headers.get("deprecation");
158
+ if (h === null && g === null || E.has(t) || (E.add(t), D({
159
+ tag: t,
160
160
  path: m.path,
161
161
  sunset: h ?? m.sunset,
162
162
  deprecated: m.deprecated
163
- })), i.status === 304 && B !== void 0) return {
163
+ })), s.status === 304 && B !== void 0) return {
164
164
  ...B.result,
165
165
  fromCache: !0,
166
166
  requestId: c
167
167
  };
168
168
  let k;
169
169
  try {
170
- k = await i.text();
170
+ k = await s.text();
171
171
  } catch (e) {
172
- throw new s({
173
- tag: n,
172
+ throw new i({
173
+ tag: t,
174
174
  reason: "network",
175
175
  message: "the body could not be read",
176
176
  cause: e,
@@ -181,28 +181,28 @@ var c = (e = Date.now()) => {
181
181
  if (k.length > 0) try {
182
182
  j = JSON.parse(k);
183
183
  } catch {
184
- throw new s({
185
- tag: n,
184
+ throw new i({
185
+ tag: t,
186
186
  reason: "decode",
187
- message: `the answer was not JSON (${i.status})`,
187
+ message: `the answer was not JSON (${s.status})`,
188
188
  requestId: c
189
189
  });
190
190
  }
191
- if (i.status === 429) {
192
- let t = u(i.headers, S()), r = Number(i.headers.get("ratelimit-limit") ?? NaN), a = Number(i.headers.get("ratelimit-remaining") ?? NaN), s = v.retry?.on429?.maxWaitMs;
193
- if (s !== void 0 && e + t <= s) return await C(t), V(e + t);
194
- throw new o({
195
- tag: n,
196
- retryAfterMs: t,
191
+ if (s.status === 429) {
192
+ let e = u(s.headers, S()), n = Number(s.headers.get("ratelimit-limit") ?? NaN), i = Number(s.headers.get("ratelimit-remaining") ?? NaN), o = v.retry?.on429?.maxWaitMs;
193
+ if (o !== void 0 && a + e <= o) return await C(e), V(a + e);
194
+ throw new r({
195
+ tag: t,
196
+ retryAfterMs: e,
197
197
  requestId: c,
198
- ...Number.isFinite(r) ? { limit: r } : {},
199
- ...Number.isFinite(a) ? { remaining: a } : {},
200
- resetAtMs: S() + t
198
+ ...Number.isFinite(n) ? { limit: n } : {},
199
+ ...Number.isFinite(i) ? { remaining: i } : {},
200
+ resetAtMs: S() + e
201
201
  });
202
202
  }
203
- if (i.status >= 400) throw N(m, i.status, j, c);
203
+ if (s.status >= 400) throw N(m, s.status, j, c);
204
204
  let M, F = j;
205
- if (y.pagination === "link-header" && (M = d(i.headers.get("link"), y.cursorParam)), y.envelope === "data" && typeof j == "object" && j && "data" in j) {
205
+ if (y.pagination === "link-header" && (M = d(s.headers.get("link"), y.cursorParam)), y.envelope === "data" && typeof j == "object" && j && "data" in j) {
206
206
  let e = j;
207
207
  F = e.data, M === void 0 && typeof e.next == "string" && (M = e.next);
208
208
  } else if (y.envelope === "jsonapi") {
@@ -213,15 +213,15 @@ var c = (e = Date.now()) => {
213
213
  let e = F[y.cursorField];
214
214
  typeof e == "string" && (M = e);
215
215
  }
216
- let L = i.status === 204 || F === void 0 ? F : t(r.wire.procedures[n]?.output, F, A);
216
+ let L = s.status === 204 || F === void 0 ? F : o(e.wire.procedures[t]?.output, F, A);
217
217
  if (M === void 0 && typeof L == "object" && L) {
218
218
  let e = L[y.cursorField];
219
219
  typeof e == "string" && (M = e);
220
220
  }
221
- let z = i.headers.get("etag") ?? void 0, H = {
221
+ let z = s.headers.get("etag") ?? void 0, H = {
222
222
  value: L,
223
223
  nextCursor: M,
224
- status: i.status,
224
+ status: s.status,
225
225
  requestId: c,
226
226
  etag: z,
227
227
  fromCache: !1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voltro/api-client",
3
- "version": "0.89.2",
3
+ "version": "0.91.0",
4
4
  "description": "The runtime of a generated TypeScript client for a Voltro public API (`voltro build api --target typescript`): the REST surface spoken profile-aware — typed errors as plain classes, dates, envelopes, pagination, a 429 as a wait, idempotency keys — with no dependencies, not on a schema library and not on Effect. Runs in Node, Bun, Deno and the browser. The Effect flavor is `@voltro/api-client-effect`.",
5
5
  "keywords": [
6
6
  "voltro",