modal 0.3.18 → 0.3.20

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;
@@ -226,9 +230,9 @@ type ExecOptions = {
226
230
  /** Timeout for the process in milliseconds. Defaults to 0 (no timeout). */
227
231
  timeout?: number;
228
232
  /** Secrets with environment variables for the command. */
229
- secrets?: [Secret];
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,46 @@ 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
+ /** Working directory of the Sandbox. */
418
422
  workdir?: string;
419
423
  /**
420
424
  * Sequence of program arguments for the main process.
421
425
  * Default behavior is to sleep indefinitely until timeout or termination.
422
426
  */
423
427
  command?: string[];
424
- /** Secrets to inject into the sandbox. */
428
+ /** Secrets to inject into the Sandbox. */
425
429
  secrets?: Secret[];
426
430
  /** Mount points for Modal Volumes. */
427
431
  volumes?: Record<string, Volume>;
428
432
  /** Mount points for cloud buckets. */
429
433
  cloudBucketMounts?: Record<string, CloudBucketMount>;
430
- /** List of ports to tunnel into the sandbox. Encrypted ports are tunneled with TLS. */
434
+ /** List of ports to tunnel into the Sandbox. Encrypted ports are tunneled with TLS. */
431
435
  encryptedPorts?: number[];
432
- /** List of encrypted ports to tunnel into the sandbox, using HTTP/2. */
436
+ /** List of encrypted ports to tunnel into the Sandbox, using HTTP/2. */
433
437
  h2Ports?: number[];
434
- /** List of ports to tunnel into the sandbox without encryption. */
438
+ /** List of ports to tunnel into the Sandbox without encryption. */
435
439
  unencryptedPorts?: number[];
436
- /** Whether to block all network access from the sandbox. */
440
+ /** Whether to block all network access from the Sandbox. */
437
441
  blockNetwork?: boolean;
438
- /** List of CIDRs the sandbox is allowed to access. If None, all CIDRs are allowed. Cannot be used with blockNetwork. */
442
+ /** List of CIDRs the Sandbox is allowed to access. If None, all CIDRs are allowed. Cannot be used with blockNetwork. */
439
443
  cidrAllowlist?: string[];
440
- /** Cloud provider to run the sandbox on. */
444
+ /** Cloud provider to run the Sandbox on. */
441
445
  cloud?: string;
442
- /** Region(s) to run the sandbox on. */
446
+ /** Region(s) to run the Sandbox on. */
443
447
  regions?: string[];
444
448
  /** Enable verbose logging. */
445
449
  verbose?: boolean;
446
450
  /** Reference to a Modal Proxy to use in front of this Sandbox. */
447
451
  proxy?: Proxy;
448
- /** Optional name for the sandbox. Unique within an app. */
452
+ /** Optional name for the Sandbox. Unique within an App. */
449
453
  name?: string;
450
454
  };
451
455
  /** Represents a deployed Modal App. */
@@ -454,7 +458,7 @@ declare class App {
454
458
  readonly name?: string;
455
459
  /** @ignore */
456
460
  constructor(appId: string, name?: string);
457
- /** Lookup a deployed app by name, or create if it does not exist. */
461
+ /** Lookup a deployed App by name, or create if it does not exist. */
458
462
  static lookup(name: string, options?: LookupOptions): Promise<App>;
459
463
  createSandbox(image: Image, options?: SandboxCreateOptions): Promise<Sandbox>;
460
464
  /**
@@ -502,11 +506,11 @@ declare class FunctionCall {
502
506
  readonly functionCallId: string;
503
507
  /** @ignore */
504
508
  constructor(functionCallId: string);
505
- /** Create a new function call from ID. */
509
+ /** Create a new Function call from ID. */
506
510
  fromId(functionCallId: string): FunctionCall;
507
- /** Get the result of a function call, optionally waiting with a timeout. */
511
+ /** Get the result of a Function call, optionally waiting with a timeout. */
508
512
  get(options?: FunctionCallGetOptions): Promise<any>;
509
- /** Cancel a running function call. */
513
+ /** Cancel a running Function call. */
510
514
  cancel(options?: FunctionCallCancelOptions): Promise<void>;
511
515
  }
512
516
 
@@ -536,7 +540,7 @@ declare class Function_ {
536
540
  updateAutoscaler(options: UpdateAutoscalerOptions): Promise<void>;
537
541
  /**
538
542
  * URL of a Function running as a web endpoint.
539
- * @returns The web URL if this function is a web endpoint, otherwise undefined
543
+ * @returns The web URL if this Function is a web endpoint, otherwise undefined
540
544
  */
541
545
  getWebUrl(): Promise<string | undefined>;
542
546
  }
@@ -627,11 +631,11 @@ declare class AlreadyExistsError extends Error {
627
631
  declare class InvalidError extends Error {
628
632
  constructor(message: string);
629
633
  }
630
- /** The queue is empty. */
634
+ /** The Queue is empty. */
631
635
  declare class QueueEmptyError extends Error {
632
636
  constructor(message: string);
633
637
  }
634
- /** The queue is full. */
638
+ /** The Queue is full. */
635
639
  declare class QueueFullError extends Error {
636
640
  constructor(message: string);
637
641
  }
@@ -644,19 +648,19 @@ declare class SandboxTimeoutError extends Error {
644
648
  type QueueClearOptions = {
645
649
  /** Partition to clear, uses default partition if not set. */
646
650
  partition?: string;
647
- /** Set to clear all queue partitions. */
651
+ /** Set to clear all Queue partitions. */
648
652
  all?: boolean;
649
653
  };
650
654
  /** Options to configure a `Queue.get()` or `Queue.getMany()` operation. */
651
655
  type QueueGetOptions = {
652
- /** How long to wait if the queue is empty (default: indefinite). */
656
+ /** How long to wait if the Queue is empty (default: indefinite). */
653
657
  timeout?: number;
654
658
  /** Partition to fetch values from, uses default partition if not set. */
655
659
  partition?: string;
656
660
  };
657
661
  /** Options to configure a `Queue.put()` or `Queue.putMany()` operation. */
658
662
  type QueuePutOptions = {
659
- /** How long to wait if the queue is full (default: indefinite). */
663
+ /** How long to wait if the Queue is full (default: indefinite). */
660
664
  timeout?: number;
661
665
  /** Partition to add items to, uses default partition if not set. */
662
666
  partition?: string;
@@ -678,7 +682,7 @@ type QueueIterateOptions = {
678
682
  partition?: string;
679
683
  };
680
684
  /**
681
- * Distributed, FIFO queue for data flow in Modal apps.
685
+ * Distributed, FIFO queue for data flow in Modal Apps.
682
686
  */
683
687
  declare class Queue {
684
688
  #private;
@@ -687,58 +691,58 @@ declare class Queue {
687
691
  /** @ignore */
688
692
  constructor(queueId: string, name?: string, ephemeralHbManager?: EphemeralHeartbeatManager);
689
693
  /**
690
- * Create a nameless, temporary queue.
691
- * You will need to call `closeEphemeral()` to delete the queue.
694
+ * Create a nameless, temporary Queue.
695
+ * You will need to call `closeEphemeral()` to delete the Queue.
692
696
  */
693
697
  static ephemeral(options?: EphemeralOptions): Promise<Queue>;
694
- /** Delete the ephemeral queue. Only usable with `Queue.ephemeral()`. */
698
+ /** Delete the ephemeral Queue. Only usable with `Queue.ephemeral()`. */
695
699
  closeEphemeral(): void;
696
700
  /**
697
- * Lookup a queue by name.
701
+ * Lookup a Queue by name.
698
702
  */
699
703
  static lookup(name: string, options?: LookupOptions): Promise<Queue>;
700
- /** Delete a queue by name. */
704
+ /** Delete a Queue by name. */
701
705
  static delete(name: string, options?: DeleteOptions): Promise<void>;
702
706
  /**
703
- * Remove all objects from a queue partition.
707
+ * Remove all objects from a Queue partition.
704
708
  */
705
709
  clear(options?: QueueClearOptions): Promise<void>;
706
710
  /**
707
- * Remove and return the next object from the queue.
711
+ * Remove and return the next object from the Queue.
708
712
  *
709
- * By default, this will wait until at least one item is present in the queue.
713
+ * By default, this will wait until at least one item is present in the Queue.
710
714
  * If `timeout` is set, raises `QueueEmptyError` if no items are available
711
715
  * within that timeout in milliseconds.
712
716
  */
713
717
  get(options?: QueueGetOptions): Promise<any | null>;
714
718
  /**
715
- * Remove and return up to `n` objects from the queue.
719
+ * Remove and return up to `n` objects from the Queue.
716
720
  *
717
- * By default, this will wait until at least one item is present in the queue.
721
+ * By default, this will wait until at least one item is present in the Queue.
718
722
  * If `timeout` is set, raises `QueueEmptyError` if no items are available
719
723
  * within that timeout in milliseconds.
720
724
  */
721
725
  getMany(n: number, options?: QueueGetOptions): Promise<any[]>;
722
726
  /**
723
- * Add an item to the end of the queue.
727
+ * Add an item to the end of the Queue.
724
728
  *
725
- * If the queue is full, this will retry with exponential backoff until the
729
+ * If the Queue is full, this will retry with exponential backoff until the
726
730
  * provided `timeout` is reached, or indefinitely if `timeout` is not set.
727
- * Raises `QueueFullError` if the queue is still full after the timeout.
731
+ * Raises `QueueFullError` if the Queue is still full after the timeout.
728
732
  */
729
733
  put(v: any, options?: QueuePutOptions): Promise<void>;
730
734
  /**
731
- * Add several items to the end of the queue.
735
+ * Add several items to the end of the Queue.
732
736
  *
733
- * If the queue is full, this will retry with exponential backoff until the
737
+ * If the Queue is full, this will retry with exponential backoff until the
734
738
  * provided `timeout` is reached, or indefinitely if `timeout` is not set.
735
- * Raises `QueueFullError` if the queue is still full after the timeout.
739
+ * Raises `QueueFullError` if the Queue is still full after the timeout.
736
740
  */
737
741
  putMany(values: any[], options?: QueuePutOptions): Promise<void>;
738
- /** Return the number of objects in the queue. */
742
+ /** Return the number of objects in the Queue. */
739
743
  len(options?: QueueLenOptions): Promise<number>;
740
- /** Iterate through items in a queue without mutation. */
744
+ /** Iterate through items in a Queue without mutation. */
741
745
  iterate(options?: QueueIterateOptions): AsyncGenerator<any, void, unknown>;
742
746
  }
743
747
 
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 };
748
+ 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 };