diff --git a/apps/server/src/orchestration/Layers/ProjectionSnapshotQuery.ts b/apps/server/src/orchestration/Layers/ProjectionSnapshotQuery.ts index 5d5d77c4823b3663f31564148db77d5e56acc5e6..a4f260118c43735096349d0726a51c7bcf9873fd 100644 --- a/apps/server/src/orchestration/Layers/ProjectionSnapshotQuery.ts +++ b/apps/server/src/orchestration/Layers/ProjectionSnapshotQuery.ts @@ -43,12 +43,13 @@ const ProjectionProjectDbRowSchema = ProjectionProject.mapFields( scripts: Schema.fromJsonString(Schema.Array(ProjectScript)), }), ); +const ProjectionThreadMessageDbRowSchema = ProjectionThreadMessage.mapFields( + Struct.assign({ + isStreaming: Schema.Number, + attachments: Schema.NullOr(Schema.fromJsonString(Schema.Array(ChatAttachment))), + }), +); const ProjectionThreadDbRowSchema = ProjectionThread; -const ProjectionThreadMessageDbRowSchema = Schema.Struct({ - ...ProjectionThreadMessage.fields, - isStreaming: Schema.Number, - attachments: Schema.NullOr(Schema.fromJsonString(Schema.Array(ChatAttachment))), -}); const ProjectionThreadActivityDbRowSchema = ProjectionThreadActivity.mapFields( Struct.assign({ payload: Schema.fromJsonString(Schema.Unknown), diff --git a/apps/server/src/persistence/Layers/ProjectionThreadMessages.ts b/apps/server/src/persistence/Layers/ProjectionThreadMessages.ts index dd30f35f92ff775da54fe7f0f5f2d45ac33ddfa8..6f0b25ddffade7dd32f1a9db625cd46b9cb0aef5 100644 --- a/apps/server/src/persistence/Layers/ProjectionThreadMessages.ts +++ b/apps/server/src/persistence/Layers/ProjectionThreadMessages.ts @@ -1,6 +1,6 @@ import * as SqlClient from "effect/unstable/sql/SqlClient"; import * as SqlSchema from "effect/unstable/sql/SqlSchema"; -import { Effect, Layer, Schema } from "effect"; +import { Effect, Layer, Schema, Struct } from "effect"; import { ChatAttachment } from "@t3tools/contracts"; import { toPersistenceSqlError } from "../Errors.ts"; @@ -12,11 +12,12 @@ import { ProjectionThreadMessage, } from "../Services/ProjectionThreadMessages.ts"; -const ProjectionThreadMessageDbRowSchema = Schema.Struct({ - ...ProjectionThreadMessage.fields, - isStreaming: Schema.Number, - attachments: Schema.NullOr(Schema.fromJsonString(Schema.Array(ChatAttachment))), -}); +const ProjectionThreadMessageDbRowSchema = ProjectionThreadMessage.mapFields( + Struct.assign({ + isStreaming: Schema.Number, + attachments: Schema.NullOr(Schema.fromJsonString(Schema.Array(ChatAttachment))), + }), +); const makeProjectionThreadMessageRepository = Effect.gen(function* () { const sql = yield* SqlClient.SqlClient; @@ -24,7 +25,8 @@ const makeProjectionThreadMessageRepository = Effect.gen(function* () { const upsertProjectionThreadMessageRow = SqlSchema.void({ Request: ProjectionThreadMessage, execute: (row) => { - const nextAttachmentsJson = row.attachments !== undefined ? JSON.stringify(row.attachments) : null; + const nextAttachmentsJson = + row.attachments !== undefined ? JSON.stringify(row.attachments) : null; return sql` INSERT INTO projection_thread_messages ( message_id,