(filter?: {
readonly integration?: IntegrationSlug;
readonly owner?: Owner;
})
| 4742 | }); |
| 4743 | |
| 4744 | const connectionsList = (filter?: { |
| 4745 | readonly integration?: IntegrationSlug; |
| 4746 | readonly owner?: Owner; |
| 4747 | }): Effect.Effect<readonly Connection[], StorageFailure> => |
| 4748 | Effect.gen(function* () { |
| 4749 | const rows = yield* core.findMany("connection", { |
| 4750 | where: (b: AnyCb) => |
| 4751 | b.and( |
| 4752 | filter?.integration === undefined |
| 4753 | ? true |
| 4754 | : b("integration", "=", String(filter.integration)), |
| 4755 | filter?.owner === undefined ? true : b("owner", "=", filter.owner), |
| 4756 | ), |
| 4757 | }); |
| 4758 | // Same catalog gate as `toolsList`: a connection whose integration was |
| 4759 | // removed is an orphan, and offering it (in the accounts list, or to |
| 4760 | // an agent as a reconnect target) leads into flows that cannot mint. |
| 4761 | const catalogSlugs = yield* listCatalogSlugs(); |
| 4762 | const connections = rows |
| 4763 | .filter((row) => catalogSlugs.has(String(row.integration))) |
| 4764 | .map(rowToConnection); |
| 4765 | if (!activeToolPolicyProvider) return connections; |
| 4766 | |
| 4767 | const visibleTools = yield* readTools( |
| 4768 | { includeAnnotations: false }, |
| 4769 | { awaitStaleSync: false }, |
| 4770 | ); |
| 4771 | const visibleConnectionKeys = new Set( |
| 4772 | visibleTools |
| 4773 | .filter((tool) => !tool.static) |
| 4774 | .map((tool) => `${tool.owner}:${tool.integration}:${tool.connection}`), |
| 4775 | ); |
| 4776 | return connections.filter((connection) => |
| 4777 | visibleConnectionKeys.has( |
| 4778 | `${connection.owner}:${connection.integration}:${connection.name}`, |
| 4779 | ), |
| 4780 | ); |
| 4781 | }); |
| 4782 | |
| 4783 | const connectionsGet = (ref: ConnectionRef): Effect.Effect<Connection | null, StorageFailure> => |
| 4784 | findConnectionRow(ref).pipe(Effect.map((row) => (row ? rowToConnection(row) : null))); |
no test coverage detected