@narrative.io/data-collaboration-sdk-ts 0.0.40 → 0.0.42

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.
@@ -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 DataStreamsApi
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 DataStreamsApi
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,128 @@
1
+ import { type Dataset } from '../datasets/types';
2
+ export interface DataStream {
3
+ id: number;
4
+ company_id: number;
5
+ name: string;
6
+ slug: string;
7
+ content?: DataStreamContent;
8
+ tags?: string[];
9
+ category?: string;
10
+ offers?: Offer[];
11
+ data_rules?: DataRules;
12
+ auth_rules?: AuthRules;
13
+ created_by: number;
14
+ created_at: Date;
15
+ updated_at: Date;
16
+ updated_by: number;
17
+ pagination_id: number;
18
+ datasets?: Dataset[];
19
+ }
20
+ export interface DataStreamContent {
21
+ description: string;
22
+ icon?: string;
23
+ sections?: string[];
24
+ }
25
+ export type SalesChannel = 'data_streams_market' | 'data_shop';
26
+ export interface Offer {
27
+ id: string;
28
+ channel: SalesChannel;
29
+ licensing: OfferLicensing;
30
+ pricing: OfferPricing;
31
+ shops?: string[];
32
+ }
33
+ export interface OfferLicensing {
34
+ period: string;
35
+ license: {
36
+ id: string;
37
+ };
38
+ }
39
+ export interface OfferPricing {
40
+ micro_cents_usd: number;
41
+ type: 'per_record' | 'max_price_per_record';
42
+ }
43
+ export interface AuthRules {
44
+ company_contstraint: CompanyConstraint;
45
+ }
46
+ export interface CompanyConstraint {
47
+ type: InclusionType;
48
+ }
49
+ export interface DataRules {
50
+ column_sets?: ColumnSet[];
51
+ attributes?: AttributeSet[];
52
+ deduplication?: Deduplication;
53
+ frequency_filter?: FrequencyFilter;
54
+ dataset_filter?: DatasetFilter;
55
+ ingestion_timestamp_filter?: TimestampFilter;
56
+ }
57
+ export interface ColumnSet {
58
+ dataset_id: string;
59
+ fields: ColumnWithFilterAndExport[];
60
+ }
61
+ export interface AttributeSet {
62
+ attribute_id: number;
63
+ fields: ColumnWithFilterAndExport[];
64
+ optional: boolean;
65
+ }
66
+ export interface Deduplication {
67
+ period: string;
68
+ column_references?: ColumnReferences[];
69
+ attribute_references?: AttributeReferences[];
70
+ }
71
+ export interface FrequencyFilter {
72
+ column_references?: ColumnReferences[];
73
+ attribute_references?: AttributeReferences[];
74
+ minInclusive?: number;
75
+ maxInclusive?: number;
76
+ }
77
+ export interface AttributeReferences {
78
+ attribute_id: number;
79
+ columnNames: string[];
80
+ }
81
+ export interface ColumnReferences {
82
+ dataset_id: number;
83
+ columnNames: string[];
84
+ }
85
+ export interface DatasetFilter {
86
+ dataset_id: string;
87
+ attribute: AttributeField;
88
+ }
89
+ export interface DatasetFilterEquality extends DatasetFilter {
90
+ parent?: AttributeField;
91
+ inclusion: InclusionType;
92
+ }
93
+ export interface AttributeField {
94
+ attribute_id: string;
95
+ field: string;
96
+ }
97
+ export interface DatasetFilterSpatial extends DatasetFilter {
98
+ predicate: SpatialPredicate;
99
+ }
100
+ export interface ColumnWithFilterAndExport {
101
+ field: string;
102
+ filter?: FilterDefinition;
103
+ exported: boolean;
104
+ }
105
+ export type FilterDefinition = 'include_all_values_including_nulls_filter' | 'include_only_if_not_null_filter' | EnumFilter | IntervalFilter | TimestampFilter | SparkSqlConstraintFilter;
106
+ export interface EnumFilter {
107
+ type: InclusionType;
108
+ list: string[];
109
+ }
110
+ export interface IntervalFilter {
111
+ min?: IntervalEnd;
112
+ max?: IntervalEnd;
113
+ }
114
+ export interface TimestampFilter {
115
+ recency?: string;
116
+ from?: IntervalEnd;
117
+ to?: IntervalEnd;
118
+ }
119
+ export interface SparkSqlConstraintFilter {
120
+ expressions: string[];
121
+ }
122
+ export type IntervalEndType = 'inclusive' | 'exclusive';
123
+ export interface IntervalEnd {
124
+ type: IntervalEndType;
125
+ value: string;
126
+ }
127
+ export type SpatialPredicate = 'contains' | 'intersects';
128
+ export type InclusionType = 'include' | 'exclude';
@@ -0,0 +1 @@
1
+ export {};
package/build/index.d.ts CHANGED
@@ -17,8 +17,9 @@ import { type Product, ProductsApi } from './products';
17
17
  import { CompanyInfoApi, type CompanyInfo } from './company-info';
18
18
  import { InstallationsApi, type Installation } from './installations';
19
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
- interface NarrativeApi extends BaseApi, HealthCheckApi, DatasetApi, RosettaStoneApi, AttributeApi, PingApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi {
23
+ interface NarrativeApi extends BaseApi, HealthCheckApi, DatasetApi, RosettaStoneApi, AttributeApi, PingApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi {
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, type NqlCompileResult };
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
- 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 };
17
+ applyMixins(NarrativeApi, [BaseApi, HealthCheckApi, DatasetApi, RosettaStoneApi, AttributeApi, PingApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi]);
18
+ export { NarrativeApi, AttributeApi, HealthCheckApi, DatasetApi, PingApi, ProductsApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@narrative.io/data-collaboration-sdk-ts",
3
- "version": "0.0.40",
3
+ "version": "0.0.42",
4
4
  "main": "build/index.js",
5
5
  "repository": "github:narrative-io/data-collaboration-sdk-ts",
6
6
  "source": "src/index.ts",