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.
| "app.home.read", |
| 5 | "files.read", |
| 6 | "files.write", |
| 7 | "index.write", |
| 8 | "notifications.read_own", |
| 9 | "notifications.write", |
| 10 | "profile.read", |
| 11 | "tasks.read", |
| 12 | "tasks.write", |
| 13 | ] as const; |
| 14 |
| 15 | export const appPermissionSchema = z.enum(appPermissionValues); |
| 16 | export type AppPermission = z.infer<typeof appPermissionSchema>; |
| 17 |
| 18 | export const appHomeRenderModeValues = ["cached", "live", "hybrid"] as const; |
| 19 | export const appHomeRenderModeSchema = z.enum(appHomeRenderModeValues); |
| 20 | export type AppHomeRenderMode = z.infer<typeof appHomeRenderModeSchema>; |
| 21 |
| 22 | export const appHostingSchema = z.object({ |
| 23 | mode: z.literal("external"), |
| 24 | baseUrl: z.url(), |
| 25 | }); |
| 26 | export type AppHostingConfig = z.infer<typeof appHostingSchema>; |
| 27 |
| 28 | export const notificationDeliveryChannelValues = [ |
| 29 | "in_app", |
| 30 | "desktop", |
| 31 | ] as const; |
| 32 | export const notificationDeliveryChannelSchema = z.enum( |
| 33 | notificationDeliveryChannelValues, |
| 34 | ); |
| 35 | export type NotificationDeliveryChannel = z.infer< |
| 36 | typeof notificationDeliveryChannelSchema |
| 37 | >; |
| 38 |
| 39 | export const notificationPriorityValues = ["low", "default", "high"] as const; |
| 40 | export const notificationPrioritySchema = z.enum(notificationPriorityValues); |
| 41 | export type NotificationPriority = z.infer<typeof notificationPrioritySchema>; |
| 42 |
| 43 | export const notificationChannelDefinitionSchema = z.object({ |
| 44 | key: z.string().trim().min(1).max(160), |
| 45 | name: z.string().trim().min(1).max(120), |
| 46 | description: z.string().trim().min(1).max(500).optional(), |
| 47 | defaultDeliveries: z |
| 48 | .array(notificationDeliveryChannelSchema) |
| 49 | .min(1) |
| 50 | .max(notificationDeliveryChannelValues.length) |
| 51 | .refine( |
| 52 | (values) => new Set(values).size === values.length, |
| 53 | "Notification channel deliveries must be unique.", |
| 54 | ), |
| 55 | defaultPriority: notificationPrioritySchema.default("default"), |
| 56 | }); |
| 57 | export type NotificationChannelDefinitionInput = z.input< |
| 58 | typeof notificationChannelDefinitionSchema |
| 59 | >; |
| 60 | export type NotificationChannelDefinition = z.infer< |
| 61 | typeof notificationChannelDefinitionSchema |
| 62 | >; |
| 63 |
| 64 | export const notificationRecipientInputSchema = z.object({ |
| 65 | userId: z.string().trim().min(1).max(200), |
| 66 | }); |
| 67 | export type NotificationRecipientInput = z.infer< |
| 68 | typeof notificationRecipientInputSchema |
| 69 | >; |
| 70 |
| 71 | export const createNotificationInputSchema = z.object({ |
| 72 | channelKey: z.string().trim().min(1).max(160), |
| 73 | typeKey: z.string().trim().min(1).max(160), |
| 74 | recipients: z.array(notificationRecipientInputSchema).min(1).max(100), |
| 75 | title: z.string().trim().min(1).max(200), |
| 76 | body: z.string().trim().min(1).max(4000).optional(), |
| 77 | targetUrl: z.string().trim().min(1).max(2000).optional(), |
| 78 | icon: z.string().trim().min(1).max(200).optional(), |
| 79 | priority: notificationPrioritySchema.default("default"), |
| 80 | dedupeKey: z.string().trim().min(1).max(200).optional(), |
| 81 | metadata: z.record(z.string(), z.unknown()).default({}), |
| 82 | }); |
| 83 | export type CreateNotificationInputInput = z.input<typeof createNotificationInputSchema>; |
| 84 | export type CreateNotificationInput = z.infer<typeof createNotificationInputSchema>; |
| 85 |
| 86 | export const colineAppManifestSchema = z.object({ |
| 87 | key: z.string().trim().min(3).max(120), |
| 88 | name: z.string().trim().min(1).max(120), |
| 89 | description: z.string().trim().min(1).max(500).optional(), |
| 90 | iconUrl: z.url().optional(), |
| 91 | permissions: z.array(appPermissionSchema).default([]), |
| 92 | notificationChannels: z.array(notificationChannelDefinitionSchema).default([]), |
| 93 | hosting: appHostingSchema, |
| 94 | }); |
| 95 | export type ColineAppManifestInput = z.input<typeof colineAppManifestSchema>; |
| 96 | export type ColineAppManifest = z.infer<typeof colineAppManifestSchema>; |
| 97 |
| 98 | export const colineFileTypeSchema = z.object({ |
| 99 | typeKey: z.string().trim().min(3).max(160), |
| 100 | name: z.string().trim().min(1).max(120), |
| 101 | description: z.string().trim().min(1).max(500).optional(), |
| 102 | storage: z.enum(["coline_document"]), |
| 103 | indexable: z.boolean().default(true), |
| 104 | homeRenderMode: appHomeRenderModeSchema.default("cached"), |
| 105 | }); |
| 106 | export type ColineFileTypeDefinitionInput = z.input<typeof colineFileTypeSchema>; |
| 107 | export type ColineFileTypeDefinition = z.infer<typeof colineFileTypeSchema>; |
| 108 |
| 109 | export const colineAppRegistrationPayloadSchema = z.object({ |
| 110 | version: z.string().trim().min(1).max(64), |
| 111 | manifest: colineAppManifestSchema, |
| 112 | fileTypes: z.array(colineFileTypeSchema).default([]), |
| 113 | }); |
| 114 | export type ColineAppRegistrationPayload = z.infer< |
| 115 | typeof colineAppRegistrationPayloadSchema |
| 116 | >; |
| 117 |