-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfigma-event.ts
More file actions
50 lines (48 loc) · 1.93 KB
/
figma-event.ts
File metadata and controls
50 lines (48 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { index, integer, sqliteTable, text } from "drizzle-orm/sqlite-core";
import { z } from "zod/v4";
import { createInsertSchema, createSelectSchema, createUpdateSchema } from "./common";
import { figmaFile } from "./figma-file";
export const figmaEvent = sqliteTable(
"figma_event",
{
id: text("id").primaryKey(),
figmaId: text("figma_id").notNull().unique(),
figmaUserId: text("figma_user_id"),
fileId: text("file_id").references(() => figmaFile.id, { onDelete: "cascade" }),
type: text("type").notNull(), // FILE_UPDATE, FILE_VERSION_UPDATE, COMMENT, etc.
payload: text("payload", { mode: "json" }).notNull(),
webhookId: text("webhook_id"),
passcode: text("passcode"),
timestamp: text("timestamp").notNull(),
createdAt: integer("created_at", { mode: "timestamp" }).notNull(),
insertedAt: integer("inserted_at", { mode: "timestamp" }).notNull(),
},
(t) => [
index("figma_event_file_id_index").on(t.fileId),
index("figma_event_figma_user_id_index").on(t.figmaUserId),
index("figma_event_type_index").on(t.type),
index("figma_event_created_at_index").on(t.createdAt),
index("figma_event_figma_id_index").on(t.figmaId),
],
);
export const FigmaEvent = createSelectSchema(figmaEvent, {
figmaId: z.string().trim().min(1),
type: z.string().trim().min(1),
payload: z.any(),
timestamp: z.string().trim().min(1),
});
export type FigmaEvent = z.output<typeof FigmaEvent>;
export const FigmaEventInsert = createInsertSchema(figmaEvent, {
figmaId: z.string().trim().min(1),
type: z.string().trim().min(1),
payload: z.any(),
timestamp: z.string().trim().min(1),
});
export type FigmaEventInsert = z.output<typeof FigmaEventInsert>;
export const FigmaEventUpdate = createUpdateSchema(figmaEvent, {
figmaId: z.string().trim().min(1),
type: z.string().trim().min(1),
payload: z.any(),
timestamp: z.string().trim().min(1),
});
export type FigmaEventUpdate = z.output<typeof FigmaEventUpdate>;