@narrative.io/data-collaboration-sdk-ts 2.58.0 → 2.59.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/README.md CHANGED
@@ -1,18 +1,316 @@
1
- # SDK
1
+ # Narrative.io Data Collaboration SDK for TypeScript
2
2
 
3
- ## Make a release
3
+ [![npm version](https://img.shields.io/npm/v/@narrative.io/data-collaboration-sdk-ts.svg)](https://www.npmjs.com/package/@narrative.io/data-collaboration-sdk-ts)
4
4
 
5
- To make a new release of the SDK, create a branch, make your changes, create a commit with a message following this
6
- format: `chore(main): release x.y.z` where x.y.z is the release number that you want. You can calculate it like this:
5
+ The official TypeScript SDK for the Narrative.io Data Collaboration Platform. This SDK provides a simple and intuitive interface for interacting with Narrative's APIs, allowing you to manage datasets, subscriptions, data streams, and more.
6
+
7
+ ## Table of Contents
8
+
9
+ - [Installation](#installation)
10
+ - [Quick Start](#quick-start)
11
+ - [API Overview](#api-overview)
12
+ - [Usage Examples](#usage-examples)
13
+ - [Configuration](#configuration)
14
+ - [TypeScript Support](#typescript-support)
15
+ - [Error Handling](#error-handling)
16
+ - [API Reference](#api-reference)
17
+ - [Contributing](#contributing)
18
+ - [License](#license)
19
+
20
+ ## Installation
21
+
22
+ Install the SDK using npm:
23
+
24
+ ```bash
25
+ npm install @narrative.io/data-collaboration-sdk-ts
26
+ ```
27
+
28
+ Or using yarn:
29
+
30
+ ```bash
31
+ yarn add @narrative.io/data-collaboration-sdk-ts
32
+ ```
33
+
34
+ Or using bun:
7
35
 
8
36
  ```bash
9
- VERSION=$(cat package.json | jq -r .version); \
10
- PATCH=$(expr $(echo $VERSION|cut -f3 -d.) + 1); \
11
- NEW_VERSION=$(printf "$(echo $VERSION | cut -f1,2 -d.).$PATCH\n"); \
12
- echo $NEW_VERSION | pbcopy; \
13
- echo "The new VERSION=${NEW_VERSION} is in your clipboard."
37
+ bun add @narrative.io/data-collaboration-sdk-ts
38
+ ```
39
+
40
+ ## Quick Start
41
+
42
+ ```typescript
43
+ import { NarrativeApi } from '@narrative.io/data-collaboration-sdk-ts';
44
+
45
+ // Initialize the SDK with your API key
46
+ const narrative = new NarrativeApi({
47
+ apiKey: 'your-api-key-here',
48
+ environment: 'prod' // 'prod' or 'dev'
49
+ });
50
+
51
+ // Make your first API call
52
+ async function getMyCompanyInfo() {
53
+ try {
54
+ const companyInfo = await narrative.getCompanyInfo();
55
+ console.log('Company:', companyInfo);
56
+ } catch (error) {
57
+ console.error('Error:', error);
58
+ }
59
+ }
60
+
61
+ getMyCompanyInfo();
62
+ ```
63
+
64
+ ## API Overview
65
+
66
+ The SDK provides access to the following Narrative.io API modules:
67
+
68
+ ### Core APIs
69
+ - **Authentication** - Manage API authentication
70
+ - **Company Info** - Retrieve company information
71
+ - **Health Check** - Check API health status
72
+ - **Who Am I** - Get current user information
73
+
74
+ ### Data Management
75
+ - **Datasets** - Create and manage datasets
76
+ - **Data Streams** - Configure real-time data streams
77
+ - **Data Planes** - Manage data plane configurations
78
+ - **Subscriptions** - Handle data subscriptions
79
+ - **Uploads** - Upload data files
80
+
81
+ ### Data Operations
82
+ - **Queries** - Execute data queries
83
+ - **Forecast** - Generate data forecasts
84
+ - **NQL (Narrative Query Language)** - Build and execute NQL queries
85
+ - **Views** - Create and manage data views
86
+
87
+ ### Marketplace & Collaboration
88
+ - **Products** - Browse and manage data products
89
+ - **Contracts** - Handle data contracts
90
+ - **Connections** - Manage data connections
91
+ - **Installations** - Track app installations
92
+
93
+ ### Advanced Features
94
+ - **Attributes** - Define data attributes
95
+ - **Mappings** - Configure data mappings
96
+ - **Models** - Work with ML models
97
+ - **Model Training** - Train custom models
98
+ - **Rosetta Stone** - Data transformation tools
99
+ - **Access Rules** - Set data access permissions
100
+ - **Access Tokens** - Manage API tokens
101
+ - **Encryption Materials** - Handle encryption keys
102
+
103
+ ## Usage Examples
104
+
105
+ ### Working with Datasets
106
+
107
+ ```typescript
108
+ // List all datasets
109
+ const datasets = await narrative.getDatasets();
110
+ console.log(`Found ${datasets.length} datasets`);
111
+
112
+ // Get a specific dataset
113
+ const datasetId = 'your-dataset-id';
114
+ const dataset = await narrative.getDataset(datasetId);
115
+ console.log('Dataset name:', dataset.name);
116
+
117
+ // Create a new dataset
118
+ const newDataset = await narrative.createDataset({
119
+ name: 'My New Dataset',
120
+ description: 'A dataset created via SDK',
121
+ schema: {
122
+ // Your schema definition
123
+ }
124
+ });
125
+ ```
126
+
127
+ ### Managing Subscriptions
128
+
129
+ ```typescript
130
+ // List active subscriptions
131
+ const subscriptions = await narrative.getSubscriptions();
132
+ subscriptions.forEach(sub => {
133
+ console.log(`Subscription: ${sub.name} - Status: ${sub.status}`);
134
+ });
135
+
136
+ // Create a subscription
137
+ const subscription = await narrative.createSubscription({
138
+ name: 'Daily Data Feed',
139
+ datasetId: 'dataset-id',
140
+ frequency: 'daily'
141
+ });
142
+ ```
143
+
144
+ ### Executing NQL Queries
145
+
146
+ ```typescript
147
+ // Build and execute an NQL query
148
+ const nqlQuery = `
149
+ SELECT *
150
+ FROM narrative.datasets
151
+ WHERE created_date >= '2024-01-01'
152
+ LIMIT 100
153
+ `;
154
+
155
+ const results = await narrative.executeNql(nqlQuery);
156
+ console.log('Query returned', results.rows.length, 'rows');
157
+ ```
158
+
159
+ ### Uploading Data
160
+
161
+ ```typescript
162
+ // Upload a file to a dataset
163
+ const upload = await narrative.createUpload({
164
+ datasetId: 'your-dataset-id',
165
+ fileName: 'data.csv',
166
+ fileSize: 1024000 // Size in bytes
167
+ });
168
+
169
+ // Get the upload URL and upload your file
170
+ console.log('Upload URL:', upload.uploadUrl);
171
+ // Use the uploadUrl to PUT your file data
172
+ ```
173
+
174
+ ## Configuration
175
+
176
+ ### Environment Configuration
177
+
178
+ The SDK supports multiple environments:
179
+
180
+ ```typescript
181
+ // Production environment (default)
182
+ const narrativeProd = new NarrativeApi({
183
+ apiKey: 'your-api-key'
184
+ });
185
+
186
+ // Development environment
187
+ const narrativeDev = new NarrativeApi({
188
+ apiKey: 'your-api-key',
189
+ environment: 'dev'
190
+ });
191
+ ```
192
+
193
+ ### Custom Headers
194
+
195
+ Add custom headers to all requests:
196
+
197
+ ```typescript
198
+ const narrative = new NarrativeApi({
199
+ apiKey: 'your-api-key',
200
+ headers: {
201
+ 'X-Custom-Header': 'custom-value'
202
+ }
203
+ });
204
+ ```
205
+
206
+ ### API Key Management
207
+
208
+ Store your API key securely using environment variables:
209
+
210
+ ```typescript
211
+ // .env file
212
+ NARRATIVE_API_KEY=your-api-key-here
213
+
214
+ // Your code
215
+ import { NarrativeApi } from '@narrative.io/data-collaboration-sdk-ts';
216
+
217
+ const narrative = new NarrativeApi({
218
+ apiKey: process.env.NARRATIVE_API_KEY!
219
+ });
220
+ ```
221
+
222
+ ## TypeScript Support
223
+
224
+ The SDK is written in TypeScript and provides comprehensive type definitions:
225
+
226
+ ```typescript
227
+ import {
228
+ NarrativeApi,
229
+ Dataset,
230
+ Subscription,
231
+ DataStream,
232
+ NqlQuery
233
+ } from '@narrative.io/data-collaboration-sdk-ts';
234
+
235
+ // Type-safe API calls
236
+ const narrative = new NarrativeApi({
237
+ apiKey: 'your-api-key'
238
+ });
239
+
240
+ // TypeScript will provide intellisense and type checking
241
+ const dataset: Dataset = await narrative.getDataset('dataset-id');
242
+ const subscriptions: Subscription[] = await narrative.getSubscriptions();
243
+ ```
244
+
245
+ ### Working with Types
246
+
247
+ ```typescript
248
+ import type {
249
+ Config,
250
+ PaginationOptions,
251
+ Dataset,
252
+ CreateDatasetRequest
253
+ } from '@narrative.io/data-collaboration-sdk-ts';
254
+
255
+ // Use types for better code organization
256
+ const config: Config = {
257
+ apiKey: process.env.NARRATIVE_API_KEY!,
258
+ environment: 'prod'
259
+ };
260
+
261
+ const paginationOptions: PaginationOptions = {
262
+ limit: 100,
263
+ offset: 0
264
+ };
14
265
  ```
15
266
 
16
- Push your changes to the branch, merge it to the `main` branch. Once the merge is completed (i.e., github actions
17
- completed) a new release pull request will be available on the github project. Merge the new pull request and the
18
- github actions will publish the new version of the SKD for you.
267
+ ## Error Handling
268
+
269
+ The SDK provides detailed error information:
270
+
271
+ ```typescript
272
+ import { NarrativeApi } from '@narrative.io/data-collaboration-sdk-ts';
273
+
274
+ const narrative = new NarrativeApi({
275
+ apiKey: 'your-api-key'
276
+ });
277
+
278
+ try {
279
+ const dataset = await narrative.getDataset('non-existent-id');
280
+ } catch (error) {
281
+ if (error.response) {
282
+ // API returned an error response
283
+ console.error('API Error:', error.response.status);
284
+ console.error('Error Message:', error.response.data.message);
285
+ } else if (error.request) {
286
+ // Request was made but no response received
287
+ console.error('Network Error:', error.message);
288
+ } else {
289
+ // Something else happened
290
+ console.error('Error:', error.message);
291
+ }
292
+ }
293
+ ```
294
+
295
+ ### Common Error Patterns
296
+
297
+ ```typescript
298
+ // Handle specific error codes
299
+ try {
300
+ const result = await narrative.someApiCall();
301
+ } catch (error) {
302
+ if (error.response?.status === 401) {
303
+ console.error('Authentication failed. Check your API key.');
304
+ } else if (error.response?.status === 404) {
305
+ console.error('Resource not found.');
306
+ } else if (error.response?.status === 429) {
307
+ console.error('Rate limit exceeded. Please retry later.');
308
+ } else {
309
+ console.error('Unexpected error:', error);
310
+ }
311
+ }
312
+ ```
313
+
314
+ ## API Reference
315
+
316
+ For detailed API documentation, please visit the [Narrative.io API Documentation](https://api.narrative.dev).
package/build/index.d.ts CHANGED
@@ -1,53 +1,82 @@
1
- import { type AccessRule, AccessRulesApi, type AccessRuleV2, type CreateAccessRuleV2Request, type GetAccessRulesParameters, type OwnedAccessRule, type SharedAccessRule, type UpdateAccessRuleV2Request } from "./access-rules/";
2
- import type { AccessRuleSchema } from "./access-rules/types";
3
- import { type AccessTokenMetadata, AccessTokensApi, type CreateSystemAccessTokenRequest, type CreateSystemAccessTokenResponse, type UpdateSystemAccessTokenRequest } from "./access-tokens";
4
- import { type Permission, resources } from "./access-tokens/types";
5
- import { type App, AppsApi } from "./apps";
1
+ export * from "./access-rules/";
2
+ export * from "./access-tokens";
3
+ export { resources } from "./access-tokens/types";
4
+ export type { App } from "./apps";
5
+ export * from "./attributes";
6
+ export * from "./authentication";
7
+ export * from "./base-api";
8
+ export * from "./company-info";
9
+ export * from "./connections";
10
+ export * from "./contracts";
11
+ export * from "./data-planes";
12
+ export * from "./data-planes/types";
13
+ export * from "./data-streams";
14
+ export * from "./datasets";
15
+ export * from "./datasets/types";
16
+ export * from "./encryption-materials";
17
+ export * from "./encryption-materials/types";
18
+ export * from "./forecast";
19
+ export * from "./health";
20
+ export * from "./health/types";
21
+ export * from "./installations";
22
+ export * from "./jobs";
23
+ export { default as JsonBigNumber } from "./json-big-number";
24
+ export * from "./mappings";
25
+ export * from "./mappings/types";
26
+ export * from "./model-training";
27
+ export * from "./models";
28
+ export * from "./nql";
29
+ export { compileStatement, parseStatement } from "./nql";
30
+ export { convertNqlObjectToForecastBody } from "./nql/DataRulesConverter";
31
+ export { buildNql, getNqlObject } from "./nql/NQLParser";
32
+ export type { AstNodeMetadata, AstNodeType, ForecastBody } from "./nql/types";
33
+ export * from "./ping";
34
+ export * from "./ping/types";
35
+ export * from "./products";
36
+ export * from "./queries";
37
+ export * from "./resources";
38
+ export * from "./rosetta/types";
39
+ export * from "./rosetta-stone";
40
+ export * from "./rosetta-stone/types";
41
+ export * from "./subscriptions";
42
+ export * from "./types";
43
+ export * from "./uploads";
44
+ export * from "./uploads/types";
45
+ export { applyMixins } from "./utils";
46
+ export * from "./views";
47
+ export * from "./whoami";
48
+ export * from "./whoami/types";
49
+ import { AccessRulesApi } from "./access-rules/";
50
+ import { AccessTokensApi } from "./access-tokens";
51
+ import { AppsApi } from "./apps";
6
52
  import { AttributeApi, AttributeApiV2 } from "./attributes";
7
- import type { ArrayAttribute, Attribute, ObjectAttribute, PrimitiveAttribute, RefAttribute, ShallowAttribute, SubAttribute } from "./attributes/types";
8
- import { type ApiToken, AuthenticationApi, type LoggedInUser, type LoginRequest, type LoginResponse, type RegisterRequest, type RegisterResponse, type RegistrationStatus, type RegistrationStatusRequest, type RegistrationStatusResponse, type StytchToken, type UserRole } from "./authentication";
53
+ import { AuthenticationApi } from "./authentication";
9
54
  import { BaseApi } from "./base-api";
10
- import { type CompanyInfo, CompanyInfoApi } from "./company-info";
11
- import { type Connection, ConnectionsApi } from "./connections";
12
- import { type ContractDetails, type ContractRateView, ContractsApi, type CustomerContract, type PaymentMethod } from "./contracts";
55
+ import { CompanyInfoApi } from "./company-info";
56
+ import { ConnectionsApi } from "./connections";
57
+ import { ContractsApi } from "./contracts";
13
58
  import { DataPlaneApi } from "./data-planes";
14
- import type { DataPlane } from "./data-planes/types";
15
- import { type AttributeSet, type ColumnSet, type ColumnWithFilterAndExport, type DataRules, type DataStream, DataStreamsApi } from "./data-streams";
59
+ import { DataStreamsApi } from "./data-streams";
16
60
  import { DatasetApi } from "./datasets";
17
- import type { AdvancedStatistics, AdvancedStatisticsMetadata, BasicStatistics, ColumnStatistics, ColumnSummary, Columns, Configuration, CreateDatasetRefreshScheduleRequest, CreateDatasetRequest, Dataset, DatasetStatus, DatasetTableSummary, DatasetTableSummaryAPIResponse, DatasetWriteMode, FilePerSnapshotResponse, Histogram, IngestDatasetFileRequest, RetentionPolicy, Schema, SchemaArrayItems, SchemaArrayItemsArray, SchemaArrayItemsObject, SchemaArrayItemsPrimitive, SchemaArrayProperty, SchemaFileConfig, SchemaFileConfigType, SchemaObjectProperty, SchemaPrimitiveProperty, SchemaProperties, SchemaPropertiesType, SchemaProperty, SnapshotRange, UpdateDatasetRefreshScheduleRequest, UpdateDatasetRequest, Value } from "./datasets/types";
18
61
  import { EncryptionMaterialApi } from "./encryption-materials";
19
- import type { BaseDataEncryptionMaterial, CreateEncryptionMaterialRequest, DataEncryptionMaterial, OwnedDataEncryptionMaterial, SharedDataEncryptionMaterial, UpdateEncryptionMaterialRequest } from "./encryption-materials/types";
20
- import { type CostForecastRequest, type CostForecastResponse, type CostForecastResult, ForecastApi, type ForecastRequest, type ForecastResponse, type ForecastResult, type ForecastResultFailure, type JobState } from "./forecast";
62
+ import { ForecastApi } from "./forecast";
21
63
  import { HealthCheckApi } from "./health";
22
- import type { HealthCheckResult } from "./health/types";
23
- import { type Installation, InstallationsApi, type Profile } from "./installations";
24
- import { 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 ModelsDeliverModelInput, type ModelsDeliverModelJob, type ModelTrainingRunInput, type ModelTrainingRunJob, type SampleInput, type StatsInput } from "./jobs";
25
- import JsonBigNumber from "./json-big-number";
26
- import { type Mapping, MappingsApi, type MappingTestResult } from "./mappings";
27
- import type { CreateMapping, ObjectMapping, ValueMapping } from "./mappings/types";
28
- import { ModelTrainingApi, type ModelTrainingConfig, type OutputModel, type TrainModelRequest, type TrainModelResponse } from "./model-training";
29
- import { type CreateModelRequest, type Model, type ModelCollaborators, ModelsApi, type UpdateModelRequest } from "./models";
30
- import { type CompiledNql, type CreateMaterializedView, compileStatement, type Deduplication, type Explain, type Expression, type Nql, NqlApi, type NqlAst, type NqlBooleanExpression, type NqlCompileResult, type NqlExpression, type NqlField, type NqlFilterBinaryExpression, type NqlFilterExpression, type NqlFilterUnaryExpression, type NqlQueryInput, type NqlResult, type NqlWhere, parseStatement, type Raw, type Select, type Statement, type Table } from "./nql";
31
- import { convertNqlObjectToForecastBody } from "./nql/DataRulesConverter";
32
- import { buildNql, getNqlObject } from "./nql/NQLParser";
33
- import type { AstNodeMetadata, AstNodeType, ForecastBody } from "./nql/types";
64
+ import { InstallationsApi } from "./installations";
65
+ import { JobsApi } from "./jobs";
66
+ import { MappingsApi } from "./mappings";
67
+ import { ModelTrainingApi } from "./model-training";
68
+ import { ModelsApi } from "./models";
69
+ import { NqlApi } from "./nql";
34
70
  import { PingApi } from "./ping";
35
- import type { PingStatus } from "./ping/types";
36
- import { type Product, ProductsApi } from "./products";
37
- import { type CreateNqlQueryRequest, type NqlOwnedQueryResponse, type NqlQueryAst, type NqlQueryCollaborators, type NqlQueryMetadata, type NqlQueryOwner, type NqlQueryResponse, type NqlSharedQueryResponse, QueriesApi, type UpdateNqlQueryRequest } from "./queries";
38
- import { type BucketCreationRequest, type Resource, ResourceApi, type UpdateAccessTypeRequest } from "./resources";
39
- import { type ConversationAssistantMessage, type ConversationAssistantMessageWithFunctionCall, type ConversationAssistantMessageWithoutFunctionCall, type ConversationFunctionMessage, type ConversationIOMessage, type ConversationMessage, type ConversationMessageFunctionCall, type ConversationMessageName, type ConversationMessageRole, type ConversationMessages, type ConversationSystemMessage, type ConversationUserMessage, isConversationAssistantMessage, isConversationAssistantMessageWithFunctionCall, isConversationAssistantMessageWithoutFunctionCall, isConversationFunctionMessage, isConversationInputMessage, isConversationMessage, isConversationMessageFunctionCall, isConversationMessageName, isConversationMessageRole, isConversationMessages, isConversationSystemMessage, isConversationUserMessage, isRosettaRequestMessage, isType, type RosettaRequestMessage, type RosettaResponseMessage } from "./rosetta/types";
71
+ import { QueriesApi } from "./queries";
72
+ import { ResourceApi } from "./resources";
40
73
  import { RosettaStoneApi } from "./rosetta-stone";
41
- import type { SampleRecords } from "./rosetta-stone/types";
42
- import { type DataStreamSubscriptionDetails, type MarketplaceSubscriptionDetails, type Subscription, type SubscriptionBudget, type SubscriptionDetails, type SubscriptionOutput, type SubscriptionStatus, SubscriptionsApi, type SubscriptionType } from "./subscriptions";
43
- import type { ApiRecords, ApiRecordsV2, CollaboratorList, CollaboratorsConfig, Config, Environment, GeneralCollaborator, GeneralCollaboratorType, MonetaryAmount, NonAuthenticatedCollaborator, QueryAccess, QueryCollaborator, SpecificCollaboratorType, ViewAccess, ViewCollaborator } from "./types";
74
+ import { SubscriptionsApi } from "./subscriptions";
44
75
  import { UploadsApi } from "./uploads";
45
- import type { UploadsResponse } from "./uploads/types";
46
- import { type CreateViewRequest, type OwnedView, type SharedView, type UpdateViewRequest, type View, type ViewOwner, ViewsApi } from "./views";
76
+ import { ViewsApi } from "./views";
47
77
  import { WhoAmIApi } from "./whoami";
48
- import type { User } from "./whoami/types";
49
78
  declare class NarrativeApi extends BaseApi {
50
79
  }
51
80
  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, EncryptionMaterialApi, WhoAmIApi {
52
81
  }
53
- export { NarrativeApi, AttributeApi, AttributeApiV2, AccessTokensApi, DataPlaneApi, HealthCheckApi, DatasetApi, EncryptionMaterialApi, PingApi, ProductsApi, CompanyInfoApi, InstallationsApi, ConnectionsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi, AuthenticationApi, AppsApi, MappingsApi, AccessRulesApi, SubscriptionsApi, JobsApi, QueriesApi, ViewsApi, ModelsApi, ModelTrainingApi, WhoAmIApi, getNqlObject, buildNql, convertNqlObjectToForecastBody, isConversationAssistantMessage, isConversationFunctionMessage, isConversationInputMessage, isConversationMessage, isConversationMessageName, isConversationMessageRole, isConversationMessages, isConversationSystemMessage, isConversationUserMessage, isType, isConversationMessageFunctionCall, isConversationAssistantMessageWithFunctionCall, isRosettaRequestMessage, isConversationAssistantMessageWithoutFunctionCall, resources, type DataPlane, type AccessTokenMetadata, type CreateSystemAccessTokenRequest, type CreateSystemAccessTokenResponse, type UpdateSystemAccessTokenRequest, type App, type Resource, type AccessRuleV2, type GetAccessRulesParameters, type CreateAccessRuleV2Request, type UpdateAccessRuleV2Request, type UploadsResponse, type PingStatus, type Attribute, type ShallowAttribute, type Connection, type RefAttribute, type SubAttribute, type PrimitiveAttribute, type ArrayAttribute, type ObjectAttribute, type Environment, type Config, type ApiRecords, type ApiRecordsV2, type GeneralCollaboratorType, type SpecificCollaboratorType, type NonAuthenticatedCollaborator, type CollaboratorList, type GeneralCollaborator, type QueryCollaborator, type ViewCollaborator, type QueryAccess, type ViewAccess, type CollaboratorsConfig, type Dataset, type HealthCheckResult, type SampleRecords, type Permission, type DatasetTableSummary, type DatasetTableSummaryAPIResponse, type UpdateDatasetRequest, type UpdateDatasetRefreshScheduleRequest, type CreateDatasetRefreshScheduleRequest, 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 Profile, 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 ForecastResult, type CostForecastResult, type ForecastResultFailure, 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 AstNodeType, type AstNodeMetadata, type SharedAccessRule, type OwnedAccessRule, type ConversationAssistantMessage, type ConversationFunctionMessage, type ConversationIOMessage, type ConversationMessage, type ConversationMessageName, type ConversationMessageRole, type AccessRuleSchema, 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, type Job, type JobRequestSource, type JobRequestSourceApiUser, type JobRequestSourceProcess, type ForecastInput, type ForecastJob, type ExplainInput, type ExplainJob, type ExplainOutput, type MaterializedViewInput, type MaterializedViewJob, type MaterializedViewOutput, type DeleteInput, type DatasetsDeleteTableJob, type DeliverInput, type DatasetsDeliverDataJob, type SampleInput, type DatasetsSampleJob, type ColumnDetails, type StatsInput, type DatasetsCalculateColumnStatsJob, type ModelTrainingRunInput, type ModelTrainingRunJob, type ModelsDeliverModelInput, type ModelsDeliverModelJob, type GetJobsParameters, type User, type Mapping, type MappingTestResult, type ValueMapping, type ObjectMapping, type CreateMapping, type CreateNqlQueryRequest, type UpdateNqlQueryRequest, type NqlQueryResponse, type NqlSharedQueryResponse, type NqlOwnedQueryResponse, type NqlQueryCollaborators, type NqlQueryOwner, type NqlQueryMetadata, type NqlQueryAst, type View, type OwnedView, type SharedView, type ViewOwner, type CreateViewRequest, type UpdateViewRequest, type OutputModel, type TrainModelRequest, type TrainModelResponse, type ModelTrainingConfig, type CreateModelRequest, type Model, type ModelCollaborators, type UpdateModelRequest, type CreateEncryptionMaterialRequest, type DataEncryptionMaterial, type BaseDataEncryptionMaterial, type OwnedDataEncryptionMaterial, type SharedDataEncryptionMaterial, type UpdateEncryptionMaterialRequest, compileStatement, parseStatement, JsonBigNumber, };
82
+ export { NarrativeApi };
package/build/index.js CHANGED
@@ -1,38 +1,81 @@
1
- import { AccessRulesApi, } from "./access-rules/";
2
- import { AccessTokensApi, } from "./access-tokens";
3
- import { resources } from "./access-tokens/types";
1
+ // This approach maintains EXACT same exports as before
2
+ export * from "./access-rules/";
3
+ export * from "./access-tokens";
4
+ export { resources } from "./access-tokens/types";
5
+ export * from "./attributes";
6
+ export * from "./authentication";
7
+ export * from "./base-api";
8
+ export * from "./company-info";
9
+ export * from "./connections";
10
+ export * from "./contracts";
11
+ export * from "./data-planes";
12
+ export * from "./data-planes/types";
13
+ export * from "./data-streams";
14
+ export * from "./datasets";
15
+ export * from "./datasets/types";
16
+ export * from "./encryption-materials";
17
+ export * from "./encryption-materials/types";
18
+ export * from "./forecast";
19
+ export * from "./health";
20
+ export * from "./health/types";
21
+ export * from "./installations";
22
+ export * from "./jobs";
23
+ // Special imports that might be from default exports or need special handling
24
+ export { default as JsonBigNumber } from "./json-big-number";
25
+ export * from "./mappings";
26
+ export * from "./mappings/types";
27
+ export * from "./model-training";
28
+ export * from "./models";
29
+ export * from "./nql";
30
+ export { compileStatement, parseStatement } from "./nql";
31
+ export { convertNqlObjectToForecastBody } from "./nql/DataRulesConverter";
32
+ export { buildNql, getNqlObject } from "./nql/NQLParser";
33
+ export * from "./ping";
34
+ export * from "./ping/types";
35
+ export * from "./products";
36
+ export * from "./queries";
37
+ export * from "./resources";
38
+ export * from "./rosetta/types";
39
+ export * from "./rosetta-stone";
40
+ export * from "./rosetta-stone/types";
41
+ export * from "./subscriptions";
42
+ export * from "./types";
43
+ export * from "./uploads";
44
+ export * from "./uploads/types";
45
+ export { applyMixins } from "./utils";
46
+ export * from "./views";
47
+ export * from "./whoami";
48
+ export * from "./whoami/types";
49
+ import { AccessRulesApi } from "./access-rules/";
50
+ import { AccessTokensApi } from "./access-tokens";
4
51
  import { AppsApi } from "./apps";
5
52
  import { AttributeApi, AttributeApiV2 } from "./attributes";
6
- import { AuthenticationApi, } from "./authentication";
53
+ import { AuthenticationApi } from "./authentication";
54
+ // Handle the NarrativeApi class with mixins
7
55
  import { BaseApi } from "./base-api";
8
56
  import { CompanyInfoApi } from "./company-info";
9
57
  import { ConnectionsApi } from "./connections";
10
- import { ContractsApi, } from "./contracts";
58
+ import { ContractsApi } from "./contracts";
11
59
  import { DataPlaneApi } from "./data-planes";
12
- import { DataStreamsApi, } from "./data-streams";
60
+ import { DataStreamsApi } from "./data-streams";
13
61
  import { DatasetApi } from "./datasets";
14
62
  import { EncryptionMaterialApi } from "./encryption-materials";
15
- import { ForecastApi, } from "./forecast";
63
+ import { ForecastApi } from "./forecast";
16
64
  import { HealthCheckApi } from "./health";
17
- import { InstallationsApi, } from "./installations";
18
- import { JobsApi, } from "./jobs";
19
- import JsonBigNumber from "./json-big-number";
65
+ import { InstallationsApi } from "./installations";
66
+ import { JobsApi } from "./jobs";
20
67
  import { MappingsApi } from "./mappings";
21
- import { ModelTrainingApi, } from "./model-training";
22
- import { ModelsApi, } from "./models";
23
- import { compileStatement, NqlApi, parseStatement, } from "./nql";
24
- import { convertNqlObjectToForecastBody } from "./nql/DataRulesConverter";
25
- import { buildNql, getNqlObject } from "./nql/NQLParser";
68
+ import { ModelTrainingApi } from "./model-training";
69
+ import { ModelsApi } from "./models";
70
+ import { NqlApi } from "./nql";
26
71
  import { PingApi } from "./ping";
27
- import { ProductsApi } from "./products";
28
- import { QueriesApi, } from "./queries";
29
- import { ResourceApi, } from "./resources";
30
- import { isConversationAssistantMessage, isConversationAssistantMessageWithFunctionCall, isConversationAssistantMessageWithoutFunctionCall, isConversationFunctionMessage, isConversationInputMessage, isConversationMessage, isConversationMessageFunctionCall, isConversationMessageName, isConversationMessageRole, isConversationMessages, isConversationSystemMessage, isConversationUserMessage, isRosettaRequestMessage, isType, } from "./rosetta/types";
72
+ import { QueriesApi } from "./queries";
73
+ import { ResourceApi } from "./resources";
31
74
  import { RosettaStoneApi } from "./rosetta-stone";
32
- import { SubscriptionsApi, } from "./subscriptions";
75
+ import { SubscriptionsApi } from "./subscriptions";
33
76
  import { UploadsApi } from "./uploads";
34
77
  import { applyMixins } from "./utils";
35
- import { ViewsApi, } from "./views";
78
+ import { ViewsApi } from "./views";
36
79
  import { WhoAmIApi } from "./whoami";
37
80
  class NarrativeApi extends BaseApi {
38
81
  }
@@ -68,4 +111,4 @@ applyMixins(NarrativeApi, [
68
111
  EncryptionMaterialApi,
69
112
  WhoAmIApi,
70
113
  ]);
71
- export { NarrativeApi, AttributeApi, AttributeApiV2, AccessTokensApi, DataPlaneApi, HealthCheckApi, DatasetApi, EncryptionMaterialApi, PingApi, ProductsApi, CompanyInfoApi, InstallationsApi, ConnectionsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi, AuthenticationApi, AppsApi, MappingsApi, AccessRulesApi, SubscriptionsApi, JobsApi, QueriesApi, ViewsApi, ModelsApi, ModelTrainingApi, WhoAmIApi, getNqlObject, buildNql, convertNqlObjectToForecastBody, isConversationAssistantMessage, isConversationFunctionMessage, isConversationInputMessage, isConversationMessage, isConversationMessageName, isConversationMessageRole, isConversationMessages, isConversationSystemMessage, isConversationUserMessage, isType, isConversationMessageFunctionCall, isConversationAssistantMessageWithFunctionCall, isRosettaRequestMessage, isConversationAssistantMessageWithoutFunctionCall, resources, compileStatement, parseStatement, JsonBigNumber, };
114
+ export { NarrativeApi };
@@ -162,7 +162,7 @@ export interface ModelsTrainClassifierJob extends BaseJob {
162
162
  result: ModelsTrainClassifierResults;
163
163
  }
164
164
  export type Job = ForecastJob | ExplainJob | MaterializedViewJob | DatasetsDeleteTableJob | DatasetsDeliverDataJob | DatasetsSampleJob | DatasetsCalculateColumnStatsJob | ModelTrainingRunJob | ModelsDeliverModelJob | ModelsTrainClassifierJob | UnknownJob;
165
- interface ModelsTrainClassifierTrainingSummary {
165
+ export interface ModelsTrainClassifierTrainingSummary {
166
166
  total_features: number;
167
167
  feature_types: Record<"text" | "categorical" | "embedding" | "numeric", number>;
168
168
  test_accuracy: number;
@@ -170,7 +170,7 @@ interface ModelsTrainClassifierTrainingSummary {
170
170
  class_names: Record<string, string>;
171
171
  error?: unknown;
172
172
  }
173
- interface ModelsTrainClassifierRegistryInfo {
173
+ export interface ModelsTrainClassifierRegistryInfo {
174
174
  model_stored: boolean;
175
175
  model_name: string;
176
176
  model_version: string;
@@ -178,7 +178,7 @@ interface ModelsTrainClassifierRegistryInfo {
178
178
  registry_schema: string;
179
179
  model_task: string;
180
180
  }
181
- interface ModelsTrainClassifierMinimalMetrics {
181
+ export interface ModelsTrainClassifierMinimalMetrics {
182
182
  num_classes: number;
183
183
  class_names: Record<string, string>;
184
184
  accuracy: number;
@@ -186,12 +186,12 @@ interface ModelsTrainClassifierMinimalMetrics {
186
186
  precision_macro: number;
187
187
  recall_macro: number;
188
188
  }
189
- interface ModelsTrainClassifierConfig {
189
+ export interface ModelsTrainClassifierConfig {
190
190
  name: string;
191
191
  version: string;
192
192
  [key: string]: unknown;
193
193
  }
194
- type ModelsTrainClassifierResults = {
194
+ export type ModelsTrainClassifierResults = {
195
195
  status: "success" | "error";
196
196
  registry_info?: ModelsTrainClassifierRegistryInfo;
197
197
  num_categories: number;
@@ -205,16 +205,16 @@ type ModelsTrainClassifierResults = {
205
205
  config: ModelsTrainClassifierConfig;
206
206
  training_summary: ModelsTrainClassifierTrainingSummary;
207
207
  };
208
- type Metric<V = unknown, M extends Record<string, unknown> = Record<string, unknown>> = {
208
+ export type Metric<V = unknown, M extends Record<string, unknown> = Record<string, unknown>> = {
209
209
  value: V;
210
210
  metadata: M;
211
211
  };
212
- interface AveragePredictionEntropy {
212
+ export interface AveragePredictionEntropy {
213
213
  correct_predictions: number;
214
214
  incorrect_predictions: number;
215
215
  entropy_difference: number;
216
216
  }
217
- interface PerClassMetricsLabeledPost {
217
+ export interface PerClassMetricsLabeledPost {
218
218
  class: string;
219
219
  f1_score: number;
220
220
  precision: number;
@@ -224,7 +224,7 @@ interface PerClassMetricsLabeledPost {
224
224
  total_instances: number;
225
225
  correct_predictions: number;
226
226
  }
227
- interface EntropyStats {
227
+ export interface EntropyStats {
228
228
  min: number;
229
229
  max: number;
230
230
  mean: number;
@@ -235,21 +235,21 @@ interface EntropyStats {
235
235
  normalized_perplexity_mean: number;
236
236
  normalized_perplexity_median: number;
237
237
  }
238
- interface EntropyPrioritizationHistogram {
238
+ export interface EntropyPrioritizationHistogram {
239
239
  min: number;
240
240
  max: number;
241
241
  count: number;
242
242
  inclusive_left: number;
243
243
  inclusive_right: number;
244
244
  }
245
- interface TopEntropyRecord {
245
+ export interface TopEntropyRecord {
246
246
  entropy: number;
247
247
  top5_predicted_classes: [string, number][];
248
248
  ID_COLUMN: string;
249
249
  LABEL_COLUMN: string;
250
250
  [key: string]: unknown;
251
251
  }
252
- interface GlobalMetrics {
252
+ export interface GlobalMetrics {
253
253
  num_documents_corpus_pre: Metric<number, never>;
254
254
  num_documents_labeled_pre: Metric<number, never>;
255
255
  percent_labeled_corpus_pre: Metric<number, never>;
@@ -270,15 +270,15 @@ interface GlobalMetrics {
270
270
  entropy_prioritization_histogram: Metric<EntropyPrioritizationHistogram[], never>;
271
271
  top_entropy_records: Metric<TopEntropyRecord[], never>;
272
272
  }
273
- type TopTermsValue = Record<string, number>;
274
- interface FeatureError {
273
+ export type TopTermsValue = Record<string, number>;
274
+ export interface FeatureError {
275
275
  feature: string;
276
276
  prevalence_diff: number;
277
277
  incorrect_prevalence: number;
278
278
  correct_prevalence: number;
279
279
  ratio: number;
280
280
  }
281
- interface ErrorConcentration {
281
+ export interface ErrorConcentration {
282
282
  feature: string;
283
283
  records_with_feature: number;
284
284
  errors_with_feature: number;
@@ -286,13 +286,13 @@ interface ErrorConcentration {
286
286
  overall_error_rate: number;
287
287
  error_lift: number;
288
288
  }
289
- interface ErrorPredictionImportance {
289
+ export interface ErrorPredictionImportance {
290
290
  feature: string;
291
291
  correlation: number;
292
292
  p_value: number;
293
293
  abs_correlation: number;
294
294
  }
295
- interface DynamicTextFeatureMetrics {
295
+ export interface DynamicTextFeatureMetrics {
296
296
  [key: `${string}_avg_doc_length_corpus_pre`]: Metric<number>;
297
297
  [key: `${string}_avg_doc_length_labeled_pre`]: Metric<number>;
298
298
  [key: `${string}_ngram_vocab_size_corpus_pre`]: Metric<number>;
@@ -1,5 +1,5 @@
1
1
  import { BaseApi } from "../base-api";
2
- import type { ModelTrainingConfig, OutputModel, TrainModelRequest, TrainModelResponse } from "./types";
2
+ import type { ModelTrainingConfig, OutputModel, TrainClassifierRequest, TrainClassifierResponse, TrainModelRequest, TrainModelResponse } from "./types";
3
3
  /**
4
4
  * A class for accessing the Model Training API.
5
5
  * @extends BaseApi
@@ -12,5 +12,12 @@ declare class ModelTrainingApi extends BaseApi {
12
12
  * @returns {Promise<NqlQueryResponse>} A promise that resolves with the model training response.
13
13
  */
14
14
  trainModel(data: TrainModelRequest): Promise<TrainModelResponse>;
15
+ /**
16
+ * Trains a classifier model.
17
+ *
18
+ * @param {TrainClassifierRequest} data - The data for the classifier training.
19
+ * @returns {Promise<TrainClassifierResponse>} A promise that resolves with the classifier training response.
20
+ */
21
+ trainClassifier(data: TrainClassifierRequest): Promise<TrainClassifierResponse>;
15
22
  }
16
- export { ModelTrainingApi, type OutputModel, type TrainModelRequest, type TrainModelResponse, type ModelTrainingConfig, };
23
+ export { ModelTrainingApi, type OutputModel, type TrainModelRequest, type TrainModelResponse, type ModelTrainingConfig, type TrainClassifierRequest, type TrainClassifierResponse, };
@@ -20,5 +20,14 @@ class ModelTrainingApi extends BaseApi {
20
20
  async trainModel(data) {
21
21
  return await this.post(`${resourceName}/run`, data);
22
22
  }
23
+ /**
24
+ * Trains a classifier model.
25
+ *
26
+ * @param {TrainClassifierRequest} data - The data for the classifier training.
27
+ * @returns {Promise<TrainClassifierResponse>} A promise that resolves with the classifier training response.
28
+ */
29
+ async trainClassifier(data) {
30
+ return await this.post("train-classifier", data);
31
+ }
23
32
  }
24
33
  export { ModelTrainingApi, };
@@ -19,3 +19,11 @@ export interface ModelTrainingConfig {
19
19
  instance_type: string;
20
20
  custom_axolotl_config_override?: string;
21
21
  }
22
+ export interface TrainClassifierRequest {
23
+ config: Record<string, unknown>;
24
+ data_plane_id: string;
25
+ tags: string[];
26
+ }
27
+ export interface TrainClassifierResponse {
28
+ job_id: string;
29
+ }
@@ -336,7 +336,7 @@ export interface QueryDetails {
336
336
  export interface QueryPricing {
337
337
  micro_cents_usd: number;
338
338
  }
339
- export interface DataRules {
339
+ interface DataRules {
340
340
  attributes: DataRulesAttributes[];
341
341
  }
342
342
  export interface DataRulesAttributes {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@narrative.io/data-collaboration-sdk-ts",
3
- "version": "2.58.0",
3
+ "version": "2.59.0",
4
4
  "main": "build/index.js",
5
5
  "repository": "github:narrative-io/data-collaboration-sdk-ts",
6
6
  "source": "src/index.ts",
@@ -26,15 +26,15 @@
26
26
  "@biomejs/biome": "2.1.2",
27
27
  "@commitlint/cli": "19.8.1",
28
28
  "@commitlint/config-conventional": "19.8.1",
29
- "@types/jest": "29.5.14",
30
- "babel-jest": "29.7.0",
31
- "jest": "29.7.0",
29
+ "@types/jest": "30.0.0",
30
+ "babel-jest": "30.0.5",
31
+ "jest": "30.0.5",
32
32
  "lefthook": "1.12.2",
33
33
  "ts-jest": "29.4.0"
34
34
  },
35
35
  "dependencies": {
36
36
  "mande": "2.0.9",
37
- "zod": "4.0.8",
37
+ "zod": "4.0.10",
38
38
  "bignumber.js": "9.3.1"
39
39
  },
40
40
  "overrides": {