6bf8bebf51
CI / Test and Build (push) Failing after 1s
CI / Migrate Dev DB (push) Has been skipped
CI / Migrate DB (push) Has been skipped
CodeQL / Analyze actions (push) Has been cancelled
CodeQL / Analyze javascript-typescript (push) Has been cancelled
CI / Detect Version (push) Has been cancelled
CI / Detect Desktop Changes (push) Has been cancelled
CI / Build AMD64 (blacksmith-2vcpu-ubuntu-2404, ./docker/cron.Dockerfile, ubuntu-latest, ghcr.io/simstudioai/cron) (push) Has been cancelled
CI / Build AMD64 (blacksmith-2vcpu-ubuntu-2404, ./docker/db.Dockerfile, ECR_MIGRATIONS, ubuntu-latest, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (blacksmith-4vcpu-ubuntu-2404, ./docker/pii.Dockerfile, ECR_PII, ubuntu-latest, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (blacksmith-4vcpu-ubuntu-2404, ./docker/realtime.Dockerfile, ECR_REALTIME, ubuntu-latest, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build AMD64 (blacksmith-8vcpu-ubuntu-2404, ./docker/app.Dockerfile, ECR_APP, linux-x64-8-core, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (blacksmith-4vcpu-ubuntu-2404-arm, ./docker/cron.Dockerfile, ubuntu-24.04-arm, ghcr.io/simstudioai/cron) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (blacksmith-4vcpu-ubuntu-2404-arm, ./docker/db.Dockerfile, ubuntu-24.04-arm, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (blacksmith-4vcpu-ubuntu-2404-arm, ./docker/pii.Dockerfile, ubuntu-24.04-arm, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (blacksmith-4vcpu-ubuntu-2404-arm, ./docker/realtime.Dockerfile, ubuntu-24.04-arm, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (blacksmith-8vcpu-ubuntu-2404-arm, ./docker/app.Dockerfile, linux-arm64-8-core, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
Helm Chart / Lint, test, and validate chart (push) Has been cancelled
Helm Chart / Chart version bumped (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
CI / Build Dev ECR (blacksmith-8vcpu-ubuntu-2404, ./docker/app.Dockerfile, ECR_APP, linux-x64-8-core) (push) Has been cancelled
CI / Promote Images (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/cron) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build Dev ECR (blacksmith-2vcpu-ubuntu-2404, ./docker/db.Dockerfile, ECR_MIGRATIONS, ubuntu-latest) (push) Has been cancelled
CI / Build Dev ECR (blacksmith-4vcpu-ubuntu-2404, ./docker/pii.Dockerfile, ECR_PII, ubuntu-latest) (push) Has been cancelled
CI / Build Dev ECR (blacksmith-4vcpu-ubuntu-2404, ./docker/realtime.Dockerfile, ECR_REALTIME, ubuntu-latest) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Check Desktop Signing Secrets (push) Has been cancelled
CI / Desktop Release (push) Has been cancelled
CI / Create Desktop Prerelease (push) Has been cancelled
CI / Desktop Prerelease Build (push) Has been cancelled
CI / Publish Desktop Prerelease (push) Has been cancelled
CI / Prune Desktop Prereleases (push) Has been cancelled
Helm Chart / Install on kind and run helm test (push) Has been cancelled
139 lines
4.5 KiB
TypeScript
139 lines
4.5 KiB
TypeScript
#!/usr/bin/env bun
|
|
import { stripVersionSuffix } from '@sim/utils/string'
|
|
/**
|
|
* Verifies the registry-free integration catalog matches the executable block
|
|
* registry fields that deployment availability depends on.
|
|
*/
|
|
import { BLOCK_REGISTRY } from '../apps/sim/blocks/registry-maps'
|
|
import { AuthMode, type BlockConfig } from '../apps/sim/blocks/types'
|
|
import integrationsJson from '../apps/sim/lib/integrations/integrations.json'
|
|
|
|
type CatalogAuthType = 'oauth' | 'api-key' | 'none'
|
|
|
|
interface CatalogEntry {
|
|
type: string
|
|
slug: string
|
|
name: string
|
|
category: string
|
|
integrationType: string
|
|
authType: CatalogAuthType
|
|
oauthServiceId?: string
|
|
}
|
|
|
|
function resolveAuthType(block: BlockConfig): CatalogAuthType {
|
|
if (block.authMode === AuthMode.OAuth) return 'oauth'
|
|
if (block.authMode === AuthMode.ApiKey || block.authMode === AuthMode.BotToken) return 'api-key'
|
|
if (block.subBlocks.some((subBlock) => subBlock.type === 'oauth-input')) return 'oauth'
|
|
if (
|
|
block.subBlocks.some((subBlock) => ['apiKey', 'api_key', 'accessToken'].includes(subBlock.id))
|
|
) {
|
|
return 'api-key'
|
|
}
|
|
return 'none'
|
|
}
|
|
|
|
function resolveOAuthServiceId(block: BlockConfig): string | undefined {
|
|
const serviceIds = new Set(
|
|
block.subBlocks
|
|
.filter((subBlock) => subBlock.type === 'oauth-input')
|
|
.map((subBlock) => subBlock.serviceId)
|
|
.filter((serviceId): serviceId is string => Boolean(serviceId))
|
|
)
|
|
if (serviceIds.size > 1) {
|
|
throw new Error(
|
|
`Integration block "${block.type}" declares more than one OAuth service ID: ${[...serviceIds].join(', ')}`
|
|
)
|
|
}
|
|
return serviceIds.values().next().value
|
|
}
|
|
|
|
function expectedEntry(block: BlockConfig): CatalogEntry {
|
|
if (!block.integrationType) {
|
|
throw new Error(`Integration block "${block.type}" is missing integrationType`)
|
|
}
|
|
const authType = resolveAuthType(block)
|
|
const oauthServiceId = authType === 'oauth' ? resolveOAuthServiceId(block) : undefined
|
|
if (authType === 'oauth' && !oauthServiceId) {
|
|
throw new Error(`OAuth integration block "${block.type}" is missing an OAuth service ID`)
|
|
}
|
|
return {
|
|
type: block.type,
|
|
slug: block.name
|
|
.toLowerCase()
|
|
.replace(/[^a-z0-9]+/g, '-')
|
|
.replace(/^-|-$/g, ''),
|
|
name: block.name,
|
|
category: block.category,
|
|
integrationType: block.integrationType,
|
|
authType,
|
|
...(oauthServiceId ? { oauthServiceId } : {}),
|
|
}
|
|
}
|
|
|
|
function verifyIntegrationCatalog(): void {
|
|
const expected = Object.values(BLOCK_REGISTRY).filter(
|
|
(block) => block.category === 'tools' && !block.hideFromToolbar && !block.preview
|
|
)
|
|
const expectedBaseTypes = new Map<string, string>()
|
|
for (const block of expected) {
|
|
const baseType = stripVersionSuffix(block.type)
|
|
const existing = expectedBaseTypes.get(baseType)
|
|
if (existing) {
|
|
throw new Error(
|
|
`Visible integration blocks "${existing}" and "${block.type}" share base type "${baseType}"`
|
|
)
|
|
}
|
|
expectedBaseTypes.set(baseType, block.type)
|
|
}
|
|
|
|
const actual = integrationsJson.integrations as readonly CatalogEntry[]
|
|
const expectedByType = new Map(expected.map((block) => [block.type, expectedEntry(block)]))
|
|
const actualByType = new Map<string, CatalogEntry>()
|
|
const actualSlugs = new Set<string>()
|
|
for (const entry of actual) {
|
|
if (actualByType.has(entry.type)) {
|
|
throw new Error(`Generated integration catalog contains duplicate type "${entry.type}"`)
|
|
}
|
|
if (actualSlugs.has(entry.slug)) {
|
|
throw new Error(`Generated integration catalog contains duplicate slug "${entry.slug}"`)
|
|
}
|
|
actualByType.set(entry.type, entry)
|
|
actualSlugs.add(entry.slug)
|
|
}
|
|
|
|
const issues: string[] = []
|
|
for (const [type, entry] of expectedByType) {
|
|
const generated = actualByType.get(type)
|
|
if (!generated) {
|
|
issues.push(`missing generated entry for "${type}"`)
|
|
continue
|
|
}
|
|
for (const field of [
|
|
'name',
|
|
'slug',
|
|
'category',
|
|
'integrationType',
|
|
'authType',
|
|
'oauthServiceId',
|
|
] as const) {
|
|
if (generated[field] !== entry[field]) {
|
|
issues.push(`"${type}" has stale ${field}`)
|
|
}
|
|
}
|
|
}
|
|
for (const type of actualByType.keys()) {
|
|
if (!expectedByType.has(type)) issues.push(`unexpected generated entry for "${type}"`)
|
|
}
|
|
|
|
if (issues.length > 0) {
|
|
throw new Error(
|
|
`Generated integration catalog is stale:\n- ${issues.join('\n- ')}\nRun \`bun run scripts/generate-docs.ts\` and commit the generated catalog.`
|
|
)
|
|
}
|
|
process.stdout.write(
|
|
`Integration deployment metadata is in sync (${actual.length} integrations).\n`
|
|
)
|
|
}
|
|
|
|
verifyIntegrationCatalog()
|