@narrative.io/data-collaboration-sdk-ts 0.0.39 → 0.0.41
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/data-streams/index.d.ts +27 -0
- package/build/data-streams/index.js +37 -0
- package/build/data-streams/types.d.ts +50 -0
- package/build/data-streams/types.js +1 -0
- package/build/index.d.ts +3 -2
- package/build/index.js +2 -1
- package/build/nql/index.d.ts +10 -3
- package/build/nql/index.js +12 -2
- package/build/nql/types.d.ts +5 -0
- package/package.json +4 -4
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type ApiRecords } from '../types';
|
|
2
|
+
import { BaseApi } from '../base-api';
|
|
3
|
+
import { type DataStream } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* @module DataStreramsApi
|
|
6
|
+
* @description This module provides methods for interacting with Data Streams.
|
|
7
|
+
* @extends BaseApi
|
|
8
|
+
*/
|
|
9
|
+
declare class DataStreamsApi extends BaseApi {
|
|
10
|
+
/**
|
|
11
|
+
* @function getDataStreamsForDSM
|
|
12
|
+
* @memberof DataStreramsApi
|
|
13
|
+
* @description Fetches a list Data Streams that contain an offer with the data_streams_market channel, given a search term
|
|
14
|
+
* @returns {Promise<ApiRecords<DataStream>>} A promise that resolves to the list of Data Streams.
|
|
15
|
+
*/
|
|
16
|
+
getDataStreamsForDSM(searchTerm: string, authenticated: boolean): Promise<ApiRecords<DataStream>>;
|
|
17
|
+
/**
|
|
18
|
+
* Gets a single Data Stream given a slug and companyId.
|
|
19
|
+
*
|
|
20
|
+
* @param {number} slug - The slug for the Data Stream to return.
|
|
21
|
+
* @param {number} companyId - The companyId for the Data Stream to return.
|
|
22
|
+
* @returns {Promise<DataStream>} A promise that resolves with the Data Stream.
|
|
23
|
+
*/
|
|
24
|
+
getDataStreamBySlug(slug: string, companyId: number, authenticated: boolean): Promise<DataStream>;
|
|
25
|
+
private getBaseUri;
|
|
26
|
+
}
|
|
27
|
+
export { DataStreamsApi, type DataStream };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { BaseApi } from '../base-api';
|
|
2
|
+
const resourceName = 'data-stream';
|
|
3
|
+
/**
|
|
4
|
+
* @module DataStreramsApi
|
|
5
|
+
* @description This module provides methods for interacting with Data Streams.
|
|
6
|
+
* @extends BaseApi
|
|
7
|
+
*/
|
|
8
|
+
class DataStreamsApi extends BaseApi {
|
|
9
|
+
/**
|
|
10
|
+
* @function getDataStreamsForDSM
|
|
11
|
+
* @memberof DataStreramsApi
|
|
12
|
+
* @description Fetches a list Data Streams that contain an offer with the data_streams_market channel, given a search term
|
|
13
|
+
* @returns {Promise<ApiRecords<DataStream>>} A promise that resolves to the list of Data Streams.
|
|
14
|
+
*/
|
|
15
|
+
async getDataStreamsForDSM(searchTerm, authenticated) {
|
|
16
|
+
return await this.get(`${this.getBaseUri(authenticated)}/sales-channel/data-streams-market/search?q=${encodeURIComponent(searchTerm)}`);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Gets a single Data Stream given a slug and companyId.
|
|
20
|
+
*
|
|
21
|
+
* @param {number} slug - The slug for the Data Stream to return.
|
|
22
|
+
* @param {number} companyId - The companyId for the Data Stream to return.
|
|
23
|
+
* @returns {Promise<DataStream>} A promise that resolves with the Data Stream.
|
|
24
|
+
*/
|
|
25
|
+
async getDataStreamBySlug(slug, companyId, authenticated) {
|
|
26
|
+
return await this.get(`${this.getBaseUri(authenticated)}/company/${companyId}/slug/${slug}`);
|
|
27
|
+
}
|
|
28
|
+
getBaseUri(authenticated) {
|
|
29
|
+
if (authenticated) {
|
|
30
|
+
return resourceName;
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
return `public/${resourceName}`;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export { DataStreamsApi };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type Dataset } from '../datasets/types';
|
|
2
|
+
import { type DataRules } from './data-rules/types';
|
|
3
|
+
export interface DataStream {
|
|
4
|
+
id: number;
|
|
5
|
+
company_id: number;
|
|
6
|
+
name: string;
|
|
7
|
+
slug: string;
|
|
8
|
+
content?: DataStreamContent;
|
|
9
|
+
tags?: string[];
|
|
10
|
+
category?: string;
|
|
11
|
+
offers?: Offer[];
|
|
12
|
+
data_rules?: DataRules;
|
|
13
|
+
auth_rules?: AuthRules;
|
|
14
|
+
created_by: number;
|
|
15
|
+
created_at: Date;
|
|
16
|
+
updated_at: Date;
|
|
17
|
+
updated_by: number;
|
|
18
|
+
pagination_id: number;
|
|
19
|
+
datasets?: Dataset[];
|
|
20
|
+
}
|
|
21
|
+
export interface DataStreamContent {
|
|
22
|
+
description: string;
|
|
23
|
+
icon?: string;
|
|
24
|
+
sections?: string[];
|
|
25
|
+
}
|
|
26
|
+
export type SalesChannel = 'data_streams_market' | 'data_shop';
|
|
27
|
+
export interface Offer {
|
|
28
|
+
id: string;
|
|
29
|
+
channel: SalesChannel;
|
|
30
|
+
licensing: OfferLicensing;
|
|
31
|
+
pricing: OfferPricing;
|
|
32
|
+
shops?: string[];
|
|
33
|
+
}
|
|
34
|
+
export interface OfferLicensing {
|
|
35
|
+
period: string;
|
|
36
|
+
license: {
|
|
37
|
+
id: string;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export interface OfferPricing {
|
|
41
|
+
micro_cents_usd: number;
|
|
42
|
+
type: 'per_record' | 'max_price_per_record';
|
|
43
|
+
}
|
|
44
|
+
export interface AuthRules {
|
|
45
|
+
company_contstraint: CompanyConstraint;
|
|
46
|
+
}
|
|
47
|
+
export interface CompanyConstraint {
|
|
48
|
+
type: InclusionType;
|
|
49
|
+
}
|
|
50
|
+
export type InclusionType = 'include' | 'exclude';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/build/index.d.ts
CHANGED
|
@@ -16,9 +16,10 @@ import { type PingStatus } from './ping/types';
|
|
|
16
16
|
import { type Product, ProductsApi } from './products';
|
|
17
17
|
import { CompanyInfoApi, type CompanyInfo } from './company-info';
|
|
18
18
|
import { InstallationsApi, type Installation } from './installations';
|
|
19
|
-
import { NqlApi, type NqlQuery, type NqlResult } from './nql';
|
|
19
|
+
import { NqlApi, type NqlCompileResult, type NqlQuery, type NqlResult } from './nql';
|
|
20
|
+
import { DataStreamsApi, type DataStream } from './data-streams';
|
|
20
21
|
declare class NarrativeApi extends BaseApi {
|
|
21
22
|
}
|
|
22
23
|
interface NarrativeApi extends BaseApi, HealthCheckApi, DatasetApi, RosettaStoneApi, AttributeApi, PingApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi {
|
|
23
24
|
}
|
|
24
|
-
export { NarrativeApi, AttributeApi, HealthCheckApi, DatasetApi, PingApi, ProductsApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi, type Resource, type UploadsResponse, type PingStatus, type Attribute, type Environment, type Config, type ApiRecords, type Dataset, type HealthCheckResult, type SampleRecords, type DatasetTableSummary, type DatasetTableSummaryAPIResponse, type Product, type MonetaryAmount, type CompanyInfo, type Installation, type FilePerSnapshotResponse, type BucketCreationRequest, type UpdateAccessTypeRequest, type NqlQuery, type NqlResult };
|
|
25
|
+
export { NarrativeApi, AttributeApi, HealthCheckApi, DatasetApi, PingApi, ProductsApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, type Resource, type UploadsResponse, type PingStatus, type Attribute, type Environment, type Config, type ApiRecords, type Dataset, type HealthCheckResult, type SampleRecords, type DatasetTableSummary, type DatasetTableSummaryAPIResponse, type Product, type MonetaryAmount, type CompanyInfo, type Installation, type FilePerSnapshotResponse, type BucketCreationRequest, type UpdateAccessTypeRequest, type NqlQuery, type NqlResult, type NqlCompileResult, type DataStream };
|
package/build/index.js
CHANGED
|
@@ -11,7 +11,8 @@ import { ProductsApi } from './products';
|
|
|
11
11
|
import { CompanyInfoApi } from './company-info';
|
|
12
12
|
import { InstallationsApi } from './installations';
|
|
13
13
|
import { NqlApi } from './nql';
|
|
14
|
+
import { DataStreamsApi } from './data-streams';
|
|
14
15
|
class NarrativeApi extends BaseApi {
|
|
15
16
|
}
|
|
16
17
|
applyMixins(NarrativeApi, [BaseApi, HealthCheckApi, DatasetApi, RosettaStoneApi, AttributeApi, PingApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi]);
|
|
17
|
-
export { NarrativeApi, AttributeApi, HealthCheckApi, DatasetApi, PingApi, ProductsApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi };
|
|
18
|
+
export { NarrativeApi, AttributeApi, HealthCheckApi, DatasetApi, PingApi, ProductsApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi };
|
package/build/nql/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseApi } from '../base-api';
|
|
2
|
-
import {
|
|
2
|
+
import type { NqlCompileResult, NqlQuery, NqlResult } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* A class for accessing the NQL API.
|
|
5
5
|
* @extends BaseApi
|
|
@@ -9,8 +9,15 @@ declare class NqlApi extends BaseApi {
|
|
|
9
9
|
* Executes an NQL query and returns the result.
|
|
10
10
|
*
|
|
11
11
|
* @param {string} nqlQuery - The NQL query to execute.
|
|
12
|
-
* @returns {Promise<
|
|
12
|
+
* @returns {Promise<NqlResult>} A promise that resolves with the result of the NQL query.
|
|
13
13
|
*/
|
|
14
14
|
executeNql(nqlQuery: NqlQuery): Promise<NqlResult>;
|
|
15
|
+
/**
|
|
16
|
+
* Compiles an NQL query and returns the result, including any errors.
|
|
17
|
+
*
|
|
18
|
+
* @param {string} nqlQuery - The NQL query to compile.
|
|
19
|
+
* @returns {Promise<NqlCompileResult>} A promise that resolves with the result of the NQL compilation.
|
|
20
|
+
*/
|
|
21
|
+
compileNql(nqlQuery: NqlQuery): Promise<NqlCompileResult>;
|
|
15
22
|
}
|
|
16
|
-
export { NqlApi, type NqlResult, type NqlQuery };
|
|
23
|
+
export { NqlApi, type NqlResult, type NqlQuery, type NqlCompileResult };
|
package/build/nql/index.js
CHANGED
|
@@ -16,10 +16,20 @@ class NqlApi extends BaseApi {
|
|
|
16
16
|
* Executes an NQL query and returns the result.
|
|
17
17
|
*
|
|
18
18
|
* @param {string} nqlQuery - The NQL query to execute.
|
|
19
|
-
* @returns {Promise<
|
|
19
|
+
* @returns {Promise<NqlResult>} A promise that resolves with the result of the NQL query.
|
|
20
20
|
*/
|
|
21
21
|
async executeNql(nqlQuery) {
|
|
22
|
-
const response = await this.post(resourceName
|
|
22
|
+
const response = await this.post(`${resourceName}/run`, nqlQuery);
|
|
23
|
+
return response;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Compiles an NQL query and returns the result, including any errors.
|
|
27
|
+
*
|
|
28
|
+
* @param {string} nqlQuery - The NQL query to compile.
|
|
29
|
+
* @returns {Promise<NqlCompileResult>} A promise that resolves with the result of the NQL compilation.
|
|
30
|
+
*/
|
|
31
|
+
async compileNql(nqlQuery) {
|
|
32
|
+
const response = await this.post(`${resourceName}/compile`, nqlQuery);
|
|
23
33
|
return response;
|
|
24
34
|
}
|
|
25
35
|
}
|
package/build/nql/types.d.ts
CHANGED
|
@@ -26,6 +26,11 @@ export interface NqlResult {
|
|
|
26
26
|
state: string;
|
|
27
27
|
updated_at: string;
|
|
28
28
|
}
|
|
29
|
+
export type NqlMappingErrors = Record<number, string>;
|
|
30
|
+
export interface NqlCompileResult {
|
|
31
|
+
sql: string;
|
|
32
|
+
mappingErrors?: NqlMappingErrors;
|
|
33
|
+
}
|
|
29
34
|
export interface NqlQuery {
|
|
30
35
|
nql: string;
|
|
31
36
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@narrative.io/data-collaboration-sdk-ts",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.41",
|
|
4
4
|
"main": "build/index.js",
|
|
5
5
|
"repository": "github:narrative-io/data-collaboration-sdk-ts",
|
|
6
6
|
"source": "src/index.ts",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"@babel/preset-typescript": "^7.18.6",
|
|
26
26
|
"@commitlint/cli": "^17.4.2",
|
|
27
27
|
"@commitlint/config-conventional": "^17.4.2",
|
|
28
|
-
"@types/jest": "^29.
|
|
28
|
+
"@types/jest": "^29.5.0",
|
|
29
29
|
"@typescript-eslint/eslint-plugin": "^5.51.0",
|
|
30
30
|
"babel-jest": "^29.4.3",
|
|
31
31
|
"eslint": "^8.33.0",
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"eslint-plugin-import": "^2.27.5",
|
|
34
34
|
"eslint-plugin-n": "^15.6.1",
|
|
35
35
|
"eslint-plugin-promise": "^6.1.1",
|
|
36
|
+
"husky": "^8.0.0",
|
|
36
37
|
"jest": "^29.4.3",
|
|
37
38
|
"ts-jest": "^29.0.5",
|
|
38
|
-
"typescript": "^5.0.2"
|
|
39
|
-
"husky": "^8.0.0"
|
|
39
|
+
"typescript": "^5.0.2"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"mande": "^2.0.3"
|