This commit is contained in:
Julius Marminge authored and Julius Marminge committed 2026-02-27 21:30:46 -08:00
1 parent 2b154db938
commit 35817601ff
2 files changed
+15 -12

No files matched your search

@@ -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),
@@ -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,