@freehour/supabase-core 1.6.0 → 1.7.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/embedding-service.d.ts.map +1 -1
- package/dist/embedding.d.ts +0 -6
- package/dist/embedding.d.ts.map +1 -1
- package/dist/errors.d.ts +24 -25
- package/dist/errors.d.ts.map +1 -1
- package/dist/index.js +18 -18
- package/package.json +4 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embedding-service.d.ts","sourceRoot":"","sources":["../lib/embedding-service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAmC,8BAA8B,EAAmC,QAAQ,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"embedding-service.d.ts","sourceRoot":"","sources":["../lib/embedding-service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAmC,8BAA8B,EAAmC,QAAQ,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAC9K,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGxD,MAAM,WAAW,sBAAsB,CACnC,UAAU,SAAS,MAAM,GAAG,MAAM;IAElC,OAAO,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;CACvC;AAED,8BAAsB,gBAAgB,CAClC,UAAU,SAAS,MAAM,GAAG,MAAM;IAElC,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;gBAE3C,EACR,OAAO,GACV,EAAE,sBAAsB,CAAC,UAAU,CAAC;IAIrC;;;;;OAKG;IACH,SAAS,CAAC,QAAQ,CAAC,aAAa,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IAEjF;;;;;;;;OAQG;IACH,SAAS,CAAC,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,EAAE,eAAe,EAAE,QAAQ,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IAEzG;;;;OAIG;IACH,SAAS,CAAC,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAE7E;;;;;;;OAOG;cACa,qBAAqB,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;IA4BnF,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IAKvD,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC,EAAE,QAAQ,GAAG,mBAAmB,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IAarG,WAAW,CAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,QAAQ,GAAG,mBAAmB,GAAG,OAAO,CAAC,8BAA8B,EAAE,CAAC;CAoB9H"}
|
package/dist/embedding.d.ts
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
import { MimeString } from '@freehour/mime';
|
|
2
1
|
import { Json } from './json';
|
|
3
2
|
import { FileRef, StorageLocation } from './storage';
|
|
4
3
|
export type Metadata = Record<string, Json>;
|
|
5
4
|
export type MetadataGeneratorFn = (location: StorageLocation) => Metadata;
|
|
6
|
-
export interface FileMetadata {
|
|
7
|
-
name: string;
|
|
8
|
-
type: MimeString;
|
|
9
|
-
size: number;
|
|
10
|
-
}
|
|
11
5
|
export interface Embedding extends StorageLocation {
|
|
12
6
|
text: string;
|
|
13
7
|
vector: number[];
|
package/dist/embedding.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embedding.d.ts","sourceRoot":"","sources":["../lib/embedding.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"embedding.d.ts","sourceRoot":"","sources":["../lib/embedding.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAG1D,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAC5C,MAAM,MAAM,mBAAmB,GAAG,CAAC,QAAQ,EAAE,eAAe,KAAK,QAAQ,CAAC;AAG1E,MAAM,WAAW,SAAU,SAAQ,eAAe;IAC9C,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,QAAQ,CAAC;IACnB,SAAS,EAAE,IAAI,CAAC;CACnB;AAED,MAAM,WAAW,+BAA+B;IAC5C,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,IAAI,CAAC;IACd,KAAK,EAAE,IAAI,CAAC;CACf;AAED,MAAM,WAAW,+BAA+B;IAC5C,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,KAAK,CAAC;IACf,KAAK,EAAE,KAAK,CAAC;CAChB;AAED,MAAM,MAAM,8BAA8B,GAAG,+BAA+B,GAAG,+BAA+B,CAAC"}
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { default as z } from 'zod';
|
|
2
|
-
import { Mime } from '@freehour/mime';
|
|
3
2
|
import { PostgrestError } from '@supabase/supabase-js';
|
|
4
3
|
/**
|
|
5
4
|
* Automatically sets the name and captures the stack trace for the error.
|
|
@@ -39,6 +38,30 @@ export declare class FileNotFoundError extends TracedError {
|
|
|
39
38
|
readonly path?: string;
|
|
40
39
|
constructor(message: string, { fileId, bucket, path, }?: FileNotFoundErrorOptions);
|
|
41
40
|
}
|
|
41
|
+
export interface FileNotSupportedErrorOptions extends ErrorOptions {
|
|
42
|
+
/**
|
|
43
|
+
* The name of the file that caused the error.
|
|
44
|
+
*/
|
|
45
|
+
fileName?: string;
|
|
46
|
+
/**
|
|
47
|
+
* The type of the file that is not supported.
|
|
48
|
+
*/
|
|
49
|
+
fileType?: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* An error that indicates that a file is not supported, e.g. due to its MIME type or extension.
|
|
53
|
+
*/
|
|
54
|
+
export declare class FileNotSupportedError extends Error {
|
|
55
|
+
/**
|
|
56
|
+
* The name of the file that caused the error.
|
|
57
|
+
*/
|
|
58
|
+
readonly fileName?: string;
|
|
59
|
+
/**
|
|
60
|
+
* The type of the file that is not supported.
|
|
61
|
+
*/
|
|
62
|
+
readonly fileType?: string;
|
|
63
|
+
constructor(message: string, { fileName, fileType, ...options }?: FileNotSupportedErrorOptions);
|
|
64
|
+
}
|
|
42
65
|
export interface ParseErrorOptions extends ErrorOptions {
|
|
43
66
|
/**
|
|
44
67
|
* The encountered expression that could not be parsed.
|
|
@@ -98,30 +121,6 @@ export declare class RecordNotFoundError extends TracedError {
|
|
|
98
121
|
readonly id?: string | number;
|
|
99
122
|
constructor(message: string, { schema, relation, id, }?: RecordNotFoundErrorOptions);
|
|
100
123
|
}
|
|
101
|
-
export interface UnsupportedMimeErrorOptions extends ErrorOptions {
|
|
102
|
-
/**
|
|
103
|
-
* The MIME type that is unsupported.
|
|
104
|
-
*/
|
|
105
|
-
value?: Mime;
|
|
106
|
-
/**
|
|
107
|
-
* The list of supported MIME types.
|
|
108
|
-
*/
|
|
109
|
-
supported?: Mime[];
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* An error that indicates that a supplied MIME type is not supported.
|
|
113
|
-
*/
|
|
114
|
-
export declare class UnsupportedMimeError extends Error {
|
|
115
|
-
/**
|
|
116
|
-
* The MIME type that is unsupported.
|
|
117
|
-
*/
|
|
118
|
-
readonly value?: Mime;
|
|
119
|
-
/**
|
|
120
|
-
* The list of supported MIME types.
|
|
121
|
-
*/
|
|
122
|
-
readonly supported?: Mime[];
|
|
123
|
-
constructor(message: string, { value, supported, ...options }?: UnsupportedMimeErrorOptions);
|
|
124
|
-
}
|
|
125
124
|
/**
|
|
126
125
|
* PostgREST errors are sometimes returned in this format instead of the declared PostgrestError class.
|
|
127
126
|
*/
|
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,
|
|
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,qBAAa,WAAY,SAAQ,KAAK;gBACtB,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB;CAK3D;AAGD,MAAM,WAAW,wBAAwB;IAErC;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,WAAW;IAC9C;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;gBAGnB,OAAO,EAAE,MAAM,EACf,EACI,MAAM,EACN,MAAM,EACN,IAAI,GACP,GAAE,wBAA6B;CAOvC;AAGD,MAAM,WAAW,4BAA6B,SAAQ,YAAY;IAE9D;;OAEG;IACH,QAAQ,CAAC,EAAE,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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
|
@@ -14,25 +14,25 @@ var i = class extends Error {
|
|
|
14
14
|
constructor(e, { fileId: t, bucket: n, path: r } = {}) {
|
|
15
15
|
super(e), this.fileId = t, this.bucket = n, this.path = r;
|
|
16
16
|
}
|
|
17
|
-
}, o = class extends
|
|
17
|
+
}, o = class extends Error {
|
|
18
|
+
fileName;
|
|
19
|
+
fileType;
|
|
20
|
+
constructor(e, { fileName: t, fileType: n, ...r } = {}) {
|
|
21
|
+
super(e, r), this.fileName = t, this.fileType = n;
|
|
22
|
+
}
|
|
23
|
+
}, s = class extends i {
|
|
18
24
|
expression;
|
|
19
25
|
format;
|
|
20
26
|
constructor(e, { expression: t, format: n, ...r } = {}) {
|
|
21
27
|
super(e, r), this.expression = t, this.format = n;
|
|
22
28
|
}
|
|
23
|
-
},
|
|
29
|
+
}, c = class extends i {
|
|
24
30
|
schema;
|
|
25
31
|
relation;
|
|
26
32
|
id;
|
|
27
33
|
constructor(e, { schema: t, relation: n, id: r } = {}) {
|
|
28
34
|
super(e), this.schema = t, this.relation = n, this.id = r;
|
|
29
35
|
}
|
|
30
|
-
}, c = class extends Error {
|
|
31
|
-
value;
|
|
32
|
-
supported;
|
|
33
|
-
constructor(e, { value: t, supported: n, ...r } = {}) {
|
|
34
|
-
super(e, r), this.value = t, this.supported = n;
|
|
35
|
-
}
|
|
36
36
|
}, l = t.object({
|
|
37
37
|
code: t.string(),
|
|
38
38
|
details: t.string().nullable(),
|
|
@@ -75,7 +75,7 @@ var g = class {
|
|
|
75
75
|
this.database = e, this.schema = t, this.relation = n;
|
|
76
76
|
}
|
|
77
77
|
recordNotFoundError(e) {
|
|
78
|
-
return new
|
|
78
|
+
return new c(`Record with id ${e} not found in ${this.schema}.${this.relation}`, {
|
|
79
79
|
schema: this.schema,
|
|
80
80
|
relation: this.relation,
|
|
81
81
|
id: e
|
|
@@ -191,7 +191,7 @@ var b = [
|
|
|
191
191
|
code: "custom",
|
|
192
192
|
input: e,
|
|
193
193
|
message: n instanceof Error ? n.message : void 0,
|
|
194
|
-
params: n instanceof
|
|
194
|
+
params: n instanceof s ? {
|
|
195
195
|
expression: n.expression,
|
|
196
196
|
format: n.format
|
|
197
197
|
} : void 0
|
|
@@ -246,8 +246,8 @@ function k(t, n = [], r = (e) => e) {
|
|
|
246
246
|
args: i(t.slice(7, -1)).map((e) => k(e, n, r))
|
|
247
247
|
};
|
|
248
248
|
}
|
|
249
|
-
let a = `^(${n.length === 0 ? "[a-zA-Z_][a-zA-Z0-9_]*" : n.join("|")})\\.((?:not\\.)?(?:${b.join("|")}))\\.(.+)$`,
|
|
250
|
-
if (!
|
|
249
|
+
let a = `^(${n.length === 0 ? "[a-zA-Z_][a-zA-Z0-9_]*" : n.join("|")})\\.((?:not\\.)?(?:${b.join("|")}))\\.(.+)$`, o = new RegExp(a).exec(t);
|
|
250
|
+
if (!o) throw new s(`Invalid filter expression '${t}'`, {
|
|
251
251
|
expression: t,
|
|
252
252
|
format: {
|
|
253
253
|
syntax: "key.(not.)op.value",
|
|
@@ -255,7 +255,7 @@ function k(t, n = [], r = (e) => e) {
|
|
|
255
255
|
operators: b
|
|
256
256
|
}
|
|
257
257
|
});
|
|
258
|
-
let [, c, l, u] =
|
|
258
|
+
let [, c, l, u] = o;
|
|
259
259
|
return {
|
|
260
260
|
type: "condition",
|
|
261
261
|
key: r(c),
|
|
@@ -400,7 +400,7 @@ var j = class t extends r.PostgrestFilterBuilder {
|
|
|
400
400
|
let t = new Date(e.updated_at), n = await this.storage.getFileStorageLocation({ fileId: e.id }), r = await this.getEmbeddings(n);
|
|
401
401
|
return r.length === 0 || r.some((e) => e.createdAt < t);
|
|
402
402
|
}));
|
|
403
|
-
t.push(...i.filter((e, t) => o[t]).map(({ id: e }) => ({ fileId: e }))), {hasNext: n, nextCursor: r} = a;
|
|
403
|
+
t.push(...i.filter((e, t) => o[t] ?? !1).map(({ id: e }) => ({ fileId: e }))), {hasNext: n, nextCursor: r} = a;
|
|
404
404
|
}
|
|
405
405
|
return t;
|
|
406
406
|
}
|
|
@@ -414,15 +414,15 @@ var j = class t extends r.PostgrestFilterBuilder {
|
|
|
414
414
|
}
|
|
415
415
|
async synchronize(e, t) {
|
|
416
416
|
let n = await this.getOutdatedEmbeddings(e);
|
|
417
|
-
return
|
|
417
|
+
return Promise.all(n.map(async (e) => this.ingest(e, t).then(() => ({
|
|
418
418
|
file: e,
|
|
419
419
|
success: !0,
|
|
420
420
|
error: null
|
|
421
|
-
})).catch((t) =>
|
|
421
|
+
})).catch((t) => ({
|
|
422
422
|
file: e,
|
|
423
423
|
error: t,
|
|
424
424
|
success: !1
|
|
425
|
-
}))))
|
|
425
|
+
}))));
|
|
426
426
|
}
|
|
427
427
|
};
|
|
428
428
|
//#endregion
|
|
@@ -541,4 +541,4 @@ var R = class {
|
|
|
541
541
|
}
|
|
542
542
|
};
|
|
543
543
|
//#endregion
|
|
544
|
-
export { g as DataService, P as DatabaseService, F as EmbeddingService, a as FileNotFoundError, w as Filter, C as FilterChainSeparator, b as FilterOp, x as LogicalOp, S as LogicalOpSeparator,
|
|
544
|
+
export { g as DataService, P as DatabaseService, F as EmbeddingService, a as FileNotFoundError, o as FileNotSupportedError, w as Filter, C as FilterChainSeparator, b as FilterOp, x as LogicalOp, S as LogicalOpSeparator, s as ParseError, N as PostgrestClient, l as PostgrestErrorInterface, j as PostgrestFilterBuilder, M as PostgrestQueryBuilder, c as RecordNotFoundError, R as StorageService, _ as TableDataService, i as TracedError, v as ViewDataService, y as assertCounted, f as coerceArray, O as encodeFilter, D as encodeFilterNode, h as entries, p as groupBy, u as isDatabaseApiError, E as negateFilterNode, T as negateOp, k as parseFilterExpression, A as parseFilterExpressionChain, m as removeElement, I as removeImagesFromMarkdown, L as removeLinksFromMarkdown, d as splitPath };
|
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": "1.
|
|
6
|
+
"version": "1.7.1",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
@@ -28,20 +28,19 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@freehour/assert": "^1.0.0",
|
|
31
|
-
"@freehour/mime": "^1.0.5",
|
|
32
31
|
"@supabase/postgrest-js": "^2.101.1",
|
|
33
32
|
"@supabase/storage-js": "^2.101.1",
|
|
34
33
|
"@supabase/supabase-js": "^2.101.1",
|
|
35
34
|
"zod": "4.3.6"
|
|
36
35
|
},
|
|
37
36
|
"devDependencies": {
|
|
38
|
-
"@freehour/eslint-rules": "^1.0.
|
|
37
|
+
"@freehour/eslint-rules": "^1.0.16",
|
|
39
38
|
"ajv": "^8.18.0",
|
|
40
39
|
"bun-types": "^1.3.11",
|
|
41
40
|
"eslint": "9.39.4",
|
|
42
|
-
"supabase": "^2.
|
|
41
|
+
"supabase": "^2.85.0",
|
|
43
42
|
"typescript": "^6.0.2",
|
|
44
|
-
"vite": "^8.0.
|
|
43
|
+
"vite": "^8.0.5",
|
|
45
44
|
"vite-plugin-dts": "^4.5.4"
|
|
46
45
|
},
|
|
47
46
|
"trustedDependencies": [
|