@narrative.io/data-collaboration-sdk-ts 2.108.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/access-rules/types.d.ts +2 -2
- package/build/base-api.d.ts +5 -5
- package/build/base-api.js +9 -8
- package/build/data-planes/index.d.ts +1 -1
- package/build/datasets/index.d.ts +1 -1
- package/build/datasets/types.d.ts +1 -1
- package/build/encryption-materials/index.d.ts +1 -1
- package/build/http-client.d.ts +45 -0
- package/build/http-client.js +86 -0
- package/build/index.d.ts +1 -0
- package/build/index.js +1 -0
- package/build/jobs/types.d.ts +3 -3
- package/build/mappings/index.d.ts +1 -1
- package/build/model-training/types.d.ts +1 -1
- package/build/models/types.d.ts +1 -1
- package/build/nql/DataRulesConverter.d.ts +1 -1
- package/build/nql/types.d.ts +1 -1
- package/build/queries/types.d.ts +1 -1
- package/build/rosetta-stone/index.d.ts +2 -2
- package/build/subscriptions/types.d.ts +2 -2
- package/build/types.d.ts +2 -2
- package/build/views/types.d.ts +2 -2
- package/build/whoami/types.d.ts +1 -1
- package/package.json +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Schema } from "
|
|
2
|
-
import type { CollaboratorsConfig } from "
|
|
1
|
+
import type { Schema } from "../datasets";
|
|
2
|
+
import type { CollaboratorsConfig } from "../types";
|
|
3
3
|
export interface AccessRule {
|
|
4
4
|
id: number;
|
|
5
5
|
dataset_id?: AccessRuleDatasetId;
|
package/build/base-api.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HttpClient } from "./http-client";
|
|
2
2
|
import type { Config, PaginationOptions } from "./types";
|
|
3
3
|
/**
|
|
4
4
|
* BaseApi class provides basic functionality for making API requests.
|
|
@@ -6,7 +6,7 @@ import type { Config, PaginationOptions } from "./types";
|
|
|
6
6
|
export declare abstract class BaseApi {
|
|
7
7
|
protected apiKey?: string;
|
|
8
8
|
protected readonly environment: string;
|
|
9
|
-
protected readonly base_api:
|
|
9
|
+
protected readonly base_api: HttpClient;
|
|
10
10
|
protected readonly headers: Record<string, string>;
|
|
11
11
|
protected readonly verbose: boolean;
|
|
12
12
|
/**
|
|
@@ -22,11 +22,11 @@ export declare abstract class BaseApi {
|
|
|
22
22
|
*/
|
|
23
23
|
getHeaders(): Record<string, string>;
|
|
24
24
|
/**
|
|
25
|
-
* Retrieves the
|
|
25
|
+
* Retrieves the underlying HTTP client backing this API instance.
|
|
26
26
|
*
|
|
27
|
-
* @returns
|
|
27
|
+
* @returns An HttpClient instance representing the base API instance.
|
|
28
28
|
*/
|
|
29
|
-
getBaseApi():
|
|
29
|
+
getBaseApi(): HttpClient;
|
|
30
30
|
/**
|
|
31
31
|
* Retrieves the API key associated with the API instance, if it exists.
|
|
32
32
|
*
|
package/build/base-api.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HttpClient } from "./http-client";
|
|
2
2
|
import { addTrailingSlash } from "./utils";
|
|
3
3
|
/**
|
|
4
4
|
* BaseApi class provides basic functionality for making API requests.
|
|
@@ -19,7 +19,8 @@ export class BaseApi {
|
|
|
19
19
|
this.environment = config.environment ?? "prod";
|
|
20
20
|
this.verbose = (config.verbose ?? false) || this.environment === "dev";
|
|
21
21
|
this.headers = config.headers ?? {};
|
|
22
|
-
this.base_api =
|
|
22
|
+
this.base_api = new HttpClient({
|
|
23
|
+
baseUrl: this.getBaseUrl(),
|
|
23
24
|
headers: this.constructHeaders(),
|
|
24
25
|
responseAs: config.responseAs ?? "json",
|
|
25
26
|
});
|
|
@@ -41,9 +42,9 @@ export class BaseApi {
|
|
|
41
42
|
return this.constructHeaders();
|
|
42
43
|
}
|
|
43
44
|
/**
|
|
44
|
-
* Retrieves the
|
|
45
|
+
* Retrieves the underlying HTTP client backing this API instance.
|
|
45
46
|
*
|
|
46
|
-
* @returns
|
|
47
|
+
* @returns An HttpClient instance representing the base API instance.
|
|
47
48
|
*/
|
|
48
49
|
getBaseApi() {
|
|
49
50
|
return this.base_api;
|
|
@@ -82,12 +83,12 @@ export class BaseApi {
|
|
|
82
83
|
async get(endpoint, params) {
|
|
83
84
|
const queryString = this.constructQueryString(params);
|
|
84
85
|
const url = `${endpoint}${queryString}`;
|
|
85
|
-
if (this.verbose)
|
|
86
|
+
if (this.verbose)
|
|
86
87
|
console.log(`Making GET request to ${url}...`);
|
|
87
|
-
|
|
88
|
+
const resp = await this.base_api.get(url);
|
|
89
|
+
if (this.verbose)
|
|
88
90
|
console.log(`Response: ${JSON.stringify(resp)}`);
|
|
89
|
-
|
|
90
|
-
return await this.base_api.get(url);
|
|
91
|
+
return resp;
|
|
91
92
|
}
|
|
92
93
|
/**
|
|
93
94
|
* Makes a POST request to the given endpoint with the given data.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ApiRecords } from "src/types";
|
|
2
1
|
import { BaseApi } from "../base-api";
|
|
2
|
+
import type { ApiRecords } from "../types";
|
|
3
3
|
import type { DataPlane, HealthCheckJobResponse } from "./types";
|
|
4
4
|
export declare class DataPlaneApi extends BaseApi {
|
|
5
5
|
getDataPlanes(): Promise<ApiRecords<DataPlane>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { UnknownJob } from "src/jobs/types";
|
|
2
1
|
import { BaseApi } from "../base-api";
|
|
2
|
+
import type { UnknownJob } from "../jobs/types";
|
|
3
3
|
import type { ApiRecords } from "../types";
|
|
4
4
|
import type { DatasetStatisticsConfiguration, StatisticsConfigurationResponse } from "./statistics-types";
|
|
5
5
|
import type { AdvancedStatistics, AdvancedStatisticsMetadata, BasicStatistics, ColumnStatistics, ColumnSummary, Columns, Configuration, CreateDatasetRefreshScheduleRequest, CreateDatasetRequest, Dataset, DatasetInterfaceError, DatasetInterfaceRef, DatasetInterfaceValidation, DatasetStatus, DatasetTableSummary, DatasetTableSummaryAPIResponse, DatasetWriteMode, FilePerSnapshotResponse, Histogram, IngestDatasetFileRequest, JsonSchemaValidationNode, RecalculationInfo, RetentionPolicy, RetentionScheduleConfig, RowClock, RowTTLPolicy, Schema, SchemaArrayItems, SchemaArrayItemsArray, SchemaArrayItemsObject, SchemaArrayItemsPrimitive, SchemaArrayProperty, SchemaFileConfig, SchemaFileConfigType, SchemaObjectProperty, SchemaPrimitiveProperty, SchemaProperties, SchemaPropertiesType, SchemaProperty, SnapshotAgeExpression, SnapshotRange, SnapshotTTLPolicy, TableClock, TableClockKind, TableTTLPolicy, TTLPolicy, TTLPolicyKind, UpdateDatasetRefreshScheduleRequest, UpdateDatasetRequest, UpsertRetentionPoliciesRequest, Value } from "./types";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ApiRecords } from "src/types";
|
|
2
1
|
import { BaseApi } from "../base-api";
|
|
2
|
+
import type { ApiRecords } from "../types";
|
|
3
3
|
import type { CreateEncryptionMaterialRequest, DataEncryptionMaterial, UpdateEncryptionMaterialRequest } from "./types";
|
|
4
4
|
export declare class EncryptionMaterialApi extends BaseApi {
|
|
5
5
|
/**
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal `fetch`-based HTTP client used by {@link BaseApi}.
|
|
3
|
+
*
|
|
4
|
+
* Replaces the previously-used `mande` package (now abandoned). The behavior
|
|
5
|
+
* here intentionally mirrors what `mande` did for the request shapes this SDK
|
|
6
|
+
* relies on, so swapping it in is transparent to callers:
|
|
7
|
+
* - joins the base URL and endpoint, normalizing the slash between them
|
|
8
|
+
* - sends `Accept`/`Content-Type: application/json` by default (overridable)
|
|
9
|
+
* - JSON-stringifies the body of POST/PUT/PATCH requests
|
|
10
|
+
* - parses the response per {@link ResponseAs}; a 204 (or parse failure)
|
|
11
|
+
* resolves to `null`
|
|
12
|
+
* - throws on any non-2xx status, attaching the {@link Response} and the parsed
|
|
13
|
+
* body to the error
|
|
14
|
+
*/
|
|
15
|
+
/** How a response body should be returned from a request. */
|
|
16
|
+
export type ResponseAs = "json" | "text" | "response";
|
|
17
|
+
/** Options for constructing an {@link HttpClient}. */
|
|
18
|
+
export interface HttpClientOptions {
|
|
19
|
+
/** Absolute base URL that every request is resolved against. */
|
|
20
|
+
baseUrl: string;
|
|
21
|
+
/** Headers applied to every request. */
|
|
22
|
+
headers?: Record<string, string>;
|
|
23
|
+
/** How to interpret response bodies. Defaults to `"json"`. */
|
|
24
|
+
responseAs?: ResponseAs;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Error thrown for any non-2xx response. Carries the originating
|
|
28
|
+
* {@link Response} and the parsed body so callers can inspect the failure.
|
|
29
|
+
*/
|
|
30
|
+
export declare class HttpError extends Error {
|
|
31
|
+
readonly response: Response;
|
|
32
|
+
readonly body: unknown;
|
|
33
|
+
constructor(response: Response, body: unknown);
|
|
34
|
+
}
|
|
35
|
+
export declare class HttpClient {
|
|
36
|
+
private readonly baseUrl;
|
|
37
|
+
private readonly headers;
|
|
38
|
+
private readonly responseAs;
|
|
39
|
+
constructor(options: HttpClientOptions);
|
|
40
|
+
get<T>(url: string): Promise<T>;
|
|
41
|
+
post<T>(url: string, data?: unknown): Promise<T>;
|
|
42
|
+
put<T>(url: string, data?: unknown): Promise<T>;
|
|
43
|
+
delete<T>(url: string): Promise<T>;
|
|
44
|
+
private request;
|
|
45
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal `fetch`-based HTTP client used by {@link BaseApi}.
|
|
3
|
+
*
|
|
4
|
+
* Replaces the previously-used `mande` package (now abandoned). The behavior
|
|
5
|
+
* here intentionally mirrors what `mande` did for the request shapes this SDK
|
|
6
|
+
* relies on, so swapping it in is transparent to callers:
|
|
7
|
+
* - joins the base URL and endpoint, normalizing the slash between them
|
|
8
|
+
* - sends `Accept`/`Content-Type: application/json` by default (overridable)
|
|
9
|
+
* - JSON-stringifies the body of POST/PUT/PATCH requests
|
|
10
|
+
* - parses the response per {@link ResponseAs}; a 204 (or parse failure)
|
|
11
|
+
* resolves to `null`
|
|
12
|
+
* - throws on any non-2xx status, attaching the {@link Response} and the parsed
|
|
13
|
+
* body to the error
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Error thrown for any non-2xx response. Carries the originating
|
|
17
|
+
* {@link Response} and the parsed body so callers can inspect the failure.
|
|
18
|
+
*/
|
|
19
|
+
export class HttpError extends Error {
|
|
20
|
+
response;
|
|
21
|
+
body;
|
|
22
|
+
constructor(response, body) {
|
|
23
|
+
super(response.statusText || `Request failed with status ${response.status}`);
|
|
24
|
+
this.name = "HttpError";
|
|
25
|
+
this.response = response;
|
|
26
|
+
this.body = body;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const leadingSlashRE = /^\/+/;
|
|
30
|
+
/** Joins a base URL and a path with exactly one slash between them. */
|
|
31
|
+
function joinUrl(base, url) {
|
|
32
|
+
if (!url)
|
|
33
|
+
return base;
|
|
34
|
+
if (base.endsWith("/"))
|
|
35
|
+
return base + url.replace(leadingSlashRE, "");
|
|
36
|
+
return url.startsWith("/") ? base + url : `${base}/${url}`;
|
|
37
|
+
}
|
|
38
|
+
export class HttpClient {
|
|
39
|
+
baseUrl;
|
|
40
|
+
headers;
|
|
41
|
+
responseAs;
|
|
42
|
+
constructor(options) {
|
|
43
|
+
this.baseUrl = options.baseUrl;
|
|
44
|
+
this.responseAs = options.responseAs ?? "json";
|
|
45
|
+
this.headers = {
|
|
46
|
+
Accept: "application/json",
|
|
47
|
+
"Content-Type": "application/json",
|
|
48
|
+
...options.headers,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
async get(url) {
|
|
52
|
+
return this.request("GET", url);
|
|
53
|
+
}
|
|
54
|
+
async post(url, data) {
|
|
55
|
+
return this.request("POST", url, data);
|
|
56
|
+
}
|
|
57
|
+
async put(url, data) {
|
|
58
|
+
return this.request("PUT", url, data);
|
|
59
|
+
}
|
|
60
|
+
async delete(url) {
|
|
61
|
+
return this.request("DELETE", url);
|
|
62
|
+
}
|
|
63
|
+
async request(method, url, data) {
|
|
64
|
+
const init = { method, headers: this.headers };
|
|
65
|
+
// Only POST/PUT/PATCH carry a body.
|
|
66
|
+
if (method[0] === "P" && data !== undefined && data !== null) {
|
|
67
|
+
init.body = JSON.stringify(data);
|
|
68
|
+
}
|
|
69
|
+
const response = await fetch(joinUrl(this.baseUrl, url), init);
|
|
70
|
+
// Return the raw Response untouched when asked.
|
|
71
|
+
if (this.responseAs === "response") {
|
|
72
|
+
if (response.status >= 200 && response.status < 300) {
|
|
73
|
+
return response;
|
|
74
|
+
}
|
|
75
|
+
throw new HttpError(response, response);
|
|
76
|
+
}
|
|
77
|
+
// 204 No Content has no body to parse.
|
|
78
|
+
const body = response.status === 204
|
|
79
|
+
? null
|
|
80
|
+
: await response[this.responseAs]().catch(() => null);
|
|
81
|
+
if (response.status >= 200 && response.status < 300) {
|
|
82
|
+
return body;
|
|
83
|
+
}
|
|
84
|
+
throw new HttpError(response, body);
|
|
85
|
+
}
|
|
86
|
+
}
|
package/build/index.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ export * from "./encryption-materials/types";
|
|
|
24
24
|
export * from "./forecast";
|
|
25
25
|
export * from "./health";
|
|
26
26
|
export * from "./health/types";
|
|
27
|
+
export * from "./http-client";
|
|
27
28
|
export * from "./installations";
|
|
28
29
|
export * from "./jobs";
|
|
29
30
|
export { default as JsonBigNumber } from "./json-big-number";
|
package/build/index.js
CHANGED
|
@@ -24,6 +24,7 @@ export * from "./encryption-materials/types";
|
|
|
24
24
|
export * from "./forecast";
|
|
25
25
|
export * from "./health";
|
|
26
26
|
export * from "./health/types";
|
|
27
|
+
export * from "./http-client";
|
|
27
28
|
export * from "./installations";
|
|
28
29
|
export * from "./jobs";
|
|
29
30
|
// Special imports that might be from default exports or need special handling
|
package/build/jobs/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ForecastResult, JobState } from "
|
|
2
|
-
import type { DataStreamPurchaseDetails, ForecastDimensions, MarketplaceForecastDetails } from "
|
|
3
|
-
import type { NqlBudget } from "
|
|
1
|
+
import type { ForecastResult, JobState } from "../forecast";
|
|
2
|
+
import type { DataStreamPurchaseDetails, ForecastDimensions, MarketplaceForecastDetails } from "../forecast/types";
|
|
3
|
+
import type { NqlBudget } from "../nql/types";
|
|
4
4
|
/**
|
|
5
5
|
* Every job type the backend can persist and return from the /jobs API.
|
|
6
6
|
* The backend's `Job.Type` is an open string, so treat this list as the
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ApiRecords, Config } from "src/types";
|
|
2
1
|
import { BaseApi } from "../base-api";
|
|
3
2
|
import { CompanyInfoApi } from "../company-info";
|
|
3
|
+
import type { ApiRecords, Config } from "../types";
|
|
4
4
|
import type { CreateMapping, Mapping, MappingExpressionDependencies, MappingTestResult, MappingTestResults, ObjectMapping, PropertyMapping, RawMappingDefinition, RawObjectMapping, RawPropertyMapping, RawValueMapping, ValueMapping } from "./types";
|
|
5
5
|
/**
|
|
6
6
|
* Class representing the Mappings API.
|
package/build/models/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CollaboratorList, GeneralCollaborator } from "
|
|
1
|
+
import type { CollaboratorList, GeneralCollaborator } from "../types";
|
|
2
2
|
export interface ModelCollaborators {
|
|
3
3
|
view: CollaboratorList | GeneralCollaborator;
|
|
4
4
|
train: CollaboratorList | GeneralCollaborator;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ObjectAttribute } from "src/attributes/types";
|
|
2
1
|
import { type Attribute } from "../attributes";
|
|
2
|
+
import type { ObjectAttribute } from "../attributes/types";
|
|
3
3
|
import type { DataRules } from "../data-streams/types";
|
|
4
4
|
import type { DataRulesAttributesField, ForecastBody, Nql } from "./types";
|
|
5
5
|
/**
|
package/build/nql/types.d.ts
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @see {@link https://github.com/colinhacks/zod} for more information about Zod.
|
|
6
6
|
*/
|
|
7
|
-
import type { Dataset } from "src/datasets/types";
|
|
8
7
|
import { z } from "zod";
|
|
8
|
+
import type { Dataset } from "../datasets/types";
|
|
9
9
|
/**
|
|
10
10
|
* Defines the structure for a budget object.
|
|
11
11
|
*
|
package/build/queries/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Dataset } from "src/datasets";
|
|
2
|
-
import type { Mapping } from "src/mappings/types";
|
|
3
1
|
import { BaseApi } from "../base-api";
|
|
2
|
+
import type { Dataset } from "../datasets";
|
|
3
|
+
import type { Mapping } from "../mappings/types";
|
|
4
4
|
import type { RosettaStoneResponse, SampleRecord, SampleRecords } from "./types";
|
|
5
5
|
declare class RosettaStoneApi extends BaseApi {
|
|
6
6
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { CompanyConstraint, DataRules, Offer } from "
|
|
2
|
-
import type { DatasetConstraint } from "
|
|
1
|
+
import type { CompanyConstraint, DataRules, Offer } from "../data-streams/types";
|
|
2
|
+
import type { DatasetConstraint } from "../forecast/types";
|
|
3
3
|
export interface Subscription {
|
|
4
4
|
id: string;
|
|
5
5
|
budget: SubscriptionBudget;
|
package/build/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ResponseAs } from "./http-client";
|
|
2
2
|
/**
|
|
3
3
|
* Environment for the API.
|
|
4
4
|
*
|
|
@@ -17,7 +17,7 @@ export interface Config {
|
|
|
17
17
|
environment?: Environment;
|
|
18
18
|
headers?: Record<string, string>;
|
|
19
19
|
verbose?: boolean;
|
|
20
|
-
responseAs?:
|
|
20
|
+
responseAs?: ResponseAs;
|
|
21
21
|
}
|
|
22
22
|
export interface ApiRecordsV2<T> extends PaginationMetadata {
|
|
23
23
|
records: T[];
|
package/build/views/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { NqlQueryMetadata, NqlQueryOwner } from "
|
|
2
|
-
import type { CollaboratorsConfig } from "
|
|
1
|
+
import type { NqlQueryMetadata, NqlQueryOwner } from "../queries";
|
|
2
|
+
import type { CollaboratorsConfig } from "../types";
|
|
3
3
|
export interface SharedView {
|
|
4
4
|
id: number;
|
|
5
5
|
name: string;
|
package/build/whoami/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": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"main": "build/index.js",
|
|
5
5
|
"repository": "github:narrative-io/data-collaboration-sdk-ts",
|
|
6
6
|
"source": "src/index.ts",
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
"babel-jest": "30.4.1",
|
|
37
37
|
"jest": "30.4.2",
|
|
38
38
|
"lefthook": "2.1.9",
|
|
39
|
-
"ts-jest": "29.4.11"
|
|
39
|
+
"ts-jest": "29.4.11",
|
|
40
|
+
"typescript": "6.0.0-dev.20260416"
|
|
40
41
|
},
|
|
41
42
|
"dependencies": {
|
|
42
|
-
"mande": "2.0.9",
|
|
43
43
|
"zod": "4.4.3",
|
|
44
44
|
"bignumber.js": "11.1.2"
|
|
45
45
|
},
|