@narrative.io/data-collaboration-sdk-ts 0.0.2 → 0.0.4
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/dist/base-api.d.ts +47 -0
- package/dist/datasets/index.d.ts +21 -0
- package/dist/health/index.d.ts +5 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.m.js +1 -1
- package/dist/index.m.js.map +1 -1
- package/dist/index.modern.mjs +1 -1
- package/dist/index.modern.mjs.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/{src/rosetta-stone → rosetta-stone}/index.d.ts +0 -0
- package/dist/{src/utils.d.ts → utils.d.ts} +0 -0
- package/package.json +9 -5
- package/dist/src/base-api.d.ts +0 -16
- package/dist/src/health/index.d.ts +0 -5
- package/dist/src/health/types.d.ts +0 -10
- package/dist/src/index.d.ts +0 -7
- package/dist/src/rosetta-stone/types.d.ts +0 -12
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Config } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* BaseApi class provides basic functionality for making API requests.
|
|
4
|
+
*/
|
|
5
|
+
export declare abstract class BaseApi {
|
|
6
|
+
private apiKey?;
|
|
7
|
+
private environment;
|
|
8
|
+
private base_api;
|
|
9
|
+
/**
|
|
10
|
+
* @param {Config} config - Configuration object.
|
|
11
|
+
* @param {string} [config.apiKey] - API key.
|
|
12
|
+
* @param {Environment} [config.environment='prod'] - Environment for the API (e.g. 'dev', 'prod').
|
|
13
|
+
*/
|
|
14
|
+
constructor(config: Config);
|
|
15
|
+
/**
|
|
16
|
+
* Makes a GET request to the given endpoint.
|
|
17
|
+
*
|
|
18
|
+
* @param {string} endpoint - Endpoint for the request.
|
|
19
|
+
* @returns {Promise<T>} - Promise that resolves with the response data.
|
|
20
|
+
* @template T - Type of the response data.
|
|
21
|
+
*/
|
|
22
|
+
protected get<T>(endpoint: string): Promise<T>;
|
|
23
|
+
/**
|
|
24
|
+
* Makes a POST request to the given endpoint with the given data.
|
|
25
|
+
*
|
|
26
|
+
* @param {string} endpoint - Endpoint for the request.
|
|
27
|
+
* @param {I} data - Data to be sent in the request.
|
|
28
|
+
* @returns {Promise<T>} - Promise that resolves with the response data.
|
|
29
|
+
* @template I - Type of the request data.
|
|
30
|
+
* @template T - Type of the response data.
|
|
31
|
+
*/
|
|
32
|
+
protected post<I, T>(endpoint: string, data: I): Promise<T>;
|
|
33
|
+
/**
|
|
34
|
+
* Returns the base URL for the API based on the environment.
|
|
35
|
+
*
|
|
36
|
+
* @returns {string} - Base URL for the API.
|
|
37
|
+
* @private
|
|
38
|
+
*/
|
|
39
|
+
private getBaseUrl;
|
|
40
|
+
/**
|
|
41
|
+
* Returns the headers for the API request.
|
|
42
|
+
*
|
|
43
|
+
* @returns {Object.<string, string>} - Headers for the API request.
|
|
44
|
+
* @private
|
|
45
|
+
*/
|
|
46
|
+
private getHeaders;
|
|
47
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ApiRecords } from "src/types";
|
|
2
|
+
import { BaseApi } from "../base-api";
|
|
3
|
+
import { Dataset } from "./types";
|
|
4
|
+
/**
|
|
5
|
+
* @module DatasetApi
|
|
6
|
+
* @description This module provides methods for fetching datasets.
|
|
7
|
+
* @extends BaseApi
|
|
8
|
+
*/
|
|
9
|
+
export declare class DatasetApi extends BaseApi {
|
|
10
|
+
/**
|
|
11
|
+
* Get a single dataset by its ID
|
|
12
|
+
* @param {number} dataset_id - The ID of the dataset
|
|
13
|
+
* @returns {Promise<Dataset>} - Promise resolving to the requested dataset
|
|
14
|
+
*/
|
|
15
|
+
getDataset(dataset_id: number): Promise<Dataset>;
|
|
16
|
+
/**
|
|
17
|
+
* Get a list of all datasets
|
|
18
|
+
* @returns {Promise<ApiRecords<Dataset>>} - Promise resolving to an array of datasets
|
|
19
|
+
*/
|
|
20
|
+
getDatasets(): Promise<ApiRecords<Dataset>>;
|
|
21
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BaseApi } from './base-api';
|
|
2
|
+
import { HealthCheckApi } from './health';
|
|
3
|
+
import { DatasetApi } from './datasets';
|
|
4
|
+
import { RosettaStoneApi } from './rosetta-stone';
|
|
5
|
+
declare class NarrativeApi extends BaseApi {
|
|
6
|
+
}
|
|
7
|
+
interface NarrativeApi extends BaseApi, HealthCheckApi, DatasetApi, RosettaStoneApi {
|
|
8
|
+
}
|
|
9
|
+
export default NarrativeApi;
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var t=require("mande");function e(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,r(t,e)}function r(t,e){return r=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},r(t,e)}var n,o=/*#__PURE__*/function(){function e(e){this.apiKey=void 0,this.environment=void 0,this.base_api=void 0,this.apiKey=e.apiKey,this.environment=e.environment||"prod",this.base_api=t.mande(""+this.getBaseUrl(),{headers:this.getHeaders()})}var r=e.prototype;return r.get=function(t){return this.base_api.get(t)},r.post=function(t,e){return this.base_api.post(t,e)},r.getBaseUrl=function(){switch(this.environment){case"prod":return"https://api.narrative.io/";case"dev":return"https://api-dev.narrative.io/";default:return this.environment}},r.getHeaders=function(){var t={"Content-type":"application/json"};return this.apiKey&&(t.Authorization="Bearer "+this.apiKey),t},e}(),i=/*#__PURE__*/function(t){function r(){return t.apply(this,arguments)||this}return e(r,t),r.prototype.getHealthCheck=function(){try{return Promise.resolve(this.get("health"))}catch(t){return Promise.reject(t)}},r}(o),p=/*#__PURE__*/function(t){function r(){return t.apply(this,arguments)||this}return e(r,t),r}(o);n=
|
|
1
|
+
var t=require("mande");function e(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,r(t,e)}function r(t,e){return r=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},r(t,e)}var n,o=/*#__PURE__*/function(){function e(e){this.apiKey=void 0,this.environment=void 0,this.base_api=void 0,this.apiKey=e.apiKey,this.environment=e.environment||"prod",this.base_api=t.mande(""+this.getBaseUrl(),{headers:this.getHeaders()})}var r=e.prototype;return r.get=function(t){return this.base_api.get(t)},r.post=function(t,e){return this.base_api.post(t,e)},r.getBaseUrl=function(){switch(this.environment){case"prod":return"https://api.narrative.io/";case"dev":return"https://api-dev.narrative.io/";default:return this.environment}},r.getHeaders=function(){var t={"Content-type":"application/json"};return this.apiKey&&(t.Authorization="Bearer "+this.apiKey),t},e}(),i=/*#__PURE__*/function(t){function r(){return t.apply(this,arguments)||this}return e(r,t),r.prototype.getHealthCheck=function(){try{return Promise.resolve(this.get("health"))}catch(t){return Promise.reject(t)}},r}(o),s="datasets",a=/*#__PURE__*/function(t){function r(){return t.apply(this,arguments)||this}e(r,t);var n=r.prototype;return n.getDataset=function(t){try{return Promise.resolve(this.get(s+"/"+t))}catch(t){return Promise.reject(t)}},n.getDatasets=function(){try{return Promise.resolve(this.get(""+s))}catch(t){return Promise.reject(t)}},r}(o),p=/*#__PURE__*/function(t){function r(){return t.apply(this,arguments)||this}return e(r,t),r.prototype.getLabelsFromSample=function(t){try{return Promise.resolve(this.post("rosetta-stone/labels/sample",t))}catch(t){return Promise.reject(t)}},r}(o),c=/*#__PURE__*/function(t){function r(){return t.apply(this,arguments)||this}return e(r,t),r}(o);n=c,[i,a,p].forEach(function(t){Object.getOwnPropertyNames(t.prototype).forEach(function(e){Object.defineProperty(n.prototype,e,Object.getOwnPropertyDescriptor(t.prototype,e)||Object.create(null))})}),module.exports=c;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/base-api.ts","../src/utils.ts","../src/health/index.ts","../src/index.ts"],"sourcesContent":["import { mande, MandeInstance } from 'mande'\
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/base-api.ts","../src/utils.ts","../src/health/index.ts","../src/datasets/index.ts","../src/rosetta-stone/index.ts","../src/index.ts"],"sourcesContent":["import { mande, MandeInstance } from 'mande'\nimport type { Config } from './types'\n\n/**\n * BaseApi class provides basic functionality for making API requests.\n */\nexport abstract class BaseApi {\n private apiKey?: string\n private environment: string\n private base_api: MandeInstance\n\n /**\n * @param {Config} config - Configuration object.\n * @param {string} [config.apiKey] - API key.\n * @param {Environment} [config.environment='prod'] - Environment for the API (e.g. 'dev', 'prod').\n */\n constructor(config: Config) {\n this.apiKey = config.apiKey\n this.environment = config.environment || 'prod'\n this.base_api = mande(`${this.getBaseUrl()}`, {\n headers: this.getHeaders(),\n })\n }\n\n /**\n * Makes a GET request to the given endpoint.\n *\n * @param {string} endpoint - Endpoint for the request.\n * @returns {Promise<T>} - Promise that resolves with the response data.\n * @template T - Type of the response data.\n */\n protected get<T>(endpoint: string): Promise<T> {\n return this.base_api.get<T>(endpoint)\n }\n\n /**\n * Makes a POST request to the given endpoint with the given data.\n *\n * @param {string} endpoint - Endpoint for the request.\n * @param {I} data - Data to be sent in the request.\n * @returns {Promise<T>} - Promise that resolves with the response data.\n * @template I - Type of the request data.\n * @template T - Type of the response data.\n */\n protected post<I, T>(endpoint: string, data: I): Promise<T> {\n return this.base_api.post<T>(endpoint, data)\n }\n\n /**\n * Returns the base URL for the API based on the environment.\n *\n * @returns {string} - Base URL for the API.\n * @private\n */\n private getBaseUrl(): string {\n switch (this.environment) {\n case 'prod': {\n return `https://api.narrative.io/`\n }\n case 'dev': {\n return `https://api-dev.narrative.io/`\n }\n default: {\n return this.environment\n }\n }\n }\n\n /**\n * Returns the headers for the API request.\n *\n * @returns {Object.<string, string>} - Headers for the API request.\n * @private\n */\n private getHeaders(): { [key: string]: string } {\n const headers: { [key: string]: string } = {\n 'Content-type': 'application/json'\n }\n\n if (this.apiKey) {\n headers['Authorization'] = `Bearer ${this.apiKey}`\n }\n\n return headers\n }\n}","export function applyMixins(derivedCtor: any, constructors: any[]) {\n constructors.forEach((baseCtor) => {\n Object.getOwnPropertyNames(baseCtor.prototype).forEach((name) => {\n Object.defineProperty(\n derivedCtor.prototype,\n name,\n Object.getOwnPropertyDescriptor(baseCtor.prototype, name) ||\n Object.create(null)\n );\n });\n });\n}","import { BaseApi } from \"../base-api\";\nimport type { HealthCheckResult } from \"./types\";\n\nconst resourceName = 'health';\n\nexport class HealthCheckApi extends BaseApi {\n public async getHealthCheck(): Promise<HealthCheckResult> {\n return await this.get<HealthCheckResult>(resourceName);\n }\n}","import { ApiRecords } from \"src/types\";\nimport { BaseApi } from \"../base-api\";\nimport { Dataset } from \"./types\";\n\nconst resourceName = 'datasets';\n\n/**\n * @module DatasetApi\n * @description This module provides methods for fetching datasets.\n * @extends BaseApi\n */\nexport class DatasetApi extends BaseApi {\n \n /**\n * Get a single dataset by its ID\n * @param {number} dataset_id - The ID of the dataset\n * @returns {Promise<Dataset>} - Promise resolving to the requested dataset\n */\n public async getDataset(dataset_id: number): Promise<Dataset> {\n return this.get<Dataset>(`${resourceName}/${dataset_id}`);\n }\n\n /**\n * Get a list of all datasets\n * @returns {Promise<ApiRecords<Dataset>>} - Promise resolving to an array of datasets\n */\n public async getDatasets(): Promise<ApiRecords<Dataset>> {\n return this.get<ApiRecords<Dataset>>(`${resourceName}`);\n }\n}","import { BaseApi } from \"../base-api\";\nimport { RosettaStoneResponse, SampleRecords } from \"./types\";\n\nconst resourceName = 'rosetta-stone';\n\nexport class RosettaStoneApi extends BaseApi {\n public async getLabelsFromSample(sample: SampleRecords): Promise<RosettaStoneResponse[]> {\n return this.post<SampleRecords, RosettaStoneResponse[]>(`${resourceName}/labels/sample`, sample);\n }\n}","import { BaseApi } from './base-api';\nimport { HealthCheckApi } from './health'\nimport { DatasetApi } from './datasets'\nimport { RosettaStoneApi } from './rosetta-stone'\nimport { applyMixins } from './utils'\n\nclass NarrativeApi extends BaseApi { }\ninterface NarrativeApi extends BaseApi, HealthCheckApi, DatasetApi, RosettaStoneApi { }\napplyMixins(NarrativeApi, [HealthCheckApi, DatasetApi, RosettaStoneApi]);\n\nexport default NarrativeApi"],"names":["derivedCtor","BaseApi","config","apiKey","this","environment","base_api","mande","getBaseUrl","headers","getHeaders","get","endpoint","post","data","_proto","HealthCheckApi","_BaseApi","apply","arguments","_inheritsLoose","prototype","getHealthCheck","Promise","resolve","e","reject","resourceName","getDataset","dataset_id","getDatasets","RosettaStoneApi","getLabelsFromSample","sample","NarrativeApi","DatasetApi","forEach","baseCtor","Object","getOwnPropertyNames","name","defineProperty","getOwnPropertyDescriptor","create"],"mappings":"wOAMA,ICN4BA,iBDgBxB,WAAA,SAAAC,EAAYC,QATJC,YAAM,EAAAC,KACNC,iBAAW,EAAAD,KACXE,cAQJ,EAAAF,KAAKD,OAASD,EAAOC,OACrBC,KAAKC,YAAcH,EAAOG,aAAe,OACzCD,KAAKE,SAAWC,EAAKA,SAAIH,KAAKI,aAAgB,CAC1CC,QAASL,KAAKM,cAEtB,CAAC,IASSC,EAAAA,EAAAA,UAqDT,OArDSA,EAAAA,IAAA,SAAOC,GACb,OAAOR,KAAKE,SAASK,IAAOC,EAChC,EAWUC,EAAAA,KAAA,SAAWD,EAAkBE,GACnC,OAAWV,KAACE,SAASO,KAAQD,EAAUE,EAC3C,EAACC,EAQOP,WAAA,WACJ,OAAQJ,KAAKC,aACT,IAAK,OACD,MACH,4BACD,IAAK,MACD,MAAA,gCAEJ,QACI,OAAOD,KAAKC,YAGxB,IAQQK,WAAA,WACJ,IAAaD,EAA8B,CACvC,eAAgB,oBAOpB,OAJIL,KAAKD,SACLM,EAAuB,cAAC,UAAaL,KAAKD,SAIlD,EAACF,CAAA,CApED,GEXwBe,eAAA,SAAAC,GAAA,SAAAD,IAAA,OAAAC,EAAAC,MAAAd,KAAAe,YAAAf,IAAA,CAGvB,OAHuBgB,EAAAJ,EAAAC,GAAAD,EAAAK,UACXC,eAAc,WAAA,IACN,OAAAC,QAAAC,QAAJpB,KAAKO,IAJL,UAKhB,CAAA,MAAAc,GAAA,OAAAF,QAAAG,OAAAD,EAAA,CAAA,EAAAT,CAAA,CAHuB,CAAQf,GCDlB0B,EAAG,0BAcJC,SAAAA,GAAAA,SAAAA,IAAAA,OAAAA,EAAAA,MAAAA,KAAAA,YAAAA,IAAAA,CAAAA,EAAAA,EAAAA,GAAAA,IAAAA,EAAAA,EAAAA,iBAAAA,EAAAA,oBAAWC,GAAkB,IACtC,uBAAOzB,KAAKO,IAAgBgB,EAAY,IAAIE,GAOnCC,CANZ,MAMYA,GAAAA,OAAAA,QAAAA,OAAAA,EAAAA,CAAAA,EAAAA,EAAAA,2BACT,OAAOP,QAAAC,QAAApB,KAAKO,IAA4BgB,GAAAA,IAC3C,sCAVYC,CAPe3B,GCNH8B,eAAA,SAAAd,GAAA,SAAAc,IAAA,OAAAd,EAAAC,MAAAd,KAAAe,YAAAf,IAAA,QAAAgB,EAAAW,EAAAd,GAAAc,EAAAV,UACZW,oBAAoBC,SAAAA,GAAqB,IAClD,OAAOV,QAAAC,QAAApB,KAAKS,KAA+Cc,8BAA8BM,IAC5F,sCAHwB,CAAQhC,GCClBiC,eAAA,SAAAjB,GAAA,SAAAiB,IAAA,OAAAjB,EAAAC,MAAAd,KAAAe,YAAAf,IAAA,CAAA,OAAAgB,EAAAc,EAAAjB,GAAAiB,CAAA,CAAA,CAAQjC,GJNCD,EIQhBkC,EAAc,CAAClB,EAAgBmB,EAAYJ,GJPtCK,QAAQ,SAACC,GAClBC,OAAOC,oBAAoBF,EAAShB,WAAWe,QAAQ,SAACI,GACpDF,OAAOG,eACHzC,EAAYqB,UACZmB,EACAF,OAAOI,yBAAyBL,EAAShB,UAAWmB,IACpDF,OAAOK,OAAO,MAEtB,EACJ"}
|
package/dist/index.m.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{mande as t}from"mande";function e(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,r(t,e)}function r(t,e){return r=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},r(t,e)}var n,o=/*#__PURE__*/function(){function e(e){this.apiKey=void 0,this.environment=void 0,this.base_api=void 0,this.apiKey=e.apiKey,this.environment=e.environment||"prod",this.base_api=t(""+this.getBaseUrl(),{headers:this.getHeaders()})}var r=e.prototype;return r.get=function(t){return this.base_api.get(t)},r.post=function(t,e){return this.base_api.post(t,e)},r.getBaseUrl=function(){switch(this.environment){case"prod":return"https://api.narrative.io/";case"dev":return"https://api-dev.narrative.io/";default:return this.environment}},r.getHeaders=function(){var t={"Content-type":"application/json"};return this.apiKey&&(t.Authorization="Bearer "+this.apiKey),t},e}(),i=/*#__PURE__*/function(t){function r(){return t.apply(this,arguments)||this}return e(r,t),r.prototype.getHealthCheck=function(){try{return Promise.resolve(this.get("health"))}catch(t){return Promise.reject(t)}},r}(o),p=/*#__PURE__*/function(t){function r(){return t.apply(this,arguments)||this}return e(r,t),r}(o);n=
|
|
1
|
+
import{mande as t}from"mande";function e(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,r(t,e)}function r(t,e){return r=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},r(t,e)}var n,o=/*#__PURE__*/function(){function e(e){this.apiKey=void 0,this.environment=void 0,this.base_api=void 0,this.apiKey=e.apiKey,this.environment=e.environment||"prod",this.base_api=t(""+this.getBaseUrl(),{headers:this.getHeaders()})}var r=e.prototype;return r.get=function(t){return this.base_api.get(t)},r.post=function(t,e){return this.base_api.post(t,e)},r.getBaseUrl=function(){switch(this.environment){case"prod":return"https://api.narrative.io/";case"dev":return"https://api-dev.narrative.io/";default:return this.environment}},r.getHeaders=function(){var t={"Content-type":"application/json"};return this.apiKey&&(t.Authorization="Bearer "+this.apiKey),t},e}(),i=/*#__PURE__*/function(t){function r(){return t.apply(this,arguments)||this}return e(r,t),r.prototype.getHealthCheck=function(){try{return Promise.resolve(this.get("health"))}catch(t){return Promise.reject(t)}},r}(o),s="datasets",a=/*#__PURE__*/function(t){function r(){return t.apply(this,arguments)||this}e(r,t);var n=r.prototype;return n.getDataset=function(t){try{return Promise.resolve(this.get(s+"/"+t))}catch(t){return Promise.reject(t)}},n.getDatasets=function(){try{return Promise.resolve(this.get(""+s))}catch(t){return Promise.reject(t)}},r}(o),p=/*#__PURE__*/function(t){function r(){return t.apply(this,arguments)||this}return e(r,t),r.prototype.getLabelsFromSample=function(t){try{return Promise.resolve(this.post("rosetta-stone/labels/sample",t))}catch(t){return Promise.reject(t)}},r}(o),c=/*#__PURE__*/function(t){function r(){return t.apply(this,arguments)||this}return e(r,t),r}(o);n=c,[i,a,p].forEach(function(t){Object.getOwnPropertyNames(t.prototype).forEach(function(e){Object.defineProperty(n.prototype,e,Object.getOwnPropertyDescriptor(t.prototype,e)||Object.create(null))})});export{c as default};
|
|
2
2
|
//# sourceMappingURL=index.m.js.map
|
package/dist/index.m.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.m.js","sources":["../src/base-api.ts","../src/utils.ts","../src/health/index.ts","../src/index.ts"],"sourcesContent":["import { mande, MandeInstance } from 'mande'\
|
|
1
|
+
{"version":3,"file":"index.m.js","sources":["../src/base-api.ts","../src/utils.ts","../src/health/index.ts","../src/datasets/index.ts","../src/rosetta-stone/index.ts","../src/index.ts"],"sourcesContent":["import { mande, MandeInstance } from 'mande'\nimport type { Config } from './types'\n\n/**\n * BaseApi class provides basic functionality for making API requests.\n */\nexport abstract class BaseApi {\n private apiKey?: string\n private environment: string\n private base_api: MandeInstance\n\n /**\n * @param {Config} config - Configuration object.\n * @param {string} [config.apiKey] - API key.\n * @param {Environment} [config.environment='prod'] - Environment for the API (e.g. 'dev', 'prod').\n */\n constructor(config: Config) {\n this.apiKey = config.apiKey\n this.environment = config.environment || 'prod'\n this.base_api = mande(`${this.getBaseUrl()}`, {\n headers: this.getHeaders(),\n })\n }\n\n /**\n * Makes a GET request to the given endpoint.\n *\n * @param {string} endpoint - Endpoint for the request.\n * @returns {Promise<T>} - Promise that resolves with the response data.\n * @template T - Type of the response data.\n */\n protected get<T>(endpoint: string): Promise<T> {\n return this.base_api.get<T>(endpoint)\n }\n\n /**\n * Makes a POST request to the given endpoint with the given data.\n *\n * @param {string} endpoint - Endpoint for the request.\n * @param {I} data - Data to be sent in the request.\n * @returns {Promise<T>} - Promise that resolves with the response data.\n * @template I - Type of the request data.\n * @template T - Type of the response data.\n */\n protected post<I, T>(endpoint: string, data: I): Promise<T> {\n return this.base_api.post<T>(endpoint, data)\n }\n\n /**\n * Returns the base URL for the API based on the environment.\n *\n * @returns {string} - Base URL for the API.\n * @private\n */\n private getBaseUrl(): string {\n switch (this.environment) {\n case 'prod': {\n return `https://api.narrative.io/`\n }\n case 'dev': {\n return `https://api-dev.narrative.io/`\n }\n default: {\n return this.environment\n }\n }\n }\n\n /**\n * Returns the headers for the API request.\n *\n * @returns {Object.<string, string>} - Headers for the API request.\n * @private\n */\n private getHeaders(): { [key: string]: string } {\n const headers: { [key: string]: string } = {\n 'Content-type': 'application/json'\n }\n\n if (this.apiKey) {\n headers['Authorization'] = `Bearer ${this.apiKey}`\n }\n\n return headers\n }\n}","export function applyMixins(derivedCtor: any, constructors: any[]) {\n constructors.forEach((baseCtor) => {\n Object.getOwnPropertyNames(baseCtor.prototype).forEach((name) => {\n Object.defineProperty(\n derivedCtor.prototype,\n name,\n Object.getOwnPropertyDescriptor(baseCtor.prototype, name) ||\n Object.create(null)\n );\n });\n });\n}","import { BaseApi } from \"../base-api\";\nimport type { HealthCheckResult } from \"./types\";\n\nconst resourceName = 'health';\n\nexport class HealthCheckApi extends BaseApi {\n public async getHealthCheck(): Promise<HealthCheckResult> {\n return await this.get<HealthCheckResult>(resourceName);\n }\n}","import { ApiRecords } from \"src/types\";\nimport { BaseApi } from \"../base-api\";\nimport { Dataset } from \"./types\";\n\nconst resourceName = 'datasets';\n\n/**\n * @module DatasetApi\n * @description This module provides methods for fetching datasets.\n * @extends BaseApi\n */\nexport class DatasetApi extends BaseApi {\n \n /**\n * Get a single dataset by its ID\n * @param {number} dataset_id - The ID of the dataset\n * @returns {Promise<Dataset>} - Promise resolving to the requested dataset\n */\n public async getDataset(dataset_id: number): Promise<Dataset> {\n return this.get<Dataset>(`${resourceName}/${dataset_id}`);\n }\n\n /**\n * Get a list of all datasets\n * @returns {Promise<ApiRecords<Dataset>>} - Promise resolving to an array of datasets\n */\n public async getDatasets(): Promise<ApiRecords<Dataset>> {\n return this.get<ApiRecords<Dataset>>(`${resourceName}`);\n }\n}","import { BaseApi } from \"../base-api\";\nimport { RosettaStoneResponse, SampleRecords } from \"./types\";\n\nconst resourceName = 'rosetta-stone';\n\nexport class RosettaStoneApi extends BaseApi {\n public async getLabelsFromSample(sample: SampleRecords): Promise<RosettaStoneResponse[]> {\n return this.post<SampleRecords, RosettaStoneResponse[]>(`${resourceName}/labels/sample`, sample);\n }\n}","import { BaseApi } from './base-api';\nimport { HealthCheckApi } from './health'\nimport { DatasetApi } from './datasets'\nimport { RosettaStoneApi } from './rosetta-stone'\nimport { applyMixins } from './utils'\n\nclass NarrativeApi extends BaseApi { }\ninterface NarrativeApi extends BaseApi, HealthCheckApi, DatasetApi, RosettaStoneApi { }\napplyMixins(NarrativeApi, [HealthCheckApi, DatasetApi, RosettaStoneApi]);\n\nexport default NarrativeApi"],"names":["derivedCtor","BaseApi","config","apiKey","this","environment","base_api","mande","getBaseUrl","headers","getHeaders","get","endpoint","post","data","_proto","HealthCheckApi","_BaseApi","apply","arguments","_inheritsLoose","prototype","getHealthCheck","Promise","resolve","e","reject","resourceName","getDataset","dataset_id","getDatasets","RosettaStoneApi","getLabelsFromSample","sample","NarrativeApi","DatasetApi","forEach","baseCtor","Object","getOwnPropertyNames","name","defineProperty","getOwnPropertyDescriptor","create"],"mappings":"+OAMA,ICN4BA,iBDgBxB,WAAA,SAAAC,EAAYC,QATJC,YAAM,EAAAC,KACNC,iBAAW,EAAAD,KACXE,cAQJ,EAAAF,KAAKD,OAASD,EAAOC,OACrBC,KAAKC,YAAcH,EAAOG,aAAe,OACzCD,KAAKE,SAAWC,KAASH,KAAKI,aAAgB,CAC1CC,QAASL,KAAKM,cAEtB,CAAC,IASSC,EAAAA,EAAAA,UAqDT,OArDSA,EAAAA,IAAA,SAAOC,GACb,OAAOR,KAAKE,SAASK,IAAOC,EAChC,EAWUC,EAAAA,KAAA,SAAWD,EAAkBE,GACnC,OAAWV,KAACE,SAASO,KAAQD,EAAUE,EAC3C,EAACC,EAQOP,WAAA,WACJ,OAAQJ,KAAKC,aACT,IAAK,OACD,MACH,4BACD,IAAK,MACD,MAAA,gCAEJ,QACI,OAAOD,KAAKC,YAGxB,IAQQK,WAAA,WACJ,IAAaD,EAA8B,CACvC,eAAgB,oBAOpB,OAJIL,KAAKD,SACLM,EAAuB,cAAC,UAAaL,KAAKD,SAIlD,EAACF,CAAA,CApED,GEXwBe,eAAA,SAAAC,GAAA,SAAAD,IAAA,OAAAC,EAAAC,MAAAd,KAAAe,YAAAf,IAAA,CAGvB,OAHuBgB,EAAAJ,EAAAC,GAAAD,EAAAK,UACXC,eAAc,WAAA,IACN,OAAAC,QAAAC,QAAJpB,KAAKO,IAJL,UAKhB,CAAA,MAAAc,GAAA,OAAAF,QAAAG,OAAAD,EAAA,CAAA,EAAAT,CAAA,CAHuB,CAAQf,GCDlB0B,EAAG,0BAcJC,SAAAA,GAAAA,SAAAA,IAAAA,OAAAA,EAAAA,MAAAA,KAAAA,YAAAA,IAAAA,CAAAA,EAAAA,EAAAA,GAAAA,IAAAA,EAAAA,EAAAA,iBAAAA,EAAAA,oBAAWC,GAAkB,IACtC,uBAAOzB,KAAKO,IAAgBgB,EAAY,IAAIE,GAOnCC,CANZ,MAMYA,GAAAA,OAAAA,QAAAA,OAAAA,EAAAA,CAAAA,EAAAA,EAAAA,2BACT,OAAOP,QAAAC,QAAApB,KAAKO,IAA4BgB,GAAAA,IAC3C,sCAVYC,CAPe3B,GCNH8B,eAAA,SAAAd,GAAA,SAAAc,IAAA,OAAAd,EAAAC,MAAAd,KAAAe,YAAAf,IAAA,QAAAgB,EAAAW,EAAAd,GAAAc,EAAAV,UACZW,oBAAoBC,SAAAA,GAAqB,IAClD,OAAOV,QAAAC,QAAApB,KAAKS,KAA+Cc,8BAA8BM,IAC5F,sCAHwB,CAAQhC,GCClBiC,eAAA,SAAAjB,GAAA,SAAAiB,IAAA,OAAAjB,EAAAC,MAAAd,KAAAe,YAAAf,IAAA,CAAA,OAAAgB,EAAAc,EAAAjB,GAAAiB,CAAA,CAAA,CAAQjC,GJNCD,EIQhBkC,EAAc,CAAClB,EAAgBmB,EAAYJ,GJPtCK,QAAQ,SAACC,GAClBC,OAAOC,oBAAoBF,EAAShB,WAAWe,QAAQ,SAACI,GACpDF,OAAOG,eACHzC,EAAYqB,UACZmB,EACAF,OAAOI,yBAAyBL,EAAShB,UAAWmB,IACpDF,OAAOK,OAAO,MAEtB,EACJ"}
|
package/dist/index.modern.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{mande as
|
|
1
|
+
import{mande as t}from"mande";class e{constructor(e){this.apiKey=void 0,this.environment=void 0,this.base_api=void 0,this.apiKey=e.apiKey,this.environment=e.environment||"prod",this.base_api=t(`${this.getBaseUrl()}`,{headers:this.getHeaders()})}get(t){return this.base_api.get(t)}post(t,e){return this.base_api.post(t,e)}getBaseUrl(){switch(this.environment){case"prod":return"https://api.narrative.io/";case"dev":return"https://api-dev.narrative.io/";default:return this.environment}}getHeaders(){const t={"Content-type":"application/json"};return this.apiKey&&(t.Authorization=`Bearer ${this.apiKey}`),t}}const s="datasets";class a extends e{}var r;r=a,[class extends e{async getHealthCheck(){return await this.get("health")}},class extends e{async getDataset(t){return this.get(`${s}/${t}`)}async getDatasets(){return this.get(`${s}`)}},class extends e{async getLabelsFromSample(t){return this.post("rosetta-stone/labels/sample",t)}}].forEach(t=>{Object.getOwnPropertyNames(t.prototype).forEach(e=>{Object.defineProperty(r.prototype,e,Object.getOwnPropertyDescriptor(t.prototype,e)||Object.create(null))})});export{a as default};
|
|
2
2
|
//# sourceMappingURL=index.modern.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.modern.mjs","sources":["../src/base-api.ts","../src/index.ts","../src/utils.ts","../src/health/index.ts"],"sourcesContent":["import { mande, MandeInstance } from 'mande'\
|
|
1
|
+
{"version":3,"file":"index.modern.mjs","sources":["../src/base-api.ts","../src/datasets/index.ts","../src/index.ts","../src/utils.ts","../src/health/index.ts","../src/rosetta-stone/index.ts"],"sourcesContent":["import { mande, MandeInstance } from 'mande'\nimport type { Config } from './types'\n\n/**\n * BaseApi class provides basic functionality for making API requests.\n */\nexport abstract class BaseApi {\n private apiKey?: string\n private environment: string\n private base_api: MandeInstance\n\n /**\n * @param {Config} config - Configuration object.\n * @param {string} [config.apiKey] - API key.\n * @param {Environment} [config.environment='prod'] - Environment for the API (e.g. 'dev', 'prod').\n */\n constructor(config: Config) {\n this.apiKey = config.apiKey\n this.environment = config.environment || 'prod'\n this.base_api = mande(`${this.getBaseUrl()}`, {\n headers: this.getHeaders(),\n })\n }\n\n /**\n * Makes a GET request to the given endpoint.\n *\n * @param {string} endpoint - Endpoint for the request.\n * @returns {Promise<T>} - Promise that resolves with the response data.\n * @template T - Type of the response data.\n */\n protected get<T>(endpoint: string): Promise<T> {\n return this.base_api.get<T>(endpoint)\n }\n\n /**\n * Makes a POST request to the given endpoint with the given data.\n *\n * @param {string} endpoint - Endpoint for the request.\n * @param {I} data - Data to be sent in the request.\n * @returns {Promise<T>} - Promise that resolves with the response data.\n * @template I - Type of the request data.\n * @template T - Type of the response data.\n */\n protected post<I, T>(endpoint: string, data: I): Promise<T> {\n return this.base_api.post<T>(endpoint, data)\n }\n\n /**\n * Returns the base URL for the API based on the environment.\n *\n * @returns {string} - Base URL for the API.\n * @private\n */\n private getBaseUrl(): string {\n switch (this.environment) {\n case 'prod': {\n return `https://api.narrative.io/`\n }\n case 'dev': {\n return `https://api-dev.narrative.io/`\n }\n default: {\n return this.environment\n }\n }\n }\n\n /**\n * Returns the headers for the API request.\n *\n * @returns {Object.<string, string>} - Headers for the API request.\n * @private\n */\n private getHeaders(): { [key: string]: string } {\n const headers: { [key: string]: string } = {\n 'Content-type': 'application/json'\n }\n\n if (this.apiKey) {\n headers['Authorization'] = `Bearer ${this.apiKey}`\n }\n\n return headers\n }\n}","import { ApiRecords } from \"src/types\";\nimport { BaseApi } from \"../base-api\";\nimport { Dataset } from \"./types\";\n\nconst resourceName = 'datasets';\n\n/**\n * @module DatasetApi\n * @description This module provides methods for fetching datasets.\n * @extends BaseApi\n */\nexport class DatasetApi extends BaseApi {\n \n /**\n * Get a single dataset by its ID\n * @param {number} dataset_id - The ID of the dataset\n * @returns {Promise<Dataset>} - Promise resolving to the requested dataset\n */\n public async getDataset(dataset_id: number): Promise<Dataset> {\n return this.get<Dataset>(`${resourceName}/${dataset_id}`);\n }\n\n /**\n * Get a list of all datasets\n * @returns {Promise<ApiRecords<Dataset>>} - Promise resolving to an array of datasets\n */\n public async getDatasets(): Promise<ApiRecords<Dataset>> {\n return this.get<ApiRecords<Dataset>>(`${resourceName}`);\n }\n}","import { BaseApi } from './base-api';\nimport { HealthCheckApi } from './health'\nimport { DatasetApi } from './datasets'\nimport { RosettaStoneApi } from './rosetta-stone'\nimport { applyMixins } from './utils'\n\nclass NarrativeApi extends BaseApi { }\ninterface NarrativeApi extends BaseApi, HealthCheckApi, DatasetApi, RosettaStoneApi { }\napplyMixins(NarrativeApi, [HealthCheckApi, DatasetApi, RosettaStoneApi]);\n\nexport default NarrativeApi","export function applyMixins(derivedCtor: any, constructors: any[]) {\n constructors.forEach((baseCtor) => {\n Object.getOwnPropertyNames(baseCtor.prototype).forEach((name) => {\n Object.defineProperty(\n derivedCtor.prototype,\n name,\n Object.getOwnPropertyDescriptor(baseCtor.prototype, name) ||\n Object.create(null)\n );\n });\n });\n}","import { BaseApi } from \"../base-api\";\nimport type { HealthCheckResult } from \"./types\";\n\nconst resourceName = 'health';\n\nexport class HealthCheckApi extends BaseApi {\n public async getHealthCheck(): Promise<HealthCheckResult> {\n return await this.get<HealthCheckResult>(resourceName);\n }\n}","import { BaseApi } from \"../base-api\";\nimport { RosettaStoneResponse, SampleRecords } from \"./types\";\n\nconst resourceName = 'rosetta-stone';\n\nexport class RosettaStoneApi extends BaseApi {\n public async getLabelsFromSample(sample: SampleRecords): Promise<RosettaStoneResponse[]> {\n return this.post<SampleRecords, RosettaStoneResponse[]>(`${resourceName}/labels/sample`, sample);\n }\n}"],"names":["BaseApi","constructor","config","this","apiKey","environment","base_api","mande","getBaseUrl","headers","getHeaders","get","endpoint","post","data","resourceName","NarrativeApi","applyMixins","derivedCtor","async","dataset_id","sample","forEach","baseCtor","Object","getOwnPropertyNames","prototype","name","defineProperty","getOwnPropertyDescriptor","create"],"mappings":"oCAM6BA,EAUzBC,YAAYC,GAAcC,KATlBC,YAAM,EAAAD,KACNE,iBACAC,EAAAA,KAAAA,cAQJ,EAAAH,KAAKC,OAASF,EAAOE,OACrBD,KAAKE,YAAcH,EAAOG,aAAe,OACzCF,KAAKG,SAAWC,EAAS,GAAAJ,KAAKK,eAAgB,CAC1CC,QAASN,KAAKO,cAEtB,CASUC,IAAOC,GACb,OAAWT,KAACG,SAASK,IAAOC,EAChC,CAWUC,KAAWD,EAAkBE,GACnC,OAAWX,KAACG,SAASO,KAAQD,EAAUE,EAC3C,CAQQN,aACJ,OAAQL,KAAKE,aACT,IAAK,OACD,kCAEJ,IAAK,MACD,sCAEJ,QACI,OAAOF,KAAKE,YAGxB,CAQQK,aACJ,MAAMD,EAAqC,CACvC,eAAgB,oBAOpB,OAJIN,KAAKC,SACLK,EAAuB,wBAAcN,KAAKC,WAIlD,EChFJ,MAAkBW,EAAG,WCErB,MAAmBC,aCNHC,IAAYC,IDQhBF,EAAc,CEHpB,cAAqChB,EAChCmB,uBACH,aAAiBhB,KAACQ,IAJL,SAKjB,mBHUOQ,iBAAiBC,GACpB,OAAOjB,KAAKQ,IAAa,GAAGI,KAAgBK,IAChD,CAMOD,oBACH,YAAYR,OAA4BI,IAC5C,GIvBE,gBACKI,0BAA0BE,GAC7B,YAAYR,KAA4C,8BAAiCQ,EAC7F,IFPaC,QAASC,IAClBC,OAAOC,oBAAoBF,EAASG,WAAWJ,QAASK,IACpDH,OAAOI,eACHV,EAAYQ,UACZC,EACAH,OAAOK,yBAAyBN,EAASG,UAAWC,IACpDH,OAAOM,OAAO,MAEtB,EACJ"}
|
package/dist/index.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("mande")):"function"==typeof define&&define.amd?define(["mande"],e):(t||self).dataCollaborationSdkTs=e(t.mande)}(this,function(t){function e(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("mande")):"function"==typeof define&&define.amd?define(["mande"],e):(t||self).dataCollaborationSdkTs=e(t.mande)}(this,function(t){function e(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,r(t,e)}function r(t,e){return r=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},r(t,e)}var n,o=/*#__PURE__*/function(){function e(e){this.apiKey=void 0,this.environment=void 0,this.base_api=void 0,this.apiKey=e.apiKey,this.environment=e.environment||"prod",this.base_api=t.mande(""+this.getBaseUrl(),{headers:this.getHeaders()})}var r=e.prototype;return r.get=function(t){return this.base_api.get(t)},r.post=function(t,e){return this.base_api.post(t,e)},r.getBaseUrl=function(){switch(this.environment){case"prod":return"https://api.narrative.io/";case"dev":return"https://api-dev.narrative.io/";default:return this.environment}},r.getHeaders=function(){var t={"Content-type":"application/json"};return this.apiKey&&(t.Authorization="Bearer "+this.apiKey),t},e}(),i=/*#__PURE__*/function(t){function r(){return t.apply(this,arguments)||this}return e(r,t),r.prototype.getHealthCheck=function(){try{return Promise.resolve(this.get("health"))}catch(t){return Promise.reject(t)}},r}(o),s="datasets",a=/*#__PURE__*/function(t){function r(){return t.apply(this,arguments)||this}e(r,t);var n=r.prototype;return n.getDataset=function(t){try{return Promise.resolve(this.get(s+"/"+t))}catch(t){return Promise.reject(t)}},n.getDatasets=function(){try{return Promise.resolve(this.get(""+s))}catch(t){return Promise.reject(t)}},r}(o),p=/*#__PURE__*/function(t){function r(){return t.apply(this,arguments)||this}return e(r,t),r.prototype.getLabelsFromSample=function(t){try{return Promise.resolve(this.post("rosetta-stone/labels/sample",t))}catch(t){return Promise.reject(t)}},r}(o),u=/*#__PURE__*/function(t){function r(){return t.apply(this,arguments)||this}return e(r,t),r}(o);return n=u,[i,a,p].forEach(function(t){Object.getOwnPropertyNames(t.prototype).forEach(function(e){Object.defineProperty(n.prototype,e,Object.getOwnPropertyDescriptor(t.prototype,e)||Object.create(null))})}),u});
|
|
2
2
|
//# sourceMappingURL=index.umd.js.map
|
package/dist/index.umd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.umd.js","sources":["../src/base-api.ts","../src/utils.ts","../src/health/index.ts","../src/index.ts"],"sourcesContent":["import { mande, MandeInstance } from 'mande'\
|
|
1
|
+
{"version":3,"file":"index.umd.js","sources":["../src/base-api.ts","../src/utils.ts","../src/health/index.ts","../src/datasets/index.ts","../src/rosetta-stone/index.ts","../src/index.ts"],"sourcesContent":["import { mande, MandeInstance } from 'mande'\nimport type { Config } from './types'\n\n/**\n * BaseApi class provides basic functionality for making API requests.\n */\nexport abstract class BaseApi {\n private apiKey?: string\n private environment: string\n private base_api: MandeInstance\n\n /**\n * @param {Config} config - Configuration object.\n * @param {string} [config.apiKey] - API key.\n * @param {Environment} [config.environment='prod'] - Environment for the API (e.g. 'dev', 'prod').\n */\n constructor(config: Config) {\n this.apiKey = config.apiKey\n this.environment = config.environment || 'prod'\n this.base_api = mande(`${this.getBaseUrl()}`, {\n headers: this.getHeaders(),\n })\n }\n\n /**\n * Makes a GET request to the given endpoint.\n *\n * @param {string} endpoint - Endpoint for the request.\n * @returns {Promise<T>} - Promise that resolves with the response data.\n * @template T - Type of the response data.\n */\n protected get<T>(endpoint: string): Promise<T> {\n return this.base_api.get<T>(endpoint)\n }\n\n /**\n * Makes a POST request to the given endpoint with the given data.\n *\n * @param {string} endpoint - Endpoint for the request.\n * @param {I} data - Data to be sent in the request.\n * @returns {Promise<T>} - Promise that resolves with the response data.\n * @template I - Type of the request data.\n * @template T - Type of the response data.\n */\n protected post<I, T>(endpoint: string, data: I): Promise<T> {\n return this.base_api.post<T>(endpoint, data)\n }\n\n /**\n * Returns the base URL for the API based on the environment.\n *\n * @returns {string} - Base URL for the API.\n * @private\n */\n private getBaseUrl(): string {\n switch (this.environment) {\n case 'prod': {\n return `https://api.narrative.io/`\n }\n case 'dev': {\n return `https://api-dev.narrative.io/`\n }\n default: {\n return this.environment\n }\n }\n }\n\n /**\n * Returns the headers for the API request.\n *\n * @returns {Object.<string, string>} - Headers for the API request.\n * @private\n */\n private getHeaders(): { [key: string]: string } {\n const headers: { [key: string]: string } = {\n 'Content-type': 'application/json'\n }\n\n if (this.apiKey) {\n headers['Authorization'] = `Bearer ${this.apiKey}`\n }\n\n return headers\n }\n}","export function applyMixins(derivedCtor: any, constructors: any[]) {\n constructors.forEach((baseCtor) => {\n Object.getOwnPropertyNames(baseCtor.prototype).forEach((name) => {\n Object.defineProperty(\n derivedCtor.prototype,\n name,\n Object.getOwnPropertyDescriptor(baseCtor.prototype, name) ||\n Object.create(null)\n );\n });\n });\n}","import { BaseApi } from \"../base-api\";\nimport type { HealthCheckResult } from \"./types\";\n\nconst resourceName = 'health';\n\nexport class HealthCheckApi extends BaseApi {\n public async getHealthCheck(): Promise<HealthCheckResult> {\n return await this.get<HealthCheckResult>(resourceName);\n }\n}","import { ApiRecords } from \"src/types\";\nimport { BaseApi } from \"../base-api\";\nimport { Dataset } from \"./types\";\n\nconst resourceName = 'datasets';\n\n/**\n * @module DatasetApi\n * @description This module provides methods for fetching datasets.\n * @extends BaseApi\n */\nexport class DatasetApi extends BaseApi {\n \n /**\n * Get a single dataset by its ID\n * @param {number} dataset_id - The ID of the dataset\n * @returns {Promise<Dataset>} - Promise resolving to the requested dataset\n */\n public async getDataset(dataset_id: number): Promise<Dataset> {\n return this.get<Dataset>(`${resourceName}/${dataset_id}`);\n }\n\n /**\n * Get a list of all datasets\n * @returns {Promise<ApiRecords<Dataset>>} - Promise resolving to an array of datasets\n */\n public async getDatasets(): Promise<ApiRecords<Dataset>> {\n return this.get<ApiRecords<Dataset>>(`${resourceName}`);\n }\n}","import { BaseApi } from \"../base-api\";\nimport { RosettaStoneResponse, SampleRecords } from \"./types\";\n\nconst resourceName = 'rosetta-stone';\n\nexport class RosettaStoneApi extends BaseApi {\n public async getLabelsFromSample(sample: SampleRecords): Promise<RosettaStoneResponse[]> {\n return this.post<SampleRecords, RosettaStoneResponse[]>(`${resourceName}/labels/sample`, sample);\n }\n}","import { BaseApi } from './base-api';\nimport { HealthCheckApi } from './health'\nimport { DatasetApi } from './datasets'\nimport { RosettaStoneApi } from './rosetta-stone'\nimport { applyMixins } from './utils'\n\nclass NarrativeApi extends BaseApi { }\ninterface NarrativeApi extends BaseApi, HealthCheckApi, DatasetApi, RosettaStoneApi { }\napplyMixins(NarrativeApi, [HealthCheckApi, DatasetApi, RosettaStoneApi]);\n\nexport default NarrativeApi"],"names":["derivedCtor","BaseApi","config","apiKey","this","environment","base_api","mande","getBaseUrl","headers","getHeaders","get","endpoint","post","data","_proto","HealthCheckApi","_BaseApi","apply","arguments","_inheritsLoose","prototype","getHealthCheck","Promise","resolve","e","reject","resourceName","getDataset","dataset_id","getDatasets","RosettaStoneApi","getLabelsFromSample","sample","NarrativeApi","DatasetApi","forEach","baseCtor","Object","getOwnPropertyNames","name","defineProperty","getOwnPropertyDescriptor","create"],"mappings":"4dAMA,ICN4BA,iBDgBxB,WAAA,SAAAC,EAAYC,QATJC,YAAM,EAAAC,KACNC,iBAAW,EAAAD,KACXE,cAQJ,EAAAF,KAAKD,OAASD,EAAOC,OACrBC,KAAKC,YAAcH,EAAOG,aAAe,OACzCD,KAAKE,SAAWC,EAAKA,SAAIH,KAAKI,aAAgB,CAC1CC,QAASL,KAAKM,cAEtB,CAAC,IASSC,EAAAA,EAAAA,UAqDT,OArDSA,EAAAA,IAAA,SAAOC,GACb,OAAOR,KAAKE,SAASK,IAAOC,EAChC,EAWUC,EAAAA,KAAA,SAAWD,EAAkBE,GACnC,OAAWV,KAACE,SAASO,KAAQD,EAAUE,EAC3C,EAACC,EAQOP,WAAA,WACJ,OAAQJ,KAAKC,aACT,IAAK,OACD,MACH,4BACD,IAAK,MACD,MAAA,gCAEJ,QACI,OAAOD,KAAKC,YAGxB,IAQQK,WAAA,WACJ,IAAaD,EAA8B,CACvC,eAAgB,oBAOpB,OAJIL,KAAKD,SACLM,EAAuB,cAAC,UAAaL,KAAKD,SAIlD,EAACF,CAAA,CApED,GEXwBe,eAAA,SAAAC,GAAA,SAAAD,IAAA,OAAAC,EAAAC,MAAAd,KAAAe,YAAAf,IAAA,CAGvB,OAHuBgB,EAAAJ,EAAAC,GAAAD,EAAAK,UACXC,eAAc,WAAA,IACN,OAAAC,QAAAC,QAAJpB,KAAKO,IAJL,UAKhB,CAAA,MAAAc,GAAA,OAAAF,QAAAG,OAAAD,EAAA,CAAA,EAAAT,CAAA,CAHuB,CAAQf,GCDlB0B,EAAG,0BAcJC,SAAAA,GAAAA,SAAAA,IAAAA,OAAAA,EAAAA,MAAAA,KAAAA,YAAAA,IAAAA,CAAAA,EAAAA,EAAAA,GAAAA,IAAAA,EAAAA,EAAAA,iBAAAA,EAAAA,oBAAWC,GAAkB,IACtC,uBAAOzB,KAAKO,IAAgBgB,EAAY,IAAIE,GAOnCC,CANZ,MAMYA,GAAAA,OAAAA,QAAAA,OAAAA,EAAAA,CAAAA,EAAAA,EAAAA,2BACT,OAAOP,QAAAC,QAAApB,KAAKO,IAA4BgB,GAAAA,IAC3C,sCAVYC,CAPe3B,GCNH8B,eAAA,SAAAd,GAAA,SAAAc,IAAA,OAAAd,EAAAC,MAAAd,KAAAe,YAAAf,IAAA,QAAAgB,EAAAW,EAAAd,GAAAc,EAAAV,UACZW,oBAAoBC,SAAAA,GAAqB,IAClD,OAAOV,QAAAC,QAAApB,KAAKS,KAA+Cc,8BAA8BM,IAC5F,sCAHwB,CAAQhC,GCClBiC,eAAA,SAAAjB,GAAA,SAAAiB,IAAA,OAAAjB,EAAAC,MAAAd,KAAAe,YAAAf,IAAA,CAAA,OAAAgB,EAAAc,EAAAjB,GAAAiB,CAAA,CAAA,CAAQjC,UJNCD,EIQhBkC,EAAc,CAAClB,EAAgBmB,EAAYJ,GJPtCK,QAAQ,SAACC,GAClBC,OAAOC,oBAAoBF,EAAShB,WAAWe,QAAQ,SAACI,GACpDF,OAAOG,eACHzC,EAAYqB,UACZmB,EACAF,OAAOI,yBAAyBL,EAAShB,UAAWmB,IACpDF,OAAOK,OAAO,MAEtB,EACJ"}
|
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@narrative.io/data-collaboration-sdk-ts",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.m.js",
|
|
6
6
|
"umd:main": "dist/index.umd.js",
|
|
7
7
|
"repository": "github:narrative-io/data-collaboration-sdk-ts",
|
|
8
8
|
"source": "src/index.ts",
|
|
9
|
+
"types": "dist/data-collaboration-sdk-ts.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
"types": "./dist/data-collaboration-sdk-ts.d.ts"
|
|
12
|
+
},
|
|
9
13
|
"description": "",
|
|
10
14
|
"scripts": {
|
|
11
|
-
"build": "rm -rf dist && microbundle
|
|
15
|
+
"build": "rm -rf dist && microbundle --generateTypes true --tsconfig tsconfig.json",
|
|
12
16
|
"dev": "microbundle watch --tsconfig tsconfig.json",
|
|
13
17
|
"test": "vitest run --coverage",
|
|
14
18
|
"push": "npm run build && npm test && npm publish --access public"
|
|
@@ -26,11 +30,11 @@
|
|
|
26
30
|
"eslint-plugin-promise": "^6.1.1",
|
|
27
31
|
"microbundle": "^0.15.1",
|
|
28
32
|
"typescript": "^4.9.5",
|
|
29
|
-
"vitest": "^0.28.4"
|
|
33
|
+
"vitest": "^0.28.4",
|
|
34
|
+
"msw": "^1.0.1"
|
|
30
35
|
},
|
|
31
36
|
"dependencies": {
|
|
32
|
-
"mande": "^2.0.3"
|
|
33
|
-
"msw": "^1.0.1"
|
|
37
|
+
"mande": "^2.0.3"
|
|
34
38
|
},
|
|
35
39
|
"files": [
|
|
36
40
|
"dist"
|
package/dist/src/base-api.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
type Environment = 'dev' | 'prod' | string;
|
|
2
|
-
type Config = {
|
|
3
|
-
apiKey?: string;
|
|
4
|
-
environment?: Environment;
|
|
5
|
-
};
|
|
6
|
-
export declare abstract class BaseApi {
|
|
7
|
-
private apiKey?;
|
|
8
|
-
private environment;
|
|
9
|
-
private base_api;
|
|
10
|
-
constructor(config: Config);
|
|
11
|
-
protected get<T>(endpoint: string): Promise<T>;
|
|
12
|
-
protected post<I, T>(endpoint: string, data: I): Promise<T>;
|
|
13
|
-
private getBaseUrl;
|
|
14
|
-
private getHeaders;
|
|
15
|
-
}
|
|
16
|
-
export {};
|
package/dist/src/index.d.ts
DELETED