@lunora/container 1.0.0-alpha.3 → 1.0.0-alpha.31
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/LICENSE.md +26 -0
- package/README.md +99 -1
- package/dist/bridge.d.mts +51 -35
- package/dist/bridge.d.ts +51 -35
- package/dist/bridge.mjs +1 -76
- package/dist/do/index.d.mts +580 -45
- package/dist/do/index.d.ts +580 -45
- package/dist/do/index.mjs +1 -138
- package/dist/index.d.mts +367 -114
- package/dist/index.d.ts +367 -114
- package/dist/index.mjs +1 -2
- package/dist/otel.d.mts +161 -0
- package/dist/otel.d.ts +161 -0
- package/dist/otel.mjs +1 -0
- package/dist/packem_shared/ContainerProxy-fTW_pXWY.mjs +27 -0
- package/dist/packem_shared/containerBindingName-D01FopQt.mjs +1 -0
- package/dist/packem_shared/createContainerContext-C8pmlFAX.mjs +1 -0
- package/dist/packem_shared/jurisdiction-DtE9s70w.mjs +1 -0
- package/dist/packem_shared/jurisdiction.d-DeQ3rtYK.d.mts +281 -0
- package/dist/packem_shared/jurisdiction.d-DeQ3rtYK.d.ts +281 -0
- package/package.json +6 -2
- package/dist/packem_shared/containerBindingName-BGdSdFNA.mjs +0 -116
- package/dist/packem_shared/createContainerContext-CTpyUQ4J.mjs +0 -133
- package/dist/packem_shared/types.d-D2l2SYol.d.mts +0 -140
- package/dist/packem_shared/types.d-D2l2SYol.d.ts +0 -140
package/dist/index.d.mts
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export type { B as BuildImageSource, c as ContainerInstanceType, d as
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
|
|
7
|
-
* Deliberately structural (no `@cloudflare/containers` import): a Durable
|
|
8
|
-
* Object namespace stub is all that is needed to route a request to a
|
|
9
|
-
* container-enabled DO, so this module stays Node-safe and the test double
|
|
10
|
-
* below can satisfy the exact same shape without a workerd runtime.
|
|
11
|
-
*/
|
|
12
|
-
/** Options for explicitly starting an instance (mirrors `@cloudflare/containers`). */
|
|
1
|
+
import { D as DurableObjectJurisdiction, C as ContainerConfig, a as ContainerDefinition, b as ContainerImageSource, N as NormalizedContainerImage } from "./packem_shared/jurisdiction.d-DeQ3rtYK.mjs";
|
|
2
|
+
export type { B as BuildImageSource, c as ContainerInstanceType, d as ContainerReadinessCheck, e as ContainerRollout, f as CustomContainerInstanceType, g as NamedContainerInstanceType, R as RegistryImageSource } from "./packem_shared/jurisdiction.d-DeQ3rtYK.mjs";
|
|
3
|
+
/**
|
|
4
|
+
* Options for explicitly starting an instance (mirrors `@cloudflare/containers`).
|
|
5
|
+
* @experimental
|
|
6
|
+
*/
|
|
13
7
|
interface ContainerStartOptions {
|
|
14
8
|
/** Override outbound internet access for this start. */
|
|
15
9
|
enableInternet?: boolean;
|
|
@@ -20,108 +14,215 @@ interface ContainerStartOptions {
|
|
|
20
14
|
/** Metadata labels attached for metrics/observability. */
|
|
21
15
|
labels?: Record<string, string>;
|
|
22
16
|
}
|
|
23
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* A container instance's runtime state, as returned by `getState()`. Structural — the platform adds fields over time.
|
|
19
|
+
* @experimental
|
|
20
|
+
*/
|
|
24
21
|
interface ContainerInstanceState {
|
|
25
22
|
[key: string]: unknown;
|
|
23
|
+
/** Process exit code, present once the instance has `stopped_with_code`. */
|
|
24
|
+
exitCode?: number;
|
|
25
|
+
/** Epoch-ms of the last state transition. */
|
|
26
26
|
lastChange?: number;
|
|
27
|
+
/** Lifecycle status. Widening union — Cloudflare adds values over time. */
|
|
28
|
+
status?: "healthy" | "running" | "stopped" | "stopped_with_code" | "stopping";
|
|
27
29
|
}
|
|
28
|
-
/** What a handle needs from a Durable Object stub — `fetch` plus the optional lifecycle RPCs the container DO exposes. */
|
|
30
|
+
/** What a handle needs from a Durable Object stub — `fetch` plus the optional lifecycle/egress RPCs the container DO exposes. */
|
|
29
31
|
interface ContainerStubLike {
|
|
32
|
+
allowHost?: (hostname: string) => Promise<void>;
|
|
33
|
+
denyHost?: (hostname: string) => Promise<void>;
|
|
30
34
|
destroy?: () => Promise<void>;
|
|
31
35
|
fetch: (input: Request) => Promise<Response>;
|
|
32
36
|
getState?: () => Promise<ContainerInstanceState>;
|
|
37
|
+
removeAllowedHost?: (hostname: string) => Promise<void>;
|
|
38
|
+
removeDeniedHost?: (hostname: string) => Promise<void>;
|
|
39
|
+
renewActivityTimeout?: () => Promise<void>;
|
|
40
|
+
setAllowedHosts?: (hosts: string[]) => Promise<void>;
|
|
41
|
+
setDeniedHosts?: (hosts: string[]) => Promise<void>;
|
|
33
42
|
start?: (options?: ContainerStartOptions) => Promise<void>;
|
|
34
43
|
stop?: (signal?: number | string) => Promise<void>;
|
|
35
44
|
}
|
|
36
45
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
|
|
40
|
-
*/
|
|
41
|
-
type DurableObjectJurisdiction = "eu" | "fedramp" | "us";
|
|
42
|
-
/** What the client needs from a Durable Object namespace binding. */
|
|
46
|
+
* What the client needs from a Durable Object namespace binding.
|
|
47
|
+
* @experimental
|
|
48
|
+
*/
|
|
43
49
|
interface ContainerNamespaceLike {
|
|
44
50
|
get: (id: unknown) => ContainerStubLike;
|
|
45
51
|
idFromName: (name: string) => unknown;
|
|
46
52
|
/**
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
53
|
+
* Derive a jurisdiction-restricted subnamespace. Optional because older
|
|
54
|
+
* workers-types releases (and test doubles) may not expose it.
|
|
55
|
+
*/
|
|
50
56
|
jurisdiction?: (jurisdiction: DurableObjectJurisdiction) => ContainerNamespaceLike;
|
|
51
57
|
}
|
|
52
|
-
/**
|
|
58
|
+
/**
|
|
59
|
+
* A handle on one container instance (one Durable Object).
|
|
60
|
+
* @experimental
|
|
61
|
+
*/
|
|
53
62
|
interface ContainerHandle {
|
|
54
63
|
/**
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
64
|
+
* Send an HTTP (or WebSocket-upgrade) request to the container. A path
|
|
65
|
+
* string (`"/transcode"`) is resolved against a synthetic origin; a full
|
|
66
|
+
* `Request`/URL passes through unchanged.
|
|
67
|
+
*/
|
|
59
68
|
fetch: (input: Request | string, init?: RequestInit) => Promise<Response>;
|
|
69
|
+
/**
|
|
70
|
+
* Return a handle that routes every request to `targetPort` on the
|
|
71
|
+
* container instead of the definition's `defaultPort` — for multi-port
|
|
72
|
+
* containers (declare the ports in `requiredPorts`). Sets the
|
|
73
|
+
* `cf-container-target-port` header the way `@cloudflare/containers`'
|
|
74
|
+
* `switchPort` does, so it composes with `.get()`, `.any()`, and `.pool()`:
|
|
75
|
+
* `ctx.containers.app.get("u1").port(9090).fetch("/admin")`.
|
|
76
|
+
*/
|
|
77
|
+
port: (targetPort: number) => ContainerHandle;
|
|
60
78
|
}
|
|
61
79
|
/**
|
|
62
|
-
* A handle on a *named* instance (from `.get(name)`) — `fetch` plus explicit
|
|
63
|
-
* lifecycle control. The per-entity pattern (a sandbox per user, a room per
|
|
64
|
-
* game, a job runner per id) often needs to tear down or inspect the instance
|
|
65
|
-
* rather than wait for `sleepAfter`, so these wrap the container DO's
|
|
66
|
-
* `start`/`stop`/`destroy`/`getState`.
|
|
67
|
-
|
|
80
|
+
* A handle on a *named* instance (from `.get(name)`) — `fetch` plus explicit
|
|
81
|
+
* lifecycle control. The per-entity pattern (a sandbox per user, a room per
|
|
82
|
+
* game, a job runner per id) often needs to tear down or inspect the instance
|
|
83
|
+
* rather than wait for `sleepAfter`, so these wrap the container DO's
|
|
84
|
+
* `start`/`stop`/`destroy`/`getState`.
|
|
85
|
+
* @experimental
|
|
86
|
+
*/
|
|
68
87
|
interface ContainerInstanceHandle extends ContainerHandle {
|
|
69
88
|
/** Stop and discard the instance (its ephemeral disk is lost). */
|
|
70
89
|
destroy: () => Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* Adjust this instance's egress allow/deny lists at runtime — the dynamic
|
|
92
|
+
* counterpart to the static `allowedHosts`/`deniedHosts` config. Useful for
|
|
93
|
+
* per-tenant egress policy. Requires the worker to export `ContainerProxy`
|
|
94
|
+
* (codegen re-exports it from the generated container file whenever any
|
|
95
|
+
* container is defined, so the runtime controls always work).
|
|
96
|
+
*/
|
|
97
|
+
egress: ContainerEgressControls;
|
|
71
98
|
/** Read the instance's current runtime state. */
|
|
72
99
|
getState: () => Promise<ContainerInstanceState>;
|
|
100
|
+
/**
|
|
101
|
+
* Reset the instance's `sleepAfter` idle timer. The platform renews it on
|
|
102
|
+
* each proxied request, and because `@lunora/container` proxies WebSocket
|
|
103
|
+
* frames through the Durable Object, message traffic on an open socket
|
|
104
|
+
* renews it too (the WebSocket-keepalive gap of cloudflare/containers#147 is
|
|
105
|
+
* closed in the bundled base). This manual control is the escape hatch for
|
|
106
|
+
* keeping a container awake during activity that is neither an HTTP request
|
|
107
|
+
* nor a WS message — e.g. a long out-of-band job running inside it.
|
|
108
|
+
*/
|
|
109
|
+
renewActivityTimeout: () => Promise<void>;
|
|
73
110
|
/** Explicitly start the instance, optionally with per-instance env/entrypoint. */
|
|
74
111
|
start: (options?: ContainerStartOptions) => Promise<void>;
|
|
75
112
|
/** Stop the instance (optionally with a signal); it can start again on the next request. */
|
|
76
113
|
stop: (signal?: number | string) => Promise<void>;
|
|
77
114
|
}
|
|
78
|
-
/**
|
|
115
|
+
/**
|
|
116
|
+
* Runtime egress-firewall controls for a named instance (`handle.egress.*`).
|
|
117
|
+
* Each maps to the corresponding `@cloudflare/containers` `Container` RPC, so
|
|
118
|
+
* an app can tighten or relax a single instance's allowed/denied hosts after
|
|
119
|
+
* start without redeploying.
|
|
120
|
+
* @experimental
|
|
121
|
+
*/
|
|
122
|
+
interface ContainerEgressControls {
|
|
123
|
+
/** Add one hostname (or glob) to the allow-list. */
|
|
124
|
+
allow: (hostname: string) => Promise<void>;
|
|
125
|
+
/** Add one hostname (or glob) to the deny-list. */
|
|
126
|
+
deny: (hostname: string) => Promise<void>;
|
|
127
|
+
/** Remove one hostname from the allow-list. */
|
|
128
|
+
removeAllowed: (hostname: string) => Promise<void>;
|
|
129
|
+
/** Remove one hostname from the deny-list. */
|
|
130
|
+
removeDenied: (hostname: string) => Promise<void>;
|
|
131
|
+
/** Replace the entire allow-list. */
|
|
132
|
+
setAllowed: (hosts: ReadonlyArray<string>) => Promise<void>;
|
|
133
|
+
/** Replace the entire deny-list. */
|
|
134
|
+
setDenied: (hosts: ReadonlyArray<string>) => Promise<void>;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* The per-definition accessor exposed as `ctx.containers.<exportName>`.
|
|
138
|
+
* @experimental
|
|
139
|
+
*/
|
|
79
140
|
interface ContainerAccessor {
|
|
80
141
|
/**
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
142
|
+
* A random instance from a fixed pool of `count` (defaults to the
|
|
143
|
+
* definition's `maxInstances`, else 3 — mirroring `getRandom` from
|
|
144
|
+
* `@cloudflare/containers`). For stateless, interchangeable workloads.
|
|
145
|
+
*
|
|
146
|
+
* Like `.get()`, a path/URL-string fetch transparently retries the
|
|
147
|
+
* cold-start "instance is provisioning" transients (cloudflare/containers#45,
|
|
148
|
+
* #139); pass {@link InstanceRetryOptions} to tune or disable it.
|
|
149
|
+
*/
|
|
150
|
+
any: (count?: number, options?: InstanceRetryOptions) => ContainerHandle;
|
|
88
151
|
/**
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
152
|
+
* The instance for `name` — one container per entity (user, room, job…),
|
|
153
|
+
* with lifecycle control.
|
|
154
|
+
*
|
|
155
|
+
* A path/URL-string fetch transparently retries the platform's cold-start
|
|
156
|
+
* transients — "there is no Container instance available" / "container is
|
|
157
|
+
* not listening" while an instance is still provisioning
|
|
158
|
+
* (cloudflare/containers#45, #139) — on the *same* instance with backoff,
|
|
159
|
+
* since the request never reached the app. Pass {@link InstanceRetryOptions}
|
|
160
|
+
* to tune attempts/backoff or disable it (`{ attempts: 1 }`). A pre-built
|
|
161
|
+
* `Request` (possibly a one-shot stream body) is sent once, never retried.
|
|
162
|
+
*/
|
|
163
|
+
get: (name: string, options?: InstanceRetryOptions) => ContainerInstanceHandle;
|
|
164
|
+
/**
|
|
165
|
+
* A resilient handle over the pool: each `fetch` picks a random instance and,
|
|
166
|
+
* on a thrown error or a retryable response (5xx by default), retries on a
|
|
167
|
+
* freshly-picked instance with exponential backoff. Until Cloudflare ships
|
|
168
|
+
* native autoscaling + health-aware routing this is the recommended way to
|
|
169
|
+
* call a stateless container pool — it rides over a single cold/unhealthy
|
|
170
|
+
* instance instead of failing the whole request.
|
|
171
|
+
*
|
|
172
|
+
* Because a retry re-issues the request, pass a **replayable** body — a path
|
|
173
|
+
* string plus an `init.body` string/`ArrayBuffer` (re-created each attempt).
|
|
174
|
+
* A pre-built `Request` carrying a stream body can only be sent once, so it
|
|
175
|
+
* is not retry-safe here; use `.get()`/`.any()` for those.
|
|
176
|
+
*/
|
|
101
177
|
pool: (options?: PoolOptions) => ContainerHandle;
|
|
102
178
|
}
|
|
103
|
-
/**
|
|
179
|
+
/**
|
|
180
|
+
* Tuning for a pooled, retrying container handle. See {@link ContainerAccessor.pool}.
|
|
181
|
+
* @experimental
|
|
182
|
+
*/
|
|
104
183
|
interface PoolOptions {
|
|
105
184
|
/** Total attempts before giving up (each on a freshly-picked instance). Default 3. */
|
|
106
185
|
attempts?: number;
|
|
107
186
|
/** Base backoff in ms between attempts; doubles each retry (0 disables the wait). Default 100. */
|
|
108
187
|
backoffMs?: number;
|
|
109
188
|
/**
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
189
|
+
* Upper bound on a single backoff sleep, in ms. The doubling delay is clamped
|
|
190
|
+
* to this ceiling so a large `attempts` count can't produce an unboundedly
|
|
191
|
+
* long wait. Default {@link DEFAULT_MAX_BACKOFF_MS} (30s).
|
|
192
|
+
*/
|
|
114
193
|
maxBackoffMs?: number;
|
|
115
194
|
/**
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
195
|
+
* Whether a *returned* response should be retried on another instance.
|
|
196
|
+
* Defaults to retrying any `5xx`. A thrown error (network/start failure) is
|
|
197
|
+
* always retried regardless of this predicate.
|
|
198
|
+
*/
|
|
120
199
|
retryOn?: (response: Response) => boolean;
|
|
121
200
|
/** Pool size to spread picks across. Defaults to the definition's `maxInstances`, else 3. */
|
|
122
201
|
size?: number;
|
|
123
202
|
}
|
|
124
|
-
/**
|
|
203
|
+
/**
|
|
204
|
+
* Tuning for the cold-start retry on a `.get()`/`.any()` handle. The retry fires
|
|
205
|
+
* only on the platform's provisioning transients (no-instance / not-listening /
|
|
206
|
+
* rate-limited — see {@link isColdStartTransient}), which is why it's safe by
|
|
207
|
+
* default: those responses mean the request never reached the container.
|
|
208
|
+
* @experimental
|
|
209
|
+
*/
|
|
210
|
+
interface InstanceRetryOptions {
|
|
211
|
+
/**
|
|
212
|
+
* Total attempts on a cold-start transient before the last outcome is
|
|
213
|
+
* surfaced as-is. `1` disables the retry. Default
|
|
214
|
+
* {@link DEFAULT_COLD_START_ATTEMPTS}.
|
|
215
|
+
*/
|
|
216
|
+
attempts?: number;
|
|
217
|
+
/** Base backoff in ms between attempts; doubles each retry (0 disables the wait). Default {@link DEFAULT_COLD_START_BACKOFF_MS}. */
|
|
218
|
+
backoffMs?: number;
|
|
219
|
+
/** Upper bound on a single backoff sleep, in ms. Default {@link DEFAULT_MAX_BACKOFF_MS} (30s). */
|
|
220
|
+
maxBackoffMs?: number;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Wiring info for one definition, emitted by codegen into the generated DO.
|
|
224
|
+
* @experimental
|
|
225
|
+
*/
|
|
125
226
|
interface ContainerBindingSpec {
|
|
126
227
|
/** Durable Object binding name, e.g. `CONTAINER_TRANSCODER`. */
|
|
127
228
|
binding: string;
|
|
@@ -131,70 +232,222 @@ interface ContainerBindingSpec {
|
|
|
131
232
|
maxInstances?: number;
|
|
132
233
|
}
|
|
133
234
|
/**
|
|
134
|
-
* Build the `ctx.containers` record from the Worker `env`. Called by the
|
|
135
|
-
* generated ShardDO with the specs codegen derived from
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
235
|
+
* Build the `ctx.containers` record from the Worker `env`. Called by the
|
|
236
|
+
* generated ShardDO with the specs codegen derived from `lunora/containers.ts`.
|
|
237
|
+
* A missing binding doesn't throw here — only when the handle is actually used —
|
|
238
|
+
* so one unprovisioned container never breaks unrelated functions.
|
|
239
|
+
*
|
|
240
|
+
* `traceparent` (the inbound RPC's W3C trace context, forwarded by the runtime
|
|
241
|
+
* and read off the request by the DO) is stamped onto every outbound container
|
|
242
|
+
* `fetch`, so the container's own spans stitch under the Worker's trace.
|
|
243
|
+
* @experimental
|
|
244
|
+
*/
|
|
245
|
+
declare const createContainerContext: (env: Record<string, unknown>, specs: ReadonlyArray<ContainerBindingSpec>, jurisdiction?: DurableObjectJurisdiction, traceparent?: string) => Record<string, ContainerAccessor>;
|
|
246
|
+
/**
|
|
247
|
+
* A test handler: receives the request plus the targeted instance name.
|
|
248
|
+
* @experimental
|
|
249
|
+
*/
|
|
142
250
|
type ContainerTestHandler = (request: Request, instance: {
|
|
143
251
|
name: string;
|
|
144
252
|
}) => Promise<Response> | Response;
|
|
145
253
|
/**
|
|
146
|
-
* Docker-free test double for `ctx.containers`: each export name maps to a
|
|
147
|
-
* fetch handler that plays the container. Mirrors the real shape exactly, so
|
|
148
|
-
* action handlers under test can't tell the difference.
|
|
149
|
-
*
|
|
150
|
-
* ```ts
|
|
151
|
-
* const containers = createContainerTestContext({
|
|
152
|
-
* transcoder: (request) => new Response("ok"),
|
|
153
|
-
* });
|
|
154
|
-
* ```
|
|
155
|
-
|
|
254
|
+
* Docker-free test double for `ctx.containers`: each export name maps to a
|
|
255
|
+
* fetch handler that plays the container. Mirrors the real shape exactly, so
|
|
256
|
+
* action handlers under test can't tell the difference.
|
|
257
|
+
*
|
|
258
|
+
* ```ts
|
|
259
|
+
* const containers = createContainerTestContext({
|
|
260
|
+
* transcoder: (request) => new Response("ok"),
|
|
261
|
+
* });
|
|
262
|
+
* ```
|
|
263
|
+
* @experimental
|
|
264
|
+
*/
|
|
156
265
|
declare const createContainerTestContext: (handlers: Record<string, ContainerTestHandler>) => Record<string, ContainerAccessor>;
|
|
157
266
|
/**
|
|
158
|
-
* Normalize a `ContainerImageSource` into the shape wrangler wants: a
|
|
159
|
-
* Dockerfile path + build context for local builds, or a fully-qualified
|
|
160
|
-
* reference for pre-built images.
|
|
161
|
-
*
|
|
162
|
-
* A local-path string whose basename starts with `Dockerfile` (so
|
|
163
|
-
* `Dockerfile.dev` also counts) is used as-is with its directory as the build
|
|
164
|
-
* context; any other path is treated as the build-context directory and the
|
|
165
|
-
* Dockerfile is expected at
|
|
166
|
-
|
|
267
|
+
* Normalize a `ContainerImageSource` into the shape wrangler wants: a
|
|
268
|
+
* Dockerfile path + build context for local builds, or a fully-qualified
|
|
269
|
+
* reference for pre-built images.
|
|
270
|
+
*
|
|
271
|
+
* A local-path string whose basename starts with `Dockerfile` (so
|
|
272
|
+
* `Dockerfile.dev` also counts) is used as-is with its directory as the build
|
|
273
|
+
* context; any other path is treated as the build-context directory and the
|
|
274
|
+
* Dockerfile is expected at `<dir>/Dockerfile`.
|
|
275
|
+
* @experimental
|
|
276
|
+
*/
|
|
167
277
|
declare const normalizeContainerImage: (image: ContainerImageSource) => NormalizedContainerImage;
|
|
168
278
|
/**
|
|
169
|
-
* The generated Container DO class name for a `lunora/containers.ts` export:
|
|
170
|
-
* `transcoder` → `TranscoderContainer`. wrangler's `containers[].class_name`
|
|
171
|
-
* and the Durable Object binding's `class_name` both reference it, so codegen
|
|
172
|
-
* and the config layer MUST derive it identically — always via this helper.
|
|
173
|
-
|
|
279
|
+
* The generated Container DO class name for a `lunora/containers.ts` export:
|
|
280
|
+
* `transcoder` → `TranscoderContainer`. wrangler's `containers[].class_name`
|
|
281
|
+
* and the Durable Object binding's `class_name` both reference it, so codegen
|
|
282
|
+
* and the config layer MUST derive it identically — always via this helper.
|
|
283
|
+
* @experimental
|
|
284
|
+
*/
|
|
174
285
|
declare const containerClassName: (exportName: string) => string;
|
|
175
286
|
/**
|
|
176
|
-
* The Durable Object binding name for a container export: `transcoder` →
|
|
177
|
-
* `CONTAINER_TRANSCODER`, `imageResizer` → `CONTAINER_IMAGE_RESIZER`. The
|
|
178
|
-
* `CONTAINER_` prefix namespaces these away from `SHARD`/`SESSION`/`SCHEDULER`
|
|
179
|
-
* so a container export can never collide with the built-in bindings.
|
|
180
|
-
|
|
287
|
+
* The Durable Object binding name for a container export: `transcoder` →
|
|
288
|
+
* `CONTAINER_TRANSCODER`, `imageResizer` → `CONTAINER_IMAGE_RESIZER`. The
|
|
289
|
+
* `CONTAINER_` prefix namespaces these away from `SHARD`/`SESSION`/`SCHEDULER`
|
|
290
|
+
* so a container export can never collide with the built-in bindings.
|
|
291
|
+
* @experimental
|
|
292
|
+
*/
|
|
181
293
|
declare const containerBindingName: (exportName: string) => string;
|
|
182
294
|
/**
|
|
183
|
-
* The local image tag a Railpack `{ build }` container is built and pushed
|
|
184
|
-
* under: `transcoder` → `lunora-transcoder:build`. The config reconciler writes
|
|
185
|
-
* it as the wrangler `containers[].image`, and `lunora deploy` builds that tag
|
|
186
|
-
* with Railpack and `wrangler containers push`es it before deploying — so all
|
|
187
|
-
* three derive the tag from this one helper and can never disagree.
|
|
188
|
-
|
|
295
|
+
* The local image tag a Railpack `{ build }` container is built and pushed
|
|
296
|
+
* under: `transcoder` → `lunora-transcoder:build`. The config reconciler writes
|
|
297
|
+
* it as the wrangler `containers[].image`, and `lunora deploy` builds that tag
|
|
298
|
+
* with Railpack and `wrangler containers push`es it before deploying — so all
|
|
299
|
+
* three derive the tag from this one helper and can never disagree.
|
|
300
|
+
* @experimental
|
|
301
|
+
*/
|
|
189
302
|
declare const containerBuildTag: (exportName: string) => string;
|
|
303
|
+
/**
|
|
304
|
+
* `defineContainer` is part of the experimental `@lunora/container` API and may change without a major version bump.
|
|
305
|
+
* @experimental
|
|
306
|
+
*/
|
|
190
307
|
declare const defineContainer: (config: ContainerConfig) => ContainerDefinition;
|
|
191
|
-
/**
|
|
308
|
+
/**
|
|
309
|
+
* True when a value is a `defineContainer` result (the runtime brand check).
|
|
310
|
+
* @experimental
|
|
311
|
+
*/
|
|
192
312
|
declare const isContainerDefinition: (value: unknown) => value is ContainerDefinition;
|
|
193
313
|
/**
|
|
194
|
-
* The container's full environment at instance start: the static `env` block
|
|
195
|
-
* plus every declared secret resolved from the Worker `env`. A declared secret
|
|
196
|
-
* missing from the Worker env fails fast — starting the container without a
|
|
197
|
-
* credential it was promised yields far worse errors downstream.
|
|
198
|
-
|
|
314
|
+
* The container's full environment at instance start: the static `env` block
|
|
315
|
+
* plus every declared secret resolved from the Worker `env`. A declared secret
|
|
316
|
+
* missing from the Worker env fails fast — starting the container without a
|
|
317
|
+
* credential it was promised yields far worse errors downstream.
|
|
318
|
+
* @experimental
|
|
319
|
+
*/
|
|
199
320
|
declare const resolveContainerEnvVariables: (definition: ContainerDefinition, workerEnv: Record<string, unknown>, exportName?: string) => Record<string, string>;
|
|
200
|
-
export {
|
|
321
|
+
export {
|
|
322
|
+
/**
|
|
323
|
+
* `@lunora/container` — Cloudflare Containers for Lunora.
|
|
324
|
+
*
|
|
325
|
+
* This root export is Node-safe (no Cloudflare runtime imports): the
|
|
326
|
+
* `defineContainer` authoring surface, the naming/normalization helpers
|
|
327
|
+
* codegen and `@lunora/config` share, the `ctx.containers` client wiring, and
|
|
328
|
+
* a Docker-free test double. The workerd-only `LunoraContainer` base class
|
|
329
|
+
* (which pulls in `@cloudflare/containers` → `cloudflare:workers`) lives
|
|
330
|
+
* behind the `@lunora/container/do` subpath.
|
|
331
|
+
*/
|
|
332
|
+
type ContainerAccessor,
|
|
333
|
+
/**
|
|
334
|
+
* `@lunora/container` — Cloudflare Containers for Lunora.
|
|
335
|
+
*
|
|
336
|
+
* This root export is Node-safe (no Cloudflare runtime imports): the
|
|
337
|
+
* `defineContainer` authoring surface, the naming/normalization helpers
|
|
338
|
+
* codegen and `@lunora/config` share, the `ctx.containers` client wiring, and
|
|
339
|
+
* a Docker-free test double. The workerd-only `LunoraContainer` base class
|
|
340
|
+
* (which pulls in `@cloudflare/containers` → `cloudflare:workers`) lives
|
|
341
|
+
* behind the `@lunora/container/do` subpath.
|
|
342
|
+
*/
|
|
343
|
+
type ContainerBindingSpec, type ContainerConfig, type ContainerDefinition,
|
|
344
|
+
/**
|
|
345
|
+
* `@lunora/container` — Cloudflare Containers for Lunora.
|
|
346
|
+
*
|
|
347
|
+
* This root export is Node-safe (no Cloudflare runtime imports): the
|
|
348
|
+
* `defineContainer` authoring surface, the naming/normalization helpers
|
|
349
|
+
* codegen and `@lunora/config` share, the `ctx.containers` client wiring, and
|
|
350
|
+
* a Docker-free test double. The workerd-only `LunoraContainer` base class
|
|
351
|
+
* (which pulls in `@cloudflare/containers` → `cloudflare:workers`) lives
|
|
352
|
+
* behind the `@lunora/container/do` subpath.
|
|
353
|
+
*/
|
|
354
|
+
type ContainerEgressControls,
|
|
355
|
+
/**
|
|
356
|
+
* `@lunora/container` — Cloudflare Containers for Lunora.
|
|
357
|
+
*
|
|
358
|
+
* This root export is Node-safe (no Cloudflare runtime imports): the
|
|
359
|
+
* `defineContainer` authoring surface, the naming/normalization helpers
|
|
360
|
+
* codegen and `@lunora/config` share, the `ctx.containers` client wiring, and
|
|
361
|
+
* a Docker-free test double. The workerd-only `LunoraContainer` base class
|
|
362
|
+
* (which pulls in `@cloudflare/containers` → `cloudflare:workers`) lives
|
|
363
|
+
* behind the `@lunora/container/do` subpath.
|
|
364
|
+
*/
|
|
365
|
+
type ContainerHandle, type ContainerImageSource,
|
|
366
|
+
/**
|
|
367
|
+
* `@lunora/container` — Cloudflare Containers for Lunora.
|
|
368
|
+
*
|
|
369
|
+
* This root export is Node-safe (no Cloudflare runtime imports): the
|
|
370
|
+
* `defineContainer` authoring surface, the naming/normalization helpers
|
|
371
|
+
* codegen and `@lunora/config` share, the `ctx.containers` client wiring, and
|
|
372
|
+
* a Docker-free test double. The workerd-only `LunoraContainer` base class
|
|
373
|
+
* (which pulls in `@cloudflare/containers` → `cloudflare:workers`) lives
|
|
374
|
+
* behind the `@lunora/container/do` subpath.
|
|
375
|
+
*/
|
|
376
|
+
type ContainerInstanceHandle,
|
|
377
|
+
/**
|
|
378
|
+
* `@lunora/container` — Cloudflare Containers for Lunora.
|
|
379
|
+
*
|
|
380
|
+
* This root export is Node-safe (no Cloudflare runtime imports): the
|
|
381
|
+
* `defineContainer` authoring surface, the naming/normalization helpers
|
|
382
|
+
* codegen and `@lunora/config` share, the `ctx.containers` client wiring, and
|
|
383
|
+
* a Docker-free test double. The workerd-only `LunoraContainer` base class
|
|
384
|
+
* (which pulls in `@cloudflare/containers` → `cloudflare:workers`) lives
|
|
385
|
+
* behind the `@lunora/container/do` subpath.
|
|
386
|
+
*/
|
|
387
|
+
type ContainerInstanceState,
|
|
388
|
+
/**
|
|
389
|
+
* `@lunora/container` — Cloudflare Containers for Lunora.
|
|
390
|
+
*
|
|
391
|
+
* This root export is Node-safe (no Cloudflare runtime imports): the
|
|
392
|
+
* `defineContainer` authoring surface, the naming/normalization helpers
|
|
393
|
+
* codegen and `@lunora/config` share, the `ctx.containers` client wiring, and
|
|
394
|
+
* a Docker-free test double. The workerd-only `LunoraContainer` base class
|
|
395
|
+
* (which pulls in `@cloudflare/containers` → `cloudflare:workers`) lives
|
|
396
|
+
* behind the `@lunora/container/do` subpath.
|
|
397
|
+
*/
|
|
398
|
+
type ContainerNamespaceLike,
|
|
399
|
+
/**
|
|
400
|
+
* `@lunora/container` — Cloudflare Containers for Lunora.
|
|
401
|
+
*
|
|
402
|
+
* This root export is Node-safe (no Cloudflare runtime imports): the
|
|
403
|
+
* `defineContainer` authoring surface, the naming/normalization helpers
|
|
404
|
+
* codegen and `@lunora/config` share, the `ctx.containers` client wiring, and
|
|
405
|
+
* a Docker-free test double. The workerd-only `LunoraContainer` base class
|
|
406
|
+
* (which pulls in `@cloudflare/containers` → `cloudflare:workers`) lives
|
|
407
|
+
* behind the `@lunora/container/do` subpath.
|
|
408
|
+
*/
|
|
409
|
+
type ContainerStartOptions,
|
|
410
|
+
/**
|
|
411
|
+
* `@lunora/container` — Cloudflare Containers for Lunora.
|
|
412
|
+
*
|
|
413
|
+
* This root export is Node-safe (no Cloudflare runtime imports): the
|
|
414
|
+
* `defineContainer` authoring surface, the naming/normalization helpers
|
|
415
|
+
* codegen and `@lunora/config` share, the `ctx.containers` client wiring, and
|
|
416
|
+
* a Docker-free test double. The workerd-only `LunoraContainer` base class
|
|
417
|
+
* (which pulls in `@cloudflare/containers` → `cloudflare:workers`) lives
|
|
418
|
+
* behind the `@lunora/container/do` subpath.
|
|
419
|
+
*/
|
|
420
|
+
type ContainerTestHandler,
|
|
421
|
+
/**
|
|
422
|
+
* `@lunora/container` — Cloudflare Containers for Lunora.
|
|
423
|
+
*
|
|
424
|
+
* This root export is Node-safe (no Cloudflare runtime imports): the
|
|
425
|
+
* `defineContainer` authoring surface, the naming/normalization helpers
|
|
426
|
+
* codegen and `@lunora/config` share, the `ctx.containers` client wiring, and
|
|
427
|
+
* a Docker-free test double. The workerd-only `LunoraContainer` base class
|
|
428
|
+
* (which pulls in `@cloudflare/containers` → `cloudflare:workers`) lives
|
|
429
|
+
* behind the `@lunora/container/do` subpath.
|
|
430
|
+
*/
|
|
431
|
+
type DurableObjectJurisdiction,
|
|
432
|
+
/**
|
|
433
|
+
* `@lunora/container` — Cloudflare Containers for Lunora.
|
|
434
|
+
*
|
|
435
|
+
* This root export is Node-safe (no Cloudflare runtime imports): the
|
|
436
|
+
* `defineContainer` authoring surface, the naming/normalization helpers
|
|
437
|
+
* codegen and `@lunora/config` share, the `ctx.containers` client wiring, and
|
|
438
|
+
* a Docker-free test double. The workerd-only `LunoraContainer` base class
|
|
439
|
+
* (which pulls in `@cloudflare/containers` → `cloudflare:workers`) lives
|
|
440
|
+
* behind the `@lunora/container/do` subpath.
|
|
441
|
+
*/
|
|
442
|
+
type InstanceRetryOptions, type NormalizedContainerImage,
|
|
443
|
+
/**
|
|
444
|
+
* `@lunora/container` — Cloudflare Containers for Lunora.
|
|
445
|
+
*
|
|
446
|
+
* This root export is Node-safe (no Cloudflare runtime imports): the
|
|
447
|
+
* `defineContainer` authoring surface, the naming/normalization helpers
|
|
448
|
+
* codegen and `@lunora/config` share, the `ctx.containers` client wiring, and
|
|
449
|
+
* a Docker-free test double. The workerd-only `LunoraContainer` base class
|
|
450
|
+
* (which pulls in `@cloudflare/containers` → `cloudflare:workers`) lives
|
|
451
|
+
* behind the `@lunora/container/do` subpath.
|
|
452
|
+
*/
|
|
453
|
+
type PoolOptions, containerBindingName, containerBuildTag, containerClassName, createContainerContext, createContainerTestContext, defineContainer, isContainerDefinition, normalizeContainerImage, resolveContainerEnvVariables as resolveContainerEnvVars };
|