@voltro/api-client 0.85.0 → 0.86.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/CHANGELOG.md +666 -0
- package/THIRD-PARTY-NOTICES.md +1 -1
- package/dist/client.js +54 -0
- package/dist/errors.js +77 -0
- package/dist/index.js +9 -859
- package/dist/live.js +230 -0
- package/dist/manifest.js +17 -0
- package/dist/mock.js +91 -0
- package/dist/rest.js +240 -0
- package/dist/rowPatch.js +76 -0
- package/dist/wire.js +101 -0
- package/package.json +1 -1
package/THIRD-PARTY-NOTICES.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Third-Party Notices — @voltro/api-client
|
|
2
2
|
|
|
3
|
-
This package
|
|
3
|
+
This package uses the open-source software listed below. Each is the
|
|
4
4
|
property of its respective copyright holders and is used under the terms of
|
|
5
5
|
its license. This file is provided for attribution; it grants no rights in
|
|
6
6
|
@voltro/api-client itself, which is proprietary (see LICENSE).
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
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
|
+
//#region src/client.ts
|
|
5
|
+
var r = (t) => {
|
|
6
|
+
let n = {};
|
|
7
|
+
for (let r of t.manifest.projections) {
|
|
8
|
+
let i = Object.assign((e, n) => t.call(r.tag, e, n), {
|
|
9
|
+
pages: (e, n) => t.pages(r.tag, e, n),
|
|
10
|
+
subscribe: (e) => t.subscribe(r.tag, e),
|
|
11
|
+
tag: r.tag
|
|
12
|
+
}), { namespace: a, method: o } = e(r.tag);
|
|
13
|
+
if (a === void 0) {
|
|
14
|
+
n[o] = i;
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
let s = n[a] ?? {};
|
|
18
|
+
s[o] = i, n[a] = s;
|
|
19
|
+
}
|
|
20
|
+
return n;
|
|
21
|
+
}, i = (e, t, n, r) => ({ async *[Symbol.asyncIterator]() {
|
|
22
|
+
let i;
|
|
23
|
+
for (;;) {
|
|
24
|
+
let a = await e(i === void 0 ? n : {
|
|
25
|
+
...typeof n == "object" && n ? n : {},
|
|
26
|
+
[t]: i
|
|
27
|
+
}, r);
|
|
28
|
+
if (yield a.value, a.nextCursor === void 0) return;
|
|
29
|
+
i = a.nextCursor;
|
|
30
|
+
}
|
|
31
|
+
} }), a = (e, r = {}) => {
|
|
32
|
+
let a = t(e.manifest, e.errors, r), o = e.manifest.profile.cursorParam, s, c = () => s ??= n(e.manifest, e.errors, a.baseUrl, {
|
|
33
|
+
token: r.token,
|
|
34
|
+
tenant: r.tenant,
|
|
35
|
+
headers: r.headers,
|
|
36
|
+
...r.subscriptions ?? {}
|
|
37
|
+
});
|
|
38
|
+
return {
|
|
39
|
+
manifest: e.manifest,
|
|
40
|
+
errors: e.errors,
|
|
41
|
+
call: async (e, t = {}, n) => (await a.call(e, t, n)).value,
|
|
42
|
+
callRaw: (e, t = {}, n) => a.call(e, t, n),
|
|
43
|
+
pages: (e, t = {}, n) => i((t, n) => a.call(e, t, n), o, t, n),
|
|
44
|
+
subscribe: (e, t = {}) => c().subscribe(e, t),
|
|
45
|
+
close: async () => {
|
|
46
|
+
await s?.close();
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}, o = (e, t = {}) => {
|
|
50
|
+
let n = a(e, t);
|
|
51
|
+
return Object.assign(r(n), n);
|
|
52
|
+
};
|
|
53
|
+
//#endregion
|
|
54
|
+
export { r as buildNamespaces, o as createClient, a as createPromiseClient, i as pagesOf };
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
//#region src/errors.ts
|
|
2
|
+
var e = class extends Error {
|
|
3
|
+
status;
|
|
4
|
+
requestId;
|
|
5
|
+
constructor(e, t = {}, n) {
|
|
6
|
+
super(e, n), this.status = t.status, this.requestId = t.requestId;
|
|
7
|
+
}
|
|
8
|
+
get name() {
|
|
9
|
+
return this._tag;
|
|
10
|
+
}
|
|
11
|
+
}, t = class extends e {
|
|
12
|
+
_tag = "TransportError";
|
|
13
|
+
tag;
|
|
14
|
+
reason;
|
|
15
|
+
constructor(e) {
|
|
16
|
+
super(e.message, { requestId: e.requestId }, e.cause === void 0 ? void 0 : { cause: e.cause }), this.tag = e.tag, this.reason = e.reason;
|
|
17
|
+
}
|
|
18
|
+
}, n = class extends e {
|
|
19
|
+
_tag = "ApiHttpError";
|
|
20
|
+
tag;
|
|
21
|
+
status;
|
|
22
|
+
errorTag;
|
|
23
|
+
detail;
|
|
24
|
+
body;
|
|
25
|
+
constructor(e) {
|
|
26
|
+
super(`${e.tag}: ${e.status}${e.errorTag === void 0 ? "" : ` ${e.errorTag}`}${e.detail === void 0 ? "" : ` — ${e.detail}`}`, {
|
|
27
|
+
status: e.status,
|
|
28
|
+
requestId: e.requestId
|
|
29
|
+
}), this.tag = e.tag, this.status = e.status, this.errorTag = e.errorTag, this.detail = e.detail, this.body = e.body;
|
|
30
|
+
}
|
|
31
|
+
}, r = class extends e {
|
|
32
|
+
_tag = "RateLimitedError";
|
|
33
|
+
tag;
|
|
34
|
+
retryAfterMs;
|
|
35
|
+
limit;
|
|
36
|
+
remaining;
|
|
37
|
+
resetAtMs;
|
|
38
|
+
constructor(e) {
|
|
39
|
+
super(`${e.tag}: rate limited — retry after ${e.retryAfterMs} ms`, {
|
|
40
|
+
status: 429,
|
|
41
|
+
requestId: e.requestId
|
|
42
|
+
}), this.tag = e.tag, this.retryAfterMs = e.retryAfterMs, this.limit = e.limit, this.remaining = e.remaining, this.resetAtMs = e.resetAtMs;
|
|
43
|
+
}
|
|
44
|
+
}, i = class extends e {
|
|
45
|
+
_tag = "ProfileMismatchError";
|
|
46
|
+
expected;
|
|
47
|
+
actual;
|
|
48
|
+
constructor(e) {
|
|
49
|
+
super(`the API speaks the '${e.actual}' profile; this client was generated for '${e.expected}' — regenerate it`), this.expected = e.expected, this.actual = e.actual;
|
|
50
|
+
}
|
|
51
|
+
}, a = class extends e {
|
|
52
|
+
_tag = "InputEncodeError";
|
|
53
|
+
tag;
|
|
54
|
+
constructor(e) {
|
|
55
|
+
super(`${e.tag}: ${e.message}`), this.tag = e.tag;
|
|
56
|
+
}
|
|
57
|
+
}, o = class extends e {
|
|
58
|
+
_tag;
|
|
59
|
+
detail;
|
|
60
|
+
constructor(e, t, n = {}) {
|
|
61
|
+
super(n.detail ?? `${e}${Object.keys(t).length > 0 ? ` ${JSON.stringify(t)}` : ""}`, n), this._tag = e, this.detail = n.detail;
|
|
62
|
+
}
|
|
63
|
+
toJSON() {
|
|
64
|
+
let e = { _tag: this._tag };
|
|
65
|
+
for (let [t, n] of Object.entries(this)) t !== "status" && t !== "requestId" && t !== "detail" && t !== "_tag" && (e[t] = n);
|
|
66
|
+
return e;
|
|
67
|
+
}
|
|
68
|
+
}, s = (e) => {
|
|
69
|
+
class t extends o {
|
|
70
|
+
constructor(t = {}, n = {}) {
|
|
71
|
+
super(e, t, n), Object.assign(this, t);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return Object.defineProperty(t, "name", { value: e }), t;
|
|
75
|
+
};
|
|
76
|
+
//#endregion
|
|
77
|
+
export { e as ApiClientError, n as ApiHttpError, o as DeclaredError, a as InputEncodeError, i as ProfileMismatchError, r as RateLimitedError, t as TransportError, s as defineError };
|