@flashbacktech/flashbackclient 0.1.26 → 0.1.28

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.
@@ -4,6 +4,7 @@ import { ActivateResponse, DeactivateResponse, LoginBody, LoginResponse, LogoutR
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;
@@ -99,5 +100,10 @@ export declare class ApiClient implements IApiClient {
99
100
  }) => Promise<BucketStatsResponse>;
100
101
  getNodeInfo: () => Promise<NodeInfo[]>;
101
102
  sendFeedbackEmail: (data: FormData) => Promise<ActionResponse>;
103
+ getSubscriptions: () => Promise<GetSubscriptionsResponse>;
104
+ getMySubscription: () => Promise<MySubscriptionResponse>;
105
+ buySubscription: (data: BuySubscriptionRequest) => Promise<BuySubscriptionResponse>;
106
+ getPayments: (params?: PaymentsQueryParams) => Promise<PaymentsListResponse>;
107
+ cancelSubscription: () => Promise<CancelSubscriptionResponse>;
102
108
  }
103
109
  export {};
@@ -276,6 +276,29 @@ class ApiClient {
276
276
  this.sendFeedbackEmail = async (data) => {
277
277
  return this.makeRequest('email/feedback', 'POST', data);
278
278
  };
279
+ ////// Subscriptions API
280
+ this.getSubscriptions = async () => {
281
+ return this.makeRequest('subscriptions', 'GET', null);
282
+ };
283
+ this.getMySubscription = async () => {
284
+ return this.makeRequest('subscriptions/my', 'GET', null);
285
+ };
286
+ this.buySubscription = async (data) => {
287
+ return this.makeRequest('subscriptions/buy', 'POST', data);
288
+ };
289
+ this.getPayments = async (params) => {
290
+ const queryParams = new URLSearchParams();
291
+ if (params?.startDate) {
292
+ queryParams.append('startDate', params.startDate);
293
+ }
294
+ if (params?.endDate) {
295
+ queryParams.append('endDate', params.endDate);
296
+ }
297
+ return this.makeRequest(`subscriptions/payments${queryParams.toString() ? `?${queryParams.toString()}` : ''}`, 'GET', null);
298
+ };
299
+ this.cancelSubscription = async () => {
300
+ return this.makeRequest('subscriptions/cancel', 'POST', null);
301
+ };
279
302
  this.baseURL = baseURL;
280
303
  this.headers = {};
281
304
  this.debug = false;
@@ -349,7 +372,7 @@ class ApiClient {
349
372
  else if ('bucketId' in params && params.bucketId.length > 0) {
350
373
  queryParams.append('bucketId', params.bucketId.join(','));
351
374
  }
352
- const response = await this.makeRequest(`stats/nodes/minute?${queryParams.toString() ? `?${queryParams.toString()}` : ''}`, 'GET', null);
375
+ const response = await this.makeRequest(`stats/nodes/minute${queryParams.toString() ? `?${queryParams.toString()}` : ''}`, 'GET', null);
353
376
  // Process the response to convert lastUpdated strings to Date objects
354
377
  const processedData = response.data.map((item) => ({
355
378
  ...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
  }
@@ -135,7 +135,7 @@ export interface GetUnitsResponse {
135
135
  }
136
136
  export interface GetReposResponse {
137
137
  success: boolean;
138
- repos: StorageRepo[];
138
+ repos: StorageRepoWithBuckets[];
139
139
  }
140
140
  export interface GetRepoKeysResponse {
141
141
  success: boolean;
@@ -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.26",
3
+ "version": "0.1.28",
4
4
  "type": "commonjs",
5
5
  "publishConfig": {
6
6
  "access": "public"