@narrative.io/data-collaboration-sdk-ts 4.4.0 → 4.5.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.
Files changed (38) hide show
  1. package/build/base-api.d.ts +11 -0
  2. package/build/base-api.js +15 -0
  3. package/build/data-planes/types.d.ts +52 -115
  4. package/build/derivations/index.d.ts +84 -0
  5. package/build/derivations/index.js +93 -0
  6. package/build/derivations/types.d.ts +56 -0
  7. package/build/derivations/types.js +1 -0
  8. package/build/generated/api-types.d.ts +7112 -5185
  9. package/build/generated/api-types.js +1 -1
  10. package/build/http-client.d.ts +1 -0
  11. package/build/http-client.js +3 -0
  12. package/build/index.d.ts +4 -1
  13. package/build/index.js +4 -0
  14. package/build/jobs/types.d.ts +137 -337
  15. package/build/jobs/types.js +3 -3
  16. package/build/model-training/index.d.ts +21 -5
  17. package/build/model-training/index.js +20 -4
  18. package/build/model-training/types.d.ts +69 -6
  19. package/build/nql/index.d.ts +28 -2
  20. package/build/nql/index.js +28 -0
  21. package/build/nql/types.d.ts +16 -4
  22. package/build/rosetta/types.d.ts +1 -1
  23. package/build/testing/fixtures/data-planes.d.ts +5 -1
  24. package/build/testing/fixtures/data-planes.js +16 -6
  25. package/build/testing/fixtures/derivations.d.ts +18 -0
  26. package/build/testing/fixtures/derivations.js +43 -0
  27. package/build/testing/fixtures/index.d.ts +4 -0
  28. package/build/testing/fixtures/index.js +4 -0
  29. package/build/testing/fixtures/jobs.d.ts +75 -0
  30. package/build/testing/fixtures/jobs.js +433 -0
  31. package/build/testing/fixtures/model-training.d.ts +8 -0
  32. package/build/testing/fixtures/model-training.js +12 -0
  33. package/build/testing/fixtures/nql.d.ts +10 -0
  34. package/build/testing/fixtures/nql.js +37 -0
  35. package/build/testing/index.d.ts +14 -2
  36. package/build/testing/index.js +13 -1
  37. package/build/testing/types.d.ts +43 -0
  38. package/package.json +3 -2
@@ -0,0 +1,433 @@
1
+ /**
2
+ * One factory per job type the spec describes, plus one for a type it does not.
3
+ *
4
+ * Each returns a completed job whose `result` is filled in, since that is the
5
+ * state with the most to assert against. A job that has not finished is an
6
+ * override: `{ state: "pending", result: null, ended_at: null }`.
7
+ *
8
+ * Values come from the spec's own examples where it carries one, so a fixture
9
+ * and the documented response agree. Two places they cannot: an id the spec
10
+ * writes beyond `Number.MAX_SAFE_INTEGER` is shortened to a safe integer, and
11
+ * fields the spec types as an object with no properties are left empty — see
12
+ * {@link createDatasetsCalculateAffectedRowsJob}.
13
+ *
14
+ * The job a health check enqueues has its own factory, `createHealthCheckJob`,
15
+ * next to the data plane fixtures it is used with.
16
+ */
17
+ const TIMESTAMP = "2026-01-01T00:00:00Z";
18
+ const DATA_PLANE_ID = "5f9d1a4e-0000-4000-8000-000000000001";
19
+ const DATASET_ID = 10736;
20
+ /**
21
+ * The envelope every job shares. `operator_type` is finer-grained than the job
22
+ * type — several job types run as `datasets_execute_select`, for instance — so
23
+ * each factory passes the operator the API reports for it.
24
+ */
25
+ function envelope(jobId, operatorType) {
26
+ return {
27
+ job_id: jobId,
28
+ company_id: 1,
29
+ data_plane_id: DATA_PLANE_ID,
30
+ compute_pool_id: null,
31
+ request_source: { type: "api_user", company_id: 1, user_id: 407 },
32
+ state: "completed",
33
+ operator_type: operatorType,
34
+ tags: [],
35
+ executor: "job-executor-test",
36
+ execution_cluster: "shared",
37
+ idempotency_key: `${jobId}:test`,
38
+ dequeued_at: TIMESTAMP,
39
+ created_at: TIMESTAMP,
40
+ updated_at: TIMESTAMP,
41
+ attempted_at: TIMESTAMP,
42
+ attempt_version: 1,
43
+ ended_at: TIMESTAMP,
44
+ workflow_id: null,
45
+ workflow_run_id: null,
46
+ };
47
+ }
48
+ /** Refreshes a materialized view into its target dataset. */
49
+ export function createMaterializeViewJob(overrides = {}) {
50
+ return {
51
+ ...envelope("2a5b9ad7-0000-4000-8000-000000000001", "materialized-view-refresh"),
52
+ type: "materialize-view",
53
+ input: {
54
+ nql: 'CREATE MATERIALIZED VIEW "test_stats" AS SELECT "value" FROM "company_data"."10674"',
55
+ compiled_select: "SELECT\n `ds_10674`.`value`\nFROM\n narrative.datasets.ds_10674 `ds_10674`",
56
+ create_as_view: null,
57
+ dataset_id: DATASET_ID,
58
+ billing_enabled: null,
59
+ stats_enabled: true,
60
+ contains_delta_syntax: null,
61
+ first_run: false,
62
+ merge: true,
63
+ partitions: null,
64
+ snowflake_create_table: null,
65
+ snowflake_insert_statement: null,
66
+ chunk_metadata: null,
67
+ nio_last_modified_at: null,
68
+ delta_dataset_bounds: null,
69
+ write_mode: "append",
70
+ },
71
+ result: {
72
+ dataset_id: DATASET_ID,
73
+ snapshot_id: 1724919539450264,
74
+ recalculation_id: "abf9a2ec-426b-4751-bd16-fcb435061925",
75
+ row_stats: null,
76
+ },
77
+ ...overrides,
78
+ };
79
+ }
80
+ /**
81
+ * Estimates what a query would return and what it would cost. The result is a
82
+ * sum type: this one succeeds, and the failure branch is
83
+ * `{ failure: { msg: "…" } }`.
84
+ */
85
+ export function createNqlForecastJob(overrides = {}) {
86
+ return {
87
+ ...envelope("2a5b9ad7-0000-4000-8000-000000000002", "nql-forecast"),
88
+ type: "nql-forecast",
89
+ input: {
90
+ nql: 'EXPLAIN SELECT narrative.rosetta_stone."age" FROM narrative.rosetta_stone WHERE narrative.rosetta_stone."age" > 50',
91
+ compiled_sql: "SELECT\n `t`.`age`\nFROM\n narrative.datasets.ds_63 `t`\nWHERE\n `t`.`age` > 50",
92
+ },
93
+ result: {
94
+ success: {
95
+ result: { Forecast: { rows: 1643721216, cost: 136130662400 } },
96
+ },
97
+ },
98
+ ...overrides,
99
+ };
100
+ }
101
+ /** Reads a sample of rows. The rows are stored separately, so only the count comes back. */
102
+ export function createDatasetsSampleJob(overrides = {}) {
103
+ return {
104
+ ...envelope("2a5b9ad7-0000-4000-8000-000000000003", "datasets_execute_select"),
105
+ type: "datasets_sample",
106
+ input: {
107
+ dataset_id: DATASET_ID,
108
+ compiled_sql: "SELECT `ds_10674`.`value` FROM narrative.datasets.ds_10674 `ds_10674` LIMIT 100",
109
+ },
110
+ result: { type: "datasets_sample", row_count: 100 },
111
+ ...overrides,
112
+ };
113
+ }
114
+ /**
115
+ * Computes per-column statistics. This one carries the V1 input, which names
116
+ * the columns and the statistics to collect for each. The V2 input hands the
117
+ * operator pre-compiled SQL instead: `{ dataset_id, compiled_sql }`.
118
+ */
119
+ export function createDatasetsCalculateColumnStatsJob(overrides = {}) {
120
+ return {
121
+ ...envelope("2a5b9ad7-0000-4000-8000-000000000004", "datasets_calculate_column_stats"),
122
+ type: "datasets_calculate_column_stats",
123
+ input: {
124
+ dataset_id: DATASET_ID,
125
+ enabled_column_stats: {
126
+ AGE: {
127
+ data_type: "long",
128
+ enabled_column_stats: {
129
+ nan_value_count: false,
130
+ null_value_count: true,
131
+ value_count: true,
132
+ lower_bound: true,
133
+ upper_bound: true,
134
+ column_stored_bytes: true,
135
+ approx_count_distinct: false,
136
+ count_distinct: false,
137
+ histogram: false,
138
+ mean: false,
139
+ standard_deviation: false,
140
+ completeness: false,
141
+ observed_types: false,
142
+ },
143
+ },
144
+ },
145
+ },
146
+ result: { type: "datasets_calculate_column_stats" },
147
+ ...overrides,
148
+ };
149
+ }
150
+ /** Bills a materialized-view refresh, per access rule it read from. */
151
+ export function createCollectAccessRulesBillingDataJob(overrides = {}) {
152
+ return {
153
+ ...envelope("2a5b9ad7-0000-4000-8000-000000000005", "materialized_views_collect_access_rules_billing_data"),
154
+ type: "materialized_views_collect_access_rules_billing_data",
155
+ input: {
156
+ dataset_id: DATASET_ID,
157
+ nio_last_modified_at: "2024-01-28T00:00:00Z",
158
+ compiled_query: "SELECT `t`.`_nio_access_rule_id` FROM narrative.datasets.ds_10736 `t`",
159
+ refresh_job_id: "2a5b9ad7-0000-4000-8000-000000000001",
160
+ },
161
+ result: {
162
+ type: "materialized_views_collect_access_rules_billing_data",
163
+ sources: [
164
+ {
165
+ access_rule_id: 88,
166
+ rows: 1200,
167
+ price_per_row: { currency: "USD", microcents: 250 },
168
+ },
169
+ ],
170
+ },
171
+ ...overrides,
172
+ };
173
+ }
174
+ /** Delivers a dataset snapshot to a connected app. One job per connection. */
175
+ export function createDatasetsDeliverDataJob(overrides = {}) {
176
+ return {
177
+ ...envelope("2a5b9ad7-0000-4000-8000-000000000006", "datasets_deliver_data"),
178
+ type: "datasets_deliver_data",
179
+ input: {
180
+ app_id: 142,
181
+ connection_id: "0f1e2d3c-4b5a-4968-9788-6a5b4c3d2e1f",
182
+ dataset_id: DATASET_ID,
183
+ external_id: "nio_10736",
184
+ snapshot_id: "1724919539450264600",
185
+ maintenance_window_predicate: null,
186
+ },
187
+ result: {},
188
+ ...overrides,
189
+ };
190
+ }
191
+ /**
192
+ * Runs one inference call against a model on the data plane.
193
+ *
194
+ * `structured_output`, `output_format_schema`, and the tool argument fields are
195
+ * empty here rather than carrying a payload: the spec types them as an object
196
+ * with no properties, so no value satisfies them.
197
+ */
198
+ export function createModelInferenceRunJob(overrides = {}) {
199
+ return {
200
+ ...envelope("2a5b9ad7-0000-4000-8000-000000000007", "model_inference_run"),
201
+ type: "model_inference_run",
202
+ input: {
203
+ model: {
204
+ id: "claude-sonnet-4",
205
+ binding: {
206
+ provider: "bedrock",
207
+ model_id: "global.anthropic.claude-sonnet-4",
208
+ capabilities: { structured_output_mode: "native" },
209
+ },
210
+ },
211
+ messages: [
212
+ { role: "user", content: [{ type: "text", text: "Which city?" }] },
213
+ ],
214
+ inference_config: {
215
+ output_format_schema: {},
216
+ max_tokens: 1024,
217
+ temperature: null,
218
+ top_p: null,
219
+ stop_sequences: null,
220
+ thinking: null,
221
+ },
222
+ tools: null,
223
+ tool_choice: null,
224
+ },
225
+ result: {
226
+ structured_output: {},
227
+ usage: {
228
+ completion_tokens: 907,
229
+ prompt_tokens: 4849,
230
+ total_tokens: 5756,
231
+ },
232
+ tool_calls: [],
233
+ stop_reason: "end_turn",
234
+ produced_blocks: [],
235
+ final_answer_from: [],
236
+ failed_structured_output: null,
237
+ },
238
+ ...overrides,
239
+ };
240
+ }
241
+ /** Drops a dataset's underlying table. */
242
+ export function createDatasetsDeleteTableJob(overrides = {}) {
243
+ return {
244
+ ...envelope("2a5b9ad7-0000-4000-8000-000000000008", "datasets_delete_table"),
245
+ type: "datasets_delete_table",
246
+ input: { external_id: "nio_10736", is_narrative_managed: true },
247
+ result: {},
248
+ ...overrides,
249
+ };
250
+ }
251
+ /** Runs an NQL `DELETE` or `UPDATE` against a dataset. */
252
+ export function createDatasetsExecuteDmlJob(overrides = {}) {
253
+ return {
254
+ ...envelope("2a5b9ad7-0000-4000-8000-000000000009", "datasets_execute_dml"),
255
+ type: "datasets_execute_dml",
256
+ input: {
257
+ dataset_id: DATASET_ID,
258
+ nql: 'DELETE FROM "company_data"."10736" WHERE "age" < 18',
259
+ compiled_sql: "DELETE FROM narrative.datasets.ds_10736 WHERE age < 18",
260
+ nio_last_modified_at: null,
261
+ },
262
+ result: {
263
+ type: "datasets_execute_dml",
264
+ affected_rows: 10,
265
+ inserted_rows: 0,
266
+ updated_rows: 0,
267
+ deleted_rows: 10,
268
+ },
269
+ ...overrides,
270
+ };
271
+ }
272
+ /** Creates a dataset's underlying table. */
273
+ export function createDatasetsCreateTableJob(overrides = {}) {
274
+ return {
275
+ ...envelope("2a5b9ad7-0000-4000-8000-00000000000a", "datasets_create_table"),
276
+ type: "datasets_create_table",
277
+ input: {
278
+ dataset_id: DATASET_ID,
279
+ compiled_sql: "CREATE TABLE narrative.datasets.ds_10736 (age BIGINT)",
280
+ },
281
+ result: {},
282
+ ...overrides,
283
+ };
284
+ }
285
+ /** Empties a dataset's table, leaving the table itself in place. */
286
+ export function createDatasetsTruncateTableJob(overrides = {}) {
287
+ return {
288
+ ...envelope("2a5b9ad7-0000-4000-8000-00000000000b", "datasets_truncate_table"),
289
+ type: "datasets_truncate_table",
290
+ input: { dataset_id: DATASET_ID },
291
+ result: {},
292
+ ...overrides,
293
+ };
294
+ }
295
+ /** Drops a table that has outlived its TTL retention policy. */
296
+ export function createDatasetsEnforceTableTtlRetentionPolicyJob(overrides = {}) {
297
+ return {
298
+ ...envelope("2a5b9ad7-0000-4000-8000-00000000000c", "datasets_enforce_table_ttl_retention_policy"),
299
+ type: "datasets_enforce_table_ttl_retention_policy",
300
+ input: { dataset_id: DATASET_ID, dataset_external_id: "nio_10736" },
301
+ result: {},
302
+ ...overrides,
303
+ };
304
+ }
305
+ /** Deletes rows that have outlived their TTL retention policy. */
306
+ export function createDatasetsEnforceRowTtlRetentionPolicyJob(overrides = {}) {
307
+ return {
308
+ ...envelope("2a5b9ad7-0000-4000-8000-00000000000d", "datasets_enforce_row_ttl_retention_policy"),
309
+ type: "datasets_enforce_row_ttl_retention_policy",
310
+ input: {
311
+ dataset_id: DATASET_ID,
312
+ sql: [
313
+ "DELETE FROM narrative.datasets.ds_10736 WHERE _nio_last_modified_at < 1706400000000",
314
+ ],
315
+ },
316
+ result: {},
317
+ ...overrides,
318
+ };
319
+ }
320
+ /**
321
+ * Counts how many rows a pending statement would touch. The result carries the
322
+ * type of the operator that produced it rather than the job's own.
323
+ *
324
+ * The API returns the count at `rows[0].values.affected_rows`, which this
325
+ * fixture cannot express: the spec types `values` as an object with no
326
+ * properties, so `{}` is the only value that satisfies it. A test asserting on
327
+ * a count needs to cast the row.
328
+ */
329
+ export function createDatasetsCalculateAffectedRowsJob(overrides = {}) {
330
+ return {
331
+ ...envelope("2a5b9ad7-0000-4000-8000-00000000000e", "datasets_execute_select"),
332
+ type: "datasets_calculate_affected_rows",
333
+ input: {
334
+ compiled_sql: "SELECT COUNT(1) AS affected_rows FROM narrative.datasets.ds_10736",
335
+ dataset_id: DATASET_ID,
336
+ },
337
+ result: { type: "datasets_execute_select", rows: [{ values: {} }] },
338
+ ...overrides,
339
+ };
340
+ }
341
+ /**
342
+ * Fine-tunes a base model and publishes the result. The API stores this job's
343
+ * result exactly as the training operator posted it, so the spec gives it no
344
+ * shape and the fixture leaves it null.
345
+ */
346
+ export function createModelTrainingRunJob(overrides = {}) {
347
+ return {
348
+ ...envelope("2a5b9ad7-0000-4000-8000-00000000000f", "model_training_run"),
349
+ type: "model_training_run",
350
+ input: {
351
+ company_id: 1,
352
+ connections: null,
353
+ custom_axolotl_config_override: null,
354
+ dataset_id: DATASET_ID,
355
+ instance_type: "ml.g5.12xlarge",
356
+ base_model_id: 57,
357
+ base_model_repository: {
358
+ type: "hugging_face",
359
+ organization: "meta-llama",
360
+ },
361
+ base_model_repo_id: "meta-llama/Llama-3.1-8B",
362
+ trained_model_narrative_repository_model_id: "7d2f1b3c-5e6a-4f8b-9c0d-1e2f3a4b5c6d",
363
+ trained_model_narrative_repo_id: "1/7d2f1b3c-5e6a-4f8b-9c0d-1e2f3a4b5c6d/1",
364
+ trained_model_version: 1,
365
+ trained_model: {
366
+ name: "churn-predictor",
367
+ collaborators: {
368
+ view: { type: "none" },
369
+ train: { type: "none" },
370
+ deploy: { type: "none" },
371
+ },
372
+ description: null,
373
+ tags: null,
374
+ license_id: null,
375
+ },
376
+ },
377
+ result: null,
378
+ ...overrides,
379
+ };
380
+ }
381
+ /** Delivers a trained model to a connected app. */
382
+ export function createModelsDeliverModelJob(overrides = {}) {
383
+ return {
384
+ ...envelope("2a5b9ad7-0000-4000-8000-000000000010", "models_deliver_model"),
385
+ type: "models_deliver_model",
386
+ input: {
387
+ company_id: 1,
388
+ app_id: 142,
389
+ connection_id: "0f1e2d3c-4b5a-4968-9788-6a5b4c3d2e1f",
390
+ profile_id: "9c1f0a2e-3d4b-4c5a-8e6f-7a8b9c0d1e2f",
391
+ model_id: "7d2f1b3c-5e6a-4f8b-9c0d-1e2f3a4b5c6d",
392
+ model_name: "churn-predictor",
393
+ model_version: 1,
394
+ quick_settings: null,
395
+ },
396
+ result: null,
397
+ ...overrides,
398
+ };
399
+ }
400
+ /**
401
+ * Trains a classifier. Both `input` and `result` are free-form on the wire, so
402
+ * the defaults here are illustrative rather than a contract.
403
+ */
404
+ export function createModelsTrainClassifierJob(overrides = {}) {
405
+ return {
406
+ ...envelope("2a5b9ad7-0000-4000-8000-000000000011", "models_train_classifier"),
407
+ type: "models_train_classifier",
408
+ input: { dataset_id: DATASET_ID, label_column: "CATEGORY" },
409
+ result: null,
410
+ ...overrides,
411
+ };
412
+ }
413
+ /**
414
+ * A job of a type the spec has no branch for, where `input` and `result` stay
415
+ * free-form. This is what a job type added after the spec was generated decodes
416
+ * as. The default is `datasets_execute_select`, a type the backend really runs
417
+ * and the spec does not describe.
418
+ *
419
+ * Undescribed by the spec is not the same as unknown to the SDK: the root entry
420
+ * point's `isKnownJob` still recognises this default. Override `type` to get a
421
+ * job neither one knows.
422
+ */
423
+ export function createOtherJob(overrides = {}) {
424
+ return {
425
+ ...envelope("2a5b9ad7-0000-4000-8000-000000000012", "datasets_execute_select"),
426
+ type: "datasets_execute_select",
427
+ input: {
428
+ compiled_sql: "SELECT `t`.`age` FROM narrative.datasets.ds_10736 `t`",
429
+ },
430
+ result: { type: "datasets_execute_select", rows: [] },
431
+ ...overrides,
432
+ };
433
+ }
@@ -0,0 +1,8 @@
1
+ import type { TrainClassifierResponse } from "../types";
2
+ /**
3
+ * What `POST /v1/model-training/train-classifier` returns: the id of the
4
+ * enqueued training job. Everything else about the run — state, metrics, the
5
+ * trained model — comes back from the jobs API, so pair this with a job
6
+ * fixture when a test follows the job through.
7
+ */
8
+ export declare function createTrainClassifierResponse(overrides?: Partial<TrainClassifierResponse>): TrainClassifierResponse;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * What `POST /v1/model-training/train-classifier` returns: the id of the
3
+ * enqueued training job. Everything else about the run — state, metrics, the
4
+ * trained model — comes back from the jobs API, so pair this with a job
5
+ * fixture when a test follows the job through.
6
+ */
7
+ export function createTrainClassifierResponse(overrides = {}) {
8
+ return {
9
+ job_id: "5f9d1a4e-0000-4000-8000-00000000000b",
10
+ ...overrides,
11
+ };
12
+ }
@@ -0,0 +1,10 @@
1
+ import type { NqlExecuteResponse } from "../types";
2
+ /**
3
+ * What `POST /v1/nql/execute` returns: an active workflow the statement was
4
+ * compiled into, plus the id of the run started for it.
5
+ *
6
+ * `archived_at` is present and `null` — the API sends it that way for an active
7
+ * workflow rather than omitting it, and a mock that left it out would let a
8
+ * consumer assert `undefined` and still pass.
9
+ */
10
+ export declare function createNqlExecutionResponse(overrides?: Partial<NqlExecuteResponse>): NqlExecuteResponse;
@@ -0,0 +1,37 @@
1
+ const TIMESTAMP = "2026-01-01T00:00:00Z";
2
+ /**
3
+ * What `POST /v1/nql/execute` returns: an active workflow the statement was
4
+ * compiled into, plus the id of the run started for it.
5
+ *
6
+ * `archived_at` is present and `null` — the API sends it that way for an active
7
+ * workflow rather than omitting it, and a mock that left it out would let a
8
+ * consumer assert `undefined` and still pass.
9
+ */
10
+ export function createNqlExecutionResponse(overrides = {}) {
11
+ return {
12
+ id: "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
13
+ name: "execute-nql",
14
+ specification: [
15
+ "document:",
16
+ " dsl: '1.0.0'",
17
+ " namespace: nql",
18
+ " name: execute-nql",
19
+ " version: '1.0.0'",
20
+ "do:",
21
+ " - execute:",
22
+ " call: ExecuteDml",
23
+ " with:",
24
+ ' nql: "INSERT INTO \\"company_data\\".\\"1\\" (\\"id\\") VALUES (1)"',
25
+ ].join("\n"),
26
+ data_plane_id: "d1e2f3a4-b5c6-7890-abcd-ef1234567890",
27
+ company_id: 1,
28
+ created_at: TIMESTAMP,
29
+ created_by: 1,
30
+ updated_at: TIMESTAMP,
31
+ status: "active",
32
+ archived_at: null,
33
+ tags: [],
34
+ run_id: "b7e3f1a2-4c5d-6e7f-8a9b-0c1d2e3f4a5b",
35
+ ...overrides,
36
+ };
37
+ }
@@ -19,8 +19,20 @@
19
19
  * }),
20
20
  * );
21
21
  * ```
22
+ *
23
+ * The job factories are standalone: there are no job handlers yet, so a test
24
+ * seeds one into a handler of its own.
25
+ *
26
+ * ```ts
27
+ * import { http, HttpResponse } from "msw";
28
+ * import { createMaterializeViewJob } from "@narrative.io/data-collaboration-sdk-ts/testing";
29
+ *
30
+ * http.get("*\/jobs/:id", () =>
31
+ * HttpResponse.json(createMaterializeViewJob({ state: "failed" })),
32
+ * );
33
+ * ```
22
34
  */
23
- export { createHealthCheckJob, createOwnedDataPlane, createSharedDataPlane, } from "./fixtures";
35
+ export { createCollectAccessRulesBillingDataJob, createDatasetsCalculateAffectedRowsJob, createDatasetsCalculateColumnStatsJob, createDatasetsCreateTableJob, createDatasetsDeleteTableJob, createDatasetsDeliverDataJob, createDatasetsEnforceRowTtlRetentionPolicyJob, createDatasetsEnforceTableTtlRetentionPolicyJob, createDatasetsExecuteDmlJob, createDatasetsSampleJob, createDatasetsTruncateTableJob, createDerivation, createHealthCheckJob, createMaterializeViewJob, createModelInferenceRunJob, createModelsDeliverModelJob, createModelsTrainClassifierJob, createModelTrainingRunJob, createNqlExecutionResponse, createNqlForecastJob, createOtherJob, createOwnedDataPlane, createSharedDataPlane, createTrainClassifierResponse, } from "./fixtures";
24
36
  export { createHandlers } from "./handlers";
25
37
  export { createDataPlaneHandlers } from "./handlers/data-planes";
26
- export type { AuthGuard, AuthGuardContext, CreateHandlersOptions, DataPlaneOwnedResponse, DataPlanePlatform, DataPlaneResponse, DataPlaneSharedPlatform, DataPlaneSharedResponse, JobResponse, } from "./types";
38
+ export type { AuthGuard, AuthGuardContext, CollectAccessRulesBillingDataJobResponse, CreateHandlersOptions, DataPlaneOwnedResponse, DataPlanePlatform, DataPlaneResponse, DataPlaneSharedPlatform, DataPlaneSharedResponse, DatasetsCalculateAffectedRowsJobResponse, DatasetsCalculateColumnStatsJobResponse, DatasetsCreateTableJobResponse, DatasetsDeleteTableJobResponse, DatasetsDeliverDataJobResponse, DatasetsEnforceRowTtlRetentionPolicyJobResponse, DatasetsEnforceTableTtlRetentionPolicyJobResponse, DatasetsExecuteDmlJobResponse, DatasetsSampleJobResponse, DatasetsTruncateTableJobResponse, DerivationResponse, HealthCheckJobResponse, JobEnvelope, JobResponse, MaterializeViewJobResponse, ModelInferenceRunJobResponse, ModelsDeliverModelJobResponse, ModelsTrainClassifierJobResponse, ModelTrainingRunJobResponse, NqlExecuteResponse, NqlForecastJobResponse, OtherJobResponse, TrainClassifierResponse, } from "./types";
@@ -19,7 +19,19 @@
19
19
  * }),
20
20
  * );
21
21
  * ```
22
+ *
23
+ * The job factories are standalone: there are no job handlers yet, so a test
24
+ * seeds one into a handler of its own.
25
+ *
26
+ * ```ts
27
+ * import { http, HttpResponse } from "msw";
28
+ * import { createMaterializeViewJob } from "@narrative.io/data-collaboration-sdk-ts/testing";
29
+ *
30
+ * http.get("*\/jobs/:id", () =>
31
+ * HttpResponse.json(createMaterializeViewJob({ state: "failed" })),
32
+ * );
33
+ * ```
22
34
  */
23
- export { createHealthCheckJob, createOwnedDataPlane, createSharedDataPlane, } from "./fixtures";
35
+ export { createCollectAccessRulesBillingDataJob, createDatasetsCalculateAffectedRowsJob, createDatasetsCalculateColumnStatsJob, createDatasetsCreateTableJob, createDatasetsDeleteTableJob, createDatasetsDeliverDataJob, createDatasetsEnforceRowTtlRetentionPolicyJob, createDatasetsEnforceTableTtlRetentionPolicyJob, createDatasetsExecuteDmlJob, createDatasetsSampleJob, createDatasetsTruncateTableJob, createDerivation, createHealthCheckJob, createMaterializeViewJob, createModelInferenceRunJob, createModelsDeliverModelJob, createModelsTrainClassifierJob, createModelTrainingRunJob, createNqlExecutionResponse, createNqlForecastJob, createOtherJob, createOwnedDataPlane, createSharedDataPlane, createTrainClassifierResponse, } from "./fixtures";
24
36
  export { createHandlers } from "./handlers";
25
37
  export { createDataPlaneHandlers } from "./handlers/data-planes";
@@ -31,6 +31,49 @@ export type DataPlanePlatform = components["schemas"]["Platform"];
31
31
  export type DataPlaneSharedPlatform = components["schemas"]["PlatformSharedResponse"];
32
32
  /** A job as the API returns it, including the one a health check enqueues. */
33
33
  export type JobResponse = components["schemas"]["JobResponse"];
34
+ /**
35
+ * The fields every job carries, whatever its type. Exported so a test can build
36
+ * a job type the fixtures do not cover without restating the envelope.
37
+ */
38
+ export type JobEnvelope = components["schemas"]["JobBase"];
39
+ export type MaterializeViewJobResponse = components["schemas"]["MaterializeViewJobResponse"];
40
+ export type NqlForecastJobResponse = components["schemas"]["NqlForecastJobResponse"];
41
+ export type DatasetsSampleJobResponse = components["schemas"]["DatasetsSampleJobResponse"];
42
+ export type DatasetsCalculateColumnStatsJobResponse = components["schemas"]["DatasetsCalculateColumnStatsJobResponse"];
43
+ export type CollectAccessRulesBillingDataJobResponse = components["schemas"]["CollectAccessRulesBillingDataJobResponse"];
44
+ export type DatasetsDeliverDataJobResponse = components["schemas"]["DatasetsDeliverDataJobResponse"];
45
+ export type ModelInferenceRunJobResponse = components["schemas"]["ModelInferenceRunJobResponse"];
46
+ export type DatasetsDeleteTableJobResponse = components["schemas"]["DatasetsDeleteTableJobResponse"];
47
+ export type DatasetsExecuteDmlJobResponse = components["schemas"]["DatasetsExecuteDmlJobResponse"];
48
+ export type DatasetsCreateTableJobResponse = components["schemas"]["DatasetsCreateTableJobResponse"];
49
+ export type DatasetsTruncateTableJobResponse = components["schemas"]["DatasetsTruncateTableJobResponse"];
50
+ export type DatasetsEnforceTableTtlRetentionPolicyJobResponse = components["schemas"]["DatasetsEnforceTableTtlRetentionPolicyJobResponse"];
51
+ export type DatasetsEnforceRowTtlRetentionPolicyJobResponse = components["schemas"]["DatasetsEnforceRowTtlRetentionPolicyJobResponse"];
52
+ export type DatasetsCalculateAffectedRowsJobResponse = components["schemas"]["DatasetsCalculateAffectedRowsJobResponse"];
53
+ export type ModelTrainingRunJobResponse = components["schemas"]["ModelTrainingRunJobResponse"];
54
+ export type ModelsDeliverModelJobResponse = components["schemas"]["ModelsDeliverModelJobResponse"];
55
+ export type ModelsTrainClassifierJobResponse = components["schemas"]["ModelsTrainClassifierJobResponse"];
56
+ export type HealthCheckJobResponse = components["schemas"]["HealthCheckJobResponse"];
57
+ /**
58
+ * A job whose type the spec does not describe a branch for. Job types are free
59
+ * strings on the server, so this is what a type added after the spec was
60
+ * generated decodes as, with `input` and `result` left free-form.
61
+ */
62
+ export type OtherJobResponse = components["schemas"]["OtherJobResponse"];
63
+ /**
64
+ * A derivation rule as the API returns it. `warnings` is populated on create
65
+ * and update responses and empty on reads.
66
+ */
67
+ export type DerivationResponse = components["schemas"]["DerivationResponse"];
68
+ /**
69
+ * What `POST /v1/nql/execute` returns — the workflow the statement compiled to,
70
+ * plus the id of its run. Named after the root entry point's
71
+ * `NqlExecuteResponse` rather than the generated schema's
72
+ * `CreateWorkflowResponseWithRunId`, so the two entry points read the same way.
73
+ */
74
+ export type NqlExecuteResponse = components["schemas"]["CreateWorkflowResponseWithRunId"];
75
+ /** What `POST /v1/model-training/train-classifier` returns. */
76
+ export type TrainClassifierResponse = components["schemas"]["TrainClassifierResponse"];
34
77
  export interface AuthGuardContext {
35
78
  request: Request;
36
79
  /** Cookies msw parsed off the request. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@narrative.io/data-collaboration-sdk-ts",
3
- "version": "4.4.0",
3
+ "version": "4.5.0",
4
4
  "main": "build/index.js",
5
5
  "repository": "github:narrative-io/data-collaboration-sdk-ts",
6
6
  "source": "src/index.ts",
@@ -29,6 +29,7 @@
29
29
  "./build/data-planes": "./build/data-planes/index.js",
30
30
  "./build/data-streams": "./build/data-streams/index.js",
31
31
  "./build/datasets": "./build/datasets/index.js",
32
+ "./build/derivations": "./build/derivations/index.js",
32
33
  "./build/encryption-materials": "./build/encryption-materials/index.js",
33
34
  "./build/forecast": "./build/forecast/index.js",
34
35
  "./build/health": "./build/health/index.js",
@@ -60,7 +61,7 @@
60
61
  "./package.json": "./package.json"
61
62
  },
62
63
  "description": "",
63
- "packageManager": "bun@1.2.21",
64
+ "packageManager": "bun@1.3.14",
64
65
  "scripts": {
65
66
  "build": "tsc",
66
67
  "lint": "bunx @biomejs/biome check --write ./src",