modal 0.3.13 → 0.3.15
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.cjs +1124 -197
- package/dist/index.d.cts +67 -17
- package/dist/index.d.ts +67 -17
- package/dist/index.js +1123 -197
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -124,6 +124,20 @@ interface ModalWriteStream<R = any> extends WritableStream<R> {
|
|
|
124
124
|
writeBytes(bytes: Uint8Array): Promise<void>;
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
+
/** Options for `Secret.fromName()`. */
|
|
128
|
+
type SecretFromNameOptions = {
|
|
129
|
+
environment?: string;
|
|
130
|
+
requiredKeys?: string[];
|
|
131
|
+
};
|
|
132
|
+
/** Secrets provide a dictionary of environment variables for images. */
|
|
133
|
+
declare class Secret {
|
|
134
|
+
readonly secretId: string;
|
|
135
|
+
/** @ignore */
|
|
136
|
+
constructor(secretId: string);
|
|
137
|
+
/** Reference a Secret by its name. */
|
|
138
|
+
static fromName(name: string, options?: SecretFromNameOptions): Promise<Secret>;
|
|
139
|
+
}
|
|
140
|
+
|
|
127
141
|
/**
|
|
128
142
|
* Stdin is always present, but this option allow you to drop stdout or stderr
|
|
129
143
|
* if you don't need them. The default is "pipe", matching Node.js behavior.
|
|
@@ -149,7 +163,24 @@ type ExecOptions = {
|
|
|
149
163
|
workdir?: string;
|
|
150
164
|
/** Timeout for the process in milliseconds. Defaults to 0 (no timeout). */
|
|
151
165
|
timeout?: number;
|
|
166
|
+
/** Secrets with environment variables for the command. */
|
|
167
|
+
secrets?: [Secret];
|
|
152
168
|
};
|
|
169
|
+
/** A port forwarded from within a running Modal sandbox. */
|
|
170
|
+
declare class Tunnel {
|
|
171
|
+
host: string;
|
|
172
|
+
port: number;
|
|
173
|
+
unencryptedHost?: string | undefined;
|
|
174
|
+
unencryptedPort?: number | undefined;
|
|
175
|
+
/** @ignore */
|
|
176
|
+
constructor(host: string, port: number, unencryptedHost?: string | undefined, unencryptedPort?: number | undefined);
|
|
177
|
+
/** Get the public HTTPS URL of the forwarded port. */
|
|
178
|
+
get url(): string;
|
|
179
|
+
/** Get the public TLS socket as a [host, port] tuple. */
|
|
180
|
+
get tlsSocket(): [string, number];
|
|
181
|
+
/** Get the public TCP socket as a [host, port] tuple. */
|
|
182
|
+
get tcpSocket(): [string, number];
|
|
183
|
+
}
|
|
153
184
|
/** Sandboxes are secure, isolated containers in Modal that boot in seconds. */
|
|
154
185
|
declare class Sandbox {
|
|
155
186
|
#private;
|
|
@@ -174,6 +205,28 @@ declare class Sandbox {
|
|
|
174
205
|
}): Promise<ContainerProcess<Uint8Array>>;
|
|
175
206
|
terminate(): Promise<void>;
|
|
176
207
|
wait(): Promise<number>;
|
|
208
|
+
/** Get Tunnel metadata for the sandbox.
|
|
209
|
+
*
|
|
210
|
+
* Raises `SandboxTimeoutError` if the tunnels are not available after the timeout.
|
|
211
|
+
*
|
|
212
|
+
* @returns A dictionary of Tunnel objects which are keyed by the container port.
|
|
213
|
+
*/
|
|
214
|
+
tunnels(timeout?: number): Promise<Record<number, Tunnel>>;
|
|
215
|
+
/**
|
|
216
|
+
* Snapshot the filesystem of the Sandbox.
|
|
217
|
+
*
|
|
218
|
+
* Returns an `Image` object which can be used to spawn a new Sandbox with the same filesystem.
|
|
219
|
+
*
|
|
220
|
+
* @param timeout - Timeout for the snapshot operation in milliseconds
|
|
221
|
+
* @returns Promise that resolves to an Image
|
|
222
|
+
*/
|
|
223
|
+
snapshotFilesystem(timeout?: number): Promise<Image>;
|
|
224
|
+
/**
|
|
225
|
+
* Check if the Sandbox has finished running.
|
|
226
|
+
*
|
|
227
|
+
* Returns `null` if the Sandbox is still running, else returns the exit code.
|
|
228
|
+
*/
|
|
229
|
+
poll(): Promise<number | null>;
|
|
177
230
|
}
|
|
178
231
|
declare class ContainerProcess<R extends string | Uint8Array = any> {
|
|
179
232
|
#private;
|
|
@@ -186,20 +239,6 @@ declare class ContainerProcess<R extends string | Uint8Array = any> {
|
|
|
186
239
|
wait(): Promise<number>;
|
|
187
240
|
}
|
|
188
241
|
|
|
189
|
-
/** Options for `Secret.fromName()`. */
|
|
190
|
-
type SecretFromNameOptions = {
|
|
191
|
-
environment?: string;
|
|
192
|
-
requiredKeys?: string[];
|
|
193
|
-
};
|
|
194
|
-
/** Secrets provide a dictionary of environment variables for images. */
|
|
195
|
-
declare class Secret {
|
|
196
|
-
readonly secretId: string;
|
|
197
|
-
/** @ignore */
|
|
198
|
-
constructor(secretId: string);
|
|
199
|
-
/** Reference a Secret by its name. */
|
|
200
|
-
static fromName(name: string, options?: SecretFromNameOptions): Promise<Secret>;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
242
|
/** Options for `Volume.fromName()`. */
|
|
204
243
|
type VolumeFromNameOptions = {
|
|
205
244
|
environment?: string;
|
|
@@ -239,8 +278,16 @@ type SandboxCreateOptions = {
|
|
|
239
278
|
* Default behavior is to sleep indefinitely until timeout or termination.
|
|
240
279
|
*/
|
|
241
280
|
command?: string[];
|
|
281
|
+
/** Secrets to inject into the sandbox. */
|
|
282
|
+
secrets?: Secret[];
|
|
242
283
|
/** Mount points for Modal Volumes. */
|
|
243
284
|
volumes?: Record<string, Volume>;
|
|
285
|
+
/** List of ports to tunnel into the sandbox. Encrypted ports are tunneled with TLS. */
|
|
286
|
+
encryptedPorts?: number[];
|
|
287
|
+
/** List of encrypted ports to tunnel into the sandbox, using HTTP/2. */
|
|
288
|
+
h2Ports?: number[];
|
|
289
|
+
/** List of ports to tunnel into the sandbox without encryption. */
|
|
290
|
+
unencryptedPorts?: number[];
|
|
244
291
|
};
|
|
245
292
|
/** Represents a deployed Modal App. */
|
|
246
293
|
declare class App {
|
|
@@ -298,8 +345,7 @@ declare class FunctionCall {
|
|
|
298
345
|
declare class Function_ {
|
|
299
346
|
#private;
|
|
300
347
|
readonly functionId: string;
|
|
301
|
-
readonly methodName
|
|
302
|
-
readonly inputPlaneUrl: string | undefined;
|
|
348
|
+
readonly methodName?: string;
|
|
303
349
|
/** @ignore */
|
|
304
350
|
constructor(functionId: string, methodName?: string, inputPlaneUrl?: string);
|
|
305
351
|
static lookup(appName: string, name: string, options?: LookupOptions): Promise<Function_>;
|
|
@@ -351,6 +397,10 @@ declare class QueueEmptyError extends Error {
|
|
|
351
397
|
declare class QueueFullError extends Error {
|
|
352
398
|
constructor(message: string);
|
|
353
399
|
}
|
|
400
|
+
/** Sandbox operations that exceed the allowed time limit. */
|
|
401
|
+
declare class SandboxTimeoutError extends Error {
|
|
402
|
+
constructor(message?: string);
|
|
403
|
+
}
|
|
354
404
|
|
|
355
405
|
/** Options to configure a `Queue.clear()` operation. */
|
|
356
406
|
type QueueClearOptions = {
|
|
@@ -452,4 +502,4 @@ declare class Queue {
|
|
|
452
502
|
iterate(options?: QueueIterateOptions): AsyncGenerator<any, void, unknown>;
|
|
453
503
|
}
|
|
454
504
|
|
|
455
|
-
export { App, type ClientOptions, Cls, ClsInstance, ContainerProcess, type DeleteOptions, type EphemeralOptions, type ExecOptions, FunctionCall, type FunctionCallCancelOptions, type FunctionCallGetOptions, FunctionTimeoutError, Function_, Image, InternalFailure, InvalidError, type LookupOptions, type ModalReadStream, type ModalWriteStream, NotFoundError, Queue, type QueueClearOptions, QueueEmptyError, QueueFullError, type QueueGetOptions, type QueueIterateOptions, type QueueLenOptions, type QueuePutOptions, RemoteError, Sandbox, type SandboxCreateOptions, SandboxFile, type SandboxFileMode, Secret, type SecretFromNameOptions, type StdioBehavior, type StreamMode, Volume, type VolumeFromNameOptions, initializeClient };
|
|
505
|
+
export { App, type ClientOptions, Cls, ClsInstance, ContainerProcess, type DeleteOptions, type EphemeralOptions, type ExecOptions, FunctionCall, type FunctionCallCancelOptions, type FunctionCallGetOptions, FunctionTimeoutError, Function_, Image, InternalFailure, InvalidError, type LookupOptions, type ModalReadStream, type ModalWriteStream, NotFoundError, Queue, type QueueClearOptions, QueueEmptyError, QueueFullError, type QueueGetOptions, type QueueIterateOptions, type QueueLenOptions, type QueuePutOptions, RemoteError, Sandbox, type SandboxCreateOptions, SandboxFile, type SandboxFileMode, SandboxTimeoutError, Secret, type SecretFromNameOptions, type StdioBehavior, type StreamMode, Tunnel, Volume, type VolumeFromNameOptions, initializeClient };
|
package/dist/index.d.ts
CHANGED
|
@@ -124,6 +124,20 @@ interface ModalWriteStream<R = any> extends WritableStream<R> {
|
|
|
124
124
|
writeBytes(bytes: Uint8Array): Promise<void>;
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
+
/** Options for `Secret.fromName()`. */
|
|
128
|
+
type SecretFromNameOptions = {
|
|
129
|
+
environment?: string;
|
|
130
|
+
requiredKeys?: string[];
|
|
131
|
+
};
|
|
132
|
+
/** Secrets provide a dictionary of environment variables for images. */
|
|
133
|
+
declare class Secret {
|
|
134
|
+
readonly secretId: string;
|
|
135
|
+
/** @ignore */
|
|
136
|
+
constructor(secretId: string);
|
|
137
|
+
/** Reference a Secret by its name. */
|
|
138
|
+
static fromName(name: string, options?: SecretFromNameOptions): Promise<Secret>;
|
|
139
|
+
}
|
|
140
|
+
|
|
127
141
|
/**
|
|
128
142
|
* Stdin is always present, but this option allow you to drop stdout or stderr
|
|
129
143
|
* if you don't need them. The default is "pipe", matching Node.js behavior.
|
|
@@ -149,7 +163,24 @@ type ExecOptions = {
|
|
|
149
163
|
workdir?: string;
|
|
150
164
|
/** Timeout for the process in milliseconds. Defaults to 0 (no timeout). */
|
|
151
165
|
timeout?: number;
|
|
166
|
+
/** Secrets with environment variables for the command. */
|
|
167
|
+
secrets?: [Secret];
|
|
152
168
|
};
|
|
169
|
+
/** A port forwarded from within a running Modal sandbox. */
|
|
170
|
+
declare class Tunnel {
|
|
171
|
+
host: string;
|
|
172
|
+
port: number;
|
|
173
|
+
unencryptedHost?: string | undefined;
|
|
174
|
+
unencryptedPort?: number | undefined;
|
|
175
|
+
/** @ignore */
|
|
176
|
+
constructor(host: string, port: number, unencryptedHost?: string | undefined, unencryptedPort?: number | undefined);
|
|
177
|
+
/** Get the public HTTPS URL of the forwarded port. */
|
|
178
|
+
get url(): string;
|
|
179
|
+
/** Get the public TLS socket as a [host, port] tuple. */
|
|
180
|
+
get tlsSocket(): [string, number];
|
|
181
|
+
/** Get the public TCP socket as a [host, port] tuple. */
|
|
182
|
+
get tcpSocket(): [string, number];
|
|
183
|
+
}
|
|
153
184
|
/** Sandboxes are secure, isolated containers in Modal that boot in seconds. */
|
|
154
185
|
declare class Sandbox {
|
|
155
186
|
#private;
|
|
@@ -174,6 +205,28 @@ declare class Sandbox {
|
|
|
174
205
|
}): Promise<ContainerProcess<Uint8Array>>;
|
|
175
206
|
terminate(): Promise<void>;
|
|
176
207
|
wait(): Promise<number>;
|
|
208
|
+
/** Get Tunnel metadata for the sandbox.
|
|
209
|
+
*
|
|
210
|
+
* Raises `SandboxTimeoutError` if the tunnels are not available after the timeout.
|
|
211
|
+
*
|
|
212
|
+
* @returns A dictionary of Tunnel objects which are keyed by the container port.
|
|
213
|
+
*/
|
|
214
|
+
tunnels(timeout?: number): Promise<Record<number, Tunnel>>;
|
|
215
|
+
/**
|
|
216
|
+
* Snapshot the filesystem of the Sandbox.
|
|
217
|
+
*
|
|
218
|
+
* Returns an `Image` object which can be used to spawn a new Sandbox with the same filesystem.
|
|
219
|
+
*
|
|
220
|
+
* @param timeout - Timeout for the snapshot operation in milliseconds
|
|
221
|
+
* @returns Promise that resolves to an Image
|
|
222
|
+
*/
|
|
223
|
+
snapshotFilesystem(timeout?: number): Promise<Image>;
|
|
224
|
+
/**
|
|
225
|
+
* Check if the Sandbox has finished running.
|
|
226
|
+
*
|
|
227
|
+
* Returns `null` if the Sandbox is still running, else returns the exit code.
|
|
228
|
+
*/
|
|
229
|
+
poll(): Promise<number | null>;
|
|
177
230
|
}
|
|
178
231
|
declare class ContainerProcess<R extends string | Uint8Array = any> {
|
|
179
232
|
#private;
|
|
@@ -186,20 +239,6 @@ declare class ContainerProcess<R extends string | Uint8Array = any> {
|
|
|
186
239
|
wait(): Promise<number>;
|
|
187
240
|
}
|
|
188
241
|
|
|
189
|
-
/** Options for `Secret.fromName()`. */
|
|
190
|
-
type SecretFromNameOptions = {
|
|
191
|
-
environment?: string;
|
|
192
|
-
requiredKeys?: string[];
|
|
193
|
-
};
|
|
194
|
-
/** Secrets provide a dictionary of environment variables for images. */
|
|
195
|
-
declare class Secret {
|
|
196
|
-
readonly secretId: string;
|
|
197
|
-
/** @ignore */
|
|
198
|
-
constructor(secretId: string);
|
|
199
|
-
/** Reference a Secret by its name. */
|
|
200
|
-
static fromName(name: string, options?: SecretFromNameOptions): Promise<Secret>;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
242
|
/** Options for `Volume.fromName()`. */
|
|
204
243
|
type VolumeFromNameOptions = {
|
|
205
244
|
environment?: string;
|
|
@@ -239,8 +278,16 @@ type SandboxCreateOptions = {
|
|
|
239
278
|
* Default behavior is to sleep indefinitely until timeout or termination.
|
|
240
279
|
*/
|
|
241
280
|
command?: string[];
|
|
281
|
+
/** Secrets to inject into the sandbox. */
|
|
282
|
+
secrets?: Secret[];
|
|
242
283
|
/** Mount points for Modal Volumes. */
|
|
243
284
|
volumes?: Record<string, Volume>;
|
|
285
|
+
/** List of ports to tunnel into the sandbox. Encrypted ports are tunneled with TLS. */
|
|
286
|
+
encryptedPorts?: number[];
|
|
287
|
+
/** List of encrypted ports to tunnel into the sandbox, using HTTP/2. */
|
|
288
|
+
h2Ports?: number[];
|
|
289
|
+
/** List of ports to tunnel into the sandbox without encryption. */
|
|
290
|
+
unencryptedPorts?: number[];
|
|
244
291
|
};
|
|
245
292
|
/** Represents a deployed Modal App. */
|
|
246
293
|
declare class App {
|
|
@@ -298,8 +345,7 @@ declare class FunctionCall {
|
|
|
298
345
|
declare class Function_ {
|
|
299
346
|
#private;
|
|
300
347
|
readonly functionId: string;
|
|
301
|
-
readonly methodName
|
|
302
|
-
readonly inputPlaneUrl: string | undefined;
|
|
348
|
+
readonly methodName?: string;
|
|
303
349
|
/** @ignore */
|
|
304
350
|
constructor(functionId: string, methodName?: string, inputPlaneUrl?: string);
|
|
305
351
|
static lookup(appName: string, name: string, options?: LookupOptions): Promise<Function_>;
|
|
@@ -351,6 +397,10 @@ declare class QueueEmptyError extends Error {
|
|
|
351
397
|
declare class QueueFullError extends Error {
|
|
352
398
|
constructor(message: string);
|
|
353
399
|
}
|
|
400
|
+
/** Sandbox operations that exceed the allowed time limit. */
|
|
401
|
+
declare class SandboxTimeoutError extends Error {
|
|
402
|
+
constructor(message?: string);
|
|
403
|
+
}
|
|
354
404
|
|
|
355
405
|
/** Options to configure a `Queue.clear()` operation. */
|
|
356
406
|
type QueueClearOptions = {
|
|
@@ -452,4 +502,4 @@ declare class Queue {
|
|
|
452
502
|
iterate(options?: QueueIterateOptions): AsyncGenerator<any, void, unknown>;
|
|
453
503
|
}
|
|
454
504
|
|
|
455
|
-
export { App, type ClientOptions, Cls, ClsInstance, ContainerProcess, type DeleteOptions, type EphemeralOptions, type ExecOptions, FunctionCall, type FunctionCallCancelOptions, type FunctionCallGetOptions, FunctionTimeoutError, Function_, Image, InternalFailure, InvalidError, type LookupOptions, type ModalReadStream, type ModalWriteStream, NotFoundError, Queue, type QueueClearOptions, QueueEmptyError, QueueFullError, type QueueGetOptions, type QueueIterateOptions, type QueueLenOptions, type QueuePutOptions, RemoteError, Sandbox, type SandboxCreateOptions, SandboxFile, type SandboxFileMode, Secret, type SecretFromNameOptions, type StdioBehavior, type StreamMode, Volume, type VolumeFromNameOptions, initializeClient };
|
|
505
|
+
export { App, type ClientOptions, Cls, ClsInstance, ContainerProcess, type DeleteOptions, type EphemeralOptions, type ExecOptions, FunctionCall, type FunctionCallCancelOptions, type FunctionCallGetOptions, FunctionTimeoutError, Function_, Image, InternalFailure, InvalidError, type LookupOptions, type ModalReadStream, type ModalWriteStream, NotFoundError, Queue, type QueueClearOptions, QueueEmptyError, QueueFullError, type QueueGetOptions, type QueueIterateOptions, type QueueLenOptions, type QueuePutOptions, RemoteError, Sandbox, type SandboxCreateOptions, SandboxFile, type SandboxFileMode, SandboxTimeoutError, Secret, type SecretFromNameOptions, type StdioBehavior, type StreamMode, Tunnel, Volume, type VolumeFromNameOptions, initializeClient };
|