edmaxlabs-core 2.5.2 → 2.5.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 CHANGED
@@ -791,6 +791,10 @@ var Query = class {
791
791
  }
792
792
  };
793
793
 
794
+ // src/utils/constants.ts
795
+ var serverURI = "https://api.edmaxlabs.com/api/v2";
796
+ var socketURI = "https://api.edmaxlabs.com";
797
+
794
798
  // src/database/CollectionRef.ts
795
799
  var CollectionRef = class {
796
800
  constructor(app, collection) {
@@ -818,7 +822,7 @@ var CollectionRef = class {
818
822
  try {
819
823
  const res = await new HttpsRequest({
820
824
  method: "POST" /* POST */,
821
- endpoint: `${this.app.getBaseUrl()}/db/read`,
825
+ endpoint: `${serverURI}/db/read`,
822
826
  headers: {
823
827
  authorization: this.app.getConfig().token,
824
828
  "x-project": this.app.getConfig().project
@@ -846,7 +850,7 @@ var CollectionRef = class {
846
850
  try {
847
851
  const res = await new HttpsRequest({
848
852
  method: "POST" /* POST */,
849
- endpoint: `${this.app.getBaseUrl()}/db/read`,
853
+ endpoint: `${serverURI}/db/read`,
850
854
  headers: {
851
855
  authorization: this.app.getConfig().token,
852
856
  "x-project": this.app.getConfig().project
@@ -936,9 +940,10 @@ var CollectionRef = class {
936
940
 
937
941
  // src/database/Batch.ts
938
942
  var Batch = class {
939
- constructor(app) {
943
+ constructor(app, config) {
940
944
  this.ops = [];
941
945
  this.app = app;
946
+ this.config = config;
942
947
  }
943
948
  set(docRef, data) {
944
949
  this.ops.push({
@@ -1023,8 +1028,8 @@ var Batch = class {
1023
1028
  }
1024
1029
  const res = await new HttpsRequest({
1025
1030
  method: "POST" /* POST */,
1026
- endpoint: `${this.app.getBaseUrl()}/db/batch`,
1027
- headers: { authorization: this.app.getConfig().token, "x-project": this.app.getConfig().project },
1031
+ endpoint: `${serverURI}/db/batch`,
1032
+ headers: { authorization: this.config.token, "x-project": this.config.project },
1028
1033
  body: { ops: this.ops }
1029
1034
  }).sendRequest();
1030
1035
  if (res?.error) {
@@ -1050,7 +1055,7 @@ var Database = class {
1050
1055
  throw new Error("doc(path) expects format 'collection/documentId'");
1051
1056
  }
1052
1057
  batch() {
1053
- return new Batch(this.app);
1058
+ return new Batch(this.app, this.app.getConfig());
1054
1059
  }
1055
1060
  /**
1056
1061
  * Server-side transaction (unchanged, but improved error handling)
@@ -1261,15 +1266,15 @@ var Realtime = class {
1261
1266
 
1262
1267
  // src/functions/Functions.ts
1263
1268
  var Functions = class {
1264
- constructor(app) {
1265
- this.app = app;
1269
+ constructor(config) {
1270
+ this.config = config;
1266
1271
  }
1267
1272
  async call(functionName, data) {
1268
1273
  try {
1269
1274
  const res = await new HttpsRequest({
1270
1275
  method: "POST" /* POST */,
1271
- endpoint: this.app.getBaseUrl() + "/functions/call/" + functionName,
1272
- headers: { authorization: this.app.getConfig().token, "x-project": this.app.getConfig().project },
1276
+ endpoint: serverURI + "/functions/call/" + functionName,
1277
+ headers: { authorization: this.config.token, "x-project": this.config.project },
1273
1278
  body: data
1274
1279
  }).sendRequest();
1275
1280
  return res;
@@ -2283,13 +2288,14 @@ var StorageSnapshot = class _StorageSnapshot {
2283
2288
 
2284
2289
  // src/storage/StorageRef.ts
2285
2290
  var StorageRef = class {
2286
- constructor(app) {
2291
+ constructor(app, config) {
2287
2292
  this.app = app;
2293
+ this.config = config;
2288
2294
  }
2289
2295
  async get(id) {
2290
2296
  const res = await new HttpsRequest({
2291
2297
  method: "GET" /* GET */,
2292
- endpoint: this.app.getBaseUrl() + `/storage/${id}`,
2298
+ endpoint: serverURI + `/storage/${id}`,
2293
2299
  headers: {
2294
2300
  //authorization: this.app.getConfig.token,
2295
2301
  }
@@ -2306,7 +2312,7 @@ var StorageRef = class {
2306
2312
  async getMeta(id) {
2307
2313
  const res = await new HttpsRequest({
2308
2314
  method: "GET" /* GET */,
2309
- endpoint: this.app.getBaseUrl() + `/storage/${id}/info`,
2315
+ endpoint: serverURI + `/storage/${id}/info`,
2310
2316
  headers: {
2311
2317
  //authorization: this.app.getConfig.token,
2312
2318
  }
@@ -2327,8 +2333,8 @@ var StorageRef = class {
2327
2333
  console.log("SRCF");
2328
2334
  const res = await new HttpsRequest({
2329
2335
  method: "POST" /* POST */,
2330
- endpoint: this.app.getBaseUrl() + "/storage/file/upload",
2331
- headers: { authorization: this.app.getConfig().token, project: this.app.getConfig().project },
2336
+ endpoint: serverURI + "/storage/file/upload",
2337
+ headers: { authorization: this.config.token, "x-project": this.config.project },
2332
2338
  file: srcFile,
2333
2339
  isMultipart: true
2334
2340
  }).sendRequest();
@@ -2344,8 +2350,8 @@ var StorageRef = class {
2344
2350
  async delete(id) {
2345
2351
  const res = await new HttpsRequest({
2346
2352
  method: "POST" /* POST */,
2347
- endpoint: this.app.getBaseUrl() + "/storage/file/delete",
2348
- headers: { authorization: this.app.getConfig().token, "x-project": this.app.getConfig().project },
2353
+ endpoint: this.config + "/storage/file/delete",
2354
+ headers: { authorization: this.config.token, "x-project": this.config.project },
2349
2355
  body: {
2350
2356
  file_id: id
2351
2357
  }
@@ -2354,20 +2360,6 @@ var StorageRef = class {
2354
2360
  }
2355
2361
  };
2356
2362
 
2357
- // src/storage/Storage.ts
2358
- var Storage = class {
2359
- constructor(app) {
2360
- this.app = app;
2361
- }
2362
- getStorage() {
2363
- return new StorageRef(this.app);
2364
- }
2365
- };
2366
-
2367
- // src/utils/constants.ts
2368
- var serverURI = "https://api.edmaxlabs.com/api/v2";
2369
- var socketURI = "https://api.edmaxlabs.com";
2370
-
2371
2363
  // src/core/EdmaxLabs.ts
2372
2364
  var _EdmaxLabs = class _EdmaxLabs {
2373
2365
  constructor(config) {
@@ -2416,10 +2408,10 @@ var _EdmaxLabs = class _EdmaxLabs {
2416
2408
  return this._db;
2417
2409
  }
2418
2410
  get getFunctions() {
2419
- return new Functions(this);
2411
+ return new Functions(this._config);
2420
2412
  }
2421
2413
  get getStorage() {
2422
- return new Storage(this);
2414
+ return new StorageRef(this, this._config);
2423
2415
  }
2424
2416
  get getAuthentication() {
2425
2417
  if (!Authentication.instance) {