@narrative.io/data-collaboration-sdk-ts 0.0.142 → 0.0.143

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.
@@ -5,8 +5,6 @@ import { BaseApi } from "../base-api";
5
5
  * @extends BaseApi
6
6
  */
7
7
  export declare class InferenceApi extends BaseApi {
8
- private readonly defaultEndpoint;
9
- private readonly endpointToFileTypes;
10
8
  private makeFileExtension;
11
9
  /**
12
10
  * Infers the schema of a file
@@ -1,4 +1,10 @@
1
1
  import { BaseApi } from "../base-api";
2
+ const defaultEndpoint = "csv/format-schema/multipart";
3
+ const endpointToFileTypes = {
4
+ [defaultEndpoint]: ["csv", "txt"],
5
+ "json/schema/multipart": ["json", "jsonl"],
6
+ "parquet/schema/multipart": ["parquet"],
7
+ };
2
8
  /**
3
9
  * The name of the resource to be used in API requests.
4
10
  * @constant
@@ -11,12 +17,6 @@ const resourceName = "inference";
11
17
  * @extends BaseApi
12
18
  */
13
19
  export class InferenceApi extends BaseApi {
14
- defaultEndpoint = "csv/format-schema/multipart";
15
- endpointToFileTypes = {
16
- [this.defaultEndpoint]: ["csv", "txt"],
17
- "json/schema/multipart": ["json", "jsonl"],
18
- "parquet/schema/multipart": ["parquet"],
19
- };
20
20
  makeFileExtension(file) {
21
21
  return file.name.split(".")?.pop();
22
22
  }
@@ -27,20 +27,23 @@ export class InferenceApi extends BaseApi {
27
27
  * @returns {Promise<Schema>} A promise that resolves with the schema.
28
28
  */
29
29
  async inferFileSchema(file) {
30
+ console.log("file", file);
30
31
  const extension = this.makeFileExtension(file);
31
32
  let endpointForExtension;
32
33
  let endpoint;
34
+ console.log("endpointToFileTypes", endpointToFileTypes);
33
35
  if (extension !== undefined) {
34
- endpointForExtension = Object.keys(this.endpointToFileTypes).find((key) => {
35
- return this.endpointToFileTypes[key].includes(extension);
36
+ endpointForExtension = Object.keys(endpointToFileTypes).find((key) => {
37
+ return endpointToFileTypes[key].includes(extension);
36
38
  });
37
39
  }
38
40
  if (endpointForExtension === undefined) {
39
- endpoint = this.defaultEndpoint;
41
+ endpoint = defaultEndpoint;
40
42
  }
41
43
  else {
42
44
  endpoint = endpointForExtension;
43
45
  }
46
+ console.log("endpoint", endpoint);
44
47
  const formData = new FormData();
45
48
  formData.append("file", file);
46
49
  return await this.post(`${resourceName}/${endpoint}`, formData);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@narrative.io/data-collaboration-sdk-ts",
3
- "version": "0.0.142",
3
+ "version": "0.0.143",
4
4
  "main": "build/index.js",
5
5
  "repository": "github:narrative-io/data-collaboration-sdk-ts",
6
6
  "source": "src/index.ts",