@narrative.io/data-collaboration-sdk-ts 0.0.77 → 0.0.80

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/README.md ADDED
@@ -0,0 +1,18 @@
1
+ # SDK
2
+
3
+ ## Make a release
4
+
5
+ To make a new release of the SDK, create a branch, make your changes, create a commit with a message following this
6
+ format: `chore(main): release x.y.z` where x.y.z is the release number that you want. You can calculate it like this:
7
+
8
+ ```bash
9
+ VERSION=$(cat package.json | jq -r .version); \
10
+ PATCH=$(expr $(echo $VERSION|cut -f3 -d.) + 1); \
11
+ NEW_VERSION=$(printf "$(echo $VERSION | cut -f1,2 -d.).$PATCH\n"); \
12
+ echo $NEW_VERSION | pbcopy; \
13
+ echo "The new VERSION=${NEW_VERSION} is in your clipboard."
14
+ ```
15
+
16
+ Push your changes to the branch, merge it to the `main` branch. Once the merge is completed (i.e., github actions
17
+ completed) a new release pull request will be available on the github project. Merge the new pull request and the
18
+ github actions will publish the new version of the SKD for you.
@@ -1,5 +1,5 @@
1
1
  import { BaseApi } from '../base-api';
2
- import { type LoginRequest, type LoginResponse, type RegisterRequest, type RegisterResponse, type LoggedInUser, type StytchToken, type ApiToken, type UserRole } from './types';
2
+ import { type LoginRequest, type LoginResponse, type RegisterRequest, type RegisterResponse, type LoggedInUser, type StytchToken, type ApiToken, type UserRole, type RegistrationStatus, type RegistrationStatusRequest } from './types';
3
3
  /**
4
4
  * A class for accessing the Authentication API
5
5
  * @extends BaseApi
@@ -19,5 +19,12 @@ declare class AuthenticationApi extends BaseApi {
19
19
  * @returns {Promise<RegisterResponse>} - A promise that resolves to the register response.
20
20
  */
21
21
  register(registerRequest: RegisterRequest): Promise<RegisterResponse>;
22
+ /**
23
+ * Checks the resgistration status of a user.
24
+ *
25
+ * @param {RegistrationStatusRequest} statusRewquest - request payload of user login for whom to check status.
26
+ * @returns {Promise<RegistrationStatus>} - A promise that resolves to the response.
27
+ */
28
+ checkRegistrationStatus(statusRequest: RegistrationStatusRequest): Promise<RegistrationStatus>;
22
29
  }
23
- export { type LoginRequest, type LoginResponse, type RegisterRequest, type RegisterResponse, type LoggedInUser, type StytchToken, type ApiToken, type UserRole, AuthenticationApi };
30
+ export { type LoginRequest, type LoginResponse, type RegisterRequest, type RegisterResponse, type LoggedInUser, type StytchToken, type ApiToken, type UserRole, type RegistrationStatus, type RegistrationStatusRequest, AuthenticationApi };
@@ -29,5 +29,14 @@ class AuthenticationApi extends BaseApi {
29
29
  async register(registerRequest) {
30
30
  return await this.post(`${resourceName}/register`, registerRequest);
31
31
  }
32
+ /**
33
+ * Checks the resgistration status of a user.
34
+ *
35
+ * @param {RegistrationStatusRequest} statusRewquest - request payload of user login for whom to check status.
36
+ * @returns {Promise<RegistrationStatus>} - A promise that resolves to the response.
37
+ */
38
+ async checkRegistrationStatus(statusRequest) {
39
+ return await this.post(`${resourceName}/registration-status`, statusRequest);
40
+ }
32
41
  }
33
42
  export { AuthenticationApi };
@@ -43,3 +43,7 @@ export interface StytchToken {
43
43
  token_type: 'magiclinks' | 'oauth';
44
44
  }
45
45
  export type UserRole = 'global_admin' | 'partner_admin' | 'partner_user';
46
+ export interface RegistrationStatusRequest {
47
+ stytch_token: StytchToken;
48
+ }
49
+ export type RegistrationStatus = 'complete' | 'pending';
@@ -1,16 +1,21 @@
1
1
  import { BaseApi } from '../base-api';
2
2
  import { type ApiRecords } from '../types';
3
- import { type CompanyInfo } from './types';
3
+ import { type CompanyInfo, type WhoAmI } from './types';
4
4
  /**
5
5
  * A class for accessing the Company Info API
6
6
  * @extends BaseApi
7
7
  */
8
8
  declare class CompanyInfoApi extends BaseApi {
9
9
  companyId: () => Promise<number>;
10
+ /**
11
+ * Get the logged in company id
12
+ * @returns {Promise<WhoAmI>}
13
+ */
14
+ whoami(): Promise<WhoAmI>;
10
15
  /**
11
16
  * Get a list of all providers in the Data Streams Market
12
17
  * @returns {Promise<ApiRecords<CompanyInfo[]>>} - Promise resolving to an array of CompanyInfo records
13
18
  */
14
19
  getAllProvidersCompanyInfo(): Promise<ApiRecords<CompanyInfo>>;
15
20
  }
16
- export { type CompanyInfo, CompanyInfoApi };
21
+ export { type CompanyInfo, type WhoAmI, CompanyInfoApi };
@@ -14,6 +14,13 @@ class CompanyInfoApi extends BaseApi {
14
14
  companyId = async () => {
15
15
  return (await this.get(`${resourceName}/whoami`)).id;
16
16
  };
17
+ /**
18
+ * Get the logged in company id
19
+ * @returns {Promise<WhoAmI>}
20
+ */
21
+ async whoami() {
22
+ return await this.get(`${resourceName}/whoami?with_user_id=true`);
23
+ }
17
24
  /**
18
25
  * Get a list of all providers in the Data Streams Market
19
26
  * @returns {Promise<ApiRecords<CompanyInfo[]>>} - Promise resolving to an array of CompanyInfo records
@@ -11,3 +11,7 @@ export interface CompanyInfo {
11
11
  contact: string;
12
12
  created_at: string;
13
13
  }
14
+ export interface WhoAmI {
15
+ id: number;
16
+ userId?: number;
17
+ }
package/build/index.d.ts CHANGED
@@ -22,11 +22,11 @@ import { ForecastApi, type ForecastRequest, type ForecastResponse, type CostFore
22
22
  import { ContractsApi, type ContractDetails, type CustomerContract, type PaymentMethod, type ContractRateView } from './contracts';
23
23
  import { getNqlObject, buildNql } from './nql/NQLParser';
24
24
  import { convertNqlObjectToForecastBody } from './nql/DataRulesConverter';
25
- import { AuthenticationApi, type LoginRequest, type LoginResponse, type RegisterRequest, type RegisterResponse, type LoggedInUser, type StytchToken, type ApiToken, type UserRole } from './authentication';
25
+ import { AuthenticationApi, type LoginRequest, type LoginResponse, type RegisterRequest, type RegisterResponse, type LoggedInUser, type StytchToken, type ApiToken, type UserRole, type RegistrationStatus, type RegistrationStatusRequest } from './authentication';
26
26
  import { AppsApi, type App } from './apps';
27
27
  import type { ForecastBody } from './nql/types';
28
28
  declare class NarrativeApi extends BaseApi {
29
29
  }
30
30
  interface NarrativeApi extends BaseApi, HealthCheckApi, DatasetApi, RosettaStoneApi, AttributeApi, PingApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi, AuthenticationApi {
31
31
  }
32
- export { NarrativeApi, AttributeApi, HealthCheckApi, DatasetApi, PingApi, ProductsApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi, AuthenticationApi, AppsApi, type App, type Resource, type UploadsResponse, type PingStatus, type Attribute, type RefAttribute, type SubAttribute, 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 Nql, type NqlField, type NqlResult, type NqlQueryInput, type NqlCompileResult, type NqlExpression, type NqlWhere, type NqlFilterExpression, type NqlBooleanExpression, type NqlFilterBinaryExpression, type NqlFilterUnaryExpression, type DataStream, type ForecastRequest, type ForecastResponse, type CostForecastRequest, type CostForecastResponse, type JobState, type ContractDetails, type CustomerContract, type PaymentMethod, type ContractRateView, type LoginRequest, type LoginResponse, type RegisterRequest, type RegisterResponse, type LoggedInUser, type StytchToken, type ApiToken, type UserRole, getNqlObject, buildNql, convertNqlObjectToForecastBody, type ForecastBody };
32
+ export { NarrativeApi, AttributeApi, HealthCheckApi, DatasetApi, PingApi, ProductsApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi, AuthenticationApi, AppsApi, type App, type Resource, type UploadsResponse, type PingStatus, type Attribute, type RefAttribute, type SubAttribute, 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 Nql, type NqlField, type NqlResult, type NqlQueryInput, type NqlCompileResult, type NqlExpression, type NqlWhere, type NqlFilterExpression, type NqlBooleanExpression, type NqlFilterBinaryExpression, type NqlFilterUnaryExpression, type DataStream, type ForecastRequest, type ForecastResponse, type CostForecastRequest, type CostForecastResponse, type JobState, type ContractDetails, type CustomerContract, type PaymentMethod, type ContractRateView, type LoginRequest, type LoginResponse, type RegisterRequest, type RegisterResponse, type LoggedInUser, type StytchToken, type ApiToken, type UserRole, type RegistrationStatus, type RegistrationStatusRequest, getNqlObject, buildNql, convertNqlObjectToForecastBody, type ForecastBody };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@narrative.io/data-collaboration-sdk-ts",
3
- "version": "0.0.77",
3
+ "version": "0.0.80",
4
4
  "main": "build/index.js",
5
5
  "repository": "github:narrative-io/data-collaboration-sdk-ts",
6
6
  "source": "src/index.ts",