@freehour/supabase-core 2.4.0 → 2.5.1
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/errors.d.ts +3 -3
- package/dist/errors.d.ts.map +1 -1
- package/dist/index.js +14 -14
- package/dist/storage.d.ts +3 -3
- package/dist/storage.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/json.d.ts +0 -4
- package/dist/json.d.ts.map +0 -1
package/dist/errors.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export interface FileNotFoundErrorOptions {
|
|
|
10
10
|
/**
|
|
11
11
|
* The ID of the file that was not found.
|
|
12
12
|
*/
|
|
13
|
-
|
|
13
|
+
id?: string;
|
|
14
14
|
/**
|
|
15
15
|
* The name of the bucket where the file was expected to be found.
|
|
16
16
|
*/
|
|
@@ -27,7 +27,7 @@ export declare class FileNotFoundError extends TracedError {
|
|
|
27
27
|
/**
|
|
28
28
|
* The ID of the file that was not found.
|
|
29
29
|
*/
|
|
30
|
-
readonly
|
|
30
|
+
readonly id?: string;
|
|
31
31
|
/**
|
|
32
32
|
* The name of the bucket where the file was expected to be found.
|
|
33
33
|
*/
|
|
@@ -36,7 +36,7 @@ export declare class FileNotFoundError extends TracedError {
|
|
|
36
36
|
* The path relative to the bucket root where the file was expected to be found.
|
|
37
37
|
*/
|
|
38
38
|
readonly path?: string;
|
|
39
|
-
constructor(message: string, {
|
|
39
|
+
constructor(message: string, { id, bucket, path, }?: FileNotFoundErrorOptions);
|
|
40
40
|
}
|
|
41
41
|
export interface ParseErrorOptions extends ErrorOptions {
|
|
42
42
|
/**
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../lib/errors.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGvD;;GAEG;AACH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,OAAO,EAAE,MAAM,EACf,EACI,UAAU,EACV,MAAM,EACN,GAAG,OAAO,EACb,GAAE,iBAAsB;CAMhC;AAGD,MAAM,WAAW,0BAA0B;IAEvC;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACxB;AAED;;;;;GAKG;AACH,qBAAa,mBAAoB,SAAQ,WAAW;IAEhD;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAE3B;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;gBAG1B,OAAO,EAAE,MAAM,EACf,EACI,MAAM,EACN,QAAQ,EACR,EAAE,GACL,GAAE,0BAA+B;CAOzC;AAED;;GAEG;AACH,eAAO,MAAM,uBAAuB;;;;;;iBAgB9B,CAAC;AAEP,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAE9E;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,cAAc,GAAG,uBAAuB,CAAC;AAExE,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,gBAAgB,CAE5E"}
|
package/dist/index.js
CHANGED
|
@@ -9,11 +9,11 @@ var i = class extends Error {
|
|
|
9
9
|
super(e, t), this.name = this.constructor.name, Error.captureStackTrace(this, this.constructor);
|
|
10
10
|
}
|
|
11
11
|
}, a = class extends i {
|
|
12
|
-
|
|
12
|
+
id;
|
|
13
13
|
bucket;
|
|
14
14
|
path;
|
|
15
|
-
constructor(e, {
|
|
16
|
-
super(e), this.
|
|
15
|
+
constructor(e, { id: t, bucket: n, path: r } = {}) {
|
|
16
|
+
super(e), this.id = t, this.bucket = n, this.path = r;
|
|
17
17
|
}
|
|
18
18
|
}, o = class extends i {
|
|
19
19
|
expression;
|
|
@@ -448,7 +448,7 @@ function j(e) {
|
|
|
448
448
|
return e.bucket !== void 0 && e.path !== void 0;
|
|
449
449
|
}
|
|
450
450
|
function M(e) {
|
|
451
|
-
return e.
|
|
451
|
+
return e.id !== void 0 && e.bucket !== void 0;
|
|
452
452
|
}
|
|
453
453
|
//#endregion
|
|
454
454
|
//#region lib/storage-service.ts
|
|
@@ -476,21 +476,21 @@ var N = class {
|
|
|
476
476
|
if (j(t)) {
|
|
477
477
|
let { id: e } = await this.getFileObject(t);
|
|
478
478
|
return {
|
|
479
|
-
|
|
479
|
+
id: e,
|
|
480
480
|
...t
|
|
481
481
|
};
|
|
482
482
|
}
|
|
483
|
-
let {
|
|
484
|
-
if (r === void 0) throw new a(`File with ID ${n} not found`, {
|
|
483
|
+
let { id: n } = t, r = await this.files.get(n, ["bucket_id", "path_tokens"]);
|
|
484
|
+
if (r === void 0) throw new a(`File with ID ${n} not found`, { id: n });
|
|
485
485
|
return {
|
|
486
|
-
|
|
486
|
+
id: n,
|
|
487
487
|
bucket: e.notNull(r.bucket_id, "bucket_id must not be null"),
|
|
488
488
|
path: e.notNull(r.path_tokens, "path_tokens must not be null").join("/")
|
|
489
489
|
};
|
|
490
490
|
}
|
|
491
491
|
async getFileInfo(t) {
|
|
492
492
|
let n = await this.getFileStorageLocation(t), { id: r, bucketId: i, metadata: a, ...o } = await this.getFileObject(n);
|
|
493
|
-
return e(r === n.
|
|
493
|
+
return e(r === n.id, "file ID from storage client must match file ID from database"), e(i === n.bucket, "bucketId from storage client must match bucket from database"), {
|
|
494
494
|
...o,
|
|
495
495
|
...n,
|
|
496
496
|
metadata: a,
|
|
@@ -521,24 +521,24 @@ var N = class {
|
|
|
521
521
|
let { data: i, error: a } = await this.client.from(t).upload(`${n}/${e.name}`, e, { upsert: r });
|
|
522
522
|
if (a) throw a;
|
|
523
523
|
return {
|
|
524
|
-
|
|
524
|
+
id: i.id,
|
|
525
525
|
bucket: t,
|
|
526
526
|
path: i.path
|
|
527
527
|
};
|
|
528
528
|
}
|
|
529
529
|
async downloadFile(e) {
|
|
530
|
-
let {
|
|
530
|
+
let { id: t, bucket: n, path: r, properties: i } = await this.getFileInfo(e), { data: a, error: o } = await this.client.from(n).download(r);
|
|
531
531
|
if (o) throw o;
|
|
532
532
|
let [, s] = u(r);
|
|
533
533
|
return {
|
|
534
|
-
|
|
534
|
+
id: t,
|
|
535
535
|
bucket: n,
|
|
536
536
|
path: r,
|
|
537
537
|
file: new File([a], s, i)
|
|
538
538
|
};
|
|
539
539
|
}
|
|
540
540
|
async deleteFiles(t) {
|
|
541
|
-
let n = t.filter((e) => "
|
|
541
|
+
let n = t.filter((e) => "id" in e).map((e) => e.id), r = (await this.files.query.select(["bucket_id", "path_tokens"]).containedBy("id", n).throwOnError()).data.map(({ bucket_id: t, path_tokens: n }) => ({
|
|
542
542
|
bucket: e.notNull(t, "bucket_id must not be null"),
|
|
543
543
|
path: e.notNull(n, "path_tokens must not be null").join("/")
|
|
544
544
|
})), i = m(f(t.filter((e) => j(e)).concat(r), (e) => e.bucket)).map(([e, t]) => ({
|
|
@@ -548,7 +548,7 @@ var N = class {
|
|
|
548
548
|
return (await Promise.all(i.map(async ({ bucket: t, paths: n }) => this.client.from(t).remove(n).then(({ data: r, error: i }) => {
|
|
549
549
|
if (i) throw i;
|
|
550
550
|
return r.map((r, i) => ({
|
|
551
|
-
|
|
551
|
+
id: e.notNull(r.id, "file id must not be null"),
|
|
552
552
|
bucket: t,
|
|
553
553
|
path: e.defined(n[i], "path must not be null")
|
|
554
554
|
}));
|
package/dist/storage.d.ts
CHANGED
|
@@ -6,12 +6,12 @@ export declare class StorageClient<BucketName extends string = string> extends S
|
|
|
6
6
|
}
|
|
7
7
|
export type StorageObject = Database['storage']['Tables']['objects']['Row'];
|
|
8
8
|
export interface StorageLocation<BucketName extends string = string> {
|
|
9
|
-
|
|
9
|
+
id: string;
|
|
10
10
|
bucket: BucketName;
|
|
11
11
|
path: string;
|
|
12
12
|
}
|
|
13
13
|
export interface FileID {
|
|
14
|
-
|
|
14
|
+
id: string;
|
|
15
15
|
}
|
|
16
16
|
export interface FilePointer<BucketName extends string = string> {
|
|
17
17
|
bucket: BucketName;
|
|
@@ -21,7 +21,7 @@ export type FileRef<BucketName extends string = string> = (FileID & {
|
|
|
21
21
|
bucket?: never;
|
|
22
22
|
path?: never;
|
|
23
23
|
}) | (FilePointer<BucketName> & {
|
|
24
|
-
|
|
24
|
+
id?: never;
|
|
25
25
|
}) | StorageLocation<BucketName>;
|
|
26
26
|
export interface FileInfo<BucketName extends string = string> extends OmitFrom<Camelize<FileObjectV2>, 'id' | 'bucketId'>, StorageLocation<BucketName> {
|
|
27
27
|
properties: FilePropertyBag;
|
package/dist/storage.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../lib/storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACrF,OAAO,EAAE,aAAa,IAAI,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAE9E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAGxC,MAAM,CAAC,OAAO,OAAO,aAAa,CAAC,UAAU,SAAS,MAAM,GAAG,MAAM,CAAE,SAAQ,qBAAqB;IAChG,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,GAAG,UAAU,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;CACtF;AAED,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,CAAC,K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IAAI,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC,GAC3C,CAAC,WAAW,CAAC,UAAU,CAAC,GAAG;IAAE,EAAE,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC,GAC1C,eAAe,CAAC,UAAU,CAAC,CAAC;AAElC,MAAM,WAAW,QAAQ,CAAC,UAAU,SAAS,MAAM,GAAG,MAAM,CAAE,SAAQ,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,IAAI,GAAG,UAAU,CAAC,EAAE,eAAe,CAAC,UAAU,CAAC;IAClJ,UAAU,EAAE,eAAe,CAAC;CAC/B;AAED,MAAM,WAAW,gBAAgB;IAC7B,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC5B,SAAS,CAAC,EAAE,gBAAgB,CAAC;CAChC;AAED,MAAM,WAAW,iBAAiB;IAC9B,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,MAAM,CAEpD;AAED,wBAAgB,aAAa,CAAC,UAAU,SAAS,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,GAAG,IAAI,WAAW,CAAC,UAAU,CAAC,CAEjH;AAED,wBAAgB,iBAAiB,CAAC,UAAU,SAAS,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,GAAG,IAAI,eAAe,CAAC,UAAU,CAAC,CAEzH"}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"private": false,
|
|
4
4
|
"displayName": "Supabase-Core",
|
|
5
5
|
"description": "Lightweight services for supabase to make it easier to work with databases, tables and storage buckets",
|
|
6
|
-
"version": "2.
|
|
6
|
+
"version": "2.5.1",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
package/dist/json.d.ts
DELETED
package/dist/json.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../lib/json.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAGjD,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,IAAI,GAAG,SAAS,CAAC,CAAC;AAE1D,YAAY,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC"}
|