@aurtic/cli 1.0.1 → 1.0.3

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,353 +0,0 @@
1
- import { authRequest, request } from "../api";
2
- import { IProject } from "./Project";
3
- import { IServer } from "./Server";
4
-
5
- export enum ProjectContainerType {
6
- m256_c1 = "m256_c1",
7
- m512_c1 = "m512_c1",
8
- m1024_c1 = "m1024_c1",
9
- m1536_c1 = "m1536_c1",
10
- m2048_c1 = "m2048_c1",
11
- m2560_c1 = "m2560_c1",
12
- m3072_c1 = "m3072_c1",
13
- m3584_c1 = "m3584_c1",
14
- m4095_c1 = "m4095_c1",
15
- m5120_c1 = "m5120_c1",
16
- m6144_c1 = "m6144_c1",
17
- m7168_c1 = "m7168_c1",
18
- m8192_c1 = "m8192_c1",
19
-
20
- m256_c2 = "m256_c2",
21
- m512_c2 = "m512_c2",
22
- m1024_c2 = "m1024_c2",
23
- m1536_c2 = "m1536_c2",
24
- m2048_c2 = "m2048_c2",
25
- m2560_c2 = "m2560_c2",
26
- m3072_c2 = "m3072_c2",
27
- m3584_c2 = "m3584_c2",
28
- m4095_c2 = "m4095_c2",
29
- m5120_c2 = "m5120_c2",
30
- m6144_c2 = "m6144_c2",
31
- m7168_c2 = "m7168_c2",
32
- m8192_c2 = "m8192_c2",
33
-
34
- m256_c3 = "m256_c3",
35
- m512_c3 = "m512_c3",
36
- m1024_c3 = "m1024_c3",
37
- m1536_c3 = "m1536_c3",
38
- m2048_c3 = "m2048_c3",
39
- m2560_c3 = "m2560_c3",
40
- m3072_c3 = "m3072_c3",
41
- m3584_c3 = "m3584_c3",
42
- m4095_c3 = "m4095_c3",
43
- m5120_c3 = "m5120_c3",
44
- m6144_c3 = "m6144_c3",
45
- m7168_c3 = "m7168_c3",
46
- m8192_c3 = "m8192_c3",
47
-
48
- m256_c4 = "m256_c4",
49
- m512_c4 = "m512_c4",
50
- m1024_c4 = "m1024_c4",
51
- m1536_c4 = "m1536_c4",
52
- m2048_c4 = "m2048_c4",
53
- m2560_c4 = "m2560_c4",
54
- m3072_c4 = "m3072_c4",
55
- m3584_c4 = "m3584_c4",
56
- m4095_c4 = "m4095_c4",
57
- m5120_c4 = "m5120_c4",
58
- m6144_c4 = "m6144_c4",
59
- m7168_c4 = "m7168_c4",
60
- m8192_c4 = "m8192_c4",
61
- }
62
-
63
- export enum ProjectContainerFlavour {
64
- PROTOTYPE = "PROTOTYPE",
65
- PRODUCTION = "PRODUCTION",
66
- ENTERPRISE = "ENTERPRISE"
67
- }
68
-
69
- export enum ProjectContainerRegion {
70
- EUROPE = 'EUROPE',
71
- ASIA = 'ASIA',
72
- OCEANIA = 'OCEANIA',
73
- NORTH_AMERICA = 'NORTH_AMERICA',
74
- SOUTH_AMERICA = 'SOUTH_AMERICA',
75
- }
76
-
77
- export interface IProjectContainer {
78
- readonly id: string;
79
- name: string;
80
- regions: ProjectContainerRegion[];
81
- type: ProjectContainerType;
82
- env: { [index: string]: string }
83
- flavour: ProjectContainerFlavour;
84
- amount: number;
85
- readonly _links: {
86
- [index: string]: {
87
- href: string,
88
- type: string,
89
- }
90
- }
91
- }
92
-
93
- export interface IProjectContainerFilesystem {
94
- readonly id: string;
95
- path: string;
96
- readonly daemon?: {
97
- username: string,
98
- password: string,
99
- server: IServer,
100
- }
101
- readonly _links: {
102
- [index: string]: {
103
- href: string,
104
- type: string,
105
- }
106
- }
107
- }
108
-
109
- export interface IProjectContainerUsage {
110
- date: Date,
111
- containers: number,
112
- type: ProjectContainerType,
113
- flavour: ProjectContainerFlavour,
114
- }
115
-
116
- export interface IProjectContainerProxy {
117
- readonly id: string;
118
- domain: string;
119
- type: 'INTERNAL' | 'EXTERNAL';
120
- certificate?: {
121
- public: string,
122
- private?: String,
123
- }
124
- readonly _links: {
125
- [index: string]: {
126
- href: string,
127
- type: string,
128
- }
129
- }
130
- }
131
-
132
- export interface IProjectContainerDeployment {
133
- readonly id: string;
134
- active: boolean;
135
- readonly time: number;
136
- build: boolean;
137
- result?: {
138
- result: boolean;
139
- logs: string[];
140
- errors: string[];
141
- }
142
- readonly created: Date;
143
- readonly _links: {
144
- [index: string]: {
145
- href: string,
146
- type: string,
147
- }
148
- }
149
- }
150
-
151
- export interface IProjectContainerLog {
152
- readonly date: Date;
153
- uuid: string;
154
- type: 'LOG' | 'ERROR';
155
- data: string[];
156
- readonly created: Date;
157
- }
158
-
159
- export const create = async (project: IProject, { name, flavour, regions, type, amount }: Pick<IProjectContainer, 'name' | 'flavour' | 'regions' | 'type' | 'amount'>): Promise<IProjectContainer> => {
160
- const res = await authRequest(project._links.containers.href, {
161
- method: 'POST',
162
- body: {
163
- name,
164
- flavour,
165
- regions,
166
- type,
167
- amount
168
- }
169
- });
170
- const result = await res.json();
171
- if (result['error']) {
172
- if (result['error'] === 'min_balance') {
173
- throw result;
174
- }
175
- throw result['error'];
176
- }
177
- return result;
178
- }
179
-
180
- export const createProxy = async (container: IProjectContainer, { domain, }: Pick<IProjectContainerProxy, 'domain'>): Promise<IProjectContainer> => {
181
- const res = await authRequest(container._links.proxies.href, {
182
- method: 'POST',
183
- body: {
184
- domain,
185
- }
186
- });
187
- const result = await res.json();
188
- if (result['error']) throw result['error'];
189
- return result;
190
- }
191
-
192
- export const get = async (project: IProject, id: string): Promise<IProjectContainer> => {
193
- const res = await authRequest(project._links.containers.href + '/' + encodeURIComponent(id));
194
- const result = await res.json();
195
- if (result['error']) throw result['error'];
196
- return result;
197
- }
198
-
199
- export const put = async (container: IProjectContainer, data: {
200
- name?: string,
201
- amount?: number,
202
- env?: { [index: string]: string },
203
- type?: ProjectContainerType,
204
- flavour?: ProjectContainerFlavour,
205
- regions?: ProjectContainerRegion[]
206
- }): Promise<IProjectContainer> => {
207
- const res = await authRequest(container._links.self.href, {
208
- method: 'PUT',
209
- body: data,
210
- });
211
- const result = await res.json();
212
- if (result['error']) throw result['error'];
213
- return result;
214
- }
215
-
216
- export const all = async (project: IProject): Promise<IProjectContainer[]> => {
217
- const res = await authRequest(project._links.containers.href);
218
- const result = await res.json();
219
- if (result['error']) throw result['error'];
220
- return result;
221
- }
222
-
223
- export const getProxies = async (container: IProjectContainer): Promise<IProjectContainerProxy[]> => {
224
- const res = await authRequest(container._links.proxies.href);
225
- const result = await res.json();
226
- if (result['error']) throw result['error'];
227
- return result;
228
- }
229
-
230
- export const getUsage = async (container: IProjectContainer): Promise<IProjectContainerUsage[]> => {
231
- const res = await authRequest(container._links.usage.href);
232
- const result = await res.json();
233
- if (result['error']) throw result['error'];
234
- return result;
235
- }
236
-
237
- export const getProxy = async (container: IProjectContainer, id: string): Promise<IProjectContainerProxy> => {
238
- const res = await authRequest(container._links.proxies.href + '/' + encodeURIComponent(id));
239
- const result = await res.json();
240
- if (result['error']) throw result['error'];
241
- return result;
242
- }
243
-
244
- export const getDeployments = async (container: IProjectContainer): Promise<IProjectContainerDeployment[]> => {
245
- const res = await authRequest(container._links.deployments.href);
246
- const result = await res.json();
247
- if (result['error']) throw result['error'];
248
- return result;
249
- }
250
-
251
- export const getLogs = async (container: IProjectContainer): Promise<IProjectContainerLog[]> => {
252
- const res = await authRequest(container._links.logs.href);
253
- const result = await res.json();
254
- if (result['error']) throw result['error'];
255
- return result;
256
- }
257
-
258
- export const getDeployment = async (container: IProjectContainer, id: string): Promise<IProjectContainerDeployment> => {
259
- const res = await authRequest(container._links.deployments.href + '/' + encodeURIComponent(id));
260
- const result = await res.json();
261
- if (result['error']) throw result['error'];
262
- return result;
263
- }
264
-
265
- export const createDeployment = async (container: IProjectContainer, { data }: { data: string }): Promise<IProjectContainerDeployment> => {
266
- const res = await authRequest(container._links.deployments.href, {
267
- method: 'POST',
268
- body: {
269
- data,
270
- }
271
- });
272
- const result = await res.json();
273
- if (result['error']) throw result['error'];
274
- return result;
275
- }
276
-
277
- export const buildDeployment = async (deployment: IProjectContainerDeployment): Promise<{
278
- result: boolean
279
- }> => {
280
- const res = await authRequest(deployment._links.build.href, {
281
- method: 'POST',
282
- });
283
- const result = await res.json();
284
- if (result['error']) throw result['error'];
285
- return result;
286
- }
287
-
288
- export const getDeploymentBuildStatus = async (deployment: IProjectContainerDeployment): Promise<{
289
- finished: boolean,
290
- result: boolean,
291
- data: {
292
- errors: string[],
293
- logs: string[],
294
- }
295
- }> => {
296
- const res = await authRequest(deployment._links.build.href, {
297
- method: 'GET',
298
- });
299
- const result = await res.json();
300
- if (result['error']) throw result['error'];
301
- return result;
302
- }
303
-
304
- export const createFilesystem = async (container: IProjectContainer, { path }: { path: string }): Promise<IProjectContainerFilesystem> => {
305
- const res = await authRequest(container._links.filesystems.href, {
306
- method: 'POST',
307
- body: {
308
- path,
309
- }
310
- });
311
- const result = await res.json();
312
- if (result['error']) throw result['error'];
313
- return result;
314
- }
315
-
316
- export const getFilesystems = async (container: IProjectContainer): Promise<IProjectContainerFilesystem[]> => {
317
- const res = await authRequest(container._links.filesystems.href);
318
- const result = await res.json();
319
- if (result['error']) throw result['error'];
320
- return result;
321
- }
322
-
323
- export const getFilesystem = async (container: IProjectContainer, id: string): Promise<IProjectContainerFilesystem> => {
324
- const res = await authRequest(container._links.filesystems.href + '/' + encodeURIComponent(id));
325
- const result = await res.json();
326
- if (result['error']) throw result['error'];
327
- return result;
328
- }
329
-
330
- const ProjectContainer = {
331
- all,
332
- get,
333
- put,
334
- create,
335
- getLogs,
336
-
337
- getProxies,
338
- getProxy,
339
- createProxy,
340
-
341
- getDeployments,
342
- getDeployment,
343
- createDeployment,
344
- buildDeployment,
345
- getDeploymentBuildStatus,
346
-
347
- createFilesystem,
348
- getFilesystem,
349
- getFilesystems,
350
-
351
- getUsage,
352
- }
353
- export default ProjectContainer;
@@ -1,88 +0,0 @@
1
- import { authRequest } from "../api";
2
- import { IProject } from "./Project";
3
- import { IProjectArchive } from "./ProjectArchive";
4
-
5
- export enum ProjectContentDeliveryNetworkType {
6
- CACHED = "CACHED",
7
- ON_DEMAND = "ON_DEMAND",
8
- }
9
-
10
- export interface IProjectContentDeliveryNetwork {
11
- readonly id: string;
12
- name: string;
13
- type: ProjectContentDeliveryNetworkType;
14
- readonly uri: string;
15
- readonly _links: {
16
- [index: string]: {
17
- href: string,
18
- type: string,
19
- }
20
- }
21
- }
22
-
23
- export const create = async (project: IProject, { name, type }: Pick<IProjectContentDeliveryNetwork, 'name' | 'type'>): Promise<IProjectContentDeliveryNetwork> => {
24
- const res = await authRequest(project._links['content-delivery-networks'].href, {
25
- method: 'POST',
26
- body: {
27
- name,
28
- type,
29
- }
30
- });
31
- const result = await res.json();
32
- if (result['error']) {
33
- if (result['error'] === 'min_balance') throw result;
34
- throw result['error'];
35
- }
36
- return result;
37
- }
38
-
39
- export const get = async (project: IProject, id: string): Promise<IProjectContentDeliveryNetwork> => {
40
- const res = await authRequest(project._links['content-delivery-networks'].href + '/' + encodeURIComponent(id));
41
- const result = await res.json();
42
- if (result['error']) throw result['error'];
43
- return result;
44
- }
45
-
46
- export const put = async (cdn: IProjectContentDeliveryNetwork, data: Pick<IProjectContentDeliveryNetwork, 'name' | 'type'>): Promise<IProjectContentDeliveryNetwork> => {
47
- const res = await authRequest(cdn._links.self.href, {
48
- method: 'PUT',
49
- body: data,
50
- });
51
- const result = await res.json();
52
- if (result['error']) throw result['error'];
53
- return result;
54
- }
55
-
56
- export const remove = async (cdn: IProjectContentDeliveryNetwork): Promise<IProjectContentDeliveryNetwork> => {
57
- const res = await authRequest(cdn._links.self.href, {
58
- method: 'DELETE',
59
- });
60
- const result = await res.json();
61
- if (result['error']) throw result['error'];
62
- return result;
63
- }
64
-
65
- export const all = async (project: IProject): Promise<IProjectContentDeliveryNetwork[]> => {
66
- const res = await authRequest(project._links['content-delivery-networks'].href);
67
- const result = await res.json();
68
- if (result['error']) throw result['error'];
69
- return result;
70
- }
71
-
72
- export const getArchive = async (cdn: IProjectContentDeliveryNetwork): Promise<IProjectArchive> => {
73
- const res = await authRequest(cdn._links.archive.href);
74
- const result = await res.json();
75
- if (result['error']) throw result['error'];
76
- return result;
77
- }
78
-
79
- const ProjectContentDeliveryNetwork = {
80
- all,
81
- get,
82
- put,
83
- create,
84
- remove,
85
- getArchive,
86
- }
87
-
88
- export default ProjectContentDeliveryNetwork;
@@ -1,68 +0,0 @@
1
- import { authRequest, request } from "../api";
2
-
3
- export interface IRefferal {
4
- readonly id: string;
5
- readonly user: {
6
- readonly id: string;
7
- first_name: string,
8
- last_name: string;
9
- email: string;
10
- phone?: string;
11
- }
12
- readonly created: string;
13
- readonly _links: {
14
- [index: string]: {
15
- href: string,
16
- type: string,
17
- }
18
- }
19
- }
20
-
21
- export const register = async ({ first_name, last_name, email, phone }: { first_name: string, last_name: string, email: string, phone?: string }): Promise<IRefferal> => {
22
- const res = await authRequest('/v1/referrals', {
23
- method: 'POST',
24
- body: {
25
- first_name,
26
- last_name,
27
- email,
28
- phone,
29
- }
30
- });
31
- const result = await res.json();
32
- if (result['error']) throw result['error'];
33
- return result;
34
- }
35
-
36
- export const get = async (id: string): Promise<IRefferal> => {
37
- const res = await authRequest('/v1/referrals/' + encodeURIComponent(id));
38
- const result = await res.json();
39
- if (result['error']) throw result['error'];
40
- return result;
41
- }
42
-
43
- export const createGrant = async (referral: IRefferal, amount: number): Promise<IRefferal> => {
44
- const res = await authRequest(referral._links.grant.href, {
45
- method: "POST",
46
- body: {
47
- amount,
48
- }
49
- });
50
- const result = await res.json();
51
- if (result['error']) throw result['error'];
52
- return result;
53
- }
54
-
55
- export const all = async (): Promise<IRefferal[]> => {
56
- const res = await authRequest('/v1/referrals');
57
- const result = await res.json();
58
- if (result['error']) throw result['error'];
59
- return result;
60
- }
61
-
62
- const Account = {
63
- register,
64
- get,
65
- all,
66
- createGrant,
67
- }
68
- export default Account;
@@ -1,68 +0,0 @@
1
- import { authRequest, request } from "../api";
2
-
3
- export enum IServerRegion {
4
- eu_west_1 = "eu_west_1",
5
- eu_west_2 = "eu_west_2",
6
- eu_west_3 = "eu_west_3",
7
- eu_west_4 = "eu_west_4",
8
- eu_west_5 = "eu_west_5",
9
- }
10
-
11
- export interface IServer {
12
- readonly id: string;
13
- ipv4: {
14
- primary: string,
15
- internal?: string,
16
- }
17
- ipv6?: {
18
- primary: string,
19
- internal?: string,
20
- }
21
- hostname: string;
22
- cores: number;
23
- speed: number;
24
- memory: number;
25
- disk: number;
26
- region: IServerRegion;
27
- readonly _links: {
28
- [index: string]: {
29
- href: string,
30
- type: string,
31
- }
32
- }
33
- }
34
-
35
- export const get = async (id: string): Promise<IServer> => {
36
- const res = await authRequest('/v1/servers/' + encodeURIComponent(id));
37
- const result = await res.json();
38
- if(result['error']) throw result['error'];
39
- return result;
40
- }
41
-
42
- export const me = async (): Promise<IServer> => {
43
- const res = await authRequest('/v1/servers/@me');
44
- const result = await res.json();
45
- if(result['error']) throw result['error'];
46
- return result;
47
- }
48
-
49
- export const login = async ({ id, password }: { id: string, password: string }) => {
50
- const result = await request('/v1/servers/login', {
51
- method: 'POST',
52
- body: {
53
- id,
54
- password,
55
- }
56
- });
57
- const json = await result.json();
58
- if(json['error']) throw json['error'];
59
- return json['access_token'];
60
- }
61
-
62
-
63
- const Server = {
64
- me,
65
- get,
66
- login
67
- }
68
- export default Server;
@@ -1,42 +0,0 @@
1
- import { authRequest, request } from "../api";
2
- import { IServer } from "./Server";
3
-
4
- export interface IStorageDaemon {
5
- readonly id: string;
6
- username: string;
7
- password: string;
8
- readonly _links: {
9
- [index: string]: {
10
- href: string,
11
- type: string,
12
- }
13
- }
14
- }
15
-
16
- export const me = async (id: string): Promise<IStorageDaemon> => {
17
- const res = await authRequest('/v1/storage-daemons/@me');
18
- const result = await res.json();
19
- if (result['error']) throw result['error'];
20
- return result;
21
- }
22
-
23
- export const get = async (id: string): Promise<IStorageDaemon> => {
24
- const res = await authRequest('/v1/storage-daemons/' + encodeURIComponent(id));
25
- const result = await res.json();
26
- if (result['error']) throw result['error'];
27
- return result;
28
- }
29
-
30
- export const getServer = async (daemon: IStorageDaemon): Promise<IServer> => {
31
- const res = await authRequest(daemon._links.server.href);
32
- const result = await res.json();
33
- if (result['error']) throw result['error'];
34
- return result;
35
- }
36
-
37
- const StorageDaemon = {
38
- get,
39
- me,
40
- getServer,
41
- }
42
- export default StorageDaemon;
@@ -1,85 +0,0 @@
1
- import { authRequest, request } from "../api";
2
-
3
- export interface ITeam {
4
- readonly id: string;
5
- name: string;
6
- readonly balance: number;
7
- readonly _links: {
8
- [index: string]: {
9
- href: string;
10
- type: string;
11
- }
12
- }
13
- }
14
-
15
- export interface ITeamPayment {
16
- readonly id: string;
17
- readonly amount: number;
18
- readonly currency: string;
19
- readonly created: Date;
20
- readonly state: -1 | 0 | 1 | 2;
21
- readonly _links: {
22
- [index: string]: {
23
- href: string;
24
- type: string;
25
- }
26
- }
27
- }
28
-
29
-
30
- export const get = async (id: string): Promise<ITeam> => {
31
- const res = await authRequest('/v1/teams/' + encodeURIComponent(id));
32
- const result = await res.json();
33
- if (result['error']) throw result['error'];
34
- return result;
35
- }
36
-
37
- export const all = async (): Promise<ITeam[]> => {
38
- const res = await authRequest('/v1/teams');
39
- const result = await res.json();
40
- if (result['error']) throw result['error'];
41
- return result;
42
- }
43
-
44
- export const getPayments = async (): Promise<ITeamPayment[]> => {
45
- const res = await authRequest('/v1/teams');
46
- const result = await res.json();
47
- if (result['error']) throw result['error'];
48
- return result;
49
- }
50
-
51
- export const create = async ({ name }: { name: string, }): Promise<ITeam> => {
52
- const res = await authRequest('/v1/teams', {
53
- method: 'POST',
54
- body: {
55
- name,
56
- }
57
- });
58
- const result = await res.json();
59
- if (result['error']) throw result['error'];
60
- return result;
61
- }
62
-
63
- export const createPayment = async (team: ITeam, { amount }: { amount: number, }): Promise<{
64
- url: string,
65
- }> => {
66
- const res = await authRequest(team._links.payments.href, {
67
- method: 'POST',
68
- body: {
69
- amount,
70
- }
71
- });
72
- const result = await res.json();
73
- if (result['error']) throw result['error'];
74
- return result;
75
- }
76
-
77
-
78
- const Team = {
79
- all,
80
- create,
81
- get,
82
- createPayment,
83
- getPayments,
84
- }
85
- export default Team;