@lunora/runtime 1.0.0-alpha.51 → 1.0.0-alpha.53
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/index.d.mts
CHANGED
|
@@ -1300,7 +1300,7 @@ interface R2PutLike {
|
|
|
1300
1300
|
}
|
|
1301
1301
|
/**
|
|
1302
1302
|
* Built-in R2 sink: write each shard's changes as an NDJSON object under
|
|
1303
|
-
*
|
|
1303
|
+
* `<prefix>/<shardKey>/<cursor>.ndjson`. The cursor in the key makes each object
|
|
1304
1304
|
* content-addressed by watermark, so an at-least-once replay overwrites the same
|
|
1305
1305
|
* key rather than duplicating (idempotent at the object level). A `put` rejection
|
|
1306
1306
|
* propagates so the tap retries.
|
|
@@ -1321,7 +1321,7 @@ interface KvLike {
|
|
|
1321
1321
|
}
|
|
1322
1322
|
/**
|
|
1323
1323
|
* KV-backed durable cursor store. The watermark key mirrors the CDC-in
|
|
1324
|
-
* convention (`__lunora_source_cursor`): `__lunora_source_cursor:export
|
|
1324
|
+
* convention (`__lunora_source_cursor`): `__lunora_source_cursor:export:<sink>`.
|
|
1325
1325
|
* A missing / malformed value reads as the empty map (drain from the beginning),
|
|
1326
1326
|
* so a fresh sink or a corrupted key can never crash the pass.
|
|
1327
1327
|
*/
|
|
@@ -2588,7 +2588,7 @@ type TrustInboundTraceContext = boolean | TraceTrustSignal | ((request: Request)
|
|
|
2588
2588
|
/**
|
|
2589
2589
|
* Wire-format RPC envelope. Posted to `POST /_lunora/rpc`.
|
|
2590
2590
|
*
|
|
2591
|
-
* `functionPath` is the
|
|
2591
|
+
* `functionPath` is the `<file>:<function>` identifier emitted by codegen,
|
|
2592
2592
|
* e.g. `"messages:list"`. `shardKey` is optional — when omitted the runtime
|
|
2593
2593
|
* routes to {@link WorkerOptions.defaultShardKey} (default `"__root__"`).
|
|
2594
2594
|
*
|
|
@@ -2781,7 +2781,7 @@ interface FunctionDescriptor {
|
|
|
2781
2781
|
/** The function's declared argument schema, derived from its `v.*` validators. */
|
|
2782
2782
|
args: FunctionArgumentDescriptor[];
|
|
2783
2783
|
kind: "action" | "mutation" | "query";
|
|
2784
|
-
/** The
|
|
2784
|
+
/** The `<file>:<function>` identifier, e.g. `messages:list`. */
|
|
2785
2785
|
path: string;
|
|
2786
2786
|
/** `"internal"` functions are never exposed by the discovery endpoint; absence === public. */
|
|
2787
2787
|
visibility?: "internal" | "public";
|
|
@@ -2793,7 +2793,7 @@ interface FunctionRegistryEntry {
|
|
|
2793
2793
|
/**
|
|
2794
2794
|
* Opt-in public-surface tag set by the `.expose({ rest: true })` builder
|
|
2795
2795
|
* modifier (plan 167). Present only on procedures deliberately published over
|
|
2796
|
-
* REST; the runtime builds a `/_lunora/rest
|
|
2796
|
+
* REST; the runtime builds a `/_lunora/rest/<namespace>/<fn>` route for each,
|
|
2797
2797
|
* routing THROUGH the procedure so auth/RLS/validators are enforced. Rides
|
|
2798
2798
|
* along on the registered function's identity (like `fn.x402` / `fn.rls`), so
|
|
2799
2799
|
* reading it needs no change to the generated registry shape.
|
|
@@ -3079,7 +3079,7 @@ interface BackupStore {
|
|
|
3079
3079
|
}
|
|
3080
3080
|
/**
|
|
3081
3081
|
* Manifest sidecar written next to each scheduled backup's NDJSON object (at
|
|
3082
|
-
*
|
|
3082
|
+
* `<file>.manifest.json`). Mirrors the manifest entry the CLI records for local
|
|
3083
3083
|
* backups so both backup planes describe a snapshot the same way;
|
|
3084
3084
|
* `cron`/`scheduledTime` additionally record which trigger produced it.
|
|
3085
3085
|
*/
|
|
@@ -3323,7 +3323,7 @@ interface WorkerOptions {
|
|
|
3323
3323
|
backupCron?: string;
|
|
3324
3324
|
/**
|
|
3325
3325
|
* Key prefix the scheduled backup writes under (default `"backups/"`). The
|
|
3326
|
-
* NDJSON object lands at
|
|
3326
|
+
* NDJSON object lands at `<prefix>lunora-backup-<id>.ndjson` and its manifest
|
|
3327
3327
|
* at the same key plus `.manifest.json`.
|
|
3328
3328
|
*/
|
|
3329
3329
|
backupPrefix?: string;
|
|
@@ -3747,7 +3747,7 @@ interface WorkerOptions {
|
|
|
3747
3747
|
* Voice-session Durable Object namespaces, keyed by the agent's
|
|
3748
3748
|
* `lunora/agents.ts` export name (e.g. `{ support: env.VOICE_SUPPORT }`).
|
|
3749
3749
|
* Codegen wires this for every voice-enabled agent. When set, the worker
|
|
3750
|
-
* exposes `/_lunora/voice
|
|
3750
|
+
* exposes `/_lunora/voice/<agentExportName>` — a WebSocket upgrade that
|
|
3751
3751
|
* resolves the caller's identity, forwards it on the server-minted
|
|
3752
3752
|
* `x-lunora-userid` / `x-lunora-identity` headers, and hands the socket to
|
|
3753
3753
|
* the agent's `VoiceSessionDO`. Omit it (voice-free apps) and the route does
|
|
@@ -4572,7 +4572,7 @@ interface ShardFunctionReference<Args = unknown, Return = unknown> {
|
|
|
4572
4572
|
};
|
|
4573
4573
|
readonly __lunoraRef: string;
|
|
4574
4574
|
}
|
|
4575
|
-
/** Args type of a {@link ShardFunctionReference} (`Record
|
|
4575
|
+
/** Args type of a {@link ShardFunctionReference} (`Record<string, unknown>` for an untyped ref). */
|
|
4576
4576
|
type ShardCallArgs<F> = F extends ShardFunctionReference<infer A, infer _R> ? A : Record<string, unknown>;
|
|
4577
4577
|
/** Return type of a {@link ShardFunctionReference} (`unknown` for an untyped ref). */
|
|
4578
4578
|
type ShardCallReturn<F> = F extends ShardFunctionReference<infer _A, infer R> ? R : unknown;
|
package/dist/index.d.ts
CHANGED
|
@@ -1300,7 +1300,7 @@ interface R2PutLike {
|
|
|
1300
1300
|
}
|
|
1301
1301
|
/**
|
|
1302
1302
|
* Built-in R2 sink: write each shard's changes as an NDJSON object under
|
|
1303
|
-
*
|
|
1303
|
+
* `<prefix>/<shardKey>/<cursor>.ndjson`. The cursor in the key makes each object
|
|
1304
1304
|
* content-addressed by watermark, so an at-least-once replay overwrites the same
|
|
1305
1305
|
* key rather than duplicating (idempotent at the object level). A `put` rejection
|
|
1306
1306
|
* propagates so the tap retries.
|
|
@@ -1321,7 +1321,7 @@ interface KvLike {
|
|
|
1321
1321
|
}
|
|
1322
1322
|
/**
|
|
1323
1323
|
* KV-backed durable cursor store. The watermark key mirrors the CDC-in
|
|
1324
|
-
* convention (`__lunora_source_cursor`): `__lunora_source_cursor:export
|
|
1324
|
+
* convention (`__lunora_source_cursor`): `__lunora_source_cursor:export:<sink>`.
|
|
1325
1325
|
* A missing / malformed value reads as the empty map (drain from the beginning),
|
|
1326
1326
|
* so a fresh sink or a corrupted key can never crash the pass.
|
|
1327
1327
|
*/
|
|
@@ -2588,7 +2588,7 @@ type TrustInboundTraceContext = boolean | TraceTrustSignal | ((request: Request)
|
|
|
2588
2588
|
/**
|
|
2589
2589
|
* Wire-format RPC envelope. Posted to `POST /_lunora/rpc`.
|
|
2590
2590
|
*
|
|
2591
|
-
* `functionPath` is the
|
|
2591
|
+
* `functionPath` is the `<file>:<function>` identifier emitted by codegen,
|
|
2592
2592
|
* e.g. `"messages:list"`. `shardKey` is optional — when omitted the runtime
|
|
2593
2593
|
* routes to {@link WorkerOptions.defaultShardKey} (default `"__root__"`).
|
|
2594
2594
|
*
|
|
@@ -2781,7 +2781,7 @@ interface FunctionDescriptor {
|
|
|
2781
2781
|
/** The function's declared argument schema, derived from its `v.*` validators. */
|
|
2782
2782
|
args: FunctionArgumentDescriptor[];
|
|
2783
2783
|
kind: "action" | "mutation" | "query";
|
|
2784
|
-
/** The
|
|
2784
|
+
/** The `<file>:<function>` identifier, e.g. `messages:list`. */
|
|
2785
2785
|
path: string;
|
|
2786
2786
|
/** `"internal"` functions are never exposed by the discovery endpoint; absence === public. */
|
|
2787
2787
|
visibility?: "internal" | "public";
|
|
@@ -2793,7 +2793,7 @@ interface FunctionRegistryEntry {
|
|
|
2793
2793
|
/**
|
|
2794
2794
|
* Opt-in public-surface tag set by the `.expose({ rest: true })` builder
|
|
2795
2795
|
* modifier (plan 167). Present only on procedures deliberately published over
|
|
2796
|
-
* REST; the runtime builds a `/_lunora/rest
|
|
2796
|
+
* REST; the runtime builds a `/_lunora/rest/<namespace>/<fn>` route for each,
|
|
2797
2797
|
* routing THROUGH the procedure so auth/RLS/validators are enforced. Rides
|
|
2798
2798
|
* along on the registered function's identity (like `fn.x402` / `fn.rls`), so
|
|
2799
2799
|
* reading it needs no change to the generated registry shape.
|
|
@@ -3079,7 +3079,7 @@ interface BackupStore {
|
|
|
3079
3079
|
}
|
|
3080
3080
|
/**
|
|
3081
3081
|
* Manifest sidecar written next to each scheduled backup's NDJSON object (at
|
|
3082
|
-
*
|
|
3082
|
+
* `<file>.manifest.json`). Mirrors the manifest entry the CLI records for local
|
|
3083
3083
|
* backups so both backup planes describe a snapshot the same way;
|
|
3084
3084
|
* `cron`/`scheduledTime` additionally record which trigger produced it.
|
|
3085
3085
|
*/
|
|
@@ -3323,7 +3323,7 @@ interface WorkerOptions {
|
|
|
3323
3323
|
backupCron?: string;
|
|
3324
3324
|
/**
|
|
3325
3325
|
* Key prefix the scheduled backup writes under (default `"backups/"`). The
|
|
3326
|
-
* NDJSON object lands at
|
|
3326
|
+
* NDJSON object lands at `<prefix>lunora-backup-<id>.ndjson` and its manifest
|
|
3327
3327
|
* at the same key plus `.manifest.json`.
|
|
3328
3328
|
*/
|
|
3329
3329
|
backupPrefix?: string;
|
|
@@ -3747,7 +3747,7 @@ interface WorkerOptions {
|
|
|
3747
3747
|
* Voice-session Durable Object namespaces, keyed by the agent's
|
|
3748
3748
|
* `lunora/agents.ts` export name (e.g. `{ support: env.VOICE_SUPPORT }`).
|
|
3749
3749
|
* Codegen wires this for every voice-enabled agent. When set, the worker
|
|
3750
|
-
* exposes `/_lunora/voice
|
|
3750
|
+
* exposes `/_lunora/voice/<agentExportName>` — a WebSocket upgrade that
|
|
3751
3751
|
* resolves the caller's identity, forwards it on the server-minted
|
|
3752
3752
|
* `x-lunora-userid` / `x-lunora-identity` headers, and hands the socket to
|
|
3753
3753
|
* the agent's `VoiceSessionDO`. Omit it (voice-free apps) and the route does
|
|
@@ -4572,7 +4572,7 @@ interface ShardFunctionReference<Args = unknown, Return = unknown> {
|
|
|
4572
4572
|
};
|
|
4573
4573
|
readonly __lunoraRef: string;
|
|
4574
4574
|
}
|
|
4575
|
-
/** Args type of a {@link ShardFunctionReference} (`Record
|
|
4575
|
+
/** Args type of a {@link ShardFunctionReference} (`Record<string, unknown>` for an untyped ref). */
|
|
4576
4576
|
type ShardCallArgs<F> = F extends ShardFunctionReference<infer A, infer _R> ? A : Record<string, unknown>;
|
|
4577
4577
|
/** Return type of a {@link ShardFunctionReference} (`unknown` for an untyped ref). */
|
|
4578
4578
|
type ShardCallReturn<F> = F extends ShardFunctionReference<infer _A, infer R> ? R : unknown;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{toAirbyteMessages as t,toFivetranResponse as a}from"./packem_shared/toAirbyteMessages-DBTuFjb5.mjs";import{composeWorker as i,createLunoraHandler as n,createWorker as p,defineRpcEnvelope as m,resolveLunoraOptions as c,withFrameworkWorker as R}from"./packem_shared/composeWorker-BieBiNab.mjs";import{createCrossShardRelationCapabilities as f}from"./packem_shared/createCrossShardRelationCapabilities-Cr8V1uO_.mjs";import{DEFAULT_REGISTRY_CACHE_TTL_MS as d,SHARD_REGISTRY_DO_NAME as l,createDynamicShardRegistry as x}from"./packem_shared/DEFAULT_REGISTRY_CACHE_TTL_MS-BclNO0yc.mjs";import{LunoraError as C,toErrorResponse as L}from"./packem_shared/LunoraError-ByasbDmd.mjs";import{createKvCursorStore as u,createMemoryCursorStore as y,defineExportSink as T,r2Sink as A,runExportTap as h,sanitizeChange as k,webhookExportSink as O}from"./packem_shared/createKvCursorStore-C24tEuYk.mjs";import{HEALTH_PATH as v,HEALTH_READY_PATH as I,buildHealthRoutes as b,d1Probe as F,durableObjectProbe as P,presenceProbe as D}from"./packem_shared/HEALTH_PATH-BpCNEAIa.mjs";import{LOG_ARCHIVE_PATH as G,resolveLogArchiveFromEnv as U}from"./packem_shared/LOG_ARCHIVE_PATH-DGsEec3K.mjs";import{memoizeIdentity as w,memoizeIdentityPerRequest as z}from"./packem_shared/memoizeIdentity-CZGtDc4H.mjs";import{e as W,a as Y}from"./packem_shared/observability-DYnm-d4g.mjs";import{analyticsEngineSink as K,combineSinks as Q,consoleSink as X,otlpSink as j,pipelineLogSink as J,sentrySink as B,webhookSink as Z}from"./packem_shared/analyticsEngineSink-CUWYuLHs.mjs";import{D as ee,a as re,c as oe}from"./packem_shared/pipeline-log-reader-DU_CCGDA.mjs";import{createQueryCoordinator as ae,createStaticShardRegistry as se,mergeStrategyForAggregate as ie}from"./packem_shared/createQueryCoordinator-DQ7dkxS6.mjs";import{applyJurisdiction as pe,resolveShard as me}from"./packem_shared/applyJurisdiction-8bzZjAPR.mjs";import{R as Re,d as Se,o as fe}from"./packem_shared/rest-cache-5unAzdFN.mjs";import{g as de,S as le,U as xe,p as _e,f as Ce}from"./packem_shared/rest-routes-BJLWmBgK.mjs";import{decorateResponse as ge,enforceOrigin as ue,handleCorsPreflight as ye,resolveSecurity as Te}from"./packem_shared/decorateResponse-DBIWsRSZ.mjs";import{createShardClient as he}from"./packem_shared/createShardClient-
|
|
1
|
+
import{toAirbyteMessages as t,toFivetranResponse as a}from"./packem_shared/toAirbyteMessages-DBTuFjb5.mjs";import{composeWorker as i,createLunoraHandler as n,createWorker as p,defineRpcEnvelope as m,resolveLunoraOptions as c,withFrameworkWorker as R}from"./packem_shared/composeWorker-BieBiNab.mjs";import{createCrossShardRelationCapabilities as f}from"./packem_shared/createCrossShardRelationCapabilities-Cr8V1uO_.mjs";import{DEFAULT_REGISTRY_CACHE_TTL_MS as d,SHARD_REGISTRY_DO_NAME as l,createDynamicShardRegistry as x}from"./packem_shared/DEFAULT_REGISTRY_CACHE_TTL_MS-BclNO0yc.mjs";import{LunoraError as C,toErrorResponse as L}from"./packem_shared/LunoraError-ByasbDmd.mjs";import{createKvCursorStore as u,createMemoryCursorStore as y,defineExportSink as T,r2Sink as A,runExportTap as h,sanitizeChange as k,webhookExportSink as O}from"./packem_shared/createKvCursorStore-C24tEuYk.mjs";import{HEALTH_PATH as v,HEALTH_READY_PATH as I,buildHealthRoutes as b,d1Probe as F,durableObjectProbe as P,presenceProbe as D}from"./packem_shared/HEALTH_PATH-BpCNEAIa.mjs";import{LOG_ARCHIVE_PATH as G,resolveLogArchiveFromEnv as U}from"./packem_shared/LOG_ARCHIVE_PATH-DGsEec3K.mjs";import{memoizeIdentity as w,memoizeIdentityPerRequest as z}from"./packem_shared/memoizeIdentity-CZGtDc4H.mjs";import{e as W,a as Y}from"./packem_shared/observability-DYnm-d4g.mjs";import{analyticsEngineSink as K,combineSinks as Q,consoleSink as X,otlpSink as j,pipelineLogSink as J,sentrySink as B,webhookSink as Z}from"./packem_shared/analyticsEngineSink-CUWYuLHs.mjs";import{D as ee,a as re,c as oe}from"./packem_shared/pipeline-log-reader-DU_CCGDA.mjs";import{createQueryCoordinator as ae,createStaticShardRegistry as se,mergeStrategyForAggregate as ie}from"./packem_shared/createQueryCoordinator-DQ7dkxS6.mjs";import{applyJurisdiction as pe,resolveShard as me}from"./packem_shared/applyJurisdiction-8bzZjAPR.mjs";import{R as Re,d as Se,o as fe}from"./packem_shared/rest-cache-5unAzdFN.mjs";import{g as de,S as le,U as xe,p as _e,f as Ce}from"./packem_shared/rest-routes-BJLWmBgK.mjs";import{decorateResponse as ge,enforceOrigin as ue,handleCorsPreflight as ye,resolveSecurity as Te}from"./packem_shared/decorateResponse-DBIWsRSZ.mjs";import{createShardClient as he}from"./packem_shared/createShardClient-gC6COZNn.mjs";import{LOG_ARCHIVE_NOT_CONFIGURED as Oe}from"./packem_shared/LOG_ARCHIVE_NOT_CONFIGURED-CDpi4yFD.mjs";import{NOOP_EXECUTION_CONTEXT as ve}from"./packem_shared/NOOP_EXECUTION_CONTEXT-YmXqH-jH.mjs";import{composeIdentityResolvers as be,routeIdentityResolvers as Fe}from"./packem_shared/composeIdentityResolvers-DwE0Jbww.mjs";const e="0.0.0";export{ee as DEFAULT_LOG_COLUMNS,re as DEFAULT_LOG_LIMIT,d as DEFAULT_REGISTRY_CACHE_TTL_MS,v as HEALTH_PATH,I as HEALTH_READY_PATH,Oe as LOG_ARCHIVE_NOT_CONFIGURED,G as LOG_ARCHIVE_PATH,C as LunoraError,ve as NOOP_EXECUTION_CONTEXT,l as SHARD_REGISTRY_DO_NAME,e as VERSION,K as analyticsEngineSink,pe as applyJurisdiction,Re as applyRestCache,de as argsFromQuery,b as buildHealthRoutes,le as buildRestRoutes,Q as combineSinks,be as composeIdentityResolvers,i as composeWorker,X as consoleSink,f as createCrossShardRelationCapabilities,x as createDynamicShardRegistry,u as createKvCursorStore,n as createLunoraHandler,y as createMemoryCursorStore,oe as createPipelineLogReader,ae as createQueryCoordinator,xe as createRestRateLimit,he as createShardClient,se as createStaticShardRegistry,p as createWorker,F as d1Probe,ge as decorateResponse,T as defineExportSink,m as defineRpcEnvelope,P as durableObjectProbe,W as emitLogEvent,Y as emitRpcEvent,ue as enforceOrigin,ye as handleCorsPreflight,w as memoizeIdentity,z as memoizeIdentityPerRequest,ie as mergeStrategyForAggregate,j as otlpSink,J as pipelineLogSink,D as presenceProbe,A as r2Sink,_e as readShardKey,Se as requestCarriesCredentials,U as resolveLogArchiveFromEnv,c as resolveLunoraOptions,Te as resolveSecurity,me as resolveShard,fe as restCacheHeaders,Ce as restSurfaceFromRegistry,Fe as routeIdentityResolvers,h as runExportTap,k as sanitizeChange,B as sentrySink,t as toAirbyteMessages,L as toErrorResponse,a as toFivetranResponse,O as webhookExportSink,Z as webhookSink,R as withFrameworkWorker};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{LunoraError as b}from"@lunora/errors";import{a as g,o as j,f as E,u as O}from"./identity-header-CDgIrYAz.mjs";import{applyJurisdiction as N,resolveShard as R}from"./applyJurisdiction-8bzZjAPR.mjs";const i="$lunora.wire$",m=64,v=1024,A="__proto__",$={BigInt64Array,BigUint64Array,Float32Array,Float64Array,Int8Array,Int16Array,Int32Array,Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array},S={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError},x=r=>{if(r===null||typeof r!="object")return!1;const t=Object.getPrototypeOf(r);return t===null||t===Object.prototype},f=(r,t=0)=>{if(t>m)throw new RangeError(`wire-codec: value nesting exceeds the ${m}-level limit`);if(r===void 0)return[i,"undefined"];if(r===null)return null;const l=typeof r;if(l==="bigint")return[i,"bigint",r.toString()];if(l==="number"){const e=r;return Number.isNaN(e)?[i,"nan"]:e===1/0?[i,"inf"]:e===-1/0?[i,"-inf"]:e}if(l!=="object")return r;if(r instanceof Date)return[i,"date",f(r.getTime(),t+1)];if(r instanceof Error){const e=r,o={};for(const s of Object.keys(e))e[s]!==void 0&&(o[s]=f(e[s],t+1));const n=[i,"error",e.name,e.message,o];return e.cause!==void 0&&n.push(f(e.cause,t+1)),n}if(r instanceof URL)return[i,"url",r.href];if(r instanceof Map)return[i,"map",[...r.entries()].map(([e,o])=>[f(e,t+1),f(o,t+1)])];if(r instanceof Set)return[i,"set",[...r].map(e=>f(e,t+1))];if(r instanceof ArrayBuffer)return[i,"bytes",g(new Uint8Array(r)),"ArrayBuffer"];if(ArrayBuffer.isView(r)){const e=r,o=e.constructor.name,n=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);return o==="Uint8Array"?[i,"bytes",g(n)]:[i,"bytes",g(n),o]}if(Array.isArray(r)){const e=r.map(o=>f(o,t+1));return e.length>0&&e[0]===i?[i,"arr",e]:e}if(!x(r)){const e=r.constructor?.name??"value";throw new TypeError(`wire-codec: cannot encode a ${e} over the Lunora wire — only plain objects, arrays, and the supported built-ins (Date, Error, URL, Map, Set, ArrayBuffer/typed arrays, bigint) round-trip`)}const d=r,a={};for(const e of Object.keys(d)){const o=d[e];if(o===void 0)continue;const n=f(o,t+1);e===A?Object.defineProperty(a,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):a[e]=n}return a},u=(r,t=0)=>{if(t>m)throw new RangeError(`wire-codec: value nesting exceeds the ${m}-level limit`);if(r===null||typeof r!="object")return r;if(Array.isArray(r)){if(r[0]===i)switch(r[1]){case"-inf":return-1/0;case"arr":return r[2].map(a=>u(a,t+1));case"bigint":{const a=r[2];if(typeof a!="string"||a.length>v||!/^-?\d+$/.test(a))throw new RangeError(`wire-codec: invalid or over-long bigint (max ${v} digits)`);return BigInt(a)}case"date":return new Date(u(r[2],t+1));case"map":return new Map(r[2].map(([a,e])=>[u(a,t+1),u(e,t+1)]));case"set":return new Set(r[2].map(a=>u(a,t+1)));case"url":return new URL(r[2]);case"error":{const a=r[2],e=r[3],o=(Object.hasOwn(S,a)?S[a]:void 0)??Error,n=new o(e);n.name!==a&&Object.defineProperty(n,"name",{configurable:!0,value:a,writable:!0});const s=u(r[4],t+1);for(const c of Object.keys(s))c===A?Object.defineProperty(n,c,{configurable:!0,enumerable:!0,value:s[c],writable:!0}):n[c]=s[c];return r.length>5&&Object.defineProperty(n,"cause",{configurable:!0,value:u(r[5],t+1),writable:!0}),n}case"bytes":{const a=j(r[2]),e=r[3]??"Uint8Array";if(e==="ArrayBuffer")return a.buffer.byteLength===a.byteLength?a.buffer:a.slice().buffer;const o=Object.hasOwn($,e)?$[e]:void 0;return o?new o(a.slice().buffer):a}case"inf":return 1/0;case"nan":return Number.NaN;case"undefined":return;default:return r.map(a=>u(a,t+1))}return r.map(a=>u(a,t+1))}const l=r,d={};for(const a of Object.keys(l)){const e=u(l[a],t+1);a===A?Object.defineProperty(d,a,{configurable:!0,enumerable:!0,value:e,writable:!0}):d[a]=e}return d},I=r=>{if(typeof r=="string")return r;const t=r?.__lunoraRef;if(typeof t!="string"||t.length===0)throw new b("INTERNAL","createShardClient: expected a generated function reference (api.*/internal.*) or a 'namespace:fn' string");return t},U=r=>{const t=new b(r.code,r.message);return r.data!==void 0&&(t.data=u(r.data)),t},L=(r,t={})=>{const l=N(r,t.jurisdiction),d=t.system??!0,a=e=>L(r,{...t,...e});return{as:e=>a({as:e}),asSystem:()=>a({as:void 0}),call:async(e,o,n)=>{const s=I(e),c=n?.shardKey??t.shardKey;if(c===void 0||c.length===0)throw new b("INTERNAL",`createShardClient: no shard key for "${s}" — pass one to createShardClient({ shardKey }), .forShard(key), or the call's options`);const p={"content-type":"application/json"};d&&(p["x-lunora-system"]="1"),t.as&&(p["x-lunora-userid"]=E(t.as.userId),t.as.claims&&(p["x-lunora-identity"]=O(t.as.claims))),n?.mutationId!==void 0&&n.mutationId.length>0&&(p["x-lunora-mutation-id"]=n.mutationId);const y=await R(l,c).fetch(new Request("https://shard.internal/rpc",{body:JSON.stringify({args:f(o??{}),functionPath:s}),headers:p,method:"POST"}));let h;try{h=await y.json()}catch{const w=y.statusText?` ${y.statusText}`:"";throw new b("INTERNAL",`createShardClient: shard response for "${s}" was not JSON (status ${String(y.status)}${w})`)}if("error"in h)throw U(h.error);if(!y.ok){const w=y.statusText?` ${y.statusText}`:"";throw new b("INTERNAL",`createShardClient: shard call "${s}" failed (status ${String(y.status)}${w})`)}return u(h.result)},forShard:e=>a({shardKey:e})}};export{L as createShardClient};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/runtime",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.53",
|
|
4
4
|
"description": "Lunora Worker runtime: the RPC router, shard resolver, and query coordinator",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
"access": "public"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@lunora/bindings": "1.0.0-alpha.
|
|
50
|
-
"@lunora/errors": "1.0.0-alpha.
|
|
51
|
-
"@lunora/platform": "1.0.0-alpha.
|
|
49
|
+
"@lunora/bindings": "1.0.0-alpha.20",
|
|
50
|
+
"@lunora/errors": "1.0.0-alpha.14",
|
|
51
|
+
"@lunora/platform": "1.0.0-alpha.6"
|
|
52
52
|
},
|
|
53
53
|
"engines": {
|
|
54
54
|
"node": "^22.15.0 || >=24.11.0"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{LunoraError as p}from"@lunora/errors";import{a as m,o as E,f as O,u as j}from"./identity-header-CDgIrYAz.mjs";import{applyJurisdiction as N,resolveShard as R}from"./applyJurisdiction-8bzZjAPR.mjs";const s="$lunora.wire$",w=64,A=1024,v="__proto__",$={BigInt64Array,BigUint64Array,Float32Array,Float64Array,Int8Array,Int16Array,Int32Array,Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array},S={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError},f=(e,n=0)=>{if(n>w)throw new RangeError(`wire-codec: value nesting exceeds the ${w}-level limit`);if(e===void 0)return[s,"undefined"];if(e===null)return null;const l=typeof e;if(l==="bigint")return[s,"bigint",e.toString()];if(l==="number"){const t=e;return Number.isNaN(t)?[s,"nan"]:t===1/0?[s,"inf"]:t===-1/0?[s,"-inf"]:t}if(l!=="object")return e;if(e instanceof Date)return[s,"date",f(e.getTime(),n+1)];if(e instanceof Error){const t=e,a={};for(const u of Object.keys(t))t[u]!==void 0&&(a[u]=f(t[u],n+1));const i=[s,"error",t.name,t.message,a];return t.cause!==void 0&&i.push(f(t.cause,n+1)),i}if(e instanceof URL)return[s,"url",e.href];if(e instanceof Map)return[s,"map",[...e.entries()].map(([t,a])=>[f(t,n+1),f(a,n+1)])];if(e instanceof Set)return[s,"set",[...e].map(t=>f(t,n+1))];if(e instanceof ArrayBuffer)return[s,"bytes",m(new Uint8Array(e)),"ArrayBuffer"];if(ArrayBuffer.isView(e)){const t=e,a=t.constructor.name,i=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);return a==="Uint8Array"?[s,"bytes",m(i)]:[s,"bytes",m(i),a]}if(Array.isArray(e)){const t=e.map(a=>f(a,n+1));return t.length>0&&t[0]===s?[s,"arr",t]:t}const d=Object.getPrototypeOf(e);if(d!==null&&d!==Object.prototype){const t=e.constructor?.name??"value";throw new TypeError(`wire-codec: cannot encode a ${t} over the Lunora wire — only plain objects, arrays, and the supported built-ins (Date, Error, URL, Map, Set, ArrayBuffer/typed arrays, bigint) round-trip`)}const r=e,o={};for(const t of Object.keys(r)){const a=r[t];a!==void 0&&(o[t]=f(a,n+1))}return o},c=(e,n=0)=>{if(n>w)throw new RangeError(`wire-codec: value nesting exceeds the ${w}-level limit`);if(e===null||typeof e!="object")return e;if(Array.isArray(e)){if(e[0]===s)switch(e[1]){case"-inf":return-1/0;case"arr":return e[2].map(r=>c(r,n+1));case"bigint":{const r=e[2];if(typeof r!="string"||r.length>A||!/^-?\d+$/.test(r))throw new RangeError(`wire-codec: invalid or over-long bigint (max ${A} digits)`);return BigInt(r)}case"date":return new Date(c(e[2],n+1));case"map":return new Map(e[2].map(([r,o])=>[c(r,n+1),c(o,n+1)]));case"set":return new Set(e[2].map(r=>c(r,n+1)));case"url":return new URL(e[2]);case"error":{const r=e[2],o=e[3],t=(Object.hasOwn(S,r)?S[r]:void 0)??Error,a=new t(o);a.name!==r&&Object.defineProperty(a,"name",{configurable:!0,value:r,writable:!0});const i=c(e[4],n+1);for(const u of Object.keys(i))u===v?Object.defineProperty(a,u,{configurable:!0,enumerable:!0,value:i[u],writable:!0}):a[u]=i[u];return e.length>5&&Object.defineProperty(a,"cause",{configurable:!0,value:c(e[5],n+1),writable:!0}),a}case"bytes":{const r=E(e[2]),o=e[3]??"Uint8Array";if(o==="ArrayBuffer")return r.buffer.byteLength===r.byteLength?r.buffer:r.slice().buffer;const t=Object.hasOwn($,o)?$[o]:void 0;return t?new t(r.slice().buffer):r}case"inf":return 1/0;case"nan":return Number.NaN;case"undefined":return;default:return e.map(r=>c(r,n+1))}return e.map(r=>c(r,n+1))}const l=e,d={};for(const r of Object.keys(l)){const o=c(l[r],n+1);r===v?Object.defineProperty(d,r,{configurable:!0,enumerable:!0,value:o,writable:!0}):d[r]=o}return d},x=e=>{if(typeof e=="string")return e;const n=e?.__lunoraRef;if(typeof n!="string"||n.length===0)throw new p("INTERNAL","createShardClient: expected a generated function reference (api.*/internal.*) or a 'namespace:fn' string");return n},I=e=>{const n=new p(e.code,e.message);return e.data!==void 0&&(n.data=c(e.data)),n},U=(e,n={})=>{const l=N(e,n.jurisdiction),d=n.system??!0,r=o=>U(e,{...n,...o});return{as:o=>r({as:o}),asSystem:()=>r({as:void 0}),call:async(o,t,a)=>{const i=x(o),u=a?.shardKey??n.shardKey;if(u===void 0||u.length===0)throw new p("INTERNAL",`createShardClient: no shard key for "${i}" — pass one to createShardClient({ shardKey }), .forShard(key), or the call's options`);const h={"content-type":"application/json"};d&&(h["x-lunora-system"]="1"),n.as&&(h["x-lunora-userid"]=O(n.as.userId),n.as.claims&&(h["x-lunora-identity"]=j(n.as.claims))),a?.mutationId!==void 0&&a.mutationId.length>0&&(h["x-lunora-mutation-id"]=a.mutationId);const y=await R(l,u).fetch(new Request("https://shard.internal/rpc",{body:JSON.stringify({args:f(t??{}),functionPath:i}),headers:h,method:"POST"}));let b;try{b=await y.json()}catch{const g=y.statusText?` ${y.statusText}`:"";throw new p("INTERNAL",`createShardClient: shard response for "${i}" was not JSON (status ${String(y.status)}${g})`)}if("error"in b)throw I(b.error);if(!y.ok){const g=y.statusText?` ${y.statusText}`:"";throw new p("INTERNAL",`createShardClient: shard call "${i}" failed (status ${String(y.status)}${g})`)}return c(b.result)},forShard:o=>r({shardKey:o})}};export{U as createShardClient};
|