UNPKG

13.8 kBTypeScriptView Raw
1import fetch from 'node-fetch';
2import { RequestInit } from 'node-fetch';
3import { ClassValidator, ValidationError } from './common';
4import { Application, Template, User, LogReadOpts, LogsResponse, CreateTicketResponse, TryTemplateResponse } from './interfaces';
5export interface Options extends Pick<RequestInit, 'agent' | 'redirect' | 'follow' | 'compress'> {
6 fetchImplementation?: typeof fetch;
7 timeoutMs?: number;
8 headers?: Record<string, string>;
9}
10export declare class RequestError extends Error {
11 /**
12 * The original error causing this request to fail
13 * Inherits Error in case of network or parse errors
14 * In case of an invalid HTTP response it will contain an object with the body/trimmed text of the response
15 */
16 readonly cause: any;
17 readonly method: string;
18 readonly options: any;
19 readonly name = "RequestError";
20 constructor(message: string,
21 /**
22 * The original error causing this request to fail
23 * Inherits Error in case of network or parse errors
24 * In case of an invalid HTTP response it will contain an object with the body/trimmed text of the response
25 */
26 cause: any, method: string, options: any);
27}
28export declare class TimeoutError extends Error {
29 readonly method: string;
30 readonly options: any;
31 readonly name = "TimeoutError";
32 constructor(message: string, method: string, options: any);
33}
34export { ValidationError, };
35export interface Lycan {
36 createTicket(): Promise<CreateTicketResponse>;
37 claimTicket(ticket: string): Promise<string>;
38 listTemplates(): Promise<Array<Template>>;
39 tryTemplate(id: string): Promise<TryTemplateResponse>;
40 whoami(): Promise<User>;
41 listApps(): Promise<Array<Application>>;
42 getApp(id: string): Promise<Application>;
43 deployInitial(env: string, name: string, digest: string, envVars: Array<[string, string]>): Promise<Application>;
44 deploy(appId: string, env: string, digest: string, envVars: Array<[string, string]>): Promise<Application>;
45 claimApp(token: string): Promise<Application>;
46 getLogs(appId: string, env: string, opts: LogReadOpts): Promise<LogsResponse>;
47 destroyApp(appId: string): Promise<void>;
48}
49export declare class LycanClient {
50 readonly serverUrl: string;
51 protected readonly options: Options;
52 static readonly methods: string[];
53 static readonly validators: ClassValidator;
54 protected readonly props: {
55 "createTicket": {
56 "description": string;
57 "type": string;
58 "properties": {
59 "params": {
60 "type": string;
61 "properties": {};
62 };
63 "returns": {
64 "$ref": string;
65 };
66 };
67 "propertyOrder": string[];
68 "required": string[];
69 };
70 "claimTicket": {
71 "description": string;
72 "type": string;
73 "properties": {
74 "params": {
75 "type": string;
76 "properties": {
77 "ticket": {
78 "type": string;
79 };
80 };
81 "propertyOrder": string[];
82 "required": string[];
83 };
84 "throws": {
85 "$ref": string;
86 };
87 "returns": {
88 "type": string;
89 };
90 };
91 "propertyOrder": string[];
92 "required": string[];
93 };
94 "listTemplates": {
95 "type": string;
96 "properties": {
97 "params": {
98 "type": string;
99 "properties": {};
100 };
101 "returns": {
102 "type": string;
103 "items": {
104 "$ref": string;
105 };
106 };
107 };
108 "propertyOrder": string[];
109 "required": string[];
110 };
111 "tryTemplate": {
112 "description": string;
113 "type": string;
114 "properties": {
115 "params": {
116 "type": string;
117 "properties": {
118 "id": {
119 "minLength": number;
120 "type": string;
121 };
122 };
123 "propertyOrder": string[];
124 "required": string[];
125 };
126 "throws": {
127 "$ref": string;
128 };
129 "returns": {
130 "$ref": string;
131 };
132 };
133 "propertyOrder": string[];
134 "required": string[];
135 };
136 "whoami": {
137 "type": string;
138 "properties": {
139 "params": {
140 "type": string;
141 "properties": {};
142 };
143 "returns": {
144 "$ref": string;
145 };
146 "throws": {
147 "$ref": string;
148 };
149 };
150 "propertyOrder": string[];
151 "required": string[];
152 };
153 "listApps": {
154 "type": string;
155 "properties": {
156 "params": {
157 "type": string;
158 "properties": {};
159 };
160 "throws": {
161 "$ref": string;
162 };
163 "returns": {
164 "type": string;
165 "items": {
166 "$ref": string;
167 };
168 };
169 };
170 "propertyOrder": string[];
171 "required": string[];
172 };
173 "getApp": {
174 "type": string;
175 "properties": {
176 "params": {
177 "type": string;
178 "properties": {
179 "id": {
180 "minLength": number;
181 "type": string;
182 };
183 };
184 "propertyOrder": string[];
185 "required": string[];
186 };
187 "throws": {
188 "$ref": string;
189 };
190 "returns": {
191 "$ref": string;
192 };
193 };
194 "propertyOrder": string[];
195 "required": string[];
196 };
197 "deployInitial": {
198 "type": string;
199 "properties": {
200 "params": {
201 "type": string;
202 "properties": {
203 "env": {
204 "pattern": string;
205 "type": string;
206 };
207 "name": {
208 "minLength": number;
209 "type": string;
210 };
211 "digest": {
212 "minLength": number;
213 "type": string;
214 };
215 "envVars": {
216 "type": string;
217 "items": {
218 "type": string;
219 "items": {
220 "type": string;
221 }[];
222 "minItems": number;
223 "additionalItems": {
224 "anyOf": {
225 "type": string;
226 }[];
227 };
228 };
229 };
230 };
231 "propertyOrder": string[];
232 "required": string[];
233 };
234 "throws": {
235 "anyOf": {
236 "$ref": string;
237 }[];
238 };
239 "returns": {
240 "$ref": string;
241 };
242 };
243 "propertyOrder": string[];
244 "required": string[];
245 };
246 "deploy": {
247 "type": string;
248 "properties": {
249 "params": {
250 "type": string;
251 "properties": {
252 "appId": {
253 "minLength": number;
254 "type": string;
255 };
256 "env": {
257 "pattern": string;
258 "type": string;
259 };
260 "digest": {
261 "minLength": number;
262 "type": string;
263 };
264 "envVars": {
265 "type": string;
266 "items": {
267 "type": string;
268 "items": {
269 "type": string;
270 }[];
271 "minItems": number;
272 "additionalItems": {
273 "anyOf": {
274 "type": string;
275 }[];
276 };
277 };
278 };
279 };
280 "propertyOrder": string[];
281 "required": string[];
282 };
283 "throws": {
284 "anyOf": {
285 "$ref": string;
286 }[];
287 };
288 "returns": {
289 "$ref": string;
290 };
291 };
292 "propertyOrder": string[];
293 "required": string[];
294 };
295 "claimApp": {
296 "description": string;
297 "type": string;
298 "properties": {
299 "params": {
300 "type": string;
301 "properties": {
302 "token": {
303 "minLength": number;
304 "type": string;
305 };
306 };
307 "propertyOrder": string[];
308 "required": string[];
309 };
310 "throws": {
311 "anyOf": {
312 "$ref": string;
313 }[];
314 };
315 "returns": {
316 "$ref": string;
317 };
318 };
319 "propertyOrder": string[];
320 "required": string[];
321 };
322 "getLogs": {
323 "type": string;
324 "properties": {
325 "params": {
326 "type": string;
327 "properties": {
328 "appId": {
329 "minLength": number;
330 "type": string;
331 };
332 "env": {
333 "pattern": string;
334 "type": string;
335 };
336 "opts": {
337 "$ref": string;
338 };
339 };
340 "propertyOrder": string[];
341 "required": string[];
342 };
343 "throws": {
344 "anyOf": {
345 "$ref": string;
346 }[];
347 };
348 "returns": {
349 "$ref": string;
350 };
351 };
352 "propertyOrder": string[];
353 "required": string[];
354 };
355 "destroyApp": {
356 "type": string;
357 "properties": {
358 "params": {
359 "type": string;
360 "properties": {
361 "appId": {
362 "minLength": number;
363 "type": string;
364 };
365 };
366 "propertyOrder": string[];
367 "required": string[];
368 };
369 "throws": {
370 "anyOf": {
371 "$ref": string;
372 }[];
373 };
374 "returns": {
375 "type": string;
376 };
377 };
378 "propertyOrder": string[];
379 "required": string[];
380 };
381 };
382 readonly validators: ClassValidator;
383 constructor(serverUrl: string, options?: Options);
384 createTicket(options?: Options): Promise<CreateTicketResponse>;
385 claimTicket(ticket: string, options?: Options): Promise<string>;
386 listTemplates(options?: Options): Promise<Array<Template>>;
387 tryTemplate(id: string, options?: Options): Promise<TryTemplateResponse>;
388 whoami(options?: Options): Promise<User>;
389 listApps(options?: Options): Promise<Array<Application>>;
390 getApp(id: string, options?: Options): Promise<Application>;
391 deployInitial(env: string, name: string, digest: string, envVars: Array<[string, string]>, options?: Options): Promise<Application>;
392 deploy(appId: string, env: string, digest: string, envVars: Array<[string, string]>, options?: Options): Promise<Application>;
393 claimApp(token: string, options?: Options): Promise<Application>;
394 getLogs(appId: string, env: string, opts: LogReadOpts, options?: Options): Promise<LogsResponse>;
395 destroyApp(appId: string, options?: Options): Promise<void>;
396}