d25d482dc2
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (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 / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
107 lines
3.1 KiB
TypeScript
107 lines
3.1 KiB
TypeScript
import type { AirtableDeleteParams, AirtableDeleteResponse } from '@/tools/airtable/types'
|
|
import type { ToolConfig } from '@/tools/types'
|
|
|
|
export const airtableDeleteRecordsTool: ToolConfig<AirtableDeleteParams, AirtableDeleteResponse> = {
|
|
id: 'airtable_delete_records',
|
|
name: 'Airtable Delete Records',
|
|
description: 'Delete one or more records from an Airtable table by ID',
|
|
version: '1.0.0',
|
|
|
|
oauth: {
|
|
required: true,
|
|
provider: 'airtable',
|
|
},
|
|
|
|
params: {
|
|
accessToken: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'hidden',
|
|
description: 'OAuth access token',
|
|
},
|
|
baseId: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-or-llm',
|
|
description: 'Airtable base ID (starts with "app", e.g., "appXXXXXXXXXXXXXX")',
|
|
},
|
|
tableId: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-or-llm',
|
|
description: 'Table ID (starts with "tbl") or table name',
|
|
},
|
|
recordIds: {
|
|
type: 'json',
|
|
required: true,
|
|
visibility: 'user-or-llm',
|
|
description:
|
|
'Array of record IDs to delete (each starts with "rec", e.g., ["recXXXXXXXXXXXXXX"]). Pass a single-element array to delete one record.',
|
|
},
|
|
},
|
|
|
|
request: {
|
|
url: (params) => {
|
|
const base = `https://api.airtable.com/v0/${params.baseId?.trim()}/${params.tableId?.trim()}`
|
|
const ids = (params.recordIds ?? [])
|
|
.map((id) => (id == null ? '' : String(id).trim()))
|
|
.filter(Boolean)
|
|
if (ids.length === 0) {
|
|
throw new Error('At least one record ID is required to delete')
|
|
}
|
|
if (ids.length > 10) {
|
|
throw new Error(
|
|
`Airtable deletes at most 10 records per request (received ${ids.length}). Split the delete into batches of 10 or fewer.`
|
|
)
|
|
}
|
|
const queryParams = new URLSearchParams()
|
|
for (const id of ids) {
|
|
queryParams.append('records[]', id as string)
|
|
}
|
|
return `${base}?${queryParams.toString()}`
|
|
},
|
|
method: 'DELETE',
|
|
headers: (params) => ({
|
|
Authorization: `Bearer ${params.accessToken}`,
|
|
'Content-Type': 'application/json',
|
|
}),
|
|
},
|
|
|
|
transformResponse: async (response) => {
|
|
const data = await response.json()
|
|
const records = data.records ?? []
|
|
return {
|
|
success: true,
|
|
output: {
|
|
records,
|
|
metadata: {
|
|
recordCount: records.length,
|
|
deletedRecordIds: records.map((r: { id: string }) => r.id),
|
|
},
|
|
},
|
|
}
|
|
},
|
|
|
|
outputs: {
|
|
records: {
|
|
type: 'array',
|
|
description: 'Array of deleted Airtable records',
|
|
items: {
|
|
type: 'object',
|
|
properties: {
|
|
id: { type: 'string', description: 'Record ID' },
|
|
deleted: { type: 'boolean', description: 'Whether the record was deleted' },
|
|
},
|
|
},
|
|
},
|
|
metadata: {
|
|
type: 'json',
|
|
description: 'Operation metadata',
|
|
properties: {
|
|
recordCount: { type: 'number', description: 'Number of records deleted' },
|
|
deletedRecordIds: { type: 'array', description: 'List of deleted record IDs' },
|
|
},
|
|
},
|
|
},
|
|
}
|