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