@medialane/ui 0.167.0 → 0.169.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/components/asset-marketplace-panel.cjs +2 -5
- package/dist/components/asset-marketplace-panel.cjs.map +1 -1
- package/dist/components/asset-marketplace-panel.d.cts +1 -3
- package/dist/components/asset-marketplace-panel.d.ts +1 -3
- package/dist/components/asset-marketplace-panel.js +2 -5
- package/dist/components/asset-marketplace-panel.js.map +1 -1
- package/dist/components/badge.d.cts +1 -1
- package/dist/components/badge.d.ts +1 -1
- package/dist/components/button.d.cts +2 -2
- package/dist/components/button.d.ts +2 -2
- package/dist/components/fast-mint/fast-mint.cjs +4 -4
- package/dist/components/fast-mint/fast-mint.cjs.map +1 -1
- package/dist/components/fast-mint/fast-mint.d.cts +2 -2
- package/dist/components/fast-mint/fast-mint.d.ts +2 -2
- package/dist/components/fast-mint/fast-mint.js +4 -4
- package/dist/components/fast-mint/fast-mint.js.map +1 -1
- package/dist/components/remixes-tab.cjs +2 -2
- package/dist/components/remixes-tab.cjs.map +1 -1
- package/dist/components/remixes-tab.d.cts +3 -3
- package/dist/components/remixes-tab.d.ts +3 -3
- package/dist/components/remixes-tab.js +2 -2
- package/dist/components/remixes-tab.js.map +1 -1
- package/dist/components/sheet.d.cts +1 -1
- package/dist/components/sheet.d.ts +1 -1
- package/dist/index.cjs +0 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +0 -2
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -5
- package/dist/index.js.map +1 -1
- package/dist/utils/ipfs-upload.cjs +11 -31
- package/dist/utils/ipfs-upload.cjs.map +1 -1
- package/dist/utils/ipfs-upload.d.cts +5 -5
- package/dist/utils/ipfs-upload.d.ts +5 -5
- package/dist/utils/ipfs-upload.js +11 -31
- package/dist/utils/ipfs-upload.js.map +1 -1
- package/dist/utils/use-notifications.cjs +2 -2
- package/dist/utils/use-notifications.cjs.map +1 -1
- package/dist/utils/use-notifications.d.cts +1 -2
- package/dist/utils/use-notifications.d.ts +1 -2
- package/dist/utils/use-notifications.js +2 -2
- package/dist/utils/use-notifications.js.map +1 -1
- package/dist/utils/use-orders.cjs +3 -3
- package/dist/utils/use-orders.cjs.map +1 -1
- package/dist/utils/use-orders.d.cts +1 -2
- package/dist/utils/use-orders.d.ts +1 -2
- package/dist/utils/use-orders.js +3 -3
- package/dist/utils/use-orders.js.map +1 -1
- package/dist/utils/use-remix-offers.cjs +5 -4
- package/dist/utils/use-remix-offers.cjs.map +1 -1
- package/dist/utils/use-remix-offers.d.cts +4 -9
- package/dist/utils/use-remix-offers.d.ts +4 -9
- package/dist/utils/use-remix-offers.js +5 -4
- package/dist/utils/use-remix-offers.js.map +1 -1
- package/package.json +3 -3
- package/dist/components/email-verification-gate.cjs +0 -57
- package/dist/components/email-verification-gate.cjs.map +0 -1
- package/dist/components/email-verification-gate.d.cts +0 -10
- package/dist/components/email-verification-gate.d.ts +0 -10
- package/dist/components/email-verification-gate.js +0 -33
- package/dist/components/email-verification-gate.js.map +0 -1
- package/dist/utils/api-fetch.cjs +0 -65
- package/dist/utils/api-fetch.cjs.map +0 -1
- package/dist/utils/api-fetch.d.cts +0 -17
- package/dist/utils/api-fetch.d.ts +0 -17
- package/dist/utils/api-fetch.js +0 -40
- package/dist/utils/api-fetch.js.map +0 -1
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
"use client";
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
-
var email_verification_gate_exports = {};
|
|
21
|
-
__export(email_verification_gate_exports, {
|
|
22
|
-
EmailVerificationGate: () => EmailVerificationGate
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(email_verification_gate_exports);
|
|
25
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
26
|
-
var import_lucide_react = require("lucide-react");
|
|
27
|
-
var import_cn = require("../utils/cn.js");
|
|
28
|
-
const BRAND_LOOP = "linear-gradient(270deg, #3b7bff, #8a5cf6, #f6608f, #fb8b46, #3b7bff)";
|
|
29
|
-
function EmailVerificationGate({
|
|
30
|
-
reason,
|
|
31
|
-
settingsHref,
|
|
32
|
-
className
|
|
33
|
-
}) {
|
|
34
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
35
|
-
"a",
|
|
36
|
-
{
|
|
37
|
-
href: settingsHref,
|
|
38
|
-
className: (0, import_cn.cn)(
|
|
39
|
-
"ml-gbtn col-span-2 mb-3 flex h-[54px] items-center justify-center gap-2 rounded-[13px] bg-transparent px-5 font-semibold transition-transform active:scale-[0.99]",
|
|
40
|
-
className
|
|
41
|
-
),
|
|
42
|
-
style: { "--ml-grad": BRAND_LOOP },
|
|
43
|
-
children: [
|
|
44
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Mail, { className: "h-4 w-4 shrink-0 text-brand-orange" }),
|
|
45
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "truncate text-base", children: [
|
|
46
|
-
"Verify email to ",
|
|
47
|
-
reason
|
|
48
|
-
] })
|
|
49
|
-
]
|
|
50
|
-
}
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
54
|
-
0 && (module.exports = {
|
|
55
|
-
EmailVerificationGate
|
|
56
|
-
});
|
|
57
|
-
//# sourceMappingURL=email-verification-gate.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/email-verification-gate.tsx"],"sourcesContent":["\"use client\";\n\nimport { Mail } from \"lucide-react\";\nimport { cn } from \"../utils/cn.js\";\n\nexport interface EmailVerificationGateProps {\n reason: string;\n settingsHref: string;\n className?: string;\n}\n\nconst BRAND_LOOP = \"linear-gradient(270deg, #3b7bff, #8a5cf6, #f6608f, #fb8b46, #3b7bff)\";\n\nexport function EmailVerificationGate({\n reason,\n settingsHref,\n className,\n}: EmailVerificationGateProps) {\n return (\n <a\n href={settingsHref}\n className={cn(\n \"ml-gbtn col-span-2 mb-3 flex h-[54px] items-center justify-center gap-2 rounded-[13px] bg-transparent px-5 font-semibold transition-transform active:scale-[0.99]\",\n className,\n )}\n style={{ '--ml-grad': BRAND_LOOP } as React.CSSProperties}\n >\n <Mail className=\"h-4 w-4 shrink-0 text-brand-orange\" />\n <span className=\"truncate text-base\">Verify email to {reason}</span>\n </a>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA2BM;AAzBN,0BAAqB;AACrB,gBAAmB;AAQnB,MAAM,aAAa;AAEZ,SAAS,sBAAsB;AAAA,EACpC;AAAA,EACA;AAAA,EACA;AACF,GAA+B;AAC7B,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAM;AAAA,MACN,eAAW;AAAA,QACT;AAAA,QACA;AAAA,MACF;AAAA,MACA,OAAO,EAAE,aAAa,WAAW;AAAA,MAEjC;AAAA,oDAAC,4BAAK,WAAU,sCAAqC;AAAA,QACrD,6CAAC,UAAK,WAAU,sBAAqB;AAAA;AAAA,UAAiB;AAAA,WAAO;AAAA;AAAA;AAAA,EAC/D;AAEJ;","names":[]}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
|
|
3
|
-
interface EmailVerificationGateProps {
|
|
4
|
-
reason: string;
|
|
5
|
-
settingsHref: string;
|
|
6
|
-
className?: string;
|
|
7
|
-
}
|
|
8
|
-
declare function EmailVerificationGate({ reason, settingsHref, className, }: EmailVerificationGateProps): react_jsx_runtime.JSX.Element;
|
|
9
|
-
|
|
10
|
-
export { EmailVerificationGate, type EmailVerificationGateProps };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
|
|
3
|
-
interface EmailVerificationGateProps {
|
|
4
|
-
reason: string;
|
|
5
|
-
settingsHref: string;
|
|
6
|
-
className?: string;
|
|
7
|
-
}
|
|
8
|
-
declare function EmailVerificationGate({ reason, settingsHref, className, }: EmailVerificationGateProps): react_jsx_runtime.JSX.Element;
|
|
9
|
-
|
|
10
|
-
export { EmailVerificationGate, type EmailVerificationGateProps };
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { Mail } from "lucide-react";
|
|
4
|
-
import { cn } from "../utils/cn.js";
|
|
5
|
-
const BRAND_LOOP = "linear-gradient(270deg, #3b7bff, #8a5cf6, #f6608f, #fb8b46, #3b7bff)";
|
|
6
|
-
function EmailVerificationGate({
|
|
7
|
-
reason,
|
|
8
|
-
settingsHref,
|
|
9
|
-
className
|
|
10
|
-
}) {
|
|
11
|
-
return /* @__PURE__ */ jsxs(
|
|
12
|
-
"a",
|
|
13
|
-
{
|
|
14
|
-
href: settingsHref,
|
|
15
|
-
className: cn(
|
|
16
|
-
"ml-gbtn col-span-2 mb-3 flex h-[54px] items-center justify-center gap-2 rounded-[13px] bg-transparent px-5 font-semibold transition-transform active:scale-[0.99]",
|
|
17
|
-
className
|
|
18
|
-
),
|
|
19
|
-
style: { "--ml-grad": BRAND_LOOP },
|
|
20
|
-
children: [
|
|
21
|
-
/* @__PURE__ */ jsx(Mail, { className: "h-4 w-4 shrink-0 text-brand-orange" }),
|
|
22
|
-
/* @__PURE__ */ jsxs("span", { className: "truncate text-base", children: [
|
|
23
|
-
"Verify email to ",
|
|
24
|
-
reason
|
|
25
|
-
] })
|
|
26
|
-
]
|
|
27
|
-
}
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
export {
|
|
31
|
-
EmailVerificationGate
|
|
32
|
-
};
|
|
33
|
-
//# sourceMappingURL=email-verification-gate.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/email-verification-gate.tsx"],"sourcesContent":["\"use client\";\n\nimport { Mail } from \"lucide-react\";\nimport { cn } from \"../utils/cn.js\";\n\nexport interface EmailVerificationGateProps {\n reason: string;\n settingsHref: string;\n className?: string;\n}\n\nconst BRAND_LOOP = \"linear-gradient(270deg, #3b7bff, #8a5cf6, #f6608f, #fb8b46, #3b7bff)\";\n\nexport function EmailVerificationGate({\n reason,\n settingsHref,\n className,\n}: EmailVerificationGateProps) {\n return (\n <a\n href={settingsHref}\n className={cn(\n \"ml-gbtn col-span-2 mb-3 flex h-[54px] items-center justify-center gap-2 rounded-[13px] bg-transparent px-5 font-semibold transition-transform active:scale-[0.99]\",\n className,\n )}\n style={{ '--ml-grad': BRAND_LOOP } as React.CSSProperties}\n >\n <Mail className=\"h-4 w-4 shrink-0 text-brand-orange\" />\n <span className=\"truncate text-base\">Verify email to {reason}</span>\n </a>\n );\n}\n"],"mappings":";AA2BM,cACA,YADA;AAzBN,SAAS,YAAY;AACrB,SAAS,UAAU;AAQnB,MAAM,aAAa;AAEZ,SAAS,sBAAsB;AAAA,EACpC;AAAA,EACA;AAAA,EACA;AACF,GAA+B;AAC7B,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAM;AAAA,MACN,WAAW;AAAA,QACT;AAAA,QACA;AAAA,MACF;AAAA,MACA,OAAO,EAAE,aAAa,WAAW;AAAA,MAEjC;AAAA,4BAAC,QAAK,WAAU,sCAAqC;AAAA,QACrD,qBAAC,UAAK,WAAU,sBAAqB;AAAA;AAAA,UAAiB;AAAA,WAAO;AAAA;AAAA;AAAA,EAC/D;AAEJ;","names":[]}
|
package/dist/utils/api-fetch.cjs
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var api_fetch_exports = {};
|
|
20
|
-
__export(api_fetch_exports, {
|
|
21
|
-
ApiError: () => ApiError,
|
|
22
|
-
apiFetch: () => apiFetch
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(api_fetch_exports);
|
|
25
|
-
class ApiError extends Error {
|
|
26
|
-
constructor(status, message) {
|
|
27
|
-
super(message);
|
|
28
|
-
this.status = status;
|
|
29
|
-
this.name = "ApiError";
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
async function apiFetch(config, path, options = {}) {
|
|
33
|
-
const { method = "GET", body, bearer, signal } = options;
|
|
34
|
-
const url = `${config.baseUrl.replace(/\/$/, "")}${path.startsWith("/") ? path : `/${path}`}`;
|
|
35
|
-
const headers = {};
|
|
36
|
-
if (body !== void 0) headers["Content-Type"] = "application/json";
|
|
37
|
-
if (config.apiKey) headers["x-api-key"] = config.apiKey;
|
|
38
|
-
if (bearer) headers["Authorization"] = `Bearer ${bearer}`;
|
|
39
|
-
const res = await fetch(url, {
|
|
40
|
-
method,
|
|
41
|
-
headers,
|
|
42
|
-
body: body !== void 0 ? JSON.stringify(body) : void 0,
|
|
43
|
-
signal
|
|
44
|
-
});
|
|
45
|
-
if (!res.ok) {
|
|
46
|
-
const text = await res.text().catch(() => res.statusText);
|
|
47
|
-
let message = text || `Request failed with HTTP ${res.status}`;
|
|
48
|
-
try {
|
|
49
|
-
const parsed = JSON.parse(text);
|
|
50
|
-
if (parsed && typeof parsed === "object" && "error" in parsed && typeof parsed.error === "string") {
|
|
51
|
-
message = parsed.error;
|
|
52
|
-
}
|
|
53
|
-
} catch {
|
|
54
|
-
}
|
|
55
|
-
throw new ApiError(res.status, message);
|
|
56
|
-
}
|
|
57
|
-
if (res.status === 204) return void 0;
|
|
58
|
-
return res.json();
|
|
59
|
-
}
|
|
60
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
61
|
-
0 && (module.exports = {
|
|
62
|
-
ApiError,
|
|
63
|
-
apiFetch
|
|
64
|
-
});
|
|
65
|
-
//# sourceMappingURL=api-fetch.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/api-fetch.ts"],"sourcesContent":["\nexport class ApiError extends Error {\n constructor(public readonly status: number, message: string) {\n super(message);\n this.name = \"ApiError\";\n }\n}\n\nexport interface ApiFetchConfig {\n baseUrl: string;\n apiKey?: string;\n}\n\nexport interface ApiFetchOptions {\n method?: \"GET\" | \"POST\" | \"PATCH\" | \"PUT\" | \"DELETE\";\n body?: unknown;\n\n bearer?: string | null;\n signal?: AbortSignal;\n}\n\nexport async function apiFetch<T = unknown>(\n config: ApiFetchConfig,\n path: string,\n options: ApiFetchOptions = {}\n): Promise<T> {\n const { method = \"GET\", body, bearer, signal } = options;\n const url = `${config.baseUrl.replace(/\\/$/, \"\")}${path.startsWith(\"/\") ? path : `/${path}`}`;\n\n const headers: Record<string, string> = {};\n if (body !== undefined) headers[\"Content-Type\"] = \"application/json\";\n if (config.apiKey) headers[\"x-api-key\"] = config.apiKey;\n if (bearer) headers[\"Authorization\"] = `Bearer ${bearer}`;\n\n const res = await fetch(url, {\n method,\n headers,\n body: body !== undefined ? JSON.stringify(body) : undefined,\n signal,\n });\n\n if (!res.ok) {\n const text = await res.text().catch(() => res.statusText);\n let message = text || `Request failed with HTTP ${res.status}`;\n try {\n const parsed = JSON.parse(text);\n if (parsed && typeof parsed === \"object\" && \"error\" in parsed && typeof parsed.error === \"string\") {\n message = parsed.error;\n }\n } catch {\n\n }\n throw new ApiError(res.status, message);\n }\n\n if (res.status === 204) return undefined as T;\n return res.json() as Promise<T>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACO,MAAM,iBAAiB,MAAM;AAAA,EAClC,YAA4B,QAAgB,SAAiB;AAC3D,UAAM,OAAO;AADa;AAE1B,SAAK,OAAO;AAAA,EACd;AACF;AAeA,eAAsB,SACpB,QACA,MACA,UAA2B,CAAC,GAChB;AACZ,QAAM,EAAE,SAAS,OAAO,MAAM,QAAQ,OAAO,IAAI;AACjD,QAAM,MAAM,GAAG,OAAO,QAAQ,QAAQ,OAAO,EAAE,CAAC,GAAG,KAAK,WAAW,GAAG,IAAI,OAAO,IAAI,IAAI,EAAE;AAE3F,QAAM,UAAkC,CAAC;AACzC,MAAI,SAAS,OAAW,SAAQ,cAAc,IAAI;AAClD,MAAI,OAAO,OAAQ,SAAQ,WAAW,IAAI,OAAO;AACjD,MAAI,OAAQ,SAAQ,eAAe,IAAI,UAAU,MAAM;AAEvD,QAAM,MAAM,MAAM,MAAM,KAAK;AAAA,IAC3B;AAAA,IACA;AAAA,IACA,MAAM,SAAS,SAAY,KAAK,UAAU,IAAI,IAAI;AAAA,IAClD;AAAA,EACF,CAAC;AAED,MAAI,CAAC,IAAI,IAAI;AACX,UAAM,OAAO,MAAM,IAAI,KAAK,EAAE,MAAM,MAAM,IAAI,UAAU;AACxD,QAAI,UAAU,QAAQ,4BAA4B,IAAI,MAAM;AAC5D,QAAI;AACF,YAAM,SAAS,KAAK,MAAM,IAAI;AAC9B,UAAI,UAAU,OAAO,WAAW,YAAY,WAAW,UAAU,OAAO,OAAO,UAAU,UAAU;AACjG,kBAAU,OAAO;AAAA,MACnB;AAAA,IACF,QAAQ;AAAA,IAER;AACA,UAAM,IAAI,SAAS,IAAI,QAAQ,OAAO;AAAA,EACxC;AAEA,MAAI,IAAI,WAAW,IAAK,QAAO;AAC/B,SAAO,IAAI,KAAK;AAClB;","names":[]}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
declare class ApiError extends Error {
|
|
2
|
-
readonly status: number;
|
|
3
|
-
constructor(status: number, message: string);
|
|
4
|
-
}
|
|
5
|
-
interface ApiFetchConfig {
|
|
6
|
-
baseUrl: string;
|
|
7
|
-
apiKey?: string;
|
|
8
|
-
}
|
|
9
|
-
interface ApiFetchOptions {
|
|
10
|
-
method?: "GET" | "POST" | "PATCH" | "PUT" | "DELETE";
|
|
11
|
-
body?: unknown;
|
|
12
|
-
bearer?: string | null;
|
|
13
|
-
signal?: AbortSignal;
|
|
14
|
-
}
|
|
15
|
-
declare function apiFetch<T = unknown>(config: ApiFetchConfig, path: string, options?: ApiFetchOptions): Promise<T>;
|
|
16
|
-
|
|
17
|
-
export { ApiError, type ApiFetchConfig, type ApiFetchOptions, apiFetch };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
declare class ApiError extends Error {
|
|
2
|
-
readonly status: number;
|
|
3
|
-
constructor(status: number, message: string);
|
|
4
|
-
}
|
|
5
|
-
interface ApiFetchConfig {
|
|
6
|
-
baseUrl: string;
|
|
7
|
-
apiKey?: string;
|
|
8
|
-
}
|
|
9
|
-
interface ApiFetchOptions {
|
|
10
|
-
method?: "GET" | "POST" | "PATCH" | "PUT" | "DELETE";
|
|
11
|
-
body?: unknown;
|
|
12
|
-
bearer?: string | null;
|
|
13
|
-
signal?: AbortSignal;
|
|
14
|
-
}
|
|
15
|
-
declare function apiFetch<T = unknown>(config: ApiFetchConfig, path: string, options?: ApiFetchOptions): Promise<T>;
|
|
16
|
-
|
|
17
|
-
export { ApiError, type ApiFetchConfig, type ApiFetchOptions, apiFetch };
|
package/dist/utils/api-fetch.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
class ApiError extends Error {
|
|
2
|
-
constructor(status, message) {
|
|
3
|
-
super(message);
|
|
4
|
-
this.status = status;
|
|
5
|
-
this.name = "ApiError";
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
async function apiFetch(config, path, options = {}) {
|
|
9
|
-
const { method = "GET", body, bearer, signal } = options;
|
|
10
|
-
const url = `${config.baseUrl.replace(/\/$/, "")}${path.startsWith("/") ? path : `/${path}`}`;
|
|
11
|
-
const headers = {};
|
|
12
|
-
if (body !== void 0) headers["Content-Type"] = "application/json";
|
|
13
|
-
if (config.apiKey) headers["x-api-key"] = config.apiKey;
|
|
14
|
-
if (bearer) headers["Authorization"] = `Bearer ${bearer}`;
|
|
15
|
-
const res = await fetch(url, {
|
|
16
|
-
method,
|
|
17
|
-
headers,
|
|
18
|
-
body: body !== void 0 ? JSON.stringify(body) : void 0,
|
|
19
|
-
signal
|
|
20
|
-
});
|
|
21
|
-
if (!res.ok) {
|
|
22
|
-
const text = await res.text().catch(() => res.statusText);
|
|
23
|
-
let message = text || `Request failed with HTTP ${res.status}`;
|
|
24
|
-
try {
|
|
25
|
-
const parsed = JSON.parse(text);
|
|
26
|
-
if (parsed && typeof parsed === "object" && "error" in parsed && typeof parsed.error === "string") {
|
|
27
|
-
message = parsed.error;
|
|
28
|
-
}
|
|
29
|
-
} catch {
|
|
30
|
-
}
|
|
31
|
-
throw new ApiError(res.status, message);
|
|
32
|
-
}
|
|
33
|
-
if (res.status === 204) return void 0;
|
|
34
|
-
return res.json();
|
|
35
|
-
}
|
|
36
|
-
export {
|
|
37
|
-
ApiError,
|
|
38
|
-
apiFetch
|
|
39
|
-
};
|
|
40
|
-
//# sourceMappingURL=api-fetch.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/api-fetch.ts"],"sourcesContent":["\nexport class ApiError extends Error {\n constructor(public readonly status: number, message: string) {\n super(message);\n this.name = \"ApiError\";\n }\n}\n\nexport interface ApiFetchConfig {\n baseUrl: string;\n apiKey?: string;\n}\n\nexport interface ApiFetchOptions {\n method?: \"GET\" | \"POST\" | \"PATCH\" | \"PUT\" | \"DELETE\";\n body?: unknown;\n\n bearer?: string | null;\n signal?: AbortSignal;\n}\n\nexport async function apiFetch<T = unknown>(\n config: ApiFetchConfig,\n path: string,\n options: ApiFetchOptions = {}\n): Promise<T> {\n const { method = \"GET\", body, bearer, signal } = options;\n const url = `${config.baseUrl.replace(/\\/$/, \"\")}${path.startsWith(\"/\") ? path : `/${path}`}`;\n\n const headers: Record<string, string> = {};\n if (body !== undefined) headers[\"Content-Type\"] = \"application/json\";\n if (config.apiKey) headers[\"x-api-key\"] = config.apiKey;\n if (bearer) headers[\"Authorization\"] = `Bearer ${bearer}`;\n\n const res = await fetch(url, {\n method,\n headers,\n body: body !== undefined ? JSON.stringify(body) : undefined,\n signal,\n });\n\n if (!res.ok) {\n const text = await res.text().catch(() => res.statusText);\n let message = text || `Request failed with HTTP ${res.status}`;\n try {\n const parsed = JSON.parse(text);\n if (parsed && typeof parsed === \"object\" && \"error\" in parsed && typeof parsed.error === \"string\") {\n message = parsed.error;\n }\n } catch {\n\n }\n throw new ApiError(res.status, message);\n }\n\n if (res.status === 204) return undefined as T;\n return res.json() as Promise<T>;\n}\n"],"mappings":"AACO,MAAM,iBAAiB,MAAM;AAAA,EAClC,YAA4B,QAAgB,SAAiB;AAC3D,UAAM,OAAO;AADa;AAE1B,SAAK,OAAO;AAAA,EACd;AACF;AAeA,eAAsB,SACpB,QACA,MACA,UAA2B,CAAC,GAChB;AACZ,QAAM,EAAE,SAAS,OAAO,MAAM,QAAQ,OAAO,IAAI;AACjD,QAAM,MAAM,GAAG,OAAO,QAAQ,QAAQ,OAAO,EAAE,CAAC,GAAG,KAAK,WAAW,GAAG,IAAI,OAAO,IAAI,IAAI,EAAE;AAE3F,QAAM,UAAkC,CAAC;AACzC,MAAI,SAAS,OAAW,SAAQ,cAAc,IAAI;AAClD,MAAI,OAAO,OAAQ,SAAQ,WAAW,IAAI,OAAO;AACjD,MAAI,OAAQ,SAAQ,eAAe,IAAI,UAAU,MAAM;AAEvD,QAAM,MAAM,MAAM,MAAM,KAAK;AAAA,IAC3B;AAAA,IACA;AAAA,IACA,MAAM,SAAS,SAAY,KAAK,UAAU,IAAI,IAAI;AAAA,IAClD;AAAA,EACF,CAAC;AAED,MAAI,CAAC,IAAI,IAAI;AACX,UAAM,OAAO,MAAM,IAAI,KAAK,EAAE,MAAM,MAAM,IAAI,UAAU;AACxD,QAAI,UAAU,QAAQ,4BAA4B,IAAI,MAAM;AAC5D,QAAI;AACF,YAAM,SAAS,KAAK,MAAM,IAAI;AAC9B,UAAI,UAAU,OAAO,WAAW,YAAY,WAAW,UAAU,OAAO,OAAO,UAAU,UAAU;AACjG,kBAAU,OAAO;AAAA,MACnB;AAAA,IACF,QAAQ;AAAA,IAER;AACA,UAAM,IAAI,SAAS,IAAI,QAAQ,OAAO;AAAA,EACxC;AAEA,MAAI,IAAI,WAAW,IAAK,QAAO;AAC/B,SAAO,IAAI,KAAK;AAClB;","names":[]}
|