@freehour/supabase-core 1.6.0 → 1.7.0
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 +0 -25
- package/dist/errors.d.ts.map +1 -1
- package/dist/index.js +62 -68
- 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.
|
|
@@ -98,30 +97,6 @@ export declare class RecordNotFoundError extends TracedError {
|
|
|
98
97
|
readonly id?: string | number;
|
|
99
98
|
constructor(message: string, { schema, relation, id, }?: RecordNotFoundErrorOptions);
|
|
100
99
|
}
|
|
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
100
|
/**
|
|
126
101
|
* PostgREST errors are sometimes returned in this format instead of the declared PostgrestError class.
|
|
127
102
|
*/
|
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,iBAAkB,SAAQ,YAAY;IAEnD;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,qBAAa,UAAW,SAAQ,WAAW;IAEvC;;OAEG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAE7B;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;gBAGtB,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;IAChD;;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
|
@@ -27,47 +27,41 @@ var i = class extends Error {
|
|
|
27
27
|
constructor(e, { schema: t, relation: n, id: r } = {}) {
|
|
28
28
|
super(e), this.schema = t, this.relation = n, this.id = r;
|
|
29
29
|
}
|
|
30
|
-
}, c =
|
|
31
|
-
value;
|
|
32
|
-
supported;
|
|
33
|
-
constructor(e, { value: t, supported: n, ...r } = {}) {
|
|
34
|
-
super(e, r), this.value = t, this.supported = n;
|
|
35
|
-
}
|
|
36
|
-
}, l = t.object({
|
|
30
|
+
}, c = t.object({
|
|
37
31
|
code: t.string(),
|
|
38
32
|
details: t.string().nullable(),
|
|
39
33
|
hint: t.string().nullable(),
|
|
40
34
|
name: t.string().optional(),
|
|
41
35
|
message: t.string().optional()
|
|
42
36
|
});
|
|
43
|
-
function
|
|
44
|
-
return e instanceof n ||
|
|
37
|
+
function l(e) {
|
|
38
|
+
return e instanceof n || c.safeParse(e).success;
|
|
45
39
|
}
|
|
46
40
|
//#endregion
|
|
47
41
|
//#region lib/utils.ts
|
|
48
|
-
function
|
|
42
|
+
function u(e, t = "/") {
|
|
49
43
|
let n = e.lastIndexOf(t);
|
|
50
44
|
return n === -1 ? ["", e] : [e.substring(0, n), e.substring(n + 1)];
|
|
51
45
|
}
|
|
52
|
-
function
|
|
46
|
+
function d(e) {
|
|
53
47
|
return Array.isArray(e) ? e : [e];
|
|
54
48
|
}
|
|
55
|
-
function
|
|
49
|
+
function f(e, t) {
|
|
56
50
|
return e.reduce((e, n) => {
|
|
57
51
|
let r = t(n);
|
|
58
52
|
return (e[r] ??= []).push(n), e;
|
|
59
53
|
}, {});
|
|
60
54
|
}
|
|
61
|
-
function
|
|
55
|
+
function p(e, t) {
|
|
62
56
|
let n = e.findIndex(t);
|
|
63
57
|
return n !== -1 && e.splice(n, 1), e;
|
|
64
58
|
}
|
|
65
|
-
function
|
|
59
|
+
function m(e) {
|
|
66
60
|
return Object.entries(e);
|
|
67
61
|
}
|
|
68
62
|
//#endregion
|
|
69
63
|
//#region lib/data-service.ts
|
|
70
|
-
var
|
|
64
|
+
var h = class {
|
|
71
65
|
database;
|
|
72
66
|
schema;
|
|
73
67
|
relation;
|
|
@@ -123,7 +117,7 @@ var g = class {
|
|
|
123
117
|
}
|
|
124
118
|
async upsert(e, { onConflict: t, ...n } = {}) {
|
|
125
119
|
let { data: r } = await this.query.upsert(e, {
|
|
126
|
-
onConflict: t === void 0 ? void 0 :
|
|
120
|
+
onConflict: t === void 0 ? void 0 : d(t).join(","),
|
|
127
121
|
...n
|
|
128
122
|
}).select().single().throwOnError();
|
|
129
123
|
return r;
|
|
@@ -132,7 +126,7 @@ var g = class {
|
|
|
132
126
|
let { data: n } = await this.query.update(t).eq("id", e).select().single().throwOnError();
|
|
133
127
|
return n;
|
|
134
128
|
}
|
|
135
|
-
},
|
|
129
|
+
}, g = class extends h {
|
|
136
130
|
constructor({ database: e, schema: t, table: n }) {
|
|
137
131
|
super({
|
|
138
132
|
database: e,
|
|
@@ -140,7 +134,7 @@ var g = class {
|
|
|
140
134
|
relation: n
|
|
141
135
|
});
|
|
142
136
|
}
|
|
143
|
-
},
|
|
137
|
+
}, _ = class extends h {
|
|
144
138
|
constructor({ database: e, schema: t, view: n }) {
|
|
145
139
|
super({
|
|
146
140
|
database: e,
|
|
@@ -149,13 +143,13 @@ var g = class {
|
|
|
149
143
|
});
|
|
150
144
|
}
|
|
151
145
|
};
|
|
152
|
-
function
|
|
146
|
+
function v(t) {
|
|
153
147
|
if (t.error) throw t.error;
|
|
154
148
|
return e(t.count !== null, "Response does not contain a count. Make sure to set the `count` option in the request."), t;
|
|
155
149
|
}
|
|
156
150
|
//#endregion
|
|
157
151
|
//#region lib/filter.ts
|
|
158
|
-
var
|
|
152
|
+
var y = [
|
|
159
153
|
"eq",
|
|
160
154
|
"neq",
|
|
161
155
|
"gt",
|
|
@@ -181,11 +175,11 @@ var b = [
|
|
|
181
175
|
"nxr",
|
|
182
176
|
"nxl",
|
|
183
177
|
"adj"
|
|
184
|
-
],
|
|
178
|
+
], b = ["and", "or"], x = ",", S = "~", C = (e) => (n = {}) => {
|
|
185
179
|
let r = (e) => n[e] ?? e, i = Object.keys(e.shape);
|
|
186
180
|
return t.string().transform((e, t) => {
|
|
187
181
|
try {
|
|
188
|
-
return
|
|
182
|
+
return k(e, i, r);
|
|
189
183
|
} catch (n) {
|
|
190
184
|
return t.addIssue({
|
|
191
185
|
code: "custom",
|
|
@@ -199,26 +193,26 @@ var b = [
|
|
|
199
193
|
}
|
|
200
194
|
});
|
|
201
195
|
};
|
|
202
|
-
function
|
|
196
|
+
function w(e) {
|
|
203
197
|
return e.startsWith("not.") ? e.slice(4) : `not.${e}`;
|
|
204
198
|
}
|
|
205
|
-
function
|
|
199
|
+
function T(e) {
|
|
206
200
|
return {
|
|
207
201
|
...e,
|
|
208
|
-
op:
|
|
202
|
+
op: w(e.op)
|
|
209
203
|
};
|
|
210
204
|
}
|
|
211
|
-
function
|
|
205
|
+
function E(e, t = (e) => e) {
|
|
212
206
|
if (e.type === "logical") {
|
|
213
|
-
let n = e.args.map((e) =>
|
|
207
|
+
let n = e.args.map((e) => E(e, t));
|
|
214
208
|
return `${e.op}(${n})`;
|
|
215
209
|
}
|
|
216
210
|
return `${t(e.key)}.${e.op}.${e.value}`;
|
|
217
211
|
}
|
|
218
|
-
function
|
|
219
|
-
return e.map((e) =>
|
|
212
|
+
function D(e, t = (e) => e, n = "~") {
|
|
213
|
+
return e.map((e) => E(e, t)).join(n);
|
|
220
214
|
}
|
|
221
|
-
function
|
|
215
|
+
function O(t, n = [], r = (e) => e) {
|
|
222
216
|
function i(e) {
|
|
223
217
|
let t = [], n = 0, r = "", i = !1;
|
|
224
218
|
for (let a of e) a === "\"" ? (i = !i, r += a) : a === "(" && !i ? (n++, r += a) : a === ")" && !i ? (n--, r += a) : a === "," && n === 0 && !i ? (t.push(r.trim()), r = "") : r += a;
|
|
@@ -228,31 +222,31 @@ function k(t, n = [], r = (e) => e) {
|
|
|
228
222
|
if (t.startsWith("and(")) return {
|
|
229
223
|
type: "logical",
|
|
230
224
|
op: "and",
|
|
231
|
-
args: i(t.slice(4, -1)).map((e) =>
|
|
225
|
+
args: i(t.slice(4, -1)).map((e) => O(e, n, r))
|
|
232
226
|
};
|
|
233
227
|
if (t.startsWith("or(")) return {
|
|
234
228
|
type: "logical",
|
|
235
229
|
op: "or",
|
|
236
|
-
args: i(t.slice(3, -1)).map((e) =>
|
|
230
|
+
args: i(t.slice(3, -1)).map((e) => O(e, n, r))
|
|
237
231
|
};
|
|
238
232
|
if (t.startsWith("not.and(")) return {
|
|
239
233
|
type: "logical",
|
|
240
234
|
op: "not.and",
|
|
241
|
-
args: i(t.slice(8, -1)).map((e) =>
|
|
235
|
+
args: i(t.slice(8, -1)).map((e) => O(e, n, r))
|
|
242
236
|
};
|
|
243
237
|
if (t.startsWith("not.or(")) return {
|
|
244
238
|
type: "logical",
|
|
245
239
|
op: "not.or",
|
|
246
|
-
args: i(t.slice(7, -1)).map((e) =>
|
|
240
|
+
args: i(t.slice(7, -1)).map((e) => O(e, n, r))
|
|
247
241
|
};
|
|
248
242
|
}
|
|
249
|
-
let a = `^(${n.length === 0 ? "[a-zA-Z_][a-zA-Z0-9_]*" : n.join("|")})\\.((?:not\\.)?(?:${
|
|
243
|
+
let a = `^(${n.length === 0 ? "[a-zA-Z_][a-zA-Z0-9_]*" : n.join("|")})\\.((?:not\\.)?(?:${y.join("|")}))\\.(.+)$`, s = new RegExp(a).exec(t);
|
|
250
244
|
if (!s) throw new o(`Invalid filter expression '${t}'`, {
|
|
251
245
|
expression: t,
|
|
252
246
|
format: {
|
|
253
247
|
syntax: "key.(not.)op.value",
|
|
254
248
|
keys: n.length === 0 ? "*" : n,
|
|
255
|
-
operators:
|
|
249
|
+
operators: y
|
|
256
250
|
}
|
|
257
251
|
});
|
|
258
252
|
let [, c, l, u] = s;
|
|
@@ -263,22 +257,22 @@ function k(t, n = [], r = (e) => e) {
|
|
|
263
257
|
value: e.defined(u)
|
|
264
258
|
};
|
|
265
259
|
}
|
|
266
|
-
function
|
|
267
|
-
return e.length === 0 ? [] : e.split(r).map((e) =>
|
|
260
|
+
function k(e, t = [], n = (e) => e, r = "~") {
|
|
261
|
+
return e.length === 0 ? [] : e.split(r).map((e) => O(e, t, n));
|
|
268
262
|
}
|
|
269
263
|
//#endregion
|
|
270
264
|
//#region lib/postgrest.ts
|
|
271
|
-
var
|
|
265
|
+
var A = class t extends r.PostgrestFilterBuilder {
|
|
272
266
|
pagination;
|
|
273
267
|
constructor(e) {
|
|
274
268
|
super(e);
|
|
275
269
|
}
|
|
276
270
|
select(e = "*") {
|
|
277
|
-
return new t(super.select(
|
|
271
|
+
return new t(super.select(d(e).join(",")));
|
|
278
272
|
}
|
|
279
273
|
where(e) {
|
|
280
274
|
if (e.type === "logical") {
|
|
281
|
-
let t = e.args.map((e) =>
|
|
275
|
+
let t = e.args.map((e) => E(e)).join(",");
|
|
282
276
|
this.url.searchParams.append(e.op, `(${t})`);
|
|
283
277
|
} else this.url.searchParams.append(e.key, `${e.op}.${e.value}`);
|
|
284
278
|
return this;
|
|
@@ -320,75 +314,75 @@ var j = class t extends r.PostgrestFilterBuilder {
|
|
|
320
314
|
};
|
|
321
315
|
});
|
|
322
316
|
}
|
|
323
|
-
},
|
|
317
|
+
}, j = class extends r.PostgrestQueryBuilder {
|
|
324
318
|
constructor(e) {
|
|
325
319
|
super(e.url, e);
|
|
326
320
|
}
|
|
327
321
|
select(e = "*", t) {
|
|
328
|
-
return new
|
|
322
|
+
return new A(super.select(d(e).join(","), t));
|
|
329
323
|
}
|
|
330
324
|
count(e = "exact") {
|
|
331
|
-
return new
|
|
325
|
+
return new A(this.select("*", {
|
|
332
326
|
count: e,
|
|
333
327
|
head: !0
|
|
334
328
|
}));
|
|
335
329
|
}
|
|
336
330
|
insert(e, t) {
|
|
337
|
-
return new
|
|
331
|
+
return new A(super.insert(e, t));
|
|
338
332
|
}
|
|
339
333
|
upsert(e, { onConflict: t, ...n } = {}) {
|
|
340
|
-
return new
|
|
341
|
-
onConflict:
|
|
334
|
+
return new A(super.upsert(e, {
|
|
335
|
+
onConflict: d(t).join(","),
|
|
342
336
|
...n
|
|
343
337
|
}));
|
|
344
338
|
}
|
|
345
339
|
update(e, t) {
|
|
346
|
-
return new
|
|
340
|
+
return new A(super.update(e, t));
|
|
347
341
|
}
|
|
348
342
|
delete() {
|
|
349
|
-
return new
|
|
343
|
+
return new A(super.delete());
|
|
350
344
|
}
|
|
351
|
-
},
|
|
345
|
+
}, M = class {
|
|
352
346
|
client;
|
|
353
347
|
constructor(e) {
|
|
354
348
|
this.client = e;
|
|
355
349
|
}
|
|
356
350
|
from(e) {
|
|
357
|
-
return new
|
|
351
|
+
return new j(this.client.from(e));
|
|
358
352
|
}
|
|
359
353
|
rpc(e, t, n) {
|
|
360
|
-
return new
|
|
354
|
+
return new A(this.client.rpc(e, t, n));
|
|
361
355
|
}
|
|
362
|
-
},
|
|
356
|
+
}, N = class {
|
|
363
357
|
supabase;
|
|
364
358
|
constructor({ supabase: e }) {
|
|
365
359
|
this.supabase = e;
|
|
366
360
|
}
|
|
367
361
|
schema(e) {
|
|
368
|
-
return new
|
|
362
|
+
return new M(this.supabase.schema(e));
|
|
369
363
|
}
|
|
370
364
|
relation(e, t) {
|
|
371
|
-
return new
|
|
365
|
+
return new h({
|
|
372
366
|
database: this,
|
|
373
367
|
schema: e,
|
|
374
368
|
relation: t
|
|
375
369
|
});
|
|
376
370
|
}
|
|
377
371
|
table(e, t) {
|
|
378
|
-
return new
|
|
372
|
+
return new g({
|
|
379
373
|
database: this,
|
|
380
374
|
schema: e,
|
|
381
375
|
table: t
|
|
382
376
|
});
|
|
383
377
|
}
|
|
384
378
|
view(e, t) {
|
|
385
|
-
return new
|
|
379
|
+
return new _({
|
|
386
380
|
database: this,
|
|
387
381
|
schema: e,
|
|
388
382
|
view: t
|
|
389
383
|
});
|
|
390
384
|
}
|
|
391
|
-
},
|
|
385
|
+
}, P = class {
|
|
392
386
|
storage;
|
|
393
387
|
constructor({ storage: e }) {
|
|
394
388
|
this.storage = e;
|
|
@@ -400,7 +394,7 @@ var j = class t extends r.PostgrestFilterBuilder {
|
|
|
400
394
|
let t = new Date(e.updated_at), n = await this.storage.getFileStorageLocation({ fileId: e.id }), r = await this.getEmbeddings(n);
|
|
401
395
|
return r.length === 0 || r.some((e) => e.createdAt < t);
|
|
402
396
|
}));
|
|
403
|
-
t.push(...i.filter((e, t) => o[t]).map(({ id: e }) => ({ fileId: e }))), {hasNext: n, nextCursor: r} = a;
|
|
397
|
+
t.push(...i.filter((e, t) => o[t] ?? !1).map(({ id: e }) => ({ fileId: e }))), {hasNext: n, nextCursor: r} = a;
|
|
404
398
|
}
|
|
405
399
|
return t;
|
|
406
400
|
}
|
|
@@ -414,28 +408,28 @@ var j = class t extends r.PostgrestFilterBuilder {
|
|
|
414
408
|
}
|
|
415
409
|
async synchronize(e, t) {
|
|
416
410
|
let n = await this.getOutdatedEmbeddings(e);
|
|
417
|
-
return
|
|
411
|
+
return Promise.all(n.map(async (e) => this.ingest(e, t).then(() => ({
|
|
418
412
|
file: e,
|
|
419
413
|
success: !0,
|
|
420
414
|
error: null
|
|
421
|
-
})).catch((t) =>
|
|
415
|
+
})).catch((t) => ({
|
|
422
416
|
file: e,
|
|
423
417
|
error: t,
|
|
424
418
|
success: !1
|
|
425
|
-
}))))
|
|
419
|
+
}))));
|
|
426
420
|
}
|
|
427
421
|
};
|
|
428
422
|
//#endregion
|
|
429
423
|
//#region lib/processing.ts
|
|
430
|
-
function
|
|
424
|
+
function F(e) {
|
|
431
425
|
return e.replace(/!\[([^\]]*)\]\([^)]*\)/g, (e, t) => `![${t}]()`);
|
|
432
426
|
}
|
|
433
|
-
function
|
|
427
|
+
function I(e) {
|
|
434
428
|
return e.replace(/\[([^\]]*)\]\([^)]*\)/g, (e, t) => `[${t}]()`);
|
|
435
429
|
}
|
|
436
430
|
//#endregion
|
|
437
431
|
//#region lib/storage-service.ts
|
|
438
|
-
var
|
|
432
|
+
var L = class {
|
|
439
433
|
client;
|
|
440
434
|
database;
|
|
441
435
|
constructor({ client: e, database: t }) {
|
|
@@ -514,7 +508,7 @@ var R = class {
|
|
|
514
508
|
async downloadFile(e) {
|
|
515
509
|
let { fileId: t, bucket: n, path: r, properties: i } = await this.getFileInfo(e), { data: a, error: o } = await this.client.from(n).download(r);
|
|
516
510
|
if (o) throw o;
|
|
517
|
-
let [, s] =
|
|
511
|
+
let [, s] = u(r);
|
|
518
512
|
return {
|
|
519
513
|
fileId: t,
|
|
520
514
|
bucket: n,
|
|
@@ -526,7 +520,7 @@ var R = class {
|
|
|
526
520
|
let n = t.filter((e) => "fileId" in e).map((e) => e.fileId), r = (await this.files.query.select(["bucket_id", "path_tokens"]).containedBy("id", n).throwOnError()).data.map(({ bucket_id: t, path_tokens: n }) => ({
|
|
527
521
|
bucket: e.notNull(t, "bucket_id must not be null"),
|
|
528
522
|
path: e.notNull(n, "path_tokens must not be null").join("/")
|
|
529
|
-
})), i =
|
|
523
|
+
})), i = m(f(t.filter((e) => "path" in e).concat(r), (e) => e.bucket)).map(([e, t]) => ({
|
|
530
524
|
bucket: e,
|
|
531
525
|
paths: t.map((e) => e.path)
|
|
532
526
|
}));
|
|
@@ -541,4 +535,4 @@ var R = class {
|
|
|
541
535
|
}
|
|
542
536
|
};
|
|
543
537
|
//#endregion
|
|
544
|
-
export {
|
|
538
|
+
export { h as DataService, N as DatabaseService, P as EmbeddingService, a as FileNotFoundError, C as Filter, S as FilterChainSeparator, y as FilterOp, b as LogicalOp, x as LogicalOpSeparator, o as ParseError, M as PostgrestClient, c as PostgrestErrorInterface, A as PostgrestFilterBuilder, j as PostgrestQueryBuilder, s as RecordNotFoundError, L as StorageService, g as TableDataService, i as TracedError, _ as ViewDataService, v as assertCounted, d as coerceArray, D as encodeFilter, E as encodeFilterNode, m as entries, f as groupBy, l as isDatabaseApiError, T as negateFilterNode, w as negateOp, O as parseFilterExpression, k as parseFilterExpressionChain, p as removeElement, F as removeImagesFromMarkdown, I as removeLinksFromMarkdown, u 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.0",
|
|
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": [
|