edmaxlabs-core 1.1.6 → 1.1.8

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.d.cts CHANGED
@@ -240,15 +240,11 @@ declare class StorageSnapshot {
240
240
 
241
241
  declare class StorageRef {
242
242
  db: EdmaxLabs;
243
- id: string;
244
- file: StorageSnapshot | undefined | null;
245
- constructor(db: EdmaxLabs, id: string);
246
- get(): Promise<StorageRef | null | undefined>;
247
- getMeta(): Promise<StorageRef | null | undefined>;
248
- upload(srcFile: File): Promise<StorageRef | null | undefined>;
249
- getBaseUrl(): string;
250
- getDownloadUrl(): string;
251
- delete(): Promise<{
243
+ constructor(db: EdmaxLabs);
244
+ get(id: string): Promise<StorageSnapshot | null | undefined>;
245
+ getMeta(id: string): Promise<StorageSnapshot | null | undefined>;
246
+ upload(srcFile: File): Promise<StorageSnapshot | null | undefined>;
247
+ delete(id: string): Promise<{
252
248
  success: boolean;
253
249
  error: string;
254
250
  }>;
@@ -257,7 +253,7 @@ declare class StorageRef {
257
253
  declare class Storage {
258
254
  app: EdmaxLabs;
259
255
  constructor(app: EdmaxLabs);
260
- get(file_id: string): StorageRef;
256
+ getStorage(): StorageRef;
261
257
  }
262
258
 
263
259
  interface EdmaxLabsConfig {
@@ -271,7 +267,6 @@ declare class EdmaxLabs {
271
267
  private socketUrl;
272
268
  private auth;
273
269
  private _db;
274
- private _storage;
275
270
  private _hosting;
276
271
  private realtime;
277
272
  private persistence;
package/dist/index.d.ts CHANGED
@@ -240,15 +240,11 @@ declare class StorageSnapshot {
240
240
 
241
241
  declare class StorageRef {
242
242
  db: EdmaxLabs;
243
- id: string;
244
- file: StorageSnapshot | undefined | null;
245
- constructor(db: EdmaxLabs, id: string);
246
- get(): Promise<StorageRef | null | undefined>;
247
- getMeta(): Promise<StorageRef | null | undefined>;
248
- upload(srcFile: File): Promise<StorageRef | null | undefined>;
249
- getBaseUrl(): string;
250
- getDownloadUrl(): string;
251
- delete(): Promise<{
243
+ constructor(db: EdmaxLabs);
244
+ get(id: string): Promise<StorageSnapshot | null | undefined>;
245
+ getMeta(id: string): Promise<StorageSnapshot | null | undefined>;
246
+ upload(srcFile: File): Promise<StorageSnapshot | null | undefined>;
247
+ delete(id: string): Promise<{
252
248
  success: boolean;
253
249
  error: string;
254
250
  }>;
@@ -257,7 +253,7 @@ declare class StorageRef {
257
253
  declare class Storage {
258
254
  app: EdmaxLabs;
259
255
  constructor(app: EdmaxLabs);
260
- get(file_id: string): StorageRef;
256
+ getStorage(): StorageRef;
261
257
  }
262
258
 
263
259
  interface EdmaxLabsConfig {
@@ -271,7 +267,6 @@ declare class EdmaxLabs {
271
267
  private socketUrl;
272
268
  private auth;
273
269
  private _db;
274
- private _storage;
275
270
  private _hosting;
276
271
  private realtime;
277
272
  private persistence;
package/dist/index.mjs CHANGED
@@ -1452,42 +1452,39 @@ var StorageSnapshot = class _StorageSnapshot {
1452
1452
  // src/storage/StorageRef.ts
1453
1453
  import FormData2 from "form-data";
1454
1454
  var StorageRef = class {
1455
- constructor(db, id) {
1455
+ constructor(db) {
1456
1456
  this.db = db;
1457
- this.id = id;
1458
1457
  }
1459
- async get() {
1458
+ async get(id) {
1460
1459
  const res = await new HttpsRequest({
1461
1460
  method: "GET" /* GET */,
1462
- endpoint: this.db.getBaseUrl + `/storage/${this.id}`,
1461
+ endpoint: this.db.getBaseUrl + `/storage/${id}`,
1463
1462
  headers: {
1464
1463
  //authorization: this.db.getAuth.token,
1465
1464
  }
1466
1465
  }).sendRequest();
1467
1466
  if (res.success) {
1468
1467
  if (res.document === void 0)
1469
- return this;
1468
+ return void 0;
1470
1469
  const result = StorageSnapshot.fromMap(res.document);
1471
- this.file = result;
1472
- return this;
1470
+ return result;
1473
1471
  } else {
1474
1472
  return null;
1475
1473
  }
1476
1474
  }
1477
- async getMeta() {
1475
+ async getMeta(id) {
1478
1476
  const res = await new HttpsRequest({
1479
1477
  method: "GET" /* GET */,
1480
- endpoint: this.db.getBaseUrl + `/storage/${this.id}/info`,
1478
+ endpoint: this.db.getBaseUrl + `/storage/${id}/info`,
1481
1479
  headers: {
1482
1480
  //authorization: this.db.getAuth.token,
1483
1481
  }
1484
1482
  }).sendRequest();
1485
1483
  if (res.success) {
1486
1484
  if (res.document === void 0)
1487
- return this;
1485
+ return void 0;
1488
1486
  const result = StorageSnapshot.fromMap(res.document);
1489
- this.file = result;
1490
- return this;
1487
+ return result;
1491
1488
  } else {
1492
1489
  return null;
1493
1490
  }
@@ -1502,36 +1499,19 @@ var StorageRef = class {
1502
1499
  method: "POST" /* POST */,
1503
1500
  endpoint: this.db.getBaseUrl + "/storage/file/upload",
1504
1501
  headers: {
1505
- authorization: this.db.getAuth.token,
1506
- ...form.getHeaders()
1507
- },
1508
- body: {
1509
- file_id: this.id
1502
+ authorization: this.db.getAuth.token
1510
1503
  }
1511
1504
  }).sendRequest();
1512
1505
  if (res.success) {
1513
1506
  if (res.document === void 0)
1514
- return this;
1507
+ return void 0;
1515
1508
  const result = StorageSnapshot.fromMap(res.document);
1516
- this.file = result;
1517
- return this;
1509
+ return result;
1518
1510
  } else {
1519
1511
  return null;
1520
1512
  }
1521
1513
  }
1522
- getBaseUrl() {
1523
- if (this.file) {
1524
- return `https://api.edmaxlabs.com/storage/${this.file.id}`;
1525
- }
1526
- return "";
1527
- }
1528
- getDownloadUrl() {
1529
- if (this.file) {
1530
- return `https://api.edmaxlabs.com/storage/d/${this.file.id}`;
1531
- }
1532
- return "";
1533
- }
1534
- async delete() {
1514
+ async delete(id) {
1535
1515
  const res = await new HttpsRequest({
1536
1516
  method: "POST" /* POST */,
1537
1517
  endpoint: this.db.getBaseUrl + "/storage/file/delete",
@@ -1539,7 +1519,7 @@ var StorageRef = class {
1539
1519
  authorization: this.db.getAuth.token
1540
1520
  },
1541
1521
  body: {
1542
- file_id: this.id
1522
+ file_id: id
1543
1523
  }
1544
1524
  }).sendRequest();
1545
1525
  return res;
@@ -1551,11 +1531,8 @@ var Storage = class {
1551
1531
  constructor(app) {
1552
1532
  this.app = app;
1553
1533
  }
1554
- get(file_id) {
1555
- if (!file_id || file_id === "") {
1556
- throw new Error("File ID is Invalid");
1557
- }
1558
- return new StorageRef(this.app, file_id);
1534
+ getStorage() {
1535
+ return new StorageRef(this.app);
1559
1536
  }
1560
1537
  };
1561
1538
 
@@ -1571,7 +1548,6 @@ var _EdmaxLabs = class _EdmaxLabs {
1571
1548
  this.socketUrl = socketURI;
1572
1549
  this.auth = { token, authToken, project };
1573
1550
  this._db = new Database(this);
1574
- this._storage = new Storage(this);
1575
1551
  this._hosting = new Hosting(this);
1576
1552
  this.realtime = new Realtime(this);
1577
1553
  this.persistence_worker = new CollectionRef(this);
@@ -1603,7 +1579,7 @@ var _EdmaxLabs = class _EdmaxLabs {
1603
1579
  return this._db;
1604
1580
  }
1605
1581
  get storage() {
1606
- return this._storage;
1582
+ return new Storage(this);
1607
1583
  }
1608
1584
  get hosting() {
1609
1585
  return this._hosting;