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 +25 -33
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -12
- package/dist/index.d.ts +8 -12
- package/dist/index.mjs +25 -33
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -206,8 +206,9 @@ declare class CollectionRef {
|
|
|
206
206
|
|
|
207
207
|
declare class Batch {
|
|
208
208
|
private app;
|
|
209
|
+
private config;
|
|
209
210
|
private ops;
|
|
210
|
-
constructor(app: EdmaxLabs);
|
|
211
|
+
constructor(app: EdmaxLabs, config: EdmaxLabsConfig);
|
|
211
212
|
set(docRef: DocumentRef, data: any): Batch;
|
|
212
213
|
create(docRef: DocumentRef, data: any): Batch;
|
|
213
214
|
update(docRef: DocumentRef, data: any): Batch;
|
|
@@ -273,8 +274,8 @@ declare class Realtime {
|
|
|
273
274
|
}
|
|
274
275
|
|
|
275
276
|
declare class Functions {
|
|
276
|
-
|
|
277
|
-
constructor(
|
|
277
|
+
private config;
|
|
278
|
+
constructor(config: EdmaxLabsConfig);
|
|
278
279
|
call(functionName: string, data?: Record<string, any>): Promise<any>;
|
|
279
280
|
}
|
|
280
281
|
|
|
@@ -413,8 +414,9 @@ declare class StorageSnapshot {
|
|
|
413
414
|
}
|
|
414
415
|
|
|
415
416
|
declare class StorageRef {
|
|
416
|
-
app
|
|
417
|
-
|
|
417
|
+
private app;
|
|
418
|
+
private config;
|
|
419
|
+
constructor(app: EdmaxLabs, config: EdmaxLabsConfig);
|
|
418
420
|
get(id: string): Promise<StorageSnapshot | null | undefined>;
|
|
419
421
|
getMeta(id: string): Promise<StorageSnapshot | null | undefined>;
|
|
420
422
|
upload(srcFile: File): Promise<StorageSnapshot | null | undefined>;
|
|
@@ -424,12 +426,6 @@ declare class StorageRef {
|
|
|
424
426
|
}>;
|
|
425
427
|
}
|
|
426
428
|
|
|
427
|
-
declare class Storage {
|
|
428
|
-
app: EdmaxLabs;
|
|
429
|
-
constructor(app: EdmaxLabs);
|
|
430
|
-
getStorage(): StorageRef;
|
|
431
|
-
}
|
|
432
|
-
|
|
433
429
|
interface EdmaxLabsConfig {
|
|
434
430
|
token: string;
|
|
435
431
|
project: string;
|
|
@@ -456,7 +452,7 @@ declare class EdmaxLabs {
|
|
|
456
452
|
static initialize(config: EdmaxLabsConfig): EdmaxLabs;
|
|
457
453
|
get getDatabase(): Database;
|
|
458
454
|
get getFunctions(): Functions;
|
|
459
|
-
get getStorage():
|
|
455
|
+
get getStorage(): StorageRef;
|
|
460
456
|
get getAuthentication(): Authentication;
|
|
461
457
|
/** Check if offline features are enabled */
|
|
462
458
|
get isOfflineEnabled(): boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -206,8 +206,9 @@ declare class CollectionRef {
|
|
|
206
206
|
|
|
207
207
|
declare class Batch {
|
|
208
208
|
private app;
|
|
209
|
+
private config;
|
|
209
210
|
private ops;
|
|
210
|
-
constructor(app: EdmaxLabs);
|
|
211
|
+
constructor(app: EdmaxLabs, config: EdmaxLabsConfig);
|
|
211
212
|
set(docRef: DocumentRef, data: any): Batch;
|
|
212
213
|
create(docRef: DocumentRef, data: any): Batch;
|
|
213
214
|
update(docRef: DocumentRef, data: any): Batch;
|
|
@@ -273,8 +274,8 @@ declare class Realtime {
|
|
|
273
274
|
}
|
|
274
275
|
|
|
275
276
|
declare class Functions {
|
|
276
|
-
|
|
277
|
-
constructor(
|
|
277
|
+
private config;
|
|
278
|
+
constructor(config: EdmaxLabsConfig);
|
|
278
279
|
call(functionName: string, data?: Record<string, any>): Promise<any>;
|
|
279
280
|
}
|
|
280
281
|
|
|
@@ -413,8 +414,9 @@ declare class StorageSnapshot {
|
|
|
413
414
|
}
|
|
414
415
|
|
|
415
416
|
declare class StorageRef {
|
|
416
|
-
app
|
|
417
|
-
|
|
417
|
+
private app;
|
|
418
|
+
private config;
|
|
419
|
+
constructor(app: EdmaxLabs, config: EdmaxLabsConfig);
|
|
418
420
|
get(id: string): Promise<StorageSnapshot | null | undefined>;
|
|
419
421
|
getMeta(id: string): Promise<StorageSnapshot | null | undefined>;
|
|
420
422
|
upload(srcFile: File): Promise<StorageSnapshot | null | undefined>;
|
|
@@ -424,12 +426,6 @@ declare class StorageRef {
|
|
|
424
426
|
}>;
|
|
425
427
|
}
|
|
426
428
|
|
|
427
|
-
declare class Storage {
|
|
428
|
-
app: EdmaxLabs;
|
|
429
|
-
constructor(app: EdmaxLabs);
|
|
430
|
-
getStorage(): StorageRef;
|
|
431
|
-
}
|
|
432
|
-
|
|
433
429
|
interface EdmaxLabsConfig {
|
|
434
430
|
token: string;
|
|
435
431
|
project: string;
|
|
@@ -456,7 +452,7 @@ declare class EdmaxLabs {
|
|
|
456
452
|
static initialize(config: EdmaxLabsConfig): EdmaxLabs;
|
|
457
453
|
get getDatabase(): Database;
|
|
458
454
|
get getFunctions(): Functions;
|
|
459
|
-
get getStorage():
|
|
455
|
+
get getStorage(): StorageRef;
|
|
460
456
|
get getAuthentication(): Authentication;
|
|
461
457
|
/** Check if offline features are enabled */
|
|
462
458
|
get isOfflineEnabled(): boolean;
|
package/dist/index.mjs
CHANGED
|
@@ -759,6 +759,10 @@ var Query = class {
|
|
|
759
759
|
}
|
|
760
760
|
};
|
|
761
761
|
|
|
762
|
+
// src/utils/constants.ts
|
|
763
|
+
var serverURI = "https://api.edmaxlabs.com/api/v2";
|
|
764
|
+
var socketURI = "https://api.edmaxlabs.com";
|
|
765
|
+
|
|
762
766
|
// src/database/CollectionRef.ts
|
|
763
767
|
var CollectionRef = class {
|
|
764
768
|
constructor(app, collection) {
|
|
@@ -786,7 +790,7 @@ var CollectionRef = class {
|
|
|
786
790
|
try {
|
|
787
791
|
const res = await new HttpsRequest({
|
|
788
792
|
method: "POST" /* POST */,
|
|
789
|
-
endpoint: `${
|
|
793
|
+
endpoint: `${serverURI}/db/read`,
|
|
790
794
|
headers: {
|
|
791
795
|
authorization: this.app.getConfig().token,
|
|
792
796
|
"x-project": this.app.getConfig().project
|
|
@@ -814,7 +818,7 @@ var CollectionRef = class {
|
|
|
814
818
|
try {
|
|
815
819
|
const res = await new HttpsRequest({
|
|
816
820
|
method: "POST" /* POST */,
|
|
817
|
-
endpoint: `${
|
|
821
|
+
endpoint: `${serverURI}/db/read`,
|
|
818
822
|
headers: {
|
|
819
823
|
authorization: this.app.getConfig().token,
|
|
820
824
|
"x-project": this.app.getConfig().project
|
|
@@ -904,9 +908,10 @@ var CollectionRef = class {
|
|
|
904
908
|
|
|
905
909
|
// src/database/Batch.ts
|
|
906
910
|
var Batch = class {
|
|
907
|
-
constructor(app) {
|
|
911
|
+
constructor(app, config) {
|
|
908
912
|
this.ops = [];
|
|
909
913
|
this.app = app;
|
|
914
|
+
this.config = config;
|
|
910
915
|
}
|
|
911
916
|
set(docRef, data) {
|
|
912
917
|
this.ops.push({
|
|
@@ -991,8 +996,8 @@ var Batch = class {
|
|
|
991
996
|
}
|
|
992
997
|
const res = await new HttpsRequest({
|
|
993
998
|
method: "POST" /* POST */,
|
|
994
|
-
endpoint: `${
|
|
995
|
-
headers: { authorization: this.
|
|
999
|
+
endpoint: `${serverURI}/db/batch`,
|
|
1000
|
+
headers: { authorization: this.config.token, "x-project": this.config.project },
|
|
996
1001
|
body: { ops: this.ops }
|
|
997
1002
|
}).sendRequest();
|
|
998
1003
|
if (res?.error) {
|
|
@@ -1018,7 +1023,7 @@ var Database = class {
|
|
|
1018
1023
|
throw new Error("doc(path) expects format 'collection/documentId'");
|
|
1019
1024
|
}
|
|
1020
1025
|
batch() {
|
|
1021
|
-
return new Batch(this.app);
|
|
1026
|
+
return new Batch(this.app, this.app.getConfig());
|
|
1022
1027
|
}
|
|
1023
1028
|
/**
|
|
1024
1029
|
* Server-side transaction (unchanged, but improved error handling)
|
|
@@ -1229,15 +1234,15 @@ var Realtime = class {
|
|
|
1229
1234
|
|
|
1230
1235
|
// src/functions/Functions.ts
|
|
1231
1236
|
var Functions = class {
|
|
1232
|
-
constructor(
|
|
1233
|
-
this.
|
|
1237
|
+
constructor(config) {
|
|
1238
|
+
this.config = config;
|
|
1234
1239
|
}
|
|
1235
1240
|
async call(functionName, data) {
|
|
1236
1241
|
try {
|
|
1237
1242
|
const res = await new HttpsRequest({
|
|
1238
1243
|
method: "POST" /* POST */,
|
|
1239
|
-
endpoint:
|
|
1240
|
-
headers: { authorization: this.
|
|
1244
|
+
endpoint: serverURI + "/functions/call/" + functionName,
|
|
1245
|
+
headers: { authorization: this.config.token, "x-project": this.config.project },
|
|
1241
1246
|
body: data
|
|
1242
1247
|
}).sendRequest();
|
|
1243
1248
|
return res;
|
|
@@ -2251,13 +2256,14 @@ var StorageSnapshot = class _StorageSnapshot {
|
|
|
2251
2256
|
|
|
2252
2257
|
// src/storage/StorageRef.ts
|
|
2253
2258
|
var StorageRef = class {
|
|
2254
|
-
constructor(app) {
|
|
2259
|
+
constructor(app, config) {
|
|
2255
2260
|
this.app = app;
|
|
2261
|
+
this.config = config;
|
|
2256
2262
|
}
|
|
2257
2263
|
async get(id) {
|
|
2258
2264
|
const res = await new HttpsRequest({
|
|
2259
2265
|
method: "GET" /* GET */,
|
|
2260
|
-
endpoint:
|
|
2266
|
+
endpoint: serverURI + `/storage/${id}`,
|
|
2261
2267
|
headers: {
|
|
2262
2268
|
//authorization: this.app.getConfig.token,
|
|
2263
2269
|
}
|
|
@@ -2274,7 +2280,7 @@ var StorageRef = class {
|
|
|
2274
2280
|
async getMeta(id) {
|
|
2275
2281
|
const res = await new HttpsRequest({
|
|
2276
2282
|
method: "GET" /* GET */,
|
|
2277
|
-
endpoint:
|
|
2283
|
+
endpoint: serverURI + `/storage/${id}/info`,
|
|
2278
2284
|
headers: {
|
|
2279
2285
|
//authorization: this.app.getConfig.token,
|
|
2280
2286
|
}
|
|
@@ -2295,8 +2301,8 @@ var StorageRef = class {
|
|
|
2295
2301
|
console.log("SRCF");
|
|
2296
2302
|
const res = await new HttpsRequest({
|
|
2297
2303
|
method: "POST" /* POST */,
|
|
2298
|
-
endpoint:
|
|
2299
|
-
headers: { authorization: this.
|
|
2304
|
+
endpoint: serverURI + "/storage/file/upload",
|
|
2305
|
+
headers: { authorization: this.config.token, "x-project": this.config.project },
|
|
2300
2306
|
file: srcFile,
|
|
2301
2307
|
isMultipart: true
|
|
2302
2308
|
}).sendRequest();
|
|
@@ -2312,8 +2318,8 @@ var StorageRef = class {
|
|
|
2312
2318
|
async delete(id) {
|
|
2313
2319
|
const res = await new HttpsRequest({
|
|
2314
2320
|
method: "POST" /* POST */,
|
|
2315
|
-
endpoint: this.
|
|
2316
|
-
headers: { authorization: this.
|
|
2321
|
+
endpoint: this.config + "/storage/file/delete",
|
|
2322
|
+
headers: { authorization: this.config.token, "x-project": this.config.project },
|
|
2317
2323
|
body: {
|
|
2318
2324
|
file_id: id
|
|
2319
2325
|
}
|
|
@@ -2322,20 +2328,6 @@ var StorageRef = class {
|
|
|
2322
2328
|
}
|
|
2323
2329
|
};
|
|
2324
2330
|
|
|
2325
|
-
// src/storage/Storage.ts
|
|
2326
|
-
var Storage = class {
|
|
2327
|
-
constructor(app) {
|
|
2328
|
-
this.app = app;
|
|
2329
|
-
}
|
|
2330
|
-
getStorage() {
|
|
2331
|
-
return new StorageRef(this.app);
|
|
2332
|
-
}
|
|
2333
|
-
};
|
|
2334
|
-
|
|
2335
|
-
// src/utils/constants.ts
|
|
2336
|
-
var serverURI = "https://api.edmaxlabs.com/api/v2";
|
|
2337
|
-
var socketURI = "https://api.edmaxlabs.com";
|
|
2338
|
-
|
|
2339
2331
|
// src/core/EdmaxLabs.ts
|
|
2340
2332
|
var _EdmaxLabs = class _EdmaxLabs {
|
|
2341
2333
|
constructor(config) {
|
|
@@ -2384,10 +2376,10 @@ var _EdmaxLabs = class _EdmaxLabs {
|
|
|
2384
2376
|
return this._db;
|
|
2385
2377
|
}
|
|
2386
2378
|
get getFunctions() {
|
|
2387
|
-
return new Functions(this);
|
|
2379
|
+
return new Functions(this._config);
|
|
2388
2380
|
}
|
|
2389
2381
|
get getStorage() {
|
|
2390
|
-
return new
|
|
2382
|
+
return new StorageRef(this, this._config);
|
|
2391
2383
|
}
|
|
2392
2384
|
get getAuthentication() {
|
|
2393
2385
|
if (!Authentication.instance) {
|