@narrative.io/data-collaboration-sdk-ts 0.0.49 → 0.0.51

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.
@@ -1,5 +1,5 @@
1
1
  import { BaseApi } from '../base-api';
2
- import { type CustomerContract, type PaymentMethod } from './types';
2
+ import { type ContractDetails, type CustomerContract, type PaymentMethod, type ContractRateView } from './types';
3
3
  /**
4
4
  * A class for accessing the Contracts API.
5
5
  * @extends BaseApi
@@ -10,7 +10,7 @@ declare class ContractsApi extends BaseApi {
10
10
  *
11
11
  * @returns {Promise<CustomerContract[]>} A promise that resolves with the list of contracts.
12
12
  */
13
- getContracts(): Promise<CustomerContract[]>;
13
+ getContracts(): Promise<ContractDetails[]>;
14
14
  /**
15
15
  * Get a customer contract based on the contract ID
16
16
  *
@@ -18,7 +18,7 @@ declare class ContractsApi extends BaseApi {
18
18
  * @returns Promise that resolves to the customer contract
19
19
  *
20
20
  */
21
- getContract(contractId: string): Promise<CustomerContract>;
21
+ getContract(contractId: string): Promise<ContractDetails>;
22
22
  /**
23
23
  * Update a customer contract's payment method based on the contract ID
24
24
  *
@@ -27,6 +27,13 @@ declare class ContractsApi extends BaseApi {
27
27
  * @returns Promise that resolves to the updated customer contract
28
28
  *
29
29
  */
30
- updatePaymentMethod(contractId: string, paymentMethod: PaymentMethod): Promise<CustomerContract>;
30
+ updatePaymentMethod(contractId: string, paymentMethod: PaymentMethod): Promise<ContractDetails>;
31
+ /**
32
+ * Get the active contract for a company
33
+ *
34
+ * @returns Promise that resolves to the customer contract
35
+ *
36
+ */
37
+ getActiveContract(): Promise<ContractDetails>;
31
38
  }
32
- export { ContractsApi, type CustomerContract, type PaymentMethod };
39
+ export { ContractsApi, type ContractDetails, type CustomerContract, type PaymentMethod, type ContractRateView };
@@ -40,5 +40,14 @@ class ContractsApi extends BaseApi {
40
40
  async updatePaymentMethod(contractId, paymentMethod) {
41
41
  return await this.put(`${resourceName}/${contractId}`, paymentMethod);
42
42
  }
43
+ /**
44
+ * Get the active contract for a company
45
+ *
46
+ * @returns Promise that resolves to the customer contract
47
+ *
48
+ */
49
+ async getActiveContract() {
50
+ return await this.get(`${resourceName}/active`);
51
+ }
43
52
  }
44
53
  export { ContractsApi };
@@ -1,29 +1,48 @@
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;
1
+ export interface ContractDetails {
2
+ contract?: CustomerContract;
3
+ rates?: ContractRateView[];
16
4
  }
17
- interface Revision {
18
- value: number;
5
+ export interface CustomerContract {
6
+ id: string;
7
+ company_id: number;
8
+ payment_method: PaymentMethod;
9
+ internal_notes?: string;
10
+ revision: number;
11
+ revision_notes?: string;
12
+ revision_start: string;
13
+ revision_end?: string;
14
+ updated_by: number;
15
+ created_at: string;
16
+ updated_at: string;
19
17
  }
20
18
  export interface PaymentMethod {
21
19
  type: 'credit_card' | 'invoice';
22
20
  }
23
- interface UserId {
24
- value: string;
21
+ export interface ContractRateView {
22
+ rate?: Rate;
23
+ product?: ProductView;
24
+ start_at?: Date;
25
+ end_at?: Date;
26
+ created_at?: Date;
27
+ updated_at?: Date;
28
+ }
29
+ export interface Rate {
30
+ type: RateType;
31
+ unit_price: UnitPrice;
32
+ }
33
+ export type RateType = 'per_unit' | 'percent_of_gmv';
34
+ export interface UnitPrice {
35
+ value: number;
36
+ expressed_in: string;
37
+ currency?: string;
25
38
  }
26
- interface CompanyId {
27
- value: string;
39
+ export interface ProductView {
40
+ id?: string;
41
+ sku?: string;
42
+ sku_type?: string;
43
+ payable_company_id?: number;
44
+ name?: string;
45
+ unit?: string;
46
+ status?: ProductStatus;
28
47
  }
29
- export {};
48
+ export type ProductStatus = 'active' | 'archived';
package/build/index.d.ts CHANGED
@@ -19,8 +19,9 @@ import { InstallationsApi, type Installation } from './installations';
19
19
  import { NqlApi, type NqlCompileResult, type NqlQuery, type NqlResult } from './nql';
20
20
  import { DataStreamsApi, type DataStream } from './data-streams';
21
21
  import { ForecastApi, type ForecastRequest, type ForecastResponse, type CostForecastRequest, type CostForecastResponse, type JobState } from './forecast';
22
+ import { ContractsApi, type ContractDetails, type CustomerContract, type PaymentMethod, type ContractRateView } from './contracts';
22
23
  declare class NarrativeApi extends BaseApi {
23
24
  }
24
- interface NarrativeApi extends BaseApi, HealthCheckApi, DatasetApi, RosettaStoneApi, AttributeApi, PingApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi {
25
+ interface NarrativeApi extends BaseApi, HealthCheckApi, DatasetApi, RosettaStoneApi, AttributeApi, PingApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi {
25
26
  }
26
- export { NarrativeApi, AttributeApi, HealthCheckApi, DatasetApi, PingApi, ProductsApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, type Resource, 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, type BucketCreationRequest, type UpdateAccessTypeRequest, type NqlQuery, type NqlResult, type NqlCompileResult, type DataStream, type ForecastRequest, type ForecastResponse, type CostForecastRequest, type CostForecastResponse, type JobState };
27
+ export { NarrativeApi, AttributeApi, HealthCheckApi, DatasetApi, PingApi, ProductsApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi, type Resource, 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, type BucketCreationRequest, type UpdateAccessTypeRequest, type NqlQuery, type NqlResult, type NqlCompileResult, type DataStream, type ForecastRequest, type ForecastResponse, type CostForecastRequest, type CostForecastResponse, type JobState, type ContractDetails, type CustomerContract, type PaymentMethod, type ContractRateView };
package/build/index.js CHANGED
@@ -13,7 +13,8 @@ import { InstallationsApi } from './installations';
13
13
  import { NqlApi } from './nql';
14
14
  import { DataStreamsApi } from './data-streams';
15
15
  import { ForecastApi } from './forecast';
16
+ import { ContractsApi } from './contracts';
16
17
  class NarrativeApi extends BaseApi {
17
18
  }
18
- applyMixins(NarrativeApi, [BaseApi, HealthCheckApi, DatasetApi, RosettaStoneApi, AttributeApi, PingApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi]);
19
- export { NarrativeApi, AttributeApi, HealthCheckApi, DatasetApi, PingApi, ProductsApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi };
19
+ applyMixins(NarrativeApi, [BaseApi, HealthCheckApi, DatasetApi, RosettaStoneApi, AttributeApi, PingApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi]);
20
+ export { NarrativeApi, AttributeApi, HealthCheckApi, DatasetApi, PingApi, ProductsApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@narrative.io/data-collaboration-sdk-ts",
3
- "version": "0.0.49",
3
+ "version": "0.0.51",
4
4
  "main": "build/index.js",
5
5
  "repository": "github:narrative-io/data-collaboration-sdk-ts",
6
6
  "source": "src/index.ts",