@narrative.io/data-collaboration-sdk-ts 0.0.15 → 0.0.16
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/attributes/index.d.ts +30 -0
- package/build/attributes/index.js +42 -0
- package/build/base-api.d.ts +8 -0
- package/build/base-api.js +10 -0
- package/build/health/index.d.ts +9 -0
- package/build/health/index.js +15 -0
- package/package.json +3 -1
|
@@ -1,6 +1,36 @@
|
|
|
1
1
|
import { type ApiRecords } from '../types';
|
|
2
2
|
import { BaseApi } from '../base-api';
|
|
3
3
|
import { type Attribute } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* A class for accessing the Attribute API.
|
|
6
|
+
* @extends BaseApi
|
|
7
|
+
*/
|
|
4
8
|
export declare class AttributeApi extends BaseApi {
|
|
9
|
+
/**
|
|
10
|
+
* Gets a list of attributes from the API.
|
|
11
|
+
*
|
|
12
|
+
* @returns {Promise<ApiRecords<Attribute>>} A promise that resolves with the list of attributes.
|
|
13
|
+
*/
|
|
5
14
|
getAttributes(): Promise<ApiRecords<Attribute>>;
|
|
15
|
+
/**
|
|
16
|
+
* Gets a single attribute from the API by its ID.
|
|
17
|
+
*
|
|
18
|
+
* @param {number} attributeId - The ID of the attribute to retrieve.
|
|
19
|
+
* @returns {Promise<Attribute>} A promise that resolves with the attribute.
|
|
20
|
+
*/
|
|
21
|
+
getAttribute(attributeId: number): Promise<Attribute>;
|
|
22
|
+
/**
|
|
23
|
+
* Deletes a single attribute from the API by its ID.
|
|
24
|
+
*
|
|
25
|
+
* @param {number} attributeId - The ID of the attribute to delete.
|
|
26
|
+
* @returns {Promise<void>} A promise that resolves when the delete operation is complete.
|
|
27
|
+
*/
|
|
28
|
+
deleteAttribute(attributeId: number): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Creates a new attribute on the API.
|
|
31
|
+
*
|
|
32
|
+
* @param {Attribute} data - The data for the new attribute.
|
|
33
|
+
* @returns {Promise<Attribute>} A promise that resolves with the newly created attribute.
|
|
34
|
+
*/
|
|
35
|
+
createAttribute(data: Attribute): Promise<Attribute>;
|
|
6
36
|
}
|
|
@@ -1,7 +1,49 @@
|
|
|
1
1
|
import { BaseApi } from '../base-api';
|
|
2
|
+
/**
|
|
3
|
+
* The name of the resource to be used in API requests.
|
|
4
|
+
* @constant
|
|
5
|
+
* @private
|
|
6
|
+
* @type {string}
|
|
7
|
+
*/
|
|
2
8
|
const resourceName = 'attributes';
|
|
9
|
+
/**
|
|
10
|
+
* A class for accessing the Attribute API.
|
|
11
|
+
* @extends BaseApi
|
|
12
|
+
*/
|
|
3
13
|
export class AttributeApi extends BaseApi {
|
|
14
|
+
/**
|
|
15
|
+
* Gets a list of attributes from the API.
|
|
16
|
+
*
|
|
17
|
+
* @returns {Promise<ApiRecords<Attribute>>} A promise that resolves with the list of attributes.
|
|
18
|
+
*/
|
|
4
19
|
async getAttributes() {
|
|
5
20
|
return await this.get(resourceName);
|
|
6
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Gets a single attribute from the API by its ID.
|
|
24
|
+
*
|
|
25
|
+
* @param {number} attributeId - The ID of the attribute to retrieve.
|
|
26
|
+
* @returns {Promise<Attribute>} A promise that resolves with the attribute.
|
|
27
|
+
*/
|
|
28
|
+
async getAttribute(attributeId) {
|
|
29
|
+
return await this.get(`${resourceName}/${attributeId}`);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Deletes a single attribute from the API by its ID.
|
|
33
|
+
*
|
|
34
|
+
* @param {number} attributeId - The ID of the attribute to delete.
|
|
35
|
+
* @returns {Promise<void>} A promise that resolves when the delete operation is complete.
|
|
36
|
+
*/
|
|
37
|
+
async deleteAttribute(attributeId) {
|
|
38
|
+
await this.delete(`${resourceName}/${attributeId}`);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Creates a new attribute on the API.
|
|
42
|
+
*
|
|
43
|
+
* @param {Attribute} data - The data for the new attribute.
|
|
44
|
+
* @returns {Promise<Attribute>} A promise that resolves with the newly created attribute.
|
|
45
|
+
*/
|
|
46
|
+
async createAttribute(data) {
|
|
47
|
+
return await this.post(`${resourceName}`, data);
|
|
48
|
+
}
|
|
7
49
|
}
|
package/build/base-api.d.ts
CHANGED
|
@@ -30,6 +30,14 @@ export declare abstract class BaseApi {
|
|
|
30
30
|
* @template T - Type of the response data.
|
|
31
31
|
*/
|
|
32
32
|
protected post<I, T>(endpoint: string, data: I): Promise<T>;
|
|
33
|
+
/**
|
|
34
|
+
* Sends a DELETE request to the specified endpoint.
|
|
35
|
+
*
|
|
36
|
+
* @param {string} endpoint - The endpoint to send the request to.
|
|
37
|
+
* @returns {Promise<void>} A promise that resolves when the DELETE request is complete.
|
|
38
|
+
* @protected
|
|
39
|
+
*/
|
|
40
|
+
protected delete(endpoint: string): Promise<void>;
|
|
33
41
|
/**
|
|
34
42
|
* Returns the base URL for the API based on the environment.
|
|
35
43
|
*
|
package/build/base-api.js
CHANGED
|
@@ -40,6 +40,16 @@ export class BaseApi {
|
|
|
40
40
|
async post(endpoint, data) {
|
|
41
41
|
return await this.base_api.post(endpoint, data);
|
|
42
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Sends a DELETE request to the specified endpoint.
|
|
45
|
+
*
|
|
46
|
+
* @param {string} endpoint - The endpoint to send the request to.
|
|
47
|
+
* @returns {Promise<void>} A promise that resolves when the DELETE request is complete.
|
|
48
|
+
* @protected
|
|
49
|
+
*/
|
|
50
|
+
async delete(endpoint) {
|
|
51
|
+
await this.base_api.delete(endpoint);
|
|
52
|
+
}
|
|
43
53
|
/**
|
|
44
54
|
* Returns the base URL for the API based on the environment.
|
|
45
55
|
*
|
package/build/health/index.d.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { BaseApi } from '../base-api';
|
|
2
2
|
import { type HealthCheckResult } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* A class for accessing the Health Check API.
|
|
5
|
+
* @extends BaseApi
|
|
6
|
+
*/
|
|
3
7
|
export declare class HealthCheckApi extends BaseApi {
|
|
8
|
+
/**
|
|
9
|
+
* Gets the result of a health check from the API.
|
|
10
|
+
*
|
|
11
|
+
* @returns {Promise<HealthCheckResult>} A promise that resolves with the result of the health check.
|
|
12
|
+
*/
|
|
4
13
|
getHealthCheck(): Promise<HealthCheckResult>;
|
|
5
14
|
}
|
package/build/health/index.js
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
import { BaseApi } from '../base-api';
|
|
2
|
+
/**
|
|
3
|
+
* The name of the resource to be used in API requests.
|
|
4
|
+
* @constant
|
|
5
|
+
* @private
|
|
6
|
+
* @type {string}
|
|
7
|
+
*/
|
|
2
8
|
const resourceName = 'health';
|
|
9
|
+
/**
|
|
10
|
+
* A class for accessing the Health Check API.
|
|
11
|
+
* @extends BaseApi
|
|
12
|
+
*/
|
|
3
13
|
export class HealthCheckApi extends BaseApi {
|
|
14
|
+
/**
|
|
15
|
+
* Gets the result of a health check from the API.
|
|
16
|
+
*
|
|
17
|
+
* @returns {Promise<HealthCheckResult>} A promise that resolves with the result of the health check.
|
|
18
|
+
*/
|
|
4
19
|
async getHealthCheck() {
|
|
5
20
|
return await this.get(resourceName);
|
|
6
21
|
}
|
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.16",
|
|
4
4
|
"main": "build/index.js",
|
|
5
5
|
"repository": "github:narrative-io/data-collaboration-sdk-ts",
|
|
6
6
|
"source": "src/index.ts",
|
|
@@ -20,6 +20,8 @@
|
|
|
20
20
|
"author": "",
|
|
21
21
|
"license": "ISC",
|
|
22
22
|
"devDependencies": {
|
|
23
|
+
"@commitlint/cli": "^17.4.2",
|
|
24
|
+
"@commitlint/config-conventional": "^17.4.2",
|
|
23
25
|
"@typescript-eslint/eslint-plugin": "^5.51.0",
|
|
24
26
|
"@vitest/coverage-c8": "^0.28.4",
|
|
25
27
|
"eslint": "^8.33.0",
|