edmaxlabs-core 1.1.6 → 1.1.7
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 +16 -39
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -11
- package/dist/index.d.ts +6 -11
- package/dist/index.mjs +16 -39
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
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
|
-
|
|
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
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
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
|
-
|
|
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
|
|
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/${
|
|
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
|
|
1468
|
+
return void 0;
|
|
1470
1469
|
const result = StorageSnapshot.fromMap(res.document);
|
|
1471
|
-
|
|
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/${
|
|
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
|
|
1485
|
+
return void 0;
|
|
1488
1486
|
const result = StorageSnapshot.fromMap(res.document);
|
|
1489
|
-
|
|
1490
|
-
return this;
|
|
1487
|
+
return result;
|
|
1491
1488
|
} else {
|
|
1492
1489
|
return null;
|
|
1493
1490
|
}
|
|
@@ -1504,34 +1501,18 @@ var StorageRef = class {
|
|
|
1504
1501
|
headers: {
|
|
1505
1502
|
authorization: this.db.getAuth.token,
|
|
1506
1503
|
...form.getHeaders()
|
|
1507
|
-
},
|
|
1508
|
-
body: {
|
|
1509
|
-
file_id: this.id
|
|
1510
1504
|
}
|
|
1511
1505
|
}).sendRequest();
|
|
1512
1506
|
if (res.success) {
|
|
1513
1507
|
if (res.document === void 0)
|
|
1514
|
-
return
|
|
1508
|
+
return void 0;
|
|
1515
1509
|
const result = StorageSnapshot.fromMap(res.document);
|
|
1516
|
-
|
|
1517
|
-
return this;
|
|
1510
|
+
return result;
|
|
1518
1511
|
} else {
|
|
1519
1512
|
return null;
|
|
1520
1513
|
}
|
|
1521
1514
|
}
|
|
1522
|
-
|
|
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() {
|
|
1515
|
+
async delete(id) {
|
|
1535
1516
|
const res = await new HttpsRequest({
|
|
1536
1517
|
method: "POST" /* POST */,
|
|
1537
1518
|
endpoint: this.db.getBaseUrl + "/storage/file/delete",
|
|
@@ -1539,7 +1520,7 @@ var StorageRef = class {
|
|
|
1539
1520
|
authorization: this.db.getAuth.token
|
|
1540
1521
|
},
|
|
1541
1522
|
body: {
|
|
1542
|
-
file_id:
|
|
1523
|
+
file_id: id
|
|
1543
1524
|
}
|
|
1544
1525
|
}).sendRequest();
|
|
1545
1526
|
return res;
|
|
@@ -1551,11 +1532,8 @@ var Storage = class {
|
|
|
1551
1532
|
constructor(app) {
|
|
1552
1533
|
this.app = app;
|
|
1553
1534
|
}
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
throw new Error("File ID is Invalid");
|
|
1557
|
-
}
|
|
1558
|
-
return new StorageRef(this.app, file_id);
|
|
1535
|
+
getStorage() {
|
|
1536
|
+
return new StorageRef(this.app);
|
|
1559
1537
|
}
|
|
1560
1538
|
};
|
|
1561
1539
|
|
|
@@ -1571,7 +1549,6 @@ var _EdmaxLabs = class _EdmaxLabs {
|
|
|
1571
1549
|
this.socketUrl = socketURI;
|
|
1572
1550
|
this.auth = { token, authToken, project };
|
|
1573
1551
|
this._db = new Database(this);
|
|
1574
|
-
this._storage = new Storage(this);
|
|
1575
1552
|
this._hosting = new Hosting(this);
|
|
1576
1553
|
this.realtime = new Realtime(this);
|
|
1577
1554
|
this.persistence_worker = new CollectionRef(this);
|
|
@@ -1603,7 +1580,7 @@ var _EdmaxLabs = class _EdmaxLabs {
|
|
|
1603
1580
|
return this._db;
|
|
1604
1581
|
}
|
|
1605
1582
|
get storage() {
|
|
1606
|
-
return this
|
|
1583
|
+
return new Storage(this);
|
|
1607
1584
|
}
|
|
1608
1585
|
get hosting() {
|
|
1609
1586
|
return this._hosting;
|