(client: Client, tenantId: string)
| 458 | }; |
| 459 | |
| 460 | const readV1Snapshot = async (client: Client, tenantId: string): Promise<LocalV1Snapshot> => { |
| 461 | const hasDefinition = await tableExists(client, "definition"); |
| 462 | const hasBlob = await tableExists(client, "blob"); |
| 463 | const bindingColumns = await columnNames(client, "credential_binding"); |
| 464 | const toolColumns = await columnNames(client, "tool"); |
| 465 | const definitionColumns = hasDefinition |
| 466 | ? await columnNames(client, "definition") |
| 467 | : new Set<string>(); |
| 468 | |
| 469 | const [ |
| 470 | sources, |
| 471 | secrets, |
| 472 | bindings, |
| 473 | connections, |
| 474 | policies, |
| 475 | sourceStorage, |
| 476 | allPluginStorage, |
| 477 | toolSources, |
| 478 | tools, |
| 479 | definitions, |
| 480 | blobs, |
| 481 | ] = await Promise.all([ |
| 482 | queryRows<Row>(client, "SELECT scope_id, id, plugin_id, kind, name FROM source"), |
| 483 | queryRows<Row>( |
| 484 | client, |
| 485 | "SELECT id, scope_id, name, provider, owned_by_connection_id FROM secret", |
| 486 | ), |
| 487 | queryRows<Row>( |
| 488 | client, |
| 489 | `SELECT scope_id, ${optionalColumn(bindingColumns, "credential_binding", "source_scope_id")} AS source_scope_id, source_id, slot_key, kind, secret_id, ${optionalColumn(bindingColumns, "credential_binding", "secret_scope_id")} AS secret_scope_id, connection_id, text_value FROM credential_binding`, |
| 490 | ), |
| 491 | queryRows<Row>( |
| 492 | client, |
| 493 | "SELECT id, scope_id, provider, identity_label, access_token_secret_id, refresh_token_secret_id, expires_at, provider_state FROM connection", |
| 494 | ), |
| 495 | queryRows<Row>(client, "SELECT id, scope_id, pattern, action, position FROM tool_policy"), |
| 496 | queryRows<Row>( |
| 497 | client, |
| 498 | "SELECT ps.scope_id, ps.key AS source_id, ps.data, s.kind FROM plugin_storage ps JOIN source s ON ps.key = s.id AND ps.scope_id = s.scope_id WHERE ps.collection = 'source'", |
| 499 | ), |
| 500 | queryRows<Row>( |
| 501 | client, |
| 502 | "SELECT scope_id, plugin_id, collection, key, data, created_at, updated_at FROM plugin_storage", |
| 503 | ), |
| 504 | queryRows<Row>(client, "SELECT DISTINCT source_id FROM tool"), |
| 505 | queryRows<Row>( |
| 506 | client, |
| 507 | `SELECT scope_id, source_id, plugin_id, name, description, ${optionalColumn(toolColumns, "tool", "input_schema")} AS input_schema, ${optionalColumn(toolColumns, "tool", "output_schema")} AS output_schema, ${optionalColumn(toolColumns, "tool", "annotations")} AS annotations, created_at, updated_at FROM tool`, |
| 508 | ), |
| 509 | hasDefinition |
| 510 | ? queryRows<Row>( |
| 511 | client, |
| 512 | `SELECT scope_id, source_id, plugin_id, name, ${optionalColumn(definitionColumns, "definition", "schema")} AS schema, created_at FROM definition`, |
| 513 | ) |
| 514 | : Promise.resolve([]), |
| 515 | hasBlob |
| 516 | ? queryRows<Row>(client, "SELECT namespace, key, value FROM blob") |
| 517 | : Promise.resolve([]), |
no test coverage detected