@powerlines/plugin-cloudflare 0.6.81 → 0.6.83

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/dist/index.mjs CHANGED
@@ -1,2 +1,181 @@
1
- import{CloudflareBuiltin as e}from"./components/cloudflare-builtin.mjs";import{CloudflareEnvBuiltin as t}from"./components/env-builtin.mjs";import{WorkerEntry as n}from"./components/worker-entry.mjs";import"./components/index.mjs";import{resolveWranglerConfigPath as r}from"./helpers/wrangler.mjs";import{createComponent as i}from"@alloy-js/core/jsx-runtime";import{For as a}from"@alloy-js/core";import{getCloudflarePreset as o}from"@cloudflare/unenv-preset";import{render as s}from"@powerlines/plugin-alloy/render";import{readEnvTypeReflection as c}from"@powerlines/plugin-env/helpers";import{resolveModule as l}from"@powerlines/plugin-esbuild/helpers/resolve";import u from"@powerlines/plugin-pulumi";import d from"@powerlines/plugin-unenv";import*as f from"@pulumi/cloudflare";import{omit as p}from"@stryke/helpers/omit";import{joinPaths as m,replaceExtension as h}from"@stryke/path";import{kebabCase as g}from"@stryke/string-format/kebab-case";import{isFunction as _}from"@stryke/type-checks/is-function";import v from"defu";import{unstable_readConfig as y}from"wrangler";function b(b={}){return[d(b.unenv),...u(b.pulumi),{name:`cloudflare`,config(){return{cloudflare:v(p(b,[`unenv`,`pulumi`]),{configPath:r(this)}),resolve:{skipNodeModulesBundle:!1},unenv:{presets:[o({compatibilityDate:this.config.compatibilityDate?.toString(),compatibilityFlags:[`nodejs_als`]})]}}},configResolved(){this.devDependencies[`@cloudflare/workers-types`]=`^4.20240616.0`;let e=y({config:this.config.cloudflare?.configPath},{preserveOriginalMain:!0,hideWarnings:!0});this.cloudflare.wrangler=structuredClone(e)},async prepare(){let n=await c(this,`env`);return s(this,[i(e,{}),i(t,{reflection:n})])},build:{order:`pre`,async handler(){let e=this;return this.cloudflare??={workers:[]},this.cloudflare.workers=await Promise.all(this.entry.map(async(e,t,n)=>{if(!e.input)throw Error(`Cloudflare Worker entry "${e.file}" is missing an input file.`);let r=await l(this,e.input);if(!r?.default)throw Error(`Cloudflare Worker entry "${e.file}" does not export a default handler. The Powerlines Cloudflare plugin expects each Worker entry module to export a default object matching the \`ExportedHandler\` interface from "@cloudflare/workers-types".`);let i=r.metadata?.name||h(e.input.file||e.file)||n.length>1?`${this.config.name}-${t}`:this.config.name;return{metadata:{name:i,pattern:`${i}.{domain}`,entry:e},fetch:_(r.default.fetch),tail:_(r.default.tail),trace:_(r.default.trace),tailStream:_(r.default.tailStream),scheduled:_(r.default.scheduled),test:_(r.default.test),email:_(r.default.email),queue:_(r.default.queue)}})),s(this,i(a,{get each(){return e.cloudflare.workers},children:e=>i(n,{worker:e})}))}},async deploy(){let e=process.env.CLOUDFLARE_API_TOKEN;if(!e)if(e=this.config.cloudflare.apiToken,e)this.warn("If possible, please use the `CLOUDFLARE_API_TOKEN` environment variable instead of using the `apiToken` option directly. The `apiToken` option will work; however, this is a less secure method of configuration.");else throw Error("Unable to determine the Cloudflare API token. Please set the `CLOUDFLARE_API_TOKEN` environment variable.")},pulumi:{async deploy(){let e=process.env.CLOUDFLARE_API_TOKEN;if(!e)if(e=this.config.cloudflare.apiToken,e)this.warn("If possible, please use the `CLOUDFLARE_API_TOKEN` environment variable instead of using the `apiToken` option directly. The `apiToken` option will work; however, this is a less secure method of configuration.");else throw Error("Unable to determine the Cloudflare API token. Please set the `CLOUDFLARE_API_TOKEN` environment variable.");await this.pulumi.setConfig(`cloudflare:apiToken`,{value:e});let t=new f.Provider(`cloudflare-provider`,{apiToken:e}),n=await f.getZone({filter:{account:{id:this.config.cloudflare.accountId},name:this.config.cloudflare.domain}},{provider:t}),r=[],i=[],a=[],o=[],s=[];for(let e of this.cloudflare.workers){let c=new f.Worker(`${this.config.organization?`${this.config.organization}.`:``}${g(this.config.name)===g(e.metadata.name)?g(this.config.name):`${g(this.config.name)}.${g(e.metadata.name)}`}.${g(this.config.mode)}.worker`,v({accountId:this.config.cloudflare.accountId,name:e.metadata.name,tags:[`project:${g(this.config.name)}`,this.config.organization?`organization:${g(this.config.organization)}`:void 0,this.config.mode?`mode:${g(this.config.mode)}`:void 0].filter(Boolean)},e.metadata),{provider:t});r.push(c);let l=new f.WorkerVersion(`${this.config.organization?`${this.config.organization}.`:``}${g(this.config.name)===g(e.metadata.name)?g(this.config.name):`${g(this.config.name)}.${g(e.metadata.name)}`}.${g(this.config.mode)}.worker-version`,v({accountId:this.config.cloudflare.accountId,workerId:c.id,mainModule:m(this.config.output.path,`index.mjs`),modules:[{name:m(this.config.output.path,`index.mjs`),contentType:`application/javascript+module`,contentFile:m(this.config.output.path,`index.mjs`)}]},e.metadata,{compatibilityDate:this.config.compatibilityDate?.cloudflare?.toString(),compatibilityFlags:[`nodejs_als`]}),{provider:t});i.push(l);let u=new f.WorkersDeployment(`${this.config.organization?`${this.config.organization}.`:``}${g(this.config.name)===g(e.metadata.name)?g(this.config.name):`${g(this.config.name)}-${g(e.metadata.name)}`}.${g(this.config.mode)}.workers-deployment`,v({accountId:this.config.cloudflare.accountId,zoneId:n.id,strategy:`percentage`,scriptName:c.name,versions:[{percentage:100,versionId:l.id}]}),{provider:t});a.push(u);let d=new f.WorkersRoute(`${this.config.organization?`${this.config.organization}.`:``}${g(this.config.name)===g(e.metadata.name)?g(this.config.name):`${g(this.config.name)}-${g(e.metadata.name)}`}.${g(this.config.mode)}.workers-route`,v({accountId:this.config.cloudflare.accountId,zoneId:n.id,pattern:e.metadata.pattern.replace(`{domain}`,this.config.cloudflare.domain).replace(`{scriptName}`,e.metadata.name).replace(`{mode}`,this.config.mode),script:c.name}),{provider:t});o.push(d);let p=new f.DnsRecord(`${this.config.organization?`${this.config.organization}.`:``}${g(this.config.name)===g(e.metadata.name)?g(this.config.name):`${g(this.config.name)}-${g(e.metadata.name)}`}.${g(this.config.mode)}.dns-record`,{name:d.pattern,type:`A`,content:`192.0.2.1`,zoneId:n.id,proxied:!0,ttl:1},{provider:t});s.push(p)}return{workers:r,workerVersions:i,workersDeployments:a,workersRoutes:o,dnsRecords:s}}}}]}export{e as CloudflareBuiltin,t as CloudflareEnvBuiltin,n as WorkerEntry,b as default,b as plugin};
1
+ import { CloudflareBuiltin } from "./components/cloudflare-builtin.mjs";
2
+ import { CloudflareEnvBuiltin } from "./components/env-builtin.mjs";
3
+ import { WorkerEntry } from "./components/worker-entry.mjs";
4
+ import "./components/index.mjs";
5
+ import { resolveWranglerConfigPath } from "./helpers/wrangler.mjs";
6
+ import { createComponent } from "@alloy-js/core/jsx-runtime";
7
+ import { For } from "@alloy-js/core";
8
+ import { getCloudflarePreset } from "@cloudflare/unenv-preset";
9
+ import { render } from "@powerlines/plugin-alloy/render";
10
+ import { readEnvTypeReflection } from "@powerlines/plugin-env/helpers";
11
+ import { resolveModule } from "@powerlines/plugin-esbuild/helpers/resolve";
12
+ import pulumi from "@powerlines/plugin-pulumi";
13
+ import unenv from "@powerlines/plugin-unenv";
14
+ import * as pulumiCloudflare from "@pulumi/cloudflare";
15
+ import { omit } from "@stryke/helpers/omit";
16
+ import { joinPaths, replaceExtension } from "@stryke/path";
17
+ import { kebabCase } from "@stryke/string-format/kebab-case";
18
+ import { isFunction } from "@stryke/type-checks/is-function";
19
+ import defu from "defu";
20
+ import { unstable_readConfig } from "wrangler";
21
+
22
+ //#region src/index.tsx
23
+ /**
24
+ * A Powerlines plugin to assist in developing other Powerlines plugins.
25
+ */
26
+ function plugin(options = {}) {
27
+ return [
28
+ unenv(options.unenv),
29
+ ...pulumi(options.pulumi),
30
+ {
31
+ name: "cloudflare",
32
+ config() {
33
+ return {
34
+ cloudflare: defu(omit(options, ["unenv", "pulumi"]), { configPath: resolveWranglerConfigPath(this) }),
35
+ resolve: { skipNodeModulesBundle: false },
36
+ unenv: { presets: [getCloudflarePreset({
37
+ compatibilityDate: this.config.compatibilityDate?.toString(),
38
+ compatibilityFlags: ["nodejs_als"]
39
+ })] }
40
+ };
41
+ },
42
+ configResolved() {
43
+ this.devDependencies["@cloudflare/workers-types"] = "^4.20240616.0";
44
+ const config = unstable_readConfig({ config: this.config.cloudflare?.configPath }, {
45
+ preserveOriginalMain: true,
46
+ hideWarnings: true
47
+ });
48
+ this.cloudflare.wrangler = structuredClone(config);
49
+ },
50
+ async prepare() {
51
+ const result = await readEnvTypeReflection(this, "env");
52
+ return render(this, [createComponent(CloudflareBuiltin, {}), createComponent(CloudflareEnvBuiltin, { reflection: result })]);
53
+ },
54
+ build: {
55
+ order: "pre",
56
+ async handler() {
57
+ const _self$ = this;
58
+ this.cloudflare ??= { workers: [] };
59
+ this.cloudflare.workers = await Promise.all(this.entry.map(async (entry, i, arr) => {
60
+ if (!entry.input) throw new Error(`Cloudflare Worker entry "${entry.file}" is missing an input file.`);
61
+ const workerModule = await resolveModule(this, entry.input);
62
+ if (!workerModule?.default) throw new Error(`Cloudflare Worker entry "${entry.file}" does not export a default handler. The Powerlines Cloudflare plugin expects each Worker entry module to export a default object matching the \`ExportedHandler\` interface from "@cloudflare/workers-types".`);
63
+ const name = workerModule.metadata?.name || replaceExtension(entry.input.file || entry.file) || arr.length > 1 ? `${this.config.name}-${i}` : this.config.name;
64
+ return {
65
+ metadata: {
66
+ name,
67
+ pattern: `${name}.{domain}`,
68
+ entry
69
+ },
70
+ fetch: isFunction(workerModule.default.fetch),
71
+ tail: isFunction(workerModule.default.tail),
72
+ trace: isFunction(workerModule.default.trace),
73
+ tailStream: isFunction(workerModule.default.tailStream),
74
+ scheduled: isFunction(workerModule.default.scheduled),
75
+ test: isFunction(workerModule.default.test),
76
+ email: isFunction(workerModule.default.email),
77
+ queue: isFunction(workerModule.default.queue)
78
+ };
79
+ }));
80
+ return render(this, createComponent(For, {
81
+ get each() {
82
+ return _self$.cloudflare.workers;
83
+ },
84
+ children: (worker) => createComponent(WorkerEntry, { worker })
85
+ }));
86
+ }
87
+ },
88
+ async deploy() {
89
+ let apiToken = process.env.CLOUDFLARE_API_TOKEN;
90
+ if (!apiToken) {
91
+ apiToken = this.config.cloudflare.apiToken;
92
+ if (apiToken) this.warn("If possible, please use the `CLOUDFLARE_API_TOKEN` environment variable instead of using the `apiToken` option directly. The `apiToken` option will work; however, this is a less secure method of configuration.");
93
+ else throw new Error("Unable to determine the Cloudflare API token. Please set the `CLOUDFLARE_API_TOKEN` environment variable.");
94
+ }
95
+ },
96
+ pulumi: { async deploy() {
97
+ let apiToken = process.env.CLOUDFLARE_API_TOKEN;
98
+ if (!apiToken) {
99
+ apiToken = this.config.cloudflare.apiToken;
100
+ if (apiToken) this.warn("If possible, please use the `CLOUDFLARE_API_TOKEN` environment variable instead of using the `apiToken` option directly. The `apiToken` option will work; however, this is a less secure method of configuration.");
101
+ else throw new Error("Unable to determine the Cloudflare API token. Please set the `CLOUDFLARE_API_TOKEN` environment variable.");
102
+ }
103
+ await this.pulumi.setConfig("cloudflare:apiToken", { value: apiToken });
104
+ const provider = new pulumiCloudflare.Provider("cloudflare-provider", { apiToken });
105
+ const zone = await pulumiCloudflare.getZone({ filter: {
106
+ account: { id: this.config.cloudflare.accountId },
107
+ name: this.config.cloudflare.domain
108
+ } }, { provider });
109
+ const workers = [];
110
+ const workerVersions = [];
111
+ const workersDeployments = [];
112
+ const workersRoutes = [];
113
+ const dnsRecords = [];
114
+ for (const worker of this.cloudflare.workers) {
115
+ const resource = new pulumiCloudflare.Worker(`${this.config.organization ? `${this.config.organization}.` : ""}${kebabCase(this.config.name) === kebabCase(worker.metadata.name) ? kebabCase(this.config.name) : `${kebabCase(this.config.name)}.${kebabCase(worker.metadata.name)}`}.${kebabCase(this.config.mode)}.worker`, defu({
116
+ accountId: this.config.cloudflare.accountId,
117
+ name: worker.metadata.name,
118
+ tags: [
119
+ `project:${kebabCase(this.config.name)}`,
120
+ this.config.organization ? `organization:${kebabCase(this.config.organization)}` : void 0,
121
+ this.config.mode ? `mode:${kebabCase(this.config.mode)}` : void 0
122
+ ].filter(Boolean)
123
+ }, worker.metadata), { provider });
124
+ workers.push(resource);
125
+ const workerVersion = new pulumiCloudflare.WorkerVersion(`${this.config.organization ? `${this.config.organization}.` : ""}${kebabCase(this.config.name) === kebabCase(worker.metadata.name) ? kebabCase(this.config.name) : `${kebabCase(this.config.name)}.${kebabCase(worker.metadata.name)}`}.${kebabCase(this.config.mode)}.worker-version`, defu({
126
+ accountId: this.config.cloudflare.accountId,
127
+ workerId: resource.id,
128
+ mainModule: joinPaths(this.config.output.path, "index.mjs"),
129
+ modules: [{
130
+ name: joinPaths(this.config.output.path, "index.mjs"),
131
+ contentType: "application/javascript+module",
132
+ contentFile: joinPaths(this.config.output.path, "index.mjs")
133
+ }]
134
+ }, worker.metadata, {
135
+ compatibilityDate: this.config.compatibilityDate?.cloudflare?.toString(),
136
+ compatibilityFlags: ["nodejs_als"]
137
+ }), { provider });
138
+ workerVersions.push(workerVersion);
139
+ const workersDeployment = new pulumiCloudflare.WorkersDeployment(`${this.config.organization ? `${this.config.organization}.` : ""}${kebabCase(this.config.name) === kebabCase(worker.metadata.name) ? kebabCase(this.config.name) : `${kebabCase(this.config.name)}-${kebabCase(worker.metadata.name)}`}.${kebabCase(this.config.mode)}.workers-deployment`, defu({
140
+ accountId: this.config.cloudflare.accountId,
141
+ zoneId: zone.id,
142
+ strategy: "percentage",
143
+ scriptName: resource.name,
144
+ versions: [{
145
+ percentage: 100,
146
+ versionId: workerVersion.id
147
+ }]
148
+ }), { provider });
149
+ workersDeployments.push(workersDeployment);
150
+ const workersRoute = new pulumiCloudflare.WorkersRoute(`${this.config.organization ? `${this.config.organization}.` : ""}${kebabCase(this.config.name) === kebabCase(worker.metadata.name) ? kebabCase(this.config.name) : `${kebabCase(this.config.name)}-${kebabCase(worker.metadata.name)}`}.${kebabCase(this.config.mode)}.workers-route`, defu({
151
+ accountId: this.config.cloudflare.accountId,
152
+ zoneId: zone.id,
153
+ pattern: worker.metadata.pattern.replace("{domain}", this.config.cloudflare.domain).replace("{scriptName}", worker.metadata.name).replace("{mode}", this.config.mode),
154
+ script: resource.name
155
+ }), { provider });
156
+ workersRoutes.push(workersRoute);
157
+ const dnsRecord = new pulumiCloudflare.DnsRecord(`${this.config.organization ? `${this.config.organization}.` : ""}${kebabCase(this.config.name) === kebabCase(worker.metadata.name) ? kebabCase(this.config.name) : `${kebabCase(this.config.name)}-${kebabCase(worker.metadata.name)}`}.${kebabCase(this.config.mode)}.dns-record`, {
158
+ name: workersRoute.pattern,
159
+ type: "A",
160
+ content: "192.0.2.1",
161
+ zoneId: zone.id,
162
+ proxied: true,
163
+ ttl: 1
164
+ }, { provider });
165
+ dnsRecords.push(dnsRecord);
166
+ }
167
+ return {
168
+ workers,
169
+ workerVersions,
170
+ workersDeployments,
171
+ workersRoutes,
172
+ dnsRecords
173
+ };
174
+ } }
175
+ }
176
+ ];
177
+ }
178
+
179
+ //#endregion
180
+ export { CloudflareBuiltin, CloudflareEnvBuiltin, WorkerEntry, plugin as default, plugin };
2
181
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { For } from \"@alloy-js/core\";\nimport { getCloudflarePreset } from \"@cloudflare/unenv-preset\";\nimport { render } from \"@powerlines/plugin-alloy/render\";\nimport { readEnvTypeReflection } from \"@powerlines/plugin-env/helpers\";\nimport { resolveModule } from \"@powerlines/plugin-esbuild/helpers/resolve\";\nimport pulumi from \"@powerlines/plugin-pulumi\";\nimport unenv from \"@powerlines/plugin-unenv\";\nimport * as pulumiCloudflare from \"@pulumi/cloudflare\";\nimport { omit } from \"@stryke/helpers/omit\";\nimport { joinPaths, replaceExtension } from \"@stryke/path\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport { PartialKeys } from \"@stryke/types\";\nimport defu from \"defu\";\nimport { Plugin } from \"powerlines\";\n\nimport { unstable_readConfig } from \"wrangler\";\nimport { CloudflareEnvBuiltin } from \"./components\";\nimport { CloudflareBuiltin } from \"./components/cloudflare-builtin\";\nimport { WorkerEntry } from \"./components/worker-entry\";\nimport { resolveWranglerConfigPath } from \"./helpers/wrangler\";\nimport {\n CloudflarePluginContext,\n CloudflarePluginOptions,\n CloudflareWorkerEntryModule\n} from \"./types/plugin\";\nimport { WorkerModule } from \"./types/worker-module\";\nimport { WranglerResolvedConfig, WranglerUserConfig } from \"./types/wrangler\";\n\nexport * from \"./components\";\nexport type * from \"./types\";\n\ndeclare module \"powerlines\" {\n interface Config {\n cloudflare?: CloudflarePluginOptions;\n }\n}\n\n/**\n * A Powerlines plugin to assist in developing other Powerlines plugins.\n */\nexport function plugin<\n TContext extends CloudflarePluginContext = CloudflarePluginContext\n>(options: CloudflarePluginOptions = {}): Plugin<TContext>[] {\n return [\n unenv<TContext>(options.unenv),\n ...pulumi<TContext>(options.pulumi),\n {\n name: \"cloudflare\",\n config() {\n return {\n cloudflare: defu(omit(options, [\"unenv\", \"pulumi\"]), {\n configPath: resolveWranglerConfigPath(this)\n }),\n resolve: {\n skipNodeModulesBundle: false\n },\n unenv: {\n presets: [\n getCloudflarePreset({\n compatibilityDate: this.config.compatibilityDate?.toString(),\n compatibilityFlags: [\"nodejs_als\"]\n })\n ]\n }\n };\n },\n configResolved() {\n this.devDependencies[\"@cloudflare/workers-types\"] = \"^4.20240616.0\";\n\n const config: PartialKeys<WranglerUserConfig, \"build\" | \"define\"> =\n unstable_readConfig(\n { config: this.config.cloudflare?.configPath },\n { preserveOriginalMain: true, hideWarnings: true }\n );\n this.cloudflare.wrangler = structuredClone(\n config\n ) as WranglerResolvedConfig;\n },\n async prepare() {\n const result = await readEnvTypeReflection(this, \"env\");\n\n return render(\n this,\n <>\n <CloudflareBuiltin />\n <CloudflareEnvBuiltin reflection={result} />\n </>\n );\n },\n build: {\n order: \"pre\",\n async handler() {\n this.cloudflare ??= { workers: [] };\n this.cloudflare.workers = (await Promise.all(\n this.entry.map(async (entry, i, arr) => {\n if (!entry.input) {\n throw new Error(\n `Cloudflare Worker entry \"${entry.file}\" is missing an input file.`\n );\n }\n\n const workerModule = await resolveModule<WorkerModule>(\n this,\n entry.input\n );\n if (!workerModule?.default) {\n throw new Error(\n `Cloudflare Worker entry \"${\n entry.file\n }\" does not export a default handler. The Powerlines Cloudflare plugin expects each Worker entry module to export a default object matching the \\`ExportedHandler\\` interface from \"@cloudflare/workers-types\".`\n );\n }\n\n const name =\n workerModule.metadata?.name ||\n replaceExtension(entry.input.file || entry.file) ||\n arr.length > 1\n ? `${this.config.name}-${i}`\n : this.config.name;\n\n return {\n metadata: {\n name,\n pattern: `${name}.{domain}`,\n entry\n },\n fetch: isFunction(workerModule.default.fetch),\n tail: isFunction(workerModule.default.tail),\n trace: isFunction(workerModule.default.trace),\n tailStream: isFunction(workerModule.default.tailStream),\n scheduled: isFunction(workerModule.default.scheduled),\n test: isFunction(workerModule.default.test),\n email: isFunction(workerModule.default.email),\n queue: isFunction(workerModule.default.queue)\n };\n })\n )) as CloudflareWorkerEntryModule[];\n\n return render(\n this,\n <For each={this.cloudflare.workers}>\n {worker => <WorkerEntry worker={worker} />}\n </For>\n );\n }\n },\n async deploy() {\n let apiToken = process.env.CLOUDFLARE_API_TOKEN;\n if (!apiToken) {\n apiToken = this.config.cloudflare.apiToken;\n if (apiToken) {\n this.warn(\n \"If possible, please use the `CLOUDFLARE_API_TOKEN` environment variable instead of using the `apiToken` option directly. The `apiToken` option will work; however, this is a less secure method of configuration.\"\n );\n } else {\n throw new Error(\n \"Unable to determine the Cloudflare API token. Please set the `CLOUDFLARE_API_TOKEN` environment variable.\"\n );\n }\n }\n\n // for (const worker of this.cloudflare.workers) {\n // }\n },\n pulumi: {\n async deploy() {\n let apiToken = process.env.CLOUDFLARE_API_TOKEN;\n if (!apiToken) {\n apiToken = this.config.cloudflare.apiToken;\n if (apiToken) {\n this.warn(\n \"If possible, please use the `CLOUDFLARE_API_TOKEN` environment variable instead of using the `apiToken` option directly. The `apiToken` option will work; however, this is a less secure method of configuration.\"\n );\n } else {\n throw new Error(\n \"Unable to determine the Cloudflare API token. Please set the `CLOUDFLARE_API_TOKEN` environment variable.\"\n );\n }\n }\n\n await this.pulumi.setConfig(\"cloudflare:apiToken\", {\n value: apiToken\n });\n\n const provider = new pulumiCloudflare.Provider(\n \"cloudflare-provider\",\n {\n apiToken\n }\n );\n\n const zone = await pulumiCloudflare.getZone(\n {\n filter: {\n account: { id: this.config.cloudflare.accountId },\n name: this.config.cloudflare.domain\n }\n },\n { provider }\n );\n\n const workers = [] as pulumiCloudflare.Worker[];\n const workerVersions = [] as pulumiCloudflare.WorkerVersion[];\n const workersDeployments = [] as pulumiCloudflare.WorkersDeployment[];\n const workersRoutes = [] as pulumiCloudflare.WorkersRoute[];\n const dnsRecords = [] as pulumiCloudflare.DnsRecord[];\n for (const worker of this.cloudflare.workers) {\n const resource = new pulumiCloudflare.Worker(\n `${this.config.organization ? `${this.config.organization}.` : \"\"}${\n kebabCase(this.config.name) === kebabCase(worker.metadata.name)\n ? kebabCase(this.config.name)\n : `${kebabCase(this.config.name)}.${kebabCase(\n worker.metadata.name\n )}`\n }.${kebabCase(this.config.mode)}.worker`,\n defu(\n {\n accountId: this.config.cloudflare.accountId,\n name: worker.metadata.name,\n tags: [\n `project:${kebabCase(this.config.name)}`,\n this.config.organization\n ? `organization:${kebabCase(this.config.organization)}`\n : undefined,\n this.config.mode\n ? `mode:${kebabCase(this.config.mode)}`\n : undefined\n ].filter(Boolean) as string[]\n },\n worker.metadata\n ),\n { provider }\n );\n workers.push(resource);\n\n const workerVersion = new pulumiCloudflare.WorkerVersion(\n `${this.config.organization ? `${this.config.organization}.` : \"\"}${\n kebabCase(this.config.name) === kebabCase(worker.metadata.name)\n ? kebabCase(this.config.name)\n : `${kebabCase(this.config.name)}.${kebabCase(\n worker.metadata.name\n )}`\n }.${kebabCase(this.config.mode)}.worker-version`,\n defu(\n {\n accountId: this.config.cloudflare.accountId,\n workerId: resource.id,\n mainModule: joinPaths(this.config.output.path, \"index.mjs\"),\n modules: [\n {\n name: joinPaths(this.config.output.path, \"index.mjs\"),\n contentType: \"application/javascript+module\",\n contentFile: joinPaths(\n this.config.output.path,\n \"index.mjs\"\n )\n }\n ]\n },\n worker.metadata,\n {\n compatibilityDate:\n this.config.compatibilityDate?.cloudflare?.toString() as string,\n compatibilityFlags: [\"nodejs_als\"]\n }\n ) as pulumiCloudflare.WorkerVersionArgs,\n { provider }\n );\n workerVersions.push(workerVersion);\n\n const workersDeployment = new pulumiCloudflare.WorkersDeployment(\n `${this.config.organization ? `${this.config.organization}.` : \"\"}${\n kebabCase(this.config.name) === kebabCase(worker.metadata.name)\n ? kebabCase(this.config.name)\n : `${kebabCase(this.config.name)}-${kebabCase(\n worker.metadata.name\n )}`\n }.${kebabCase(this.config.mode)}.workers-deployment`,\n defu({\n accountId: this.config.cloudflare.accountId,\n zoneId: zone.id,\n strategy: \"percentage\",\n scriptName: resource.name,\n versions: [\n {\n percentage: 100,\n versionId: workerVersion.id\n }\n ]\n }),\n { provider }\n );\n workersDeployments.push(workersDeployment);\n\n const workersRoute = new pulumiCloudflare.WorkersRoute(\n `${this.config.organization ? `${this.config.organization}.` : \"\"}${\n kebabCase(this.config.name) === kebabCase(worker.metadata.name)\n ? kebabCase(this.config.name)\n : `${kebabCase(this.config.name)}-${kebabCase(\n worker.metadata.name\n )}`\n }.${kebabCase(this.config.mode)}.workers-route`,\n defu({\n accountId: this.config.cloudflare.accountId,\n zoneId: zone.id,\n pattern: worker.metadata.pattern\n .replace(\"{domain}\", this.config.cloudflare.domain)\n .replace(\"{scriptName}\", worker.metadata.name)\n .replace(\"{mode}\", this.config.mode),\n script: resource.name\n }),\n { provider }\n );\n workersRoutes.push(workersRoute);\n\n const dnsRecord = new pulumiCloudflare.DnsRecord(\n `${this.config.organization ? `${this.config.organization}.` : \"\"}${\n kebabCase(this.config.name) === kebabCase(worker.metadata.name)\n ? kebabCase(this.config.name)\n : `${kebabCase(this.config.name)}-${kebabCase(\n worker.metadata.name\n )}`\n }.${kebabCase(this.config.mode)}.dns-record`,\n {\n name: workersRoute.pattern,\n type: \"A\",\n content: \"192.0.2.1\",\n zoneId: zone.id,\n proxied: true,\n ttl: 1\n },\n { provider }\n );\n dnsRecords.push(dnsRecord);\n }\n\n return {\n workers,\n workerVersions,\n workersDeployments,\n workersRoutes,\n dnsRecords\n };\n }\n }\n }\n ] as Plugin<TContext>[];\n}\n\nexport default plugin;\n"],"mappings":"qkCA+CA,MAAS,CAAA,EAAO,EAAC,MAAW,CAAA,GAAA,EAAA,EAAA,OAAA,CAAA,CAC5B,KAAO,sBAEP,MAAQ,CACN,WAAiB,EAAA,EAAA,EAAA,CAAA,QAAA,SAAA,CAAA,CAAA,CACf,WAAa,EAAuB,KAAA,CACtC,CAAA,CACF,QAAA,CAAA,sBAAA,GAEE,CACG,MAAU,CACb,QAAA,CAAA,EAAA,CACK,kBAAe,KAAA,OAAA,mBAAA,UAAA,CACX,mBAAQ,CAAA,aAA0B,CAClC,CAAA,CAAA,CACF,CACL,EAEA,gBAAA,CACE,KAAK,gBAAa,6BAAA,gBAClB,IAAM,EAAG,EAAA,CACP,OAAO,KAAA,OAAA,YAAA,WACR,CAAE,CACD,qBAAgB,GAChB,aAAI,GACL,CAAC,CACF,KAAK,WAAC,SAAqB,gBAAE,EAAA,EAE/B,MAAM,SAAO,CACX,IAAM,EAAS,MAAA,EAAA,KAAA,MAAA,CACf,OAAO,EAAC,KAAA,CAAA,EAAoB,EAAA,EAAA,CAAA,CAAA,EAAA,EAAA,CAC1B,WAAQ,EACT,CAAC,CAAC,CAAC,EAEN,MAAO,C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AA,KAAA,OAAA,KAAA,CAAA,GAAA,EAAA,EAAA,SAAA,KAAA,GAAA,GAAA,EAAA,KAAA,OAAA,KAAA,CAAA,gBAAA,EAAA,CACD,UAAA,KAAA,OAAA,WAAA,sBAED,QAAW,EAAO,SAAC,QAAgB,QAAQ,WAAA,KAAA,OAAA,WAAA,OAAA,CAAA,QAAA,eAAA,EAAA,SAAA,KAAA,CAAA,QAAA,SAAA,KAAA,OAAA,KAAA,CACzC,OAAA,EAAA,KACD,CAAC,CAAE,CACF,WACD,CAAC,CACF,EAAI,KAAA,EAAA,CACJ,IAAG,EAAA,IAAA,EAAA,UAAA,GAAA,KAAA,OAAA,aAAA,GAAA,KAAA,OAAA,aAAA,GAAA,KAAA,EAAA,KAAA,OAAA,KAAA,GAAA,EAAA,EAAA,SAAA,KAAA,CAAA,EAAA,KAAA,OAAA,KAAA,CAAA,GAAA,EAAA,KAAA,OAAA,KAAA,CAAA,GAAA,EAAA,EAAA,SAAA,KAAA,GAAA,GAAA,EAAA,KAAA,OAAA,KAAA,CAAA,aAAA,CACD,KAAE,EAAS,QACZ,KAAA,wBAED,OAAM,EAAS,GACf,QAAM,GACN,IAAM,EACN,CAAA,CACA,WACA,CAAA,CACA,EAAQ,KAAQ,EAAO,CAEzB,MAAO,CACL,UACA,iBACA,qBACA,gBACA,aACD,EAEJ,CACF,CAAC"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { For } from \"@alloy-js/core\";\nimport { getCloudflarePreset } from \"@cloudflare/unenv-preset\";\nimport { render } from \"@powerlines/plugin-alloy/render\";\nimport { readEnvTypeReflection } from \"@powerlines/plugin-env/helpers\";\nimport { resolveModule } from \"@powerlines/plugin-esbuild/helpers/resolve\";\nimport pulumi from \"@powerlines/plugin-pulumi\";\nimport unenv from \"@powerlines/plugin-unenv\";\nimport * as pulumiCloudflare from \"@pulumi/cloudflare\";\nimport { omit } from \"@stryke/helpers/omit\";\nimport { joinPaths, replaceExtension } from \"@stryke/path\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport { PartialKeys } from \"@stryke/types\";\nimport defu from \"defu\";\nimport { Plugin } from \"powerlines\";\n\nimport { unstable_readConfig } from \"wrangler\";\nimport { CloudflareEnvBuiltin } from \"./components\";\nimport { CloudflareBuiltin } from \"./components/cloudflare-builtin\";\nimport { WorkerEntry } from \"./components/worker-entry\";\nimport { resolveWranglerConfigPath } from \"./helpers/wrangler\";\nimport {\n CloudflarePluginContext,\n CloudflarePluginOptions,\n CloudflareWorkerEntryModule\n} from \"./types/plugin\";\nimport { WorkerModule } from \"./types/worker-module\";\nimport { WranglerResolvedConfig, WranglerUserConfig } from \"./types/wrangler\";\n\nexport * from \"./components\";\nexport type * from \"./types\";\n\ndeclare module \"powerlines\" {\n interface Config {\n cloudflare?: CloudflarePluginOptions;\n }\n}\n\n/**\n * A Powerlines plugin to assist in developing other Powerlines plugins.\n */\nexport function plugin<\n TContext extends CloudflarePluginContext = CloudflarePluginContext\n>(options: CloudflarePluginOptions = {}): Plugin<TContext>[] {\n return [\n unenv<TContext>(options.unenv),\n ...pulumi<TContext>(options.pulumi),\n {\n name: \"cloudflare\",\n config() {\n return {\n cloudflare: defu(omit(options, [\"unenv\", \"pulumi\"]), {\n configPath: resolveWranglerConfigPath(this)\n }),\n resolve: {\n skipNodeModulesBundle: false\n },\n unenv: {\n presets: [\n getCloudflarePreset({\n compatibilityDate: this.config.compatibilityDate?.toString(),\n compatibilityFlags: [\"nodejs_als\"]\n })\n ]\n }\n };\n },\n configResolved() {\n this.devDependencies[\"@cloudflare/workers-types\"] = \"^4.20240616.0\";\n\n const config: PartialKeys<WranglerUserConfig, \"build\" | \"define\"> =\n unstable_readConfig(\n { config: this.config.cloudflare?.configPath },\n { preserveOriginalMain: true, hideWarnings: true }\n );\n this.cloudflare.wrangler = structuredClone(\n config\n ) as WranglerResolvedConfig;\n },\n async prepare() {\n const result = await readEnvTypeReflection(this, \"env\");\n\n return render(\n this,\n <>\n <CloudflareBuiltin />\n <CloudflareEnvBuiltin reflection={result} />\n </>\n );\n },\n build: {\n order: \"pre\",\n async handler() {\n this.cloudflare ??= { workers: [] };\n this.cloudflare.workers = (await Promise.all(\n this.entry.map(async (entry, i, arr) => {\n if (!entry.input) {\n throw new Error(\n `Cloudflare Worker entry \"${entry.file}\" is missing an input file.`\n );\n }\n\n const workerModule = await resolveModule<WorkerModule>(\n this,\n entry.input\n );\n if (!workerModule?.default) {\n throw new Error(\n `Cloudflare Worker entry \"${\n entry.file\n }\" does not export a default handler. The Powerlines Cloudflare plugin expects each Worker entry module to export a default object matching the \\`ExportedHandler\\` interface from \"@cloudflare/workers-types\".`\n );\n }\n\n const name =\n workerModule.metadata?.name ||\n replaceExtension(entry.input.file || entry.file) ||\n arr.length > 1\n ? `${this.config.name}-${i}`\n : this.config.name;\n\n return {\n metadata: {\n name,\n pattern: `${name}.{domain}`,\n entry\n },\n fetch: isFunction(workerModule.default.fetch),\n tail: isFunction(workerModule.default.tail),\n trace: isFunction(workerModule.default.trace),\n tailStream: isFunction(workerModule.default.tailStream),\n scheduled: isFunction(workerModule.default.scheduled),\n test: isFunction(workerModule.default.test),\n email: isFunction(workerModule.default.email),\n queue: isFunction(workerModule.default.queue)\n };\n })\n )) as CloudflareWorkerEntryModule[];\n\n return render(\n this,\n <For each={this.cloudflare.workers}>\n {worker => <WorkerEntry worker={worker} />}\n </For>\n );\n }\n },\n async deploy() {\n let apiToken = process.env.CLOUDFLARE_API_TOKEN;\n if (!apiToken) {\n apiToken = this.config.cloudflare.apiToken;\n if (apiToken) {\n this.warn(\n \"If possible, please use the `CLOUDFLARE_API_TOKEN` environment variable instead of using the `apiToken` option directly. The `apiToken` option will work; however, this is a less secure method of configuration.\"\n );\n } else {\n throw new Error(\n \"Unable to determine the Cloudflare API token. Please set the `CLOUDFLARE_API_TOKEN` environment variable.\"\n );\n }\n }\n\n // for (const worker of this.cloudflare.workers) {\n // }\n },\n pulumi: {\n async deploy() {\n let apiToken = process.env.CLOUDFLARE_API_TOKEN;\n if (!apiToken) {\n apiToken = this.config.cloudflare.apiToken;\n if (apiToken) {\n this.warn(\n \"If possible, please use the `CLOUDFLARE_API_TOKEN` environment variable instead of using the `apiToken` option directly. The `apiToken` option will work; however, this is a less secure method of configuration.\"\n );\n } else {\n throw new Error(\n \"Unable to determine the Cloudflare API token. Please set the `CLOUDFLARE_API_TOKEN` environment variable.\"\n );\n }\n }\n\n await this.pulumi.setConfig(\"cloudflare:apiToken\", {\n value: apiToken\n });\n\n const provider = new pulumiCloudflare.Provider(\n \"cloudflare-provider\",\n {\n apiToken\n }\n );\n\n const zone = await pulumiCloudflare.getZone(\n {\n filter: {\n account: { id: this.config.cloudflare.accountId },\n name: this.config.cloudflare.domain\n }\n },\n { provider }\n );\n\n const workers = [] as pulumiCloudflare.Worker[];\n const workerVersions = [] as pulumiCloudflare.WorkerVersion[];\n const workersDeployments = [] as pulumiCloudflare.WorkersDeployment[];\n const workersRoutes = [] as pulumiCloudflare.WorkersRoute[];\n const dnsRecords = [] as pulumiCloudflare.DnsRecord[];\n for (const worker of this.cloudflare.workers) {\n const resource = new pulumiCloudflare.Worker(\n `${this.config.organization ? `${this.config.organization}.` : \"\"}${\n kebabCase(this.config.name) === kebabCase(worker.metadata.name)\n ? kebabCase(this.config.name)\n : `${kebabCase(this.config.name)}.${kebabCase(\n worker.metadata.name\n )}`\n }.${kebabCase(this.config.mode)}.worker`,\n defu(\n {\n accountId: this.config.cloudflare.accountId,\n name: worker.metadata.name,\n tags: [\n `project:${kebabCase(this.config.name)}`,\n this.config.organization\n ? `organization:${kebabCase(this.config.organization)}`\n : undefined,\n this.config.mode\n ? `mode:${kebabCase(this.config.mode)}`\n : undefined\n ].filter(Boolean) as string[]\n },\n worker.metadata\n ),\n { provider }\n );\n workers.push(resource);\n\n const workerVersion = new pulumiCloudflare.WorkerVersion(\n `${this.config.organization ? `${this.config.organization}.` : \"\"}${\n kebabCase(this.config.name) === kebabCase(worker.metadata.name)\n ? kebabCase(this.config.name)\n : `${kebabCase(this.config.name)}.${kebabCase(\n worker.metadata.name\n )}`\n }.${kebabCase(this.config.mode)}.worker-version`,\n defu(\n {\n accountId: this.config.cloudflare.accountId,\n workerId: resource.id,\n mainModule: joinPaths(this.config.output.path, \"index.mjs\"),\n modules: [\n {\n name: joinPaths(this.config.output.path, \"index.mjs\"),\n contentType: \"application/javascript+module\",\n contentFile: joinPaths(\n this.config.output.path,\n \"index.mjs\"\n )\n }\n ]\n },\n worker.metadata,\n {\n compatibilityDate:\n this.config.compatibilityDate?.cloudflare?.toString() as string,\n compatibilityFlags: [\"nodejs_als\"]\n }\n ) as pulumiCloudflare.WorkerVersionArgs,\n { provider }\n );\n workerVersions.push(workerVersion);\n\n const workersDeployment = new pulumiCloudflare.WorkersDeployment(\n `${this.config.organization ? `${this.config.organization}.` : \"\"}${\n kebabCase(this.config.name) === kebabCase(worker.metadata.name)\n ? kebabCase(this.config.name)\n : `${kebabCase(this.config.name)}-${kebabCase(\n worker.metadata.name\n )}`\n }.${kebabCase(this.config.mode)}.workers-deployment`,\n defu({\n accountId: this.config.cloudflare.accountId,\n zoneId: zone.id,\n strategy: \"percentage\",\n scriptName: resource.name,\n versions: [\n {\n percentage: 100,\n versionId: workerVersion.id\n }\n ]\n }),\n { provider }\n );\n workersDeployments.push(workersDeployment);\n\n const workersRoute = new pulumiCloudflare.WorkersRoute(\n `${this.config.organization ? `${this.config.organization}.` : \"\"}${\n kebabCase(this.config.name) === kebabCase(worker.metadata.name)\n ? kebabCase(this.config.name)\n : `${kebabCase(this.config.name)}-${kebabCase(\n worker.metadata.name\n )}`\n }.${kebabCase(this.config.mode)}.workers-route`,\n defu({\n accountId: this.config.cloudflare.accountId,\n zoneId: zone.id,\n pattern: worker.metadata.pattern\n .replace(\"{domain}\", this.config.cloudflare.domain)\n .replace(\"{scriptName}\", worker.metadata.name)\n .replace(\"{mode}\", this.config.mode),\n script: resource.name\n }),\n { provider }\n );\n workersRoutes.push(workersRoute);\n\n const dnsRecord = new pulumiCloudflare.DnsRecord(\n `${this.config.organization ? `${this.config.organization}.` : \"\"}${\n kebabCase(this.config.name) === kebabCase(worker.metadata.name)\n ? kebabCase(this.config.name)\n : `${kebabCase(this.config.name)}-${kebabCase(\n worker.metadata.name\n )}`\n }.${kebabCase(this.config.mode)}.dns-record`,\n {\n name: workersRoute.pattern,\n type: \"A\",\n content: \"192.0.2.1\",\n zoneId: zone.id,\n proxied: true,\n ttl: 1\n },\n { provider }\n );\n dnsRecords.push(dnsRecord);\n }\n\n return {\n workers,\n workerVersions,\n workersDeployments,\n workersRoutes,\n dnsRecords\n };\n }\n }\n }\n ] as Plugin<TContext>[];\n}\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,QAAS;EAAA,MAAO,QAAC,MAAW;EAAA,GAAA,OAAA,QAAA,OAAA;EAAA;GAC5B,MAAO;;AAEP,WAAQ;KACN,YAAiB,KAAA,KAAA,SAAA,CAAA,SAAA,SAAA,CAAA,EAAA,EACf,YAAa,0BAAuB,KAAA,EACtC,CAAA;KACF,SAAA,gCAEE;KACG,OAAU,EACb,SAAA,CAAA,oBAAA;MACK,mBAAe,KAAA,OAAA,mBAAA,UAAA;MACX,oBAAQ,CAAA,aAA0B;MAClC,CAAA,CAAA,EACF;KACL;;GAEA,iBAAA;AACE,SAAK,gBAAa,+BAAA;IAClB,MAAM,SAAG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object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./wrangler.cjs`);exports.JsonSchema=e.JsonSchema,exports.LiteralSchema=e.LiteralSchema,exports.PathSchema=e.PathSchema,exports.defaultWranglerConfig=e.defaultWranglerConfig,exports.isCyclic=e.isCyclic,exports.parseWithRootPath=e.parseWithRootPath;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_types_wrangler = require('./wrangler.cjs');
3
+
4
+ exports.JsonSchema = require_types_wrangler.JsonSchema;
5
+ exports.LiteralSchema = require_types_wrangler.LiteralSchema;
6
+ exports.PathSchema = require_types_wrangler.PathSchema;
7
+ exports.defaultWranglerConfig = require_types_wrangler.defaultWranglerConfig;
8
+ exports.isCyclic = require_types_wrangler.isCyclic;
9
+ exports.parseWithRootPath = require_types_wrangler.parseWithRootPath;
@@ -1 +1,3 @@
1
- import{JsonSchema as e,LiteralSchema as t,PathSchema as n,defaultWranglerConfig as r,isCyclic as i,parseWithRootPath as a}from"./wrangler.mjs";export{e as JsonSchema,t as LiteralSchema,n as PathSchema,r as defaultWranglerConfig,i as isCyclic,a as parseWithRootPath};
1
+ import { JsonSchema, LiteralSchema, PathSchema, defaultWranglerConfig, isCyclic, parseWithRootPath } from "./wrangler.mjs";
2
+
3
+ export { JsonSchema, LiteralSchema, PathSchema, defaultWranglerConfig, isCyclic, parseWithRootPath };
@@ -1 +1 @@
1
- export{};
1
+ export { };
@@ -1 +1 @@
1
- export{};
1
+ export { };
@@ -1 +1,172 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`);let t=require(`node:assert`);t=e.__toESM(t,1);let n=require(`node:path`);n=e.__toESM(n,1);let r=require(`zod`);r=e.__toESM(r,1);const i=r.union([r.string(),r.number(),r.boolean(),r.null()]),a=r.lazy(()=>r.union([i,r.array(a),r.record(r.string(),a)]));let o;async function s(e,t,n,r){o=e;try{return await t._zod.parse(n,r)}finally{o=void 0}}const c=r.string().transform(e=>((0,t.default)(o!==void 0,"Expected `PathSchema` to be parsed within `parseWithRootPath()`"),n.default.resolve(o,e)));function l(e,t=new Set){if(typeof e!=`object`||!e)return!1;for(let n of Object.values(e)){if(t.has(n)||(t.add(n),l(n,t)))return!0;t.delete(n)}return!1}const u={configPath:void 0,userConfigPath:void 0,topLevelName:void 0,definedEnvironments:void 0,targetEnvironment:void 0,pages_build_output_dir:void 0,send_metrics:void 0,dev:{ip:process.platform===`win32`?`127.0.0.1`:`localhost`,port:void 0,inspector_port:void 0,inspector_ip:void 0,local_protocol:`http`,upstream_protocol:`http`,host:void 0,enable_containers:!0,container_engine:void 0,generate_types:!1},name:void 0,compatibility_date:void 0,compatibility_flags:[],limits:void 0,placement:void 0,vars:{},durable_objects:{bindings:[]},kv_namespaces:[],queues:{producers:[],consumers:[]},r2_buckets:[],d1_databases:[],vectorize:[],hyperdrive:[],workflows:[],secrets_store_secrets:[],services:[],analytics_engine_datasets:[],ai:void 0,images:void 0,stream:void 0,media:void 0,version_metadata:void 0,unsafe_hello_world:[],ratelimits:[],worker_loaders:[],legacy_env:!0,site:void 0,wasm_modules:void 0,text_blobs:void 0,data_blobs:void 0,keep_vars:void 0,alias:void 0,account_id:void 0,main:void 0,find_additional_modules:void 0,preserve_file_names:void 0,base_dir:void 0,workers_dev:void 0,preview_urls:void 0,route:void 0,routes:void 0,tsconfig:void 0,jsx_factory:`React.createElement`,jsx_fragment:`React.Fragment`,migrations:[],triggers:{crons:void 0},rules:[],build:{command:void 0,watch_dir:`./src`,cwd:void 0},no_bundle:void 0,minify:void 0,keep_names:void 0,dispatch_namespaces:[],first_party_worker:void 0,logfwdr:{bindings:[]},logpush:void 0,upload_source_maps:void 0,assets:void 0,observability:{enabled:!0},cache:void 0,compliance_region:void 0,python_modules:{exclude:[`**/*.pyc`]},define:{},cloudchamber:{},containers:void 0,send_email:[],browser:void 0,unsafe:{},mtls_certificates:[],tail_consumers:void 0,streaming_tail_consumers:void 0,pipelines:[],vpc_services:[],ai_search_namespaces:[]};exports.JsonSchema=a,exports.LiteralSchema=i,exports.PathSchema=c,exports.defaultWranglerConfig=u,exports.isCyclic=l,exports.parseWithRootPath=s;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ let node_assert = require("node:assert");
4
+ node_assert = require_runtime.__toESM(node_assert, 1);
5
+ let node_path = require("node:path");
6
+ node_path = require_runtime.__toESM(node_path, 1);
7
+ let zod = require("zod");
8
+ zod = require_runtime.__toESM(zod, 1);
9
+
10
+ //#region src/types/wrangler.ts
11
+ const LiteralSchema = zod.union([
12
+ zod.string(),
13
+ zod.number(),
14
+ zod.boolean(),
15
+ zod.null()
16
+ ]);
17
+ const JsonSchema = zod.lazy(() => zod.union([
18
+ LiteralSchema,
19
+ zod.array(JsonSchema),
20
+ zod.record(zod.string(), JsonSchema)
21
+ ]));
22
+ let rootPath;
23
+ async function parseWithRootPath(newRootPath, schema, payload, ctx) {
24
+ rootPath = newRootPath;
25
+ try {
26
+ return await schema._zod.parse(payload, ctx);
27
+ } finally {
28
+ rootPath = void 0;
29
+ }
30
+ }
31
+ const PathSchema = zod.string().transform((p) => {
32
+ (0, node_assert.default)(rootPath !== void 0, "Expected `PathSchema` to be parsed within `parseWithRootPath()`");
33
+ return node_path.default.resolve(rootPath, p);
34
+ });
35
+ function isCyclic(value, seen = /* @__PURE__ */ new Set()) {
36
+ if (typeof value !== "object" || value === null) return false;
37
+ for (const child of Object.values(value)) {
38
+ if (seen.has(child)) return true;
39
+ seen.add(child);
40
+ if (isCyclic(child, seen)) return true;
41
+ seen.delete(child);
42
+ }
43
+ return false;
44
+ }
45
+ /**
46
+ * This is the static type definition for the configuration object.
47
+ *
48
+ * It reflects a normalized and validated version of the configuration that you can write in a Wrangler configuration file,
49
+ * and optionally augment with arguments passed directly to wrangler.
50
+ *
51
+ * For more information about the configuration object, see the documentation at https://developers.cloudflare.com/workers/cli-wrangler/configuration
52
+ *
53
+ * @remarks
54
+ * - Fields that are only specified in `ConfigFields` and not `Environment` can only appear
55
+ * in the top level config and should not appear in any environments.
56
+ * - Fields that are specified in `PagesConfigFields` are only relevant for Pages projects
57
+ * - All top level fields in config and environments are optional in the Wrangler configuration file.
58
+ */
59
+ const defaultWranglerConfig = {
60
+ configPath: void 0,
61
+ userConfigPath: void 0,
62
+ topLevelName: void 0,
63
+ definedEnvironments: void 0,
64
+ targetEnvironment: void 0,
65
+ pages_build_output_dir: void 0,
66
+ send_metrics: void 0,
67
+ dev: {
68
+ ip: process.platform === "win32" ? "127.0.0.1" : "localhost",
69
+ port: void 0,
70
+ inspector_port: void 0,
71
+ inspector_ip: void 0,
72
+ local_protocol: "http",
73
+ upstream_protocol: "http",
74
+ host: void 0,
75
+ enable_containers: true,
76
+ container_engine: void 0,
77
+ generate_types: false
78
+ },
79
+ /** INHERITABLE ENVIRONMENT FIELDS */
80
+ name: void 0,
81
+ compatibility_date: void 0,
82
+ compatibility_flags: [],
83
+ limits: void 0,
84
+ placement: void 0,
85
+ /** NON-INHERITABLE ENVIRONMENT FIELDS */
86
+ vars: {},
87
+ durable_objects: { bindings: [] },
88
+ kv_namespaces: [],
89
+ queues: {
90
+ producers: [],
91
+ consumers: []
92
+ },
93
+ r2_buckets: [],
94
+ d1_databases: [],
95
+ vectorize: [],
96
+ hyperdrive: [],
97
+ workflows: [],
98
+ secrets_store_secrets: [],
99
+ services: [],
100
+ analytics_engine_datasets: [],
101
+ ai: void 0,
102
+ images: void 0,
103
+ stream: void 0,
104
+ media: void 0,
105
+ version_metadata: void 0,
106
+ unsafe_hello_world: [],
107
+ ratelimits: [],
108
+ worker_loaders: [],
109
+ legacy_env: true,
110
+ site: void 0,
111
+ wasm_modules: void 0,
112
+ text_blobs: void 0,
113
+ data_blobs: void 0,
114
+ keep_vars: void 0,
115
+ alias: void 0,
116
+ /** INHERITABLE ENVIRONMENT FIELDS */
117
+ account_id: void 0,
118
+ main: void 0,
119
+ find_additional_modules: void 0,
120
+ preserve_file_names: void 0,
121
+ base_dir: void 0,
122
+ workers_dev: void 0,
123
+ preview_urls: void 0,
124
+ route: void 0,
125
+ routes: void 0,
126
+ tsconfig: void 0,
127
+ jsx_factory: "React.createElement",
128
+ jsx_fragment: "React.Fragment",
129
+ migrations: [],
130
+ triggers: { crons: void 0 },
131
+ rules: [],
132
+ build: {
133
+ command: void 0,
134
+ watch_dir: "./src",
135
+ cwd: void 0
136
+ },
137
+ no_bundle: void 0,
138
+ minify: void 0,
139
+ keep_names: void 0,
140
+ dispatch_namespaces: [],
141
+ first_party_worker: void 0,
142
+ logfwdr: { bindings: [] },
143
+ logpush: void 0,
144
+ upload_source_maps: void 0,
145
+ assets: void 0,
146
+ observability: { enabled: true },
147
+ cache: void 0,
148
+ /** The default here is undefined so that we can delegate to the CLOUDFLARE_COMPLIANCE_REGION environment variable. */
149
+ compliance_region: void 0,
150
+ python_modules: { exclude: ["**/*.pyc"] },
151
+ /** NON-INHERITABLE ENVIRONMENT FIELDS */
152
+ define: {},
153
+ cloudchamber: {},
154
+ containers: void 0,
155
+ send_email: [],
156
+ browser: void 0,
157
+ unsafe: {},
158
+ mtls_certificates: [],
159
+ tail_consumers: void 0,
160
+ streaming_tail_consumers: void 0,
161
+ pipelines: [],
162
+ vpc_services: [],
163
+ ai_search_namespaces: []
164
+ };
165
+
166
+ //#endregion
167
+ exports.JsonSchema = JsonSchema;
168
+ exports.LiteralSchema = LiteralSchema;
169
+ exports.PathSchema = PathSchema;
170
+ exports.defaultWranglerConfig = defaultWranglerConfig;
171
+ exports.isCyclic = isCyclic;
172
+ exports.parseWithRootPath = parseWithRootPath;
@@ -1,2 +1,163 @@
1
- import e from"node:assert";import t from"node:path";import*as n from"zod";const r=n.union([n.string(),n.number(),n.boolean(),n.null()]),i=n.lazy(()=>n.union([r,n.array(i),n.record(n.string(),i)]));let a;async function o(e,t,n,r){a=e;try{return await t._zod.parse(n,r)}finally{a=void 0}}const s=n.string().transform(n=>(e(a!==void 0,"Expected `PathSchema` to be parsed within `parseWithRootPath()`"),t.resolve(a,n)));function c(e,t=new Set){if(typeof e!=`object`||!e)return!1;for(let n of Object.values(e)){if(t.has(n)||(t.add(n),c(n,t)))return!0;t.delete(n)}return!1}const l={configPath:void 0,userConfigPath:void 0,topLevelName:void 0,definedEnvironments:void 0,targetEnvironment:void 0,pages_build_output_dir:void 0,send_metrics:void 0,dev:{ip:process.platform===`win32`?`127.0.0.1`:`localhost`,port:void 0,inspector_port:void 0,inspector_ip:void 0,local_protocol:`http`,upstream_protocol:`http`,host:void 0,enable_containers:!0,container_engine:void 0,generate_types:!1},name:void 0,compatibility_date:void 0,compatibility_flags:[],limits:void 0,placement:void 0,vars:{},durable_objects:{bindings:[]},kv_namespaces:[],queues:{producers:[],consumers:[]},r2_buckets:[],d1_databases:[],vectorize:[],hyperdrive:[],workflows:[],secrets_store_secrets:[],services:[],analytics_engine_datasets:[],ai:void 0,images:void 0,stream:void 0,media:void 0,version_metadata:void 0,unsafe_hello_world:[],ratelimits:[],worker_loaders:[],legacy_env:!0,site:void 0,wasm_modules:void 0,text_blobs:void 0,data_blobs:void 0,keep_vars:void 0,alias:void 0,account_id:void 0,main:void 0,find_additional_modules:void 0,preserve_file_names:void 0,base_dir:void 0,workers_dev:void 0,preview_urls:void 0,route:void 0,routes:void 0,tsconfig:void 0,jsx_factory:`React.createElement`,jsx_fragment:`React.Fragment`,migrations:[],triggers:{crons:void 0},rules:[],build:{command:void 0,watch_dir:`./src`,cwd:void 0},no_bundle:void 0,minify:void 0,keep_names:void 0,dispatch_namespaces:[],first_party_worker:void 0,logfwdr:{bindings:[]},logpush:void 0,upload_source_maps:void 0,assets:void 0,observability:{enabled:!0},cache:void 0,compliance_region:void 0,python_modules:{exclude:[`**/*.pyc`]},define:{},cloudchamber:{},containers:void 0,send_email:[],browser:void 0,unsafe:{},mtls_certificates:[],tail_consumers:void 0,streaming_tail_consumers:void 0,pipelines:[],vpc_services:[],ai_search_namespaces:[]};export{i as JsonSchema,r as LiteralSchema,s as PathSchema,l as defaultWranglerConfig,c as isCyclic,o as parseWithRootPath};
1
+ import assert from "node:assert";
2
+ import path from "node:path";
3
+ import * as z from "zod";
4
+
5
+ //#region src/types/wrangler.ts
6
+ const LiteralSchema = z.union([
7
+ z.string(),
8
+ z.number(),
9
+ z.boolean(),
10
+ z.null()
11
+ ]);
12
+ const JsonSchema = z.lazy(() => z.union([
13
+ LiteralSchema,
14
+ z.array(JsonSchema),
15
+ z.record(z.string(), JsonSchema)
16
+ ]));
17
+ let rootPath;
18
+ async function parseWithRootPath(newRootPath, schema, payload, ctx) {
19
+ rootPath = newRootPath;
20
+ try {
21
+ return await schema._zod.parse(payload, ctx);
22
+ } finally {
23
+ rootPath = void 0;
24
+ }
25
+ }
26
+ const PathSchema = z.string().transform((p) => {
27
+ assert(rootPath !== void 0, "Expected `PathSchema` to be parsed within `parseWithRootPath()`");
28
+ return path.resolve(rootPath, p);
29
+ });
30
+ function isCyclic(value, seen = /* @__PURE__ */ new Set()) {
31
+ if (typeof value !== "object" || value === null) return false;
32
+ for (const child of Object.values(value)) {
33
+ if (seen.has(child)) return true;
34
+ seen.add(child);
35
+ if (isCyclic(child, seen)) return true;
36
+ seen.delete(child);
37
+ }
38
+ return false;
39
+ }
40
+ /**
41
+ * This is the static type definition for the configuration object.
42
+ *
43
+ * It reflects a normalized and validated version of the configuration that you can write in a Wrangler configuration file,
44
+ * and optionally augment with arguments passed directly to wrangler.
45
+ *
46
+ * For more information about the configuration object, see the documentation at https://developers.cloudflare.com/workers/cli-wrangler/configuration
47
+ *
48
+ * @remarks
49
+ * - Fields that are only specified in `ConfigFields` and not `Environment` can only appear
50
+ * in the top level config and should not appear in any environments.
51
+ * - Fields that are specified in `PagesConfigFields` are only relevant for Pages projects
52
+ * - All top level fields in config and environments are optional in the Wrangler configuration file.
53
+ */
54
+ const defaultWranglerConfig = {
55
+ configPath: void 0,
56
+ userConfigPath: void 0,
57
+ topLevelName: void 0,
58
+ definedEnvironments: void 0,
59
+ targetEnvironment: void 0,
60
+ pages_build_output_dir: void 0,
61
+ send_metrics: void 0,
62
+ dev: {
63
+ ip: process.platform === "win32" ? "127.0.0.1" : "localhost",
64
+ port: void 0,
65
+ inspector_port: void 0,
66
+ inspector_ip: void 0,
67
+ local_protocol: "http",
68
+ upstream_protocol: "http",
69
+ host: void 0,
70
+ enable_containers: true,
71
+ container_engine: void 0,
72
+ generate_types: false
73
+ },
74
+ /** INHERITABLE ENVIRONMENT FIELDS */
75
+ name: void 0,
76
+ compatibility_date: void 0,
77
+ compatibility_flags: [],
78
+ limits: void 0,
79
+ placement: void 0,
80
+ /** NON-INHERITABLE ENVIRONMENT FIELDS */
81
+ vars: {},
82
+ durable_objects: { bindings: [] },
83
+ kv_namespaces: [],
84
+ queues: {
85
+ producers: [],
86
+ consumers: []
87
+ },
88
+ r2_buckets: [],
89
+ d1_databases: [],
90
+ vectorize: [],
91
+ hyperdrive: [],
92
+ workflows: [],
93
+ secrets_store_secrets: [],
94
+ services: [],
95
+ analytics_engine_datasets: [],
96
+ ai: void 0,
97
+ images: void 0,
98
+ stream: void 0,
99
+ media: void 0,
100
+ version_metadata: void 0,
101
+ unsafe_hello_world: [],
102
+ ratelimits: [],
103
+ worker_loaders: [],
104
+ legacy_env: true,
105
+ site: void 0,
106
+ wasm_modules: void 0,
107
+ text_blobs: void 0,
108
+ data_blobs: void 0,
109
+ keep_vars: void 0,
110
+ alias: void 0,
111
+ /** INHERITABLE ENVIRONMENT FIELDS */
112
+ account_id: void 0,
113
+ main: void 0,
114
+ find_additional_modules: void 0,
115
+ preserve_file_names: void 0,
116
+ base_dir: void 0,
117
+ workers_dev: void 0,
118
+ preview_urls: void 0,
119
+ route: void 0,
120
+ routes: void 0,
121
+ tsconfig: void 0,
122
+ jsx_factory: "React.createElement",
123
+ jsx_fragment: "React.Fragment",
124
+ migrations: [],
125
+ triggers: { crons: void 0 },
126
+ rules: [],
127
+ build: {
128
+ command: void 0,
129
+ watch_dir: "./src",
130
+ cwd: void 0
131
+ },
132
+ no_bundle: void 0,
133
+ minify: void 0,
134
+ keep_names: void 0,
135
+ dispatch_namespaces: [],
136
+ first_party_worker: void 0,
137
+ logfwdr: { bindings: [] },
138
+ logpush: void 0,
139
+ upload_source_maps: void 0,
140
+ assets: void 0,
141
+ observability: { enabled: true },
142
+ cache: void 0,
143
+ /** The default here is undefined so that we can delegate to the CLOUDFLARE_COMPLIANCE_REGION environment variable. */
144
+ compliance_region: void 0,
145
+ python_modules: { exclude: ["**/*.pyc"] },
146
+ /** NON-INHERITABLE ENVIRONMENT FIELDS */
147
+ define: {},
148
+ cloudchamber: {},
149
+ containers: void 0,
150
+ send_email: [],
151
+ browser: void 0,
152
+ unsafe: {},
153
+ mtls_certificates: [],
154
+ tail_consumers: void 0,
155
+ streaming_tail_consumers: void 0,
156
+ pipelines: [],
157
+ vpc_services: [],
158
+ ai_search_namespaces: []
159
+ };
160
+
161
+ //#endregion
162
+ export { JsonSchema, LiteralSchema, PathSchema, defaultWranglerConfig, isCyclic, parseWithRootPath };
2
163
  //# sourceMappingURL=wrangler.mjs.map