@narrative.io/data-collaboration-sdk-ts 0.0.158 → 0.1.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.
@@ -72,7 +72,7 @@ export interface DatasetTableSummaryAPIResponse {
72
72
  }
73
73
  export type SchemaFileConfigType = "flat" | "json" | "parquet";
74
74
  export type SchemaPropertiesType = "string" | "boolean" | "double" | "long" | "timestamptz" | "object" | "array";
75
- export type DatasetStatus = "active" | "archived";
75
+ export type DatasetStatus = "active" | "archived" | "pending";
76
76
  export type DatasetWriteMode = "append" | "overwrite";
77
77
  type ExpressionlessRetentionPolicyType = "retain_everything" | "expire_everything";
78
78
  type ExpressionedRetentionPolicyType = "retain_when" | "expire_when";
@@ -34,5 +34,7 @@ declare class MappingsApi extends BaseApi {
34
34
  * @async
35
35
  */
36
36
  private getCompanyId;
37
+ acceptMapping(mappingId: string): Promise<void>;
38
+ rejectMapping(mappingId: string): Promise<void>;
37
39
  }
38
40
  export { type Mapping, MappingsApi, type CreateMapping, type MappingTestResult, };
@@ -62,5 +62,11 @@ class MappingsApi extends BaseApi {
62
62
  async getCompanyId() {
63
63
  return await this.companyInfoApi?.companyId();
64
64
  }
65
+ async acceptMapping(mappingId) {
66
+ await this.post(`${resourceName}/${mappingId}/accept`);
67
+ }
68
+ async rejectMapping(mappingId) {
69
+ await this.post(`${resourceName}/${mappingId}/reject`);
70
+ }
65
71
  }
66
72
  export { MappingsApi, };
@@ -12,8 +12,9 @@ export interface Mapping {
12
12
  scope: MappingScope;
13
13
  source: MappingSource;
14
14
  derived_from: string;
15
+ tags?: string[];
15
16
  }
16
- type MappingStatus = "active" | "archived" | "pending";
17
+ type MappingStatus = "active" | "archived" | "pending" | "rejected";
17
18
  type MappingScope = "global" | "private";
18
19
  type MappingSource = "system" | "admin" | "company";
19
20
  interface PropertyMapping {
@@ -28,7 +29,8 @@ interface ValueMapping {
28
29
  type: "value_mapping";
29
30
  expression: string;
30
31
  }
31
- export type CreateMapping = Pick<Mapping, "attribute_id" | "dataset_id" | "mapping">;
32
+ type WithOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
33
+ export type CreateMapping = WithOptional<Pick<Mapping, "attribute_id" | "dataset_id" | "mapping" | "tags" | "status">, "status">;
32
34
  export interface MappingTestResult {
33
35
  input: Record<string, unknown>;
34
36
  output: Record<string, unknown>;
@@ -302,7 +302,7 @@ class SubstraitParser {
302
302
  }
303
303
  else if (lit.decimal != null) {
304
304
  return {
305
- name: String(this.base64ToDecimal(lit.decimal.value, lit.decimal.precision, lit.decimal.scale)),
305
+ name: String(this.base64ToDecimal(lit.decimal.value ?? "", lit.decimal.precision, lit.decimal.scale)),
306
306
  type: "decimal",
307
307
  nullability,
308
308
  children: [],
@@ -1,6 +1,15 @@
1
+ import type { Mapping } from "src/mappings/types";
1
2
  import { BaseApi } from "../base-api";
2
3
  import type { RosettaStoneResponse, SampleRecords, SampleRecord } from "./types";
3
4
  declare class RosettaStoneApi extends BaseApi {
4
5
  getLabelsFromSample(sample: SampleRecords): Promise<RosettaStoneResponse[]>;
6
+ /**
7
+ * Fetches suggested mappings generated from sample records.
8
+ *
9
+ * @param sample
10
+ * @returns {Promise<Mapping[]>} - A promise that resolves to the created mapping.
11
+ * @experimental
12
+ */
13
+ getMappingRecommendationsFromSample(sample: SampleRecords): Promise<Mapping[]>;
5
14
  }
6
15
  export { RosettaStoneApi, type SampleRecords, type RosettaStoneResponse, type SampleRecord, };
@@ -4,5 +4,29 @@ class RosettaStoneApi extends BaseApi {
4
4
  async getLabelsFromSample(sample) {
5
5
  return await this.post(`${resourceName}/labels/sample`, sample);
6
6
  }
7
+ /**
8
+ * Fetches suggested mappings generated from sample records.
9
+ *
10
+ * @param sample
11
+ * @returns {Promise<Mapping[]>} - A promise that resolves to the created mapping.
12
+ * @experimental
13
+ */
14
+ async getMappingRecommendationsFromSample(sample) {
15
+ try {
16
+ const resp = await fetch("https://rosetta-stone-api.narrative.io/predict", {
17
+ method: "POST",
18
+ body: JSON.stringify(sample),
19
+ headers: {
20
+ "Content-Type": "application/json",
21
+ },
22
+ });
23
+ const mappings = (await resp.json());
24
+ return mappings.mappings;
25
+ }
26
+ catch (e) {
27
+ console.error(e);
28
+ return [];
29
+ }
30
+ }
7
31
  }
8
32
  export { RosettaStoneApi, };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@narrative.io/data-collaboration-sdk-ts",
3
- "version": "0.0.158",
3
+ "version": "0.1.0",
4
4
  "main": "build/index.js",
5
5
  "repository": "github:narrative-io/data-collaboration-sdk-ts",
6
6
  "source": "src/index.ts",
@@ -28,7 +28,7 @@
28
28
  "@types/jest": "^29.5.0",
29
29
  "babel-jest": "^29.4.3",
30
30
  "eslint-config-prettier": "^9.0.0",
31
- "eslint-config-standard-with-typescript": "^40.0.0",
31
+ "eslint-config-standard-with-typescript": "^42.0.0",
32
32
  "eslint-plugin-prettier": "^5.0.0",
33
33
  "husky": "^8.0.0",
34
34
  "jest": "^29.4.3",