Deduplicate DB row schemas for projects and threads
Export ProjectionProjectDbRow and ProjectionThreadDbRow from their respective repository Layer files and reuse them in ProjectionSnapshotQuery instead of redefining identical schemas. This eliminates the risk of the two read paths silently diverging if the mapFields transforms are updated in one place but not the other.
This commit is contained in:
3 files changed
+6
-16
No files matched your search
@@ -6,7 +6,6 @@ import {
|
||||
OrchestrationCheckpointFile,
|
||||
OrchestrationProposedPlanId,
|
||||
OrchestrationReadModel,
|
||||
ProjectScript,
|
||||
ThreadId,
|
||||
TurnId,
|
||||
type OrchestrationCheckpointSummary,
|
||||
@@ -17,7 +16,6 @@ import {
|
||||
type OrchestrationSession,
|
||||
type OrchestrationThread,
|
||||
type OrchestrationThreadActivity,
|
||||
ModelSelection,
|
||||
} from "@t3tools/contracts";
|
||||
import { Effect, Layer, Schema, Struct } from "effect";
|
||||
import * as SqlClient from "effect/unstable/sql/SqlClient";
|
||||
@@ -29,8 +27,9 @@ import {
|
||||
toPersistenceSqlError,
|
||||
type ProjectionRepositoryError,
|
||||
} from "../../persistence/Errors.ts";
|
||||
import { ProjectionProjectDbRow } from "../../persistence/Layers/ProjectionProjects.ts";
|
||||
import { ProjectionThreadDbRow } from "../../persistence/Layers/ProjectionThreads.ts";
|
||||
import { ProjectionCheckpoint } from "../../persistence/Services/ProjectionCheckpoints.ts";
|
||||
import { ProjectionProject } from "../../persistence/Services/ProjectionProjects.ts";
|
||||
import { ProjectionState } from "../../persistence/Services/ProjectionState.ts";
|
||||
import { ProjectionThreadActivity } from "../../persistence/Services/ProjectionThreadActivities.ts";
|
||||
import { ProjectionThreadMessage } from "../../persistence/Services/ProjectionThreadMessages.ts";
|
||||
@@ -44,12 +43,7 @@ import {
|
||||
} from "../Services/ProjectionSnapshotQuery.ts";
|
||||
|
||||
const decodeReadModel = Schema.decodeUnknownEffect(OrchestrationReadModel);
|
||||
const ProjectionProjectDbRowSchema = ProjectionProject.mapFields(
|
||||
Struct.assign({
|
||||
defaultModelSelection: Schema.NullOr(Schema.fromJsonString(ModelSelection)),
|
||||
scripts: Schema.fromJsonString(Schema.Array(ProjectScript)),
|
||||
}),
|
||||
);
|
||||
const ProjectionProjectDbRowSchema = ProjectionProjectDbRow;
|
||||
const ProjectionThreadMessageDbRowSchema = ProjectionThreadMessage.mapFields(
|
||||
Struct.assign({
|
||||
isStreaming: Schema.Number,
|
||||
@@ -57,11 +51,7 @@ const ProjectionThreadMessageDbRowSchema = ProjectionThreadMessage.mapFields(
|
||||
}),
|
||||
);
|
||||
const ProjectionThreadProposedPlanDbRowSchema = ProjectionThreadProposedPlan;
|
||||
const ProjectionThreadDbRowSchema = ProjectionThread.mapFields(
|
||||
Struct.assign({
|
||||
modelSelection: Schema.fromJsonString(ModelSelection),
|
||||
}),
|
||||
);
|
||||
const ProjectionThreadDbRowSchema = ProjectionThreadDbRow;
|
||||
const ProjectionThreadActivityDbRowSchema = ProjectionThreadActivity.mapFields(
|
||||
Struct.assign({
|
||||
payload: Schema.fromJsonString(Schema.Unknown),
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
type ProjectionProjectRepositoryShape,
|
||||
} from "../Services/ProjectionProjects.ts";
|
||||
|
||||
const ProjectionProjectDbRow = ProjectionProject.mapFields(
|
||||
export const ProjectionProjectDbRow = ProjectionProject.mapFields(
|
||||
Struct.assign({
|
||||
defaultModelSelection: Schema.NullOr(Schema.fromJsonString(ModelSelection)),
|
||||
scripts: Schema.fromJsonString(Schema.Array(ProjectScript)),
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
} from "../Services/ProjectionThreads.ts";
|
||||
import { ModelSelection } from "@t3tools/contracts";
|
||||
|
||||
const ProjectionThreadDbRow = ProjectionThread.mapFields(
|
||||
export const ProjectionThreadDbRow = ProjectionThread.mapFields(
|
||||
Struct.assign({
|
||||
modelSelection: Schema.fromJsonString(ModelSelection),
|
||||
}),
|
||||
|
||||
Reference in new issue
Block a user