@netlify/dev 4.7.1 → 4.8.1
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/main.cjs +35 -2
- package/dist/main.js +35 -2
- package/package.json +11 -10
package/dist/main.cjs
CHANGED
|
@@ -36,6 +36,7 @@ module.exports = __toCommonJS(main_exports);
|
|
|
36
36
|
var import_node_fs2 = require("fs");
|
|
37
37
|
var import_node_path2 = __toESM(require("path"), 1);
|
|
38
38
|
var import_node_process2 = __toESM(require("process"), 1);
|
|
39
|
+
var import_bootstrap = require("@netlify/ai/bootstrap");
|
|
39
40
|
var import_config = require("@netlify/config");
|
|
40
41
|
var import_dev_utils = require("@netlify/dev-utils");
|
|
41
42
|
var import_edge_functions_dev = require("@netlify/edge-functions-dev");
|
|
@@ -200,8 +201,16 @@ var isFile = async (path3) => {
|
|
|
200
201
|
|
|
201
202
|
// src/lib/reqres.ts
|
|
202
203
|
var import_node_stream = require("stream");
|
|
203
|
-
var normalizeHeaders = (
|
|
204
|
+
var normalizeHeaders = (request) => {
|
|
204
205
|
const result = [];
|
|
206
|
+
let headers = request.headers;
|
|
207
|
+
if (request.httpVersionMajor >= 2) {
|
|
208
|
+
headers = { ...headers };
|
|
209
|
+
delete headers[":authority"];
|
|
210
|
+
delete headers[":method"];
|
|
211
|
+
delete headers[":path"];
|
|
212
|
+
delete headers[":scheme"];
|
|
213
|
+
}
|
|
205
214
|
for (const [key, value] of Object.entries(headers)) {
|
|
206
215
|
if (Array.isArray(value)) {
|
|
207
216
|
result.push([key, value.join(",")]);
|
|
@@ -229,11 +238,13 @@ var getNormalizedRequestFromNodeRequest = (input, requestID, removeBody) => {
|
|
|
229
238
|
const fullUrl = new URL(url, origin);
|
|
230
239
|
const method = input.method?.toUpperCase() ?? "GET";
|
|
231
240
|
const body = input.method === "GET" || input.method === "HEAD" || removeBody ? null : import_node_stream.Readable.toWeb(input);
|
|
241
|
+
const normalizedHeaders = normalizeHeaders(input);
|
|
242
|
+
normalizedHeaders.push(["x-nf-request-id", requestID]);
|
|
232
243
|
return new Request(fullUrl, {
|
|
233
244
|
body,
|
|
234
245
|
// @ts-expect-error Not typed!
|
|
235
246
|
duplex: "half",
|
|
236
|
-
headers:
|
|
247
|
+
headers: normalizedHeaders,
|
|
237
248
|
method
|
|
238
249
|
});
|
|
239
250
|
};
|
|
@@ -526,6 +537,28 @@ var NetlifyDev = class {
|
|
|
526
537
|
siteID: siteID ?? "0"
|
|
527
538
|
});
|
|
528
539
|
this.#cleanupJobs.push(() => runtime.stop());
|
|
540
|
+
if (this.#features.environmentVariables && config?.api && siteID && config?.siteInfo?.url) {
|
|
541
|
+
await (0, import_bootstrap.setupAIGateway)({
|
|
542
|
+
api: config.api,
|
|
543
|
+
env: config.env || {},
|
|
544
|
+
siteID,
|
|
545
|
+
siteURL: config.siteInfo.url
|
|
546
|
+
});
|
|
547
|
+
if (config.env.AI_GATEWAY) {
|
|
548
|
+
runtime.env.set("AI_GATEWAY", config.env.AI_GATEWAY.value);
|
|
549
|
+
const aiGatewayContext = (0, import_bootstrap.parseAIGatewayContext)(config.env.AI_GATEWAY.value);
|
|
550
|
+
if (aiGatewayContext) {
|
|
551
|
+
runtime.env.set("NETLIFY_AI_GATEWAY_KEY", aiGatewayContext.token);
|
|
552
|
+
runtime.env.set("NETLIFY_AI_GATEWAY_URL", aiGatewayContext.url);
|
|
553
|
+
if (aiGatewayContext.envVars) {
|
|
554
|
+
for (const envVar of aiGatewayContext.envVars) {
|
|
555
|
+
runtime.env.set(envVar.key, aiGatewayContext.token);
|
|
556
|
+
runtime.env.set(envVar.url, aiGatewayContext.url);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
}
|
|
529
562
|
let serverAddress;
|
|
530
563
|
if (typeof this.#serverAddress === "string") {
|
|
531
564
|
serverAddress = this.#serverAddress;
|
package/dist/main.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { promises as fs2 } from "fs";
|
|
3
3
|
import path2 from "path";
|
|
4
4
|
import process2 from "process";
|
|
5
|
+
import { parseAIGatewayContext, setupAIGateway } from "@netlify/ai/bootstrap";
|
|
5
6
|
import { resolveConfig } from "@netlify/config";
|
|
6
7
|
import {
|
|
7
8
|
ensureNetlifyIgnore,
|
|
@@ -172,8 +173,16 @@ var isFile = async (path3) => {
|
|
|
172
173
|
|
|
173
174
|
// src/lib/reqres.ts
|
|
174
175
|
import { Readable } from "stream";
|
|
175
|
-
var normalizeHeaders = (
|
|
176
|
+
var normalizeHeaders = (request) => {
|
|
176
177
|
const result = [];
|
|
178
|
+
let headers = request.headers;
|
|
179
|
+
if (request.httpVersionMajor >= 2) {
|
|
180
|
+
headers = { ...headers };
|
|
181
|
+
delete headers[":authority"];
|
|
182
|
+
delete headers[":method"];
|
|
183
|
+
delete headers[":path"];
|
|
184
|
+
delete headers[":scheme"];
|
|
185
|
+
}
|
|
177
186
|
for (const [key, value] of Object.entries(headers)) {
|
|
178
187
|
if (Array.isArray(value)) {
|
|
179
188
|
result.push([key, value.join(",")]);
|
|
@@ -201,11 +210,13 @@ var getNormalizedRequestFromNodeRequest = (input, requestID, removeBody) => {
|
|
|
201
210
|
const fullUrl = new URL(url, origin);
|
|
202
211
|
const method = input.method?.toUpperCase() ?? "GET";
|
|
203
212
|
const body = input.method === "GET" || input.method === "HEAD" || removeBody ? null : Readable.toWeb(input);
|
|
213
|
+
const normalizedHeaders = normalizeHeaders(input);
|
|
214
|
+
normalizedHeaders.push(["x-nf-request-id", requestID]);
|
|
204
215
|
return new Request(fullUrl, {
|
|
205
216
|
body,
|
|
206
217
|
// @ts-expect-error Not typed!
|
|
207
218
|
duplex: "half",
|
|
208
|
-
headers:
|
|
219
|
+
headers: normalizedHeaders,
|
|
209
220
|
method
|
|
210
221
|
});
|
|
211
222
|
};
|
|
@@ -498,6 +509,28 @@ var NetlifyDev = class {
|
|
|
498
509
|
siteID: siteID ?? "0"
|
|
499
510
|
});
|
|
500
511
|
this.#cleanupJobs.push(() => runtime.stop());
|
|
512
|
+
if (this.#features.environmentVariables && config?.api && siteID && config?.siteInfo?.url) {
|
|
513
|
+
await setupAIGateway({
|
|
514
|
+
api: config.api,
|
|
515
|
+
env: config.env || {},
|
|
516
|
+
siteID,
|
|
517
|
+
siteURL: config.siteInfo.url
|
|
518
|
+
});
|
|
519
|
+
if (config.env.AI_GATEWAY) {
|
|
520
|
+
runtime.env.set("AI_GATEWAY", config.env.AI_GATEWAY.value);
|
|
521
|
+
const aiGatewayContext = parseAIGatewayContext(config.env.AI_GATEWAY.value);
|
|
522
|
+
if (aiGatewayContext) {
|
|
523
|
+
runtime.env.set("NETLIFY_AI_GATEWAY_KEY", aiGatewayContext.token);
|
|
524
|
+
runtime.env.set("NETLIFY_AI_GATEWAY_URL", aiGatewayContext.url);
|
|
525
|
+
if (aiGatewayContext.envVars) {
|
|
526
|
+
for (const envVar of aiGatewayContext.envVars) {
|
|
527
|
+
runtime.env.set(envVar.key, aiGatewayContext.token);
|
|
528
|
+
runtime.env.set(envVar.url, aiGatewayContext.url);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
}
|
|
501
534
|
let serverAddress;
|
|
502
535
|
if (typeof this.#serverAddress === "string") {
|
|
503
536
|
serverAddress = this.#serverAddress;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/dev",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.8.1",
|
|
4
4
|
"description": "Emulation of the Netlify environment for local development",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -56,16 +56,17 @@
|
|
|
56
56
|
"vitest": "^3.0.0"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@netlify/
|
|
59
|
+
"@netlify/ai": "^0.3.3",
|
|
60
|
+
"@netlify/blobs": "10.4.0",
|
|
60
61
|
"@netlify/config": "^23.2.0",
|
|
61
|
-
"@netlify/dev-utils": "4.3.
|
|
62
|
-
"@netlify/edge-functions-dev": "1.0.
|
|
63
|
-
"@netlify/functions-dev": "1.1.
|
|
64
|
-
"@netlify/headers": "2.1.
|
|
65
|
-
"@netlify/images": "1.3.
|
|
66
|
-
"@netlify/redirects": "3.1.
|
|
67
|
-
"@netlify/runtime": "4.1.
|
|
68
|
-
"@netlify/static": "3.1.
|
|
62
|
+
"@netlify/dev-utils": "4.3.2",
|
|
63
|
+
"@netlify/edge-functions-dev": "1.0.5",
|
|
64
|
+
"@netlify/functions-dev": "1.1.1",
|
|
65
|
+
"@netlify/headers": "2.1.2",
|
|
66
|
+
"@netlify/images": "1.3.2",
|
|
67
|
+
"@netlify/redirects": "3.1.3",
|
|
68
|
+
"@netlify/runtime": "4.1.8",
|
|
69
|
+
"@netlify/static": "3.1.2",
|
|
69
70
|
"ulid": "^3.0.0"
|
|
70
71
|
}
|
|
71
72
|
}
|