@lunora/container 1.0.0-alpha.75 → 1.0.0-alpha.76
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.mjs +1 -1
- package/package.json +3 -2
package/dist/bridge.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LunoraError as
|
|
1
|
+
import{LunoraError as u}from"@lunora/errors";import{encodeWire as h,decodeWire as p}from"@lunora/wire";const w="/_lunora/rpc";class m extends u{constructor(r,t){super(r,t,{name:"ContainerBridgeError"})}}const b=(e,r)=>{let t=e;for(;t.endsWith("/");)t=t.slice(0,-1);return`${t}${r}`},y=(e,r)=>new Error(`createContainerBridge: request to "${e}" failed (status ${String(r.status)}${r.statusText?` ${r.statusText}`:""})`),$=async(e,r)=>{try{return await e.json()}catch{throw e.ok?new u("INTERNAL",`createContainerBridge: request to "${r}" returned a non-JSON response (status ${String(e.status)})`):y(r,e)}},T=e=>{if(typeof e.baseUrl!="string"||e.baseUrl.length===0)throw new TypeError("createContainerBridge: `baseUrl` must be a non-empty Worker URL (e.g. https://my-app.workers.dev) — is the URL env var set?");const r=e.fetch??globalThis.fetch,t=async(o,i={},c)=>{if(typeof r!="function")throw new TypeError("createContainerBridge: no `fetch` available — pass `fetch` in options for this runtime.");const d={"content-type":"application/json"};e.token!==void 0&&(d.authorization=`Bearer ${e.token}`);const s=await r(b(e.baseUrl,w),{body:JSON.stringify({args:h(i),functionPath:o,shardKey:c}),headers:d,method:"POST"}),n=await $(s,o);if(typeof n=="object"&&n!==null&&"error"in n){const{error:a}=n;if(typeof a=="object"&&a!==null){const{code:f,message:g}=a;if(typeof f=="string"&&typeof g=="string")throw new m(f,g)}let l;try{l=JSON.stringify(a)}catch{l=String(a)}throw new u("INTERNAL",`createContainerBridge: request to "${o}" returned a malformed error envelope (status ${String(s.status)}): ${l}`)}if(!s.ok)throw y(o,s);return p(n.result)};return{action:t,call:t,mutation:t,query:t,run:async(o,i,c)=>t(o.__lunoraRef,i,c)}};export{m as ContainerBridgeError,T as createContainerBridge};
|
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.76",
|
|
4
4
|
"description": "Cloudflare Containers for Lunora: defineContainer, generated Container DO classes, and the ctx.containers action surface",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -61,7 +61,8 @@
|
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"@cloudflare/sandbox": "1.0.0",
|
|
64
|
-
"@lunora/errors": ">=1.0.0-alpha.51 <2.0.0-0"
|
|
64
|
+
"@lunora/errors": ">=1.0.0-alpha.51 <2.0.0-0",
|
|
65
|
+
"@lunora/wire": "1.0.0-alpha.1"
|
|
65
66
|
},
|
|
66
67
|
"engines": {
|
|
67
68
|
"node": "^22.15.0 || >=24.11.0"
|