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 | "ambient.events.write", |
| 6 | "files.read", |
| 7 | "files.write", |
| 8 | "index.write", |
| 9 | "notifications.read_own", |
| 10 | "notifications.write", |
| 11 | "profile.read", |
| 12 | "tasks.read", |
| 13 | "tasks.write", |
| 14 | ] as const; |
| 15 |
| 16 | export const appPermissionSchema = z.enum(appPermissionValues); |
| 17 | export type AppPermission = z.infer<typeof appPermissionSchema>; |
| 18 |
| 19 | export const appHomeRenderModeValues = ["cached", "live", "hybrid"] as const; |
| 20 | export const appHomeRenderModeSchema = z.enum(appHomeRenderModeValues); |
| 21 | export type AppHomeRenderMode = z.infer<typeof appHomeRenderModeSchema>; |
| 22 |
| 23 | export const appIndexVisibilityModeValues = ["workspace", "scoped"] as const; |
| 24 | export const appIndexVisibilityModeSchema = z.enum(appIndexVisibilityModeValues); |
| 25 | export type AppIndexVisibilityMode = z.infer<typeof appIndexVisibilityModeSchema>; |
| 26 |
| 27 | export const appIndexSubjectTypeValues = ["user", "role", "workspace"] as const; |
| 28 | export const appIndexSubjectTypeSchema = z.enum(appIndexSubjectTypeValues); |
| 29 | export type AppIndexSubjectType = z.infer<typeof appIndexSubjectTypeSchema>; |
| 30 |
| 31 | export const appHostingSchema = z.object({ |
| 32 | mode: z.literal("external"), |
| 33 | baseUrl: z.url(), |
| 34 | }); |
| 35 | export type AppHostingConfig = z.infer<typeof appHostingSchema>; |
| 36 |
| 37 | export const colineKairoDocumentFieldSchema = z.object({ |
| 38 | key: z.string().trim().min(1).max(120), |
| 39 | description: z.string().trim().min(1).max(500).optional(), |
| 40 | }); |
| 41 | export type ColineKairoDocumentFieldInput = z.input< |
| 42 | typeof colineKairoDocumentFieldSchema |
| 43 | >; |
| 44 | export type ColineKairoDocumentField = z.infer<typeof colineKairoDocumentFieldSchema>; |
| 45 |
| 46 | export const colineKairoDocumentTypeSchema = z.object({ |
| 47 | documentType: z.string().trim().min(1).max(160), |
| 48 | name: z.string().trim().min(1).max(120), |
| 49 | description: z.string().trim().min(1).max(500).optional(), |
| 50 | instructions: z.string().trim().min(1).max(4000).optional(), |
| 51 | metadata: z.array(colineKairoDocumentFieldSchema).max(30).default([]), |
| 52 | }); |
| 53 | export type ColineKairoDocumentTypeInput = z.input< |
| 54 | typeof colineKairoDocumentTypeSchema |
| 55 | >; |
| 56 | export type ColineKairoDocumentType = z.infer<typeof colineKairoDocumentTypeSchema>; |
| 57 |
| 58 | export const colineKairoIntegrationSchema = z.object({ |
| 59 | enabled: z.boolean().default(true), |
| 60 | description: z.string().trim().min(1).max(500).optional(), |
| 61 | instructions: z.string().trim().min(1).max(4000).optional(), |
| 62 | documentTypes: z.array(colineKairoDocumentTypeSchema).max(50).default([]), |
| 63 | }); |
| 64 | export type ColineKairoIntegrationInput = z.input< |
| 65 | typeof colineKairoIntegrationSchema |
| 66 | >; |
| 67 | export type ColineKairoIntegration = z.infer<typeof colineKairoIntegrationSchema>; |
| 68 |
| 69 | export const notificationDeliveryChannelValues = [ |
| 70 | "in_app", |
| 71 | "desktop", |
| 72 | ] as const; |
| 73 | export const notificationDeliveryChannelSchema = z.enum( |
| 74 | notificationDeliveryChannelValues, |
| 75 | ); |
| 76 | export type NotificationDeliveryChannel = z.infer< |
| 77 | typeof notificationDeliveryChannelSchema |
| 78 | >; |
| 79 |
| 80 | export const notificationPriorityValues = ["low", "default", "high"] as const; |
| 81 | export const notificationPrioritySchema = z.enum(notificationPriorityValues); |
| 82 | export type NotificationPriority = z.infer<typeof notificationPrioritySchema>; |
| 83 |
| 84 | export const notificationChannelDefinitionSchema = z.object({ |
| 85 | key: z.string().trim().min(1).max(160), |
| 86 | name: z.string().trim().min(1).max(120), |
| 87 | description: z.string().trim().min(1).max(500).optional(), |
| 88 | defaultDeliveries: z |
| 89 | .array(notificationDeliveryChannelSchema) |
| 90 | .min(1) |
| 91 | .max(notificationDeliveryChannelValues.length) |
| 92 | .refine( |
| 93 | (values) => new Set(values).size === values.length, |
| 94 | "Notification channel deliveries must be unique.", |
| 95 | ), |
| 96 | defaultPriority: notificationPrioritySchema.default("default"), |
| 97 | }); |
| 98 | export type NotificationChannelDefinitionInput = z.input< |
| 99 | typeof notificationChannelDefinitionSchema |
| 100 | >; |
| 101 | export type NotificationChannelDefinition = z.infer< |
| 102 | typeof notificationChannelDefinitionSchema |
| 103 | >; |
| 104 |
| 105 | export const notificationRecipientInputSchema = z.object({ |
| 106 | userId: z.string().trim().min(1).max(200), |
| 107 | }); |
| 108 | export type NotificationRecipientInput = z.infer< |
| 109 | typeof notificationRecipientInputSchema |
| 110 | >; |
| 111 |
| 112 | export const createNotificationInputSchema = z.object({ |
| 113 | channelKey: z.string().trim().min(1).max(160), |
| 114 | typeKey: z.string().trim().min(1).max(160), |
| 115 | recipients: z.array(notificationRecipientInputSchema).min(1).max(100), |
| 116 | title: z.string().trim().min(1).max(200), |
| 117 | body: z.string().trim().min(1).max(4000).optional(), |
| 118 | targetUrl: z.string().trim().min(1).max(2000).optional(), |
| 119 | icon: z.string().trim().min(1).max(200).optional(), |
| 120 | priority: notificationPrioritySchema.default("default"), |
| 121 | dedupeKey: z.string().trim().min(1).max(200).optional(), |
| 122 | metadata: z.record(z.string(), z.unknown()).default({}), |
| 123 | }); |
| 124 | export type CreateNotificationInputInput = z.input<typeof createNotificationInputSchema>; |
| 125 | export type CreateNotificationInput = z.infer<typeof createNotificationInputSchema>; |
| 126 |
| 127 | export const ambientEventSourceKindValues = [ |
| 128 | "message", |
| 129 | "calendar", |
| 130 | "file", |
| 131 | "app_signal", |
| 132 | "scheduled_trigger", |
| 133 | ] as const; |
| 134 | export const ambientEventSourceKindSchema = z.enum(ambientEventSourceKindValues); |
| 135 | export type AmbientEventSourceKind = z.infer<typeof ambientEventSourceKindSchema>; |
| 136 |
| 137 | export const ambientEventActionValues = [ |
| 138 | "created", |
| 139 | "updated", |
| 140 | "deleted", |
| 141 | "responded", |
| 142 | "approaching", |
| 143 | "synced", |
| 144 | ] as const; |
| 145 | export const ambientEventActionSchema = z.enum(ambientEventActionValues); |
| 146 | export type AmbientEventAction = z.infer<typeof ambientEventActionSchema>; |
| 147 |
| 148 | export const ambientEntityTypeValues = [ |
| 149 | "message", |
| 150 | "calendar_event", |
| 151 | "file", |
| 152 | "app_document", |
| 153 | "scheduled_trigger", |
| 154 | ] as const; |
| 155 | export const ambientEntityTypeSchema = z.enum(ambientEntityTypeValues); |
| 156 | export type AmbientEntityType = z.infer<typeof ambientEntityTypeSchema>; |
| 157 |
| 158 | export const ambientContainerTypeValues = ["channel", "dm", "event"] as const; |
| 159 | export const ambientContainerTypeSchema = z.enum(ambientContainerTypeValues); |
| 160 | export type AmbientContainerType = z.infer<typeof ambientContainerTypeSchema>; |
| 161 |
| 162 | export const ambientContentEventInputSchema = z.object({ |
| 163 | sourceKind: ambientEventSourceKindSchema.default("app_signal"), |
| 164 | action: ambientEventActionSchema, |
| 165 | entityType: ambientEntityTypeSchema, |
| 166 | entityId: z.string().trim().min(1).max(200), |
| 167 | actorUserId: z.string().trim().min(1).max(200).optional(), |
| 168 | containerType: ambientContainerTypeSchema.optional(), |
| 169 | containerId: z.string().trim().min(1).max(200).optional(), |
| 170 | occurredAt: z.coerce.date().optional(), |
| 171 | dedupeKey: z.string().trim().min(1).max(240), |
| 172 | payload: z.record(z.string(), z.unknown()).default({}), |
| 173 | metadata: z.record(z.string(), z.unknown()).default({}), |
| 174 | schemaVersion: z.number().int().min(1).default(1), |
| 175 | }); |
| 176 | export type AmbientContentEventInputInput = z.input< |
| 177 | typeof ambientContentEventInputSchema |
| 178 | >; |
| 179 | export type AmbientContentEventInput = z.infer<typeof ambientContentEventInputSchema>; |
| 180 |
| 181 | export const emitAmbientEventsInputSchema = z.object({ |
| 182 | events: z.array(ambientContentEventInputSchema).min(1).max(100), |
| 183 | }); |
| 184 | export type EmitAmbientEventsInputInput = z.input<typeof emitAmbientEventsInputSchema>; |
| 185 | export type EmitAmbientEventsInput = z.infer<typeof emitAmbientEventsInputSchema>; |
| 186 |
| 187 | export const colineAppManifestSchema = z.object({ |
| 188 | key: z.string().trim().min(3).max(120), |
| 189 | name: z.string().trim().min(1).max(120), |
| 190 | description: z.string().trim().min(1).max(500).optional(), |
| 191 | iconUrl: z.url().optional(), |
| 192 | permissions: z.array(appPermissionSchema).default([]), |
| 193 | notificationChannels: z.array(notificationChannelDefinitionSchema).default([]), |
| 194 | kairo: colineKairoIntegrationSchema.optional(), |
| 195 | hosting: appHostingSchema, |
| 196 | }); |
| 197 | export type ColineAppManifestInput = z.input<typeof colineAppManifestSchema>; |
| 198 | export type ColineAppManifest = z.infer<typeof colineAppManifestSchema>; |
| 199 |
| 200 | export const colineFileTypeSchema = z.object({ |
| 201 | typeKey: z.string().trim().min(3).max(160), |
| 202 | name: z.string().trim().min(1).max(120), |
| 203 | description: z.string().trim().min(1).max(500).optional(), |
| 204 | storage: z.enum(["coline_document"]), |
| 205 | indexable: z.boolean().default(true), |
| 206 | homeRenderMode: appHomeRenderModeSchema.default("cached"), |
| 207 | }); |
| 208 | export type ColineFileTypeDefinitionInput = z.input<typeof colineFileTypeSchema>; |
| 209 | export type ColineFileTypeDefinition = z.infer<typeof colineFileTypeSchema>; |
| 210 |
| 211 | export const colineAppRegistrationPayloadSchema = z.object({ |
| 212 | version: z.string().trim().min(1).max(64), |
| 213 | manifest: colineAppManifestSchema, |
| 214 | fileTypes: z.array(colineFileTypeSchema).default([]), |
| 215 | }); |
| 216 | export type ColineAppRegistrationPayload = z.infer< |
| 217 | typeof colineAppRegistrationPayloadSchema |
| 218 | >; |
| 219 |
| 220 | export const appIndexVisibilityGrantSchema = z.object({ |
| 221 | subjectType: appIndexSubjectTypeSchema, |
| 222 | subjectId: z.string().trim().min(1).max(200), |
| 223 | }); |
| 224 | export type AppIndexVisibilityGrantInput = z.input< |
| 225 | typeof appIndexVisibilityGrantSchema |
| 226 | >; |
| 227 | export type AppIndexVisibilityGrant = z.infer<typeof appIndexVisibilityGrantSchema>; |
| 228 |
| 229 | export const appIndexDocumentSchema = z.object({ |
| 230 | documentKey: z.string().trim().min(1).max(200), |
| 231 | documentType: z.string().trim().min(1).max(160), |
| 232 | fileId: z.string().trim().min(1).max(200).optional(), |
| 233 | title: z.string().trim().min(1).max(200), |
| 234 | body: z.string().trim().max(100_000).default(""), |
| 235 | url: z.string().trim().min(1).max(2_000).optional(), |
| 236 | metadata: z.record(z.string(), z.unknown()).default({}), |
| 237 | visibilityMode: appIndexVisibilityModeSchema.default("workspace"), |
| 238 | visibility: z.array(appIndexVisibilityGrantSchema).default([]), |
| 239 | }); |
| 240 | export type AppIndexDocumentInput = z.input<typeof appIndexDocumentSchema>; |
| 241 | export type AppIndexDocument = z.infer<typeof appIndexDocumentSchema>; |
| 242 |
| 243 | export const batchUpsertAppIndexDocumentsSchema = z.object({ |
| 244 | documents: z.array(appIndexDocumentSchema).min(1).max(100), |
| 245 | }); |
| 246 | export type BatchUpsertAppIndexDocumentsInput = z.input< |
| 247 | typeof batchUpsertAppIndexDocumentsSchema |
| 248 | >; |
| 249 | export type BatchUpsertAppIndexDocuments = z.infer< |
| 250 | typeof batchUpsertAppIndexDocumentsSchema |
| 251 | >; |
| 252 |
| 253 | export const batchDeleteAppIndexDocumentsSchema = z.object({ |
| 254 | documentKeys: z.array(z.string().trim().min(1).max(200)).min(1).max(100), |
| 255 | }); |
| 256 | export type BatchDeleteAppIndexDocumentsInput = z.input< |
| 257 | typeof batchDeleteAppIndexDocumentsSchema |
| 258 | >; |
| 259 | export type BatchDeleteAppIndexDocuments = z.infer< |
| 260 | typeof batchDeleteAppIndexDocumentsSchema |
| 261 | >; |
| 262 |