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 appIndexVisibilityModeValues = ["workspace", "scoped"] as const; |
| 23 | export const appIndexVisibilityModeSchema = z.enum(appIndexVisibilityModeValues); |
| 24 | export type AppIndexVisibilityMode = z.infer<typeof appIndexVisibilityModeSchema>; |
| 25 |
| 26 | export const appIndexSubjectTypeValues = ["user", "role", "workspace"] as const; |
| 27 | export const appIndexSubjectTypeSchema = z.enum(appIndexSubjectTypeValues); |
| 28 | export type AppIndexSubjectType = z.infer<typeof appIndexSubjectTypeSchema>; |
| 29 |
| 30 | export const appHostingSchema = z.object({ |
| 31 | mode: z.literal("external"), |
| 32 | baseUrl: z.url(), |
| 33 | }); |
| 34 | export type AppHostingConfig = z.infer<typeof appHostingSchema>; |
| 35 |
| 36 | export const notificationDeliveryChannelValues = [ |
| 37 | "in_app", |
| 38 | "desktop", |
| 39 | ] as const; |
| 40 | export const notificationDeliveryChannelSchema = z.enum( |
| 41 | notificationDeliveryChannelValues, |
| 42 | ); |
| 43 | export type NotificationDeliveryChannel = z.infer< |
| 44 | typeof notificationDeliveryChannelSchema |
| 45 | >; |
| 46 |
| 47 | export const notificationPriorityValues = ["low", "default", "high"] as const; |
| 48 | export const notificationPrioritySchema = z.enum(notificationPriorityValues); |
| 49 | export type NotificationPriority = z.infer<typeof notificationPrioritySchema>; |
| 50 |
| 51 | export const notificationChannelDefinitionSchema = z.object({ |
| 52 | key: z.string().trim().min(1).max(160), |
| 53 | name: z.string().trim().min(1).max(120), |
| 54 | description: z.string().trim().min(1).max(500).optional(), |
| 55 | defaultDeliveries: z |
| 56 | .array(notificationDeliveryChannelSchema) |
| 57 | .min(1) |
| 58 | .max(notificationDeliveryChannelValues.length) |
| 59 | .refine( |
| 60 | (values) => new Set(values).size === values.length, |
| 61 | "Notification channel deliveries must be unique.", |
| 62 | ), |
| 63 | defaultPriority: notificationPrioritySchema.default("default"), |
| 64 | }); |
| 65 | export type NotificationChannelDefinitionInput = z.input< |
| 66 | typeof notificationChannelDefinitionSchema |
| 67 | >; |
| 68 | export type NotificationChannelDefinition = z.infer< |
| 69 | typeof notificationChannelDefinitionSchema |
| 70 | >; |
| 71 |
| 72 | export const notificationRecipientInputSchema = z.object({ |
| 73 | userId: z.string().trim().min(1).max(200), |
| 74 | }); |
| 75 | export type NotificationRecipientInput = z.infer< |
| 76 | typeof notificationRecipientInputSchema |
| 77 | >; |
| 78 |
| 79 | export const createNotificationInputSchema = z.object({ |
| 80 | channelKey: z.string().trim().min(1).max(160), |
| 81 | typeKey: z.string().trim().min(1).max(160), |
| 82 | recipients: z.array(notificationRecipientInputSchema).min(1).max(100), |
| 83 | title: z.string().trim().min(1).max(200), |
| 84 | body: z.string().trim().min(1).max(4000).optional(), |
| 85 | targetUrl: z.string().trim().min(1).max(2000).optional(), |
| 86 | icon: z.string().trim().min(1).max(200).optional(), |
| 87 | priority: notificationPrioritySchema.default("default"), |
| 88 | dedupeKey: z.string().trim().min(1).max(200).optional(), |
| 89 | metadata: z.record(z.string(), z.unknown()).default({}), |
| 90 | }); |
| 91 | export type CreateNotificationInputInput = z.input<typeof createNotificationInputSchema>; |
| 92 | export type CreateNotificationInput = z.infer<typeof createNotificationInputSchema>; |
| 93 |
| 94 | export const colineAppManifestSchema = z.object({ |
| 95 | key: z.string().trim().min(3).max(120), |
| 96 | name: z.string().trim().min(1).max(120), |
| 97 | description: z.string().trim().min(1).max(500).optional(), |
| 98 | iconUrl: z.url().optional(), |
| 99 | permissions: z.array(appPermissionSchema).default([]), |
| 100 | notificationChannels: z.array(notificationChannelDefinitionSchema).default([]), |
| 101 | hosting: appHostingSchema, |
| 102 | }); |
| 103 | export type ColineAppManifestInput = z.input<typeof colineAppManifestSchema>; |
| 104 | export type ColineAppManifest = z.infer<typeof colineAppManifestSchema>; |
| 105 |
| 106 | export const colineFileTypeSchema = z.object({ |
| 107 | typeKey: z.string().trim().min(3).max(160), |
| 108 | name: z.string().trim().min(1).max(120), |
| 109 | description: z.string().trim().min(1).max(500).optional(), |
| 110 | storage: z.enum(["coline_document"]), |
| 111 | indexable: z.boolean().default(true), |
| 112 | homeRenderMode: appHomeRenderModeSchema.default("cached"), |
| 113 | }); |
| 114 | export type ColineFileTypeDefinitionInput = z.input<typeof colineFileTypeSchema>; |
| 115 | export type ColineFileTypeDefinition = z.infer<typeof colineFileTypeSchema>; |
| 116 |
| 117 | export const colineAppRegistrationPayloadSchema = z.object({ |
| 118 | version: z.string().trim().min(1).max(64), |
| 119 | manifest: colineAppManifestSchema, |
| 120 | fileTypes: z.array(colineFileTypeSchema).default([]), |
| 121 | }); |
| 122 | export type ColineAppRegistrationPayload = z.infer< |
| 123 | typeof colineAppRegistrationPayloadSchema |
| 124 | >; |
| 125 |
| 126 | export const appIndexVisibilityGrantSchema = z.object({ |
| 127 | subjectType: appIndexSubjectTypeSchema, |
| 128 | subjectId: z.string().trim().min(1).max(200), |
| 129 | }); |
| 130 | export type AppIndexVisibilityGrantInput = z.input< |
| 131 | typeof appIndexVisibilityGrantSchema |
| 132 | >; |
| 133 | export type AppIndexVisibilityGrant = z.infer<typeof appIndexVisibilityGrantSchema>; |
| 134 |
| 135 | export const appIndexDocumentSchema = z.object({ |
| 136 | documentKey: z.string().trim().min(1).max(200), |
| 137 | documentType: z.string().trim().min(1).max(160), |
| 138 | fileId: z.string().trim().min(1).max(200).optional(), |
| 139 | title: z.string().trim().min(1).max(200), |
| 140 | body: z.string().trim().max(100_000).default(""), |
| 141 | url: z.string().trim().min(1).max(2_000).optional(), |
| 142 | metadata: z.record(z.string(), z.unknown()).default({}), |
| 143 | visibilityMode: appIndexVisibilityModeSchema.default("workspace"), |
| 144 | visibility: z.array(appIndexVisibilityGrantSchema).default([]), |
| 145 | }); |
| 146 | export type AppIndexDocumentInput = z.input<typeof appIndexDocumentSchema>; |
| 147 | export type AppIndexDocument = z.infer<typeof appIndexDocumentSchema>; |
| 148 |
| 149 | export const batchUpsertAppIndexDocumentsSchema = z.object({ |
| 150 | documents: z.array(appIndexDocumentSchema).min(1).max(100), |
| 151 | }); |
| 152 | export type BatchUpsertAppIndexDocumentsInput = z.input< |
| 153 | typeof batchUpsertAppIndexDocumentsSchema |
| 154 | >; |
| 155 | export type BatchUpsertAppIndexDocuments = z.infer< |
| 156 | typeof batchUpsertAppIndexDocumentsSchema |
| 157 | >; |
| 158 |
| 159 | export const batchDeleteAppIndexDocumentsSchema = z.object({ |
| 160 | documentKeys: z.array(z.string().trim().min(1).max(200)).min(1).max(100), |
| 161 | }); |
| 162 | export type BatchDeleteAppIndexDocumentsInput = z.input< |
| 163 | typeof batchDeleteAppIndexDocumentsSchema |
| 164 | >; |
| 165 | export type BatchDeleteAppIndexDocuments = z.infer< |
| 166 | typeof batchDeleteAppIndexDocumentsSchema |
| 167 | >; |
| 168 |