The Coline App SDK: apps, tools, file types and surfaces that run inside Coline workspaces, and public websites with Coline Sites. TypeScript, with an in-memory test workspace. MIT.
| * Defined independently of the legacy module so v2 has no legacy imports. |
| 6 | */ |
| 7 |
| 8 | export const NOTIFICATION_DELIVERY_CHANNELS = [ |
| 9 | "in_app", |
| 10 | "desktop", |
| 11 | "mobile_push", |
| 12 | ] as const; |
| 13 | export const notificationDeliveryChannelV2Schema = z.enum( |
| 14 | NOTIFICATION_DELIVERY_CHANNELS, |
| 15 | ); |
| 16 | export type NotificationDeliveryChannelV2 = z.infer< |
| 17 | typeof notificationDeliveryChannelV2Schema |
| 18 | >; |
| 19 |
| 20 | export const NOTIFICATION_PRIORITIES = ["low", "default", "high"] as const; |
| 21 | export const notificationPriorityV2Schema = z.enum(NOTIFICATION_PRIORITIES); |
| 22 | export type NotificationPriorityV2 = z.infer<typeof notificationPriorityV2Schema>; |
| 23 |
| 24 | export const notificationChannelV2Schema = z.strictObject({ |
| 25 | key: z |
| 26 | .string() |
| 27 | .trim() |
| 28 | .regex(/^[a-z][a-z0-9-]*$/, "Channel keys are lowercase kebab-case.") |
| 29 | .max(160), |
| 30 | name: z.string().trim().min(1).max(120), |
| 31 | description: z.string().trim().max(500).optional(), |
| 32 | defaultDeliveries: z |
| 33 | .array(notificationDeliveryChannelV2Schema) |
| 34 | .min(1) |
| 35 | .max(NOTIFICATION_DELIVERY_CHANNELS.length) |
| 36 | .default(["in_app"]) |
| 37 | .refine( |
| 38 | (values) => new Set(values).size === values.length, |
| 39 | "Deliveries must be unique.", |
| 40 | ), |
| 41 | defaultPriority: notificationPriorityV2Schema.default("default"), |
| 42 | }); |
| 43 | export type NotificationChannelV2 = z.infer<typeof notificationChannelV2Schema>; |
| 44 |
| 45 | export const appNotificationsV2Schema = z |
| 46 | .strictObject({ |
| 47 | channels: z |
| 48 | .array(notificationChannelV2Schema) |
| 49 | .max(20) |
| 50 | .default([]) |
| 51 | .refine( |
| 52 | (channels) => new Set(channels.map((channel) => channel.key)).size === channels.length, |
| 53 | "Channel keys must be unique.", |
| 54 | ), |
| 55 | }) |
| 56 | .default({ channels: [] }); |
| 57 | export type AppNotificationsV2 = z.infer<typeof appNotificationsV2Schema>; |
| 58 |