/** * Journal schemas for home space data. * These define the structure of user's activity journal. */ import type { JSONSchema, Schema } from "@commontools/api"; /** * Journal entry event types - the significant events we track */ export const journalEventTypes = [ "charm:favorited", "charm:unfavorited", "charm:created", "charm:modified", "space:entered", ] as const; export type JournalEventType = (typeof journalEventTypes)[number]; /** * Snapshot of a cell's state at a point in time */ export const journalSnapshotSchema = { type: "object", properties: { name: { type: "string", default: "" }, schemaTag: { type: "string", default: "" }, valueExcerpt: { type: "string", default: "" }, }, } as const satisfies JSONSchema; export type JournalSnapshot = Schema; /** * A single journal entry capturing a significant event */ export const journalEntrySchema = { type: "object", properties: { timestamp: { type: "number" }, eventType: { type: "string", enum: journalEventTypes as unknown as string[], }, // Live cell reference (may update over time) subject: { not: true, asCell: true }, // Frozen snapshot at entry time snapshot: journalSnapshotSchema, // LLM-generated narrative prose narrative: { type: "string", default: "" }, // Tags for filtering/searching tags: { type: "array", items: { type: "string" }, default: [], }, // Space where event occurred space: { type: "string" }, }, required: ["timestamp", "eventType", "space"], } as const satisfies JSONSchema; export type JournalEntry = Schema; /** * The journal is an array of entries */ export const journalSchema = { type: "array", items: journalEntrySchema, default: [], } as const satisfies JSONSchema; export type Journal = Schema;