@lunora/container 1.0.0-alpha.11 → 1.0.0-alpha.13
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/README.md +2 -0
- package/dist/bridge.d.mts +49 -33
- package/dist/bridge.d.ts +49 -33
- package/dist/do/index.d.mts +71 -70
- package/dist/do/index.d.ts +71 -70
- package/dist/index.d.mts +188 -147
- package/dist/index.d.ts +188 -147
- package/dist/otel.d.mts +63 -46
- package/dist/otel.d.ts +63 -46
- package/dist/otel.mjs +4 -0
- package/dist/packem_shared/jurisdiction.d-8oUUvrew.d.mts +281 -0
- package/dist/packem_shared/jurisdiction.d-8oUUvrew.d.ts +281 -0
- package/package.json +2 -2
- package/dist/packem_shared/jurisdiction.d-TwTGkgTg.d.mts +0 -266
- package/dist/packem_shared/jurisdiction.d-TwTGkgTg.d.ts +0 -266
package/README.md
CHANGED
package/dist/bridge.d.mts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { LunoraError } from '@lunora/errors';
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* A `fetch` implementation — defaults to the runtime global.
|
|
4
|
+
* @experimental
|
|
5
|
+
*/
|
|
3
6
|
type FetchLike = (input: string, init: {
|
|
4
7
|
body: string;
|
|
5
8
|
headers: Record<string, string>;
|
|
@@ -10,33 +13,41 @@ type FetchLike = (input: string, init: {
|
|
|
10
13
|
status: number;
|
|
11
14
|
statusText?: string;
|
|
12
15
|
}>;
|
|
16
|
+
/**
|
|
17
|
+
* `ContainerBridgeOptions` is part of the experimental `@lunora/container` API and may change without a major version bump.
|
|
18
|
+
* @experimental
|
|
19
|
+
*/
|
|
13
20
|
interface ContainerBridgeOptions {
|
|
14
21
|
/**
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
22
|
+
* Base URL of the deployed Lunora Worker (no trailing `/_lunora/rpc`), e.g.
|
|
23
|
+
* `https://my-app.workers.dev`. In a Lunora container, surface it as an
|
|
24
|
+
* `env` value on the definition.
|
|
25
|
+
*/
|
|
19
26
|
baseUrl: string;
|
|
20
27
|
/** Injectable `fetch` (tests / non-global runtimes). Defaults to `globalThis.fetch`. */
|
|
21
28
|
fetch?: FetchLike;
|
|
22
29
|
/**
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
30
|
+
* Bearer token sent as `Authorization: Bearer <token>`. Your Worker's
|
|
31
|
+
* `resolveIdentity` maps it to the identity the called functions run as.
|
|
32
|
+
* Pass it to the container as a `secret`, never bake it into the image.
|
|
33
|
+
*/
|
|
27
34
|
token?: string;
|
|
28
35
|
}
|
|
29
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* Thrown when a Lunora function returns an error envelope. A `LunoraError` subclass carrying the wire `code`.
|
|
38
|
+
* @experimental
|
|
39
|
+
*/
|
|
30
40
|
declare class ContainerBridgeError extends LunoraError {
|
|
31
41
|
constructor(code: string, message: string);
|
|
32
42
|
}
|
|
33
43
|
/**
|
|
34
|
-
* Structural mirror of `@lunora/client`'s `FunctionReference` — the typed
|
|
35
|
-
* handle the generated `_generated/api` object carries. Declared locally (not
|
|
36
|
-
* imported) so the bridge stays dependency-free and its `.d.ts` is
|
|
37
|
-
* self-contained; the `__lunoraPhantom` shape matches, so a real `api.x.y`
|
|
38
|
-
* reference is assignable and its arg/return types are inferable.
|
|
39
|
-
|
|
44
|
+
* Structural mirror of `@lunora/client`'s `FunctionReference` — the typed
|
|
45
|
+
* handle the generated `_generated/api` object carries. Declared locally (not
|
|
46
|
+
* imported) so the bridge stays dependency-free and its `.d.ts` is
|
|
47
|
+
* self-contained; the `__lunoraPhantom` shape matches, so a real `api.x.y`
|
|
48
|
+
* reference is assignable and its arg/return types are inferable.
|
|
49
|
+
* @experimental
|
|
50
|
+
*/
|
|
40
51
|
interface BridgeFunctionReference<Args = unknown, Result = unknown> {
|
|
41
52
|
readonly __lunoraPhantom?: {
|
|
42
53
|
args: Args;
|
|
@@ -56,6 +67,10 @@ type ResultOfReference<Reference> = Reference extends {
|
|
|
56
67
|
returns: infer Result;
|
|
57
68
|
};
|
|
58
69
|
} ? Result : never;
|
|
70
|
+
/**
|
|
71
|
+
* `ContainerBridge` is part of the experimental `@lunora/container` API and may change without a major version bump.
|
|
72
|
+
* @experimental
|
|
73
|
+
*/
|
|
59
74
|
interface ContainerBridge {
|
|
60
75
|
/** Call an `action` by `namespace:fn` path. Alias of {@link ContainerBridge.call} for intent. */
|
|
61
76
|
action: <Result = unknown>(functionPath: string, args?: Record<string, unknown>, shardKey?: string) => Promise<Result>;
|
|
@@ -66,25 +81,26 @@ interface ContainerBridge {
|
|
|
66
81
|
/** Call a `query` by `namespace:fn` path. Alias of {@link ContainerBridge.call} for intent. */
|
|
67
82
|
query: <Result = unknown>(functionPath: string, args?: Record<string, unknown>, shardKey?: string) => Promise<Result>;
|
|
68
83
|
/**
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
84
|
+
* Fully-typed call via a generated function reference. Pass a reference from
|
|
85
|
+
* the project's `_generated/api` (e.g. `api.messages.list`) and the args +
|
|
86
|
+
* result are inferred from it — the typed counterpart to {@link ContainerBridge.call}
|
|
87
|
+
* for JS/TS containers that can import the generated `api`.
|
|
88
|
+
*/
|
|
74
89
|
run: <Reference extends BridgeFunctionReference>(reference: Reference, args: ArgsOfReference<Reference>, shardKey?: string) => Promise<ResultOfReference<Reference>>;
|
|
75
90
|
}
|
|
76
91
|
/**
|
|
77
|
-
* Build a container→Lunora bridge bound to a Worker URL + token.
|
|
78
|
-
*
|
|
79
|
-
* ```ts
|
|
80
|
-
* const lunora = createContainerBridge({ baseUrl: process.env.LUNORA_URL!, token: process.env.LUNORA_TOKEN });
|
|
81
|
-
* const messages = await lunora.query("messages:list", { limit: 20 });
|
|
82
|
-
* await lunora.mutation("messages:markProcessed", { id });
|
|
83
|
-
* ```
|
|
84
|
-
*
|
|
85
|
-
* `query`/`mutation`/`action` are intent-revealing aliases of one `call` — the
|
|
86
|
-
* wire is identical and the server dispatches by the function's registered
|
|
87
|
-
* kind, so a query path called via `.mutation(...)` still runs as a query.
|
|
88
|
-
|
|
92
|
+
* Build a container→Lunora bridge bound to a Worker URL + token.
|
|
93
|
+
*
|
|
94
|
+
* ```ts
|
|
95
|
+
* const lunora = createContainerBridge({ baseUrl: process.env.LUNORA_URL!, token: process.env.LUNORA_TOKEN });
|
|
96
|
+
* const messages = await lunora.query("messages:list", { limit: 20 });
|
|
97
|
+
* await lunora.mutation("messages:markProcessed", { id });
|
|
98
|
+
* ```
|
|
99
|
+
*
|
|
100
|
+
* `query`/`mutation`/`action` are intent-revealing aliases of one `call` — the
|
|
101
|
+
* wire is identical and the server dispatches by the function's registered
|
|
102
|
+
* kind, so a query path called via `.mutation(...)` still runs as a query.
|
|
103
|
+
* @experimental
|
|
104
|
+
*/
|
|
89
105
|
declare const createContainerBridge: (options: ContainerBridgeOptions) => ContainerBridge;
|
|
90
106
|
export { type BridgeFunctionReference, type ContainerBridge, ContainerBridgeError, type ContainerBridgeOptions, type FetchLike, createContainerBridge };
|
package/dist/bridge.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { LunoraError } from '@lunora/errors';
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* A `fetch` implementation — defaults to the runtime global.
|
|
4
|
+
* @experimental
|
|
5
|
+
*/
|
|
3
6
|
type FetchLike = (input: string, init: {
|
|
4
7
|
body: string;
|
|
5
8
|
headers: Record<string, string>;
|
|
@@ -10,33 +13,41 @@ type FetchLike = (input: string, init: {
|
|
|
10
13
|
status: number;
|
|
11
14
|
statusText?: string;
|
|
12
15
|
}>;
|
|
16
|
+
/**
|
|
17
|
+
* `ContainerBridgeOptions` is part of the experimental `@lunora/container` API and may change without a major version bump.
|
|
18
|
+
* @experimental
|
|
19
|
+
*/
|
|
13
20
|
interface ContainerBridgeOptions {
|
|
14
21
|
/**
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
22
|
+
* Base URL of the deployed Lunora Worker (no trailing `/_lunora/rpc`), e.g.
|
|
23
|
+
* `https://my-app.workers.dev`. In a Lunora container, surface it as an
|
|
24
|
+
* `env` value on the definition.
|
|
25
|
+
*/
|
|
19
26
|
baseUrl: string;
|
|
20
27
|
/** Injectable `fetch` (tests / non-global runtimes). Defaults to `globalThis.fetch`. */
|
|
21
28
|
fetch?: FetchLike;
|
|
22
29
|
/**
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
30
|
+
* Bearer token sent as `Authorization: Bearer <token>`. Your Worker's
|
|
31
|
+
* `resolveIdentity` maps it to the identity the called functions run as.
|
|
32
|
+
* Pass it to the container as a `secret`, never bake it into the image.
|
|
33
|
+
*/
|
|
27
34
|
token?: string;
|
|
28
35
|
}
|
|
29
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* Thrown when a Lunora function returns an error envelope. A `LunoraError` subclass carrying the wire `code`.
|
|
38
|
+
* @experimental
|
|
39
|
+
*/
|
|
30
40
|
declare class ContainerBridgeError extends LunoraError {
|
|
31
41
|
constructor(code: string, message: string);
|
|
32
42
|
}
|
|
33
43
|
/**
|
|
34
|
-
* Structural mirror of `@lunora/client`'s `FunctionReference` — the typed
|
|
35
|
-
* handle the generated `_generated/api` object carries. Declared locally (not
|
|
36
|
-
* imported) so the bridge stays dependency-free and its `.d.ts` is
|
|
37
|
-
* self-contained; the `__lunoraPhantom` shape matches, so a real `api.x.y`
|
|
38
|
-
* reference is assignable and its arg/return types are inferable.
|
|
39
|
-
|
|
44
|
+
* Structural mirror of `@lunora/client`'s `FunctionReference` — the typed
|
|
45
|
+
* handle the generated `_generated/api` object carries. Declared locally (not
|
|
46
|
+
* imported) so the bridge stays dependency-free and its `.d.ts` is
|
|
47
|
+
* self-contained; the `__lunoraPhantom` shape matches, so a real `api.x.y`
|
|
48
|
+
* reference is assignable and its arg/return types are inferable.
|
|
49
|
+
* @experimental
|
|
50
|
+
*/
|
|
40
51
|
interface BridgeFunctionReference<Args = unknown, Result = unknown> {
|
|
41
52
|
readonly __lunoraPhantom?: {
|
|
42
53
|
args: Args;
|
|
@@ -56,6 +67,10 @@ type ResultOfReference<Reference> = Reference extends {
|
|
|
56
67
|
returns: infer Result;
|
|
57
68
|
};
|
|
58
69
|
} ? Result : never;
|
|
70
|
+
/**
|
|
71
|
+
* `ContainerBridge` is part of the experimental `@lunora/container` API and may change without a major version bump.
|
|
72
|
+
* @experimental
|
|
73
|
+
*/
|
|
59
74
|
interface ContainerBridge {
|
|
60
75
|
/** Call an `action` by `namespace:fn` path. Alias of {@link ContainerBridge.call} for intent. */
|
|
61
76
|
action: <Result = unknown>(functionPath: string, args?: Record<string, unknown>, shardKey?: string) => Promise<Result>;
|
|
@@ -66,25 +81,26 @@ interface ContainerBridge {
|
|
|
66
81
|
/** Call a `query` by `namespace:fn` path. Alias of {@link ContainerBridge.call} for intent. */
|
|
67
82
|
query: <Result = unknown>(functionPath: string, args?: Record<string, unknown>, shardKey?: string) => Promise<Result>;
|
|
68
83
|
/**
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
84
|
+
* Fully-typed call via a generated function reference. Pass a reference from
|
|
85
|
+
* the project's `_generated/api` (e.g. `api.messages.list`) and the args +
|
|
86
|
+
* result are inferred from it — the typed counterpart to {@link ContainerBridge.call}
|
|
87
|
+
* for JS/TS containers that can import the generated `api`.
|
|
88
|
+
*/
|
|
74
89
|
run: <Reference extends BridgeFunctionReference>(reference: Reference, args: ArgsOfReference<Reference>, shardKey?: string) => Promise<ResultOfReference<Reference>>;
|
|
75
90
|
}
|
|
76
91
|
/**
|
|
77
|
-
* Build a container→Lunora bridge bound to a Worker URL + token.
|
|
78
|
-
*
|
|
79
|
-
* ```ts
|
|
80
|
-
* const lunora = createContainerBridge({ baseUrl: process.env.LUNORA_URL!, token: process.env.LUNORA_TOKEN });
|
|
81
|
-
* const messages = await lunora.query("messages:list", { limit: 20 });
|
|
82
|
-
* await lunora.mutation("messages:markProcessed", { id });
|
|
83
|
-
* ```
|
|
84
|
-
*
|
|
85
|
-
* `query`/`mutation`/`action` are intent-revealing aliases of one `call` — the
|
|
86
|
-
* wire is identical and the server dispatches by the function's registered
|
|
87
|
-
* kind, so a query path called via `.mutation(...)` still runs as a query.
|
|
88
|
-
|
|
92
|
+
* Build a container→Lunora bridge bound to a Worker URL + token.
|
|
93
|
+
*
|
|
94
|
+
* ```ts
|
|
95
|
+
* const lunora = createContainerBridge({ baseUrl: process.env.LUNORA_URL!, token: process.env.LUNORA_TOKEN });
|
|
96
|
+
* const messages = await lunora.query("messages:list", { limit: 20 });
|
|
97
|
+
* await lunora.mutation("messages:markProcessed", { id });
|
|
98
|
+
* ```
|
|
99
|
+
*
|
|
100
|
+
* `query`/`mutation`/`action` are intent-revealing aliases of one `call` — the
|
|
101
|
+
* wire is identical and the server dispatches by the function's registered
|
|
102
|
+
* kind, so a query path called via `.mutation(...)` still runs as a query.
|
|
103
|
+
* @experimental
|
|
104
|
+
*/
|
|
89
105
|
declare const createContainerBridge: (options: ContainerBridgeOptions) => ContainerBridge;
|
|
90
106
|
export { type BridgeFunctionReference, type ContainerBridge, ContainerBridgeError, type ContainerBridgeOptions, type FetchLike, createContainerBridge };
|
package/dist/do/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DurableObject, WorkerEntrypoint } from 'cloudflare:workers';
|
|
2
|
-
import { a as ContainerDefinition, D as DurableObjectJurisdiction } from "../packem_shared/jurisdiction.d-
|
|
2
|
+
import { a as ContainerDefinition, D as DurableObjectJurisdiction } from "../packem_shared/jurisdiction.d-8oUUvrew.mjs";
|
|
3
3
|
/**
|
|
4
4
|
* ContainerStartOptions as they come from worker types
|
|
5
5
|
*/
|
|
@@ -119,7 +119,7 @@ type OutboundHandler<E = Cloudflare.Env, P = unknown> = {
|
|
|
119
119
|
type OutboundHandlerParams = Record<string, unknown>;
|
|
120
120
|
type OutboundHandlerParamsOf<THandler> = THandler extends ((req: Request, env: unknown, ctx: OutboundHandlerContext<infer Params>) => Promise<Response> | Response) ? Params : never;
|
|
121
121
|
declare function outboundParams<THandler extends OutboundHandler<unknown, unknown>>(_handler: THandler, params: OutboundHandlerParamsOf<THandler>): OutboundHandlerParamsOf<THandler>;
|
|
122
|
-
type OutboundHandlers<ParamsByMethod extends OutboundHandlerParams, E = Cloudflare.Env> = { [Method in keyof ParamsByMethod]?: OutboundHandler<E, ParamsByMethod[Method]
|
|
122
|
+
type OutboundHandlers<ParamsByMethod extends OutboundHandlerParams, E = Cloudflare.Env> = { [Method in keyof ParamsByMethod]?: OutboundHandler<E, ParamsByMethod[Method]>; };
|
|
123
123
|
type OutboundHandlerOverride<Params = unknown> = {
|
|
124
124
|
method: string;
|
|
125
125
|
} & ([Params] extends [undefined] ? {
|
|
@@ -485,28 +485,29 @@ declare class Container<Env = Cloudflare.Env> extends DurableObject<Env> {
|
|
|
485
485
|
}
|
|
486
486
|
type DurableObjectContext = ConstructorParameters<typeof Container>[0];
|
|
487
487
|
/**
|
|
488
|
-
* Base class for the generated Container DO classes. Applies a
|
|
489
|
-
* `defineContainer` definition onto `@cloudflare/containers`' `Container`:
|
|
490
|
-
* port, sleep timeout, internet access, and the container environment (static
|
|
491
|
-
* `env` merged with the declared Worker secrets — a declared-but-unset secret
|
|
492
|
-
* fails fast here rather than starting a container without its credential).
|
|
493
|
-
*
|
|
494
|
-
* Generated subclasses stay one line of behavior:
|
|
495
|
-
*
|
|
496
|
-
* ```ts
|
|
497
|
-
* export class TranscoderContainer extends LunoraContainer {
|
|
498
|
-
* constructor(ctx: DurableObjectState, env: Env) {
|
|
499
|
-
* super(ctx, env, transcoder, "transcoder");
|
|
500
|
-
* }
|
|
501
|
-
* }
|
|
502
|
-
* ```
|
|
503
|
-
|
|
488
|
+
* Base class for the generated Container DO classes. Applies a
|
|
489
|
+
* `defineContainer` definition onto `@cloudflare/containers`' `Container`:
|
|
490
|
+
* port, sleep timeout, internet access, and the container environment (static
|
|
491
|
+
* `env` merged with the declared Worker secrets — a declared-but-unset secret
|
|
492
|
+
* fails fast here rather than starting a container without its credential).
|
|
493
|
+
*
|
|
494
|
+
* Generated subclasses stay one line of behavior:
|
|
495
|
+
*
|
|
496
|
+
* ```ts
|
|
497
|
+
* export class TranscoderContainer extends LunoraContainer {
|
|
498
|
+
* constructor(ctx: DurableObjectState, env: Env) {
|
|
499
|
+
* super(ctx, env, transcoder, "transcoder");
|
|
500
|
+
* }
|
|
501
|
+
* }
|
|
502
|
+
* ```
|
|
503
|
+
* @experimental
|
|
504
|
+
*/
|
|
504
505
|
declare class LunoraContainer<Env = unknown> extends Container<Env> {
|
|
505
506
|
/**
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
507
|
+
* Data-residency jurisdiction the app's DOs are pinned to (codegen passes the
|
|
508
|
+
* schema's `.jurisdiction("…")`). Used to pin the best-effort lifecycle report
|
|
509
|
+
* to the same region as the root shard. `undefined` ⇒ un-pinned.
|
|
510
|
+
*/
|
|
510
511
|
private readonly lunoraJurisdiction?;
|
|
511
512
|
/** The `lunora/containers.ts` export name, for lifecycle log correlation. */
|
|
512
513
|
private readonly lunoraName;
|
|
@@ -522,76 +523,76 @@ declare class LunoraContainer<Env = unknown> extends Container<Env> {
|
|
|
522
523
|
private lunoraSecretsStoreResolved?;
|
|
523
524
|
constructor(context: DurableObjectContext, env: Env, definition: ContainerDefinition, exportName?: string, jurisdiction?: DurableObjectJurisdiction);
|
|
524
525
|
/**
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
526
|
+
* Proxy entry for every `ctx.containers.<name>` fetch. Resolves the
|
|
527
|
+
* `secretsStore` bindings into `envVars` before delegating, so the values
|
|
528
|
+
* are present when the base implicitly starts the container for this
|
|
529
|
+
* request — a no-op when `secretsStore` is unset.
|
|
530
|
+
*/
|
|
530
531
|
override containerFetch(...args: Parameters<Container<Env>["containerFetch"]>): Promise<Response>;
|
|
531
532
|
/**
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
533
|
+
* Explicit start (`ctx.containers.<name>.get(id).start()`). Resolves the
|
|
534
|
+
* `secretsStore` bindings into `envVars` first, mirroring
|
|
535
|
+
* {@link containerFetch}. A per-instance `start({ envVars })` replaces the
|
|
536
|
+
* env set wholesale (base behavior), so the injected values only apply to a
|
|
537
|
+
* bare `start()` — same as the static `env`/`secrets`. When the caller
|
|
538
|
+
* supplies its own `envVars` we skip resolution entirely: those values would
|
|
539
|
+
* be discarded anyway, so a missing/unreadable binding shouldn't fail a start
|
|
540
|
+
* that never uses them.
|
|
541
|
+
*/
|
|
541
542
|
override start(...args: Parameters<Container<Env>["start"]>): Promise<void>;
|
|
542
543
|
override onActivityExpired(): Promise<void>;
|
|
543
544
|
override onError(error: unknown): unknown;
|
|
544
545
|
override onStart(): Promise<void>;
|
|
545
546
|
/**
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
547
|
+
* Hook run when the container's `hardTimeout` elapses (dispatched by the base
|
|
548
|
+
* scheduler via the run-generation-stamped schedule armed in
|
|
549
|
+
* {@link onStart}). Default: stop the instance. Override to drain/checkpoint
|
|
550
|
+
* first. A stale schedule from a previous run, or an already-stopped
|
|
551
|
+
* instance, is ignored (upstream cloudflare/containers#85).
|
|
552
|
+
*/
|
|
552
553
|
onHardTimeoutExpired(payload?: {
|
|
553
554
|
generation?: number;
|
|
554
555
|
}): Promise<void>;
|
|
555
556
|
override onStop(parameters: StopParams): Promise<void>;
|
|
556
557
|
/**
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
558
|
+
* Arm the hard-timeout kill via the base scheduler (so it integrates with
|
|
559
|
+
* the container's own alarm machinery instead of fighting it). Bumps the run
|
|
560
|
+
* generation and stamps the schedule with it, so {@link onHardTimeoutExpired}
|
|
561
|
+
* can tell a fresh schedule from a stale one. No-op without a `hardTimeout`.
|
|
562
|
+
*/
|
|
562
563
|
private armHardTimeout;
|
|
563
564
|
/**
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
565
|
+
* Resolve the `secretsStore` bindings (async `.get()`) once and merge the
|
|
566
|
+
* values into `envVars`, so they're present when the base starts the
|
|
567
|
+
* container. Memoised on the first call — every later start reuses the
|
|
568
|
+
* resolved promise. A missing binding or a non-string value fails fast (the
|
|
569
|
+
* start surfaces the error), the same fail-closed stance the static
|
|
570
|
+
* `secrets` resolution takes for a missing Worker secret. No-op without
|
|
571
|
+
* `secretsStore`.
|
|
572
|
+
*/
|
|
572
573
|
private resolveSecretsStoreEnv;
|
|
573
574
|
/**
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
575
|
+
* Block until every `readyOn` probe responds with its expected status, or
|
|
576
|
+
* throw once the readiness budget is spent. Probes run in parallel and hit
|
|
577
|
+
* the container's TCP port directly (NOT `containerFetch`, which would
|
|
578
|
+
* recurse back into the start path). No-op without `readyOn`.
|
|
579
|
+
*/
|
|
579
580
|
private awaitContainerReadiness;
|
|
580
581
|
/** Poll one readiness probe until it returns its expected status or the shared deadline passes. */
|
|
581
582
|
private awaitReadinessCheck;
|
|
582
583
|
/**
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
584
|
+
* Best-effort push of `envelope` into the root ShardDO's log buffer so it
|
|
585
|
+
* also appears in the Studio Logs panel (the terminal already has it via
|
|
586
|
+
* `emitContainerLifecycle`). Fire-and-forget and fully swallowed: a missing
|
|
587
|
+
* `SHARD` binding, a missing admin token, or a fetch failure NEVER throws
|
|
588
|
+
* out of a lifecycle hook — the `console` path stays the source of truth.
|
|
589
|
+
*/
|
|
589
590
|
private surfaceInStudioLogs;
|
|
590
591
|
/**
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
592
|
+
* Per-instance correlation id: the Durable Object id, which Cloudflare also
|
|
593
|
+
* injects into the container as `CLOUDFLARE_DURABLE_OBJECT_ID`. Read
|
|
594
|
+
* defensively — the id shape varies and isn't worth crashing a hook over.
|
|
595
|
+
*/
|
|
595
596
|
private instanceId;
|
|
596
597
|
}
|
|
597
598
|
export { ContainerProxy, LunoraContainer, type OutboundHandler, type OutboundHandlerContext, type OutboundHandlerParams, type OutboundHandlerParamsOf, type OutboundHandlers, outboundParams };
|
package/dist/do/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DurableObject, WorkerEntrypoint } from 'cloudflare:workers';
|
|
2
|
-
import { a as ContainerDefinition, D as DurableObjectJurisdiction } from "../packem_shared/jurisdiction.d-
|
|
2
|
+
import { a as ContainerDefinition, D as DurableObjectJurisdiction } from "../packem_shared/jurisdiction.d-8oUUvrew.js";
|
|
3
3
|
/**
|
|
4
4
|
* ContainerStartOptions as they come from worker types
|
|
5
5
|
*/
|
|
@@ -119,7 +119,7 @@ type OutboundHandler<E = Cloudflare.Env, P = unknown> = {
|
|
|
119
119
|
type OutboundHandlerParams = Record<string, unknown>;
|
|
120
120
|
type OutboundHandlerParamsOf<THandler> = THandler extends ((req: Request, env: unknown, ctx: OutboundHandlerContext<infer Params>) => Promise<Response> | Response) ? Params : never;
|
|
121
121
|
declare function outboundParams<THandler extends OutboundHandler<unknown, unknown>>(_handler: THandler, params: OutboundHandlerParamsOf<THandler>): OutboundHandlerParamsOf<THandler>;
|
|
122
|
-
type OutboundHandlers<ParamsByMethod extends OutboundHandlerParams, E = Cloudflare.Env> = { [Method in keyof ParamsByMethod]?: OutboundHandler<E, ParamsByMethod[Method]
|
|
122
|
+
type OutboundHandlers<ParamsByMethod extends OutboundHandlerParams, E = Cloudflare.Env> = { [Method in keyof ParamsByMethod]?: OutboundHandler<E, ParamsByMethod[Method]>; };
|
|
123
123
|
type OutboundHandlerOverride<Params = unknown> = {
|
|
124
124
|
method: string;
|
|
125
125
|
} & ([Params] extends [undefined] ? {
|
|
@@ -485,28 +485,29 @@ declare class Container<Env = Cloudflare.Env> extends DurableObject<Env> {
|
|
|
485
485
|
}
|
|
486
486
|
type DurableObjectContext = ConstructorParameters<typeof Container>[0];
|
|
487
487
|
/**
|
|
488
|
-
* Base class for the generated Container DO classes. Applies a
|
|
489
|
-
* `defineContainer` definition onto `@cloudflare/containers`' `Container`:
|
|
490
|
-
* port, sleep timeout, internet access, and the container environment (static
|
|
491
|
-
* `env` merged with the declared Worker secrets — a declared-but-unset secret
|
|
492
|
-
* fails fast here rather than starting a container without its credential).
|
|
493
|
-
*
|
|
494
|
-
* Generated subclasses stay one line of behavior:
|
|
495
|
-
*
|
|
496
|
-
* ```ts
|
|
497
|
-
* export class TranscoderContainer extends LunoraContainer {
|
|
498
|
-
* constructor(ctx: DurableObjectState, env: Env) {
|
|
499
|
-
* super(ctx, env, transcoder, "transcoder");
|
|
500
|
-
* }
|
|
501
|
-
* }
|
|
502
|
-
* ```
|
|
503
|
-
|
|
488
|
+
* Base class for the generated Container DO classes. Applies a
|
|
489
|
+
* `defineContainer` definition onto `@cloudflare/containers`' `Container`:
|
|
490
|
+
* port, sleep timeout, internet access, and the container environment (static
|
|
491
|
+
* `env` merged with the declared Worker secrets — a declared-but-unset secret
|
|
492
|
+
* fails fast here rather than starting a container without its credential).
|
|
493
|
+
*
|
|
494
|
+
* Generated subclasses stay one line of behavior:
|
|
495
|
+
*
|
|
496
|
+
* ```ts
|
|
497
|
+
* export class TranscoderContainer extends LunoraContainer {
|
|
498
|
+
* constructor(ctx: DurableObjectState, env: Env) {
|
|
499
|
+
* super(ctx, env, transcoder, "transcoder");
|
|
500
|
+
* }
|
|
501
|
+
* }
|
|
502
|
+
* ```
|
|
503
|
+
* @experimental
|
|
504
|
+
*/
|
|
504
505
|
declare class LunoraContainer<Env = unknown> extends Container<Env> {
|
|
505
506
|
/**
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
507
|
+
* Data-residency jurisdiction the app's DOs are pinned to (codegen passes the
|
|
508
|
+
* schema's `.jurisdiction("…")`). Used to pin the best-effort lifecycle report
|
|
509
|
+
* to the same region as the root shard. `undefined` ⇒ un-pinned.
|
|
510
|
+
*/
|
|
510
511
|
private readonly lunoraJurisdiction?;
|
|
511
512
|
/** The `lunora/containers.ts` export name, for lifecycle log correlation. */
|
|
512
513
|
private readonly lunoraName;
|
|
@@ -522,76 +523,76 @@ declare class LunoraContainer<Env = unknown> extends Container<Env> {
|
|
|
522
523
|
private lunoraSecretsStoreResolved?;
|
|
523
524
|
constructor(context: DurableObjectContext, env: Env, definition: ContainerDefinition, exportName?: string, jurisdiction?: DurableObjectJurisdiction);
|
|
524
525
|
/**
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
526
|
+
* Proxy entry for every `ctx.containers.<name>` fetch. Resolves the
|
|
527
|
+
* `secretsStore` bindings into `envVars` before delegating, so the values
|
|
528
|
+
* are present when the base implicitly starts the container for this
|
|
529
|
+
* request — a no-op when `secretsStore` is unset.
|
|
530
|
+
*/
|
|
530
531
|
override containerFetch(...args: Parameters<Container<Env>["containerFetch"]>): Promise<Response>;
|
|
531
532
|
/**
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
533
|
+
* Explicit start (`ctx.containers.<name>.get(id).start()`). Resolves the
|
|
534
|
+
* `secretsStore` bindings into `envVars` first, mirroring
|
|
535
|
+
* {@link containerFetch}. A per-instance `start({ envVars })` replaces the
|
|
536
|
+
* env set wholesale (base behavior), so the injected values only apply to a
|
|
537
|
+
* bare `start()` — same as the static `env`/`secrets`. When the caller
|
|
538
|
+
* supplies its own `envVars` we skip resolution entirely: those values would
|
|
539
|
+
* be discarded anyway, so a missing/unreadable binding shouldn't fail a start
|
|
540
|
+
* that never uses them.
|
|
541
|
+
*/
|
|
541
542
|
override start(...args: Parameters<Container<Env>["start"]>): Promise<void>;
|
|
542
543
|
override onActivityExpired(): Promise<void>;
|
|
543
544
|
override onError(error: unknown): unknown;
|
|
544
545
|
override onStart(): Promise<void>;
|
|
545
546
|
/**
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
547
|
+
* Hook run when the container's `hardTimeout` elapses (dispatched by the base
|
|
548
|
+
* scheduler via the run-generation-stamped schedule armed in
|
|
549
|
+
* {@link onStart}). Default: stop the instance. Override to drain/checkpoint
|
|
550
|
+
* first. A stale schedule from a previous run, or an already-stopped
|
|
551
|
+
* instance, is ignored (upstream cloudflare/containers#85).
|
|
552
|
+
*/
|
|
552
553
|
onHardTimeoutExpired(payload?: {
|
|
553
554
|
generation?: number;
|
|
554
555
|
}): Promise<void>;
|
|
555
556
|
override onStop(parameters: StopParams): Promise<void>;
|
|
556
557
|
/**
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
558
|
+
* Arm the hard-timeout kill via the base scheduler (so it integrates with
|
|
559
|
+
* the container's own alarm machinery instead of fighting it). Bumps the run
|
|
560
|
+
* generation and stamps the schedule with it, so {@link onHardTimeoutExpired}
|
|
561
|
+
* can tell a fresh schedule from a stale one. No-op without a `hardTimeout`.
|
|
562
|
+
*/
|
|
562
563
|
private armHardTimeout;
|
|
563
564
|
/**
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
565
|
+
* Resolve the `secretsStore` bindings (async `.get()`) once and merge the
|
|
566
|
+
* values into `envVars`, so they're present when the base starts the
|
|
567
|
+
* container. Memoised on the first call — every later start reuses the
|
|
568
|
+
* resolved promise. A missing binding or a non-string value fails fast (the
|
|
569
|
+
* start surfaces the error), the same fail-closed stance the static
|
|
570
|
+
* `secrets` resolution takes for a missing Worker secret. No-op without
|
|
571
|
+
* `secretsStore`.
|
|
572
|
+
*/
|
|
572
573
|
private resolveSecretsStoreEnv;
|
|
573
574
|
/**
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
575
|
+
* Block until every `readyOn` probe responds with its expected status, or
|
|
576
|
+
* throw once the readiness budget is spent. Probes run in parallel and hit
|
|
577
|
+
* the container's TCP port directly (NOT `containerFetch`, which would
|
|
578
|
+
* recurse back into the start path). No-op without `readyOn`.
|
|
579
|
+
*/
|
|
579
580
|
private awaitContainerReadiness;
|
|
580
581
|
/** Poll one readiness probe until it returns its expected status or the shared deadline passes. */
|
|
581
582
|
private awaitReadinessCheck;
|
|
582
583
|
/**
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
584
|
+
* Best-effort push of `envelope` into the root ShardDO's log buffer so it
|
|
585
|
+
* also appears in the Studio Logs panel (the terminal already has it via
|
|
586
|
+
* `emitContainerLifecycle`). Fire-and-forget and fully swallowed: a missing
|
|
587
|
+
* `SHARD` binding, a missing admin token, or a fetch failure NEVER throws
|
|
588
|
+
* out of a lifecycle hook — the `console` path stays the source of truth.
|
|
589
|
+
*/
|
|
589
590
|
private surfaceInStudioLogs;
|
|
590
591
|
/**
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
592
|
+
* Per-instance correlation id: the Durable Object id, which Cloudflare also
|
|
593
|
+
* injects into the container as `CLOUDFLARE_DURABLE_OBJECT_ID`. Read
|
|
594
|
+
* defensively — the id shape varies and isn't worth crashing a hook over.
|
|
595
|
+
*/
|
|
595
596
|
private instanceId;
|
|
596
597
|
}
|
|
597
598
|
export { ContainerProxy, LunoraContainer, type OutboundHandler, type OutboundHandlerContext, type OutboundHandlerParams, type OutboundHandlerParamsOf, type OutboundHandlers, outboundParams };
|