@narrative.io/data-collaboration-sdk-ts 4.1.0 → 4.3.0
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.
- package/README.md +71 -1
- package/build/generated/api-types.d.ts +25866 -0
- package/build/generated/api-types.js +13 -0
- package/build/mcp-connections/index.d.ts +18 -1
- package/build/mcp-connections/index.js +20 -1
- package/build/mcp-connections/types.d.ts +3 -0
- package/build/testing/auth.d.ts +8 -0
- package/build/testing/auth.js +32 -0
- package/build/testing/fixtures/data-planes.d.ts +8 -0
- package/build/testing/fixtures/data-planes.js +45 -0
- package/build/testing/fixtures/index.d.ts +1 -0
- package/build/testing/fixtures/index.js +1 -0
- package/build/testing/handlers/data-planes.d.ts +4 -0
- package/build/testing/handlers/data-planes.js +69 -0
- package/build/testing/handlers/index.d.ts +10 -0
- package/build/testing/handlers/index.js +16 -0
- package/build/testing/handlers/openapi-http.d.ts +10 -0
- package/build/testing/handlers/openapi-http.js +9 -0
- package/build/testing/index.d.ts +18 -0
- package/build/testing/index.js +17 -0
- package/build/testing/types.d.ts +39 -0
- package/build/testing/types.js +1 -0
- package/package.json +72 -2
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GENERATED FILE — DO NOT EDIT.
|
|
3
|
+
*
|
|
4
|
+
* Source: https://docs-cdn.narrative.io/api-reference/main/openapi.json
|
|
5
|
+
* Spec etag: W/"2579229b75ddefef951659560f71d465"
|
|
6
|
+
*
|
|
7
|
+
* Regenerate with: bun run generate:api-types
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* This file was auto-generated by openapi-typescript.
|
|
11
|
+
* Do not make direct changes to the file.
|
|
12
|
+
*/
|
|
13
|
+
export {};
|
|
@@ -6,7 +6,10 @@ import type { CreateMcpConnectionRequest, ListMcpConnectionsResponse, McpConnect
|
|
|
6
6
|
* can reference it by id via `mcp_servers[].connection_id`. Tokens are never returned by the API.
|
|
7
7
|
*
|
|
8
8
|
* The OAuth callback (`GET /mcp-connections/callback`) is a browser redirect, not an SDK call, so
|
|
9
|
-
* it is intentionally not wrapped here.
|
|
9
|
+
* it is intentionally not wrapped here. It only stores the authorization code and redirects; the
|
|
10
|
+
* app then calls {@link McpConnectionsApi.completeMcpConnection} to finish, authenticated as the
|
|
11
|
+
* user who began the flow. Because the callback is public, it is not allowed to complete anything
|
|
12
|
+
* itself — otherwise a `state` alone could turn another user's consent into a stored token.
|
|
10
13
|
*/
|
|
11
14
|
export declare class McpConnectionsApi extends BaseApi {
|
|
12
15
|
/**
|
|
@@ -21,6 +24,20 @@ export declare class McpConnectionsApi extends BaseApi {
|
|
|
21
24
|
* `authorization_url` the user must visit to consent.
|
|
22
25
|
*/
|
|
23
26
|
createMcpConnection(request: CreateMcpConnectionRequest): Promise<McpConnectionCreatedResponse>;
|
|
27
|
+
/**
|
|
28
|
+
* Completes a connection begun with {@link McpConnectionsApi.createMcpConnection}, once the user
|
|
29
|
+
* has consented and the OAuth callback has stored the authorization code. Exchanges that code and
|
|
30
|
+
* validates the connection with a `tools/list` call before storing the tokens.
|
|
31
|
+
*
|
|
32
|
+
* Must be called with the credentials of the user who began the flow — the `state` on its own is
|
|
33
|
+
* not enough.
|
|
34
|
+
* @param {string} state - The one-time `state` the OAuth callback forwarded to the app.
|
|
35
|
+
* @returns {Promise<McpConnectionSummary>} The connection's status view, normally `connected`.
|
|
36
|
+
* Rejects with 404 if the connection does not exist or belongs to another user; 400 if the
|
|
37
|
+
* `state` is unknown or expired, the authorization code has not arrived yet, or the token
|
|
38
|
+
* exchange or validation failed.
|
|
39
|
+
*/
|
|
40
|
+
completeMcpConnection(state: string): Promise<McpConnectionSummary>;
|
|
24
41
|
/**
|
|
25
42
|
* Fetches one of the calling user's connections.
|
|
26
43
|
* @param {string} connectionId - The connection id.
|
|
@@ -6,7 +6,10 @@ const resourceName = "mcp-connections";
|
|
|
6
6
|
* can reference it by id via `mcp_servers[].connection_id`. Tokens are never returned by the API.
|
|
7
7
|
*
|
|
8
8
|
* The OAuth callback (`GET /mcp-connections/callback`) is a browser redirect, not an SDK call, so
|
|
9
|
-
* it is intentionally not wrapped here.
|
|
9
|
+
* it is intentionally not wrapped here. It only stores the authorization code and redirects; the
|
|
10
|
+
* app then calls {@link McpConnectionsApi.completeMcpConnection} to finish, authenticated as the
|
|
11
|
+
* user who began the flow. Because the callback is public, it is not allowed to complete anything
|
|
12
|
+
* itself — otherwise a `state` alone could turn another user's consent into a stored token.
|
|
10
13
|
*/
|
|
11
14
|
export class McpConnectionsApi extends BaseApi {
|
|
12
15
|
/**
|
|
@@ -25,6 +28,22 @@ export class McpConnectionsApi extends BaseApi {
|
|
|
25
28
|
async createMcpConnection(request) {
|
|
26
29
|
return await this.post(resourceName, request);
|
|
27
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Completes a connection begun with {@link McpConnectionsApi.createMcpConnection}, once the user
|
|
33
|
+
* has consented and the OAuth callback has stored the authorization code. Exchanges that code and
|
|
34
|
+
* validates the connection with a `tools/list` call before storing the tokens.
|
|
35
|
+
*
|
|
36
|
+
* Must be called with the credentials of the user who began the flow — the `state` on its own is
|
|
37
|
+
* not enough.
|
|
38
|
+
* @param {string} state - The one-time `state` the OAuth callback forwarded to the app.
|
|
39
|
+
* @returns {Promise<McpConnectionSummary>} The connection's status view, normally `connected`.
|
|
40
|
+
* Rejects with 404 if the connection does not exist or belongs to another user; 400 if the
|
|
41
|
+
* `state` is unknown or expired, the authorization code has not arrived yet, or the token
|
|
42
|
+
* exchange or validation failed.
|
|
43
|
+
*/
|
|
44
|
+
async completeMcpConnection(state) {
|
|
45
|
+
return await this.post(`${resourceName}/complete`, { state });
|
|
46
|
+
}
|
|
28
47
|
/**
|
|
29
48
|
* Fetches one of the calling user's connections.
|
|
30
49
|
* @param {string} connectionId - The connection id.
|
|
@@ -7,6 +7,9 @@ export interface McpConnectionCreatedResponse {
|
|
|
7
7
|
connection_id: string;
|
|
8
8
|
authorization_url: string;
|
|
9
9
|
}
|
|
10
|
+
export interface CompleteMcpConnectionRequest {
|
|
11
|
+
state: string;
|
|
12
|
+
}
|
|
10
13
|
export interface McpConnectionSummary {
|
|
11
14
|
connection_id: string;
|
|
12
15
|
server_url: string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AuthGuard, AuthGuardContext } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Returns the 401 to send back, or undefined when the request may proceed.
|
|
4
|
+
*
|
|
5
|
+
* The response is built here rather than through openapi-msw's typed `response`
|
|
6
|
+
* helper because none of the covered paths declare a 401 in the spec.
|
|
7
|
+
*/
|
|
8
|
+
export declare function rejectUnauthenticated(guard: AuthGuard, context: AuthGuardContext): Response | undefined;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { HttpResponse } from "msw";
|
|
2
|
+
const BEARER_PREFIX = /^Bearer\s+/i;
|
|
3
|
+
function isAuthenticated(guard, context) {
|
|
4
|
+
if (typeof guard === "function") {
|
|
5
|
+
return guard(context);
|
|
6
|
+
}
|
|
7
|
+
if (guard.type === "bearer") {
|
|
8
|
+
const header = context.request.headers.get("Authorization");
|
|
9
|
+
if (header == null || !BEARER_PREFIX.test(header)) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
const token = header.replace(BEARER_PREFIX, "");
|
|
13
|
+
return guard.token == null ? token.length > 0 : token === guard.token;
|
|
14
|
+
}
|
|
15
|
+
const cookie = context.cookies[guard.name];
|
|
16
|
+
if (cookie == null) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
return guard.value == null ? cookie.length > 0 : cookie === guard.value;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Returns the 401 to send back, or undefined when the request may proceed.
|
|
23
|
+
*
|
|
24
|
+
* The response is built here rather than through openapi-msw's typed `response`
|
|
25
|
+
* helper because none of the covered paths declare a 401 in the spec.
|
|
26
|
+
*/
|
|
27
|
+
export function rejectUnauthenticated(guard, context) {
|
|
28
|
+
if (guard === false || isAuthenticated(guard, context)) {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
return HttpResponse.json({ message: "Unauthorized" }, { status: 401 });
|
|
32
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DataPlaneOwnedResponse, JobResponse } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* An owned, active data plane. Every field the spec requires is filled in, so a
|
|
4
|
+
* caller only overrides what its assertion is about.
|
|
5
|
+
*/
|
|
6
|
+
export declare function createDataPlane(overrides?: Partial<DataPlaneOwnedResponse>): DataPlaneOwnedResponse;
|
|
7
|
+
/** The job a health check enqueues, pending and not yet attempted. */
|
|
8
|
+
export declare function createHealthCheckJob(overrides?: Partial<JobResponse>): JobResponse;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const TIMESTAMP = "2026-01-01T00:00:00Z";
|
|
2
|
+
/**
|
|
3
|
+
* An owned, active data plane. Every field the spec requires is filled in, so a
|
|
4
|
+
* caller only overrides what its assertion is about.
|
|
5
|
+
*/
|
|
6
|
+
export function createDataPlane(overrides = {}) {
|
|
7
|
+
return {
|
|
8
|
+
type: "owned",
|
|
9
|
+
id: "5f9d1a4e-0000-4000-8000-000000000001",
|
|
10
|
+
company_id: 1,
|
|
11
|
+
created_at: TIMESTAMP,
|
|
12
|
+
display_name: "Test Data Plane",
|
|
13
|
+
external_id: "test-data-plane",
|
|
14
|
+
platform: { type: "platform_aws", region: "us-east-1" },
|
|
15
|
+
status: "active",
|
|
16
|
+
updated_at: TIMESTAMP,
|
|
17
|
+
collaborators: {
|
|
18
|
+
participants: { type: "none" },
|
|
19
|
+
manage_compute_pools: { type: "none" },
|
|
20
|
+
},
|
|
21
|
+
...overrides,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/** The job a health check enqueues, pending and not yet attempted. */
|
|
25
|
+
export function createHealthCheckJob(overrides = {}) {
|
|
26
|
+
return {
|
|
27
|
+
job_id: "5f9d1a4e-0000-4000-8000-00000000000a",
|
|
28
|
+
data_plane_id: "5f9d1a4e-0000-4000-8000-000000000001",
|
|
29
|
+
request_source: { type: "api_user", company_id: 1, user_id: 1 },
|
|
30
|
+
state: "pending",
|
|
31
|
+
type: "data-plane-health-check",
|
|
32
|
+
input: {},
|
|
33
|
+
executor: "job-executor-test",
|
|
34
|
+
execution_cluster: "dedicated",
|
|
35
|
+
failures: [],
|
|
36
|
+
idempotency_key: "test-idempotency-key",
|
|
37
|
+
result: {},
|
|
38
|
+
created_at: TIMESTAMP,
|
|
39
|
+
updated_at: TIMESTAMP,
|
|
40
|
+
attempted_at: TIMESTAMP,
|
|
41
|
+
attempt_version: 1,
|
|
42
|
+
ended_at: TIMESTAMP,
|
|
43
|
+
...overrides,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createDataPlane, createHealthCheckJob } from "./data-planes";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createDataPlane, createHealthCheckJob } from "./data-planes";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { HttpHandler } from "msw";
|
|
2
|
+
import type { AuthGuard, DataPlaneResponse } from "../types";
|
|
3
|
+
import type { OpenApiHttp } from "./openapi-http";
|
|
4
|
+
export declare function createDataPlaneHandlers(http: OpenApiHttp, auth: AuthGuard, seed?: DataPlaneResponse[]): HttpHandler[];
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { rejectUnauthenticated } from "../auth";
|
|
2
|
+
import { createDataPlane, createHealthCheckJob } from "../fixtures/data-planes";
|
|
3
|
+
/**
|
|
4
|
+
* Records live for the lifetime of one `createHandlers()` call, so each test
|
|
5
|
+
* suite gets its own copy and writes from one test can't leak into another.
|
|
6
|
+
*/
|
|
7
|
+
function createStore(seed) {
|
|
8
|
+
const records = seed.map((record) => ({ ...record }));
|
|
9
|
+
return {
|
|
10
|
+
list: () => records,
|
|
11
|
+
find: (id) => records.find((record) => record.id === id),
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
/** The default-compute-pool endpoints exist only for data planes we own. */
|
|
15
|
+
function findOwned(store, id) {
|
|
16
|
+
const record = store.find(id);
|
|
17
|
+
return record?.type === "owned" ? record : undefined;
|
|
18
|
+
}
|
|
19
|
+
export function createDataPlaneHandlers(http, auth, seed = [createDataPlane()]) {
|
|
20
|
+
const store = createStore(seed);
|
|
21
|
+
return [
|
|
22
|
+
http.get("/data-planes", ({ request, cookies, response }) => {
|
|
23
|
+
const unauthorized = rejectUnauthenticated(auth, { request, cookies });
|
|
24
|
+
if (unauthorized)
|
|
25
|
+
return response.untyped(unauthorized);
|
|
26
|
+
return response(200).json({ records: store.list() });
|
|
27
|
+
}),
|
|
28
|
+
http.get("/data-planes/{data_plane_id}", ({ params, request, cookies, response }) => {
|
|
29
|
+
const unauthorized = rejectUnauthenticated(auth, { request, cookies });
|
|
30
|
+
if (unauthorized)
|
|
31
|
+
return response.untyped(unauthorized);
|
|
32
|
+
const record = store.find(params.data_plane_id);
|
|
33
|
+
return record ? response(200).json(record) : response(404).empty();
|
|
34
|
+
}),
|
|
35
|
+
http.put("/data-planes/{data_plane_id}/default-compute-pool/{compute_pool_id}", ({ params, request, cookies, response }) => {
|
|
36
|
+
const unauthorized = rejectUnauthenticated(auth, { request, cookies });
|
|
37
|
+
if (unauthorized)
|
|
38
|
+
return response.untyped(unauthorized);
|
|
39
|
+
const record = findOwned(store, params.data_plane_id);
|
|
40
|
+
if (!record)
|
|
41
|
+
return response(404).empty();
|
|
42
|
+
record.default_compute_pool_id = params.compute_pool_id;
|
|
43
|
+
return response(200).json(record);
|
|
44
|
+
}),
|
|
45
|
+
http.delete("/data-planes/{data_plane_id}/default-compute-pool", ({ params, request, cookies, response }) => {
|
|
46
|
+
const unauthorized = rejectUnauthenticated(auth, { request, cookies });
|
|
47
|
+
if (unauthorized)
|
|
48
|
+
return response.untyped(unauthorized);
|
|
49
|
+
const record = findOwned(store, params.data_plane_id);
|
|
50
|
+
if (!record)
|
|
51
|
+
return response(404).empty();
|
|
52
|
+
record.default_compute_pool_id = undefined;
|
|
53
|
+
return response(200).json(record);
|
|
54
|
+
}),
|
|
55
|
+
http.post("/data-planes/{data_plane_id}/health-check", async ({ params, request, cookies, response }) => {
|
|
56
|
+
const unauthorized = rejectUnauthenticated(auth, { request, cookies });
|
|
57
|
+
if (unauthorized)
|
|
58
|
+
return response.untyped(unauthorized);
|
|
59
|
+
const record = store.find(params.data_plane_id);
|
|
60
|
+
if (!record)
|
|
61
|
+
return response(404).empty();
|
|
62
|
+
const body = await request.json();
|
|
63
|
+
return response(201).json(createHealthCheckJob({
|
|
64
|
+
data_plane_id: params.data_plane_id,
|
|
65
|
+
compute_pool_id: body?.compute_pool_id,
|
|
66
|
+
}));
|
|
67
|
+
}),
|
|
68
|
+
];
|
|
69
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { HttpHandler } from "msw";
|
|
2
|
+
import type { CreateHandlersOptions } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* Builds the request handlers for a mock Narrative API.
|
|
5
|
+
*
|
|
6
|
+
* Pass the result to msw's `setupServer` in tests or `setupWorker` in a browser
|
|
7
|
+
* dev mode. Each call gets its own record store, so handlers from one suite
|
|
8
|
+
* never see another's writes.
|
|
9
|
+
*/
|
|
10
|
+
export declare function createHandlers(options?: CreateHandlersOptions): HttpHandler[];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createDataPlaneHandlers } from "./data-planes";
|
|
2
|
+
import { createHttp } from "./openapi-http";
|
|
3
|
+
/** Matches `BaseApi`'s default environment, so the common case needs no options. */
|
|
4
|
+
const DEFAULT_BASE_URL = "https://api.narrative.io";
|
|
5
|
+
/**
|
|
6
|
+
* Builds the request handlers for a mock Narrative API.
|
|
7
|
+
*
|
|
8
|
+
* Pass the result to msw's `setupServer` in tests or `setupWorker` in a browser
|
|
9
|
+
* dev mode. Each call gets its own record store, so handlers from one suite
|
|
10
|
+
* never see another's writes.
|
|
11
|
+
*/
|
|
12
|
+
export function createHandlers(options = {}) {
|
|
13
|
+
const { baseUrl = DEFAULT_BASE_URL, auth = false, dataPlanes } = options;
|
|
14
|
+
const http = createHttp(baseUrl);
|
|
15
|
+
return [...createDataPlaneHandlers(http, auth, dataPlanes)];
|
|
16
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createOpenApiHttp } from "openapi-msw";
|
|
2
|
+
import type { paths } from "../../generated/api-types";
|
|
3
|
+
/** The openapi-msw builder, bound to the generated spec. */
|
|
4
|
+
export type OpenApiHttp = ReturnType<typeof createOpenApiHttp<paths>>;
|
|
5
|
+
/**
|
|
6
|
+
* openapi-msw joins `baseUrl` to a path that already starts with a slash, so a
|
|
7
|
+
* trailing slash produces a double slash and every handler quietly stops
|
|
8
|
+
* matching. `BaseApi#getBaseUrl` returns one, which makes this worth guarding.
|
|
9
|
+
*/
|
|
10
|
+
export declare function createHttp(baseUrl: string): OpenApiHttp;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createOpenApiHttp } from "openapi-msw";
|
|
2
|
+
/**
|
|
3
|
+
* openapi-msw joins `baseUrl` to a path that already starts with a slash, so a
|
|
4
|
+
* trailing slash produces a double slash and every handler quietly stops
|
|
5
|
+
* matching. `BaseApi#getBaseUrl` returns one, which makes this worth guarding.
|
|
6
|
+
*/
|
|
7
|
+
export function createHttp(baseUrl) {
|
|
8
|
+
return createOpenApiHttp({ baseUrl: baseUrl.replace(/\/+$/, "") });
|
|
9
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed MSW handlers for the Narrative API, generated against the same OpenAPI
|
|
3
|
+
* spec the client is checked against.
|
|
4
|
+
*
|
|
5
|
+
* Requires `msw` and `openapi-msw`, which are optional peer dependencies —
|
|
6
|
+
* install them to use this entry point.
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { setupServer } from "msw/node";
|
|
10
|
+
* import { createHandlers, createDataPlane } from "@narrative.io/data-collaboration-sdk-ts/testing";
|
|
11
|
+
*
|
|
12
|
+
* const server = setupServer(...createHandlers({ dataPlanes: [createDataPlane()] }));
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export { createDataPlane, createHealthCheckJob } from "./fixtures";
|
|
16
|
+
export { createHandlers } from "./handlers";
|
|
17
|
+
export { createDataPlaneHandlers } from "./handlers/data-planes";
|
|
18
|
+
export type { AuthGuard, AuthGuardContext, CreateHandlersOptions, DataPlaneOwnedResponse, DataPlaneResponse, JobResponse, } from "./types";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed MSW handlers for the Narrative API, generated against the same OpenAPI
|
|
3
|
+
* spec the client is checked against.
|
|
4
|
+
*
|
|
5
|
+
* Requires `msw` and `openapi-msw`, which are optional peer dependencies —
|
|
6
|
+
* install them to use this entry point.
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { setupServer } from "msw/node";
|
|
10
|
+
* import { createHandlers, createDataPlane } from "@narrative.io/data-collaboration-sdk-ts/testing";
|
|
11
|
+
*
|
|
12
|
+
* const server = setupServer(...createHandlers({ dataPlanes: [createDataPlane()] }));
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export { createDataPlane, createHealthCheckJob } from "./fixtures";
|
|
16
|
+
export { createHandlers } from "./handlers";
|
|
17
|
+
export { createDataPlaneHandlers } from "./handlers/data-planes";
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { components } from "../generated/api-types";
|
|
2
|
+
/** A data plane as the API returns it, owned or shared. */
|
|
3
|
+
export type DataPlaneResponse = components["schemas"]["DataPlaneResponse"];
|
|
4
|
+
/** A data plane this company owns. Only owned planes have a default compute pool. */
|
|
5
|
+
export type DataPlaneOwnedResponse = components["schemas"]["DataPlaneOwnedResponse"];
|
|
6
|
+
/** A job as the API returns it, including the one a health check enqueues. */
|
|
7
|
+
export type JobResponse = components["schemas"]["JobResponse"];
|
|
8
|
+
export interface AuthGuardContext {
|
|
9
|
+
request: Request;
|
|
10
|
+
/** Cookies msw parsed off the request. */
|
|
11
|
+
cookies: Record<string, string>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* How handlers decide whether a request is authenticated.
|
|
15
|
+
*
|
|
16
|
+
* `false` accepts everything, which is what SDK tests want. A bearer or cookie
|
|
17
|
+
* guard omitting its `token`/`value` accepts any non-empty credential, so a
|
|
18
|
+
* test can assert that the client sends one without pinning its value.
|
|
19
|
+
*/
|
|
20
|
+
export type AuthGuard = false | {
|
|
21
|
+
type: "bearer";
|
|
22
|
+
token?: string;
|
|
23
|
+
} | {
|
|
24
|
+
type: "cookie";
|
|
25
|
+
name: string;
|
|
26
|
+
value?: string;
|
|
27
|
+
} | ((context: AuthGuardContext) => boolean);
|
|
28
|
+
export interface CreateHandlersOptions {
|
|
29
|
+
/**
|
|
30
|
+
* Origin the handlers match against, without a trailing slash. Note that
|
|
31
|
+
* `BaseApi#getBaseUrl` returns one with a trailing slash, so pass the origin
|
|
32
|
+
* rather than that value — or let this default, which matches the client's
|
|
33
|
+
* own default environment.
|
|
34
|
+
*/
|
|
35
|
+
baseUrl?: string;
|
|
36
|
+
auth?: AuthGuard;
|
|
37
|
+
/** Seeds the in-memory data planes the handlers read and write. */
|
|
38
|
+
dataPlanes?: DataPlaneResponse[];
|
|
39
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,22 +1,77 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@narrative.io/data-collaboration-sdk-ts",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.0",
|
|
4
4
|
"main": "build/index.js",
|
|
5
5
|
"repository": "github:narrative-io/data-collaboration-sdk-ts",
|
|
6
6
|
"source": "src/index.ts",
|
|
7
7
|
"types": "build/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./build/index.d.ts",
|
|
11
|
+
"default": "./build/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./testing": {
|
|
14
|
+
"types": "./build/testing/index.d.ts",
|
|
15
|
+
"default": "./build/testing/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./build/access-rules": "./build/access-rules/index.js",
|
|
18
|
+
"./build/access-tokens": "./build/access-tokens/index.js",
|
|
19
|
+
"./build/agents": "./build/agents/index.js",
|
|
20
|
+
"./build/apps": "./build/apps/index.js",
|
|
21
|
+
"./build/attributes": "./build/attributes/index.js",
|
|
22
|
+
"./build/authentication": "./build/authentication/index.js",
|
|
23
|
+
"./build/collaboration-policy": "./build/collaboration-policy/index.js",
|
|
24
|
+
"./build/companies": "./build/companies/index.js",
|
|
25
|
+
"./build/company-info": "./build/company-info/index.js",
|
|
26
|
+
"./build/compute-pools": "./build/compute-pools/index.js",
|
|
27
|
+
"./build/connections": "./build/connections/index.js",
|
|
28
|
+
"./build/contracts": "./build/contracts/index.js",
|
|
29
|
+
"./build/data-planes": "./build/data-planes/index.js",
|
|
30
|
+
"./build/data-streams": "./build/data-streams/index.js",
|
|
31
|
+
"./build/datasets": "./build/datasets/index.js",
|
|
32
|
+
"./build/encryption-materials": "./build/encryption-materials/index.js",
|
|
33
|
+
"./build/forecast": "./build/forecast/index.js",
|
|
34
|
+
"./build/health": "./build/health/index.js",
|
|
35
|
+
"./build/installations": "./build/installations/index.js",
|
|
36
|
+
"./build/jobs": "./build/jobs/index.js",
|
|
37
|
+
"./build/json-big-number": "./build/json-big-number/index.js",
|
|
38
|
+
"./build/mappings": "./build/mappings/index.js",
|
|
39
|
+
"./build/mcp-connections": "./build/mcp-connections/index.js",
|
|
40
|
+
"./build/model-inference": "./build/model-inference/index.js",
|
|
41
|
+
"./build/model-training": "./build/model-training/index.js",
|
|
42
|
+
"./build/models": "./build/models/index.js",
|
|
43
|
+
"./build/nql": "./build/nql/index.js",
|
|
44
|
+
"./build/ping": "./build/ping/index.js",
|
|
45
|
+
"./build/products": "./build/products/index.js",
|
|
46
|
+
"./build/queries": "./build/queries/index.js",
|
|
47
|
+
"./build/resources": "./build/resources/index.js",
|
|
48
|
+
"./build/rosetta-stone": "./build/rosetta-stone/index.js",
|
|
49
|
+
"./build/subscriptions": "./build/subscriptions/index.js",
|
|
50
|
+
"./build/testing": "./build/testing/index.js",
|
|
51
|
+
"./build/uploads": "./build/uploads/index.js",
|
|
52
|
+
"./build/views": "./build/views/index.js",
|
|
53
|
+
"./build/whoami": "./build/whoami/index.js",
|
|
54
|
+
"./build/workflows": "./build/workflows/index.js",
|
|
55
|
+
"./build/*": [
|
|
56
|
+
"./build/*.js",
|
|
57
|
+
"./build/*/index.js",
|
|
58
|
+
"./build/*"
|
|
59
|
+
],
|
|
60
|
+
"./package.json": "./package.json"
|
|
61
|
+
},
|
|
8
62
|
"description": "",
|
|
9
63
|
"packageManager": "bun@1.2.21",
|
|
10
64
|
"scripts": {
|
|
11
65
|
"build": "tsc",
|
|
12
66
|
"lint": "bunx @biomejs/biome check --write ./src",
|
|
13
67
|
"prepare": "bunx @biomejs/biome check --write ./src && bun run build",
|
|
14
|
-
"prepublishOnly": "bun run test && bun run lint",
|
|
68
|
+
"prepublishOnly": "bun run test && bun run lint && bun run check:built",
|
|
15
69
|
"preversion": "bun run lint",
|
|
16
70
|
"version": "bun run && git add -A src",
|
|
17
71
|
"postversion": "git push && git push --tags",
|
|
18
72
|
"test": "jest --coverage",
|
|
19
73
|
"dev": "tsc -w",
|
|
74
|
+
"generate:api-types": "bun scripts/generate-api-types.ts",
|
|
20
75
|
"check:built": "node scripts/ensureBuild.js",
|
|
21
76
|
"link:global": "bun run check:built && bun link",
|
|
22
77
|
"pack:dist": "bun run check:built && bun pm pack",
|
|
@@ -38,6 +93,9 @@
|
|
|
38
93
|
"babel-jest": "30.4.1",
|
|
39
94
|
"jest": "30.4.2",
|
|
40
95
|
"lefthook": "2.1.10",
|
|
96
|
+
"msw": "2.15.0",
|
|
97
|
+
"openapi-msw": "2.0.0",
|
|
98
|
+
"openapi-typescript": "7.13.0",
|
|
41
99
|
"ts-jest": "29.4.12",
|
|
42
100
|
"typescript": "6.0.0-dev.20260416"
|
|
43
101
|
},
|
|
@@ -45,6 +103,18 @@
|
|
|
45
103
|
"zod": "4.4.3",
|
|
46
104
|
"bignumber.js": "11.1.5"
|
|
47
105
|
},
|
|
106
|
+
"peerDependencies": {
|
|
107
|
+
"msw": "^2.10.5",
|
|
108
|
+
"openapi-msw": "^2.0.0"
|
|
109
|
+
},
|
|
110
|
+
"peerDependenciesMeta": {
|
|
111
|
+
"msw": {
|
|
112
|
+
"optional": true
|
|
113
|
+
},
|
|
114
|
+
"openapi-msw": {
|
|
115
|
+
"optional": true
|
|
116
|
+
}
|
|
117
|
+
},
|
|
48
118
|
"overrides": {
|
|
49
119
|
"semver@<7.5.2": "7.5.2"
|
|
50
120
|
},
|