@substrat-run/kernel 0.140.0 → 0.142.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.
Files changed (67) hide show
  1. package/dist/async-invocation-log.d.ts +1 -1
  2. package/dist/async-invocation-log.d.ts.map +1 -1
  3. package/dist/async-invocation-log.js +1 -1
  4. package/dist/async-invocation-log.js.map +1 -1
  5. package/dist/capability.d.ts +127 -4
  6. package/dist/capability.d.ts.map +1 -1
  7. package/dist/capability.js +279 -20
  8. package/dist/capability.js.map +1 -1
  9. package/dist/connector-calls.d.ts +3 -72
  10. package/dist/connector-calls.d.ts.map +1 -1
  11. package/dist/connector-calls.js +3 -62
  12. package/dist/connector-calls.js.map +1 -1
  13. package/dist/index.d.ts +12 -91
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +7 -58
  16. package/dist/index.js.map +1 -1
  17. package/dist/invocation-line.d.ts +211 -0
  18. package/dist/invocation-line.d.ts.map +1 -0
  19. package/dist/invocation-line.js +33 -0
  20. package/dist/invocation-line.js.map +1 -0
  21. package/dist/meters.d.ts +21 -1
  22. package/dist/meters.d.ts.map +1 -1
  23. package/dist/meters.js +0 -0
  24. package/dist/meters.js.map +1 -1
  25. package/dist/module-log.d.ts +5 -4
  26. package/dist/module-log.d.ts.map +1 -1
  27. package/dist/module-log.js +5 -4
  28. package/dist/module-log.js.map +1 -1
  29. package/dist/permission-checker.d.ts +23 -0
  30. package/dist/permission-checker.d.ts.map +1 -1
  31. package/dist/permission-checker.js.map +1 -1
  32. package/dist/permission-eval.d.ts.map +1 -1
  33. package/dist/permission-eval.js +77 -21
  34. package/dist/permission-eval.js.map +1 -1
  35. package/dist/platform-sweep.d.ts +81 -1
  36. package/dist/platform-sweep.d.ts.map +1 -1
  37. package/dist/platform-sweep.js +125 -0
  38. package/dist/platform-sweep.js.map +1 -1
  39. package/dist/scope-copy-ledger.d.ts +128 -0
  40. package/dist/scope-copy-ledger.d.ts.map +1 -0
  41. package/dist/scope-copy-ledger.js +125 -0
  42. package/dist/scope-copy-ledger.js.map +1 -0
  43. package/dist/scope-host.d.ts +157 -13
  44. package/dist/scope-host.d.ts.map +1 -1
  45. package/dist/scope-host.js +2 -0
  46. package/dist/scope-host.js.map +1 -1
  47. package/dist/storage-gauge.d.ts +125 -0
  48. package/dist/storage-gauge.d.ts.map +1 -0
  49. package/dist/storage-gauge.js +234 -0
  50. package/dist/storage-gauge.js.map +1 -0
  51. package/package.json +12 -4
  52. package/dist/invocation-log.d.ts +0 -447
  53. package/dist/invocation-log.d.ts.map +0 -1
  54. package/dist/invocation-log.js +0 -410
  55. package/dist/invocation-log.js.map +0 -1
  56. package/dist/platform-call.d.ts +0 -45
  57. package/dist/platform-call.d.ts.map +0 -1
  58. package/dist/platform-call.js +0 -63
  59. package/dist/platform-call.js.map +0 -1
  60. package/dist/provider-error.d.ts +0 -38
  61. package/dist/provider-error.d.ts.map +0 -1
  62. package/dist/provider-error.js +0 -65
  63. package/dist/provider-error.js.map +0 -1
  64. package/dist/routed-node.d.ts +0 -87
  65. package/dist/routed-node.d.ts.map +0 -1
  66. package/dist/routed-node.js +0 -67
  67. package/dist/routed-node.js.map +0 -1
@@ -1,447 +0,0 @@
1
- /**
2
- * One structured log line per invocation, carrying the two dimensions Cloudflare
3
- * structurally cannot record: which TENANT and which SCOPE a request belonged to
4
- * (`docs/architecture/observability.md` §4.2/§4.3).
5
- *
6
- * ## Why this exists at all
7
- *
8
- * Observability is keyed on the deployed unit — a worker script — and one vertical's
9
- * script serves every tenant that installed it. That makes script-grain data safe for
10
- * staff and for the vertical's builder, and unsafe for an installer: their own numbers
11
- * are inseparable from everyone else's (§3). The router already stamps `tenantId` on the
12
- * datapoints and log lines IT emits, which is why tenant-keyed *metrics* need no code in
13
- * this package. Logs are the other half, and the router cannot supply it: a trace does
14
- * not cross the dispatch hop. Verified against production — a router line's `traceId`
15
- * reaches `substrat-control-plane` (a service binding) but never the dispatched vertical,
16
- * and every vertical event is a trace of exactly one event. There is nothing to join on,
17
- * so the line has to be emitted on this side.
18
- *
19
- * ## What it makes possible that nothing else does
20
- *
21
- * A vertical's successful request emits NO log event whatsoever — the host logs only on a
22
- * platform fault, and the scope host logs nothing at all. So before this middleware, a
23
- * vertical's entire log presence was its crashes. The stamped line is therefore not only
24
- * the correlation key; it is the thing that makes a tenant-facing log view have any rows.
25
- *
26
- * ## The correlation contract
27
- *
28
- * Every log line emitted during one invocation shares `$metadata.requestId`, so a reader
29
- * resolves a tenant's lines in two phases: filter on `tenantId` to find the invocations,
30
- * then fetch every line sharing their request ids. That is what attributes a vertical's
31
- * OWN `console.log` output — which carries no tenant of its own — to the tenant whose
32
- * request produced it.
33
- *
34
- * The inverse of that contract is a rule, not an optimisation: a line with no `tenantId`
35
- * is never shown to a tenant (§4.3). An un-routed local invocation has no asserted
36
- * headers and therefore emits no line — there is no tenant it could be attributed to, and
37
- * inventing one is the only way this could ever leak.
38
- *
39
- * ## The tenant is a VERIFIED assertion, never a header
40
- *
41
- * Which is why the line is written from `readRoutedNode`'s answer and not from
42
- * `headers.get('x-substrat-tenant')`. The two look interchangeable — behind the router
43
- * they are — and they are not, for exactly the reason #966 made `readRoutedNode` itself
44
- * fail closed: K-26's boundary is that a vertical's script has no public route, and that
45
- * is a DEPLOYMENT fact, with `workers.dev` on by default. Reading the header directly
46
- * meant anyone who could reach the script could name any tenant they liked and have the
47
- * line filed under it — a request the vertical then refuses with a 400, since `nodeFor`
48
- * does verify, while this middleware's `finally` had already written the forged line.
49
- *
50
- * That is not a cosmetic wrong row. The read path uses the stamped line as PROOF that an
51
- * invocation was a given tenant's, and admits that invocation's other log lines — which
52
- * carry no tenant of their own — into that tenant's view on the strength of it. A forged
53
- * stamp is therefore a way to put chosen text on somebody else's dashboard. So the same
54
- * verification the vertical does for its own routing happens here, with the same secret
55
- * and the same dev opt-out, and a failed one writes nothing at all.
56
- */
57
- import { type InvocationLevel } from '@substrat-run/contracts/invocation-record';
58
- import type { HeaderReader } from './routed-node.js';
59
- import type { EmittedReport } from './scope-host.js';
60
- /**
61
- * The per-request store key the middleware parks its {@link InvocationRecord} under (#1746).
62
- * A published name, like `substratInvocationId`: `mountOperations` reads it in another
63
- * package, and a vertical's own routes may fill it in too.
64
- */
65
- export declare const INVOCATION_RECORD_KEY = "substratInvocationRecord";
66
- /**
67
- * What the handler chain learns about a request that the middleware cannot see from
68
- * outside it (#1746): which operation ran, who it ran as, how it failed, and what it
69
- * touched. The middleware creates one per request, hands it down through the context, and
70
- * writes whatever was filled in when the request ends.
71
- *
72
- * Mutable on purpose. The alternative was reading several context keys back in the
73
- * `finally`, which would add a `get` to the structural context below and make every field
74
- * a string-keyed lookup; one object handed down and written back is the smaller seam.
75
- *
76
- * Every field is optional, and an unfilled one is written as `null`: a custom route that
77
- * never reaches an operation is still logged, it just has nothing to say about these.
78
- */
79
- export interface InvocationRecord {
80
- /** The operation name `mountOperations` dispatched to. */
81
- operation?: string;
82
- /** The `errorCode` a failed call was classified with, when the kernel's vocabulary names it. */
83
- problemCode?: string;
84
- /** The kind of subject the stub acted as — `ScopeStub.subjectKind`. */
85
- principalKind?: string;
86
- /** What the operation itself emitted — `InvokeOptions.onEmitted`. */
87
- emitted?: EmittedReport;
88
- /**
89
- * #1331: which of the operation's DECLARED output fields its response carried. Filled
90
- * only on a request the router armed the walk for ({@link fieldCoverageArmed}), and absent
91
- * otherwise — never an empty report, so "not walked" cannot read as "returned nothing".
92
- */
93
- outputFields?: OutputFieldsReport;
94
- }
95
- /**
96
- * The field walk's answer for one response (#1331). Names only, and only names the
97
- * operation DECLARES: a key the response carries that the declaration does not name is
98
- * never written down, since a key can be data (a map keyed by email is still a map). No
99
- * value is ever read into it.
100
- */
101
- export interface OutputFieldsReport {
102
- /** Declared fields the response carried with a value other than `null`, in declaration order. */
103
- present: string[];
104
- /** Declared fields the response carried as `null` — on the wire, carrying nothing. */
105
- empty: string[];
106
- /** Declared fields the response did not carry (missing, or `undefined`). */
107
- absent: string[];
108
- }
109
- export { invocationLevelOf, type InvocationLevel } from '@substrat-run/contracts/invocation-record';
110
- /**
111
- * The middleware's context, taken STRUCTURALLY — kernel depends on no web framework,
112
- * not even for a type. The shape below is the subset of a Hono context this reads, so
113
- * `app.use('*', invocationLog())` type-checks inside a vertical without this package
114
- * knowing which framework that vertical chose. Same posture as `vertical-host` taking
115
- * its scope host as `VerticalScopeHost` rather than importing a concrete adapter: the
116
- * seam is the shape, not the vendor.
117
- *
118
- * This line belongs with the router-assertion family (`readRoutedNode`,
119
- * `assertPlatformCall`) — the code that reads what the router asserted about a request —
120
- * because it is the same family seen from the other end: it writes that assertion down so
121
- * a reader can find it again. The family is moving from the kernel to `vertical-host`
122
- * (#1978), which already re-exports it; `vertical-host` keeps its AI SDK behind the
123
- * `./model` subpath, so a vertical importing this from its root bundles none of it.
124
- */
125
- export interface InvocationLogContext<Env = unknown> {
126
- req: {
127
- method: string;
128
- raw: {
129
- url: string;
130
- headers: HeaderReader;
131
- };
132
- };
133
- res?: {
134
- status: number;
135
- };
136
- /**
137
- * The framework's per-request store (#1237). Hono's `Context` has one; the type is
138
- * structural and narrow on purpose, so it is declared optional — a caller that does
139
- * not provide it simply gets no invocation id on the scope's events, which reads as
140
- * unrecorded exactly like every other absent stamp.
141
- */
142
- set?: {
143
- (key: 'substratInvocationId', value: string): void;
144
- /** #1746: the record the handler chain fills in. See {@link InvocationRecord}. */
145
- (key: typeof INVOCATION_RECORD_KEY, value: InvocationRecord): void;
146
- };
147
- /** The worker's bindings — read ONLY through the options below, never otherwise. */
148
- env: Env;
149
- }
150
- /**
151
- * How this middleware verifies the router's assertion, in the vertical's own terms.
152
- *
153
- * Both are functions of the env rather than plain values because a Worker's bindings
154
- * arrive per-request, while `app.use(...)` runs once at module scope. They are the same
155
- * two knobs the vertical already passes to `readRoutedNode` in its `nodeFor`, and they
156
- * must be given the same answers: a log that trusts more than the router does is the
157
- * forged-tenant hole, and one that trusts less is silently empty.
158
- */
159
- export interface InvocationLogOptions<Env = unknown> {
160
- /**
161
- * The router's shared secret as this worker holds it — `(env) => env.ROUTER_SECRET`.
162
- *
163
- * Omitting it is not a shortcut: with no secret to check against, an assertion can
164
- * only be accepted by `allowUnsigned`, so a bare `invocationLog()` in a deployed
165
- * vertical writes NOTHING. `pnpm lint:invocation-log` refuses that arrangement rather
166
- * than leaving a vertical to discover it from an empty log view.
167
- */
168
- routerSecret?: (env: Env) => string | undefined;
169
- /**
170
- * The vertical's own `ALLOW_DEV_NODE` — an un-routed local instance behind a dev
171
- * router that holds no secret either. Anywhere else this must stay false, or the
172
- * header is a claim again.
173
- */
174
- allowUnsigned?: (env: Env) => boolean;
175
- }
176
- /**
177
- * The shape of the emitted line. Deliberately a published contract rather than an
178
- * incidental object: the read proxy filters on these key names, and Workers Logs indexes
179
- * a `JSON.stringify`ed `console.log` as queryable TOP-LEVEL fields (`tenantId`, not
180
- * `$metadata.tenantId` nor `source.tenantId` — verified against the live telemetry API).
181
- * Renaming a key here silently empties a view, because a filter on a key that does not
182
- * exist returns `success: true` with zero events. Add fields; never rename one.
183
- */
184
- export interface InvocationLogLine {
185
- /** Discriminator — what lets a reader tell this line from a vertical's own output. */
186
- substrat: 'invocation';
187
- /**
188
- * #1901: what kind of work the line is about. ABSENT on a request's line — the line every
189
- * reader already knew — and present only on the scope host's lines for async work: a
190
- * consumer delivery (`consumer`) or a schedule run (`schedule`). A reader treats a missing
191
- * `kind` as `request`, which keeps every line written before this field existed meaning
192
- * what it meant.
193
- */
194
- kind?: AsyncInvocationKind;
195
- tenantId: string;
196
- scopeId: string | null;
197
- vertical: string | null;
198
- /**
199
- * The K-26 surface that answered. Taken from the verified node, so an assertion that
200
- * named none reads as `readRoutedNode`'s documented default (`app`) rather than as a
201
- * null only this writer would produce — one representation across the platform.
202
- */
203
- surface: string | null;
204
- /** The request's method. `null` on an async line (#1901), which no request carried. */
205
- method: string | null;
206
- /** Path ONLY — see `pathOf`. `null` on an async line (#1901). */
207
- path: string | null;
208
- /**
209
- * #1237: the id every event this invocation emitted is stamped with.
210
- *
211
- * The join nothing could make before. `$metadata.requestId` correlates the LINES of
212
- * one invocation, and it is stamped by the log platform at ingestion — no code here
213
- * can read it, and the spine could not have been given it. So the platform mints its
214
- * own, writes it here, and carries it to the scope on `InvokeOptions`.
215
- *
216
- * Which makes this line the other half of a trace: the events say what happened and
217
- * in what order, and this says how long the whole call took and how it ended.
218
- */
219
- invocationId: string;
220
- /**
221
- * The response status as the caller received it — including the status `onError`
222
- * mapped a thrown error to.
223
- *
224
- * Hono composes `onError` INSIDE the handler chain, not around it, so a handler that
225
- * throws does not reject this middleware's `await next()`: the envelope has already
226
- * turned it into a response by the time control comes back, and `c.res` holds the
227
- * mapped status. That is worth stating because the opposite is the natural guess, and
228
- * guessing it would have put `null` on every error line — the exact rows a tenant
229
- * opens this view to find.
230
- *
231
- * `null` therefore survives only for a genuine escape: an error that got past the
232
- * envelope itself, which `threw` marks.
233
- *
234
- * Always `null` on an async line (#1901): no caller received a status. Its `outcome` and
235
- * `level` say how it ended instead.
236
- */
237
- status: number | null;
238
- /** The error escaped even `onError` — rare, and the most interesting line on the page. */
239
- threw: boolean;
240
- durationMs: number;
241
- /** {@link invocationLevelOf}. Always present: it is derived from the two fields above. */
242
- level: InvocationLevel;
243
- /** The operation that ran. `null` for a route that is not a mounted operation. */
244
- operation: string | null;
245
- /** The kernel `errorCode` of a failed call, when it has one. */
246
- problemCode: string | null;
247
- /** Who the call ran as: `principal`, `connection`, `system`, `capability` or `vertical`. */
248
- principalKind: string | null;
249
- /**
250
- * How many events the operation itself emitted. `null` when not recorded, which is
251
- * different from `0`: a read emits nothing, and that is a fact about it.
252
- */
253
- eventCount: number | null;
254
- /** The distinct types among those events, in emission order (capped, see `entities`). */
255
- eventTypes: string[];
256
- /**
257
- * The distinct entities those events were about, as `<entityType>:<entityId>`. Taken from
258
- * at most `EMITTED_REPORT_CAP` events, so a bulk operation's line names the first few and
259
- * `eventCount` says how many there were.
260
- */
261
- entities: string[];
262
- /**
263
- * The registry id of the version that served the call — the platform's
264
- * `SUBSTRAT_VERSION_ID` binding, the same identity the spine stamps on events. `null`
265
- * locally and on a script pushed before the binding existed.
266
- */
267
- versionId: string | null;
268
- /**
269
- * #1331: which declared output fields the response carried. The one field on this line
270
- * that is OMITTED rather than `null` when unrecorded: the walk behind it is off by
271
- * default, and an unarmed line must stay byte-for-byte what it was before the field
272
- * existed. A reader treats absence exactly as it treats `null` elsewhere.
273
- */
274
- outputFields?: OutputFieldsReport;
275
- /**
276
- * #1923: the router's dispatch id for the request whose response {@link outputFields}
277
- * describes — its provenance. Present exactly when `outputFields` is: a reader joins it to
278
- * the router's own line for the request, and counts the report only for the tenant and app
279
- * that line names.
280
- */
281
- fieldCoverageId?: string;
282
- /** How the unit ended — see {@link AsyncOutcome}. */
283
- outcome?: AsyncOutcome;
284
- /** A consumer's event type. */
285
- eventType?: string | null;
286
- /** A consumer's event id — the join to the spine's outbox and delivery journal. */
287
- eventId?: string | null;
288
- /** Which attempt at this delivery the line is about, counting from 1. */
289
- attempt?: number | null;
290
- /** A schedule run's due time (ISO 8601), or `null` for a schedule's first run. */
291
- dueAt?: string | null;
292
- /** How late the run started against `dueAt`, in milliseconds; `null` on a first run. */
293
- latenessMs?: number | null;
294
- /** A `suppressed` line's count of the lines the pass's cap withheld. */
295
- suppressed?: number;
296
- /** The same count per `<kind>:<outcome>`, so a storm of one outcome is named, not averaged. */
297
- suppressedBy?: Record<string, number>;
298
- }
299
- /** #1901: the kinds of async work a scope host writes a line for. A request has no `kind`. */
300
- export type AsyncInvocationKind = 'consumer' | 'schedule';
301
- /**
302
- * #1901: how a unit of async work ended.
303
- *
304
- * - `delivered` — a consumer's handler ran and its delivery is journaled done.
305
- * - `retrying` — the handler threw and the delivery is due again later.
306
- * - `dead-lettered` — the delivery is journaled failed for good: the handler threw on its
307
- * last attempt, or the event never reached it (undecodable, a schema version the consumer
308
- * does not take, withheld by the producer).
309
- * - `inert` — a copy of a scope (#2005): the delivery is journaled terminal and NO handler
310
- * ran. Never `delivered`, because nothing was.
311
- * - `routed` — the delivery was handed to the platform's drain to run with authority this
312
- * host lacks (a connector on a control-plane-less host).
313
- * - `ok` / `failed` — a schedule run.
314
- * - `suppressed` — the pass's line cap was reached; the line counts what it withheld.
315
- */
316
- export type AsyncOutcome = 'delivered' | 'retrying' | 'dead-lettered' | 'inert' | 'routed' | 'ok' | 'failed' | 'suppressed';
317
- /**
318
- * The fields of an invocation line, before defaults. The ONE place the line's grammar lives
319
- * (#1901): the request writer below and the scope host's async writer both build through
320
- * {@link invocationLine}, so a field added to one is a field added to both, in one order.
321
- */
322
- export interface InvocationLineFields {
323
- kind?: AsyncInvocationKind;
324
- tenantId: string;
325
- scopeId: string | null;
326
- vertical?: string | null;
327
- surface?: string | null;
328
- method?: string | null;
329
- path?: string | null;
330
- invocationId: string;
331
- status?: number | null;
332
- threw: boolean;
333
- durationMs: number;
334
- level: InvocationLevel;
335
- operation?: string | null;
336
- problemCode?: string | null;
337
- principalKind?: string | null;
338
- emitted?: EmittedReport;
339
- /**
340
- * #1901: write `entities` from `emitted` (the default). An async line passes `false`: an
341
- * entity id is data a vertical chose — an email, a customer number — and the async line
342
- * carries ids the platform minted, declared names and codes only. Its `entities` is then
343
- * always `[]`, which a reader takes as "not recorded" beside a non-null `eventCount`.
344
- */
345
- withEntities?: boolean;
346
- versionId?: string | null;
347
- outputFields?: OutputFieldsReport;
348
- /** #1923: written only beside `outputFields`. */
349
- fieldCoverageId?: string;
350
- async?: Pick<InvocationLogLine, 'outcome' | 'eventType' | 'eventId' | 'attempt' | 'dueAt' | 'latenessMs' | 'suppressed' | 'suppressedBy'>;
351
- }
352
- /** Build a line. Unfilled fields are `null` (or empty), as the line's contract says. */
353
- export declare function invocationLine(f: InvocationLineFields): InvocationLogLine;
354
- /**
355
- * #1893: one request's stamp — the id minted for it and the record the handler chain fills
356
- * in — shared by whichever layer started it.
357
- */
358
- export interface InvocationStamp {
359
- invocationId: string;
360
- record: InvocationRecord;
361
- /**
362
- * #1923: the dispatch id the router armed this request's field walk with, when it did and
363
- * the request's router assertion verified. Decided once, when the stamp begins — see
364
- * {@link armedFieldCoverageId}. Written on the line beside the report, as its provenance.
365
- */
366
- fieldCoverageId?: string;
367
- }
368
- /**
369
- * The stamp a request already carries, if a layer outside this one started it (#1893).
370
- * `vertical-host` reads the record through this when the Hono context has none, which is
371
- * the case when the platform's entry stamped the request and the vertical mounts nothing.
372
- */
373
- export declare function invocationStampOf(request: object): InvocationStamp | undefined;
374
- /**
375
- * #1923: whether the per-response field walk is armed for this request — the one question the
376
- * walk's two callers in `vertical-host` (the operation routes and the MCP door) ask.
377
- *
378
- * `false` for a request no stamp covers, and for a stamp begun by a layer that predates the
379
- * switch: every version skew between the platform's entry and a vertical's bundled kernel
380
- * reads as off, never as on.
381
- */
382
- export declare function fieldCoverageArmed(request: object): boolean;
383
- /**
384
- * Mount as the FIRST middleware on a vertical's app, with the same two answers the
385
- * vertical gives `readRoutedNode` in its own `nodeFor`:
386
- *
387
- * ```ts
388
- * const app = new Hono<{ Bindings: Env }>();
389
- * app.use(
390
- * '*',
391
- * invocationLog<Env>({
392
- * routerSecret: (env) => env.ROUTER_SECRET,
393
- * allowUnsigned: (env) => env.ALLOW_DEV_NODE === 'true',
394
- * }),
395
- * );
396
- * ```
397
- *
398
- * First, because Hono composes handlers in registration order and stops at the one that
399
- * returns a response — middleware registered after a route does not wrap that route.
400
- *
401
- * **Since #1893 the platform stamps every deployed request itself**, by wrapping the
402
- * uploaded entry with `withInvocationLog`. A vertical that still mounts this middleware
403
- * then finds the request already stamped and steps aside — it hands the platform's stamp
404
- * to the handler chain through the context, as it always did, and writes no second line.
405
- * Mounted where no platform entry runs (a dev server behind a dev router), it stamps as
406
- * before.
407
- *
408
- * Nothing here can fail a request: the line is written in a `finally`, and a throw from
409
- * the handler is re-thrown untouched for `onError` to map as it always did.
410
- */
411
- export declare function invocationLog<Env = unknown>(options?: InvocationLogOptions<Env>): (c: InvocationLogContext<Env>, next: () => Promise<void>) => Promise<void>;
412
- /** The request a module worker's `fetch` receives, as far as the stamp reads it. */
413
- export interface IncomingRequest {
414
- method: string;
415
- url: string;
416
- headers: HeaderReader;
417
- }
418
- /**
419
- * The module-worker shape `withInvocationLog` wraps: a default export with handlers. Typed
420
- * structurally — kernel compiles with no DOM and no workers types — so a Hono app, a plain
421
- * `{ fetch }` object and anything else with the method all fit.
422
- */
423
- export interface ModuleWorker<Env = unknown> {
424
- fetch?: (request: IncomingRequest, env: Env, ctx: unknown) => {
425
- status: number;
426
- } | Promise<{
427
- status: number;
428
- }>;
429
- [handler: string]: unknown;
430
- }
431
- /**
432
- * The platform's half of the stamp (#1893): wrap a module worker's `fetch` so every request
433
- * it serves is stamped, whatever framework the worker is written in and whether or not it
434
- * mounts the middleware.
435
- *
436
- * The control plane builds this into the entry it uploads in front of every vertical's
437
- * bundle (`platform-entry.generated.ts`), which is what makes the stamp the platform's
438
- * rather than a line each vertical has to remember. A request the vertical's own
439
- * middleware already stamped — possible only if something wrapped this one — is passed
440
- * straight through. The other handlers (`scheduled`, `queue`, …) are passed through
441
- * untouched, bound to the worker, since a stamp is about a routed request.
442
- *
443
- * Nothing here can fail a request: the line is written in a `finally`, and a throw is
444
- * re-thrown untouched.
445
- */
446
- export declare function withInvocationLog<Env = unknown>(worker: ModuleWorker<Env>, options?: InvocationLogOptions<Env>): ModuleWorker<Env>;
447
- //# sourceMappingURL=invocation-log.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"invocation-log.d.ts","sourceRoot":"","sources":["../src/invocation-log.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AAGH,OAAO,EAKL,KAAK,eAAe,EACrB,MAAM,2CAA2C,CAAC;AAGnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD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