@powerlines/plugin-cloudflare 0.2.19 → 0.2.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -16
- package/dist/_virtual/{rolldown_runtime.cjs → _rolldown/runtime.cjs} +1 -1
- package/dist/_virtual/_rolldown/runtime.mjs +3 -0
- package/dist/components/cloudflare-builtin.cjs +225 -224
- package/dist/components/cloudflare-builtin.d.cts.map +1 -1
- package/dist/components/cloudflare-builtin.d.mts +2 -2
- package/dist/components/cloudflare-builtin.d.mts.map +1 -1
- package/dist/components/env-builtin.cjs +10 -9
- package/dist/components/env-builtin.d.cts +2 -2
- package/dist/components/env-builtin.d.cts.map +1 -1
- package/dist/components/env-builtin.d.mts.map +1 -1
- package/dist/components/index.cjs +1 -0
- package/dist/components/worker-entry.cjs +45 -44
- package/dist/components/worker-entry.d.cts +0 -1
- package/dist/components/worker-entry.d.cts.map +1 -1
- package/dist/components/worker-entry.d.mts +0 -1
- package/dist/components/worker-entry.d.mts.map +1 -1
- package/dist/index.cjs +30 -31
- package/dist/index.d.cts +0 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +0 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +3 -4
- package/dist/index.mjs.map +1 -1
- package/dist/types/plugin.d.cts.map +1 -1
- package/dist/types/plugin.d.mts.map +1 -1
- package/package.json +27 -24
- package/dist/node_modules/.pnpm/@stryke_string-format@0.17.3/node_modules/@stryke/string-format/dist/get-words.cjs +0 -38
- package/dist/node_modules/.pnpm/@stryke_string-format@0.17.3/node_modules/@stryke/string-format/dist/get-words.mjs +0 -38
- package/dist/node_modules/.pnpm/@stryke_string-format@0.17.3/node_modules/@stryke/string-format/dist/get-words.mjs.map +0 -1
- package/dist/node_modules/.pnpm/@stryke_string-format@0.17.3/node_modules/@stryke/string-format/dist/kebab-case.cjs +0 -33
- package/dist/node_modules/.pnpm/@stryke_string-format@0.17.3/node_modules/@stryke/string-format/dist/kebab-case.mjs +0 -34
- package/dist/node_modules/.pnpm/@stryke_string-format@0.17.3/node_modules/@stryke/string-format/dist/kebab-case.mjs.map +0 -1
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.38/node_modules/@stryke/type-checks/dist/get-object-tag.cjs +0 -15
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.38/node_modules/@stryke/type-checks/dist/get-object-tag.mjs +0 -15
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.38/node_modules/@stryke/type-checks/dist/get-object-tag.mjs.map +0 -1
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.38/node_modules/@stryke/type-checks/dist/is-function.cjs +0 -25
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.38/node_modules/@stryke/type-checks/dist/is-function.mjs +0 -26
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.38/node_modules/@stryke/type-checks/dist/is-function.mjs.map +0 -1
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
let
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
4
|
+
let _alloy_js_core = require("@alloy-js/core");
|
|
4
5
|
let defu = require("defu");
|
|
5
|
-
defu =
|
|
6
|
-
let
|
|
7
|
-
let
|
|
8
|
-
let
|
|
9
|
-
let
|
|
10
|
-
let
|
|
6
|
+
defu = require_runtime.__toESM(defu);
|
|
7
|
+
let _alloy_js_typescript = require("@alloy-js/typescript");
|
|
8
|
+
let _powerlines_plugin_alloy_core_components = require("@powerlines/plugin-alloy/core/components");
|
|
9
|
+
let _powerlines_plugin_alloy_typescript_components_builtin_file = require("@powerlines/plugin-alloy/typescript/components/builtin-file");
|
|
10
|
+
let _powerlines_plugin_alloy_typescript_components_interface_declaration = require("@powerlines/plugin-alloy/typescript/components/interface-declaration");
|
|
11
|
+
let _powerlines_plugin_alloy_typescript_components_tsdoc = require("@powerlines/plugin-alloy/typescript/components/tsdoc");
|
|
11
12
|
|
|
12
13
|
//#region src/components/cloudflare-builtin.tsx
|
|
13
14
|
/**
|
|
14
15
|
* Generates the Cloudflare environment configuration module for the Powerlines project.
|
|
15
16
|
*/
|
|
16
17
|
function CloudflareBuiltin(props) {
|
|
17
|
-
const [{ imports, children }, rest] = (0,
|
|
18
|
-
return (0,
|
|
18
|
+
const [{ imports, children }, rest] = (0, _alloy_js_core.splitProps)(props, ["imports", "children"]);
|
|
19
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_builtin_file.BuiltinFile, (0, _alloy_js_core_jsx_runtime.mergeProps)({
|
|
19
20
|
id: "cloudflare",
|
|
20
21
|
description: "A set of helpful runtime utilities for integrating Cloudflare services."
|
|
21
22
|
}, rest, {
|
|
@@ -76,14 +77,14 @@ function CloudflareBuiltin(props) {
|
|
|
76
77
|
},
|
|
77
78
|
get children() {
|
|
78
79
|
return [
|
|
79
|
-
(0,
|
|
80
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
80
81
|
"const": true,
|
|
81
82
|
name: "globalContextStorage",
|
|
82
|
-
initializer:
|
|
83
|
+
initializer: _alloy_js_core.code`globalThis as unknown as Record<PropertyKey, unknown>; `
|
|
83
84
|
}),
|
|
84
|
-
(0,
|
|
85
|
-
(0,
|
|
86
|
-
(0,
|
|
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, {
|
|
87
88
|
"export": true,
|
|
88
89
|
name: "CloudflareFetchContext",
|
|
89
90
|
typeParameters: [{
|
|
@@ -96,17 +97,17 @@ function CloudflareBuiltin(props) {
|
|
|
96
97
|
doc: "An interface representing the runtime context for Cloudflare operations, containing relevant information and utilities for performing actions within the Cloudflare environment.",
|
|
97
98
|
get children() {
|
|
98
99
|
return [
|
|
99
|
-
(0,
|
|
100
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
100
101
|
name: "request",
|
|
101
102
|
type: "Request<CfHostMetadata, IncomingRequestCfProperties<CfHostMetadata>>",
|
|
102
103
|
doc: "The incoming Cloudflare request."
|
|
103
104
|
}),
|
|
104
|
-
(0,
|
|
105
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
105
106
|
name: "env",
|
|
106
107
|
type: "Env",
|
|
107
108
|
doc: "The Cloudflare environment bindings available during runtime."
|
|
108
109
|
}),
|
|
109
|
-
(0,
|
|
110
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
110
111
|
name: "ctx",
|
|
111
112
|
type: "ExecutionContext",
|
|
112
113
|
doc: "The Cloudflare execution context for the incoming request."
|
|
@@ -114,28 +115,28 @@ function CloudflareBuiltin(props) {
|
|
|
114
115
|
];
|
|
115
116
|
}
|
|
116
117
|
}),
|
|
117
|
-
(0,
|
|
118
|
-
(0,
|
|
118
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
119
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
119
120
|
"const": true,
|
|
120
121
|
name: "CLOUDFLARE_FETCH_CONTEXT_KEY",
|
|
121
|
-
initializer:
|
|
122
|
+
initializer: _alloy_js_core.code`Symbol.for("powerlines-cloudflare-fetch"); `
|
|
122
123
|
}),
|
|
123
|
-
(0,
|
|
124
|
-
(0,
|
|
124
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
125
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
125
126
|
"export": true,
|
|
126
127
|
"const": true,
|
|
127
128
|
name: "fetchContextStorage",
|
|
128
129
|
doc: "An AsyncLocalStorage instance for managing the Cloudflare fetch context.",
|
|
129
|
-
initializer:
|
|
130
|
+
initializer: _alloy_js_core.code`(globalContextStorage[CLOUDFLARE_FETCH_CONTEXT_KEY] ??= new AsyncLocalStorage<CloudflareFetchContext>()) as AsyncLocalStorage<CloudflareFetchContext>; `
|
|
130
131
|
}),
|
|
131
|
-
(0,
|
|
132
|
-
(0,
|
|
132
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
133
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
133
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.",
|
|
134
135
|
get children() {
|
|
135
|
-
return (0,
|
|
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.` });
|
|
136
137
|
}
|
|
137
138
|
}),
|
|
138
|
-
(0,
|
|
139
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
139
140
|
"export": true,
|
|
140
141
|
name: "getFetchContext",
|
|
141
142
|
typeParameters: [{
|
|
@@ -147,30 +148,30 @@ function CloudflareBuiltin(props) {
|
|
|
147
148
|
}],
|
|
148
149
|
parameters: [],
|
|
149
150
|
returnType: "CloudflareFetchContext<Env, CfHostMetadata>",
|
|
150
|
-
children:
|
|
151
|
+
children: _alloy_js_core.code`const context = fetchContextStorage.getStore();
|
|
151
152
|
if (!context) {
|
|
152
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.");
|
|
153
154
|
}
|
|
154
155
|
return context as CloudflareFetchContext<Env, CfHostMetadata>; `
|
|
155
156
|
}),
|
|
156
|
-
(0,
|
|
157
|
-
(0,
|
|
157
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
158
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
158
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.",
|
|
159
160
|
get children() {
|
|
160
161
|
return [
|
|
161
|
-
(0,
|
|
162
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
162
163
|
name: "context",
|
|
163
|
-
children:
|
|
164
|
+
children: _alloy_js_core.code`The Cloudflare fetch context to run the function with.`
|
|
164
165
|
}),
|
|
165
|
-
(0,
|
|
166
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
166
167
|
name: "callback",
|
|
167
|
-
children:
|
|
168
|
+
children: _alloy_js_core.code`The function to execute within the scope of the provided context.`
|
|
168
169
|
}),
|
|
169
|
-
(0,
|
|
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.` })
|
|
170
171
|
];
|
|
171
172
|
}
|
|
172
173
|
}),
|
|
173
|
-
(0,
|
|
174
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
174
175
|
"export": true,
|
|
175
176
|
name: "withFetchContext",
|
|
176
177
|
typeParameters: [{
|
|
@@ -188,11 +189,11 @@ return context as CloudflareFetchContext<Env, CfHostMetadata>; `
|
|
|
188
189
|
type: "(request: Request<CfHostMetadata, IncomingRequestCfProperties<CfHostMetadata>>, env: Env, ctx: ExecutionContext) => Promise<Response>"
|
|
189
190
|
}],
|
|
190
191
|
returnType: "Promise<Response>",
|
|
191
|
-
children:
|
|
192
|
+
children: _alloy_js_core.code`return fetchContextStorage.run(context, () => callback(context.request, context.env, context.ctx)); `
|
|
192
193
|
}),
|
|
193
|
-
(0,
|
|
194
|
-
(0,
|
|
195
|
-
(0,
|
|
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, {
|
|
196
197
|
"export": true,
|
|
197
198
|
name: "CloudflareScheduledContext",
|
|
198
199
|
typeParameters: [{
|
|
@@ -202,17 +203,17 @@ return context as CloudflareFetchContext<Env, CfHostMetadata>; `
|
|
|
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.",
|
|
203
204
|
get children() {
|
|
204
205
|
return [
|
|
205
|
-
(0,
|
|
206
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
206
207
|
name: "controller",
|
|
207
208
|
type: "ScheduledController",
|
|
208
209
|
doc: "The Cloudflare scheduled controller for the scheduled operation."
|
|
209
210
|
}),
|
|
210
|
-
(0,
|
|
211
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
211
212
|
name: "env",
|
|
212
213
|
type: "Env",
|
|
213
214
|
doc: "The Cloudflare environment bindings available during runtime."
|
|
214
215
|
}),
|
|
215
|
-
(0,
|
|
216
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
216
217
|
name: "ctx",
|
|
217
218
|
type: "ExecutionContext",
|
|
218
219
|
doc: "The Cloudflare execution context for the scheduled operation."
|
|
@@ -220,28 +221,28 @@ return context as CloudflareFetchContext<Env, CfHostMetadata>; `
|
|
|
220
221
|
];
|
|
221
222
|
}
|
|
222
223
|
}),
|
|
223
|
-
(0,
|
|
224
|
-
(0,
|
|
224
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
225
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
225
226
|
"const": true,
|
|
226
227
|
name: "CLOUDFLARE_SCHEDULED_CONTEXT_KEY",
|
|
227
|
-
initializer:
|
|
228
|
+
initializer: _alloy_js_core.code`Symbol.for("powerlines-cloudflare-scheduled"); `
|
|
228
229
|
}),
|
|
229
|
-
(0,
|
|
230
|
-
(0,
|
|
230
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
231
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
231
232
|
"export": true,
|
|
232
233
|
"const": true,
|
|
233
234
|
name: "scheduledContextStorage",
|
|
234
235
|
doc: "An AsyncLocalStorage instance for managing the Cloudflare scheduled runtime context.",
|
|
235
|
-
initializer:
|
|
236
|
+
initializer: _alloy_js_core.code`(globalContextStorage[CLOUDFLARE_SCHEDULED_CONTEXT_KEY] ??= new AsyncLocalStorage<CloudflareScheduledContext>()) as AsyncLocalStorage<CloudflareScheduledContext>; `
|
|
236
237
|
}),
|
|
237
|
-
(0,
|
|
238
|
-
(0,
|
|
238
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
239
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
239
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.",
|
|
240
241
|
get children() {
|
|
241
|
-
return (0,
|
|
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.` });
|
|
242
243
|
}
|
|
243
244
|
}),
|
|
244
|
-
(0,
|
|
245
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
245
246
|
"export": true,
|
|
246
247
|
name: "getScheduledContext",
|
|
247
248
|
typeParameters: [{
|
|
@@ -250,30 +251,30 @@ return context as CloudflareFetchContext<Env, CfHostMetadata>; `
|
|
|
250
251
|
}],
|
|
251
252
|
parameters: [],
|
|
252
253
|
returnType: "CloudflareScheduledContext<Env>",
|
|
253
|
-
children:
|
|
254
|
+
children: _alloy_js_core.code`const context = scheduledContextStorage.getStore();
|
|
254
255
|
if (!context) {
|
|
255
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.");
|
|
256
257
|
}
|
|
257
258
|
return context as CloudflareScheduledContext<Env>; `
|
|
258
259
|
}),
|
|
259
|
-
(0,
|
|
260
|
-
(0,
|
|
260
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
261
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
261
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.",
|
|
262
263
|
get children() {
|
|
263
264
|
return [
|
|
264
|
-
(0,
|
|
265
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
265
266
|
name: "context",
|
|
266
|
-
children:
|
|
267
|
+
children: _alloy_js_core.code`The Cloudflare scheduled context to run the function with.`
|
|
267
268
|
}),
|
|
268
|
-
(0,
|
|
269
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
269
270
|
name: "callback",
|
|
270
|
-
children:
|
|
271
|
+
children: _alloy_js_core.code`The function to execute within the scope of the provided context.`
|
|
271
272
|
}),
|
|
272
|
-
(0,
|
|
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.` })
|
|
273
274
|
];
|
|
274
275
|
}
|
|
275
276
|
}),
|
|
276
|
-
(0,
|
|
277
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
277
278
|
"export": true,
|
|
278
279
|
name: "withScheduledContext",
|
|
279
280
|
typeParameters: [{
|
|
@@ -288,11 +289,11 @@ return context as CloudflareScheduledContext<Env>; `
|
|
|
288
289
|
type: "(ctx: CloudflareScheduledContext<Env>) => Promise<void>"
|
|
289
290
|
}],
|
|
290
291
|
returnType: "Promise<void>",
|
|
291
|
-
children:
|
|
292
|
+
children: _alloy_js_core.code`return scheduledContextStorage.run(context, () => callback(context)); `
|
|
292
293
|
}),
|
|
293
|
-
(0,
|
|
294
|
-
(0,
|
|
295
|
-
(0,
|
|
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, {
|
|
296
297
|
"export": true,
|
|
297
298
|
name: "CloudflareEmailContext",
|
|
298
299
|
typeParameters: [{
|
|
@@ -302,17 +303,17 @@ return context as CloudflareScheduledContext<Env>; `
|
|
|
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.",
|
|
303
304
|
get children() {
|
|
304
305
|
return [
|
|
305
|
-
(0,
|
|
306
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
306
307
|
name: "message",
|
|
307
308
|
type: "ForwardableEmailMessage",
|
|
308
309
|
doc: "The Cloudflare email instance for the email operation."
|
|
309
310
|
}),
|
|
310
|
-
(0,
|
|
311
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
311
312
|
name: "env",
|
|
312
313
|
type: "Env",
|
|
313
314
|
doc: "The Cloudflare environment bindings available during runtime."
|
|
314
315
|
}),
|
|
315
|
-
(0,
|
|
316
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
316
317
|
name: "ctx",
|
|
317
318
|
type: "ExecutionContext",
|
|
318
319
|
doc: "The Cloudflare execution context for the email operation."
|
|
@@ -320,28 +321,28 @@ return context as CloudflareScheduledContext<Env>; `
|
|
|
320
321
|
];
|
|
321
322
|
}
|
|
322
323
|
}),
|
|
323
|
-
(0,
|
|
324
|
-
(0,
|
|
324
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
325
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
325
326
|
"const": true,
|
|
326
327
|
name: "CLOUDFLARE_EMAIL_CONTEXT_KEY",
|
|
327
|
-
initializer:
|
|
328
|
+
initializer: _alloy_js_core.code`Symbol.for("powerlines-cloudflare-email"); `
|
|
328
329
|
}),
|
|
329
|
-
(0,
|
|
330
|
-
(0,
|
|
330
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
331
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
331
332
|
"export": true,
|
|
332
333
|
"const": true,
|
|
333
334
|
name: "emailContextStorage",
|
|
334
335
|
doc: "An AsyncLocalStorage instance for managing the Cloudflare email runtime context.",
|
|
335
|
-
initializer:
|
|
336
|
+
initializer: _alloy_js_core.code`(globalContextStorage[CLOUDFLARE_EMAIL_CONTEXT_KEY] ??= new AsyncLocalStorage<CloudflareEmailContext>()) as AsyncLocalStorage<CloudflareEmailContext>; `
|
|
336
337
|
}),
|
|
337
|
-
(0,
|
|
338
|
-
(0,
|
|
338
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
339
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
339
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.",
|
|
340
341
|
get children() {
|
|
341
|
-
return (0,
|
|
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.` });
|
|
342
343
|
}
|
|
343
344
|
}),
|
|
344
|
-
(0,
|
|
345
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
345
346
|
"export": true,
|
|
346
347
|
name: "getEmailContext",
|
|
347
348
|
typeParameters: [{
|
|
@@ -350,30 +351,30 @@ return context as CloudflareScheduledContext<Env>; `
|
|
|
350
351
|
}],
|
|
351
352
|
parameters: [],
|
|
352
353
|
returnType: "CloudflareEmailContext<Env>",
|
|
353
|
-
children:
|
|
354
|
+
children: _alloy_js_core.code`const context = emailContextStorage.getStore();
|
|
354
355
|
if (!context) {
|
|
355
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.");
|
|
356
357
|
}
|
|
357
358
|
return context as CloudflareEmailContext<Env>; `
|
|
358
359
|
}),
|
|
359
|
-
(0,
|
|
360
|
-
(0,
|
|
360
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
361
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
361
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.",
|
|
362
363
|
get children() {
|
|
363
364
|
return [
|
|
364
|
-
(0,
|
|
365
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
365
366
|
name: "context",
|
|
366
|
-
children:
|
|
367
|
+
children: _alloy_js_core.code`The Cloudflare email context to run the function with.`
|
|
367
368
|
}),
|
|
368
|
-
(0,
|
|
369
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
369
370
|
name: "callback",
|
|
370
|
-
children:
|
|
371
|
+
children: _alloy_js_core.code`The function to execute within the scope of the provided context.`
|
|
371
372
|
}),
|
|
372
|
-
(0,
|
|
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.` })
|
|
373
374
|
];
|
|
374
375
|
}
|
|
375
376
|
}),
|
|
376
|
-
(0,
|
|
377
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
377
378
|
"export": true,
|
|
378
379
|
name: "withEmailContext",
|
|
379
380
|
typeParameters: [{
|
|
@@ -388,11 +389,11 @@ return context as CloudflareEmailContext<Env>; `
|
|
|
388
389
|
type: "(ctx: CloudflareEmailContext<Env>) => Promise<void>"
|
|
389
390
|
}],
|
|
390
391
|
returnType: "Promise<void>",
|
|
391
|
-
children:
|
|
392
|
+
children: _alloy_js_core.code`return emailContextStorage.run(context, () => callback(context)); `
|
|
392
393
|
}),
|
|
393
|
-
(0,
|
|
394
|
-
(0,
|
|
395
|
-
(0,
|
|
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, {
|
|
396
397
|
"export": true,
|
|
397
398
|
name: "CloudflareQueueContext",
|
|
398
399
|
typeParameters: [{
|
|
@@ -405,17 +406,17 @@ return context as CloudflareEmailContext<Env>; `
|
|
|
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.",
|
|
406
407
|
get children() {
|
|
407
408
|
return [
|
|
408
|
-
(0,
|
|
409
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
409
410
|
name: "batch",
|
|
410
411
|
type: "MessageBatch<Message>",
|
|
411
412
|
doc: "The Cloudflare queue event instance for the queue operation."
|
|
412
413
|
}),
|
|
413
|
-
(0,
|
|
414
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
414
415
|
name: "env",
|
|
415
416
|
type: "Env",
|
|
416
417
|
doc: "The Cloudflare environment bindings available during runtime."
|
|
417
418
|
}),
|
|
418
|
-
(0,
|
|
419
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
419
420
|
name: "ctx",
|
|
420
421
|
type: "ExecutionContext",
|
|
421
422
|
doc: "The Cloudflare execution context for the queue operation."
|
|
@@ -423,28 +424,28 @@ return context as CloudflareEmailContext<Env>; `
|
|
|
423
424
|
];
|
|
424
425
|
}
|
|
425
426
|
}),
|
|
426
|
-
(0,
|
|
427
|
-
(0,
|
|
427
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
428
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
428
429
|
"const": true,
|
|
429
430
|
name: "CLOUDFLARE_QUEUE_CONTEXT_KEY",
|
|
430
|
-
initializer:
|
|
431
|
+
initializer: _alloy_js_core.code`Symbol.for("powerlines-cloudflare-queue"); `
|
|
431
432
|
}),
|
|
432
|
-
(0,
|
|
433
|
-
(0,
|
|
433
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
434
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
434
435
|
"export": true,
|
|
435
436
|
"const": true,
|
|
436
437
|
name: "queueContextStorage",
|
|
437
438
|
doc: "An AsyncLocalStorage instance for managing the Cloudflare queue runtime context.",
|
|
438
|
-
initializer:
|
|
439
|
+
initializer: _alloy_js_core.code`(globalContextStorage[CLOUDFLARE_QUEUE_CONTEXT_KEY] ??= new AsyncLocalStorage<CloudflareQueueContext>()) as AsyncLocalStorage<CloudflareQueueContext>; `
|
|
439
440
|
}),
|
|
440
|
-
(0,
|
|
441
|
-
(0,
|
|
441
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
442
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
442
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.",
|
|
443
444
|
get children() {
|
|
444
|
-
return (0,
|
|
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.` });
|
|
445
446
|
}
|
|
446
447
|
}),
|
|
447
|
-
(0,
|
|
448
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
448
449
|
"export": true,
|
|
449
450
|
name: "getQueueContext",
|
|
450
451
|
typeParameters: [{
|
|
@@ -456,30 +457,30 @@ return context as CloudflareEmailContext<Env>; `
|
|
|
456
457
|
}],
|
|
457
458
|
parameters: [],
|
|
458
459
|
returnType: "CloudflareQueueContext<Message, Env>",
|
|
459
|
-
children:
|
|
460
|
+
children: _alloy_js_core.code`const context = queueContextStorage.getStore();
|
|
460
461
|
if (!context) {
|
|
461
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.");
|
|
462
463
|
}
|
|
463
464
|
return context as CloudflareQueueContext<Message, Env>; `
|
|
464
465
|
}),
|
|
465
|
-
(0,
|
|
466
|
-
(0,
|
|
466
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
467
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
467
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.",
|
|
468
469
|
get children() {
|
|
469
470
|
return [
|
|
470
|
-
(0,
|
|
471
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
471
472
|
name: "context",
|
|
472
|
-
children:
|
|
473
|
+
children: _alloy_js_core.code`The Cloudflare queue context to run the function with.`
|
|
473
474
|
}),
|
|
474
|
-
(0,
|
|
475
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
475
476
|
name: "callback",
|
|
476
|
-
children:
|
|
477
|
+
children: _alloy_js_core.code`The function to execute within the scope of the provided context.`
|
|
477
478
|
}),
|
|
478
|
-
(0,
|
|
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.` })
|
|
479
480
|
];
|
|
480
481
|
}
|
|
481
482
|
}),
|
|
482
|
-
(0,
|
|
483
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
483
484
|
"export": true,
|
|
484
485
|
name: "withQueueContext",
|
|
485
486
|
typeParameters: [{
|
|
@@ -497,11 +498,11 @@ return context as CloudflareQueueContext<Message, Env>; `
|
|
|
497
498
|
type: "(ctx: CloudflareQueueContext<Message, Env>) => Promise<void>"
|
|
498
499
|
}],
|
|
499
500
|
returnType: "Promise<void>",
|
|
500
|
-
children:
|
|
501
|
+
children: _alloy_js_core.code`return queueContextStorage.run(context, () => callback(context)); `
|
|
501
502
|
}),
|
|
502
|
-
(0,
|
|
503
|
-
(0,
|
|
504
|
-
(0,
|
|
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, {
|
|
505
506
|
"export": true,
|
|
506
507
|
name: "CloudflareTailContext",
|
|
507
508
|
typeParameters: [{
|
|
@@ -511,17 +512,17 @@ return context as CloudflareQueueContext<Message, Env>; `
|
|
|
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.",
|
|
512
513
|
get children() {
|
|
513
514
|
return [
|
|
514
|
-
(0,
|
|
515
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
515
516
|
name: "events",
|
|
516
517
|
type: "TraceItem[]",
|
|
517
518
|
doc: "An array of trace items representing the events in the Cloudflare tail context."
|
|
518
519
|
}),
|
|
519
|
-
(0,
|
|
520
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
520
521
|
name: "env",
|
|
521
522
|
type: "Env",
|
|
522
523
|
doc: "The Cloudflare environment bindings available during runtime."
|
|
523
524
|
}),
|
|
524
|
-
(0,
|
|
525
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
525
526
|
name: "ctx",
|
|
526
527
|
type: "ExecutionContext",
|
|
527
528
|
doc: "The Cloudflare execution context for the tail operation."
|
|
@@ -529,28 +530,28 @@ return context as CloudflareQueueContext<Message, Env>; `
|
|
|
529
530
|
];
|
|
530
531
|
}
|
|
531
532
|
}),
|
|
532
|
-
(0,
|
|
533
|
-
(0,
|
|
533
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
534
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
534
535
|
"const": true,
|
|
535
536
|
name: "CLOUDFLARE_TAIL_CONTEXT_KEY",
|
|
536
|
-
initializer:
|
|
537
|
+
initializer: _alloy_js_core.code`Symbol.for("powerlines-cloudflare-tail"); `
|
|
537
538
|
}),
|
|
538
|
-
(0,
|
|
539
|
-
(0,
|
|
539
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
540
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
540
541
|
"export": true,
|
|
541
542
|
"const": true,
|
|
542
543
|
name: "tailContextStorage",
|
|
543
544
|
doc: "An AsyncLocalStorage instance for managing the Cloudflare tail runtime context.",
|
|
544
|
-
initializer:
|
|
545
|
+
initializer: _alloy_js_core.code`(globalContextStorage[CLOUDFLARE_TAIL_CONTEXT_KEY] ??= new AsyncLocalStorage<CloudflareTailContext>()) as AsyncLocalStorage<CloudflareTailContext>; `
|
|
545
546
|
}),
|
|
546
|
-
(0,
|
|
547
|
-
(0,
|
|
547
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
548
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
548
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.",
|
|
549
550
|
get children() {
|
|
550
|
-
return (0,
|
|
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.` });
|
|
551
552
|
}
|
|
552
553
|
}),
|
|
553
|
-
(0,
|
|
554
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
554
555
|
"export": true,
|
|
555
556
|
name: "getTailContext",
|
|
556
557
|
typeParameters: [{
|
|
@@ -559,30 +560,30 @@ return context as CloudflareQueueContext<Message, Env>; `
|
|
|
559
560
|
}],
|
|
560
561
|
parameters: [],
|
|
561
562
|
returnType: "CloudflareTailContext<Env>",
|
|
562
|
-
children:
|
|
563
|
+
children: _alloy_js_core.code`const context = tailContextStorage.getStore();
|
|
563
564
|
if (!context) {
|
|
564
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.");
|
|
565
566
|
}
|
|
566
567
|
return context as CloudflareTailContext<Env>; `
|
|
567
568
|
}),
|
|
568
|
-
(0,
|
|
569
|
-
(0,
|
|
569
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
570
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
570
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.",
|
|
571
572
|
get children() {
|
|
572
573
|
return [
|
|
573
|
-
(0,
|
|
574
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
574
575
|
name: "context",
|
|
575
|
-
children:
|
|
576
|
+
children: _alloy_js_core.code`The Cloudflare tail context to run the function with.`
|
|
576
577
|
}),
|
|
577
|
-
(0,
|
|
578
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
578
579
|
name: "callback",
|
|
579
|
-
children:
|
|
580
|
+
children: _alloy_js_core.code`The function to execute within the scope of the provided context.`
|
|
580
581
|
}),
|
|
581
|
-
(0,
|
|
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.` })
|
|
582
583
|
];
|
|
583
584
|
}
|
|
584
585
|
}),
|
|
585
|
-
(0,
|
|
586
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
586
587
|
"export": true,
|
|
587
588
|
name: "withTailContext",
|
|
588
589
|
typeParameters: [{
|
|
@@ -597,11 +598,11 @@ return context as CloudflareTailContext<Env>; `
|
|
|
597
598
|
type: "(ctx: CloudflareTailContext<Env>) => Promise<void>"
|
|
598
599
|
}],
|
|
599
600
|
returnType: "T",
|
|
600
|
-
children:
|
|
601
|
+
children: _alloy_js_core.code`return tailContextStorage.run(context, () => callback(context)); `
|
|
601
602
|
}),
|
|
602
|
-
(0,
|
|
603
|
-
(0,
|
|
604
|
-
(0,
|
|
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, {
|
|
605
606
|
"export": true,
|
|
606
607
|
name: "CloudflareTailStreamContext",
|
|
607
608
|
typeParameters: [{
|
|
@@ -611,17 +612,17 @@ return context as CloudflareTailContext<Env>; `
|
|
|
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.",
|
|
612
613
|
get children() {
|
|
613
614
|
return [
|
|
614
|
-
(0,
|
|
615
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
615
616
|
name: "event",
|
|
616
617
|
type: "TailStream.TailEvent<TailStream.Onset>",
|
|
617
618
|
doc: "The tail event associated with the Cloudflare tail stream context."
|
|
618
619
|
}),
|
|
619
|
-
(0,
|
|
620
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
620
621
|
name: "env",
|
|
621
622
|
type: "Env",
|
|
622
623
|
doc: "The Cloudflare environment bindings available during runtime."
|
|
623
624
|
}),
|
|
624
|
-
(0,
|
|
625
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
625
626
|
name: "ctx",
|
|
626
627
|
type: "ExecutionContext",
|
|
627
628
|
doc: "The Cloudflare execution context for the tail stream operation."
|
|
@@ -629,28 +630,28 @@ return context as CloudflareTailContext<Env>; `
|
|
|
629
630
|
];
|
|
630
631
|
}
|
|
631
632
|
}),
|
|
632
|
-
(0,
|
|
633
|
-
(0,
|
|
633
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
634
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
634
635
|
"const": true,
|
|
635
636
|
name: "CLOUDFLARE_TAIL_STREAM_CONTEXT_KEY",
|
|
636
|
-
initializer:
|
|
637
|
+
initializer: _alloy_js_core.code`Symbol.for("powerlines-cloudflare-tail-stream"); `
|
|
637
638
|
}),
|
|
638
|
-
(0,
|
|
639
|
-
(0,
|
|
639
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
640
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
640
641
|
"export": true,
|
|
641
642
|
"const": true,
|
|
642
643
|
name: "tailStreamContextStorage",
|
|
643
644
|
doc: "An AsyncLocalStorage instance for managing the Cloudflare tail stream runtime context.",
|
|
644
|
-
initializer:
|
|
645
|
+
initializer: _alloy_js_core.code`(globalContextStorage[CLOUDFLARE_TAIL_STREAM_CONTEXT_KEY] ??= new AsyncLocalStorage<CloudflareTailStreamContext>()) as AsyncLocalStorage<CloudflareTailStreamContext>; `
|
|
645
646
|
}),
|
|
646
|
-
(0,
|
|
647
|
-
(0,
|
|
647
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
648
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
648
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.",
|
|
649
650
|
get children() {
|
|
650
|
-
return (0,
|
|
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.` });
|
|
651
652
|
}
|
|
652
653
|
}),
|
|
653
|
-
(0,
|
|
654
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
654
655
|
"export": true,
|
|
655
656
|
name: "getTailStreamContext",
|
|
656
657
|
typeParameters: [{
|
|
@@ -659,30 +660,30 @@ return context as CloudflareTailContext<Env>; `
|
|
|
659
660
|
}],
|
|
660
661
|
parameters: [],
|
|
661
662
|
returnType: "CloudflareTailStreamContext<Env>",
|
|
662
|
-
children:
|
|
663
|
+
children: _alloy_js_core.code`const context = tailStreamContextStorage.getStore();
|
|
663
664
|
if (!context) {
|
|
664
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.");
|
|
665
666
|
}
|
|
666
667
|
return context as CloudflareTailStreamContext<Env>; `
|
|
667
668
|
}),
|
|
668
|
-
(0,
|
|
669
|
-
(0,
|
|
669
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
670
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
670
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.",
|
|
671
672
|
get children() {
|
|
672
673
|
return [
|
|
673
|
-
(0,
|
|
674
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
674
675
|
name: "context",
|
|
675
|
-
children:
|
|
676
|
+
children: _alloy_js_core.code`The Cloudflare tail stream context to run the function with.`
|
|
676
677
|
}),
|
|
677
|
-
(0,
|
|
678
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
678
679
|
name: "callback",
|
|
679
|
-
children:
|
|
680
|
+
children: _alloy_js_core.code`The function to execute within the scope of the provided context.`
|
|
680
681
|
}),
|
|
681
|
-
(0,
|
|
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.` })
|
|
682
683
|
];
|
|
683
684
|
}
|
|
684
685
|
}),
|
|
685
|
-
(0,
|
|
686
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
686
687
|
"export": true,
|
|
687
688
|
name: "withTailStreamContext",
|
|
688
689
|
typeParameters: [{
|
|
@@ -697,11 +698,11 @@ return context as CloudflareTailStreamContext<Env>; `
|
|
|
697
698
|
type: "(ctx: CloudflareTailStreamContext<Env>) => Promise<TailStream.TailEventHandlerType>"
|
|
698
699
|
}],
|
|
699
700
|
returnType: "Promise<TailStream.TailEventHandlerType>",
|
|
700
|
-
children:
|
|
701
|
+
children: _alloy_js_core.code`return tailStreamContextStorage.run(context, () => callback(context)); `
|
|
701
702
|
}),
|
|
702
|
-
(0,
|
|
703
|
-
(0,
|
|
704
|
-
(0,
|
|
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, {
|
|
705
706
|
"export": true,
|
|
706
707
|
name: "CloudflareTraceContext",
|
|
707
708
|
typeParameters: [{
|
|
@@ -711,17 +712,17 @@ return context as CloudflareTailStreamContext<Env>; `
|
|
|
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.",
|
|
712
713
|
get children() {
|
|
713
714
|
return [
|
|
714
|
-
(0,
|
|
715
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
715
716
|
name: "traces",
|
|
716
717
|
type: "TraceItem[]",
|
|
717
718
|
doc: "An array of trace items associated with the Cloudflare trace context."
|
|
718
719
|
}),
|
|
719
|
-
(0,
|
|
720
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
720
721
|
name: "env",
|
|
721
722
|
type: "Env",
|
|
722
723
|
doc: "The Cloudflare environment bindings available during runtime."
|
|
723
724
|
}),
|
|
724
|
-
(0,
|
|
725
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
725
726
|
name: "ctx",
|
|
726
727
|
type: "ExecutionContext",
|
|
727
728
|
doc: "The Cloudflare execution context for the trace operation."
|
|
@@ -729,28 +730,28 @@ return context as CloudflareTailStreamContext<Env>; `
|
|
|
729
730
|
];
|
|
730
731
|
}
|
|
731
732
|
}),
|
|
732
|
-
(0,
|
|
733
|
-
(0,
|
|
733
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
734
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
734
735
|
"const": true,
|
|
735
736
|
name: "CLOUDFLARE_TRACE_CONTEXT_KEY",
|
|
736
|
-
initializer:
|
|
737
|
+
initializer: _alloy_js_core.code`Symbol.for("powerlines-cloudflare-trace"); `
|
|
737
738
|
}),
|
|
738
|
-
(0,
|
|
739
|
-
(0,
|
|
739
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
740
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
740
741
|
"export": true,
|
|
741
742
|
"const": true,
|
|
742
743
|
name: "traceContextStorage",
|
|
743
744
|
doc: "An AsyncLocalStorage instance for managing the Cloudflare trace runtime context.",
|
|
744
|
-
initializer:
|
|
745
|
+
initializer: _alloy_js_core.code`(globalContextStorage[CLOUDFLARE_TRACE_CONTEXT_KEY] ??= new AsyncLocalStorage<CloudflareTraceContext>()) as AsyncLocalStorage<CloudflareTraceContext>; `
|
|
745
746
|
}),
|
|
746
|
-
(0,
|
|
747
|
-
(0,
|
|
747
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
748
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
748
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.",
|
|
749
750
|
get children() {
|
|
750
|
-
return (0,
|
|
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.` });
|
|
751
752
|
}
|
|
752
753
|
}),
|
|
753
|
-
(0,
|
|
754
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
754
755
|
"export": true,
|
|
755
756
|
name: "getTraceContext",
|
|
756
757
|
typeParameters: [{
|
|
@@ -759,30 +760,30 @@ return context as CloudflareTailStreamContext<Env>; `
|
|
|
759
760
|
}],
|
|
760
761
|
parameters: [],
|
|
761
762
|
returnType: "CloudflareTraceContext<Env>",
|
|
762
|
-
children:
|
|
763
|
+
children: _alloy_js_core.code`const context = traceContextStorage.getStore();
|
|
763
764
|
if (!context) {
|
|
764
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.");
|
|
765
766
|
}
|
|
766
767
|
return context as CloudflareTraceContext<Env>; `
|
|
767
768
|
}),
|
|
768
|
-
(0,
|
|
769
|
-
(0,
|
|
769
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
770
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
770
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.",
|
|
771
772
|
get children() {
|
|
772
773
|
return [
|
|
773
|
-
(0,
|
|
774
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
774
775
|
name: "context",
|
|
775
|
-
children:
|
|
776
|
+
children: _alloy_js_core.code`The Cloudflare trace context to run the function with.`
|
|
776
777
|
}),
|
|
777
|
-
(0,
|
|
778
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
778
779
|
name: "callback",
|
|
779
|
-
children:
|
|
780
|
+
children: _alloy_js_core.code`The function to execute within the scope of the provided context.`
|
|
780
781
|
}),
|
|
781
|
-
(0,
|
|
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.` })
|
|
782
783
|
];
|
|
783
784
|
}
|
|
784
785
|
}),
|
|
785
|
-
(0,
|
|
786
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
786
787
|
"export": true,
|
|
787
788
|
name: "withTraceContext",
|
|
788
789
|
typeParameters: [{
|
|
@@ -797,11 +798,11 @@ return context as CloudflareTraceContext<Env>; `
|
|
|
797
798
|
type: "(ctx: CloudflareTraceContext<Env>) => Promise<void>"
|
|
798
799
|
}],
|
|
799
800
|
returnType: "Promise<void>",
|
|
800
|
-
children:
|
|
801
|
+
children: _alloy_js_core.code`return traceContextStorage.run(context, () => callback(context)); `
|
|
801
802
|
}),
|
|
802
|
-
(0,
|
|
803
|
-
(0,
|
|
804
|
-
(0,
|
|
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, {
|
|
805
806
|
"export": true,
|
|
806
807
|
name: "CloudflareTestContext",
|
|
807
808
|
typeParameters: [{
|
|
@@ -811,17 +812,17 @@ return context as CloudflareTraceContext<Env>; `
|
|
|
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.",
|
|
812
813
|
get children() {
|
|
813
814
|
return [
|
|
814
|
-
(0,
|
|
815
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
815
816
|
name: "controller",
|
|
816
817
|
type: "TestController",
|
|
817
818
|
doc: "The test controller associated with the Cloudflare test context."
|
|
818
819
|
}),
|
|
819
|
-
(0,
|
|
820
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
820
821
|
name: "env",
|
|
821
822
|
type: "Env",
|
|
822
823
|
doc: "The Cloudflare environment bindings available during runtime."
|
|
823
824
|
}),
|
|
824
|
-
(0,
|
|
825
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
825
826
|
name: "ctx",
|
|
826
827
|
type: "ExecutionContext",
|
|
827
828
|
doc: "The Cloudflare execution context for the test operation."
|
|
@@ -829,28 +830,28 @@ return context as CloudflareTraceContext<Env>; `
|
|
|
829
830
|
];
|
|
830
831
|
}
|
|
831
832
|
}),
|
|
832
|
-
(0,
|
|
833
|
-
(0,
|
|
833
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
834
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
834
835
|
"const": true,
|
|
835
836
|
name: "CLOUDFLARE_TEST_CONTEXT_KEY",
|
|
836
|
-
initializer:
|
|
837
|
+
initializer: _alloy_js_core.code`Symbol.for("powerlines-cloudflare-test"); `
|
|
837
838
|
}),
|
|
838
|
-
(0,
|
|
839
|
-
(0,
|
|
839
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
840
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
840
841
|
"export": true,
|
|
841
842
|
"const": true,
|
|
842
843
|
name: "testContextStorage",
|
|
843
844
|
doc: "An AsyncLocalStorage instance for managing the Cloudflare test runtime context.",
|
|
844
|
-
initializer:
|
|
845
|
+
initializer: _alloy_js_core.code`(globalContextStorage[CLOUDFLARE_TEST_CONTEXT_KEY] ??= new AsyncLocalStorage<CloudflareTestContext>()) as AsyncLocalStorage<CloudflareTestContext>; `
|
|
845
846
|
}),
|
|
846
|
-
(0,
|
|
847
|
-
(0,
|
|
847
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
848
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
848
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.",
|
|
849
850
|
get children() {
|
|
850
|
-
return (0,
|
|
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.` });
|
|
851
852
|
}
|
|
852
853
|
}),
|
|
853
|
-
(0,
|
|
854
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
854
855
|
"export": true,
|
|
855
856
|
name: "getTestContext",
|
|
856
857
|
typeParameters: [{
|
|
@@ -859,30 +860,30 @@ return context as CloudflareTraceContext<Env>; `
|
|
|
859
860
|
}],
|
|
860
861
|
parameters: [],
|
|
861
862
|
returnType: "CloudflareTestContext<Env>",
|
|
862
|
-
children:
|
|
863
|
+
children: _alloy_js_core.code`const context = testContextStorage.getStore();
|
|
863
864
|
if (!context) {
|
|
864
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.");
|
|
865
866
|
}
|
|
866
867
|
return context as CloudflareTestContext<Env>; `
|
|
867
868
|
}),
|
|
868
|
-
(0,
|
|
869
|
-
(0,
|
|
869
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
870
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
870
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.",
|
|
871
872
|
get children() {
|
|
872
873
|
return [
|
|
873
|
-
(0,
|
|
874
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
874
875
|
name: "context",
|
|
875
|
-
children:
|
|
876
|
+
children: _alloy_js_core.code`The Cloudflare test context to run the function with.`
|
|
876
877
|
}),
|
|
877
|
-
(0,
|
|
878
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
878
879
|
name: "callback",
|
|
879
|
-
children:
|
|
880
|
+
children: _alloy_js_core.code`The function to execute within the scope of the provided context.`
|
|
880
881
|
}),
|
|
881
|
-
(0,
|
|
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.` })
|
|
882
883
|
];
|
|
883
884
|
}
|
|
884
885
|
}),
|
|
885
|
-
(0,
|
|
886
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
886
887
|
"export": true,
|
|
887
888
|
name: "withTestContext",
|
|
888
889
|
typeParameters: [{
|
|
@@ -897,11 +898,11 @@ return context as CloudflareTestContext<Env>; `
|
|
|
897
898
|
type: "(ctx: CloudflareTestContext<Env>) => Promise<void>"
|
|
898
899
|
}],
|
|
899
900
|
returnType: "Promise<void>",
|
|
900
|
-
children:
|
|
901
|
+
children: _alloy_js_core.code`return testContextStorage.run(context, () => callback(context)); `
|
|
901
902
|
}),
|
|
902
|
-
(0,
|
|
903
|
-
(0,
|
|
904
|
-
(0,
|
|
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, {
|
|
905
906
|
get when() {
|
|
906
907
|
return Boolean(children);
|
|
907
908
|
},
|