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
76 lines
2.2 KiB
TypeScript
76 lines
2.2 KiB
TypeScript
import { TABLE_LIMITS } from '@/lib/table/constants'
|
|
import { enrichTableToolSchema } from '@/tools/schema-enrichers'
|
|
import type { TableBatchInsertParams, TableBatchInsertResponse } from '@/tools/table/types'
|
|
import type { ToolConfig } from '@/tools/types'
|
|
|
|
export const tableBatchInsertRowsTool: ToolConfig<
|
|
TableBatchInsertParams,
|
|
TableBatchInsertResponse
|
|
> = {
|
|
id: 'table_batch_insert_rows',
|
|
name: 'Batch Insert Rows',
|
|
description: `Insert multiple rows into a table at once (up to ${TABLE_LIMITS.MAX_BATCH_INSERT_SIZE} rows)`,
|
|
version: '1.0.0',
|
|
|
|
toolEnrichment: {
|
|
dependsOn: 'tableId',
|
|
enrichTool: (tableId, schema, desc) =>
|
|
enrichTableToolSchema(tableId, 'table_batch_insert_rows', schema, desc),
|
|
},
|
|
|
|
params: {
|
|
tableId: {
|
|
type: 'string',
|
|
required: true,
|
|
description: 'Table ID',
|
|
visibility: 'user-only',
|
|
},
|
|
rows: {
|
|
type: 'array',
|
|
required: true,
|
|
description: `Array of row data objects (max ${TABLE_LIMITS.MAX_BATCH_INSERT_SIZE} rows)`,
|
|
visibility: 'user-or-llm',
|
|
},
|
|
},
|
|
|
|
request: {
|
|
url: (params: TableBatchInsertParams) => `/api/table/${params.tableId}/rows`,
|
|
method: 'POST',
|
|
headers: () => ({
|
|
'Content-Type': 'application/json',
|
|
}),
|
|
body: (params: TableBatchInsertParams) => {
|
|
const workspaceId = params._context?.workspaceId
|
|
if (!workspaceId) {
|
|
throw new Error('Workspace ID is required in execution context')
|
|
}
|
|
|
|
return {
|
|
rows: params.rows,
|
|
workspaceId,
|
|
}
|
|
},
|
|
},
|
|
|
|
transformResponse: async (response): Promise<TableBatchInsertResponse> => {
|
|
const result = await response.json()
|
|
const data = result.data || result
|
|
|
|
return {
|
|
success: true,
|
|
output: {
|
|
rows: data.rows,
|
|
insertedCount: data.insertedCount,
|
|
message: data.message || 'Rows inserted successfully',
|
|
},
|
|
}
|
|
},
|
|
|
|
outputs: {
|
|
success: { type: 'boolean', description: 'Whether rows were inserted' },
|
|
rows: { type: 'array', description: 'Inserted rows data' },
|
|
insertedCount: { type: 'number', description: 'Number of rows inserted' },
|
|
message: { type: 'string', description: 'Status message' },
|
|
},
|
|
}
|