@freehour/supabase-core 1.7.2 → 2.0.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/index.d.ts +0 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -48
- package/dist/json.d.ts +3 -3
- package/dist/json.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/embedding-service.d.ts +0 -46
- package/dist/embedding-service.d.ts.map +0 -1
- package/dist/embedding.d.ts +0 -22
- package/dist/embedding.d.ts.map +0 -1
- package/dist/processing.d.ts +0 -3
- package/dist/processing.d.ts.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
export * from './data-service';
|
|
2
2
|
export type * from './database';
|
|
3
3
|
export * from './database-service';
|
|
4
|
-
export type * from './embedding';
|
|
5
|
-
export * from './embedding-service';
|
|
6
4
|
export * from './errors';
|
|
7
5
|
export * from './filter';
|
|
8
6
|
export type * from './json';
|
|
9
7
|
export * from './postgrest';
|
|
10
|
-
export * from './processing';
|
|
11
8
|
export type * from './storage';
|
|
12
9
|
export * from './storage-service';
|
|
13
10
|
export * from './utils';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,UAAU,CAAC;AACzB,mBAAmB,QAAQ,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,mBAAmB,WAAW,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -389,53 +389,6 @@ var j = class t extends r.PostgrestFilterBuilder {
|
|
|
389
389
|
});
|
|
390
390
|
}
|
|
391
391
|
}, F = class {
|
|
392
|
-
storage;
|
|
393
|
-
constructor({ storage: e }) {
|
|
394
|
-
this.storage = e;
|
|
395
|
-
}
|
|
396
|
-
async getOutdatedEmbeddings(e) {
|
|
397
|
-
let t = [], n = !0, r;
|
|
398
|
-
for (; n;) {
|
|
399
|
-
let { objects: i, ...a } = await this.storage.getFiles(e, { cursor: r }), o = await Promise.all(i.map(async (e) => {
|
|
400
|
-
let t = new Date(e.updated_at), n = await this.storage.getFileStorageLocation({ fileId: e.id }), r = await this.getEmbeddings(n);
|
|
401
|
-
return r.length === 0 || r.some((e) => e.createdAt < t);
|
|
402
|
-
}));
|
|
403
|
-
t.push(...i.filter((e, t) => o[t] ?? !1).map(({ id: e }) => ({ fileId: e }))), {hasNext: n, nextCursor: r} = a;
|
|
404
|
-
}
|
|
405
|
-
return t;
|
|
406
|
-
}
|
|
407
|
-
async get(e) {
|
|
408
|
-
let t = await this.storage.getFileStorageLocation(e);
|
|
409
|
-
return this.getEmbeddings(t);
|
|
410
|
-
}
|
|
411
|
-
async ingest(e, t) {
|
|
412
|
-
let n = await this.storage.getFileStorageLocation(e);
|
|
413
|
-
return await this.deleteEmbeddings(n), this.createEmbeddings(n, typeof t == "function" ? t(n) : t);
|
|
414
|
-
}
|
|
415
|
-
async synchronize(e, t) {
|
|
416
|
-
let n = await this.getOutdatedEmbeddings(e);
|
|
417
|
-
return Promise.all(n.map(async (e) => this.ingest(e, t).then(() => ({
|
|
418
|
-
file: e,
|
|
419
|
-
success: !0,
|
|
420
|
-
error: null
|
|
421
|
-
})).catch((t) => ({
|
|
422
|
-
file: e,
|
|
423
|
-
error: t,
|
|
424
|
-
success: !1
|
|
425
|
-
}))));
|
|
426
|
-
}
|
|
427
|
-
};
|
|
428
|
-
//#endregion
|
|
429
|
-
//#region lib/processing.ts
|
|
430
|
-
function I(e) {
|
|
431
|
-
return e.replace(/!\[([^\]]*)\]\([^)]*\)/g, (e, t) => `![${t}]()`);
|
|
432
|
-
}
|
|
433
|
-
function L(e) {
|
|
434
|
-
return e.replace(/\[([^\]]*)\]\([^)]*\)/g, (e, t) => `[${t}]()`);
|
|
435
|
-
}
|
|
436
|
-
//#endregion
|
|
437
|
-
//#region lib/storage-service.ts
|
|
438
|
-
var R = class {
|
|
439
392
|
client;
|
|
440
393
|
database;
|
|
441
394
|
constructor({ client: e, database: t }) {
|
|
@@ -541,4 +494,4 @@ var R = class {
|
|
|
541
494
|
}
|
|
542
495
|
};
|
|
543
496
|
//#endregion
|
|
544
|
-
export { g as DataService, P as DatabaseService,
|
|
497
|
+
export { g as DataService, P as DatabaseService, 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, F 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, d as splitPath };
|
package/dist/json.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
}
|
|
1
|
+
import { Json } from './generated/database';
|
|
2
|
+
export type JsonObject = Record<string, Json | undefined>;
|
|
3
|
+
export type { Json } from './generated/database';
|
|
4
4
|
//# sourceMappingURL=json.d.ts.map
|
package/dist/json.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../lib/json.ts"],"names":[],"mappings":"AAAA,
|
|
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"}
|
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": "
|
|
6
|
+
"version": "2.0.0",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { Embedding, EmbeddingSynchronizationResult, Metadata, MetadataGeneratorFn } from './embedding';
|
|
2
|
-
import { FileRef, StorageLocation } from './storage';
|
|
3
|
-
import { StorageService } from './storage-service';
|
|
4
|
-
export interface EmbeddingServiceParams<BucketName extends string = string> {
|
|
5
|
-
storage: StorageService<BucketName>;
|
|
6
|
-
}
|
|
7
|
-
export declare abstract class EmbeddingService<BucketName extends string = string> {
|
|
8
|
-
protected readonly storage: StorageService<BucketName>;
|
|
9
|
-
constructor({ storage, }: EmbeddingServiceParams<BucketName>);
|
|
10
|
-
/**
|
|
11
|
-
* Retrieves the embeddings associated with the given file reference.
|
|
12
|
-
*
|
|
13
|
-
* @param location The storage location of the file whose embeddings should be retrieved.
|
|
14
|
-
* @return An array of embeddings.
|
|
15
|
-
*/
|
|
16
|
-
protected abstract getEmbeddings(location: StorageLocation): Promise<Embedding[]>;
|
|
17
|
-
/**
|
|
18
|
-
* Generates and stores embeddings for the given text.
|
|
19
|
-
*
|
|
20
|
-
* @param location The storage location of the file content that is being embedded.
|
|
21
|
-
* @param text The text to generate embeddings for.
|
|
22
|
-
* @param file The metadata of the corresponding file.
|
|
23
|
-
* @param metadata Additional metadata to store with the embedding.
|
|
24
|
-
* @return An array of generated embeddings.
|
|
25
|
-
*/
|
|
26
|
-
protected abstract createEmbeddings(location: StorageLocation, metadata?: Metadata): Promise<Embedding[]>;
|
|
27
|
-
/**
|
|
28
|
-
* Delete the embeddings associated with the given file reference.
|
|
29
|
-
*
|
|
30
|
-
* @param location The storage location of the file whose embeddings should be deleted.
|
|
31
|
-
*/
|
|
32
|
-
protected abstract deleteEmbeddings(location: StorageLocation): Promise<void>;
|
|
33
|
-
/**
|
|
34
|
-
* Retrieves a list of files in the specified bucket that have either no embeddings or embeddings that are outdated.
|
|
35
|
-
* Note: The base implementation of this method is expensive to run.
|
|
36
|
-
* It is recommended to override it with a more efficient implementation (e.g. using pure SQL) if possible.
|
|
37
|
-
*
|
|
38
|
-
* @param bucket The name of the bucket to check for outdated embeddings.
|
|
39
|
-
* @returns A promise that resolves to an array of file references with outdated embeddings.
|
|
40
|
-
*/
|
|
41
|
-
protected getOutdatedEmbeddings(bucket: BucketName): Promise<FileRef<BucketName>[]>;
|
|
42
|
-
get(fileRef: FileRef<BucketName>): Promise<Embedding[]>;
|
|
43
|
-
ingest(fileRef: FileRef<BucketName>, metadata?: Metadata | MetadataGeneratorFn): Promise<Embedding[]>;
|
|
44
|
-
synchronize(bucket: BucketName, metadata?: Metadata | MetadataGeneratorFn): Promise<EmbeddingSynchronizationResult[]>;
|
|
45
|
-
}
|
|
46
|
-
//# sourceMappingURL=embedding-service.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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,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
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Json } from './json';
|
|
2
|
-
import { FileRef, StorageLocation } from './storage';
|
|
3
|
-
export type Metadata = Json;
|
|
4
|
-
export type MetadataGeneratorFn = (location: StorageLocation) => Metadata;
|
|
5
|
-
export interface Embedding extends StorageLocation {
|
|
6
|
-
text: string;
|
|
7
|
-
vector: number[];
|
|
8
|
-
metadata: Metadata;
|
|
9
|
-
createdAt: Date;
|
|
10
|
-
}
|
|
11
|
-
export interface EmbeddingSynchronizationSuccess {
|
|
12
|
-
file: FileRef;
|
|
13
|
-
success: true;
|
|
14
|
-
error: null;
|
|
15
|
-
}
|
|
16
|
-
export interface EmbeddingSynchronizationFailure {
|
|
17
|
-
file: FileRef;
|
|
18
|
-
success: false;
|
|
19
|
-
error: Error;
|
|
20
|
-
}
|
|
21
|
-
export type EmbeddingSynchronizationResult = EmbeddingSynchronizationSuccess | EmbeddingSynchronizationFailure;
|
|
22
|
-
//# sourceMappingURL=embedding.d.ts.map
|
package/dist/embedding.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,IAAI,CAAC;AAC5B,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/processing.d.ts
DELETED
package/dist/processing.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"processing.d.ts","sourceRoot":"","sources":["../lib/processing.ts"],"names":[],"mappings":"AACA,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAG7D;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAG5D"}
|