@sixb/pg 0.1.19 → 0.1.21
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/agents/threads.d.ts +4 -0
- package/dist/agents/threads.d.ts.map +1 -1
- package/dist/auth-storage/auth-storage.d.ts.map +1 -1
- package/dist/auth-storage/magic-links.d.ts.map +1 -1
- package/dist/auth-storage/oidc-attempts.d.ts.map +1 -1
- package/dist/auth-storage/rows.d.ts +0 -3
- package/dist/auth-storage/rows.d.ts.map +1 -1
- package/dist/auth-storage/sessions.d.ts +2 -11
- package/dist/auth-storage/sessions.d.ts.map +1 -1
- package/dist/auth-storage/shared.d.ts +1 -2
- package/dist/auth-storage/shared.d.ts.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +984 -80
- package/dist/index.js.map +20 -18
- package/dist/migrations.d.ts.map +1 -1
- package/dist/ontology-storage/replacement-plans.d.ts.map +1 -1
- package/dist/ontology-storage/sources.d.ts +2 -1
- package/dist/ontology-storage/sources.d.ts.map +1 -1
- package/dist/pg-action-run-storage.d.ts +4 -0
- package/dist/pg-action-run-storage.d.ts.map +1 -1
- package/dist/pg-activity-storage.d.ts +22 -0
- package/dist/pg-activity-storage.d.ts.map +1 -0
- package/dist/pg-artifact-storage.d.ts +19 -0
- package/dist/pg-artifact-storage.d.ts.map +1 -0
- package/dist/pg-execution-storage.d.ts +2 -1
- package/dist/pg-execution-storage.d.ts.map +1 -1
- package/dist/pg-workflow-run-storage.d.ts +4 -0
- package/dist/pg-workflow-run-storage.d.ts.map +1 -1
- package/dist/share-grant-storage.d.ts +2 -1
- package/dist/share-grant-storage.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/agents/threads.ts +23 -0
- package/src/auth-storage/auth-storage.ts +1 -22
- package/src/auth-storage/magic-links.ts +0 -4
- package/src/auth-storage/oidc-attempts.ts +0 -4
- package/src/auth-storage/rows.ts +0 -6
- package/src/auth-storage/sessions.ts +18 -30
- package/src/auth-storage/shared.ts +3 -35
- package/src/index.ts +10 -0
- package/src/migrations/062-drop-auth-audience.sql +19 -0
- package/src/migrations/063-artifacts.sql +67 -0
- package/src/migrations/064-drop-output-diagnostics.sql +14 -0
- package/src/migrations/065-plan-work-payload-statistics.sql +5 -0
- package/src/migrations/066-activity.sql +61 -0
- package/src/migrations/067-activity-timeline.sql +15 -0
- package/src/migrations/068-activity-interactions.sql +20 -0
- package/src/migrations.ts +20 -0
- package/src/ontology-storage/replacement-plans.ts +25 -7
- package/src/ontology-storage/sources.ts +37 -0
- package/src/pg-action-run-storage.ts +23 -0
- package/src/pg-activity-storage.ts +486 -0
- package/src/pg-artifact-storage.ts +325 -0
- package/src/pg-execution-storage.ts +52 -0
- package/src/pg-workflow-run-storage.ts +23 -0
- package/src/share-grant-storage.ts +21 -0
package/dist/migrations.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../src/migrations.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,KAAK,EAGV,YAAY,EACZ,aAAa,EACb,oBAAoB,EACrB,MAAM,oBAAoB,CAAA;AAqH3B,OAAO,KAAK,EAAe,GAAG,EAAa,MAAM,aAAa,CAAA;AAG9D,MAAM,WAAW,wBAAwB;IACvC,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACrC;AAED,eAAO,MAAM,2BAA2B,wBAAwB,CAAA;AAEhE,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,aAAa,CAAC,wBAAwB,CAAC,CAE1F;AAED,wBAAgB,MAAM,CACpB,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,CAAC,OAAO,EAAE,wBAAwB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EAC/D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ACpC,QAAQ,CAAC,IAAI,CAAC,EAAE;QACd,QAAQ,CAAC,MAAM,EAAE;YAAE,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;SAAE,CAAA;QAClD,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAA;KACnC,CAAA;CACF,GACA,OAAO,CAAC,iBAAiB,CAAC,CA2B5B;AAED;;;GAGG;AACH,wBAAsB,6BAA6B,CACjD,GAAG,EAAE,SAAS,EACd,IAAI,EAAE,iBAAiB,GACtB,OAAO,CAAC,IAAI,CAAC,CAUf;AAED,qEAAqE;AACrE,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,SAAS,EACd,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,qBAAqB,CAAC,CAyBhC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AbandonRunSourceMaterializationInput, AbandonSourceMaterializationCandidateInput, AdoptedSourceMaterialization, AdoptSourceMaterializationInput, BeginSourceMaterializationInput, CleanupTerminalSourceMaterializationsInput, CleanupTerminalSourceMaterializationsResult, GetActiveOntologySourceInput, MarkSourceMaterializationReadyInput, OntologySourceRecord, OntologySourceStorage, PurgeAbandonedSourceMaterializationsInput, StageSourceRowsInput, StageSourceRowsResult } from "@sixb/core/storage";
|
|
1
|
+
import type { AbandonRunSourceMaterializationInput, AbandonSourceMaterializationCandidateInput, ActiveOntologySource, AdoptedSourceMaterialization, AdoptSourceMaterializationInput, BeginSourceMaterializationInput, CleanupTerminalSourceMaterializationsInput, CleanupTerminalSourceMaterializationsResult, GetActiveOntologySourceInput, ListActiveOntologySourcesInput, MarkSourceMaterializationReadyInput, OntologySourceRecord, OntologySourceStorage, PurgeAbandonedSourceMaterializationsInput, StageSourceRowsInput, StageSourceRowsResult } from "@sixb/core/storage";
|
|
2
2
|
import { type PgRootOperation } from "./shared";
|
|
3
3
|
export declare class PgOntologySourceStorage implements OntologySourceStorage {
|
|
4
4
|
private readonly runRootOperation;
|
|
@@ -7,6 +7,7 @@ export declare class PgOntologySourceStorage implements OntologySourceStorage {
|
|
|
7
7
|
stageRows(input: StageSourceRowsInput): Promise<StageSourceRowsResult>;
|
|
8
8
|
markReady(input: MarkSourceMaterializationReadyInput): Promise<OntologySourceRecord>;
|
|
9
9
|
getActive(input: GetActiveOntologySourceInput): Promise<OntologySourceRecord | null>;
|
|
10
|
+
listActive(input: ListActiveOntologySourcesInput): Promise<readonly ActiveOntologySource[]>;
|
|
10
11
|
adopt(input: AdoptSourceMaterializationInput): Promise<AdoptedSourceMaterialization | null>;
|
|
11
12
|
abandon(input: AbandonSourceMaterializationCandidateInput): Promise<OntologySourceRecord>;
|
|
12
13
|
abandon(input: AbandonRunSourceMaterializationInput): Promise<OntologySourceRecord | null>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sources.d.ts","sourceRoot":"","sources":["../../src/ontology-storage/sources.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EACV,oCAAoC,EACpC,0CAA0C,EAE1C,4BAA4B,EAC5B,+BAA+B,EAE/B,+BAA+B,EAC/B,0CAA0C,EAC1C,2CAA2C,EAC3C,4BAA4B,EAC5B,mCAAmC,EACnC,oBAAoB,EACpB,qBAAqB,EACrB,yCAAyC,EACzC,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,oBAAoB,CAAA;AAG3B,OAAO,EAUL,KAAK,eAAe,EAIrB,MAAM,UAAU,CAAA;AAIjB,qBAAa,uBAAwB,YAAW,qBAAqB;IACvD,OAAO,CAAC,QAAQ,CAAC,gBAAgB;gBAAhB,gBAAgB,EAAE,eAAe;IAExD,oBAAoB,CACxB,KAAK,EAAE,+BAA+B,GACrC,OAAO,CAAC,oBAAoB,CAAC;IA8E1B,SAAS,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IA2BtE,SAAS,CAAC,KAAK,EAAE,mCAAmC,GAAG,OAAO,CAAC,oBAAoB,CAAC;IA6DpF,SAAS,CAAC,KAAK,EAAE,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,CAAC,oBAAoB,CAAC;IA8E1B,SAAS,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IA2BtE,SAAS,CAAC,KAAK,EAAE,mCAAmC,GAAG,OAAO,CAAC,oBAAoB,CAAC;IA6DpF,SAAS,CAAC,KAAK,EAAE,4BAA4B,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IAapF,UAAU,CACd,KAAK,EAAE,8BAA8B,GACpC,OAAO,CAAC,SAAS,oBAAoB,EAAE,CAAC;IAwBrC,KAAK,CACT,KAAK,EAAE,+BAA+B,GACrC,OAAO,CAAC,4BAA4B,GAAG,IAAI,CAAC;IA+BzC,OAAO,CAAC,KAAK,EAAE,0CAA0C,GAAG,OAAO,CAAC,oBAAoB,CAAC;IACzF,OAAO,CAAC,KAAK,EAAE,oCAAoC,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IAa1F,eAAe,CACnB,KAAK,EAAE,0CAA0C,GAChD,OAAO,CAAC,2CAA2C,CAAC;IASjD,cAAc,CAClB,KAAK,EAAE,yCAAyC,GAC/C,OAAO,CAAC,2CAA2C,CAAC;YAQzC,gBAAgB;IA2B9B,uFAAuF;YACzE,gBAAgB;YAwBhB,iBAAiB;YAQjB,qBAAqB;YAgCrB,gBAAgB;IA2F9B,0EAA0E;YAC5D,aAAa;YAsBb,eAAe;IA0C7B,OAAO,CAAC,eAAe;YAkBT,eAAe;YAef,WAAW;YAkBX,eAAe;CAW9B"}
|
|
@@ -10,6 +10,10 @@ export declare class PgActionRunStorage implements ActionRunStorage {
|
|
|
10
10
|
projectId: string;
|
|
11
11
|
id: string;
|
|
12
12
|
}): Promise<ActionRunRecord | null>;
|
|
13
|
+
getByExecutionIds(params: {
|
|
14
|
+
readonly projectId: string;
|
|
15
|
+
readonly executionIds: readonly string[];
|
|
16
|
+
}): Promise<readonly ActionRunRecord[]>;
|
|
13
17
|
list(input: ListActionRunsInput): Promise<ListActionRunsResult>;
|
|
14
18
|
}
|
|
15
19
|
//# sourceMappingURL=pg-action-run-storage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pg-action-run-storage.d.ts","sourceRoot":"","sources":["../src/pg-action-run-storage.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAIV,eAAe,EAEf,gBAAgB,EAEhB,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,EACpB,wBAAwB,EACxB,oBAAoB,EACrB,MAAM,oBAAoB,CAAA;AAG3B,OAAO,EAAE,KAAK,aAAa,EAAoB,MAAM,gBAAgB,CAAA;AAErE,qBAAa,kBAAmB,YAAW,gBAAgB;IAEvD,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,UAAU;gBADV,GAAG,EAAE,aAAa,EAClB,UAAU,EAAE,gBAAgB;IAGzC,MAAM,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,eAAe,CAAC;IAuE7D,aAAa,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,eAAe,CAAC;IA2BxE,OAAO,CAAC,MAAM,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;IASnF,IAAI,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAiHtE"}
|
|
1
|
+
{"version":3,"file":"pg-action-run-storage.d.ts","sourceRoot":"","sources":["../src/pg-action-run-storage.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAIV,eAAe,EAEf,gBAAgB,EAEhB,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,EACpB,wBAAwB,EACxB,oBAAoB,EACrB,MAAM,oBAAoB,CAAA;AAG3B,OAAO,EAAE,KAAK,aAAa,EAAoB,MAAM,gBAAgB,CAAA;AAErE,qBAAa,kBAAmB,YAAW,gBAAgB;IAEvD,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,UAAU;gBADV,GAAG,EAAE,aAAa,EAClB,UAAU,EAAE,gBAAgB;IAGzC,MAAM,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,eAAe,CAAC;IAuE7D,aAAa,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,eAAe,CAAC;IA2BxE,OAAO,CAAC,MAAM,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;IASnF,iBAAiB,CAAC,MAAM,EAAE;QAC9B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;QAC1B,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAA;KACzC,GAAG,OAAO,CAAC,SAAS,eAAe,EAAE,CAAC;IAoBjC,IAAI,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAiHtE"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ActivityCalendarInput, ActivityDay, ActivityPeriodInput, ActivitySessionVisits, ActivityStorage, ActivitySummary, ActivityUsersPage, ActivityVisitsPage, AppendActivityInput, AppendActivityResult, ListActivitySessionVisitsInput, ListActivityUsersInput, ListActivityVisitsInput, ReadActivityVisitInput, StoredActivityVisitPage } from "@sixb/core/storage";
|
|
2
|
+
import { type PgStoreClient } from "./transactions";
|
|
3
|
+
/** PostgreSQL activity. An advisory lock per session serializes its batches across replicas. */
|
|
4
|
+
export declare class PgActivityStorage implements ActivityStorage {
|
|
5
|
+
private readonly sql;
|
|
6
|
+
constructor(sql: PgStoreClient);
|
|
7
|
+
append(input: AppendActivityInput): Promise<AppendActivityResult>;
|
|
8
|
+
list(input: ListActivityVisitsInput): Promise<ActivityVisitsPage>;
|
|
9
|
+
users(input: ListActivityUsersInput): Promise<ActivityUsersPage>;
|
|
10
|
+
summarize(input: ActivityPeriodInput): Promise<ActivitySummary>;
|
|
11
|
+
calendar(input: ActivityCalendarInput): Promise<readonly ActivityDay[]>;
|
|
12
|
+
read(input: ReadActivityVisitInput): Promise<StoredActivityVisitPage | null>;
|
|
13
|
+
sessionVisits(input: ListActivitySessionVisitsInput): Promise<readonly ActivitySessionVisits[]>;
|
|
14
|
+
/**
|
|
15
|
+
* The visits `v` active in the period, and only the account's when one is asked for. A visit
|
|
16
|
+
* lasts less than a day, so it started at most a day before the period: that bounds the index
|
|
17
|
+
* range.
|
|
18
|
+
*/
|
|
19
|
+
private overlapping;
|
|
20
|
+
private visitColumns;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=pg-activity-storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pg-activity-storage.d.ts","sourceRoot":"","sources":["../src/pg-activity-storage.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EACV,qBAAqB,EAErB,WAAW,EAGX,mBAAmB,EACnB,qBAAqB,EACrB,eAAe,EACf,eAAe,EACf,iBAAiB,EAEjB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,8BAA8B,EAC9B,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,EACxB,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EAAoB,KAAK,aAAa,EAAoB,MAAM,gBAAgB,CAAA;AAKvF,gGAAgG;AAChG,qBAAa,iBAAkB,YAAW,eAAe;IAC3C,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,aAAa;IAEzC,MAAM,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IA4FjE,IAAI,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAoBjE,KAAK,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAiChE,SAAS,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,eAAe,CAAC;IAwB/D,QAAQ,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,SAAS,WAAW,EAAE,CAAC;IA4BvE,IAAI,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC;IA4C5E,aAAa,CACjB,KAAK,EAAE,8BAA8B,GACpC,OAAO,CAAC,SAAS,qBAAqB,EAAE,CAAC;IAoC5C;;;;OAIG;IACH,OAAO,CAAC,WAAW;IAanB,OAAO,CAAC,YAAY;CAMrB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ArtifactFrameGrantRecord, ArtifactRecord, ArtifactStorage, ArtifactVersionRecord, CreateArtifactInput, DeleteArtifactInput, DeleteArtifactVersionsByOriginInput, DeleteExpiredArtifactFrameGrantsInput, FindArtifactFrameGrantInput, GetArtifactInput, GetArtifactVersionInput, ListArtifactsInput, ListArtifactsResult, ListArtifactVersionsInput, ListArtifactVersionsResult, ListReferencingVersionsInput, PublishArtifactVersionInput, PublishedArtifactVersion } from "@sixb/core/storage";
|
|
2
|
+
import { type PgStoreClient } from "./transactions";
|
|
3
|
+
export declare class PgArtifactStorage implements ArtifactStorage {
|
|
4
|
+
private readonly sql;
|
|
5
|
+
constructor(sql: PgStoreClient);
|
|
6
|
+
create(input: CreateArtifactInput): Promise<PublishedArtifactVersion>;
|
|
7
|
+
publish(input: PublishArtifactVersionInput): Promise<PublishedArtifactVersion>;
|
|
8
|
+
get(input: GetArtifactInput): Promise<ArtifactRecord | null>;
|
|
9
|
+
list(input: ListArtifactsInput): Promise<ListArtifactsResult>;
|
|
10
|
+
getVersion(input: GetArtifactVersionInput): Promise<ArtifactVersionRecord | null>;
|
|
11
|
+
listVersions(input: ListArtifactVersionsInput): Promise<ListArtifactVersionsResult>;
|
|
12
|
+
listReferencingVersions(input: ListReferencingVersionsInput): Promise<ArtifactVersionRecord[]>;
|
|
13
|
+
createFrameGrant(record: ArtifactFrameGrantRecord): Promise<void>;
|
|
14
|
+
findFrameGrant(input: FindArtifactFrameGrantInput): Promise<ArtifactFrameGrantRecord | null>;
|
|
15
|
+
deleteExpiredFrameGrants(input: DeleteExpiredArtifactFrameGrantsInput): Promise<number>;
|
|
16
|
+
delete(input: DeleteArtifactInput): Promise<boolean>;
|
|
17
|
+
deleteVersionsByOrigin(input: DeleteArtifactVersionsByOriginInput): Promise<number>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=pg-artifact-storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pg-artifact-storage.d.ts","sourceRoot":"","sources":["../src/pg-artifact-storage.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,wBAAwB,EACxB,cAAc,EACd,eAAe,EAEf,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB,mCAAmC,EACnC,qCAAqC,EACrC,2BAA2B,EAC3B,gBAAgB,EAChB,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,EACnB,yBAAyB,EACzB,0BAA0B,EAC1B,4BAA4B,EAC5B,2BAA2B,EAC3B,wBAAwB,EACzB,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EAAE,KAAK,aAAa,EAAoB,MAAM,gBAAgB,CAAA;AAyBrE,qBAAa,iBAAkB,YAAW,eAAe;IAC3C,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,aAAa;IAEzC,MAAM,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAsBrE,OAAO,CAAC,KAAK,EAAE,2BAA2B,GAAG,OAAO,CAAC,wBAAwB,CAAC;IA+B9E,GAAG,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;IAQ5D,IAAI,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAuC7D,UAAU,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC;IASjF,YAAY,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,0BAA0B,CAAC;IAoBnF,uBAAuB,CAC3B,KAAK,EAAE,4BAA4B,GAClC,OAAO,CAAC,qBAAqB,EAAE,CAAC;IAkB7B,gBAAgB,CAAC,MAAM,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC;IAejE,cAAc,CAClB,KAAK,EAAE,2BAA2B,GACjC,OAAO,CAAC,wBAAwB,GAAG,IAAI,CAAC;IAQrC,wBAAwB,CAAC,KAAK,EAAE,qCAAqC,GAAG,OAAO,CAAC,MAAM,CAAC;IAavF,MAAM,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC;IASpD,sBAAsB,CAAC,KAAK,EAAE,mCAAmC,GAAG,OAAO,CAAC,MAAM,CAAC;CAgD1F"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ExecutionStorageRow } from "@sixb/core/internal/execution-storage";
|
|
2
|
-
import type { CreateExecutionInput, ExecutionRecord, ExecutionStorage, ShareSessionStorage } from "@sixb/core/storage";
|
|
2
|
+
import type { CreateExecutionInput, ExecutionRecord, ExecutionStorage, ListSessionExecutionsInput, SessionExecutions, ShareSessionStorage } from "@sixb/core/storage";
|
|
3
3
|
import type { PgAuthStorage } from "./auth-storage";
|
|
4
4
|
import type { PgStoreClient } from "./transactions";
|
|
5
5
|
export declare class PgExecutionStorage implements ExecutionStorage {
|
|
@@ -12,6 +12,7 @@ export declare class PgExecutionStorage implements ExecutionStorage {
|
|
|
12
12
|
readonly projectId: string;
|
|
13
13
|
readonly id: string;
|
|
14
14
|
}): Promise<ExecutionRecord | null>;
|
|
15
|
+
listBySession(input: ListSessionExecutionsInput): Promise<SessionExecutions>;
|
|
15
16
|
}
|
|
16
17
|
/** An `executions` row as its record, for any store that reads executions alongside its own rows. */
|
|
17
18
|
export declare function pgExecutionRecord(row: PgExecutionRow): ExecutionRecord;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pg-execution-storage.d.ts","sourceRoot":"","sources":["../src/pg-execution-storage.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"pg-execution-storage.d.ts","sourceRoot":"","sources":["../src/pg-execution-storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,mBAAmB,EAIzB,MAAM,uCAAuC,CAAA;AAC9C,OAAO,KAAK,EACV,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,0BAA0B,EAC1B,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,oBAAoB,CAAA;AAE3B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAEnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAEnD,qBAAa,kBAAmB,YAAW,gBAAgB;IAEvD,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,aAAa;gBAFb,GAAG,EAAE,aAAa,EAClB,IAAI,EAAE,aAAa,EACnB,aAAa,EAAE,IAAI,CAAC,mBAAmB,EAAE,SAAS,CAAC;IAGhE,MAAM,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,eAAe,CAAC;IA8E7D,OAAO,CAAC,MAAM,EAAE;QACpB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;QAC1B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;KACpB,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;IAS7B,aAAa,CAAC,KAAK,EAAE,0BAA0B,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAgDnF;AAED,qGAAqG;AACrG,wBAAgB,iBAAiB,CAAC,GAAG,EAA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,GAAG,IAAI,CAAA;IAC/C,QAAQ,CAAC,+BAA+B,EAAE,MAAM,GAAG,IAAI,CAAA;IACvD,QAAQ,CAAC,UAAU,EAAE,IAAI,GAAG,MAAM,CAAA;CACnC"}
|
|
@@ -17,6 +17,10 @@ export declare class PgWorkflowRunStorage implements WorkflowRunStorage {
|
|
|
17
17
|
projectId: string;
|
|
18
18
|
id: string;
|
|
19
19
|
}): Promise<WorkflowRunRecord | null>;
|
|
20
|
+
getByExecutionIds(params: {
|
|
21
|
+
readonly projectId: string;
|
|
22
|
+
readonly executionIds: readonly string[];
|
|
23
|
+
}): Promise<readonly WorkflowRunRecord[]>;
|
|
20
24
|
list(input: ListWorkflowRunsInput): Promise<ListWorkflowRunsResult>;
|
|
21
25
|
listLatestByWorkflowIds(input: ListLatestWorkflowRunsInput): Promise<ListLatestWorkflowRunsResult>;
|
|
22
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pg-workflow-run-storage.d.ts","sourceRoot":"","sources":["../src/pg-workflow-run-storage.ts"],"names":[],"mappings":"AAOA,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,qBAAqB,EACrB,gCAAgC,EAChC,uBAAuB,EACvB,sBAAsB,EACtB,8BAA8B,EAC9B,yBAAyB,EACzB,qBAAqB,EACrB,wBAAwB,EACxB,oBAAoB,EACpB,0BAA0B,EAC1B,2BAA2B,EAC3B,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,oBAAoB,CAAA;AAU3B,OAAO,EAAE,KAAK,aAAa,EAAoB,MAAM,gBAAgB,CAAA;A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OAAO,CAAC,0BAA0B,CAAC;IA+BnF,cAAc,CAAC,MAAM,EAAE;QAC3B,SAAS,EAAE,MAAM,CAAA;QACjB,SAAS,EAAE,MAAM,CAAA;KAClB,GAAG,OAAO,CAAC,0BAA0B,GAAG,IAAI,CAAC;IAQxC,IAAI,CAAC,KAAK,EAAE,8BAA8B,GAAG,OAAO,CAAC,+BAA+B,CAAC;CAsB5F;AAED,qBAAa,wBAAyB,YAAW,sBAAsB;IACzD,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,aAAa;IAEzC,KAAK,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAwEvE,MAAM,CAAC,KAAK,EAAE,0BAA0B,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAgDzE,IAAI,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAoCrE,OAAO,CAAC,MAAM,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC;IASzF,IAAI,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,0BAA0B,CAAC;CA0DlF"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import type { CreateShareGrantInput, GetShareGrantByIdInput, ListShareGrantsInput, ListShareGrantsResult, RevokeShareGrantInput, ShareGrantRecord, ShareGrantStorage } from "@sixb/core/storage";
|
|
1
|
+
import type { CreateShareGrantInput, GetShareGrantByIdInput, GetShareGrantsByIdsInput, ListShareGrantsInput, ListShareGrantsResult, RevokeShareGrantInput, ShareGrantRecord, ShareGrantStorage } from "@sixb/core/storage";
|
|
2
2
|
import type { PgStoreClient } from "./transactions";
|
|
3
3
|
export declare class PgShareGrantStorage implements ShareGrantStorage {
|
|
4
4
|
private readonly sql;
|
|
5
5
|
constructor(sql: PgStoreClient);
|
|
6
6
|
create(input: CreateShareGrantInput): Promise<ShareGrantRecord>;
|
|
7
7
|
getById(input: GetShareGrantByIdInput): Promise<ShareGrantRecord | null>;
|
|
8
|
+
getByIds(input: GetShareGrantsByIdsInput): Promise<readonly ShareGrantRecord[]>;
|
|
8
9
|
list(input: ListShareGrantsInput): Promise<ListShareGrantsResult>;
|
|
9
10
|
revoke(input: RevokeShareGrantInput): Promise<ShareGrantRecord | null>;
|
|
10
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"share-grant-storage.d.ts","sourceRoot":"","sources":["../src/share-grant-storage.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,oBAAoB,CAAA;AAI3B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAEnD,qBAAa,mBAAoB,YAAW,iBAAiB;IAC/C,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,aAAa;IAEzC,MAAM,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAqD/D,OAAO,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAUxE,IAAI,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IA8CjE,MAAM,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;CAqB7E"}
|
|
1
|
+
{"version":3,"file":"share-grant-storage.d.ts","sourceRoot":"","sources":["../src/share-grant-storage.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,qBAAqB,EACrB,sBAAsB,EACtB,wBAAwB,EACxB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,oBAAoB,CAAA;AAI3B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAEnD,qBAAa,mBAAoB,YAAW,iBAAiB;IAC/C,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,aAAa;IAEzC,MAAM,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAqD/D,OAAO,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAUxE,QAAQ,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,SAAS,gBAAgB,EAAE,CAAC;IAoB/E,IAAI,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IA8CjE,MAAM,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;CAqB7E"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sixb/pg",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.21",
|
|
4
4
|
"description": "PostgreSQL storage provider for Sixb",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sixb",
|
|
@@ -40,10 +40,10 @@
|
|
|
40
40
|
"postgres": "^3.4.5"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@sixb/core": "0.1.
|
|
43
|
+
"@sixb/core": "0.1.21"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@sixb/core": "0.1.
|
|
46
|
+
"@sixb/core": "0.1.21",
|
|
47
47
|
"@types/bun": "latest",
|
|
48
48
|
"typescript": "^5.7.0"
|
|
49
49
|
},
|
package/src/agents/threads.ts
CHANGED
|
@@ -108,6 +108,29 @@ export class PgAgentThreadStore implements AgentThreadStore {
|
|
|
108
108
|
return row ? rowToThreadRecord(row) : null
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
+
async getByIds(params: {
|
|
112
|
+
readonly projectId: string
|
|
113
|
+
readonly ids: readonly string[]
|
|
114
|
+
}): Promise<readonly AgentThreadRecord[]> {
|
|
115
|
+
const ids = [...new Set(params.ids)]
|
|
116
|
+
if (ids.length === 0) {
|
|
117
|
+
return []
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const rows = await this.sql<AgentThreadRow[]>`
|
|
121
|
+
SELECT *
|
|
122
|
+
FROM agent_threads
|
|
123
|
+
WHERE project_id = ${params.projectId}
|
|
124
|
+
AND id = ANY(${this.sql.array(ids)}::text[])
|
|
125
|
+
`
|
|
126
|
+
|
|
127
|
+
const byId = new Map(rows.map((row) => [row.id, row]))
|
|
128
|
+
return ids.flatMap((id) => {
|
|
129
|
+
const row = byId.get(id)
|
|
130
|
+
return row ? [rowToThreadRecord(row)] : []
|
|
131
|
+
})
|
|
132
|
+
}
|
|
133
|
+
|
|
111
134
|
async list(input: ListAgentThreadsInput): Promise<ListAgentThreadsResult> {
|
|
112
135
|
if (input.statuses !== undefined && input.statuses.length === 0) {
|
|
113
136
|
return { threads: [], hasMore: false, total: 0 }
|
|
@@ -234,7 +234,6 @@ export class PgAuthStorage implements AuthStorage {
|
|
|
234
234
|
}
|
|
235
235
|
|
|
236
236
|
await validateCompleteSessionInput(tx, projectId, input.session)
|
|
237
|
-
assertSignInSessionAudience(projectId, input.session.audience, magicLink.audience)
|
|
238
237
|
|
|
239
238
|
let newUserId: string | undefined
|
|
240
239
|
if (shouldCreateUser) {
|
|
@@ -394,7 +393,6 @@ export class PgAuthStorage implements AuthStorage {
|
|
|
394
393
|
}
|
|
395
394
|
|
|
396
395
|
await validateCompleteSessionInput(tx, projectId, input.session)
|
|
397
|
-
assertSignInSessionAudience(projectId, input.session.audience, attempt.audience)
|
|
398
396
|
|
|
399
397
|
let newUserId: string | undefined
|
|
400
398
|
if (shouldCreateUser) {
|
|
@@ -719,17 +717,13 @@ export class PgAuthStorage implements AuthStorage {
|
|
|
719
717
|
readonly userId: string
|
|
720
718
|
}
|
|
721
719
|
): Promise<SessionRecord> {
|
|
722
|
-
await lockAdvisoryKeys(sql, [
|
|
723
|
-
authLockKey("sessions", input.projectId, input.userId),
|
|
724
|
-
authLockKey("sessions", input.projectId, input.userId, input.session.audience),
|
|
725
|
-
])
|
|
720
|
+
await lockAdvisoryKeys(sql, [authLockKey("sessions", input.projectId, input.userId)])
|
|
726
721
|
|
|
727
722
|
return createSession(sql, {
|
|
728
723
|
id: input.session.id,
|
|
729
724
|
projectId: input.projectId,
|
|
730
725
|
userId: input.userId,
|
|
731
726
|
strategyId: input.strategyId,
|
|
732
|
-
audience: input.session.audience,
|
|
733
727
|
tokenHash: input.session.tokenHash,
|
|
734
728
|
createdAt: input.session.createdAt,
|
|
735
729
|
expiresAt: input.session.expiresAt,
|
|
@@ -795,21 +789,6 @@ export class PgAuthStorage implements AuthStorage {
|
|
|
795
789
|
}
|
|
796
790
|
}
|
|
797
791
|
|
|
798
|
-
function assertSignInSessionAudience(
|
|
799
|
-
projectId: string,
|
|
800
|
-
sessionAudience: string,
|
|
801
|
-
storedAudience: string
|
|
802
|
-
): void {
|
|
803
|
-
if (sessionAudience === storedAudience) {
|
|
804
|
-
return
|
|
805
|
-
}
|
|
806
|
-
|
|
807
|
-
throw new AuthStorageError(
|
|
808
|
-
"invalid_input",
|
|
809
|
-
`[Sixb] Sign-in session audience '${sessionAudience}' does not match stored auth audience '${storedAudience}' for project '${projectId}'.`
|
|
810
|
-
)
|
|
811
|
-
}
|
|
812
|
-
|
|
813
792
|
function assertCompletableDeviceAuthorization(
|
|
814
793
|
authorization: DeviceAuthorizationRecord,
|
|
815
794
|
input: CompleteDeviceAuthorizationInput
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { resolveAuthSessionAudience } from "@sixb/core"
|
|
2
1
|
import type {
|
|
3
2
|
AuthMagicLinkStore,
|
|
4
3
|
CreateAuthMagicLinkInput,
|
|
@@ -31,7 +30,6 @@ export class PgAuthMagicLinkStore implements AuthMagicLinkStore {
|
|
|
31
30
|
const id = assertNonEmpty(input.id, "Magic link id")
|
|
32
31
|
const projectId = assertNonEmpty(input.projectId, "Project id")
|
|
33
32
|
const strategyId = assertNonEmpty(input.strategyId, "Strategy id")
|
|
34
|
-
const audience = resolveAuthSessionAudience(input.audience)
|
|
35
33
|
const email = normalizeEmail(input.email)
|
|
36
34
|
const tokenHash = assertNonEmpty(input.tokenHash, "Magic link token hash")
|
|
37
35
|
|
|
@@ -56,7 +54,6 @@ export class PgAuthMagicLinkStore implements AuthMagicLinkStore {
|
|
|
56
54
|
project_id,
|
|
57
55
|
id,
|
|
58
56
|
strategy_id,
|
|
59
|
-
audience,
|
|
60
57
|
email,
|
|
61
58
|
token_hash,
|
|
62
59
|
return_to,
|
|
@@ -66,7 +63,6 @@ export class PgAuthMagicLinkStore implements AuthMagicLinkStore {
|
|
|
66
63
|
${projectId},
|
|
67
64
|
${id},
|
|
68
65
|
${strategyId},
|
|
69
|
-
${audience},
|
|
70
66
|
${email},
|
|
71
67
|
${tokenHash},
|
|
72
68
|
${input.returnTo ?? null},
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { resolveAuthSessionAudience } from "@sixb/core"
|
|
2
1
|
import type {
|
|
3
2
|
AuthOidcAuthorizationAttemptStore,
|
|
4
3
|
CreateOidcAuthorizationAttemptInput,
|
|
@@ -25,7 +24,6 @@ export class PgAuthOidcAuthorizationAttemptStore implements AuthOidcAuthorizatio
|
|
|
25
24
|
const id = assertNonEmpty(input.id, "OIDC authorization attempt id")
|
|
26
25
|
const projectId = assertNonEmpty(input.projectId, "Project id")
|
|
27
26
|
const strategyId = assertNonEmpty(input.strategyId, "Strategy id")
|
|
28
|
-
const audience = resolveAuthSessionAudience(input.audience)
|
|
29
27
|
const stateHash = assertNonEmpty(input.stateHash, "OIDC state hash")
|
|
30
28
|
const nonceHash = assertNonEmpty(input.nonceHash, "OIDC nonce hash")
|
|
31
29
|
const codeVerifier = assertNonEmpty(input.codeVerifier, "OIDC code verifier")
|
|
@@ -43,7 +41,6 @@ export class PgAuthOidcAuthorizationAttemptStore implements AuthOidcAuthorizatio
|
|
|
43
41
|
project_id,
|
|
44
42
|
id,
|
|
45
43
|
strategy_id,
|
|
46
|
-
audience,
|
|
47
44
|
state_hash,
|
|
48
45
|
nonce_hash,
|
|
49
46
|
code_verifier,
|
|
@@ -54,7 +51,6 @@ export class PgAuthOidcAuthorizationAttemptStore implements AuthOidcAuthorizatio
|
|
|
54
51
|
${projectId},
|
|
55
52
|
${id},
|
|
56
53
|
${strategyId},
|
|
57
|
-
${audience},
|
|
58
54
|
${stateHash},
|
|
59
55
|
${nonceHash},
|
|
60
56
|
${codeVerifier},
|
package/src/auth-storage/rows.ts
CHANGED
|
@@ -67,7 +67,6 @@ export interface PgAuthSessionRow {
|
|
|
67
67
|
readonly id: string
|
|
68
68
|
readonly user_id: string
|
|
69
69
|
readonly strategy_id: string
|
|
70
|
-
readonly audience: SessionRecord["audience"]
|
|
71
70
|
readonly token_hash: string
|
|
72
71
|
readonly created_at: PgDate
|
|
73
72
|
readonly expires_at: PgDate
|
|
@@ -132,7 +131,6 @@ export interface PgAuthMagicLinkRow {
|
|
|
132
131
|
readonly project_id: string
|
|
133
132
|
readonly id: string
|
|
134
133
|
readonly strategy_id: string
|
|
135
|
-
readonly audience: MagicLinkRecord["audience"]
|
|
136
134
|
readonly email: string
|
|
137
135
|
readonly token_hash: string
|
|
138
136
|
readonly return_to: string | null
|
|
@@ -146,7 +144,6 @@ export interface PgAuthOidcAttemptRow {
|
|
|
146
144
|
readonly project_id: string
|
|
147
145
|
readonly id: string
|
|
148
146
|
readonly strategy_id: string
|
|
149
|
-
readonly audience: OidcAuthorizationAttemptRecord["audience"]
|
|
150
147
|
readonly state_hash: string
|
|
151
148
|
readonly nonce_hash: string
|
|
152
149
|
readonly code_verifier: string
|
|
@@ -229,7 +226,6 @@ export function rowToSessionRecord(row: PgAuthSessionRow): SessionRecord {
|
|
|
229
226
|
projectId: row.project_id,
|
|
230
227
|
userId: row.user_id,
|
|
231
228
|
strategyId: row.strategy_id,
|
|
232
|
-
audience: row.audience,
|
|
233
229
|
tokenHash: row.token_hash,
|
|
234
230
|
createdAt: toDate(row.created_at),
|
|
235
231
|
expiresAt: toDate(row.expires_at),
|
|
@@ -306,7 +302,6 @@ export function rowToMagicLinkRecord(row: PgAuthMagicLinkRow): MagicLinkRecord {
|
|
|
306
302
|
id: row.id,
|
|
307
303
|
projectId: row.project_id,
|
|
308
304
|
strategyId: row.strategy_id,
|
|
309
|
-
audience: row.audience,
|
|
310
305
|
email: row.email,
|
|
311
306
|
tokenHash: row.token_hash,
|
|
312
307
|
returnTo: row.return_to ?? undefined,
|
|
@@ -324,7 +319,6 @@ export function rowToOidcAuthorizationAttemptRecord(
|
|
|
324
319
|
id: row.id,
|
|
325
320
|
projectId: row.project_id,
|
|
326
321
|
strategyId: row.strategy_id,
|
|
327
|
-
audience: row.audience,
|
|
328
322
|
stateHash: row.state_hash,
|
|
329
323
|
nonceHash: row.nonce_hash,
|
|
330
324
|
codeVerifier: row.code_verifier,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { AuthSessionAudience } from "@sixb/core"
|
|
2
1
|
import type {
|
|
3
2
|
AuthSessionStore,
|
|
4
3
|
CreateAuthSessionInput,
|
|
4
|
+
ListAuthSessionsInput,
|
|
5
|
+
ListAuthSessionsResult,
|
|
5
6
|
RotateSessionRefreshTokenResult,
|
|
6
7
|
SessionRecord,
|
|
7
8
|
} from "@sixb/core/storage"
|
|
@@ -38,51 +39,46 @@ export class PgAuthSessionStore implements AuthSessionStore {
|
|
|
38
39
|
return getSessionById(this.sql, params)
|
|
39
40
|
}
|
|
40
41
|
|
|
41
|
-
async
|
|
42
|
+
async listActiveByUserId(params: {
|
|
42
43
|
readonly projectId: string
|
|
43
44
|
readonly userId: string
|
|
44
|
-
readonly audience: AuthSessionAudience
|
|
45
45
|
readonly now: Date
|
|
46
|
-
}): Promise<SessionRecord
|
|
47
|
-
const
|
|
46
|
+
}): Promise<readonly SessionRecord[]> {
|
|
47
|
+
const rows = (await this.sql`
|
|
48
48
|
SELECT *
|
|
49
49
|
FROM auth_sessions
|
|
50
50
|
WHERE project_id = ${params.projectId}
|
|
51
51
|
AND user_id = ${params.userId}
|
|
52
|
-
AND audience = ${params.audience}
|
|
53
52
|
AND revoked_at IS NULL
|
|
54
53
|
AND expires_at > ${params.now}
|
|
55
54
|
AND (absolute_expires_at IS NULL OR absolute_expires_at > ${params.now})
|
|
56
|
-
ORDER BY created_at DESC, id DESC
|
|
57
|
-
|
|
58
|
-
`
|
|
55
|
+
ORDER BY COALESCE(last_seen_at, created_at) DESC, created_at DESC, id DESC
|
|
56
|
+
`) as PgAuthSessionRow[]
|
|
59
57
|
|
|
60
|
-
return
|
|
58
|
+
return rows.map(rowToSessionRecord)
|
|
61
59
|
}
|
|
62
60
|
|
|
63
|
-
async
|
|
64
|
-
readonly projectId: string
|
|
65
|
-
readonly userId: string
|
|
66
|
-
readonly now: Date
|
|
67
|
-
}): Promise<readonly SessionRecord[]> {
|
|
61
|
+
async listByUserId(params: ListAuthSessionsInput): Promise<ListAuthSessionsResult> {
|
|
68
62
|
const rows = (await this.sql`
|
|
69
63
|
SELECT *
|
|
70
64
|
FROM auth_sessions
|
|
71
65
|
WHERE project_id = ${params.projectId}
|
|
72
66
|
AND user_id = ${params.userId}
|
|
73
|
-
AND
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
67
|
+
${params.before ? this.sql`AND created_at <= ${params.before.createdAt}` : this.sql``}
|
|
68
|
+
ORDER BY created_at DESC, id DESC
|
|
69
|
+
LIMIT ${params.limit + 1}
|
|
70
|
+
OFFSET ${params.before?.skip ?? 0}
|
|
77
71
|
`) as PgAuthSessionRow[]
|
|
78
72
|
|
|
79
|
-
return
|
|
73
|
+
return {
|
|
74
|
+
sessions: rows.slice(0, params.limit).map(rowToSessionRecord),
|
|
75
|
+
hasMore: rows.length > params.limit,
|
|
76
|
+
}
|
|
80
77
|
}
|
|
81
78
|
|
|
82
79
|
async findValidByTokenHash(params: {
|
|
83
80
|
readonly projectId: string
|
|
84
81
|
readonly id: string
|
|
85
|
-
readonly audience: AuthSessionAudience
|
|
86
82
|
readonly tokenHash: string
|
|
87
83
|
readonly now: Date
|
|
88
84
|
}): Promise<SessionRecord | null> {
|
|
@@ -91,7 +87,6 @@ export class PgAuthSessionStore implements AuthSessionStore {
|
|
|
91
87
|
if (
|
|
92
88
|
!row ||
|
|
93
89
|
row.refresh_token_hash !== null ||
|
|
94
|
-
row.audience !== params.audience ||
|
|
95
90
|
row.token_hash !== params.tokenHash ||
|
|
96
91
|
!isLiveSessionRow(row, params.now)
|
|
97
92
|
) {
|
|
@@ -169,7 +164,6 @@ export class PgAuthSessionStore implements AuthSessionStore {
|
|
|
169
164
|
async renewIfValid(params: {
|
|
170
165
|
readonly projectId: string
|
|
171
166
|
readonly id: string
|
|
172
|
-
readonly audience: AuthSessionAudience
|
|
173
167
|
readonly tokenHash: string
|
|
174
168
|
readonly now: Date
|
|
175
169
|
readonly expiresAt: Date
|
|
@@ -186,7 +180,6 @@ export class PgAuthSessionStore implements AuthSessionStore {
|
|
|
186
180
|
last_seen_at = ${params.now}
|
|
187
181
|
WHERE project_id = ${params.projectId}
|
|
188
182
|
AND id = ${params.id}
|
|
189
|
-
AND audience = ${params.audience}
|
|
190
183
|
AND token_hash = ${params.tokenHash}
|
|
191
184
|
AND refresh_token_hash IS NULL
|
|
192
185
|
AND revoked_at IS NULL
|
|
@@ -228,15 +221,10 @@ export class PgAuthSessionStore implements AuthSessionStore {
|
|
|
228
221
|
async revokeActiveForUser(params: {
|
|
229
222
|
readonly projectId: string
|
|
230
223
|
readonly userId: string
|
|
231
|
-
readonly audience?: AuthSessionAudience
|
|
232
224
|
readonly revokedAt: Date
|
|
233
225
|
}): Promise<readonly SessionRecord[]> {
|
|
234
226
|
return runPgTransaction(this.sql, async (tx) => {
|
|
235
|
-
|
|
236
|
-
if (params.audience) {
|
|
237
|
-
locks.push(authLockKey("sessions", params.projectId, params.userId, params.audience))
|
|
238
|
-
}
|
|
239
|
-
await lockAdvisoryKeys(tx, locks)
|
|
227
|
+
await lockAdvisoryKeys(tx, [authLockKey("sessions", params.projectId, params.userId)])
|
|
240
228
|
return revokeActiveSessionsForUser(tx, params)
|
|
241
229
|
})
|
|
242
230
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Principal } from "@sixb/core"
|
|
2
2
|
import type {
|
|
3
3
|
CompleteAuthSessionInput,
|
|
4
4
|
CreateAuthSessionInput,
|
|
@@ -442,7 +442,6 @@ export async function validateCompleteSessionInput(
|
|
|
442
442
|
session: CompleteAuthSessionInput
|
|
443
443
|
): Promise<void> {
|
|
444
444
|
const sessionId = assertNonEmpty(session.id, "Session id")
|
|
445
|
-
assertNonEmpty(session.audience, "Session audience")
|
|
446
445
|
assertNonEmpty(session.tokenHash, "Session token hash")
|
|
447
446
|
await assertSessionIdAvailable(sql, projectId, sessionId)
|
|
448
447
|
}
|
|
@@ -468,7 +467,6 @@ export async function createSession(
|
|
|
468
467
|
const projectId = assertNonEmpty(input.projectId, "Project id")
|
|
469
468
|
const userId = assertNonEmpty(input.userId, "User id")
|
|
470
469
|
const strategyId = assertNonEmpty(input.strategyId, "Strategy id")
|
|
471
|
-
const audience = assertNonEmpty(input.audience, "Session audience")
|
|
472
470
|
const tokenHash = assertNonEmpty(input.tokenHash, "Session token hash")
|
|
473
471
|
|
|
474
472
|
await requireUserById(sql, { projectId, id: userId })
|
|
@@ -481,7 +479,6 @@ export async function createSession(
|
|
|
481
479
|
id,
|
|
482
480
|
user_id,
|
|
483
481
|
strategy_id,
|
|
484
|
-
audience,
|
|
485
482
|
token_hash,
|
|
486
483
|
created_at,
|
|
487
484
|
expires_at,
|
|
@@ -496,7 +493,6 @@ export async function createSession(
|
|
|
496
493
|
${id},
|
|
497
494
|
${userId},
|
|
498
495
|
${strategyId},
|
|
499
|
-
${audience},
|
|
500
496
|
${tokenHash},
|
|
501
497
|
${input.createdAt},
|
|
502
498
|
${input.expiresAt},
|
|
@@ -525,13 +521,10 @@ export async function revokeActiveSessionsForUser(
|
|
|
525
521
|
params: {
|
|
526
522
|
readonly projectId: string
|
|
527
523
|
readonly userId: string
|
|
528
|
-
readonly audience?: AuthSessionAudience
|
|
529
524
|
readonly revokedAt: Date
|
|
530
525
|
}
|
|
531
526
|
): Promise<readonly SessionRecord[]> {
|
|
532
|
-
const rows =
|
|
533
|
-
params.audience === undefined
|
|
534
|
-
? await sql<PgAuthSessionRow[]>`
|
|
527
|
+
const rows = await sql<PgAuthSessionRow[]>`
|
|
535
528
|
SELECT *
|
|
536
529
|
FROM auth_sessions
|
|
537
530
|
WHERE project_id = ${params.projectId}
|
|
@@ -542,41 +535,16 @@ export async function revokeActiveSessionsForUser(
|
|
|
542
535
|
ORDER BY created_at ASC, id ASC
|
|
543
536
|
FOR UPDATE
|
|
544
537
|
`
|
|
545
|
-
: await sql<PgAuthSessionRow[]>`
|
|
546
|
-
SELECT *
|
|
547
|
-
FROM auth_sessions
|
|
548
|
-
WHERE project_id = ${params.projectId}
|
|
549
|
-
AND user_id = ${params.userId}
|
|
550
|
-
AND audience = ${params.audience}
|
|
551
|
-
AND revoked_at IS NULL
|
|
552
|
-
AND expires_at > ${params.revokedAt}
|
|
553
|
-
AND (absolute_expires_at IS NULL OR absolute_expires_at > ${params.revokedAt})
|
|
554
|
-
ORDER BY created_at ASC, id ASC
|
|
555
|
-
FOR UPDATE
|
|
556
|
-
`
|
|
557
538
|
|
|
558
|
-
|
|
559
|
-
await sql`
|
|
560
|
-
UPDATE auth_sessions
|
|
561
|
-
SET revoked_at = ${params.revokedAt}
|
|
562
|
-
WHERE project_id = ${params.projectId}
|
|
563
|
-
AND user_id = ${params.userId}
|
|
564
|
-
AND revoked_at IS NULL
|
|
565
|
-
AND expires_at > ${params.revokedAt}
|
|
566
|
-
AND (absolute_expires_at IS NULL OR absolute_expires_at > ${params.revokedAt})
|
|
567
|
-
`
|
|
568
|
-
} else {
|
|
569
|
-
await sql`
|
|
539
|
+
await sql`
|
|
570
540
|
UPDATE auth_sessions
|
|
571
541
|
SET revoked_at = ${params.revokedAt}
|
|
572
542
|
WHERE project_id = ${params.projectId}
|
|
573
543
|
AND user_id = ${params.userId}
|
|
574
|
-
AND audience = ${params.audience}
|
|
575
544
|
AND revoked_at IS NULL
|
|
576
545
|
AND expires_at > ${params.revokedAt}
|
|
577
546
|
AND (absolute_expires_at IS NULL OR absolute_expires_at > ${params.revokedAt})
|
|
578
547
|
`
|
|
579
|
-
}
|
|
580
548
|
|
|
581
549
|
return rows.map((row) =>
|
|
582
550
|
rowToSessionRecord({
|