@cossistant/types 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/common.d.ts +44 -0
- package/dist/api/common.d.ts.map +1 -0
- package/dist/api/common.js +72 -0
- package/dist/api/common.js.map +1 -0
- package/dist/api/contact.d.ts +138 -0
- package/dist/api/contact.d.ts.map +1 -0
- package/dist/api/contact.js +297 -0
- package/dist/api/contact.js.map +1 -0
- package/dist/api/conversation.d.ts +91 -0
- package/dist/api/conversation.d.ts.map +1 -0
- package/dist/api/conversation.js +81 -0
- package/dist/api/conversation.js.map +1 -0
- package/dist/api/index.d.ts +10 -0
- package/dist/api/index.js +11 -0
- package/dist/api/organization.d.ts +15 -0
- package/dist/api/organization.d.ts.map +1 -0
- package/dist/api/organization.js +20 -0
- package/dist/api/organization.js.map +1 -0
- package/dist/api/timeline-item.d.ts +270 -0
- package/dist/api/timeline-item.d.ts.map +1 -0
- package/dist/api/timeline-item.js +111 -0
- package/dist/api/timeline-item.js.map +1 -0
- package/dist/api/upload.d.ts +100 -0
- package/dist/api/upload.d.ts.map +1 -0
- package/dist/api/upload.js +119 -0
- package/dist/api/upload.js.map +1 -0
- package/dist/api/user.d.ts +27 -0
- package/dist/api/user.d.ts.map +1 -0
- package/dist/api/user.js +52 -0
- package/dist/api/user.js.map +1 -0
- package/dist/api/visitor.d.ts +125 -0
- package/dist/api/visitor.d.ts.map +1 -0
- package/dist/api/visitor.js +301 -0
- package/dist/api/visitor.js.map +1 -0
- package/dist/api/website.d.ts +192 -0
- package/dist/api/website.d.ts.map +1 -0
- package/dist/api/website.js +320 -0
- package/dist/api/website.js.map +1 -0
- package/dist/enums.d.ts +79 -0
- package/dist/enums.d.ts.map +1 -0
- package/dist/enums.js +69 -0
- package/dist/enums.js.map +1 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/presence.d.ts +7 -0
- package/dist/presence.d.ts.map +1 -0
- package/dist/presence.js +8 -0
- package/dist/presence.js.map +1 -0
- package/dist/realtime-events.d.ts +136 -0
- package/dist/realtime-events.d.ts.map +1 -0
- package/dist/realtime-events.js +99 -0
- package/dist/realtime-events.js.map +1 -0
- package/dist/schemas.d.ts +44 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +46 -0
- package/dist/schemas.js.map +1 -0
- package/dist/trpc/contact.d.ts +68 -0
- package/dist/trpc/contact.d.ts.map +1 -0
- package/dist/trpc/contact.js +45 -0
- package/dist/trpc/contact.js.map +1 -0
- package/dist/trpc/conversation.d.ts +139 -0
- package/dist/trpc/conversation.d.ts.map +1 -0
- package/dist/trpc/conversation.js +80 -0
- package/dist/trpc/conversation.js.map +1 -0
- package/dist/trpc/visitor.d.ts +53 -0
- package/dist/trpc/visitor.d.ts.map +1 -0
- package/dist/trpc/visitor.js +34 -0
- package/dist/trpc/visitor.js.map +1 -0
- package/package.json +40 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { ConversationEventType, ConversationTimelineType, TimelineItemVisibility } from "../enums.js";
|
|
2
|
+
import { z } from "@hono/zod-openapi";
|
|
3
|
+
|
|
4
|
+
//#region src/api/timeline-item.ts
|
|
5
|
+
const timelinePartImageSchema = z.object({
|
|
6
|
+
type: z.literal("image").openapi({ description: "Type of timeline part - always 'image' for image parts" }),
|
|
7
|
+
url: z.string().openapi({ description: "URL of the image" }),
|
|
8
|
+
mediaType: z.string().openapi({ description: "MIME type of the image" }),
|
|
9
|
+
fileName: z.string().optional().openapi({ description: "Original filename of the image" }),
|
|
10
|
+
size: z.number().optional().openapi({ description: "Size of the image in bytes" }),
|
|
11
|
+
width: z.number().optional().openapi({ description: "Width of the image in pixels" }),
|
|
12
|
+
height: z.number().optional().openapi({ description: "Height of the image in pixels" })
|
|
13
|
+
});
|
|
14
|
+
const timelinePartTextSchema = z.object({
|
|
15
|
+
type: z.literal("text").openapi({ description: "Type of timeline part - always 'text' for text parts" }),
|
|
16
|
+
text: z.string().openapi({ description: "The text content of this timeline part" })
|
|
17
|
+
});
|
|
18
|
+
const timelineFileSchema = z.object({
|
|
19
|
+
type: z.literal("file").openapi({ description: "Type of timeline part - always 'file' for file parts" }),
|
|
20
|
+
url: z.string().openapi({ description: "URL of the file" }),
|
|
21
|
+
mediaType: z.string().openapi({ description: "MIME type of the file" }),
|
|
22
|
+
fileName: z.string().optional().openapi({ description: "Original filename of the file" }),
|
|
23
|
+
size: z.number().optional().openapi({ description: "Size of the file in bytes" })
|
|
24
|
+
});
|
|
25
|
+
const timelinePartEventSchema = z.object({
|
|
26
|
+
type: z.literal("event").openapi({ description: "Type of timeline part - always 'event' for event parts" }),
|
|
27
|
+
eventType: z.enum([
|
|
28
|
+
ConversationEventType.ASSIGNED,
|
|
29
|
+
ConversationEventType.UNASSIGNED,
|
|
30
|
+
ConversationEventType.PARTICIPANT_REQUESTED,
|
|
31
|
+
ConversationEventType.PARTICIPANT_JOINED,
|
|
32
|
+
ConversationEventType.PARTICIPANT_LEFT,
|
|
33
|
+
ConversationEventType.STATUS_CHANGED,
|
|
34
|
+
ConversationEventType.PRIORITY_CHANGED,
|
|
35
|
+
ConversationEventType.TAG_ADDED,
|
|
36
|
+
ConversationEventType.TAG_REMOVED,
|
|
37
|
+
ConversationEventType.RESOLVED,
|
|
38
|
+
ConversationEventType.REOPENED,
|
|
39
|
+
ConversationEventType.VISITOR_BLOCKED,
|
|
40
|
+
ConversationEventType.VISITOR_UNBLOCKED,
|
|
41
|
+
ConversationEventType.VISITOR_IDENTIFIED
|
|
42
|
+
]).openapi({ description: "Type of event that occurred" }),
|
|
43
|
+
actorUserId: z.string().nullable().openapi({ description: "User that triggered the event, if applicable" }),
|
|
44
|
+
actorAiAgentId: z.string().nullable().openapi({ description: "AI agent that triggered the event, if applicable" }),
|
|
45
|
+
targetUserId: z.string().nullable().openapi({ description: "User targeted by the event, if applicable" }),
|
|
46
|
+
targetAiAgentId: z.string().nullable().openapi({ description: "AI agent targeted by the event, if applicable" }),
|
|
47
|
+
message: z.string().nullable().optional().openapi({ description: "Optional human readable message attached to the event" })
|
|
48
|
+
});
|
|
49
|
+
const timelineItemPartsSchema = z.array(z.union([
|
|
50
|
+
timelinePartTextSchema,
|
|
51
|
+
timelinePartEventSchema,
|
|
52
|
+
timelinePartImageSchema,
|
|
53
|
+
timelineFileSchema
|
|
54
|
+
])).openapi({ description: "Array of timeline parts that make up the timeline item content" });
|
|
55
|
+
const timelineItemSchema = z.object({
|
|
56
|
+
id: z.string().optional().openapi({ description: "Unique identifier for the timeline item" }),
|
|
57
|
+
conversationId: z.string().openapi({ description: "ID of the conversation this timeline item belongs to" }),
|
|
58
|
+
organizationId: z.string().openapi({ description: "ID of the organization this timeline item belongs to" }),
|
|
59
|
+
visibility: z.enum([TimelineItemVisibility.PUBLIC, TimelineItemVisibility.PRIVATE]).openapi({ description: "Visibility level of the timeline item" }),
|
|
60
|
+
type: z.enum([
|
|
61
|
+
ConversationTimelineType.MESSAGE,
|
|
62
|
+
ConversationTimelineType.EVENT,
|
|
63
|
+
ConversationTimelineType.IDENTIFICATION
|
|
64
|
+
]).openapi({ description: "Type of timeline item - message, event, or interactive identification tool" }),
|
|
65
|
+
text: z.string().nullable().openapi({ description: "Main text content of the timeline item" }),
|
|
66
|
+
tool: z.string().nullable().optional().openapi({ description: "Optional tool identifier associated with this timeline item" }),
|
|
67
|
+
parts: timelineItemPartsSchema,
|
|
68
|
+
userId: z.string().nullable().openapi({ description: "ID of the user who created this timeline item, if applicable" }),
|
|
69
|
+
aiAgentId: z.string().nullable().openapi({ description: "ID of the AI agent that created this timeline item, if applicable" }),
|
|
70
|
+
visitorId: z.string().nullable().openapi({ description: "ID of the visitor who created this timeline item, if applicable" }),
|
|
71
|
+
createdAt: z.string().openapi({ description: "ISO 8601 timestamp when the timeline item was created" }),
|
|
72
|
+
deletedAt: z.string().nullable().optional().openapi({ description: "ISO 8601 timestamp when the timeline item was deleted, if applicable" })
|
|
73
|
+
});
|
|
74
|
+
const getConversationTimelineItemsRequestSchema = z.object({
|
|
75
|
+
limit: z.coerce.number().min(1).max(100).default(50).openapi({
|
|
76
|
+
description: "Number of timeline items to fetch per page",
|
|
77
|
+
default: 50
|
|
78
|
+
}),
|
|
79
|
+
cursor: z.string().nullable().optional().openapi({ description: "Cursor for pagination (timestamp_id format from previous response)" })
|
|
80
|
+
}).openapi({ description: "Query parameters for fetching conversation timeline items" });
|
|
81
|
+
const getConversationTimelineItemsResponseSchema = z.object({
|
|
82
|
+
items: z.array(timelineItemSchema).openapi({ description: "Array of timeline items in chronological order" }),
|
|
83
|
+
nextCursor: z.string().nullable().openapi({ description: "Cursor for the next page, null if no more items are available" }),
|
|
84
|
+
hasNextPage: z.boolean().openapi({ description: "Whether there are more items available to fetch" })
|
|
85
|
+
}).openapi({ description: "Response containing paginated timeline items" });
|
|
86
|
+
const sendTimelineItemRequestSchema = z.object({
|
|
87
|
+
conversationId: z.string().openapi({ description: "ID of the conversation to send the timeline item to" }),
|
|
88
|
+
item: z.object({
|
|
89
|
+
id: z.string().optional().openapi({ description: "Optional client-generated ID for the timeline item" }),
|
|
90
|
+
type: z.enum([ConversationTimelineType.MESSAGE, ConversationTimelineType.EVENT]).default(ConversationTimelineType.MESSAGE).openapi({
|
|
91
|
+
description: "Type of timeline item - defaults to MESSAGE",
|
|
92
|
+
default: ConversationTimelineType.MESSAGE
|
|
93
|
+
}),
|
|
94
|
+
text: z.string().openapi({ description: "Main text content of the timeline item" }),
|
|
95
|
+
parts: timelineItemPartsSchema.optional(),
|
|
96
|
+
visibility: z.enum([TimelineItemVisibility.PUBLIC, TimelineItemVisibility.PRIVATE]).default(TimelineItemVisibility.PUBLIC).openapi({
|
|
97
|
+
description: "Visibility level of the timeline item",
|
|
98
|
+
default: TimelineItemVisibility.PUBLIC
|
|
99
|
+
}),
|
|
100
|
+
tool: z.string().nullable().optional().openapi({ description: "Optional tool identifier when sending non-message timeline items" }),
|
|
101
|
+
userId: z.string().nullable().optional().openapi({ description: "ID of the user creating this timeline item" }),
|
|
102
|
+
aiAgentId: z.string().nullable().optional().openapi({ description: "ID of the AI agent creating this timeline item" }),
|
|
103
|
+
visitorId: z.string().nullable().optional().openapi({ description: "ID of the visitor creating this timeline item" }),
|
|
104
|
+
createdAt: z.string().optional().openapi({ description: "Optional timestamp for the timeline item" })
|
|
105
|
+
})
|
|
106
|
+
}).openapi({ description: "Request body for sending a timeline item to a conversation" });
|
|
107
|
+
const sendTimelineItemResponseSchema = z.object({ item: timelineItemSchema.openapi({ description: "The created timeline item" }) }).openapi({ description: "Response containing the created timeline item" });
|
|
108
|
+
|
|
109
|
+
//#endregion
|
|
110
|
+
export { getConversationTimelineItemsRequestSchema, getConversationTimelineItemsResponseSchema, sendTimelineItemRequestSchema, sendTimelineItemResponseSchema, timelineItemPartsSchema, timelineItemSchema };
|
|
111
|
+
//# sourceMappingURL=timeline-item.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeline-item.js","names":[],"sources":["../../src/api/timeline-item.ts"],"sourcesContent":["import { z } from \"@hono/zod-openapi\";\n\nimport {\n\tConversationEventType,\n\tConversationTimelineType,\n\tTimelineItemVisibility,\n} from \"../enums\";\n\nconst timelinePartImageSchema = z.object({\n\ttype: z.literal(\"image\").openapi({\n\t\tdescription: \"Type of timeline part - always 'image' for image parts\",\n\t}),\n\turl: z.string().openapi({\n\t\tdescription: \"URL of the image\",\n\t}),\n\tmediaType: z.string().openapi({\n\t\tdescription: \"MIME type of the image\",\n\t}),\n\tfileName: z.string().optional().openapi({\n\t\tdescription: \"Original filename of the image\",\n\t}),\n\tsize: z.number().optional().openapi({\n\t\tdescription: \"Size of the image in bytes\",\n\t}),\n\twidth: z.number().optional().openapi({\n\t\tdescription: \"Width of the image in pixels\",\n\t}),\n\theight: z.number().optional().openapi({\n\t\tdescription: \"Height of the image in pixels\",\n\t}),\n});\n\nconst timelinePartTextSchema = z.object({\n\ttype: z.literal(\"text\").openapi({\n\t\tdescription: \"Type of timeline part - always 'text' for text parts\",\n\t}),\n\ttext: z.string().openapi({\n\t\tdescription: \"The text content of this timeline part\",\n\t}),\n});\n\nconst timelineFileSchema = z.object({\n\ttype: z.literal(\"file\").openapi({\n\t\tdescription: \"Type of timeline part - always 'file' for file parts\",\n\t}),\n\turl: z.string().openapi({\n\t\tdescription: \"URL of the file\",\n\t}),\n\tmediaType: z.string().openapi({\n\t\tdescription: \"MIME type of the file\",\n\t}),\n\tfileName: z.string().optional().openapi({\n\t\tdescription: \"Original filename of the file\",\n\t}),\n\tsize: z.number().optional().openapi({\n\t\tdescription: \"Size of the file in bytes\",\n\t}),\n});\n\nconst timelinePartEventSchema = z.object({\n\ttype: z.literal(\"event\").openapi({\n\t\tdescription: \"Type of timeline part - always 'event' for event parts\",\n\t}),\n\teventType: z\n\t\t.enum([\n\t\t\tConversationEventType.ASSIGNED,\n\t\t\tConversationEventType.UNASSIGNED,\n\t\t\tConversationEventType.PARTICIPANT_REQUESTED,\n\t\t\tConversationEventType.PARTICIPANT_JOINED,\n\t\t\tConversationEventType.PARTICIPANT_LEFT,\n\t\t\tConversationEventType.STATUS_CHANGED,\n\t\t\tConversationEventType.PRIORITY_CHANGED,\n\t\t\tConversationEventType.TAG_ADDED,\n\t\t\tConversationEventType.TAG_REMOVED,\n\t\t\tConversationEventType.RESOLVED,\n\t\t\tConversationEventType.REOPENED,\n\t\t\tConversationEventType.VISITOR_BLOCKED,\n\t\t\tConversationEventType.VISITOR_UNBLOCKED,\n\t\t\tConversationEventType.VISITOR_IDENTIFIED,\n\t\t])\n\t\t.openapi({\n\t\t\tdescription: \"Type of event that occurred\",\n\t\t}),\n\tactorUserId: z.string().nullable().openapi({\n\t\tdescription: \"User that triggered the event, if applicable\",\n\t}),\n\tactorAiAgentId: z.string().nullable().openapi({\n\t\tdescription: \"AI agent that triggered the event, if applicable\",\n\t}),\n\ttargetUserId: z.string().nullable().openapi({\n\t\tdescription: \"User targeted by the event, if applicable\",\n\t}),\n\ttargetAiAgentId: z.string().nullable().openapi({\n\t\tdescription: \"AI agent targeted by the event, if applicable\",\n\t}),\n\tmessage: z.string().nullable().optional().openapi({\n\t\tdescription: \"Optional human readable message attached to the event\",\n\t}),\n});\n\nexport const timelineItemPartsSchema = z\n\t.array(\n\t\tz.union([\n\t\t\ttimelinePartTextSchema,\n\t\t\ttimelinePartEventSchema,\n\t\t\ttimelinePartImageSchema,\n\t\t\ttimelineFileSchema,\n\t\t])\n\t)\n\t.openapi({\n\t\tdescription:\n\t\t\t\"Array of timeline parts that make up the timeline item content\",\n\t});\n\nexport const timelineItemSchema = z.object({\n\tid: z.string().optional().openapi({\n\t\tdescription: \"Unique identifier for the timeline item\",\n\t}),\n\tconversationId: z.string().openapi({\n\t\tdescription: \"ID of the conversation this timeline item belongs to\",\n\t}),\n\torganizationId: z.string().openapi({\n\t\tdescription: \"ID of the organization this timeline item belongs to\",\n\t}),\n\tvisibility: z\n\t\t.enum([TimelineItemVisibility.PUBLIC, TimelineItemVisibility.PRIVATE])\n\t\t.openapi({\n\t\t\tdescription: \"Visibility level of the timeline item\",\n\t\t}),\n\ttype: z\n\t\t.enum([\n\t\t\tConversationTimelineType.MESSAGE,\n\t\t\tConversationTimelineType.EVENT,\n\t\t\tConversationTimelineType.IDENTIFICATION,\n\t\t])\n\t\t.openapi({\n\t\t\tdescription:\n\t\t\t\t\"Type of timeline item - message, event, or interactive identification tool\",\n\t\t}),\n\ttext: z.string().nullable().openapi({\n\t\tdescription: \"Main text content of the timeline item\",\n\t}),\n\ttool: z.string().nullable().optional().openapi({\n\t\tdescription: \"Optional tool identifier associated with this timeline item\",\n\t}),\n\tparts: timelineItemPartsSchema,\n\tuserId: z.string().nullable().openapi({\n\t\tdescription: \"ID of the user who created this timeline item, if applicable\",\n\t}),\n\taiAgentId: z.string().nullable().openapi({\n\t\tdescription:\n\t\t\t\"ID of the AI agent that created this timeline item, if applicable\",\n\t}),\n\tvisitorId: z.string().nullable().openapi({\n\t\tdescription:\n\t\t\t\"ID of the visitor who created this timeline item, if applicable\",\n\t}),\n\tcreatedAt: z.string().openapi({\n\t\tdescription: \"ISO 8601 timestamp when the timeline item was created\",\n\t}),\n\tdeletedAt: z.string().nullable().optional().openapi({\n\t\tdescription:\n\t\t\t\"ISO 8601 timestamp when the timeline item was deleted, if applicable\",\n\t}),\n});\n\nexport type timelineItemSchema = z.infer<typeof timelineItemSchema>;\n\nexport type TimelineItem = z.infer<typeof timelineItemSchema>;\nexport type TimelineItemParts = z.infer<typeof timelineItemPartsSchema>;\n\nexport type TimelinePartText = z.infer<typeof timelinePartTextSchema>;\nexport type TimelinePartImage = z.infer<typeof timelinePartImageSchema>;\nexport type TimelinePartFile = z.infer<typeof timelineFileSchema>;\nexport type TimelinePartEvent = z.infer<typeof timelinePartEventSchema>;\n\n// REST API Schemas\nexport const getConversationTimelineItemsRequestSchema = z\n\t.object({\n\t\tlimit: z.coerce.number().min(1).max(100).default(50).openapi({\n\t\t\tdescription: \"Number of timeline items to fetch per page\",\n\t\t\tdefault: 50,\n\t\t}),\n\t\tcursor: z.string().nullable().optional().openapi({\n\t\t\tdescription:\n\t\t\t\t\"Cursor for pagination (timestamp_id format from previous response)\",\n\t\t}),\n\t})\n\t.openapi({\n\t\tdescription: \"Query parameters for fetching conversation timeline items\",\n\t});\n\nexport type GetConversationTimelineItemsRequest = z.infer<\n\ttypeof getConversationTimelineItemsRequestSchema\n>;\n\nexport const getConversationTimelineItemsResponseSchema = z\n\t.object({\n\t\titems: z.array(timelineItemSchema).openapi({\n\t\t\tdescription: \"Array of timeline items in chronological order\",\n\t\t}),\n\t\tnextCursor: z.string().nullable().openapi({\n\t\t\tdescription:\n\t\t\t\t\"Cursor for the next page, null if no more items are available\",\n\t\t}),\n\t\thasNextPage: z.boolean().openapi({\n\t\t\tdescription: \"Whether there are more items available to fetch\",\n\t\t}),\n\t})\n\t.openapi({\n\t\tdescription: \"Response containing paginated timeline items\",\n\t});\n\nexport type GetConversationTimelineItemsResponse = z.infer<\n\ttypeof getConversationTimelineItemsResponseSchema\n>;\n\n// Send Timeline Item (Message) Schemas\nexport const sendTimelineItemRequestSchema = z\n\t.object({\n\t\tconversationId: z.string().openapi({\n\t\t\tdescription: \"ID of the conversation to send the timeline item to\",\n\t\t}),\n\t\titem: z.object({\n\t\t\tid: z.string().optional().openapi({\n\t\t\t\tdescription: \"Optional client-generated ID for the timeline item\",\n\t\t\t}),\n\t\t\ttype: z\n\t\t\t\t.enum([\n\t\t\t\t\tConversationTimelineType.MESSAGE,\n\t\t\t\t\tConversationTimelineType.EVENT,\n\t\t\t\t])\n\t\t\t\t.default(ConversationTimelineType.MESSAGE)\n\t\t\t\t.openapi({\n\t\t\t\t\tdescription: \"Type of timeline item - defaults to MESSAGE\",\n\t\t\t\t\tdefault: ConversationTimelineType.MESSAGE,\n\t\t\t\t}),\n\t\t\ttext: z.string().openapi({\n\t\t\t\tdescription: \"Main text content of the timeline item\",\n\t\t\t}),\n\t\t\tparts: timelineItemPartsSchema.optional(),\n\t\t\tvisibility: z\n\t\t\t\t.enum([TimelineItemVisibility.PUBLIC, TimelineItemVisibility.PRIVATE])\n\t\t\t\t.default(TimelineItemVisibility.PUBLIC)\n\t\t\t\t.openapi({\n\t\t\t\t\tdescription: \"Visibility level of the timeline item\",\n\t\t\t\t\tdefault: TimelineItemVisibility.PUBLIC,\n\t\t\t\t}),\n\t\t\ttool: z.string().nullable().optional().openapi({\n\t\t\t\tdescription:\n\t\t\t\t\t\"Optional tool identifier when sending non-message timeline items\",\n\t\t\t}),\n\t\t\tuserId: z.string().nullable().optional().openapi({\n\t\t\t\tdescription: \"ID of the user creating this timeline item\",\n\t\t\t}),\n\t\t\taiAgentId: z.string().nullable().optional().openapi({\n\t\t\t\tdescription: \"ID of the AI agent creating this timeline item\",\n\t\t\t}),\n\t\t\tvisitorId: z.string().nullable().optional().openapi({\n\t\t\t\tdescription: \"ID of the visitor creating this timeline item\",\n\t\t\t}),\n\t\t\tcreatedAt: z.string().optional().openapi({\n\t\t\t\tdescription: \"Optional timestamp for the timeline item\",\n\t\t\t}),\n\t\t}),\n\t})\n\t.openapi({\n\t\tdescription: \"Request body for sending a timeline item to a conversation\",\n\t});\n\nexport type SendTimelineItemRequest = z.infer<\n\ttypeof sendTimelineItemRequestSchema\n>;\n\nexport const sendTimelineItemResponseSchema = z\n\t.object({\n\t\titem: timelineItemSchema.openapi({\n\t\t\tdescription: \"The created timeline item\",\n\t\t}),\n\t})\n\t.openapi({\n\t\tdescription: \"Response containing the created timeline item\",\n\t});\n\nexport type SendTimelineItemResponse = z.infer<\n\ttypeof sendTimelineItemResponseSchema\n>;\n"],"mappings":";;;;AAQA,MAAM,0BAA0B,EAAE,OAAO;CACxC,MAAM,EAAE,QAAQ,QAAQ,CAAC,QAAQ,EAChC,aAAa,0DACb,CAAC;CACF,KAAK,EAAE,QAAQ,CAAC,QAAQ,EACvB,aAAa,oBACb,CAAC;CACF,WAAW,EAAE,QAAQ,CAAC,QAAQ,EAC7B,aAAa,0BACb,CAAC;CACF,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC,QAAQ,EACvC,aAAa,kCACb,CAAC;CACF,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC,QAAQ,EACnC,aAAa,8BACb,CAAC;CACF,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,QAAQ,EACpC,aAAa,gCACb,CAAC;CACF,QAAQ,EAAE,QAAQ,CAAC,UAAU,CAAC,QAAQ,EACrC,aAAa,iCACb,CAAC;CACF,CAAC;AAEF,MAAM,yBAAyB,EAAE,OAAO;CACvC,MAAM,EAAE,QAAQ,OAAO,CAAC,QAAQ,EAC/B,aAAa,wDACb,CAAC;CACF,MAAM,EAAE,QAAQ,CAAC,QAAQ,EACxB,aAAa,0CACb,CAAC;CACF,CAAC;AAEF,MAAM,qBAAqB,EAAE,OAAO;CACnC,MAAM,EAAE,QAAQ,OAAO,CAAC,QAAQ,EAC/B,aAAa,wDACb,CAAC;CACF,KAAK,EAAE,QAAQ,CA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CAAC;EACF,CAAC;CACF,CAAC,CACD,QAAQ,EACR,aAAa,8DACb,CAAC;AAMH,MAAa,iCAAiC,EAC5C,OAAO,EACP,MAAM,mBAAmB,QAAQ,EAChC,aAAa,6BACb,CAAC,EACF,CAAC,CACD,QAAQ,EACR,aAAa,iDACb,CAAC"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { z } from "@hono/zod-openapi";
|
|
2
|
+
|
|
3
|
+
//#region src/api/upload.d.ts
|
|
4
|
+
declare const uploadOrganizationIdSchema: z.ZodString;
|
|
5
|
+
declare const uploadWebsiteIdSchema: z.ZodString;
|
|
6
|
+
declare const uploadConversationIdSchema: z.ZodString;
|
|
7
|
+
declare const uploadUserIdSchema: z.ZodString;
|
|
8
|
+
declare const uploadContactIdSchema: z.ZodString;
|
|
9
|
+
declare const uploadVisitorIdSchema: z.ZodString;
|
|
10
|
+
declare const uploadPathSchema: z.ZodString;
|
|
11
|
+
declare const uploadFileNameSchema: z.ZodString;
|
|
12
|
+
declare const uploadFileExtensionSchema: z.ZodString;
|
|
13
|
+
declare const uploadScopeConversationSchema: z.ZodObject<{
|
|
14
|
+
type: z.ZodLiteral<"conversation">;
|
|
15
|
+
conversationId: z.ZodString;
|
|
16
|
+
organizationId: z.ZodString;
|
|
17
|
+
websiteId: z.ZodString;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
declare const uploadScopeUserSchema: z.ZodObject<{
|
|
20
|
+
type: z.ZodLiteral<"user">;
|
|
21
|
+
userId: z.ZodString;
|
|
22
|
+
organizationId: z.ZodString;
|
|
23
|
+
websiteId: z.ZodString;
|
|
24
|
+
}, z.core.$strip>;
|
|
25
|
+
declare const uploadScopeContactSchema: z.ZodObject<{
|
|
26
|
+
type: z.ZodLiteral<"contact">;
|
|
27
|
+
contactId: z.ZodString;
|
|
28
|
+
organizationId: z.ZodString;
|
|
29
|
+
websiteId: z.ZodString;
|
|
30
|
+
}, z.core.$strip>;
|
|
31
|
+
declare const uploadScopeVisitorSchema: z.ZodObject<{
|
|
32
|
+
type: z.ZodLiteral<"visitor">;
|
|
33
|
+
visitorId: z.ZodString;
|
|
34
|
+
organizationId: z.ZodString;
|
|
35
|
+
websiteId: z.ZodString;
|
|
36
|
+
}, z.core.$strip>;
|
|
37
|
+
declare const uploadScopeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
38
|
+
type: z.ZodLiteral<"conversation">;
|
|
39
|
+
conversationId: z.ZodString;
|
|
40
|
+
organizationId: z.ZodString;
|
|
41
|
+
websiteId: z.ZodString;
|
|
42
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
43
|
+
type: z.ZodLiteral<"user">;
|
|
44
|
+
userId: z.ZodString;
|
|
45
|
+
organizationId: z.ZodString;
|
|
46
|
+
websiteId: z.ZodString;
|
|
47
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
48
|
+
type: z.ZodLiteral<"contact">;
|
|
49
|
+
contactId: z.ZodString;
|
|
50
|
+
organizationId: z.ZodString;
|
|
51
|
+
websiteId: z.ZodString;
|
|
52
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
53
|
+
type: z.ZodLiteral<"visitor">;
|
|
54
|
+
visitorId: z.ZodString;
|
|
55
|
+
organizationId: z.ZodString;
|
|
56
|
+
websiteId: z.ZodString;
|
|
57
|
+
}, z.core.$strip>], "type">;
|
|
58
|
+
declare const generateUploadUrlRequestSchema: z.ZodObject<{
|
|
59
|
+
contentType: z.ZodString;
|
|
60
|
+
websiteId: z.ZodString;
|
|
61
|
+
scope: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
62
|
+
type: z.ZodLiteral<"conversation">;
|
|
63
|
+
conversationId: z.ZodString;
|
|
64
|
+
organizationId: z.ZodString;
|
|
65
|
+
websiteId: z.ZodString;
|
|
66
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
67
|
+
type: z.ZodLiteral<"user">;
|
|
68
|
+
userId: z.ZodString;
|
|
69
|
+
organizationId: z.ZodString;
|
|
70
|
+
websiteId: z.ZodString;
|
|
71
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
72
|
+
type: z.ZodLiteral<"contact">;
|
|
73
|
+
contactId: z.ZodString;
|
|
74
|
+
organizationId: z.ZodString;
|
|
75
|
+
websiteId: z.ZodString;
|
|
76
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
77
|
+
type: z.ZodLiteral<"visitor">;
|
|
78
|
+
visitorId: z.ZodString;
|
|
79
|
+
organizationId: z.ZodString;
|
|
80
|
+
websiteId: z.ZodString;
|
|
81
|
+
}, z.core.$strip>], "type">;
|
|
82
|
+
path: z.ZodOptional<z.ZodString>;
|
|
83
|
+
fileName: z.ZodOptional<z.ZodString>;
|
|
84
|
+
fileExtension: z.ZodOptional<z.ZodString>;
|
|
85
|
+
useCdn: z.ZodOptional<z.ZodBoolean>;
|
|
86
|
+
expiresInSeconds: z.ZodOptional<z.ZodNumber>;
|
|
87
|
+
}, z.core.$strip>;
|
|
88
|
+
type GenerateUploadUrlRequest = z.infer<typeof generateUploadUrlRequestSchema>;
|
|
89
|
+
declare const generateUploadUrlResponseSchema: z.ZodObject<{
|
|
90
|
+
uploadUrl: z.ZodString;
|
|
91
|
+
key: z.ZodString;
|
|
92
|
+
bucket: z.ZodString;
|
|
93
|
+
expiresAt: z.ZodString;
|
|
94
|
+
contentType: z.ZodString;
|
|
95
|
+
publicUrl: z.ZodString;
|
|
96
|
+
}, z.core.$strip>;
|
|
97
|
+
type GenerateUploadUrlResponse = z.infer<typeof generateUploadUrlResponseSchema>;
|
|
98
|
+
//#endregion
|
|
99
|
+
export { GenerateUploadUrlRequest, GenerateUploadUrlResponse, generateUploadUrlRequestSchema, generateUploadUrlResponseSchema, uploadContactIdSchema, uploadConversationIdSchema, uploadFileExtensionSchema, uploadFileNameSchema, uploadOrganizationIdSchema, uploadPathSchema, uploadScopeContactSchema, uploadScopeConversationSchema, uploadScopeSchema, uploadScopeUserSchema, uploadScopeVisitorSchema, uploadUserIdSchema, uploadVisitorIdS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AA;IAYjB,cAAA,aAAA;;;;;;;;;;;;;;KAgCD,wBAAA,GAA2B,CAAA,CAAE,aACjC;cAGK,iCAA+B,CAAA,CAAA;;;;;;;;KAmChC,yBAAA,GAA4B,CAAA,CAAE,aAClC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { z } from "@hono/zod-openapi";
|
|
2
|
+
|
|
3
|
+
//#region src/api/upload.ts
|
|
4
|
+
const idSchema = z.string().min(1).max(128);
|
|
5
|
+
const uploadOrganizationIdSchema = idSchema.openapi({
|
|
6
|
+
description: "Identifier of the organization that owns the uploaded file.",
|
|
7
|
+
example: "org_01HZYFG9W5V6YB5R6T6V7N9M2Q"
|
|
8
|
+
});
|
|
9
|
+
const uploadWebsiteIdSchema = idSchema.openapi({
|
|
10
|
+
description: "Identifier of the website associated with the uploaded file.",
|
|
11
|
+
example: "site_01HZYFH3KJ3MYHJJ3JJ6Y2RNAV"
|
|
12
|
+
});
|
|
13
|
+
const uploadConversationIdSchema = idSchema.openapi({
|
|
14
|
+
description: "Conversation identifier that will scope the uploaded asset.",
|
|
15
|
+
example: "conv_01HZYFJ5P7DQ0VE8F68G5VYBAQ"
|
|
16
|
+
});
|
|
17
|
+
const uploadUserIdSchema = idSchema.openapi({
|
|
18
|
+
description: "User identifier that will scope the uploaded asset.",
|
|
19
|
+
example: "user_01HZYFKJS3K0M9W6PQZ0J6G1WR"
|
|
20
|
+
});
|
|
21
|
+
const uploadContactIdSchema = idSchema.openapi({
|
|
22
|
+
description: "Contact identifier that will scope the uploaded asset.",
|
|
23
|
+
example: "contact_01HZYFMN7J2J4F2SW3Q2N1H0D9"
|
|
24
|
+
});
|
|
25
|
+
const uploadVisitorIdSchema = idSchema.openapi({
|
|
26
|
+
description: "Visitor identifier that will scope the uploaded asset.",
|
|
27
|
+
example: "visitor_01HZYFPQ8R2FK1D9V7ZQ6CG6TN"
|
|
28
|
+
});
|
|
29
|
+
const uploadPathSchema = z.string().max(512).openapi({
|
|
30
|
+
description: "Optional relative path used to group uploads inside the bucket. Nested paths are supported.",
|
|
31
|
+
example: "assets/avatars"
|
|
32
|
+
});
|
|
33
|
+
const uploadFileNameSchema = z.string().min(1).max(128).regex(/^[^\\/]+$/).openapi({
|
|
34
|
+
description: "Optional file name to use for the object. Invalid characters will be sanitized on the server side.",
|
|
35
|
+
example: "profile-picture.png"
|
|
36
|
+
});
|
|
37
|
+
const uploadFileExtensionSchema = z.string().min(1).max(16).regex(/^[a-zA-Z0-9]+$/).openapi({
|
|
38
|
+
description: "Optional file extension without the leading dot. Use this when providing a custom file name without an extension.",
|
|
39
|
+
example: "png"
|
|
40
|
+
});
|
|
41
|
+
const baseScope = {
|
|
42
|
+
organizationId: uploadOrganizationIdSchema,
|
|
43
|
+
websiteId: uploadWebsiteIdSchema
|
|
44
|
+
};
|
|
45
|
+
const uploadScopeConversationSchema = z.object({
|
|
46
|
+
...baseScope,
|
|
47
|
+
type: z.literal("conversation"),
|
|
48
|
+
conversationId: uploadConversationIdSchema
|
|
49
|
+
}).openapi({ description: "Scope uploads to a specific conversation. Files will be placed under /{organizationId}/{websiteId}/{conversationId}." });
|
|
50
|
+
const uploadScopeUserSchema = z.object({
|
|
51
|
+
...baseScope,
|
|
52
|
+
type: z.literal("user"),
|
|
53
|
+
userId: uploadUserIdSchema
|
|
54
|
+
}).openapi({ description: "Scope uploads to a specific user. Files will be placed under /{organizationId}/{websiteId}/{userId}." });
|
|
55
|
+
const uploadScopeContactSchema = z.object({
|
|
56
|
+
...baseScope,
|
|
57
|
+
type: z.literal("contact"),
|
|
58
|
+
contactId: uploadContactIdSchema
|
|
59
|
+
}).openapi({ description: "Scope uploads to a specific contact. Files will be placed under /{organizationId}/{websiteId}/{contactId}." });
|
|
60
|
+
const uploadScopeVisitorSchema = z.object({
|
|
61
|
+
...baseScope,
|
|
62
|
+
type: z.literal("visitor"),
|
|
63
|
+
visitorId: uploadVisitorIdSchema
|
|
64
|
+
}).openapi({ description: "Scope uploads to a specific visitor. Files will be placed under /{organizationId}/{websiteId}/{visitorId}." });
|
|
65
|
+
const uploadScopeSchema = z.discriminatedUnion("type", [
|
|
66
|
+
uploadScopeConversationSchema,
|
|
67
|
+
uploadScopeUserSchema,
|
|
68
|
+
uploadScopeContactSchema,
|
|
69
|
+
uploadScopeVisitorSchema
|
|
70
|
+
]).openapi({ description: "Defines how uploaded files should be grouped inside the S3 bucket." });
|
|
71
|
+
const generateUploadUrlRequestSchema = z.object({
|
|
72
|
+
contentType: z.string().min(1).max(256).openapi({
|
|
73
|
+
description: "MIME type of the file to upload.",
|
|
74
|
+
example: "image/png"
|
|
75
|
+
}),
|
|
76
|
+
websiteId: z.string(),
|
|
77
|
+
scope: uploadScopeSchema,
|
|
78
|
+
path: uploadPathSchema.optional(),
|
|
79
|
+
fileName: uploadFileNameSchema.optional(),
|
|
80
|
+
fileExtension: uploadFileExtensionSchema.optional(),
|
|
81
|
+
useCdn: z.boolean().optional().openapi({
|
|
82
|
+
description: "Set to true to place the file under the /cdn prefix so it is cached by the CDN.",
|
|
83
|
+
example: true
|
|
84
|
+
}),
|
|
85
|
+
expiresInSeconds: z.number().int().min(60).max(3600).openapi({
|
|
86
|
+
description: "Number of seconds before the signed URL expires. Defaults to 900 seconds (15 minutes).",
|
|
87
|
+
example: 900
|
|
88
|
+
}).optional()
|
|
89
|
+
}).openapi({ description: "Request payload to create a signed S3 upload URL." });
|
|
90
|
+
const generateUploadUrlResponseSchema = z.object({
|
|
91
|
+
uploadUrl: z.string().url().openapi({
|
|
92
|
+
description: "Pre-signed URL that accepts a PUT request to upload the file to S3.",
|
|
93
|
+
example: "https://example-bucket.s3.amazonaws.com/org-id/file.png?X-Amz-Signature=..."
|
|
94
|
+
}),
|
|
95
|
+
key: z.string().openapi({
|
|
96
|
+
description: "Resolved object key that can be used to reference the uploaded asset.",
|
|
97
|
+
example: "01JG000000000000000000000/assets/file.png"
|
|
98
|
+
}),
|
|
99
|
+
bucket: z.string().openapi({
|
|
100
|
+
description: "Name of the S3 bucket that will receive the upload.",
|
|
101
|
+
example: "cossistant-uploads"
|
|
102
|
+
}),
|
|
103
|
+
expiresAt: z.string().openapi({
|
|
104
|
+
description: "ISO timestamp indicating when the signed URL will expire.",
|
|
105
|
+
example: "2024-01-01T12:00:00.000Z"
|
|
106
|
+
}),
|
|
107
|
+
contentType: z.string().openapi({
|
|
108
|
+
description: "MIME type that should be used when uploading the file.",
|
|
109
|
+
example: "image/png"
|
|
110
|
+
}),
|
|
111
|
+
publicUrl: z.string().url().openapi({
|
|
112
|
+
description: "Publicly accessible URL (or CDN URL when requested) that can be used to read the uploaded file.",
|
|
113
|
+
example: "https://cdn.example.com/org-id/file.png"
|
|
114
|
+
})
|
|
115
|
+
}).openapi({ description: "Response payload containing the signed upload URL." });
|
|
116
|
+
|
|
117
|
+
//#endregion
|
|
118
|
+
export { generateUploadUrlRequestSchema, generateUploadUrlResponseSchema, uploadContactIdSchema, uploadConversationIdSchema, uploadFileExtensionSchema, uploadFileNameSchema, uploadOrganizationIdSchema, uploadPathSchema, uploadScopeContactSchema, uploadScopeConversationSchema, uploadScopeSchema, uploadScopeUserSchema, uploadScopeVisitorSchema, uploadUserIdSchema, uploadVisitorIdSchema, uploadWebsiteIdSchema };
|
|
119
|
+
//# sourceMappingURL=upload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload.js","names":[],"sources":["../../src/api/upload.ts"],"sourcesContent":["import { z } from \"@hono/zod-openapi\";\n\nconst idSchema = z.string().min(1).max(128);\n\nexport const uploadOrganizationIdSchema = idSchema.openapi({\n\tdescription: \"Identifier of the organization that owns the uploaded file.\",\n\texample: \"org_01HZYFG9W5V6YB5R6T6V7N9M2Q\",\n});\n\nexport const uploadWebsiteIdSchema = idSchema.openapi({\n\tdescription: \"Identifier of the website associated with the uploaded file.\",\n\texample: \"site_01HZYFH3KJ3MYHJJ3JJ6Y2RNAV\",\n});\n\nexport const uploadConversationIdSchema = idSchema.openapi({\n\tdescription: \"Conversation identifier that will scope the uploaded asset.\",\n\texample: \"conv_01HZYFJ5P7DQ0VE8F68G5VYBAQ\",\n});\n\nexport const uploadUserIdSchema = idSchema.openapi({\n\tdescription: \"User identifier that will scope the uploaded asset.\",\n\texample: \"user_01HZYFKJS3K0M9W6PQZ0J6G1WR\",\n});\n\nexport const uploadContactIdSchema = idSchema.openapi({\n\tdescription: \"Contact identifier that will scope the uploaded asset.\",\n\texample: \"contact_01HZYFMN7J2J4F2SW3Q2N1H0D9\",\n});\n\nexport const uploadVisitorIdSchema = idSchema.openapi({\n\tdescription: \"Visitor identifier that will scope the uploaded asset.\",\n\texample: \"visitor_01HZYFPQ8R2FK1D9V7ZQ6CG6TN\",\n});\n\nexport const uploadPathSchema = z.string().max(512).openapi({\n\tdescription:\n\t\t\"Optional relative path used to group uploads inside the bucket. Nested paths are supported.\",\n\texample: \"assets/avatars\",\n});\n\nexport const uploadFileNameSchema = z\n\t.string()\n\t.min(1)\n\t.max(128)\n\t.regex(/^[^\\\\/]+$/)\n\t.openapi({\n\t\tdescription:\n\t\t\t\"Optional file name to use for the object. Invalid characters will be sanitized on the server side.\",\n\t\texample: \"profile-picture.png\",\n\t});\n\nexport const uploadFileExtensionSchema = z\n\t.string()\n\t.min(1)\n\t.max(16)\n\t.regex(/^[a-zA-Z0-9]+$/)\n\t.openapi({\n\t\tdescription:\n\t\t\t\"Optional file extension without the leading dot. Use this when providing a custom file name without an extension.\",\n\t\texample: \"png\",\n\t});\n\nconst baseScope = {\n\torganizationId: uploadOrganizationIdSchema,\n\twebsiteId: uploadWebsiteIdSchema,\n};\n\nexport const uploadScopeConversationSchema = z\n\t.object({\n\t\t...baseScope,\n\t\ttype: z.literal(\"conversation\"),\n\t\tconversationId: uploadConversationIdSchema,\n\t})\n\t.openapi({\n\t\tdescription:\n\t\t\t\"Scope uploads to a specific conversation. Files will be placed under /{organizationId}/{websiteId}/{conversationId}.\",\n\t});\n\nexport const uploadScopeUserSchema = z\n\t.object({\n\t\t...baseScope,\n\t\ttype: z.literal(\"user\"),\n\t\tuserId: uploadUserIdSchema,\n\t})\n\t.openapi({\n\t\tdescription:\n\t\t\t\"Scope uploads to a specific user. Files will be placed under /{organizationId}/{websiteId}/{userId}.\",\n\t});\n\nexport const uploadScopeContactSchema = z\n\t.object({\n\t\t...baseScope,\n\t\ttype: z.literal(\"contact\"),\n\t\tcontactId: uploadContactIdSchema,\n\t})\n\t.openapi({\n\t\tdescription:\n\t\t\t\"Scope uploads to a specific contact. Files will be placed under /{organizationId}/{websiteId}/{contactId}.\",\n\t});\n\nexport const uploadScopeVisitorSchema = z\n\t.object({\n\t\t...baseScope,\n\t\ttype: z.literal(\"visitor\"),\n\t\tvisitorId: uploadVisitorIdSchema,\n\t})\n\t.openapi({\n\t\tdescription:\n\t\t\t\"Scope uploads to a specific visitor. Files will be placed under /{organizationId}/{websiteId}/{visitorId}.\",\n\t});\n\nexport const uploadScopeSchema = z\n\t.discriminatedUnion(\"type\", [\n\t\tuploadScopeConversationSchema,\n\t\tuploadScopeUserSchema,\n\t\tuploadScopeContactSchema,\n\t\tuploadScopeVisitorSchema,\n\t])\n\t.openapi({\n\t\tdescription:\n\t\t\t\"Defines how uploaded files should be grouped inside the S3 bucket.\",\n\t});\n\nexport const generateUploadUrlRequestSchema = z\n\t.object({\n\t\tcontentType: z.string().min(1).max(256).openapi({\n\t\t\tdescription: \"MIME type of the file to upload.\",\n\t\t\texample: \"image/png\",\n\t\t}),\n\t\twebsiteId: z.string(),\n\t\tscope: uploadScopeSchema,\n\t\tpath: uploadPathSchema.optional(),\n\t\tfileName: uploadFileNameSchema.optional(),\n\t\tfileExtension: uploadFileExtensionSchema.optional(),\n\t\tuseCdn: z.boolean().optional().openapi({\n\t\t\tdescription:\n\t\t\t\t\"Set to true to place the file under the /cdn prefix so it is cached by the CDN.\",\n\t\t\texample: true,\n\t\t}),\n\t\texpiresInSeconds: z\n\t\t\t.number()\n\t\t\t.int()\n\t\t\t.min(60)\n\t\t\t.max(3600)\n\t\t\t.openapi({\n\t\t\t\tdescription:\n\t\t\t\t\t\"Number of seconds before the signed URL expires. Defaults to 900 seconds (15 minutes).\",\n\t\t\t\texample: 900,\n\t\t\t})\n\t\t\t.optional(),\n\t})\n\t.openapi({\n\t\tdescription: \"Request payload to create a signed S3 upload URL.\",\n\t});\n\nexport type GenerateUploadUrlRequest = z.infer<\n\ttypeof generateUploadUrlRequestSchema\n>;\n\nexport const generateUploadUrlResponseSchema = z\n\t.object({\n\t\tuploadUrl: z.string().url().openapi({\n\t\t\tdescription:\n\t\t\t\t\"Pre-signed URL that accepts a PUT request to upload the file to S3.\",\n\t\t\texample:\n\t\t\t\t\"https://example-bucket.s3.amazonaws.com/org-id/file.png?X-Amz-Signature=...\",\n\t\t}),\n\t\tkey: z.string().openapi({\n\t\t\tdescription:\n\t\t\t\t\"Resolved object key that can be used to reference the uploaded asset.\",\n\t\t\texample: \"01JG000000000000000000000/assets/file.png\",\n\t\t}),\n\t\tbucket: z.string().openapi({\n\t\t\tdescription: \"Name of the S3 bucket that will receive the upload.\",\n\t\t\texample: \"cossistant-uploads\",\n\t\t}),\n\t\texpiresAt: z.string().openapi({\n\t\t\tdescription: \"ISO timestamp indicating when the signed URL will expire.\",\n\t\t\texample: \"2024-01-01T12:00:00.000Z\",\n\t\t}),\n\t\tcontentType: z.string().openapi({\n\t\t\tdescription: \"MIME type that should be used when uploading the file.\",\n\t\t\texample: \"image/png\",\n\t\t}),\n\t\tpublicUrl: z.string().url().openapi({\n\t\t\tdescription:\n\t\t\t\t\"Publicly accessible URL (or CDN URL when requested) that can be used to read the uploaded file.\",\n\t\t\texample: \"https://cdn.example.com/org-id/file.png\",\n\t\t}),\n\t})\n\t.openapi({\n\t\tdescription: \"Response payload containing the signed upload URL.\",\n\t});\n\nexport type GenerateUploadUrlResponse = z.infer<\n\ttypeof generateUploadUrlResponseSchema\n>;\n"],"mappings":";;;AAEA,MAAM,WAAW,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,IAAI;AAE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Q,EACR,aAAa,sDACb,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { z } from "@hono/zod-openapi";
|
|
2
|
+
|
|
3
|
+
//#region src/api/user.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Visitor data update request schema
|
|
7
|
+
*/
|
|
8
|
+
declare const userResponseSchema: z.ZodObject<{
|
|
9
|
+
id: z.ZodULID;
|
|
10
|
+
name: z.ZodOptional<z.ZodString>;
|
|
11
|
+
email: z.ZodEmail;
|
|
12
|
+
role: z.ZodNullable<z.ZodString>;
|
|
13
|
+
image: z.ZodNullable<z.ZodURL>;
|
|
14
|
+
createdAt: z.ZodString;
|
|
15
|
+
updatedAt: z.ZodString;
|
|
16
|
+
lastSeenAt: z.ZodNullable<z.ZodString>;
|
|
17
|
+
}, z.core.$strip>;
|
|
18
|
+
declare const updateUserProfileRequestSchema: z.ZodObject<{
|
|
19
|
+
userId: z.ZodULID;
|
|
20
|
+
name: z.ZodString;
|
|
21
|
+
image: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
type UserResponse = z.infer<typeof userResponseSchema>;
|
|
24
|
+
type UpdateUserProfileRequest = z.infer<typeof updateUserProfileRequestSchema>;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { UpdateUserProfileRequest, UserResponse, updateUserProfileRequestSchema, userResponseSchema };
|
|
27
|
+
//# sourceMappingURL=user.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user.d.ts","names":[],"sources":["../../src/api/user.ts"],"sourcesContent":[],"mappings":";;;;;;AAKA;cAAa,oBAAkB,CAAA,CAAA;;;;;;;;;;cAsClB,gCAA8B,CAAA,CAAA;;;EAtCZ,KAAA,eAAA,cAAA,YAAA,CAAA,CAAA;CAAA,eAAA,CAAA;AAsClB,KAuBD,YAAA,GAAe,CAAA,CAAE,KAvBhB,CAAA,OAuB6B,kBAFvC,CAAA;KAGS,wBAAA,GAA2B,CAAA,CAAE,aACjC"}
|
package/dist/api/user.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { z } from "@hono/zod-openapi";
|
|
2
|
+
|
|
3
|
+
//#region src/api/user.ts
|
|
4
|
+
/**
|
|
5
|
+
* Visitor data update request schema
|
|
6
|
+
*/
|
|
7
|
+
const userResponseSchema = z.object({
|
|
8
|
+
id: z.ulid().openapi({
|
|
9
|
+
description: "The user's unique identifier.",
|
|
10
|
+
example: "01JG000000000000000000000"
|
|
11
|
+
}),
|
|
12
|
+
name: z.string().openapi({
|
|
13
|
+
description: "The user's name.",
|
|
14
|
+
example: "John Doe"
|
|
15
|
+
}).optional(),
|
|
16
|
+
email: z.email().openapi({
|
|
17
|
+
description: "The user's email address.",
|
|
18
|
+
example: "john.doe@example.com"
|
|
19
|
+
}),
|
|
20
|
+
role: z.string().nullable().openapi({
|
|
21
|
+
description: "The user's role.",
|
|
22
|
+
example: "admin"
|
|
23
|
+
}),
|
|
24
|
+
image: z.url().nullable().openapi({
|
|
25
|
+
description: "The user's image URL.",
|
|
26
|
+
example: "https://example.com/image.png"
|
|
27
|
+
}),
|
|
28
|
+
createdAt: z.string().openapi({
|
|
29
|
+
description: "The user's creation date.",
|
|
30
|
+
example: "2021-01-01T00:00:00.000Z"
|
|
31
|
+
}),
|
|
32
|
+
updatedAt: z.string().openapi({
|
|
33
|
+
description: "The user's last update date.",
|
|
34
|
+
example: "2021-01-01T00:00:00.000Z"
|
|
35
|
+
}),
|
|
36
|
+
lastSeenAt: z.string().nullable().openapi({
|
|
37
|
+
description: "The user's last seen date.",
|
|
38
|
+
example: "2021-01-01T00:00:00.000Z"
|
|
39
|
+
})
|
|
40
|
+
});
|
|
41
|
+
const updateUserProfileRequestSchema = z.object({
|
|
42
|
+
userId: z.ulid({ message: "Missing user identifier." }).openapi({
|
|
43
|
+
description: "The identifier of the user that should be updated.",
|
|
44
|
+
example: "01JG000000000000000000000"
|
|
45
|
+
}),
|
|
46
|
+
name: z.string({ message: "Enter your name." }).trim().min(1, { message: "Enter your name." }).max(120, { message: "Name must be 120 characters or fewer." }),
|
|
47
|
+
image: z.string().url({ message: "Provide a valid image URL." }).nullable().optional()
|
|
48
|
+
}).openapi({ description: "Payload used to update the current user's profile details." });
|
|
49
|
+
|
|
50
|
+
//#endregion
|
|
51
|
+
export { updateUserProfileRequestSchema, userResponseSchema };
|
|
52
|
+
//# sourceMappingURL=user.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user.js","names":[],"sources":["../../src/api/user.ts"],"sourcesContent":["import { z } from \"@hono/zod-openapi\";\n\n/**\n * Visitor data update request schema\n */\nexport const userResponseSchema = z.object({\n\tid: z.ulid().openapi({\n\t\tdescription: \"The user's unique identifier.\",\n\t\texample: \"01JG000000000000000000000\",\n\t}),\n\tname: z\n\t\t.string()\n\t\t.openapi({\n\t\t\tdescription: \"The user's name.\",\n\t\t\texample: \"John Doe\",\n\t\t})\n\t\t.optional(),\n\temail: z.email().openapi({\n\t\tdescription: \"The user's email address.\",\n\t\texample: \"john.doe@example.com\",\n\t}),\n\trole: z.string().nullable().openapi({\n\t\tdescription: \"The user's role.\",\n\t\texample: \"admin\",\n\t}),\n\timage: z.url().nullable().openapi({\n\t\tdescription: \"The user's image URL.\",\n\t\texample: \"https://example.com/image.png\",\n\t}),\n\tcreatedAt: z.string().openapi({\n\t\tdescription: \"The user's creation date.\",\n\t\texample: \"2021-01-01T00:00:00.000Z\",\n\t}),\n\tupdatedAt: z.string().openapi({\n\t\tdescription: \"The user's last update date.\",\n\t\texample: \"2021-01-01T00:00:00.000Z\",\n\t}),\n\tlastSeenAt: z.string().nullable().openapi({\n\t\tdescription: \"The user's last seen date.\",\n\t\texample: \"2021-01-01T00:00:00.000Z\",\n\t}),\n});\n\nexport const updateUserProfileRequestSchema = z\n\t.object({\n\t\tuserId: z.ulid({ message: \"Missing user identifier.\" }).openapi({\n\t\t\tdescription: \"The identifier of the user that should be updated.\",\n\t\t\texample: \"01JG000000000000000000000\",\n\t\t}),\n\t\tname: z\n\t\t\t.string({ message: \"Enter your name.\" })\n\t\t\t.trim()\n\t\t\t.min(1, { message: \"Enter your name.\" })\n\t\t\t.max(120, {\n\t\t\t\tmessage: \"Name must be 120 characters or fewer.\",\n\t\t\t}),\n\t\timage: z\n\t\t\t.string()\n\t\t\t.url({ message: \"Provide a valid image URL.\" })\n\t\t\t.nullable()\n\t\t\t.optional(),\n\t})\n\t.openapi({\n\t\tdescription: \"Payload used to update the current user's profile details.\",\n\t});\n\nexport type UserResponse = z.infer<typeof userResponseSchema>;\nexport type UpdateUserProfileRequest = z.infer<\n\ttypeof updateUserProfileRequestSchema\n>;\n"],"mappings":";;;;;;AAKA,MAAa,qBAAqB,EAAE,OAAO;CAC1C,IAAI,EAAE,MAAM,CAAC,QAAQ;EACpB,aAAa;EACb,SAAS;EACT,CAAC;CACF,MAAM,EACJ,QAAQ,CACR,QAAQ;EACR,aAAa;EACb,SAAS;EACT,CAAC,CACD,UAAU;CACZ,OAAO,EAAE,OAAO,CAAC,QAAQ;EACxB,aAAa;EACb,SAAS;EACT,CAAC;CACF,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC,QAAQ;EACnC,aAAa;EACb,SAAS;EACT,CAAC;CACF,OAAO,EAAE,KAAK,CAAC,UAAU,CAAC,QAAQ;EACjC,aAAa;EACb,SAAS;EACT,CAAC;CACF,WAAW,EAAE,QAAQ,CAAC,QAAQ;EAC7B,aAAa;EACb,SAAS;EACT,CAAC;CACF,WAAW,EAAE,QAAQ,CAAC,QAAQ;EAC7B,aAAa;EACb,SAAS;EACT,CAAC;CACF,YAAY,EAAE,QAAQ,CAAC,UAAU,CAAC,QAAQ;EACzC,aAAa;EACb,SAAS;EACT,CAAC;CACF,CAAC;AAEF,MAAa,iCAAiC,EAC5C,OAAO;CACP,QAAQ,EAAE,KAAK,EAAE,SAAS,4BAA4B,CAAC,CAAC,QAAQ;EAC/D,aAAa;EACb,SAAS;EACT,CAAC;CACF,MAAM,EACJ,OAAO,EAAE,SAAS,oBAAoB,CAAC,CACvC,MAAM,CACN,IAAI,GAAG,EAAE,SAAS,oBAAoB,CAAC,CACvC,IAAI,KAAK,EACT,SAAS,yCACT,CAAC;CACH,OAAO,EACL,QAAQ,CACR,IAAI,EAAE,SAAS,8BAA8B,CAAC,CAC9C,UAAU,CACV,UAAU;CACZ,CAAC,CACD,QAAQ,EACR,aAAa,8DACb,CAAC"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { z } from "@hono/zod-openapi";
|
|
2
|
+
|
|
3
|
+
//#region src/api/visitor.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Visitor metadata are stored as key value pairs
|
|
7
|
+
* Values can be strings, numbers, booleans, or null
|
|
8
|
+
*/
|
|
9
|
+
declare const visitorMetadataSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodNumber]>, z.ZodBoolean]>, z.ZodNull]>>;
|
|
10
|
+
/**
|
|
11
|
+
* Contact information for identified visitors
|
|
12
|
+
*/
|
|
13
|
+
declare const publicContactResponseSchema: z.ZodObject<{
|
|
14
|
+
id: z.ZodULID;
|
|
15
|
+
name: z.ZodNullable<z.ZodString>;
|
|
16
|
+
email: z.ZodNullable<z.ZodString>;
|
|
17
|
+
image: z.ZodNullable<z.ZodString>;
|
|
18
|
+
metadataHash: z.ZodOptional<z.ZodString>;
|
|
19
|
+
}, z.core.$strip>;
|
|
20
|
+
type PublicContact = z.infer<typeof publicContactResponseSchema>;
|
|
21
|
+
type VisitorMetadata = z.infer<typeof visitorMetadataSchema>;
|
|
22
|
+
/**
|
|
23
|
+
* Visitor data update request schema
|
|
24
|
+
*/
|
|
25
|
+
declare const updateVisitorRequestSchema: z.ZodObject<{
|
|
26
|
+
externalId: z.ZodOptional<z.ZodString>;
|
|
27
|
+
name: z.ZodOptional<z.ZodString>;
|
|
28
|
+
email: z.ZodOptional<z.ZodString>;
|
|
29
|
+
browser: z.ZodOptional<z.ZodString>;
|
|
30
|
+
browserVersion: z.ZodOptional<z.ZodString>;
|
|
31
|
+
os: z.ZodOptional<z.ZodString>;
|
|
32
|
+
osVersion: z.ZodOptional<z.ZodString>;
|
|
33
|
+
device: z.ZodOptional<z.ZodString>;
|
|
34
|
+
deviceType: z.ZodOptional<z.ZodEnum<{
|
|
35
|
+
unknown: "unknown";
|
|
36
|
+
desktop: "desktop";
|
|
37
|
+
mobile: "mobile";
|
|
38
|
+
tablet: "tablet";
|
|
39
|
+
}>>;
|
|
40
|
+
ip: z.ZodOptional<z.ZodString>;
|
|
41
|
+
city: z.ZodOptional<z.ZodString>;
|
|
42
|
+
region: z.ZodOptional<z.ZodString>;
|
|
43
|
+
country: z.ZodOptional<z.ZodString>;
|
|
44
|
+
countryCode: z.ZodOptional<z.ZodString>;
|
|
45
|
+
latitude: z.ZodOptional<z.ZodNumber>;
|
|
46
|
+
longitude: z.ZodOptional<z.ZodNumber>;
|
|
47
|
+
language: z.ZodOptional<z.ZodString>;
|
|
48
|
+
timezone: z.ZodOptional<z.ZodString>;
|
|
49
|
+
screenResolution: z.ZodOptional<z.ZodString>;
|
|
50
|
+
viewport: z.ZodOptional<z.ZodString>;
|
|
51
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodNumber]>, z.ZodBoolean]>, z.ZodNull]>>>;
|
|
52
|
+
}, z.core.$strip>;
|
|
53
|
+
type UpdateVisitorRequest = z.infer<typeof updateVisitorRequestSchema>;
|
|
54
|
+
declare const updateVisitorMetadataRequestSchema: z.ZodObject<{
|
|
55
|
+
metadata: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodNumber]>, z.ZodBoolean]>, z.ZodNull]>>;
|
|
56
|
+
}, z.core.$strip>;
|
|
57
|
+
type UpdateVisitorMetadataRequest = z.infer<typeof updateVisitorMetadataRequestSchema>;
|
|
58
|
+
declare const visitorProfileSchema: z.ZodObject<{
|
|
59
|
+
id: z.ZodULID;
|
|
60
|
+
lastSeenAt: z.ZodNullable<z.ZodString>;
|
|
61
|
+
blockedAt: z.ZodNullable<z.ZodString>;
|
|
62
|
+
blockedByUserId: z.ZodNullable<z.ZodString>;
|
|
63
|
+
isBlocked: z.ZodBoolean;
|
|
64
|
+
contact: z.ZodNullable<z.ZodObject<{
|
|
65
|
+
id: z.ZodULID;
|
|
66
|
+
name: z.ZodNullable<z.ZodString>;
|
|
67
|
+
email: z.ZodNullable<z.ZodString>;
|
|
68
|
+
image: z.ZodNullable<z.ZodString>;
|
|
69
|
+
metadataHash: z.ZodOptional<z.ZodString>;
|
|
70
|
+
}, z.core.$strip>>;
|
|
71
|
+
}, z.core.$strip>;
|
|
72
|
+
/**
|
|
73
|
+
* Visitor response schema
|
|
74
|
+
*/
|
|
75
|
+
declare const visitorResponseSchema: z.ZodObject<{
|
|
76
|
+
id: z.ZodULID;
|
|
77
|
+
browser: z.ZodNullable<z.ZodString>;
|
|
78
|
+
browserVersion: z.ZodNullable<z.ZodString>;
|
|
79
|
+
os: z.ZodNullable<z.ZodString>;
|
|
80
|
+
osVersion: z.ZodNullable<z.ZodString>;
|
|
81
|
+
device: z.ZodNullable<z.ZodString>;
|
|
82
|
+
deviceType: z.ZodNullable<z.ZodString>;
|
|
83
|
+
ip: z.ZodNullable<z.ZodString>;
|
|
84
|
+
city: z.ZodNullable<z.ZodString>;
|
|
85
|
+
region: z.ZodNullable<z.ZodString>;
|
|
86
|
+
country: z.ZodNullable<z.ZodString>;
|
|
87
|
+
countryCode: z.ZodNullable<z.ZodString>;
|
|
88
|
+
latitude: z.ZodNullable<z.ZodNumber>;
|
|
89
|
+
longitude: z.ZodNullable<z.ZodNumber>;
|
|
90
|
+
language: z.ZodNullable<z.ZodString>;
|
|
91
|
+
timezone: z.ZodNullable<z.ZodString>;
|
|
92
|
+
screenResolution: z.ZodNullable<z.ZodString>;
|
|
93
|
+
viewport: z.ZodNullable<z.ZodString>;
|
|
94
|
+
createdAt: z.ZodString;
|
|
95
|
+
updatedAt: z.ZodString;
|
|
96
|
+
lastSeenAt: z.ZodNullable<z.ZodString>;
|
|
97
|
+
websiteId: z.ZodULID;
|
|
98
|
+
organizationId: z.ZodULID;
|
|
99
|
+
blockedAt: z.ZodNullable<z.ZodString>;
|
|
100
|
+
blockedByUserId: z.ZodNullable<z.ZodString>;
|
|
101
|
+
isBlocked: z.ZodBoolean;
|
|
102
|
+
contact: any;
|
|
103
|
+
}, z.core.$strip>;
|
|
104
|
+
type Visitor = z.infer<typeof visitorResponseSchema>;
|
|
105
|
+
type VisitorResponse = Visitor;
|
|
106
|
+
/**
|
|
107
|
+
* Visitor response schema
|
|
108
|
+
*/
|
|
109
|
+
declare const publicVisitorResponseSchema: z.ZodObject<{
|
|
110
|
+
id: z.ZodULID;
|
|
111
|
+
isBlocked: z.ZodBoolean;
|
|
112
|
+
language: z.ZodNullable<z.ZodString>;
|
|
113
|
+
contact: z.ZodNullable<z.ZodObject<{
|
|
114
|
+
id: z.ZodULID;
|
|
115
|
+
name: z.ZodNullable<z.ZodString>;
|
|
116
|
+
email: z.ZodNullable<z.ZodString>;
|
|
117
|
+
image: z.ZodNullable<z.ZodString>;
|
|
118
|
+
metadataHash: z.ZodOptional<z.ZodString>;
|
|
119
|
+
}, z.core.$strip>>;
|
|
120
|
+
}, z.core.$strip>;
|
|
121
|
+
type PublicVisitor = z.infer<typeof publicVisitorResponseSchema>;
|
|
122
|
+
type PublicVisitorResponse = PublicVisitor;
|
|
123
|
+
//#endregion
|
|
124
|
+
export { PublicContact, PublicVisitor, PublicVisitorResponse, UpdateVisitorMetadataRequest, UpdateVisitorRequest, Visitor, VisitorMetadata, VisitorResponse, publicContactResponseSchema, publicVisitorResponseSchema, updateVisitorMetadataRequestSchema, updateVisitorRequestSchema, visitorMetadataSchema, visitorProfileSchema, visitorResponseSchema };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