@narrative.io/data-collaboration-sdk-ts 2.7.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.
@@ -2,7 +2,7 @@
2
2
  * A mapping of AST (Abstract Syntax Tree) node types to their corresponding TypeScript types.
3
3
  * This object acts as a type registry for the various components of the NQL (Notation Query Language) AST.
4
4
  */
5
- declare const NqlAstTypes: {
5
+ export declare const NqlAstTypes: {
6
6
  agg_function: NqlAggFunction;
7
7
  binary_op: NqlBinaryOp;
8
8
  case: NqlCase;
@@ -97,7 +97,7 @@ type ExtractNqlType<T extends NqlAstType | NqlAstType[]> = T extends NqlAstType[
97
97
  * type NonPlaceholderType = NqlAst; // Assuming NqlAst is not a placeholder.
98
98
  * type ExtractedType = ExtractPlaceholderType<NonPlaceholderType>; // `never`
99
99
  */
100
- export type ExtractPlaceholderType<T> = T extends NqlPlaceholder<infer U> ? ExtractNqlType<U> : never;
100
+ type ExtractPlaceholderType<T> = T extends NqlPlaceholder<infer U> ? ExtractNqlType<U> : never;
101
101
  /**
102
102
  * Represents a placeholder within a NQL query template. Placeholders are used to dynamically insert
103
103
  * values, columns, or other AST nodes into a query based on certain constraints and expectations.
@@ -297,4 +297,4 @@ export declare function isAstArray(n: NqlAst): n is NqlAstList;
297
297
  type NqlAst = {
298
298
  type: string;
299
299
  } & (NqlAstList | NqlAggFunction | NqlBinaryOp | NqlCase | NqlFunction | NqlLit | NqlIdent | NqlJoin | NqlTypeSpec | NqlOp | NqlWindow | NqlUnknown | NqlSelect | NqlCreateMaterializedView | NqlExplain | NqlWhen | NqlElse | NqlPlaceholder);
300
- export type { NqlAst, NqlAstList, NqlAggFunction, NqlBinaryOp, NqlBudget, NqlCase, NqlFunction, NqlSimpleType, NqlLit, NqlIdent, NqlIdentColumn, NqlIdentTable, NqlJoin, NqlJoinType, NqlJoinConditionType, NqlTypeSpec, NqlOp, NqlWindow, NqlUnknown, NqlSelect, NqlCreateMaterializedView, NqlExplain, NqlAstType, NqlPlaceholder, };
300
+ export type { NqlAst, NqlAstList, NqlAggFunction, NqlBinaryOp, NqlBudget, NqlCase, NqlFunction, NqlSimpleType, NqlLit, NqlIdent, NqlIdentColumn, NqlIdentTable, NqlJoin, NqlJoinType, NqlJoinConditionType, NqlTypeSpec, NqlOp, NqlWindow, NqlUnknown, NqlSelect, NqlCreateMaterializedView, NqlExplain, NqlAstType, NqlPlaceholder, NqlTemplateConstraintLogicalOperator, NqlTemplateConstraint, NqlTemplateConstraintGroup, ExtractPlaceholderType, };
package/build/nql/Ast.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * A mapping of AST (Abstract Syntax Tree) node types to their corresponding TypeScript types.
3
3
  * This object acts as a type registry for the various components of the NQL (Notation Query Language) AST.
4
4
  */
5
- const NqlAstTypes = {
5
+ export const NqlAstTypes = {
6
6
  agg_function: null,
7
7
  binary_op: null,
8
8
  case: null,
@@ -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.7.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",