modal 0.3.12 → 0.3.14
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 +1099 -202
- package/dist/index.d.cts +50 -4
- package/dist/index.d.ts +50 -4
- package/dist/index.js +1097 -202
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -150,6 +150,21 @@ type ExecOptions = {
|
|
|
150
150
|
/** Timeout for the process in milliseconds. Defaults to 0 (no timeout). */
|
|
151
151
|
timeout?: number;
|
|
152
152
|
};
|
|
153
|
+
/** A port forwarded from within a running Modal sandbox. */
|
|
154
|
+
declare class Tunnel {
|
|
155
|
+
host: string;
|
|
156
|
+
port: number;
|
|
157
|
+
unencryptedHost?: string | undefined;
|
|
158
|
+
unencryptedPort?: number | undefined;
|
|
159
|
+
/** @ignore */
|
|
160
|
+
constructor(host: string, port: number, unencryptedHost?: string | undefined, unencryptedPort?: number | undefined);
|
|
161
|
+
/** Get the public HTTPS URL of the forwarded port. */
|
|
162
|
+
get url(): string;
|
|
163
|
+
/** Get the public TLS socket as a [host, port] tuple. */
|
|
164
|
+
get tlsSocket(): [string, number];
|
|
165
|
+
/** Get the public TCP socket as a [host, port] tuple. */
|
|
166
|
+
get tcpSocket(): [string, number];
|
|
167
|
+
}
|
|
153
168
|
/** Sandboxes are secure, isolated containers in Modal that boot in seconds. */
|
|
154
169
|
declare class Sandbox {
|
|
155
170
|
#private;
|
|
@@ -174,6 +189,13 @@ declare class Sandbox {
|
|
|
174
189
|
}): Promise<ContainerProcess<Uint8Array>>;
|
|
175
190
|
terminate(): Promise<void>;
|
|
176
191
|
wait(): Promise<number>;
|
|
192
|
+
/** Get Tunnel metadata for the sandbox.
|
|
193
|
+
*
|
|
194
|
+
* Raises `SandboxTimeoutError` if the tunnels are not available after the timeout.
|
|
195
|
+
*
|
|
196
|
+
* @returns A dictionary of Tunnel objects which are keyed by the container port.
|
|
197
|
+
*/
|
|
198
|
+
tunnels(timeout?: number): Promise<Record<number, Tunnel>>;
|
|
177
199
|
}
|
|
178
200
|
declare class ContainerProcess<R extends string | Uint8Array = any> {
|
|
179
201
|
#private;
|
|
@@ -200,6 +222,19 @@ declare class Secret {
|
|
|
200
222
|
static fromName(name: string, options?: SecretFromNameOptions): Promise<Secret>;
|
|
201
223
|
}
|
|
202
224
|
|
|
225
|
+
/** Options for `Volume.fromName()`. */
|
|
226
|
+
type VolumeFromNameOptions = {
|
|
227
|
+
environment?: string;
|
|
228
|
+
createIfMissing?: boolean;
|
|
229
|
+
};
|
|
230
|
+
/** Volumes provide persistent storage that can be mounted in Modal functions. */
|
|
231
|
+
declare class Volume {
|
|
232
|
+
readonly volumeId: string;
|
|
233
|
+
/** @ignore */
|
|
234
|
+
constructor(volumeId: string);
|
|
235
|
+
static fromName(name: string, options?: VolumeFromNameOptions): Promise<Volume>;
|
|
236
|
+
}
|
|
237
|
+
|
|
203
238
|
/** Options for functions that find deployed Modal objects. */
|
|
204
239
|
type LookupOptions = {
|
|
205
240
|
environment?: string;
|
|
@@ -226,6 +261,14 @@ type SandboxCreateOptions = {
|
|
|
226
261
|
* Default behavior is to sleep indefinitely until timeout or termination.
|
|
227
262
|
*/
|
|
228
263
|
command?: string[];
|
|
264
|
+
/** Mount points for Modal Volumes. */
|
|
265
|
+
volumes?: Record<string, Volume>;
|
|
266
|
+
/** List of ports to tunnel into the sandbox. Encrypted ports are tunneled with TLS. */
|
|
267
|
+
encryptedPorts?: number[];
|
|
268
|
+
/** List of encrypted ports to tunnel into the sandbox, using HTTP/2. */
|
|
269
|
+
h2Ports?: number[];
|
|
270
|
+
/** List of ports to tunnel into the sandbox without encryption. */
|
|
271
|
+
unencryptedPorts?: number[];
|
|
229
272
|
};
|
|
230
273
|
/** Represents a deployed Modal App. */
|
|
231
274
|
declare class App {
|
|
@@ -283,8 +326,7 @@ declare class FunctionCall {
|
|
|
283
326
|
declare class Function_ {
|
|
284
327
|
#private;
|
|
285
328
|
readonly functionId: string;
|
|
286
|
-
readonly methodName
|
|
287
|
-
readonly inputPlaneUrl: string | undefined;
|
|
329
|
+
readonly methodName?: string;
|
|
288
330
|
/** @ignore */
|
|
289
331
|
constructor(functionId: string, methodName?: string, inputPlaneUrl?: string);
|
|
290
332
|
static lookup(appName: string, name: string, options?: LookupOptions): Promise<Function_>;
|
|
@@ -296,7 +338,7 @@ declare class Function_ {
|
|
|
296
338
|
declare class Cls {
|
|
297
339
|
#private;
|
|
298
340
|
/** @ignore */
|
|
299
|
-
constructor(serviceFunctionId: string, schema: ClassParameterSpec[], methodNames: string[]);
|
|
341
|
+
constructor(serviceFunctionId: string, schema: ClassParameterSpec[], methodNames: string[], inputPlaneUrl?: string);
|
|
300
342
|
static lookup(appName: string, name: string, options?: LookupOptions): Promise<Cls>;
|
|
301
343
|
/** Create a new instance of the Cls with parameters. */
|
|
302
344
|
instance(params?: Record<string, any>): Promise<ClsInstance>;
|
|
@@ -336,6 +378,10 @@ declare class QueueEmptyError extends Error {
|
|
|
336
378
|
declare class QueueFullError extends Error {
|
|
337
379
|
constructor(message: string);
|
|
338
380
|
}
|
|
381
|
+
/** Sandbox operations that exceed the allowed time limit. */
|
|
382
|
+
declare class SandboxTimeoutError extends Error {
|
|
383
|
+
constructor(message?: string);
|
|
384
|
+
}
|
|
339
385
|
|
|
340
386
|
/** Options to configure a `Queue.clear()` operation. */
|
|
341
387
|
type QueueClearOptions = {
|
|
@@ -437,4 +483,4 @@ declare class Queue {
|
|
|
437
483
|
iterate(options?: QueueIterateOptions): AsyncGenerator<any, void, unknown>;
|
|
438
484
|
}
|
|
439
485
|
|
|
440
|
-
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, initializeClient };
|
|
486
|
+
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
|
@@ -150,6 +150,21 @@ type ExecOptions = {
|
|
|
150
150
|
/** Timeout for the process in milliseconds. Defaults to 0 (no timeout). */
|
|
151
151
|
timeout?: number;
|
|
152
152
|
};
|
|
153
|
+
/** A port forwarded from within a running Modal sandbox. */
|
|
154
|
+
declare class Tunnel {
|
|
155
|
+
host: string;
|
|
156
|
+
port: number;
|
|
157
|
+
unencryptedHost?: string | undefined;
|
|
158
|
+
unencryptedPort?: number | undefined;
|
|
159
|
+
/** @ignore */
|
|
160
|
+
constructor(host: string, port: number, unencryptedHost?: string | undefined, unencryptedPort?: number | undefined);
|
|
161
|
+
/** Get the public HTTPS URL of the forwarded port. */
|
|
162
|
+
get url(): string;
|
|
163
|
+
/** Get the public TLS socket as a [host, port] tuple. */
|
|
164
|
+
get tlsSocket(): [string, number];
|
|
165
|
+
/** Get the public TCP socket as a [host, port] tuple. */
|
|
166
|
+
get tcpSocket(): [string, number];
|
|
167
|
+
}
|
|
153
168
|
/** Sandboxes are secure, isolated containers in Modal that boot in seconds. */
|
|
154
169
|
declare class Sandbox {
|
|
155
170
|
#private;
|
|
@@ -174,6 +189,13 @@ declare class Sandbox {
|
|
|
174
189
|
}): Promise<ContainerProcess<Uint8Array>>;
|
|
175
190
|
terminate(): Promise<void>;
|
|
176
191
|
wait(): Promise<number>;
|
|
192
|
+
/** Get Tunnel metadata for the sandbox.
|
|
193
|
+
*
|
|
194
|
+
* Raises `SandboxTimeoutError` if the tunnels are not available after the timeout.
|
|
195
|
+
*
|
|
196
|
+
* @returns A dictionary of Tunnel objects which are keyed by the container port.
|
|
197
|
+
*/
|
|
198
|
+
tunnels(timeout?: number): Promise<Record<number, Tunnel>>;
|
|
177
199
|
}
|
|
178
200
|
declare class ContainerProcess<R extends string | Uint8Array = any> {
|
|
179
201
|
#private;
|
|
@@ -200,6 +222,19 @@ declare class Secret {
|
|
|
200
222
|
static fromName(name: string, options?: SecretFromNameOptions): Promise<Secret>;
|
|
201
223
|
}
|
|
202
224
|
|
|
225
|
+
/** Options for `Volume.fromName()`. */
|
|
226
|
+
type VolumeFromNameOptions = {
|
|
227
|
+
environment?: string;
|
|
228
|
+
createIfMissing?: boolean;
|
|
229
|
+
};
|
|
230
|
+
/** Volumes provide persistent storage that can be mounted in Modal functions. */
|
|
231
|
+
declare class Volume {
|
|
232
|
+
readonly volumeId: string;
|
|
233
|
+
/** @ignore */
|
|
234
|
+
constructor(volumeId: string);
|
|
235
|
+
static fromName(name: string, options?: VolumeFromNameOptions): Promise<Volume>;
|
|
236
|
+
}
|
|
237
|
+
|
|
203
238
|
/** Options for functions that find deployed Modal objects. */
|
|
204
239
|
type LookupOptions = {
|
|
205
240
|
environment?: string;
|
|
@@ -226,6 +261,14 @@ type SandboxCreateOptions = {
|
|
|
226
261
|
* Default behavior is to sleep indefinitely until timeout or termination.
|
|
227
262
|
*/
|
|
228
263
|
command?: string[];
|
|
264
|
+
/** Mount points for Modal Volumes. */
|
|
265
|
+
volumes?: Record<string, Volume>;
|
|
266
|
+
/** List of ports to tunnel into the sandbox. Encrypted ports are tunneled with TLS. */
|
|
267
|
+
encryptedPorts?: number[];
|
|
268
|
+
/** List of encrypted ports to tunnel into the sandbox, using HTTP/2. */
|
|
269
|
+
h2Ports?: number[];
|
|
270
|
+
/** List of ports to tunnel into the sandbox without encryption. */
|
|
271
|
+
unencryptedPorts?: number[];
|
|
229
272
|
};
|
|
230
273
|
/** Represents a deployed Modal App. */
|
|
231
274
|
declare class App {
|
|
@@ -283,8 +326,7 @@ declare class FunctionCall {
|
|
|
283
326
|
declare class Function_ {
|
|
284
327
|
#private;
|
|
285
328
|
readonly functionId: string;
|
|
286
|
-
readonly methodName
|
|
287
|
-
readonly inputPlaneUrl: string | undefined;
|
|
329
|
+
readonly methodName?: string;
|
|
288
330
|
/** @ignore */
|
|
289
331
|
constructor(functionId: string, methodName?: string, inputPlaneUrl?: string);
|
|
290
332
|
static lookup(appName: string, name: string, options?: LookupOptions): Promise<Function_>;
|
|
@@ -296,7 +338,7 @@ declare class Function_ {
|
|
|
296
338
|
declare class Cls {
|
|
297
339
|
#private;
|
|
298
340
|
/** @ignore */
|
|
299
|
-
constructor(serviceFunctionId: string, schema: ClassParameterSpec[], methodNames: string[]);
|
|
341
|
+
constructor(serviceFunctionId: string, schema: ClassParameterSpec[], methodNames: string[], inputPlaneUrl?: string);
|
|
300
342
|
static lookup(appName: string, name: string, options?: LookupOptions): Promise<Cls>;
|
|
301
343
|
/** Create a new instance of the Cls with parameters. */
|
|
302
344
|
instance(params?: Record<string, any>): Promise<ClsInstance>;
|
|
@@ -336,6 +378,10 @@ declare class QueueEmptyError extends Error {
|
|
|
336
378
|
declare class QueueFullError extends Error {
|
|
337
379
|
constructor(message: string);
|
|
338
380
|
}
|
|
381
|
+
/** Sandbox operations that exceed the allowed time limit. */
|
|
382
|
+
declare class SandboxTimeoutError extends Error {
|
|
383
|
+
constructor(message?: string);
|
|
384
|
+
}
|
|
339
385
|
|
|
340
386
|
/** Options to configure a `Queue.clear()` operation. */
|
|
341
387
|
type QueueClearOptions = {
|
|
@@ -437,4 +483,4 @@ declare class Queue {
|
|
|
437
483
|
iterate(options?: QueueIterateOptions): AsyncGenerator<any, void, unknown>;
|
|
438
484
|
}
|
|
439
485
|
|
|
440
|
-
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, initializeClient };
|
|
486
|
+
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 };
|