@databasin/mcp-client 0.1.0 → 0.2.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/README.md +128 -61
  2. package/dist/abort.d.ts +5 -0
  3. package/dist/abort.d.ts.map +1 -0
  4. package/dist/abort.js +25 -0
  5. package/dist/abort.js.map +1 -0
  6. package/dist/api-client.d.ts +49 -34
  7. package/dist/api-client.d.ts.map +1 -1
  8. package/dist/api-client.js +142 -145
  9. package/dist/api-client.js.map +1 -1
  10. package/dist/api-contract.d.ts +59 -0
  11. package/dist/api-contract.d.ts.map +1 -0
  12. package/dist/api-contract.js +47 -0
  13. package/dist/api-contract.js.map +1 -0
  14. package/dist/api-profile.d.ts +5 -0
  15. package/dist/api-profile.d.ts.map +1 -0
  16. package/dist/api-profile.js +38 -0
  17. package/dist/api-profile.js.map +1 -0
  18. package/dist/api-request.d.ts +27 -0
  19. package/dist/api-request.d.ts.map +1 -0
  20. package/dist/api-request.js +147 -0
  21. package/dist/api-request.js.map +1 -0
  22. package/dist/api-response.d.ts +9 -0
  23. package/dist/api-response.d.ts.map +1 -0
  24. package/dist/api-response.js +206 -0
  25. package/dist/api-response.js.map +1 -0
  26. package/dist/auth.d.ts +22 -11
  27. package/dist/auth.d.ts.map +1 -1
  28. package/dist/auth.js +71 -71
  29. package/dist/auth.js.map +1 -1
  30. package/dist/browser.d.ts +20 -1
  31. package/dist/browser.d.ts.map +1 -1
  32. package/dist/browser.js +19 -17
  33. package/dist/browser.js.map +1 -1
  34. package/dist/cli.d.ts +31 -2
  35. package/dist/cli.d.ts.map +1 -1
  36. package/dist/cli.js +147 -67
  37. package/dist/cli.js.map +1 -1
  38. package/dist/config.js +2 -2
  39. package/dist/config.js.map +1 -1
  40. package/dist/correlation.d.ts +6 -0
  41. package/dist/correlation.d.ts.map +1 -0
  42. package/dist/correlation.js +15 -0
  43. package/dist/correlation.js.map +1 -0
  44. package/dist/credential-store.d.ts +21 -0
  45. package/dist/credential-store.d.ts.map +1 -0
  46. package/dist/credential-store.js +46 -0
  47. package/dist/credential-store.js.map +1 -0
  48. package/dist/errors.d.ts +17 -3
  49. package/dist/errors.d.ts.map +1 -1
  50. package/dist/errors.js +24 -6
  51. package/dist/errors.js.map +1 -1
  52. package/dist/login-url.d.ts +18 -0
  53. package/dist/login-url.d.ts.map +1 -0
  54. package/dist/login-url.js +82 -0
  55. package/dist/login-url.js.map +1 -0
  56. package/dist/safety.d.ts +4 -0
  57. package/dist/safety.d.ts.map +1 -1
  58. package/dist/safety.js +94 -10
  59. package/dist/safety.js.map +1 -1
  60. package/dist/schemas.d.ts +326 -49
  61. package/dist/schemas.d.ts.map +1 -1
  62. package/dist/schemas.js +242 -55
  63. package/dist/schemas.js.map +1 -1
  64. package/dist/server.d.ts +2 -4
  65. package/dist/server.d.ts.map +1 -1
  66. package/dist/server.js +17 -10
  67. package/dist/server.js.map +1 -1
  68. package/dist/token-validation.d.ts +5 -0
  69. package/dist/token-validation.d.ts.map +1 -0
  70. package/dist/token-validation.js +183 -0
  71. package/dist/token-validation.js.map +1 -0
  72. package/dist/tools.d.ts +12 -1
  73. package/dist/tools.d.ts.map +1 -1
  74. package/dist/tools.js +286 -75
  75. package/dist/tools.js.map +1 -1
  76. package/dist/version.d.ts +1 -1
  77. package/dist/version.d.ts.map +1 -1
  78. package/dist/version.js +1 -1
  79. package/dist/version.js.map +1 -1
  80. package/package.json +10 -6
  81. package/dist/mappers.d.ts +0 -56
  82. package/dist/mappers.d.ts.map +0 -1
  83. package/dist/mappers.js +0 -171
  84. package/dist/mappers.js.map +0 -1
package/README.md CHANGED
@@ -1,108 +1,175 @@
1
1
  # DataBasin MCP Client
2
2
 
3
- Run DataBasin tools locally in Codex, Claude Code, and other MCP clients. The package uses stdio locally and calls the remote DataBasin API over HTTPS as the signed-in user.
3
+ Local stdio MCP client for DataBasin. It keeps Microsoft Entra credentials in the OS-protected MSAL cache and calls only the versioned DataBasin SvelteKit machine façade over HTTPS.
4
4
 
5
- Production is the default. Users do not need to configure an API URL, tenant ID, client ID, scope, bearer token, callback port, or client secret.
5
+ Production is the default. The non-production profile is selected with `--environment np`.
6
6
 
7
- ## Requirements
7
+ ## NP beta pilot
8
8
 
9
- - Node.js 22.14 or newer
10
- - A DataBasin account
11
- - A supported OS credential store: Windows DPAPI, macOS Keychain, or Linux Secret Service/LibSecret
9
+ The `0.2.0-beta.1` candidate is for the DataBasin team and invited beta testers against NP only. Install the exact version so npm's production `latest` tag remains on the production-compatible `0.1.0` line:
12
10
 
13
- ## Sign in with your assistant
11
+ ```bash
12
+ npx -y @databasin/mcp-client@0.2.0-beta.1 doctor --environment np
13
+ npx -y @databasin/mcp-client@0.2.0-beta.1 login --environment np
14
+ ```
14
15
 
15
- After adding the MCP server, ask your assistant to connect to DataBasin. It can:
16
+ The beta requires Node.js 22.20+ or Node.js 24 and an available OS-protected credential store. `doctor` reports the selected fixed profile, runtime support, credential-store availability, and sign-in state; it never prints account identity, tokens, or credentials.
16
17
 
17
- 1. Call `databasin_auth_status` to check the local session.
18
- 2. Call `databasin_login` when sign-in is needed. It returns Microsoft's short-lived device-login URL and user code immediately.
19
- 3. Give you that URL and code. You can complete sign-in from any browser or device, after which the assistant calls `databasin_auth_status` again.
18
+ Use the exact beta version in the host configuration during the pilot:
20
19
 
21
- Enter credentials only on Microsoft's page. The assistant receives the intentionally displayable, short-lived device user code, but never receives the password, OAuth device code, authorization code, access token, refresh token, or signed-in account identity.
20
+ | Host | NP beta setup |
21
+ | --- | --- |
22
+ | Codex | `codex mcp add databasin-np -- npx -y @databasin/mcp-client@0.2.0-beta.1 --environment np` |
23
+ | Claude Code | `claude mcp add --transport stdio --scope user databasin-np -- npx -y @databasin/mcp-client@0.2.0-beta.1 --environment np` |
24
+ | Claude Desktop / Cursor-compatible config | Use the `mcpServers` JSON below |
25
+ | VS Code | Use the `servers` JSON below in user or workspace `mcp.json` |
26
+ | OpenCode v2 | Use the `mcp.servers` JSON below in `opencode.jsonc` |
22
27
 
23
- The CLI remains available as a fallback:
28
+ Claude Desktop and other hosts that accept the common `mcpServers` shape:
24
29
 
25
- ```bash
26
- npx -y @databasin/mcp-client login
30
+ ```json
31
+ {
32
+ "mcpServers": {
33
+ "databasin-np": {
34
+ "type": "stdio",
35
+ "command": "npx",
36
+ "args": ["-y", "@databasin/mcp-client@0.2.0-beta.1", "--environment", "np"]
37
+ }
38
+ }
39
+ }
27
40
  ```
28
41
 
29
- Assistant-driven login uses Microsoft's OAuth device authorization flow. CLI fallback uses Authorization Code with PKCE and an ephemeral `http://localhost` loopback callback. Both use a public client; no client secret is installed on the user's machine. MSAL stores and refreshes the session in the operating system credential store.
42
+ VS Code `mcp.json`:
30
43
 
31
- Check or clear the session:
44
+ ```json
45
+ {
46
+ "servers": {
47
+ "databasinNp": {
48
+ "type": "stdio",
49
+ "command": "npx",
50
+ "args": ["-y", "@databasin/mcp-client@0.2.0-beta.1", "--environment", "np"]
51
+ }
52
+ }
53
+ }
54
+ ```
32
55
 
33
- ```bash
34
- npx -y @databasin/mcp-client status
35
- npx -y @databasin/mcp-client logout
56
+ OpenCode v2 `opencode.jsonc`:
57
+
58
+ ```jsonc
59
+ {
60
+ "$schema": "https://opencode.ai/config.json",
61
+ "mcp": {
62
+ "servers": {
63
+ "databasin-np": {
64
+ "type": "local",
65
+ "command": ["npx", "-y", "@databasin/mcp-client@0.2.0-beta.1", "--environment", "np"]
66
+ }
67
+ }
68
+ }
69
+ }
36
70
  ```
37
71
 
38
- ## Codex
72
+ On native Windows, a host that cannot launch `npx` directly should use `cmd` with arguments beginning `[/c, npx, ...]` (JSON string form: `["/c", "npx", ...]`). Restart the host after changing its MCP configuration so it refreshes the 13-tool inventory.
73
+
74
+ The only remote façades are:
75
+
76
+ - Production: `https://databasin.cloud/api/v1/mcp`
77
+ - NP: `https://databasin-ui-np.grayriver-813df174.centralus.azurecontainerapps.io/api/v1/mcp`
78
+
79
+ ## Install and connect
39
80
 
40
81
  ```bash
41
- codex mcp add databasin -- npx -y @databasin/mcp-client
82
+ npx -y @databasin/mcp-client
42
83
  ```
43
84
 
44
- Equivalent `config.toml`:
85
+ The client requires an OS credential store. On Linux, an available and unlocked
86
+ Secret Service/libsecret keyring is required; headless environments must provide
87
+ one explicitly. The client fails closed rather than falling back to a plaintext
88
+ token cache.
89
+
90
+ Codex:
45
91
 
46
- ```toml
47
- [mcp_servers.databasin]
48
- command = "npx"
49
- args = ["-y", "@databasin/mcp-client"]
92
+ ```bash
93
+ codex mcp add databasin -- npx -y @databasin/mcp-client
50
94
  ```
51
95
 
52
- ## Claude Code
96
+ Claude Code:
53
97
 
54
98
  ```bash
55
99
  claude mcp add --transport stdio --scope user databasin -- npx -y @databasin/mcp-client
56
100
  ```
57
101
 
58
- Equivalent `.mcp.json` entry:
102
+ To use non-production:
59
103
 
60
- ```json
61
- {
62
- "mcpServers": {
63
- "databasin": {
64
- "command": "npx",
65
- "args": ["-y", "@databasin/mcp-client"]
66
- }
67
- }
68
- }
104
+ ```bash
105
+ npx -y @databasin/mcp-client --environment np
69
106
  ```
70
107
 
71
- ## Non-production
108
+ The assistant can call `databasin_login` and give you the short-lived Microsoft device URL and code. Enter credentials only on Microsoft’s page. The client never sends credentials or tokens through MCP tool output.
72
109
 
73
- Production is selected when no environment is supplied. To use the DataBasin NP environment, add the option to the MCP command. The assistant-driven login tools automatically use that environment:
110
+ Device login output is restricted to the HTTPS `microsoft.com/devicelogin` endpoint (with an optional trailing slash, canonicalized away). Interactive CLI login is restricted to the configured tenant’s exact `login.microsoftonline.com/<tenant>/oauth2/v2.0/authorize` path and client ID. Credential-bearing URLs, redirects to other hosts, other schemes, ports, fragments, and unexpected paths fail closed before a URL is opened or returned. Raw MSAL device codes, polling intervals/handles, and provider messages are discarded immediately; only the validated verification URL, human-entered user code, and expiry are retained.
74
111
 
75
- ```toml
76
- [mcp_servers.databasin_np]
77
- command = "npx"
78
- args = ["-y", "@databasin/mcp-client", "--environment", "np"]
79
- ```
112
+ Before using an MSAL access token, the client fail-closes on its tenant, issuer, audience, delegated scope, timing, authority, account, and expiry metadata. JWT payload decoding here is local defense-in-depth, not signature verification; the DataBasin API remains the cryptographic validation and authorization boundary.
113
+
114
+ ## Tools
80
115
 
81
- For CLI fallback, run `npx -y @databasin/mcp-client login --environment np`.
116
+ The MCP server exposes thirteen tools in two deliberately separate groups. Eleven product tools call the remote DataBasin façade:
82
117
 
83
- `test`, `staging`, and `non-production` are accepted aliases for `np`; `production` is accepted as an alias for `prod`.
118
+ - `databasin_get_capabilities` — fetch the server-owned capability allowlist.
119
+ - `databasin_get_context` — fetch authorized project and connector metadata.
120
+ - `databasin_search` — bounded authorized metadata search.
121
+ - `databasin_get_schema` — bounded non-secret schema metadata.
122
+ - `databasin_run_agent` — run the fixed `metadata_readonly` profile for an explicit institution and optional project/connector scope.
123
+ - `databasin_get_agent_run` — read an authorized run status/result.
124
+ - `databasin_cancel_agent_run` — request cancellation and report the server’s truthful state.
125
+ - `databasin_run_query` — execute a single read-only `SELECT`/`WITH` statement against an authorized connector and return up to `maxRows` rows.
126
+ - `databasin_get_query_status` — read an authorized query's status, and its columns/rows/error once terminal.
127
+ - `databasin_cancel_query` — request cancellation and report the server’s truthful state.
128
+ - `databasin_run_assistant` — run the read-only DataBasin assistant (a server-side Claude Code agent) that browses metadata and runs DataBasin skills over multiple steps to answer a natural-language request.
84
129
 
85
- ## Tools
130
+ The other two tools, `databasin_auth_status` and `databasin_login`, are client-local authentication helpers. They interact only with the local MSAL credential manager and Microsoft sign-in; they are not part of the eleven-tool DataBasin product façade and do not call DataBasin product routes.
131
+
132
+ No organization configuration is required. Unscoped `databasin_get_context` and `databasin_search` discover metadata only across organizations the signed-in user is authorized to access. A project-scoped search must include its `institutionId`; account discovery is not a wildcard and never broadens server-side authorization.
133
+
134
+ The client does not expose arbitrary SQL, shell commands, connector credentials, arbitrary URLs, or arbitrary headers. `databasin_run_query` accepts only a single read-only `SELECT`/`WITH` statement, enforced server-side; multi-statement text and any mutating keyword are rejected outright, and `language`/`sessionId`/`timeoutSeconds` are never caller-facing (`language` is always `sql`; `timeoutSeconds` is a fixed server-side constant). Every remote success is the strict envelope `{ "data": T, "correlationId": "..." }` and must match the response `X-Correlation-Id` header.
86
135
 
87
- - `databasin_auth_status`: check whether the local DataBasin session is authenticated without exposing account identity
88
- - `databasin_login`: return Microsoft device-login instructions without blocking the assistant
89
- - `databasin_get_context`: list caller-visible projects and connection identifiers
90
- - `databasin_search`: search visible pipelines, connectors, and automations
91
- - `databasin_browse_schema`: browse catalogs, schemas, tables, and columns
92
- - `databasin_get_operation`: read bounded query status and results
93
- - `databasin_cancel_operation`: request cancellation of a visible query operation
136
+ `databasin_run_agent` accepts `institutionId`, `prompt`, an optional JSON-object `context`, optional `projectInternalId`, `connectorId`, `model`, and top-level `maxTurns` (`1..100`). The optional model is restricted to the server-owned `haiku` or `sonnet` allowlist; omitting it uses `haiku`. Its profile is always `metadata_readonly`. Agent creation and cancellation each accept an optional UUID `idempotencyKey` for replay after a lost response; otherwise the client generates one. The key is sent only as `Idempotency-Key`, never in the request body. Polling is bounded to 30 minutes with bounded backoff and honors MCP cancellation.
94
137
 
95
- Tool output is bounded and inspected for credential-like fields. API URLs are fixed by the selected release profile, authentication tokens remain inside MSAL, and the agent cannot supply arbitrary URLs or headers.
138
+ Agent status, result, and cancellation responses include the complete server-authorized scope. A canonical run contains `runId`, the three scope IDs (nullable where optional), `profile`, `status`, bounded `result`/`error`, and `createdAt`/`updatedAt`. Cancellation reports the state returned by the server and does not imply completion before the server says `cancelled`.
96
139
 
97
- ## Publishing
140
+ `databasin_run_query` accepts `connectorId`, `code` (the SQL text, 1–32768 bytes), and `maxRows` (`1..1000`, default `1000`). Unlike agent runs, query creation and cancellation take no idempotency key. Polling is bounded to 2 minutes with the same bounded backoff, since a query is meant to feel like a fast synchronous tool call rather than a long-running job; on timeout the last observed non-terminal status is returned with its `queryId` for `databasin_get_query_status`/`databasin_cancel_query` to follow up. A canonical query result contains `queryId`, `connectorId`, `status`, bounded `columns`/`data`/`rowCount` (populated once terminal, otherwise `null`), `truncated`, and `error`.
98
141
 
99
- The package publishes only `dist/` and this README. Before publishing:
142
+ `databasin_run_assistant` accepts `connectorId` (required, so the assistant has an LLM to route to), `prompt` (1–32768 bytes), an optional `context` string (up to 4096 characters), and `maxTurns` (`1..25`, default `6`). It never accepts `model`, `sessionId`, `options`, or any tool/permission override — the assistant is stateless per call in v1 (no session continuity), and the server-side agent's read-only tool policy is enforced entirely on the façade, not by this client. The call is synchronous and may take up to a few minutes; the client gives this one endpoint a longer request timeout than the shared default so a legitimate in-progress run is never cut off client-side first. A canonical result contains `status` (`completed`/`failed`/`incomplete`), bounded `text`, `turns`, and `error`. This tool is metadata-and-skills only — it never executes SQL; use `databasin_run_query` for that.
143
+
144
+ ## CLI fallback
145
+
146
+ ```bash
147
+ npx -y @databasin/mcp-client login
148
+ npx -y @databasin/mcp-client status
149
+ npx -y @databasin/mcp-client logout
150
+ npx -y @databasin/mcp-client login --environment np
151
+ npx -y @databasin/mcp-client doctor --environment np
152
+ ```
153
+
154
+ Environment aliases `production` and `staging`/`test` are accepted for `prod` and `np` respectively.
155
+
156
+ ## Development
100
157
 
101
158
  ```bash
102
159
  npm ci
103
160
  npm run verify
104
- npm pack --dry-run
105
- npm publish --access public
161
+ npm audit --omit=dev --audit-level=high
162
+ npm run verify:package
106
163
  ```
107
164
 
108
- Publishing from CI should use npm trusted publishing with provenance. Choose and record DataBasin's approved package license before the first public release; the package is currently marked `UNLICENSED`.
165
+ `npm run verify` runs the TypeScript check, unit tests, build, and stdio child-process E2E. CI runs those checks on Node 22 and 24 across Linux, macOS, and Windows, audits production dependencies, and verifies the exact package allowlist with `npm pack --dry-run --json`.
166
+
167
+ Release qualification uses an exact local tarball, never a mutable dist-tag. After `npm pack`, an authorized tester with an existing NP session can run the read-only qualification:
168
+
169
+ ```bash
170
+ DATABASIN_MCP_BETA_TARBALL=./databasin-mcp-client-0.2.0-beta.1.tgz npm run qualify:np
171
+ ```
172
+
173
+ The release owner may add `DATABASIN_MCP_QUALIFY_STATEFUL=1` plus explicit authorized connector/scope environment variables to exercise all 13 tools, including the agent, query, and assistant lifecycles. The command emits only package/version, counts, mode, and terminal statuses; resource identifiers, names, responses, and credentials are not evidence output.
174
+
175
+ Release approval still requires proof of the Entra registration, tenant, issuer, audience, delegated scope, and wrong-claim rejection behavior for each environment.
@@ -0,0 +1,5 @@
1
+ import { DataBasinError } from './errors.js';
2
+ export declare function abortedRequest(correlationId?: string): DataBasinError;
3
+ export declare function throwIfAborted(signal?: AbortSignal, correlationId?: string): void;
4
+ export declare function abortableDelay(milliseconds: number, signal?: AbortSignal): Promise<void>;
5
+ //# sourceMappingURL=abort.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abort.d.ts","sourceRoot":"","sources":["../src/abort.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,wBAAgB,cAAc,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,cAAc,CAMrE;AAED,wBAAgB,cAAc,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAEjF;AAED,wBAAsB,cAAc,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAe9F"}
package/dist/abort.js ADDED
@@ -0,0 +1,25 @@
1
+ import { DataBasinError } from './errors.js';
2
+ export function abortedRequest(correlationId) {
3
+ return new DataBasinError('REQUEST_ABORTED', 'The DataBasin request was cancelled by the caller.', correlationId === undefined ? {} : { correlationId });
4
+ }
5
+ export function throwIfAborted(signal, correlationId) {
6
+ if (signal?.aborted)
7
+ throw abortedRequest(correlationId);
8
+ }
9
+ export async function abortableDelay(milliseconds, signal) {
10
+ throwIfAborted(signal);
11
+ await new Promise((resolve, reject) => {
12
+ const cleanup = () => signal?.removeEventListener('abort', onAbort);
13
+ const onAbort = () => {
14
+ clearTimeout(handle);
15
+ cleanup();
16
+ reject(abortedRequest());
17
+ };
18
+ const handle = setTimeout(() => {
19
+ cleanup();
20
+ resolve();
21
+ }, milliseconds);
22
+ signal?.addEventListener('abort', onAbort, { once: true });
23
+ });
24
+ }
25
+ //# sourceMappingURL=abort.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abort.js","sourceRoot":"","sources":["../src/abort.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,UAAU,cAAc,CAAC,aAAsB;IACnD,OAAO,IAAI,cAAc,CACvB,iBAAiB,EACjB,oDAAoD,EACpD,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,CACrD,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,MAAoB,EAAE,aAAsB;IACzE,IAAI,MAAM,EAAE,OAAO;QAAE,MAAM,cAAc,CAAC,aAAa,CAAC,CAAC;AAC3D,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,YAAoB,EAAE,MAAoB;IAC7E,cAAc,CAAC,MAAM,CAAC,CAAC;IACvB,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC1C,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACpE,MAAM,OAAO,GAAG,GAAG,EAAE;YACnB,YAAY,CAAC,MAAM,CAAC,CAAC;YACrB,OAAO,EAAE,CAAC;YACV,MAAM,CAAC,cAAc,EAAE,CAAC,CAAC;QAC3B,CAAC,CAAC;QACF,MAAM,MAAM,GAAG,UAAU,CAAC,GAAG,EAAE;YAC7B,OAAO,EAAE,CAAC;YACV,OAAO,EAAE,CAAC;QACZ,CAAC,EAAE,YAAY,CAAC,CAAC;QACjB,MAAM,EAAE,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -1,43 +1,58 @@
1
+ import { z } from 'zod';
2
+ import { fixedFacadeBaseUrl } from './api-profile.js';
3
+ import { type Sleep } from './api-request.js';
4
+ import { parseRetryAfter } from './api-response.js';
1
5
  import type { DataBasinProfile } from './config.js';
2
- import type { BrowseSchemaInput, SearchInput } from './schemas.js';
6
+ import { CapabilitiesEnvelopeSchema, ContextEnvelopeSchema, GetSchemaEnvelopeSchema, SearchEnvelopeSchema, type AgentRunEnvelope, type AgentRunRequest, type AssistantEnvelope, type GetSchemaInput, type QueryEnvelope, type RunAssistantInput, type RunQueryInput, type SearchInput } from './schemas.js';
7
+ type CapabilitiesEnvelope = z.infer<typeof CapabilitiesEnvelopeSchema>;
8
+ type ContextEnvelope = z.infer<typeof ContextEnvelopeSchema>;
9
+ type SearchEnvelope = z.infer<typeof SearchEnvelopeSchema>;
10
+ type GetSchemaEnvelope = z.infer<typeof GetSchemaEnvelopeSchema>;
3
11
  export interface DataBasinApi {
4
- getProjects(signal?: AbortSignal): Promise<unknown>;
5
- getAccessibleConnections(signal?: AbortSignal): Promise<unknown>;
6
- search(input: SearchInput, signal?: AbortSignal): Promise<unknown>;
7
- browseSchema(input: BrowseSchemaInput, signal?: AbortSignal): Promise<unknown>;
8
- getOperation(operationId: string, options: {
9
- offset: number;
10
- limit: number;
11
- }, signal?: AbortSignal): Promise<unknown>;
12
- cancelOperation(operationId: string, signal?: AbortSignal): Promise<unknown>;
12
+ getCapabilities(signal?: AbortSignal): Promise<CapabilitiesEnvelope>;
13
+ getContext(signal?: AbortSignal): Promise<ContextEnvelope>;
14
+ search(input: SearchInput, signal?: AbortSignal): Promise<SearchEnvelope>;
15
+ getSchema(input: GetSchemaInput, signal?: AbortSignal): Promise<GetSchemaEnvelope>;
16
+ createAgentRun(input: AgentRunRequest, idempotencyKey: string, signal?: AbortSignal): Promise<AgentRunEnvelope>;
17
+ getAgentRun(runId: string, signal?: AbortSignal): Promise<AgentRunEnvelope>;
18
+ cancelAgentRun(runId: string, idempotencyKey: string, reason: string, signal?: AbortSignal): Promise<AgentRunEnvelope>;
19
+ runQuery(input: RunQueryInput, signal?: AbortSignal): Promise<QueryEnvelope>;
20
+ getQueryStatus(queryId: string, signal?: AbortSignal): Promise<QueryEnvelope>;
21
+ cancelQuery(queryId: string, signal?: AbortSignal): Promise<QueryEnvelope>;
22
+ runAssistant(input: RunAssistantInput, signal?: AbortSignal): Promise<AssistantEnvelope>;
13
23
  }
14
- export interface DataBasinApiClientOptions {
15
- baseUrl: string;
16
- auth: {
17
- profile: DataBasinProfile;
18
- getAccessToken(): Promise<string>;
19
- };
20
- fetchImpl?: typeof fetch;
24
+ export interface AuthProvider {
25
+ profile: DataBasinProfile;
26
+ getAccessToken(): Promise<string>;
27
+ }
28
+ export interface TestOnlyDataBasinApiClientOptions {
29
+ testOnlyBaseUrl: string;
30
+ auth: AuthProvider;
31
+ fetchImpl: typeof fetch;
21
32
  maxResponseBytes?: number;
22
33
  timeoutMs?: number;
34
+ sleepImpl?: Sleep;
35
+ now?: () => number;
23
36
  }
24
37
  export declare class DataBasinApiClient implements DataBasinApi {
25
- private readonly baseUrl;
26
- private readonly auth;
27
- private readonly fetchImpl;
28
- private readonly maxResponseBytes;
29
- private readonly timeoutMs;
30
- constructor(options: DataBasinApiClientOptions);
31
- getProjects(signal?: AbortSignal): Promise<unknown>;
32
- getAccessibleConnections(signal?: AbortSignal): Promise<unknown>;
33
- search(input: SearchInput, signal?: AbortSignal): Promise<unknown>;
34
- browseSchema(input: BrowseSchemaInput, signal?: AbortSignal): Promise<unknown>;
35
- getOperation(operationId: string, options: {
36
- offset: number;
37
- limit: number;
38
- }, signal?: AbortSignal): Promise<unknown>;
39
- cancelOperation(operationId: string, signal?: AbortSignal): Promise<unknown>;
40
- private request;
38
+ private readonly transport;
39
+ private constructor();
40
+ static forProfile(auth: AuthProvider): DataBasinApiClient;
41
+ static createForTests(options: TestOnlyDataBasinApiClientOptions): DataBasinApiClient;
42
+ getCapabilities(signal?: AbortSignal): Promise<CapabilitiesEnvelope>;
43
+ getContext(signal?: AbortSignal): Promise<ContextEnvelope>;
44
+ search(input: SearchInput, signal?: AbortSignal): Promise<SearchEnvelope>;
45
+ getSchema(input: GetSchemaInput, signal?: AbortSignal): Promise<GetSchemaEnvelope>;
46
+ createAgentRun(input: AgentRunRequest, idempotencyKey: string, signal?: AbortSignal): Promise<AgentRunEnvelope>;
47
+ getAgentRun(runId: string, signal?: AbortSignal): Promise<AgentRunEnvelope>;
48
+ cancelAgentRun(runId: string, idempotencyKey: string, reason: string, signal?: AbortSignal): Promise<AgentRunEnvelope>;
49
+ runQuery(input: RunQueryInput, signal?: AbortSignal): Promise<QueryEnvelope>;
50
+ getQueryStatus(queryId: string, signal?: AbortSignal): Promise<QueryEnvelope>;
51
+ cancelQuery(queryId: string, signal?: AbortSignal): Promise<QueryEnvelope>;
52
+ runAssistant(input: RunAssistantInput, signal?: AbortSignal): Promise<AssistantEnvelope>;
53
+ private execute;
41
54
  }
42
- export declare function normalizeApiBase(raw: string): string;
55
+ export declare function createDataBasinApiClientForTests(options: TestOnlyDataBasinApiClientOptions): DataBasinApiClient;
56
+ export { fixedFacadeBaseUrl, parseRetryAfter };
57
+ export declare const ASSISTANT_REQUEST_TIMEOUT_MS: number;
43
58
  //# sourceMappingURL=api-client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"api-client.d.ts","sourceRoot":"","sources":["../src/api-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAKnE,MAAM,WAAW,YAAY;IAC3B,WAAW,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,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