@sixb/sqlite 0.1.7 → 0.1.8
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/execution-storage.d.ts +3 -2
- package/dist/execution-storage.d.ts.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1492 -380
- package/dist/index.js.map +16 -10
- package/dist/migrations.d.ts.map +1 -1
- package/dist/objects/index.d.ts +3 -0
- package/dist/objects/index.d.ts.map +1 -0
- package/dist/{object-query-compiler.d.ts → objects/query-compiler.d.ts} +16 -1
- package/dist/objects/query-compiler.d.ts.map +1 -0
- package/dist/objects/read-scope.d.ts +17 -0
- package/dist/objects/read-scope.d.ts.map +1 -0
- package/dist/objects/reader.d.ts +51 -0
- package/dist/objects/reader.d.ts.map +1 -0
- package/dist/objects/rows.d.ts +33 -0
- package/dist/objects/rows.d.ts.map +1 -0
- package/dist/objects/selected-reader.d.ts +9 -0
- package/dist/objects/selected-reader.d.ts.map +1 -0
- package/dist/{object-storage.d.ts → objects/storage.d.ts} +12 -9
- package/dist/objects/storage.d.ts.map +1 -0
- package/dist/share-grant-storage.d.ts +20 -0
- package/dist/share-grant-storage.d.ts.map +1 -0
- package/dist/share-session-storage.d.ts +19 -0
- package/dist/share-session-storage.d.ts.map +1 -0
- package/dist/storage-errors.d.ts +1 -0
- package/dist/storage-errors.d.ts.map +1 -1
- package/dist/transactions.d.ts +8 -0
- package/dist/transactions.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/execution-storage.ts +22 -3
- package/src/index.ts +18 -3
- package/src/migrations/035-share-grants.sql +66 -0
- package/src/migrations/036-share-sessions.sql +226 -0
- package/src/migrations.ts +4 -0
- package/src/objects/index.ts +2 -0
- package/src/{object-query-compiler.ts → objects/query-compiler.ts} +104 -54
- package/src/objects/read-scope.ts +316 -0
- package/src/objects/reader.ts +526 -0
- package/src/objects/rows.ts +123 -0
- package/src/objects/selected-reader.ts +119 -0
- package/src/objects/storage.ts +296 -0
- package/src/share-grant-storage.ts +252 -0
- package/src/share-session-storage.ts +189 -0
- package/src/storage-errors.ts +4 -0
- package/src/transactions.ts +32 -0
- package/dist/object-query-compiler.d.ts.map +0 -1
- package/dist/object-storage.d.ts.map +0 -1
- package/src/object-storage.ts +0 -709
package/dist/migrations.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../src/migrations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAIrC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,KAAK,EAGV,YAAY,EACZ,aAAa,EACb,oBAAoB,EACrB,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../src/migrations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAIrC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,KAAK,EAGV,YAAY,EACZ,aAAa,EACb,oBAAoB,EACrB,MAAM,oBAAoB,CAAA;AA+F3B,eAAO,MAAM,yBAAyB,sBAAsB,CAAA;AAC5D,eAAO,MAAM,mBAAmB,mBAAmB,CAAA;AAEnD,eAAO,MAAM,uBAAuB,wBA2ElC,CAAA;AAEF,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,aAAa,CAAC,QAAQ,CAAC,CAQ9E;AAED,wBAAgB,UAAU,CACxB,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,CAAC,EAAE,EAAE,QAAQ,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EAC1C,OAAO,GAAE,oBAAyB,GACjC,aAAa,CAAC,QAAQ,CAAC,CAEzB;AAED,wBAAgB,wBAAwB,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CAS3D;AAED,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,eAAe,EAAE,CAOzF;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE;IAC3C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,UAAU,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAA;CAC5C,GAAG,eAAe,CAoBlB;AAED,wBAAsB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAM1E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/objects/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAA;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAA"}
|
|
@@ -39,6 +39,21 @@ type CompiledOrderField = {
|
|
|
39
39
|
};
|
|
40
40
|
export declare function compileObjectQuery(projectId: string, query: ObjectQuery, options?: {
|
|
41
41
|
includeTotal?: boolean;
|
|
42
|
+
source?: SqliteObjectQuerySource;
|
|
42
43
|
}): CompiledObjectQuery;
|
|
44
|
+
/** Physical relations used by the object-query compiler. */
|
|
45
|
+
export interface SqliteObjectQuerySource {
|
|
46
|
+
readonly objectsTable: string;
|
|
47
|
+
readonly linksTable: string;
|
|
48
|
+
/** Wrap a terminal SELECT without its own WITH clause; the selected source owns the only WITH. */
|
|
49
|
+
wrapStatement(sql: string, args?: readonly SqliteValue[]): {
|
|
50
|
+
readonly sql: string;
|
|
51
|
+
readonly args: readonly SqliteValue[];
|
|
52
|
+
};
|
|
53
|
+
wrapQuery(query: CompiledObjectQuery): CompiledObjectQuery;
|
|
54
|
+
}
|
|
55
|
+
export declare const DEFAULT_OBJECT_QUERY_SOURCE: SqliteObjectQuerySource;
|
|
56
|
+
/** json_each exposes JSON booleans as integer SQL values; restore their JSON representation. */
|
|
57
|
+
export declare function sqliteJsonEachValue(alias: string): string;
|
|
43
58
|
export {};
|
|
44
|
-
//# sourceMappingURL=
|
|
59
|
+
//# sourceMappingURL=query-compiler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-compiler.d.ts","sourceRoot":"","sources":["../../src/objects/query-compiler.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,WAAW,EAKjB,MAAM,YAAY,CAAA;AAEnB,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAA;AAEnE,MAAM,WAAW,wBAAwB;IACvC,cAAc,EAAE,MAAM,CAAA;IACtB,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAC5B;AAED,MAAM,WAAW,mBAAmB;IAClC,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,WAAW,EAAE,CAAA;IACnB,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,WAAW,EAAE,CAAA;IACxB,KAAK,EAAE,aAAa,CAAA;IACpB,YAAY,CAAC,EAAE,oBAAoB,CAAA;IACnC,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IAClD,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,CAAA;IAC7C,aAAa,CAAC,IAAI,EAAE,SAAS,wBAAwB,EAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;CAC/F;AAED,UAAU,oBAAoB;IAC5B,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,WAAW,EAAE,CAA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0 +1,17 @@
|
|
|
1
|
+
import type { CompiledSelectedObjectReadScope } from "@sixb/core/storage";
|
|
2
|
+
import { type SqliteObjectQuerySource, type SqliteValue } from "./query-compiler";
|
|
3
|
+
export interface SqliteSelectedObjectReadSource extends SqliteObjectQuerySource {
|
|
4
|
+
readonly objectPropertyPermissionsTable: string;
|
|
5
|
+
readonly traversalProbe: {
|
|
6
|
+
readonly sql: string;
|
|
7
|
+
readonly args: readonly SqliteValue[];
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Prepare one immutable selected scope as live, path-sensitive SQLite relations.
|
|
12
|
+
*
|
|
13
|
+
* The complete compiled scope is serialized once. Every statement receives that one JSON document
|
|
14
|
+
* and the bound project id, keeping the host-parameter count constant as selections grow.
|
|
15
|
+
*/
|
|
16
|
+
export declare function compileSqliteSelectedObjectReadSource(projectId: string, scope: CompiledSelectedObjectReadScope, maxTraversalFacts: number): SqliteSelectedObjectReadSource;
|
|
17
|
+
//# sourceMappingURL=read-scope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-scope.d.ts","sourceRoot":"","sources":["../../src/objects/read-scope.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,oBAAoB,CAAA;AACzE,OAAO,EAEL,KAAK,uBAAuB,EAC5B,KAAK,WAAW,EAEjB,MAAM,kBAAkB,CAAA;AAEzB,MAAM,WAAW,8BAA+B,SAAQ,uBAAuB;IAC7E,QAAQ,CAAC,8BAA8B,EAAE,MAAM,CAAA;IAC/C,QAAQ,CAAC,cAAc,EAAE;QACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;QACpB,QAAQ,CAAC,IAAI,EAAE,SAAS,WAAW,EAAE,CAAA;KACtC,CAAA;CACF;AAED;;;;;GAKG;AACH,wBAAgB,qCAAqC,CACnD,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,+BAA+B,EACtC,iBAAiB,EAAE,MAAM,GACxB,8BAA8B,CAiDhC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { Database } from "bun:sqlite";
|
|
2
|
+
import type { CountObjectsInput, CountObjectsResult, ExistsObjectsInput, ExistsObjectsResult, FacetObjectsInput, FacetObjectsResult, LinkBatchKey, LinkDirection, ObjectBatchKey, ObjectLinkRow, ObjectReadStorage, ObjectRow, QueryObjectLinksInput, QueryObjectLinksResult, QueryObjectsInput, QueryObjectsResult } from "@sixb/core/storage";
|
|
3
|
+
import { type SqliteObjectQuerySource } from "./query-compiler";
|
|
4
|
+
import type { SqliteSelectedObjectReadSource } from "./read-scope";
|
|
5
|
+
/** Synchronous SQL reads over one explicit source; transaction and budget ownership stay outside. */
|
|
6
|
+
export declare class SqliteObjectReader {
|
|
7
|
+
private readonly db;
|
|
8
|
+
private readonly source;
|
|
9
|
+
constructor(db: Database, source: SqliteObjectQuerySource | SqliteSelectedObjectReadSource);
|
|
10
|
+
queryObjects(params: QueryObjectsInput): QueryObjectsResult;
|
|
11
|
+
countObjects(params: CountObjectsInput): CountObjectsResult;
|
|
12
|
+
existsObjects(params: ExistsObjectsInput): ExistsObjectsResult;
|
|
13
|
+
facetObjects(params: FacetObjectsInput): FacetObjectsResult;
|
|
14
|
+
getByPrimaryId(params: {
|
|
15
|
+
projectId: string;
|
|
16
|
+
objectTypeId: string;
|
|
17
|
+
primaryId: string;
|
|
18
|
+
}): ObjectRow | null;
|
|
19
|
+
selectsObjectProperties(params: Parameters<ObjectReadStorage["selectsObjectProperties"]>[0]): readonly boolean[];
|
|
20
|
+
listLinks(params: {
|
|
21
|
+
projectId: string;
|
|
22
|
+
objectTypeId: string;
|
|
23
|
+
objectId: string;
|
|
24
|
+
linkId?: string;
|
|
25
|
+
direction?: LinkDirection;
|
|
26
|
+
}): readonly ObjectLinkRow[];
|
|
27
|
+
getByPrimaryIdBatch(params: {
|
|
28
|
+
projectId: string;
|
|
29
|
+
items: readonly {
|
|
30
|
+
objectTypeId: string;
|
|
31
|
+
primaryId: string;
|
|
32
|
+
}[];
|
|
33
|
+
}): Map<ObjectBatchKey, ObjectRow>;
|
|
34
|
+
listLinksBatch(params: {
|
|
35
|
+
projectId: string;
|
|
36
|
+
direction?: LinkDirection;
|
|
37
|
+
items: readonly {
|
|
38
|
+
objectTypeId: string;
|
|
39
|
+
objectId: string;
|
|
40
|
+
linkId: string;
|
|
41
|
+
}[];
|
|
42
|
+
}): Map<LinkBatchKey, ObjectLinkRow[]>;
|
|
43
|
+
queryLinks(params: QueryObjectLinksInput): QueryObjectLinksResult;
|
|
44
|
+
list(params: Parameters<ObjectReadStorage["list"]>[0]): {
|
|
45
|
+
objects: readonly ObjectRow[];
|
|
46
|
+
hasMore: boolean;
|
|
47
|
+
total: number;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export declare function assertLinkQueryLimit(limit: number): void;
|
|
51
|
+
//# sourceMappingURL=reader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reader.d.ts","sourceRoot":"","sources":["../../src/objects/reader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAE1C,OAAO,KAAK,EACV,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,EACZ,aAAa,EACb,cAAc,EAEd,aAAa,EACb,iBAAiB,EACjB,SAAS,EACT,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EAGL,KAAK,uBAAuB,EAC7B,MAAM,kBAAkB,CAAA;AACzB,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,cAAc,CAAA;AAUlE,qGAAqG;AACrG,qBAAa,kBAAkB;IAE3B,OAAO,CAAC,QAAQ,CAAC,EAAE;IACnB,OAAO,CAAC,QAAQ,CAAC,MA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,CAAA;KAC7E,GAAG,GAAG,CAAC,YAAY,EAAE,aAAa,EAAE,CAAC;IA+CtC,UAAU,CAAC,MAAM,EAAE,qBAAqB,GAAG,sBAAsB;IAiFjE,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG;QACtD,OAAO,EAAE,SAAS,SAAS,EAAE,CAAA;QAC7B,OAAO,EAAE,OAAO,CAAA;QAChB,KAAK,EAAE,MAAM,CAAA;KACd;CA6EF;AAYD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAIxD"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ObjectLinkRow, ObjectRow } from "@sixb/core/storage";
|
|
2
|
+
export declare function rowToObject(row: DatabaseRow): ObjectRow;
|
|
3
|
+
/** Decode an expanded query row with the same shape as Core link hydration. */
|
|
4
|
+
export declare function queryRowToObject(row: ObjectQueryDatabaseRow): ObjectRow;
|
|
5
|
+
export declare function rowToLink(row: LinkDatabaseRow): ObjectLinkRow;
|
|
6
|
+
export interface DatabaseRow {
|
|
7
|
+
project_id: string;
|
|
8
|
+
object_type_id: string;
|
|
9
|
+
primary_id: string;
|
|
10
|
+
properties: string;
|
|
11
|
+
created_at: string;
|
|
12
|
+
updated_at: string;
|
|
13
|
+
version: number;
|
|
14
|
+
last_commit_id: string;
|
|
15
|
+
}
|
|
16
|
+
export interface ObjectQueryDatabaseRow extends DatabaseRow {
|
|
17
|
+
_cursor_properties?: string;
|
|
18
|
+
/** `json_object(linkId, value, ...)` serialized text from an `expand` pushdown; absent otherwise. */
|
|
19
|
+
_expand?: string | null;
|
|
20
|
+
}
|
|
21
|
+
export interface LinkDatabaseRow {
|
|
22
|
+
project_id: string;
|
|
23
|
+
source_type_id: string;
|
|
24
|
+
source_id: string;
|
|
25
|
+
link_id: string;
|
|
26
|
+
target_type_id: string;
|
|
27
|
+
target_id: string;
|
|
28
|
+
properties: string | null;
|
|
29
|
+
created_at: string;
|
|
30
|
+
updated_at: string;
|
|
31
|
+
last_commit_id: string;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=rows.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rows.d.ts","sourceRoot":"","sources":["../../src/objects/rows.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,aAAa,EACb,SAAS,EAEV,MAAM,oBAAoB,CAAA;AAE3B,wBAAgB,WAAW,CAAC,GAAG,EAAE,WAAW,GAAG,SAAS,CAWvD;AAED,+EAA+E;AAC/E,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,sBAAsB,GAAG,SAAS,CAIvE;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,eAAe,GAAG,aAAa,CAa7D;AAqDD,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAA;IAClB,cAAc,EAAE,MAAM,CAAA;IACtB,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,MAAM,CAAA;IACf,cAAc,EAAE,MAAM,CAAA;CACvB;AAED,MAAM,WAAW,sBAAuB,SAAQ,WAAW;IACzD,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,qGAAqG;IACrG,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACxB;AAED,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,MAAM,CAAA;IAClB,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;IACf,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,cAAc,EAAE,MAAM,CAAA;CACvB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Database } from "bun:sqlite";
|
|
2
|
+
import type { CompiledSelectedObjectReadScope, ObjectQueryCapabilities, ObjectReadExecutionLimits, ObjectReadStorage } from "@sixb/core/storage";
|
|
3
|
+
/** Keep the traversal probe and every terminal statement in the same synchronous snapshot. */
|
|
4
|
+
export declare function createSqliteSelectedReader(db: Database, params: {
|
|
5
|
+
projectId: string;
|
|
6
|
+
scope: CompiledSelectedObjectReadScope;
|
|
7
|
+
limits: ObjectReadExecutionLimits;
|
|
8
|
+
}, queryCapabilities: () => ObjectQueryCapabilities): ObjectReadStorage;
|
|
9
|
+
//# sourceMappingURL=selected-reader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selected-reader.d.ts","sourceRoot":"","sources":["../../src/objects/selected-reader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAC1C,OAAO,KAAK,EACV,+BAA+B,EAC/B,uBAAuB,EACvB,yBAAyB,EACzB,iBAAiB,EAClB,MAAM,oBAAoB,CAAA;AAe3B,8FAA8F;AAC9F,wBAAgB,0BAA0B,CACxC,EAAE,EAAE,QAAQ,EACZ,MAAM,EAAE;IACN,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,+BAA+B,CAAA;IACtC,MAAM,EAAE,yBAAyB,CAAA;CAClC,EACD,iBAAiB,EAAE,MAAM,uBAAuB,GAC/C,iBAAiB,CA2EnB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { CountObjectsInput, CountObjectsResult, ExistsObjectsInput, ExistsObjectsResult, FacetObjectsInput, FacetObjectsResult, LinkBatchKey, LinkDirection, ObjectBatchKey, ObjectLinkRow, ObjectQueryCapabilities, ObjectRow, ObjectStorage, QueryObjectLinksInput, QueryObjectLinksResult, QueryObjectsInput, QueryObjectsResult } from "@sixb/core/storage";
|
|
2
|
-
import { type SqliteStoreConnection } from "
|
|
1
|
+
import type { CompiledSelectedObjectReadScope, CountObjectsInput, CountObjectsResult, ExistsObjectsInput, ExistsObjectsResult, FacetObjectsInput, FacetObjectsResult, LinkBatchKey, LinkDirection, ObjectBatchKey, ObjectLinkRow, ObjectQueryCapabilities, ObjectReadExecutionLimits, ObjectReadStorage, ObjectRow, ObjectStorage, QueryObjectLinksInput, QueryObjectLinksResult, QueryObjectsInput, QueryObjectsResult } from "@sixb/core/storage";
|
|
2
|
+
import { type SqliteStoreConnection } from "../transactions";
|
|
3
3
|
export interface SqliteObjectStorageOptions {
|
|
4
4
|
/** Path to SQLite database file. Defaults to ':memory:' for in-memory database. */
|
|
5
5
|
path?: string;
|
|
@@ -15,8 +15,14 @@ export interface SqliteObjectStorageOptions {
|
|
|
15
15
|
export declare class SqliteObjectStorage implements ObjectStorage {
|
|
16
16
|
private readonly connection;
|
|
17
17
|
private readonly db;
|
|
18
|
+
private readonly reader;
|
|
18
19
|
constructor(options?: SqliteObjectStorageOptions);
|
|
19
20
|
queryCapabilities(): ObjectQueryCapabilities;
|
|
21
|
+
createSelectedReadScope(params: {
|
|
22
|
+
projectId: string;
|
|
23
|
+
scope: CompiledSelectedObjectReadScope;
|
|
24
|
+
limits: ObjectReadExecutionLimits;
|
|
25
|
+
}): ObjectReadStorage;
|
|
20
26
|
queryObjects(params: QueryObjectsInput): Promise<QueryObjectsResult>;
|
|
21
27
|
countObjects(params: CountObjectsInput): Promise<CountObjectsResult>;
|
|
22
28
|
existsObjects(params: ExistsObjectsInput): Promise<ExistsObjectsResult>;
|
|
@@ -26,6 +32,7 @@ export declare class SqliteObjectStorage implements ObjectStorage {
|
|
|
26
32
|
objectTypeId: string;
|
|
27
33
|
primaryId: string;
|
|
28
34
|
}): Promise<ObjectRow | null>;
|
|
35
|
+
selectsObjectProperties(params: Parameters<ObjectReadStorage["selectsObjectProperties"]>[0]): Promise<readonly boolean[]>;
|
|
29
36
|
listLinks(params: {
|
|
30
37
|
projectId: string;
|
|
31
38
|
objectTypeId: string;
|
|
@@ -42,6 +49,7 @@ export declare class SqliteObjectStorage implements ObjectStorage {
|
|
|
42
49
|
}): Promise<Map<ObjectBatchKey, ObjectRow>>;
|
|
43
50
|
listLinksBatch(params: {
|
|
44
51
|
projectId: string;
|
|
52
|
+
direction?: LinkDirection;
|
|
45
53
|
items: readonly {
|
|
46
54
|
objectTypeId: string;
|
|
47
55
|
objectId: string;
|
|
@@ -83,12 +91,7 @@ export declare class SqliteObjectStorage implements ObjectStorage {
|
|
|
83
91
|
hasMore: boolean;
|
|
84
92
|
total: number;
|
|
85
93
|
}>;
|
|
86
|
-
|
|
87
|
-
private queryRowToObject;
|
|
88
|
-
private rowToLink;
|
|
89
|
-
/**
|
|
90
|
-
* Close the database connection.
|
|
91
|
-
*/
|
|
94
|
+
/** Close the connection only when this provider owns it. */
|
|
92
95
|
close(): void;
|
|
93
96
|
}
|
|
94
|
-
//# sourceMappingURL=
|
|
97
|
+
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/objects/storage.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,+BAA+B,EAC/B,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,EACZ,aAAa,EACb,cAAc,EACd,aAAa,EACb,uBAAuB,EACvB,yBAAyB,EACzB,iBAAiB,EACjB,SAAS,EACT,aAAa,EACb,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EAGL,KAAK,qBAAqB,EAC3B,MAAM,iBAAiB,CAAA;AAMxB,MAAM,WAAW,0BAA0B;IACzC,mFAAmF;IACnF,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,gEAAgE;IAChE,U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AM,GAAG,SAAS,MAAM,EAAE,CAAA;QACzC,eAAe,CAAC,EAAE,MAAM,CAAA;QACxB,eAAe,CAAC,EAAE,MAAM,CAAA;QACxB,YAAY,CAAC,EAAE,IAAI,CAAA;QACnB,aAAa,CAAC,EAAE,IAAI,CAAA;QACpB,YAAY,CAAC,EAAE,IAAI,CAAA;QACnB,aAAa,CAAC,EAAE,IAAI,CAAA;QACpB,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,OAAO,CAAC,EAAE,WAAW,GAAG,WAAW,GAAG,WAAW,CAAA;QACjD,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,CAAA;KACvB,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,SAAS,SAAS,EAAE,CAAC;QAAC,OAAO,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAI/E,4DAA4D;IAC5D,KAAK,IAAI,IAAI;CAGd"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { CreateShareGrantInput, GetShareGrantByIdInput, ListShareGrantsInput, ListShareGrantsResult, RevokeShareGrantInput, ShareGrantRecord, ShareGrantStorage } from "@sixb/core/storage";
|
|
2
|
+
import { type SqliteStoreConnection } from "./transactions";
|
|
3
|
+
export interface SqliteShareGrantStorageOptions {
|
|
4
|
+
readonly path?: string;
|
|
5
|
+
readonly connection?: SqliteStoreConnection;
|
|
6
|
+
}
|
|
7
|
+
/** SQLite persistence for issued Share grants. Secret handling remains in Core. */
|
|
8
|
+
export declare class SqliteShareGrantStorage implements ShareGrantStorage {
|
|
9
|
+
private readonly connection;
|
|
10
|
+
private readonly db;
|
|
11
|
+
constructor(options?: SqliteShareGrantStorageOptions);
|
|
12
|
+
create(input: CreateShareGrantInput): Promise<ShareGrantRecord>;
|
|
13
|
+
getById(input: GetShareGrantByIdInput): Promise<ShareGrantRecord | null>;
|
|
14
|
+
list(input: ListShareGrantsInput): Promise<ListShareGrantsResult>;
|
|
15
|
+
revoke(input: RevokeShareGrantInput): Promise<ShareGrantRecord | null>;
|
|
16
|
+
close(): void;
|
|
17
|
+
private getRow;
|
|
18
|
+
private require;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=share-grant-storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"share-grant-storage.d.ts","sourceRoot":"","sources":["../src/share-grant-storage.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,oBAAoB,CAAA;AAI3B,OAAO,EAGL,KAAK,qBAAqB,EAC3B,MAAM,gBAAgB,CAAA;AAEvB,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,UAAU,CAAC,EAAE,qBAAqB,CAAA;CAC5C;AAED,mFAAmF;AACnF,qBAAa,uBAAwB,YAAW,iBAAiB;IAC/D,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAuB;IAClD,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAU;gBAEjB,OAAO,GAAE,8BAAmC;IAMlD,MAAM,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IA0C/D,OAAO,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAKxE,IAAI,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAwCjE,MAAM,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAwB5E,KAAK,IAAI,IAAI;IAIb,OAAO,CAAC,MAAM;IAOd,OAAO,CAAC,OAAO;CAUhB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { CreateShareSessionInput, GetShareSessionByIdInput, RenewShareSessionIfValidInput, RevokeShareSessionInput, ShareSessionRecord, ShareSessionStorage } from "@sixb/core/storage";
|
|
2
|
+
import { type SqliteStoreConnection } from "./transactions";
|
|
3
|
+
export interface SqliteShareSessionStorageOptions {
|
|
4
|
+
readonly path?: string;
|
|
5
|
+
readonly connection?: SqliteStoreConnection;
|
|
6
|
+
}
|
|
7
|
+
/** SQLite persistence for short-lived Share access sessions. */
|
|
8
|
+
export declare class SqliteShareSessionStorage implements ShareSessionStorage {
|
|
9
|
+
private readonly connection;
|
|
10
|
+
private readonly db;
|
|
11
|
+
constructor(options?: SqliteShareSessionStorageOptions);
|
|
12
|
+
create(input: CreateShareSessionInput): Promise<ShareSessionRecord>;
|
|
13
|
+
getById(input: GetShareSessionByIdInput): Promise<ShareSessionRecord | null>;
|
|
14
|
+
renewIfValid(input: RenewShareSessionIfValidInput): Promise<ShareSessionRecord | null>;
|
|
15
|
+
revoke(input: RevokeShareSessionInput): Promise<ShareSessionRecord | null>;
|
|
16
|
+
close(): void;
|
|
17
|
+
private getRow;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=share-session-storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"share-session-storage.d.ts","sourceRoot":"","sources":["../src/share-session-storage.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,uBAAuB,EACvB,wBAAwB,EACxB,6BAA6B,EAC7B,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,oBAAoB,CAAA;AAI3B,OAAO,EAGL,KAAK,qBAAqB,EAC3B,MAAM,gBAAgB,CAAA;AAEvB,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,UAAU,CAAC,EAAE,qBAAqB,CAAA;CAC5C;AAED,gEAAgE;AAChE,qBAAa,yBAA0B,YAAW,mBAAmB;IACnE,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAuB;IAClD,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAU;gBAEjB,OAAO,GAAE,gCAAqC;IAMpD,MAAM,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA2CnE,OAAO,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;IAK5E,YAAY,CAAC,KAAK,EAAE,6BAA6B,GAAG,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;IAuCtF,MAAM,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;IAsBhF,KAAK,IAAI,IAAI;IAIb,OAAO,CAAC,MAAM;CAMf"}
|
package/dist/storage-errors.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-errors.d.ts","sourceRoot":"","sources":["../src/storage-errors.ts"],"names":[],"mappings":"AAAA,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAE/D"}
|
|
1
|
+
{"version":3,"file":"storage-errors.d.ts","sourceRoot":"","sources":["../src/storage-errors.ts"],"names":[],"mappings":"AAAA,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAE/D;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAEnE"}
|
package/dist/transactions.d.ts
CHANGED
|
@@ -15,4 +15,12 @@ export declare function runImmediateTransaction<T>(db: Database, run: () => T):
|
|
|
15
15
|
/** Lets timers and request handlers run between bounded synchronous SQLite chunks. */
|
|
16
16
|
export declare function yieldSqliteEventLoop(): Promise<void>;
|
|
17
17
|
export declare function runImmediateTransactionAsync<T>(db: Database, run: () => Promise<T> | T): Promise<T>;
|
|
18
|
+
/**
|
|
19
|
+
* Run a multi-statement read against one proven SQLite snapshot.
|
|
20
|
+
*
|
|
21
|
+
* A provider-owned immediate transaction already has a stable snapshot and may be reused. Any
|
|
22
|
+
* other pre-existing transaction is rejected because this provider cannot prove who owns it or
|
|
23
|
+
* which lifecycle will close it.
|
|
24
|
+
*/
|
|
25
|
+
export declare function runDeferredReadTransaction<T>(db: Database, run: () => T): T;
|
|
18
26
|
//# sourceMappingURL=transactions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transactions.d.ts","sourceRoot":"","sources":["../src/transactions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAK1C,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAA;IACrB,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAA;IAChC,QAAQ,CAAC,kBAAkB,EAAE,OAAO,CAAA;CACrC;AAED,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,UAAU,CAAC,EAAE,qBAAqB,CAAA;IAC3C,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAC5B;AAED,wBAAgB,yBAAyB,CACvC,OAAO,GAAE,4BAAiC,GACzC,qBAAqB,CAmBvB;AAED,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,qBAAqB,GAAG,IAAI,CAIlF;
|
|
1
|
+
{"version":3,"file":"transactions.d.ts","sourceRoot":"","sources":["../src/transactions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAK1C,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAA;IACrB,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAA;IAChC,QAAQ,CAAC,kBAAkB,EAAE,OAAO,CAAA;CACrC;AAED,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,UAAU,CAAC,EAAE,qBAAqB,CAAA;IAC3C,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAC5B;AAED,wBAAgB,yBAAyB,CACvC,OAAO,GAAE,4BAAiC,GACzC,qBAAqB,CAmBvB;AAED,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,qBAAqB,GAAG,IAAI,CAIlF;AAKD,wBAAgB,uBAAuB,CAAC,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,CAkBxE;AAED,sFAAsF;AACtF,wBAAgB,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC,CAEpD;AAED,wBAAsB,4BAA4B,CAAC,CAAC,EAClD,EAAE,EAAE,QAAQ,EACZ,GAAG,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,GACxB,OAAO,CAAC,CAAC,CAAC,CAkBZ;AAED;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,CAsB3E"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sixb/sqlite",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "SQLite storage provider for Sixb",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sixb",
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
"prepack": "bun run build"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@sixb/core": "0.1.
|
|
39
|
+
"@sixb/core": "0.1.8"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@sixb/core": "0.1.
|
|
42
|
+
"@sixb/core": "0.1.8",
|
|
43
43
|
"@types/bun": "latest",
|
|
44
44
|
"typescript": "^5.7.0"
|
|
45
45
|
},
|
package/src/execution-storage.ts
CHANGED
|
@@ -6,14 +6,20 @@ import {
|
|
|
6
6
|
normalizeExecutionRecord,
|
|
7
7
|
validateExecutionRecordReferences,
|
|
8
8
|
} from "@sixb/core/internal/execution-storage"
|
|
9
|
-
import type {
|
|
9
|
+
import type {
|
|
10
|
+
CreateExecutionInput,
|
|
11
|
+
ExecutionRecord,
|
|
12
|
+
ExecutionStorage,
|
|
13
|
+
ShareSessionStorage,
|
|
14
|
+
} from "@sixb/core/storage"
|
|
10
15
|
import { ExecutionStorageError } from "@sixb/core/storage"
|
|
11
16
|
import type { SqliteAuthStorage } from "./auth-storage"
|
|
12
17
|
|
|
13
18
|
export class SqliteExecutionStorage implements ExecutionStorage {
|
|
14
19
|
constructor(
|
|
15
20
|
private readonly db: Database,
|
|
16
|
-
private readonly auth: SqliteAuthStorage
|
|
21
|
+
private readonly auth: SqliteAuthStorage,
|
|
22
|
+
private readonly shareSessions: Pick<ShareSessionStorage, "getById">
|
|
17
23
|
) {}
|
|
18
24
|
|
|
19
25
|
async create(input: CreateExecutionInput): Promise<ExecutionRecord> {
|
|
@@ -21,6 +27,7 @@ export class SqliteExecutionStorage implements ExecutionStorage {
|
|
|
21
27
|
await validateExecutionRecordReferences(record, {
|
|
22
28
|
auth: this.auth,
|
|
23
29
|
getExecution: (params) => this.getById(params),
|
|
30
|
+
getShareSession: (params) => this.shareSessions.getById(params),
|
|
24
31
|
})
|
|
25
32
|
const row = executionRecordToStorageRow(record)
|
|
26
33
|
|
|
@@ -47,8 +54,11 @@ export class SqliteExecutionStorage implements ExecutionStorage {
|
|
|
47
54
|
authority_primitive_kind,
|
|
48
55
|
authority_primitive_id,
|
|
49
56
|
authority_kernel_operation,
|
|
57
|
+
authority_delegation_kind,
|
|
58
|
+
authority_delegation_id,
|
|
59
|
+
authority_delegation_session_id,
|
|
50
60
|
created_at
|
|
51
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
61
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
52
62
|
`
|
|
53
63
|
)
|
|
54
64
|
.run(
|
|
@@ -70,6 +80,9 @@ export class SqliteExecutionStorage implements ExecutionStorage {
|
|
|
70
80
|
row.authorityPrimitiveKind,
|
|
71
81
|
row.authorityPrimitiveId,
|
|
72
82
|
row.authorityKernelOperation,
|
|
83
|
+
row.authorityDelegationKind,
|
|
84
|
+
row.authorityDelegationId,
|
|
85
|
+
row.authorityDelegationSessionId,
|
|
73
86
|
row.createdAt.toISOString()
|
|
74
87
|
)
|
|
75
88
|
} catch (error) {
|
|
@@ -124,6 +137,9 @@ function toStorageRow(row: SqliteExecutionRow): ExecutionStorageRow {
|
|
|
124
137
|
authorityPrimitiveKind: row.authority_primitive_kind,
|
|
125
138
|
authorityPrimitiveId: row.authority_primitive_id,
|
|
126
139
|
authorityKernelOperation: row.authority_kernel_operation,
|
|
140
|
+
authorityDelegationKind: row.authority_delegation_kind,
|
|
141
|
+
authorityDelegationId: row.authority_delegation_id,
|
|
142
|
+
authorityDelegationSessionId: row.authority_delegation_session_id,
|
|
127
143
|
createdAt: new Date(row.created_at),
|
|
128
144
|
}
|
|
129
145
|
}
|
|
@@ -154,5 +170,8 @@ interface SqliteExecutionRow {
|
|
|
154
170
|
readonly authority_primitive_kind: ExecutionStorageRow["authorityPrimitiveKind"]
|
|
155
171
|
readonly authority_primitive_id: string | null
|
|
156
172
|
readonly authority_kernel_operation: ExecutionStorageRow["authorityKernelOperation"]
|
|
173
|
+
readonly authority_delegation_kind: ExecutionStorageRow["authorityDelegationKind"]
|
|
174
|
+
readonly authority_delegation_id: string | null
|
|
175
|
+
readonly authority_delegation_session_id: string | null
|
|
157
176
|
readonly created_at: string
|
|
158
177
|
}
|
package/src/index.ts
CHANGED
|
@@ -13,6 +13,7 @@ import { ProviderMaterializationTransactionLifecycle } from "@sixb/core/internal
|
|
|
13
13
|
import {
|
|
14
14
|
createAgentOperationScope,
|
|
15
15
|
createAuthOperationScope,
|
|
16
|
+
createObjectOperationScope,
|
|
16
17
|
createOntologyOperationScope,
|
|
17
18
|
createOperationScopedFacade,
|
|
18
19
|
createStorageOperationScope,
|
|
@@ -23,6 +24,8 @@ import {
|
|
|
23
24
|
type AiLimitStorage,
|
|
24
25
|
type AiUsageStorage,
|
|
25
26
|
createTransactionStorageProxy,
|
|
27
|
+
type ShareGrantStorage,
|
|
28
|
+
type ShareSessionStorage,
|
|
26
29
|
StorageTransactionError,
|
|
27
30
|
throwNestedStorageTransaction,
|
|
28
31
|
} from "@sixb/core/storage"
|
|
@@ -39,11 +42,13 @@ import {
|
|
|
39
42
|
installFreshSqliteSchema,
|
|
40
43
|
sqliteStoragePath,
|
|
41
44
|
} from "./migrations"
|
|
42
|
-
import { SqliteObjectStorage } from "./
|
|
45
|
+
import { SqliteObjectStorage } from "./objects"
|
|
43
46
|
import { SqliteOntologyStorage, type SqliteOntologyTransactionContext } from "./ontology-storage"
|
|
44
47
|
import { SqlitePipelineRunStorage } from "./pipeline-run-storage"
|
|
45
48
|
import { SqliteProjectionRunStorage } from "./projection-run-storage"
|
|
46
49
|
import { SqliteRulesStorage } from "./rules-storage"
|
|
50
|
+
import { SqliteShareGrantStorage } from "./share-grant-storage"
|
|
51
|
+
import { SqliteShareSessionStorage } from "./share-session-storage"
|
|
47
52
|
import { SqliteSyncRunStorage } from "./sync-run-storage"
|
|
48
53
|
import { registerSqliteStorageTestingAdapter } from "./testing"
|
|
49
54
|
import { SqliteTimeseriesStorage } from "./timeseries-storage"
|
|
@@ -96,6 +101,8 @@ export class SqliteStorage implements MigrationCapableStorage {
|
|
|
96
101
|
readonly timeseries: Storage["timeseries"]
|
|
97
102
|
readonly webhookRuns: SqliteWebhookRunStorage
|
|
98
103
|
readonly rules: SqliteRulesStorage
|
|
104
|
+
readonly shareGrants: ShareGrantStorage
|
|
105
|
+
readonly shareSessions: ShareSessionStorage
|
|
99
106
|
readonly connectorConnections: SqliteConnectorConnectionStorage
|
|
100
107
|
readonly migrators: readonly StorageMigrator[]
|
|
101
108
|
|
|
@@ -143,7 +150,7 @@ export class SqliteStorage implements MigrationCapableStorage {
|
|
|
143
150
|
const readTimeseries = path
|
|
144
151
|
? new SqliteTimeseriesStorage({ connection: this.readConnection })
|
|
145
152
|
: stores.timeseries
|
|
146
|
-
this.objects =
|
|
153
|
+
this.objects = createObjectOperationScope(readObjects, readScope)
|
|
147
154
|
this.ontology = createOntologyOperationScope(stores.ontology, ontologyScope)
|
|
148
155
|
this.auth = createAuthOperationScope(stores.auth, scope)
|
|
149
156
|
this.executions = createOperationScopedFacade(stores.executions, scope)
|
|
@@ -160,6 +167,8 @@ export class SqliteStorage implements MigrationCapableStorage {
|
|
|
160
167
|
this.workflowInterventions = createOperationScopedFacade(stores.workflowInterventions, scope)
|
|
161
168
|
this.webhookRuns = createOperationScopedFacade(stores.webhookRuns, scope)
|
|
162
169
|
this.rules = createOperationScopedFacade(stores.rules, scope)
|
|
170
|
+
this.shareGrants = createOperationScopedFacade(stores.shareGrants, scope)
|
|
171
|
+
this.shareSessions = createOperationScopedFacade(stores.shareSessions, scope)
|
|
163
172
|
this.connectorConnections = createOperationScopedFacade(stores.connectorConnections, scope)
|
|
164
173
|
this.migrators = options.path ? createSqliteStorageMigrators(options.path) : []
|
|
165
174
|
registerSqliteStorageTestingAdapter(this, (durationMs) =>
|
|
@@ -294,7 +303,9 @@ function createSqliteStores(
|
|
|
294
303
|
}
|
|
295
304
|
): SqliteStoreSet {
|
|
296
305
|
const auth = new SqliteAuthStorage({ connection })
|
|
297
|
-
const
|
|
306
|
+
const shareGrants = new SqliteShareGrantStorage({ connection })
|
|
307
|
+
const shareSessions = new SqliteShareSessionStorage({ connection })
|
|
308
|
+
const executions = new SqliteExecutionStorage(connection.db, auth, shareSessions)
|
|
298
309
|
return {
|
|
299
310
|
objects: new SqliteObjectStorage({ connection }),
|
|
300
311
|
ontology: new SqliteOntologyStorage({
|
|
@@ -317,6 +328,8 @@ function createSqliteStores(
|
|
|
317
328
|
workflowInterventions: new SqliteWorkflowInterventionStorage({ connection }),
|
|
318
329
|
webhookRuns: new SqliteWebhookRunStorage({ connection, executions }),
|
|
319
330
|
rules: new SqliteRulesStorage({ connection }),
|
|
331
|
+
shareGrants,
|
|
332
|
+
shareSessions,
|
|
320
333
|
connectorConnections: new SqliteConnectorConnectionStorage(connection),
|
|
321
334
|
}
|
|
322
335
|
}
|
|
@@ -339,6 +352,8 @@ interface SqliteStoreSet {
|
|
|
339
352
|
readonly timeseries: SqliteTimeseriesStorage
|
|
340
353
|
readonly webhookRuns: SqliteWebhookRunStorage
|
|
341
354
|
readonly rules: SqliteRulesStorage
|
|
355
|
+
readonly shareGrants: SqliteShareGrantStorage
|
|
356
|
+
readonly shareSessions: SqliteShareSessionStorage
|
|
342
357
|
readonly connectorConnections: SqliteConnectorConnectionStorage
|
|
343
358
|
}
|
|
344
359
|
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
CREATE TABLE share_grants (
|
|
2
|
+
project_id TEXT NOT NULL CHECK (length(trim(project_id)) > 0),
|
|
3
|
+
id TEXT NOT NULL CHECK (length(trim(id)) > 0),
|
|
4
|
+
definition_id TEXT NOT NULL CHECK (length(trim(definition_id)) > 0),
|
|
5
|
+
target_object_type_id TEXT NOT NULL CHECK (length(trim(target_object_type_id)) > 0),
|
|
6
|
+
target_primary_id TEXT NOT NULL CHECK (length(trim(target_primary_id)) > 0),
|
|
7
|
+
issued_by_type TEXT NOT NULL CHECK (issued_by_type IN ('user', 'serviceAccount')),
|
|
8
|
+
issued_by_id TEXT NOT NULL CHECK (length(trim(issued_by_id)) > 0),
|
|
9
|
+
authority_version INTEGER NOT NULL CHECK (authority_version > 0),
|
|
10
|
+
authority_snapshot TEXT NOT NULL CHECK (
|
|
11
|
+
json_valid(authority_snapshot)
|
|
12
|
+
AND json_type(authority_snapshot) = 'object'
|
|
13
|
+
AND json_type(authority_snapshot, '$.version') = 'integer'
|
|
14
|
+
AND json_extract(authority_snapshot, '$.version') = authority_version
|
|
15
|
+
AND json_type(authority_snapshot, '$.access') = 'object'
|
|
16
|
+
),
|
|
17
|
+
authority_digest TEXT NOT NULL CHECK (
|
|
18
|
+
length(authority_digest) = 64
|
|
19
|
+
AND authority_digest = lower(authority_digest)
|
|
20
|
+
AND authority_digest NOT GLOB '*[^0-9a-f]*'
|
|
21
|
+
),
|
|
22
|
+
token_hash TEXT NOT NULL CHECK (
|
|
23
|
+
length(token_hash) = 64
|
|
24
|
+
AND token_hash = lower(token_hash)
|
|
25
|
+
AND token_hash NOT GLOB '*[^0-9a-f]*'
|
|
26
|
+
),
|
|
27
|
+
destination_path TEXT NOT NULL CHECK (
|
|
28
|
+
substr(destination_path, 1, 1) = '/'
|
|
29
|
+
AND instr(destination_path, '?') = 0
|
|
30
|
+
AND instr(destination_path, '#') = 0
|
|
31
|
+
AND instr(destination_path, char(92)) = 0
|
|
32
|
+
),
|
|
33
|
+
created_at TEXT NOT NULL,
|
|
34
|
+
expires_at TEXT NOT NULL,
|
|
35
|
+
revoked_at TEXT,
|
|
36
|
+
revoked_by_type TEXT CHECK (
|
|
37
|
+
revoked_by_type IS NULL OR revoked_by_type IN ('user', 'serviceAccount', 'system')
|
|
38
|
+
),
|
|
39
|
+
revoked_by_id TEXT CHECK (revoked_by_id IS NULL OR length(trim(revoked_by_id)) > 0),
|
|
40
|
+
PRIMARY KEY (project_id, id),
|
|
41
|
+
UNIQUE (project_id, token_hash),
|
|
42
|
+
CHECK (expires_at > created_at),
|
|
43
|
+
CHECK (revoked_at IS NULL OR revoked_at >= created_at),
|
|
44
|
+
CHECK (
|
|
45
|
+
(revoked_at IS NULL AND revoked_by_type IS NULL AND revoked_by_id IS NULL)
|
|
46
|
+
OR
|
|
47
|
+
(revoked_at IS NOT NULL AND revoked_by_type IS NOT NULL AND revoked_by_id IS NOT NULL)
|
|
48
|
+
)
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
CREATE INDEX idx_share_grants_target
|
|
52
|
+
ON share_grants (
|
|
53
|
+
project_id,
|
|
54
|
+
definition_id,
|
|
55
|
+
target_object_type_id,
|
|
56
|
+
target_primary_id,
|
|
57
|
+
created_at DESC,
|
|
58
|
+
id DESC
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
CREATE INDEX idx_share_grants_project_created
|
|
62
|
+
ON share_grants (project_id, created_at DESC, id DESC);
|
|
63
|
+
|
|
64
|
+
CREATE INDEX idx_share_grants_expiry
|
|
65
|
+
ON share_grants (project_id, expires_at)
|
|
66
|
+
WHERE revoked_at IS NULL;
|