@flashbacktech/flashbackclient 0.1.22 → 0.1.24

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,8 @@
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 } from './types/storage';
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 } from './types/storage';
2
2
  import { IApiClient, ProviderType } from './interfaces';
3
3
  import { ActivateResponse, DeactivateResponse, LoginBody, LoginResponse, LogoutResponse, OAuth2ResponseDTO, RefreshTokenErrorResponse, RefreshTokenResponse, RegisterBody, RegisterResponse, ResetPasswordBody } from './types/auth';
4
4
  import { StatsQueryParams, StatsResponse, NodeStatsMinuteResponse, NodeStatsDailyResponse, NodeStatsQueryParams, UnitStatsResponse, RepoStatsResponse, NodeStatsDailyQueryParams } from './types/stats';
5
5
  import { NodeInfo } from './types/bridge';
6
- import { FeedbackEmailBody } from './types/email';
7
6
  import { QuotaResponse } from './types/quota';
8
7
  interface ErrorResponse {
9
8
  message?: string;
@@ -48,6 +47,14 @@ export declare class ApiClient implements IApiClient {
48
47
  getAvailableStorageUnits: () => Promise<StorageUnit[]>;
49
48
  getStorageUnitStatus: (unitId: string) => Promise<StorageUnitStatusResponse>;
50
49
  getUnitNodeStats: (unitId: string, data: GetUnitNodeStatsRequest) => Promise<GetUnitNodeStatsResponse>;
50
+ createStorageBucket: (data: CreateBucketRequest) => Promise<CreateBucketResponse>;
51
+ getStorageBuckets: () => Promise<GetBucketsResponse>;
52
+ validateStorageBucket: (bucketId: string, data: ValidateBucketRequest) => Promise<ValidateBucketResponse>;
53
+ updateStorageBucket: (bucketId: string, data: UpdateBucketRequest) => Promise<UpdateBucketResponse>;
54
+ deleteStorageBucket: (bucketId: string) => Promise<ActionResponse>;
55
+ getAvailableStorageBuckets: () => Promise<StorageBucket[]>;
56
+ getStorageBucketStatus: (bucketId: string) => Promise<StorageBucketStatusResponse>;
57
+ getBucketNodeStats: (bucketId: string, data: GetBucketNodeStatsRequest) => Promise<GetBucketNodeStatsResponse>;
51
58
  createStorageRepo: (data: CreateRepoRequest) => Promise<CreateRepoResponse>;
52
59
  getStorageRepos: () => Promise<GetReposResponse>;
53
60
  updateStorageRepo: (repoId: string, data: UpdateRepoRequest) => Promise<UpdateRepoResponse>;
@@ -80,6 +87,6 @@ export declare class ApiClient implements IApiClient {
80
87
  unitId?: string[];
81
88
  }) => Promise<UnitStatsResponse>;
82
89
  getNodeInfo: () => Promise<NodeInfo[]>;
83
- sendFeedbackEmail: (data: FeedbackEmailBody) => Promise<ActionResponse>;
90
+ sendFeedbackEmail: (data: FormData) => Promise<ActionResponse>;
84
91
  }
85
92
  export {};
@@ -80,12 +80,13 @@ class ApiClient {
80
80
  throw new Error('Not implemented');
81
81
  };
82
82
  this.makeRequest = async (path, method, data) => {
83
+ const isFormData = data instanceof FormData;
83
84
  const options = {
84
85
  method,
85
86
  headers: this.headers,
86
- body: data ? JSON.stringify(data) : null,
87
+ body: data ? (isFormData ? data : JSON.stringify(data)) : null,
87
88
  };
88
- if (data) {
89
+ if (data && !isFormData) {
89
90
  options.headers = {
90
91
  ...options.headers,
91
92
  'Content-Type': 'application/json',
@@ -173,6 +174,31 @@ class ApiClient {
173
174
  this.getUnitNodeStats = async (unitId, data) => {
174
175
  return this.makeRequest(`unit/${unitId}/stats`, 'POST', data);
175
176
  };
177
+ ////// Buckets API (new bucket-based endpoints)
178
+ this.createStorageBucket = async (data) => {
179
+ return this.makeRequest('bucket', 'POST', data);
180
+ };
181
+ this.getStorageBuckets = async () => {
182
+ return this.makeRequest('bucket', 'GET', null);
183
+ };
184
+ this.validateStorageBucket = async (bucketId, data) => {
185
+ return this.makeRequest(`bucket/${bucketId}/validate`, 'POST', data);
186
+ };
187
+ this.updateStorageBucket = async (bucketId, data) => {
188
+ return this.makeRequest(`bucket/${bucketId}`, 'PUT', data);
189
+ };
190
+ this.deleteStorageBucket = async (bucketId) => {
191
+ return this.makeRequest(`bucket/${bucketId}`, 'DELETE', null);
192
+ };
193
+ this.getAvailableStorageBuckets = async () => {
194
+ return this.makeRequest('bucket/available', 'GET', null);
195
+ };
196
+ this.getStorageBucketStatus = async (bucketId) => {
197
+ return this.makeRequest(`bucket/${bucketId}/status`, 'GET', null);
198
+ };
199
+ this.getBucketNodeStats = async (bucketId, data) => {
200
+ return this.makeRequest(`bucket/${bucketId}/stats`, 'POST', data);
201
+ };
176
202
  ////// Repos API
177
203
  this.createStorageRepo = async (data) => {
178
204
  return this.makeRequest('repo', 'POST', data);
@@ -179,3 +179,78 @@ export declare enum RepoErrorCodes {
179
179
  NORMAL_UNIT_CANNOT_EDIT_FOLDER = "NORMAL_UNIT_CANNOT_EDIT_FOLDER",
180
180
  QUOTA_EXCEEDED = "QUOTA_EXCEEDED"
181
181
  }
182
+ export interface CreateBucketRequest extends CreateUnitRequest {
183
+ }
184
+ export interface UpdateBucketRequest extends UpdateUnitRequest {
185
+ }
186
+ export interface ValidateBucketRequest extends ValidateUnitRequest {
187
+ }
188
+ export interface ValidateBucketResponse extends ValidateUnitResponse {
189
+ }
190
+ export interface StorageBucket extends StorageUnit {
191
+ }
192
+ export interface GetBucketsResponse extends GetUnitsResponse {
193
+ }
194
+ export interface CreateBucketResponse {
195
+ success: boolean;
196
+ bucketId: string;
197
+ }
198
+ export interface UpdateBucketResponse extends CreateBucketResponse {
199
+ status?: string;
200
+ latency_ms?: number;
201
+ }
202
+ export interface RepoBucketInfo {
203
+ folder: string;
204
+ master: boolean;
205
+ bucketId?: string;
206
+ bucket?: StorageBucket;
207
+ }
208
+ export interface CreateRepoWithBucketsRequest {
209
+ name: string;
210
+ storageType: StorageType;
211
+ mode: ModeType;
212
+ repoBuckets: RepoBucketInfo[];
213
+ }
214
+ export interface UpdateRepoWithBucketsRequest extends CreateRepoWithBucketsRequest {
215
+ }
216
+ export interface StorageRepoWithBuckets {
217
+ id: string;
218
+ name: string;
219
+ storageType: StorageType;
220
+ mode: ModeType;
221
+ buckets: RepoBucketInfo[];
222
+ apiKeys?: ApiKey[];
223
+ createdAt: string;
224
+ disabled?: boolean;
225
+ }
226
+ export interface ValidateRepoBucketsRequest {
227
+ repoId: string;
228
+ mode: ModeType;
229
+ repoBuckets: RepoBucketInfo[];
230
+ }
231
+ export interface ValidateRepoBucketsResponse {
232
+ success: boolean;
233
+ error_code?: RepoErrorCodes;
234
+ error_message?: string;
235
+ }
236
+ export interface StorageBucketStatusResponse {
237
+ bucketId: string;
238
+ nodeStatus: NodeStatusInfo[];
239
+ }
240
+ export interface GetBucketNodeStatsRequest {
241
+ day: Date;
242
+ }
243
+ export interface GetBucketNodeStatsResponse {
244
+ success: boolean;
245
+ nodeStats: BucketNodeStatsDailyInfo[];
246
+ }
247
+ export interface BucketNodeStatsDailyInfo {
248
+ ip: string;
249
+ host: string;
250
+ perc_uptime: number;
251
+ avg_latency_ms: number;
252
+ version: string;
253
+ node_status: NodeStatusType;
254
+ last_updated: string;
255
+ last_latency_ms: number;
256
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flashbacktech/flashbackclient",
3
- "version": "0.1.22",
3
+ "version": "0.1.24",
4
4
  "type": "commonjs",
5
5
  "publishConfig": {
6
6
  "access": "public"