@narrative.io/data-collaboration-sdk-ts 2.85.0 → 2.89.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 +26 -30
- package/build/authentication/index.d.ts +36 -3
- package/build/authentication/index.js +40 -1
- package/build/authentication/types.d.ts +4 -0
- package/build/datasets/index.d.ts +24 -0
- package/build/datasets/index.js +47 -0
- package/build/index.d.ts +3 -1
- package/build/index.js +3 -0
- package/build/jobs/index.d.ts +2 -2
- package/build/jobs/types.d.ts +29 -2
- package/build/model-inference/index.d.ts +18 -0
- package/build/model-inference/index.js +19 -0
- package/build/model-inference/types.d.ts +68 -0
- package/build/model-inference/types.js +1 -0
- package/package.json +16 -15
package/README.md
CHANGED
|
@@ -326,14 +326,14 @@ Both approaches use the SDK’s **built output** in `build/`, exactly like the p
|
|
|
326
326
|
|
|
327
327
|
### Prerequisites
|
|
328
328
|
|
|
329
|
-
-
|
|
329
|
+
- Bun (this project uses bun as its package manager)
|
|
330
330
|
- This repo builds TypeScript to `build/`
|
|
331
331
|
- This repo includes `scripts/ensureBuild.js` to verify artifacts exist
|
|
332
332
|
|
|
333
333
|
```bash
|
|
334
334
|
# In the SDK repo (this one)
|
|
335
|
-
|
|
336
|
-
|
|
335
|
+
bun install
|
|
336
|
+
bun run build # one-time; emits build/**
|
|
337
337
|
node scripts/ensureBuild.js
|
|
338
338
|
```
|
|
339
339
|
|
|
@@ -344,41 +344,38 @@ node scripts/ensureBuild.js
|
|
|
344
344
|
1. **Keep the SDK building on save**
|
|
345
345
|
In the SDK repo (leave this running):
|
|
346
346
|
```bash
|
|
347
|
-
|
|
347
|
+
bun run dev # tsc -w → continuously updates build/**
|
|
348
348
|
```
|
|
349
349
|
|
|
350
350
|
2. **Register the SDK globally**
|
|
351
351
|
In the SDK repo (new terminal):
|
|
352
352
|
```bash
|
|
353
|
-
|
|
353
|
+
bun run link:global # runs ensureBuild + bun link
|
|
354
354
|
```
|
|
355
355
|
|
|
356
356
|
3. **Link into your consumer app**
|
|
357
357
|
In your app repo (e.g., Nuxt project):
|
|
358
358
|
```bash
|
|
359
|
-
#
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
# link the globally-registered SDK into this app’s node_modules
|
|
363
|
-
npm link @narrative.io/data-collaboration-sdk-ts
|
|
359
|
+
# link the globally-registered SDK into this app's node_modules
|
|
360
|
+
bun link @narrative.io/data-collaboration-sdk-ts
|
|
364
361
|
```
|
|
365
362
|
|
|
366
363
|
4. **Verify the app resolves to your local SDK**
|
|
367
364
|
```bash
|
|
368
365
|
node -e "console.log(require.resolve('@narrative.io/data-collaboration-sdk-ts/package.json'))"
|
|
369
366
|
```
|
|
370
|
-
You should see a path inside your SDK repo (not a versioned folder under the app
|
|
367
|
+
You should see a path inside your SDK repo (not a versioned folder under the app's `node_modules`).
|
|
371
368
|
|
|
372
369
|
5. **Run your app**
|
|
373
370
|
```bash
|
|
374
|
-
|
|
371
|
+
bun run dev
|
|
375
372
|
```
|
|
376
373
|
Edit files under `SDK/src/**` → the watcher writes to `build/**` → your app hot-reloads.
|
|
377
374
|
|
|
378
375
|
**Revert to the registry version (in the app):**
|
|
379
376
|
```bash
|
|
380
|
-
|
|
381
|
-
|
|
377
|
+
bun remove @narrative.io/data-collaboration-sdk-ts
|
|
378
|
+
bun add @narrative.io/data-collaboration-sdk-ts
|
|
382
379
|
```
|
|
383
380
|
|
|
384
381
|
---
|
|
@@ -388,20 +385,20 @@ npm i
|
|
|
388
385
|
1. **Pack the SDK (same artifact you would publish)**
|
|
389
386
|
```bash
|
|
390
387
|
# in the SDK repo
|
|
391
|
-
|
|
392
|
-
|
|
388
|
+
bun run build
|
|
389
|
+
bun run pack:dist # creates ./<name>-<version>.tgz
|
|
393
390
|
```
|
|
394
391
|
|
|
395
392
|
2. **Install the tarball in the app**
|
|
396
393
|
```bash
|
|
397
394
|
# in the app repo
|
|
398
|
-
|
|
399
|
-
|
|
395
|
+
bun add /ABS/PATH/TO/<name>-<version>.tgz
|
|
396
|
+
bun run dev
|
|
400
397
|
```
|
|
401
398
|
|
|
402
399
|
**Revert to a registry version (in the app):**
|
|
403
400
|
```bash
|
|
404
|
-
|
|
401
|
+
bun add @narrative.io/data-collaboration-sdk-ts@<semver>
|
|
405
402
|
```
|
|
406
403
|
|
|
407
404
|
---
|
|
@@ -428,25 +425,24 @@ npm i @narrative.io/data-collaboration-sdk-ts@<semver>
|
|
|
428
425
|
|
|
429
426
|
```bash
|
|
430
427
|
# SDK (this repo)
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
428
|
+
bun install
|
|
429
|
+
bun run build
|
|
430
|
+
bun run dev
|
|
431
|
+
bun run link:global
|
|
435
432
|
|
|
436
433
|
# App (consumer repo)
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
npm run dev
|
|
434
|
+
bun link @narrative.io/data-collaboration-sdk-ts
|
|
435
|
+
bun run dev
|
|
440
436
|
```
|
|
441
437
|
|
|
442
438
|
Alternative (publish-parity):
|
|
443
439
|
|
|
444
440
|
```bash
|
|
445
441
|
# SDK
|
|
446
|
-
|
|
447
|
-
|
|
442
|
+
bun run build
|
|
443
|
+
bun run pack:dist
|
|
448
444
|
|
|
449
445
|
# App
|
|
450
|
-
|
|
451
|
-
|
|
446
|
+
bun add /ABS/PATH/TO/*.tgz
|
|
447
|
+
bun run dev
|
|
452
448
|
```
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseApi } from "../base-api";
|
|
2
|
-
import type { ApiToken, LoggedInUser, LoginRequest, LoginResponse, RegisterRequest, RegisterResponse, RegistrationStatus, RegistrationStatusRequest, RegistrationStatusResponse, StytchToken, UserRole } from "./types";
|
|
2
|
+
import type { ApiToken, LoggedInUser, LoginRequest, LoginResponse, RegisterRequest, RegisterResponse, RegistrationStatus, RegistrationStatusB2bRequest, RegistrationStatusRequest, RegistrationStatusResponse, StytchToken, UserRole } from "./types";
|
|
3
3
|
/**
|
|
4
4
|
* A class for accessing the Authentication API
|
|
5
5
|
* @extends BaseApi
|
|
@@ -8,23 +8,56 @@ declare class AuthenticationApi extends BaseApi {
|
|
|
8
8
|
/**
|
|
9
9
|
* Logs in the user.
|
|
10
10
|
*
|
|
11
|
+
* @see https://docs.narrative.io/open-api#tag/Authentication/paths/~1authentication~1login/post
|
|
12
|
+
*
|
|
11
13
|
* @param {LoginRequest} loginRequest - The login request object.
|
|
12
14
|
* @returns {Promise<LoginResponse>} - A promise that resolves to the login response.
|
|
13
15
|
*/
|
|
14
16
|
login(loginRequest: LoginRequest): Promise<LoginResponse>;
|
|
17
|
+
/**
|
|
18
|
+
* Logs in a B2B user.
|
|
19
|
+
*
|
|
20
|
+
* @see https://docs.narrative.io/open-api#tag/Authentication/paths/~1authentication~1b2b~1login/post
|
|
21
|
+
*
|
|
22
|
+
* @param {LoginRequest} loginRequest - The login request object.
|
|
23
|
+
* @returns {Promise<LoginResponse>} - A promise that resolves to the login response.
|
|
24
|
+
*/
|
|
25
|
+
loginB2b(loginRequest: LoginRequest): Promise<LoginResponse>;
|
|
15
26
|
/**
|
|
16
27
|
* Registers a new user.
|
|
17
28
|
*
|
|
29
|
+
* @see https://docs.narrative.io/open-api#tag/Authentication/paths/~1authentication~1register/post
|
|
30
|
+
*
|
|
18
31
|
* @param {RegisterRequest} registerRequest - The register request object.
|
|
19
32
|
* @returns {Promise<RegisterResponse>} - A promise that resolves to the register response.
|
|
20
33
|
*/
|
|
21
34
|
register(registerRequest: RegisterRequest): Promise<RegisterResponse>;
|
|
35
|
+
/**
|
|
36
|
+
* Registers a new B2B user.
|
|
37
|
+
*
|
|
38
|
+
* @see https://docs.narrative.io/open-api#tag/Authentication/paths/~1authentication~1b2b~1register/post
|
|
39
|
+
*
|
|
40
|
+
* @param {RegisterRequest} registerRequest - The register request object.
|
|
41
|
+
* @returns {Promise<RegisterResponse>} - A promise that resolves to the register response.
|
|
42
|
+
*/
|
|
43
|
+
registerB2b(registerRequest: RegisterRequest): Promise<RegisterResponse>;
|
|
22
44
|
/**
|
|
23
45
|
* Checks the resgistration status of a user.
|
|
24
46
|
*
|
|
25
|
-
* @
|
|
47
|
+
* @see https://docs.narrative.io/open-api#tag/Authentication/paths/~1authentication~1registration-status/post
|
|
48
|
+
*
|
|
49
|
+
* @param {RegistrationStatusRequest} statusRequest - request payload of user login for whom to check status.
|
|
26
50
|
* @returns {Promise<RegistrationStatusResponse>} - A promise that resolves to the response.
|
|
27
51
|
*/
|
|
28
52
|
checkRegistrationStatus(statusRequest: RegistrationStatusRequest): Promise<RegistrationStatusResponse>;
|
|
53
|
+
/**
|
|
54
|
+
* Checks the registration status of a B2B user.
|
|
55
|
+
*
|
|
56
|
+
* @see https://docs.narrative.io/open-api#tag/Authentication/paths/~1authentication~1b2b~1registration-status/post
|
|
57
|
+
*
|
|
58
|
+
* @param {RegistrationStatusB2bRequest} statusRequest - The B2B registration status request.
|
|
59
|
+
* @returns {Promise<RegistrationStatusResponse>} - A promise that resolves to the response.
|
|
60
|
+
*/
|
|
61
|
+
checkRegistrationStatusB2b(statusRequest: RegistrationStatusB2bRequest): Promise<RegistrationStatusResponse>;
|
|
29
62
|
}
|
|
30
|
-
export { type LoginRequest, type LoginResponse, type RegisterRequest, type RegisterResponse, type LoggedInUser, type StytchToken, type ApiToken, type UserRole, type RegistrationStatus, type RegistrationStatusRequest, type RegistrationStatusResponse, AuthenticationApi, };
|
|
63
|
+
export { type LoginRequest, type LoginResponse, type RegisterRequest, type RegisterResponse, type LoggedInUser, type StytchToken, type ApiToken, type UserRole, type RegistrationStatus, type RegistrationStatusB2bRequest, type RegistrationStatusRequest, type RegistrationStatusResponse, AuthenticationApi, };
|
|
@@ -14,29 +14,68 @@ class AuthenticationApi extends BaseApi {
|
|
|
14
14
|
/**
|
|
15
15
|
* Logs in the user.
|
|
16
16
|
*
|
|
17
|
+
* @see https://docs.narrative.io/open-api#tag/Authentication/paths/~1authentication~1login/post
|
|
18
|
+
*
|
|
17
19
|
* @param {LoginRequest} loginRequest - The login request object.
|
|
18
20
|
* @returns {Promise<LoginResponse>} - A promise that resolves to the login response.
|
|
19
21
|
*/
|
|
20
22
|
async login(loginRequest) {
|
|
21
23
|
return await this.post(`${resourceName}/login`, loginRequest);
|
|
22
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Logs in a B2B user.
|
|
27
|
+
*
|
|
28
|
+
* @see https://docs.narrative.io/open-api#tag/Authentication/paths/~1authentication~1b2b~1login/post
|
|
29
|
+
*
|
|
30
|
+
* @param {LoginRequest} loginRequest - The login request object.
|
|
31
|
+
* @returns {Promise<LoginResponse>} - A promise that resolves to the login response.
|
|
32
|
+
*/
|
|
33
|
+
async loginB2b(loginRequest) {
|
|
34
|
+
return await this.post(`${resourceName}/b2b/login`, loginRequest);
|
|
35
|
+
}
|
|
23
36
|
/**
|
|
24
37
|
* Registers a new user.
|
|
25
38
|
*
|
|
39
|
+
* @see https://docs.narrative.io/open-api#tag/Authentication/paths/~1authentication~1register/post
|
|
40
|
+
*
|
|
26
41
|
* @param {RegisterRequest} registerRequest - The register request object.
|
|
27
42
|
* @returns {Promise<RegisterResponse>} - A promise that resolves to the register response.
|
|
28
43
|
*/
|
|
29
44
|
async register(registerRequest) {
|
|
30
45
|
return await this.post(`${resourceName}/register`, registerRequest);
|
|
31
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Registers a new B2B user.
|
|
49
|
+
*
|
|
50
|
+
* @see https://docs.narrative.io/open-api#tag/Authentication/paths/~1authentication~1b2b~1register/post
|
|
51
|
+
*
|
|
52
|
+
* @param {RegisterRequest} registerRequest - The register request object.
|
|
53
|
+
* @returns {Promise<RegisterResponse>} - A promise that resolves to the register response.
|
|
54
|
+
*/
|
|
55
|
+
async registerB2b(registerRequest) {
|
|
56
|
+
return await this.post(`${resourceName}/b2b/register`, registerRequest);
|
|
57
|
+
}
|
|
32
58
|
/**
|
|
33
59
|
* Checks the resgistration status of a user.
|
|
34
60
|
*
|
|
35
|
-
* @
|
|
61
|
+
* @see https://docs.narrative.io/open-api#tag/Authentication/paths/~1authentication~1registration-status/post
|
|
62
|
+
*
|
|
63
|
+
* @param {RegistrationStatusRequest} statusRequest - request payload of user login for whom to check status.
|
|
36
64
|
* @returns {Promise<RegistrationStatusResponse>} - A promise that resolves to the response.
|
|
37
65
|
*/
|
|
38
66
|
async checkRegistrationStatus(statusRequest) {
|
|
39
67
|
return await this.post(`${resourceName}/registration-status`, statusRequest);
|
|
40
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* Checks the registration status of a B2B user.
|
|
71
|
+
*
|
|
72
|
+
* @see https://docs.narrative.io/open-api#tag/Authentication/paths/~1authentication~1b2b~1registration-status/post
|
|
73
|
+
*
|
|
74
|
+
* @param {RegistrationStatusB2bRequest} statusRequest - The B2B registration status request.
|
|
75
|
+
* @returns {Promise<RegistrationStatusResponse>} - A promise that resolves to the response.
|
|
76
|
+
*/
|
|
77
|
+
async checkRegistrationStatusB2b(statusRequest) {
|
|
78
|
+
return await this.post(`${resourceName}/b2b/registration-status`, statusRequest);
|
|
79
|
+
}
|
|
41
80
|
}
|
|
42
81
|
export { AuthenticationApi, };
|
|
@@ -44,6 +44,10 @@ export interface RegistrationStatusRequest {
|
|
|
44
44
|
stytch_token: StytchToken;
|
|
45
45
|
session_duration_minutes?: number;
|
|
46
46
|
}
|
|
47
|
+
export interface RegistrationStatusB2bRequest {
|
|
48
|
+
stytch_token: string;
|
|
49
|
+
session_duration_minutes: number;
|
|
50
|
+
}
|
|
47
51
|
export interface RegistrationStatusResponse {
|
|
48
52
|
status: RegistrationStatus;
|
|
49
53
|
email: string;
|
|
@@ -44,6 +44,30 @@ export declare class DatasetApi extends BaseApi {
|
|
|
44
44
|
* @returns {Promise<Dataset>} A promise that resolves with the newly created dataset.
|
|
45
45
|
*/
|
|
46
46
|
createDataset(request: CreateDatasetRequest): Promise<Dataset>;
|
|
47
|
+
/**
|
|
48
|
+
* Adds tags to an existing dataset without removing existing tags.
|
|
49
|
+
* Duplicate tags will be ignored.
|
|
50
|
+
*
|
|
51
|
+
* **Note**: This method performs a read-modify-write operation.
|
|
52
|
+
* Concurrent calls may result in lost updates.
|
|
53
|
+
*
|
|
54
|
+
* @param {number} datasetId - The ID of the dataset to add tags to.
|
|
55
|
+
* @param {string[]} tags - The tags to add to the dataset. Empty array returns the dataset unchanged.
|
|
56
|
+
* @returns {Promise<Dataset>} A promise that resolves with the updated dataset.
|
|
57
|
+
*/
|
|
58
|
+
addTags(datasetId: number, tags: string[]): Promise<Dataset>;
|
|
59
|
+
/**
|
|
60
|
+
* Removes specified tags from an existing dataset.
|
|
61
|
+
* Tags that don't exist on the dataset will be ignored.
|
|
62
|
+
*
|
|
63
|
+
* **Note**: This method performs a read-modify-write operation.
|
|
64
|
+
* Concurrent calls may result in lost updates.
|
|
65
|
+
*
|
|
66
|
+
* @param {number} datasetId - The ID of the dataset to remove tags from.
|
|
67
|
+
* @param {string[]} tags - The tags to remove from the dataset. Empty array returns the dataset unchanged.
|
|
68
|
+
* @returns {Promise<Dataset>} A promise that resolves with the updated dataset.
|
|
69
|
+
*/
|
|
70
|
+
removeTags(datasetId: number, tags: string[]): Promise<Dataset>;
|
|
47
71
|
/**
|
|
48
72
|
* Activates a dataset with the specified dataset ID.
|
|
49
73
|
*
|
package/build/datasets/index.js
CHANGED
|
@@ -51,6 +51,53 @@ export class DatasetApi extends BaseApi {
|
|
|
51
51
|
async createDataset(request) {
|
|
52
52
|
return await this.post(`${resourceName}`, request);
|
|
53
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Adds tags to an existing dataset without removing existing tags.
|
|
56
|
+
* Duplicate tags will be ignored.
|
|
57
|
+
*
|
|
58
|
+
* **Note**: This method performs a read-modify-write operation.
|
|
59
|
+
* Concurrent calls may result in lost updates.
|
|
60
|
+
*
|
|
61
|
+
* @param {number} datasetId - The ID of the dataset to add tags to.
|
|
62
|
+
* @param {string[]} tags - The tags to add to the dataset. Empty array returns the dataset unchanged.
|
|
63
|
+
* @returns {Promise<Dataset>} A promise that resolves with the updated dataset.
|
|
64
|
+
*/
|
|
65
|
+
async addTags(datasetId, tags) {
|
|
66
|
+
if (tags.length === 0) {
|
|
67
|
+
return await this.getDataset(datasetId);
|
|
68
|
+
}
|
|
69
|
+
const dataset = await this.getDataset(datasetId);
|
|
70
|
+
const existingTags = dataset.tags ?? [];
|
|
71
|
+
const uniqueNewTags = tags.filter((tag) => !existingTags.includes(tag));
|
|
72
|
+
const updatedTags = [...existingTags, ...uniqueNewTags];
|
|
73
|
+
return await this.updateDataset({
|
|
74
|
+
dataset_id: datasetId,
|
|
75
|
+
tags: updatedTags,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Removes specified tags from an existing dataset.
|
|
80
|
+
* Tags that don't exist on the dataset will be ignored.
|
|
81
|
+
*
|
|
82
|
+
* **Note**: This method performs a read-modify-write operation.
|
|
83
|
+
* Concurrent calls may result in lost updates.
|
|
84
|
+
*
|
|
85
|
+
* @param {number} datasetId - The ID of the dataset to remove tags from.
|
|
86
|
+
* @param {string[]} tags - The tags to remove from the dataset. Empty array returns the dataset unchanged.
|
|
87
|
+
* @returns {Promise<Dataset>} A promise that resolves with the updated dataset.
|
|
88
|
+
*/
|
|
89
|
+
async removeTags(datasetId, tags) {
|
|
90
|
+
if (tags.length === 0) {
|
|
91
|
+
return await this.getDataset(datasetId);
|
|
92
|
+
}
|
|
93
|
+
const dataset = await this.getDataset(datasetId);
|
|
94
|
+
const existingTags = dataset.tags ?? [];
|
|
95
|
+
const updatedTags = existingTags.filter((tag) => !tags.includes(tag));
|
|
96
|
+
return await this.updateDataset({
|
|
97
|
+
dataset_id: datasetId,
|
|
98
|
+
tags: updatedTags,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
54
101
|
/**
|
|
55
102
|
* Activates a dataset with the specified dataset ID.
|
|
56
103
|
*
|
package/build/index.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ export * from "./jobs";
|
|
|
24
24
|
export { default as JsonBigNumber } from "./json-big-number";
|
|
25
25
|
export * from "./mappings";
|
|
26
26
|
export * from "./mappings/types";
|
|
27
|
+
export * from "./model-inference";
|
|
27
28
|
export * from "./model-training";
|
|
28
29
|
export * from "./models";
|
|
29
30
|
export * from "./nql";
|
|
@@ -65,6 +66,7 @@ import { HealthCheckApi } from "./health";
|
|
|
65
66
|
import { InstallationsApi } from "./installations";
|
|
66
67
|
import { JobsApi } from "./jobs";
|
|
67
68
|
import { MappingsApi } from "./mappings";
|
|
69
|
+
import { ModelInferenceApi } from "./model-inference";
|
|
68
70
|
import { ModelTrainingApi } from "./model-training";
|
|
69
71
|
import { ModelsApi } from "./models";
|
|
70
72
|
import { NqlApi } from "./nql";
|
|
@@ -78,6 +80,6 @@ import { ViewsApi } from "./views";
|
|
|
78
80
|
import { WhoAmIApi } from "./whoami";
|
|
79
81
|
declare class NarrativeApi extends BaseApi {
|
|
80
82
|
}
|
|
81
|
-
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 {
|
|
83
|
+
interface NarrativeApi extends BaseApi, HealthCheckApi, AccessTokensApi, DataPlaneApi, DatasetApi, RosettaStoneApi, AttributeApi, AttributeApiV2, PingApi, CompanyInfoApi, InstallationsApi, ConnectionsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi, AuthenticationApi, MappingsApi, AccessRulesApi, AppsApi, SubscriptionsApi, JobsApi, QueriesApi, ViewsApi, ModelsApi, ModelTrainingApi, ModelInferenceApi, EncryptionMaterialApi, WhoAmIApi {
|
|
82
84
|
}
|
|
83
85
|
export { NarrativeApi };
|
package/build/index.js
CHANGED
|
@@ -25,6 +25,7 @@ export * from "./jobs";
|
|
|
25
25
|
export { default as JsonBigNumber } from "./json-big-number";
|
|
26
26
|
export * from "./mappings";
|
|
27
27
|
export * from "./mappings/types";
|
|
28
|
+
export * from "./model-inference";
|
|
28
29
|
export * from "./model-training";
|
|
29
30
|
export * from "./models";
|
|
30
31
|
export * from "./nql";
|
|
@@ -66,6 +67,7 @@ import { HealthCheckApi } from "./health";
|
|
|
66
67
|
import { InstallationsApi } from "./installations";
|
|
67
68
|
import { JobsApi } from "./jobs";
|
|
68
69
|
import { MappingsApi } from "./mappings";
|
|
70
|
+
import { ModelInferenceApi } from "./model-inference";
|
|
69
71
|
import { ModelTrainingApi } from "./model-training";
|
|
70
72
|
import { ModelsApi } from "./models";
|
|
71
73
|
import { NqlApi } from "./nql";
|
|
@@ -109,6 +111,7 @@ applyMixins(NarrativeApi, [
|
|
|
109
111
|
ViewsApi,
|
|
110
112
|
ModelsApi,
|
|
111
113
|
ModelTrainingApi,
|
|
114
|
+
ModelInferenceApi,
|
|
112
115
|
EncryptionMaterialApi,
|
|
113
116
|
WhoAmIApi,
|
|
114
117
|
]);
|
package/build/jobs/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseApi } from "../base-api";
|
|
2
2
|
import type { ApiRecords } from "../types";
|
|
3
|
-
import type { ColumnDetails, DatasetsCalculateColumnStatsJob, DatasetsDeleteTableJob, DatasetsDeliverDataJob, DatasetsSampleJob, DeleteInput, DeliverInput, ExplainInput, ExplainJob, ExplainOutput, ForecastInput, ForecastJob, Job, JobRequestSource, JobRequestSourceApiUser, JobRequestSourceProcess, MaterializedViewInput, MaterializedViewJob, MaterializedViewOutput, ModelsDeliverModelInput, ModelsDeliverModelJob, ModelTrainingRunInput, ModelTrainingRunJob, SampleInput, StatsInput } from "./types";
|
|
3
|
+
import type { ColumnDetails, DatasetsCalculateColumnStatsJob, DatasetsDeleteTableJob, DatasetsDeliverDataJob, DatasetsSampleJob, DeleteInput, DeliverInput, ExplainInput, ExplainJob, ExplainOutput, ForecastInput, ForecastJob, Job, JobRequestSource, JobRequestSourceApiUser, JobRequestSourceProcess, MaterializedViewInput, MaterializedViewJob, MaterializedViewOutput, ModelInferenceRunInput, ModelInferenceRunJob, ModelInferenceRunJobResult, ModelsDeliverModelInput, ModelsDeliverModelJob, ModelTrainingRunInput, ModelTrainingRunJob, SampleInput, StatsInput } from "./types";
|
|
4
4
|
interface GetJobsParameters extends Record<string, string | number | boolean | undefined> {
|
|
5
5
|
dataset_id?: number;
|
|
6
6
|
per_page?: number;
|
|
@@ -31,4 +31,4 @@ declare class JobsApi extends BaseApi {
|
|
|
31
31
|
*/
|
|
32
32
|
cancelJob(jobId: string): Promise<void>;
|
|
33
33
|
}
|
|
34
|
-
export { 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, JobsApi, };
|
|
34
|
+
export { 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 ModelInferenceRunInput, type ModelInferenceRunJob, type ModelInferenceRunJobResult, type GetJobsParameters, JobsApi, };
|
package/build/jobs/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ForecastResult, JobState } from "src/forecast";
|
|
2
2
|
import type { DataStreamPurchaseDetails, ForecastDimensions, MarketplaceForecastDetails } from "src/forecast/types";
|
|
3
3
|
import type { NqlBudget } from "src/nql/types";
|
|
4
|
-
export type JobType = "forecast" | "nql-forecast" | "materialize-view" | "datasets_calculate_column_stats" | "datasets_delete_table" | "datasets_deliver_data" | "datasets_sample" | "models_deliver_model" | "models_train_classifier" | "model_training_run";
|
|
4
|
+
export type JobType = "forecast" | "nql-forecast" | "materialize-view" | "datasets_calculate_column_stats" | "datasets_delete_table" | "datasets_deliver_data" | "datasets_sample" | "models_deliver_model" | "models_train_classifier" | "model_training_run" | "model_inference_run";
|
|
5
5
|
export interface JobRequestSource {
|
|
6
6
|
type: string;
|
|
7
7
|
company_id: number;
|
|
@@ -170,7 +170,34 @@ export interface ModelsTrainClassifierJob extends BaseJob {
|
|
|
170
170
|
type: "models_train_classifier";
|
|
171
171
|
result: ModelsTrainClassifierResults;
|
|
172
172
|
}
|
|
173
|
-
export
|
|
173
|
+
export interface ModelInferenceRunInput {
|
|
174
|
+
model: string;
|
|
175
|
+
messages: Array<{
|
|
176
|
+
role: string;
|
|
177
|
+
text: string;
|
|
178
|
+
}>;
|
|
179
|
+
inference_config: {
|
|
180
|
+
output_format_schema: Record<string, unknown>;
|
|
181
|
+
max_tokens?: number | null;
|
|
182
|
+
temperature?: number | null;
|
|
183
|
+
top_p?: number | null;
|
|
184
|
+
stop_sequences?: string[] | null;
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
export interface ModelInferenceRunJobResult {
|
|
188
|
+
usage: {
|
|
189
|
+
total_tokens: number;
|
|
190
|
+
prompt_tokens: number;
|
|
191
|
+
completion_tokens: number;
|
|
192
|
+
};
|
|
193
|
+
structured_output: unknown;
|
|
194
|
+
}
|
|
195
|
+
export interface ModelInferenceRunJob extends BaseJob {
|
|
196
|
+
type: "model_inference_run";
|
|
197
|
+
input: ModelInferenceRunInput;
|
|
198
|
+
result?: ModelInferenceRunJobResult;
|
|
199
|
+
}
|
|
200
|
+
export type Job = ForecastJob | ExplainJob | MaterializedViewJob | DatasetsDeleteTableJob | DatasetsDeliverDataJob | DatasetsSampleJob | DatasetsCalculateColumnStatsJob | ModelTrainingRunJob | ModelsDeliverModelJob | ModelsTrainClassifierJob | ModelInferenceRunJob | UnknownJob;
|
|
174
201
|
export interface ModelsTrainClassifierTrainingSummary {
|
|
175
202
|
total_features: number;
|
|
176
203
|
feature_types: Record<"text" | "categorical" | "embedding" | "numeric", number>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { BaseApi } from "../base-api";
|
|
2
|
+
import type { ModelInferenceRunJob } from "../jobs";
|
|
3
|
+
import type { InferenceConfig, InferenceMessage, InferenceModel, InferenceUsage, MessageRole, ModelInferenceRunRequest, ModelInferenceRunResult } from "./types";
|
|
4
|
+
/**
|
|
5
|
+
* @module ModelInferenceApi
|
|
6
|
+
* @description This module provides methods for running model inference jobs.
|
|
7
|
+
* @extends BaseApi
|
|
8
|
+
*/
|
|
9
|
+
declare class ModelInferenceApi extends BaseApi {
|
|
10
|
+
/**
|
|
11
|
+
* Run a model inference job.
|
|
12
|
+
* Creates a job that sends messages to a specified model and returns structured output.
|
|
13
|
+
* @param request - The inference request parameters
|
|
14
|
+
* @returns Promise resolving with the created job
|
|
15
|
+
*/
|
|
16
|
+
runModelInference(request: ModelInferenceRunRequest): Promise<ModelInferenceRunJob>;
|
|
17
|
+
}
|
|
18
|
+
export { ModelInferenceApi, type InferenceConfig, type InferenceMessage, type InferenceModel, type InferenceUsage, type MessageRole, type ModelInferenceRunRequest, type ModelInferenceRunResult, };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BaseApi } from "../base-api";
|
|
2
|
+
const resourceName = "model-inference";
|
|
3
|
+
/**
|
|
4
|
+
* @module ModelInferenceApi
|
|
5
|
+
* @description This module provides methods for running model inference jobs.
|
|
6
|
+
* @extends BaseApi
|
|
7
|
+
*/
|
|
8
|
+
class ModelInferenceApi extends BaseApi {
|
|
9
|
+
/**
|
|
10
|
+
* Run a model inference job.
|
|
11
|
+
* Creates a job that sends messages to a specified model and returns structured output.
|
|
12
|
+
* @param request - The inference request parameters
|
|
13
|
+
* @returns Promise resolving with the created job
|
|
14
|
+
*/
|
|
15
|
+
async runModelInference(request) {
|
|
16
|
+
return await this.post(`${resourceName}/run`, request);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export { ModelInferenceApi, };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model identifiers supported by the Narrative model inference API.
|
|
3
|
+
* Maps to Scala ModelInferenceRunJobInput.Model
|
|
4
|
+
*/
|
|
5
|
+
export type InferenceModel = "anthropic.claude-haiku-4.5" | "anthropic.claude-sonnet-4.5" | "anthropic.claude-opus-4.5" | "openai.gpt-oss-120b" | "openai.gpt-4.1" | "openai.o4-mini";
|
|
6
|
+
/**
|
|
7
|
+
* Message role for inference requests.
|
|
8
|
+
* Maps to Scala ModelInferenceRunJobInput.Role
|
|
9
|
+
*/
|
|
10
|
+
export type MessageRole = "user" | "assistant" | "system";
|
|
11
|
+
/**
|
|
12
|
+
* A message in the inference conversation.
|
|
13
|
+
* Maps to Scala ModelInferenceRunJobInput.Message
|
|
14
|
+
*/
|
|
15
|
+
export interface InferenceMessage {
|
|
16
|
+
role: MessageRole;
|
|
17
|
+
text: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Configuration for the inference request.
|
|
21
|
+
* Maps to Scala ModelInferenceRunJobInput.InferenceConfig
|
|
22
|
+
*/
|
|
23
|
+
export interface InferenceConfig {
|
|
24
|
+
/** JSON Schema defining the expected output format */
|
|
25
|
+
output_format_schema: Record<string, unknown>;
|
|
26
|
+
/** Maximum number of tokens to generate */
|
|
27
|
+
max_tokens?: number;
|
|
28
|
+
/** Sampling temperature (0-1) */
|
|
29
|
+
temperature?: number;
|
|
30
|
+
/** Top-p (nucleus) sampling parameter (0-1) */
|
|
31
|
+
top_p?: number;
|
|
32
|
+
/** Sequences that will stop generation */
|
|
33
|
+
stop_sequences?: string[];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Request body for running a model inference job.
|
|
37
|
+
* Maps to Scala RunRequest
|
|
38
|
+
*/
|
|
39
|
+
export interface ModelInferenceRunRequest {
|
|
40
|
+
/** The data plane ID to run the inference on */
|
|
41
|
+
data_plane_id: string;
|
|
42
|
+
/** The model to use for inference */
|
|
43
|
+
model: InferenceModel;
|
|
44
|
+
/** The conversation messages */
|
|
45
|
+
messages: InferenceMessage[];
|
|
46
|
+
/** Configuration for the inference */
|
|
47
|
+
inference_config: InferenceConfig;
|
|
48
|
+
/** Optional tags for the job */
|
|
49
|
+
tags?: string[];
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Token usage metrics from the inference.
|
|
53
|
+
*/
|
|
54
|
+
export interface InferenceUsage {
|
|
55
|
+
total_tokens: number;
|
|
56
|
+
prompt_tokens: number;
|
|
57
|
+
completion_tokens: number;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Result from a model inference job.
|
|
61
|
+
* @template T - The type of the structured output, defaults to unknown
|
|
62
|
+
*/
|
|
63
|
+
export interface ModelInferenceRunResult<T = unknown> {
|
|
64
|
+
/** Token usage metrics */
|
|
65
|
+
usage: InferenceUsage;
|
|
66
|
+
/** The structured output matching the output_format_schema */
|
|
67
|
+
structured_output: T;
|
|
68
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,44 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@narrative.io/data-collaboration-sdk-ts",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.89.0",
|
|
4
4
|
"main": "build/index.js",
|
|
5
5
|
"repository": "github:narrative-io/data-collaboration-sdk-ts",
|
|
6
6
|
"source": "src/index.ts",
|
|
7
7
|
"types": "build/index.d.ts",
|
|
8
8
|
"description": "",
|
|
9
|
+
"packageManager": "bun@1.2.21",
|
|
9
10
|
"scripts": {
|
|
10
11
|
"build": "tsc",
|
|
11
|
-
"lint": "
|
|
12
|
-
"prepare": "
|
|
13
|
-
"prepublishOnly": "
|
|
14
|
-
"preversion": "
|
|
15
|
-
"version": "
|
|
12
|
+
"lint": "bunx @biomejs/biome check --write ./src",
|
|
13
|
+
"prepare": "bunx @biomejs/biome check --write ./src && bun run build",
|
|
14
|
+
"prepublishOnly": "bun run test && bun run lint",
|
|
15
|
+
"preversion": "bun run lint",
|
|
16
|
+
"version": "bun run && git add -A src",
|
|
16
17
|
"postversion": "git push && git push --tags",
|
|
17
18
|
"test": "jest --coverage",
|
|
18
19
|
"dev": "tsc -w",
|
|
19
20
|
"check:built": "node scripts/ensureBuild.js",
|
|
20
|
-
"link:global": "
|
|
21
|
-
"pack:dist": "
|
|
21
|
+
"link:global": "bun run check:built && bun link",
|
|
22
|
+
"pack:dist": "bun run check:built && bun pm pack"
|
|
22
23
|
},
|
|
23
24
|
"keywords": [],
|
|
24
25
|
"author": "",
|
|
25
26
|
"license": "ISC",
|
|
26
27
|
"devDependencies": {
|
|
27
|
-
"@babel/core": "7.28.
|
|
28
|
-
"@babel/preset-env": "7.28.
|
|
29
|
-
"@babel/preset-typescript": "7.
|
|
30
|
-
"@biomejs/biome": "2.
|
|
28
|
+
"@babel/core": "7.28.5",
|
|
29
|
+
"@babel/preset-env": "7.28.5",
|
|
30
|
+
"@babel/preset-typescript": "7.28.5",
|
|
31
|
+
"@biomejs/biome": "2.3.8",
|
|
31
32
|
"@commitlint/cli": "20.1.0",
|
|
32
33
|
"@commitlint/config-conventional": "20.0.0",
|
|
33
34
|
"@types/jest": "30.0.0",
|
|
34
35
|
"babel-jest": "30.2.0",
|
|
35
36
|
"jest": "30.2.0",
|
|
36
|
-
"lefthook": "2.0.
|
|
37
|
-
"ts-jest": "29.4.
|
|
37
|
+
"lefthook": "2.0.7",
|
|
38
|
+
"ts-jest": "29.4.6"
|
|
38
39
|
},
|
|
39
40
|
"dependencies": {
|
|
40
41
|
"mande": "2.0.9",
|
|
41
|
-
"zod": "4.1.
|
|
42
|
+
"zod": "4.1.13",
|
|
42
43
|
"bignumber.js": "9.3.1"
|
|
43
44
|
},
|
|
44
45
|
"overrides": {
|