swiftbase-admin-sdk 1.0.2 → 1.0.4
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 +42 -33
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +38 -3
- package/dist/index.d.ts +38 -3
- package/dist/index.js +42 -33
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -221,9 +221,6 @@ var init_login = __esm({
|
|
|
221
221
|
body.append("client_secret", secretKey);
|
|
222
222
|
body.append("scope", "openid profile email");
|
|
223
223
|
let base = app.baseUrl || "https://api.swiftbase.io";
|
|
224
|
-
if (!base.includes("localhost") && !base.includes("127.0.0.1")) {
|
|
225
|
-
base = base.replace("api.swiftbase", "identity.swiftbase");
|
|
226
|
-
}
|
|
227
224
|
const url = `${base}/oauth2/token`;
|
|
228
225
|
const response = yield fetch(url, {
|
|
229
226
|
method: "POST",
|
|
@@ -3901,15 +3898,6 @@ var makeRequest = (method, path, params, body) => __async(null, null, function*
|
|
|
3901
3898
|
headers["Authorization"] = `Bearer ${app.accessToken.value()}`;
|
|
3902
3899
|
}
|
|
3903
3900
|
let base = app.baseUrl || "https://api.swiftbase.io";
|
|
3904
|
-
if (!base.includes("localhost") && !base.includes("127.0.0.1")) {
|
|
3905
|
-
if (path.includes("/db/") || path.includes("/database") || path.includes("/tables") || path.includes("/sql") || path.includes("/queries")) {
|
|
3906
|
-
base = base.replace("api.swiftbase", "database.swiftbase");
|
|
3907
|
-
} else if (path.includes("/oauth2") || path.includes("/login") || path.includes("/api/roles") || path.includes("/api/services") || path.includes("/api/users") || path.includes("/api/me")) {
|
|
3908
|
-
base = base.replace("api.swiftbase", "identity.swiftbase");
|
|
3909
|
-
} else {
|
|
3910
|
-
base = base.replace("api.swiftbase", "app.swiftbase");
|
|
3911
|
-
}
|
|
3912
|
-
}
|
|
3913
3901
|
let url = path.startsWith("http") ? path : `${base}${!path.startsWith("/") ? "/" : ""}${path}`;
|
|
3914
3902
|
if (params) {
|
|
3915
3903
|
const query = new URLSearchParams();
|
|
@@ -3979,9 +3967,6 @@ var verifyToken = (token) => __async(null, null, function* () {
|
|
|
3979
3967
|
"Authorization": `Bearer ${token}`
|
|
3980
3968
|
};
|
|
3981
3969
|
let base = app.baseUrl || "https://api.swiftbase.io";
|
|
3982
|
-
if (!base.includes("localhost") && !base.includes("127.0.0.1")) {
|
|
3983
|
-
base = base.replace("api.swiftbase", "identity.swiftbase");
|
|
3984
|
-
}
|
|
3985
3970
|
const response = yield fetch(`${base}/api/me`, { headers });
|
|
3986
3971
|
if (!response.ok) {
|
|
3987
3972
|
throw new Error(`Token verification failed: ${response.status}`);
|
|
@@ -3993,9 +3978,6 @@ var verifyToken = (token) => __async(null, null, function* () {
|
|
|
3993
3978
|
init_app();
|
|
3994
3979
|
var verifyServiceToken = (token, scope) => __async(null, null, function* () {
|
|
3995
3980
|
let base = app.baseUrl || "https://api.swiftbase.io";
|
|
3996
|
-
if (!base.includes("localhost") && !base.includes("127.0.0.1")) {
|
|
3997
|
-
base = base.replace("api.swiftbase", "identity.swiftbase");
|
|
3998
|
-
}
|
|
3999
3981
|
const url = `${base}/api/verify-service-token`;
|
|
4000
3982
|
const response = yield fetch(url, {
|
|
4001
3983
|
method: "POST",
|
|
@@ -4613,10 +4595,7 @@ function signS3Request(options) {
|
|
|
4613
4595
|
// src/storage/storage.ts
|
|
4614
4596
|
function getDefaultEndpoint() {
|
|
4615
4597
|
const base = app.baseUrl || "https://api.swiftbase.io";
|
|
4616
|
-
|
|
4617
|
-
return "http://localhost:3006";
|
|
4618
|
-
}
|
|
4619
|
-
return base.replace("api.swiftbase", "storage.swiftbase");
|
|
4598
|
+
return base + "/storage";
|
|
4620
4599
|
}
|
|
4621
4600
|
function parseListBuckets(xml) {
|
|
4622
4601
|
const buckets = [];
|
|
@@ -4634,13 +4613,39 @@ function parseListBuckets(xml) {
|
|
|
4634
4613
|
}
|
|
4635
4614
|
return buckets;
|
|
4636
4615
|
}
|
|
4637
|
-
function parseListObjects(
|
|
4638
|
-
const
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4616
|
+
function parseListObjects(text) {
|
|
4617
|
+
const trimmed = text.trim();
|
|
4618
|
+
if (trimmed.startsWith("[") || trimmed.startsWith("{")) {
|
|
4619
|
+
try {
|
|
4620
|
+
const parsed = JSON.parse(trimmed);
|
|
4621
|
+
const items = Array.isArray(parsed) ? parsed : parsed.contents || [];
|
|
4622
|
+
const contents2 = items.map((item) => {
|
|
4623
|
+
const pathPrefix = item.path && item.path !== "/" ? item.path.replace(/\/$/, "") + "/" : "";
|
|
4624
|
+
const key = item.key || (item.name ? `${pathPrefix}${item.name}` : "");
|
|
4625
|
+
return {
|
|
4626
|
+
key,
|
|
4627
|
+
lastModified: item.modified || item.lastModified,
|
|
4628
|
+
etag: item.etag,
|
|
4629
|
+
size: item.size || 0
|
|
4630
|
+
};
|
|
4631
|
+
});
|
|
4632
|
+
return {
|
|
4633
|
+
name: "",
|
|
4634
|
+
prefix: "",
|
|
4635
|
+
maxKeys: contents2.length,
|
|
4636
|
+
isTruncated: false,
|
|
4637
|
+
contents: contents2,
|
|
4638
|
+
commonPrefixes: []
|
|
4639
|
+
};
|
|
4640
|
+
} catch (e) {
|
|
4641
|
+
}
|
|
4642
|
+
}
|
|
4643
|
+
const nameMatch = text.match(/<Name>(.*?)<\/Name>/);
|
|
4644
|
+
const prefixMatch = text.match(/<Prefix>(.*?)<\/Prefix>/);
|
|
4645
|
+
const maxKeysMatch = text.match(/<MaxKeys>(.*?)<\/MaxKeys>/);
|
|
4646
|
+
const isTruncatedMatch = text.match(/<IsTruncated>(.*?)<\/IsTruncated>/);
|
|
4642
4647
|
const contents = [];
|
|
4643
|
-
const contentMatches =
|
|
4648
|
+
const contentMatches = text.matchAll(/<Contents>([\s\S]*?)<\/Contents>/g);
|
|
4644
4649
|
for (const match of contentMatches) {
|
|
4645
4650
|
const content = match[1];
|
|
4646
4651
|
const keyMatch = content.match(/<Key>(.*?)<\/Key>/);
|
|
@@ -4657,11 +4662,11 @@ function parseListObjects(xml) {
|
|
|
4657
4662
|
}
|
|
4658
4663
|
}
|
|
4659
4664
|
const commonPrefixes = [];
|
|
4660
|
-
const cpMatches =
|
|
4665
|
+
const cpMatches = text.matchAll(/<CommonPrefixes>([\s\S]*?)<\/CommonPrefixes>/g);
|
|
4661
4666
|
for (const match of cpMatches) {
|
|
4662
|
-
const
|
|
4663
|
-
if (
|
|
4664
|
-
commonPrefixes.push(
|
|
4667
|
+
const pMatch = match[1].match(/<Prefix>(.*?)<\/Prefix>/);
|
|
4668
|
+
if (pMatch) {
|
|
4669
|
+
commonPrefixes.push(pMatch[1]);
|
|
4665
4670
|
}
|
|
4666
4671
|
}
|
|
4667
4672
|
return {
|
|
@@ -4830,7 +4835,11 @@ var ai = {
|
|
|
4830
4835
|
create: (options) => __async(null, null, function* () {
|
|
4831
4836
|
return yield makeRequest("post" /* POST */, "/api/ai/chat/completions", void 0, {
|
|
4832
4837
|
model: options.model || "gemini-3.5-flash",
|
|
4833
|
-
messages: options.messages
|
|
4838
|
+
messages: options.messages,
|
|
4839
|
+
tools: options.tools,
|
|
4840
|
+
tool_choice: options.tool_choice,
|
|
4841
|
+
temperature: options.temperature,
|
|
4842
|
+
max_tokens: options.max_tokens
|
|
4834
4843
|
});
|
|
4835
4844
|
})
|
|
4836
4845
|
}
|