swiftbase-admin-sdk 1.0.1 → 1.0.3

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 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",
@@ -4416,15 +4398,6 @@ function db(dbName) {
4416
4398
  }
4417
4399
  const databaseId = myDb.id;
4418
4400
  const schemaName = dbName.toLowerCase().replace(/[^a-z0-9_]/g, "_");
4419
- try {
4420
- yield makeRequest("post" /* POST */, "/api/sql", void 0, {
4421
- databaseId,
4422
- sql: `CREATE SCHEMA IF NOT EXISTS "${schemaName}"`
4423
- });
4424
- } catch (err) {
4425
- console.error("[DatabaseInit] Failed to create schema:", err.message);
4426
- throw err;
4427
- }
4428
4401
  let existingTables = [];
4429
4402
  try {
4430
4403
  existingTables = yield makeRequest("get" /* GET */, "/api/tables", { databaseId });
@@ -4622,10 +4595,7 @@ function signS3Request(options) {
4622
4595
  // src/storage/storage.ts
4623
4596
  function getDefaultEndpoint() {
4624
4597
  const base = app.baseUrl || "https://api.swiftbase.io";
4625
- if (base.includes("localhost") || base.includes("127.0.0.1")) {
4626
- return "http://localhost:3006";
4627
- }
4628
- return base.replace("api.swiftbase", "storage.swiftbase");
4598
+ return base + "/storage";
4629
4599
  }
4630
4600
  function parseListBuckets(xml) {
4631
4601
  const buckets = [];