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