@narrative.io/data-collaboration-sdk-ts 0.8.0 → 0.10.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/index.d.ts +15 -18
- package/build/access-rules/index.js +1 -2
- package/build/base-api.d.ts +3 -3
- package/build/base-api.js +18 -14
- package/build/datasets/types.d.ts +1 -1
- package/build/index.d.ts +2 -2
- package/build/types.d.ts +14 -0
- package/package.json +1 -1
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import type { ApiRecords } from "../types";
|
|
1
|
+
import type { ApiRecords, ApiRecordsV2, PaginationOptions } from "../types";
|
|
2
2
|
import { BaseApi } from "../base-api";
|
|
3
3
|
import type { AccessRule, AccessRuleV2 } from "./types";
|
|
4
4
|
/**
|
|
5
5
|
* Represents the parameters used to retrieve access rules.
|
|
6
|
-
* This interface extends a generic record allowing for
|
|
6
|
+
* This interface extends a generic record allowing for a range of value types including arrays.
|
|
7
|
+
* It's primarily used to filter access rules.
|
|
7
8
|
*
|
|
8
9
|
* @interface GetAccessRulesParameters
|
|
9
|
-
* @extends {Record<string, string | number | boolean | undefined>}
|
|
10
|
+
* @extends {Record<string, string | number | boolean | undefined | string[] | number[]>}
|
|
10
11
|
*
|
|
11
12
|
* @property {boolean} [owned_only] - Optional filter to retrieve only the access rules owned by the user.
|
|
12
13
|
* Setting this to true will fetch only the access rules that are owned.
|
|
@@ -14,25 +15,21 @@ import type { AccessRule, AccessRuleV2 } from "./types";
|
|
|
14
15
|
* @property {boolean} [shared_only] - Optional filter to retrieve only the access rules shared with the user.
|
|
15
16
|
* Setting this to true will fetch only the access rules that are shared.
|
|
16
17
|
*
|
|
17
|
-
* @property {string} [tag] - Optional filter to retrieve access rules
|
|
18
|
-
*
|
|
18
|
+
* @property {string | string[]} [tag] - Optional filter to retrieve access rules tagged with a specific tag or tags.
|
|
19
|
+
* Provide a single tag or an array of tags to fetch access rules associated with them.
|
|
19
20
|
*
|
|
20
|
-
* @property {number} [company_id] - Optional filter to retrieve access rules associated with a specific company.
|
|
21
|
-
*
|
|
21
|
+
* @property {number | number[]} [company_id] - Optional filter to retrieve access rules associated with a specific company or companies.
|
|
22
|
+
* Provide a company ID or an array of IDs to fetch access rules related to those companies.
|
|
22
23
|
*
|
|
23
|
-
* @property {number} [
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* @property {number} [per_page] - Optional pagination parameter that specifies the number of records to return per page.
|
|
27
|
-
* Provide a number to set the maximum number of records returned in one page of results.
|
|
24
|
+
* @property {number | number[]} [dataset_id] - Optional filter to retrieve access rules associated with a specific dataset or datasets.
|
|
25
|
+
* Provide a dataset ID or an array of IDs to fetch access rules related to those datasets.
|
|
28
26
|
*/
|
|
29
|
-
interface GetAccessRulesParameters extends Record<string, string | number | boolean | undefined> {
|
|
27
|
+
interface GetAccessRulesParameters extends Record<string, string | number | boolean | undefined | string[] | number[]> {
|
|
30
28
|
owned_only?: boolean;
|
|
31
29
|
shared_only?: boolean;
|
|
32
|
-
tag?: string;
|
|
33
|
-
company_id?: number;
|
|
34
|
-
|
|
35
|
-
per_page?: number;
|
|
30
|
+
tag?: string | string[];
|
|
31
|
+
company_id?: number | number[];
|
|
32
|
+
dataset_id?: number | number[];
|
|
36
33
|
}
|
|
37
34
|
/**
|
|
38
35
|
* @module AccessRulesApi
|
|
@@ -107,6 +104,6 @@ declare class AccessRulesApi extends BaseApi {
|
|
|
107
104
|
* @description This method fetches access rules based on the specified filters and pagination options provided in the parameters.
|
|
108
105
|
* It returns a promise that resolves to a list of access rules that match the criteria.
|
|
109
106
|
*/
|
|
110
|
-
getAccessableAccessRules(parameters: GetAccessRulesParameters): Promise<
|
|
107
|
+
getAccessableAccessRules(parameters: GetAccessRulesParameters & PaginationOptions): Promise<ApiRecordsV2<AccessRuleV2>>;
|
|
111
108
|
}
|
|
112
109
|
export { AccessRulesApi, type AccessRule, type AccessRuleV2, type GetAccessRulesParameters, };
|
|
@@ -89,8 +89,7 @@ class AccessRulesApi extends BaseApi {
|
|
|
89
89
|
* It returns a promise that resolves to a list of access rules that match the criteria.
|
|
90
90
|
*/
|
|
91
91
|
async getAccessableAccessRules(parameters) {
|
|
92
|
-
|
|
93
|
-
return await this.get(`v2/${resourceName}${queryString}`);
|
|
92
|
+
return await this.get(`v2/${resourceName}`, parameters);
|
|
94
93
|
}
|
|
95
94
|
}
|
|
96
95
|
export { AccessRulesApi, };
|
package/build/base-api.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type MandeInstance } from "mande";
|
|
2
|
-
import { type Config } from "./types";
|
|
2
|
+
import { type PaginationOptions, type Config } from "./types";
|
|
3
3
|
/**
|
|
4
4
|
* BaseApi class provides basic functionality for making API requests.
|
|
5
5
|
*/
|
|
@@ -46,7 +46,7 @@ export declare abstract class BaseApi {
|
|
|
46
46
|
* @returns {Promise<T>} - Promise that resolves with the response data.
|
|
47
47
|
* @template T - Type of the response data.
|
|
48
48
|
*/
|
|
49
|
-
protected get<T>(endpoint: string): Promise<T>;
|
|
49
|
+
protected get<T>(endpoint: string, params?: Record<string, any> & PaginationOptions): Promise<T>;
|
|
50
50
|
/**
|
|
51
51
|
* Makes a POST request to the given endpoint with the given data.
|
|
52
52
|
*
|
|
@@ -87,5 +87,5 @@ export declare abstract class BaseApi {
|
|
|
87
87
|
* @private
|
|
88
88
|
*/
|
|
89
89
|
private constructHeaders;
|
|
90
|
-
constructQueryString<T extends Record<string,
|
|
90
|
+
protected constructQueryString<T extends Record<string, any>>(parameters?: T): string;
|
|
91
91
|
}
|
package/build/base-api.js
CHANGED
|
@@ -70,13 +70,15 @@ export class BaseApi {
|
|
|
70
70
|
* @returns {Promise<T>} - Promise that resolves with the response data.
|
|
71
71
|
* @template T - Type of the response data.
|
|
72
72
|
*/
|
|
73
|
-
async get(endpoint) {
|
|
73
|
+
async get(endpoint, params) {
|
|
74
|
+
const queryString = this.constructQueryString(params);
|
|
75
|
+
const url = `${endpoint}${queryString}`;
|
|
74
76
|
if (this.verbose) {
|
|
75
|
-
console.log(`Making GET request to ${
|
|
76
|
-
const resp = await this.base_api.get(
|
|
77
|
+
console.log(`Making GET request to ${url}...`);
|
|
78
|
+
const resp = await this.base_api.get(url);
|
|
77
79
|
console.log(`Response: ${JSON.stringify(resp)}`);
|
|
78
80
|
}
|
|
79
|
-
return await this.base_api.get(
|
|
81
|
+
return await this.base_api.get(url);
|
|
80
82
|
}
|
|
81
83
|
/**
|
|
82
84
|
* Makes a POST request to the given endpoint with the given data.
|
|
@@ -153,16 +155,18 @@ export class BaseApi {
|
|
|
153
155
|
}
|
|
154
156
|
constructQueryString(parameters) {
|
|
155
157
|
const queryParameters = [];
|
|
156
|
-
if (parameters
|
|
157
|
-
Object.
|
|
158
|
-
|
|
159
|
-
|
|
158
|
+
if (parameters != null) {
|
|
159
|
+
for (const [key, value] of Object.entries(parameters)) {
|
|
160
|
+
if (value !== undefined && value !== null && !Array.isArray(value)) {
|
|
161
|
+
queryParameters.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`);
|
|
162
|
+
}
|
|
163
|
+
if (Array.isArray(value)) {
|
|
164
|
+
for (const val of value) {
|
|
165
|
+
queryParameters.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(val))}`);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
160
169
|
}
|
|
161
|
-
|
|
162
|
-
? queryParameters
|
|
163
|
-
.map((param) => Object.entries(param).map(([key, value]) => `${key}=${value}`))
|
|
164
|
-
.join("&")
|
|
165
|
-
: "";
|
|
166
|
-
return queryString.length > 0 ? `?${queryString}` : "";
|
|
170
|
+
return queryParameters.length > 0 ? `?${queryParameters.join("&")}` : "";
|
|
167
171
|
}
|
|
168
172
|
}
|
package/build/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { BaseApi } from "./base-api";
|
|
|
2
2
|
import { DatasetApi } from "./datasets";
|
|
3
3
|
import { HealthCheckApi } from "./health";
|
|
4
4
|
import { RosettaStoneApi } from "./rosetta-stone";
|
|
5
|
-
import { type Environment, type Config, type ApiRecords, type MonetaryAmount } from "./types";
|
|
5
|
+
import { type Environment, type Config, type ApiRecords, type ApiRecordsV2, type MonetaryAmount } from "./types";
|
|
6
6
|
import type { DatasetTableSummaryAPIResponse, Dataset, DatasetTableSummary, FilePerSnapshotResponse, RetentionPolicy, UpdateDatasetRequest, SchemaFileConfigType, SchemaPropertiesType, DatasetStatus, DatasetWriteMode, SchemaFileConfig, SchemaProperties, SchemaProperty, SchemaPrimitiveProperty, SchemaObjectProperty, SchemaArrayProperty, SchemaArrayItems, SchemaArrayItemsPrimitive, SchemaArrayItemsObject, SchemaArrayItemsArray, Schema, AdvancedStatisticsMetadata, SnapshotRange, Configuration, Columns, ColumnSummary, ColumnStatistics, BasicStatistics, AdvancedStatistics, Histogram, Value, CreateDatasetRequest, IngestDatasetFileRequest } from "./datasets/types";
|
|
7
7
|
import { type User } from "./whoami/types";
|
|
8
8
|
import { type HealthCheckResult } from "./health/types";
|
|
@@ -38,4 +38,4 @@ declare class NarrativeApi extends BaseApi {
|
|
|
38
38
|
}
|
|
39
39
|
interface NarrativeApi extends BaseApi, HealthCheckApi, DatasetApi, RosettaStoneApi, AttributeApi, PingApi, CompanyInfoApi, InstallationsApi, ConnectionsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi, AuthenticationApi, MappingsApi, AccessRulesApi, AppsApi, SubscriptionsApi, JobsApi, WhoAmIApi {
|
|
40
40
|
}
|
|
41
|
-
export { NarrativeApi, AttributeApi, HealthCheckApi, DatasetApi, PingApi, ProductsApi, CompanyInfoApi, InstallationsApi, ConnectionsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi, AuthenticationApi, AppsApi, MappingsApi, AccessRulesApi, SubscriptionsApi, JobsApi, WhoAmIApi, getNqlObject, buildNql, convertNqlObjectToForecastBody, isConversationAssistantMessage, isConversationFunctionMessage, isConversationInputMessage, isConversationMessage, isConversationMessageName, isConversationMessageRole, isConversationMessages, isConversationSystemMessage, isConversationUserMessage, isType, isConversationMessageFunctionCall, isConversationAssistantMessageWithFunctionCall, isRosettaRequestMessage, isConversationAssistantMessageWithoutFunctionCall, type App, type Resource, type AccessRuleV2, type GetAccessRulesParameters, type UploadsResponse, type PingStatus, type Attribute, type ShallowAttribute, type Connection, type RefAttribute, type SubAttribute, type PrimitiveAttribute, type ArrayAttribute, type ObjectAttribute, type Environment, type Config, type ApiRecords, type Dataset, type HealthCheckResult, type SampleRecords, type DatasetTableSummary, type DatasetTableSummaryAPIResponse, type UpdateDatasetRequest, type SchemaFileConfigType, type SchemaPropertiesType, type DatasetStatus, type DatasetWriteMode, type SchemaFileConfig, type SchemaProperties, type SchemaProperty, type SchemaPrimitiveProperty, type SchemaObjectProperty, type SchemaArrayProperty, type SchemaArrayItems, type SchemaArrayItemsPrimitive, type SchemaArrayItemsObject, type SchemaArrayItemsArray, type Schema, type AdvancedStatisticsMetadata, type SnapshotRange, type Configuration, type Columns, type ColumnSummary, type ColumnStatistics, type BasicStatistics, type AdvancedStatistics, type Histogram, type Value, type CreateDatasetRequest, type IngestDatasetFileRequest, type Product, type MonetaryAmount, type CompanyInfo, type Installation, type Profile, type FilePerSnapshotResponse, type BucketCreationRequest, type UpdateAccessTypeRequest, type CompiledNql, type CreateMaterializedView, type GetJobsParameters, type Deduplication, type Explain, type Expression, type Raw, type Select, type Statement, type Table, type Nql, type NqlAst, type NqlField, type NqlResult, type NqlQueryInput, type NqlCompileResult, type NqlExpression, type NqlWhere, type NqlFilterExpression, type NqlBooleanExpression, type NqlFilterBinaryExpression, type NqlFilterUnaryExpression, type DataStream, type DataRules, type ColumnSet, type ColumnWithFilterAndExport, type AttributeSet, type ForecastRequest, type ForecastResponse, type CostForecastRequest, type CostForecastResponse, type JobState, type ContractDetails, type CustomerContract, type PaymentMethod, type ContractRateView, type LoginRequest, type LoginResponse, type RegisterRequest, type RegisterResponse, type LoggedInUser, type StytchToken, type ApiToken, type UserRole, type RegistrationStatus, type RegistrationStatusRequest, type RegistrationStatusResponse, type ForecastBody, type ConversationAssistantMessage, type ConversationFunctionMessage, type ConversationIOMessage, type ConversationMessage, type ConversationMessageName, type ConversationMessageRole, type ConversationMessages, type ConversationSystemMessage, type ConversationUserMessage, type RosettaRequestMessage, type ConversationMessageFunctionCall, type ConversationAssistantMessageWithFunctionCall, type RosettaResponseMessage, type ConversationAssistantMessageWithoutFunctionCall, type RetentionPolicy, type AccessRule, type Subscription, type SubscriptionDetails, type DataStreamSubscriptionDetails, type MarketplaceSubscriptionDetails, type SubscriptionOutput, type SubscriptionType, type SubscriptionStatus, type SubscriptionBudget, type Job, type User, type Mapping, type MappingTestResult, type ValueMapping, type ObjectMapping, type CreateMapping, compileStatement, parseStatement, };
|
|
41
|
+
export { NarrativeApi, AttributeApi, HealthCheckApi, DatasetApi, PingApi, ProductsApi, CompanyInfoApi, InstallationsApi, ConnectionsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi, AuthenticationApi, AppsApi, MappingsApi, AccessRulesApi, SubscriptionsApi, JobsApi, WhoAmIApi, getNqlObject, buildNql, convertNqlObjectToForecastBody, isConversationAssistantMessage, isConversationFunctionMessage, isConversationInputMessage, isConversationMessage, isConversationMessageName, isConversationMessageRole, isConversationMessages, isConversationSystemMessage, isConversationUserMessage, isType, isConversationMessageFunctionCall, isConversationAssistantMessageWithFunctionCall, isRosettaRequestMessage, isConversationAssistantMessageWithoutFunctionCall, type App, type Resource, type AccessRuleV2, type GetAccessRulesParameters, type UploadsResponse, type PingStatus, type Attribute, type ShallowAttribute, type Connection, type RefAttribute, type SubAttribute, type PrimitiveAttribute, type ArrayAttribute, type ObjectAttribute, type Environment, type Config, type ApiRecords, type ApiRecordsV2, type Dataset, type HealthCheckResult, type SampleRecords, type DatasetTableSummary, type DatasetTableSummaryAPIResponse, type UpdateDatasetRequest, type SchemaFileConfigType, type SchemaPropertiesType, type DatasetStatus, type DatasetWriteMode, type SchemaFileConfig, type SchemaProperties, type SchemaProperty, type SchemaPrimitiveProperty, type SchemaObjectProperty, type SchemaArrayProperty, type SchemaArrayItems, type SchemaArrayItemsPrimitive, type SchemaArrayItemsObject, type SchemaArrayItemsArray, type Schema, type AdvancedStatisticsMetadata, type SnapshotRange, type Configuration, type Columns, type ColumnSummary, type ColumnStatistics, type BasicStatistics, type AdvancedStatistics, type Histogram, type Value, type CreateDatasetRequest, type IngestDatasetFileRequest, type Product, type MonetaryAmount, type CompanyInfo, type Installation, type Profile, type FilePerSnapshotResponse, type BucketCreationRequest, type UpdateAccessTypeRequest, type CompiledNql, type CreateMaterializedView, type GetJobsParameters, type Deduplication, type Explain, type Expression, type Raw, type Select, type Statement, type Table, type Nql, type NqlAst, type NqlField, type NqlResult, type NqlQueryInput, type NqlCompileResult, type NqlExpression, type NqlWhere, type NqlFilterExpression, type NqlBooleanExpression, type NqlFilterBinaryExpression, type NqlFilterUnaryExpression, type DataStream, type DataRules, type ColumnSet, type ColumnWithFilterAndExport, type AttributeSet, type ForecastRequest, type ForecastResponse, type CostForecastRequest, type CostForecastResponse, type JobState, type ContractDetails, type CustomerContract, type PaymentMethod, type ContractRateView, type LoginRequest, type LoginResponse, type RegisterRequest, type RegisterResponse, type LoggedInUser, type StytchToken, type ApiToken, type UserRole, type RegistrationStatus, type RegistrationStatusRequest, type RegistrationStatusResponse, type ForecastBody, type ConversationAssistantMessage, type ConversationFunctionMessage, type ConversationIOMessage, type ConversationMessage, type ConversationMessageName, type ConversationMessageRole, type ConversationMessages, type ConversationSystemMessage, type ConversationUserMessage, type RosettaRequestMessage, type ConversationMessageFunctionCall, type ConversationAssistantMessageWithFunctionCall, type RosettaResponseMessage, type ConversationAssistantMessageWithoutFunctionCall, type RetentionPolicy, type AccessRule, type Subscription, type SubscriptionDetails, type DataStreamSubscriptionDetails, type MarketplaceSubscriptionDetails, type SubscriptionOutput, type SubscriptionType, type SubscriptionStatus, type SubscriptionBudget, type Job, type User, type Mapping, type MappingTestResult, type ValueMapping, type ObjectMapping, type CreateMapping, compileStatement, parseStatement, };
|
package/build/types.d.ts
CHANGED
|
@@ -17,6 +17,9 @@ export interface Config {
|
|
|
17
17
|
headers?: Record<string, string>;
|
|
18
18
|
verbose?: boolean;
|
|
19
19
|
}
|
|
20
|
+
export interface ApiRecordsV2<T> extends PaginationMetadata {
|
|
21
|
+
records: T[];
|
|
22
|
+
}
|
|
20
23
|
export interface ApiRecords<T> {
|
|
21
24
|
records: T[];
|
|
22
25
|
}
|
|
@@ -30,4 +33,15 @@ export interface MonetaryAmount {
|
|
|
30
33
|
microCentsUsd: number;
|
|
31
34
|
}
|
|
32
35
|
type CurrencyCode = "USD";
|
|
36
|
+
export interface PaginationMetadata {
|
|
37
|
+
prev_page: number | null;
|
|
38
|
+
current_page: number;
|
|
39
|
+
next_page: number | null;
|
|
40
|
+
total_records: number;
|
|
41
|
+
total_pages: number;
|
|
42
|
+
}
|
|
43
|
+
export interface PaginationOptions {
|
|
44
|
+
page?: number | null;
|
|
45
|
+
per_page?: number | null;
|
|
46
|
+
}
|
|
33
47
|
export {};
|