@narrative.io/data-collaboration-sdk-ts 0.0.143 → 0.0.145
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/datasets/index.d.ts +41 -19
- package/build/datasets/index.js +49 -21
- package/build/datasets/types.d.ts +11 -0
- package/build/index.d.ts +3 -4
- package/build/index.js +1 -3
- package/package.json +1 -1
- package/build/inference/index.d.ts +0 -16
- package/build/inference/index.js +0 -51
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ApiRecords } from "../types";
|
|
2
2
|
import { BaseApi } from "../base-api";
|
|
3
|
-
import type { FilePerSnapshotResponse, Dataset, DatasetTableSummaryAPIResponse, ColumnStatistics, RetentionPolicy, DatasetTableSummary, RecalculationInfo, UpdateDatasetRequest, SchemaFileConfigType, SchemaPropertiesType, DatasetStatus, DatasetWriteMode, SchemaFileConfig, SchemaProperties, SchemaProperty, SchemaPrimitiveProperty, SchemaObjectProperty, SchemaArrayProperty, SchemaArrayItems, SchemaArrayItemsPrimitive, SchemaArrayItemsObject, SchemaArrayItemsArray, Schema, AdvancedStatisticsMetadata, SnapshotRange, Configuration, Columns, ColumnSummary, BasicStatistics, AdvancedStatistics, Histogram, Value } from "./types";
|
|
4
|
-
export { type FilePerSnapshotResponse, type Dataset, type RetentionPolicy, type DatasetTableSummaryAPIResponse, type ColumnStatistics, type UpdateDatasetRequest, type SchemaFileConfigType, type SchemaPropertiesType, type DatasetStatus, type DatasetWriteMode, type SchemaFileConfig, type SchemaProperties, type SchemaProperty, type SchemaPrimitiveProperty, type SchemaObjectProperty, type SchemaArrayProperty, type SchemaArrayItems, type SchemaArrayItemsPrimitive, type SchemaArrayItemsObject, type SchemaArrayItemsArray, type Schema, type AdvancedStatisticsMetadata, type SnapshotRange, type Configuration, type Columns, type ColumnSummary, type BasicStatistics, type AdvancedStatistics, type Histogram, type Value, };
|
|
3
|
+
import type { FilePerSnapshotResponse, Dataset, DatasetTableSummaryAPIResponse, ColumnStatistics, RetentionPolicy, DatasetTableSummary, RecalculationInfo, UpdateDatasetRequest, SchemaFileConfigType, SchemaPropertiesType, DatasetStatus, DatasetWriteMode, SchemaFileConfig, SchemaProperties, SchemaProperty, SchemaPrimitiveProperty, SchemaObjectProperty, SchemaArrayProperty, SchemaArrayItems, SchemaArrayItemsPrimitive, SchemaArrayItemsObject, SchemaArrayItemsArray, Schema, AdvancedStatisticsMetadata, SnapshotRange, Configuration, Columns, ColumnSummary, BasicStatistics, AdvancedStatistics, Histogram, Value, CreateDatasetRequest, IngestDatasetFileRequest } from "./types";
|
|
4
|
+
export { type FilePerSnapshotResponse, type Dataset, type RetentionPolicy, type DatasetTableSummaryAPIResponse, type ColumnStatistics, type UpdateDatasetRequest, type SchemaFileConfigType, type SchemaPropertiesType, type DatasetStatus, type DatasetWriteMode, type SchemaFileConfig, type SchemaProperties, type SchemaProperty, type SchemaPrimitiveProperty, type SchemaObjectProperty, type SchemaArrayProperty, type SchemaArrayItems, type SchemaArrayItemsPrimitive, type SchemaArrayItemsObject, type SchemaArrayItemsArray, type Schema, type AdvancedStatisticsMetadata, type SnapshotRange, type Configuration, type Columns, type ColumnSummary, type BasicStatistics, type AdvancedStatistics, type Histogram, type Value, type CreateDatasetRequest, };
|
|
5
5
|
/**
|
|
6
6
|
* @module DatasetApi
|
|
7
7
|
* @description This module provides methods for fetching datasets.
|
|
@@ -19,6 +19,45 @@ export declare class DatasetApi extends BaseApi {
|
|
|
19
19
|
* @returns {Promise<ApiRecords<Dataset>>} - Promise resolving to an array of datasets
|
|
20
20
|
*/
|
|
21
21
|
getDatasets(): Promise<ApiRecords<Dataset>>;
|
|
22
|
+
/**
|
|
23
|
+
* Deletes a specific dataset from the system.
|
|
24
|
+
* This method sends a DELETE request to the specified endpoint to remove the dataset.
|
|
25
|
+
*
|
|
26
|
+
* @param {number} datasetId - The ID of the dataset to be deleted.
|
|
27
|
+
* @returns {Promise<void>} A promise that resolves when the dataset has been successfully deleted.
|
|
28
|
+
*/
|
|
29
|
+
deleteDataset(datasetId: number): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Updates an existing dataset with the provided data.
|
|
32
|
+
*
|
|
33
|
+
* @param {UpdateDatasetRequest} request - The request containing the dataset information to be updated.
|
|
34
|
+
* @returns {Promise<Dataset>} - Returns a Promise that resolves to the updated Dataset.
|
|
35
|
+
* @public
|
|
36
|
+
* @async
|
|
37
|
+
*/
|
|
38
|
+
updateDataset(request: UpdateDatasetRequest): Promise<Dataset>;
|
|
39
|
+
/**
|
|
40
|
+
* Creates a dataset based on the provided request.
|
|
41
|
+
*
|
|
42
|
+
* @param {CreateDatasetRequest} request - The request payload for creating a dataset.
|
|
43
|
+
* @returns {Promise<Dataset>} A promise that resolves with the newly created dataset.
|
|
44
|
+
*/
|
|
45
|
+
createDataset(request: CreateDatasetRequest): Promise<Dataset>;
|
|
46
|
+
/**
|
|
47
|
+
* Activates a dataset with the specified dataset ID.
|
|
48
|
+
*
|
|
49
|
+
* @param {number} datasetId - The ID of the dataset to activate.
|
|
50
|
+
* @returns {Promise<Dataset>} A promise that resolves with the activated dataset.
|
|
51
|
+
*/
|
|
52
|
+
activateDataset(datasetId: number): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Ingests a dataset file with the provided source_file url to the dataset with the specified dataset ID.
|
|
55
|
+
*
|
|
56
|
+
* @param {IngestDatasetFileRequest} request - The request containing the source_file url
|
|
57
|
+
* @param {number} datasetId - The ID of the dataset to which to ingest the file.
|
|
58
|
+
* @returns {Promise<void>} A promise that resolve when the operation is successful.
|
|
59
|
+
*/
|
|
60
|
+
ingestDatasetFile(request: IngestDatasetFileRequest, datasetId: number): Promise<void>;
|
|
22
61
|
/**
|
|
23
62
|
* Get summary information for a dataset.
|
|
24
63
|
*
|
|
@@ -118,21 +157,4 @@ export declare class DatasetApi extends BaseApi {
|
|
|
118
157
|
* @returns {Promise<RecalculationInfo>} A promise that resolves when the operation is complete.
|
|
119
158
|
*/
|
|
120
159
|
recalculateDatasetColumnStatistics(datasetId: number): Promise<RecalculationInfo>;
|
|
121
|
-
/**
|
|
122
|
-
* Deletes a specific dataset from the system.
|
|
123
|
-
* This method sends a DELETE request to the specified endpoint to remove the dataset.
|
|
124
|
-
*
|
|
125
|
-
* @param {number} datasetId - The ID of the dataset to be deleted.
|
|
126
|
-
* @returns {Promise<void>} A promise that resolves when the dataset has been successfully deleted.
|
|
127
|
-
*/
|
|
128
|
-
deleteDataset(datasetId: number): Promise<void>;
|
|
129
|
-
/**
|
|
130
|
-
* Updates an existing dataset with the provided data.
|
|
131
|
-
*
|
|
132
|
-
* @param {UpdateDatasetRequest} request - The request containing the dataset information to be updated.
|
|
133
|
-
* @returns {Promise<Dataset>} - Returns a Promise that resolves to the updated Dataset.
|
|
134
|
-
* @public
|
|
135
|
-
* @async
|
|
136
|
-
*/
|
|
137
|
-
updateDataset(request: UpdateDatasetRequest): Promise<Dataset>;
|
|
138
160
|
}
|
package/build/datasets/index.js
CHANGED
|
@@ -21,6 +21,55 @@ export class DatasetApi extends BaseApi {
|
|
|
21
21
|
async getDatasets() {
|
|
22
22
|
return await this.get(`${resourceName}`);
|
|
23
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Deletes a specific dataset from the system.
|
|
26
|
+
* This method sends a DELETE request to the specified endpoint to remove the dataset.
|
|
27
|
+
*
|
|
28
|
+
* @param {number} datasetId - The ID of the dataset to be deleted.
|
|
29
|
+
* @returns {Promise<void>} A promise that resolves when the dataset has been successfully deleted.
|
|
30
|
+
*/
|
|
31
|
+
async deleteDataset(datasetId) {
|
|
32
|
+
await this.delete(`${resourceName}/${datasetId}`);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Updates an existing dataset with the provided data.
|
|
36
|
+
*
|
|
37
|
+
* @param {UpdateDatasetRequest} request - The request containing the dataset information to be updated.
|
|
38
|
+
* @returns {Promise<Dataset>} - Returns a Promise that resolves to the updated Dataset.
|
|
39
|
+
* @public
|
|
40
|
+
* @async
|
|
41
|
+
*/
|
|
42
|
+
async updateDataset(request) {
|
|
43
|
+
return await this.put(`${resourceName}/${request.dataset_id}`, request);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Creates a dataset based on the provided request.
|
|
47
|
+
*
|
|
48
|
+
* @param {CreateDatasetRequest} request - The request payload for creating a dataset.
|
|
49
|
+
* @returns {Promise<Dataset>} A promise that resolves with the newly created dataset.
|
|
50
|
+
*/
|
|
51
|
+
async createDataset(request) {
|
|
52
|
+
return await this.post(`${resourceName}`, request);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Activates a dataset with the specified dataset ID.
|
|
56
|
+
*
|
|
57
|
+
* @param {number} datasetId - The ID of the dataset to activate.
|
|
58
|
+
* @returns {Promise<Dataset>} A promise that resolves with the activated dataset.
|
|
59
|
+
*/
|
|
60
|
+
async activateDataset(datasetId) {
|
|
61
|
+
await this.put(`${resourceName}/${datasetId}/activate`, null);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Ingests a dataset file with the provided source_file url to the dataset with the specified dataset ID.
|
|
65
|
+
*
|
|
66
|
+
* @param {IngestDatasetFileRequest} request - The request containing the source_file url
|
|
67
|
+
* @param {number} datasetId - The ID of the dataset to which to ingest the file.
|
|
68
|
+
* @returns {Promise<void>} A promise that resolve when the operation is successful.
|
|
69
|
+
*/
|
|
70
|
+
async ingestDatasetFile(request, datasetId) {
|
|
71
|
+
await this.post(`${resourceName}/${datasetId}/upload`, request);
|
|
72
|
+
}
|
|
24
73
|
/**
|
|
25
74
|
* Get summary information for a dataset.
|
|
26
75
|
*
|
|
@@ -145,25 +194,4 @@ export class DatasetApi extends BaseApi {
|
|
|
145
194
|
async recalculateDatasetColumnStatistics(datasetId) {
|
|
146
195
|
return await this.post(`${resourceName}/${datasetId}/column-stats/recalculate`, {});
|
|
147
196
|
}
|
|
148
|
-
/**
|
|
149
|
-
* Deletes a specific dataset from the system.
|
|
150
|
-
* This method sends a DELETE request to the specified endpoint to remove the dataset.
|
|
151
|
-
*
|
|
152
|
-
* @param {number} datasetId - The ID of the dataset to be deleted.
|
|
153
|
-
* @returns {Promise<void>} A promise that resolves when the dataset has been successfully deleted.
|
|
154
|
-
*/
|
|
155
|
-
async deleteDataset(datasetId) {
|
|
156
|
-
await this.delete(`${resourceName}/${datasetId}`);
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Updates an existing dataset with the provided data.
|
|
160
|
-
*
|
|
161
|
-
* @param {UpdateDatasetRequest} request - The request containing the dataset information to be updated.
|
|
162
|
-
* @returns {Promise<Dataset>} - Returns a Promise that resolves to the updated Dataset.
|
|
163
|
-
* @public
|
|
164
|
-
* @async
|
|
165
|
-
*/
|
|
166
|
-
async updateDataset(request) {
|
|
167
|
-
return await this.put(`${resourceName}/${request.dataset_id}`, request);
|
|
168
|
-
}
|
|
169
197
|
}
|
|
@@ -220,4 +220,15 @@ export interface UpdateDatasetRequest {
|
|
|
220
220
|
write_mode?: DatasetWriteMode;
|
|
221
221
|
schema?: Schema;
|
|
222
222
|
}
|
|
223
|
+
export interface CreateDatasetRequest {
|
|
224
|
+
name: string;
|
|
225
|
+
schema: Schema;
|
|
226
|
+
write_mode: DatasetWriteMode;
|
|
227
|
+
description?: string;
|
|
228
|
+
tags?: string[];
|
|
229
|
+
derive_metrics_config?: boolean;
|
|
230
|
+
}
|
|
231
|
+
export interface IngestDatasetFileRequest {
|
|
232
|
+
source_file: string;
|
|
233
|
+
}
|
|
223
234
|
export {};
|
package/build/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { DatasetApi } from "./datasets";
|
|
|
3
3
|
import { HealthCheckApi } from "./health";
|
|
4
4
|
import { RosettaStoneApi } from "./rosetta-stone";
|
|
5
5
|
import { type Environment, type Config, type ApiRecords, type MonetaryAmount } from "./types";
|
|
6
|
-
import type { DatasetTableSummaryAPIResponse, Dataset, DatasetTableSummary, FilePerSnapshotResponse, RetentionPolicy, UpdateDatasetRequest, SchemaFileConfigType, SchemaPropertiesType, DatasetStatus, DatasetWriteMode, SchemaFileConfig, SchemaProperties, SchemaProperty, SchemaPrimitiveProperty, SchemaObjectProperty, SchemaArrayProperty, SchemaArrayItems, SchemaArrayItemsPrimitive, SchemaArrayItemsObject, SchemaArrayItemsArray, Schema, AdvancedStatisticsMetadata, SnapshotRange, Configuration, Columns, ColumnSummary, ColumnStatistics, BasicStatistics, AdvancedStatistics, Histogram, Value } from "./datasets/types";
|
|
6
|
+
import type { DatasetTableSummaryAPIResponse, Dataset, DatasetTableSummary, FilePerSnapshotResponse, RetentionPolicy, UpdateDatasetRequest, SchemaFileConfigType, SchemaPropertiesType, DatasetStatus, DatasetWriteMode, SchemaFileConfig, SchemaProperties, SchemaProperty, SchemaPrimitiveProperty, SchemaObjectProperty, SchemaArrayProperty, SchemaArrayItems, SchemaArrayItemsPrimitive, SchemaArrayItemsObject, SchemaArrayItemsArray, Schema, AdvancedStatisticsMetadata, SnapshotRange, Configuration, Columns, ColumnSummary, ColumnStatistics, BasicStatistics, AdvancedStatistics, Histogram, Value, CreateDatasetRequest, IngestDatasetFileRequest } from "./datasets/types";
|
|
7
7
|
import { type HealthCheckResult } from "./health/types";
|
|
8
8
|
import { type SampleRecords } from "./rosetta-stone/types";
|
|
9
9
|
import { AttributeApi } from "./attributes";
|
|
@@ -29,9 +29,8 @@ import { type ConversationMessageRole, isConversationMessageRole, type Conversat
|
|
|
29
29
|
import { MappingsApi } from "./mappings";
|
|
30
30
|
import { type AccessRule, AccessRulesApi } from "./access-rules/";
|
|
31
31
|
import { type Subscription, type SubscriptionDetails, type DataStreamSubscriptionDetails, type MarketplaceSubscriptionDetails, type SubscriptionOutput, type SubscriptionType, type SubscriptionStatus, type SubscriptionBudget, SubscriptionsApi } from "./subscriptions";
|
|
32
|
-
import { InferenceApi } from "./inference";
|
|
33
32
|
declare class NarrativeApi extends BaseApi {
|
|
34
33
|
}
|
|
35
|
-
interface NarrativeApi extends BaseApi, HealthCheckApi, DatasetApi, RosettaStoneApi, AttributeApi, PingApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi, AuthenticationApi, MappingsApi, AccessRulesApi, AppsApi, SubscriptionsApi
|
|
34
|
+
interface NarrativeApi extends BaseApi, HealthCheckApi, DatasetApi, RosettaStoneApi, AttributeApi, PingApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi, AuthenticationApi, MappingsApi, AccessRulesApi, AppsApi, SubscriptionsApi {
|
|
36
35
|
}
|
|
37
|
-
export { NarrativeApi, AttributeApi, HealthCheckApi, DatasetApi, PingApi, ProductsApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi, AuthenticationApi, AppsApi, MappingsApi, AccessRulesApi, SubscriptionsApi,
|
|
36
|
+
export { NarrativeApi, AttributeApi, HealthCheckApi, DatasetApi, PingApi, ProductsApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi, AuthenticationApi, AppsApi, MappingsApi, AccessRulesApi, SubscriptionsApi, getNqlObject, buildNql, convertNqlObjectToForecastBody, isConversationAssistantMessage, isConversationFunctionMessage, isConversationInputMessage, isConversationMessage, isConversationMessageName, isConversationMessageRole, isConversationMessages, isConversationSystemMessage, isConversationUserMessage, isType, isConversationMessageFunctionCall, isConversationAssistantMessageWithFunctionCall, isRosettaRequestMessage, isConversationAssistantMessageWithoutFunctionCall, type App, type Resource, type UploadsResponse, type PingStatus, type Attribute, type ShallowAttribute, type RefAttribute, type SubAttribute, type PrimitiveAttribute, type ArrayAttribute, type ObjectAttribute, type Environment, type Config, type ApiRecords, type Dataset, type HealthCheckResult, type SampleRecords, type DatasetTableSummary, type DatasetTableSummaryAPIResponse, type UpdateDatasetRequest, type SchemaFileConfigType, type SchemaPropertiesType, type DatasetStatus, type DatasetWriteMode, type SchemaFileConfig, type SchemaProperties, type SchemaProperty, type SchemaPrimitiveProperty, type SchemaObjectProperty, type SchemaArrayProperty, type SchemaArrayItems, type SchemaArrayItemsPrimitive, type SchemaArrayItemsObject, type SchemaArrayItemsArray, type Schema, type AdvancedStatisticsMetadata, type SnapshotRange, type Configuration, type Columns, type ColumnSummary, type ColumnStatistics, type BasicStatistics, type AdvancedStatistics, type Histogram, type Value, type CreateDatasetRequest, type IngestDatasetFileRequest, type Product, type MonetaryAmount, type CompanyInfo, type Installation, type FilePerSnapshotResponse, type BucketCreationRequest, type UpdateAccessTypeRequest, type CompiledNql, type CreateMaterializedView, type Deduplication, type Explain, type Expression, type Raw, type Select, type Statement, type Table, type Nql, type NqlAst, type NqlField, type NqlResult, type NqlQueryInput, type NqlCompileResult, type NqlExpression, type NqlWhere, type NqlFilterExpression, type NqlBooleanExpression, type NqlFilterBinaryExpression, type NqlFilterUnaryExpression, type DataStream, type DataRules, type ColumnSet, type ColumnWithFilterAndExport, type AttributeSet, type ForecastRequest, type ForecastResponse, type CostForecastRequest, type CostForecastResponse, type JobState, type ContractDetails, type CustomerContract, type PaymentMethod, type ContractRateView, type LoginRequest, type LoginResponse, type RegisterRequest, type RegisterResponse, type LoggedInUser, type StytchToken, type ApiToken, type UserRole, type RegistrationStatus, type RegistrationStatusRequest, type RegistrationStatusResponse, type ForecastBody, type ConversationAssistantMessage, type ConversationFunctionMessage, type ConversationIOMessage, type ConversationMessage, type ConversationMessageName, type ConversationMessageRole, type ConversationMessages, type ConversationSystemMessage, type ConversationUserMessage, type RosettaRequestMessage, type ConversationMessageFunctionCall, type ConversationAssistantMessageWithFunctionCall, type RosettaResponseMessage, type ConversationAssistantMessageWithoutFunctionCall, type RetentionPolicy, type AccessRule, type Subscription, type SubscriptionDetails, type DataStreamSubscriptionDetails, type MarketplaceSubscriptionDetails, type SubscriptionOutput, type SubscriptionType, type SubscriptionStatus, type SubscriptionBudget, compileStatement, parseStatement, };
|
package/build/index.js
CHANGED
|
@@ -22,7 +22,6 @@ import { isConversationMessageRole, isConversationMessageName, isConversationUse
|
|
|
22
22
|
import { MappingsApi } from "./mappings";
|
|
23
23
|
import { AccessRulesApi } from "./access-rules/";
|
|
24
24
|
import { SubscriptionsApi, } from "./subscriptions";
|
|
25
|
-
import { InferenceApi } from "./inference";
|
|
26
25
|
class NarrativeApi extends BaseApi {
|
|
27
26
|
}
|
|
28
27
|
applyMixins(NarrativeApi, [
|
|
@@ -45,6 +44,5 @@ applyMixins(NarrativeApi, [
|
|
|
45
44
|
AppsApi,
|
|
46
45
|
AccessRulesApi,
|
|
47
46
|
SubscriptionsApi,
|
|
48
|
-
InferenceApi,
|
|
49
47
|
]);
|
|
50
|
-
export { NarrativeApi, AttributeApi, HealthCheckApi, DatasetApi, PingApi, ProductsApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi, AuthenticationApi, AppsApi, MappingsApi, AccessRulesApi, SubscriptionsApi,
|
|
48
|
+
export { NarrativeApi, AttributeApi, HealthCheckApi, DatasetApi, PingApi, ProductsApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi, AuthenticationApi, AppsApi, MappingsApi, AccessRulesApi, SubscriptionsApi, getNqlObject, buildNql, convertNqlObjectToForecastBody, isConversationAssistantMessage, isConversationFunctionMessage, isConversationInputMessage, isConversationMessage, isConversationMessageName, isConversationMessageRole, isConversationMessages, isConversationSystemMessage, isConversationUserMessage, isType, isConversationMessageFunctionCall, isConversationAssistantMessageWithFunctionCall, isRosettaRequestMessage, isConversationAssistantMessageWithoutFunctionCall, compileStatement, parseStatement, };
|
package/package.json
CHANGED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { type Schema } from "src/datasets";
|
|
2
|
-
import { BaseApi } from "../base-api";
|
|
3
|
-
/**
|
|
4
|
-
* A class for accessing the Inference API.
|
|
5
|
-
* @extends BaseApi
|
|
6
|
-
*/
|
|
7
|
-
export declare class InferenceApi extends BaseApi {
|
|
8
|
-
private makeFileExtension;
|
|
9
|
-
/**
|
|
10
|
-
* Infers the schema of a file
|
|
11
|
-
*
|
|
12
|
-
* @param {File} file - The file for which to infer the schema.
|
|
13
|
-
* @returns {Promise<Schema>} A promise that resolves with the schema.
|
|
14
|
-
*/
|
|
15
|
-
inferFileSchema(file: File): Promise<Schema>;
|
|
16
|
-
}
|
package/build/inference/index.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { BaseApi } from "../base-api";
|
|
2
|
-
const defaultEndpoint = "csv/format-schema/multipart";
|
|
3
|
-
const endpointToFileTypes = {
|
|
4
|
-
[defaultEndpoint]: ["csv", "txt"],
|
|
5
|
-
"json/schema/multipart": ["json", "jsonl"],
|
|
6
|
-
"parquet/schema/multipart": ["parquet"],
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* The name of the resource to be used in API requests.
|
|
10
|
-
* @constant
|
|
11
|
-
* @private
|
|
12
|
-
* @type {string}
|
|
13
|
-
*/
|
|
14
|
-
const resourceName = "inference";
|
|
15
|
-
/**
|
|
16
|
-
* A class for accessing the Inference API.
|
|
17
|
-
* @extends BaseApi
|
|
18
|
-
*/
|
|
19
|
-
export class InferenceApi extends BaseApi {
|
|
20
|
-
makeFileExtension(file) {
|
|
21
|
-
return file.name.split(".")?.pop();
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Infers the schema of a file
|
|
25
|
-
*
|
|
26
|
-
* @param {File} file - The file for which to infer the schema.
|
|
27
|
-
* @returns {Promise<Schema>} A promise that resolves with the schema.
|
|
28
|
-
*/
|
|
29
|
-
async inferFileSchema(file) {
|
|
30
|
-
console.log("file", file);
|
|
31
|
-
const extension = this.makeFileExtension(file);
|
|
32
|
-
let endpointForExtension;
|
|
33
|
-
let endpoint;
|
|
34
|
-
console.log("endpointToFileTypes", endpointToFileTypes);
|
|
35
|
-
if (extension !== undefined) {
|
|
36
|
-
endpointForExtension = Object.keys(endpointToFileTypes).find((key) => {
|
|
37
|
-
return endpointToFileTypes[key].includes(extension);
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
if (endpointForExtension === undefined) {
|
|
41
|
-
endpoint = defaultEndpoint;
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
endpoint = endpointForExtension;
|
|
45
|
-
}
|
|
46
|
-
console.log("endpoint", endpoint);
|
|
47
|
-
const formData = new FormData();
|
|
48
|
-
formData.append("file", file);
|
|
49
|
-
return await this.post(`${resourceName}/${endpoint}`, formData);
|
|
50
|
-
}
|
|
51
|
-
}
|