@narrative.io/data-collaboration-sdk-ts 0.0.100 → 0.0.102
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 +5 -5
- package/build/company-info/index.d.ts +1 -1
- package/build/company-info/index.js +2 -2
- package/build/mappings/index.d.ts +20 -4
- package/build/mappings/index.js +37 -4
- package/build/rosetta/types.d.ts +6 -0
- package/build/rosetta/types.js +2 -1
- package/package.json +1 -1
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>}
|
|
@@ -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 };
|
package/build/rosetta/types.d.ts
CHANGED
|
@@ -822,24 +822,29 @@ declare const RosettaRequestMessageSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
822
822
|
data: z.ZodObject<{
|
|
823
823
|
input: z.ZodString;
|
|
824
824
|
apiKey: z.ZodOptional<z.ZodString>;
|
|
825
|
+
team_member: z.ZodOptional<z.ZodString>;
|
|
825
826
|
}, "strip", z.ZodTypeAny, {
|
|
826
827
|
input: string;
|
|
827
828
|
apiKey?: string | undefined;
|
|
829
|
+
team_member?: string | undefined;
|
|
828
830
|
}, {
|
|
829
831
|
input: string;
|
|
830
832
|
apiKey?: string | undefined;
|
|
833
|
+
team_member?: string | undefined;
|
|
831
834
|
}>;
|
|
832
835
|
}, "strip", z.ZodTypeAny, {
|
|
833
836
|
type: "request";
|
|
834
837
|
data: {
|
|
835
838
|
input: string;
|
|
836
839
|
apiKey?: string | undefined;
|
|
840
|
+
team_member?: string | undefined;
|
|
837
841
|
};
|
|
838
842
|
}, {
|
|
839
843
|
type: "request";
|
|
840
844
|
data: {
|
|
841
845
|
input: string;
|
|
842
846
|
apiKey?: string | undefined;
|
|
847
|
+
team_member?: string | undefined;
|
|
843
848
|
};
|
|
844
849
|
}>, z.ZodObject<{
|
|
845
850
|
type: z.ZodLiteral<"ping">;
|
|
@@ -866,6 +871,7 @@ declare const isRosettaRequestMessage: (input: unknown) => input is {
|
|
|
866
871
|
data: {
|
|
867
872
|
input: string;
|
|
868
873
|
apiKey?: string | undefined;
|
|
874
|
+
team_member?: string | undefined;
|
|
869
875
|
};
|
|
870
876
|
} | {
|
|
871
877
|
type: "ping";
|
package/build/rosetta/types.js
CHANGED
|
@@ -166,7 +166,8 @@ const RequestMessageSchema = z.object({
|
|
|
166
166
|
type: z.literal('request'),
|
|
167
167
|
data: z.object({
|
|
168
168
|
input: z.string(),
|
|
169
|
-
apiKey: z.string().optional()
|
|
169
|
+
apiKey: z.string().optional(),
|
|
170
|
+
team_member: z.string().optional().describe('The team member who should handle the request')
|
|
170
171
|
})
|
|
171
172
|
});
|
|
172
173
|
const PingEventSchema = z.object({
|