| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | import * as SqlClient from "effect/unstable/sql/SqlClient"; |
| 2 | 2 | import * as SqlSchema from "effect/unstable/sql/SqlSchema"; |
| 3 | | import { Effect, Layer, Schema } from "effect"; |
| 3 | import { Effect, Layer, Schema, Struct } from "effect"; |
| 4 | 4 | import { ChatAttachment } from "@t3tools/contracts"; |
| 5 | 5 | |
| 6 | 6 | import { toPersistenceSqlError } from "../Errors.ts"; |
| ... | ... | @@ -12,11 +12,12 @@ import { |
| 12 | 12 | ProjectionThreadMessage, |
| 13 | 13 | } from "../Services/ProjectionThreadMessages.ts"; |
| 14 | 14 | |
| 15 | | const ProjectionThreadMessageDbRowSchema = Schema.Struct({ |
| 16 | | ...ProjectionThreadMessage.fields, |
| 17 | | isStreaming: Schema.Number, |
| 18 | | attachments: Schema.NullOr(Schema.fromJsonString(Schema.Array(ChatAttachment))), |
| 19 | | }); |
| 15 | const ProjectionThreadMessageDbRowSchema = ProjectionThreadMessage.mapFields( |
| 16 | Struct.assign({ |
| 17 | isStreaming: Schema.Number, |
| 18 | attachments: Schema.NullOr(Schema.fromJsonString(Schema.Array(ChatAttachment))), |
| 19 | }), |
| 20 | ); |
| 20 | 21 | |
| 21 | 22 | const makeProjectionThreadMessageRepository = Effect.gen(function* () { |
| 22 | 23 | const sql = yield* SqlClient.SqlClient; |
| ... | ... | @@ -24,7 +25,8 @@ const makeProjectionThreadMessageRepository = Effect.gen(function* () { |
| 24 | 25 | const upsertProjectionThreadMessageRow = SqlSchema.void({ |
| 25 | 26 | Request: ProjectionThreadMessage, |
| 26 | 27 | execute: (row) => { |
| 27 | | const nextAttachmentsJson = row.attachments !== undefined ? JSON.stringify(row.attachments) : null; |
| 28 | const nextAttachmentsJson = |
| 29 | row.attachments !== undefined ? JSON.stringify(row.attachments) : null; |
| 28 | 30 | return sql` |
| 29 | 31 | INSERT INTO projection_thread_messages ( |
| 30 | 32 | message_id, |