@cdwr/fly-node 0.2.3 → 0.3.1

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,6 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  import { AppsCreateTransformedResponseSchema } from './schemas/apps-create.schema';
3
3
  import { AppsListTransformedResponseSchema } from './schemas/apps-list.schema';
4
+ import { BuildResponseSchema } from './schemas/build-response.schema';
4
5
  import { CertsListWithAppTransformedResponseSchema } from './schemas/certs-list-with-app.schema';
5
6
  import { CertsListTransformedResponseSchema } from './schemas/certs-list.schema';
6
7
  import { ConfigShowResponseSchema } from './schemas/config-show.schema';
@@ -10,38 +11,43 @@ import { PostgresUsersListTransformedResponseSchema } from './schemas/postgres-u
10
11
  import { SecretsListWithAppTransformedResponseSchema } from './schemas/secrets-list-with-app.schema';
11
12
  import { SecretsListTransformedResponseSchema } from './schemas/secrets-list.schema';
12
13
  import { StatusTransformedResponseSchema } from './schemas/status.schema';
14
+ import { VersionTransformedResponseSchema } from './schemas/version.schema';
13
15
  /** List applications */
14
- export type ListAppResponse = z.infer<typeof AppsListTransformedResponseSchema.element>;
16
+ export type ListAppResponse = z.infer<typeof AppsListTransformedResponseSchema>;
15
17
  /** Create an application */
16
18
  export type CreateAppResponse = z.infer<typeof AppsCreateTransformedResponseSchema>;
19
+ /** Build application image response */
20
+ export type BuildResponse = z.infer<typeof BuildResponseSchema>;
17
21
  /** Deploy application response */
18
22
  export type DeployResponse = z.infer<typeof DeployResponseSchema>;
19
23
  /** List certificates for an application */
20
- export type ListCertForAppResponse = z.infer<typeof CertsListTransformedResponseSchema.element>;
24
+ export type ListCertForAppResponse = z.infer<typeof CertsListTransformedResponseSchema>;
21
25
  /** List certificates for all applications */
22
- export type ListCertForAllResponse = z.infer<typeof CertsListWithAppTransformedResponseSchema.element>;
26
+ export type ListCertForAllResponse = z.infer<typeof CertsListWithAppTransformedResponseSchema>;
23
27
  /** List secrets for an application */
24
- export type ListSecretForAppResponse = z.infer<typeof SecretsListTransformedResponseSchema.element>;
28
+ export type ListSecretForAppResponse = z.infer<typeof SecretsListTransformedResponseSchema>;
25
29
  /** List secrets for all applications */
26
- export type ListSecretForAllResponse = z.infer<typeof SecretsListWithAppTransformedResponseSchema.element>;
30
+ export type ListSecretForAllResponse = z.infer<typeof SecretsListWithAppTransformedResponseSchema>;
27
31
  /** List postgres databases */
28
- export type ListPostgresResponse = z.infer<typeof PostgresListTransformedResponseSchema.element>;
32
+ export type ListPostgresResponse = z.infer<typeof PostgresListTransformedResponseSchema>;
33
+ /** `ListPostgresResponse` without the string option */
34
+ export type ListPostgresResponseWithoutString = Exclude<ListPostgresResponse, string>;
29
35
  /** List users for a postgres database application */
30
- export type ListPostgresUsersResponse = z.infer<typeof PostgresUsersListTransformedResponseSchema.element>;
36
+ export type ListPostgresUsersResponse = z.infer<typeof PostgresUsersListTransformedResponseSchema>;
31
37
  /** Show application configuration */
32
38
  export type ShowConfigResponse = z.infer<typeof ConfigShowResponseSchema>;
33
39
  /** Get the status of an application */
34
40
  export type StatusResponse = z.infer<typeof StatusTransformedResponseSchema>;
41
+ /** Get the version information of the Fly CLI */
42
+ export type VersionResponse = z.infer<typeof VersionTransformedResponseSchema>;
35
43
  /**
36
44
  * Configuration options for the Fly class.
37
45
  */
38
46
  export type Config = {
39
47
  /**
40
- * Authenticate using a Fly API access token.
48
+ * Authenticate using a Fly token.
41
49
  *
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.
50
+ * Fall back to environment variables `FLY_ACCESS_TOKEN` or `FLY_API_TOKEN`.
45
51
  */
46
52
  token?: string;
47
53
  /**
@@ -139,6 +145,13 @@ export type DeployAppOptions = {
139
145
  * Spaces are supported in values.
140
146
  */
141
147
  env?: Record<string, string>;
148
+ /**
149
+ * Build arguments to pass to the Docker build.
150
+ *
151
+ * These are available during the build phase (e.g. NEXT_PUBLIC_ vars, etc.).
152
+ * Use `env` for runtime environment variables instead.
153
+ */
154
+ buildArgs?: Record<string, string>;
142
155
  /**
143
156
  * Target environment for the application.
144
157
  *
@@ -161,6 +174,13 @@ export type DeployAppOptions = {
161
174
  * Connection details will be provided via environment variable `DATABASE_URL`.
162
175
  */
163
176
  postgres?: string;
177
+ /**
178
+ * Database name to use when attaching to Postgres.
179
+ *
180
+ * If not specified, Fly will create a database with a default name.
181
+ * Use this to ensure multiple apps share the same database.
182
+ */
183
+ databaseName?: string;
164
184
  /**
165
185
  * Target region for the application.
166
186
  *
@@ -173,23 +193,47 @@ export type DeployAppOptions = {
173
193
  * Spaces are supported in values.
174
194
  */
175
195
  secrets?: Record<string, string>;
196
+ /**
197
+ * Docker image to use for deployment.
198
+ *
199
+ * This allows deploying with an existing image instead of rebuilding.
200
+ * Useful for config-only updates where you want to reuse the current image.
201
+ *
202
+ * Format: Can be either a full image reference (e.g., `registry.fly.io/app:tag`)
203
+ * or just the image tag from the registry (the shorthand will be expanded to the full reference).
204
+ *
205
+ * When provided, the build phase is skipped and the deployment uses the specified image.
206
+ */
207
+ image?: string;
208
+ /**
209
+ * Build the image and push it to the registry without deploying.
210
+ *
211
+ * Use this to separate the build phase from the deploy phase.
212
+ * The image reference is returned and can be passed to a subsequent
213
+ * deploy call via the `image` option to skip rebuilding.
214
+ *
215
+ * Defaults to `false`.
216
+ */
217
+ buildOnly?: boolean;
176
218
  /**
177
219
  * Whether to opt out of the Depot Builder.
178
220
  *
179
221
  * Defaults to `false`.
180
222
  */
181
223
  optOutDepotBuilder?: boolean;
182
- };
183
- /**
184
- * Options for destroying an application
185
- */
186
- export type DestroyAppOptions = {
187
224
  /**
188
- * Whether to force the destruction of the application.
225
+ * Whether to prefer remote configuration for existing apps.
226
+ *
227
+ * When enabled and the app already exists on Fly:
228
+ * - Saves the remote configuration locally to `{app-root}/fly.{app-name}.toml`
229
+ * - Uses the remote config for deployment
230
+ *
231
+ * When disabled or the app doesn't exist:
232
+ * - Uses the local config file specified in the `config` option
189
233
  *
190
234
  * Defaults to `false`.
191
235
  */
192
- force?: boolean;
236
+ preferRemoteConfig?: boolean;
193
237
  };
194
238
  /**
195
239
  * Options for showing an application's configuration
@@ -215,6 +259,23 @@ export type ShowConfigOptions = {
215
259
  */
216
260
  local?: boolean;
217
261
  };
262
+ /**
263
+ * Options for saving an application's configuration to a local file
264
+ */
265
+ export type SaveConfigOptions = {
266
+ /**
267
+ * Name of the application to save the remote configuration for.
268
+ */
269
+ app: string;
270
+ /**
271
+ * Path to save the configuration file to.
272
+ *
273
+ * The format is read from this path's extension — `.json` and `.yaml`/
274
+ * `.yml` request that output from flyctl explicitly, anything else saves
275
+ * as TOML.
276
+ */
277
+ config: string;
278
+ };
218
279
  /**
219
280
  * Options for setting application secrets
220
281
  */
@@ -228,12 +289,25 @@ export type SetAppSecretsOptions = AppOrConfig & {
228
289
  * Options for unsetting application secrets
229
290
  */
230
291
  export type UnsetAppSecretsOptions = SetAppSecretsOptions;
292
+ /**
293
+ * Options for machine operations (start, stop, restart)
294
+ */
295
+ export type MachineOperationOptions = {
296
+ /**
297
+ * Name of the application
298
+ */
299
+ app: string;
300
+ /**
301
+ * Machine ID to perform the operation on
302
+ */
303
+ machineId: string;
304
+ };
231
305
  /**
232
306
  * Extended application status
233
307
  */
234
308
  export type StatusExtendedResponse = StatusResponse & {
235
- domains: Array<Pick<ListCertForAppResponse, 'hostname'>>;
236
- secrets: Array<Pick<ListSecretForAppResponse, 'name'>>;
309
+ domains: Array<Pick<ListCertForAppResponse[number], 'hostname'>>;
310
+ secrets: Array<Pick<ListSecretForAppResponse[number], 'name'>>;
237
311
  };
238
312
  /**
239
313
  * Logger interface using the `console` signature
@@ -286,4 +360,68 @@ export type Logger = {
286
360
  * ```
287
361
  */
288
362
  traceCLI: boolean;
363
+ /**
364
+ * Enable verbose output for Fly CLI commands (e.g., Docker build logs)
365
+ *
366
+ * When enabled, adds `--verbose` flag to commands.
367
+ *
368
+ * @default false
369
+ */
370
+ verbose: boolean;
371
+ /**
372
+ * Enable debug output for Fly CLI commands
373
+ *
374
+ * When enabled, adds `--debug` flag to commands for detailed debugging information.
375
+ *
376
+ * @default false
377
+ */
378
+ debug: boolean;
379
+ /**
380
+ * Stream command output to console in real-time
381
+ *
382
+ * When enabled, stdout and stderr are piped to the console in real-time
383
+ * while still being captured for JSON parsing and result processing.
384
+ * Useful for long-running commands like deployments where you want to see progress.
385
+ *
386
+ * Works independently from `traceCLI`, `verbose`, and `debug`.
387
+ *
388
+ * @default false
389
+ */
390
+ streamToConsole: boolean;
391
+ /**
392
+ * Redact sensitive call values in CLI trace logs.
393
+ *
394
+ * When enabled, secrets and tokens are masked:
395
+ * - Values > 10 chars: first 3 + [REDACTED] + last 3 (e.g., "foo[REDACTED]bar")
396
+ * - Values ≤ 10 chars: [REDACTED]
397
+ *
398
+ * Redacts:
399
+ * - `secrets set KEY1=VALUE1 KEY2=VALUE2 ...`
400
+ *
401
+ * Only applies when `traceCLI` is `true`.
402
+ *
403
+ * @default true
404
+ *
405
+ * @example
406
+ *
407
+ * ```ts
408
+ * const fly = new Fly({
409
+ * logger: {
410
+ * traceCLI: true,
411
+ * redactSecrets: true
412
+ * }
413
+ * });
414
+ * ```
415
+ *
416
+ * @example
417
+ *
418
+ * ```sh
419
+ * # Without redaction:
420
+ * [ CALL ] flyctl secrets set API_KEY=secret!
421
+ *
422
+ * # With redaction:
423
+ * [ CALL ] flyctl secrets set API_KEY=[REDACTED]
424
+ * ```
425
+ */
426
+ redactSecrets?: boolean;
289
427
  };