@lunora/container 1.0.0-alpha.5 → 1.0.0-alpha.6
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/bridge.d.mts +3 -3
- package/dist/bridge.d.ts +3 -3
- package/dist/bridge.mjs +10 -7
- package/dist/do/index.mjs +8 -4
- package/dist/index.d.mts +0 -9
- package/dist/index.d.ts +0 -9
- package/dist/index.mjs +2 -2
- package/dist/packem_shared/{containerBindingName-CWmEE_3Y.mjs → containerBindingName-D5KTrblH.mjs} +4 -1
- package/dist/packem_shared/{createContainerContext-BtzK5gJL.mjs → createContainerContext-Cibbh7AE.mjs} +4 -1
- package/package.json +4 -1
package/dist/bridge.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { LunoraError } from '@lunora/errors';
|
|
1
2
|
/** A `fetch` implementation — defaults to the runtime global. */
|
|
2
3
|
type FetchLike = (input: string, init: {
|
|
3
4
|
body: string;
|
|
@@ -25,9 +26,8 @@ interface ContainerBridgeOptions {
|
|
|
25
26
|
*/
|
|
26
27
|
token?: string;
|
|
27
28
|
}
|
|
28
|
-
/** Thrown when a Lunora function returns an error envelope.
|
|
29
|
-
declare class ContainerBridgeError extends
|
|
30
|
-
readonly code: string;
|
|
29
|
+
/** Thrown when a Lunora function returns an error envelope. A `LunoraError` subclass carrying the wire `code`. */
|
|
30
|
+
declare class ContainerBridgeError extends LunoraError {
|
|
31
31
|
constructor(code: string, message: string);
|
|
32
32
|
}
|
|
33
33
|
/**
|
package/dist/bridge.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { LunoraError } from '@lunora/errors';
|
|
1
2
|
/** A `fetch` implementation — defaults to the runtime global. */
|
|
2
3
|
type FetchLike = (input: string, init: {
|
|
3
4
|
body: string;
|
|
@@ -25,9 +26,8 @@ interface ContainerBridgeOptions {
|
|
|
25
26
|
*/
|
|
26
27
|
token?: string;
|
|
27
28
|
}
|
|
28
|
-
/** Thrown when a Lunora function returns an error envelope.
|
|
29
|
-
declare class ContainerBridgeError extends
|
|
30
|
-
readonly code: string;
|
|
29
|
+
/** Thrown when a Lunora function returns an error envelope. A `LunoraError` subclass carrying the wire `code`. */
|
|
30
|
+
declare class ContainerBridgeError extends LunoraError {
|
|
31
31
|
constructor(code: string, message: string);
|
|
32
32
|
}
|
|
33
33
|
/**
|
package/dist/bridge.mjs
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
+
import { LunoraError } from '@lunora/errors';
|
|
2
|
+
|
|
1
3
|
const RPC_PATH = "/_lunora/rpc";
|
|
2
|
-
class ContainerBridgeError extends
|
|
3
|
-
code;
|
|
4
|
+
class ContainerBridgeError extends LunoraError {
|
|
4
5
|
constructor(code, message) {
|
|
5
|
-
super(message);
|
|
6
|
-
this.name = "ContainerBridgeError";
|
|
7
|
-
this.code = code;
|
|
6
|
+
super(code, message, { name: "ContainerBridgeError" });
|
|
8
7
|
}
|
|
9
8
|
}
|
|
10
9
|
const joinUrl = (baseUrl, path) => {
|
|
@@ -24,7 +23,10 @@ const parseResponseBody = async (response, functionPath) => {
|
|
|
24
23
|
if (!response.ok) {
|
|
25
24
|
throw statusError(functionPath, response);
|
|
26
25
|
}
|
|
27
|
-
throw new
|
|
26
|
+
throw new LunoraError(
|
|
27
|
+
"INTERNAL",
|
|
28
|
+
`createContainerBridge: request to "${functionPath}" returned a non-JSON response (status ${String(response.status)})`
|
|
29
|
+
);
|
|
28
30
|
}
|
|
29
31
|
};
|
|
30
32
|
const createContainerBridge = (options) => {
|
|
@@ -60,7 +62,8 @@ const createContainerBridge = (options) => {
|
|
|
60
62
|
} catch {
|
|
61
63
|
detail = String(error);
|
|
62
64
|
}
|
|
63
|
-
throw new
|
|
65
|
+
throw new LunoraError(
|
|
66
|
+
"INTERNAL",
|
|
64
67
|
`createContainerBridge: request to "${functionPath}" returned a malformed error envelope (status ${String(response.status)}): ${detail}`
|
|
65
68
|
);
|
|
66
69
|
}
|
package/dist/do/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Container } from '../packem_shared/ContainerProxy-DWqUX_re.mjs';
|
|
2
2
|
export { ContainerProxy, outboundParams } from '../packem_shared/ContainerProxy-DWqUX_re.mjs';
|
|
3
|
-
import {
|
|
3
|
+
import { LunoraError } from '@lunora/errors';
|
|
4
|
+
import { resolveContainerEnvVars as resolveContainerEnvVariables, parseDurationSeconds } from '../packem_shared/containerBindingName-D5KTrblH.mjs';
|
|
4
5
|
|
|
5
6
|
const LUNORA_EVENT_SOURCE = "lunora";
|
|
6
7
|
const buildContainerLifecycleEvent = (container, instance, event, message) => {
|
|
@@ -233,7 +234,8 @@ class LunoraContainer extends Container {
|
|
|
233
234
|
for (const [envName, binding] of Object.entries(secretsStore)) {
|
|
234
235
|
const store = workerEnv[binding];
|
|
235
236
|
if (store === void 0 || typeof store.get !== "function") {
|
|
236
|
-
throw new
|
|
237
|
+
throw new LunoraError(
|
|
238
|
+
"INTERNAL",
|
|
237
239
|
`container "${this.lunoraName}": secretsStore env "${envName}" points at binding "${binding}", which is not a Secrets Store binding on the Worker env. Add a \`secrets_store_secrets\` entry binding "${binding}".`
|
|
238
240
|
);
|
|
239
241
|
}
|
|
@@ -270,7 +272,8 @@ class LunoraContainer extends Container {
|
|
|
270
272
|
async awaitReadinessCheck(container, check, deadline) {
|
|
271
273
|
const port = check.port ?? this.lunoraDefaultPort;
|
|
272
274
|
if (port === void 0) {
|
|
273
|
-
throw new
|
|
275
|
+
throw new LunoraError(
|
|
276
|
+
"INTERNAL",
|
|
274
277
|
`container "${this.lunoraName}": readyOn check "${check.path}" has no port — set the check's \`port\` or the container \`defaultPort\`.`
|
|
275
278
|
);
|
|
276
279
|
}
|
|
@@ -286,7 +289,8 @@ class LunoraContainer extends Container {
|
|
|
286
289
|
} catch {
|
|
287
290
|
}
|
|
288
291
|
if (Date.now() >= deadline) {
|
|
289
|
-
throw new
|
|
292
|
+
throw new LunoraError(
|
|
293
|
+
"INTERNAL",
|
|
290
294
|
`container "${this.lunoraName}": readiness check "${check.path}" (port ${String(port)}) did not return ${String(expectedStatus)} within ${String(READINESS_TIMEOUT_MS)}ms`
|
|
291
295
|
);
|
|
292
296
|
}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
import { C as ContainerConfig, a as ContainerDefinition, b as ContainerImageSource, N as NormalizedContainerImage } from "./packem_shared/types.d-BlNwNY44.mjs";
|
|
2
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/types.d-BlNwNY44.mjs";
|
|
3
|
-
/**
|
|
4
|
-
* The `ctx.containers` action surface: typed handles over the `CONTAINER_*`
|
|
5
|
-
* Durable Object namespace bindings the config layer reconciles.
|
|
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
3
|
/** Options for explicitly starting an instance (mirrors `@cloudflare/containers`). */
|
|
13
4
|
interface ContainerStartOptions {
|
|
14
5
|
/** Override outbound internet access for this start. */
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
import { C as ContainerConfig, a as ContainerDefinition, b as ContainerImageSource, N as NormalizedContainerImage } from "./packem_shared/types.d-BlNwNY44.js";
|
|
2
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/types.d-BlNwNY44.js";
|
|
3
|
-
/**
|
|
4
|
-
* The `ctx.containers` action surface: typed handles over the `CONTAINER_*`
|
|
5
|
-
* Durable Object namespace bindings the config layer reconciles.
|
|
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
3
|
/** Options for explicitly starting an instance (mirrors `@cloudflare/containers`). */
|
|
13
4
|
interface ContainerStartOptions {
|
|
14
5
|
/** Override outbound internet access for this start. */
|
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-Cibbh7AE.mjs';
|
|
2
|
+
export { containerBindingName, containerBuildTag, containerClassName, defineContainer, isContainerDefinition, normalizeContainerImage, resolveContainerEnvVars } from './packem_shared/containerBindingName-D5KTrblH.mjs';
|
package/dist/packem_shared/{containerBindingName-CWmEE_3Y.mjs → containerBindingName-D5KTrblH.mjs}
RENAMED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { LunoraError } from '@lunora/errors';
|
|
2
|
+
|
|
1
3
|
const NAMED_INSTANCE_TYPES = /* @__PURE__ */ new Set(["basic", "lite", "standard-1", "standard-2", "standard-3", "standard-4"]);
|
|
2
4
|
const ENV_NAME_PATTERN = /^[A-Z_]\w*$/i;
|
|
3
5
|
const SLEEP_AFTER_PATTERN = /^\d+[smh]$/;
|
|
@@ -203,7 +205,8 @@ const resolveContainerEnvVariables = (definition, workerEnv, exportName) => {
|
|
|
203
205
|
const value = workerEnv[secret];
|
|
204
206
|
if (typeof value !== "string") {
|
|
205
207
|
const label = exportName === void 0 ? "container" : `container "${exportName}"`;
|
|
206
|
-
throw new
|
|
208
|
+
throw new LunoraError(
|
|
209
|
+
"INTERNAL",
|
|
207
210
|
`${label}: declared secret "${secret}" is not set on the Worker environment. Add it to .dev.vars for local dev and run \`wrangler secret put ${secret}\` for production.`
|
|
208
211
|
);
|
|
209
212
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { LunoraError } from '@lunora/errors';
|
|
2
|
+
|
|
1
3
|
const applyJurisdiction = (namespace, jurisdiction) => {
|
|
2
4
|
if (jurisdiction === void 0) {
|
|
3
5
|
return namespace;
|
|
@@ -171,7 +173,8 @@ const accessorFor = (namespace, spec) => {
|
|
|
171
173
|
};
|
|
172
174
|
const missingBindingAccessor = (spec) => {
|
|
173
175
|
const fail = () => {
|
|
174
|
-
throw new
|
|
176
|
+
throw new LunoraError(
|
|
177
|
+
"INTERNAL",
|
|
175
178
|
`ctx.containers.${spec.exportName}: no "${spec.binding}" Durable Object binding found. Run \`lunora dev\` (or \`lunora deploy\`) to reconcile wrangler.jsonc, and make sure the worker entry re-exports the generated container classes.`
|
|
176
179
|
);
|
|
177
180
|
};
|
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.6",
|
|
4
4
|
"description": "Cloudflare Containers for Lunora: defineContainer, generated Container DO classes, and the ctx.containers action surface",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -51,6 +51,9 @@
|
|
|
51
51
|
"publishConfig": {
|
|
52
52
|
"access": "public"
|
|
53
53
|
},
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"@lunora/errors": "1.0.0-alpha.1"
|
|
56
|
+
},
|
|
54
57
|
"engines": {
|
|
55
58
|
"node": "^22.15.0 || >=24.11.0"
|
|
56
59
|
}
|