@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 +310 -12
- package/build/index.d.ts +68 -39
- package/build/index.js +65 -22
- package/build/jobs/types.d.ts +17 -17
- package/build/model-training/index.d.ts +9 -2
- package/build/model-training/index.js +9 -0
- package/build/model-training/types.d.ts +8 -0
- package/build/nql/types.d.ts +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,18 +1,316 @@
|
|
|
1
|
-
# SDK
|
|
1
|
+
# Narrative.io Data Collaboration SDK for TypeScript
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@narrative.io/data-collaboration-sdk-ts)
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
|
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 {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
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
|
|
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
|
|
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
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import
|
|
26
|
-
import {
|
|
27
|
-
import
|
|
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
|
|
36
|
-
import {
|
|
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
|
|
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
|
|
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
|
|
82
|
+
export { NarrativeApi };
|
package/build/index.js
CHANGED
|
@@ -1,38 +1,81 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
|
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
|
|
58
|
+
import { ContractsApi } from "./contracts";
|
|
11
59
|
import { DataPlaneApi } from "./data-planes";
|
|
12
|
-
import { DataStreamsApi
|
|
60
|
+
import { DataStreamsApi } from "./data-streams";
|
|
13
61
|
import { DatasetApi } from "./datasets";
|
|
14
62
|
import { EncryptionMaterialApi } from "./encryption-materials";
|
|
15
|
-
import { ForecastApi
|
|
63
|
+
import { ForecastApi } from "./forecast";
|
|
16
64
|
import { HealthCheckApi } from "./health";
|
|
17
|
-
import { InstallationsApi
|
|
18
|
-
import { JobsApi
|
|
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
|
|
22
|
-
import { ModelsApi
|
|
23
|
-
import {
|
|
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 {
|
|
28
|
-
import {
|
|
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
|
|
75
|
+
import { SubscriptionsApi } from "./subscriptions";
|
|
33
76
|
import { UploadsApi } from "./uploads";
|
|
34
77
|
import { applyMixins } from "./utils";
|
|
35
|
-
import { ViewsApi
|
|
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
|
|
114
|
+
export { NarrativeApi };
|
package/build/jobs/types.d.ts
CHANGED
|
@@ -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
|
+
}
|
package/build/nql/types.d.ts
CHANGED
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.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": "
|
|
30
|
-
"babel-jest": "
|
|
31
|
-
"jest": "
|
|
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.
|
|
37
|
+
"zod": "4.0.10",
|
|
38
38
|
"bignumber.js": "9.3.1"
|
|
39
39
|
},
|
|
40
40
|
"overrides": {
|