@narrative.io/data-collaboration-sdk-ts 2.8.0 → 2.8.1

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.
@@ -10,6 +10,8 @@ declare class RosettaStoneApi extends BaseApi {
10
10
  * @returns {Promise<Mapping[]>} - A promise that resolves to the created mapping.
11
11
  * @experimental
12
12
  */
13
- getMappingRecommendationsFromSample(dataset: Partial<Dataset>, sample: SampleRecords): Promise<Mapping[]>;
13
+ getMappingRecommendationsFromSample(dataset: Partial<Dataset>, sample: SampleRecords, remap_existing_mappings?: boolean): Promise<{
14
+ response: Mapping[];
15
+ }>;
14
16
  }
15
17
  export { RosettaStoneApi, type SampleRecords, type RosettaStoneResponse, type SampleRecord, };
@@ -7,31 +7,34 @@ class RosettaStoneApi extends BaseApi {
7
7
  * @returns {Promise<Mapping[]>} - A promise that resolves to the created mapping.
8
8
  * @experimental
9
9
  */
10
- async getMappingRecommendationsFromSample(dataset, sample) {
10
+ async getMappingRecommendationsFromSample(dataset, sample, remap_existing_mappings = false) {
11
11
  try {
12
- const resp = await fetch("https://rosetta-stone-api.narrative.io/suggest", {
12
+ const resp = await fetch("https://rosetta-stone-api.narrative.io/v1/rosetta_stone/suggest_mappings ", {
13
13
  method: "POST",
14
14
  body: JSON.stringify({
15
15
  dataset,
16
16
  sample: {
17
17
  records: sample.sample,
18
18
  },
19
+ remap_existing_mappings,
19
20
  }),
20
21
  headers: {
21
22
  "Content-Type": "application/json",
22
23
  },
23
24
  });
24
25
  const mappings = (await resp.json());
25
- return mappings.map((mapping) => {
26
- return {
27
- ...mapping,
28
- dataset_id: dataset.id ?? 0,
29
- };
30
- });
26
+ return {
27
+ response: mappings.response.map((mapping) => {
28
+ return {
29
+ ...mapping,
30
+ dataset_id: dataset.id ?? 0,
31
+ };
32
+ }),
33
+ };
31
34
  }
32
35
  catch (e) {
33
36
  console.error(e);
34
- return [];
37
+ return { response: [] };
35
38
  }
36
39
  }
37
40
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@narrative.io/data-collaboration-sdk-ts",
3
- "version": "2.8.0",
3
+ "version": "2.8.1",
4
4
  "main": "build/index.js",
5
5
  "repository": "github:narrative-io/data-collaboration-sdk-ts",
6
6
  "source": "src/index.ts",