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