@sixb/sqlite 0.1.7 → 0.1.9
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/action-run-storage.d.ts.map +1 -1
- package/dist/agents/rows.d.ts +0 -1
- package/dist/agents/rows.d.ts.map +1 -1
- package/dist/agents/runs.d.ts.map +1 -1
- package/dist/ai-cost-storage.d.ts.map +1 -1
- package/dist/ai-usage-storage.d.ts.map +1 -1
- 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 +1567 -430
- package/dist/index.js.map +25 -19
- 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/pipeline-run-storage.d.ts.map +1 -1
- 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/sync-run-storage.d.ts.map +1 -1
- package/dist/transactions.d.ts +8 -0
- package/dist/transactions.d.ts.map +1 -1
- package/dist/workflow-run-storage.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/action-run-storage.ts +6 -7
- package/src/agents/rows.ts +0 -2
- package/src/agents/runs.ts +3 -7
- package/src/ai-cost-groups.ts +3 -0
- package/src/ai-cost-storage.ts +11 -2
- package/src/ai-usage-storage.ts +1 -2
- package/src/execution-storage.ts +28 -7
- package/src/index.ts +22 -5
- package/src/migrations/035-share-grants.sql +66 -0
- package/src/migrations/036-share-sessions.sql +226 -0
- package/src/migrations/037-execution-requester-groups.sql +24 -0
- package/src/migrations.ts +9 -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/pipeline-run-storage.ts +2 -5
- 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/sync-run-storage.ts +2 -5
- package/src/transactions.ts +32 -0
- package/src/workflow-run-storage.ts +1 -6
- 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;A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|
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,I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DAA4D;AAC5D,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,kGAAkG;IAClG,aAAa,CACX,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE,SAAS,WAAW,EAAE,GAC5B;QACD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;QACpB,QAAQ,CAAC,IAAI,EAAE,SAAS,WAAW,EAAE,CAAA;KACtC,CAAA;IACD,SAAS,CAAC,KAAK,EAAE,mBAAmB,GAAG,mBAAmB,CAAA;CAC3D;AAED,eAAO,MAAM,2BAA2B,EAAE,uBAKzC,CAAA;AA+sBD,gGAAgG;AAChG,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMzD"}
|
|
@@ -0,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":"AAA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MAAM,CAAC,EAAE,MAAM,CAAA;QACf,SAAS,CAAC,EAAE,aAAa,CAAA;KAC1B,GAAG,SAAS,aAAa,EAAE;IAgC5B,mBAAmB,CAAC,MAAM,EAAE;QAC1B,SAAS,EAAE,MAAM,CAAA;QACjB,KAAK,EAAE,SAAS;YAAE,YAAY,EAAE,MAAM,CAAC;YAAC,SAAS,EAAE,MAAM,CAAA;SAAE,EAAE,CAAA;KAC9D,GAAG,GAAG,CAAC,cAAc,EAAE,SAAS,CAAC;IA4BlC,cAAc,CAAC,MAAM,EAAE;QACrB,SAAS,EAAE,MAAM,CAAA;QACjB,SAAS,CAAC,EAAE,aAAa,CAAA;QACzB,KAAK,EAAE,SAAS;YAAE,YAAY,EAAE,MAAM,CAAC;YAAC,QAAQ,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,EAAE,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
|
+
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":["../src/pipeline-run-storage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pipeline-run-storage.d.ts","sourceRoot":"","sources":["../src/pipeline-run-storage.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,gBAAgB,EAChB,sBAAsB,EACtB,0BAA0B,EAC1B,2BAA2B,EAC3B,4BAA4B,EAC5B,qBAAqB,EACrB,sBAAsB,EACtB,yBAAyB,EACzB,0BAA0B,EAC1B,iBAAiB,EACjB,kBAAkB,EAClB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,yBAAyB,EAC1B,MAAM,oBAAoB,CAAA;AAW3B,OAAO,EAGL,KAAK,qBAAqB,EAC3B,MAAM,gBAAgB,CAAA;AAEvB,MAAM,WAAW,+BAA+B;IAC9C,8DAA8D;IAC9D,UAAU,EAAE,gBAAgB,CAAA;IAC5B,mFAAmF;IACnF,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,gEAAgE;IAChE,UAAU,CAAC,EAAE,qBAAqB,CAAA;CACnC;AAED,qBAAa,wBAAyB,YAAW,kBAAkB;IACjE,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAuB;IAClD,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAU;IAC7B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAkB;gBAEjC,OAAO,EAAE,+BAA+B;IAU9C,KAAK,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,iBAAiB,CAAC;YAmDvD,0BAA0B;IAmClC,KAAK,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAgC/D,MAAM,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAwDjE,SAAS,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAgF3E,UAAU,CAAC,KAAK,EAAE,0BAA0B,GAAG,OAAO,CAAC,qBAAqB,CAAC;IA2D7E,OAAO,CAAC,MAAM,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC;IAQrF,IAAI,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAyCnE,uBAAuB,CAC3B,KAAK,EAAE,2BAA2B,GACjC,OAAO,CAAC,4BAA4B,CAAC;IAelC,SAAS,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,0BAA0B,CAAC;IAmDtF,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-run-storage.d.ts","sourceRoot":"","sources":["../src/sync-run-storage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sync-run-storage.d.ts","sourceRoot":"","sources":["../src/sync-run-storage.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,gBAAgB,EAChB,kBAAkB,EAClB,uBAAuB,EACvB,wBAAwB,EACxB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACb,cAAc,EACf,MAAM,oBAAoB,CAAA;AAU3B,OAAO,EAGL,KAAK,qBAAqB,EAC3B,MAAM,gBAAgB,CAAA;AAEvB,MAAM,WAAW,2BAA2B;IAC1C,8DAA8D;IAC9D,UAAU,EAAE,gBAAgB,CAAA;IAC5B,mFAAmF;IACnF,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,gEAAgE;IAChE,UAAU,CAAC,EAAE,qBAAqB,CAAA;CACnC;AAED,qBAAa,oBAAqB,YAAW,cAAc;IACzD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAuB;IAClD,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAU;IAC7B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAkB;gBAEjC,OAAO,EAAE,2BAA2B;IAU1C,KAAK,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,aAAa,CAAC;YA2D/C,0BAA0B;IAgClC,KAAK,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,aAAa,CAAC;IAgCvD,MAAM,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,aAAa,CAAC;IAyEzD,OAAO,CAAC,MAAM,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAQjF,IAAI,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA8C3D,mBAAmB,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAe5F,KAAK,IAAI,IAAI;CAGd"}
|
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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-run-storage.d.ts","sourceRoot":"","sources":["../src/workflow-run-storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"workflow-run-storage.d.ts","sourceRoot":"","sources":["../src/workflow-run-storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAO1C,OAAO,KAAK,EACV,+BAA+B,EAC/B,kDAAkD,EAClD,yCAAyC,EACzC,+BAA+B,EAC/B,gBAAgB,EAChB,+BAA+B,EAC/B,0BAA0B,EAC1B,sBAAsB,EACtB,2BAA2B,EAC3B,4BAA4B,EAC5B,8BAA8B,EAC9B,+BAA+B,EAC/B,yBAAyB,EACzB,0BAA0B,EAC1B,qBAAqB,EACrB,sBAAsB,EACtB,q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AG,OAAO,CAAC,+BAA+B,CAAC;IAqB3F,OAAO,CAAC,OAAO;IAYf,OAAO,CAAC,aAAa;CAoBtB;AAED,qBAAa,4BAA6B,YAAW,sBAAsB;IAC7D,OAAO,CAAC,QAAQ,CAAC,EAAE;gBAAF,EAAE,EAAE,QAAQ;IAEnC,KAAK,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAqFvE,MAAM,CAAC,KAAK,EAAE,0BAA0B,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAkDzE,IAAI,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAyCrE,OAAO,CAAC,MAAM,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC;IAQzF,IAAI,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,0BAA0B,CAAC;IAwDjF,OAAO,CAAC,yBAAyB;CAOlC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sixb/sqlite",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "SQLite storage provider for Sixb",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sixb",
|
|
@@ -36,16 +36,16 @@
|
|
|
36
36
|
"prepack": "bun run build"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@sixb/core": "0.1.
|
|
39
|
+
"@sixb/core": "0.1.9"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@sixb/core": "0.1.
|
|
42
|
+
"@sixb/core": "0.1.9",
|
|
43
43
|
"@types/bun": "latest",
|
|
44
44
|
"typescript": "^5.7.0"
|
|
45
45
|
},
|
|
46
46
|
"license": "MIT",
|
|
47
47
|
"engines": {
|
|
48
|
-
"bun": ">=1.
|
|
48
|
+
"bun": ">=1.4.2"
|
|
49
49
|
},
|
|
50
50
|
"publishConfig": {
|
|
51
51
|
"access": "public"
|
|
@@ -5,6 +5,11 @@ import {
|
|
|
5
5
|
serializeActionRunFailure,
|
|
6
6
|
} from "@sixb/core/internal/action-run-storage"
|
|
7
7
|
import { assertActionRunExecution } from "@sixb/core/internal/action-run-storage-provider"
|
|
8
|
+
import {
|
|
9
|
+
actionRunPhaseRecordsEqual,
|
|
10
|
+
canRequeueActionRunAfterEnqueueFailure,
|
|
11
|
+
finishActionRunPhase,
|
|
12
|
+
} from "@sixb/core/internal/storage"
|
|
8
13
|
import type {
|
|
9
14
|
ActionRunEffectsRecord,
|
|
10
15
|
ActionRunFailure,
|
|
@@ -24,13 +29,7 @@ import type {
|
|
|
24
29
|
RecordActionWritebackInput,
|
|
25
30
|
StartActionRunInput,
|
|
26
31
|
} from "@sixb/core/storage"
|
|
27
|
-
import {
|
|
28
|
-
ActionRunError,
|
|
29
|
-
actionRunPhaseRecordsEqual,
|
|
30
|
-
canRequeueActionRunAfterEnqueueFailure,
|
|
31
|
-
finishActionRunPhase,
|
|
32
|
-
isTerminalActionRun,
|
|
33
|
-
} from "@sixb/core/storage"
|
|
32
|
+
import { ActionRunError, isTerminalActionRun } from "@sixb/core/storage"
|
|
34
33
|
import { installFreshSqliteSchema } from "./migrations"
|
|
35
34
|
import {
|
|
36
35
|
closeSqliteStoreConnection,
|
package/src/agents/rows.ts
CHANGED
|
@@ -42,7 +42,6 @@ export interface AgentRunRow {
|
|
|
42
42
|
spawn_key: string | null
|
|
43
43
|
spec: string | null
|
|
44
44
|
result: string | null
|
|
45
|
-
requester_group_ids: string
|
|
46
45
|
status: AgentRunRecord["status"]
|
|
47
46
|
model_id: string | null
|
|
48
47
|
finish_reason: string | null
|
|
@@ -111,7 +110,6 @@ export function rowToRunRecord(row: AgentRunRow): AgentRunRecord {
|
|
|
111
110
|
id: row.id,
|
|
112
111
|
projectId: row.project_id,
|
|
113
112
|
executionId: row.execution_id,
|
|
114
|
-
requesterGroupIds: JSON.parse(row.requester_group_ids) as string[],
|
|
115
113
|
status: row.status,
|
|
116
114
|
modelId: row.model_id ?? undefined,
|
|
117
115
|
finishReason: coerceAgentRunFinishReason(row.finish_reason),
|
package/src/agents/runs.ts
CHANGED
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
assertSubagentRunResult,
|
|
7
7
|
subagentRunMatchesCreateInput,
|
|
8
8
|
} from "@sixb/core/internal/agent-run-storage-provider"
|
|
9
|
-
import { normalizeRequesterGroupIds } from "@sixb/core/internal/auth"
|
|
10
9
|
import { serializeSixbFailure } from "@sixb/core/internal/errors"
|
|
11
10
|
import {
|
|
12
11
|
AGENT_RUN_FAILURE_CODES,
|
|
@@ -83,11 +82,10 @@ export class SqliteAgentRunStore implements AgentRunStore {
|
|
|
83
82
|
thread_id,
|
|
84
83
|
trigger_message_id,
|
|
85
84
|
spec,
|
|
86
|
-
requester_group_ids,
|
|
87
85
|
status,
|
|
88
86
|
attempt,
|
|
89
87
|
created_at
|
|
90
|
-
) VALUES (?, ?, ?, 'conversation', ?, ?, ?,
|
|
88
|
+
) VALUES (?, ?, ?, 'conversation', ?, ?, ?, 'queued', 0, ?)
|
|
91
89
|
`
|
|
92
90
|
)
|
|
93
91
|
.run(
|
|
@@ -97,7 +95,6 @@ export class SqliteAgentRunStore implements AgentRunStore {
|
|
|
97
95
|
input.threadId,
|
|
98
96
|
input.triggerMessageId,
|
|
99
97
|
JSON.stringify(input.spec),
|
|
100
|
-
JSON.stringify(normalizeRequesterGroupIds(input.requesterGroupIds)),
|
|
101
98
|
createdAt.toISOString()
|
|
102
99
|
)
|
|
103
100
|
} catch (error) {
|
|
@@ -197,8 +194,8 @@ export class SqliteAgentRunStore implements AgentRunStore {
|
|
|
197
194
|
`
|
|
198
195
|
INSERT INTO agent_runs (
|
|
199
196
|
project_id, id, execution_id, kind, parent_run_id, spawn_key, spec,
|
|
200
|
-
|
|
201
|
-
) VALUES (?, ?, ?, 'subagent', ?, ?, ?,
|
|
197
|
+
status, attempt, created_at
|
|
198
|
+
) VALUES (?, ?, ?, 'subagent', ?, ?, ?, 'queued', 0, ?)
|
|
202
199
|
`
|
|
203
200
|
)
|
|
204
201
|
.run(
|
|
@@ -208,7 +205,6 @@ export class SqliteAgentRunStore implements AgentRunStore {
|
|
|
208
205
|
input.parentRunId,
|
|
209
206
|
input.spawnKey,
|
|
210
207
|
JSON.stringify(input.spec),
|
|
211
|
-
parentRow.requester_group_ids,
|
|
212
208
|
(input.createdAt ?? new Date()).toISOString()
|
|
213
209
|
)
|
|
214
210
|
} catch (error) {
|
package/src/ai-cost-groups.ts
CHANGED
|
@@ -37,6 +37,7 @@ WITH filtered AS (
|
|
|
37
37
|
SELECT COALESCE(root_agent.execution_id, usage.execution_id) AS root_execution_id,
|
|
38
38
|
usage.execution_id, usage.provider_id, usage.requested_model_id, usage.occurred_at,
|
|
39
39
|
usage.total_tokens,
|
|
40
|
+
execution.executor_kind, execution.executor_id, execution.authority_primitive_id AS primitive_id,
|
|
40
41
|
COALESCE(cost.status, 'unvalued') AS valuation_status,
|
|
41
42
|
cost.currency AS amount_currency, cost.amount_nanos,
|
|
42
43
|
root_agent.id AS root_agent_run_id,
|
|
@@ -49,6 +50,7 @@ WITH filtered AS (
|
|
|
49
50
|
workflow_node.workflow_id AS workflow_id,
|
|
50
51
|
workflow_node.workflow_run_id AS workflow_run_id
|
|
51
52
|
FROM ai_model_call_usage AS usage
|
|
53
|
+
JOIN executions AS execution ON execution.project_id = usage.project_id AND execution.id = usage.execution_id
|
|
52
54
|
LEFT JOIN agent_runs AS direct_agent
|
|
53
55
|
ON direct_agent.project_id = usage.project_id AND direct_agent.execution_id = usage.execution_id
|
|
54
56
|
LEFT JOIN agent_runs AS root_agent
|
|
@@ -86,6 +88,7 @@ SELECT filtered.root_execution_id, execution_id, provider_id, requested_model_id
|
|
|
86
88
|
CAST(SUM((amount_nanos / 1000000) % 1000000) AS TEXT) AS amount_middle,
|
|
87
89
|
CAST(SUM(amount_nanos % 1000000) AS TEXT) AS amount_low,
|
|
88
90
|
MAX(root_agent_run_id) AS root_agent_run_id,
|
|
91
|
+
MAX(executor_kind) AS executor_kind, MAX(executor_id) AS executor_id, MAX(primitive_id) AS primitive_id,
|
|
89
92
|
MAX(root_thread_id) AS root_thread_id,
|
|
90
93
|
MAX(direct_kind) AS direct_kind,
|
|
91
94
|
MAX(direct_run_id) AS direct_run_id,
|
package/src/ai-cost-storage.ts
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
aiModelCallCostDetails,
|
|
5
5
|
aiModelCallCostMatchesUsage,
|
|
6
6
|
buildAiAccountingOverviewFromFragments,
|
|
7
|
+
directModelCallAttribution,
|
|
7
8
|
normalizeAiAccountingQuery,
|
|
8
9
|
normalizeAiModelCallAccountingQuery,
|
|
9
10
|
normalizeAiModelCallCostRecord,
|
|
@@ -199,6 +200,7 @@ const SQLITE_ACCOUNTING_LIST_PAGE_SQL = `
|
|
|
199
200
|
workflow_agent.node_run_id AS attribution_node_run_id,
|
|
200
201
|
workflow_node.workflow_id AS attribution_workflow_id,
|
|
201
202
|
workflow_node.workflow_run_id AS attribution_workflow_run_id,
|
|
203
|
+
execution.executor_kind, execution.executor_id, execution.authority_primitive_id AS primitive_id,
|
|
202
204
|
COALESCE((
|
|
203
205
|
SELECT json_group_array(group_id) FROM (
|
|
204
206
|
SELECT group_id FROM ai_model_call_usage_groups
|
|
@@ -215,6 +217,7 @@ const SQLITE_ACCOUNTING_LIST_PAGE_SQL = `
|
|
|
215
217
|
cost.details AS cost_details,
|
|
216
218
|
cost.rated_at AS cost_rated_at
|
|
217
219
|
FROM ai_model_call_usage AS usage
|
|
220
|
+
JOIN executions AS execution ON execution.project_id = usage.project_id AND execution.id = usage.execution_id
|
|
218
221
|
LEFT JOIN agent_runs AS direct_agent
|
|
219
222
|
ON direct_agent.project_id = usage.project_id
|
|
220
223
|
AND direct_agent.execution_id = usage.execution_id
|
|
@@ -250,7 +253,9 @@ const SQLITE_ACCOUNTING_OVERVIEW_SQL = `
|
|
|
250
253
|
ELSE NULL
|
|
251
254
|
END AS attribution_agent_kind,
|
|
252
255
|
workflow_node.node_id AS attribution_agent_step_id,
|
|
253
|
-
workflow_node.workflow_id
|
|
256
|
+
COALESCE(workflow_node.workflow_id,
|
|
257
|
+
CASE WHEN execution.executor_kind = 'workflow' THEN execution.authority_primitive_id END
|
|
258
|
+
) AS attribution_workflow_id,
|
|
254
259
|
CASE
|
|
255
260
|
WHEN cost.status = 'rated' THEN 'rated'
|
|
256
261
|
WHEN cost.status = 'unpriceable' THEN 'unpriceable'
|
|
@@ -259,6 +264,7 @@ const SQLITE_ACCOUNTING_OVERVIEW_SQL = `
|
|
|
259
264
|
CASE WHEN cost.status = 'rated' THEN cost.currency ELSE NULL END AS amount_currency,
|
|
260
265
|
CASE WHEN cost.status = 'rated' THEN cost.amount_nanos ELSE NULL END AS amount_nanos
|
|
261
266
|
FROM ai_model_call_usage AS usage
|
|
267
|
+
JOIN executions AS execution ON execution.project_id = usage.project_id AND execution.id = usage.execution_id
|
|
262
268
|
LEFT JOIN agent_runs AS direct_agent
|
|
263
269
|
ON direct_agent.project_id = usage.project_id
|
|
264
270
|
AND direct_agent.execution_id = usage.execution_id
|
|
@@ -393,6 +399,9 @@ interface UsageRow {
|
|
|
393
399
|
}
|
|
394
400
|
|
|
395
401
|
interface JoinedRow extends UsageRow {
|
|
402
|
+
readonly executor_kind: string | null
|
|
403
|
+
readonly executor_id: string | null
|
|
404
|
+
readonly primitive_id: string | null
|
|
396
405
|
readonly attribution_kind: "agent" | "subagent" | "workflowAgent" | null
|
|
397
406
|
readonly attribution_agent_step_id: string | null
|
|
398
407
|
readonly attribution_agent_run_id: string | null
|
|
@@ -534,7 +543,7 @@ function accountingItemFromRow(row: JoinedRow): AiAccountingRecordSetItem {
|
|
|
534
543
|
const cost = row.cost_status === null ? undefined : costFromJoinedRow(row)
|
|
535
544
|
const attribution =
|
|
536
545
|
row.attribution_kind === null
|
|
537
|
-
?
|
|
546
|
+
? directModelCallAttribution(row.executor_kind, row.executor_id, row.primitive_id)
|
|
538
547
|
: row.attribution_kind === "agent"
|
|
539
548
|
? {
|
|
540
549
|
kind: "agent" as const,
|
package/src/ai-usage-storage.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { assertAiUsageExecutionId, normalizeAiModelCallRecord } from "@sixb/core/internal/storage"
|
|
1
2
|
import { isModelReasoning, normalizeModelProviderIds } from "@sixb/core/models"
|
|
2
3
|
import type { ReadonlyJsonObject } from "@sixb/core/storage"
|
|
3
4
|
import {
|
|
@@ -7,9 +8,7 @@ import {
|
|
|
7
8
|
type AiUsageStorage,
|
|
8
9
|
AiUsageStorageError,
|
|
9
10
|
aggregateAiModelCallUsage,
|
|
10
|
-
assertAiUsageExecutionId,
|
|
11
11
|
type GetLatestAiModelCallForExecutionInput,
|
|
12
|
-
normalizeAiModelCallRecord,
|
|
13
12
|
type RecordAiModelCallInput,
|
|
14
13
|
type RecordAiModelCallResult,
|
|
15
14
|
type SummarizeAiUsageExecutionInput,
|