@rexezuge/runtime 1.6.0 → 1.7.0
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 +21 -1
- package/dist/base/AbstractDurableObjectWorker.d.ts +6 -0
- package/dist/base/AbstractDurableObjectWorker.d.ts.map +1 -1
- package/dist/base/AbstractDurableObjectWorker.js +1 -1
- package/dist/base/AbstractDurableObjectWorker.js.map +3 -3
- package/dist/base/AbstractEntrypointWorker.d.ts +10 -0
- package/dist/base/AbstractEntrypointWorker.d.ts.map +1 -1
- package/dist/base/AbstractEntrypointWorker.js +1 -1
- package/dist/base/AbstractEntrypointWorker.js.map +3 -3
- package/dist/base/AbstractQueueWorker.d.ts +21 -10
- package/dist/base/AbstractQueueWorker.d.ts.map +1 -1
- package/dist/base/AbstractQueueWorker.js +1 -1
- package/dist/base/AbstractQueueWorker.js.map +3 -3
- package/dist/base/AbstractWorkflowWorker.d.ts +23 -16
- package/dist/base/AbstractWorkflowWorker.d.ts.map +1 -1
- package/dist/base/AbstractWorkflowWorker.js +1 -1
- package/dist/base/AbstractWorkflowWorker.js.map +3 -3
- package/dist/base/baseWorkerError.d.ts +34 -0
- package/dist/base/baseWorkerError.d.ts.map +1 -0
- package/dist/base/baseWorkerError.js +1 -0
- package/dist/base/baseWorkerError.js.map +7 -0
- package/dist/base/index.d.ts +2 -2
- package/dist/base/index.d.ts.map +1 -1
- package/dist/base/index.js +1 -1
- package/dist/base/index.js.map +3 -3
- package/dist/config/EnvParser.d.ts +15 -0
- package/dist/config/EnvParser.d.ts.map +1 -1
- package/dist/config/EnvParser.js +1 -1
- package/dist/config/EnvParser.js.map +2 -2
- package/dist/di/RequestScope.d.ts +25 -1
- package/dist/di/RequestScope.d.ts.map +1 -1
- package/dist/di/RequestScope.js +1 -1
- package/dist/di/RequestScope.js.map +3 -3
- package/dist/index.d.ts +6 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +3 -3
- package/dist/kv/KvCache.d.ts +86 -12
- package/dist/kv/KvCache.d.ts.map +1 -1
- package/dist/kv/KvCache.js +1 -1
- package/dist/kv/KvCache.js.map +3 -3
- package/dist/kv/KvDomains.d.ts +49 -5
- package/dist/kv/KvDomains.d.ts.map +1 -1
- package/dist/kv/KvDomains.js +1 -1
- package/dist/kv/KvDomains.js.map +3 -3
- package/dist/kv/SubrequestMeterLike.d.ts +26 -0
- package/dist/kv/SubrequestMeterLike.d.ts.map +1 -0
- package/dist/kv/SubrequestMeterLike.js +1 -0
- package/dist/kv/SubrequestMeterLike.js.map +7 -0
- package/dist/kv/index.d.ts +5 -3
- package/dist/kv/index.d.ts.map +1 -1
- package/dist/kv/index.js +1 -1
- package/dist/kv/index.js.map +3 -3
- package/dist/logger.d.ts +34 -5
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +1 -1
- package/dist/logger.js.map +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -37,7 +37,7 @@ import { AppConfiguration, EnvParser } from '@rexezuge/runtime';
|
|
|
37
37
|
|
|
38
38
|
class MyConfig extends AppConfiguration {
|
|
39
39
|
public getPageSize(): number {
|
|
40
|
-
return EnvParser.
|
|
40
|
+
return EnvParser.positiveInt(this.raw(), 'PAGE_SIZE', '50');
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
|
|
@@ -58,6 +58,26 @@ for (const warning of config.validate()) console.warn(warning); // warnings, nev
|
|
|
58
58
|
|
|
59
59
|
`fetch()` / `scheduled()` log-and-contain: an unhandled throw is a 500 response or a logged cron failure, never a platform crash. There is deliberately no `/__scheduled` HTTP branch — cron runs through the wrangler `triggers.crons` binding. The structural `WorkerExecutionContext` / `WorkerScheduledController` types mean this package typechecks without `@cloudflare/workers-types`.
|
|
60
60
|
|
|
61
|
+
`AbstractQueueWorker` and `AbstractWorkflowWorker` use the platform's own `MessageBatch` / `WorkflowEntrypoint` types rather than structural stand-ins, so a handler gets `batch.queue`, `message.ack()` / `retry()`, `this.env` and three-argument `step.do(name, { retries, timeout }, fn)` without a cast. Pass your platform batch as the type parameter:
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
class DispatcherWorker extends AbstractQueueWorker<MessageBatch<EmailQueueMessage>> {
|
|
65
|
+
protected async onQueue(batch: MessageBatch<EmailQueueMessage>): Promise<void> {
|
|
66
|
+
for (const message of batch.messages) message.ack();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
**Redacting the error log.** Every base's catch reports through a `reportUnhandled(message, error)` hook that defaults to `console.error`. That default hands the caught value to the log verbatim, which is only safe when nothing in the call path can carry a secret. Override it where that is not true — the message stays a literal from `BASE_WORKER_MESSAGES`, so the override never has to interpolate untrusted text into a log line:
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
class TokenRefresher extends AbstractDurableObjectWorker<Env> {
|
|
75
|
+
protected override reportUnhandled(message: string, error: unknown): void {
|
|
76
|
+
logTokenAdjacentError('error', message); // never interpolates `error`
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
61
81
|
## 4. Logger and KV cache
|
|
62
82
|
|
|
63
83
|
```ts
|
|
@@ -15,6 +15,12 @@ import { DurableObject } from 'cloudflare:workers';
|
|
|
15
15
|
*/
|
|
16
16
|
declare abstract class AbstractDurableObjectWorker<TEnv = Env> extends DurableObject<TEnv> {
|
|
17
17
|
fetch(request: Request): Promise<Response>;
|
|
18
|
+
/**
|
|
19
|
+
* The sink for an unhandled rejection at this base's boundary. See
|
|
20
|
+
* `AbstractEntrypointWorker.reportUnhandled` — the base owns the static
|
|
21
|
+
* message, the consumer owns whether the caught value may be logged as-is.
|
|
22
|
+
*/
|
|
23
|
+
protected reportUnhandled(message: string, error: unknown): void;
|
|
18
24
|
/**
|
|
19
25
|
* The platform `ExecutionContext` shape, forwards `waitUntil` into the DO's
|
|
20
26
|
* own `ctx` so a handler can keep a task alive past the response.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractDurableObjectWorker.d.ts","sourceRoot":"","sources":["../../src/base/AbstractDurableObjectWorker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"AbstractDurableObjectWorker.d.ts","sourceRoot":"","sources":["../../src/base/AbstractDurableObjectWorker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD;;;;;;;;;;;;;GAaG;AACH,uBAAe,2BAA2B,CAAC,IAAI,GAAG,GAAG,CAAE,SAAQ,aAAa,CAAC,IAAI,CAAC;IACnE,KAAK,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;IASvD;;;;OAIG;IACH,SAAS,CAAC,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;IAIhE;;;OAGG;IACH,SAAS,CAAC,sBAAsB,IAAI,gBAAgB;IAOpD,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;CAClE;AAED,OAAO,EAAE,2BAA2B,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var o=Object.defineProperty;var
|
|
1
|
+
var o=Object.defineProperty;var t=(n,r)=>o(n,"name",{value:r,configurable:!0});import{DurableObject as a}from"cloudflare:workers";import{BASE_WORKER_MESSAGES as s}from"./baseWorkerError.js";class c extends a{static{t(this,"AbstractDurableObjectWorker")}async fetch(r){try{return await this.onRequest(r)}catch(e){return this.reportUnhandled(s.durableObjectFetch,e),Response.json({error:"Internal Error"},{status:500})}}reportUnhandled(r,e){console.error(r,e)}createExecutionContext(){return{waitUntil:t(r=>this.ctx.waitUntil(r),"waitUntil"),passThroughOnException:t(()=>{},"passThroughOnException")}}}export{c as AbstractDurableObjectWorker};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/base/AbstractDurableObjectWorker.ts"],
|
|
4
|
-
"sourcesContent": ["import { DurableObject } from 'cloudflare:workers';\n\n/**\n * The Durable Object base: one `fetch` entry, error containment inside it.\n *\n * Converged from the `AbstractDurableObjectWorker` copies in AWS-AccessBridge,\n * CalDAV-Bridge, ChordDHT-Tracker, Edge-Git, Mail-Meow and Mail-Otter (the\n * union is exactly Mail-Meow's shape: the fetch wrapper plus\n * `createExecutionContext` for handlers that need to forward `waitUntil`).\n * Durable-DAV's DO writes more context per handler, but the *base* is the same.\n *\n * A DO has no routing layer, so an unhandled rejection here would surface as a\n * raw 500 with no JSON body and no log. The catch is the boundary: it logs the\n * sanitized error and answers `{ error: 'Internal Error' }` so a caller always\n * gets a parseable response.\n */\nabstract class AbstractDurableObjectWorker<TEnv = Env> extends DurableObject<TEnv> {\n public async fetch(request: Request): Promise<Response> {\n try {\n return await this.onRequest(request);\n } catch (err: unknown) {\n
|
|
5
|
-
"mappings": "+EAAA,OAAS,iBAAAA,MAAqB,
|
|
6
|
-
"names": ["DurableObject", "AbstractDurableObjectWorker", "__name", "request", "err", "promise"]
|
|
4
|
+
"sourcesContent": ["import { DurableObject } from 'cloudflare:workers';\nimport { BASE_WORKER_MESSAGES } from './baseWorkerError.ts';\n\n/**\n * The Durable Object base: one `fetch` entry, error containment inside it.\n *\n * Converged from the `AbstractDurableObjectWorker` copies in AWS-AccessBridge,\n * CalDAV-Bridge, ChordDHT-Tracker, Edge-Git, Mail-Meow and Mail-Otter (the\n * union is exactly Mail-Meow's shape: the fetch wrapper plus\n * `createExecutionContext` for handlers that need to forward `waitUntil`).\n * Durable-DAV's DO writes more context per handler, but the *base* is the same.\n *\n * A DO has no routing layer, so an unhandled rejection here would surface as a\n * raw 500 with no JSON body and no log. The catch is the boundary: it logs the\n * sanitized error and answers `{ error: 'Internal Error' }` so a caller always\n * gets a parseable response.\n */\nabstract class AbstractDurableObjectWorker<TEnv = Env> extends DurableObject<TEnv> {\n public async fetch(request: Request): Promise<Response> {\n try {\n return await this.onRequest(request);\n } catch (err: unknown) {\n this.reportUnhandled(BASE_WORKER_MESSAGES.durableObjectFetch, err);\n return Response.json({ error: 'Internal Error' }, { status: 500 });\n }\n }\n\n /**\n * The sink for an unhandled rejection at this base's boundary. See\n * `AbstractEntrypointWorker.reportUnhandled` — the base owns the static\n * message, the consumer owns whether the caught value may be logged as-is.\n */\n protected reportUnhandled(message: string, error: unknown): void {\n console.error(message, error);\n }\n\n /**\n * The platform `ExecutionContext` shape, forwards `waitUntil` into the DO's\n * own `ctx` so a handler can keep a task alive past the response.\n */\n protected createExecutionContext(): ExecutionContext {\n return {\n waitUntil: (promise: Promise<unknown>): void => this.ctx.waitUntil(promise),\n passThroughOnException: (): void => undefined,\n };\n }\n\n protected abstract onRequest(request: Request): Promise<Response>;\n}\n\nexport { AbstractDurableObjectWorker };\n"],
|
|
5
|
+
"mappings": "+EAAA,OAAS,iBAAAA,MAAqB,qBAC9B,OAAS,wBAAAC,MAA4B,uBAgBrC,MAAeC,UAAgDF,CAAmB,CAjBlF,MAiBkF,CAAAG,EAAA,oCACzE,MAAM,MAAMC,EAAgB,CACjC,GAAI,CACF,OAAO,MAAM,KAAK,UAAUA,CAAO,CACrC,OAASC,EAAc,CACrB,YAAK,gBAAgBJ,EAAqB,mBAAoBI,CAAG,EAC1D,SAAS,KAAK,CAAE,MAAO,gBAAgB,EAAI,CAAE,OAAQ,GAAG,CAAE,CACnE,CACF,CAOU,gBAAgBC,EAAiBC,EAAc,CACvD,QAAQ,MAAMD,EAASC,CAAK,CAC9B,CAMU,wBAAsB,CAC9B,MAAO,CACL,UAAWJ,EAACK,GAAoC,KAAK,IAAI,UAAUA,CAAO,EAA/D,aACX,uBAAwBL,EAAA,IAAS,GAAT,0BAE5B",
|
|
6
|
+
"names": ["DurableObject", "BASE_WORKER_MESSAGES", "AbstractDurableObjectWorker", "__name", "request", "err", "message", "error", "promise"]
|
|
7
7
|
}
|
|
@@ -32,6 +32,16 @@ declare abstract class AbstractEntrypointWorker {
|
|
|
32
32
|
*/
|
|
33
33
|
fetch(request: Request, env: Env, ctx: WorkerExecutionContext): Promise<Response>;
|
|
34
34
|
scheduled(event: WorkerScheduledController, env: Env, ctx: WorkerExecutionContext): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* The sink for an unhandled rejection at this base's boundaries.
|
|
37
|
+
*
|
|
38
|
+
* Overridable because the default hands the caught value to `console.error`
|
|
39
|
+
* verbatim, which is only safe when nothing in the call path can carry a
|
|
40
|
+
* secret. A consumer whose entrypoint can transitively carry one overrides
|
|
41
|
+
* this to a redacting sink, and keeps the static message as the argument, so
|
|
42
|
+
* the redaction decision stays in the consumer where the threat model lives.
|
|
43
|
+
*/
|
|
44
|
+
protected reportUnhandled(message: string, error: unknown): void;
|
|
35
45
|
protected abstract onRequest(request: Request, env: Env, ctx: WorkerExecutionContext): Promise<Response>;
|
|
36
46
|
protected abstract onScheduled(event: WorkerScheduledController, env: Env, ctx: WorkerExecutionContext): Promise<void>;
|
|
37
47
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractEntrypointWorker.d.ts","sourceRoot":"","sources":["../../src/base/AbstractEntrypointWorker.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AbstractEntrypointWorker.d.ts","sourceRoot":"","sources":["../../src/base/AbstractEntrypointWorker.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,UAAU,sBAAsB;IAC9B,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;IAC3C,sBAAsB,IAAI,IAAI,CAAC;CAChC;AAED,UAAU,yBAAyB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,uBAAe,wBAAwB;IACrC;;;;;;;;;;;;;OAaG;IACU,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,sBAAsB,GAAG,OAAO,CAAC,QAAQ,CAAC;IASjF,SAAS,CAAC,KAAK,EAAE,yBAAyB,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ9G;;;;;;;;OAQG;IACH,SAAS,CAAC,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;IAIhE,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,sBAAsB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAExG,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,KAAK,EAAE,yBAAyB,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;CACvH;AAED,OAAO,EAAE,wBAAwB,EAAE,CAAC;AACpC,YAAY,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var c=Object.defineProperty;var a=(s,r)=>c(s,"name",{value:r,configurable:!0});import{BASE_WORKER_MESSAGES as o}from"./baseWorkerError.js";class h{static{a(this,"AbstractEntrypointWorker")}async fetch(r,e,t){try{return await this.onRequest(r,e,t)}catch(n){return this.reportUnhandled(o.fetch,n),new Response("Internal Error",{status:500})}}async scheduled(r,e,t){try{await this.onScheduled(r,e,t)}catch(n){this.reportUnhandled(o.scheduled,n)}}reportUnhandled(r,e){console.error(r,e)}}export{h as AbstractEntrypointWorker};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/base/AbstractEntrypointWorker.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Minimal Workers-compatible context types so backend-runtime typechecks\n * without @cloudflare/workers-types. Apps pass the real ExecutionContext /\n * ScheduledController which satisfy these structurally.\n *\n * Converged verbatim from `backend-runtime/src/base/AbstractEntrypointWorker.ts`\n * (identical in all nine repos).\n */\ninterface WorkerExecutionContext {\n waitUntil(promise: Promise<unknown>): void;\n passThroughOnException(): void;\n}\n\ninterface WorkerScheduledController {\n cron: string;\n scheduledTime: number;\n noRetry(): void;\n}\n\nabstract class AbstractEntrypointWorker {\n /**\n * The HTTP request path.\n *\n * There is deliberately no `/__scheduled` branch here. It used to run before\n * `onRequest`, which made `GET /__scheduled` an unauthenticated, un-rated\n * trigger for the scheduled work: it bypassed the app's security headers, its\n * request scope, and its rate limits, and any caller could fire the cron\n * Durable Object on demand. `noRetry` was a `(): void => undefined` stub, so\n * the retry semantics were lost too.\n *\n * Nothing needed it — `scheduled()` is wired through the platform by the\n * `triggers.crons` entry in the wrangler config, which is how the cron\n * actually runs.\n */\n public async fetch(request: Request, env: Env, ctx: WorkerExecutionContext): Promise<Response> {\n try {\n return await this.onRequest(request, env, ctx);\n } catch (err: unknown) {\n
|
|
5
|
-
"mappings": "+
|
|
6
|
-
"names": ["AbstractEntrypointWorker", "__name", "request", "env", "ctx", "err", "event"]
|
|
4
|
+
"sourcesContent": ["import { BASE_WORKER_MESSAGES } from './baseWorkerError.ts';\n\n/**\n * Minimal Workers-compatible context types so backend-runtime typechecks\n * without @cloudflare/workers-types. Apps pass the real ExecutionContext /\n * ScheduledController which satisfy these structurally.\n *\n * Converged verbatim from `backend-runtime/src/base/AbstractEntrypointWorker.ts`\n * (identical in all nine repos).\n */\ninterface WorkerExecutionContext {\n waitUntil(promise: Promise<unknown>): void;\n passThroughOnException(): void;\n}\n\ninterface WorkerScheduledController {\n cron: string;\n scheduledTime: number;\n noRetry(): void;\n}\n\nabstract class AbstractEntrypointWorker {\n /**\n * The HTTP request path.\n *\n * There is deliberately no `/__scheduled` branch here. It used to run before\n * `onRequest`, which made `GET /__scheduled` an unauthenticated, un-rated\n * trigger for the scheduled work: it bypassed the app's security headers, its\n * request scope, and its rate limits, and any caller could fire the cron\n * Durable Object on demand. `noRetry` was a `(): void => undefined` stub, so\n * the retry semantics were lost too.\n *\n * Nothing needed it — `scheduled()` is wired through the platform by the\n * `triggers.crons` entry in the wrangler config, which is how the cron\n * actually runs.\n */\n public async fetch(request: Request, env: Env, ctx: WorkerExecutionContext): Promise<Response> {\n try {\n return await this.onRequest(request, env, ctx);\n } catch (err: unknown) {\n this.reportUnhandled(BASE_WORKER_MESSAGES.fetch, err);\n return new Response('Internal Error', { status: 500 });\n }\n }\n\n public async scheduled(event: WorkerScheduledController, env: Env, ctx: WorkerExecutionContext): Promise<void> {\n try {\n await this.onScheduled(event, env, ctx);\n } catch (err: unknown) {\n this.reportUnhandled(BASE_WORKER_MESSAGES.scheduled, err);\n }\n }\n\n /**\n * The sink for an unhandled rejection at this base's boundaries.\n *\n * Overridable because the default hands the caught value to `console.error`\n * verbatim, which is only safe when nothing in the call path can carry a\n * secret. A consumer whose entrypoint can transitively carry one overrides\n * this to a redacting sink, and keeps the static message as the argument, so\n * the redaction decision stays in the consumer where the threat model lives.\n */\n protected reportUnhandled(message: string, error: unknown): void {\n console.error(message, error);\n }\n\n protected abstract onRequest(request: Request, env: Env, ctx: WorkerExecutionContext): Promise<Response>;\n\n protected abstract onScheduled(event: WorkerScheduledController, env: Env, ctx: WorkerExecutionContext): Promise<void>;\n}\n\nexport { AbstractEntrypointWorker };\nexport type { WorkerExecutionContext, WorkerScheduledController };\n"],
|
|
5
|
+
"mappings": "+EAAA,OAAS,wBAAAA,MAA4B,uBAqBrC,MAAeC,CAAwB,CArBvC,MAqBuC,CAAAC,EAAA,iCAe9B,MAAM,MAAMC,EAAkBC,EAAUC,EAA2B,CACxE,GAAI,CACF,OAAO,MAAM,KAAK,UAAUF,EAASC,EAAKC,CAAG,CAC/C,OAASC,EAAc,CACrB,YAAK,gBAAgBN,EAAqB,MAAOM,CAAG,EAC7C,IAAI,SAAS,iBAAkB,CAAE,OAAQ,GAAG,CAAE,CACvD,CACF,CAEO,MAAM,UAAUC,EAAkCH,EAAUC,EAA2B,CAC5F,GAAI,CACF,MAAM,KAAK,YAAYE,EAAOH,EAAKC,CAAG,CACxC,OAASC,EAAc,CACrB,KAAK,gBAAgBN,EAAqB,UAAWM,CAAG,CAC1D,CACF,CAWU,gBAAgBE,EAAiBC,EAAc,CACvD,QAAQ,MAAMD,EAASC,CAAK,CAC9B",
|
|
6
|
+
"names": ["BASE_WORKER_MESSAGES", "AbstractEntrypointWorker", "__name", "request", "env", "ctx", "err", "event", "message", "error"]
|
|
7
7
|
}
|
|
@@ -1,20 +1,31 @@
|
|
|
1
1
|
import type { WorkerExecutionContext } from './AbstractEntrypointWorker.ts';
|
|
2
2
|
/**
|
|
3
|
-
* The queue consumer base, converged
|
|
4
|
-
*
|
|
5
|
-
* consumers).
|
|
3
|
+
* The queue consumer base, converged from the `AbstractQueueWorker` copies in
|
|
4
|
+
* Edge-Git and Mail-Otter (the only two repos with queue consumers).
|
|
6
5
|
*
|
|
7
6
|
* It rethrows after logging: a queue message that failed must be *retried* by
|
|
8
7
|
* the platform, and a base that swallowed the rejection would turn a transient
|
|
9
8
|
* handler failure into an acked, dropped message.
|
|
9
|
+
*
|
|
10
|
+
* **The batch is a type parameter, not a modelled shape.** This base never
|
|
11
|
+
* reads the batch — it forwards it — so declaring a structural stand-in for it
|
|
12
|
+
* bought nothing and cost correctness: the old `WorkerMessageBatch<T>` modelled
|
|
13
|
+
* `messages: T[]`, which is wrong twice over (the platform's elements are
|
|
14
|
+
* `Message<T>`, and a real batch also carries `queue`, `metadata`, `ackAll` and
|
|
15
|
+
* `retryAll`). A consumer subclassing against that type lost `batch.queue` and
|
|
16
|
+
* every `message.ack()`/`message.retry()`, and had to cast to get them back.
|
|
17
|
+
*
|
|
18
|
+
* Passing the platform `MessageBatch<Body>` as `TBatch` gives the handler the
|
|
19
|
+
* full surface with no cast and no duplication of the platform's own types.
|
|
10
20
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
21
|
+
declare abstract class AbstractQueueWorker<TBatch = unknown> {
|
|
22
|
+
queue(batch: TBatch, env: Env, ctx: WorkerExecutionContext): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* The sink for an unhandled rejection at this base's boundary. See
|
|
25
|
+
* `AbstractEntrypointWorker.reportUnhandled`.
|
|
26
|
+
*/
|
|
27
|
+
protected reportUnhandled(message: string, error: unknown): void;
|
|
28
|
+
protected abstract onQueue(batch: TBatch, env: Env, ctx: WorkerExecutionContext): Promise<void>;
|
|
17
29
|
}
|
|
18
30
|
export { AbstractQueueWorker };
|
|
19
|
-
export type { WorkerMessageBatch };
|
|
20
31
|
//# sourceMappingURL=AbstractQueueWorker.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractQueueWorker.d.ts","sourceRoot":"","sources":["../../src/base/AbstractQueueWorker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"AbstractQueueWorker.d.ts","sourceRoot":"","sources":["../../src/base/AbstractQueueWorker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAG5E;;;;;;;;;;;;;;;;;;GAkBG;AACH,uBAAe,mBAAmB,CAAC,MAAM,GAAG,OAAO;IACpC,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IASvF;;;OAGG;IACH,SAAS,CAAC,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;IAIhE,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;CAChG;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var n=Object.defineProperty;var a=(t,e)=>n(t,"name",{value:e,configurable:!0});import{BASE_WORKER_MESSAGES as s}from"./baseWorkerError.js";class c{static{a(this,"AbstractQueueWorker")}async queue(e,r,u){try{await this.onQueue(e,r,u)}catch(o){throw this.reportUnhandled(s.queue,o),o}}reportUnhandled(e,r){console.error(e,r)}}export{c as AbstractQueueWorker};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/base/AbstractQueueWorker.ts"],
|
|
4
|
-
"sourcesContent": ["import type { WorkerExecutionContext } from './AbstractEntrypointWorker.ts';\n\n/**\n * The queue consumer base, converged
|
|
5
|
-
"mappings": "+
|
|
6
|
-
"names": ["AbstractQueueWorker", "__name", "batch", "env", "ctx", "err"]
|
|
4
|
+
"sourcesContent": ["import type { WorkerExecutionContext } from './AbstractEntrypointWorker.ts';\nimport { BASE_WORKER_MESSAGES } from './baseWorkerError.ts';\n\n/**\n * The queue consumer base, converged from the `AbstractQueueWorker` copies in\n * Edge-Git and Mail-Otter (the only two repos with queue consumers).\n *\n * It rethrows after logging: a queue message that failed must be *retried* by\n * the platform, and a base that swallowed the rejection would turn a transient\n * handler failure into an acked, dropped message.\n *\n * **The batch is a type parameter, not a modelled shape.** This base never\n * reads the batch — it forwards it — so declaring a structural stand-in for it\n * bought nothing and cost correctness: the old `WorkerMessageBatch<T>` modelled\n * `messages: T[]`, which is wrong twice over (the platform's elements are\n * `Message<T>`, and a real batch also carries `queue`, `metadata`, `ackAll` and\n * `retryAll`). A consumer subclassing against that type lost `batch.queue` and\n * every `message.ack()`/`message.retry()`, and had to cast to get them back.\n *\n * Passing the platform `MessageBatch<Body>` as `TBatch` gives the handler the\n * full surface with no cast and no duplication of the platform's own types.\n */\nabstract class AbstractQueueWorker<TBatch = unknown> {\n public async queue(batch: TBatch, env: Env, ctx: WorkerExecutionContext): Promise<void> {\n try {\n await this.onQueue(batch, env, ctx);\n } catch (err: unknown) {\n this.reportUnhandled(BASE_WORKER_MESSAGES.queue, err);\n throw err;\n }\n }\n\n /**\n * The sink for an unhandled rejection at this base's boundary. See\n * `AbstractEntrypointWorker.reportUnhandled`.\n */\n protected reportUnhandled(message: string, error: unknown): void {\n console.error(message, error);\n }\n\n protected abstract onQueue(batch: TBatch, env: Env, ctx: WorkerExecutionContext): Promise<void>;\n}\n\nexport { AbstractQueueWorker };\n"],
|
|
5
|
+
"mappings": "+EACA,OAAS,wBAAAA,MAA4B,uBAqBrC,MAAeC,CAAmB,CArBlC,MAqBkC,CAAAC,EAAA,4BACzB,MAAM,MAAMC,EAAeC,EAAUC,EAA2B,CACrE,GAAI,CACF,MAAM,KAAK,QAAQF,EAAOC,EAAKC,CAAG,CACpC,OAASC,EAAc,CACrB,WAAK,gBAAgBN,EAAqB,MAAOM,CAAG,EAC9CA,CACR,CACF,CAMU,gBAAgBC,EAAiBC,EAAc,CACvD,QAAQ,MAAMD,EAASC,CAAK,CAC9B",
|
|
6
|
+
"names": ["BASE_WORKER_MESSAGES", "AbstractQueueWorker", "__name", "batch", "env", "ctx", "err", "message", "error"]
|
|
7
7
|
}
|
|
@@ -1,22 +1,29 @@
|
|
|
1
|
+
import { WorkflowEntrypoint } from 'cloudflare:workers';
|
|
2
|
+
import type { WorkflowEvent, WorkflowStep } from 'cloudflare:workers';
|
|
1
3
|
/**
|
|
2
|
-
* The Workflow base, converged
|
|
3
|
-
*
|
|
4
|
-
*
|
|
4
|
+
* The Workflow base, converged from the `AbstractWorkflowWorker` copies in
|
|
5
|
+
* Edge-Git and Mail-Otter (Edge-Sonic ships the same shape as `runWorkflow.ts`
|
|
6
|
+
* with a `WorkflowEntrypoint` wrapper around it).
|
|
5
7
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
8
|
+
* It extends the platform `WorkflowEntrypoint` because a workflow handler needs
|
|
9
|
+
* `this.env` — it is where the bindings come from, and every step in a real
|
|
10
|
+
* workflow builds a request scope from it. An earlier version of this file
|
|
11
|
+
* modelled `WorkflowEventLike`/`WorkflowStepLike` as standalone structural
|
|
12
|
+
* types and dropped the parent class, which removed `this.env` and reduced
|
|
13
|
+
* `step.do` to `(name, callback)`. That is not a stricter shape, it is a lossy
|
|
14
|
+
* one: it took away the per-step `retries`/`timeout` config that makes a step
|
|
15
|
+
* retryable under the platform rather than a bare coroutine call. Both are
|
|
16
|
+
* restored here, and the structural types are gone with them — the platform
|
|
17
|
+
* types are the ones that were correct all along.
|
|
9
18
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
protected abstract onWorkflow(event: Readonly<WorkflowEventLike<TPayload>>, step: WorkflowStepLike): Promise<TResult>;
|
|
19
|
+
declare abstract class AbstractWorkflowWorker<TEnv = Env, TPayload = unknown, TResult = unknown> extends WorkflowEntrypoint<TEnv, TPayload> {
|
|
20
|
+
run(event: Readonly<WorkflowEvent<TPayload>>, step: WorkflowStep): Promise<TResult>;
|
|
21
|
+
/**
|
|
22
|
+
* The sink for an unhandled rejection at this base's boundary. See
|
|
23
|
+
* `AbstractEntrypointWorker.reportUnhandled`.
|
|
24
|
+
*/
|
|
25
|
+
protected reportUnhandled(message: string, error: unknown): void;
|
|
26
|
+
protected abstract onWorkflow(event: Readonly<WorkflowEvent<TPayload>>, step: WorkflowStep): Promise<TResult>;
|
|
19
27
|
}
|
|
20
28
|
export { AbstractWorkflowWorker };
|
|
21
|
-
export type { WorkflowEventLike, WorkflowStepLike };
|
|
22
29
|
//# sourceMappingURL=AbstractWorkflowWorker.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractWorkflowWorker.d.ts","sourceRoot":"","sources":["../../src/base/AbstractWorkflowWorker.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"AbstractWorkflowWorker.d.ts","sourceRoot":"","sources":["../../src/base/AbstractWorkflowWorker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGtE;;;;;;;;;;;;;;;GAeG;AACH,uBAAe,sBAAsB,CAAC,IAAI,GAAG,GAAG,EAAE,QAAQ,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO,CAAE,SAAQ,kBAAkB,CAAC,IAAI,EAAE,QAAQ,CAAC;IACpH,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC;IAShG;;;OAGG;IACH,SAAS,CAAC,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;IAIhE,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,EAAE,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC;CAC9G;AAED,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var a=Object.defineProperty;var
|
|
1
|
+
var a=Object.defineProperty;var n=(t,r)=>a(t,"name",{value:r,configurable:!0});import{WorkflowEntrypoint as l}from"cloudflare:workers";import{BASE_WORKER_MESSAGES as s}from"./baseWorkerError.js";class w extends l{static{n(this,"AbstractWorkflowWorker")}async run(r,o){try{return await this.onWorkflow(r,o)}catch(e){throw this.reportUnhandled(s.workflow,e),e}}reportUnhandled(r,o){console.error(r,o)}}export{w as AbstractWorkflowWorker};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/base/AbstractWorkflowWorker.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * The Workflow base, converged
|
|
5
|
-
"mappings": "+
|
|
6
|
-
"names": ["AbstractWorkflowWorker", "__name", "event", "step", "err"]
|
|
4
|
+
"sourcesContent": ["import { WorkflowEntrypoint } from 'cloudflare:workers';\nimport type { WorkflowEvent, WorkflowStep } from 'cloudflare:workers';\nimport { BASE_WORKER_MESSAGES } from './baseWorkerError.ts';\n\n/**\n * The Workflow base, converged from the `AbstractWorkflowWorker` copies in\n * Edge-Git and Mail-Otter (Edge-Sonic ships the same shape as `runWorkflow.ts`\n * with a `WorkflowEntrypoint` wrapper around it).\n *\n * It extends the platform `WorkflowEntrypoint` because a workflow handler needs\n * `this.env` — it is where the bindings come from, and every step in a real\n * workflow builds a request scope from it. An earlier version of this file\n * modelled `WorkflowEventLike`/`WorkflowStepLike` as standalone structural\n * types and dropped the parent class, which removed `this.env` and reduced\n * `step.do` to `(name, callback)`. That is not a stricter shape, it is a lossy\n * one: it took away the per-step `retries`/`timeout` config that makes a step\n * retryable under the platform rather than a bare coroutine call. Both are\n * restored here, and the structural types are gone with them — the platform\n * types are the ones that were correct all along.\n */\nabstract class AbstractWorkflowWorker<TEnv = Env, TPayload = unknown, TResult = unknown> extends WorkflowEntrypoint<TEnv, TPayload> {\n public async run(event: Readonly<WorkflowEvent<TPayload>>, step: WorkflowStep): Promise<TResult> {\n try {\n return await this.onWorkflow(event, step);\n } catch (err: unknown) {\n this.reportUnhandled(BASE_WORKER_MESSAGES.workflow, err);\n throw err;\n }\n }\n\n /**\n * The sink for an unhandled rejection at this base's boundary. See\n * `AbstractEntrypointWorker.reportUnhandled`.\n */\n protected reportUnhandled(message: string, error: unknown): void {\n console.error(message, error);\n }\n\n protected abstract onWorkflow(event: Readonly<WorkflowEvent<TPayload>>, step: WorkflowStep): Promise<TResult>;\n}\n\nexport { AbstractWorkflowWorker };\n"],
|
|
5
|
+
"mappings": "+EAAA,OAAS,sBAAAA,MAA0B,qBAEnC,OAAS,wBAAAC,MAA4B,uBAkBrC,MAAeC,UAAkFF,CAAkC,CApBnI,MAoBmI,CAAAG,EAAA,+BAC1H,MAAM,IAAIC,EAA0CC,EAAkB,CAC3E,GAAI,CACF,OAAO,MAAM,KAAK,WAAWD,EAAOC,CAAI,CAC1C,OAASC,EAAc,CACrB,WAAK,gBAAgBL,EAAqB,SAAUK,CAAG,EACjDA,CACR,CACF,CAMU,gBAAgBC,EAAiBC,EAAc,CACvD,QAAQ,MAAMD,EAASC,CAAK,CAC9B",
|
|
6
|
+
"names": ["WorkflowEntrypoint", "BASE_WORKER_MESSAGES", "AbstractWorkflowWorker", "__name", "event", "step", "err", "message", "error"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The error-reporting seam shared by every worker base.
|
|
3
|
+
*
|
|
4
|
+
* Each base catches an unhandled rejection, reports it, and (for the
|
|
5
|
+
* request-shaped ones) answers 500. What it must *not* do is decide what the
|
|
6
|
+
* caught value is safe to write, because that is not the base's knowledge: the
|
|
7
|
+
* base cannot know whether the value transitively carries a credential, and
|
|
8
|
+
* every consumer's token-adjacent boundaries redact differently.
|
|
9
|
+
*
|
|
10
|
+
* So the base owns the message and the consumer owns the sink. `message` is
|
|
11
|
+
* always one of the literals in `BASE_WORKER_MESSAGES` — never an interpolated
|
|
12
|
+
* value — so an override can forward it without itself becoming a place where
|
|
13
|
+
* untrusted text reaches a log line.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Every boundary that reports an unhandled rejection.
|
|
17
|
+
*
|
|
18
|
+
* A member per base rather than a free-form string, because the message table
|
|
19
|
+
* is keyed on it: a base that grows a new entry point cannot pick a message the
|
|
20
|
+
* table does not have.
|
|
21
|
+
*/
|
|
22
|
+
type BaseWorkerOperation = 'fetch' | 'scheduled' | 'queue' | 'workflow' | 'durableObjectFetch';
|
|
23
|
+
/**
|
|
24
|
+
* Operator-facing text per boundary, in the shape a log line wants: a constant
|
|
25
|
+
* prefix, with the caught value following it.
|
|
26
|
+
*
|
|
27
|
+
* Static by construction. A base interpolating anything into these is the exact
|
|
28
|
+
* pattern consumer codebases are told to avoid, and it would be the kit
|
|
29
|
+
* introducing it.
|
|
30
|
+
*/
|
|
31
|
+
declare const BASE_WORKER_MESSAGES: Readonly<Record<BaseWorkerOperation, string>>;
|
|
32
|
+
export { BASE_WORKER_MESSAGES };
|
|
33
|
+
export type { BaseWorkerOperation };
|
|
34
|
+
//# sourceMappingURL=baseWorkerError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"baseWorkerError.d.ts","sourceRoot":"","sources":["../../src/base/baseWorkerError.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH;;;;;;GAMG;AACH,KAAK,mBAAmB,GAAG,OAAO,GAAG,WAAW,GAAG,OAAO,GAAG,UAAU,GAAG,oBAAoB,CAAC;AAE/F;;;;;;;GAOG;AACH,QAAA,MAAM,oBAAoB,EAAE,QAAQ,CAAC,MAAM,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAMvE,CAAC;AAEF,OAAO,EAAE,oBAAoB,EAAE,CAAC;AAChC,YAAY,EAAE,mBAAmB,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e={fetch:"Unhandled error in fetch():",scheduled:"Unhandled error in scheduled():",queue:"Unhandled error in queue():",workflow:"Unhandled error in workflow run():",durableObjectFetch:"Unhandled error in durable object fetch():"};export{e as BASE_WORKER_MESSAGES};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/base/baseWorkerError.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * The error-reporting seam shared by every worker base.\n *\n * Each base catches an unhandled rejection, reports it, and (for the\n * request-shaped ones) answers 500. What it must *not* do is decide what the\n * caught value is safe to write, because that is not the base's knowledge: the\n * base cannot know whether the value transitively carries a credential, and\n * every consumer's token-adjacent boundaries redact differently.\n *\n * So the base owns the message and the consumer owns the sink. `message` is\n * always one of the literals in `BASE_WORKER_MESSAGES` — never an interpolated\n * value — so an override can forward it without itself becoming a place where\n * untrusted text reaches a log line.\n */\n\n/**\n * Every boundary that reports an unhandled rejection.\n *\n * A member per base rather than a free-form string, because the message table\n * is keyed on it: a base that grows a new entry point cannot pick a message the\n * table does not have.\n */\ntype BaseWorkerOperation = 'fetch' | 'scheduled' | 'queue' | 'workflow' | 'durableObjectFetch';\n\n/**\n * Operator-facing text per boundary, in the shape a log line wants: a constant\n * prefix, with the caught value following it.\n *\n * Static by construction. A base interpolating anything into these is the exact\n * pattern consumer codebases are told to avoid, and it would be the kit\n * introducing it.\n */\nconst BASE_WORKER_MESSAGES: Readonly<Record<BaseWorkerOperation, string>> = {\n fetch: 'Unhandled error in fetch():',\n scheduled: 'Unhandled error in scheduled():',\n queue: 'Unhandled error in queue():',\n workflow: 'Unhandled error in workflow run():',\n durableObjectFetch: 'Unhandled error in durable object fetch():',\n};\n\nexport { BASE_WORKER_MESSAGES };\nexport type { BaseWorkerOperation };\n"],
|
|
5
|
+
"mappings": "AAgCA,MAAMA,EAAsE,CAC1E,MAAO,8BACP,UAAW,kCACX,MAAO,8BACP,SAAU,qCACV,mBAAoB",
|
|
6
|
+
"names": ["BASE_WORKER_MESSAGES"]
|
|
7
|
+
}
|
package/dist/base/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { AbstractEntrypointWorker } from './AbstractEntrypointWorker.ts';
|
|
|
2
2
|
export type { WorkerExecutionContext, WorkerScheduledController } from './AbstractEntrypointWorker.ts';
|
|
3
3
|
export { AbstractDurableObjectWorker } from './AbstractDurableObjectWorker.ts';
|
|
4
4
|
export { AbstractQueueWorker } from './AbstractQueueWorker.ts';
|
|
5
|
-
export type { WorkerMessageBatch } from './AbstractQueueWorker.ts';
|
|
6
5
|
export { AbstractWorkflowWorker } from './AbstractWorkflowWorker.ts';
|
|
7
|
-
export
|
|
6
|
+
export { BASE_WORKER_MESSAGES } from './baseWorkerError.ts';
|
|
7
|
+
export type { BaseWorkerOperation } from './baseWorkerError.ts';
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/base/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/base/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,YAAY,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AACvG,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/base/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,YAAY,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AACvG,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,YAAY,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/base/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AbstractEntrypointWorker as t}from"./AbstractEntrypointWorker.js";import{AbstractDurableObjectWorker as b}from"./AbstractDurableObjectWorker.js";import{AbstractQueueWorker as
|
|
1
|
+
import{AbstractEntrypointWorker as t}from"./AbstractEntrypointWorker.js";import{AbstractDurableObjectWorker as b}from"./AbstractDurableObjectWorker.js";import{AbstractQueueWorker as p}from"./AbstractQueueWorker.js";import{AbstractWorkflowWorker as W}from"./AbstractWorkflowWorker.js";import{BASE_WORKER_MESSAGES as c}from"./baseWorkerError.js";export{b as AbstractDurableObjectWorker,t as AbstractEntrypointWorker,p as AbstractQueueWorker,W as AbstractWorkflowWorker,c as BASE_WORKER_MESSAGES};
|
package/dist/base/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/base/index.ts"],
|
|
4
|
-
"sourcesContent": ["export { AbstractEntrypointWorker } from './AbstractEntrypointWorker.ts';\nexport type { WorkerExecutionContext, WorkerScheduledController } from './AbstractEntrypointWorker.ts';\nexport { AbstractDurableObjectWorker } from './AbstractDurableObjectWorker.ts';\nexport { AbstractQueueWorker } from './AbstractQueueWorker.ts';\nexport
|
|
5
|
-
"mappings": "AAAA,OAAS,4BAAAA,MAAgC,gCAEzC,OAAS,+BAAAC,MAAmC,mCAC5C,OAAS,uBAAAC,MAA2B,
|
|
6
|
-
"names": ["AbstractEntrypointWorker", "AbstractDurableObjectWorker", "AbstractQueueWorker", "AbstractWorkflowWorker"]
|
|
4
|
+
"sourcesContent": ["export { AbstractEntrypointWorker } from './AbstractEntrypointWorker.ts';\nexport type { WorkerExecutionContext, WorkerScheduledController } from './AbstractEntrypointWorker.ts';\nexport { AbstractDurableObjectWorker } from './AbstractDurableObjectWorker.ts';\nexport { AbstractQueueWorker } from './AbstractQueueWorker.ts';\nexport { AbstractWorkflowWorker } from './AbstractWorkflowWorker.ts';\nexport { BASE_WORKER_MESSAGES } from './baseWorkerError.ts';\nexport type { BaseWorkerOperation } from './baseWorkerError.ts';\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,4BAAAA,MAAgC,gCAEzC,OAAS,+BAAAC,MAAmC,mCAC5C,OAAS,uBAAAC,MAA2B,2BACpC,OAAS,0BAAAC,MAA8B,8BACvC,OAAS,wBAAAC,MAA4B",
|
|
6
|
+
"names": ["AbstractEntrypointWorker", "AbstractDurableObjectWorker", "AbstractQueueWorker", "AbstractWorkflowWorker", "BASE_WORKER_MESSAGES"]
|
|
7
7
|
}
|
|
@@ -31,9 +31,24 @@ declare class EnvParser {
|
|
|
31
31
|
* would appear to do nothing at all.
|
|
32
32
|
*/
|
|
33
33
|
static nonNegativeInt(env: unknown, key: string, defaultValue: string): number;
|
|
34
|
+
/**
|
|
35
|
+
* Whether an explicitly-set numeric var is a usable non-negative integer.
|
|
36
|
+
*
|
|
37
|
+
* The `nonNegativeInt` counterpart of {@link isValidPositiveInt}, for the same
|
|
38
|
+
* reason and with zero admitted. Two repos carried this and the kit did not,
|
|
39
|
+
* so a repo adopting it would have had to re-add it locally to keep its
|
|
40
|
+
* `validate()` checks whole.
|
|
41
|
+
*/
|
|
42
|
+
static isValidNonNegativeInt(env: unknown, key: string): boolean;
|
|
34
43
|
static boolean(env: unknown, key: string, defaultValue: string): boolean;
|
|
35
44
|
/**
|
|
36
45
|
The raw value, or undefined when unset. Public because presence checks (validate) need it.
|
|
46
|
+
|
|
47
|
+
Guards its input rather than casting it. `AppConfiguration` takes `env: unknown`
|
|
48
|
+
precisely so a caller can hand it whatever the platform produced, and the cast
|
|
49
|
+
this replaced threw a `TypeError` on `null`/`undefined` instead of answering
|
|
50
|
+
"unset" — so the one moment a config check needs to be most forgiving (a
|
|
51
|
+
binding missing entirely) was the one that could not be asked.
|
|
37
52
|
*/
|
|
38
53
|
static readString(env: unknown, key: string): string | undefined;
|
|
39
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnvParser.d.ts","sourceRoot":"","sources":["../../src/config/EnvParser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,cAAM,SAAS;WACC,WAAW,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM;IAMlF;;;;;;;OAOG;WACW,kBAAkB,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO;WAOtD,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM;IAI7E;;;;;;;OAOG;WACW,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM;
|
|
1
|
+
{"version":3,"file":"EnvParser.d.ts","sourceRoot":"","sources":["../../src/config/EnvParser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,cAAM,SAAS;WACC,WAAW,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM;IAMlF;;;;;;;OAOG;WACW,kBAAkB,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO;WAOtD,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM;IAI7E;;;;;;;OAOG;WACW,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM;IAMrF;;;;;;;OAOG;WACW,qBAAqB,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO;WAOzD,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO;IAI/E;;;;;;;;MAQE;WACY,UAAU,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;CAKxE;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
package/dist/config/EnvParser.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var u=Object.defineProperty;var a=(s,t)=>u(s,"name",{value:t,configurable:!0});class
|
|
1
|
+
var u=Object.defineProperty;var a=(s,t)=>u(s,"name",{value:t,configurable:!0});class d{static{a(this,"EnvParser")}static positiveInt(t,r,e){const n=this.readString(t,r),i=Number(n??e);return Number.isSafeInteger(i)&&i>0?i:Number(e)}static isValidPositiveInt(t,r){const e=this.readString(t,r);if(e===void 0)return!0;const n=Number(e);return Number.isSafeInteger(n)&&n>0}static string(t,r,e){return this.readString(t,r)??e}static nonNegativeInt(t,r,e){const n=this.readString(t,r),i=Number(n??e);return Number.isSafeInteger(i)&&i>=0?i:Number(e)}static isValidNonNegativeInt(t,r){const e=this.readString(t,r);if(e===void 0)return!0;const n=Number(e);return Number.isSafeInteger(n)&&n>=0}static boolean(t,r,e){return(this.readString(t,r)??e)==="true"}static readString(t,r){if(t===null||typeof t!="object")return;const e=t[r];return typeof e=="string"?e:void 0}}export{d as EnvParser};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/config/EnvParser.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Typed readers for a Worker `env` binding.\n *\n * Converged from `backend-runtime/src/config/EnvParser.ts` — effectively\n * identical in all six repos that have the file (Mail-Meow/CalDAV-Bridge call\n * their copy `ConfigurationManager` with the same three readers).\n *\n * The var table is `Record<string, string | undefined>` by contract: Cloudflare\n * passes every binding as a string, so a reader that returned `number` for\n * `MAX_*` would be inventing a parse that never happened. `boolean` is\n * presence-of-\"true\", and anything else is `false` — never \"absent means true\".\n */\nclass EnvParser {\n public static positiveInt(env: unknown, key: string, defaultValue: string): number {\n const value = this.readString(env, key);\n const parsed = Number(value ?? defaultValue);\n return Number.isSafeInteger(parsed) && parsed > 0 ? parsed : Number(defaultValue);\n }\n\n /**\n * Whether an explicitly-set numeric var is a usable positive integer.\n *\n * Used by `AppConfiguration.validate()` to *report* misconfiguration at\n * startup while still running with the default. The throwing counterpart\n * (`strictPositiveInt`) is gone: no caller opted in, and a fail-fast parse on\n * a request path would turn a config typo into a 500 rather than a warning.\n */\n public static isValidPositiveInt(env: unknown, key: string): boolean {\n const value = this.readString(env, key);\n if (value === undefined) return true;\n const parsed = Number(value);\n return Number.isSafeInteger(parsed) && parsed > 0;\n }\n\n public static string(env: unknown, key: string, defaultValue: string): string {\n return this.readString(env, key) ?? defaultValue;\n }\n\n /**\n * A non-negative integer, zero included.\n *\n * Distinct from `positiveInt` because zero is a meaningful configuration for\n * retention and quota knobs (\"keep nothing\"), and a parser that rejected it\n * would silently substitute the default — so setting `0` in the dashboard\n * would appear to do nothing at all.\n */\n public static nonNegativeInt(env: unknown, key: string, defaultValue: string): number {\n const value = this.readString(env, key);\n const parsed = Number(value ?? defaultValue);\n return Number.isSafeInteger(parsed) && parsed >= 0 ? parsed : Number(defaultValue);\n }\n\n public static boolean(env: unknown, key: string, defaultValue: string): boolean {\n return (this.readString(env, key) ?? defaultValue) === 'true';\n }\n\n /**\n The raw value, or undefined when unset. Public because presence checks (validate) need it.\n */\n public static readString(env: unknown, key: string): string | undefined {\n return (env as Record<string,
|
|
5
|
-
"mappings": "+EAYA,MAAMA,CAAS,CAZf,MAYe,CAAAC,EAAA,kBACN,OAAO,YAAYC,EAAcC,EAAaC,EAAoB,CACvE,MAAMC,EAAQ,KAAK,WAAWH,EAAKC,CAAG,EAChCG,EAAS,OAAOD,GAASD,CAAY,EAC3C,OAAO,OAAO,cAAcE,CAAM,GAAKA,EAAS,EAAIA,EAAS,OAAOF,CAAY,CAClF,CAUO,OAAO,mBAAmBF,EAAcC,EAAW,CACxD,MAAME,EAAQ,KAAK,WAAWH,EAAKC,CAAG,EACtC,GAAIE,IAAU,OAAW,MAAO,GAChC,MAAMC,EAAS,OAAOD,CAAK,EAC3B,OAAO,OAAO,cAAcC,CAAM,GAAKA,EAAS,CAClD,CAEO,OAAO,OAAOJ,EAAcC,EAAaC,EAAoB,CAClE,OAAO,KAAK,WAAWF,EAAKC,CAAG,GAAKC,CACtC,CAUO,OAAO,eAAeF,EAAcC,EAAaC,EAAoB,CAC1E,MAAMC,EAAQ,KAAK,WAAWH,EAAKC,CAAG,EAChCG,EAAS,OAAOD,GAASD,CAAY,EAC3C,OAAO,OAAO,cAAcE,CAAM,GAAKA,GAAU,EAAIA,EAAS,OAAOF,CAAY,CACnF,CAEO,OAAO,
|
|
4
|
+
"sourcesContent": ["/**\n * Typed readers for a Worker `env` binding.\n *\n * Converged from `backend-runtime/src/config/EnvParser.ts` — effectively\n * identical in all six repos that have the file (Mail-Meow/CalDAV-Bridge call\n * their copy `ConfigurationManager` with the same three readers).\n *\n * The var table is `Record<string, string | undefined>` by contract: Cloudflare\n * passes every binding as a string, so a reader that returned `number` for\n * `MAX_*` would be inventing a parse that never happened. `boolean` is\n * presence-of-\"true\", and anything else is `false` — never \"absent means true\".\n */\nclass EnvParser {\n public static positiveInt(env: unknown, key: string, defaultValue: string): number {\n const value = this.readString(env, key);\n const parsed = Number(value ?? defaultValue);\n return Number.isSafeInteger(parsed) && parsed > 0 ? parsed : Number(defaultValue);\n }\n\n /**\n * Whether an explicitly-set numeric var is a usable positive integer.\n *\n * Used by `AppConfiguration.validate()` to *report* misconfiguration at\n * startup while still running with the default. The throwing counterpart\n * (`strictPositiveInt`) is gone: no caller opted in, and a fail-fast parse on\n * a request path would turn a config typo into a 500 rather than a warning.\n */\n public static isValidPositiveInt(env: unknown, key: string): boolean {\n const value = this.readString(env, key);\n if (value === undefined) return true;\n const parsed = Number(value);\n return Number.isSafeInteger(parsed) && parsed > 0;\n }\n\n public static string(env: unknown, key: string, defaultValue: string): string {\n return this.readString(env, key) ?? defaultValue;\n }\n\n /**\n * A non-negative integer, zero included.\n *\n * Distinct from `positiveInt` because zero is a meaningful configuration for\n * retention and quota knobs (\"keep nothing\"), and a parser that rejected it\n * would silently substitute the default — so setting `0` in the dashboard\n * would appear to do nothing at all.\n */\n public static nonNegativeInt(env: unknown, key: string, defaultValue: string): number {\n const value = this.readString(env, key);\n const parsed = Number(value ?? defaultValue);\n return Number.isSafeInteger(parsed) && parsed >= 0 ? parsed : Number(defaultValue);\n }\n\n /**\n * Whether an explicitly-set numeric var is a usable non-negative integer.\n *\n * The `nonNegativeInt` counterpart of {@link isValidPositiveInt}, for the same\n * reason and with zero admitted. Two repos carried this and the kit did not,\n * so a repo adopting it would have had to re-add it locally to keep its\n * `validate()` checks whole.\n */\n public static isValidNonNegativeInt(env: unknown, key: string): boolean {\n const value = this.readString(env, key);\n if (value === undefined) return true;\n const parsed = Number(value);\n return Number.isSafeInteger(parsed) && parsed >= 0;\n }\n\n public static boolean(env: unknown, key: string, defaultValue: string): boolean {\n return (this.readString(env, key) ?? defaultValue) === 'true';\n }\n\n /**\n The raw value, or undefined when unset. Public because presence checks (validate) need it.\n\n Guards its input rather than casting it. `AppConfiguration` takes `env: unknown`\n precisely so a caller can hand it whatever the platform produced, and the cast\n this replaced threw a `TypeError` on `null`/`undefined` instead of answering\n \"unset\" — so the one moment a config check needs to be most forgiving (a\n binding missing entirely) was the one that could not be asked.\n */\n public static readString(env: unknown, key: string): string | undefined {\n if (env === null || typeof env !== 'object') return undefined;\n const value = (env as Record<string, unknown>)[key];\n return typeof value === 'string' ? value : undefined;\n }\n}\n\nexport { EnvParser };\n"],
|
|
5
|
+
"mappings": "+EAYA,MAAMA,CAAS,CAZf,MAYe,CAAAC,EAAA,kBACN,OAAO,YAAYC,EAAcC,EAAaC,EAAoB,CACvE,MAAMC,EAAQ,KAAK,WAAWH,EAAKC,CAAG,EAChCG,EAAS,OAAOD,GAASD,CAAY,EAC3C,OAAO,OAAO,cAAcE,CAAM,GAAKA,EAAS,EAAIA,EAAS,OAAOF,CAAY,CAClF,CAUO,OAAO,mBAAmBF,EAAcC,EAAW,CACxD,MAAME,EAAQ,KAAK,WAAWH,EAAKC,CAAG,EACtC,GAAIE,IAAU,OAAW,MAAO,GAChC,MAAMC,EAAS,OAAOD,CAAK,EAC3B,OAAO,OAAO,cAAcC,CAAM,GAAKA,EAAS,CAClD,CAEO,OAAO,OAAOJ,EAAcC,EAAaC,EAAoB,CAClE,OAAO,KAAK,WAAWF,EAAKC,CAAG,GAAKC,CACtC,CAUO,OAAO,eAAeF,EAAcC,EAAaC,EAAoB,CAC1E,MAAMC,EAAQ,KAAK,WAAWH,EAAKC,CAAG,EAChCG,EAAS,OAAOD,GAASD,CAAY,EAC3C,OAAO,OAAO,cAAcE,CAAM,GAAKA,GAAU,EAAIA,EAAS,OAAOF,CAAY,CACnF,CAUO,OAAO,sBAAsBF,EAAcC,EAAW,CAC3D,MAAME,EAAQ,KAAK,WAAWH,EAAKC,CAAG,EACtC,GAAIE,IAAU,OAAW,MAAO,GAChC,MAAMC,EAAS,OAAOD,CAAK,EAC3B,OAAO,OAAO,cAAcC,CAAM,GAAKA,GAAU,CACnD,CAEO,OAAO,QAAQJ,EAAcC,EAAaC,EAAoB,CACnE,OAAQ,KAAK,WAAWF,EAAKC,CAAG,GAAKC,KAAkB,MACzD,CAWO,OAAO,WAAWF,EAAcC,EAAW,CAChD,GAAID,IAAQ,MAAQ,OAAOA,GAAQ,SAAU,OAC7C,MAAMG,EAASH,EAAgCC,CAAG,EAClD,OAAO,OAAOE,GAAU,SAAWA,EAAQ,MAC7C",
|
|
6
6
|
"names": ["EnvParser", "__name", "env", "key", "defaultValue", "value", "parsed"]
|
|
7
7
|
}
|
|
@@ -13,6 +13,21 @@ interface ScopedContext {
|
|
|
13
13
|
set(key: string, value: unknown): void;
|
|
14
14
|
readonly env: unknown;
|
|
15
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* What {@link getRequestScope} throws when no scope is installed.
|
|
18
|
+
*
|
|
19
|
+
* Exported because a caller that wants to *react* to the absence — rather than
|
|
20
|
+
* let it propagate — has no other option than copying this sentence out of the
|
|
21
|
+
* throw and comparing against it. That is a string comparison across a package
|
|
22
|
+
* boundary: reword the message and the consumer's branch silently stops
|
|
23
|
+
* matching, which is the one direction that produces no error anywhere.
|
|
24
|
+
*
|
|
25
|
+
* Prefer {@link tryGetRequestScope}, which is checked by construction. This
|
|
26
|
+
* constant is for a caller that must react to the *specific* failure rather than
|
|
27
|
+
* to "no scope" in general — a route that answers a scoped JSON error instead of
|
|
28
|
+
* propagating, for instance.
|
|
29
|
+
*/
|
|
30
|
+
declare const SCOPE_MISSING_MESSAGE = "Request scope is not set. Register the scope middleware before routes.";
|
|
16
31
|
declare function setRequestScope(c: ScopedContext, scope: Container): void;
|
|
17
32
|
/**
|
|
18
33
|
* Structural adapter for framework contexts.
|
|
@@ -27,6 +42,15 @@ declare function asScopedContext(c: {
|
|
|
27
42
|
readonly env: unknown;
|
|
28
43
|
}): ScopedContext;
|
|
29
44
|
declare function getRequestScope(c: ScopedContext): Container;
|
|
30
|
-
|
|
45
|
+
/**
|
|
46
|
+
* The installed scope, or `null`.
|
|
47
|
+
*
|
|
48
|
+
* The way to ask without throwing. `getRequestScope` is right where a missing
|
|
49
|
+
* scope is a bug that should surface; this is right where it is an expected
|
|
50
|
+
* branch — and it is checked by construction, so it cannot drift from the
|
|
51
|
+
* message the throwing form uses.
|
|
52
|
+
*/
|
|
53
|
+
declare function tryGetRequestScope(c: ScopedContext): Container | null;
|
|
54
|
+
export { setRequestScope, getRequestScope, tryGetRequestScope, asScopedContext, SCOPE_MISSING_MESSAGE };
|
|
31
55
|
export type { ScopedContext };
|
|
32
56
|
//# sourceMappingURL=RequestScope.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RequestScope.d.ts","sourceRoot":"","sources":["../../src/di/RequestScope.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD;;;;;;;;GAQG;AACH,UAAU,aAAa;IACrB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAC1B,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IACvC,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC;CACvB;AAID,iBAAS,eAAe,CAAC,CAAC,EAAE,aAAa,EAAE,KAAK,EAAE,SAAS,GAAG,IAAI,CAEjE;AAED;;;;;;GAMG;AACH,iBAAS,eAAe,CAAC,CAAC,EAAE;IAAE,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAAC,GAAG,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAA;CAAE,GAAG,aAAa,CAExI;AAED,iBAAS,eAAe,CAAC,CAAC,EAAE,aAAa,GAAG,SAAS,CAIpD;AAED,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,eAAe,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"RequestScope.d.ts","sourceRoot":"","sources":["../../src/di/RequestScope.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD;;;;;;;;GAQG;AACH,UAAU,aAAa;IACrB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAC1B,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IACvC,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC;CACvB;AAID;;;;;;;;;;;;;GAaG;AACH,QAAA,MAAM,qBAAqB,2EAA2E,CAAC;AAEvG,iBAAS,eAAe,CAAC,CAAC,EAAE,aAAa,EAAE,KAAK,EAAE,SAAS,GAAG,IAAI,CAEjE;AAED;;;;;;GAMG;AACH,iBAAS,eAAe,CAAC,CAAC,EAAE;IAAE,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAAC,GAAG,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAA;CAAE,GAAG,aAAa,CAExI;AAED,iBAAS,eAAe,CAAC,CAAC,EAAE,aAAa,GAAG,SAAS,CAIpD;AAED;;;;;;;GAOG;AACH,iBAAS,kBAAkB,CAAC,CAAC,EAAE,aAAa,GAAG,SAAS,GAAG,IAAI,CAE9D;AAED,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,kBAAkB,EAAE,eAAe,EAAE,qBAAqB,EAAE,CAAC;AACxG,YAAY,EAAE,aAAa,EAAE,CAAC"}
|
package/dist/di/RequestScope.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var c=Object.defineProperty;var o=(e,t)=>c(e,"name",{value:t,configurable:!0});const n="__kitScope",s="Request scope is not set. Register the scope middleware before routes.";function u(e,t){e.set(n,t)}o(u,"setRequestScope");function S(e){return e}o(S,"asScopedContext");function i(e){const t=r(e);if(!t)throw new Error(s);return t}o(i,"getRequestScope");function r(e){return e.get(n)??null}o(r,"tryGetRequestScope");export{s as SCOPE_MISSING_MESSAGE,S as asScopedContext,i as getRequestScope,u as setRequestScope,r as tryGetRequestScope};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/di/RequestScope.ts"],
|
|
4
|
-
"sourcesContent": ["import type { Container } from './Container.ts';\n\n/**\n * Single-scope-per-request helper.\n *\n * Converged verbatim from `backend-runtime/src/di/RequestScope.ts` (identical in\n * all nine repos). Middleware creates one `Container` per request and stores it\n * on the request context; handlers resolve via `getRequestScope(c)` instead of\n * building a scope per handler — which minted N scopes per request and broke\n * singleton memoization.\n */\ninterface ScopedContext {\n get(key: string): unknown;\n set(key: string, value: unknown): void;\n readonly env: unknown;\n}\n\nconst SCOPE_KEY = '__kitScope';\n\nfunction setRequestScope(c: ScopedContext, scope: Container): void {\n c.set(SCOPE_KEY, scope);\n}\n\n/**\n * Structural adapter for framework contexts.\n *\n * Hono's `Context.get` overloads are not assignable to `ScopedContext['get']`,\n * so call sites used `c as never`. Centralize that single unsafe cast here —\n * one audited location instead of many scattered ones.\n */\nfunction asScopedContext(c: { get(key: string): unknown; set?(key: string, value: unknown): void; readonly env: unknown }): ScopedContext {\n return c as unknown as ScopedContext;\n}\n\nfunction getRequestScope(c: ScopedContext): Container {\n const scope = c
|
|
5
|
-
"mappings": "+EAiBA,MAAMA,EAAY,
|
|
6
|
-
"names": ["SCOPE_KEY", "setRequestScope", "c", "scope", "__name", "asScopedContext", "getRequestScope"]
|
|
4
|
+
"sourcesContent": ["import type { Container } from './Container.ts';\n\n/**\n * Single-scope-per-request helper.\n *\n * Converged verbatim from `backend-runtime/src/di/RequestScope.ts` (identical in\n * all nine repos). Middleware creates one `Container` per request and stores it\n * on the request context; handlers resolve via `getRequestScope(c)` instead of\n * building a scope per handler — which minted N scopes per request and broke\n * singleton memoization.\n */\ninterface ScopedContext {\n get(key: string): unknown;\n set(key: string, value: unknown): void;\n readonly env: unknown;\n}\n\nconst SCOPE_KEY = '__kitScope';\n\n/**\n * What {@link getRequestScope} throws when no scope is installed.\n *\n * Exported because a caller that wants to *react* to the absence — rather than\n * let it propagate — has no other option than copying this sentence out of the\n * throw and comparing against it. That is a string comparison across a package\n * boundary: reword the message and the consumer's branch silently stops\n * matching, which is the one direction that produces no error anywhere.\n *\n * Prefer {@link tryGetRequestScope}, which is checked by construction. This\n * constant is for a caller that must react to the *specific* failure rather than\n * to \"no scope\" in general — a route that answers a scoped JSON error instead of\n * propagating, for instance.\n */\nconst SCOPE_MISSING_MESSAGE = 'Request scope is not set. Register the scope middleware before routes.';\n\nfunction setRequestScope(c: ScopedContext, scope: Container): void {\n c.set(SCOPE_KEY, scope);\n}\n\n/**\n * Structural adapter for framework contexts.\n *\n * Hono's `Context.get` overloads are not assignable to `ScopedContext['get']`,\n * so call sites used `c as never`. Centralize that single unsafe cast here —\n * one audited location instead of many scattered ones.\n */\nfunction asScopedContext(c: { get(key: string): unknown; set?(key: string, value: unknown): void; readonly env: unknown }): ScopedContext {\n return c as unknown as ScopedContext;\n}\n\nfunction getRequestScope(c: ScopedContext): Container {\n const scope = tryGetRequestScope(c);\n if (!scope) throw new Error(SCOPE_MISSING_MESSAGE);\n return scope;\n}\n\n/**\n * The installed scope, or `null`.\n *\n * The way to ask without throwing. `getRequestScope` is right where a missing\n * scope is a bug that should surface; this is right where it is an expected\n * branch — and it is checked by construction, so it cannot drift from the\n * message the throwing form uses.\n */\nfunction tryGetRequestScope(c: ScopedContext): Container | null {\n return (c.get(SCOPE_KEY) as Container | undefined) ?? null;\n}\n\nexport { setRequestScope, getRequestScope, tryGetRequestScope, asScopedContext, SCOPE_MISSING_MESSAGE };\nexport type { ScopedContext };\n"],
|
|
5
|
+
"mappings": "+EAiBA,MAAMA,EAAY,aAgBZC,EAAwB,yEAE9B,SAASC,EAAgBC,EAAkBC,EAAgB,CACzDD,EAAE,IAAIH,EAAWI,CAAK,CACxB,CAFSC,EAAAH,EAAA,mBAWT,SAASI,EAAgBH,EAAgG,CACvH,OAAOA,CACT,CAFSE,EAAAC,EAAA,mBAIT,SAASC,EAAgBJ,EAAgB,CACvC,MAAMC,EAAQI,EAAmBL,CAAC,EAClC,GAAI,CAACC,EAAO,MAAM,IAAI,MAAMH,CAAqB,EACjD,OAAOG,CACT,CAJSC,EAAAE,EAAA,mBAcT,SAASC,EAAmBL,EAAgB,CAC1C,OAAQA,EAAE,IAAIH,CAAS,GAA+B,IACxD,CAFSK,EAAAG,EAAA",
|
|
6
|
+
"names": ["SCOPE_KEY", "SCOPE_MISSING_MESSAGE", "setRequestScope", "c", "scope", "__name", "asScopedContext", "getRequestScope", "tryGetRequestScope"]
|
|
7
7
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export { Container } from './di/Container.ts';
|
|
7
7
|
export type { Factory, Token } from './di/Container.ts';
|
|
8
|
-
export { asScopedContext, getRequestScope, setRequestScope } from './di/RequestScope.ts';
|
|
8
|
+
export { asScopedContext, getRequestScope, tryGetRequestScope, setRequestScope, SCOPE_MISSING_MESSAGE } from './di/RequestScope.ts';
|
|
9
9
|
export type { ScopedContext } from './di/RequestScope.ts';
|
|
10
10
|
export { AppConfiguration } from './config/AppConfiguration.ts';
|
|
11
11
|
export { EnvParser } from './config/EnvParser.ts';
|
|
@@ -14,13 +14,13 @@ export { AbstractEntrypointWorker } from './base/AbstractEntrypointWorker.ts';
|
|
|
14
14
|
export type { WorkerExecutionContext, WorkerScheduledController } from './base/AbstractEntrypointWorker.ts';
|
|
15
15
|
export { AbstractDurableObjectWorker } from './base/AbstractDurableObjectWorker.ts';
|
|
16
16
|
export { AbstractQueueWorker } from './base/AbstractQueueWorker.ts';
|
|
17
|
-
export type { WorkerMessageBatch } from './base/AbstractQueueWorker.ts';
|
|
18
17
|
export { AbstractWorkflowWorker } from './base/AbstractWorkflowWorker.ts';
|
|
19
|
-
export
|
|
20
|
-
export {
|
|
18
|
+
export { BASE_WORKER_MESSAGES } from './base/baseWorkerError.ts';
|
|
19
|
+
export type { BaseWorkerOperation } from './base/baseWorkerError.ts';
|
|
20
|
+
export { createLogger, isLogLevel, resetLogLevelForTests, resolveLogLevel, setLogLevel } from './logger.ts';
|
|
21
21
|
export type { LogLevel, Logger } from './logger.ts';
|
|
22
|
-
export {
|
|
23
|
-
export type { KvDomainDef, KvDomainName, KvNamespaceLike } from './kv/index.ts';
|
|
22
|
+
export { COOLDOWN_MS, FAILURE_THRESHOLD, KV_DOMAINS, KV_KEY_VERSION, KV_MAX_KEY_LENGTH, KV_MIN_TTL_SECONDS, KvCache, PURGE_LIST_LIMIT, PURGE_MAX_PAGES, UNMETERED, buildKvKey, clampTtl, digest128, resetBreakerForTests, sanitizeSegment, utf8ByteLength, } from './kv/index.ts';
|
|
23
|
+
export type { KvDomainDef, KvDomainName, KvDomains, KvNamespaceLike, KvPutOptions, SubrequestMeterLike } from './kv/index.ts';
|
|
24
24
|
export { AbstractScheduledTask, TaskRegistry } from './scheduled/index.ts';
|
|
25
25
|
export type { ApplicationRunHandle, ScheduledTaskEnv, TaskLogger, TaskRunRecorder, TaskRunSummary } from './scheduled/index.ts';
|
|
26
26
|
//# sourceMappingURL=index.d.ts.map
|