@lunora/runtime 1.0.0-alpha.20 → 1.0.0-alpha.21
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
CHANGED
|
@@ -86,6 +86,23 @@ export { ShardDO };
|
|
|
86
86
|
|
|
87
87
|
> This README covers the basics. For the full API, options, and guides, see the **[documentation](https://lunora.sh/docs/packages/runtime)**.
|
|
88
88
|
|
|
89
|
+
### Workers Cache
|
|
90
|
+
|
|
91
|
+
When `cache: { enabled: true }` is present in `wrangler.jsonc` and `compatibility_date >= "2026-05-01"`, the runtime forwards the Worker's `ExecutionContext.cache` into action handlers as `ctx.cache`. This lets you purge cache by tag from HTTP action handlers:
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
export const refreshProducts = action.action(async ({ ctx }) => {
|
|
95
|
+
if (!ctx.cache) {
|
|
96
|
+
throw new Error("Workers Cache is not enabled in wrangler.jsonc");
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
await ctx.cache.purge({ tags: ["products"] });
|
|
100
|
+
return { ok: true };
|
|
101
|
+
});
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
The `ctx.cache` binding is only available in **action** handlers (not query/mutation), because actions run in the Worker while queries/mutations run inside the Durable Object. Cache header declarations on `httpRoute` (`.cacheControl()`, `.cacheTag()`, `.vary()`) are attached by `@lunora/server` before the response leaves the handler.
|
|
105
|
+
|
|
89
106
|
## Related
|
|
90
107
|
|
|
91
108
|
- [`@lunora/do`](https://www.npmjs.com/package/@lunora/do) — the `ShardDO` / `SessionDO` Durable Objects this runtime routes to.
|
package/dist/index.d.mts
CHANGED
|
@@ -134,6 +134,12 @@ declare const toAirbyteMessages: (page: ConnectorSyncPage, emittedAt?: number) =
|
|
|
134
134
|
* fall back to {@link NOOP_EXECUTION_CONTEXT}.
|
|
135
135
|
*/
|
|
136
136
|
interface ExecutionContextLike {
|
|
137
|
+
cache?: {
|
|
138
|
+
purge: (options: {
|
|
139
|
+
purgeEverything?: boolean;
|
|
140
|
+
tags?: string[];
|
|
141
|
+
}) => Promise<unknown>;
|
|
142
|
+
};
|
|
137
143
|
passThroughOnException?: () => void;
|
|
138
144
|
waitUntil?: (promise: Promise<unknown>) => void;
|
|
139
145
|
}
|
|
@@ -1500,6 +1506,12 @@ interface HttpActionContext {
|
|
|
1500
1506
|
getIdentity: () => Promise<Record<string, unknown> | null>;
|
|
1501
1507
|
userId: null | string;
|
|
1502
1508
|
};
|
|
1509
|
+
cache?: {
|
|
1510
|
+
purge: (options: {
|
|
1511
|
+
purgeEverything?: boolean;
|
|
1512
|
+
tags?: string[];
|
|
1513
|
+
}) => Promise<unknown>;
|
|
1514
|
+
};
|
|
1503
1515
|
fetch: typeof globalThis.fetch;
|
|
1504
1516
|
runAction: <R>(reference: unknown, args?: Record<string, unknown>) => Promise<R>;
|
|
1505
1517
|
runMutation: <R>(reference: unknown, args?: Record<string, unknown>) => Promise<R>;
|
package/dist/index.d.ts
CHANGED
|
@@ -134,6 +134,12 @@ declare const toAirbyteMessages: (page: ConnectorSyncPage, emittedAt?: number) =
|
|
|
134
134
|
* fall back to {@link NOOP_EXECUTION_CONTEXT}.
|
|
135
135
|
*/
|
|
136
136
|
interface ExecutionContextLike {
|
|
137
|
+
cache?: {
|
|
138
|
+
purge: (options: {
|
|
139
|
+
purgeEverything?: boolean;
|
|
140
|
+
tags?: string[];
|
|
141
|
+
}) => Promise<unknown>;
|
|
142
|
+
};
|
|
137
143
|
passThroughOnException?: () => void;
|
|
138
144
|
waitUntil?: (promise: Promise<unknown>) => void;
|
|
139
145
|
}
|
|
@@ -1500,6 +1506,12 @@ interface HttpActionContext {
|
|
|
1500
1506
|
getIdentity: () => Promise<Record<string, unknown> | null>;
|
|
1501
1507
|
userId: null | string;
|
|
1502
1508
|
};
|
|
1509
|
+
cache?: {
|
|
1510
|
+
purge: (options: {
|
|
1511
|
+
purgeEverything?: boolean;
|
|
1512
|
+
tags?: string[];
|
|
1513
|
+
}) => Promise<unknown>;
|
|
1514
|
+
};
|
|
1503
1515
|
fetch: typeof globalThis.fetch;
|
|
1504
1516
|
runAction: <R>(reference: unknown, args?: Record<string, unknown>) => Promise<R>;
|
|
1505
1517
|
runMutation: <R>(reference: unknown, args?: Record<string, unknown>) => Promise<R>;
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { toAirbyteMessages, toFivetranResponse } from './packem_shared/toAirbyteMessages-DrHdplb4.mjs';
|
|
2
|
-
export { composeWorker, createLunoraHandler, createWorker, defineRpcEnvelope, resolveLunoraOptions, withFrameworkWorker } from './packem_shared/composeWorker-
|
|
2
|
+
export { composeWorker, createLunoraHandler, createWorker, defineRpcEnvelope, resolveLunoraOptions, withFrameworkWorker } from './packem_shared/composeWorker-Dpw9d1s5.mjs';
|
|
3
3
|
export { createCrossShardRelationCapabilities } from './packem_shared/createCrossShardRelationCapabilities-CbcWjkAn.mjs';
|
|
4
4
|
export { DEFAULT_REGISTRY_CACHE_TTL_MS, SHARD_REGISTRY_DO_NAME, createDynamicShardRegistry } from './packem_shared/DEFAULT_REGISTRY_CACHE_TTL_MS-B3pA7aXp.mjs';
|
|
5
5
|
export { LunoraError, toErrorResponse } from './packem_shared/LunoraError-Bpb9EFJ3.mjs';
|
|
@@ -2434,7 +2434,7 @@ const createWorker = (options) => {
|
|
|
2434
2434
|
queryParameter,
|
|
2435
2435
|
requireAdminOption
|
|
2436
2436
|
});
|
|
2437
|
-
const buildHttpActionContext = async (request, env) => {
|
|
2437
|
+
const buildHttpActionContext = async (request, env, context) => {
|
|
2438
2438
|
const { claims, headers, userId } = await resolveForwardContext(request, env, publicResolveIdentity);
|
|
2439
2439
|
const run = async (reference, args = {}) => {
|
|
2440
2440
|
const functionPath = reference.__lunoraRef;
|
|
@@ -2461,6 +2461,7 @@ const createWorker = (options) => {
|
|
|
2461
2461
|
getIdentity: () => Promise.resolve(claims),
|
|
2462
2462
|
userId
|
|
2463
2463
|
},
|
|
2464
|
+
cache: context.cache,
|
|
2464
2465
|
fetch: globalThis.fetch.bind(globalThis),
|
|
2465
2466
|
runAction: run,
|
|
2466
2467
|
runMutation: run,
|
|
@@ -2471,7 +2472,7 @@ const createWorker = (options) => {
|
|
|
2471
2472
|
if (!options.httpRouter) {
|
|
2472
2473
|
return void 0;
|
|
2473
2474
|
}
|
|
2474
|
-
const httpContext = await buildHttpActionContext(request, env);
|
|
2475
|
+
const httpContext = await buildHttpActionContext(request, env, context);
|
|
2475
2476
|
try {
|
|
2476
2477
|
return await options.httpRouter.fetch(request, { ...env, __lunoraCtx: httpContext }, context);
|
|
2477
2478
|
} catch (error) {
|