UNPKG

12.9 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 deployInitial(env: string, name: string, digest: string, envVars: Array<[string, string]>): Promise<Application>;
43 deploy(appId: string, env: string, digest: string, envVars: Array<[string, string]>): Promise<Application>;
44 claimApp(token: string): Promise<Application>;
45 getLogs(appId: string, env: string, opts: LogReadOpts): Promise<LogsResponse>;
46 destroyApp(appId: string): Promise<void>;
47}
48export declare class LycanClient {
49 readonly serverUrl: string;
50 protected readonly options: Options;
51 static readonly methods: string[];
52 static readonly validators: ClassValidator;
53 protected readonly props: {
54 "createTicket": {
55 "description": string;
56 "type": string;
57 "properties": {
58 "params": {
59 "type": string;
60 "properties": {};
61 };
62 "returns": {
63 "$ref": string;
64 };
65 };
66 "propertyOrder": string[];
67 "required": string[];
68 };
69 "claimTicket": {
70 "description": string;
71 "type": string;
72 "properties": {
73 "params": {
74 "type": string;
75 "properties": {
76 "ticket": {
77 "type": string;
78 };
79 };
80 "propertyOrder": string[];
81 "required": string[];
82 };
83 "throws": {
84 "$ref": string;
85 };
86 "returns": {
87 "type": string;
88 };
89 };
90 "propertyOrder": string[];
91 "required": string[];
92 };
93 "listTemplates": {
94 "type": string;
95 "properties": {
96 "params": {
97 "type": string;
98 "properties": {};
99 };
100 "returns": {
101 "type": string;
102 "items": {
103 "$ref": string;
104 };
105 };
106 };
107 "propertyOrder": string[];
108 "required": string[];
109 };
110 "tryTemplate": {
111 "description": string;
112 "type": string;
113 "properties": {
114 "params": {
115 "type": string;
116 "properties": {
117 "id": {
118 "minLength": number;
119 "type": string;
120 };
121 };
122 "propertyOrder": string[];
123 "required": string[];
124 };
125 "throws": {
126 "$ref": string;
127 };
128 "returns": {
129 "$ref": string;
130 };
131 };
132 "propertyOrder": string[];
133 "required": string[];
134 };
135 "whoami": {
136 "type": string;
137 "properties": {
138 "params": {
139 "type": string;
140 "properties": {};
141 };
142 "returns": {
143 "$ref": string;
144 };
145 "throws": {
146 "$ref": string;
147 };
148 };
149 "propertyOrder": string[];
150 "required": string[];
151 };
152 "listApps": {
153 "type": string;
154 "properties": {
155 "params": {
156 "type": string;
157 "properties": {};
158 };
159 "throws": {
160 "$ref": string;
161 };
162 "returns": {
163 "type": string;
164 "items": {
165 "$ref": string;
166 };
167 };
168 };
169 "propertyOrder": string[];
170 "required": string[];
171 };
172 "deployInitial": {
173 "type": string;
174 "properties": {
175 "params": {
176 "type": string;
177 "properties": {
178 "env": {
179 "pattern": string;
180 "type": string;
181 };
182 "name": {
183 "minLength": number;
184 "type": string;
185 };
186 "digest": {
187 "minLength": number;
188 "type": string;
189 };
190 "envVars": {
191 "type": string;
192 "items": {
193 "type": string;
194 "items": {
195 "type": string;
196 }[];
197 "minItems": number;
198 "additionalItems": {
199 "anyOf": {
200 "type": string;
201 }[];
202 };
203 };
204 };
205 };
206 "propertyOrder": string[];
207 "required": string[];
208 };
209 "throws": {
210 "anyOf": {
211 "$ref": string;
212 }[];
213 };
214 "returns": {
215 "$ref": string;
216 };
217 };
218 "propertyOrder": string[];
219 "required": string[];
220 };
221 "deploy": {
222 "type": string;
223 "properties": {
224 "params": {
225 "type": string;
226 "properties": {
227 "appId": {
228 "minLength": number;
229 "type": string;
230 };
231 "env": {
232 "pattern": string;
233 "type": string;
234 };
235 "digest": {
236 "minLength": number;
237 "type": string;
238 };
239 "envVars": {
240 "type": string;
241 "items": {
242 "type": string;
243 "items": {
244 "type": string;
245 }[];
246 "minItems": number;
247 "additionalItems": {
248 "anyOf": {
249 "type": string;
250 }[];
251 };
252 };
253 };
254 };
255 "propertyOrder": string[];
256 "required": string[];
257 };
258 "throws": {
259 "anyOf": {
260 "$ref": string;
261 }[];
262 };
263 "returns": {
264 "$ref": string;
265 };
266 };
267 "propertyOrder": string[];
268 "required": string[];
269 };
270 "claimApp": {
271 "description": string;
272 "type": string;
273 "properties": {
274 "params": {
275 "type": string;
276 "properties": {
277 "token": {
278 "minLength": number;
279 "type": string;
280 };
281 };
282 "propertyOrder": string[];
283 "required": string[];
284 };
285 "throws": {
286 "anyOf": {
287 "$ref": string;
288 }[];
289 };
290 "returns": {
291 "$ref": string;
292 };
293 };
294 "propertyOrder": string[];
295 "required": string[];
296 };
297 "getLogs": {
298 "type": string;
299 "properties": {
300 "params": {
301 "type": string;
302 "properties": {
303 "appId": {
304 "minLength": number;
305 "type": string;
306 };
307 "env": {
308 "pattern": string;
309 "type": string;
310 };
311 "opts": {
312 "$ref": string;
313 };
314 };
315 "propertyOrder": string[];
316 "required": string[];
317 };
318 "throws": {
319 "anyOf": {
320 "$ref": string;
321 }[];
322 };
323 "returns": {
324 "$ref": string;
325 };
326 };
327 "propertyOrder": string[];
328 "required": string[];
329 };
330 "destroyApp": {
331 "type": string;
332 "properties": {
333 "params": {
334 "type": string;
335 "properties": {
336 "appId": {
337 "minLength": number;
338 "type": string;
339 };
340 };
341 "propertyOrder": string[];
342 "required": string[];
343 };
344 "throws": {
345 "anyOf": {
346 "$ref": string;
347 }[];
348 };
349 "returns": {
350 "type": string;
351 };
352 };
353 "propertyOrder": string[];
354 "required": string[];
355 };
356 };
357 readonly validators: ClassValidator;
358 constructor(serverUrl: string, options?: Options);
359 createTicket(options?: Options): Promise<CreateTicketResponse>;
360 claimTicket(ticket: string, options?: Options): Promise<string>;
361 listTemplates(options?: Options): Promise<Array<Template>>;
362 tryTemplate(id: string, options?: Options): Promise<TryTemplateResponse>;
363 whoami(options?: Options): Promise<User>;
364 listApps(options?: Options): Promise<Array<Application>>;
365 deployInitial(env: string, name: string, digest: string, envVars: Array<[string, string]>, options?: Options): Promise<Application>;
366 deploy(appId: string, env: string, digest: string, envVars: Array<[string, string]>, options?: Options): Promise<Application>;
367 claimApp(token: string, options?: Options): Promise<Application>;
368 getLogs(appId: string, env: string, opts: LogReadOpts, options?: Options): Promise<LogsResponse>;
369 destroyApp(appId: string, options?: Options): Promise<void>;
370}