@narrative.io/data-collaboration-sdk-ts 0.0.32 → 0.0.33
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.
- package/build/datasets/index.d.ts +30 -1
- package/build/datasets/index.js +39 -0
- package/build/datasets/types.d.ts +14 -0
- package/build/index.d.ts +2 -2
- package/package.json +2 -2
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type ApiRecords } from '../types';
|
|
2
2
|
import { BaseApi } from '../base-api';
|
|
3
|
-
import { type Dataset, type DatasetTableSummaryAPIResponse } from './types';
|
|
3
|
+
import { type FilePerSnapshotResponse, type Dataset, type DatasetTableSummaryAPIResponse } from './types';
|
|
4
|
+
export { type FilePerSnapshotResponse, type Dataset, type DatasetTableSummaryAPIResponse };
|
|
4
5
|
/**
|
|
5
6
|
* @module DatasetApi
|
|
6
7
|
* @description This module provides methods for fetching datasets.
|
|
@@ -42,4 +43,32 @@ export declare class DatasetApi extends BaseApi {
|
|
|
42
43
|
const records = await getDatasetSample(datasetId, size);
|
|
43
44
|
*/
|
|
44
45
|
getDatasetSample(datasetId: number, size?: number): Promise<ApiRecords<Record<string, string>>>;
|
|
46
|
+
/**
|
|
47
|
+
* Fetches a list of dataset files based on the provided parameters.
|
|
48
|
+
*
|
|
49
|
+
* @param {number} datasetId - The ID of the dataset to fetch files for.
|
|
50
|
+
* @param {number} [size] - The number of snapshots to return. Optional.
|
|
51
|
+
* @param {number} [offset] - The starting index of the file list. Optional.
|
|
52
|
+
* @param {string} [afterTimestamp] - Fetch files with a timestamp greater than or equal to the given value. Optional.
|
|
53
|
+
* @param {number} [fromSnapshotId] - Fetch files from the specified snapshot ID. Optional.
|
|
54
|
+
* @returns {Promise<FilePerSnapshotResponse>} A Promise that resolves with the fetched dataset files.
|
|
55
|
+
* @throws {Error} If there is an issue with the request or the response.
|
|
56
|
+
* @memberof DatasetApi
|
|
57
|
+
* @public
|
|
58
|
+
*/
|
|
59
|
+
getDatasetFiles(datasetId: number, size?: number, offset?: number, afterTimestamp?: string, fromSnapshotId?: number): Promise<FilePerSnapshotResponse>;
|
|
60
|
+
/**
|
|
61
|
+
* Fetches the download URL for a specific dataset file.
|
|
62
|
+
*
|
|
63
|
+
* @param {number} datasetId - The ID of the dataset to fetch the file download URL for.
|
|
64
|
+
* @param {number} snapshotId - The ID of the snapshot the file is associated with.
|
|
65
|
+
* @param {string} fileId - The ID of the file to fetch the download URL for.
|
|
66
|
+
* @returns {Promise<{ download_url: string }>} A Promise that resolves with an object containing the download URL.
|
|
67
|
+
* @throws {Error} If there is an issue with the request or the response.
|
|
68
|
+
* @memberof DatasetApi
|
|
69
|
+
* @public
|
|
70
|
+
*/
|
|
71
|
+
getDatasetFileDownloadUrl(datasetId: number, snapshotId: number, fileId: string): Promise<{
|
|
72
|
+
download_url: string;
|
|
73
|
+
}>;
|
|
45
74
|
}
|
package/build/datasets/index.js
CHANGED
|
@@ -49,4 +49,43 @@ export class DatasetApi extends BaseApi {
|
|
|
49
49
|
async getDatasetSample(datasetId, size = 1000) {
|
|
50
50
|
return await this.get(`${resourceName}/${datasetId}/sample?size=${size}`);
|
|
51
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Fetches a list of dataset files based on the provided parameters.
|
|
54
|
+
*
|
|
55
|
+
* @param {number} datasetId - The ID of the dataset to fetch files for.
|
|
56
|
+
* @param {number} [size] - The number of snapshots to return. Optional.
|
|
57
|
+
* @param {number} [offset] - The starting index of the file list. Optional.
|
|
58
|
+
* @param {string} [afterTimestamp] - Fetch files with a timestamp greater than or equal to the given value. Optional.
|
|
59
|
+
* @param {number} [fromSnapshotId] - Fetch files from the specified snapshot ID. Optional.
|
|
60
|
+
* @returns {Promise<FilePerSnapshotResponse>} A Promise that resolves with the fetched dataset files.
|
|
61
|
+
* @throws {Error} If there is an issue with the request or the response.
|
|
62
|
+
* @memberof DatasetApi
|
|
63
|
+
* @public
|
|
64
|
+
*/
|
|
65
|
+
async getDatasetFiles(datasetId, size, offset, afterTimestamp, fromSnapshotId) {
|
|
66
|
+
const params = new URLSearchParams();
|
|
67
|
+
if (size != null)
|
|
68
|
+
params.append('per_page', String(size));
|
|
69
|
+
if (offset != null)
|
|
70
|
+
params.append('offset', String(offset));
|
|
71
|
+
if (afterTimestamp != null)
|
|
72
|
+
params.append('timestamp.gte', afterTimestamp);
|
|
73
|
+
if (fromSnapshotId != null)
|
|
74
|
+
params.append('from_snapshot_id', String(fromSnapshotId));
|
|
75
|
+
return await this.get(`${resourceName}/${datasetId}/find-files?${params.toString()}`);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Fetches the download URL for a specific dataset file.
|
|
79
|
+
*
|
|
80
|
+
* @param {number} datasetId - The ID of the dataset to fetch the file download URL for.
|
|
81
|
+
* @param {number} snapshotId - The ID of the snapshot the file is associated with.
|
|
82
|
+
* @param {string} fileId - The ID of the file to fetch the download URL for.
|
|
83
|
+
* @returns {Promise<{ download_url: string }>} A Promise that resolves with an object containing the download URL.
|
|
84
|
+
* @throws {Error} If there is an issue with the request or the response.
|
|
85
|
+
* @memberof DatasetApi
|
|
86
|
+
* @public
|
|
87
|
+
*/
|
|
88
|
+
async getDatasetFileDownloadUrl(datasetId, snapshotId, fileId) {
|
|
89
|
+
return await this.get(`${resourceName}/${datasetId}/snapshots/${snapshotId}/files-added/${fileId}/download`);
|
|
90
|
+
}
|
|
52
91
|
}
|
|
@@ -74,4 +74,18 @@ interface Schema {
|
|
|
74
74
|
required: string[];
|
|
75
75
|
primary: string;
|
|
76
76
|
}
|
|
77
|
+
interface File {
|
|
78
|
+
path: string;
|
|
79
|
+
size: number;
|
|
80
|
+
}
|
|
81
|
+
interface Snapshot {
|
|
82
|
+
files: File[];
|
|
83
|
+
snapshot_id: number;
|
|
84
|
+
timestamp: string;
|
|
85
|
+
}
|
|
86
|
+
export interface FilePerSnapshotResponse {
|
|
87
|
+
files_per_snapshot: Snapshot[];
|
|
88
|
+
has_next: boolean;
|
|
89
|
+
next_snapshot: number | null;
|
|
90
|
+
}
|
|
77
91
|
export {};
|
package/build/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { DatasetApi } from './datasets';
|
|
|
3
3
|
import { HealthCheckApi } from './health';
|
|
4
4
|
import { RosettaStoneApi } from './rosetta-stone';
|
|
5
5
|
import { type Environment, type Config, type ApiRecords, type MonetaryAmount } from './types';
|
|
6
|
-
import { type DatasetTableSummaryAPIResponse, type Dataset, type DatasetTableSummary } from './datasets/types';
|
|
6
|
+
import { type DatasetTableSummaryAPIResponse, type Dataset, type DatasetTableSummary, type FilePerSnapshotResponse } from './datasets/types';
|
|
7
7
|
import { type HealthCheckResult } from './health/types';
|
|
8
8
|
import { type SampleRecords } from './rosetta-stone/types';
|
|
9
9
|
import { AttributeApi } from './attributes';
|
|
@@ -19,4 +19,4 @@ declare class NarrativeApi extends BaseApi {
|
|
|
19
19
|
}
|
|
20
20
|
interface NarrativeApi extends BaseApi, HealthCheckApi, DatasetApi, RosettaStoneApi, AttributeApi, PingApi, CompanyInfoApi, InstallationsApi, UploadsApi {
|
|
21
21
|
}
|
|
22
|
-
export { NarrativeApi, AttributeApi, HealthCheckApi, DatasetApi, PingApi, ProductsApi, CompanyInfoApi, InstallationsApi, UploadsApi, type UploadsResponse, type PingStatus, type Attribute, type Environment, type Config, type ApiRecords, type Dataset, type HealthCheckResult, type SampleRecords, type DatasetTableSummary, type DatasetTableSummaryAPIResponse, type Product, type MonetaryAmount, type CompanyInfo, type Installation };
|
|
22
|
+
export { NarrativeApi, AttributeApi, HealthCheckApi, DatasetApi, PingApi, ProductsApi, CompanyInfoApi, InstallationsApi, UploadsApi, type UploadsResponse, type PingStatus, type Attribute, type Environment, type Config, type ApiRecords, type Dataset, type HealthCheckResult, type SampleRecords, type DatasetTableSummary, type DatasetTableSummaryAPIResponse, type Product, type MonetaryAmount, type CompanyInfo, type Installation, type FilePerSnapshotResponse };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@narrative.io/data-collaboration-sdk-ts",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.33",
|
|
4
4
|
"main": "build/index.js",
|
|
5
5
|
"repository": "github:narrative-io/data-collaboration-sdk-ts",
|
|
6
6
|
"source": "src/index.ts",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"eslint-plugin-promise": "^6.1.1",
|
|
36
36
|
"jest": "^29.4.3",
|
|
37
37
|
"ts-jest": "^29.0.5",
|
|
38
|
-
"typescript": "^
|
|
38
|
+
"typescript": "^5.0.2",
|
|
39
39
|
"husky": "^8.0.0"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|