@narrative.io/data-collaboration-sdk-ts 0.0.99 → 0.0.101
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/base-api.d.ts
CHANGED
|
@@ -4,11 +4,11 @@ import { type Config } from './types';
|
|
|
4
4
|
* BaseApi class provides basic functionality for making API requests.
|
|
5
5
|
*/
|
|
6
6
|
export declare abstract class BaseApi {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
protected readonly apiKey?: string;
|
|
8
|
+
protected readonly environment: string;
|
|
9
|
+
protected readonly base_api: MandeInstance;
|
|
10
|
+
protected readonly headers: Record<string, string>;
|
|
11
|
+
protected readonly verbose: boolean;
|
|
12
12
|
/**
|
|
13
13
|
* @param {Config} config - Configuration object.
|
|
14
14
|
* @param {string} [config.apiKey] - API key.
|
|
@@ -6,7 +6,7 @@ import { type CompanyInfo, type WhoAmI } from './types';
|
|
|
6
6
|
* @extends BaseApi
|
|
7
7
|
*/
|
|
8
8
|
declare class CompanyInfoApi extends BaseApi {
|
|
9
|
-
companyId
|
|
9
|
+
companyId(): Promise<number>;
|
|
10
10
|
/**
|
|
11
11
|
* Get the logged in company id
|
|
12
12
|
* @returns {Promise<WhoAmI>}
|
|
@@ -11,9 +11,9 @@ const resourceName = 'company-info';
|
|
|
11
11
|
* @extends BaseApi
|
|
12
12
|
*/
|
|
13
13
|
class CompanyInfoApi extends BaseApi {
|
|
14
|
-
|
|
14
|
+
async companyId() {
|
|
15
15
|
return (await this.get(`${resourceName}/whoami`)).id;
|
|
16
|
-
}
|
|
16
|
+
}
|
|
17
17
|
/**
|
|
18
18
|
* Get the logged in company id
|
|
19
19
|
* @returns {Promise<WhoAmI>}
|
package/build/index.d.ts
CHANGED
|
@@ -26,8 +26,9 @@ import { AuthenticationApi, type LoginRequest, type LoginResponse, type Register
|
|
|
26
26
|
import { AppsApi, type App } from './apps';
|
|
27
27
|
import type { ForecastBody } from './nql/types';
|
|
28
28
|
import { type ConversationMessageRole, isConversationMessageRole, type ConversationMessageName, isConversationMessageName, type ConversationUserMessage, isConversationUserMessage, type ConversationAssistantMessage, isConversationAssistantMessage, type ConversationSystemMessage, isConversationSystemMessage, type ConversationFunctionMessage, isConversationFunctionMessage, type ConversationMessage, isConversationMessage, type ConversationIOMessage, isConversationInputMessage, type ConversationMessages, isConversationMessages, isType, type RosettaRequestMessage, isRosettaRequestMessage, type ConversationMessageFunctionCall, isConversationMessageFunctionCall, type ConversationAssistantMessageWithFunctionCall, isConversationAssistantMessageWithFunctionCall, type RosettaResponseMessage, type ConversationAssistantMessageWithoutFunctionCall, isConversationAssistantMessageWithoutFunctionCall } from './rosetta/types';
|
|
29
|
+
import { MappingsApi } from './mappings';
|
|
29
30
|
declare class NarrativeApi extends BaseApi {
|
|
30
31
|
}
|
|
31
|
-
interface NarrativeApi extends BaseApi, HealthCheckApi, DatasetApi, RosettaStoneApi, AttributeApi, PingApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi, AuthenticationApi {
|
|
32
|
+
interface NarrativeApi extends BaseApi, HealthCheckApi, DatasetApi, RosettaStoneApi, AttributeApi, PingApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi, AuthenticationApi, MappingsApi {
|
|
32
33
|
}
|
|
33
|
-
export { NarrativeApi, AttributeApi, HealthCheckApi, DatasetApi, PingApi, ProductsApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi, AuthenticationApi, AppsApi, getNqlObject, buildNql, convertNqlObjectToForecastBody, isConversationAssistantMessage, isConversationFunctionMessage, isConversationInputMessage, isConversationMessage, isConversationMessageName, isConversationMessageRole, isConversationMessages, isConversationSystemMessage, isConversationUserMessage, isType, isConversationMessageFunctionCall, isConversationAssistantMessageWithFunctionCall, isRosettaRequestMessage, isConversationAssistantMessageWithoutFunctionCall, type App, type Resource, type UploadsResponse, type PingStatus, type Attribute, type ShallowAttribute, 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 Product, type MonetaryAmount, type CompanyInfo, type Installation, type FilePerSnapshotResponse, type BucketCreationRequest, type UpdateAccessTypeRequest, type Nql, 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 };
|
|
34
|
+
export { NarrativeApi, AttributeApi, HealthCheckApi, DatasetApi, PingApi, ProductsApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi, AuthenticationApi, AppsApi, MappingsApi, getNqlObject, buildNql, convertNqlObjectToForecastBody, isConversationAssistantMessage, isConversationFunctionMessage, isConversationInputMessage, isConversationMessage, isConversationMessageName, isConversationMessageRole, isConversationMessages, isConversationSystemMessage, isConversationUserMessage, isType, isConversationMessageFunctionCall, isConversationAssistantMessageWithFunctionCall, isRosettaRequestMessage, isConversationAssistantMessageWithoutFunctionCall, type App, type Resource, type UploadsResponse, type PingStatus, type Attribute, type ShallowAttribute, 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 Product, type MonetaryAmount, type CompanyInfo, type Installation, type FilePerSnapshotResponse, type BucketCreationRequest, type UpdateAccessTypeRequest, type Nql, 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 };
|
package/build/index.js
CHANGED
|
@@ -19,7 +19,8 @@ import { convertNqlObjectToForecastBody } from './nql/DataRulesConverter';
|
|
|
19
19
|
import { AuthenticationApi } from './authentication';
|
|
20
20
|
import { AppsApi } from './apps';
|
|
21
21
|
import { isConversationMessageRole, isConversationMessageName, isConversationUserMessage, isConversationAssistantMessage, isConversationSystemMessage, isConversationFunctionMessage, isConversationMessage, isConversationInputMessage, isConversationMessages, isType, isRosettaRequestMessage, isConversationMessageFunctionCall, isConversationAssistantMessageWithFunctionCall, isConversationAssistantMessageWithoutFunctionCall } from './rosetta/types';
|
|
22
|
+
import { MappingsApi } from './mappings';
|
|
22
23
|
class NarrativeApi extends BaseApi {
|
|
23
24
|
}
|
|
24
|
-
applyMixins(NarrativeApi, [BaseApi, HealthCheckApi, DatasetApi, RosettaStoneApi, AttributeApi, PingApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi, AuthenticationApi]);
|
|
25
|
-
export { NarrativeApi, AttributeApi, HealthCheckApi, DatasetApi, PingApi, ProductsApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi, AuthenticationApi, AppsApi, getNqlObject, buildNql, convertNqlObjectToForecastBody, isConversationAssistantMessage, isConversationFunctionMessage, isConversationInputMessage, isConversationMessage, isConversationMessageName, isConversationMessageRole, isConversationMessages, isConversationSystemMessage, isConversationUserMessage, isType, isConversationMessageFunctionCall, isConversationAssistantMessageWithFunctionCall, isRosettaRequestMessage, isConversationAssistantMessageWithoutFunctionCall };
|
|
25
|
+
applyMixins(NarrativeApi, [BaseApi, HealthCheckApi, DatasetApi, RosettaStoneApi, AttributeApi, PingApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi, AuthenticationApi, MappingsApi]);
|
|
26
|
+
export { NarrativeApi, AttributeApi, HealthCheckApi, DatasetApi, PingApi, ProductsApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi, AuthenticationApi, AppsApi, MappingsApi, getNqlObject, buildNql, convertNqlObjectToForecastBody, isConversationAssistantMessage, isConversationFunctionMessage, isConversationInputMessage, isConversationMessage, isConversationMessageName, isConversationMessageRole, isConversationMessages, isConversationSystemMessage, isConversationUserMessage, isType, isConversationMessageFunctionCall, isConversationAssistantMessageWithFunctionCall, isRosettaRequestMessage, isConversationAssistantMessageWithoutFunctionCall };
|
|
@@ -1,21 +1,37 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Config, ApiRecords } from 'src/types';
|
|
2
2
|
import { BaseApi } from '../base-api';
|
|
3
3
|
import type { CreateMapping, Mapping } from './types';
|
|
4
|
+
import { CompanyInfoApi } from '../company-info';
|
|
4
5
|
/**
|
|
5
6
|
* A class for accessing the Mappings API.
|
|
6
7
|
* @extends BaseApi
|
|
7
8
|
*/
|
|
8
9
|
declare class MappingsApi extends BaseApi {
|
|
10
|
+
private readonly companyInfoApi?;
|
|
11
|
+
constructor(config: Config, companyInfoApi?: CompanyInfoApi | undefined);
|
|
9
12
|
/**
|
|
10
13
|
* Fetches all mappings.
|
|
11
14
|
* @return {Promise<ApiRecords<Mapping>>} Promise object represents the API records of mappings.
|
|
12
15
|
*/
|
|
13
16
|
getMappings(): Promise<ApiRecords<Mapping>>;
|
|
14
17
|
/**
|
|
15
|
-
* Creates a
|
|
18
|
+
* Creates a private (specific to a company) mapping between a dataset and an attribute.
|
|
19
|
+
*
|
|
16
20
|
* @param {CreateMapping} mapping - The mapping to be created.
|
|
17
|
-
* @
|
|
21
|
+
* @param {number} [companyId] - The ID of the company. If not provided, will be fetched from the API.
|
|
22
|
+
* @returns {Promise<Mapping>} - A promise that resolves to the created mapping.
|
|
23
|
+
* @public
|
|
24
|
+
* @throws {Error} - If the company ID is undefined and cannot be fetched from the API.
|
|
25
|
+
* @async
|
|
18
26
|
*/
|
|
19
|
-
|
|
27
|
+
createPrivateMapping(mapping: CreateMapping, companyId?: number): Promise<Mapping>;
|
|
28
|
+
/**
|
|
29
|
+
* Retrieves the company ID from the API.
|
|
30
|
+
*
|
|
31
|
+
* @returns {Promise<number | undefined>} - A promise that resolves to the company ID.
|
|
32
|
+
* @private
|
|
33
|
+
* @async
|
|
34
|
+
*/
|
|
35
|
+
private getCompanyId;
|
|
20
36
|
}
|
|
21
37
|
export { type Mapping, MappingsApi, type CreateMapping };
|
package/build/mappings/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BaseApi } from '../base-api';
|
|
2
|
+
import { CompanyInfoApi } from '../company-info';
|
|
2
3
|
/**
|
|
3
4
|
* The name of the resource to be used in API requests.
|
|
4
5
|
* @constant
|
|
@@ -11,6 +12,19 @@ const resourceName = 'mappings';
|
|
|
11
12
|
* @extends BaseApi
|
|
12
13
|
*/
|
|
13
14
|
class MappingsApi extends BaseApi {
|
|
15
|
+
companyInfoApi;
|
|
16
|
+
constructor(config, companyInfoApi) {
|
|
17
|
+
super(config);
|
|
18
|
+
this.companyInfoApi = companyInfoApi;
|
|
19
|
+
if (companyInfoApi === undefined) {
|
|
20
|
+
this.companyInfoApi = new CompanyInfoApi({
|
|
21
|
+
apiKey: this.apiKey,
|
|
22
|
+
environment: this.environment,
|
|
23
|
+
verbose: this.verbose,
|
|
24
|
+
headers: this.headers
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
14
28
|
/**
|
|
15
29
|
* Fetches all mappings.
|
|
16
30
|
* @return {Promise<ApiRecords<Mapping>>} Promise object represents the API records of mappings.
|
|
@@ -19,12 +33,31 @@ class MappingsApi extends BaseApi {
|
|
|
19
33
|
return await this.get(resourceName);
|
|
20
34
|
}
|
|
21
35
|
/**
|
|
22
|
-
* Creates a
|
|
36
|
+
* Creates a private (specific to a company) mapping between a dataset and an attribute.
|
|
37
|
+
*
|
|
23
38
|
* @param {CreateMapping} mapping - The mapping to be created.
|
|
24
|
-
* @
|
|
39
|
+
* @param {number} [companyId] - The ID of the company. If not provided, will be fetched from the API.
|
|
40
|
+
* @returns {Promise<Mapping>} - A promise that resolves to the created mapping.
|
|
41
|
+
* @public
|
|
42
|
+
* @throws {Error} - If the company ID is undefined and cannot be fetched from the API.
|
|
43
|
+
* @async
|
|
25
44
|
*/
|
|
26
|
-
async
|
|
27
|
-
|
|
45
|
+
async createPrivateMapping(mapping, companyId) {
|
|
46
|
+
companyId = companyId ?? await this.getCompanyId();
|
|
47
|
+
if (companyId === undefined)
|
|
48
|
+
throw new Error('Company ID is undefined');
|
|
49
|
+
const resource = `${resourceName}/companies/${companyId}`;
|
|
50
|
+
return await this.post(resource, mapping);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Retrieves the company ID from the API.
|
|
54
|
+
*
|
|
55
|
+
* @returns {Promise<number | undefined>} - A promise that resolves to the company ID.
|
|
56
|
+
* @private
|
|
57
|
+
* @async
|
|
58
|
+
*/
|
|
59
|
+
async getCompanyId() {
|
|
60
|
+
return await this.companyInfoApi?.companyId();
|
|
28
61
|
}
|
|
29
62
|
}
|
|
30
63
|
export { MappingsApi };
|