@flashbacktech/flashbackclient 0.1.27 → 0.1.30

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,9 +1,10 @@
1
1
  import { CreateUnitRequest, CreateUnitResponse, CreateRepoRequest, CreateRepoResponse, StorageUnit, CreateRepoKeyRequest, CreateRepoKeyResponse, GetUnitsResponse, GetReposResponse, GetRepoKeysResponse, UpdateUnitRequest, UpdateUnitResponse, ActionResponse, UpdateRepoRequest, UpdateRepoResponse, UpdateRepoKeyRequest, UpdateRepoKeyResponse, ValidateUnitRequest, ValidateUnitResponse, ValidateRepoUnitsRequest, ValidateRepoUnitsResponse, StorageUnitStatusResponse, GetUnitNodeStatsResponse, GetUnitNodeStatsRequest, CreateBucketRequest, CreateBucketResponse, UpdateBucketRequest, UpdateBucketResponse, ValidateBucketRequest, ValidateBucketResponse, StorageBucket, GetBucketsResponse, StorageBucketStatusResponse, GetBucketNodeStatsRequest, GetBucketNodeStatsResponse, CreateRepoWithBucketsRequest, UpdateRepoWithBucketsRequest, ValidateRepoBucketsRequest, ValidateRepoBucketsResponse } from './types/storage';
2
2
  import { IApiClient, ProviderType } from './interfaces';
3
- import { ActivateResponse, DeactivateResponse, LoginBody, LoginResponse, LogoutResponse, OAuth2ResponseDTO, RefreshTokenErrorResponse, RefreshTokenResponse, RegisterBody, RegisterResponse, ResetPasswordBody } from './types/auth';
3
+ import { ActivateResponse, DeactivateResponse, LoginBody, LoginResponse, LogoutResponse, OAuth2ResponseDTO, RefreshTokenErrorResponse, RefreshTokenResponse, RegisterBody, RegisterResponse, ResetPasswordBody, Web3RegisterBody } from './types/auth';
4
4
  import { StatsQueryParams, StatsResponse, NodeStatsMinuteResponse, NodeStatsDailyResponse, NodeStatsQueryParams, UnitStatsResponse, RepoStatsResponse, NodeStatsDailyQueryParams, BucketStatsResponse, StatsQueryWithBucketParams, NodeStatsQueryWithBucketParams, NodeStatsDailyQueryWithBucketParams } from './types/stats';
5
5
  import { NodeInfo } from './types/bridge';
6
6
  import { QuotaResponse } from './types/quota';
7
+ import { BuySubscriptionRequest, BuySubscriptionResponse, GetSubscriptionsResponse, MySubscriptionResponse, PaymentsListResponse, PaymentsQueryParams, CancelSubscriptionResponse } from './types/subscriptions';
7
8
  interface ErrorResponse {
8
9
  message?: string;
9
10
  [key: string]: any;
@@ -32,10 +33,15 @@ export declare class ApiClient implements IApiClient {
32
33
  * @returns The refreshed token
33
34
  */
34
35
  refreshToken: (refreshToken: string, provider: ProviderType) => Promise<RefreshTokenResponse | RefreshTokenErrorResponse>;
35
- private authenticateWeb3Stellar;
36
36
  private makeRequest;
37
37
  private authenticateGoogle;
38
38
  private authenticateGithub;
39
+ /**
40
+ * Authenticate with a web3 provider
41
+ * @param data - The data to authenticate with
42
+ * @returns The authentication response
43
+ */
44
+ web3Authenticate: (data: Web3RegisterBody) => Promise<any>;
39
45
  private refreshGoogleToken;
40
46
  private refreshGithubToken;
41
47
  private exchangeGoogleCode;
@@ -99,5 +105,10 @@ export declare class ApiClient implements IApiClient {
99
105
  }) => Promise<BucketStatsResponse>;
100
106
  getNodeInfo: () => Promise<NodeInfo[]>;
101
107
  sendFeedbackEmail: (data: FormData) => Promise<ActionResponse>;
108
+ getSubscriptions: () => Promise<GetSubscriptionsResponse>;
109
+ getMySubscription: () => Promise<MySubscriptionResponse>;
110
+ buySubscription: (data: BuySubscriptionRequest) => Promise<BuySubscriptionResponse>;
111
+ getPayments: (params?: PaymentsQueryParams) => Promise<PaymentsListResponse>;
112
+ cancelSubscription: () => Promise<CancelSubscriptionResponse>;
102
113
  }
103
114
  export {};
@@ -33,7 +33,7 @@ class ApiClient {
33
33
  case interfaces_1.ProviderType.GITHUB:
34
34
  return this.authenticateGithub(token);
35
35
  case interfaces_1.ProviderType.WEB3_STELLAR:
36
- return this.authenticateWeb3Stellar(token);
36
+ throw new Error('Call web3Authenticate for web3 authentication');
37
37
  case interfaces_1.ProviderType.LOCAL:
38
38
  throw new Error('Call userLogin for local authentication');
39
39
  default:
@@ -76,9 +76,6 @@ class ApiClient {
76
76
  throw new Error(`Unsupported provider: ${provider}`);
77
77
  }
78
78
  };
79
- this.authenticateWeb3Stellar = async (token) => {
80
- throw new Error('Not implemented');
81
- };
82
79
  this.makeRequest = async (path, method, data) => {
83
80
  const isFormData = data instanceof FormData;
84
81
  const options = {
@@ -136,6 +133,14 @@ class ApiClient {
136
133
  this.setAuthToken(code);
137
134
  return this.makeRequest('auth/github', 'POST', { code });
138
135
  };
136
+ /**
137
+ * Authenticate with a web3 provider
138
+ * @param data - The data to authenticate with
139
+ * @returns The authentication response
140
+ */
141
+ this.web3Authenticate = async (data) => {
142
+ return this.makeRequest('auth/web3', 'POST', data);
143
+ };
139
144
  this.refreshGoogleToken = async (refreshToken) => {
140
145
  return this.makeRequest('auth/google/refresh', 'POST', {
141
146
  refresh_token: refreshToken,
@@ -276,6 +281,29 @@ class ApiClient {
276
281
  this.sendFeedbackEmail = async (data) => {
277
282
  return this.makeRequest('email/feedback', 'POST', data);
278
283
  };
284
+ ////// Subscriptions API
285
+ this.getSubscriptions = async () => {
286
+ return this.makeRequest('subscriptions', 'GET', null);
287
+ };
288
+ this.getMySubscription = async () => {
289
+ return this.makeRequest('subscriptions/my', 'GET', null);
290
+ };
291
+ this.buySubscription = async (data) => {
292
+ return this.makeRequest('subscriptions/buy', 'POST', data);
293
+ };
294
+ this.getPayments = async (params) => {
295
+ const queryParams = new URLSearchParams();
296
+ if (params?.startDate) {
297
+ queryParams.append('startDate', params.startDate);
298
+ }
299
+ if (params?.endDate) {
300
+ queryParams.append('endDate', params.endDate);
301
+ }
302
+ return this.makeRequest(`subscriptions/payments${queryParams.toString() ? `?${queryParams.toString()}` : ''}`, 'GET', null);
303
+ };
304
+ this.cancelSubscription = async () => {
305
+ return this.makeRequest('subscriptions/cancel', 'POST', null);
306
+ };
279
307
  this.baseURL = baseURL;
280
308
  this.headers = {};
281
309
  this.debug = false;
@@ -349,7 +377,7 @@ class ApiClient {
349
377
  else if ('bucketId' in params && params.bucketId.length > 0) {
350
378
  queryParams.append('bucketId', params.bucketId.join(','));
351
379
  }
352
- const response = await this.makeRequest(`stats/nodes/minute?${queryParams.toString() ? `?${queryParams.toString()}` : ''}`, 'GET', null);
380
+ const response = await this.makeRequest(`stats/nodes/minute${queryParams.toString() ? `?${queryParams.toString()}` : ''}`, 'GET', null);
353
381
  // Process the response to convert lastUpdated strings to Date objects
354
382
  const processedData = response.data.map((item) => ({
355
383
  ...item,
@@ -6,4 +6,5 @@ import * as ApiInterfaces from './interfaces';
6
6
  import * as BridgeTypes from './types/bridge';
7
7
  import * as EmailTypes from './types/email';
8
8
  import * as QuotaTypes from './types/quota';
9
- export { ApiClient, ApiTypes, AuthTypes, StatsTypes, ApiInterfaces, HttpError, BridgeTypes, EmailTypes, QuotaTypes };
9
+ import * as SubscriptionTypes from './types/subscriptions';
10
+ export { ApiClient, ApiTypes, AuthTypes, StatsTypes, ApiInterfaces, HttpError, BridgeTypes, EmailTypes, QuotaTypes, SubscriptionTypes };
package/dist/api/index.js CHANGED
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.QuotaTypes = exports.EmailTypes = exports.BridgeTypes = exports.HttpError = exports.ApiInterfaces = exports.StatsTypes = exports.AuthTypes = exports.ApiTypes = exports.ApiClient = void 0;
36
+ exports.SubscriptionTypes = exports.QuotaTypes = exports.EmailTypes = exports.BridgeTypes = exports.HttpError = exports.ApiInterfaces = exports.StatsTypes = exports.AuthTypes = exports.ApiTypes = exports.ApiClient = void 0;
37
37
  const client_1 = require("./client");
38
38
  Object.defineProperty(exports, "ApiClient", { enumerable: true, get: function () { return client_1.ApiClient; } });
39
39
  Object.defineProperty(exports, "HttpError", { enumerable: true, get: function () { return client_1.HttpError; } });
@@ -51,3 +51,5 @@ const EmailTypes = __importStar(require("./types/email"));
51
51
  exports.EmailTypes = EmailTypes;
52
52
  const QuotaTypes = __importStar(require("./types/quota"));
53
53
  exports.QuotaTypes = QuotaTypes;
54
+ const SubscriptionTypes = __importStar(require("./types/subscriptions"));
55
+ exports.SubscriptionTypes = SubscriptionTypes;
@@ -1,6 +1,7 @@
1
1
  import { StorageUnit, CreateUnitRequest, CreateUnitResponse, CreateRepoRequest, CreateRepoResponse, CreateRepoKeyRequest, CreateRepoKeyResponse, GetUnitsResponse, GetReposResponse, GetRepoKeysResponse, UpdateUnitRequest, UpdateUnitResponse, ActionResponse, UpdateRepoResponse, UpdateRepoRequest, UpdateRepoKeyRequest, UpdateRepoKeyResponse, ValidateUnitRequest, ValidateUnitResponse, ValidateRepoUnitsRequest, ValidateRepoUnitsResponse, GetUnitNodeStatsRequest, GetUnitNodeStatsResponse } from './types/storage';
2
2
  import { RegisterBody, LoginBody, RegisterResponse, LoginResponse, LogoutResponse, ActivateResponse, DeactivateResponse, RefreshTokenResponse, RefreshTokenErrorResponse } from './types/auth';
3
3
  import { StatsQueryParams, StatsResponse, NodeStatsMinuteResponse, NodeStatsDailyResponse, NodeStatsQueryParams } from './types/stats';
4
+ import { BuySubscriptionRequest, BuySubscriptionResponse, GetSubscriptionsResponse, MySubscriptionResponse, PaymentsListResponse, PaymentsQueryParams, CancelSubscriptionResponse } from './types/subscriptions';
4
5
  export declare enum ProviderType {
5
6
  GOOGLE = "GOOGLE",
6
7
  GITHUB = "GITHUB",
@@ -36,4 +37,9 @@ export interface IApiClient {
36
37
  getMinuteStats(params: StatsQueryParams): Promise<StatsResponse>;
37
38
  getNodeStatsMinute(params?: NodeStatsQueryParams): Promise<NodeStatsMinuteResponse>;
38
39
  getNodeStatsDaily(params?: NodeStatsQueryParams): Promise<NodeStatsDailyResponse>;
40
+ getSubscriptions(): Promise<GetSubscriptionsResponse>;
41
+ getMySubscription(): Promise<MySubscriptionResponse>;
42
+ buySubscription(data: BuySubscriptionRequest): Promise<BuySubscriptionResponse>;
43
+ getPayments(params?: PaymentsQueryParams): Promise<PaymentsListResponse>;
44
+ cancelSubscription(): Promise<CancelSubscriptionResponse>;
39
45
  }
@@ -35,6 +35,12 @@ export interface JwtPayload {
35
35
  iat?: number;
36
36
  exp?: number;
37
37
  }
38
+ export interface Web3RegisterBody {
39
+ address: string;
40
+ network: string;
41
+ signature: string;
42
+ nonce: string;
43
+ }
38
44
  export interface RegisterBody {
39
45
  email: string;
40
46
  password: string;
@@ -0,0 +1,65 @@
1
+ export interface SubscriptionPeriodResponse {
2
+ id: string;
3
+ subscriptionId: string;
4
+ periodType: string;
5
+ price: number;
6
+ }
7
+ export interface SubscriptionResponse {
8
+ id: string;
9
+ name: string;
10
+ description: string;
11
+ periods: SubscriptionPeriodResponse[];
12
+ }
13
+ export interface BuySubscriptionRequest {
14
+ subscriptionPeriodId: string;
15
+ }
16
+ export interface BuySubscriptionResponse {
17
+ success: boolean;
18
+ clientSecret?: string;
19
+ sessionId?: string;
20
+ message?: string;
21
+ error_code?: string;
22
+ }
23
+ export interface OrgSubscriptionResponse {
24
+ id: string;
25
+ name: string;
26
+ description: string;
27
+ periodId: string;
28
+ periodType: string;
29
+ price: number;
30
+ dateFrom: string;
31
+ dateTo: string | null;
32
+ status: string;
33
+ autoRenew: boolean;
34
+ }
35
+ export interface MySubscriptionResponse {
36
+ success: boolean;
37
+ data: OrgSubscriptionResponse | null;
38
+ message?: string;
39
+ }
40
+ export interface GetSubscriptionsResponse {
41
+ success: boolean;
42
+ data: SubscriptionResponse[];
43
+ }
44
+ export interface PaymentResponse {
45
+ id: string;
46
+ amount: number;
47
+ currency: string;
48
+ status: string;
49
+ timestamp: string;
50
+ }
51
+ export interface PaymentsListResponse {
52
+ success: boolean;
53
+ data?: PaymentResponse[];
54
+ message?: string;
55
+ error_code?: string;
56
+ }
57
+ export interface PaymentsQueryParams {
58
+ startDate?: string;
59
+ endDate?: string;
60
+ }
61
+ export interface CancelSubscriptionResponse {
62
+ success: boolean;
63
+ message?: string;
64
+ error_code?: string;
65
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flashbacktech/flashbackclient",
3
- "version": "0.1.27",
3
+ "version": "0.1.30",
4
4
  "type": "commonjs",
5
5
  "publishConfig": {
6
6
  "access": "public"