@narrative.io/data-collaboration-sdk-ts 4.3.1 → 4.4.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.
@@ -1,10 +1,25 @@
1
- import type { DataPlaneOwnedResponse, JobResponse } from "../types";
1
+ import type { DataPlaneOwnedResponse, DataPlaneSharedResponse, JobResponse } from "../types";
2
2
  /**
3
3
  * An owned, active data plane. Every field the spec requires is filled in, so a
4
4
  * caller only overrides what its assertion is about. The optional fields are
5
5
  * present and `null`, which is what the API sends for an absent value — a mock
6
6
  * that omitted them would let a consumer assert `undefined` and still pass.
7
7
  */
8
- export declare function createDataPlane(overrides?: Partial<DataPlaneOwnedResponse>): DataPlaneOwnedResponse;
8
+ export declare function createOwnedDataPlane(overrides?: Partial<DataPlaneOwnedResponse>): DataPlaneOwnedResponse;
9
+ /**
10
+ * A data plane shared with the calling company, active, on AWS. Shared planes
11
+ * belong to someone else, so this one carries a different `company_id` and id
12
+ * than {@link createOwnedDataPlane} — seeding both gives you two records.
13
+ *
14
+ * Optional fields are present and `null` for the same reason as on the owned
15
+ * factory. For the other platform the API serves, override it:
16
+ *
17
+ * ```ts
18
+ * createSharedDataPlane({
19
+ * platform: { type: "platform_shared_snowflake", region: null },
20
+ * });
21
+ * ```
22
+ */
23
+ export declare function createSharedDataPlane(overrides?: Partial<DataPlaneSharedResponse>): DataPlaneSharedResponse;
9
24
  /** The job a health check enqueues, pending and not yet attempted. */
10
25
  export declare function createHealthCheckJob(overrides?: Partial<JobResponse>): JobResponse;
@@ -5,7 +5,7 @@ const TIMESTAMP = "2026-01-01T00:00:00Z";
5
5
  * present and `null`, which is what the API sends for an absent value — a mock
6
6
  * that omitted them would let a consumer assert `undefined` and still pass.
7
7
  */
8
- export function createDataPlane(overrides = {}) {
8
+ export function createOwnedDataPlane(overrides = {}) {
9
9
  return {
10
10
  type: "owned",
11
11
  id: "5f9d1a4e-0000-4000-8000-000000000001",
@@ -32,6 +32,41 @@ export function createDataPlane(overrides = {}) {
32
32
  ...overrides,
33
33
  };
34
34
  }
35
+ /**
36
+ * A data plane shared with the calling company, active, on AWS. Shared planes
37
+ * belong to someone else, so this one carries a different `company_id` and id
38
+ * than {@link createOwnedDataPlane} — seeding both gives you two records.
39
+ *
40
+ * Optional fields are present and `null` for the same reason as on the owned
41
+ * factory. For the other platform the API serves, override it:
42
+ *
43
+ * ```ts
44
+ * createSharedDataPlane({
45
+ * platform: { type: "platform_shared_snowflake", region: null },
46
+ * });
47
+ * ```
48
+ */
49
+ export function createSharedDataPlane(overrides = {}) {
50
+ return {
51
+ type: "shared",
52
+ id: "5f9d1a4e-0000-4000-8000-000000000002",
53
+ company_id: 2,
54
+ created_at: TIMESTAMP,
55
+ display_name: "Test Shared Data Plane",
56
+ platform: {
57
+ type: "platform_shared_aws",
58
+ region: { type: "region_aws", id: "us-east-1" },
59
+ },
60
+ status: "active",
61
+ updated_at: TIMESTAMP,
62
+ compute_pools: [],
63
+ description: null,
64
+ tags: null,
65
+ last_heartbeat_at: null,
66
+ default_compute_pool_id: null,
67
+ ...overrides,
68
+ };
69
+ }
35
70
  /** The job a health check enqueues, pending and not yet attempted. */
36
71
  export function createHealthCheckJob(overrides = {}) {
37
72
  return {
@@ -1 +1 @@
1
- export { createDataPlane, createHealthCheckJob } from "./data-planes";
1
+ export { createHealthCheckJob, createOwnedDataPlane, createSharedDataPlane, } from "./data-planes";
@@ -1 +1 @@
1
- export { createDataPlane, createHealthCheckJob } from "./data-planes";
1
+ export { createHealthCheckJob, createOwnedDataPlane, createSharedDataPlane, } from "./data-planes";
@@ -1,5 +1,5 @@
1
1
  import { rejectUnauthenticated } from "../auth";
2
- import { createDataPlane, createHealthCheckJob } from "../fixtures/data-planes";
2
+ import { createHealthCheckJob, createOwnedDataPlane, } from "../fixtures/data-planes";
3
3
  /**
4
4
  * Records live for the lifetime of one `createHandlers()` call, so each test
5
5
  * suite gets its own copy and writes from one test can't leak into another.
@@ -16,7 +16,7 @@ function findOwned(store, id) {
16
16
  const record = store.find(id);
17
17
  return record?.type === "owned" ? record : undefined;
18
18
  }
19
- export function createDataPlaneHandlers(http, auth, seed = [createDataPlane()]) {
19
+ export function createDataPlaneHandlers(http, auth, seed = [createOwnedDataPlane()]) {
20
20
  const store = createStore(seed);
21
21
  return [
22
22
  http.get("/data-planes", ({ request, cookies, response }) => {
@@ -49,7 +49,9 @@ export function createDataPlaneHandlers(http, auth, seed = [createDataPlane()])
49
49
  const record = findOwned(store, params.data_plane_id);
50
50
  if (!record)
51
51
  return response(404).empty();
52
- record.default_compute_pool_id = undefined;
52
+ // null, not undefined: the encoder emits the key with an explicit
53
+ // null, and JSON.stringify would drop an undefined one entirely.
54
+ record.default_compute_pool_id = null;
53
55
  return response(200).json(record);
54
56
  }),
55
57
  http.post("/data-planes/{data_plane_id}/health-check", async ({ params, request, cookies, response }) => {
@@ -7,12 +7,20 @@
7
7
  *
8
8
  * ```ts
9
9
  * import { setupServer } from "msw/node";
10
- * import { createHandlers, createDataPlane } from "@narrative.io/data-collaboration-sdk-ts/testing";
10
+ * import {
11
+ * createHandlers,
12
+ * createOwnedDataPlane,
13
+ * createSharedDataPlane,
14
+ * } from "@narrative.io/data-collaboration-sdk-ts/testing";
11
15
  *
12
- * const server = setupServer(...createHandlers({ dataPlanes: [createDataPlane()] }));
16
+ * const server = setupServer(
17
+ * ...createHandlers({
18
+ * dataPlanes: [createOwnedDataPlane(), createSharedDataPlane()],
19
+ * }),
20
+ * );
13
21
  * ```
14
22
  */
15
- export { createDataPlane, createHealthCheckJob } from "./fixtures";
23
+ export { createHealthCheckJob, createOwnedDataPlane, createSharedDataPlane, } from "./fixtures";
16
24
  export { createHandlers } from "./handlers";
17
25
  export { createDataPlaneHandlers } from "./handlers/data-planes";
18
- export type { AuthGuard, AuthGuardContext, CreateHandlersOptions, DataPlaneOwnedResponse, DataPlaneResponse, JobResponse, } from "./types";
26
+ export type { AuthGuard, AuthGuardContext, CreateHandlersOptions, DataPlaneOwnedResponse, DataPlanePlatform, DataPlaneResponse, DataPlaneSharedPlatform, DataPlaneSharedResponse, JobResponse, } from "./types";
@@ -7,11 +7,19 @@
7
7
  *
8
8
  * ```ts
9
9
  * import { setupServer } from "msw/node";
10
- * import { createHandlers, createDataPlane } from "@narrative.io/data-collaboration-sdk-ts/testing";
10
+ * import {
11
+ * createHandlers,
12
+ * createOwnedDataPlane,
13
+ * createSharedDataPlane,
14
+ * } from "@narrative.io/data-collaboration-sdk-ts/testing";
11
15
  *
12
- * const server = setupServer(...createHandlers({ dataPlanes: [createDataPlane()] }));
16
+ * const server = setupServer(
17
+ * ...createHandlers({
18
+ * dataPlanes: [createOwnedDataPlane(), createSharedDataPlane()],
19
+ * }),
20
+ * );
13
21
  * ```
14
22
  */
15
- export { createDataPlane, createHealthCheckJob } from "./fixtures";
23
+ export { createHealthCheckJob, createOwnedDataPlane, createSharedDataPlane, } from "./fixtures";
16
24
  export { createHandlers } from "./handlers";
17
25
  export { createDataPlaneHandlers } from "./handlers/data-planes";
@@ -1,8 +1,34 @@
1
1
  import type { components } from "../generated/api-types";
2
2
  /** A data plane as the API returns it, owned or shared. */
3
3
  export type DataPlaneResponse = components["schemas"]["DataPlaneResponse"];
4
- /** A data plane this company owns. Only owned planes have a default compute pool. */
4
+ /**
5
+ * A data plane this company owns. Only owned planes carry an external id and
6
+ * collaborators, and only they accept the default-compute-pool endpoints.
7
+ */
5
8
  export type DataPlaneOwnedResponse = components["schemas"]["DataPlaneOwnedResponse"];
9
+ /**
10
+ * A data plane shared with this company. Same shape as the owned variant minus
11
+ * `external_id` and `collaborators`, and its platform is one of the
12
+ * `platform_shared_*` types rather than the owned ones.
13
+ */
14
+ export type DataPlaneSharedResponse = components["schemas"]["DataPlaneSharedResponse"];
15
+ /**
16
+ * The platform an owned data plane runs on — AWS or Snowflake.
17
+ *
18
+ * Both factories default to AWS, so a test that needs another variant passes
19
+ * this as a `platform` override. Named after the root entry point's
20
+ * `DataPlanePlatform` rather than the generated schema's bare `Platform`, so
21
+ * the two entry points read the same way — the two are assignable in both
22
+ * directions.
23
+ */
24
+ export type DataPlanePlatform = components["schemas"]["Platform"];
25
+ /**
26
+ * The platform a shared data plane runs on. Distinct from
27
+ * {@link DataPlanePlatform}: the discriminators are the `platform_shared_*`
28
+ * ones, and `region` is required on the AWS variant but optional and nullable
29
+ * on the Snowflake one.
30
+ */
31
+ export type DataPlaneSharedPlatform = components["schemas"]["PlatformSharedResponse"];
6
32
  /** A job as the API returns it, including the one a health check enqueues. */
7
33
  export type JobResponse = components["schemas"]["JobResponse"];
8
34
  export interface AuthGuardContext {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@narrative.io/data-collaboration-sdk-ts",
3
- "version": "4.3.1",
3
+ "version": "4.4.0",
4
4
  "main": "build/index.js",
5
5
  "repository": "github:narrative-io/data-collaboration-sdk-ts",
6
6
  "source": "src/index.ts",