@flashbacktech/flashbackclient 0.0.32 → 0.0.33

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,4 +1,4 @@
1
- import { CreateUnitRequest, CreateUnitResponse } from './types';
1
+ import { CreateUnitRequest, CreateUnitResponse, CreateRepoRequest, CreateRepoResponse, StorageUnit, StorageRepo, CreateRepoKeyRequest, CreateRepoKeyResponse, ApiKey } from './types';
2
2
  export declare class ApiClient {
3
3
  private baseURL;
4
4
  private headers;
@@ -7,4 +7,9 @@ export declare class ApiClient {
7
7
  authenticateGoogle: (token: string) => Promise<any>;
8
8
  authenticateGithub: (code: string) => Promise<any>;
9
9
  createStorageUnit: (data: CreateUnitRequest) => Promise<CreateUnitResponse>;
10
+ getStorageUnits: () => Promise<StorageUnit[]>;
11
+ createRepo: (data: CreateRepoRequest) => Promise<CreateRepoResponse>;
12
+ getRepos: () => Promise<StorageRepo[]>;
13
+ createRepoKey: (data: CreateRepoKeyRequest) => Promise<CreateRepoKeyResponse>;
14
+ getRepoKeys: (repoId: string) => Promise<ApiKey[]>;
10
15
  }
@@ -17,6 +17,7 @@ class ApiClient {
17
17
  }
18
18
  };
19
19
  this.authenticateGoogle = async (token) => {
20
+ this.setAuthToken(token);
20
21
  const response = await fetch(`${this.baseURL}/auth/google`, {
21
22
  method: 'POST',
22
23
  headers: this.headers,
@@ -27,6 +28,7 @@ class ApiClient {
27
28
  return response.json();
28
29
  };
29
30
  this.authenticateGithub = async (code) => {
31
+ this.setAuthToken(code);
30
32
  const response = await fetch(`${this.baseURL}/auth/github`, {
31
33
  method: 'POST',
32
34
  headers: this.headers,
@@ -46,6 +48,54 @@ class ApiClient {
46
48
  throw new Error(`HTTP error! status: ${response.status}`);
47
49
  return response.json();
48
50
  };
51
+ this.getStorageUnits = async () => {
52
+ const response = await fetch(`${this.baseURL}/unit`, {
53
+ method: 'GET',
54
+ headers: this.headers,
55
+ });
56
+ if (!response.ok) {
57
+ throw new Error(`HTTP error! status: ${response.status}`);
58
+ }
59
+ return response.json();
60
+ };
61
+ this.createRepo = async (data) => {
62
+ const response = await fetch(`${this.baseURL}/repo`, {
63
+ method: 'POST',
64
+ headers: this.headers,
65
+ body: JSON.stringify(data),
66
+ });
67
+ if (!response.ok)
68
+ throw new Error(`HTTP error! status: ${response.status}`);
69
+ return response.json();
70
+ };
71
+ this.getRepos = async () => {
72
+ const response = await fetch(`${this.baseURL}/repo`, {
73
+ method: 'GET',
74
+ headers: this.headers,
75
+ });
76
+ if (!response.ok)
77
+ throw new Error(`HTTP error! status: ${response.status}`);
78
+ return response.json();
79
+ };
80
+ this.createRepoKey = async (data) => {
81
+ const response = await fetch(`${this.baseURL}/repo/${data.repoId}/apikey`, {
82
+ method: 'POST',
83
+ headers: this.headers,
84
+ body: JSON.stringify(data),
85
+ });
86
+ if (!response.ok)
87
+ throw new Error(`HTTP error! status: ${response.status}`);
88
+ return response.json();
89
+ };
90
+ this.getRepoKeys = async (repoId) => {
91
+ const response = await fetch(`${this.baseURL}/repo/${repoId}/apikey`, {
92
+ method: 'GET',
93
+ headers: this.headers,
94
+ });
95
+ if (!response.ok)
96
+ throw new Error(`HTTP error! status: ${response.status}`);
97
+ return response.json();
98
+ };
49
99
  this.baseURL = baseURL;
50
100
  this.headers = {
51
101
  'Content-Type': 'application/json',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flashbacktech/flashbackclient",
3
- "version": "0.0.32",
3
+ "version": "0.0.33",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },