@abloatai/decks 0.1.0 → 0.1.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/index.cjs +15 -3
- package/dist/index.js +15 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -7099,8 +7099,20 @@ function createImagesApi(config) {
|
|
|
7099
7099
|
}
|
|
7100
7100
|
|
|
7101
7101
|
// src/http.ts
|
|
7102
|
+
function ensureApiSuffix(rawBase) {
|
|
7103
|
+
const trimmed = rawBase.replace(/\/+$/, "");
|
|
7104
|
+
try {
|
|
7105
|
+
const u = new URL(trimmed);
|
|
7106
|
+
const segments = u.pathname.split("/").filter(Boolean);
|
|
7107
|
+
if (segments[segments.length - 1] === "api") return trimmed;
|
|
7108
|
+
u.pathname = `${u.pathname.replace(/\/+$/, "")}/api`;
|
|
7109
|
+
return u.toString().replace(/\/+$/, "");
|
|
7110
|
+
} catch {
|
|
7111
|
+
return /\/api$/.test(trimmed) ? trimmed : `${trimmed}/api`;
|
|
7112
|
+
}
|
|
7113
|
+
}
|
|
7102
7114
|
function createHttpClient({ baseURL, apiKey }) {
|
|
7103
|
-
const base = baseURL
|
|
7115
|
+
const base = ensureApiSuffix(baseURL);
|
|
7104
7116
|
const headers = {
|
|
7105
7117
|
"Content-Type": "application/json",
|
|
7106
7118
|
Authorization: `Bearer ${apiKey}`
|
|
@@ -7137,7 +7149,7 @@ function createHttpClient({ baseURL, apiKey }) {
|
|
|
7137
7149
|
function reader(model) {
|
|
7138
7150
|
return {
|
|
7139
7151
|
async retrieve({ id }) {
|
|
7140
|
-
const res = await fetch(`${base}/v1/${model}/${encodeURIComponent(id)}`, { headers });
|
|
7152
|
+
const res = await fetch(`${base}/v1/models/${model}/${encodeURIComponent(id)}`, { headers });
|
|
7141
7153
|
if (!res.ok) await fail(res, `${model}.retrieve`);
|
|
7142
7154
|
const body = await res.json();
|
|
7143
7155
|
return { data: body.data ?? body };
|
|
@@ -7148,7 +7160,7 @@ function createHttpClient({ baseURL, apiKey }) {
|
|
|
7148
7160
|
if (options?.orderBy) qs.set("orderBy", JSON.stringify(options.orderBy));
|
|
7149
7161
|
if (options?.limit != null) qs.set("limit", String(options.limit));
|
|
7150
7162
|
const suffix = qs.toString() ? `?${qs.toString()}` : "";
|
|
7151
|
-
const res = await fetch(`${base}/v1/${model}${suffix}`, { headers });
|
|
7163
|
+
const res = await fetch(`${base}/v1/models/${model}${suffix}`, { headers });
|
|
7152
7164
|
if (!res.ok) await fail(res, `${model}.list`);
|
|
7153
7165
|
const body = await res.json();
|
|
7154
7166
|
return body.data ?? body.rows ?? body;
|
package/dist/index.js
CHANGED
|
@@ -7097,8 +7097,20 @@ function createImagesApi(config) {
|
|
|
7097
7097
|
}
|
|
7098
7098
|
|
|
7099
7099
|
// src/http.ts
|
|
7100
|
+
function ensureApiSuffix(rawBase) {
|
|
7101
|
+
const trimmed = rawBase.replace(/\/+$/, "");
|
|
7102
|
+
try {
|
|
7103
|
+
const u = new URL(trimmed);
|
|
7104
|
+
const segments = u.pathname.split("/").filter(Boolean);
|
|
7105
|
+
if (segments[segments.length - 1] === "api") return trimmed;
|
|
7106
|
+
u.pathname = `${u.pathname.replace(/\/+$/, "")}/api`;
|
|
7107
|
+
return u.toString().replace(/\/+$/, "");
|
|
7108
|
+
} catch {
|
|
7109
|
+
return /\/api$/.test(trimmed) ? trimmed : `${trimmed}/api`;
|
|
7110
|
+
}
|
|
7111
|
+
}
|
|
7100
7112
|
function createHttpClient({ baseURL, apiKey }) {
|
|
7101
|
-
const base = baseURL
|
|
7113
|
+
const base = ensureApiSuffix(baseURL);
|
|
7102
7114
|
const headers = {
|
|
7103
7115
|
"Content-Type": "application/json",
|
|
7104
7116
|
Authorization: `Bearer ${apiKey}`
|
|
@@ -7135,7 +7147,7 @@ function createHttpClient({ baseURL, apiKey }) {
|
|
|
7135
7147
|
function reader(model) {
|
|
7136
7148
|
return {
|
|
7137
7149
|
async retrieve({ id }) {
|
|
7138
|
-
const res = await fetch(`${base}/v1/${model}/${encodeURIComponent(id)}`, { headers });
|
|
7150
|
+
const res = await fetch(`${base}/v1/models/${model}/${encodeURIComponent(id)}`, { headers });
|
|
7139
7151
|
if (!res.ok) await fail(res, `${model}.retrieve`);
|
|
7140
7152
|
const body = await res.json();
|
|
7141
7153
|
return { data: body.data ?? body };
|
|
@@ -7146,7 +7158,7 @@ function createHttpClient({ baseURL, apiKey }) {
|
|
|
7146
7158
|
if (options?.orderBy) qs.set("orderBy", JSON.stringify(options.orderBy));
|
|
7147
7159
|
if (options?.limit != null) qs.set("limit", String(options.limit));
|
|
7148
7160
|
const suffix = qs.toString() ? `?${qs.toString()}` : "";
|
|
7149
|
-
const res = await fetch(`${base}/v1/${model}${suffix}`, { headers });
|
|
7161
|
+
const res = await fetch(`${base}/v1/models/${model}${suffix}`, { headers });
|
|
7150
7162
|
if (!res.ok) await fail(res, `${model}.list`);
|
|
7151
7163
|
const body = await res.json();
|
|
7152
7164
|
return body.data ?? body.rows ?? body;
|