modal 0.3.19 → 0.3.21

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.
package/dist/index.d.cts CHANGED
@@ -69,7 +69,7 @@ type SecretFromNameOptions = {
69
69
  environment?: string;
70
70
  requiredKeys?: string[];
71
71
  };
72
- /** Secrets provide a dictionary of environment variables for images. */
72
+ /** Secrets provide a dictionary of environment variables for Images. */
73
73
  declare class Secret {
74
74
  readonly secretId: string;
75
75
  readonly name?: string;
@@ -83,51 +83,55 @@ declare class Secret {
83
83
  }): Promise<Secret>;
84
84
  }
85
85
 
86
- /** A container image, used for starting sandboxes. */
86
+ /** Options for deleting an Image. */
87
+ type ImageDeleteOptions = Record<never, never>;
88
+ /** A container image, used for starting Sandboxes. */
87
89
  declare class Image {
88
90
  #private;
89
91
  /** @ignore */
90
92
  constructor(imageId: string, tag: string, imageRegistryConfig?: ImageRegistryConfig);
91
93
  get imageId(): string;
92
94
  /**
93
- * Creates an `Image` instance from an image id
95
+ * Creates an Image from an Image ID
94
96
  *
95
- * @param imageId - Image id.
97
+ * @param imageId - Image ID.
96
98
  */
97
- static fromId(imageId: string): Image;
99
+ static fromId(imageId: string): Promise<Image>;
98
100
  /**
99
- * Creates an `Image` instance from a raw registry tag, optionally using a secret for authentication.
101
+ * Creates an Image from a raw registry tag, optionally using a Secret for authentication.
100
102
  *
101
- * @param tag - The registry tag for the image.
102
- * @param secret - Optional. A `Secret` instance containing credentials for registry authentication.
103
+ * @param tag - The registry tag for the Image.
104
+ * @param secret - Optional. A Secret containing credentials for registry authentication.
103
105
  */
104
106
  static fromRegistry(tag: string, secret?: Secret): Image;
105
107
  /**
106
- * Creates an `Image` instance from a raw registry tag, optionally using a secret for authentication.
108
+ * Creates an Image from a raw registry tag, optionally using a Secret for authentication.
107
109
  *
108
- * @param tag - The registry tag for the image.
109
- * @param secret - A `Secret` instance containing credentials for registry authentication.
110
+ * @param tag - The registry tag for the Image.
111
+ * @param secret - A Secret containing credentials for registry authentication.
110
112
  */
111
113
  static fromAwsEcr(tag: string, secret: Secret): Image;
112
114
  /**
113
- * Creates an `Image` instance from a raw registry tag, optionally using a secret for authentication.
115
+ * Creates an Image from a raw registry tag, optionally using a Secret for authentication.
114
116
  *
115
- * @param tag - The registry tag for the image.
116
- * @param secret - A `Secret` instance containing credentials for registry authentication.
117
+ * @param tag - The registry tag for the Image.
118
+ * @param secret - A Secret containing credentials for registry authentication.
117
119
  */
118
120
  static fromGcpArtifactRegistry(tag: string, secret: Secret): Image;
119
121
  /**
120
- * Eagerly builds an `Image` on Modal.
122
+ * Eagerly builds an Image on Modal.
121
123
  *
122
- * @param app - App to use to build image.
124
+ * @param app - App to use to build the Image.
123
125
  */
124
126
  build(app: App): Promise<Image>;
127
+ /** Delete an Image by ID. Warning: This removes an *entire Image*, and cannot be undone. */
128
+ static delete(imageId: string, _?: ImageDeleteOptions): Promise<void>;
125
129
  }
126
130
 
127
131
  /** File open modes supported by the filesystem API. */
128
132
  type SandboxFileMode = "r" | "w" | "a" | "r+" | "w+" | "a+";
129
133
  /**
130
- * SandboxFile represents an open file in the sandbox filesystem.
134
+ * SandboxFile represents an open file in the Sandbox filesystem.
131
135
  * Provides read/write operations similar to Node.js `fsPromises.FileHandle`.
132
136
  */
133
137
  declare class SandboxFile {
@@ -199,16 +203,16 @@ interface ModalWriteStream<R = any> extends WritableStream<R> {
199
203
  */
200
204
  type StdioBehavior = "pipe" | "ignore";
201
205
  /**
202
- * Specifies the type of data that will be read from the sandbox or container
206
+ * Specifies the type of data that will be read from the Sandbox or container
203
207
  * process. "text" means the data will be read as UTF-8 text, while "binary"
204
208
  * means the data will be read as raw bytes (Uint8Array).
205
209
  */
206
210
  type StreamMode = "text" | "binary";
207
211
  /** Options for `Sandbox.list()`. */
208
212
  type SandboxListOptions = {
209
- /** Filter sandboxes for a specific app. */
213
+ /** Filter Sandboxes for a specific App. */
210
214
  appId?: string;
211
- /** Only return sandboxes that include all specified tags. */
215
+ /** Only return Sandboxes that include all specified tags. */
212
216
  tags?: Record<string, string>;
213
217
  /** Override environment for the request; defaults to current profile. */
214
218
  environment?: string;
@@ -228,7 +232,7 @@ type ExecOptions = {
228
232
  /** Secrets with environment variables for the command. */
229
233
  secrets?: Secret[];
230
234
  };
231
- /** A port forwarded from within a running Modal sandbox. */
235
+ /** A port forwarded from within a running Modal Sandbox. */
232
236
  declare class Tunnel {
233
237
  host: string;
234
238
  port: number;
@@ -264,14 +268,14 @@ declare class Sandbox {
264
268
  * Raises a NotFoundError if no running Sandbox is found with the given name.
265
269
  * A Sandbox's name is the `name` argument passed to `App.createSandbox`.
266
270
  *
267
- * @param appName - Name of the deployed app
268
- * @param name - Name of the sandbox
271
+ * @param appName - Name of the deployed App
272
+ * @param name - Name of the Sandbox
269
273
  * @param environment - Optional override for the environment
270
274
  * @returns Promise that resolves to a Sandbox
271
275
  */
272
276
  static fromName(appName: string, name: string, environment?: string): Promise<Sandbox>;
273
277
  /**
274
- * Open a file in the sandbox filesystem.
278
+ * Open a file in the Sandbox filesystem.
275
279
  * @param path - Path to the file to open
276
280
  * @param mode - File open mode (r, w, a, r+, w+, a+)
277
281
  * @returns Promise that resolves to a SandboxFile
@@ -285,7 +289,7 @@ declare class Sandbox {
285
289
  }): Promise<ContainerProcess<Uint8Array>>;
286
290
  terminate(): Promise<void>;
287
291
  wait(): Promise<number>;
288
- /** Get Tunnel metadata for the sandbox.
292
+ /** Get Tunnel metadata for the Sandbox.
289
293
  *
290
294
  * Raises `SandboxTimeoutError` if the tunnels are not available after the timeout.
291
295
  *
@@ -338,7 +342,7 @@ type VolumeFromNameOptions = {
338
342
  environment?: string;
339
343
  createIfMissing?: boolean;
340
344
  };
341
- /** Volumes provide persistent storage that can be mounted in Modal functions. */
345
+ /** Volumes provide persistent storage that can be mounted in Modal Functions. */
342
346
  declare class Volume {
343
347
  #private;
344
348
  readonly volumeId: string;
@@ -351,11 +355,11 @@ declare class Volume {
351
355
  readOnly(): Volume;
352
356
  get isReadOnly(): boolean;
353
357
  /**
354
- * Create a nameless, temporary volume.
355
- * You will need to call `closeEphemeral()` to delete the volume.
358
+ * Create a nameless, temporary Volume.
359
+ * You will need to call `closeEphemeral()` to delete the Volume.
356
360
  */
357
361
  static ephemeral(options?: EphemeralOptions): Promise<Volume>;
358
- /** Delete the ephemeral volume. Only usable with `Volume.ephemeral()`. */
362
+ /** Delete the ephemeral Volume. Only usable with `Volume.ephemeral()`. */
359
363
  closeEphemeral(): void;
360
364
  }
361
365
 
@@ -372,7 +376,7 @@ declare class Proxy {
372
376
  static fromName(name: string, options?: ProxyFromNameOptions): Promise<Proxy>;
373
377
  }
374
378
 
375
- /** Cloud bucket mounts provide access to cloud storage buckets within Modal functions. */
379
+ /** Cloud Bucket Mounts provide access to cloud storage buckets within Modal Functions. */
376
380
  declare class CloudBucketMount {
377
381
  readonly bucketName: string;
378
382
  readonly secret?: Secret;
@@ -406,46 +410,48 @@ type EphemeralOptions = {
406
410
  };
407
411
  /** Options for `App.createSandbox()`. */
408
412
  type SandboxCreateOptions = {
409
- /** Reservation of physical CPU cores for the sandbox, can be fractional. */
413
+ /** Reservation of physical CPU cores for the Sandbox, can be fractional. */
410
414
  cpu?: number;
411
415
  /** Reservation of memory in MiB. */
412
416
  memory?: number;
413
- /** GPU reservation for the sandbox (e.g. "A100", "T4:2", "A100-80GB:4"). */
417
+ /** GPU reservation for the Sandbox (e.g. "A100", "T4:2", "A100-80GB:4"). */
414
418
  gpu?: string;
415
- /** Timeout of the sandbox container, defaults to 10 minutes. */
419
+ /** Timeout of the Sandbox container, defaults to 10 minutes. */
416
420
  timeout?: number;
417
- /** Working directory of the sandbox. */
421
+ /** The amount of time in milliseconds that a sandbox can be idle before being terminated. */
422
+ idleTimeout?: number;
423
+ /** Working directory of the Sandbox. */
418
424
  workdir?: string;
419
425
  /**
420
426
  * Sequence of program arguments for the main process.
421
427
  * Default behavior is to sleep indefinitely until timeout or termination.
422
428
  */
423
429
  command?: string[];
424
- /** Secrets to inject into the sandbox. */
430
+ /** Secrets to inject into the Sandbox. */
425
431
  secrets?: Secret[];
426
432
  /** Mount points for Modal Volumes. */
427
433
  volumes?: Record<string, Volume>;
428
434
  /** Mount points for cloud buckets. */
429
435
  cloudBucketMounts?: Record<string, CloudBucketMount>;
430
- /** List of ports to tunnel into the sandbox. Encrypted ports are tunneled with TLS. */
436
+ /** List of ports to tunnel into the Sandbox. Encrypted ports are tunneled with TLS. */
431
437
  encryptedPorts?: number[];
432
- /** List of encrypted ports to tunnel into the sandbox, using HTTP/2. */
438
+ /** List of encrypted ports to tunnel into the Sandbox, using HTTP/2. */
433
439
  h2Ports?: number[];
434
- /** List of ports to tunnel into the sandbox without encryption. */
440
+ /** List of ports to tunnel into the Sandbox without encryption. */
435
441
  unencryptedPorts?: number[];
436
- /** Whether to block all network access from the sandbox. */
442
+ /** Whether to block all network access from the Sandbox. */
437
443
  blockNetwork?: boolean;
438
- /** List of CIDRs the sandbox is allowed to access. If None, all CIDRs are allowed. Cannot be used with blockNetwork. */
444
+ /** List of CIDRs the Sandbox is allowed to access. If None, all CIDRs are allowed. Cannot be used with blockNetwork. */
439
445
  cidrAllowlist?: string[];
440
- /** Cloud provider to run the sandbox on. */
446
+ /** Cloud provider to run the Sandbox on. */
441
447
  cloud?: string;
442
- /** Region(s) to run the sandbox on. */
448
+ /** Region(s) to run the Sandbox on. */
443
449
  regions?: string[];
444
450
  /** Enable verbose logging. */
445
451
  verbose?: boolean;
446
452
  /** Reference to a Modal Proxy to use in front of this Sandbox. */
447
453
  proxy?: Proxy;
448
- /** Optional name for the sandbox. Unique within an app. */
454
+ /** Optional name for the Sandbox. Unique within an App. */
449
455
  name?: string;
450
456
  };
451
457
  /** Represents a deployed Modal App. */
@@ -454,7 +460,7 @@ declare class App {
454
460
  readonly name?: string;
455
461
  /** @ignore */
456
462
  constructor(appId: string, name?: string);
457
- /** Lookup a deployed app by name, or create if it does not exist. */
463
+ /** Lookup a deployed App by name, or create if it does not exist. */
458
464
  static lookup(name: string, options?: LookupOptions): Promise<App>;
459
465
  createSandbox(image: Image, options?: SandboxCreateOptions): Promise<Sandbox>;
460
466
  /**
@@ -502,11 +508,11 @@ declare class FunctionCall {
502
508
  readonly functionCallId: string;
503
509
  /** @ignore */
504
510
  constructor(functionCallId: string);
505
- /** Create a new function call from ID. */
511
+ /** Create a new Function call from ID. */
506
512
  fromId(functionCallId: string): FunctionCall;
507
- /** Get the result of a function call, optionally waiting with a timeout. */
513
+ /** Get the result of a Function call, optionally waiting with a timeout. */
508
514
  get(options?: FunctionCallGetOptions): Promise<any>;
509
- /** Cancel a running function call. */
515
+ /** Cancel a running Function call. */
510
516
  cancel(options?: FunctionCallCancelOptions): Promise<void>;
511
517
  }
512
518
 
@@ -536,7 +542,7 @@ declare class Function_ {
536
542
  updateAutoscaler(options: UpdateAutoscalerOptions): Promise<void>;
537
543
  /**
538
544
  * URL of a Function running as a web endpoint.
539
- * @returns The web URL if this function is a web endpoint, otherwise undefined
545
+ * @returns The web URL if this Function is a web endpoint, otherwise undefined
540
546
  */
541
547
  getWebUrl(): Promise<string | undefined>;
542
548
  }
@@ -627,11 +633,11 @@ declare class AlreadyExistsError extends Error {
627
633
  declare class InvalidError extends Error {
628
634
  constructor(message: string);
629
635
  }
630
- /** The queue is empty. */
636
+ /** The Queue is empty. */
631
637
  declare class QueueEmptyError extends Error {
632
638
  constructor(message: string);
633
639
  }
634
- /** The queue is full. */
640
+ /** The Queue is full. */
635
641
  declare class QueueFullError extends Error {
636
642
  constructor(message: string);
637
643
  }
@@ -644,19 +650,19 @@ declare class SandboxTimeoutError extends Error {
644
650
  type QueueClearOptions = {
645
651
  /** Partition to clear, uses default partition if not set. */
646
652
  partition?: string;
647
- /** Set to clear all queue partitions. */
653
+ /** Set to clear all Queue partitions. */
648
654
  all?: boolean;
649
655
  };
650
656
  /** Options to configure a `Queue.get()` or `Queue.getMany()` operation. */
651
657
  type QueueGetOptions = {
652
- /** How long to wait if the queue is empty (default: indefinite). */
658
+ /** How long to wait if the Queue is empty (default: indefinite). */
653
659
  timeout?: number;
654
660
  /** Partition to fetch values from, uses default partition if not set. */
655
661
  partition?: string;
656
662
  };
657
663
  /** Options to configure a `Queue.put()` or `Queue.putMany()` operation. */
658
664
  type QueuePutOptions = {
659
- /** How long to wait if the queue is full (default: indefinite). */
665
+ /** How long to wait if the Queue is full (default: indefinite). */
660
666
  timeout?: number;
661
667
  /** Partition to add items to, uses default partition if not set. */
662
668
  partition?: string;
@@ -678,7 +684,7 @@ type QueueIterateOptions = {
678
684
  partition?: string;
679
685
  };
680
686
  /**
681
- * Distributed, FIFO queue for data flow in Modal apps.
687
+ * Distributed, FIFO queue for data flow in Modal Apps.
682
688
  */
683
689
  declare class Queue {
684
690
  #private;
@@ -687,58 +693,58 @@ declare class Queue {
687
693
  /** @ignore */
688
694
  constructor(queueId: string, name?: string, ephemeralHbManager?: EphemeralHeartbeatManager);
689
695
  /**
690
- * Create a nameless, temporary queue.
691
- * You will need to call `closeEphemeral()` to delete the queue.
696
+ * Create a nameless, temporary Queue.
697
+ * You will need to call `closeEphemeral()` to delete the Queue.
692
698
  */
693
699
  static ephemeral(options?: EphemeralOptions): Promise<Queue>;
694
- /** Delete the ephemeral queue. Only usable with `Queue.ephemeral()`. */
700
+ /** Delete the ephemeral Queue. Only usable with `Queue.ephemeral()`. */
695
701
  closeEphemeral(): void;
696
702
  /**
697
- * Lookup a queue by name.
703
+ * Lookup a Queue by name.
698
704
  */
699
705
  static lookup(name: string, options?: LookupOptions): Promise<Queue>;
700
- /** Delete a queue by name. */
706
+ /** Delete a Queue by name. */
701
707
  static delete(name: string, options?: DeleteOptions): Promise<void>;
702
708
  /**
703
- * Remove all objects from a queue partition.
709
+ * Remove all objects from a Queue partition.
704
710
  */
705
711
  clear(options?: QueueClearOptions): Promise<void>;
706
712
  /**
707
- * Remove and return the next object from the queue.
713
+ * Remove and return the next object from the Queue.
708
714
  *
709
- * By default, this will wait until at least one item is present in the queue.
715
+ * By default, this will wait until at least one item is present in the Queue.
710
716
  * If `timeout` is set, raises `QueueEmptyError` if no items are available
711
717
  * within that timeout in milliseconds.
712
718
  */
713
719
  get(options?: QueueGetOptions): Promise<any | null>;
714
720
  /**
715
- * Remove and return up to `n` objects from the queue.
721
+ * Remove and return up to `n` objects from the Queue.
716
722
  *
717
- * By default, this will wait until at least one item is present in the queue.
723
+ * By default, this will wait until at least one item is present in the Queue.
718
724
  * If `timeout` is set, raises `QueueEmptyError` if no items are available
719
725
  * within that timeout in milliseconds.
720
726
  */
721
727
  getMany(n: number, options?: QueueGetOptions): Promise<any[]>;
722
728
  /**
723
- * Add an item to the end of the queue.
729
+ * Add an item to the end of the Queue.
724
730
  *
725
- * If the queue is full, this will retry with exponential backoff until the
731
+ * If the Queue is full, this will retry with exponential backoff until the
726
732
  * provided `timeout` is reached, or indefinitely if `timeout` is not set.
727
- * Raises `QueueFullError` if the queue is still full after the timeout.
733
+ * Raises `QueueFullError` if the Queue is still full after the timeout.
728
734
  */
729
735
  put(v: any, options?: QueuePutOptions): Promise<void>;
730
736
  /**
731
- * Add several items to the end of the queue.
737
+ * Add several items to the end of the Queue.
732
738
  *
733
- * If the queue is full, this will retry with exponential backoff until the
739
+ * If the Queue is full, this will retry with exponential backoff until the
734
740
  * provided `timeout` is reached, or indefinitely if `timeout` is not set.
735
- * Raises `QueueFullError` if the queue is still full after the timeout.
741
+ * Raises `QueueFullError` if the Queue is still full after the timeout.
736
742
  */
737
743
  putMany(values: any[], options?: QueuePutOptions): Promise<void>;
738
- /** Return the number of objects in the queue. */
744
+ /** Return the number of objects in the Queue. */
739
745
  len(options?: QueueLenOptions): Promise<number>;
740
- /** Iterate through items in a queue without mutation. */
746
+ /** Iterate through items in a Queue without mutation. */
741
747
  iterate(options?: QueueIterateOptions): AsyncGenerator<any, void, unknown>;
742
748
  }
743
749
 
744
- export { AlreadyExistsError, App, type ClientOptions, CloudBucketMount, Cls, type ClsBatchingOptions, type ClsConcurrencyOptions, ClsInstance, type ClsOptions, ContainerProcess, type DeleteOptions, type EphemeralOptions, type ExecOptions, FunctionCall, type FunctionCallCancelOptions, type FunctionCallGetOptions, type FunctionStats, FunctionTimeoutError, Function_, Image, InternalFailure, InvalidError, type LookupOptions, type ModalReadStream, type ModalWriteStream, NotFoundError, Proxy, type ProxyFromNameOptions, Queue, type QueueClearOptions, QueueEmptyError, QueueFullError, type QueueGetOptions, type QueueIterateOptions, type QueueLenOptions, type QueuePutOptions, RemoteError, Retries, Sandbox, type SandboxCreateOptions, SandboxFile, type SandboxFileMode, type SandboxListOptions, SandboxTimeoutError, Secret, type SecretFromNameOptions, type StdioBehavior, type StreamMode, Tunnel, type UpdateAutoscalerOptions, Volume, type VolumeFromNameOptions, initializeClient };
750
+ export { AlreadyExistsError, App, type ClientOptions, CloudBucketMount, Cls, type ClsBatchingOptions, type ClsConcurrencyOptions, ClsInstance, type ClsOptions, ContainerProcess, type DeleteOptions, type EphemeralOptions, type ExecOptions, FunctionCall, type FunctionCallCancelOptions, type FunctionCallGetOptions, type FunctionStats, FunctionTimeoutError, Function_, Image, type ImageDeleteOptions, InternalFailure, InvalidError, type LookupOptions, type ModalReadStream, type ModalWriteStream, NotFoundError, Proxy, type ProxyFromNameOptions, Queue, type QueueClearOptions, QueueEmptyError, QueueFullError, type QueueGetOptions, type QueueIterateOptions, type QueueLenOptions, type QueuePutOptions, RemoteError, Retries, Sandbox, type SandboxCreateOptions, SandboxFile, type SandboxFileMode, type SandboxListOptions, SandboxTimeoutError, Secret, type SecretFromNameOptions, type StdioBehavior, type StreamMode, Tunnel, type UpdateAutoscalerOptions, Volume, type VolumeFromNameOptions, initializeClient };