@powerlines/plugin-cloudflare 0.2.21 → 0.2.23

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.
@@ -1,6 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
- let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
4
3
  let _alloy_js_core = require("@alloy-js/core");
5
4
  let defu = require("defu");
6
5
  defu = require_runtime.__toESM(defu);
@@ -16,901 +15,450 @@ let _powerlines_plugin_alloy_typescript_components_tsdoc = require("@powerlines/
16
15
  */
17
16
  function CloudflareBuiltin(props) {
18
17
  const [{ imports, children }, rest] = (0, _alloy_js_core.splitProps)(props, ["imports", "children"]);
19
- return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_builtin_file.BuiltinFile, (0, _alloy_js_core_jsx_runtime.mergeProps)({
20
- id: "cloudflare",
21
- description: "A set of helpful runtime utilities for integrating Cloudflare services."
22
- }, rest, {
23
- get imports() {
24
- return (0, defu.default)({
25
- "node:async_hooks": ["AsyncLocalStorage"],
26
- "@cloudflare/workers-types": [
27
- {
28
- name: "Request",
29
- type: true
30
- },
31
- {
32
- name: "Response",
33
- type: true
34
- },
35
- {
36
- name: "ExecutionContext",
37
- type: true
38
- },
39
- {
40
- name: "IncomingRequestCfProperties",
41
- type: true
42
- },
43
- {
44
- name: "ScheduledController",
45
- type: true
46
- },
47
- {
48
- name: "ForwardableEmailMessage",
49
- type: true
50
- },
51
- {
52
- name: "MessageBatch",
53
- type: true
54
- },
55
- {
56
- name: "TailStream",
57
- type: true
58
- },
59
- {
60
- name: "TraceItem",
61
- type: true
62
- },
63
- {
64
- name: "TailStream.TailEvent",
65
- type: true
66
- },
67
- {
68
- name: "TailStream.Onset",
69
- type: true
70
- },
71
- {
72
- name: "TailStream.TailEventHandlerType",
73
- type: true
74
- }
75
- ]
76
- }, imports ?? {});
77
- },
78
- get children() {
79
- return [
80
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
81
- "const": true,
82
- name: "globalContextStorage",
83
- initializer: _alloy_js_core.code`globalThis as unknown as Record<PropertyKey, unknown>; `
84
- }),
85
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components.Spacing, {}),
86
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components.Spacing, {}),
87
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration, {
88
- "export": true,
89
- name: "CloudflareFetchContext",
90
- typeParameters: [{
91
- name: "Env",
92
- default: "CloudflareBindings"
93
- }, {
94
- name: "CfHostMetadata",
95
- default: "unknown"
96
- }],
97
- doc: "An interface representing the runtime context for Cloudflare operations, containing relevant information and utilities for performing actions within the Cloudflare environment.",
98
- get children() {
99
- return [
100
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
101
- name: "request",
102
- type: "Request<CfHostMetadata, IncomingRequestCfProperties<CfHostMetadata>>",
103
- doc: "The incoming Cloudflare request."
104
- }),
105
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
106
- name: "env",
107
- type: "Env",
108
- doc: "The Cloudflare environment bindings available during runtime."
109
- }),
110
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
111
- name: "ctx",
112
- type: "ExecutionContext",
113
- doc: "The Cloudflare execution context for the incoming request."
114
- })
115
- ];
116
- }
117
- }),
118
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
119
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
120
- "const": true,
121
- name: "CLOUDFLARE_FETCH_CONTEXT_KEY",
122
- initializer: _alloy_js_core.code`Symbol.for("powerlines-cloudflare-fetch"); `
123
- }),
124
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
125
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
126
- "export": true,
127
- "const": true,
128
- name: "fetchContextStorage",
129
- doc: "An AsyncLocalStorage instance for managing the Cloudflare fetch context.",
130
- initializer: _alloy_js_core.code`(globalContextStorage[CLOUDFLARE_FETCH_CONTEXT_KEY] ??= new AsyncLocalStorage<CloudflareFetchContext>()) as AsyncLocalStorage<CloudflareFetchContext>; `
131
- }),
132
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
133
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
134
- heading: "Retrieves the current Cloudflare fetch context from the AsyncLocalStorage. This context contains relevant information and utilities for performing actions within the Cloudflare environment. If no context is currently set, this function will throw an error.",
135
- get children() {
136
- return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: _alloy_js_core.code`The current Cloudflare fetch context.` });
137
- }
138
- }),
139
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
140
- "export": true,
141
- name: "getFetchContext",
142
- typeParameters: [{
143
- name: "Env",
144
- default: "CloudflareBindings"
145
- }, {
146
- name: "CfHostMetadata",
147
- default: "unknown"
148
- }],
149
- parameters: [],
150
- returnType: "CloudflareFetchContext<Env, CfHostMetadata>",
151
- children: _alloy_js_core.code`const context = fetchContextStorage.getStore();
18
+ return <_powerlines_plugin_alloy_typescript_components_builtin_file.BuiltinFile id="cloudflare" description="A set of helpful runtime utilities for integrating Cloudflare services." {...rest} imports={(0, defu.default)({
19
+ "node:async_hooks": ["AsyncLocalStorage"],
20
+ "@cloudflare/workers-types": [
21
+ {
22
+ name: "Request",
23
+ type: true
24
+ },
25
+ {
26
+ name: "Response",
27
+ type: true
28
+ },
29
+ {
30
+ name: "ExecutionContext",
31
+ type: true
32
+ },
33
+ {
34
+ name: "IncomingRequestCfProperties",
35
+ type: true
36
+ },
37
+ {
38
+ name: "ScheduledController",
39
+ type: true
40
+ },
41
+ {
42
+ name: "ForwardableEmailMessage",
43
+ type: true
44
+ },
45
+ {
46
+ name: "MessageBatch",
47
+ type: true
48
+ },
49
+ {
50
+ name: "TailStream",
51
+ type: true
52
+ },
53
+ {
54
+ name: "TraceItem",
55
+ type: true
56
+ },
57
+ {
58
+ name: "TailStream.TailEvent",
59
+ type: true
60
+ },
61
+ {
62
+ name: "TailStream.Onset",
63
+ type: true
64
+ },
65
+ {
66
+ name: "TailStream.TailEventHandlerType",
67
+ type: true
68
+ }
69
+ ]
70
+ }, imports ?? {})}>
71
+ <_alloy_js_typescript.VarDeclaration const name="globalContextStorage" initializer={_alloy_js_core.code`globalThis as unknown as Record<PropertyKey, unknown>; `} />
72
+ <_powerlines_plugin_alloy_core_components.Spacing />
73
+ <_powerlines_plugin_alloy_core_components.Spacing />
74
+ <_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration export name="CloudflareFetchContext" typeParameters={[{
75
+ name: "Env",
76
+ default: "CloudflareBindings"
77
+ }, {
78
+ name: "CfHostMetadata",
79
+ default: "unknown"
80
+ }]} doc="An interface representing the runtime context for Cloudflare operations, containing relevant information and utilities for performing actions within the Cloudflare environment.">
81
+ <_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember name="request" type="Request<CfHostMetadata, IncomingRequestCfProperties<CfHostMetadata>>" doc="The incoming Cloudflare request." />
82
+ <_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember name="env" type="Env" doc="The Cloudflare environment bindings available during runtime." />
83
+ <_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember name="ctx" type="ExecutionContext" doc="The Cloudflare execution context for the incoming request." />
84
+ </_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration>
85
+ <hbr />
86
+ <_alloy_js_typescript.VarDeclaration const name="CLOUDFLARE_FETCH_CONTEXT_KEY" initializer={_alloy_js_core.code`Symbol.for("powerlines-cloudflare-fetch"); `} />
87
+ <hbr />
88
+ <_alloy_js_typescript.VarDeclaration export const name="fetchContextStorage" doc="An AsyncLocalStorage instance for managing the Cloudflare fetch context." initializer={_alloy_js_core.code`(globalContextStorage[CLOUDFLARE_FETCH_CONTEXT_KEY] ??= new AsyncLocalStorage<CloudflareFetchContext>()) as AsyncLocalStorage<CloudflareFetchContext>; `} />
89
+ <hbr />
90
+ <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc heading="Retrieves the current Cloudflare fetch context from the AsyncLocalStorage. This context contains relevant information and utilities for performing actions within the Cloudflare environment. If no context is currently set, this function will throw an error.">
91
+ <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns>{_alloy_js_core.code`The current Cloudflare fetch context.`}</_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns>
92
+ </_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc>
93
+ <_alloy_js_typescript.FunctionDeclaration export name="getFetchContext" typeParameters={[{
94
+ name: "Env",
95
+ default: "CloudflareBindings"
96
+ }, {
97
+ name: "CfHostMetadata",
98
+ default: "unknown"
99
+ }]} parameters={[]} returnType="CloudflareFetchContext<Env, CfHostMetadata>">
100
+ {_alloy_js_core.code`const context = fetchContextStorage.getStore();
152
101
  if (!context) {
153
102
  throw new Error("Cloudflare fetch context is not available. Ensure that you are calling this function within the scope of a Cloudflare fetch request.");
154
103
  }
155
- return context as CloudflareFetchContext<Env, CfHostMetadata>; `
156
- }),
157
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
158
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
159
- heading: "Runs a given function within the scope of a Cloudflare fetch context. This is typically used to set up the context for handling a Cloudflare fetch request, ensuring that any code executed within the function has access to the relevant Cloudflare environment information and utilities. The provided context will be available through the `getFetchContext` function for any code executed within the callback.",
160
- get children() {
161
- return [
162
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
163
- name: "context",
164
- children: _alloy_js_core.code`The Cloudflare fetch context to run the function with.`
165
- }),
166
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
167
- name: "callback",
168
- children: _alloy_js_core.code`The function to execute within the scope of the provided context.`
169
- }),
170
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: _alloy_js_core.code`The result of the executed function.` })
171
- ];
172
- }
173
- }),
174
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
175
- "export": true,
176
- name: "withFetchContext",
177
- typeParameters: [{
178
- name: "Env",
179
- default: "CloudflareBindings"
180
- }, {
181
- name: "CfHostMetadata",
182
- default: "unknown"
183
- }],
184
- parameters: [{
185
- name: "context",
186
- type: "CloudflareFetchContext<Env, CfHostMetadata>"
187
- }, {
188
- name: "callback",
189
- type: "(request: Request<CfHostMetadata, IncomingRequestCfProperties<CfHostMetadata>>, env: Env, ctx: ExecutionContext) => Promise<Response>"
190
- }],
191
- returnType: "Promise<Response>",
192
- children: _alloy_js_core.code`return fetchContextStorage.run(context, () => callback(context.request, context.env, context.ctx)); `
193
- }),
194
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components.Spacing, {}),
195
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components.Spacing, {}),
196
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration, {
197
- "export": true,
198
- name: "CloudflareScheduledContext",
199
- typeParameters: [{
200
- name: "Env",
201
- default: "CloudflareBindings"
202
- }],
203
- doc: "An interface representing the runtime context for Cloudflare scheduled operations, containing relevant information and utilities for performing actions within the Cloudflare environment.",
204
- get children() {
205
- return [
206
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
207
- name: "controller",
208
- type: "ScheduledController",
209
- doc: "The Cloudflare scheduled controller for the scheduled operation."
210
- }),
211
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
212
- name: "env",
213
- type: "Env",
214
- doc: "The Cloudflare environment bindings available during runtime."
215
- }),
216
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
217
- name: "ctx",
218
- type: "ExecutionContext",
219
- doc: "The Cloudflare execution context for the scheduled operation."
220
- })
221
- ];
222
- }
223
- }),
224
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
225
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
226
- "const": true,
227
- name: "CLOUDFLARE_SCHEDULED_CONTEXT_KEY",
228
- initializer: _alloy_js_core.code`Symbol.for("powerlines-cloudflare-scheduled"); `
229
- }),
230
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
231
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
232
- "export": true,
233
- "const": true,
234
- name: "scheduledContextStorage",
235
- doc: "An AsyncLocalStorage instance for managing the Cloudflare scheduled runtime context.",
236
- initializer: _alloy_js_core.code`(globalContextStorage[CLOUDFLARE_SCHEDULED_CONTEXT_KEY] ??= new AsyncLocalStorage<CloudflareScheduledContext>()) as AsyncLocalStorage<CloudflareScheduledContext>; `
237
- }),
238
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
239
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
240
- heading: "Retrieves the current Cloudflare scheduled runtime context from the AsyncLocalStorage. This context contains relevant information and utilities for performing actions within the Cloudflare environment. If no context is currently set, this function will throw an error.",
241
- get children() {
242
- return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: _alloy_js_core.code`The current Cloudflare scheduled runtime context.` });
243
- }
244
- }),
245
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
246
- "export": true,
247
- name: "getScheduledContext",
248
- typeParameters: [{
249
- name: "Env",
250
- default: "CloudflareBindings"
251
- }],
252
- parameters: [],
253
- returnType: "CloudflareScheduledContext<Env>",
254
- children: _alloy_js_core.code`const context = scheduledContextStorage.getStore();
104
+ return context as CloudflareFetchContext<Env, CfHostMetadata>; `}
105
+ </_alloy_js_typescript.FunctionDeclaration>
106
+ <hbr />
107
+ <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc heading="Runs a given function within the scope of a Cloudflare fetch context. This is typically used to set up the context for handling a Cloudflare fetch request, ensuring that any code executed within the function has access to the relevant Cloudflare environment information and utilities. The provided context will be available through the `getFetchContext` function for any code executed within the callback.">
108
+ <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam name="context">{_alloy_js_core.code`The Cloudflare fetch context to run the function with.`}</_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam>
109
+ <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam name="callback">{_alloy_js_core.code`The function to execute within the scope of the provided context.`}</_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam>
110
+ <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns>{_alloy_js_core.code`The result of the executed function.`}</_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns>
111
+ </_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc>
112
+ <_alloy_js_typescript.FunctionDeclaration export name="withFetchContext" typeParameters={[{
113
+ name: "Env",
114
+ default: "CloudflareBindings"
115
+ }, {
116
+ name: "CfHostMetadata",
117
+ default: "unknown"
118
+ }]} parameters={[{
119
+ name: "context",
120
+ type: "CloudflareFetchContext<Env, CfHostMetadata>"
121
+ }, {
122
+ name: "callback",
123
+ type: "(request: Request<CfHostMetadata, IncomingRequestCfProperties<CfHostMetadata>>, env: Env, ctx: ExecutionContext) => Promise<Response>"
124
+ }]} returnType="Promise<Response>">
125
+ {_alloy_js_core.code`return fetchContextStorage.run(context, () => callback(context.request, context.env, context.ctx)); `}
126
+ </_alloy_js_typescript.FunctionDeclaration>
127
+ <_powerlines_plugin_alloy_core_components.Spacing />
128
+ <_powerlines_plugin_alloy_core_components.Spacing />
129
+ <_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration export name="CloudflareScheduledContext" typeParameters={[{
130
+ name: "Env",
131
+ default: "CloudflareBindings"
132
+ }]} doc="An interface representing the runtime context for Cloudflare scheduled operations, containing relevant information and utilities for performing actions within the Cloudflare environment.">
133
+ <_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember name="controller" type="ScheduledController" doc="The Cloudflare scheduled controller for the scheduled operation." />
134
+ <_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember name="env" type="Env" doc="The Cloudflare environment bindings available during runtime." />
135
+ <_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember name="ctx" type="ExecutionContext" doc="The Cloudflare execution context for the scheduled operation." />
136
+ </_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration>
137
+ <hbr />
138
+ <_alloy_js_typescript.VarDeclaration const name="CLOUDFLARE_SCHEDULED_CONTEXT_KEY" initializer={_alloy_js_core.code`Symbol.for("powerlines-cloudflare-scheduled"); `} />
139
+ <hbr />
140
+ <_alloy_js_typescript.VarDeclaration export const name="scheduledContextStorage" doc="An AsyncLocalStorage instance for managing the Cloudflare scheduled runtime context." initializer={_alloy_js_core.code`(globalContextStorage[CLOUDFLARE_SCHEDULED_CONTEXT_KEY] ??= new AsyncLocalStorage<CloudflareScheduledContext>()) as AsyncLocalStorage<CloudflareScheduledContext>; `} />
141
+ <hbr />
142
+ <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc heading="Retrieves the current Cloudflare scheduled runtime context from the AsyncLocalStorage. This context contains relevant information and utilities for performing actions within the Cloudflare environment. If no context is currently set, this function will throw an error.">
143
+ <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns>{_alloy_js_core.code`The current Cloudflare scheduled runtime context.`}</_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns>
144
+ </_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc>
145
+ <_alloy_js_typescript.FunctionDeclaration export name="getScheduledContext" typeParameters={[{
146
+ name: "Env",
147
+ default: "CloudflareBindings"
148
+ }]} parameters={[]} returnType="CloudflareScheduledContext<Env>">
149
+ {_alloy_js_core.code`const context = scheduledContextStorage.getStore();
255
150
  if (!context) {
256
151
  throw new Error("Cloudflare scheduled context is not available. Ensure that you are calling this function within the scope of a Cloudflare scheduled operation.");
257
152
  }
258
- return context as CloudflareScheduledContext<Env>; `
259
- }),
260
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
261
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
262
- heading: "Runs a given function within the scope of a Cloudflare scheduled context. This is typically used to set up the context for handling a Cloudflare scheduled operation, ensuring that any code executed within the function has access to the relevant Cloudflare environment information and utilities. The provided context will be available through the `getScheduledContext` function for any code executed within the callback.",
263
- get children() {
264
- return [
265
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
266
- name: "context",
267
- children: _alloy_js_core.code`The Cloudflare scheduled context to run the function with.`
268
- }),
269
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
270
- name: "callback",
271
- children: _alloy_js_core.code`The function to execute within the scope of the provided context.`
272
- }),
273
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: _alloy_js_core.code`The result of the executed function.` })
274
- ];
275
- }
276
- }),
277
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
278
- "export": true,
279
- name: "withScheduledContext",
280
- typeParameters: [{
281
- name: "Env",
282
- default: "CloudflareBindings"
283
- }],
284
- parameters: [{
285
- name: "context",
286
- type: "CloudflareScheduledContext<Env>"
287
- }, {
288
- name: "callback",
289
- type: "(ctx: CloudflareScheduledContext<Env>) => Promise<void>"
290
- }],
291
- returnType: "Promise<void>",
292
- children: _alloy_js_core.code`return scheduledContextStorage.run(context, () => callback(context)); `
293
- }),
294
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components.Spacing, {}),
295
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components.Spacing, {}),
296
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration, {
297
- "export": true,
298
- name: "CloudflareEmailContext",
299
- typeParameters: [{
300
- name: "Env",
301
- default: "CloudflareBindings"
302
- }],
303
- doc: "An interface representing the runtime context for Cloudflare email operations, containing relevant information and utilities for performing actions within the Cloudflare environment.",
304
- get children() {
305
- return [
306
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
307
- name: "message",
308
- type: "ForwardableEmailMessage",
309
- doc: "The Cloudflare email instance for the email operation."
310
- }),
311
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
312
- name: "env",
313
- type: "Env",
314
- doc: "The Cloudflare environment bindings available during runtime."
315
- }),
316
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
317
- name: "ctx",
318
- type: "ExecutionContext",
319
- doc: "The Cloudflare execution context for the email operation."
320
- })
321
- ];
322
- }
323
- }),
324
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
325
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
326
- "const": true,
327
- name: "CLOUDFLARE_EMAIL_CONTEXT_KEY",
328
- initializer: _alloy_js_core.code`Symbol.for("powerlines-cloudflare-email"); `
329
- }),
330
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
331
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
332
- "export": true,
333
- "const": true,
334
- name: "emailContextStorage",
335
- doc: "An AsyncLocalStorage instance for managing the Cloudflare email runtime context.",
336
- initializer: _alloy_js_core.code`(globalContextStorage[CLOUDFLARE_EMAIL_CONTEXT_KEY] ??= new AsyncLocalStorage<CloudflareEmailContext>()) as AsyncLocalStorage<CloudflareEmailContext>; `
337
- }),
338
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
339
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
340
- heading: "Retrieves the current Cloudflare email runtime context from the AsyncLocalStorage. This context contains relevant information and utilities for performing actions within the Cloudflare environment. If no context is currently set, this function will throw an error.",
341
- get children() {
342
- return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: _alloy_js_core.code`The current Cloudflare email runtime context.` });
343
- }
344
- }),
345
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
346
- "export": true,
347
- name: "getEmailContext",
348
- typeParameters: [{
349
- name: "Env",
350
- default: "CloudflareBindings"
351
- }],
352
- parameters: [],
353
- returnType: "CloudflareEmailContext<Env>",
354
- children: _alloy_js_core.code`const context = emailContextStorage.getStore();
153
+ return context as CloudflareScheduledContext<Env>; `}
154
+ </_alloy_js_typescript.FunctionDeclaration>
155
+ <hbr />
156
+ <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc heading="Runs a given function within the scope of a Cloudflare scheduled context. This is typically used to set up the context for handling a Cloudflare scheduled operation, ensuring that any code executed within the function has access to the relevant Cloudflare environment information and utilities. The provided context will be available through the `getScheduledContext` function for any code executed within the callback.">
157
+ <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam name="context">{_alloy_js_core.code`The Cloudflare scheduled context to run the function with.`}</_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam>
158
+ <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam name="callback">{_alloy_js_core.code`The function to execute within the scope of the provided context.`}</_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam>
159
+ <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns>{_alloy_js_core.code`The result of the executed function.`}</_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns>
160
+ </_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc>
161
+ <_alloy_js_typescript.FunctionDeclaration export name="withScheduledContext" typeParameters={[{
162
+ name: "Env",
163
+ default: "CloudflareBindings"
164
+ }]} parameters={[{
165
+ name: "context",
166
+ type: "CloudflareScheduledContext<Env>"
167
+ }, {
168
+ name: "callback",
169
+ type: "(ctx: CloudflareScheduledContext<Env>) => Promise<void>"
170
+ }]} returnType="Promise<void>">
171
+ {_alloy_js_core.code`return scheduledContextStorage.run(context, () => callback(context)); `}
172
+ </_alloy_js_typescript.FunctionDeclaration>
173
+ <_powerlines_plugin_alloy_core_components.Spacing />
174
+ <_powerlines_plugin_alloy_core_components.Spacing />
175
+ <_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration export name="CloudflareEmailContext" typeParameters={[{
176
+ name: "Env",
177
+ default: "CloudflareBindings"
178
+ }]} doc="An interface representing the runtime context for Cloudflare email operations, containing relevant information and utilities for performing actions within the Cloudflare environment.">
179
+ <_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember name="message" type="ForwardableEmailMessage" doc="The Cloudflare email instance for the email operation." />
180
+ <_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember name="env" type="Env" doc="The Cloudflare environment bindings available during runtime." />
181
+ <_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember name="ctx" type="ExecutionContext" doc="The Cloudflare execution context for the email operation." />
182
+ </_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration>
183
+ <hbr />
184
+ <_alloy_js_typescript.VarDeclaration const name="CLOUDFLARE_EMAIL_CONTEXT_KEY" initializer={_alloy_js_core.code`Symbol.for("powerlines-cloudflare-email"); `} />
185
+ <hbr />
186
+ <_alloy_js_typescript.VarDeclaration export const name="emailContextStorage" doc="An AsyncLocalStorage instance for managing the Cloudflare email runtime context." initializer={_alloy_js_core.code`(globalContextStorage[CLOUDFLARE_EMAIL_CONTEXT_KEY] ??= new AsyncLocalStorage<CloudflareEmailContext>()) as AsyncLocalStorage<CloudflareEmailContext>; `} />
187
+ <hbr />
188
+ <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc heading="Retrieves the current Cloudflare email runtime context from the AsyncLocalStorage. This context contains relevant information and utilities for performing actions within the Cloudflare environment. If no context is currently set, this function will throw an error.">
189
+ <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns>{_alloy_js_core.code`The current Cloudflare email runtime context.`}</_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns>
190
+ </_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc>
191
+ <_alloy_js_typescript.FunctionDeclaration export name="getEmailContext" typeParameters={[{
192
+ name: "Env",
193
+ default: "CloudflareBindings"
194
+ }]} parameters={[]} returnType="CloudflareEmailContext<Env>">
195
+ {_alloy_js_core.code`const context = emailContextStorage.getStore();
355
196
  if (!context) {
356
197
  throw new Error("Cloudflare email context is not available. Ensure that you are calling this function within the scope of a Cloudflare email operation.");
357
198
  }
358
- return context as CloudflareEmailContext<Env>; `
359
- }),
360
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
361
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
362
- heading: "Runs a given function within the scope of a Cloudflare email context. This is typically used to set up the context for handling a Cloudflare email operation, ensuring that any code executed within the function has access to the relevant Cloudflare environment information and utilities. The provided context will be available through the `getEmailContext` function for any code executed within the callback.",
363
- get children() {
364
- return [
365
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
366
- name: "context",
367
- children: _alloy_js_core.code`The Cloudflare email context to run the function with.`
368
- }),
369
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
370
- name: "callback",
371
- children: _alloy_js_core.code`The function to execute within the scope of the provided context.`
372
- }),
373
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: _alloy_js_core.code`A promise that resolves with the result of the executed function.` })
374
- ];
375
- }
376
- }),
377
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
378
- "export": true,
379
- name: "withEmailContext",
380
- typeParameters: [{
381
- name: "Env",
382
- default: "CloudflareBindings"
383
- }],
384
- parameters: [{
385
- name: "context",
386
- type: "CloudflareEmailContext<Env>"
387
- }, {
388
- name: "callback",
389
- type: "(ctx: CloudflareEmailContext<Env>) => Promise<void>"
390
- }],
391
- returnType: "Promise<void>",
392
- children: _alloy_js_core.code`return emailContextStorage.run(context, () => callback(context)); `
393
- }),
394
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components.Spacing, {}),
395
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components.Spacing, {}),
396
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration, {
397
- "export": true,
398
- name: "CloudflareQueueContext",
399
- typeParameters: [{
400
- name: "Message",
401
- default: "unknown"
402
- }, {
403
- name: "Env",
404
- default: "CloudflareBindings"
405
- }],
406
- doc: "An interface representing the runtime context for Cloudflare queue operations, containing relevant information and utilities for performing actions within the Cloudflare environment.",
407
- get children() {
408
- return [
409
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
410
- name: "batch",
411
- type: "MessageBatch<Message>",
412
- doc: "The Cloudflare queue event instance for the queue operation."
413
- }),
414
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
415
- name: "env",
416
- type: "Env",
417
- doc: "The Cloudflare environment bindings available during runtime."
418
- }),
419
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
420
- name: "ctx",
421
- type: "ExecutionContext",
422
- doc: "The Cloudflare execution context for the queue operation."
423
- })
424
- ];
425
- }
426
- }),
427
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
428
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
429
- "const": true,
430
- name: "CLOUDFLARE_QUEUE_CONTEXT_KEY",
431
- initializer: _alloy_js_core.code`Symbol.for("powerlines-cloudflare-queue"); `
432
- }),
433
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
434
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
435
- "export": true,
436
- "const": true,
437
- name: "queueContextStorage",
438
- doc: "An AsyncLocalStorage instance for managing the Cloudflare queue runtime context.",
439
- initializer: _alloy_js_core.code`(globalContextStorage[CLOUDFLARE_QUEUE_CONTEXT_KEY] ??= new AsyncLocalStorage<CloudflareQueueContext>()) as AsyncLocalStorage<CloudflareQueueContext>; `
440
- }),
441
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
442
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
443
- heading: "Retrieves the current Cloudflare queue runtime context from the AsyncLocalStorage. This context contains relevant information and utilities for performing actions within the Cloudflare environment. If no context is currently set, this function will throw an error.",
444
- get children() {
445
- return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: _alloy_js_core.code`The current Cloudflare queue runtime context.` });
446
- }
447
- }),
448
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
449
- "export": true,
450
- name: "getQueueContext",
451
- typeParameters: [{
452
- name: "Message",
453
- default: "unknown"
454
- }, {
455
- name: "Env",
456
- default: "CloudflareBindings"
457
- }],
458
- parameters: [],
459
- returnType: "CloudflareQueueContext<Message, Env>",
460
- children: _alloy_js_core.code`const context = queueContextStorage.getStore();
199
+ return context as CloudflareEmailContext<Env>; `}
200
+ </_alloy_js_typescript.FunctionDeclaration>
201
+ <hbr />
202
+ <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc heading="Runs a given function within the scope of a Cloudflare email context. This is typically used to set up the context for handling a Cloudflare email operation, ensuring that any code executed within the function has access to the relevant Cloudflare environment information and utilities. The provided context will be available through the `getEmailContext` function for any code executed within the callback.">
203
+ <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam name="context">{_alloy_js_core.code`The Cloudflare email context to run the function with.`}</_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam>
204
+ <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam name="callback">{_alloy_js_core.code`The function to execute within the scope of the provided context.`}</_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam>
205
+ <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns>{_alloy_js_core.code`A promise that resolves with the result of the executed function.`}</_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns>
206
+ </_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc>
207
+ <_alloy_js_typescript.FunctionDeclaration export name="withEmailContext" typeParameters={[{
208
+ name: "Env",
209
+ default: "CloudflareBindings"
210
+ }]} parameters={[{
211
+ name: "context",
212
+ type: "CloudflareEmailContext<Env>"
213
+ }, {
214
+ name: "callback",
215
+ type: "(ctx: CloudflareEmailContext<Env>) => Promise<void>"
216
+ }]} returnType="Promise<void>">
217
+ {_alloy_js_core.code`return emailContextStorage.run(context, () => callback(context)); `}
218
+ </_alloy_js_typescript.FunctionDeclaration>
219
+ <_powerlines_plugin_alloy_core_components.Spacing />
220
+ <_powerlines_plugin_alloy_core_components.Spacing />
221
+ <_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration export name="CloudflareQueueContext" typeParameters={[{
222
+ name: "Message",
223
+ default: "unknown"
224
+ }, {
225
+ name: "Env",
226
+ default: "CloudflareBindings"
227
+ }]} doc="An interface representing the runtime context for Cloudflare queue operations, containing relevant information and utilities for performing actions within the Cloudflare environment.">
228
+ <_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember name="batch" type="MessageBatch<Message>" doc="The Cloudflare queue event instance for the queue operation." />
229
+ <_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember name="env" type="Env" doc="The Cloudflare environment bindings available during runtime." />
230
+ <_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember name="ctx" type="ExecutionContext" doc="The Cloudflare execution context for the queue operation." />
231
+ </_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration>
232
+ <hbr />
233
+ <_alloy_js_typescript.VarDeclaration const name="CLOUDFLARE_QUEUE_CONTEXT_KEY" initializer={_alloy_js_core.code`Symbol.for("powerlines-cloudflare-queue"); `} />
234
+ <hbr />
235
+ <_alloy_js_typescript.VarDeclaration export const name="queueContextStorage" doc="An AsyncLocalStorage instance for managing the Cloudflare queue runtime context." initializer={_alloy_js_core.code`(globalContextStorage[CLOUDFLARE_QUEUE_CONTEXT_KEY] ??= new AsyncLocalStorage<CloudflareQueueContext>()) as AsyncLocalStorage<CloudflareQueueContext>; `} />
236
+ <hbr />
237
+ <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc heading="Retrieves the current Cloudflare queue runtime context from the AsyncLocalStorage. This context contains relevant information and utilities for performing actions within the Cloudflare environment. If no context is currently set, this function will throw an error.">
238
+ <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns>{_alloy_js_core.code`The current Cloudflare queue runtime context.`}</_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns>
239
+ </_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc>
240
+ <_alloy_js_typescript.FunctionDeclaration export name="getQueueContext" typeParameters={[{
241
+ name: "Message",
242
+ default: "unknown"
243
+ }, {
244
+ name: "Env",
245
+ default: "CloudflareBindings"
246
+ }]} parameters={[]} returnType="CloudflareQueueContext<Message, Env>">
247
+ {_alloy_js_core.code`const context = queueContextStorage.getStore();
461
248
  if (!context) {
462
249
  throw new Error("Cloudflare queue context is not available. Ensure that you are calling this function within the scope of a Cloudflare queue operation.");
463
250
  }
464
- return context as CloudflareQueueContext<Message, Env>; `
465
- }),
466
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
467
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
468
- heading: "Runs a given function within the scope of a Cloudflare queue context. This is typically used to set up the context for handling a Cloudflare queue operation, ensuring that any code executed within the function has access to the relevant Cloudflare environment information and utilities. The provided context will be available through the `getQueueContext` function for any code executed within the callback.",
469
- get children() {
470
- return [
471
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
472
- name: "context",
473
- children: _alloy_js_core.code`The Cloudflare queue context to run the function with.`
474
- }),
475
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
476
- name: "callback",
477
- children: _alloy_js_core.code`The function to execute within the scope of the provided context.`
478
- }),
479
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: _alloy_js_core.code`The result of the executed function.` })
480
- ];
481
- }
482
- }),
483
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
484
- "export": true,
485
- name: "withQueueContext",
486
- typeParameters: [{
487
- name: "Message",
488
- default: "unknown"
489
- }, {
490
- name: "Env",
491
- default: "CloudflareBindings"
492
- }],
493
- parameters: [{
494
- name: "context",
495
- type: "CloudflareQueueContext<Message, Env>"
496
- }, {
497
- name: "callback",
498
- type: "(ctx: CloudflareQueueContext<Message, Env>) => Promise<void>"
499
- }],
500
- returnType: "Promise<void>",
501
- children: _alloy_js_core.code`return queueContextStorage.run(context, () => callback(context)); `
502
- }),
503
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components.Spacing, {}),
504
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components.Spacing, {}),
505
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration, {
506
- "export": true,
507
- name: "CloudflareTailContext",
508
- typeParameters: [{
509
- name: "Env",
510
- default: "CloudflareBindings"
511
- }],
512
- doc: "An interface representing the tail context for Cloudflare tail operations, containing relevant information and utilities for performing actions within the Cloudflare environment.",
513
- get children() {
514
- return [
515
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
516
- name: "events",
517
- type: "TraceItem[]",
518
- doc: "An array of trace items representing the events in the Cloudflare tail context."
519
- }),
520
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
521
- name: "env",
522
- type: "Env",
523
- doc: "The Cloudflare environment bindings available during runtime."
524
- }),
525
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
526
- name: "ctx",
527
- type: "ExecutionContext",
528
- doc: "The Cloudflare execution context for the tail operation."
529
- })
530
- ];
531
- }
532
- }),
533
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
534
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
535
- "const": true,
536
- name: "CLOUDFLARE_TAIL_CONTEXT_KEY",
537
- initializer: _alloy_js_core.code`Symbol.for("powerlines-cloudflare-tail"); `
538
- }),
539
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
540
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
541
- "export": true,
542
- "const": true,
543
- name: "tailContextStorage",
544
- doc: "An AsyncLocalStorage instance for managing the Cloudflare tail runtime context.",
545
- initializer: _alloy_js_core.code`(globalContextStorage[CLOUDFLARE_TAIL_CONTEXT_KEY] ??= new AsyncLocalStorage<CloudflareTailContext>()) as AsyncLocalStorage<CloudflareTailContext>; `
546
- }),
547
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
548
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
549
- heading: "Retrieves the current Cloudflare tail runtime context from the AsyncLocalStorage. This context contains relevant information and utilities for performing actions within the Cloudflare environment. If no context is currently set, this function will throw an error.",
550
- get children() {
551
- return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: _alloy_js_core.code`The current Cloudflare tail runtime context.` });
552
- }
553
- }),
554
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
555
- "export": true,
556
- name: "getTailContext",
557
- typeParameters: [{
558
- name: "Env",
559
- default: "CloudflareBindings"
560
- }],
561
- parameters: [],
562
- returnType: "CloudflareTailContext<Env>",
563
- children: _alloy_js_core.code`const context = tailContextStorage.getStore();
251
+ return context as CloudflareQueueContext<Message, Env>; `}
252
+ </_alloy_js_typescript.FunctionDeclaration>
253
+ <hbr />
254
+ <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc heading="Runs a given function within the scope of a Cloudflare queue context. This is typically used to set up the context for handling a Cloudflare queue operation, ensuring that any code executed within the function has access to the relevant Cloudflare environment information and utilities. The provided context will be available through the `getQueueContext` function for any code executed within the callback.">
255
+ <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam name="context">{_alloy_js_core.code`The Cloudflare queue context to run the function with.`}</_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam>
256
+ <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam name="callback">{_alloy_js_core.code`The function to execute within the scope of the provided context.`}</_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam>
257
+ <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns>{_alloy_js_core.code`The result of the executed function.`}</_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns>
258
+ </_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc>
259
+ <_alloy_js_typescript.FunctionDeclaration export name="withQueueContext" typeParameters={[{
260
+ name: "Message",
261
+ default: "unknown"
262
+ }, {
263
+ name: "Env",
264
+ default: "CloudflareBindings"
265
+ }]} parameters={[{
266
+ name: "context",
267
+ type: "CloudflareQueueContext<Message, Env>"
268
+ }, {
269
+ name: "callback",
270
+ type: "(ctx: CloudflareQueueContext<Message, Env>) => Promise<void>"
271
+ }]} returnType="Promise<void>">
272
+ {_alloy_js_core.code`return queueContextStorage.run(context, () => callback(context)); `}
273
+ </_alloy_js_typescript.FunctionDeclaration>
274
+ <_powerlines_plugin_alloy_core_components.Spacing />
275
+ <_powerlines_plugin_alloy_core_components.Spacing />
276
+ <_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration export name="CloudflareTailContext" typeParameters={[{
277
+ name: "Env",
278
+ default: "CloudflareBindings"
279
+ }]} doc="An interface representing the tail context for Cloudflare tail operations, containing relevant information and utilities for performing actions within the Cloudflare environment.">
280
+ <_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember name="events" type="TraceItem[]" doc="An array of trace items representing the events in the Cloudflare tail context." />
281
+ <_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember name="env" type="Env" doc="The Cloudflare environment bindings available during runtime." />
282
+ <_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember name="ctx" type="ExecutionContext" doc="The Cloudflare execution context for the tail operation." />
283
+ </_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration>
284
+ <hbr />
285
+ <_alloy_js_typescript.VarDeclaration const name="CLOUDFLARE_TAIL_CONTEXT_KEY" initializer={_alloy_js_core.code`Symbol.for("powerlines-cloudflare-tail"); `} />
286
+ <hbr />
287
+ <_alloy_js_typescript.VarDeclaration export const name="tailContextStorage" doc="An AsyncLocalStorage instance for managing the Cloudflare tail runtime context." initializer={_alloy_js_core.code`(globalContextStorage[CLOUDFLARE_TAIL_CONTEXT_KEY] ??= new AsyncLocalStorage<CloudflareTailContext>()) as AsyncLocalStorage<CloudflareTailContext>; `} />
288
+ <hbr />
289
+ <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc heading="Retrieves the current Cloudflare tail runtime context from the AsyncLocalStorage. This context contains relevant information and utilities for performing actions within the Cloudflare environment. If no context is currently set, this function will throw an error.">
290
+ <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns>{_alloy_js_core.code`The current Cloudflare tail runtime context.`}</_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns>
291
+ </_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc>
292
+ <_alloy_js_typescript.FunctionDeclaration export name="getTailContext" typeParameters={[{
293
+ name: "Env",
294
+ default: "CloudflareBindings"
295
+ }]} parameters={[]} returnType="CloudflareTailContext<Env>">
296
+ {_alloy_js_core.code`const context = tailContextStorage.getStore();
564
297
  if (!context) {
565
298
  throw new Error("Cloudflare tail context is not available. Ensure that you are calling this function within the scope of a Cloudflare tail operation.");
566
299
  }
567
- return context as CloudflareTailContext<Env>; `
568
- }),
569
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
570
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
571
- heading: "Runs a given function within the scope of a Cloudflare tail context. This is typically used to set up the context for handling a Cloudflare tail operation, ensuring that any code executed within the function has access to the relevant Cloudflare environment information and utilities. The provided context will be available through the `getTailContext` function for any code executed within the callback.",
572
- get children() {
573
- return [
574
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
575
- name: "context",
576
- children: _alloy_js_core.code`The Cloudflare tail context to run the function with.`
577
- }),
578
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
579
- name: "callback",
580
- children: _alloy_js_core.code`The function to execute within the scope of the provided context.`
581
- }),
582
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: _alloy_js_core.code`The result of the executed function.` })
583
- ];
584
- }
585
- }),
586
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
587
- "export": true,
588
- name: "withTailContext",
589
- typeParameters: [{
590
- name: "Env",
591
- default: "CloudflareBindings"
592
- }],
593
- parameters: [{
594
- name: "context",
595
- type: "CloudflareTailContext<Env>"
596
- }, {
597
- name: "callback",
598
- type: "(ctx: CloudflareTailContext<Env>) => Promise<void>"
599
- }],
600
- returnType: "T",
601
- children: _alloy_js_core.code`return tailContextStorage.run(context, () => callback(context)); `
602
- }),
603
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components.Spacing, {}),
604
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components.Spacing, {}),
605
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration, {
606
- "export": true,
607
- name: "CloudflareTailStreamContext",
608
- typeParameters: [{
609
- name: "Env",
610
- default: "CloudflareBindings"
611
- }],
612
- doc: "An interface representing the tail context for Cloudflare tail stream operations, containing relevant information and utilities for performing actions within the Cloudflare environment.",
613
- get children() {
614
- return [
615
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
616
- name: "event",
617
- type: "TailStream.TailEvent<TailStream.Onset>",
618
- doc: "The tail event associated with the Cloudflare tail stream context."
619
- }),
620
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
621
- name: "env",
622
- type: "Env",
623
- doc: "The Cloudflare environment bindings available during runtime."
624
- }),
625
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
626
- name: "ctx",
627
- type: "ExecutionContext",
628
- doc: "The Cloudflare execution context for the tail stream operation."
629
- })
630
- ];
631
- }
632
- }),
633
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
634
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
635
- "const": true,
636
- name: "CLOUDFLARE_TAIL_STREAM_CONTEXT_KEY",
637
- initializer: _alloy_js_core.code`Symbol.for("powerlines-cloudflare-tail-stream"); `
638
- }),
639
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
640
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
641
- "export": true,
642
- "const": true,
643
- name: "tailStreamContextStorage",
644
- doc: "An AsyncLocalStorage instance for managing the Cloudflare tail stream runtime context.",
645
- initializer: _alloy_js_core.code`(globalContextStorage[CLOUDFLARE_TAIL_STREAM_CONTEXT_KEY] ??= new AsyncLocalStorage<CloudflareTailStreamContext>()) as AsyncLocalStorage<CloudflareTailStreamContext>; `
646
- }),
647
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
648
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
649
- heading: "Retrieves the current Cloudflare tail stream runtime context from the AsyncLocalStorage. This context contains relevant information and utilities for performing actions within the Cloudflare environment. If no context is currently set, this function will throw an error.",
650
- get children() {
651
- return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: _alloy_js_core.code`The current Cloudflare tail stream runtime context.` });
652
- }
653
- }),
654
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
655
- "export": true,
656
- name: "getTailStreamContext",
657
- typeParameters: [{
658
- name: "Env",
659
- default: "CloudflareBindings"
660
- }],
661
- parameters: [],
662
- returnType: "CloudflareTailStreamContext<Env>",
663
- children: _alloy_js_core.code`const context = tailStreamContextStorage.getStore();
300
+ return context as CloudflareTailContext<Env>; `}
301
+ </_alloy_js_typescript.FunctionDeclaration>
302
+ <hbr />
303
+ <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc heading="Runs a given function within the scope of a Cloudflare tail context. This is typically used to set up the context for handling a Cloudflare tail operation, ensuring that any code executed within the function has access to the relevant Cloudflare environment information and utilities. The provided context will be available through the `getTailContext` function for any code executed within the callback.">
304
+ <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam name="context">{_alloy_js_core.code`The Cloudflare tail context to run the function with.`}</_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam>
305
+ <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam name="callback">{_alloy_js_core.code`The function to execute within the scope of the provided context.`}</_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam>
306
+ <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns>{_alloy_js_core.code`The result of the executed function.`}</_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns>
307
+ </_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc>
308
+ <_alloy_js_typescript.FunctionDeclaration export name="withTailContext" typeParameters={[{
309
+ name: "Env",
310
+ default: "CloudflareBindings"
311
+ }]} parameters={[{
312
+ name: "context",
313
+ type: "CloudflareTailContext<Env>"
314
+ }, {
315
+ name: "callback",
316
+ type: "(ctx: CloudflareTailContext<Env>) => Promise<void>"
317
+ }]} returnType="T">
318
+ {_alloy_js_core.code`return tailContextStorage.run(context, () => callback(context)); `}
319
+ </_alloy_js_typescript.FunctionDeclaration>
320
+ <_powerlines_plugin_alloy_core_components.Spacing />
321
+ <_powerlines_plugin_alloy_core_components.Spacing />
322
+ <_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration export name="CloudflareTailStreamContext" typeParameters={[{
323
+ name: "Env",
324
+ default: "CloudflareBindings"
325
+ }]} doc="An interface representing the tail context for Cloudflare tail stream operations, containing relevant information and utilities for performing actions within the Cloudflare environment.">
326
+ <_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember name="event" type="TailStream.TailEvent<TailStream.Onset>" doc="The tail event associated with the Cloudflare tail stream context." />
327
+ <_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember name="env" type="Env" doc="The Cloudflare environment bindings available during runtime." />
328
+ <_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember name="ctx" type="ExecutionContext" doc="The Cloudflare execution context for the tail stream operation." />
329
+ </_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration>
330
+ <hbr />
331
+ <_alloy_js_typescript.VarDeclaration const name="CLOUDFLARE_TAIL_STREAM_CONTEXT_KEY" initializer={_alloy_js_core.code`Symbol.for("powerlines-cloudflare-tail-stream"); `} />
332
+ <hbr />
333
+ <_alloy_js_typescript.VarDeclaration export const name="tailStreamContextStorage" doc="An AsyncLocalStorage instance for managing the Cloudflare tail stream runtime context." initializer={_alloy_js_core.code`(globalContextStorage[CLOUDFLARE_TAIL_STREAM_CONTEXT_KEY] ??= new AsyncLocalStorage<CloudflareTailStreamContext>()) as AsyncLocalStorage<CloudflareTailStreamContext>; `} />
334
+ <hbr />
335
+ <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc heading="Retrieves the current Cloudflare tail stream runtime context from the AsyncLocalStorage. This context contains relevant information and utilities for performing actions within the Cloudflare environment. If no context is currently set, this function will throw an error.">
336
+ <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns>{_alloy_js_core.code`The current Cloudflare tail stream runtime context.`}</_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns>
337
+ </_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc>
338
+ <_alloy_js_typescript.FunctionDeclaration export name="getTailStreamContext" typeParameters={[{
339
+ name: "Env",
340
+ default: "CloudflareBindings"
341
+ }]} parameters={[]} returnType="CloudflareTailStreamContext<Env>">
342
+ {_alloy_js_core.code`const context = tailStreamContextStorage.getStore();
664
343
  if (!context) {
665
344
  throw new Error("Cloudflare tail stream context is not available. Ensure that you are calling this function within the scope of a Cloudflare tail stream operation.");
666
345
  }
667
- return context as CloudflareTailStreamContext<Env>; `
668
- }),
669
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
670
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
671
- heading: "Runs a given function within the scope of a Cloudflare tail stream context. This is typically used to set up the context for handling a Cloudflare tail stream operation, ensuring that any code executed within the function has access to the relevant Cloudflare environment information and utilities. The provided context will be available through the `getTailStreamContext` function for any code executed within the callback.",
672
- get children() {
673
- return [
674
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
675
- name: "context",
676
- children: _alloy_js_core.code`The Cloudflare tail stream context to run the function with.`
677
- }),
678
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
679
- name: "callback",
680
- children: _alloy_js_core.code`The function to execute within the scope of the provided context.`
681
- }),
682
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: _alloy_js_core.code`The result of the executed function.` })
683
- ];
684
- }
685
- }),
686
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
687
- "export": true,
688
- name: "withTailStreamContext",
689
- typeParameters: [{
690
- name: "Env",
691
- default: "CloudflareBindings"
692
- }],
693
- parameters: [{
694
- name: "context",
695
- type: "CloudflareTailStreamContext<Env>"
696
- }, {
697
- name: "callback",
698
- type: "(ctx: CloudflareTailStreamContext<Env>) => Promise<TailStream.TailEventHandlerType>"
699
- }],
700
- returnType: "Promise<TailStream.TailEventHandlerType>",
701
- children: _alloy_js_core.code`return tailStreamContextStorage.run(context, () => callback(context)); `
702
- }),
703
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components.Spacing, {}),
704
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components.Spacing, {}),
705
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration, {
706
- "export": true,
707
- name: "CloudflareTraceContext",
708
- typeParameters: [{
709
- name: "Env",
710
- default: "CloudflareBindings"
711
- }],
712
- doc: "An interface representing the trace context for Cloudflare trace operations, containing relevant information and utilities for performing actions within the Cloudflare environment.",
713
- get children() {
714
- return [
715
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
716
- name: "traces",
717
- type: "TraceItem[]",
718
- doc: "An array of trace items associated with the Cloudflare trace context."
719
- }),
720
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
721
- name: "env",
722
- type: "Env",
723
- doc: "The Cloudflare environment bindings available during runtime."
724
- }),
725
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
726
- name: "ctx",
727
- type: "ExecutionContext",
728
- doc: "The Cloudflare execution context for the trace operation."
729
- })
730
- ];
731
- }
732
- }),
733
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
734
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
735
- "const": true,
736
- name: "CLOUDFLARE_TRACE_CONTEXT_KEY",
737
- initializer: _alloy_js_core.code`Symbol.for("powerlines-cloudflare-trace"); `
738
- }),
739
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
740
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
741
- "export": true,
742
- "const": true,
743
- name: "traceContextStorage",
744
- doc: "An AsyncLocalStorage instance for managing the Cloudflare trace runtime context.",
745
- initializer: _alloy_js_core.code`(globalContextStorage[CLOUDFLARE_TRACE_CONTEXT_KEY] ??= new AsyncLocalStorage<CloudflareTraceContext>()) as AsyncLocalStorage<CloudflareTraceContext>; `
746
- }),
747
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
748
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
749
- heading: "Retrieves the current Cloudflare trace runtime context from the AsyncLocalStorage. This context contains relevant information and utilities for performing actions within the Cloudflare environment. If no context is currently set, this function will throw an error.",
750
- get children() {
751
- return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: _alloy_js_core.code`The current Cloudflare trace runtime context.` });
752
- }
753
- }),
754
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
755
- "export": true,
756
- name: "getTraceContext",
757
- typeParameters: [{
758
- name: "Env",
759
- default: "CloudflareBindings"
760
- }],
761
- parameters: [],
762
- returnType: "CloudflareTraceContext<Env>",
763
- children: _alloy_js_core.code`const context = traceContextStorage.getStore();
346
+ return context as CloudflareTailStreamContext<Env>; `}
347
+ </_alloy_js_typescript.FunctionDeclaration>
348
+ <hbr />
349
+ <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc heading="Runs a given function within the scope of a Cloudflare tail stream context. This is typically used to set up the context for handling a Cloudflare tail stream operation, ensuring that any code executed within the function has access to the relevant Cloudflare environment information and utilities. The provided context will be available through the `getTailStreamContext` function for any code executed within the callback.">
350
+ <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam name="context">{_alloy_js_core.code`The Cloudflare tail stream context to run the function with.`}</_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam>
351
+ <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam name="callback">{_alloy_js_core.code`The function to execute within the scope of the provided context.`}</_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam>
352
+ <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns>{_alloy_js_core.code`The result of the executed function.`}</_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns>
353
+ </_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc>
354
+ <_alloy_js_typescript.FunctionDeclaration export name="withTailStreamContext" typeParameters={[{
355
+ name: "Env",
356
+ default: "CloudflareBindings"
357
+ }]} parameters={[{
358
+ name: "context",
359
+ type: "CloudflareTailStreamContext<Env>"
360
+ }, {
361
+ name: "callback",
362
+ type: "(ctx: CloudflareTailStreamContext<Env>) => Promise<TailStream.TailEventHandlerType>"
363
+ }]} returnType="Promise<TailStream.TailEventHandlerType>">
364
+ {_alloy_js_core.code`return tailStreamContextStorage.run(context, () => callback(context)); `}
365
+ </_alloy_js_typescript.FunctionDeclaration>
366
+ <_powerlines_plugin_alloy_core_components.Spacing />
367
+ <_powerlines_plugin_alloy_core_components.Spacing />
368
+ <_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration export name="CloudflareTraceContext" typeParameters={[{
369
+ name: "Env",
370
+ default: "CloudflareBindings"
371
+ }]} doc="An interface representing the trace context for Cloudflare trace operations, containing relevant information and utilities for performing actions within the Cloudflare environment.">
372
+ <_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember name="traces" type="TraceItem[]" doc="An array of trace items associated with the Cloudflare trace context." />
373
+ <_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember name="env" type="Env" doc="The Cloudflare environment bindings available during runtime." />
374
+ <_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember name="ctx" type="ExecutionContext" doc="The Cloudflare execution context for the trace operation." />
375
+ </_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration>
376
+ <hbr />
377
+ <_alloy_js_typescript.VarDeclaration const name="CLOUDFLARE_TRACE_CONTEXT_KEY" initializer={_alloy_js_core.code`Symbol.for("powerlines-cloudflare-trace"); `} />
378
+ <hbr />
379
+ <_alloy_js_typescript.VarDeclaration export const name="traceContextStorage" doc="An AsyncLocalStorage instance for managing the Cloudflare trace runtime context." initializer={_alloy_js_core.code`(globalContextStorage[CLOUDFLARE_TRACE_CONTEXT_KEY] ??= new AsyncLocalStorage<CloudflareTraceContext>()) as AsyncLocalStorage<CloudflareTraceContext>; `} />
380
+ <hbr />
381
+ <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc heading="Retrieves the current Cloudflare trace runtime context from the AsyncLocalStorage. This context contains relevant information and utilities for performing actions within the Cloudflare environment. If no context is currently set, this function will throw an error.">
382
+ <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns>{_alloy_js_core.code`The current Cloudflare trace runtime context.`}</_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns>
383
+ </_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc>
384
+ <_alloy_js_typescript.FunctionDeclaration export name="getTraceContext" typeParameters={[{
385
+ name: "Env",
386
+ default: "CloudflareBindings"
387
+ }]} parameters={[]} returnType="CloudflareTraceContext<Env>">
388
+ {_alloy_js_core.code`const context = traceContextStorage.getStore();
764
389
  if (!context) {
765
390
  throw new Error("Cloudflare trace context is not available. Ensure that you are calling this function within the scope of a Cloudflare trace operation.");
766
391
  }
767
- return context as CloudflareTraceContext<Env>; `
768
- }),
769
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
770
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
771
- heading: "Runs a given function within the scope of a Cloudflare trace context. This is typically used to set up the context for handling a Cloudflare trace operation, ensuring that any code executed within the function has access to the relevant Cloudflare environment information and utilities. The provided context will be available through the `getTraceContext` function for any code executed within the callback.",
772
- get children() {
773
- return [
774
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
775
- name: "context",
776
- children: _alloy_js_core.code`The Cloudflare trace context to run the function with.`
777
- }),
778
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
779
- name: "callback",
780
- children: _alloy_js_core.code`The function to execute within the scope of the provided context.`
781
- }),
782
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: _alloy_js_core.code`The result of the executed function.` })
783
- ];
784
- }
785
- }),
786
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
787
- "export": true,
788
- name: "withTraceContext",
789
- typeParameters: [{
790
- name: "Env",
791
- default: "CloudflareBindings"
792
- }],
793
- parameters: [{
794
- name: "context",
795
- type: "CloudflareTraceContext<Env>"
796
- }, {
797
- name: "callback",
798
- type: "(ctx: CloudflareTraceContext<Env>) => Promise<void>"
799
- }],
800
- returnType: "Promise<void>",
801
- children: _alloy_js_core.code`return traceContextStorage.run(context, () => callback(context)); `
802
- }),
803
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components.Spacing, {}),
804
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components.Spacing, {}),
805
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration, {
806
- "export": true,
807
- name: "CloudflareTestContext",
808
- typeParameters: [{
809
- name: "Env",
810
- default: "CloudflareBindings"
811
- }],
812
- doc: "An interface representing the test context for Cloudflare trace operations, containing relevant information and utilities for performing actions within the Cloudflare environment.",
813
- get children() {
814
- return [
815
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
816
- name: "controller",
817
- type: "TestController",
818
- doc: "The test controller associated with the Cloudflare test context."
819
- }),
820
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
821
- name: "env",
822
- type: "Env",
823
- doc: "The Cloudflare environment bindings available during runtime."
824
- }),
825
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
826
- name: "ctx",
827
- type: "ExecutionContext",
828
- doc: "The Cloudflare execution context for the test operation."
829
- })
830
- ];
831
- }
832
- }),
833
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
834
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
835
- "const": true,
836
- name: "CLOUDFLARE_TEST_CONTEXT_KEY",
837
- initializer: _alloy_js_core.code`Symbol.for("powerlines-cloudflare-test"); `
838
- }),
839
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
840
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
841
- "export": true,
842
- "const": true,
843
- name: "testContextStorage",
844
- doc: "An AsyncLocalStorage instance for managing the Cloudflare test runtime context.",
845
- initializer: _alloy_js_core.code`(globalContextStorage[CLOUDFLARE_TEST_CONTEXT_KEY] ??= new AsyncLocalStorage<CloudflareTestContext>()) as AsyncLocalStorage<CloudflareTestContext>; `
846
- }),
847
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
848
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
849
- heading: "Retrieves the current Cloudflare test runtime context from the AsyncLocalStorage. This context contains relevant information and utilities for performing actions within the Cloudflare environment. If no context is currently set, this function will throw an error.",
850
- get children() {
851
- return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: _alloy_js_core.code`The current Cloudflare test runtime context.` });
852
- }
853
- }),
854
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
855
- "export": true,
856
- name: "getTestContext",
857
- typeParameters: [{
858
- name: "Env",
859
- default: "CloudflareBindings"
860
- }],
861
- parameters: [],
862
- returnType: "CloudflareTestContext<Env>",
863
- children: _alloy_js_core.code`const context = testContextStorage.getStore();
392
+ return context as CloudflareTraceContext<Env>; `}
393
+ </_alloy_js_typescript.FunctionDeclaration>
394
+ <hbr />
395
+ <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc heading="Runs a given function within the scope of a Cloudflare trace context. This is typically used to set up the context for handling a Cloudflare trace operation, ensuring that any code executed within the function has access to the relevant Cloudflare environment information and utilities. The provided context will be available through the `getTraceContext` function for any code executed within the callback.">
396
+ <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam name="context">{_alloy_js_core.code`The Cloudflare trace context to run the function with.`}</_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam>
397
+ <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam name="callback">{_alloy_js_core.code`The function to execute within the scope of the provided context.`}</_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam>
398
+ <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns>{_alloy_js_core.code`The result of the executed function.`}</_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns>
399
+ </_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc>
400
+ <_alloy_js_typescript.FunctionDeclaration export name="withTraceContext" typeParameters={[{
401
+ name: "Env",
402
+ default: "CloudflareBindings"
403
+ }]} parameters={[{
404
+ name: "context",
405
+ type: "CloudflareTraceContext<Env>"
406
+ }, {
407
+ name: "callback",
408
+ type: "(ctx: CloudflareTraceContext<Env>) => Promise<void>"
409
+ }]} returnType="Promise<void>">
410
+ {_alloy_js_core.code`return traceContextStorage.run(context, () => callback(context)); `}
411
+ </_alloy_js_typescript.FunctionDeclaration>
412
+ <_powerlines_plugin_alloy_core_components.Spacing />
413
+ <_powerlines_plugin_alloy_core_components.Spacing />
414
+ <_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration export name="CloudflareTestContext" typeParameters={[{
415
+ name: "Env",
416
+ default: "CloudflareBindings"
417
+ }]} doc="An interface representing the test context for Cloudflare trace operations, containing relevant information and utilities for performing actions within the Cloudflare environment.">
418
+ <_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember name="controller" type="TestController" doc="The test controller associated with the Cloudflare test context." />
419
+ <_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember name="env" type="Env" doc="The Cloudflare environment bindings available during runtime." />
420
+ <_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember name="ctx" type="ExecutionContext" doc="The Cloudflare execution context for the test operation." />
421
+ </_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration>
422
+ <hbr />
423
+ <_alloy_js_typescript.VarDeclaration const name="CLOUDFLARE_TEST_CONTEXT_KEY" initializer={_alloy_js_core.code`Symbol.for("powerlines-cloudflare-test"); `} />
424
+ <hbr />
425
+ <_alloy_js_typescript.VarDeclaration export const name="testContextStorage" doc="An AsyncLocalStorage instance for managing the Cloudflare test runtime context." initializer={_alloy_js_core.code`(globalContextStorage[CLOUDFLARE_TEST_CONTEXT_KEY] ??= new AsyncLocalStorage<CloudflareTestContext>()) as AsyncLocalStorage<CloudflareTestContext>; `} />
426
+ <hbr />
427
+ <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc heading="Retrieves the current Cloudflare test runtime context from the AsyncLocalStorage. This context contains relevant information and utilities for performing actions within the Cloudflare environment. If no context is currently set, this function will throw an error.">
428
+ <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns>{_alloy_js_core.code`The current Cloudflare test runtime context.`}</_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns>
429
+ </_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc>
430
+ <_alloy_js_typescript.FunctionDeclaration export name="getTestContext" typeParameters={[{
431
+ name: "Env",
432
+ default: "CloudflareBindings"
433
+ }]} parameters={[]} returnType="CloudflareTestContext<Env>">
434
+ {_alloy_js_core.code`const context = testContextStorage.getStore();
864
435
  if (!context) {
865
436
  throw new Error("Cloudflare test context is not available. Ensure that you are calling this function within the scope of a Cloudflare test operation.");
866
437
  }
867
- return context as CloudflareTestContext<Env>; `
868
- }),
869
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
870
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
871
- heading: "Runs a given function within the scope of a Cloudflare test context. This is typically used to set up the context for handling a Cloudflare test operation, ensuring that any code executed within the function has access to the relevant Cloudflare environment information and utilities. The provided context will be available through the `getTestContext` function for any code executed within the callback.",
872
- get children() {
873
- return [
874
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
875
- name: "context",
876
- children: _alloy_js_core.code`The Cloudflare test context to run the function with.`
877
- }),
878
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
879
- name: "callback",
880
- children: _alloy_js_core.code`The function to execute within the scope of the provided context.`
881
- }),
882
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: _alloy_js_core.code`The result of the executed function.` })
883
- ];
884
- }
885
- }),
886
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
887
- "export": true,
888
- name: "withTestContext",
889
- typeParameters: [{
890
- name: "Env",
891
- default: "CloudflareBindings"
892
- }],
893
- parameters: [{
894
- name: "context",
895
- type: "CloudflareTestContext<Env>"
896
- }, {
897
- name: "callback",
898
- type: "(ctx: CloudflareTestContext<Env>) => Promise<void>"
899
- }],
900
- returnType: "Promise<void>",
901
- children: _alloy_js_core.code`return testContextStorage.run(context, () => callback(context)); `
902
- }),
903
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components.Spacing, {}),
904
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components.Spacing, {}),
905
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
906
- get when() {
907
- return Boolean(children);
908
- },
909
- children
910
- })
911
- ];
912
- }
913
- }));
438
+ return context as CloudflareTestContext<Env>; `}
439
+ </_alloy_js_typescript.FunctionDeclaration>
440
+ <hbr />
441
+ <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc heading="Runs a given function within the scope of a Cloudflare test context. This is typically used to set up the context for handling a Cloudflare test operation, ensuring that any code executed within the function has access to the relevant Cloudflare environment information and utilities. The provided context will be available through the `getTestContext` function for any code executed within the callback.">
442
+ <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam name="context">{_alloy_js_core.code`The Cloudflare test context to run the function with.`}</_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam>
443
+ <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam name="callback">{_alloy_js_core.code`The function to execute within the scope of the provided context.`}</_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam>
444
+ <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns>{_alloy_js_core.code`The result of the executed function.`}</_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns>
445
+ </_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc>
446
+ <_alloy_js_typescript.FunctionDeclaration export name="withTestContext" typeParameters={[{
447
+ name: "Env",
448
+ default: "CloudflareBindings"
449
+ }]} parameters={[{
450
+ name: "context",
451
+ type: "CloudflareTestContext<Env>"
452
+ }, {
453
+ name: "callback",
454
+ type: "(ctx: CloudflareTestContext<Env>) => Promise<void>"
455
+ }]} returnType="Promise<void>">
456
+ {_alloy_js_core.code`return testContextStorage.run(context, () => callback(context)); `}
457
+ </_alloy_js_typescript.FunctionDeclaration>
458
+ <_powerlines_plugin_alloy_core_components.Spacing />
459
+ <_powerlines_plugin_alloy_core_components.Spacing />
460
+ <_alloy_js_core.Show when={Boolean(children)}>{children}</_alloy_js_core.Show>
461
+ </_powerlines_plugin_alloy_typescript_components_builtin_file.BuiltinFile>;
914
462
  }
915
463
 
916
464
  //#endregion