@rexezuge/runtime 1.3.0 → 1.4.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/dist/base/AbstractDurableObjectWorker.js +1 -38
- package/dist/base/AbstractDurableObjectWorker.js.map +7 -1
- package/dist/base/AbstractEntrypointWorker.js +1 -35
- package/dist/base/AbstractEntrypointWorker.js.map +7 -1
- package/dist/base/AbstractQueueWorker.js +1 -13
- package/dist/base/AbstractQueueWorker.js.map +7 -1
- package/dist/base/AbstractWorkflowWorker.js +1 -13
- package/dist/base/AbstractWorkflowWorker.js.map +7 -1
- package/dist/base/index.js +1 -5
- package/dist/base/index.js.map +7 -1
- package/dist/config/AppConfiguration.d.ts +6 -2
- package/dist/config/AppConfiguration.d.ts.map +1 -1
- package/dist/config/AppConfiguration.js +1 -63
- package/dist/config/AppConfiguration.js.map +7 -1
- package/dist/config/ConfigurationDefaults.d.ts +3 -1
- package/dist/config/ConfigurationDefaults.d.ts.map +1 -1
- package/dist/config/ConfigurationDefaults.js +1 -12
- package/dist/config/ConfigurationDefaults.js.map +7 -1
- package/dist/config/EnvParser.d.ts +3 -1
- package/dist/config/EnvParser.d.ts.map +1 -1
- package/dist/config/EnvParser.js +1 -59
- package/dist/config/EnvParser.js.map +7 -1
- package/dist/config/index.js +1 -4
- package/dist/config/index.js.map +7 -1
- package/dist/di/Container.js +1 -48
- package/dist/di/Container.js.map +7 -1
- package/dist/di/RequestScope.js +1 -22
- package/dist/di/RequestScope.js.map +7 -1
- package/dist/di/index.js +1 -3
- package/dist/di/index.js.map +7 -1
- package/dist/index.js +1 -18
- package/dist/index.js.map +7 -1
- package/dist/kv/KvCache.js +1 -197
- package/dist/kv/KvCache.js.map +7 -1
- package/dist/kv/KvDomains.js +1 -101
- package/dist/kv/KvDomains.js.map +7 -1
- package/dist/kv/index.js +1 -3
- package/dist/kv/index.js.map +7 -1
- package/dist/logger.js +1 -47
- package/dist/logger.js.map +7 -1
- package/dist/scheduled/index.d.ts +21 -7
- package/dist/scheduled/index.d.ts.map +1 -1
- package/dist/scheduled/index.js +1 -151
- package/dist/scheduled/index.js.map +7 -1
- package/package.json +2 -2
|
@@ -1,38 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
/**
|
|
3
|
-
* The Durable Object base: one `fetch` entry, error containment inside it.
|
|
4
|
-
*
|
|
5
|
-
* Converged from the `AbstractDurableObjectWorker` copies in AWS-AccessBridge,
|
|
6
|
-
* CalDAV-Bridge, ChordDHT-Tracker, Edge-Git, Mail-Meow and Mail-Otter (the
|
|
7
|
-
* union is exactly Mail-Meow's shape: the fetch wrapper plus
|
|
8
|
-
* `createExecutionContext` for handlers that need to forward `waitUntil`).
|
|
9
|
-
* Durable-DAV's DO writes more context per handler, but the *base* is the same.
|
|
10
|
-
*
|
|
11
|
-
* A DO has no routing layer, so an unhandled rejection here would surface as a
|
|
12
|
-
* raw 500 with no JSON body and no log. The catch is the boundary: it logs the
|
|
13
|
-
* sanitized error and answers `{ error: 'Internal Error' }` so a caller always
|
|
14
|
-
* gets a parseable response.
|
|
15
|
-
*/
|
|
16
|
-
class AbstractDurableObjectWorker extends DurableObject {
|
|
17
|
-
async fetch(request) {
|
|
18
|
-
try {
|
|
19
|
-
return await this.onRequest(request);
|
|
20
|
-
}
|
|
21
|
-
catch (err) {
|
|
22
|
-
console.error('Unhandled error in durable object fetch():', err);
|
|
23
|
-
return Response.json({ error: 'Internal Error' }, { status: 500 });
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* The platform `ExecutionContext` shape, forwards `waitUntil` into the DO's
|
|
28
|
-
* own `ctx` so a handler can keep a task alive past the response.
|
|
29
|
-
*/
|
|
30
|
-
createExecutionContext() {
|
|
31
|
-
return {
|
|
32
|
-
waitUntil: (promise) => this.ctx.waitUntil(promise),
|
|
33
|
-
passThroughOnException: () => undefined,
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
export { AbstractDurableObjectWorker };
|
|
38
|
-
//# sourceMappingURL=AbstractDurableObjectWorker.js.map
|
|
1
|
+
import{DurableObject as t}from"cloudflare:workers";class n extends t{async fetch(e){try{return await this.onRequest(e)}catch(r){return console.error("Unhandled error in durable object fetch():",r),Response.json({error:"Internal Error"},{status:500})}}createExecutionContext(){return{waitUntil:e=>this.ctx.waitUntil(e),passThroughOnException:()=>{}}}}export{n as AbstractDurableObjectWorker};
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 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 console.error('Unhandled error in durable object fetch():', err);\n return Response.json({ error: 'Internal Error' }, { status: 500 });\n }\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": "AAAA,OAAS,iBAAAA,MAAqB,qBAgB9B,MAAeC,UAAgDD,CAAmB,CACzE,MAAM,MAAME,EAAgB,CACjC,GAAI,CACF,OAAO,MAAM,KAAK,UAAUA,CAAO,CACrC,OAASC,EAAc,CACrB,eAAQ,MAAM,6CAA8CA,CAAG,EACxD,SAAS,KAAK,CAAE,MAAO,gBAAgB,EAAI,CAAE,OAAQ,GAAG,CAAE,CACnE,CACF,CAMU,wBAAsB,CAC9B,MAAO,CACL,UAAYC,GAAoC,KAAK,IAAI,UAAUA,CAAO,EAC1E,uBAAwB,IAAS,GAErC",
|
|
6
|
+
"names": ["DurableObject", "AbstractDurableObjectWorker", "request", "err", "promise"]
|
|
7
|
+
}
|
|
@@ -1,35 +1 @@
|
|
|
1
|
-
class
|
|
2
|
-
/**
|
|
3
|
-
* The HTTP request path.
|
|
4
|
-
*
|
|
5
|
-
* There is deliberately no `/__scheduled` branch here. It used to run before
|
|
6
|
-
* `onRequest`, which made `GET /__scheduled` an unauthenticated, un-rated
|
|
7
|
-
* trigger for the scheduled work: it bypassed the app's security headers, its
|
|
8
|
-
* request scope, and its rate limits, and any caller could fire the cron
|
|
9
|
-
* Durable Object on demand. `noRetry` was a `(): void => undefined` stub, so
|
|
10
|
-
* the retry semantics were lost too.
|
|
11
|
-
*
|
|
12
|
-
* Nothing needed it — `scheduled()` is wired through the platform by the
|
|
13
|
-
* `triggers.crons` entry in the wrangler config, which is how the cron
|
|
14
|
-
* actually runs.
|
|
15
|
-
*/
|
|
16
|
-
async fetch(request, env, ctx) {
|
|
17
|
-
try {
|
|
18
|
-
return await this.onRequest(request, env, ctx);
|
|
19
|
-
}
|
|
20
|
-
catch (err) {
|
|
21
|
-
console.error('Unhandled error in fetch():', err);
|
|
22
|
-
return new Response('Internal Error', { status: 500 });
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
async scheduled(event, env, ctx) {
|
|
26
|
-
try {
|
|
27
|
-
await this.onScheduled(event, env, ctx);
|
|
28
|
-
}
|
|
29
|
-
catch (err) {
|
|
30
|
-
console.error('Unhandled error in scheduled():', err);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
export { AbstractEntrypointWorker };
|
|
35
|
-
//# sourceMappingURL=AbstractEntrypointWorker.js.map
|
|
1
|
+
class s{async fetch(r,e,t){try{return await this.onRequest(r,e,t)}catch(n){return console.error("Unhandled error in fetch():",n),new Response("Internal Error",{status:500})}}async scheduled(r,e,t){try{await this.onScheduled(r,e,t)}catch(n){console.error("Unhandled error in scheduled():",n)}}}export{s as AbstractEntrypointWorker};
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 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 console.error('Unhandled error in 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 console.error('Unhandled error in scheduled():', err);\n }\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": "AAmBA,MAAeA,CAAwB,CAe9B,MAAM,MAAMC,EAAkBC,EAAUC,EAA2B,CACxE,GAAI,CACF,OAAO,MAAM,KAAK,UAAUF,EAASC,EAAKC,CAAG,CAC/C,OAASC,EAAc,CACrB,eAAQ,MAAM,8BAA+BA,CAAG,EACzC,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,QAAQ,MAAM,kCAAmCA,CAAG,CACtD,CACF",
|
|
6
|
+
"names": ["AbstractEntrypointWorker", "request", "env", "ctx", "err", "event"]
|
|
7
|
+
}
|
|
@@ -1,13 +1 @@
|
|
|
1
|
-
class
|
|
2
|
-
async queue(batch, env, ctx) {
|
|
3
|
-
try {
|
|
4
|
-
await this.onQueue(batch, env, ctx);
|
|
5
|
-
}
|
|
6
|
-
catch (err) {
|
|
7
|
-
console.error('Unhandled error in queue():', err);
|
|
8
|
-
throw err;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
export { AbstractQueueWorker };
|
|
13
|
-
//# sourceMappingURL=AbstractQueueWorker.js.map
|
|
1
|
+
class u{async queue(r,o,t){try{await this.onQueue(r,o,t)}catch(e){throw console.error("Unhandled error in queue():",e),e}}}export{u as AbstractQueueWorker};
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/base/AbstractQueueWorker.ts"],
|
|
4
|
+
"sourcesContent": ["import type { WorkerExecutionContext } from './AbstractEntrypointWorker.ts';\n\n/**\n * The queue consumer base, converged verbatim from `AbstractQueueWorker.ts`\n * (identical in Edge-Git and Mail-Otter; the only two repos with queue\n * 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 */\ninterface WorkerMessageBatch<T = unknown> {\n messages: T[];\n}\n\nabstract class AbstractQueueWorker<T = unknown> {\n public async queue(batch: WorkerMessageBatch<T>, env: Env, ctx: WorkerExecutionContext): Promise<void> {\n try {\n await this.onQueue(batch, env, ctx);\n } catch (err: unknown) {\n console.error('Unhandled error in queue():', err);\n throw err;\n }\n }\n\n protected abstract onQueue(batch: WorkerMessageBatch<T>, env: Env, ctx: WorkerExecutionContext): Promise<void>;\n}\n\nexport { AbstractQueueWorker };\nexport type { WorkerMessageBatch };\n"],
|
|
5
|
+
"mappings": "AAeA,MAAeA,CAAmB,CACzB,MAAM,MAAMC,EAA8BC,EAAUC,EAA2B,CACpF,GAAI,CACF,MAAM,KAAK,QAAQF,EAAOC,EAAKC,CAAG,CACpC,OAASC,EAAc,CACrB,cAAQ,MAAM,8BAA+BA,CAAG,EAC1CA,CACR,CACF",
|
|
6
|
+
"names": ["AbstractQueueWorker", "batch", "env", "ctx", "err"]
|
|
7
|
+
}
|
|
@@ -1,13 +1 @@
|
|
|
1
|
-
class
|
|
2
|
-
async run(event, step) {
|
|
3
|
-
try {
|
|
4
|
-
return await this.onWorkflow(event, step);
|
|
5
|
-
}
|
|
6
|
-
catch (err) {
|
|
7
|
-
console.error('Unhandled error in workflow run():', err);
|
|
8
|
-
throw err;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
export { AbstractWorkflowWorker };
|
|
13
|
-
//# sourceMappingURL=AbstractWorkflowWorker.js.map
|
|
1
|
+
class t{async run(o,n){try{return await this.onWorkflow(o,n)}catch(r){throw console.error("Unhandled error in workflow run():",r),r}}}export{t as AbstractWorkflowWorker};
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/base/AbstractWorkflowWorker.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * The Workflow base, converged verbatim from `AbstractWorkflowWorker.ts`\n * (identical in Edge-Git and Mail-Otter; Edge-Sonic ships the same shape as\n * `runWorkflow.ts` with a `WorkflowEntrypoint` wrapper around it).\n *\n * `WorkflowStepLike` is the minimal `step.do` surface: a workflow whose steps\n * are not retried by the platform is just a coroutine, and the wrapper exists\n * to keep the retry semantics visible in one place.\n */\ninterface WorkflowEventLike<T = unknown> {\n payload: T;\n}\n\ninterface WorkflowStepLike {\n do<T>(name: string, callback: () => Promise<T>): Promise<T>;\n}\n\nabstract class AbstractWorkflowWorker<TPayload = unknown, TResult = unknown> {\n public async run(event: Readonly<WorkflowEventLike<TPayload>>, step: WorkflowStepLike): Promise<TResult> {\n try {\n return await this.onWorkflow(event, step);\n } catch (err: unknown) {\n console.error('Unhandled error in workflow run():', err);\n throw err;\n }\n }\n\n protected abstract onWorkflow(event: Readonly<WorkflowEventLike<TPayload>>, step: WorkflowStepLike): Promise<TResult>;\n}\n\nexport { AbstractWorkflowWorker };\nexport type { WorkflowEventLike, WorkflowStepLike };\n"],
|
|
5
|
+
"mappings": "AAiBA,MAAeA,CAAsB,CAC5B,MAAM,IAAIC,EAA8CC,EAAsB,CACnF,GAAI,CACF,OAAO,MAAM,KAAK,WAAWD,EAAOC,CAAI,CAC1C,OAASC,EAAc,CACrB,cAAQ,MAAM,qCAAsCA,CAAG,EACjDA,CACR,CACF",
|
|
6
|
+
"names": ["AbstractWorkflowWorker", "event", "step", "err"]
|
|
7
|
+
}
|
package/dist/base/index.js
CHANGED
|
@@ -1,5 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { AbstractDurableObjectWorker } from "./AbstractDurableObjectWorker.js";
|
|
3
|
-
export { AbstractQueueWorker } from "./AbstractQueueWorker.js";
|
|
4
|
-
export { AbstractWorkflowWorker } from "./AbstractWorkflowWorker.js";
|
|
5
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import{AbstractEntrypointWorker as t}from"./AbstractEntrypointWorker.js";import{AbstractDurableObjectWorker as b}from"./AbstractDurableObjectWorker.js";import{AbstractQueueWorker as c}from"./AbstractQueueWorker.js";import{AbstractWorkflowWorker as k}from"./AbstractWorkflowWorker.js";export{b as AbstractDurableObjectWorker,t as AbstractEntrypointWorker,c as AbstractQueueWorker,k as AbstractWorkflowWorker};
|
package/dist/base/index.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 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 type { WorkerMessageBatch } from './AbstractQueueWorker.ts';\nexport { AbstractWorkflowWorker } from './AbstractWorkflowWorker.ts';\nexport type { WorkflowEventLike, WorkflowStepLike } from './AbstractWorkflowWorker.ts';\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,4BAAAA,MAAgC,gCAEzC,OAAS,+BAAAC,MAAmC,mCAC5C,OAAS,uBAAAC,MAA2B,2BAEpC,OAAS,0BAAAC,MAA8B",
|
|
6
|
+
"names": ["AbstractEntrypointWorker", "AbstractDurableObjectWorker", "AbstractQueueWorker", "AbstractWorkflowWorker"]
|
|
7
|
+
}
|
|
@@ -21,7 +21,9 @@ declare abstract class AppConfiguration {
|
|
|
21
21
|
* onto it, so a trailing `/` would double them in every generated link.
|
|
22
22
|
*/
|
|
23
23
|
getSiteUrl(): string;
|
|
24
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
The deployment stage this configuration believes itself in.
|
|
26
|
+
*/
|
|
25
27
|
getEnvironment(): string;
|
|
26
28
|
/**
|
|
27
29
|
* Warnings for suspicious settings, logged at startup. The base checks the
|
|
@@ -29,7 +31,9 @@ declare abstract class AppConfiguration {
|
|
|
29
31
|
* a subclass appends its own.
|
|
30
32
|
*/
|
|
31
33
|
validate(): string[];
|
|
32
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
The raw env, for subclasses that need a key this base does not know.
|
|
36
|
+
*/
|
|
33
37
|
protected raw(): unknown;
|
|
34
38
|
}
|
|
35
39
|
export { AppConfiguration };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppConfiguration.d.ts","sourceRoot":"","sources":["../../src/config/AppConfiguration.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;GAaG;AACH,uBAAe,gBAAgB;IACP,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,OAAO;IAArD,SAAS,aAAgC,GAAG,EAAE,OAAO;WAEvC,OAAO,CAAC,CAAC,SAAS,gBAAgB,EAAE,IAAI,EAAE,KAAK,GAAG,EAAE,OAAO,KAAK,CAAC,EAAE,GAAG,EAAE,OAAO,GAAG,CAAC;IAIjG;;;OAGG;IACI,UAAU,IAAI,MAAM;IAM3B
|
|
1
|
+
{"version":3,"file":"AppConfiguration.d.ts","sourceRoot":"","sources":["../../src/config/AppConfiguration.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;GAaG;AACH,uBAAe,gBAAgB;IACP,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,OAAO;IAArD,SAAS,aAAgC,GAAG,EAAE,OAAO;WAEvC,OAAO,CAAC,CAAC,SAAS,gBAAgB,EAAE,IAAI,EAAE,KAAK,GAAG,EAAE,OAAO,KAAK,CAAC,EAAE,GAAG,EAAE,OAAO,GAAG,CAAC;IAIjG;;;OAGG;IACI,UAAU,IAAI,MAAM;IAM3B;;MAEE;IACK,cAAc,IAAI,MAAM;IAI/B;;;;OAIG;IACI,QAAQ,IAAI,MAAM,EAAE;IAc3B;;MAEE;IACF,SAAS,CAAC,GAAG,IAAI,OAAO;CAGzB;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -1,63 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { DEFAULT_SITE_URL } from "./ConfigurationDefaults.js";
|
|
3
|
-
/**
|
|
4
|
-
* The base class every consumer's `AppConfiguration` extends.
|
|
5
|
-
*
|
|
6
|
-
* Converged from the six `config/AppConfiguration.ts` files and Mail-Meow's
|
|
7
|
-
* `config/AppConfig.ts` (the same class under a different name — consumers
|
|
8
|
-
* adapt to this one). The family's design — a thin facade over typed section
|
|
9
|
-
* objects, each owning one group of getters — is kept, minus the sections,
|
|
10
|
-
* which are per-project by nature: a consumer subclasses this and composes its
|
|
11
|
-
* own sections (limits, auth, replication …), each of which reads the env once
|
|
12
|
-
* through `EnvParser`.
|
|
13
|
-
*
|
|
14
|
-
* `validate()` returns warnings rather than throwing: a config typo must be a
|
|
15
|
-
* startup log line, not a 500 on a request path.
|
|
16
|
-
*/
|
|
17
|
-
class AppConfiguration {
|
|
18
|
-
env;
|
|
19
|
-
constructor(env) {
|
|
20
|
-
this.env = env;
|
|
21
|
-
}
|
|
22
|
-
static fromEnv(env) {
|
|
23
|
-
return new this(env);
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* The public origin, trailing slashes stripped. Callers concatenate paths
|
|
27
|
-
* onto it, so a trailing `/` would double them in every generated link.
|
|
28
|
-
*/
|
|
29
|
-
getSiteUrl() {
|
|
30
|
-
let url = EnvParser.string(this.env, 'SITE_URL', DEFAULT_SITE_URL);
|
|
31
|
-
while (url.endsWith('/'))
|
|
32
|
-
url = url.slice(0, -1);
|
|
33
|
-
return url;
|
|
34
|
-
}
|
|
35
|
-
/** The deployment stage this configuration believes itself in. */
|
|
36
|
-
getEnvironment() {
|
|
37
|
-
return EnvParser.string(this.env, 'ENVIRONMENT', 'development');
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Warnings for suspicious settings, logged at startup. The base checks the
|
|
41
|
-
* one the whole family agrees on — a dev bypass left enabled in production;
|
|
42
|
-
* a subclass appends its own.
|
|
43
|
-
*/
|
|
44
|
-
validate() {
|
|
45
|
-
const warnings = [];
|
|
46
|
-
const environment = this.getEnvironment();
|
|
47
|
-
if (environment === 'production') {
|
|
48
|
-
if (EnvParser.boolean(this.env, 'DEMO_MODE', 'false')) {
|
|
49
|
-
warnings.push('DEMO_MODE is enabled in production — every request will bypass authentication.');
|
|
50
|
-
}
|
|
51
|
-
if (EnvParser.readString(this.env, 'DEV_AUTH_EMAIL') !== undefined) {
|
|
52
|
-
warnings.push('DEV_AUTH_EMAIL is set in production — a fixed identity can authenticate.');
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return warnings;
|
|
56
|
-
}
|
|
57
|
-
/** The raw env, for subclasses that need a key this base does not know. */
|
|
58
|
-
raw() {
|
|
59
|
-
return this.env;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
export { AppConfiguration };
|
|
63
|
-
//# sourceMappingURL=AppConfiguration.js.map
|
|
1
|
+
import{EnvParser as t}from"./EnvParser.js";import{DEFAULT_SITE_URL as e}from"./ConfigurationDefaults.js";class i{env;constructor(n){this.env=n}static fromEnv(n){return new this(n)}getSiteUrl(){let n=t.string(this.env,"SITE_URL",e);for(;n.endsWith("/");)n=n.slice(0,-1);return n}getEnvironment(){return t.string(this.env,"ENVIRONMENT","development")}validate(){const n=[];return this.getEnvironment()==="production"&&(t.boolean(this.env,"DEMO_MODE","false")&&n.push("DEMO_MODE is enabled in production \u2014 every request will bypass authentication."),t.readString(this.env,"DEV_AUTH_EMAIL")!==void 0&&n.push("DEV_AUTH_EMAIL is set in production \u2014 a fixed identity can authenticate.")),n}raw(){return this.env}}export{i as AppConfiguration};
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/config/AppConfiguration.ts"],
|
|
4
|
+
"sourcesContent": ["import { EnvParser } from './EnvParser.ts';\nimport { DEFAULT_SITE_URL } from './ConfigurationDefaults.ts';\n\n/**\n * The base class every consumer's `AppConfiguration` extends.\n *\n * Converged from the six `config/AppConfiguration.ts` files and Mail-Meow's\n * `config/AppConfig.ts` (the same class under a different name — consumers\n * adapt to this one). The family's design — a thin facade over typed section\n * objects, each owning one group of getters — is kept, minus the sections,\n * which are per-project by nature: a consumer subclasses this and composes its\n * own sections (limits, auth, replication …), each of which reads the env once\n * through `EnvParser`.\n *\n * `validate()` returns warnings rather than throwing: a config typo must be a\n * startup log line, not a 500 on a request path.\n */\nabstract class AppConfiguration {\n protected constructor(protected readonly env: unknown) {}\n\n public static fromEnv<T extends AppConfiguration>(this: new (env: unknown) => T, env: unknown): T {\n return new this(env);\n }\n\n /**\n * The public origin, trailing slashes stripped. Callers concatenate paths\n * onto it, so a trailing `/` would double them in every generated link.\n */\n public getSiteUrl(): string {\n let url = EnvParser.string(this.env, 'SITE_URL', DEFAULT_SITE_URL);\n while (url.endsWith('/')) url = url.slice(0, -1);\n return url;\n }\n\n /**\n The deployment stage this configuration believes itself in.\n */\n public getEnvironment(): string {\n return EnvParser.string(this.env, 'ENVIRONMENT', 'development');\n }\n\n /**\n * Warnings for suspicious settings, logged at startup. The base checks the\n * one the whole family agrees on — a dev bypass left enabled in production;\n * a subclass appends its own.\n */\n public validate(): string[] {\n const warnings: string[] = [];\n const environment = this.getEnvironment();\n if (environment === 'production') {\n if (EnvParser.boolean(this.env, 'DEMO_MODE', 'false')) {\n warnings.push('DEMO_MODE is enabled in production — every request will bypass authentication.');\n }\n if (EnvParser.readString(this.env, 'DEV_AUTH_EMAIL') !== undefined) {\n warnings.push('DEV_AUTH_EMAIL is set in production — a fixed identity can authenticate.');\n }\n }\n return warnings;\n }\n\n /**\n The raw env, for subclasses that need a key this base does not know.\n */\n protected raw(): unknown {\n return this.env;\n }\n}\n\nexport { AppConfiguration };\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,aAAAA,MAAiB,iBAC1B,OAAS,oBAAAC,MAAwB,6BAgBjC,MAAeC,CAAgB,CACY,IAAzC,YAAyCC,EAAY,CAAZ,KAAA,IAAAA,CAAe,CAEjD,OAAO,QAAmEA,EAAY,CAC3F,OAAO,IAAI,KAAKA,CAAG,CACrB,CAMO,YAAU,CACf,IAAIC,EAAMJ,EAAU,OAAO,KAAK,IAAK,WAAYC,CAAgB,EACjE,KAAOG,EAAI,SAAS,GAAG,GAAGA,EAAMA,EAAI,MAAM,EAAG,EAAE,EAC/C,OAAOA,CACT,CAKO,gBAAc,CACnB,OAAOJ,EAAU,OAAO,KAAK,IAAK,cAAe,aAAa,CAChE,CAOO,UAAQ,CACb,MAAMK,EAAqB,CAAA,EAE3B,OADoB,KAAK,eAAc,IACnB,eACdL,EAAU,QAAQ,KAAK,IAAK,YAAa,OAAO,GAClDK,EAAS,KAAK,qFAAgF,EAE5FL,EAAU,WAAW,KAAK,IAAK,gBAAgB,IAAM,QACvDK,EAAS,KAAK,+EAA0E,GAGrFA,CACT,CAKU,KAAG,CACX,OAAO,KAAK,GACd",
|
|
6
|
+
"names": ["EnvParser", "DEFAULT_SITE_URL", "AppConfiguration", "env", "url", "warnings"]
|
|
7
|
+
}
|
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
* the values every repo agrees on live here; a project-specific default belongs
|
|
7
7
|
* in that project's config section.
|
|
8
8
|
*/
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
Used when `SITE_URL` is unset — the value that renders correct absolute links in tests.
|
|
11
|
+
*/
|
|
10
12
|
declare const DEFAULT_SITE_URL = "http://localhost:8787";
|
|
11
13
|
export { DEFAULT_SITE_URL };
|
|
12
14
|
//# sourceMappingURL=ConfigurationDefaults.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigurationDefaults.d.ts","sourceRoot":"","sources":["../../src/config/ConfigurationDefaults.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH
|
|
1
|
+
{"version":3,"file":"ConfigurationDefaults.d.ts","sourceRoot":"","sources":["../../src/config/ConfigurationDefaults.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;EAEE;AACF,QAAA,MAAM,gBAAgB,0BAA0B,CAAC;AAEjD,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -1,12 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Defaults shared by the family's configuration layers.
|
|
3
|
-
*
|
|
4
|
-
* Converged from `backend-runtime/src/config/ConfigurationDefaults.ts` (five
|
|
5
|
-
* repos) and the `ConfigurationManager` default table in the other four. Only
|
|
6
|
-
* the values every repo agrees on live here; a project-specific default belongs
|
|
7
|
-
* in that project's config section.
|
|
8
|
-
*/
|
|
9
|
-
/** Used when `SITE_URL` is unset — the value that renders correct absolute links in tests. */
|
|
10
|
-
const DEFAULT_SITE_URL = 'http://localhost:8787';
|
|
11
|
-
export { DEFAULT_SITE_URL };
|
|
12
|
-
//# sourceMappingURL=ConfigurationDefaults.js.map
|
|
1
|
+
const t="http://localhost:8787";export{t as DEFAULT_SITE_URL};
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/config/ConfigurationDefaults.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Defaults shared by the family's configuration layers.\n *\n * Converged from `backend-runtime/src/config/ConfigurationDefaults.ts` (five\n * repos) and the `ConfigurationManager` default table in the other four. Only\n * the values every repo agrees on live here; a project-specific default belongs\n * in that project's config section.\n */\n\n/**\nUsed when `SITE_URL` is unset — the value that renders correct absolute links in tests.\n*/\nconst DEFAULT_SITE_URL = 'http://localhost:8787';\n\nexport { DEFAULT_SITE_URL };\n"],
|
|
5
|
+
"mappings": "AAYA,MAAMA,EAAmB",
|
|
6
|
+
"names": ["DEFAULT_SITE_URL"]
|
|
7
|
+
}
|
|
@@ -32,7 +32,9 @@ declare class EnvParser {
|
|
|
32
32
|
*/
|
|
33
33
|
static nonNegativeInt(env: unknown, key: string, defaultValue: string): number;
|
|
34
34
|
static boolean(env: unknown, key: string, defaultValue: string): boolean;
|
|
35
|
-
/**
|
|
35
|
+
/**
|
|
36
|
+
The raw value, or undefined when unset. Public because presence checks (validate) need it.
|
|
37
|
+
*/
|
|
36
38
|
static readString(env: unknown, key: string): string | undefined;
|
|
37
39
|
}
|
|
38
40
|
export { EnvParser };
|
|
@@ -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;WAMvE,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO;IAI/E
|
|
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;WAMvE,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO;IAI/E;;MAEE;WACY,UAAU,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;CAGxE;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
package/dist/config/EnvParser.js
CHANGED
|
@@ -1,59 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Typed readers for a Worker `env` binding.
|
|
3
|
-
*
|
|
4
|
-
* Converged from `backend-runtime/src/config/EnvParser.ts` — effectively
|
|
5
|
-
* identical in all six repos that have the file (Mail-Meow/CalDAV-Bridge call
|
|
6
|
-
* their copy `ConfigurationManager` with the same three readers).
|
|
7
|
-
*
|
|
8
|
-
* The var table is `Record<string, string | undefined>` by contract: Cloudflare
|
|
9
|
-
* passes every binding as a string, so a reader that returned `number` for
|
|
10
|
-
* `MAX_*` would be inventing a parse that never happened. `boolean` is
|
|
11
|
-
* presence-of-"true", and anything else is `false` — never "absent means true".
|
|
12
|
-
*/
|
|
13
|
-
class EnvParser {
|
|
14
|
-
static positiveInt(env, key, defaultValue) {
|
|
15
|
-
const value = this.readString(env, key);
|
|
16
|
-
const parsed = Number(value ?? defaultValue);
|
|
17
|
-
return Number.isSafeInteger(parsed) && parsed > 0 ? parsed : Number(defaultValue);
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Whether an explicitly-set numeric var is a usable positive integer.
|
|
21
|
-
*
|
|
22
|
-
* Used by `AppConfiguration.validate()` to *report* misconfiguration at
|
|
23
|
-
* startup while still running with the default. The throwing counterpart
|
|
24
|
-
* (`strictPositiveInt`) is gone: no caller opted in, and a fail-fast parse on
|
|
25
|
-
* a request path would turn a config typo into a 500 rather than a warning.
|
|
26
|
-
*/
|
|
27
|
-
static isValidPositiveInt(env, key) {
|
|
28
|
-
const value = this.readString(env, key);
|
|
29
|
-
if (value === undefined)
|
|
30
|
-
return true;
|
|
31
|
-
const parsed = Number(value);
|
|
32
|
-
return Number.isSafeInteger(parsed) && parsed > 0;
|
|
33
|
-
}
|
|
34
|
-
static string(env, key, defaultValue) {
|
|
35
|
-
return this.readString(env, key) ?? defaultValue;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* A non-negative integer, zero included.
|
|
39
|
-
*
|
|
40
|
-
* Distinct from `positiveInt` because zero is a meaningful configuration for
|
|
41
|
-
* retention and quota knobs ("keep nothing"), and a parser that rejected it
|
|
42
|
-
* would silently substitute the default — so setting `0` in the dashboard
|
|
43
|
-
* would appear to do nothing at all.
|
|
44
|
-
*/
|
|
45
|
-
static nonNegativeInt(env, key, defaultValue) {
|
|
46
|
-
const value = this.readString(env, key);
|
|
47
|
-
const parsed = Number(value ?? defaultValue);
|
|
48
|
-
return Number.isSafeInteger(parsed) && parsed >= 0 ? parsed : Number(defaultValue);
|
|
49
|
-
}
|
|
50
|
-
static boolean(env, key, defaultValue) {
|
|
51
|
-
return (this.readString(env, key) ?? defaultValue) === 'true';
|
|
52
|
-
}
|
|
53
|
-
/** The raw value, or undefined when unset. Public because presence checks (validate) need it. */
|
|
54
|
-
static readString(env, key) {
|
|
55
|
-
return env[key];
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
export { EnvParser };
|
|
59
|
-
//# sourceMappingURL=EnvParser.js.map
|
|
1
|
+
class s{static positiveInt(r,e,t){const i=this.readString(r,e),n=Number(i??t);return Number.isSafeInteger(n)&&n>0?n:Number(t)}static isValidPositiveInt(r,e){const t=this.readString(r,e);if(t===void 0)return!0;const i=Number(t);return Number.isSafeInteger(i)&&i>0}static string(r,e,t){return this.readString(r,e)??t}static nonNegativeInt(r,e,t){const i=this.readString(r,e),n=Number(i??t);return Number.isSafeInteger(n)&&n>=0?n:Number(t)}static boolean(r,e,t){return(this.readString(r,e)??t)==="true"}static readString(r,e){return r[e]}}export{s as EnvParser};
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 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, string | undefined>)[key];\n }\n}\n\nexport { EnvParser };\n"],
|
|
5
|
+
"mappings": "AAYA,MAAMA,CAAS,CACN,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,QAAQF,EAAcC,EAAaC,EAAoB,CACnE,OAAQ,KAAK,WAAWF,EAAKC,CAAG,GAAKC,KAAkB,MACzD,CAKO,OAAO,WAAWF,EAAcC,EAAW,CAChD,OAAQD,EAA2CC,CAAG,CACxD",
|
|
6
|
+
"names": ["EnvParser", "env", "key", "defaultValue", "value", "parsed"]
|
|
7
|
+
}
|
package/dist/config/index.js
CHANGED
|
@@ -1,4 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { EnvParser } from "./EnvParser.js";
|
|
3
|
-
export { DEFAULT_SITE_URL } from "./ConfigurationDefaults.js";
|
|
4
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import{AppConfiguration as p}from"./AppConfiguration.js";import{EnvParser as f}from"./EnvParser.js";import{DEFAULT_SITE_URL as m}from"./ConfigurationDefaults.js";export{p as AppConfiguration,m as DEFAULT_SITE_URL,f as EnvParser};
|
package/dist/config/index.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/config/index.ts"],
|
|
4
|
+
"sourcesContent": ["export { AppConfiguration } from './AppConfiguration.ts';\nexport { EnvParser } from './EnvParser.ts';\nexport { DEFAULT_SITE_URL } from './ConfigurationDefaults.ts';\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,oBAAAA,MAAwB,wBACjC,OAAS,aAAAC,MAAiB,iBAC1B,OAAS,oBAAAC,MAAwB",
|
|
6
|
+
"names": ["AppConfiguration", "EnvParser", "DEFAULT_SITE_URL"]
|
|
7
|
+
}
|
package/dist/di/Container.js
CHANGED
|
@@ -1,48 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* The dependency-injection container.
|
|
3
|
-
*
|
|
4
|
-
* Converged verbatim from `backend-runtime/src/di/Container.ts` — the file is
|
|
5
|
-
* byte-identical (modulo scope) across all nine full-framework consumer repos,
|
|
6
|
-
* because the last divergence in it was fixed in all of them at once.
|
|
7
|
-
*
|
|
8
|
-
* Minimal by design: factory + singleton scopes, branded tokens for inference,
|
|
9
|
-
* nothing else. A DI container that grows features grows coupling with it.
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* Composition roots (a request scope, a cron entrypoint, tests) wire concrete
|
|
13
|
-
* implementations once; handlers resolve via `scope.get(Tokens.X)`. Prefer
|
|
14
|
-
* constructor injection of ports at registration time over inline
|
|
15
|
-
* `scope.get()` in business logic.
|
|
16
|
-
*/
|
|
17
|
-
class Container {
|
|
18
|
-
factories = new Map();
|
|
19
|
-
singletons = new Map();
|
|
20
|
-
bind(token, factory) {
|
|
21
|
-
this.factories.set(token, factory);
|
|
22
|
-
return this;
|
|
23
|
-
}
|
|
24
|
-
bindValue(token, value) {
|
|
25
|
-
this.singletons.set(token, value);
|
|
26
|
-
return this;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Is a token bound (as a value or a factory)? Used to assert wiring.
|
|
30
|
-
*/
|
|
31
|
-
has(token) {
|
|
32
|
-
return this.singletons.has(token) || this.factories.has(token);
|
|
33
|
-
}
|
|
34
|
-
get(token) {
|
|
35
|
-
if (this.singletons.has(token)) {
|
|
36
|
-
return this.singletons.get(token);
|
|
37
|
-
}
|
|
38
|
-
const factory = this.factories.get(token);
|
|
39
|
-
if (!factory) {
|
|
40
|
-
throw new Error(`DI container has no binding for token: ${String(token)}`);
|
|
41
|
-
}
|
|
42
|
-
const instance = factory(this);
|
|
43
|
-
this.singletons.set(token, instance);
|
|
44
|
-
return instance;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
export { Container };
|
|
48
|
-
//# sourceMappingURL=Container.js.map
|
|
1
|
+
class n{factories=new Map;singletons=new Map;bind(s,t){return this.factories.set(s,t),this}bindValue(s,t){return this.singletons.set(s,t),this}has(s){return this.singletons.has(s)||this.factories.has(s)}get(s){if(this.singletons.has(s))return this.singletons.get(s);const t=this.factories.get(s);if(!t)throw new Error(`DI container has no binding for token: ${String(s)}`);const i=t(this);return this.singletons.set(s,i),i}}export{n as Container};
|
package/dist/di/Container.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/di/Container.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * The dependency-injection container.\n *\n * Converged verbatim from `backend-runtime/src/di/Container.ts` — the file is\n * byte-identical (modulo scope) across all nine full-framework consumer repos,\n * because the last divergence in it was fixed in all of them at once.\n *\n * Minimal by design: factory + singleton scopes, branded tokens for inference,\n * nothing else. A DI container that grows features grows coupling with it.\n */\n\ntype Factory<T> = (container: Container) => T;\n\n/**\n * Branded token so `scope.get(Tokens.X)` infers `X` without an explicit generic\n * at call sites. The brand is optional (and `unknown`-compatible) so\n * `Token<Service>` remains assignable to `Token<unknown>` for Map storage.\n */\ntype Token<T = unknown> = (string | symbol) & { readonly __type?: T };\n\n/**\n * Composition roots (a request scope, a cron entrypoint, tests) wire concrete\n * implementations once; handlers resolve via `scope.get(Tokens.X)`. Prefer\n * constructor injection of ports at registration time over inline\n * `scope.get()` in business logic.\n */\nclass Container {\n private readonly factories = new Map<Token<unknown>, Factory<unknown>>();\n\n private readonly singletons = new Map<Token<unknown>, unknown>();\n\n public bind<T>(token: Token<T>, factory: Factory<T>): this {\n this.factories.set(token, factory);\n return this;\n }\n\n public bindValue<T>(token: Token<T>, value: T): this {\n this.singletons.set(token, value);\n return this;\n }\n\n /**\n * Is a token bound (as a value or a factory)? Used to assert wiring.\n */\n public has<T>(token: Token<T>): boolean {\n return this.singletons.has(token) || this.factories.has(token);\n }\n\n public get<T>(token: Token<T>): T {\n if (this.singletons.has(token)) {\n return this.singletons.get(token) as T;\n }\n const factory = this.factories.get(token);\n if (!factory) {\n throw new Error(`DI container has no binding for token: ${String(token)}`);\n }\n const instance = (factory as Factory<T>)(this);\n this.singletons.set(token, instance);\n return instance;\n }\n}\n\nexport { Container };\nexport type { Factory, Token };\n"],
|
|
5
|
+
"mappings": "AA0BA,MAAMA,CAAS,CACI,UAAY,IAAI,IAEhB,WAAa,IAAI,IAE3B,KAAQC,EAAiBC,EAAmB,CACjD,YAAK,UAAU,IAAID,EAAOC,CAAO,EAC1B,IACT,CAEO,UAAaD,EAAiBE,EAAQ,CAC3C,YAAK,WAAW,IAAIF,EAAOE,CAAK,EACzB,IACT,CAKO,IAAOF,EAAe,CAC3B,OAAO,KAAK,WAAW,IAAIA,CAAK,GAAK,KAAK,UAAU,IAAIA,CAAK,CAC/D,CAEO,IAAOA,EAAe,CAC3B,GAAI,KAAK,WAAW,IAAIA,CAAK,EAC3B,OAAO,KAAK,WAAW,IAAIA,CAAK,EAElC,MAAMC,EAAU,KAAK,UAAU,IAAID,CAAK,EACxC,GAAI,CAACC,EACH,MAAM,IAAI,MAAM,0CAA0C,OAAOD,CAAK,CAAC,EAAE,EAE3E,MAAMG,EAAYF,EAAuB,IAAI,EAC7C,YAAK,WAAW,IAAID,EAAOG,CAAQ,EAC5BA,CACT",
|
|
6
|
+
"names": ["Container", "token", "factory", "value", "instance"]
|
|
7
|
+
}
|
package/dist/di/RequestScope.js
CHANGED
|
@@ -1,22 +1 @@
|
|
|
1
|
-
const
|
|
2
|
-
function setRequestScope(c, scope) {
|
|
3
|
-
c.set(SCOPE_KEY, scope);
|
|
4
|
-
}
|
|
5
|
-
/**
|
|
6
|
-
* Structural adapter for framework contexts.
|
|
7
|
-
*
|
|
8
|
-
* Hono's `Context.get` overloads are not assignable to `ScopedContext['get']`,
|
|
9
|
-
* so call sites used `c as never`. Centralize that single unsafe cast here —
|
|
10
|
-
* one audited location instead of many scattered ones.
|
|
11
|
-
*/
|
|
12
|
-
function asScopedContext(c) {
|
|
13
|
-
return c;
|
|
14
|
-
}
|
|
15
|
-
function getRequestScope(c) {
|
|
16
|
-
const scope = c.get(SCOPE_KEY);
|
|
17
|
-
if (!scope)
|
|
18
|
-
throw new Error('Request scope is not set. Register the scope middleware before routes.');
|
|
19
|
-
return scope;
|
|
20
|
-
}
|
|
21
|
-
export { setRequestScope, getRequestScope, asScopedContext };
|
|
22
|
-
//# sourceMappingURL=RequestScope.js.map
|
|
1
|
+
const o="__kitScope";function s(e,t){e.set(o,t)}function n(e){return e}function r(e){const t=e.get(o);if(!t)throw new Error("Request scope is not set. Register the scope middleware before routes.");return t}export{n as asScopedContext,r as getRequestScope,s as setRequestScope};
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 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.get(SCOPE_KEY) as Container | undefined;\n if (!scope) throw new Error('Request scope is not set. Register the scope middleware before routes.');\n return scope;\n}\n\nexport { setRequestScope, getRequestScope, asScopedContext };\nexport type { ScopedContext };\n"],
|
|
5
|
+
"mappings": "AAiBA,MAAMA,EAAY,aAElB,SAASC,EAAgBC,EAAkBC,EAAgB,CACzDD,EAAE,IAAIF,EAAWG,CAAK,CACxB,CASA,SAASC,EAAgBF,EAAgG,CACvH,OAAOA,CACT,CAEA,SAASG,EAAgBH,EAAgB,CACvC,MAAMC,EAAQD,EAAE,IAAIF,CAAS,EAC7B,GAAI,CAACG,EAAO,MAAM,IAAI,MAAM,wEAAwE,EACpG,OAAOA,CACT",
|
|
6
|
+
"names": ["SCOPE_KEY", "setRequestScope", "c", "scope", "asScopedContext", "getRequestScope"]
|
|
7
|
+
}
|
package/dist/di/index.js
CHANGED
|
@@ -1,3 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { asScopedContext, getRequestScope, setRequestScope } from "./RequestScope.js";
|
|
3
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import{Container as t}from"./Container.js";import{asScopedContext as r,getRequestScope as s,setRequestScope as c}from"./RequestScope.js";export{t as Container,r as asScopedContext,s as getRequestScope,c as setRequestScope};
|