@narrative.io/data-collaboration-sdk-ts 0.0.16 → 0.0.19

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,7 @@ import { type Attribute } from './types';
5
5
  * A class for accessing the Attribute API.
6
6
  * @extends BaseApi
7
7
  */
8
- export declare class AttributeApi extends BaseApi {
8
+ declare class AttributeApi extends BaseApi {
9
9
  /**
10
10
  * Gets a list of attributes from the API.
11
11
  *
@@ -34,3 +34,4 @@ export declare class AttributeApi extends BaseApi {
34
34
  */
35
35
  createAttribute(data: Attribute): Promise<Attribute>;
36
36
  }
37
+ export { AttributeApi, type Attribute };
@@ -10,7 +10,7 @@ const resourceName = 'attributes';
10
10
  * A class for accessing the Attribute API.
11
11
  * @extends BaseApi
12
12
  */
13
- export class AttributeApi extends BaseApi {
13
+ class AttributeApi extends BaseApi {
14
14
  /**
15
15
  * Gets a list of attributes from the API.
16
16
  *
@@ -47,3 +47,4 @@ export class AttributeApi extends BaseApi {
47
47
  return await this.post(`${resourceName}`, data);
48
48
  }
49
49
  }
50
+ export { AttributeApi };
@@ -6,12 +6,14 @@ export interface Attribute {
6
6
  type: string;
7
7
  enum?: string[] | number[];
8
8
  validations?: string[];
9
+ is_join_key?: boolean;
9
10
  properties?: Record<string, {
10
11
  type: string;
11
12
  description?: string;
12
13
  validations?: string[];
13
14
  enum?: string[];
14
15
  items?: unknown;
16
+ is_join_key?: boolean;
15
17
  }>;
16
18
  required?: string[];
17
19
  }
@@ -38,6 +38,14 @@ export declare abstract class BaseApi {
38
38
  * @protected
39
39
  */
40
40
  protected delete(endpoint: string): Promise<void>;
41
+ /**
42
+ * Makes a PUT request to the specified endpoint with the given data.
43
+ *
44
+ * @param endpoint - The endpoint to make the request to.
45
+ * @param data - The data to send in the request body.
46
+ * @returns A Promise that resolves to the data returned by the server.
47
+ */
48
+ protected put<I, T>(endpoint: string, data: I): Promise<T>;
41
49
  /**
42
50
  * Returns the base URL for the API based on the environment.
43
51
  *
package/build/base-api.js CHANGED
@@ -50,6 +50,16 @@ export class BaseApi {
50
50
  async delete(endpoint) {
51
51
  await this.base_api.delete(endpoint);
52
52
  }
53
+ /**
54
+ * Makes a PUT request to the specified endpoint with the given data.
55
+ *
56
+ * @param endpoint - The endpoint to make the request to.
57
+ * @param data - The data to send in the request body.
58
+ * @returns A Promise that resolves to the data returned by the server.
59
+ */
60
+ async put(endpoint, data) {
61
+ return await this.base_api.put(endpoint, data);
62
+ }
53
63
  /**
54
64
  * Returns the base URL for the API based on the environment.
55
65
  *
@@ -0,0 +1,18 @@
1
+ import { BaseApi } from '../base-api';
2
+ import { type CompanyInfo } from './types';
3
+ /**
4
+ * A class for accessing the Contracts API.
5
+ * @extends BaseApi
6
+ */
7
+ declare class CompanyInfoApi extends BaseApi {
8
+ private readonly companyId;
9
+ /**
10
+ * Get a customer contract based on the contract ID
11
+ *
12
+ * @param contractId - ID of the customer contract
13
+ * @returns Promise that resolves to the customer contract
14
+ *
15
+ */
16
+ getCompanyInfo(contractId: string): Promise<CompanyInfo>;
17
+ }
18
+ export { type CompanyInfo, CompanyInfoApi };
@@ -0,0 +1,29 @@
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
+ */
8
+ const resourceName = 'company-info';
9
+ /**
10
+ * A class for accessing the Contracts API.
11
+ * @extends BaseApi
12
+ */
13
+ class CompanyInfoApi extends BaseApi {
14
+ companyId = async () => {
15
+ return await this.get(`${resourceName}/whoami`);
16
+ };
17
+ /**
18
+ * Get a customer contract based on the contract ID
19
+ *
20
+ * @param contractId - ID of the customer contract
21
+ * @returns Promise that resolves to the customer contract
22
+ *
23
+ */
24
+ async getCompanyInfo(contractId) {
25
+ const companyId = await this.companyId();
26
+ return await this.get(`${resourceName}/${companyId}`);
27
+ }
28
+ }
29
+ export { CompanyInfoApi };
@@ -0,0 +1,13 @@
1
+ export interface CompanyInfo {
2
+ id: number;
3
+ name: string;
4
+ short_description: string;
5
+ long_description: string;
6
+ company_type: string;
7
+ image_url: string;
8
+ location: string;
9
+ size: string;
10
+ website: string;
11
+ contact: string;
12
+ created_at: string;
13
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,32 @@
1
+ import { BaseApi } from '../base-api';
2
+ import { type CustomerContract, type PaymentMethod } from './types';
3
+ /**
4
+ * A class for accessing the Contracts API.
5
+ * @extends BaseApi
6
+ */
7
+ declare class ContractsApi extends BaseApi {
8
+ /**
9
+ * Gets a list of contracts from the API.
10
+ *
11
+ * @returns {Promise<CustomerContract[]>} A promise that resolves with the list of contracts.
12
+ */
13
+ getContracts(): Promise<CustomerContract[]>;
14
+ /**
15
+ * Get a customer contract based on the contract ID
16
+ *
17
+ * @param contractId - ID of the customer contract
18
+ * @returns Promise that resolves to the customer contract
19
+ *
20
+ */
21
+ getContract(contractId: string): Promise<CustomerContract>;
22
+ /**
23
+ * Update a customer contract's payment method based on the contract ID
24
+ *
25
+ * @param contractId - ID of the customer contract
26
+ * @param paymentMethod - the updated payment method
27
+ * @returns Promise that resolves to the updated customer contract
28
+ *
29
+ */
30
+ updatePaymentMethod(contractId: string, paymentMethod: PaymentMethod): Promise<CustomerContract>;
31
+ }
32
+ export { ContractsApi, type CustomerContract, type PaymentMethod };
@@ -0,0 +1,44 @@
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
+ */
8
+ const resourceName = 'contracts';
9
+ /**
10
+ * A class for accessing the Contracts API.
11
+ * @extends BaseApi
12
+ */
13
+ class ContractsApi extends BaseApi {
14
+ /**
15
+ * Gets a list of contracts from the API.
16
+ *
17
+ * @returns {Promise<CustomerContract[]>} A promise that resolves with the list of contracts.
18
+ */
19
+ async getContracts() {
20
+ return await this.get(resourceName);
21
+ }
22
+ /**
23
+ * Get a customer contract based on the contract ID
24
+ *
25
+ * @param contractId - ID of the customer contract
26
+ * @returns Promise that resolves to the customer contract
27
+ *
28
+ */
29
+ async getContract(contractId) {
30
+ return await this.get(`${resourceName}/${contractId}`);
31
+ }
32
+ /**
33
+ * Update a customer contract's payment method based on the contract ID
34
+ *
35
+ * @param contractId - ID of the customer contract
36
+ * @param paymentMethod - the updated payment method
37
+ * @returns Promise that resolves to the updated customer contract
38
+ *
39
+ */
40
+ async updatePaymentMethod(contractId, paymentMethod) {
41
+ return await this.put(`${resourceName}/${contractId}`, paymentMethod);
42
+ }
43
+ }
44
+ export { ContractsApi };
@@ -0,0 +1,29 @@
1
+ export interface CustomerContract {
2
+ id: CustomerContractId;
3
+ payableCompanyId: CompanyId;
4
+ paymentMethod: PaymentMethod;
5
+ internalNotes?: string;
6
+ revision: Revision;
7
+ revisionNotes?: string;
8
+ revisionStart: string;
9
+ revisionEnd?: string;
10
+ updatedBy: UserId;
11
+ createdAt: string;
12
+ updatedAt: string;
13
+ }
14
+ interface CustomerContractId {
15
+ value: string;
16
+ }
17
+ interface Revision {
18
+ value: number;
19
+ }
20
+ export interface PaymentMethod {
21
+ type: 'credit_card' | 'invoice';
22
+ }
23
+ interface UserId {
24
+ value: string;
25
+ }
26
+ interface CompanyId {
27
+ value: string;
28
+ }
29
+ export {};
@@ -0,0 +1 @@
1
+ export {};
package/build/index.d.ts CHANGED
@@ -2,14 +2,18 @@ import { BaseApi } from './base-api';
2
2
  import { DatasetApi } from './datasets';
3
3
  import { HealthCheckApi } from './health';
4
4
  import { RosettaStoneApi } from './rosetta-stone';
5
- import { type Environment, type Config, type ApiRecords } from './types';
5
+ import { type Environment, type Config, type ApiRecords, type MonetaryAmount } from './types';
6
6
  import { type DatasetTableSummaryAPIResponse, type Dataset, type DatasetTableSummary } 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';
10
10
  import { type Attribute } from './attributes/types';
11
+ import { PingApi } from './ping';
12
+ import { type PingStatus } from './ping/types';
13
+ import { type Product, ProductsApi } from './products';
14
+ import { CompanyInfoApi, type CompanyInfo } from './company-info';
11
15
  declare class NarrativeApi extends BaseApi {
12
16
  }
13
- interface NarrativeApi extends BaseApi, HealthCheckApi, DatasetApi, RosettaStoneApi, AttributeApi {
17
+ interface NarrativeApi extends BaseApi, HealthCheckApi, DatasetApi, RosettaStoneApi, AttributeApi, PingApi, CompanyInfoApi {
14
18
  }
15
- export { NarrativeApi, AttributeApi, HealthCheckApi, DatasetApi, type Attribute, type Environment, type Config, type ApiRecords, type Dataset, type HealthCheckResult, type SampleRecords, type DatasetTableSummary, type DatasetTableSummaryAPIResponse };
19
+ export { NarrativeApi, AttributeApi, HealthCheckApi, DatasetApi, PingApi, ProductsApi, CompanyInfoApi, 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 };
package/build/index.js CHANGED
@@ -4,7 +4,10 @@ import { HealthCheckApi } from './health';
4
4
  import { RosettaStoneApi } from './rosetta-stone';
5
5
  import { applyMixins } from './utils';
6
6
  import { AttributeApi } from './attributes';
7
+ import { PingApi } from './ping';
8
+ import { ProductsApi } from './products';
9
+ import { CompanyInfoApi } from './company-info';
7
10
  class NarrativeApi extends BaseApi {
8
11
  }
9
- applyMixins(NarrativeApi, [BaseApi, HealthCheckApi, DatasetApi, RosettaStoneApi, AttributeApi]);
10
- export { NarrativeApi, AttributeApi, HealthCheckApi, DatasetApi };
12
+ applyMixins(NarrativeApi, [BaseApi, HealthCheckApi, DatasetApi, RosettaStoneApi, AttributeApi, PingApi, CompanyInfoApi]);
13
+ export { NarrativeApi, AttributeApi, HealthCheckApi, DatasetApi, PingApi, ProductsApi, CompanyInfoApi };
@@ -0,0 +1,14 @@
1
+ import { BaseApi } from '../base-api';
2
+ import { type PingStatus } from './types';
3
+ /**
4
+ * A class for accessing the Ping API.
5
+ * @extends BaseApi
6
+ */
7
+ export declare class PingApi extends BaseApi {
8
+ /**
9
+ * Gets the result of a ping from the API.
10
+ *
11
+ * @returns {Promise<HealthCheckResult>} A promise that resolves with the result of the ping.
12
+ */
13
+ ping(): Promise<PingStatus>;
14
+ }
@@ -0,0 +1,22 @@
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
+ */
8
+ const resourceName = 'ping';
9
+ /**
10
+ * A class for accessing the Ping API.
11
+ * @extends BaseApi
12
+ */
13
+ export class PingApi extends BaseApi {
14
+ /**
15
+ * Gets the result of a ping from the API.
16
+ *
17
+ * @returns {Promise<HealthCheckResult>} A promise that resolves with the result of the ping.
18
+ */
19
+ async ping() {
20
+ return await this.get(resourceName);
21
+ }
22
+ }
@@ -0,0 +1 @@
1
+ export type PingStatus = 'healthy' | unknown;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,15 @@
1
+ import { BaseApi } from '../base-api';
2
+ import { type Product } from './types';
3
+ /**
4
+ * A class for accessing the Products API.
5
+ * @extends BaseApi
6
+ */
7
+ declare class ProductsApi extends BaseApi {
8
+ /**
9
+ * Gets the result of a product from the API.
10
+ *
11
+ * @returns {Promise<Product[]>} A promise that resolves with the products.
12
+ */
13
+ getHealthCheck(): Promise<Product[]>;
14
+ }
15
+ export { ProductsApi, type Product };
@@ -0,0 +1,23 @@
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
+ */
8
+ const resourceName = 'admin/products';
9
+ /**
10
+ * A class for accessing the Products API.
11
+ * @extends BaseApi
12
+ */
13
+ class ProductsApi extends BaseApi {
14
+ /**
15
+ * Gets the result of a product from the API.
16
+ *
17
+ * @returns {Promise<Product[]>} A promise that resolves with the products.
18
+ */
19
+ async getHealthCheck() {
20
+ return await this.get(resourceName);
21
+ }
22
+ }
23
+ export { ProductsApi };
@@ -0,0 +1,34 @@
1
+ type ProductId = string;
2
+ type ProductSkuType = 'processing' | 'storage' | 'transfer';
3
+ type ProductCloudType = 'aws' | 'gcp' | 'azure';
4
+ type ProductUnitType = 'bytes' | 'average-bytes-per-month';
5
+ type ProductStatus = 'active' | 'archived';
6
+ interface ProductRate {
7
+ type: string;
8
+ unitPrice: {
9
+ type: string;
10
+ currency: string;
11
+ priceInMicroCents: number;
12
+ };
13
+ }
14
+ export interface ProductUnitPrice {
15
+ type: string;
16
+ currency: string;
17
+ priceInMicroCents: number;
18
+ }
19
+ export interface Product {
20
+ id: ProductId;
21
+ sku: string;
22
+ skuType: ProductSkuType;
23
+ payableCompanyId: number;
24
+ name: string;
25
+ description?: string | null;
26
+ cloud?: ProductCloudType | null;
27
+ region?: string | null;
28
+ unit: ProductUnitType;
29
+ defaultRate: ProductRate;
30
+ status: ProductStatus;
31
+ createdAt: string;
32
+ updatedAt: string;
33
+ }
34
+ export {};
@@ -0,0 +1 @@
1
+ export {};
package/build/types.d.ts CHANGED
@@ -18,3 +18,14 @@ export interface Config {
18
18
  export interface ApiRecords<T> {
19
19
  records: T[];
20
20
  }
21
+ export interface MonetaryAmount {
22
+ value: {
23
+ amount: number;
24
+ currency: {
25
+ code: CurrencyCode;
26
+ };
27
+ };
28
+ microCentsUsd: number;
29
+ }
30
+ type CurrencyCode = 'USD';
31
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@narrative.io/data-collaboration-sdk-ts",
3
- "version": "0.0.16",
3
+ "version": "0.0.19",
4
4
  "main": "build/index.js",
5
5
  "repository": "github:narrative-io/data-collaboration-sdk-ts",
6
6
  "source": "src/index.ts",
@@ -9,7 +9,7 @@
9
9
  "scripts": {
10
10
  "build": "tsc",
11
11
  "lint": "npx eslint . --fix",
12
- "prepare": "npm run build",
12
+ "prepare": "npx eslint . --fix && npm run build",
13
13
  "prepublishOnly": "npm test && npm run lint",
14
14
  "preversion": "npm run lint",
15
15
  "version": "npm run && git add -A src",