@powerlines/plugin-cloudflare 0.6.30 → 0.6.33

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