@cdwr/fly-node 0.1.0

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.
@@ -0,0 +1,414 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Fly status response schema
4
+ *
5
+ * ```ts
6
+ * fly status --app [name] --json
7
+ * ```
8
+ */
9
+ export declare const statusFlyResponseSchema: z.ZodObject<{
10
+ deployed: z.ZodBoolean;
11
+ hostname: z.ZodString;
12
+ id: z.ZodString;
13
+ machines: z.ZodArray<z.ZodObject<{
14
+ id: z.ZodString;
15
+ name: z.ZodString;
16
+ state: z.ZodString;
17
+ region: z.ZodString;
18
+ createdAt: z.ZodString;
19
+ updatedAt: z.ZodString;
20
+ config: z.ZodObject<{
21
+ env: z.ZodRecord<z.ZodString, z.ZodString>;
22
+ metadata: z.ZodRecord<z.ZodString, z.ZodString>;
23
+ }, "strip", z.ZodTypeAny, {
24
+ env: Record<string, string>;
25
+ metadata: Record<string, string>;
26
+ }, {
27
+ env: Record<string, string>;
28
+ metadata: Record<string, string>;
29
+ }>;
30
+ events: z.ZodArray<z.ZodObject<{
31
+ type: z.ZodString;
32
+ status: z.ZodString;
33
+ timestamp: z.ZodNumber;
34
+ }, "strip", z.ZodTypeAny, {
35
+ type: string;
36
+ status: string;
37
+ timestamp: number;
38
+ }, {
39
+ type: string;
40
+ status: string;
41
+ timestamp: number;
42
+ }>, "many">;
43
+ checks: z.ZodOptional<z.ZodArray<z.ZodObject<{
44
+ name: z.ZodString;
45
+ status: z.ZodString;
46
+ output: z.ZodString;
47
+ updatedAt: z.ZodString;
48
+ }, "strip", z.ZodTypeAny, {
49
+ name: string;
50
+ status: string;
51
+ updatedAt: string;
52
+ output: string;
53
+ }, {
54
+ name: string;
55
+ status: string;
56
+ updatedAt: string;
57
+ output: string;
58
+ }>, "many">>;
59
+ hostStatus: z.ZodString;
60
+ }, "strip", z.ZodTypeAny, {
61
+ name: string;
62
+ id: string;
63
+ createdAt: string;
64
+ state: string;
65
+ region: string;
66
+ updatedAt: string;
67
+ config: {
68
+ env: Record<string, string>;
69
+ metadata: Record<string, string>;
70
+ };
71
+ events: {
72
+ type: string;
73
+ status: string;
74
+ timestamp: number;
75
+ }[];
76
+ hostStatus: string;
77
+ checks?: {
78
+ name: string;
79
+ status: string;
80
+ updatedAt: string;
81
+ output: string;
82
+ }[] | undefined;
83
+ }, {
84
+ name: string;
85
+ id: string;
86
+ createdAt: string;
87
+ state: string;
88
+ region: string;
89
+ updatedAt: string;
90
+ config: {
91
+ env: Record<string, string>;
92
+ metadata: Record<string, string>;
93
+ };
94
+ events: {
95
+ type: string;
96
+ status: string;
97
+ timestamp: number;
98
+ }[];
99
+ hostStatus: string;
100
+ checks?: {
101
+ name: string;
102
+ status: string;
103
+ updatedAt: string;
104
+ output: string;
105
+ }[] | undefined;
106
+ }>, "many">;
107
+ name: z.ZodString;
108
+ organization: z.ZodObject<{
109
+ id: z.ZodString;
110
+ slug: z.ZodString;
111
+ }, "strip", z.ZodTypeAny, {
112
+ id: string;
113
+ slug: string;
114
+ }, {
115
+ id: string;
116
+ slug: string;
117
+ }>;
118
+ status: z.ZodString;
119
+ version: z.ZodNumber;
120
+ }, "strip", z.ZodTypeAny, {
121
+ name: string;
122
+ status: string;
123
+ id: string;
124
+ organization: {
125
+ id: string;
126
+ slug: string;
127
+ };
128
+ deployed: boolean;
129
+ hostname: string;
130
+ version: number;
131
+ machines: {
132
+ name: string;
133
+ id: string;
134
+ createdAt: string;
135
+ state: string;
136
+ region: string;
137
+ updatedAt: string;
138
+ config: {
139
+ env: Record<string, string>;
140
+ metadata: Record<string, string>;
141
+ };
142
+ events: {
143
+ type: string;
144
+ status: string;
145
+ timestamp: number;
146
+ }[];
147
+ hostStatus: string;
148
+ checks?: {
149
+ name: string;
150
+ status: string;
151
+ updatedAt: string;
152
+ output: string;
153
+ }[] | undefined;
154
+ }[];
155
+ }, {
156
+ name: string;
157
+ status: string;
158
+ id: string;
159
+ organization: {
160
+ id: string;
161
+ slug: string;
162
+ };
163
+ deployed: boolean;
164
+ hostname: string;
165
+ version: number;
166
+ machines: {
167
+ name: string;
168
+ id: string;
169
+ createdAt: string;
170
+ state: string;
171
+ region: string;
172
+ updatedAt: string;
173
+ config: {
174
+ env: Record<string, string>;
175
+ metadata: Record<string, string>;
176
+ };
177
+ events: {
178
+ type: string;
179
+ status: string;
180
+ timestamp: number;
181
+ }[];
182
+ hostStatus: string;
183
+ checks?: {
184
+ name: string;
185
+ status: string;
186
+ updatedAt: string;
187
+ output: string;
188
+ }[] | undefined;
189
+ }[];
190
+ }>;
191
+ /**
192
+ * Transformed status response schema
193
+ *
194
+ * ```ts
195
+ * fly status --app [name] --json
196
+ * ```
197
+ */
198
+ export declare const StatusTransformedResponseSchema: z.ZodEffects<z.ZodObject<{
199
+ deployed: z.ZodBoolean;
200
+ hostname: z.ZodString;
201
+ id: z.ZodString;
202
+ machines: z.ZodArray<z.ZodObject<{
203
+ id: z.ZodString;
204
+ name: z.ZodString;
205
+ state: z.ZodString;
206
+ region: z.ZodString;
207
+ createdAt: z.ZodString;
208
+ updatedAt: z.ZodString;
209
+ config: z.ZodObject<{
210
+ env: z.ZodRecord<z.ZodString, z.ZodString>;
211
+ metadata: z.ZodRecord<z.ZodString, z.ZodString>;
212
+ }, "strip", z.ZodTypeAny, {
213
+ env: Record<string, string>;
214
+ metadata: Record<string, string>;
215
+ }, {
216
+ env: Record<string, string>;
217
+ metadata: Record<string, string>;
218
+ }>;
219
+ events: z.ZodArray<z.ZodObject<{
220
+ type: z.ZodString;
221
+ status: z.ZodString;
222
+ timestamp: z.ZodNumber;
223
+ }, "strip", z.ZodTypeAny, {
224
+ type: string;
225
+ status: string;
226
+ timestamp: number;
227
+ }, {
228
+ type: string;
229
+ status: string;
230
+ timestamp: number;
231
+ }>, "many">;
232
+ checks: z.ZodOptional<z.ZodArray<z.ZodObject<{
233
+ name: z.ZodString;
234
+ status: z.ZodString;
235
+ output: z.ZodString;
236
+ updatedAt: z.ZodString;
237
+ }, "strip", z.ZodTypeAny, {
238
+ name: string;
239
+ status: string;
240
+ updatedAt: string;
241
+ output: string;
242
+ }, {
243
+ name: string;
244
+ status: string;
245
+ updatedAt: string;
246
+ output: string;
247
+ }>, "many">>;
248
+ hostStatus: z.ZodString;
249
+ }, "strip", z.ZodTypeAny, {
250
+ name: string;
251
+ id: string;
252
+ createdAt: string;
253
+ state: string;
254
+ region: string;
255
+ updatedAt: string;
256
+ config: {
257
+ env: Record<string, string>;
258
+ metadata: Record<string, string>;
259
+ };
260
+ events: {
261
+ type: string;
262
+ status: string;
263
+ timestamp: number;
264
+ }[];
265
+ hostStatus: string;
266
+ checks?: {
267
+ name: string;
268
+ status: string;
269
+ updatedAt: string;
270
+ output: string;
271
+ }[] | undefined;
272
+ }, {
273
+ name: string;
274
+ id: string;
275
+ createdAt: string;
276
+ state: string;
277
+ region: string;
278
+ updatedAt: string;
279
+ config: {
280
+ env: Record<string, string>;
281
+ metadata: Record<string, string>;
282
+ };
283
+ events: {
284
+ type: string;
285
+ status: string;
286
+ timestamp: number;
287
+ }[];
288
+ hostStatus: string;
289
+ checks?: {
290
+ name: string;
291
+ status: string;
292
+ updatedAt: string;
293
+ output: string;
294
+ }[] | undefined;
295
+ }>, "many">;
296
+ name: z.ZodString;
297
+ organization: z.ZodObject<{
298
+ id: z.ZodString;
299
+ slug: z.ZodString;
300
+ }, "strip", z.ZodTypeAny, {
301
+ id: string;
302
+ slug: string;
303
+ }, {
304
+ id: string;
305
+ slug: string;
306
+ }>;
307
+ status: z.ZodString;
308
+ version: z.ZodNumber;
309
+ }, "strip", z.ZodTypeAny, {
310
+ name: string;
311
+ status: string;
312
+ id: string;
313
+ organization: {
314
+ id: string;
315
+ slug: string;
316
+ };
317
+ deployed: boolean;
318
+ hostname: string;
319
+ version: number;
320
+ machines: {
321
+ name: string;
322
+ id: string;
323
+ createdAt: string;
324
+ state: string;
325
+ region: string;
326
+ updatedAt: string;
327
+ config: {
328
+ env: Record<string, string>;
329
+ metadata: Record<string, string>;
330
+ };
331
+ events: {
332
+ type: string;
333
+ status: string;
334
+ timestamp: number;
335
+ }[];
336
+ hostStatus: string;
337
+ checks?: {
338
+ name: string;
339
+ status: string;
340
+ updatedAt: string;
341
+ output: string;
342
+ }[] | undefined;
343
+ }[];
344
+ }, {
345
+ name: string;
346
+ status: string;
347
+ id: string;
348
+ organization: {
349
+ id: string;
350
+ slug: string;
351
+ };
352
+ deployed: boolean;
353
+ hostname: string;
354
+ version: number;
355
+ machines: {
356
+ name: string;
357
+ id: string;
358
+ createdAt: string;
359
+ state: string;
360
+ region: string;
361
+ updatedAt: string;
362
+ config: {
363
+ env: Record<string, string>;
364
+ metadata: Record<string, string>;
365
+ };
366
+ events: {
367
+ type: string;
368
+ status: string;
369
+ timestamp: number;
370
+ }[];
371
+ hostStatus: string;
372
+ checks?: {
373
+ name: string;
374
+ status: string;
375
+ updatedAt: string;
376
+ output: string;
377
+ }[] | undefined;
378
+ }[];
379
+ }>, {
380
+ name: string;
381
+ status: string;
382
+ id: string;
383
+ organization: {
384
+ id: string;
385
+ slug: string;
386
+ };
387
+ deployed: boolean;
388
+ hostname: string;
389
+ version: number;
390
+ machines: {
391
+ name: string;
392
+ id: string;
393
+ createdAt: string;
394
+ state: string;
395
+ region: string;
396
+ updatedAt: string;
397
+ config: {
398
+ env: Record<string, string>;
399
+ metadata: Record<string, string>;
400
+ };
401
+ events: {
402
+ type: string;
403
+ status: string;
404
+ timestamp: number;
405
+ }[];
406
+ hostStatus: string;
407
+ checks?: {
408
+ name: string;
409
+ status: string;
410
+ updatedAt: string;
411
+ output: string;
412
+ }[] | undefined;
413
+ }[];
414
+ }, unknown>;
@@ -0,0 +1,283 @@
1
+ import { z } from 'zod';
2
+ import { AppsCreateTransformedResponseSchema } from './schemas/apps-create.schema';
3
+ import { AppsListTransformedResponseSchema } from './schemas/apps-list.schema';
4
+ import { CertsListWithAppTransformedResponseSchema } from './schemas/certs-list-with-app.schema';
5
+ import { CertsListTransformedResponseSchema } from './schemas/certs-list.schema';
6
+ import { ConfigShowResponseSchema } from './schemas/config-show.schema';
7
+ import { DeployResponseSchema } from './schemas/deploy.schema';
8
+ import { PostgresListTransformedResponseSchema } from './schemas/postgres-list';
9
+ import { PostgresUsersListTransformedResponseSchema } from './schemas/postgres-users-list';
10
+ import { SecretsListWithAppTransformedResponseSchema } from './schemas/secrets-list-with-app.schema';
11
+ import { SecretsListTransformedResponseSchema } from './schemas/secrets-list.schema';
12
+ import { StatusTransformedResponseSchema } from './schemas/status.schema';
13
+ /** List applications */
14
+ export type ListAppResponse = z.infer<typeof AppsListTransformedResponseSchema.element>;
15
+ /** Create an application */
16
+ export type CreateAppResponse = z.infer<typeof AppsCreateTransformedResponseSchema>;
17
+ /** Deploy application response */
18
+ export type DeployResponse = z.infer<typeof DeployResponseSchema>;
19
+ /** List certificates for an application */
20
+ export type ListCertForAppResponse = z.infer<typeof CertsListTransformedResponseSchema.element>;
21
+ /** List certificates for all applications */
22
+ export type ListCertForAllResponse = z.infer<typeof CertsListWithAppTransformedResponseSchema.element>;
23
+ /** List secrets for an application */
24
+ export type ListSecretForAppResponse = z.infer<typeof SecretsListTransformedResponseSchema.element>;
25
+ /** List secrets for all applications */
26
+ export type ListSecretForAllResponse = z.infer<typeof SecretsListWithAppTransformedResponseSchema.element>;
27
+ /** List postgres databases */
28
+ export type ListPostgresResponse = z.infer<typeof PostgresListTransformedResponseSchema.element>;
29
+ /** List users for a postgres database application */
30
+ export type ListPostgresUsersResponse = z.infer<typeof PostgresUsersListTransformedResponseSchema.element>;
31
+ /** Show application configuration */
32
+ export type ShowConfigResponse = z.infer<typeof ConfigShowResponseSchema>;
33
+ /** Get the status of an application */
34
+ export type StatusResponse = z.infer<typeof StatusTransformedResponseSchema>;
35
+ /**
36
+ * Configuration options for the Fly class.
37
+ */
38
+ export type Config = {
39
+ /**
40
+ * Authenticate using a Fly API access token.
41
+ *
42
+ * This token is used unless a currently logged in user is detected.
43
+ *
44
+ * As alternative to token, the `FLY_API_TOKEN` environment variable is also supported.
45
+ */
46
+ token?: string;
47
+ /**
48
+ * The target organisation for your apps.
49
+ *
50
+ * Defaults to your personal organisation.
51
+ */
52
+ org?: string;
53
+ /**
54
+ * The target region for your apps.
55
+ *
56
+ * Defaults to auto-detect the fastest location.
57
+ */
58
+ region?: string;
59
+ /**
60
+ * Customize the logging behaviour.
61
+ */
62
+ logger?: Partial<Logger>;
63
+ } & ({
64
+ /**
65
+ * Name of the application to initiate commands on.
66
+ *
67
+ * Use it when your current workspace doesn't have a fly configuration file
68
+ * or you want to target a different application.
69
+ *
70
+ * Defaults to the application defined in `fly.toml` in the current workspace.
71
+ */
72
+ app?: string;
73
+ } | {
74
+ /**
75
+ * Path to the fly configuration file to initiate commands on.
76
+ *
77
+ * Use it when your current workspace doesn't have a fly configuration file.
78
+ */
79
+ config?: string;
80
+ });
81
+ /**
82
+ * Options for initiating commands
83
+ * where the application or configuration is optional
84
+ */
85
+ export type AppOrConfig = {
86
+ /**
87
+ * Name of the application.
88
+ *
89
+ * Defaults to the application in the class configuration.
90
+ */
91
+ app?: string;
92
+ } | {
93
+ /**
94
+ * Path to the fly configuration file.
95
+ *
96
+ * Defaults to the file in the class configuration.
97
+ */
98
+ config?: string;
99
+ };
100
+ /**
101
+ * Options for creating an application
102
+ */
103
+ export type CreateAppOptions = {
104
+ /**
105
+ * Name of the application to create.
106
+ *
107
+ * Defaults to a generated name.
108
+ */
109
+ app?: string;
110
+ /**
111
+ * Target organisation for your app.
112
+ *
113
+ * Defaults to the organisation in the class configuration.
114
+ */
115
+ org?: string;
116
+ };
117
+ /**
118
+ * Options for deploying an application
119
+ */
120
+ export type DeployAppOptions = {
121
+ /**
122
+ * Name of the application to deploy.
123
+ *
124
+ * This name can be different from what's defined in the `fly.toml` file.
125
+ * You can for example deploy to a new application but reuse a blueprint.
126
+ *
127
+ * Defaults to the class configuration app or config app, or the app defined in `fly.toml` in the current workspace.
128
+ */
129
+ app?: string;
130
+ /**
131
+ * Path to the `fly.toml` file to deploy.
132
+ *
133
+ * Defaults to the class configuration or the `fly.toml` in the working directory.
134
+ */
135
+ config?: string;
136
+ /**
137
+ * Environment variables to set for the application.
138
+ *
139
+ * Spaces are supported in values.
140
+ */
141
+ env?: Record<string, string>;
142
+ /**
143
+ * Target environment for the application.
144
+ *
145
+ * Environment variable `DEPLOY_ENV` will be set to the provided value.
146
+ *
147
+ * _Typical values for a preview environment can be `'staging'`, `'testing'`, `'development'`, `'preview'`, `'review'`, etc.
148
+ * This is up to the developer to choose._
149
+ */
150
+ environment?: string;
151
+ /**
152
+ * Target organisation for the application.
153
+ *
154
+ * Only used when a new application must be created.
155
+ * Defaults to the organisation in the class configuration.
156
+ */
157
+ org?: string;
158
+ /**
159
+ * Attach to a Postgres database application.
160
+ *
161
+ * Connection details will be provided via environment variable `DATABASE_URL`.
162
+ */
163
+ postgres?: string;
164
+ /**
165
+ * Target region for the application.
166
+ *
167
+ * Defaults to the region in the class configuration.
168
+ */
169
+ region?: string;
170
+ /**
171
+ * Secrets to set for the application.
172
+ *
173
+ * Spaces are supported in values.
174
+ */
175
+ secrets?: Record<string, string>;
176
+ };
177
+ /**
178
+ * Options for destroying an application
179
+ */
180
+ export type DestroyAppOptions = {
181
+ /**
182
+ * Whether to force the destruction of the application.
183
+ *
184
+ * Defaults to `false`.
185
+ */
186
+ force?: boolean;
187
+ };
188
+ /**
189
+ * Options for showing an application's configuration
190
+ */
191
+ export type ShowConfigOptions = {
192
+ /**
193
+ * Name of the application to show the remote configuration for.
194
+ */
195
+ app?: string;
196
+ } | {
197
+ /**
198
+ * Path to a `fly.toml` file to extract the application name from.
199
+ *
200
+ * The configuration will be fetched from the application on remote.
201
+ */
202
+ config?: string;
203
+ /**
204
+ * Whether to show the local `fly.toml` file instead of the remote configuration.
205
+ *
206
+ * Use this option when the application is not deployed yet.
207
+ *
208
+ * Defaults to `false`.
209
+ */
210
+ local?: boolean;
211
+ };
212
+ /**
213
+ * Options for setting application secrets
214
+ */
215
+ export type SetAppSecretsOptions = AppOrConfig & {
216
+ /**
217
+ * Whether to only stage the secrets and skip the deployment.
218
+ */
219
+ stage?: boolean;
220
+ };
221
+ /**
222
+ * Options for unsetting application secrets
223
+ */
224
+ export type UnsetAppSecretsOptions = SetAppSecretsOptions;
225
+ /**
226
+ * Extended application status
227
+ */
228
+ export type StatusExtendedResponse = StatusResponse & {
229
+ domains: Array<Pick<ListCertForAppResponse, 'hostname'>>;
230
+ secrets: Array<Pick<ListSecretForAppResponse, 'name'>>;
231
+ };
232
+ /**
233
+ * Logger interface using the `console` signature
234
+ */
235
+ export type Logger = {
236
+ /**
237
+ * Log informational messages function.
238
+ *
239
+ * Defaults to `console.log`.
240
+ */
241
+ info: typeof console.log;
242
+ /**
243
+ * Log error messages function.
244
+ *
245
+ * Defaults to `console.error`.
246
+ */
247
+ error: typeof console.error;
248
+ /**
249
+ * Whether to trace the `flyctl` CLI commands.
250
+ *
251
+ * Logs the Fly CLI commands being called and the returned results
252
+ * with special formatting for better readability.
253
+ *
254
+ * It's useful for debugging the CLI commands or just to see what's happening under the hood.
255
+ *
256
+ * Errors are most likely to be unknown application names or missing configuration files
257
+ * that are hidden from the user by the library.
258
+ *
259
+ * Defaults to `false`.
260
+ *
261
+ * @example
262
+ *
263
+ * ```sh
264
+ * # success
265
+ * [ CALL ] flyctl auth whoami
266
+ * [RESULT] auth@user.io
267
+ * [ CALL ] flyctl certs list --app demo-app --json
268
+ * [RESULT] [
269
+ * {
270
+ * "CreatedAt": "2022-11-20T22:36:46Z",
271
+ * "Hostname": "*.demo-app.io",
272
+ * "ClientStatus": "Ready"
273
+ * },
274
+ * ]
275
+ *
276
+ * # error
277
+ * [ CALL ] flyctl status --config apps/demo-app/fly.toml --json
278
+ * [RESULT] Error: Command failed: flyctl status --config apps/demo-app/fly.toml --json
279
+ * Error: the config for your app is missing an app name, add an app field to the fly.toml file or specify with the -a flag
280
+ * ```
281
+ */
282
+ traceCLI: boolean;
283
+ };