@freehour/supabase-core 2.5.1 → 2.5.3
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 +16 -31
- package/dist/errors.d.ts.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -14
- package/dist/storage-service.d.ts.map +1 -1
- package/package.json +10 -10
package/dist/errors.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { default as z } from 'zod';
|
|
2
2
|
import { PostgrestError } from '@supabase/supabase-js';
|
|
3
|
+
import { FileRef } from './storage';
|
|
3
4
|
/**
|
|
4
5
|
* Automatically sets the name and captures the stack trace for the error.
|
|
5
6
|
*/
|
|
@@ -8,41 +9,25 @@ export declare class TracedError extends Error {
|
|
|
8
9
|
}
|
|
9
10
|
export interface FileNotFoundErrorOptions {
|
|
10
11
|
/**
|
|
11
|
-
*
|
|
12
|
+
* A reference to the file that was expected to be found.
|
|
12
13
|
*/
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* The name of the bucket where the file was expected to be found.
|
|
16
|
-
*/
|
|
17
|
-
bucket?: string;
|
|
18
|
-
/**
|
|
19
|
-
* The path relative to the bucket root where the file was expected to be found.
|
|
20
|
-
*/
|
|
21
|
-
path?: string;
|
|
14
|
+
ref: FileRef;
|
|
22
15
|
}
|
|
23
16
|
/**
|
|
24
17
|
* Error indicating that a file with a specified ID could not be found in storage.
|
|
25
18
|
*/
|
|
26
19
|
export declare class FileNotFoundError extends TracedError {
|
|
27
20
|
/**
|
|
28
|
-
*
|
|
29
|
-
*/
|
|
30
|
-
readonly id?: string;
|
|
31
|
-
/**
|
|
32
|
-
* The name of the bucket where the file was expected to be found.
|
|
33
|
-
*/
|
|
34
|
-
readonly bucket?: string;
|
|
35
|
-
/**
|
|
36
|
-
* The path relative to the bucket root where the file was expected to be found.
|
|
21
|
+
* A reference to the file that was expected to be found.
|
|
37
22
|
*/
|
|
38
|
-
readonly
|
|
39
|
-
constructor(message: string, {
|
|
23
|
+
readonly ref: FileRef;
|
|
24
|
+
constructor(message: string, { ref, }: FileNotFoundErrorOptions);
|
|
40
25
|
}
|
|
41
26
|
export interface ParseErrorOptions extends ErrorOptions {
|
|
42
27
|
/**
|
|
43
28
|
* The encountered expression that could not be parsed.
|
|
44
29
|
*/
|
|
45
|
-
expression
|
|
30
|
+
expression: string;
|
|
46
31
|
/**
|
|
47
32
|
* Additional context about the expected format or structure.
|
|
48
33
|
*/
|
|
@@ -55,26 +40,26 @@ export declare class ParseError extends TracedError {
|
|
|
55
40
|
/**
|
|
56
41
|
* The encountered expression that could not be parsed.
|
|
57
42
|
*/
|
|
58
|
-
readonly expression
|
|
43
|
+
readonly expression: string;
|
|
59
44
|
/**
|
|
60
45
|
* Additional context about the expected format or structure.
|
|
61
46
|
*/
|
|
62
47
|
readonly format?: unknown;
|
|
63
|
-
constructor(message: string, { expression, format, ...options }
|
|
48
|
+
constructor(message: string, { expression, format, ...options }: ParseErrorOptions);
|
|
64
49
|
}
|
|
65
50
|
export interface RecordNotFoundErrorOptions {
|
|
66
51
|
/**
|
|
67
52
|
* The schema where the record was expected to be found.
|
|
68
53
|
*/
|
|
69
|
-
schema
|
|
54
|
+
schema: string;
|
|
70
55
|
/**
|
|
71
56
|
* The table or view where the record was expected to be found.
|
|
72
57
|
*/
|
|
73
|
-
relation
|
|
58
|
+
relation: string;
|
|
74
59
|
/**
|
|
75
60
|
* The ID of the record that was not found.
|
|
76
61
|
*/
|
|
77
|
-
id
|
|
62
|
+
id: string | number;
|
|
78
63
|
}
|
|
79
64
|
/**
|
|
80
65
|
* Error indicating that a record with a specified ID could not be found in a database table or view.
|
|
@@ -86,16 +71,16 @@ export declare class RecordNotFoundError extends TracedError {
|
|
|
86
71
|
/**
|
|
87
72
|
* The schema where the record was expected to be found.
|
|
88
73
|
*/
|
|
89
|
-
readonly schema
|
|
74
|
+
readonly schema: string;
|
|
90
75
|
/**
|
|
91
76
|
* The table or view where the record was expected to be found.
|
|
92
77
|
*/
|
|
93
|
-
readonly relation
|
|
78
|
+
readonly relation: string;
|
|
94
79
|
/**
|
|
95
80
|
* The ID of the record that was not found.
|
|
96
81
|
*/
|
|
97
|
-
readonly id
|
|
98
|
-
constructor(message: string, { schema, relation, id, }
|
|
82
|
+
readonly id: string | number;
|
|
83
|
+
constructor(message: string, { schema, relation, id, }: RecordNotFoundErrorOptions);
|
|
99
84
|
}
|
|
100
85
|
/**
|
|
101
86
|
* PostgREST errors are sometimes returned in this format instead of the declared PostgrestError class.
|
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;
|
|
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;AAEvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGzC;;GAEG;AACH,qBAAa,WAAY,SAAQ,KAAK;gBACtB,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB;CAK3D;AAGD,MAAM,WAAW,wBAAwB;IAErC;;OAEG;IACH,GAAG,EAAE,OAAO,CAAC;CAChB;AAED;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,WAAW;IAE9C;;OAEG;IACH,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC;gBAGlB,OAAO,EAAE,MAAM,EACf,EACI,GAAG,GACN,EAAE,wBAAwB;CAKlC;AAGD,MAAM,WAAW,iBAAkB,SAAQ,YAAY;IAEnD;;OAEG;IACH,UAAU,EAAE,MAAM,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ib/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,mBAAmB,YAAY,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,UAAU,CAAC;AACzB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,mBAAmB,YAAY,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,mBAAmB,WAAW,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -9,23 +9,21 @@ 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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
constructor(e, { id: t, bucket: n, path: r } = {}) {
|
|
16
|
-
super(e), this.id = t, this.bucket = n, this.path = r;
|
|
12
|
+
ref;
|
|
13
|
+
constructor(e, { ref: t }) {
|
|
14
|
+
super(e), this.ref = t;
|
|
17
15
|
}
|
|
18
16
|
}, o = class extends i {
|
|
19
17
|
expression;
|
|
20
18
|
format;
|
|
21
|
-
constructor(e, { expression: t, format: n, ...r }
|
|
19
|
+
constructor(e, { expression: t, format: n, ...r }) {
|
|
22
20
|
super(e, r), this.expression = t, this.format = n;
|
|
23
21
|
}
|
|
24
22
|
}, s = class extends i {
|
|
25
23
|
schema;
|
|
26
24
|
relation;
|
|
27
25
|
id;
|
|
28
|
-
constructor(e, { schema: t, relation: n, id: r }
|
|
26
|
+
constructor(e, { schema: t, relation: n, id: r }) {
|
|
29
27
|
super(e), this.schema = t, this.relation = n, this.id = r;
|
|
30
28
|
}
|
|
31
29
|
}, c = t.object({
|
|
@@ -481,7 +479,7 @@ var N = class {
|
|
|
481
479
|
};
|
|
482
480
|
}
|
|
483
481
|
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`, {
|
|
482
|
+
if (r === void 0) throw new a(`File with ID ${n} not found`, { ref: t });
|
|
485
483
|
return {
|
|
486
484
|
id: n,
|
|
487
485
|
bucket: e.notNull(r.bucket_id, "bucket_id must not be null"),
|
|
@@ -510,12 +508,9 @@ var N = class {
|
|
|
510
508
|
return r;
|
|
511
509
|
}
|
|
512
510
|
async assertExistsFile(e) {
|
|
513
|
-
let { bucket:
|
|
514
|
-
if (
|
|
515
|
-
if (!
|
|
516
|
-
bucket: t,
|
|
517
|
-
path: n
|
|
518
|
-
});
|
|
511
|
+
let t = await this.getFileStorageLocation(e), { bucket: n, path: r } = t, { data: i, error: o } = await this.client.from(n).exists(r);
|
|
512
|
+
if (o) throw o;
|
|
513
|
+
if (!i) throw new a(`File not found in bucket '${n}' at path '${r}'`, { ref: t });
|
|
519
514
|
}
|
|
520
515
|
async uploadFile(e, { bucket: t, path: n }, { overwriteExisting: r = !1 } = {}) {
|
|
521
516
|
let { data: i, error: a } = await this.client.from(t).upload(`${n}/${e.name}`, e, { upsert: r });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-service.d.ts","sourceRoot":"","sources":["../lib/storage-service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAA0B,eAAe,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAIpG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1D,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAKrI,MAAM,WAAW,oBAAoB,CACjC,UAAU,SAAS,MAAM,GAAG,MAAM;IAElC,MAAM,EAAE,aAAa,CAAC,UAAU,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,GACtD,OAAO,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;IAsBjC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC,UAAU,CAAC,GAAG;QAAE,IAAI,EAAE,IAAI,CAAA;KAAE,CAAC;IAoBjG,WAAW,CAAC,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,GAAG,OAAO,CAAC,eAAe,CAAC,UAAU,CAAC,EAAE,CAAC;CA2C7F"}
|
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.5.
|
|
6
|
+
"version": "2.5.3",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
@@ -31,22 +31,22 @@
|
|
|
31
31
|
"zod": "^4.4.3"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"@supabase/postgrest-js": "^2.
|
|
35
|
-
"@supabase/storage-js": "^2.
|
|
36
|
-
"@supabase/supabase-js": "^2.
|
|
34
|
+
"@supabase/postgrest-js": "^2.107.0",
|
|
35
|
+
"@supabase/storage-js": "^2.107.0",
|
|
36
|
+
"@supabase/supabase-js": "^2.107.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@freehour/eslint-rules": "^1.0.19",
|
|
40
|
-
"@supabase/postgrest-js": "^2.
|
|
41
|
-
"@supabase/storage-js": "^2.
|
|
42
|
-
"@supabase/supabase-js": "^2.
|
|
40
|
+
"@supabase/postgrest-js": "^2.107.0",
|
|
41
|
+
"@supabase/storage-js": "^2.107.0",
|
|
42
|
+
"@supabase/supabase-js": "^2.107.0",
|
|
43
43
|
"ajv": "^8.20.0",
|
|
44
44
|
"bun-types": "^1.3.14",
|
|
45
45
|
"eslint": "9.39.4",
|
|
46
|
-
"supabase": "^2.
|
|
46
|
+
"supabase": "^2.104.0",
|
|
47
47
|
"typescript": "^6.0.3",
|
|
48
|
-
"vite": "^8.0.
|
|
49
|
-
"vite-plugin-dts": "^5.0.
|
|
48
|
+
"vite": "^8.0.16",
|
|
49
|
+
"vite-plugin-dts": "^5.0.2"
|
|
50
50
|
},
|
|
51
51
|
"trustedDependencies": [
|
|
52
52
|
"unrs-resolver"
|