@narrative.io/data-collaboration-sdk-ts 4.3.1 → 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 (39) 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 +22 -3
  24. package/build/testing/fixtures/data-planes.js +52 -7
  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 +5 -1
  28. package/build/testing/fixtures/index.js +5 -1
  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/handlers/data-planes.js +5 -3
  36. package/build/testing/index.d.ts +24 -4
  37. package/build/testing/index.js +23 -3
  38. package/build/testing/types.d.ts +70 -1
  39. package/package.json +3 -2
@@ -2,7 +2,7 @@
2
2
  * GENERATED FILE — DO NOT EDIT.
3
3
  *
4
4
  * Source: https://docs-cdn.narrative.io/api-reference/main/openapi.json
5
- * Spec etag: W/"1b05b0fe6188a5d59c67bbde3678af08"
5
+ * Spec etag: W/"b4c876661400c5ac03697ec6dde62625"
6
6
  *
7
7
  * Regenerate with: bun run generate:api-types
8
8
  */
@@ -83,6 +83,7 @@ export declare class HttpClient {
83
83
  get<T>(url: string): Promise<T>;
84
84
  post<T>(url: string, data?: unknown): Promise<T>;
85
85
  put<T>(url: string, data?: unknown): Promise<T>;
86
+ patch<T>(url: string, data?: unknown): Promise<T>;
86
87
  delete<T>(url: string): Promise<T>;
87
88
  private request;
88
89
  /**
@@ -66,6 +66,9 @@ export class HttpClient {
66
66
  async put(url, data) {
67
67
  return this.request("PUT", url, data);
68
68
  }
69
+ async patch(url, data) {
70
+ return this.request("PATCH", url, data);
71
+ }
69
72
  async delete(url) {
70
73
  return this.request("DELETE", url);
71
74
  }
package/build/index.d.ts CHANGED
@@ -19,6 +19,8 @@ export * from "./data-streams";
19
19
  export * from "./datasets";
20
20
  export * from "./datasets/statistics-types";
21
21
  export * from "./datasets/types";
22
+ export * from "./derivations";
23
+ export * from "./derivations/types";
22
24
  export * from "./encryption-materials";
23
25
  export * from "./encryption-materials/types";
24
26
  export * from "./forecast";
@@ -73,6 +75,7 @@ import { ContractsApi } from "./contracts";
73
75
  import { DataPlaneApi } from "./data-planes";
74
76
  import { DataStreamsApi } from "./data-streams";
75
77
  import { DatasetApi } from "./datasets";
78
+ import { DerivationsApi } from "./derivations";
76
79
  import { EncryptionMaterialApi } from "./encryption-materials";
77
80
  import { ForecastApi } from "./forecast";
78
81
  import { HealthCheckApi } from "./health";
@@ -95,6 +98,6 @@ import { WhoAmIApi } from "./whoami";
95
98
  import { WorkflowsApi } from "./workflows";
96
99
  declare class NarrativeApi extends BaseApi {
97
100
  }
98
- interface NarrativeApi extends BaseApi, HealthCheckApi, AccessTokensApi, DataPlaneApi, DatasetApi, RosettaStoneApi, AttributeApi, AttributeApiV2, PingApi, CompanyInfoApi, InstallationsApi, ConnectionsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi, AuthenticationApi, MappingsApi, AccessRulesApi, AppsApi, SubscriptionsApi, JobsApi, QueriesApi, ViewsApi, ModelsApi, ModelTrainingApi, ModelInferenceApi, EncryptionMaterialApi, WhoAmIApi, WorkflowsApi, ComputePoolsApi, AgentsApi, CompaniesApi, McpConnectionsApi {
101
+ interface NarrativeApi extends BaseApi, HealthCheckApi, AccessTokensApi, DataPlaneApi, DatasetApi, RosettaStoneApi, AttributeApi, AttributeApiV2, PingApi, CompanyInfoApi, InstallationsApi, ConnectionsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi, AuthenticationApi, MappingsApi, AccessRulesApi, AppsApi, SubscriptionsApi, JobsApi, QueriesApi, ViewsApi, ModelsApi, ModelTrainingApi, ModelInferenceApi, EncryptionMaterialApi, WhoAmIApi, WorkflowsApi, ComputePoolsApi, AgentsApi, CompaniesApi, McpConnectionsApi, DerivationsApi {
99
102
  }
100
103
  export { NarrativeApi };
package/build/index.js CHANGED
@@ -19,6 +19,8 @@ export * from "./data-streams";
19
19
  export * from "./datasets";
20
20
  export * from "./datasets/statistics-types";
21
21
  export * from "./datasets/types";
22
+ export * from "./derivations";
23
+ export * from "./derivations/types";
22
24
  export * from "./encryption-materials";
23
25
  export * from "./encryption-materials/types";
24
26
  export * from "./forecast";
@@ -74,6 +76,7 @@ import { ContractsApi } from "./contracts";
74
76
  import { DataPlaneApi } from "./data-planes";
75
77
  import { DataStreamsApi } from "./data-streams";
76
78
  import { DatasetApi } from "./datasets";
79
+ import { DerivationsApi } from "./derivations";
77
80
  import { EncryptionMaterialApi } from "./encryption-materials";
78
81
  import { ForecastApi } from "./forecast";
79
82
  import { HealthCheckApi } from "./health";
@@ -134,5 +137,6 @@ applyMixins(NarrativeApi, [
134
137
  AgentsApi,
135
138
  CompaniesApi,
136
139
  McpConnectionsApi,
140
+ DerivationsApi,
137
141
  ]);
138
142
  export { NarrativeApi };
@@ -1,14 +1,14 @@
1
- import type { ForecastResult, JobState } from "../forecast";
1
+ import type { ForecastResult } from "../forecast";
2
2
  import type { DataStreamPurchaseDetails, ForecastDimensions, MarketplaceForecastDetails } from "../forecast/types";
3
- import type { NqlBudget } from "../nql/types";
3
+ import type { components } from "../generated/api-types";
4
4
  /**
5
- * Every job type the backend can persist and return from the /jobs API.
6
- * The backend's `Job.Type` is an open string, so treat this list as the
7
- * known set rather than a closed enum see {@link UnknownJob}.
5
+ * Every job type the backend can persist and return from the /jobs API. The
6
+ * backend's job type is an open string, so this is the known set rather than a
7
+ * closed enum. Anything outside it arrives as an {@link UnknownJob}.
8
8
  */
9
9
  export declare const KNOWN_JOB_TYPES: readonly ["forecast", "forecast-internal", "nql-forecast", "costs", "materialize-view", "materialized_views_collect_access_rules_billing_data", "datasets_calculate_affected_rows", "datasets_calculate_column_stats", "datasets_create_table", "datasets_delete_table", "datasets_deliver_data", "datasets_enforce_row_ttl_retention_policy", "datasets_enforce_table_ttl_retention_policy", "datasets_execute_dml", "datasets_execute_select", "datasets_sample", "datasets_suggest_mappings", "datasets_truncate_table", "health_check", "model_inference_run", "model_training_run", "models_deliver_model", "models_train_classifier"];
10
10
  export type JobType = (typeof KNOWN_JOB_TYPES)[number];
11
- export type JobExecutionCluster = "shared" | "dedicated";
11
+ export type JobExecutionCluster = components["schemas"]["ExecutionClusterType"];
12
12
  export interface JobRequestSourceApiUser {
13
13
  type: "api_user";
14
14
  company_id: number;
@@ -18,371 +18,171 @@ export interface JobRequestSourceProcess {
18
18
  type: "process";
19
19
  name: string;
20
20
  }
21
+ /**
22
+ * What asked for the job: a user calling the API, or an internal process
23
+ * running on its own.
24
+ *
25
+ * This is the one field the SDK does not take from the spec. The spec describes
26
+ * `request_source` as three independently optional fields, which covers both
27
+ * shapes at once, narrows to neither, and has no `name` at all. The backend
28
+ * models it as a closed sum type, so the union below is what actually arrives.
29
+ */
21
30
  export type JobRequestSource = JobRequestSourceApiUser | JobRequestSourceProcess;
22
- interface BaseJob {
23
- job_id: string;
24
- type: JobType;
25
- company_id: number;
31
+ /** Swaps the spec's `request_source` for {@link JobRequestSource}. */
32
+ type WithRequestSource<J> = Omit<J, "request_source"> & {
26
33
  request_source: JobRequestSource;
27
- data_plane_id?: string;
28
- compute_pool_id?: string;
29
- state: JobState;
30
- execution_cluster: JobExecutionCluster;
31
- /**
32
- * The job type actually executed on the data plane. Multiple business-level
33
- * types (e.g. `datasets_calculate_affected_rows`, `datasets_sample`) can map
34
- * to a single operator type (`datasets_execute_select`); otherwise it equals
35
- * `type`.
36
- */
37
- operator_type: string;
38
- executor?: string;
39
- idempotency_key: string;
40
- created_at: string;
41
- updated_at: string;
42
- attempted_at: string;
43
- attempt_version: number;
44
- ended_at?: string;
45
- tags?: string[];
46
- dequeued_at?: string;
47
- }
34
+ };
35
+ /**
36
+ * Swaps a branch's `result` for a shape the SDK describes and the spec leaves
37
+ * free-form.
38
+ */
39
+ type WithResult<J, R> = Omit<J, "result"> & {
40
+ result: R | null;
41
+ };
42
+ /**
43
+ * The fields every job carries, whatever its type. Each branch below adds
44
+ * `type`, `input`, and `result` on top of these.
45
+ *
46
+ * `operator_type` is finer-grained than `type`: several job types can share one
47
+ * operator, so `datasets_calculate_affected_rows` and `datasets_sample` both
48
+ * run as `datasets_execute_select`. Where no operator of its own exists, it
49
+ * equals `type`.
50
+ */
51
+ type BaseJob = WithRequestSource<components["schemas"]["JobBase"]>;
52
+ export type ExplainInput = components["schemas"]["NqlForecastJobInput"];
53
+ /**
54
+ * The forecast, or the reason it could not be produced. Exactly one of
55
+ * `success` / `failure` is present; the absent branch is not sent as null.
56
+ */
57
+ export type ExplainOutput = components["schemas"]["NqlForecastJobResult"];
58
+ export type ExplainJob = WithRequestSource<components["schemas"]["NqlForecastJobResponse"]>;
59
+ export type MaterializedViewInput = components["schemas"]["MaterializeViewJobInput"];
60
+ export type MaterializedViewRowStats = components["schemas"]["MaterializeViewJobRowStats"];
61
+ /** What a data plane reports after refreshing a view. */
62
+ export type RefreshMaterializedViewResult = components["schemas"]["MaterializeViewJobResult"];
63
+ /**
64
+ * @deprecated The forecast-shaped result the Spark executor produced. The spec
65
+ * attributes this shape to `nql-forecast` rather than to `materialize-view`, so
66
+ * read it through {@link ExplainOutput} instead.
67
+ */
68
+ export type MaterializedViewOutput = components["schemas"]["NqlForecastJobSuccess"];
69
+ export type MaterializedViewJob = WithRequestSource<components["schemas"]["MaterializeViewJobResponse"]>;
70
+ export type CollectAccessRulesBillingDataInput = components["schemas"]["CollectAccessRulesBillingDataJobInput"];
71
+ export type CollectAccessRulesBillingDataResult = components["schemas"]["CollectAccessRulesBillingDataJobResult"];
72
+ export type CollectAccessRulesBillingDataJob = WithRequestSource<components["schemas"]["CollectAccessRulesBillingDataJobResponse"]>;
73
+ export type CalculateAffectedRowsInput = components["schemas"]["DatasetsCalculateAffectedRowsJobInput"];
74
+ export type CalculateAffectedRowsJob = WithRequestSource<components["schemas"]["DatasetsCalculateAffectedRowsJobResponse"]>;
75
+ export type CreateTableInput = components["schemas"]["DatasetsCreateTableJobInput"];
76
+ export type DatasetsCreateTableJob = WithRequestSource<components["schemas"]["DatasetsCreateTableJobResponse"]>;
77
+ export type TruncateTableInput = components["schemas"]["DatasetsTruncateTableJobInput"];
78
+ export type DatasetsTruncateTableJob = WithRequestSource<components["schemas"]["DatasetsTruncateTableJobResponse"]>;
79
+ export type DeleteInput = components["schemas"]["DatasetsDeleteTableJobInput"];
80
+ export type DeleteResult = components["schemas"]["DatasetsDeleteTableJobResult"];
81
+ export type DatasetsDeleteTableJob = WithRequestSource<components["schemas"]["DatasetsDeleteTableJobResponse"]>;
82
+ export type DeliverInput = components["schemas"]["DatasetsDeliverDataJobInput"];
83
+ export type DeliverResult = components["schemas"]["DatasetsDeliverDataJobResult"];
84
+ export type DatasetsDeliverDataJob = WithRequestSource<components["schemas"]["DatasetsDeliverDataJobResponse"]>;
85
+ export type EnforceRowTtlRetentionPolicyInput = components["schemas"]["DatasetsEnforceRowTtlRetentionPolicyJobInput"];
86
+ export type DatasetsEnforceRowTtlRetentionPolicyJob = WithRequestSource<components["schemas"]["DatasetsEnforceRowTtlRetentionPolicyJobResponse"]>;
87
+ export type EnforceTableTtlRetentionPolicyInput = components["schemas"]["DatasetsEnforceTableTtlRetentionPolicyJobInput"];
88
+ export type DatasetsEnforceTableTtlRetentionPolicyJob = WithRequestSource<components["schemas"]["DatasetsEnforceTableTtlRetentionPolicyJobResponse"]>;
89
+ export type ExecuteDmlInput = components["schemas"]["DatasetsExecuteDmlJobInput"];
90
+ export type ExecuteDmlResult = components["schemas"]["DatasetsExecuteDmlJobResult"];
91
+ export type DatasetsExecuteDmlJob = WithRequestSource<components["schemas"]["DatasetsExecuteDmlJobResponse"]>;
92
+ export type SampleInput = components["schemas"]["DatasetsSampleJobInput"];
93
+ export type SampleResult = components["schemas"]["DatasetsSampleJobResult"];
94
+ export type DatasetsSampleJob = WithRequestSource<components["schemas"]["DatasetsSampleJobResponse"]>;
95
+ /**
96
+ * The column types the statistics job reports. The spec types `data_type` as a
97
+ * plain string so an unrecognised type still decodes, which is why
98
+ * {@link ColumnDetails} does not use this union.
99
+ */
100
+ export type ColumnStatDataType = "boolean" | "double" | "long" | "string" | "timestamp_tz" | "array" | "object";
101
+ export type EnabledColumnStatFlags = components["schemas"]["DatasetsCalculateColumnStatsFlags"];
102
+ export type ColumnDetails = components["schemas"]["DatasetsCalculateColumnStatsColumnDetails"];
103
+ export type StatsInput = components["schemas"]["DatasetsCalculateColumnStatsJobInputV1"];
104
+ export type StatsInputV2 = components["schemas"]["DatasetsCalculateColumnStatsJobInputV2"];
105
+ export type StatsResult = components["schemas"]["DatasetsCalculateColumnStatsJobResult"];
106
+ export type DatasetsCalculateColumnStatsJob = WithRequestSource<components["schemas"]["DatasetsCalculateColumnStatsJobResponse"]>;
107
+ export type HealthCheckJob = WithRequestSource<components["schemas"]["HealthCheckJobResponse"]>;
108
+ export type ModelInferenceRunInput = components["schemas"]["ModelInferenceRunJobInput"];
109
+ export type ModelInferenceRunJobResult = components["schemas"]["ModelInferenceRunJobResult"];
110
+ export type ModelInferenceRunJob = WithRequestSource<components["schemas"]["ModelInferenceRunJobResponse"]>;
111
+ export type ModelTrainingRunInput = components["schemas"]["ModelTrainingRunJobInput"];
112
+ /** Whatever the training operator posted on completion. The API stores it as
113
+ * sent rather than reshaping it, so it has no fixed shape. */
114
+ export type ModelTrainingRunResult = components["schemas"]["JobResult"];
115
+ export type ModelTrainingRunJob = WithRequestSource<components["schemas"]["ModelTrainingRunJobResponse"]>;
116
+ export type ModelsDeliverModelInput = components["schemas"]["ModelsDeliverModelJobInput"];
117
+ /** Whatever the delivery operator posted on completion. */
118
+ export type ModelsDeliverModelResult = components["schemas"]["JobResult"];
119
+ export type ModelsDeliverModelJob = WithRequestSource<components["schemas"]["ModelsDeliverModelJobResponse"]>;
120
+ /**
121
+ * The spec leaves this job's `result` free-form because it never passes through
122
+ * a typed class in the marketplace. {@link ModelsTrainClassifierResults} is the
123
+ * SDK's own description of what the training operator actually posts, so the
124
+ * result keeps that shape rather than widening to `unknown`.
125
+ */
126
+ export type ModelsTrainClassifierJob = WithResult<WithRequestSource<components["schemas"]["ModelsTrainClassifierJobResponse"]>, ModelsTrainClassifierResults>;
48
127
  export interface ForecastInput {
49
128
  as_of?: string;
50
129
  dimensions: ForecastDimensions;
51
130
  fingerprint?: string;
52
131
  details: MarketplaceForecastDetails | DataStreamPurchaseDetails;
53
132
  }
54
- export interface ForecastJob extends BaseJob {
133
+ export type ForecastJob = BaseJob & {
55
134
  type: "forecast";
56
135
  input: ForecastInput;
57
- result?: ForecastResult;
58
- }
59
- export interface ForecastInternalJob extends BaseJob {
136
+ result: ForecastResult | null;
137
+ };
138
+ export type ForecastInternalJob = BaseJob & {
60
139
  type: "forecast-internal";
61
140
  input: ForecastInput;
62
- result?: ForecastResult;
63
- }
64
- export interface ExplainInput {
65
- nql: string;
66
- compiled_nql: string;
67
- dataset_id: number;
68
- }
69
- export interface ExplainOutput {
70
- dataset_id: number;
71
- }
72
- export interface ExplainJob extends BaseJob {
73
- type: "nql-forecast";
74
- input: ExplainInput;
75
- result?: ExplainOutput;
76
- }
141
+ result: ForecastResult | null;
142
+ };
77
143
  export interface CostsInput {
78
144
  as_of?: string;
79
145
  /** Subscription purchase details; shape mirrors the marketplace subscription model. */
80
146
  details: unknown;
81
147
  }
82
- export interface CostsJob extends BaseJob {
148
+ export type CostsJob = BaseJob & {
83
149
  type: "costs";
84
150
  input: CostsInput;
85
- result?: unknown;
86
- }
87
- export interface MaterializedViewInput {
88
- nql: string;
89
- compiled_nql: string;
90
- budget: NqlBudget;
91
- dataset_id: number;
92
- stats_enabled: boolean;
93
- chunk_metadata?: {
94
- batch_id: string;
95
- chunk_sequence: {
96
- number: number;
97
- of: number;
98
- };
99
- };
100
- }
101
- export interface MaterializedViewRowStats {
102
- affected_rows: number;
103
- inserted_rows: number;
104
- updated_rows: number;
105
- deleted_rows: number;
106
- }
107
- /** Result shape reported by data planes completing a refresh. */
108
- export interface RefreshMaterializedViewResult {
109
- type: "refresh_materialized_view";
110
- snapshot_id: string;
111
- row_stats?: MaterializedViewRowStats;
112
- }
113
- /** Legacy result shape produced by the Spark executor. */
114
- export interface MaterializedViewOutput {
115
- success: {
116
- result: {
117
- Forecast: {
118
- cost: number;
119
- rows: number;
120
- };
121
- };
122
- };
123
- }
124
- export interface MaterializedViewJob extends BaseJob {
125
- type: "materialize-view";
126
- input: MaterializedViewInput;
127
- result?: MaterializedViewOutput | RefreshMaterializedViewResult;
128
- }
129
- export interface CollectAccessRulesBillingDataInput {
130
- dataset_id?: number;
131
- nio_last_modified_at: string;
132
- compiled_query: string;
133
- refresh_job_id: string;
134
- }
135
- export interface CollectAccessRulesBillingDataResult {
136
- sources: Array<{
137
- access_rule_id: number;
138
- rows: number;
139
- price_per_row: unknown;
140
- }>;
141
- }
142
- export interface CollectAccessRulesBillingDataJob extends BaseJob {
143
- type: "materialized_views_collect_access_rules_billing_data";
144
- input: CollectAccessRulesBillingDataInput;
145
- result?: CollectAccessRulesBillingDataResult;
146
- }
147
- export interface CalculateAffectedRowsInput {
148
- dataset_id: number;
149
- compiled_sql: string;
150
- }
151
- export interface CalculateAffectedRowsJob extends BaseJob {
152
- type: "datasets_calculate_affected_rows";
153
- input: CalculateAffectedRowsInput;
154
- /** Runs on the `datasets_execute_select` operator, so the stored result is select-shaped. */
155
- result?: ExecuteSelectResult;
156
- }
157
- export interface CreateTableInput {
158
- dataset_id: number;
159
- compiled_sql: string;
160
- }
161
- export interface DatasetsCreateTableJob extends BaseJob {
162
- type: "datasets_create_table";
163
- input: CreateTableInput;
164
- result?: unknown;
165
- }
166
- export interface TruncateTableInput {
167
- dataset_id: number;
168
- }
169
- export interface DatasetsTruncateTableJob extends BaseJob {
170
- type: "datasets_truncate_table";
171
- input: TruncateTableInput;
172
- result?: unknown;
173
- }
174
- export interface DeleteInput {
175
- external_id: string;
176
- is_narrative_managed?: boolean;
177
- }
178
- export type DeleteResult = unknown;
179
- export interface DatasetsDeleteTableJob extends BaseJob {
180
- type: "datasets_delete_table";
181
- input: DeleteInput;
182
- result?: DeleteResult;
183
- }
184
- export interface DeliverInput {
185
- app_id?: string;
186
- connection_id?: string;
187
- dataset_id: number;
188
- external_id: string;
189
- snapshot_id?: string;
190
- maintenance_window_predicate?: string;
191
- }
192
- export type DeliverResult = unknown;
193
- export interface DatasetsDeliverDataJob extends BaseJob {
194
- type: "datasets_deliver_data";
195
- input: DeliverInput;
196
- result?: DeliverResult;
197
- }
198
- export interface EnforceRowTtlRetentionPolicyInput {
199
- dataset_id: number;
200
- sql: string[];
201
- }
202
- export interface DatasetsEnforceRowTtlRetentionPolicyJob extends BaseJob {
203
- type: "datasets_enforce_row_ttl_retention_policy";
204
- input: EnforceRowTtlRetentionPolicyInput;
205
- result?: unknown;
206
- }
207
- export interface EnforceTableTtlRetentionPolicyInput {
208
- dataset_id: number;
209
- dataset_external_id?: string;
210
- }
211
- export interface DatasetsEnforceTableTtlRetentionPolicyJob extends BaseJob {
212
- type: "datasets_enforce_table_ttl_retention_policy";
213
- input: EnforceTableTtlRetentionPolicyInput;
214
- result?: unknown;
215
- }
216
- export interface ExecuteDmlInput {
217
- dataset_id: number;
218
- nql: string;
219
- compiled_sql: string;
220
- nio_last_modified_at?: string;
221
- }
222
- export interface ExecuteDmlResult {
223
- affected_rows: number;
224
- inserted_rows: number;
225
- updated_rows: number;
226
- deleted_rows: number;
227
- }
228
- export interface DatasetsExecuteDmlJob extends BaseJob {
229
- type: "datasets_execute_dml";
230
- input: ExecuteDmlInput;
231
- result?: ExecuteDmlResult;
232
- }
151
+ result: unknown;
152
+ };
233
153
  export interface ExecuteSelectInput {
234
154
  compiled_sql: string;
235
155
  }
236
- export interface ExecuteSelectResult {
237
- rows: Array<{
238
- values: Record<string, unknown>;
239
- }>;
240
- }
241
- export interface DatasetsExecuteSelectJob extends BaseJob {
156
+ /**
157
+ * The operator's raw SELECT output. Jobs that read a single value out of a
158
+ * query carry this rather than a field of their own, so
159
+ * {@link CalculateAffectedRowsJob} finds its count at
160
+ * `rows[0].values.affected_rows`.
161
+ */
162
+ export type ExecuteSelectResult = components["schemas"]["DatasetsCalculateAffectedRowsJobResult"];
163
+ export type DatasetsExecuteSelectJob = BaseJob & {
242
164
  type: "datasets_execute_select";
243
165
  input: ExecuteSelectInput;
244
- result?: ExecuteSelectResult;
245
- }
246
- export interface SampleInput {
247
- dataset_id: number;
248
- }
249
- export type SampleResult = unknown;
250
- export interface DatasetsSampleJob extends BaseJob {
251
- type: "datasets_sample";
252
- input: SampleInput;
253
- result?: SampleResult;
254
- }
166
+ result: ExecuteSelectResult | null;
167
+ };
255
168
  export interface SuggestMappingsInput {
256
169
  dataset_id: number;
257
170
  }
258
171
  export interface SuggestMappingsResult {
259
172
  result: string;
260
173
  }
261
- export interface DatasetsSuggestMappingsJob extends BaseJob {
174
+ export type DatasetsSuggestMappingsJob = BaseJob & {
262
175
  type: "datasets_suggest_mappings";
263
176
  input: SuggestMappingsInput;
264
- result?: SuggestMappingsResult;
265
- }
266
- export type ColumnStatDataType = "boolean" | "double" | "long" | "string" | "timestamp_tz" | "array" | "object";
267
- export interface EnabledColumnStatFlags {
268
- nan_value_count: boolean;
269
- null_value_count: boolean;
270
- value_count: boolean;
271
- lower_bound: boolean;
272
- upper_bound: boolean;
273
- column_stored_bytes: boolean;
274
- approx_count_distinct: boolean;
275
- count_distinct: boolean;
276
- histogram: boolean;
277
- mean: boolean;
278
- standard_deviation: boolean;
279
- completeness: boolean;
280
- observed_types: boolean;
281
- }
282
- export interface ColumnDetails {
283
- data_type: ColumnStatDataType;
284
- enabled_column_stats: EnabledColumnStatFlags;
285
- }
286
- export interface StatsInput {
287
- dataset_id: number;
288
- enabled_column_stats?: Record<string, ColumnDetails>;
289
- }
290
- /** V2 input ships pre-compiled SQL instead of a column configuration. */
291
- export interface StatsInputV2 {
292
- dataset_id: number;
293
- compiled_sql: string;
294
- }
295
- export type StatsResult = unknown;
296
- export interface DatasetsCalculateColumnStatsJob extends BaseJob {
297
- type: "datasets_calculate_column_stats";
298
- input: StatsInput | StatsInputV2;
299
- result?: StatsResult;
300
- }
301
- export interface HealthCheckJob extends BaseJob {
302
- type: "health_check";
303
- input: unknown;
304
- /** Compute pool health check report. */
305
- result?: unknown;
306
- }
307
- export interface ModelTrainingRunInput {
308
- company_id: number;
309
- connections?: unknown[];
310
- custom_axolotl_config_override?: unknown;
311
- dataset_id: number;
312
- instance_type: string;
313
- base_model_id: string;
314
- base_model_repository: string;
315
- base_model_repo_id: string;
316
- trained_model_narrative_repository_model_id: string;
317
- trained_model_narrative_repo_id: string;
318
- trained_model_version: string;
319
- trained_model: unknown;
320
- }
321
- export type ModelTrainingRunResult = unknown;
322
- export interface ModelTrainingRunJob extends BaseJob {
323
- type: "model_training_run";
324
- input: ModelTrainingRunInput;
325
- result?: ModelTrainingRunResult;
326
- }
327
- export interface ModelsDeliverModelInput {
328
- company_id: number;
329
- app_id: string;
330
- connection_id: string;
331
- profile_id: string;
332
- model_id: string;
333
- model_name: string;
334
- model_version: string;
335
- quick_settings?: unknown;
336
- }
337
- export type ModelsDeliverModelResult = unknown;
338
- export interface ModelsDeliverModelJob extends BaseJob {
339
- type: "models_deliver_model";
340
- input: ModelsDeliverModelInput;
341
- result?: ModelsDeliverModelResult;
342
- }
343
- export interface ModelsTrainClassifierJob extends BaseJob {
344
- type: "models_train_classifier";
345
- input: unknown;
346
- result?: ModelsTrainClassifierResults;
347
- }
348
- export interface ModelInferenceRunInput {
349
- model: string;
350
- messages: Array<{
351
- role: string;
352
- text: string;
353
- }>;
354
- inference_config: {
355
- output_format_schema: Record<string, unknown>;
356
- max_tokens?: number | null;
357
- temperature?: number | null;
358
- top_p?: number | null;
359
- stop_sequences?: string[] | null;
360
- };
361
- }
362
- export interface ModelInferenceRunJobResult {
363
- usage: {
364
- total_tokens: number;
365
- prompt_tokens: number;
366
- completion_tokens: number;
367
- };
368
- structured_output?: unknown;
369
- tool_calls?: unknown[];
370
- stop_reason?: string;
371
- }
372
- export interface ModelInferenceRunJob extends BaseJob {
373
- type: "model_inference_run";
374
- input: ModelInferenceRunInput;
375
- result?: ModelInferenceRunJobResult;
376
- }
177
+ result: SuggestMappingsResult | null;
178
+ };
377
179
  /**
378
- * Fallback for job types the SDK does not know about yet — the backend's
379
- * job type is an open string, so new types can appear without an SDK release.
180
+ * A job whose type the SDK does not know about. The backend's job type is an
181
+ * open string and it stores `input` and `result` as arbitrary JSON, so a type
182
+ * added after an SDK release lands here rather than failing to parse. Read
183
+ * `type` to find out what arrived.
380
184
  */
381
- export interface UnknownJob extends Omit<BaseJob, "type"> {
382
- type: string;
383
- input: unknown;
384
- result?: unknown;
385
- }
185
+ export type UnknownJob = WithRequestSource<components["schemas"]["OtherJobResponse"]>;
386
186
  /** Discriminated union over every job type the SDK knows about. */
387
187
  export type KnownJob = ForecastJob | ForecastInternalJob | ExplainJob | CostsJob | MaterializedViewJob | CollectAccessRulesBillingDataJob | CalculateAffectedRowsJob | DatasetsCalculateColumnStatsJob | DatasetsCreateTableJob | DatasetsDeleteTableJob | DatasetsDeliverDataJob | DatasetsEnforceRowTtlRetentionPolicyJob | DatasetsEnforceTableTtlRetentionPolicyJob | DatasetsExecuteDmlJob | DatasetsExecuteSelectJob | DatasetsSampleJob | DatasetsSuggestMappingsJob | DatasetsTruncateTableJob | HealthCheckJob | ModelInferenceRunJob | ModelTrainingRunJob | ModelsDeliverModelJob | ModelsTrainClassifierJob;
388
188
  export type Job = KnownJob | UnknownJob;
@@ -1,7 +1,7 @@
1
1
  /**
2
- * Every job type the backend can persist and return from the /jobs API.
3
- * The backend's `Job.Type` is an open string, so treat this list as the
4
- * known set rather than a closed enum see {@link UnknownJob}.
2
+ * Every job type the backend can persist and return from the /jobs API. The
3
+ * backend's job type is an open string, so this is the known set rather than a
4
+ * closed enum. Anything outside it arrives as an {@link UnknownJob}.
5
5
  */
6
6
  export const KNOWN_JOB_TYPES = [
7
7
  "forecast",
@@ -1,5 +1,5 @@
1
1
  import { BaseApi } from "../base-api";
2
- import type { ModelTrainingConfig, OutputModel, TrainClassifierRequest, TrainClassifierResponse, TrainModelRequest, TrainModelResponse } from "./types";
2
+ import type { CategoricalFeatureInput, ClassifierSettings, EmbeddingFeatureInput, FeatureInput, ModelTrainingConfig, NewModelConnection, NumericFeatureInput, OutputModel, TextFeatureInput, TrainClassifierRequest, TrainClassifierResponse, TrainModelRequest, TrainModelResponse } from "./types";
3
3
  /**
4
4
  * A class for accessing the Model Training API.
5
5
  * @extends BaseApi
@@ -13,11 +13,27 @@ declare class ModelTrainingApi extends BaseApi {
13
13
  */
14
14
  trainModel(data: TrainModelRequest): Promise<TrainModelResponse>;
15
15
  /**
16
- * Trains a classifier model.
16
+ * Trains a text classifier on a dataset. Only datasets on Snowflake data
17
+ * planes are supported.
17
18
  *
18
- * @param {TrainClassifierRequest} data - The data for the classifier training.
19
- * @returns {Promise<TrainClassifierResponse>} A promise that resolves with the classifier training response.
19
+ * The training data is named by `dataset_id` and the backing table resolved
20
+ * server-side, so the caller never handles it. Every column reference
21
+ * `label_column`, `id_column`, and each feature's `field_path` — is checked
22
+ * against the dataset's schema before the job is created.
23
+ *
24
+ * This posts to `v1/model-training/train-classifier`. The unversioned
25
+ * endpoint still exists but is deprecated: it took the training table as an
26
+ * opaque `config` blob and validated none of it.
27
+ *
28
+ * @param {TrainClassifierRequest} data - The dataset, features and classifier
29
+ * settings to train with.
30
+ * @returns {Promise<TrainClassifierResponse>} The id of the created job. Poll
31
+ * the jobs API for status and results. Rejects with 400 if a name is not a
32
+ * valid identifier, a column reference is not in the dataset's schema, or the
33
+ * dataset is not materialized on a Snowflake data plane; 403 if the dataset
34
+ * is reachable but owned by another company.
35
+ * @see https://docs.narrative.io/api-reference/model-training/train-a-classifier
20
36
  */
21
37
  trainClassifier(data: TrainClassifierRequest): Promise<TrainClassifierResponse>;
22
38
  }
23
- export { ModelTrainingApi, type ModelTrainingConfig, type OutputModel, type TrainClassifierRequest, type TrainClassifierResponse, type TrainModelRequest, type TrainModelResponse, };
39
+ export { type CategoricalFeatureInput, type ClassifierSettings, type EmbeddingFeatureInput, type FeatureInput, ModelTrainingApi, type ModelTrainingConfig, type NewModelConnection, type NumericFeatureInput, type OutputModel, type TextFeatureInput, type TrainClassifierRequest, type TrainClassifierResponse, type TrainModelRequest, type TrainModelResponse, };