wrangler 2.4.1 → 2.4.2
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/package.json +1 -1
- package/src/__tests__/type-generation.test.ts +3 -2
- package/src/type-generation.ts +19 -19
- package/wrangler-dist/cli.js +18 -21
package/package.json
CHANGED
|
@@ -216,8 +216,9 @@ describe("generateTypes()", () => {
|
|
|
216
216
|
|
|
217
217
|
await runWrangler("types");
|
|
218
218
|
expect(std.out).toMatchInlineSnapshot(`
|
|
219
|
-
"
|
|
220
|
-
|
|
219
|
+
"export {};
|
|
220
|
+
declare global {
|
|
221
|
+
const testing_unsafe: any;
|
|
221
222
|
}
|
|
222
223
|
"
|
|
223
224
|
`);
|
package/src/type-generation.ts
CHANGED
|
@@ -15,7 +15,7 @@ export async function generateTypes(
|
|
|
15
15
|
|
|
16
16
|
if (configToDTS.kv_namespaces) {
|
|
17
17
|
for (const kvNamespace of configToDTS.kv_namespaces) {
|
|
18
|
-
envTypeStructure.push(
|
|
18
|
+
envTypeStructure.push(`${kvNamespace.binding}: KVNamespace;`);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
|
|
@@ -27,70 +27,70 @@ export async function generateTypes(
|
|
|
27
27
|
typeof varValue === "number" ||
|
|
28
28
|
typeof varValue === "boolean"
|
|
29
29
|
) {
|
|
30
|
-
envTypeStructure.push(
|
|
30
|
+
envTypeStructure.push(`${varName}: "${varValue}";`);
|
|
31
31
|
}
|
|
32
32
|
if (typeof varValue === "object" && varValue !== null) {
|
|
33
|
-
envTypeStructure.push(
|
|
33
|
+
envTypeStructure.push(`${varName}: ${JSON.stringify(varValue)};`);
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
if (configToDTS.durable_objects?.bindings) {
|
|
39
39
|
for (const durableObject of configToDTS.durable_objects.bindings) {
|
|
40
|
-
envTypeStructure.push(
|
|
40
|
+
envTypeStructure.push(`${durableObject.name}: DurableObjectNamespace;`);
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
if (configToDTS.r2_buckets) {
|
|
45
45
|
for (const R2Bucket of configToDTS.r2_buckets) {
|
|
46
|
-
envTypeStructure.push(
|
|
46
|
+
envTypeStructure.push(`${R2Bucket.binding}: R2Bucket;`);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
if (configToDTS.d1_databases) {
|
|
51
51
|
for (const d1 of configToDTS.d1_databases) {
|
|
52
|
-
envTypeStructure.push(
|
|
52
|
+
envTypeStructure.push(`${d1.binding}: D1Database;`);
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
if (configToDTS.services) {
|
|
57
57
|
for (const service of configToDTS.services) {
|
|
58
|
-
envTypeStructure.push(
|
|
58
|
+
envTypeStructure.push(`${service.binding}: Fetcher;`);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
if (configToDTS.dispatch_namespaces) {
|
|
63
63
|
for (const namespace of configToDTS.dispatch_namespaces) {
|
|
64
|
-
envTypeStructure.push(
|
|
64
|
+
envTypeStructure.push(`${namespace.binding}: any;`);
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
if (configToDTS.logfwdr?.schema) {
|
|
69
|
-
envTypeStructure.push(`
|
|
69
|
+
envTypeStructure.push(`LOGFWDR_SCHEMA: any;`);
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
if (configToDTS.data_blobs) {
|
|
73
73
|
for (const dataBlobs in configToDTS.data_blobs) {
|
|
74
|
-
envTypeStructure.push(
|
|
74
|
+
envTypeStructure.push(`${dataBlobs}: ArrayBuffer;`);
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
if (configToDTS.text_blobs) {
|
|
79
79
|
for (const textBlobs in configToDTS.text_blobs) {
|
|
80
|
-
envTypeStructure.push(
|
|
80
|
+
envTypeStructure.push(`${textBlobs}: string;`);
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
if (configToDTS.unsafe) {
|
|
85
85
|
for (const unsafe of configToDTS.unsafe.bindings) {
|
|
86
|
-
envTypeStructure.push(
|
|
86
|
+
envTypeStructure.push(`${unsafe.name}: any;`);
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
if (configToDTS.queues) {
|
|
91
91
|
if (configToDTS.queues.producers) {
|
|
92
92
|
for (const queue of configToDTS.queues.producers) {
|
|
93
|
-
envTypeStructure.push(
|
|
93
|
+
envTypeStructure.push(`${queue.binding}: Queue;`);
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
}
|
|
@@ -154,13 +154,13 @@ function writeDTSFile({
|
|
|
154
154
|
|
|
155
155
|
let combinedTypeStrings = "";
|
|
156
156
|
if (formatType === "modules") {
|
|
157
|
-
combinedTypeStrings += `interface Env {\n${envTypeStructure
|
|
158
|
-
|
|
159
|
-
|
|
157
|
+
combinedTypeStrings += `interface Env {\n${envTypeStructure
|
|
158
|
+
.map((value) => `\t${value}`)
|
|
159
|
+
.join("\n")} \n}\n${modulesTypeStructure.join("\n")}`;
|
|
160
160
|
} else {
|
|
161
|
-
combinedTypeStrings += `
|
|
162
|
-
|
|
163
|
-
|
|
161
|
+
combinedTypeStrings += `export {};\ndeclare global {\n${envTypeStructure
|
|
162
|
+
.map((value) => `\tconst ${value}`)
|
|
163
|
+
.join("\n")} \n}\n${modulesTypeStructure.join("\n")}`;
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
if (envTypeStructure.length || modulesTypeStructure.length) {
|
package/wrangler-dist/cli.js
CHANGED
|
@@ -141160,7 +141160,7 @@ var import_websocket_server = __toESM(require_websocket_server2(), 1);
|
|
|
141160
141160
|
var wrapper_default = import_websocket.default;
|
|
141161
141161
|
|
|
141162
141162
|
// package.json
|
|
141163
|
-
var version = "2.4.
|
|
141163
|
+
var version = "2.4.2";
|
|
141164
141164
|
var package_default = {
|
|
141165
141165
|
name: "wrangler",
|
|
141166
141166
|
version,
|
|
@@ -162563,67 +162563,67 @@ async function generateTypes(configToDTS, config) {
|
|
|
162563
162563
|
const envTypeStructure = [];
|
|
162564
162564
|
if (configToDTS.kv_namespaces) {
|
|
162565
162565
|
for (const kvNamespace2 of configToDTS.kv_namespaces) {
|
|
162566
|
-
envTypeStructure.push(
|
|
162566
|
+
envTypeStructure.push(`${kvNamespace2.binding}: KVNamespace;`);
|
|
162567
162567
|
}
|
|
162568
162568
|
}
|
|
162569
162569
|
if (configToDTS.vars) {
|
|
162570
162570
|
for (const varName in configToDTS.vars) {
|
|
162571
162571
|
const varValue = configToDTS.vars[varName];
|
|
162572
162572
|
if (typeof varValue === "string" || typeof varValue === "number" || typeof varValue === "boolean") {
|
|
162573
|
-
envTypeStructure.push(
|
|
162573
|
+
envTypeStructure.push(`${varName}: "${varValue}";`);
|
|
162574
162574
|
}
|
|
162575
162575
|
if (typeof varValue === "object" && varValue !== null) {
|
|
162576
|
-
envTypeStructure.push(
|
|
162576
|
+
envTypeStructure.push(`${varName}: ${JSON.stringify(varValue)};`);
|
|
162577
162577
|
}
|
|
162578
162578
|
}
|
|
162579
162579
|
}
|
|
162580
162580
|
if (configToDTS.durable_objects?.bindings) {
|
|
162581
162581
|
for (const durableObject of configToDTS.durable_objects.bindings) {
|
|
162582
|
-
envTypeStructure.push(
|
|
162582
|
+
envTypeStructure.push(`${durableObject.name}: DurableObjectNamespace;`);
|
|
162583
162583
|
}
|
|
162584
162584
|
}
|
|
162585
162585
|
if (configToDTS.r2_buckets) {
|
|
162586
162586
|
for (const R2Bucket of configToDTS.r2_buckets) {
|
|
162587
|
-
envTypeStructure.push(
|
|
162587
|
+
envTypeStructure.push(`${R2Bucket.binding}: R2Bucket;`);
|
|
162588
162588
|
}
|
|
162589
162589
|
}
|
|
162590
162590
|
if (configToDTS.d1_databases) {
|
|
162591
162591
|
for (const d12 of configToDTS.d1_databases) {
|
|
162592
|
-
envTypeStructure.push(
|
|
162592
|
+
envTypeStructure.push(`${d12.binding}: D1Database;`);
|
|
162593
162593
|
}
|
|
162594
162594
|
}
|
|
162595
162595
|
if (configToDTS.services) {
|
|
162596
162596
|
for (const service of configToDTS.services) {
|
|
162597
|
-
envTypeStructure.push(
|
|
162597
|
+
envTypeStructure.push(`${service.binding}: Fetcher;`);
|
|
162598
162598
|
}
|
|
162599
162599
|
}
|
|
162600
162600
|
if (configToDTS.dispatch_namespaces) {
|
|
162601
162601
|
for (const namespace of configToDTS.dispatch_namespaces) {
|
|
162602
|
-
envTypeStructure.push(
|
|
162602
|
+
envTypeStructure.push(`${namespace.binding}: any;`);
|
|
162603
162603
|
}
|
|
162604
162604
|
}
|
|
162605
162605
|
if (configToDTS.logfwdr?.schema) {
|
|
162606
|
-
envTypeStructure.push(`
|
|
162606
|
+
envTypeStructure.push(`LOGFWDR_SCHEMA: any;`);
|
|
162607
162607
|
}
|
|
162608
162608
|
if (configToDTS.data_blobs) {
|
|
162609
162609
|
for (const dataBlobs in configToDTS.data_blobs) {
|
|
162610
|
-
envTypeStructure.push(
|
|
162610
|
+
envTypeStructure.push(`${dataBlobs}: ArrayBuffer;`);
|
|
162611
162611
|
}
|
|
162612
162612
|
}
|
|
162613
162613
|
if (configToDTS.text_blobs) {
|
|
162614
162614
|
for (const textBlobs in configToDTS.text_blobs) {
|
|
162615
|
-
envTypeStructure.push(
|
|
162615
|
+
envTypeStructure.push(`${textBlobs}: string;`);
|
|
162616
162616
|
}
|
|
162617
162617
|
}
|
|
162618
162618
|
if (configToDTS.unsafe) {
|
|
162619
162619
|
for (const unsafe of configToDTS.unsafe.bindings) {
|
|
162620
|
-
envTypeStructure.push(
|
|
162620
|
+
envTypeStructure.push(`${unsafe.name}: any;`);
|
|
162621
162621
|
}
|
|
162622
162622
|
}
|
|
162623
162623
|
if (configToDTS.queues) {
|
|
162624
162624
|
if (configToDTS.queues.producers) {
|
|
162625
162625
|
for (const queue of configToDTS.queues.producers) {
|
|
162626
|
-
envTypeStructure.push(
|
|
162626
|
+
envTypeStructure.push(`${queue.binding}: Queue;`);
|
|
162627
162627
|
}
|
|
162628
162628
|
}
|
|
162629
162629
|
}
|
|
@@ -162672,16 +162672,13 @@ function writeDTSFile({
|
|
|
162672
162672
|
let combinedTypeStrings = "";
|
|
162673
162673
|
if (formatType === "modules") {
|
|
162674
162674
|
combinedTypeStrings += `interface Env {
|
|
162675
|
-
${envTypeStructure.join(
|
|
162676
|
-
"\n"
|
|
162677
|
-
)}
|
|
162675
|
+
${envTypeStructure.map((value) => ` ${value}`).join("\n")}
|
|
162678
162676
|
}
|
|
162679
162677
|
${modulesTypeStructure.join("\n")}`;
|
|
162680
162678
|
} else {
|
|
162681
|
-
combinedTypeStrings += `
|
|
162682
|
-
|
|
162683
|
-
|
|
162684
|
-
)}
|
|
162679
|
+
combinedTypeStrings += `export {};
|
|
162680
|
+
declare global {
|
|
162681
|
+
${envTypeStructure.map((value) => ` const ${value}`).join("\n")}
|
|
162685
162682
|
}
|
|
162686
162683
|
${modulesTypeStructure.join("\n")}`;
|
|
162687
162684
|
}
|