@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/dist/logger.d.ts
CHANGED
|
@@ -6,14 +6,43 @@
|
|
|
6
6
|
* copies in AWS/ChordDHT's `shared` are the same shape without the env floor).
|
|
7
7
|
*
|
|
8
8
|
* The level resolves from an injected `env` first, then `process.env`, then
|
|
9
|
-
* `info`: Workers have no
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* `
|
|
9
|
+
* anything {@link setLogLevel} installed, then `info`: Workers have no
|
|
10
|
+
* `process.env` at runtime, so an injected object is the configuration path,
|
|
11
|
+
* and `process.env` is a local-tooling affordance. An unrecognized level floors
|
|
12
|
+
* at `info` rather than throwing — a typo in `LOG_LEVEL` costing a worker a
|
|
13
|
+
* cold start is not a trade worth making.
|
|
14
|
+
*
|
|
15
|
+
* ### The level is read per emit, not per construction
|
|
16
|
+
*
|
|
17
|
+
* Both loggers a repo holds at module scope — one in this file's `KvCache`, one
|
|
18
|
+
* in its KV facade — are constructed when the isolate starts, long before any
|
|
19
|
+
* request scope exists to hand them an `env`. Resolving the level in the
|
|
20
|
+
* constructor therefore meant a module-scope logger could *only ever* read
|
|
21
|
+
* `process.env`, which workerd does not have: `LOG_LEVEL=debug` shipped,
|
|
22
|
+
* validated by nothing, and was inert. `setLogLevel` is the seam that closes
|
|
23
|
+
* that, and every emit re-reads so an already-constructed logger picks the level
|
|
24
|
+
* up without being rebuilt.
|
|
13
25
|
*/
|
|
14
26
|
type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
15
27
|
declare function isLogLevel(level: string): level is LogLevel;
|
|
16
28
|
declare function resolveLogLevel(env?: unknown): LogLevel;
|
|
29
|
+
/**
|
|
30
|
+
* Install the level every logger falls back to, for the rest of the isolate.
|
|
31
|
+
*
|
|
32
|
+
* The third source in {@link resolveLogLevel}'s chain, and below both an
|
|
33
|
+
* injected `env` and `process.env` on purpose: an explicit request scope
|
|
34
|
+
* outranks a process-wide default, and a developer's local shell outranks both.
|
|
35
|
+
* Only what neither can answer falls through to this.
|
|
36
|
+
*
|
|
37
|
+
* A composition root calls it once, with the level its config resolved to.
|
|
38
|
+
* Unrecognized input clears the installation rather than throwing — the same
|
|
39
|
+
* "a typo costs a cold start" trade as everywhere else in this file.
|
|
40
|
+
*/
|
|
41
|
+
declare function setLogLevel(level: string | undefined): void;
|
|
42
|
+
/**
|
|
43
|
+
* Test seam: forget whatever {@link setLogLevel} installed.
|
|
44
|
+
*/
|
|
45
|
+
declare function resetLogLevelForTests(): void;
|
|
17
46
|
interface Logger {
|
|
18
47
|
debug(...args: unknown[]): void;
|
|
19
48
|
info(...args: unknown[]): void;
|
|
@@ -21,6 +50,6 @@ interface Logger {
|
|
|
21
50
|
error(...args: unknown[]): void;
|
|
22
51
|
}
|
|
23
52
|
declare function createLogger(namespace?: string, fullRepoName?: string, env?: unknown): Logger;
|
|
24
|
-
export { createLogger, isLogLevel, resolveLogLevel };
|
|
53
|
+
export { createLogger, isLogLevel, resetLogLevelForTests, resolveLogLevel, setLogLevel };
|
|
25
54
|
export type { LogLevel, Logger };
|
|
26
55
|
//# sourceMappingURL=logger.d.ts.map
|
package/dist/logger.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,KAAK,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AASpD,iBAAS,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,QAAQ,CAEpD;AAWD,iBAAS,eAAe,CAAC,GAAG,CAAC,EAAE,OAAO,GAAG,QAAQ,CAKhD;AAED;;;;;;;;;;;GAWG;AACH,iBAAS,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAEpD;AAED;;GAEG;AACH,iBAAS,qBAAqB,IAAI,IAAI,CAErC;AAED,UAAU,MAAM;IACd,KAAK,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAChC,IAAI,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAC/B,IAAI,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAC/B,KAAK,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;CACjC;AAED,iBAAS,YAAY,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,GAAG,MAAM,CAiCtF;AAED,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,qBAAqB,EAAE,eAAe,EAAE,WAAW,EAAE,CAAC;AACzF,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC"}
|
package/dist/logger.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var u=Object.defineProperty;var n=(
|
|
1
|
+
var u=Object.defineProperty;var n=(e,t)=>u(e,"name",{value:t,configurable:!0});const L={debug:0,info:1,warn:2,error:3};function s(e){return["debug","info","warn","error"].includes(e)}n(s,"isLogLevel");let c;function l(e){const t=e!==null&&typeof e=="object"?e.LOG_LEVEL:void 0,f=globalThis.process?.env?.LOG_LEVEL,r=t??f??c??"info";return s(r)?r:"info"}n(l,"resolveLogLevel");function d(e){c=typeof e=="string"&&s(e)?e:void 0}n(d,"setLogLevel");function g(){c=void 0}n(g,"resetLogLevelForTests");function a(e,t,f){const r=[t,e].filter(Boolean).map(o=>`[${o}]`).join(" "),i=n(o=>L[o]>=L[l(f)],"enabled");return{debug:n((...o)=>{i("debug")&&console.debug(`[DEBUG] ${r}`,...o)},"debug"),info:n((...o)=>{i("info")&&console.info(`[INFO] ${r}`,...o)},"info"),warn:n((...o)=>{i("warn")&&console.warn(`[WARN] ${r}`,...o)},"warn"),error:n((...o)=>{i("error")&&console.error(`[ERROR] ${r}`,...o)},"error")}}n(a,"createLogger");export{a as createLogger,s as isLogLevel,g as resetLogLevelForTests,l as resolveLogLevel,d as setLogLevel};
|
package/dist/logger.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/logger.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * `KvLogger` — the family's console logger with a level floor.\n *\n * Converged from `backend-runtime/src/logger.ts`, which is identical in\n * Durable-DAV, Durable-DAV-Router, Edge-Sonic, Mail-Otter and Mail-Meow (the\n * copies in AWS/ChordDHT's `shared` are the same shape without the env floor).\n *\n * The level resolves from an injected `env` first, then `process.env`, then\n * `info`: Workers have no `process.env` at runtime, so an injected object is
|
|
5
|
-
"mappings": "+
|
|
6
|
-
"names": ["LOG_LEVELS", "isLogLevel", "level", "__name", "resolveLogLevel", "env", "fromInjected", "fromEnv", "
|
|
4
|
+
"sourcesContent": ["/**\n * `KvLogger` — the family's console logger with a level floor.\n *\n * Converged from `backend-runtime/src/logger.ts`, which is identical in\n * Durable-DAV, Durable-DAV-Router, Edge-Sonic, Mail-Otter and Mail-Meow (the\n * copies in AWS/ChordDHT's `shared` are the same shape without the env floor).\n *\n * The level resolves from an injected `env` first, then `process.env`, then\n * anything {@link setLogLevel} installed, then `info`: Workers have no\n * `process.env` at runtime, so an injected object is the configuration path,\n * and `process.env` is a local-tooling affordance. An unrecognized level floors\n * at `info` rather than throwing — a typo in `LOG_LEVEL` costing a worker a\n * cold start is not a trade worth making.\n *\n * ### The level is read per emit, not per construction\n *\n * Both loggers a repo holds at module scope — one in this file's `KvCache`, one\n * in its KV facade — are constructed when the isolate starts, long before any\n * request scope exists to hand them an `env`. Resolving the level in the\n * constructor therefore meant a module-scope logger could *only ever* read\n * `process.env`, which workerd does not have: `LOG_LEVEL=debug` shipped,\n * validated by nothing, and was inert. `setLogLevel` is the seam that closes\n * that, and every emit re-reads so an already-constructed logger picks the level\n * up without being rebuilt.\n */\ntype LogLevel = 'debug' | 'info' | 'warn' | 'error';\n\nconst LOG_LEVELS: Record<LogLevel, number> = {\n debug: 0,\n info: 1,\n warn: 2,\n error: 3,\n} as const;\n\nfunction isLogLevel(level: string): level is LogLevel {\n return (['debug', 'info', 'warn', 'error'] as const).includes(level as LogLevel);\n}\n\n/**\n * What {@link setLogLevel} installed, or `undefined` when nothing has.\n *\n * Module-level rather than per-logger because the emit path must not depend on\n * which logger asks: a logger built before the scope existed and a logger built\n * after it have to answer the same question identically.\n */\nlet installedLogLevel: LogLevel | undefined;\n\nfunction resolveLogLevel(env?: unknown): LogLevel {\n const fromInjected = env !== null && typeof env === 'object' ? (env as Record<string, string | undefined>)['LOG_LEVEL'] : undefined;\n const fromEnv = (globalThis as { process?: { env?: Record<string, string | undefined> } }).process?.env?.LOG_LEVEL;\n const level = fromInjected ?? fromEnv ?? installedLogLevel ?? 'info';\n return isLogLevel(level) ? level : 'info';\n}\n\n/**\n * Install the level every logger falls back to, for the rest of the isolate.\n *\n * The third source in {@link resolveLogLevel}'s chain, and below both an\n * injected `env` and `process.env` on purpose: an explicit request scope\n * outranks a process-wide default, and a developer's local shell outranks both.\n * Only what neither can answer falls through to this.\n *\n * A composition root calls it once, with the level its config resolved to.\n * Unrecognized input clears the installation rather than throwing — the same\n * \"a typo costs a cold start\" trade as everywhere else in this file.\n */\nfunction setLogLevel(level: string | undefined): void {\n installedLogLevel = typeof level === 'string' && isLogLevel(level) ? level : undefined;\n}\n\n/**\n * Test seam: forget whatever {@link setLogLevel} installed.\n */\nfunction resetLogLevelForTests(): void {\n installedLogLevel = undefined;\n}\n\ninterface Logger {\n debug(...args: unknown[]): void;\n info(...args: unknown[]): void;\n warn(...args: unknown[]): void;\n error(...args: unknown[]): void;\n}\n\nfunction createLogger(namespace?: string, fullRepoName?: string, env?: unknown): Logger {\n const argsStr = [fullRepoName, namespace]\n .filter(Boolean)\n .map((s) => `[${s}]`)\n .join(' ');\n\n // `enabled` is called per emit rather than compared against a level captured\n // at construction, for the reason in the header: these loggers are built at\n // module scope and the level that answers is not known until a scope runs.\n const enabled = (level: LogLevel): boolean => LOG_LEVELS[level] >= LOG_LEVELS[resolveLogLevel(env)];\n\n return {\n debug: (...args: unknown[]): void => {\n if (enabled('debug')) {\n console.debug(`[DEBUG] ${argsStr}`, ...args);\n }\n },\n info: (...args: unknown[]): void => {\n if (enabled('info')) {\n console.info(`[INFO] ${argsStr}`, ...args);\n }\n },\n warn: (...args: unknown[]): void => {\n if (enabled('warn')) {\n console.warn(`[WARN] ${argsStr}`, ...args);\n }\n },\n error: (...args: unknown[]): void => {\n if (enabled('error')) {\n console.error(`[ERROR] ${argsStr}`, ...args);\n }\n },\n };\n}\n\nexport { createLogger, isLogLevel, resetLogLevelForTests, resolveLogLevel, setLogLevel };\nexport type { LogLevel, Logger };\n"],
|
|
5
|
+
"mappings": "+EA2BA,MAAMA,EAAuC,CAC3C,MAAO,EACP,KAAM,EACN,KAAM,EACN,MAAO,GAGT,SAASC,EAA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AO,GAAI,GAAGG,CAAI,CAE/C,EAJO,SAMX,CAjCSd,EAAAQ,EAAA",
|
|
6
|
+
"names": ["LOG_LEVELS", "isLogLevel", "level", "__name", "installedLogLevel", "resolveLogLevel", "env", "fromInjected", "fromEnv", "setLogLevel", "resetLogLevelForTests", "createLogger", "namespace", "fullRepoName", "argsStr", "s", "enabled", "args"]
|
|
7
7
|
}
|