@narrative.io/data-collaboration-sdk-ts 2.105.0 → 2.107.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/build/forecast/types.d.ts +1 -1
- package/build/jobs/index.d.ts +12 -9
- package/build/jobs/index.js +4 -2
- package/build/jobs/types.d.ts +224 -26
- package/build/jobs/types.js +45 -1
- package/package.json +8 -8
|
@@ -72,7 +72,7 @@ export interface ForecastDimensions {
|
|
|
72
72
|
distinct_counts: string[];
|
|
73
73
|
group_by?: string;
|
|
74
74
|
}
|
|
75
|
-
export type JobState = "pending" | "running" | "completed" | "cancelled" | "failed";
|
|
75
|
+
export type JobState = "pending" | "running" | "completed" | "pending_cancellation" | "cancelled" | "failed";
|
|
76
76
|
export interface ForecastResult {
|
|
77
77
|
cost: number;
|
|
78
78
|
datasets: DatasetForecastResponse[];
|
package/build/jobs/index.d.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { BaseApi } from "../base-api";
|
|
2
|
-
import type {
|
|
3
|
-
import type { ColumnDetails, DatasetsCalculateColumnStatsJob, DatasetsDeleteTableJob, DatasetsDeliverDataJob, DatasetsSampleJob, DeleteInput, DeliverInput, ExplainInput, ExplainJob, ExplainOutput, ForecastInput, ForecastJob, Job, JobRequestSource, JobRequestSourceApiUser, JobRequestSourceProcess, MaterializedViewInput, MaterializedViewJob, MaterializedViewOutput, ModelInferenceRunInput, ModelInferenceRunJob, ModelInferenceRunJobResult, ModelsDeliverModelInput, ModelsDeliverModelJob, ModelTrainingRunInput, ModelTrainingRunJob, SampleInput, StatsInput } from "./types";
|
|
4
|
-
|
|
2
|
+
import type { ApiRecordsV2 } from "../types";
|
|
3
|
+
import type { CalculateAffectedRowsInput, CalculateAffectedRowsJob, CollectAccessRulesBillingDataInput, CollectAccessRulesBillingDataJob, CollectAccessRulesBillingDataResult, ColumnDetails, ColumnStatDataType, CostsInput, CostsJob, CreateTableInput, DatasetsCalculateColumnStatsJob, DatasetsCreateTableJob, DatasetsDeleteTableJob, DatasetsDeliverDataJob, DatasetsEnforceRowTtlRetentionPolicyJob, DatasetsEnforceTableTtlRetentionPolicyJob, DatasetsExecuteDmlJob, DatasetsExecuteSelectJob, DatasetsSampleJob, DatasetsSuggestMappingsJob, DatasetsTruncateTableJob, DeleteInput, DeliverInput, EnabledColumnStatFlags, EnforceRowTtlRetentionPolicyInput, EnforceTableTtlRetentionPolicyInput, ExecuteDmlInput, ExecuteDmlResult, ExecuteSelectInput, ExecuteSelectResult, ExplainInput, ExplainJob, ExplainOutput, ForecastInput, ForecastInternalJob, ForecastJob, HealthCheckJob, Job, JobExecutionCluster, JobRequestSource, JobRequestSourceApiUser, JobRequestSourceProcess, JobType, KnownJob, MaterializedViewInput, MaterializedViewJob, MaterializedViewOutput, MaterializedViewRowStats, ModelInferenceRunInput, ModelInferenceRunJob, ModelInferenceRunJobResult, ModelsDeliverModelInput, ModelsDeliverModelJob, ModelsTrainClassifierJob, ModelTrainingRunInput, ModelTrainingRunJob, RefreshMaterializedViewResult, SampleInput, StatsInput, StatsInputV2, SuggestMappingsInput, SuggestMappingsResult, TruncateTableInput } from "./types";
|
|
4
|
+
import { isKnownJob, KNOWN_JOB_TYPES } from "./types";
|
|
5
|
+
type JobStateFilter = "cancelled" | "completed" | "failed" | "pending" | "pending_cancellation" | "running";
|
|
6
|
+
interface GetJobsParameters extends Record<string, string | number | boolean | string[] | undefined> {
|
|
5
7
|
dataset_id?: number;
|
|
6
8
|
per_page?: number;
|
|
7
9
|
offset?: number;
|
|
8
|
-
order_by?: "created_at_asc" | "created_at_desc";
|
|
9
|
-
state?:
|
|
10
|
-
type?: string;
|
|
10
|
+
order_by?: "created_at_asc" | "created_at_desc" | "updated_at_asc" | "updated_at_desc";
|
|
11
|
+
state?: JobStateFilter | JobStateFilter[];
|
|
12
|
+
type?: string | string[];
|
|
11
13
|
}
|
|
12
14
|
/**
|
|
13
15
|
* @module JobsApi
|
|
@@ -17,9 +19,10 @@ interface GetJobsParameters extends Record<string, string | number | boolean | u
|
|
|
17
19
|
declare class JobsApi extends BaseApi {
|
|
18
20
|
/**
|
|
19
21
|
* Get all jobs for the current company
|
|
20
|
-
* @returns {Promise<
|
|
22
|
+
* @returns {Promise<ApiRecordsV2<Job>>} - Promise resolving with a page of jobs plus pagination
|
|
23
|
+
* metadata (current_page, total_pages, total_records, prev_page, next_page).
|
|
21
24
|
*/
|
|
22
|
-
getJobs(parameters?: GetJobsParameters): Promise<
|
|
25
|
+
getJobs(parameters?: GetJobsParameters): Promise<ApiRecordsV2<Job>>;
|
|
23
26
|
/**
|
|
24
27
|
* Get a specific job by id
|
|
25
28
|
* @returns {Promise<Job>} - Promise resolving with the job.
|
|
@@ -31,4 +34,4 @@ declare class JobsApi extends BaseApi {
|
|
|
31
34
|
*/
|
|
32
35
|
cancelJob(jobId: string): Promise<void>;
|
|
33
36
|
}
|
|
34
|
-
export { type ColumnDetails, type DatasetsCalculateColumnStatsJob, type DatasetsDeleteTableJob, type DatasetsDeliverDataJob, type DatasetsSampleJob, type DeleteInput, type DeliverInput, type ExplainInput, type ExplainJob, type ExplainOutput, type ForecastInput, type ForecastJob, type GetJobsParameters, type Job, type JobRequestSource, type JobRequestSourceApiUser, type JobRequestSourceProcess, JobsApi, type MaterializedViewInput, type MaterializedViewJob, type MaterializedViewOutput, type ModelInferenceRunInput, type ModelInferenceRunJob, type ModelInferenceRunJobResult, type ModelsDeliverModelInput, type ModelsDeliverModelJob, type ModelTrainingRunInput, type ModelTrainingRunJob, type SampleInput, type StatsInput, };
|
|
37
|
+
export { type CalculateAffectedRowsInput, type CalculateAffectedRowsJob, type CollectAccessRulesBillingDataInput, type CollectAccessRulesBillingDataJob, type CollectAccessRulesBillingDataResult, type ColumnDetails, type ColumnStatDataType, type CostsInput, type CostsJob, type CreateTableInput, type DatasetsCalculateColumnStatsJob, type DatasetsCreateTableJob, type DatasetsDeleteTableJob, type DatasetsDeliverDataJob, type DatasetsEnforceRowTtlRetentionPolicyJob, type DatasetsEnforceTableTtlRetentionPolicyJob, type DatasetsExecuteDmlJob, type DatasetsExecuteSelectJob, type DatasetsSampleJob, type DatasetsSuggestMappingsJob, type DatasetsTruncateTableJob, type DeleteInput, type DeliverInput, type EnabledColumnStatFlags, type EnforceRowTtlRetentionPolicyInput, type EnforceTableTtlRetentionPolicyInput, type ExecuteDmlInput, type ExecuteDmlResult, type ExecuteSelectInput, type ExecuteSelectResult, type ExplainInput, type ExplainJob, type ExplainOutput, type ForecastInput, type ForecastInternalJob, type ForecastJob, type GetJobsParameters, type HealthCheckJob, isKnownJob, type Job, type JobExecutionCluster, type JobRequestSource, type JobRequestSourceApiUser, type JobRequestSourceProcess, type JobStateFilter, JobsApi, type JobType, KNOWN_JOB_TYPES, type KnownJob, type MaterializedViewInput, type MaterializedViewJob, type MaterializedViewOutput, type MaterializedViewRowStats, type ModelInferenceRunInput, type ModelInferenceRunJob, type ModelInferenceRunJobResult, type ModelsDeliverModelInput, type ModelsDeliverModelJob, type ModelsTrainClassifierJob, type ModelTrainingRunInput, type ModelTrainingRunJob, type RefreshMaterializedViewResult, type SampleInput, type StatsInput, type StatsInputV2, type SuggestMappingsInput, type SuggestMappingsResult, type TruncateTableInput, };
|
package/build/jobs/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BaseApi } from "../base-api";
|
|
2
|
+
import { isKnownJob, KNOWN_JOB_TYPES } from "./types";
|
|
2
3
|
const resourceName = "jobs";
|
|
3
4
|
/**
|
|
4
5
|
* @module JobsApi
|
|
@@ -8,7 +9,8 @@ const resourceName = "jobs";
|
|
|
8
9
|
class JobsApi extends BaseApi {
|
|
9
10
|
/**
|
|
10
11
|
* Get all jobs for the current company
|
|
11
|
-
* @returns {Promise<
|
|
12
|
+
* @returns {Promise<ApiRecordsV2<Job>>} - Promise resolving with a page of jobs plus pagination
|
|
13
|
+
* metadata (current_page, total_pages, total_records, prev_page, next_page).
|
|
12
14
|
*/
|
|
13
15
|
async getJobs(parameters) {
|
|
14
16
|
const queryString = this.constructQueryString(parameters);
|
|
@@ -29,4 +31,4 @@ class JobsApi extends BaseApi {
|
|
|
29
31
|
await this.post(`${resourceName}/${jobId}/request-cancellation`);
|
|
30
32
|
}
|
|
31
33
|
}
|
|
32
|
-
export { JobsApi, };
|
|
34
|
+
export { isKnownJob, JobsApi, KNOWN_JOB_TYPES, };
|
package/build/jobs/types.d.ts
CHANGED
|
@@ -1,26 +1,40 @@
|
|
|
1
1
|
import type { ForecastResult, JobState } from "src/forecast";
|
|
2
2
|
import type { DataStreamPurchaseDetails, ForecastDimensions, MarketplaceForecastDetails } from "src/forecast/types";
|
|
3
3
|
import type { NqlBudget } from "src/nql/types";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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}.
|
|
8
|
+
*/
|
|
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
|
+
export type JobType = (typeof KNOWN_JOB_TYPES)[number];
|
|
11
|
+
export type JobExecutionCluster = "shared" | "dedicated";
|
|
12
|
+
export interface JobRequestSourceApiUser {
|
|
13
|
+
type: "api_user";
|
|
7
14
|
company_id: number;
|
|
8
15
|
user_id: number;
|
|
9
16
|
}
|
|
10
|
-
export interface JobRequestSourceApiUser {
|
|
11
|
-
company_id: string;
|
|
12
|
-
user_id: string;
|
|
13
|
-
}
|
|
14
17
|
export interface JobRequestSourceProcess {
|
|
18
|
+
type: "process";
|
|
15
19
|
name: string;
|
|
16
20
|
}
|
|
21
|
+
export type JobRequestSource = JobRequestSourceApiUser | JobRequestSourceProcess;
|
|
17
22
|
interface BaseJob {
|
|
18
23
|
job_id: string;
|
|
19
24
|
type: JobType;
|
|
25
|
+
company_id: number;
|
|
20
26
|
request_source: JobRequestSource;
|
|
21
27
|
data_plane_id?: string;
|
|
22
28
|
compute_pool_id?: string;
|
|
23
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;
|
|
24
38
|
executor?: string;
|
|
25
39
|
idempotency_key: string;
|
|
26
40
|
created_at: string;
|
|
@@ -37,7 +51,12 @@ export interface ForecastInput {
|
|
|
37
51
|
}
|
|
38
52
|
export interface ForecastJob extends BaseJob {
|
|
39
53
|
type: "forecast";
|
|
40
|
-
input:
|
|
54
|
+
input: ForecastInput;
|
|
55
|
+
result?: ForecastResult;
|
|
56
|
+
}
|
|
57
|
+
export interface ForecastInternalJob extends BaseJob {
|
|
58
|
+
type: "forecast-internal";
|
|
59
|
+
input: ForecastInput;
|
|
41
60
|
result?: ForecastResult;
|
|
42
61
|
}
|
|
43
62
|
export interface ExplainInput {
|
|
@@ -53,6 +72,16 @@ export interface ExplainJob extends BaseJob {
|
|
|
53
72
|
input: ExplainInput;
|
|
54
73
|
result?: ExplainOutput;
|
|
55
74
|
}
|
|
75
|
+
export interface CostsInput {
|
|
76
|
+
as_of?: string;
|
|
77
|
+
/** Subscription purchase details; shape mirrors the marketplace subscription model. */
|
|
78
|
+
details: unknown;
|
|
79
|
+
}
|
|
80
|
+
export interface CostsJob extends BaseJob {
|
|
81
|
+
type: "costs";
|
|
82
|
+
input: CostsInput;
|
|
83
|
+
result?: unknown;
|
|
84
|
+
}
|
|
56
85
|
export interface MaterializedViewInput {
|
|
57
86
|
nql: string;
|
|
58
87
|
compiled_nql: string;
|
|
@@ -67,6 +96,19 @@ export interface MaterializedViewInput {
|
|
|
67
96
|
};
|
|
68
97
|
};
|
|
69
98
|
}
|
|
99
|
+
export interface MaterializedViewRowStats {
|
|
100
|
+
affected_rows: number;
|
|
101
|
+
inserted_rows: number;
|
|
102
|
+
updated_rows: number;
|
|
103
|
+
deleted_rows: number;
|
|
104
|
+
}
|
|
105
|
+
/** Result shape reported by data planes completing a refresh. */
|
|
106
|
+
export interface RefreshMaterializedViewResult {
|
|
107
|
+
type: "refresh_materialized_view";
|
|
108
|
+
snapshot_id: string;
|
|
109
|
+
row_stats?: MaterializedViewRowStats;
|
|
110
|
+
}
|
|
111
|
+
/** Legacy result shape produced by the Spark executor. */
|
|
70
112
|
export interface MaterializedViewOutput {
|
|
71
113
|
success: {
|
|
72
114
|
result: {
|
|
@@ -80,10 +122,56 @@ export interface MaterializedViewOutput {
|
|
|
80
122
|
export interface MaterializedViewJob extends BaseJob {
|
|
81
123
|
type: "materialize-view";
|
|
82
124
|
input: MaterializedViewInput;
|
|
83
|
-
result?: MaterializedViewOutput;
|
|
125
|
+
result?: MaterializedViewOutput | RefreshMaterializedViewResult;
|
|
126
|
+
}
|
|
127
|
+
export interface CollectAccessRulesBillingDataInput {
|
|
128
|
+
dataset_id?: number;
|
|
129
|
+
nio_last_modified_at: string;
|
|
130
|
+
compiled_query: string;
|
|
131
|
+
refresh_job_id: string;
|
|
132
|
+
}
|
|
133
|
+
export interface CollectAccessRulesBillingDataResult {
|
|
134
|
+
sources: Array<{
|
|
135
|
+
access_rule_id: number;
|
|
136
|
+
rows: number;
|
|
137
|
+
price_per_row: unknown;
|
|
138
|
+
}>;
|
|
139
|
+
}
|
|
140
|
+
export interface CollectAccessRulesBillingDataJob extends BaseJob {
|
|
141
|
+
type: "materialized_views_collect_access_rules_billing_data";
|
|
142
|
+
input: CollectAccessRulesBillingDataInput;
|
|
143
|
+
result?: CollectAccessRulesBillingDataResult;
|
|
144
|
+
}
|
|
145
|
+
export interface CalculateAffectedRowsInput {
|
|
146
|
+
dataset_id: number;
|
|
147
|
+
compiled_sql: string;
|
|
148
|
+
}
|
|
149
|
+
export interface CalculateAffectedRowsJob extends BaseJob {
|
|
150
|
+
type: "datasets_calculate_affected_rows";
|
|
151
|
+
input: CalculateAffectedRowsInput;
|
|
152
|
+
/** Runs on the `datasets_execute_select` operator, so the stored result is select-shaped. */
|
|
153
|
+
result?: ExecuteSelectResult;
|
|
154
|
+
}
|
|
155
|
+
export interface CreateTableInput {
|
|
156
|
+
dataset_id: number;
|
|
157
|
+
compiled_sql: string;
|
|
158
|
+
}
|
|
159
|
+
export interface DatasetsCreateTableJob extends BaseJob {
|
|
160
|
+
type: "datasets_create_table";
|
|
161
|
+
input: CreateTableInput;
|
|
162
|
+
result?: unknown;
|
|
163
|
+
}
|
|
164
|
+
export interface TruncateTableInput {
|
|
165
|
+
dataset_id: number;
|
|
166
|
+
}
|
|
167
|
+
export interface DatasetsTruncateTableJob extends BaseJob {
|
|
168
|
+
type: "datasets_truncate_table";
|
|
169
|
+
input: TruncateTableInput;
|
|
170
|
+
result?: unknown;
|
|
84
171
|
}
|
|
85
172
|
export interface DeleteInput {
|
|
86
173
|
external_id: string;
|
|
174
|
+
is_narrative_managed?: boolean;
|
|
87
175
|
}
|
|
88
176
|
export type DeleteResult = unknown;
|
|
89
177
|
export interface DatasetsDeleteTableJob extends BaseJob {
|
|
@@ -92,9 +180,9 @@ export interface DatasetsDeleteTableJob extends BaseJob {
|
|
|
92
180
|
result?: DeleteResult;
|
|
93
181
|
}
|
|
94
182
|
export interface DeliverInput {
|
|
95
|
-
app_id
|
|
96
|
-
connection_id
|
|
97
|
-
dataset_id:
|
|
183
|
+
app_id?: string;
|
|
184
|
+
connection_id?: string;
|
|
185
|
+
dataset_id: number;
|
|
98
186
|
external_id: string;
|
|
99
187
|
snapshot_id?: string;
|
|
100
188
|
maintenance_window_predicate?: string;
|
|
@@ -105,8 +193,56 @@ export interface DatasetsDeliverDataJob extends BaseJob {
|
|
|
105
193
|
input: DeliverInput;
|
|
106
194
|
result?: DeliverResult;
|
|
107
195
|
}
|
|
196
|
+
export interface EnforceRowTtlRetentionPolicyInput {
|
|
197
|
+
dataset_id: number;
|
|
198
|
+
sql: string[];
|
|
199
|
+
}
|
|
200
|
+
export interface DatasetsEnforceRowTtlRetentionPolicyJob extends BaseJob {
|
|
201
|
+
type: "datasets_enforce_row_ttl_retention_policy";
|
|
202
|
+
input: EnforceRowTtlRetentionPolicyInput;
|
|
203
|
+
result?: unknown;
|
|
204
|
+
}
|
|
205
|
+
export interface EnforceTableTtlRetentionPolicyInput {
|
|
206
|
+
dataset_id: number;
|
|
207
|
+
dataset_external_id?: string;
|
|
208
|
+
}
|
|
209
|
+
export interface DatasetsEnforceTableTtlRetentionPolicyJob extends BaseJob {
|
|
210
|
+
type: "datasets_enforce_table_ttl_retention_policy";
|
|
211
|
+
input: EnforceTableTtlRetentionPolicyInput;
|
|
212
|
+
result?: unknown;
|
|
213
|
+
}
|
|
214
|
+
export interface ExecuteDmlInput {
|
|
215
|
+
dataset_id: number;
|
|
216
|
+
nql: string;
|
|
217
|
+
compiled_sql: string;
|
|
218
|
+
nio_last_modified_at?: string;
|
|
219
|
+
}
|
|
220
|
+
export interface ExecuteDmlResult {
|
|
221
|
+
affected_rows: number;
|
|
222
|
+
inserted_rows: number;
|
|
223
|
+
updated_rows: number;
|
|
224
|
+
deleted_rows: number;
|
|
225
|
+
}
|
|
226
|
+
export interface DatasetsExecuteDmlJob extends BaseJob {
|
|
227
|
+
type: "datasets_execute_dml";
|
|
228
|
+
input: ExecuteDmlInput;
|
|
229
|
+
result?: ExecuteDmlResult;
|
|
230
|
+
}
|
|
231
|
+
export interface ExecuteSelectInput {
|
|
232
|
+
compiled_sql: string;
|
|
233
|
+
}
|
|
234
|
+
export interface ExecuteSelectResult {
|
|
235
|
+
rows: Array<{
|
|
236
|
+
values: Record<string, unknown>;
|
|
237
|
+
}>;
|
|
238
|
+
}
|
|
239
|
+
export interface DatasetsExecuteSelectJob extends BaseJob {
|
|
240
|
+
type: "datasets_execute_select";
|
|
241
|
+
input: ExecuteSelectInput;
|
|
242
|
+
result?: ExecuteSelectResult;
|
|
243
|
+
}
|
|
108
244
|
export interface SampleInput {
|
|
109
|
-
dataset_id:
|
|
245
|
+
dataset_id: number;
|
|
110
246
|
}
|
|
111
247
|
export type SampleResult = unknown;
|
|
112
248
|
export interface DatasetsSampleJob extends BaseJob {
|
|
@@ -114,24 +250,63 @@ export interface DatasetsSampleJob extends BaseJob {
|
|
|
114
250
|
input: SampleInput;
|
|
115
251
|
result?: SampleResult;
|
|
116
252
|
}
|
|
253
|
+
export interface SuggestMappingsInput {
|
|
254
|
+
dataset_id: number;
|
|
255
|
+
}
|
|
256
|
+
export interface SuggestMappingsResult {
|
|
257
|
+
result: string;
|
|
258
|
+
}
|
|
259
|
+
export interface DatasetsSuggestMappingsJob extends BaseJob {
|
|
260
|
+
type: "datasets_suggest_mappings";
|
|
261
|
+
input: SuggestMappingsInput;
|
|
262
|
+
result?: SuggestMappingsResult;
|
|
263
|
+
}
|
|
264
|
+
export type ColumnStatDataType = "boolean" | "double" | "long" | "string" | "timestamp_tz" | "array" | "object";
|
|
265
|
+
export interface EnabledColumnStatFlags {
|
|
266
|
+
nan_value_count?: boolean;
|
|
267
|
+
null_value_count?: boolean;
|
|
268
|
+
value_count?: boolean;
|
|
269
|
+
lower_bound?: boolean;
|
|
270
|
+
upper_bound?: boolean;
|
|
271
|
+
column_stored_bytes?: boolean;
|
|
272
|
+
approx_count_distinct?: boolean;
|
|
273
|
+
count_distinct?: boolean;
|
|
274
|
+
histogram?: boolean;
|
|
275
|
+
mean?: boolean;
|
|
276
|
+
standard_deviation?: boolean;
|
|
277
|
+
completeness?: boolean;
|
|
278
|
+
observed_types?: boolean;
|
|
279
|
+
}
|
|
117
280
|
export interface ColumnDetails {
|
|
118
|
-
data_type:
|
|
281
|
+
data_type: ColumnStatDataType;
|
|
282
|
+
enabled_column_stats?: EnabledColumnStatFlags;
|
|
119
283
|
}
|
|
120
284
|
export interface StatsInput {
|
|
121
|
-
dataset_id:
|
|
285
|
+
dataset_id: number;
|
|
122
286
|
enabled_column_stats?: Record<string, ColumnDetails>;
|
|
123
287
|
}
|
|
288
|
+
/** V2 input ships pre-compiled SQL instead of a column configuration. */
|
|
289
|
+
export interface StatsInputV2 {
|
|
290
|
+
dataset_id: number;
|
|
291
|
+
compiled_sql: string;
|
|
292
|
+
}
|
|
124
293
|
export type StatsResult = unknown;
|
|
125
294
|
export interface DatasetsCalculateColumnStatsJob extends BaseJob {
|
|
126
295
|
type: "datasets_calculate_column_stats";
|
|
127
|
-
input: StatsInput;
|
|
296
|
+
input: StatsInput | StatsInputV2;
|
|
128
297
|
result?: StatsResult;
|
|
129
298
|
}
|
|
299
|
+
export interface HealthCheckJob extends BaseJob {
|
|
300
|
+
type: "health_check";
|
|
301
|
+
input: unknown;
|
|
302
|
+
/** Compute pool health check report. */
|
|
303
|
+
result?: unknown;
|
|
304
|
+
}
|
|
130
305
|
export interface ModelTrainingRunInput {
|
|
131
|
-
company_id:
|
|
306
|
+
company_id: number;
|
|
132
307
|
connections?: unknown[];
|
|
133
308
|
custom_axolotl_config_override?: unknown;
|
|
134
|
-
dataset_id:
|
|
309
|
+
dataset_id: number;
|
|
135
310
|
instance_type: string;
|
|
136
311
|
base_model_id: string;
|
|
137
312
|
base_model_repository: string;
|
|
@@ -148,7 +323,7 @@ export interface ModelTrainingRunJob extends BaseJob {
|
|
|
148
323
|
result?: ModelTrainingRunResult;
|
|
149
324
|
}
|
|
150
325
|
export interface ModelsDeliverModelInput {
|
|
151
|
-
company_id:
|
|
326
|
+
company_id: number;
|
|
152
327
|
app_id: string;
|
|
153
328
|
connection_id: string;
|
|
154
329
|
profile_id: string;
|
|
@@ -163,13 +338,10 @@ export interface ModelsDeliverModelJob extends BaseJob {
|
|
|
163
338
|
input: ModelsDeliverModelInput;
|
|
164
339
|
result?: ModelsDeliverModelResult;
|
|
165
340
|
}
|
|
166
|
-
export interface UnknownJob extends BaseJob {
|
|
167
|
-
input: unknown;
|
|
168
|
-
result?: unknown;
|
|
169
|
-
}
|
|
170
341
|
export interface ModelsTrainClassifierJob extends BaseJob {
|
|
171
342
|
type: "models_train_classifier";
|
|
172
|
-
|
|
343
|
+
input: unknown;
|
|
344
|
+
result?: ModelsTrainClassifierResults;
|
|
173
345
|
}
|
|
174
346
|
export interface ModelInferenceRunInput {
|
|
175
347
|
model: string;
|
|
@@ -191,14 +363,40 @@ export interface ModelInferenceRunJobResult {
|
|
|
191
363
|
prompt_tokens: number;
|
|
192
364
|
completion_tokens: number;
|
|
193
365
|
};
|
|
194
|
-
structured_output
|
|
366
|
+
structured_output?: unknown;
|
|
367
|
+
tool_calls?: unknown[];
|
|
368
|
+
stop_reason?: string;
|
|
195
369
|
}
|
|
196
370
|
export interface ModelInferenceRunJob extends BaseJob {
|
|
197
371
|
type: "model_inference_run";
|
|
198
372
|
input: ModelInferenceRunInput;
|
|
199
373
|
result?: ModelInferenceRunJobResult;
|
|
200
374
|
}
|
|
201
|
-
|
|
375
|
+
/**
|
|
376
|
+
* Fallback for job types the SDK does not know about yet — the backend's
|
|
377
|
+
* job type is an open string, so new types can appear without an SDK release.
|
|
378
|
+
*/
|
|
379
|
+
export interface UnknownJob extends Omit<BaseJob, "type"> {
|
|
380
|
+
type: string;
|
|
381
|
+
input: unknown;
|
|
382
|
+
result?: unknown;
|
|
383
|
+
}
|
|
384
|
+
/** Discriminated union over every job type the SDK knows about. */
|
|
385
|
+
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;
|
|
386
|
+
export type Job = KnownJob | UnknownJob;
|
|
387
|
+
/**
|
|
388
|
+
* Narrows a job to the discriminated union of known types, enabling
|
|
389
|
+
* exhaustive `switch (job.type)` handling in consumers:
|
|
390
|
+
*
|
|
391
|
+
* ```ts
|
|
392
|
+
* if (isKnownJob(job)) {
|
|
393
|
+
* switch (job.type) {
|
|
394
|
+
* case "forecast": // job is ForecastJob
|
|
395
|
+
* }
|
|
396
|
+
* }
|
|
397
|
+
* ```
|
|
398
|
+
*/
|
|
399
|
+
export declare function isKnownJob(job: Job): job is KnownJob;
|
|
202
400
|
export interface ModelsTrainClassifierTrainingSummary {
|
|
203
401
|
total_features: number;
|
|
204
402
|
feature_types: Record<"text" | "categorical" | "embedding" | "numeric", number>;
|
package/build/jobs/types.js
CHANGED
|
@@ -1 +1,45 @@
|
|
|
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}.
|
|
5
|
+
*/
|
|
6
|
+
export const KNOWN_JOB_TYPES = [
|
|
7
|
+
"forecast",
|
|
8
|
+
"forecast-internal",
|
|
9
|
+
"nql-forecast",
|
|
10
|
+
"costs",
|
|
11
|
+
"materialize-view",
|
|
12
|
+
"materialized_views_collect_access_rules_billing_data",
|
|
13
|
+
"datasets_calculate_affected_rows",
|
|
14
|
+
"datasets_calculate_column_stats",
|
|
15
|
+
"datasets_create_table",
|
|
16
|
+
"datasets_delete_table",
|
|
17
|
+
"datasets_deliver_data",
|
|
18
|
+
"datasets_enforce_row_ttl_retention_policy",
|
|
19
|
+
"datasets_enforce_table_ttl_retention_policy",
|
|
20
|
+
"datasets_execute_dml",
|
|
21
|
+
"datasets_execute_select",
|
|
22
|
+
"datasets_sample",
|
|
23
|
+
"datasets_suggest_mappings",
|
|
24
|
+
"datasets_truncate_table",
|
|
25
|
+
"health_check",
|
|
26
|
+
"model_inference_run",
|
|
27
|
+
"model_training_run",
|
|
28
|
+
"models_deliver_model",
|
|
29
|
+
"models_train_classifier",
|
|
30
|
+
];
|
|
31
|
+
/**
|
|
32
|
+
* Narrows a job to the discriminated union of known types, enabling
|
|
33
|
+
* exhaustive `switch (job.type)` handling in consumers:
|
|
34
|
+
*
|
|
35
|
+
* ```ts
|
|
36
|
+
* if (isKnownJob(job)) {
|
|
37
|
+
* switch (job.type) {
|
|
38
|
+
* case "forecast": // job is ForecastJob
|
|
39
|
+
* }
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export function isKnownJob(job) {
|
|
44
|
+
return KNOWN_JOB_TYPES.includes(job.type);
|
|
45
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@narrative.io/data-collaboration-sdk-ts",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.107.0",
|
|
4
4
|
"main": "build/index.js",
|
|
5
5
|
"repository": "github:narrative-io/data-collaboration-sdk-ts",
|
|
6
6
|
"source": "src/index.ts",
|
|
@@ -25,18 +25,18 @@
|
|
|
25
25
|
"author": "",
|
|
26
26
|
"license": "ISC",
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@babel/core": "7.29.
|
|
29
|
-
"@babel/preset-env": "7.29.
|
|
30
|
-
"@babel/preset-typescript": "7.
|
|
31
|
-
"@biomejs/biome": "2.4.
|
|
28
|
+
"@babel/core": "7.29.7",
|
|
29
|
+
"@babel/preset-env": "7.29.7",
|
|
30
|
+
"@babel/preset-typescript": "7.29.7",
|
|
31
|
+
"@biomejs/biome": "2.4.16",
|
|
32
32
|
"@commitlint/cli": "21.0.1",
|
|
33
33
|
"@commitlint/config-conventional": "21.0.1",
|
|
34
34
|
"@types/jest": "30.0.0",
|
|
35
|
-
"@types/json-schema": "
|
|
35
|
+
"@types/json-schema": "7.0.15",
|
|
36
36
|
"babel-jest": "30.4.1",
|
|
37
37
|
"jest": "30.4.2",
|
|
38
|
-
"lefthook": "2.1.
|
|
39
|
-
"ts-jest": "29.4.
|
|
38
|
+
"lefthook": "2.1.8",
|
|
39
|
+
"ts-jest": "29.4.11"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"mande": "2.0.9",
|