@zilfu/sdk 1.0.2 → 1.2.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/index.cjs +43 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +43 -42
- package/dist/index.js.map +1 -1
- package/package.json +14 -16
- package/README.md +0 -143
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
// src/errors.ts
|
|
4
|
+
var ZilfuApiError = class extends Error {
|
|
5
|
+
status;
|
|
6
|
+
statusText;
|
|
7
|
+
url;
|
|
8
|
+
body;
|
|
9
|
+
errors;
|
|
10
|
+
constructor(init) {
|
|
11
|
+
const message = extractMessage(init);
|
|
12
|
+
super(message);
|
|
13
|
+
this.name = "ZilfuApiError";
|
|
14
|
+
this.status = init.status;
|
|
15
|
+
this.statusText = init.statusText;
|
|
16
|
+
this.url = init.url;
|
|
17
|
+
this.body = init.body;
|
|
18
|
+
this.errors = extractValidationErrors(init.body);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
function extractMessage(init) {
|
|
22
|
+
const body = init.body;
|
|
23
|
+
if (body && typeof body === "object" && "message" in body) {
|
|
24
|
+
const m = body.message;
|
|
25
|
+
if (typeof m === "string" && m.length > 0) {
|
|
26
|
+
return m;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return `Zilfu API ${init.status}${init.statusText ? ` ${init.statusText}` : ""}`;
|
|
30
|
+
}
|
|
31
|
+
function extractValidationErrors(body) {
|
|
32
|
+
if (!body || typeof body !== "object" || !("errors" in body)) {
|
|
33
|
+
return void 0;
|
|
34
|
+
}
|
|
35
|
+
const errors = body.errors;
|
|
36
|
+
if (!errors || typeof errors !== "object") {
|
|
37
|
+
return void 0;
|
|
38
|
+
}
|
|
39
|
+
return errors;
|
|
40
|
+
}
|
|
41
|
+
|
|
3
42
|
// src/generated/core/bodySerializer.gen.ts
|
|
4
43
|
var serializeFormDataPair = (data, key, value) => {
|
|
5
44
|
if (typeof value === "string" || value instanceof Blob) {
|
|
@@ -808,7 +847,7 @@ var createClient = (config = {}) => {
|
|
|
808
847
|
};
|
|
809
848
|
|
|
810
849
|
// src/generated/client.gen.ts
|
|
811
|
-
var client = createClient(createConfig({ baseUrl: "https://zilfu.app/api" }));
|
|
850
|
+
var client = createClient(createConfig({ baseUrl: "https://app.zilfu.app/api" }));
|
|
812
851
|
|
|
813
852
|
// src/generated/sdk.gen.ts
|
|
814
853
|
var HeyApiClient = class {
|
|
@@ -1675,50 +1714,12 @@ var ZilfuApi = class _ZilfuApi extends HeyApiClient {
|
|
|
1675
1714
|
}
|
|
1676
1715
|
};
|
|
1677
1716
|
|
|
1678
|
-
// src/errors.ts
|
|
1679
|
-
var ZilfuApiError = class extends Error {
|
|
1680
|
-
status;
|
|
1681
|
-
statusText;
|
|
1682
|
-
url;
|
|
1683
|
-
body;
|
|
1684
|
-
errors;
|
|
1685
|
-
constructor(init) {
|
|
1686
|
-
const message = extractMessage(init);
|
|
1687
|
-
super(message);
|
|
1688
|
-
this.name = "ZilfuApiError";
|
|
1689
|
-
this.status = init.status;
|
|
1690
|
-
this.statusText = init.statusText;
|
|
1691
|
-
this.url = init.url;
|
|
1692
|
-
this.body = init.body;
|
|
1693
|
-
this.errors = extractValidationErrors(init.body);
|
|
1694
|
-
}
|
|
1695
|
-
};
|
|
1696
|
-
function extractMessage(init) {
|
|
1697
|
-
const body = init.body;
|
|
1698
|
-
if (body && typeof body === "object" && "message" in body) {
|
|
1699
|
-
const m = body.message;
|
|
1700
|
-
if (typeof m === "string" && m.length > 0) {
|
|
1701
|
-
return m;
|
|
1702
|
-
}
|
|
1703
|
-
}
|
|
1704
|
-
return `Zilfu API ${init.status}${init.statusText ? ` ${init.statusText}` : ""}`;
|
|
1705
|
-
}
|
|
1706
|
-
function extractValidationErrors(body) {
|
|
1707
|
-
if (!body || typeof body !== "object" || !("errors" in body)) {
|
|
1708
|
-
return void 0;
|
|
1709
|
-
}
|
|
1710
|
-
const errors = body.errors;
|
|
1711
|
-
if (!errors || typeof errors !== "object") {
|
|
1712
|
-
return void 0;
|
|
1713
|
-
}
|
|
1714
|
-
return errors;
|
|
1715
|
-
}
|
|
1716
|
-
|
|
1717
1717
|
// src/client.ts
|
|
1718
|
+
var DEFAULT_API_BASE_URL = client.getConfig().baseUrl;
|
|
1718
1719
|
function createZilfuClient(opts) {
|
|
1719
1720
|
const client2 = createClient(
|
|
1720
1721
|
createConfig({
|
|
1721
|
-
baseUrl: opts.baseUrl ??
|
|
1722
|
+
baseUrl: opts.baseUrl ?? DEFAULT_API_BASE_URL,
|
|
1722
1723
|
fetch: opts.fetch,
|
|
1723
1724
|
headers: { accept: "application/json", ...opts.headers },
|
|
1724
1725
|
auth: opts.token,
|
|
@@ -1736,6 +1737,7 @@ function createZilfuClient(opts) {
|
|
|
1736
1737
|
return new ZilfuApi({ client: client2 });
|
|
1737
1738
|
}
|
|
1738
1739
|
|
|
1740
|
+
exports.DEFAULT_API_BASE_URL = DEFAULT_API_BASE_URL;
|
|
1739
1741
|
exports.ZilfuApiError = ZilfuApiError;
|
|
1740
1742
|
exports.createZilfuClient = createZilfuClient;
|
|
1741
1743
|
//# sourceMappingURL=index.cjs.map
|