@narrative.io/data-collaboration-sdk-ts 0.0.98 → 0.0.99

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.
@@ -71,5 +71,14 @@ export declare class DatasetApi extends BaseApi {
71
71
  getDatasetFileDownloadUrl(datasetId: number, snapshotId: number, fileId: string): Promise<{
72
72
  download_url: string;
73
73
  }>;
74
+ /**
75
+ * Fetches column statistics for a given dataset.
76
+ *
77
+ * @param {number} datasetId - The ID of the dataset to fetch column statistics for.
78
+ * @returns {Promise<ColumnStatistics>} A Promise that resolves with an object containing the column statistics.
79
+ * @throws {Error} If there is an issue with the request or the response.
80
+ * @memberof DatasetApi
81
+ * @public
82
+ */
74
83
  getColumnStats(datasetId: number): Promise<ColumnStatistics>;
75
84
  }
@@ -88,6 +88,15 @@ export class DatasetApi extends BaseApi {
88
88
  async getDatasetFileDownloadUrl(datasetId, snapshotId, fileId) {
89
89
  return await this.post(`${resourceName}/${datasetId}/snapshots/${snapshotId}/files-added/${fileId}/download`);
90
90
  }
91
+ /**
92
+ * Fetches column statistics for a given dataset.
93
+ *
94
+ * @param {number} datasetId - The ID of the dataset to fetch column statistics for.
95
+ * @returns {Promise<ColumnStatistics>} A Promise that resolves with an object containing the column statistics.
96
+ * @throws {Error} If there is an issue with the request or the response.
97
+ * @memberof DatasetApi
98
+ * @public
99
+ */
91
100
  async getColumnStats(datasetId) {
92
101
  return await this.get(`${resourceName}/${datasetId}/column-stats`);
93
102
  }
@@ -1,11 +1,21 @@
1
1
  import { type ApiRecords } from 'src/types';
2
2
  import { BaseApi } from '../base-api';
3
- import { type Mapping } from './types';
3
+ import type { CreateMapping, Mapping } from './types';
4
4
  /**
5
5
  * A class for accessing the Mappings API.
6
6
  * @extends BaseApi
7
7
  */
8
8
  declare class MappingsApi extends BaseApi {
9
+ /**
10
+ * Fetches all mappings.
11
+ * @return {Promise<ApiRecords<Mapping>>} Promise object represents the API records of mappings.
12
+ */
9
13
  getMappings(): Promise<ApiRecords<Mapping>>;
14
+ /**
15
+ * Creates a new mapping.
16
+ * @param {CreateMapping} mapping - The mapping to be created.
17
+ * @return {Promise<Mapping>} Promise object represents the newly created mapping.
18
+ */
19
+ createMapping(mapping: CreateMapping): Promise<Mapping>;
10
20
  }
11
- export { type Mapping, MappingsApi };
21
+ export { type Mapping, MappingsApi, type CreateMapping };
@@ -11,8 +11,20 @@ const resourceName = 'mappings';
11
11
  * @extends BaseApi
12
12
  */
13
13
  class MappingsApi extends BaseApi {
14
+ /**
15
+ * Fetches all mappings.
16
+ * @return {Promise<ApiRecords<Mapping>>} Promise object represents the API records of mappings.
17
+ */
14
18
  async getMappings() {
15
19
  return await this.get(resourceName);
16
20
  }
21
+ /**
22
+ * Creates a new mapping.
23
+ * @param {CreateMapping} mapping - The mapping to be created.
24
+ * @return {Promise<Mapping>} Promise object represents the newly created mapping.
25
+ */
26
+ async createMapping(mapping) {
27
+ return await this.post(resourceName, mapping);
28
+ }
17
29
  }
18
30
  export { MappingsApi };
@@ -28,4 +28,5 @@ interface ValueMapping {
28
28
  type: 'value_mapping';
29
29
  expression: string;
30
30
  }
31
+ export type CreateMapping = Pick<Mapping, 'attribute_id' | 'dataset_id' | 'mapping'>;
31
32
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@narrative.io/data-collaboration-sdk-ts",
3
- "version": "0.0.98",
3
+ "version": "0.0.99",
4
4
  "main": "build/index.js",
5
5
  "repository": "github:narrative-io/data-collaboration-sdk-ts",
6
6
  "source": "src/index.ts",