@narrative.io/data-collaboration-sdk-ts 0.0.21 → 0.0.23

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,7 +5,6 @@ import { type CompanyInfo } from './types';
5
5
  * @extends BaseApi
6
6
  */
7
7
  declare class CompanyInfoApi extends BaseApi {
8
- private readonly companyId;
9
- getCompanyInfo(): Promise<CompanyInfo>;
8
+ companyId: () => Promise<number>;
10
9
  }
11
10
  export { type CompanyInfo, CompanyInfoApi };
@@ -12,11 +12,7 @@ const resourceName = 'company-info';
12
12
  */
13
13
  class CompanyInfoApi extends BaseApi {
14
14
  companyId = async () => {
15
- return await this.get(`${resourceName}/whoami`);
15
+ return (await this.get(`${resourceName}/whoami`)).id;
16
16
  };
17
- async getCompanyInfo() {
18
- const companyId = (await this.companyId()).id;
19
- return await this.get(`${resourceName}/${companyId}`);
20
- }
21
17
  }
22
18
  export { CompanyInfoApi };
@@ -28,4 +28,18 @@ export declare class DatasetApi extends BaseApi {
28
28
  * @returns {Promise<DatasetTableSummaryAPIResponse>} A promise that resolves with the dataset summary information.
29
29
  */
30
30
  getDatasetSummary(datasetId: number, allRecords?: boolean, perPage?: number, offset?: number): Promise<DatasetTableSummaryAPIResponse>;
31
+ /**
32
+ Retrieve a sample of records from a specified dataset by its ID.
33
+ @async
34
+ @function
35
+ @param {number} datasetId - The ID of the dataset to retrieve records from.
36
+ @param {number} [size=1000] - The number of records to retrieve. Defaults to 1000 if not specified.
37
+ @returns {Promise<ApiRecords<{[key: string]: string}>>} A Promise that resolves with an object containing the requested records and additional metadata.
38
+ @throws {Error} If the request fails or if the response is not in the expected format.
39
+ @example
40
+ const datasetId = 1234;
41
+ const size = 500;
42
+ const records = await getDatasetSample(datasetId, size);
43
+ */
44
+ getDatasetSample(datasetId: number, size?: number): Promise<ApiRecords<Record<string, string>>>;
31
45
  }
@@ -33,4 +33,20 @@ export class DatasetApi extends BaseApi {
33
33
  async getDatasetSummary(datasetId, allRecords = false, perPage = 100, offset = 0) {
34
34
  return await this.get(`${resourceName}/${datasetId}/stats?all_records=${String(allRecords)}&per_page=${perPage}&offset=${offset}`);
35
35
  }
36
+ /**
37
+ Retrieve a sample of records from a specified dataset by its ID.
38
+ @async
39
+ @function
40
+ @param {number} datasetId - The ID of the dataset to retrieve records from.
41
+ @param {number} [size=1000] - The number of records to retrieve. Defaults to 1000 if not specified.
42
+ @returns {Promise<ApiRecords<{[key: string]: string}>>} A Promise that resolves with an object containing the requested records and additional metadata.
43
+ @throws {Error} If the request fails or if the response is not in the expected format.
44
+ @example
45
+ const datasetId = 1234;
46
+ const size = 500;
47
+ const records = await getDatasetSample(datasetId, size);
48
+ */
49
+ async getDatasetSample(datasetId, size = 1000) {
50
+ return await this.get(`${resourceName}/${datasetId}/stats?size=${size}`);
51
+ }
36
52
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@narrative.io/data-collaboration-sdk-ts",
3
- "version": "0.0.21",
3
+ "version": "0.0.23",
4
4
  "main": "build/index.js",
5
5
  "repository": "github:narrative-io/data-collaboration-sdk-ts",
6
6
  "source": "src/index.ts",