Files
orca/cloud/apps/connector/src/connector-database.ts
T
Jinwoo Hong 53c426f6b4 feat(connector): each Slack app verified with its own signing secret at its own URL (#34125)
Groundwork for per-company Slack apps. Each Slack app gets its own row with encrypted secrets, and Slack posts to /slack/apps/<app id>/..., where the address only selects which secret to check; a request acts only in a workspace where that app is installed. Rate limits are per address and per app, so one workspace can't hold up another's posts. Schema changes are additive. The existing staging app keeps working on the old route until a documented cutover. Inert for users.
2026-10-26 21:10:22 -04:00

36 lines
1.3 KiB
TypeScript

import {
openCloudDatabase,
openInMemoryCloudDatabase,
type CloudDatabase,
type OpenCloudDatabaseInput
} from '@orca-cloud/cloud-database'
import { connectorSchemaChanges } from './connector-schema-changes.js'
import { connectorSchemaStatements } from './connector-schema.js'
import { discordSchemaStatements } from './discord-schema.js'
import { slackSchemaStatements } from './slack-schema.js'
// Production has run these CREATE TABLEs, so editing one never reaches it. Change the schema by
// appending idempotent statements (ADD COLUMN IF NOT EXISTS, nullable or defaulted) to
// connector-schema-changes.ts; connector-schema-upgrade.test.ts boots the shipped baseline, then
// this list.
export const connectorBootStatements = () => [
...connectorSchemaStatements(),
...slackSchemaStatements(),
...discordSchemaStatements(),
...connectorSchemaChanges()
]
export async function openConnectorDatabase(
input: Omit<OpenCloudDatabaseInput, 'service' | 'schemaStatements'>
): Promise<CloudDatabase> {
return await openCloudDatabase({
...input,
service: 'connector',
schemaStatements: connectorBootStatements()
})
}
export async function openInMemoryConnectorDatabase(): Promise<CloudDatabase> {
return await openInMemoryCloudDatabase(connectorBootStatements())
}