@narrative.io/data-collaboration-sdk-ts 0.5.0 → 0.6.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.
@@ -3,30 +3,58 @@ import { BaseApi } from "../base-api";
3
3
  import type { CreateMapping, Mapping, MappingTestResult, MappingTestResults } from "./types";
4
4
  import { CompanyInfoApi } from "../company-info";
5
5
  /**
6
- * A class for accessing the Mappings API.
6
+ * Class representing the Mappings API.
7
+ * Extends the BaseApi to provide functionalities specific to mappings.
7
8
  * @extends BaseApi
8
9
  */
9
10
  declare class MappingsApi extends BaseApi {
10
11
  private readonly companyInfoApi?;
11
12
  constructor(config: Config, companyInfoApi?: CompanyInfoApi | undefined);
12
13
  /**
13
- * Fetches all mappings.
14
- * @return {Promise<ApiRecords<Mapping>>} Promise object represents the API records of mappings.
14
+ * Retrieves all mappings.
15
+ *
16
+ * @returns {Promise<ApiRecords<Mapping>>} A promise that resolves to a collection of Mapping records.
17
+ * @public
18
+ * @async
15
19
  */
16
20
  getMappings(): Promise<ApiRecords<Mapping>>;
17
21
  /**
18
- * Creates a private (specific to a company) mapping between a dataset and an attribute.
22
+ * Creates a new mapping specific to a company.
19
23
  *
20
- * @param {CreateMapping} mapping - The mapping to be created.
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.
24
+ * @param {CreateMapping} mapping - The mapping configuration to be created.
25
+ * @param {number} [companyId] - Optional company ID. If not provided, it will be fetched from the API.
26
+ * @returns {Promise<Mapping>} A promise that resolves to the created mapping.
23
27
  * @public
24
- * @throws {Error} - If the company ID is undefined and cannot be fetched from the API.
25
28
  * @async
29
+ * @throws {Error} Throws an error if the company ID is undefined and cannot be fetched.
26
30
  */
27
31
  createPrivateMapping(mapping: CreateMapping, companyId?: number): Promise<Mapping>;
32
+ /**
33
+ * Tests a mapping configuration and returns the results.
34
+ *
35
+ * @param {CreateMapping} mapping - The mapping configuration to test.
36
+ * @returns {Promise<MappingTestResults>} A promise that resolves to the test results of the mapping.
37
+ * @public
38
+ * @async
39
+ */
28
40
  testMapping(mapping: CreateMapping): Promise<MappingTestResults>;
41
+ /**
42
+ * Previews a sample of the mapping results.
43
+ *
44
+ * @param {string} mappingId - The ID of the mapping to preview.
45
+ * @returns {Promise<MappingTestResults>} A promise that resolves to the sample test results of the mapping.
46
+ * @public
47
+ * @async
48
+ */
29
49
  previewMapping(mappingId: string): Promise<MappingTestResults>;
50
+ /**
51
+ * Deletes a mapping.
52
+ *
53
+ * @param {string} mappingId - The ID of the mapping to delete.
54
+ * @returns {Promise<void>} A promise that resolves when the mapping is successfully deleted.
55
+ * @public
56
+ * @async
57
+ */
30
58
  deleteMapping(mappingId: string): Promise<void>;
31
59
  /**
32
60
  * Retrieves the company ID from the API.
@@ -36,8 +64,42 @@ declare class MappingsApi extends BaseApi {
36
64
  * @async
37
65
  */
38
66
  private getCompanyId;
67
+ /**
68
+ * Accepts a mapping.
69
+ *
70
+ * @param {string} mappingId - The ID of the mapping to accept.
71
+ * @returns {Promise<void>} A promise that resolves when the mapping is accepted.
72
+ * @public
73
+ * @async
74
+ */
39
75
  acceptMapping(mappingId: string): Promise<void>;
76
+ /**
77
+ * Rejects a mapping.
78
+ *
79
+ * @param {string} mappingId - The ID of the mapping to reject.
80
+ * @returns {Promise<void>} A promise that resolves when the mapping is rejected.
81
+ * @public
82
+ * @async
83
+ */
40
84
  rejectMapping(mappingId: string): Promise<void>;
85
+ /**
86
+ * Updates a mapping.
87
+ *
88
+ * @param {string} mappingId - The ID of the mapping to update.
89
+ * @param {CreateMapping} mapping - The mapping configuration to update.
90
+ * @returns {Promise<Mapping>} A promise that resolves to the updated mapping.
91
+ * @public
92
+ * @async
93
+ */
41
94
  updateMapping(mappingId: string, mapping: Pick<CreateMapping, "mapping">): Promise<Mapping>;
95
+ /**
96
+ * Retrieves a mapping.
97
+ *
98
+ * @param {string} mappingId - The ID of the mapping to retrieve.
99
+ * @returns {Promise<Mapping>} A promise that resolves to the retrieved mapping.
100
+ * @public
101
+ * @async
102
+ */
103
+ getMapping(mappingId: string): Promise<Mapping>;
42
104
  }
43
105
  export { type Mapping, MappingsApi, type CreateMapping, type MappingTestResult, type MappingTestResults, };
@@ -8,7 +8,8 @@ import { CompanyInfoApi } from "../company-info";
8
8
  */
9
9
  const resourceName = "mappings";
10
10
  /**
11
- * A class for accessing the Mappings API.
11
+ * Class representing the Mappings API.
12
+ * Extends the BaseApi to provide functionalities specific to mappings.
12
13
  * @extends BaseApi
13
14
  */
14
15
  class MappingsApi extends BaseApi {
@@ -26,21 +27,24 @@ class MappingsApi extends BaseApi {
26
27
  }
27
28
  }
28
29
  /**
29
- * Fetches all mappings.
30
- * @return {Promise<ApiRecords<Mapping>>} Promise object represents the API records of mappings.
30
+ * Retrieves all mappings.
31
+ *
32
+ * @returns {Promise<ApiRecords<Mapping>>} A promise that resolves to a collection of Mapping records.
33
+ * @public
34
+ * @async
31
35
  */
32
36
  async getMappings() {
33
37
  return await this.get(resourceName);
34
38
  }
35
39
  /**
36
- * Creates a private (specific to a company) mapping between a dataset and an attribute.
40
+ * Creates a new mapping specific to a company.
37
41
  *
38
- * @param {CreateMapping} mapping - The mapping to be created.
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.
42
+ * @param {CreateMapping} mapping - The mapping configuration to be created.
43
+ * @param {number} [companyId] - Optional company ID. If not provided, it will be fetched from the API.
44
+ * @returns {Promise<Mapping>} A promise that resolves to the created mapping.
41
45
  * @public
42
- * @throws {Error} - If the company ID is undefined and cannot be fetched from the API.
43
46
  * @async
47
+ * @throws {Error} Throws an error if the company ID is undefined and cannot be fetched.
44
48
  */
45
49
  async createPrivateMapping(mapping, companyId) {
46
50
  companyId = companyId ?? (await this.getCompanyId());
@@ -49,12 +53,36 @@ class MappingsApi extends BaseApi {
49
53
  const resource = `${resourceName}/companies/${companyId}`;
50
54
  return await this.post(resource, mapping);
51
55
  }
56
+ /**
57
+ * Tests a mapping configuration and returns the results.
58
+ *
59
+ * @param {CreateMapping} mapping - The mapping configuration to test.
60
+ * @returns {Promise<MappingTestResults>} A promise that resolves to the test results of the mapping.
61
+ * @public
62
+ * @async
63
+ */
52
64
  async testMapping(mapping) {
53
65
  return await this.post(`${resourceName}/test`, mapping);
54
66
  }
67
+ /**
68
+ * Previews a sample of the mapping results.
69
+ *
70
+ * @param {string} mappingId - The ID of the mapping to preview.
71
+ * @returns {Promise<MappingTestResults>} A promise that resolves to the sample test results of the mapping.
72
+ * @public
73
+ * @async
74
+ */
55
75
  async previewMapping(mappingId) {
56
76
  return await this.get(`${resourceName}/${mappingId}/sample`);
57
77
  }
78
+ /**
79
+ * Deletes a mapping.
80
+ *
81
+ * @param {string} mappingId - The ID of the mapping to delete.
82
+ * @returns {Promise<void>} A promise that resolves when the mapping is successfully deleted.
83
+ * @public
84
+ * @async
85
+ */
58
86
  async deleteMapping(mappingId) {
59
87
  await this.delete(`${resourceName}/${mappingId}`);
60
88
  }
@@ -68,14 +96,50 @@ class MappingsApi extends BaseApi {
68
96
  async getCompanyId() {
69
97
  return await this.companyInfoApi?.companyId();
70
98
  }
99
+ /**
100
+ * Accepts a mapping.
101
+ *
102
+ * @param {string} mappingId - The ID of the mapping to accept.
103
+ * @returns {Promise<void>} A promise that resolves when the mapping is accepted.
104
+ * @public
105
+ * @async
106
+ */
71
107
  async acceptMapping(mappingId) {
72
108
  await this.post(`${resourceName}/${mappingId}/accept`);
73
109
  }
110
+ /**
111
+ * Rejects a mapping.
112
+ *
113
+ * @param {string} mappingId - The ID of the mapping to reject.
114
+ * @returns {Promise<void>} A promise that resolves when the mapping is rejected.
115
+ * @public
116
+ * @async
117
+ */
74
118
  async rejectMapping(mappingId) {
75
119
  await this.post(`${resourceName}/${mappingId}/reject`);
76
120
  }
121
+ /**
122
+ * Updates a mapping.
123
+ *
124
+ * @param {string} mappingId - The ID of the mapping to update.
125
+ * @param {CreateMapping} mapping - The mapping configuration to update.
126
+ * @returns {Promise<Mapping>} A promise that resolves to the updated mapping.
127
+ * @public
128
+ * @async
129
+ */
77
130
  async updateMapping(mappingId, mapping) {
78
131
  return await this.put(`${resourceName}/${mappingId}`, mapping);
79
132
  }
133
+ /**
134
+ * Retrieves a mapping.
135
+ *
136
+ * @param {string} mappingId - The ID of the mapping to retrieve.
137
+ * @returns {Promise<Mapping>} A promise that resolves to the retrieved mapping.
138
+ * @public
139
+ * @async
140
+ */
141
+ async getMapping(mappingId) {
142
+ return await this.get(`${resourceName}/${mappingId}`);
143
+ }
80
144
  }
81
145
  export { MappingsApi, };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@narrative.io/data-collaboration-sdk-ts",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "main": "build/index.js",
5
5
  "repository": "github:narrative-io/data-collaboration-sdk-ts",
6
6
  "source": "src/index.ts",