@lunora/container 1.0.0-alpha.8 → 1.0.0-alpha.9
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/do/index.d.mts +1 -15
- package/dist/do/index.d.ts +1 -15
- package/dist/do/index.mjs +6 -13
- package/dist/index.d.mts +2 -8
- package/dist/index.d.ts +2 -8
- package/dist/index.mjs +2 -2
- package/dist/packem_shared/{containerBindingName-D5KTrblH.mjs → containerBindingName-BiTrAF1J.mjs} +8 -2
- package/dist/packem_shared/{createContainerContext-Cibbh7AE.mjs → createContainerContext-CIVzsY5m.mjs} +7 -15
- package/dist/packem_shared/jurisdiction-CuPNcLDt.mjs +13 -0
- package/dist/packem_shared/{types.d-BlNwNY44.d.mts → jurisdiction.d-TwTGkgTg.d.mts} +17 -1
- package/dist/packem_shared/{types.d-BlNwNY44.d.ts → jurisdiction.d-TwTGkgTg.d.ts} +17 -1
- package/package.json +2 -2
package/dist/do/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DurableObject, WorkerEntrypoint } from 'cloudflare:workers';
|
|
2
|
-
import { a as ContainerDefinition } from "../packem_shared/
|
|
2
|
+
import { a as ContainerDefinition, D as DurableObjectJurisdiction } from "../packem_shared/jurisdiction.d-TwTGkgTg.mjs";
|
|
3
3
|
/**
|
|
4
4
|
* ContainerStartOptions as they come from worker types
|
|
5
5
|
*/
|
|
@@ -483,20 +483,6 @@ declare class Container<Env = Cloudflare.Env> extends DurableObject<Env> {
|
|
|
483
483
|
getSchedule<T = string>(id: string): Promise<Schedule<T> | undefined>;
|
|
484
484
|
private isActivityExpired;
|
|
485
485
|
}
|
|
486
|
-
/**
|
|
487
|
-
* Cloudflare Durable Object data-residency jurisdiction. Widening union —
|
|
488
|
-
* Cloudflare adds values over time.
|
|
489
|
-
* @see https://developers.cloudflare.com/durable-objects/reference/data-location/
|
|
490
|
-
*/
|
|
491
|
-
type DurableObjectJurisdiction = "eu" | "fedramp" | "us";
|
|
492
|
-
/**
|
|
493
|
-
* Forward one lifecycle envelope to the root ShardDO's log buffer, best-effort.
|
|
494
|
-
*
|
|
495
|
-
* `env` is the Container DO's worker `env`: we read the `SHARD` namespace and
|
|
496
|
-
* the `LUNORA_ADMIN_TOKEN` from it. Returns a promise that NEVER rejects — every
|
|
497
|
-
* failure path (missing binding, missing token, fetch error) resolves to
|
|
498
|
-
* `undefined` — so the caller can `void` it from a lifecycle hook safely.
|
|
499
|
-
*/
|
|
500
486
|
type DurableObjectContext = ConstructorParameters<typeof Container>[0];
|
|
501
487
|
/**
|
|
502
488
|
* Base class for the generated Container DO classes. Applies a
|
package/dist/do/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DurableObject, WorkerEntrypoint } from 'cloudflare:workers';
|
|
2
|
-
import { a as ContainerDefinition } from "../packem_shared/
|
|
2
|
+
import { a as ContainerDefinition, D as DurableObjectJurisdiction } from "../packem_shared/jurisdiction.d-TwTGkgTg.js";
|
|
3
3
|
/**
|
|
4
4
|
* ContainerStartOptions as they come from worker types
|
|
5
5
|
*/
|
|
@@ -483,20 +483,6 @@ declare class Container<Env = Cloudflare.Env> extends DurableObject<Env> {
|
|
|
483
483
|
getSchedule<T = string>(id: string): Promise<Schedule<T> | undefined>;
|
|
484
484
|
private isActivityExpired;
|
|
485
485
|
}
|
|
486
|
-
/**
|
|
487
|
-
* Cloudflare Durable Object data-residency jurisdiction. Widening union —
|
|
488
|
-
* Cloudflare adds values over time.
|
|
489
|
-
* @see https://developers.cloudflare.com/durable-objects/reference/data-location/
|
|
490
|
-
*/
|
|
491
|
-
type DurableObjectJurisdiction = "eu" | "fedramp" | "us";
|
|
492
|
-
/**
|
|
493
|
-
* Forward one lifecycle envelope to the root ShardDO's log buffer, best-effort.
|
|
494
|
-
*
|
|
495
|
-
* `env` is the Container DO's worker `env`: we read the `SHARD` namespace and
|
|
496
|
-
* the `LUNORA_ADMIN_TOKEN` from it. Returns a promise that NEVER rejects — every
|
|
497
|
-
* failure path (missing binding, missing token, fetch error) resolves to
|
|
498
|
-
* `undefined` — so the caller can `void` it from a lifecycle hook safely.
|
|
499
|
-
*/
|
|
500
486
|
type DurableObjectContext = ConstructorParameters<typeof Container>[0];
|
|
501
487
|
/**
|
|
502
488
|
* Base class for the generated Container DO classes. Applies a
|
package/dist/do/index.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Container } from '../packem_shared/ContainerProxy-DWqUX_re.mjs';
|
|
2
2
|
export { ContainerProxy, outboundParams } from '../packem_shared/ContainerProxy-DWqUX_re.mjs';
|
|
3
3
|
import { LunoraError } from '@lunora/errors';
|
|
4
|
-
import { resolveContainerEnvVars as resolveContainerEnvVariables, parseDurationSeconds } from '../packem_shared/containerBindingName-
|
|
4
|
+
import { resolveContainerEnvVars as resolveContainerEnvVariables, parseDurationSeconds } from '../packem_shared/containerBindingName-BiTrAF1J.mjs';
|
|
5
|
+
import { a as applyJurisdiction } from '../packem_shared/jurisdiction-CuPNcLDt.mjs';
|
|
5
6
|
|
|
6
7
|
const LUNORA_EVENT_SOURCE = "lunora";
|
|
7
8
|
const buildContainerLifecycleEvent = (container, instance, event, message) => {
|
|
@@ -29,17 +30,6 @@ const emitContainerLifecycle = (container, instance, event, message) => {
|
|
|
29
30
|
|
|
30
31
|
const RECORD_CONTAINER_EVENT_OP = "__lunora_admin__:recordContainerEvent";
|
|
31
32
|
const ROOT_SHARD_NAME = "__root__";
|
|
32
|
-
const applyJurisdiction = (namespace, jurisdiction) => {
|
|
33
|
-
if (jurisdiction === void 0) {
|
|
34
|
-
return namespace;
|
|
35
|
-
}
|
|
36
|
-
if (typeof namespace.jurisdiction !== "function") {
|
|
37
|
-
throw new TypeError(
|
|
38
|
-
`@lunora/container: Durable Object namespace does not support jurisdiction("${jurisdiction}") — update @cloudflare/workers-types or remove the jurisdiction option`
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
return namespace.jurisdiction(jurisdiction);
|
|
42
|
-
};
|
|
43
33
|
const isShardNamespace = (value) => {
|
|
44
34
|
if (value === null || typeof value !== "object") {
|
|
45
35
|
return false;
|
|
@@ -248,7 +238,10 @@ class LunoraContainer extends Container {
|
|
|
248
238
|
resolved[envName] = value;
|
|
249
239
|
}
|
|
250
240
|
this.envVars = { ...this.envVars, ...resolved };
|
|
251
|
-
})()
|
|
241
|
+
})().catch((error) => {
|
|
242
|
+
this.lunoraSecretsStoreResolved = void 0;
|
|
243
|
+
throw error;
|
|
244
|
+
});
|
|
252
245
|
await this.lunoraSecretsStoreResolved;
|
|
253
246
|
}
|
|
254
247
|
/**
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as ContainerConfig, a as ContainerDefinition, b as ContainerImageSource, N as NormalizedContainerImage } from "./packem_shared/
|
|
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/
|
|
1
|
+
import { D as DurableObjectJurisdiction, C as ContainerConfig, a as ContainerDefinition, b as ContainerImageSource, N as NormalizedContainerImage } from "./packem_shared/jurisdiction.d-TwTGkgTg.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-TwTGkgTg.mjs";
|
|
3
3
|
/** Options for explicitly starting an instance (mirrors `@cloudflare/containers`). */
|
|
4
4
|
interface ContainerStartOptions {
|
|
5
5
|
/** Override outbound internet access for this start. */
|
|
@@ -36,12 +36,6 @@ interface ContainerStubLike {
|
|
|
36
36
|
start?: (options?: ContainerStartOptions) => Promise<void>;
|
|
37
37
|
stop?: (signal?: number | string) => Promise<void>;
|
|
38
38
|
}
|
|
39
|
-
/**
|
|
40
|
-
* Cloudflare Durable Object data-residency jurisdiction. Widening union —
|
|
41
|
-
* Cloudflare adds values over time.
|
|
42
|
-
* @see https://developers.cloudflare.com/durable-objects/reference/data-location/
|
|
43
|
-
*/
|
|
44
|
-
type DurableObjectJurisdiction = "eu" | "fedramp" | "us";
|
|
45
39
|
/** What the client needs from a Durable Object namespace binding. */
|
|
46
40
|
interface ContainerNamespaceLike {
|
|
47
41
|
get: (id: unknown) => ContainerStubLike;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as ContainerConfig, a as ContainerDefinition, b as ContainerImageSource, N as NormalizedContainerImage } from "./packem_shared/
|
|
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/
|
|
1
|
+
import { D as DurableObjectJurisdiction, C as ContainerConfig, a as ContainerDefinition, b as ContainerImageSource, N as NormalizedContainerImage } from "./packem_shared/jurisdiction.d-TwTGkgTg.js";
|
|
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-TwTGkgTg.js";
|
|
3
3
|
/** Options for explicitly starting an instance (mirrors `@cloudflare/containers`). */
|
|
4
4
|
interface ContainerStartOptions {
|
|
5
5
|
/** Override outbound internet access for this start. */
|
|
@@ -36,12 +36,6 @@ interface ContainerStubLike {
|
|
|
36
36
|
start?: (options?: ContainerStartOptions) => Promise<void>;
|
|
37
37
|
stop?: (signal?: number | string) => Promise<void>;
|
|
38
38
|
}
|
|
39
|
-
/**
|
|
40
|
-
* Cloudflare Durable Object data-residency jurisdiction. Widening union —
|
|
41
|
-
* Cloudflare adds values over time.
|
|
42
|
-
* @see https://developers.cloudflare.com/durable-objects/reference/data-location/
|
|
43
|
-
*/
|
|
44
|
-
type DurableObjectJurisdiction = "eu" | "fedramp" | "us";
|
|
45
39
|
/** What the client needs from a Durable Object namespace binding. */
|
|
46
40
|
interface ContainerNamespaceLike {
|
|
47
41
|
get: (id: unknown) => ContainerStubLike;
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { createContainerContext, createContainerTestContext } from './packem_shared/createContainerContext-
|
|
2
|
-
export { containerBindingName, containerBuildTag, containerClassName, defineContainer, isContainerDefinition, normalizeContainerImage, resolveContainerEnvVars } from './packem_shared/containerBindingName-
|
|
1
|
+
export { createContainerContext, createContainerTestContext } from './packem_shared/createContainerContext-CIVzsY5m.mjs';
|
|
2
|
+
export { containerBindingName, containerBuildTag, containerClassName, defineContainer, isContainerDefinition, normalizeContainerImage, resolveContainerEnvVars } from './packem_shared/containerBindingName-BiTrAF1J.mjs';
|
package/dist/packem_shared/{containerBindingName-D5KTrblH.mjs → containerBindingName-BiTrAF1J.mjs}
RENAMED
|
@@ -188,9 +188,15 @@ const defineContainer = (config) => {
|
|
|
188
188
|
`defineContainer: unknown \`instanceType\` "${config.instanceType}" — use one of ${[...NAMED_INSTANCE_TYPES].join(", ")}, or a custom { vcpu, memoryMib, diskMb } object`
|
|
189
189
|
);
|
|
190
190
|
}
|
|
191
|
-
if (typeof config.sleepAfter === "string"
|
|
191
|
+
if (typeof config.sleepAfter === "string") {
|
|
192
|
+
if (!SLEEP_AFTER_PATTERN.test(config.sleepAfter)) {
|
|
193
|
+
throw new TypeError(
|
|
194
|
+
`defineContainer: \`sleepAfter\` string "${config.sleepAfter}" must be a number of seconds followed by a unit, e.g. "30s", "5m", or "1h"`
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
} else if (config.sleepAfter !== void 0 && (!Number.isInteger(config.sleepAfter) || config.sleepAfter < 1)) {
|
|
192
198
|
throw new TypeError(
|
|
193
|
-
`defineContainer: \`sleepAfter\`
|
|
199
|
+
`defineContainer: \`sleepAfter\` must be a positive integer number of seconds or a duration string like "5m" (got ${String(config.sleepAfter)})`
|
|
194
200
|
);
|
|
195
201
|
}
|
|
196
202
|
assertValidHardTimeout(config.hardTimeout);
|
|
@@ -1,16 +1,7 @@
|
|
|
1
1
|
import { LunoraError } from '@lunora/errors';
|
|
2
|
+
import { containerBindingName } from './containerBindingName-BiTrAF1J.mjs';
|
|
3
|
+
import { a as applyJurisdiction } from './jurisdiction-CuPNcLDt.mjs';
|
|
2
4
|
|
|
3
|
-
const applyJurisdiction = (namespace, jurisdiction) => {
|
|
4
|
-
if (jurisdiction === void 0) {
|
|
5
|
-
return namespace;
|
|
6
|
-
}
|
|
7
|
-
if (typeof namespace.jurisdiction !== "function") {
|
|
8
|
-
throw new TypeError(
|
|
9
|
-
`@lunora/container: Durable Object namespace does not support jurisdiction("${jurisdiction}") — update @cloudflare/workers-types or remove the jurisdiction option`
|
|
10
|
-
);
|
|
11
|
-
}
|
|
12
|
-
return namespace.jurisdiction(jurisdiction);
|
|
13
|
-
};
|
|
14
5
|
const DEFAULT_POOL_SIZE = 3;
|
|
15
6
|
const DEFAULT_MAX_BACKOFF_MS = 3e4;
|
|
16
7
|
const DEFAULT_COLD_START_ATTEMPTS = 3;
|
|
@@ -144,22 +135,23 @@ const poolHandleFor = (namespace, spec, options = {}, port) => {
|
|
|
144
135
|
const shouldRetry = options.retryOn ?? retryOnServerError;
|
|
145
136
|
return {
|
|
146
137
|
fetch: async (input, init) => {
|
|
138
|
+
const totalAttempts = typeof input === "string" ? attempts : 1;
|
|
147
139
|
let lastError;
|
|
148
|
-
for (let attempt = 0; attempt <
|
|
140
|
+
for (let attempt = 0; attempt < totalAttempts; attempt += 1) {
|
|
149
141
|
if (attempt > 0) {
|
|
150
142
|
await sleep(Math.min(baseBackoff * 2 ** (attempt - 1), maxBackoff));
|
|
151
143
|
}
|
|
152
144
|
const request = toRequest(input, init, port);
|
|
153
145
|
try {
|
|
154
146
|
const response = await namespace.get(namespace.idFromName(randomPoolName(size))).fetch(request);
|
|
155
|
-
if (attempt ===
|
|
147
|
+
if (attempt === totalAttempts - 1 || !shouldRetry(response)) {
|
|
156
148
|
return response;
|
|
157
149
|
}
|
|
158
150
|
} catch (error) {
|
|
159
151
|
lastError = error;
|
|
160
152
|
}
|
|
161
153
|
}
|
|
162
|
-
throw lastError instanceof Error ? lastError : new Error(`ctx.containers.${spec.exportName}.pool(): all ${String(
|
|
154
|
+
throw lastError instanceof Error ? lastError : new Error(`ctx.containers.${spec.exportName}.pool(): all ${String(totalAttempts)} attempts failed`);
|
|
163
155
|
},
|
|
164
156
|
port: (targetPort) => poolHandleFor(namespace, spec, options, targetPort)
|
|
165
157
|
};
|
|
@@ -211,7 +203,7 @@ const createContainerTestContext = (handlers) => {
|
|
|
211
203
|
const containers = {};
|
|
212
204
|
for (const [exportName, handler] of Object.entries(handlers)) {
|
|
213
205
|
const namespace = testNamespaceFor(handler);
|
|
214
|
-
const spec = { binding:
|
|
206
|
+
const spec = { binding: containerBindingName(exportName)};
|
|
215
207
|
containers[exportName] = {
|
|
216
208
|
// `.any()`/`.pool()` route to a fixed `pool-0` so the handler's
|
|
217
209
|
// `instance.name` is deterministic under test; the double doesn't
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const applyJurisdiction = (namespace, jurisdiction) => {
|
|
2
|
+
if (jurisdiction === void 0) {
|
|
3
|
+
return namespace;
|
|
4
|
+
}
|
|
5
|
+
if (typeof namespace.jurisdiction !== "function") {
|
|
6
|
+
throw new TypeError(
|
|
7
|
+
`@lunora/container: Durable Object namespace does not support jurisdiction("${jurisdiction}") — update @cloudflare/workers-types or remove the jurisdiction option`
|
|
8
|
+
);
|
|
9
|
+
}
|
|
10
|
+
return namespace.jurisdiction(jurisdiction);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { applyJurisdiction as a };
|
|
@@ -247,4 +247,20 @@ type NormalizedContainerImage = {
|
|
|
247
247
|
kind: "registry"; /** Fully-qualified image reference (wrangler `image`). */
|
|
248
248
|
reference: string;
|
|
249
249
|
};
|
|
250
|
-
|
|
250
|
+
/**
|
|
251
|
+
* Cloudflare Durable Object data-residency jurisdiction. Widening union —
|
|
252
|
+
* Cloudflare adds values over time.
|
|
253
|
+
* @see https://developers.cloudflare.com/durable-objects/reference/data-location/
|
|
254
|
+
*/
|
|
255
|
+
type DurableObjectJurisdiction = "eu" | "fedramp" | "us";
|
|
256
|
+
/**
|
|
257
|
+
* Return a jurisdiction-restricted view of `namespace`, or `namespace`
|
|
258
|
+
* unchanged when no jurisdiction is configured. Fail-closed when the binding
|
|
259
|
+
* lacks `.jurisdiction()` so a residency constraint is never silently dropped.
|
|
260
|
+
*
|
|
261
|
+
* Generic over the namespace shape so both the `ctx.containers` client
|
|
262
|
+
* (`ContainerNamespaceLike`) and the lifecycle reporter (`ShardNamespaceLike`)
|
|
263
|
+
* share one implementation — the only requirement is an optional
|
|
264
|
+
* `.jurisdiction()` that returns the same namespace type.
|
|
265
|
+
*/
|
|
266
|
+
export { BuildImageSource as B, ContainerConfig as C, DurableObjectJurisdiction as D, NormalizedContainerImage as N, RegistryImageSource as R, ContainerDefinition as a, ContainerImageSource as b, ContainerInstanceType as c, ContainerReadinessCheck as d, ContainerRollout as e, CustomContainerInstanceType as f, NamedContainerInstanceType as g };
|
|
@@ -247,4 +247,20 @@ type NormalizedContainerImage = {
|
|
|
247
247
|
kind: "registry"; /** Fully-qualified image reference (wrangler `image`). */
|
|
248
248
|
reference: string;
|
|
249
249
|
};
|
|
250
|
-
|
|
250
|
+
/**
|
|
251
|
+
* Cloudflare Durable Object data-residency jurisdiction. Widening union —
|
|
252
|
+
* Cloudflare adds values over time.
|
|
253
|
+
* @see https://developers.cloudflare.com/durable-objects/reference/data-location/
|
|
254
|
+
*/
|
|
255
|
+
type DurableObjectJurisdiction = "eu" | "fedramp" | "us";
|
|
256
|
+
/**
|
|
257
|
+
* Return a jurisdiction-restricted view of `namespace`, or `namespace`
|
|
258
|
+
* unchanged when no jurisdiction is configured. Fail-closed when the binding
|
|
259
|
+
* lacks `.jurisdiction()` so a residency constraint is never silently dropped.
|
|
260
|
+
*
|
|
261
|
+
* Generic over the namespace shape so both the `ctx.containers` client
|
|
262
|
+
* (`ContainerNamespaceLike`) and the lifecycle reporter (`ShardNamespaceLike`)
|
|
263
|
+
* share one implementation — the only requirement is an optional
|
|
264
|
+
* `.jurisdiction()` that returns the same namespace type.
|
|
265
|
+
*/
|
|
266
|
+
export { BuildImageSource as B, ContainerConfig as C, DurableObjectJurisdiction as D, NormalizedContainerImage as N, RegistryImageSource as R, ContainerDefinition as a, ContainerImageSource as b, ContainerInstanceType as c, ContainerReadinessCheck as d, ContainerRollout as e, CustomContainerInstanceType as f, NamedContainerInstanceType as g };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/container",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.9",
|
|
4
4
|
"description": "Cloudflare Containers for Lunora: defineContainer, generated Container DO classes, and the ctx.containers action surface",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"access": "public"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@lunora/errors": "1.0.0-alpha.
|
|
55
|
+
"@lunora/errors": "1.0.0-alpha.4"
|
|
56
56
|
},
|
|
57
57
|
"engines": {
|
|
58
58
|
"node": "^22.15.0 || >=24.11.0"
|