@netlify/plugin-nextjs 5.10.0 → 5.10.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/build/advanced-api-routes.js +136 -4
- package/dist/build/cache.js +25 -4
- package/dist/build/content/prerendered.js +293 -11
- package/dist/build/content/server.js +219 -11
- package/dist/build/content/static.js +112 -15
- package/dist/build/functions/edge.js +540 -7
- package/dist/build/functions/server.js +130 -11
- package/dist/build/image-cdn.js +1599 -3
- package/dist/build/plugin-context.js +292 -6
- package/dist/build/verification.js +104 -9
- package/dist/esm-chunks/{package-F536DQ6H.js → package-UN6EVEHD.js} +1 -1
- package/dist/index.js +19 -40
- package/dist/run/config.js +1 -4
- package/dist/run/constants.js +7 -5
- package/dist/run/handlers/cache.cjs +44 -1654
- package/dist/run/handlers/server.js +14 -33
- package/dist/run/handlers/tracer.cjs +2 -114
- package/dist/run/handlers/tracing.js +2 -4
- package/dist/run/handlers/wait-until.cjs +2 -116
- package/dist/run/headers.js +198 -10
- package/dist/run/next.cjs +11 -1623
- package/dist/run/regional-blob-store.cjs +37 -4
- package/dist/run/revalidate.js +24 -3
- package/dist/shared/blobkey.js +15 -3
- package/package.json +1 -1
- package/dist/esm-chunks/chunk-3RQSTU2O.js +0 -554
- package/dist/esm-chunks/chunk-72ZI2IVI.js +0 -36
- package/dist/esm-chunks/chunk-AMY4NOT5.js +0 -1610
- package/dist/esm-chunks/chunk-DLBTTDNJ.js +0 -309
- package/dist/esm-chunks/chunk-DLVROEVU.js +0 -144
- package/dist/esm-chunks/chunk-GFYWJNQR.js +0 -305
- package/dist/esm-chunks/chunk-IJZEDP6B.js +0 -235
- package/dist/esm-chunks/chunk-K4RDUZYO.js +0 -609
- package/dist/esm-chunks/chunk-SGXRYMYQ.js +0 -127
- package/dist/esm-chunks/chunk-TYCYFZ22.js +0 -25
- package/dist/esm-chunks/chunk-UYKENJEU.js +0 -19
- package/dist/esm-chunks/chunk-VTKZZRGT.js +0 -132
- package/dist/esm-chunks/chunk-WHUPSPWV.js +0 -73
- package/dist/esm-chunks/chunk-XS27YRA5.js +0 -34
- package/dist/esm-chunks/chunk-YMNWVS6T.js +0 -218
- package/dist/esm-chunks/chunk-ZENB67PD.js +0 -148
- package/dist/esm-chunks/chunk-ZSVHJNNY.js +0 -120
- package/dist/esm-chunks/next-7JK63CHT.js +0 -567
|
@@ -5,9 +5,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __esm = (fn, res) => function __init() {
|
|
9
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
10
|
-
};
|
|
11
8
|
var __export = (target, all) => {
|
|
12
9
|
for (var name2 in all)
|
|
13
10
|
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
@@ -30,31 +27,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
27
|
));
|
|
31
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
29
|
|
|
33
|
-
// src/shared/blobkey.ts
|
|
34
|
-
var blobkey_exports = {};
|
|
35
|
-
__export(blobkey_exports, {
|
|
36
|
-
encodeBlobKey: () => encodeBlobKey
|
|
37
|
-
});
|
|
38
|
-
async function encodeBlobKey(key) {
|
|
39
|
-
const buffer = import_node_buffer.Buffer.from(key);
|
|
40
|
-
const base64 = buffer.toString("base64url");
|
|
41
|
-
if (base64.length <= maxLength) {
|
|
42
|
-
return base64;
|
|
43
|
-
}
|
|
44
|
-
const digest = await import_node_crypto.webcrypto.subtle.digest("SHA-256", buffer);
|
|
45
|
-
const hash = import_node_buffer.Buffer.from(digest).toString("base64url");
|
|
46
|
-
return `${base64.slice(0, maxLength - hash.length - 1)}-${hash}`;
|
|
47
|
-
}
|
|
48
|
-
var import_node_buffer, import_node_crypto, maxLength;
|
|
49
|
-
var init_blobkey = __esm({
|
|
50
|
-
"src/shared/blobkey.ts"() {
|
|
51
|
-
"use strict";
|
|
52
|
-
import_node_buffer = require("node:buffer");
|
|
53
|
-
import_node_crypto = require("node:crypto");
|
|
54
|
-
maxLength = 180;
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
|
|
58
30
|
// src/run/handlers/cache.cts
|
|
59
31
|
var cache_exports = {};
|
|
60
32
|
__export(cache_exports, {
|
|
@@ -62,13 +34,13 @@ __export(cache_exports, {
|
|
|
62
34
|
default: () => cache_default
|
|
63
35
|
});
|
|
64
36
|
module.exports = __toCommonJS(cache_exports);
|
|
65
|
-
var
|
|
37
|
+
var import_node_buffer = require("node:buffer");
|
|
66
38
|
var import_node_path = require("node:path");
|
|
67
39
|
var import_posix = require("node:path/posix");
|
|
68
40
|
|
|
69
41
|
// node_modules/@netlify/functions/dist/chunk-C6P2IO65.mjs
|
|
70
42
|
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
71
|
-
var
|
|
43
|
+
var __esm = (fn, res) => function __init() {
|
|
72
44
|
return fn && (res = (0, fn[__getOwnPropNames2(fn)[0]])(fn = 0)), res;
|
|
73
45
|
};
|
|
74
46
|
|
|
@@ -77,7 +49,7 @@ var BUILDER_FUNCTIONS_FLAG;
|
|
|
77
49
|
var HTTP_STATUS_METHOD_NOT_ALLOWED;
|
|
78
50
|
var HTTP_STATUS_OK;
|
|
79
51
|
var METADATA_VERSION;
|
|
80
|
-
var init_consts =
|
|
52
|
+
var init_consts = __esm({
|
|
81
53
|
"src/lib/consts.ts"() {
|
|
82
54
|
BUILDER_FUNCTIONS_FLAG = true;
|
|
83
55
|
HTTP_STATUS_METHOD_NOT_ALLOWED = 405;
|
|
@@ -89,7 +61,7 @@ var init_consts = __esm2({
|
|
|
89
61
|
// node_modules/@netlify/functions/dist/chunk-6V4VUZWK.mjs
|
|
90
62
|
var augmentResponse;
|
|
91
63
|
var wrapHandler;
|
|
92
|
-
var init_builder =
|
|
64
|
+
var init_builder = __esm({
|
|
93
65
|
"src/lib/builder.ts"() {
|
|
94
66
|
init_consts();
|
|
95
67
|
augmentResponse = (response) => {
|
|
@@ -104,7 +76,7 @@ var init_builder = __esm2({
|
|
|
104
76
|
};
|
|
105
77
|
wrapHandler = (handler) => (
|
|
106
78
|
// eslint-disable-next-line promise/prefer-await-to-callbacks
|
|
107
|
-
(event,
|
|
79
|
+
(event, context, callback) => {
|
|
108
80
|
if (event.httpMethod !== "GET" && event.httpMethod !== "HEAD") {
|
|
109
81
|
return Promise.resolve({
|
|
110
82
|
body: "Method Not Allowed",
|
|
@@ -120,7 +92,7 @@ var init_builder = __esm2({
|
|
|
120
92
|
// eslint-disable-next-line promise/prefer-await-to-callbacks
|
|
121
93
|
callback ? callback(error, augmentResponse(response)) : null
|
|
122
94
|
);
|
|
123
|
-
const execution = handler(modifiedEvent,
|
|
95
|
+
const execution = handler(modifiedEvent, context, wrappedCallback);
|
|
124
96
|
if (typeof execution === "object" && typeof execution.then === "function") {
|
|
125
97
|
return execution.then(augmentResponse);
|
|
126
98
|
}
|
|
@@ -133,7 +105,7 @@ var init_builder = __esm2({
|
|
|
133
105
|
// node_modules/@netlify/functions/dist/chunk-SURWFFYE.mjs
|
|
134
106
|
var import_process = require("process");
|
|
135
107
|
var purgeCache;
|
|
136
|
-
var init_purge_cache =
|
|
108
|
+
var init_purge_cache = __esm({
|
|
137
109
|
"src/lib/purge_cache.ts"() {
|
|
138
110
|
purgeCache = async (options = {}) => {
|
|
139
111
|
if (globalThis.fetch === void 0) {
|
|
@@ -203,1611 +175,29 @@ var import_constants = require("next/dist/lib/constants.js");
|
|
|
203
175
|
|
|
204
176
|
// package.json
|
|
205
177
|
var name = "@netlify/plugin-nextjs";
|
|
206
|
-
var version = "5.10.
|
|
207
|
-
|
|
208
|
-
// src/shared/cache-types.cts
|
|
209
|
-
var isCachedPageValue = (value) => value.kind === "PAGE" || value.kind === "PAGES";
|
|
210
|
-
var isCachedRouteValue = (value) => value.kind === "ROUTE" || value.kind === "APP_ROUTE";
|
|
211
|
-
|
|
212
|
-
// node_modules/@netlify/blobs/dist/chunk-GUEW34CP.js
|
|
213
|
-
var NF_ERROR = "x-nf-error";
|
|
214
|
-
var NF_REQUEST_ID = "x-nf-request-id";
|
|
215
|
-
var BlobsInternalError = class extends Error {
|
|
216
|
-
constructor(res) {
|
|
217
|
-
let details = res.headers.get(NF_ERROR) || `${res.status} status code`;
|
|
218
|
-
if (res.headers.has(NF_REQUEST_ID)) {
|
|
219
|
-
details += `, ID: ${res.headers.get(NF_REQUEST_ID)}`;
|
|
220
|
-
}
|
|
221
|
-
super(`Netlify Blobs has generated an internal error (${details})`);
|
|
222
|
-
this.name = "BlobsInternalError";
|
|
223
|
-
}
|
|
224
|
-
};
|
|
225
|
-
var collectIterator = async (iterator) => {
|
|
226
|
-
const result = [];
|
|
227
|
-
for await (const item of iterator) {
|
|
228
|
-
result.push(item);
|
|
229
|
-
}
|
|
230
|
-
return result;
|
|
231
|
-
};
|
|
232
|
-
var base64Decode = (input) => {
|
|
233
|
-
const { Buffer: Buffer4 } = globalThis;
|
|
234
|
-
if (Buffer4) {
|
|
235
|
-
return Buffer4.from(input, "base64").toString();
|
|
236
|
-
}
|
|
237
|
-
return atob(input);
|
|
238
|
-
};
|
|
239
|
-
var base64Encode = (input) => {
|
|
240
|
-
const { Buffer: Buffer4 } = globalThis;
|
|
241
|
-
if (Buffer4) {
|
|
242
|
-
return Buffer4.from(input).toString("base64");
|
|
243
|
-
}
|
|
244
|
-
return btoa(input);
|
|
245
|
-
};
|
|
246
|
-
var getEnvironment = () => {
|
|
247
|
-
const { Deno, Netlify, process: process2 } = globalThis;
|
|
248
|
-
return Netlify?.env ?? Deno?.env ?? {
|
|
249
|
-
delete: (key) => delete process2?.env[key],
|
|
250
|
-
get: (key) => process2?.env[key],
|
|
251
|
-
has: (key) => Boolean(process2?.env[key]),
|
|
252
|
-
set: (key, value) => {
|
|
253
|
-
if (process2?.env) {
|
|
254
|
-
process2.env[key] = value;
|
|
255
|
-
}
|
|
256
|
-
},
|
|
257
|
-
toObject: () => process2?.env ?? {}
|
|
258
|
-
};
|
|
259
|
-
};
|
|
260
|
-
var getEnvironmentContext = () => {
|
|
261
|
-
const context2 = globalThis.netlifyBlobsContext || getEnvironment().get("NETLIFY_BLOBS_CONTEXT");
|
|
262
|
-
if (typeof context2 !== "string" || !context2) {
|
|
263
|
-
return {};
|
|
264
|
-
}
|
|
265
|
-
const data = base64Decode(context2);
|
|
266
|
-
try {
|
|
267
|
-
return JSON.parse(data);
|
|
268
|
-
} catch {
|
|
269
|
-
}
|
|
270
|
-
return {};
|
|
271
|
-
};
|
|
272
|
-
var MissingBlobsEnvironmentError = class extends Error {
|
|
273
|
-
constructor(requiredProperties) {
|
|
274
|
-
super(
|
|
275
|
-
`The environment has not been configured to use Netlify Blobs. To use it manually, supply the following properties when creating a store: ${requiredProperties.join(
|
|
276
|
-
", "
|
|
277
|
-
)}`
|
|
278
|
-
);
|
|
279
|
-
this.name = "MissingBlobsEnvironmentError";
|
|
280
|
-
}
|
|
281
|
-
};
|
|
282
|
-
var BASE64_PREFIX = "b64;";
|
|
283
|
-
var METADATA_HEADER_INTERNAL = "x-amz-meta-user";
|
|
284
|
-
var METADATA_HEADER_EXTERNAL = "netlify-blobs-metadata";
|
|
285
|
-
var METADATA_MAX_SIZE = 2 * 1024;
|
|
286
|
-
var encodeMetadata = (metadata) => {
|
|
287
|
-
if (!metadata) {
|
|
288
|
-
return null;
|
|
289
|
-
}
|
|
290
|
-
const encodedObject = base64Encode(JSON.stringify(metadata));
|
|
291
|
-
const payload = `b64;${encodedObject}`;
|
|
292
|
-
if (METADATA_HEADER_EXTERNAL.length + payload.length > METADATA_MAX_SIZE) {
|
|
293
|
-
throw new Error("Metadata object exceeds the maximum size");
|
|
294
|
-
}
|
|
295
|
-
return payload;
|
|
296
|
-
};
|
|
297
|
-
var decodeMetadata = (header) => {
|
|
298
|
-
if (!header || !header.startsWith(BASE64_PREFIX)) {
|
|
299
|
-
return {};
|
|
300
|
-
}
|
|
301
|
-
const encodedData = header.slice(BASE64_PREFIX.length);
|
|
302
|
-
const decodedData = base64Decode(encodedData);
|
|
303
|
-
const metadata = JSON.parse(decodedData);
|
|
304
|
-
return metadata;
|
|
305
|
-
};
|
|
306
|
-
var getMetadataFromResponse = (response) => {
|
|
307
|
-
if (!response.headers) {
|
|
308
|
-
return {};
|
|
309
|
-
}
|
|
310
|
-
const value = response.headers.get(METADATA_HEADER_EXTERNAL) || response.headers.get(METADATA_HEADER_INTERNAL);
|
|
311
|
-
try {
|
|
312
|
-
return decodeMetadata(value);
|
|
313
|
-
} catch {
|
|
314
|
-
throw new Error(
|
|
315
|
-
"An internal error occurred while trying to retrieve the metadata for an entry. Please try updating to the latest version of the Netlify Blobs client."
|
|
316
|
-
);
|
|
317
|
-
}
|
|
318
|
-
};
|
|
319
|
-
var BlobsConsistencyError = class extends Error {
|
|
320
|
-
constructor() {
|
|
321
|
-
super(
|
|
322
|
-
`Netlify Blobs has failed to perform a read using strong consistency because the environment has not been configured with a 'uncachedEdgeURL' property`
|
|
323
|
-
);
|
|
324
|
-
this.name = "BlobsConsistencyError";
|
|
325
|
-
}
|
|
326
|
-
};
|
|
327
|
-
var REGION_AUTO = "auto";
|
|
328
|
-
var regions = {
|
|
329
|
-
"us-east-1": true,
|
|
330
|
-
"us-east-2": true
|
|
331
|
-
};
|
|
332
|
-
var isValidRegion = (input) => Object.keys(regions).includes(input);
|
|
333
|
-
var InvalidBlobsRegionError = class extends Error {
|
|
334
|
-
constructor(region) {
|
|
335
|
-
super(
|
|
336
|
-
`${region} is not a supported Netlify Blobs region. Supported values are: ${Object.keys(regions).join(", ")}.`
|
|
337
|
-
);
|
|
338
|
-
this.name = "InvalidBlobsRegionError";
|
|
339
|
-
}
|
|
340
|
-
};
|
|
341
|
-
var DEFAULT_RETRY_DELAY = getEnvironment().get("NODE_ENV") === "test" ? 1 : 5e3;
|
|
342
|
-
var MIN_RETRY_DELAY = 1e3;
|
|
343
|
-
var MAX_RETRY = 5;
|
|
344
|
-
var RATE_LIMIT_HEADER = "X-RateLimit-Reset";
|
|
345
|
-
var fetchAndRetry = async (fetch2, url, options, attemptsLeft = MAX_RETRY) => {
|
|
346
|
-
try {
|
|
347
|
-
const res = await fetch2(url, options);
|
|
348
|
-
if (attemptsLeft > 0 && (res.status === 429 || res.status >= 500)) {
|
|
349
|
-
const delay = getDelay(res.headers.get(RATE_LIMIT_HEADER));
|
|
350
|
-
await sleep(delay);
|
|
351
|
-
return fetchAndRetry(fetch2, url, options, attemptsLeft - 1);
|
|
352
|
-
}
|
|
353
|
-
return res;
|
|
354
|
-
} catch (error) {
|
|
355
|
-
if (attemptsLeft === 0) {
|
|
356
|
-
throw error;
|
|
357
|
-
}
|
|
358
|
-
const delay = getDelay();
|
|
359
|
-
await sleep(delay);
|
|
360
|
-
return fetchAndRetry(fetch2, url, options, attemptsLeft - 1);
|
|
361
|
-
}
|
|
362
|
-
};
|
|
363
|
-
var getDelay = (rateLimitReset) => {
|
|
364
|
-
if (!rateLimitReset) {
|
|
365
|
-
return DEFAULT_RETRY_DELAY;
|
|
366
|
-
}
|
|
367
|
-
return Math.max(Number(rateLimitReset) * 1e3 - Date.now(), MIN_RETRY_DELAY);
|
|
368
|
-
};
|
|
369
|
-
var sleep = (ms) => new Promise((resolve) => {
|
|
370
|
-
setTimeout(resolve, ms);
|
|
371
|
-
});
|
|
372
|
-
var SIGNED_URL_ACCEPT_HEADER = "application/json;type=signed-url";
|
|
373
|
-
var Client = class {
|
|
374
|
-
constructor({ apiURL, consistency, edgeURL, fetch: fetch2, region, siteID, token, uncachedEdgeURL }) {
|
|
375
|
-
this.apiURL = apiURL;
|
|
376
|
-
this.consistency = consistency ?? "eventual";
|
|
377
|
-
this.edgeURL = edgeURL;
|
|
378
|
-
this.fetch = fetch2 ?? globalThis.fetch;
|
|
379
|
-
this.region = region;
|
|
380
|
-
this.siteID = siteID;
|
|
381
|
-
this.token = token;
|
|
382
|
-
this.uncachedEdgeURL = uncachedEdgeURL;
|
|
383
|
-
if (!this.fetch) {
|
|
384
|
-
throw new Error(
|
|
385
|
-
"Netlify Blobs could not find a `fetch` client in the global scope. You can either update your runtime to a version that includes `fetch` (like Node.js 18.0.0 or above), or you can supply your own implementation using the `fetch` property."
|
|
386
|
-
);
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
async getFinalRequest({
|
|
390
|
-
consistency: opConsistency,
|
|
391
|
-
key,
|
|
392
|
-
metadata,
|
|
393
|
-
method,
|
|
394
|
-
parameters = {},
|
|
395
|
-
storeName
|
|
396
|
-
}) {
|
|
397
|
-
const encodedMetadata = encodeMetadata(metadata);
|
|
398
|
-
const consistency = opConsistency ?? this.consistency;
|
|
399
|
-
let urlPath = `/${this.siteID}`;
|
|
400
|
-
if (storeName) {
|
|
401
|
-
urlPath += `/${storeName}`;
|
|
402
|
-
}
|
|
403
|
-
if (key) {
|
|
404
|
-
urlPath += `/${key}`;
|
|
405
|
-
}
|
|
406
|
-
if (this.edgeURL) {
|
|
407
|
-
if (consistency === "strong" && !this.uncachedEdgeURL) {
|
|
408
|
-
throw new BlobsConsistencyError();
|
|
409
|
-
}
|
|
410
|
-
const headers = {
|
|
411
|
-
authorization: `Bearer ${this.token}`
|
|
412
|
-
};
|
|
413
|
-
if (encodedMetadata) {
|
|
414
|
-
headers[METADATA_HEADER_INTERNAL] = encodedMetadata;
|
|
415
|
-
}
|
|
416
|
-
if (this.region) {
|
|
417
|
-
urlPath = `/region:${this.region}${urlPath}`;
|
|
418
|
-
}
|
|
419
|
-
const url2 = new URL(urlPath, consistency === "strong" ? this.uncachedEdgeURL : this.edgeURL);
|
|
420
|
-
for (const key2 in parameters) {
|
|
421
|
-
url2.searchParams.set(key2, parameters[key2]);
|
|
422
|
-
}
|
|
423
|
-
return {
|
|
424
|
-
headers,
|
|
425
|
-
url: url2.toString()
|
|
426
|
-
};
|
|
427
|
-
}
|
|
428
|
-
const apiHeaders = { authorization: `Bearer ${this.token}` };
|
|
429
|
-
const url = new URL(`/api/v1/blobs${urlPath}`, this.apiURL ?? "https://api.netlify.com");
|
|
430
|
-
for (const key2 in parameters) {
|
|
431
|
-
url.searchParams.set(key2, parameters[key2]);
|
|
432
|
-
}
|
|
433
|
-
if (this.region) {
|
|
434
|
-
url.searchParams.set("region", this.region);
|
|
435
|
-
}
|
|
436
|
-
if (storeName === void 0 || key === void 0) {
|
|
437
|
-
return {
|
|
438
|
-
headers: apiHeaders,
|
|
439
|
-
url: url.toString()
|
|
440
|
-
};
|
|
441
|
-
}
|
|
442
|
-
if (encodedMetadata) {
|
|
443
|
-
apiHeaders[METADATA_HEADER_EXTERNAL] = encodedMetadata;
|
|
444
|
-
}
|
|
445
|
-
if (method === "head" || method === "delete") {
|
|
446
|
-
return {
|
|
447
|
-
headers: apiHeaders,
|
|
448
|
-
url: url.toString()
|
|
449
|
-
};
|
|
450
|
-
}
|
|
451
|
-
const res = await this.fetch(url.toString(), {
|
|
452
|
-
headers: { ...apiHeaders, accept: SIGNED_URL_ACCEPT_HEADER },
|
|
453
|
-
method
|
|
454
|
-
});
|
|
455
|
-
if (res.status !== 200) {
|
|
456
|
-
throw new BlobsInternalError(res);
|
|
457
|
-
}
|
|
458
|
-
const { url: signedURL } = await res.json();
|
|
459
|
-
const userHeaders = encodedMetadata ? { [METADATA_HEADER_INTERNAL]: encodedMetadata } : void 0;
|
|
460
|
-
return {
|
|
461
|
-
headers: userHeaders,
|
|
462
|
-
url: signedURL
|
|
463
|
-
};
|
|
464
|
-
}
|
|
465
|
-
async makeRequest({
|
|
466
|
-
body,
|
|
467
|
-
consistency,
|
|
468
|
-
headers: extraHeaders,
|
|
469
|
-
key,
|
|
470
|
-
metadata,
|
|
471
|
-
method,
|
|
472
|
-
parameters,
|
|
473
|
-
storeName
|
|
474
|
-
}) {
|
|
475
|
-
const { headers: baseHeaders = {}, url } = await this.getFinalRequest({
|
|
476
|
-
consistency,
|
|
477
|
-
key,
|
|
478
|
-
metadata,
|
|
479
|
-
method,
|
|
480
|
-
parameters,
|
|
481
|
-
storeName
|
|
482
|
-
});
|
|
483
|
-
const headers = {
|
|
484
|
-
...baseHeaders,
|
|
485
|
-
...extraHeaders
|
|
486
|
-
};
|
|
487
|
-
if (method === "put") {
|
|
488
|
-
headers["cache-control"] = "max-age=0, stale-while-revalidate=60";
|
|
489
|
-
}
|
|
490
|
-
const options = {
|
|
491
|
-
body,
|
|
492
|
-
headers,
|
|
493
|
-
method
|
|
494
|
-
};
|
|
495
|
-
if (body instanceof ReadableStream) {
|
|
496
|
-
options.duplex = "half";
|
|
497
|
-
}
|
|
498
|
-
return fetchAndRetry(this.fetch, url, options);
|
|
499
|
-
}
|
|
500
|
-
};
|
|
501
|
-
var getClientOptions = (options, contextOverride) => {
|
|
502
|
-
const context2 = contextOverride ?? getEnvironmentContext();
|
|
503
|
-
const siteID = context2.siteID ?? options.siteID;
|
|
504
|
-
const token = context2.token ?? options.token;
|
|
505
|
-
if (!siteID || !token) {
|
|
506
|
-
throw new MissingBlobsEnvironmentError(["siteID", "token"]);
|
|
507
|
-
}
|
|
508
|
-
if (options.region !== void 0 && !isValidRegion(options.region)) {
|
|
509
|
-
throw new InvalidBlobsRegionError(options.region);
|
|
510
|
-
}
|
|
511
|
-
const clientOptions = {
|
|
512
|
-
apiURL: context2.apiURL ?? options.apiURL,
|
|
513
|
-
consistency: options.consistency,
|
|
514
|
-
edgeURL: context2.edgeURL ?? options.edgeURL,
|
|
515
|
-
fetch: options.fetch,
|
|
516
|
-
region: options.region,
|
|
517
|
-
siteID,
|
|
518
|
-
token,
|
|
519
|
-
uncachedEdgeURL: context2.uncachedEdgeURL ?? options.uncachedEdgeURL
|
|
520
|
-
};
|
|
521
|
-
return clientOptions;
|
|
522
|
-
};
|
|
523
|
-
|
|
524
|
-
// node_modules/@netlify/blobs/dist/main.js
|
|
525
|
-
var DEPLOY_STORE_PREFIX = "deploy:";
|
|
526
|
-
var LEGACY_STORE_INTERNAL_PREFIX = "netlify-internal/legacy-namespace/";
|
|
527
|
-
var SITE_STORE_PREFIX = "site:";
|
|
528
|
-
var Store = class _Store {
|
|
529
|
-
constructor(options) {
|
|
530
|
-
this.client = options.client;
|
|
531
|
-
if ("deployID" in options) {
|
|
532
|
-
_Store.validateDeployID(options.deployID);
|
|
533
|
-
let name2 = DEPLOY_STORE_PREFIX + options.deployID;
|
|
534
|
-
if (options.name) {
|
|
535
|
-
name2 += `:${options.name}`;
|
|
536
|
-
}
|
|
537
|
-
this.name = name2;
|
|
538
|
-
} else if (options.name.startsWith(LEGACY_STORE_INTERNAL_PREFIX)) {
|
|
539
|
-
const storeName = options.name.slice(LEGACY_STORE_INTERNAL_PREFIX.length);
|
|
540
|
-
_Store.validateStoreName(storeName);
|
|
541
|
-
this.name = storeName;
|
|
542
|
-
} else {
|
|
543
|
-
_Store.validateStoreName(options.name);
|
|
544
|
-
this.name = SITE_STORE_PREFIX + options.name;
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
async delete(key) {
|
|
548
|
-
const res = await this.client.makeRequest({ key, method: "delete", storeName: this.name });
|
|
549
|
-
if (![200, 204, 404].includes(res.status)) {
|
|
550
|
-
throw new BlobsInternalError(res);
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
async get(key, options) {
|
|
554
|
-
const { consistency, type } = options ?? {};
|
|
555
|
-
const res = await this.client.makeRequest({ consistency, key, method: "get", storeName: this.name });
|
|
556
|
-
if (res.status === 404) {
|
|
557
|
-
return null;
|
|
558
|
-
}
|
|
559
|
-
if (res.status !== 200) {
|
|
560
|
-
throw new BlobsInternalError(res);
|
|
561
|
-
}
|
|
562
|
-
if (type === void 0 || type === "text") {
|
|
563
|
-
return res.text();
|
|
564
|
-
}
|
|
565
|
-
if (type === "arrayBuffer") {
|
|
566
|
-
return res.arrayBuffer();
|
|
567
|
-
}
|
|
568
|
-
if (type === "blob") {
|
|
569
|
-
return res.blob();
|
|
570
|
-
}
|
|
571
|
-
if (type === "json") {
|
|
572
|
-
return res.json();
|
|
573
|
-
}
|
|
574
|
-
if (type === "stream") {
|
|
575
|
-
return res.body;
|
|
576
|
-
}
|
|
577
|
-
throw new BlobsInternalError(res);
|
|
578
|
-
}
|
|
579
|
-
async getMetadata(key, { consistency } = {}) {
|
|
580
|
-
const res = await this.client.makeRequest({ consistency, key, method: "head", storeName: this.name });
|
|
581
|
-
if (res.status === 404) {
|
|
582
|
-
return null;
|
|
583
|
-
}
|
|
584
|
-
if (res.status !== 200 && res.status !== 304) {
|
|
585
|
-
throw new BlobsInternalError(res);
|
|
586
|
-
}
|
|
587
|
-
const etag = res?.headers.get("etag") ?? void 0;
|
|
588
|
-
const metadata = getMetadataFromResponse(res);
|
|
589
|
-
const result = {
|
|
590
|
-
etag,
|
|
591
|
-
metadata
|
|
592
|
-
};
|
|
593
|
-
return result;
|
|
594
|
-
}
|
|
595
|
-
async getWithMetadata(key, options) {
|
|
596
|
-
const { consistency, etag: requestETag, type } = options ?? {};
|
|
597
|
-
const headers = requestETag ? { "if-none-match": requestETag } : void 0;
|
|
598
|
-
const res = await this.client.makeRequest({
|
|
599
|
-
consistency,
|
|
600
|
-
headers,
|
|
601
|
-
key,
|
|
602
|
-
method: "get",
|
|
603
|
-
storeName: this.name
|
|
604
|
-
});
|
|
605
|
-
if (res.status === 404) {
|
|
606
|
-
return null;
|
|
607
|
-
}
|
|
608
|
-
if (res.status !== 200 && res.status !== 304) {
|
|
609
|
-
throw new BlobsInternalError(res);
|
|
610
|
-
}
|
|
611
|
-
const responseETag = res?.headers.get("etag") ?? void 0;
|
|
612
|
-
const metadata = getMetadataFromResponse(res);
|
|
613
|
-
const result = {
|
|
614
|
-
etag: responseETag,
|
|
615
|
-
metadata
|
|
616
|
-
};
|
|
617
|
-
if (res.status === 304 && requestETag) {
|
|
618
|
-
return { data: null, ...result };
|
|
619
|
-
}
|
|
620
|
-
if (type === void 0 || type === "text") {
|
|
621
|
-
return { data: await res.text(), ...result };
|
|
622
|
-
}
|
|
623
|
-
if (type === "arrayBuffer") {
|
|
624
|
-
return { data: await res.arrayBuffer(), ...result };
|
|
625
|
-
}
|
|
626
|
-
if (type === "blob") {
|
|
627
|
-
return { data: await res.blob(), ...result };
|
|
628
|
-
}
|
|
629
|
-
if (type === "json") {
|
|
630
|
-
return { data: await res.json(), ...result };
|
|
631
|
-
}
|
|
632
|
-
if (type === "stream") {
|
|
633
|
-
return { data: res.body, ...result };
|
|
634
|
-
}
|
|
635
|
-
throw new Error(`Invalid 'type' property: ${type}. Expected: arrayBuffer, blob, json, stream, or text.`);
|
|
636
|
-
}
|
|
637
|
-
list(options = {}) {
|
|
638
|
-
const iterator = this.getListIterator(options);
|
|
639
|
-
if (options.paginate) {
|
|
640
|
-
return iterator;
|
|
641
|
-
}
|
|
642
|
-
return collectIterator(iterator).then(
|
|
643
|
-
(items) => items.reduce(
|
|
644
|
-
(acc, item) => ({
|
|
645
|
-
blobs: [...acc.blobs, ...item.blobs],
|
|
646
|
-
directories: [...acc.directories, ...item.directories]
|
|
647
|
-
}),
|
|
648
|
-
{ blobs: [], directories: [] }
|
|
649
|
-
)
|
|
650
|
-
);
|
|
651
|
-
}
|
|
652
|
-
async set(key, data, { metadata } = {}) {
|
|
653
|
-
_Store.validateKey(key);
|
|
654
|
-
const res = await this.client.makeRequest({
|
|
655
|
-
body: data,
|
|
656
|
-
key,
|
|
657
|
-
metadata,
|
|
658
|
-
method: "put",
|
|
659
|
-
storeName: this.name
|
|
660
|
-
});
|
|
661
|
-
if (res.status !== 200) {
|
|
662
|
-
throw new BlobsInternalError(res);
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
async setJSON(key, data, { metadata } = {}) {
|
|
666
|
-
_Store.validateKey(key);
|
|
667
|
-
const payload = JSON.stringify(data);
|
|
668
|
-
const headers = {
|
|
669
|
-
"content-type": "application/json"
|
|
670
|
-
};
|
|
671
|
-
const res = await this.client.makeRequest({
|
|
672
|
-
body: payload,
|
|
673
|
-
headers,
|
|
674
|
-
key,
|
|
675
|
-
metadata,
|
|
676
|
-
method: "put",
|
|
677
|
-
storeName: this.name
|
|
678
|
-
});
|
|
679
|
-
if (res.status !== 200) {
|
|
680
|
-
throw new BlobsInternalError(res);
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
static formatListResultBlob(result) {
|
|
684
|
-
if (!result.key) {
|
|
685
|
-
return null;
|
|
686
|
-
}
|
|
687
|
-
return {
|
|
688
|
-
etag: result.etag,
|
|
689
|
-
key: result.key
|
|
690
|
-
};
|
|
691
|
-
}
|
|
692
|
-
static validateKey(key) {
|
|
693
|
-
if (key === "") {
|
|
694
|
-
throw new Error("Blob key must not be empty.");
|
|
695
|
-
}
|
|
696
|
-
if (key.startsWith("/") || key.startsWith("%2F")) {
|
|
697
|
-
throw new Error("Blob key must not start with forward slash (/).");
|
|
698
|
-
}
|
|
699
|
-
if (new TextEncoder().encode(key).length > 600) {
|
|
700
|
-
throw new Error(
|
|
701
|
-
"Blob key must be a sequence of Unicode characters whose UTF-8 encoding is at most 600 bytes long."
|
|
702
|
-
);
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
static validateDeployID(deployID) {
|
|
706
|
-
if (!/^\w{1,24}$/.test(deployID)) {
|
|
707
|
-
throw new Error(`'${deployID}' is not a valid Netlify deploy ID.`);
|
|
708
|
-
}
|
|
709
|
-
}
|
|
710
|
-
static validateStoreName(name2) {
|
|
711
|
-
if (name2.includes("/") || name2.includes("%2F")) {
|
|
712
|
-
throw new Error("Store name must not contain forward slashes (/).");
|
|
713
|
-
}
|
|
714
|
-
if (new TextEncoder().encode(name2).length > 64) {
|
|
715
|
-
throw new Error(
|
|
716
|
-
"Store name must be a sequence of Unicode characters whose UTF-8 encoding is at most 64 bytes long."
|
|
717
|
-
);
|
|
718
|
-
}
|
|
719
|
-
}
|
|
720
|
-
getListIterator(options) {
|
|
721
|
-
const { client, name: storeName } = this;
|
|
722
|
-
const parameters = {};
|
|
723
|
-
if (options?.prefix) {
|
|
724
|
-
parameters.prefix = options.prefix;
|
|
725
|
-
}
|
|
726
|
-
if (options?.directories) {
|
|
727
|
-
parameters.directories = "true";
|
|
728
|
-
}
|
|
729
|
-
return {
|
|
730
|
-
[Symbol.asyncIterator]() {
|
|
731
|
-
let currentCursor = null;
|
|
732
|
-
let done = false;
|
|
733
|
-
return {
|
|
734
|
-
async next() {
|
|
735
|
-
if (done) {
|
|
736
|
-
return { done: true, value: void 0 };
|
|
737
|
-
}
|
|
738
|
-
const nextParameters = { ...parameters };
|
|
739
|
-
if (currentCursor !== null) {
|
|
740
|
-
nextParameters.cursor = currentCursor;
|
|
741
|
-
}
|
|
742
|
-
const res = await client.makeRequest({
|
|
743
|
-
method: "get",
|
|
744
|
-
parameters: nextParameters,
|
|
745
|
-
storeName
|
|
746
|
-
});
|
|
747
|
-
let blobs = [];
|
|
748
|
-
let directories = [];
|
|
749
|
-
if (![200, 204, 404].includes(res.status)) {
|
|
750
|
-
throw new BlobsInternalError(res);
|
|
751
|
-
}
|
|
752
|
-
if (res.status === 404) {
|
|
753
|
-
done = true;
|
|
754
|
-
} else {
|
|
755
|
-
const page = await res.json();
|
|
756
|
-
if (page.next_cursor) {
|
|
757
|
-
currentCursor = page.next_cursor;
|
|
758
|
-
} else {
|
|
759
|
-
done = true;
|
|
760
|
-
}
|
|
761
|
-
blobs = (page.blobs ?? []).map(_Store.formatListResultBlob).filter(Boolean);
|
|
762
|
-
directories = page.directories ?? [];
|
|
763
|
-
}
|
|
764
|
-
return {
|
|
765
|
-
done: false,
|
|
766
|
-
value: {
|
|
767
|
-
blobs,
|
|
768
|
-
directories
|
|
769
|
-
}
|
|
770
|
-
};
|
|
771
|
-
}
|
|
772
|
-
};
|
|
773
|
-
}
|
|
774
|
-
};
|
|
775
|
-
}
|
|
776
|
-
};
|
|
777
|
-
var getDeployStore = (input = {}) => {
|
|
778
|
-
const context2 = getEnvironmentContext();
|
|
779
|
-
const options = typeof input === "string" ? { name: input } : input;
|
|
780
|
-
const deployID = options.deployID ?? context2.deployID;
|
|
781
|
-
if (!deployID) {
|
|
782
|
-
throw new MissingBlobsEnvironmentError(["deployID"]);
|
|
783
|
-
}
|
|
784
|
-
const clientOptions = getClientOptions(options, context2);
|
|
785
|
-
if (!clientOptions.region) {
|
|
786
|
-
if (clientOptions.edgeURL || clientOptions.uncachedEdgeURL) {
|
|
787
|
-
if (!context2.primaryRegion) {
|
|
788
|
-
throw new Error(
|
|
789
|
-
"When accessing a deploy store, the Netlify Blobs client needs to be configured with a region, and one was not found in the environment. To manually set the region, set the `region` property in the `getDeployStore` options. If you are using the Netlify CLI, you may have an outdated version; run `npm install -g netlify-cli@latest` to update and try again."
|
|
790
|
-
);
|
|
791
|
-
}
|
|
792
|
-
clientOptions.region = context2.primaryRegion;
|
|
793
|
-
} else {
|
|
794
|
-
clientOptions.region = REGION_AUTO;
|
|
795
|
-
}
|
|
796
|
-
}
|
|
797
|
-
const client = new Client(clientOptions);
|
|
798
|
-
return new Store({ client, deployID, name: options.name });
|
|
799
|
-
};
|
|
800
|
-
|
|
801
|
-
// src/run/regional-blob-store.cts
|
|
802
|
-
var fetchBeforeNextPatchedIt = globalThis.fetch;
|
|
803
|
-
var getRegionalBlobStore = (args = {}) => {
|
|
804
|
-
return getDeployStore({
|
|
805
|
-
...args,
|
|
806
|
-
fetch: fetchBeforeNextPatchedIt,
|
|
807
|
-
region: process.env.USE_REGIONAL_BLOBS?.toUpperCase() === "TRUE" ? void 0 : "us-east-2"
|
|
808
|
-
});
|
|
809
|
-
};
|
|
810
|
-
|
|
811
|
-
// src/run/handlers/request-context.cts
|
|
812
|
-
var import_node_async_hooks = require("node:async_hooks");
|
|
813
|
-
|
|
814
|
-
// node_modules/@netlify/functions/dist/chunk-ATZ7N7EG.mjs
|
|
815
|
-
var import_process2 = require("process");
|
|
816
|
-
var systemLogTag;
|
|
817
|
-
var serializeError;
|
|
818
|
-
var LogLevel;
|
|
819
|
-
var SystemLogger;
|
|
820
|
-
var systemLogger;
|
|
821
|
-
var init_system_logger = __esm2({
|
|
822
|
-
"src/lib/system_logger.ts"() {
|
|
823
|
-
systemLogTag = "__nfSystemLog";
|
|
824
|
-
serializeError = (error) => {
|
|
825
|
-
const cause = error?.cause instanceof Error ? serializeError(error.cause) : error.cause;
|
|
826
|
-
return {
|
|
827
|
-
error: error.message,
|
|
828
|
-
error_cause: cause,
|
|
829
|
-
error_stack: error.stack
|
|
830
|
-
};
|
|
831
|
-
};
|
|
832
|
-
LogLevel = /* @__PURE__ */ ((LogLevel2) => {
|
|
833
|
-
LogLevel2[LogLevel2["Debug"] = 1] = "Debug";
|
|
834
|
-
LogLevel2[LogLevel2["Log"] = 2] = "Log";
|
|
835
|
-
LogLevel2[LogLevel2["Error"] = 3] = "Error";
|
|
836
|
-
return LogLevel2;
|
|
837
|
-
})(LogLevel || {});
|
|
838
|
-
SystemLogger = class _SystemLogger {
|
|
839
|
-
fields;
|
|
840
|
-
logLevel;
|
|
841
|
-
constructor(fields = {}, logLevel = 2) {
|
|
842
|
-
this.fields = fields;
|
|
843
|
-
this.logLevel = logLevel;
|
|
844
|
-
}
|
|
845
|
-
doLog(logger, message) {
|
|
846
|
-
if (import_process2.env.NETLIFY_DEV && !import_process2.env.NETLIFY_ENABLE_SYSTEM_LOGGING) {
|
|
847
|
-
return;
|
|
848
|
-
}
|
|
849
|
-
logger(systemLogTag, JSON.stringify({ msg: message, fields: this.fields }));
|
|
850
|
-
}
|
|
851
|
-
log(message) {
|
|
852
|
-
if (this.logLevel > 2) {
|
|
853
|
-
return;
|
|
854
|
-
}
|
|
855
|
-
this.doLog(console.log, message);
|
|
856
|
-
}
|
|
857
|
-
debug(message) {
|
|
858
|
-
if (this.logLevel > 1) {
|
|
859
|
-
return;
|
|
860
|
-
}
|
|
861
|
-
this.doLog(console.debug, message);
|
|
862
|
-
}
|
|
863
|
-
error(message) {
|
|
864
|
-
if (this.logLevel > 3) {
|
|
865
|
-
return;
|
|
866
|
-
}
|
|
867
|
-
this.doLog(console.error, message);
|
|
868
|
-
}
|
|
869
|
-
withLogLevel(level) {
|
|
870
|
-
return new _SystemLogger(this.fields, level);
|
|
871
|
-
}
|
|
872
|
-
withFields(fields) {
|
|
873
|
-
return new _SystemLogger(
|
|
874
|
-
{
|
|
875
|
-
...this.fields,
|
|
876
|
-
...fields
|
|
877
|
-
},
|
|
878
|
-
this.logLevel
|
|
879
|
-
);
|
|
880
|
-
}
|
|
881
|
-
withError(error) {
|
|
882
|
-
const fields = error instanceof Error ? serializeError(error) : { error };
|
|
883
|
-
return this.withFields(fields);
|
|
884
|
-
}
|
|
885
|
-
};
|
|
886
|
-
systemLogger = new SystemLogger();
|
|
887
|
-
}
|
|
888
|
-
});
|
|
889
|
-
|
|
890
|
-
// node_modules/@netlify/functions/dist/chunk-7ANA32NV.mjs
|
|
891
|
-
var init_internal = __esm2({
|
|
892
|
-
"src/internal.ts"() {
|
|
893
|
-
init_system_logger();
|
|
894
|
-
}
|
|
895
|
-
});
|
|
896
|
-
|
|
897
|
-
// node_modules/@netlify/functions/dist/internal.mjs
|
|
898
|
-
init_internal();
|
|
899
|
-
|
|
900
|
-
// src/run/handlers/request-context.cts
|
|
901
|
-
var REQUEST_CONTEXT_GLOBAL_KEY = Symbol.for("nf-request-context-async-local-storage");
|
|
902
|
-
var requestContextAsyncLocalStorage;
|
|
903
|
-
function getRequestContextAsyncLocalStorage() {
|
|
904
|
-
if (requestContextAsyncLocalStorage) {
|
|
905
|
-
return requestContextAsyncLocalStorage;
|
|
906
|
-
}
|
|
907
|
-
const extendedGlobalThis = globalThis;
|
|
908
|
-
if (extendedGlobalThis[REQUEST_CONTEXT_GLOBAL_KEY]) {
|
|
909
|
-
return extendedGlobalThis[REQUEST_CONTEXT_GLOBAL_KEY];
|
|
910
|
-
}
|
|
911
|
-
const storage = new import_node_async_hooks.AsyncLocalStorage();
|
|
912
|
-
requestContextAsyncLocalStorage = storage;
|
|
913
|
-
extendedGlobalThis[REQUEST_CONTEXT_GLOBAL_KEY] = storage;
|
|
914
|
-
return storage;
|
|
915
|
-
}
|
|
916
|
-
var getRequestContext = () => getRequestContextAsyncLocalStorage().getStore();
|
|
917
|
-
function getLogger() {
|
|
918
|
-
return getRequestContext()?.logger ?? systemLogger;
|
|
919
|
-
}
|
|
920
|
-
|
|
921
|
-
// node_modules/@opentelemetry/api/build/esm/platform/node/globalThis.js
|
|
922
|
-
var _globalThis = typeof globalThis === "object" ? globalThis : global;
|
|
923
|
-
|
|
924
|
-
// node_modules/@opentelemetry/api/build/esm/version.js
|
|
925
|
-
var VERSION = "1.8.0";
|
|
926
|
-
|
|
927
|
-
// node_modules/@opentelemetry/api/build/esm/internal/semver.js
|
|
928
|
-
var re = /^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;
|
|
929
|
-
function _makeCompatibilityCheck(ownVersion) {
|
|
930
|
-
var acceptedVersions = /* @__PURE__ */ new Set([ownVersion]);
|
|
931
|
-
var rejectedVersions = /* @__PURE__ */ new Set();
|
|
932
|
-
var myVersionMatch = ownVersion.match(re);
|
|
933
|
-
if (!myVersionMatch) {
|
|
934
|
-
return function() {
|
|
935
|
-
return false;
|
|
936
|
-
};
|
|
937
|
-
}
|
|
938
|
-
var ownVersionParsed = {
|
|
939
|
-
major: +myVersionMatch[1],
|
|
940
|
-
minor: +myVersionMatch[2],
|
|
941
|
-
patch: +myVersionMatch[3],
|
|
942
|
-
prerelease: myVersionMatch[4]
|
|
943
|
-
};
|
|
944
|
-
if (ownVersionParsed.prerelease != null) {
|
|
945
|
-
return function isExactmatch(globalVersion) {
|
|
946
|
-
return globalVersion === ownVersion;
|
|
947
|
-
};
|
|
948
|
-
}
|
|
949
|
-
function _reject(v) {
|
|
950
|
-
rejectedVersions.add(v);
|
|
951
|
-
return false;
|
|
952
|
-
}
|
|
953
|
-
function _accept(v) {
|
|
954
|
-
acceptedVersions.add(v);
|
|
955
|
-
return true;
|
|
956
|
-
}
|
|
957
|
-
return function isCompatible2(globalVersion) {
|
|
958
|
-
if (acceptedVersions.has(globalVersion)) {
|
|
959
|
-
return true;
|
|
960
|
-
}
|
|
961
|
-
if (rejectedVersions.has(globalVersion)) {
|
|
962
|
-
return false;
|
|
963
|
-
}
|
|
964
|
-
var globalVersionMatch = globalVersion.match(re);
|
|
965
|
-
if (!globalVersionMatch) {
|
|
966
|
-
return _reject(globalVersion);
|
|
967
|
-
}
|
|
968
|
-
var globalVersionParsed = {
|
|
969
|
-
major: +globalVersionMatch[1],
|
|
970
|
-
minor: +globalVersionMatch[2],
|
|
971
|
-
patch: +globalVersionMatch[3],
|
|
972
|
-
prerelease: globalVersionMatch[4]
|
|
973
|
-
};
|
|
974
|
-
if (globalVersionParsed.prerelease != null) {
|
|
975
|
-
return _reject(globalVersion);
|
|
976
|
-
}
|
|
977
|
-
if (ownVersionParsed.major !== globalVersionParsed.major) {
|
|
978
|
-
return _reject(globalVersion);
|
|
979
|
-
}
|
|
980
|
-
if (ownVersionParsed.major === 0) {
|
|
981
|
-
if (ownVersionParsed.minor === globalVersionParsed.minor && ownVersionParsed.patch <= globalVersionParsed.patch) {
|
|
982
|
-
return _accept(globalVersion);
|
|
983
|
-
}
|
|
984
|
-
return _reject(globalVersion);
|
|
985
|
-
}
|
|
986
|
-
if (ownVersionParsed.minor <= globalVersionParsed.minor) {
|
|
987
|
-
return _accept(globalVersion);
|
|
988
|
-
}
|
|
989
|
-
return _reject(globalVersion);
|
|
990
|
-
};
|
|
991
|
-
}
|
|
992
|
-
var isCompatible = _makeCompatibilityCheck(VERSION);
|
|
993
|
-
|
|
994
|
-
// node_modules/@opentelemetry/api/build/esm/internal/global-utils.js
|
|
995
|
-
var major = VERSION.split(".")[0];
|
|
996
|
-
var GLOBAL_OPENTELEMETRY_API_KEY = Symbol.for("opentelemetry.js.api." + major);
|
|
997
|
-
var _global = _globalThis;
|
|
998
|
-
function registerGlobal(type, instance, diag, allowOverride) {
|
|
999
|
-
var _a;
|
|
1000
|
-
if (allowOverride === void 0) {
|
|
1001
|
-
allowOverride = false;
|
|
1002
|
-
}
|
|
1003
|
-
var api = _global[GLOBAL_OPENTELEMETRY_API_KEY] = (_a = _global[GLOBAL_OPENTELEMETRY_API_KEY]) !== null && _a !== void 0 ? _a : {
|
|
1004
|
-
version: VERSION
|
|
1005
|
-
};
|
|
1006
|
-
if (!allowOverride && api[type]) {
|
|
1007
|
-
var err = new Error("@opentelemetry/api: Attempted duplicate registration of API: " + type);
|
|
1008
|
-
diag.error(err.stack || err.message);
|
|
1009
|
-
return false;
|
|
1010
|
-
}
|
|
1011
|
-
if (api.version !== VERSION) {
|
|
1012
|
-
var err = new Error("@opentelemetry/api: Registration of version v" + api.version + " for " + type + " does not match previously registered API v" + VERSION);
|
|
1013
|
-
diag.error(err.stack || err.message);
|
|
1014
|
-
return false;
|
|
1015
|
-
}
|
|
1016
|
-
api[type] = instance;
|
|
1017
|
-
diag.debug("@opentelemetry/api: Registered a global for " + type + " v" + VERSION + ".");
|
|
1018
|
-
return true;
|
|
1019
|
-
}
|
|
1020
|
-
function getGlobal(type) {
|
|
1021
|
-
var _a, _b;
|
|
1022
|
-
var globalVersion = (_a = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _a === void 0 ? void 0 : _a.version;
|
|
1023
|
-
if (!globalVersion || !isCompatible(globalVersion)) {
|
|
1024
|
-
return;
|
|
1025
|
-
}
|
|
1026
|
-
return (_b = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _b === void 0 ? void 0 : _b[type];
|
|
1027
|
-
}
|
|
1028
|
-
function unregisterGlobal(type, diag) {
|
|
1029
|
-
diag.debug("@opentelemetry/api: Unregistering a global for " + type + " v" + VERSION + ".");
|
|
1030
|
-
var api = _global[GLOBAL_OPENTELEMETRY_API_KEY];
|
|
1031
|
-
if (api) {
|
|
1032
|
-
delete api[type];
|
|
1033
|
-
}
|
|
1034
|
-
}
|
|
1035
|
-
|
|
1036
|
-
// node_modules/@opentelemetry/api/build/esm/diag/ComponentLogger.js
|
|
1037
|
-
var __read = function(o, n) {
|
|
1038
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
1039
|
-
if (!m) return o;
|
|
1040
|
-
var i = m.call(o), r, ar = [], e;
|
|
1041
|
-
try {
|
|
1042
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
1043
|
-
} catch (error) {
|
|
1044
|
-
e = { error };
|
|
1045
|
-
} finally {
|
|
1046
|
-
try {
|
|
1047
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
1048
|
-
} finally {
|
|
1049
|
-
if (e) throw e.error;
|
|
1050
|
-
}
|
|
1051
|
-
}
|
|
1052
|
-
return ar;
|
|
1053
|
-
};
|
|
1054
|
-
var __spreadArray = function(to, from, pack) {
|
|
1055
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
1056
|
-
if (ar || !(i in from)) {
|
|
1057
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
1058
|
-
ar[i] = from[i];
|
|
1059
|
-
}
|
|
1060
|
-
}
|
|
1061
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
1062
|
-
};
|
|
1063
|
-
var DiagComponentLogger = (
|
|
1064
|
-
/** @class */
|
|
1065
|
-
function() {
|
|
1066
|
-
function DiagComponentLogger2(props) {
|
|
1067
|
-
this._namespace = props.namespace || "DiagComponentLogger";
|
|
1068
|
-
}
|
|
1069
|
-
DiagComponentLogger2.prototype.debug = function() {
|
|
1070
|
-
var args = [];
|
|
1071
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1072
|
-
args[_i] = arguments[_i];
|
|
1073
|
-
}
|
|
1074
|
-
return logProxy("debug", this._namespace, args);
|
|
1075
|
-
};
|
|
1076
|
-
DiagComponentLogger2.prototype.error = function() {
|
|
1077
|
-
var args = [];
|
|
1078
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1079
|
-
args[_i] = arguments[_i];
|
|
1080
|
-
}
|
|
1081
|
-
return logProxy("error", this._namespace, args);
|
|
1082
|
-
};
|
|
1083
|
-
DiagComponentLogger2.prototype.info = function() {
|
|
1084
|
-
var args = [];
|
|
1085
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1086
|
-
args[_i] = arguments[_i];
|
|
1087
|
-
}
|
|
1088
|
-
return logProxy("info", this._namespace, args);
|
|
1089
|
-
};
|
|
1090
|
-
DiagComponentLogger2.prototype.warn = function() {
|
|
1091
|
-
var args = [];
|
|
1092
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1093
|
-
args[_i] = arguments[_i];
|
|
1094
|
-
}
|
|
1095
|
-
return logProxy("warn", this._namespace, args);
|
|
1096
|
-
};
|
|
1097
|
-
DiagComponentLogger2.prototype.verbose = function() {
|
|
1098
|
-
var args = [];
|
|
1099
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1100
|
-
args[_i] = arguments[_i];
|
|
1101
|
-
}
|
|
1102
|
-
return logProxy("verbose", this._namespace, args);
|
|
1103
|
-
};
|
|
1104
|
-
return DiagComponentLogger2;
|
|
1105
|
-
}()
|
|
1106
|
-
);
|
|
1107
|
-
function logProxy(funcName, namespace, args) {
|
|
1108
|
-
var logger = getGlobal("diag");
|
|
1109
|
-
if (!logger) {
|
|
1110
|
-
return;
|
|
1111
|
-
}
|
|
1112
|
-
args.unshift(namespace);
|
|
1113
|
-
return logger[funcName].apply(logger, __spreadArray([], __read(args), false));
|
|
1114
|
-
}
|
|
1115
|
-
|
|
1116
|
-
// node_modules/@opentelemetry/api/build/esm/diag/types.js
|
|
1117
|
-
var DiagLogLevel;
|
|
1118
|
-
(function(DiagLogLevel2) {
|
|
1119
|
-
DiagLogLevel2[DiagLogLevel2["NONE"] = 0] = "NONE";
|
|
1120
|
-
DiagLogLevel2[DiagLogLevel2["ERROR"] = 30] = "ERROR";
|
|
1121
|
-
DiagLogLevel2[DiagLogLevel2["WARN"] = 50] = "WARN";
|
|
1122
|
-
DiagLogLevel2[DiagLogLevel2["INFO"] = 60] = "INFO";
|
|
1123
|
-
DiagLogLevel2[DiagLogLevel2["DEBUG"] = 70] = "DEBUG";
|
|
1124
|
-
DiagLogLevel2[DiagLogLevel2["VERBOSE"] = 80] = "VERBOSE";
|
|
1125
|
-
DiagLogLevel2[DiagLogLevel2["ALL"] = 9999] = "ALL";
|
|
1126
|
-
})(DiagLogLevel || (DiagLogLevel = {}));
|
|
1127
|
-
|
|
1128
|
-
// node_modules/@opentelemetry/api/build/esm/diag/internal/logLevelLogger.js
|
|
1129
|
-
function createLogLevelDiagLogger(maxLevel, logger) {
|
|
1130
|
-
if (maxLevel < DiagLogLevel.NONE) {
|
|
1131
|
-
maxLevel = DiagLogLevel.NONE;
|
|
1132
|
-
} else if (maxLevel > DiagLogLevel.ALL) {
|
|
1133
|
-
maxLevel = DiagLogLevel.ALL;
|
|
1134
|
-
}
|
|
1135
|
-
logger = logger || {};
|
|
1136
|
-
function _filterFunc(funcName, theLevel) {
|
|
1137
|
-
var theFunc = logger[funcName];
|
|
1138
|
-
if (typeof theFunc === "function" && maxLevel >= theLevel) {
|
|
1139
|
-
return theFunc.bind(logger);
|
|
1140
|
-
}
|
|
1141
|
-
return function() {
|
|
1142
|
-
};
|
|
1143
|
-
}
|
|
1144
|
-
return {
|
|
1145
|
-
error: _filterFunc("error", DiagLogLevel.ERROR),
|
|
1146
|
-
warn: _filterFunc("warn", DiagLogLevel.WARN),
|
|
1147
|
-
info: _filterFunc("info", DiagLogLevel.INFO),
|
|
1148
|
-
debug: _filterFunc("debug", DiagLogLevel.DEBUG),
|
|
1149
|
-
verbose: _filterFunc("verbose", DiagLogLevel.VERBOSE)
|
|
1150
|
-
};
|
|
1151
|
-
}
|
|
1152
|
-
|
|
1153
|
-
// node_modules/@opentelemetry/api/build/esm/api/diag.js
|
|
1154
|
-
var __read2 = function(o, n) {
|
|
1155
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
1156
|
-
if (!m) return o;
|
|
1157
|
-
var i = m.call(o), r, ar = [], e;
|
|
1158
|
-
try {
|
|
1159
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
1160
|
-
} catch (error) {
|
|
1161
|
-
e = { error };
|
|
1162
|
-
} finally {
|
|
1163
|
-
try {
|
|
1164
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
1165
|
-
} finally {
|
|
1166
|
-
if (e) throw e.error;
|
|
1167
|
-
}
|
|
1168
|
-
}
|
|
1169
|
-
return ar;
|
|
1170
|
-
};
|
|
1171
|
-
var __spreadArray2 = function(to, from, pack) {
|
|
1172
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
1173
|
-
if (ar || !(i in from)) {
|
|
1174
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
1175
|
-
ar[i] = from[i];
|
|
1176
|
-
}
|
|
1177
|
-
}
|
|
1178
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
1179
|
-
};
|
|
1180
|
-
var API_NAME = "diag";
|
|
1181
|
-
var DiagAPI = (
|
|
1182
|
-
/** @class */
|
|
1183
|
-
function() {
|
|
1184
|
-
function DiagAPI2() {
|
|
1185
|
-
function _logProxy(funcName) {
|
|
1186
|
-
return function() {
|
|
1187
|
-
var args = [];
|
|
1188
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1189
|
-
args[_i] = arguments[_i];
|
|
1190
|
-
}
|
|
1191
|
-
var logger = getGlobal("diag");
|
|
1192
|
-
if (!logger)
|
|
1193
|
-
return;
|
|
1194
|
-
return logger[funcName].apply(logger, __spreadArray2([], __read2(args), false));
|
|
1195
|
-
};
|
|
1196
|
-
}
|
|
1197
|
-
var self = this;
|
|
1198
|
-
var setLogger = function(logger, optionsOrLogLevel) {
|
|
1199
|
-
var _a, _b, _c;
|
|
1200
|
-
if (optionsOrLogLevel === void 0) {
|
|
1201
|
-
optionsOrLogLevel = { logLevel: DiagLogLevel.INFO };
|
|
1202
|
-
}
|
|
1203
|
-
if (logger === self) {
|
|
1204
|
-
var err = new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
|
|
1205
|
-
self.error((_a = err.stack) !== null && _a !== void 0 ? _a : err.message);
|
|
1206
|
-
return false;
|
|
1207
|
-
}
|
|
1208
|
-
if (typeof optionsOrLogLevel === "number") {
|
|
1209
|
-
optionsOrLogLevel = {
|
|
1210
|
-
logLevel: optionsOrLogLevel
|
|
1211
|
-
};
|
|
1212
|
-
}
|
|
1213
|
-
var oldLogger = getGlobal("diag");
|
|
1214
|
-
var newLogger = createLogLevelDiagLogger((_b = optionsOrLogLevel.logLevel) !== null && _b !== void 0 ? _b : DiagLogLevel.INFO, logger);
|
|
1215
|
-
if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
|
|
1216
|
-
var stack = (_c = new Error().stack) !== null && _c !== void 0 ? _c : "<failed to generate stacktrace>";
|
|
1217
|
-
oldLogger.warn("Current logger will be overwritten from " + stack);
|
|
1218
|
-
newLogger.warn("Current logger will overwrite one already registered from " + stack);
|
|
1219
|
-
}
|
|
1220
|
-
return registerGlobal("diag", newLogger, self, true);
|
|
1221
|
-
};
|
|
1222
|
-
self.setLogger = setLogger;
|
|
1223
|
-
self.disable = function() {
|
|
1224
|
-
unregisterGlobal(API_NAME, self);
|
|
1225
|
-
};
|
|
1226
|
-
self.createComponentLogger = function(options) {
|
|
1227
|
-
return new DiagComponentLogger(options);
|
|
1228
|
-
};
|
|
1229
|
-
self.verbose = _logProxy("verbose");
|
|
1230
|
-
self.debug = _logProxy("debug");
|
|
1231
|
-
self.info = _logProxy("info");
|
|
1232
|
-
self.warn = _logProxy("warn");
|
|
1233
|
-
self.error = _logProxy("error");
|
|
1234
|
-
}
|
|
1235
|
-
DiagAPI2.instance = function() {
|
|
1236
|
-
if (!this._instance) {
|
|
1237
|
-
this._instance = new DiagAPI2();
|
|
1238
|
-
}
|
|
1239
|
-
return this._instance;
|
|
1240
|
-
};
|
|
1241
|
-
return DiagAPI2;
|
|
1242
|
-
}()
|
|
1243
|
-
);
|
|
1244
|
-
|
|
1245
|
-
// node_modules/@opentelemetry/api/build/esm/context/context.js
|
|
1246
|
-
function createContextKey(description) {
|
|
1247
|
-
return Symbol.for(description);
|
|
1248
|
-
}
|
|
1249
|
-
var BaseContext = (
|
|
1250
|
-
/** @class */
|
|
1251
|
-
/* @__PURE__ */ function() {
|
|
1252
|
-
function BaseContext2(parentContext) {
|
|
1253
|
-
var self = this;
|
|
1254
|
-
self._currentContext = parentContext ? new Map(parentContext) : /* @__PURE__ */ new Map();
|
|
1255
|
-
self.getValue = function(key) {
|
|
1256
|
-
return self._currentContext.get(key);
|
|
1257
|
-
};
|
|
1258
|
-
self.setValue = function(key, value) {
|
|
1259
|
-
var context2 = new BaseContext2(self._currentContext);
|
|
1260
|
-
context2._currentContext.set(key, value);
|
|
1261
|
-
return context2;
|
|
1262
|
-
};
|
|
1263
|
-
self.deleteValue = function(key) {
|
|
1264
|
-
var context2 = new BaseContext2(self._currentContext);
|
|
1265
|
-
context2._currentContext.delete(key);
|
|
1266
|
-
return context2;
|
|
1267
|
-
};
|
|
1268
|
-
}
|
|
1269
|
-
return BaseContext2;
|
|
1270
|
-
}()
|
|
1271
|
-
);
|
|
1272
|
-
var ROOT_CONTEXT = new BaseContext();
|
|
1273
|
-
|
|
1274
|
-
// node_modules/@opentelemetry/api/build/esm/context/NoopContextManager.js
|
|
1275
|
-
var __read3 = function(o, n) {
|
|
1276
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
1277
|
-
if (!m) return o;
|
|
1278
|
-
var i = m.call(o), r, ar = [], e;
|
|
1279
|
-
try {
|
|
1280
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
1281
|
-
} catch (error) {
|
|
1282
|
-
e = { error };
|
|
1283
|
-
} finally {
|
|
1284
|
-
try {
|
|
1285
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
1286
|
-
} finally {
|
|
1287
|
-
if (e) throw e.error;
|
|
1288
|
-
}
|
|
1289
|
-
}
|
|
1290
|
-
return ar;
|
|
1291
|
-
};
|
|
1292
|
-
var __spreadArray3 = function(to, from, pack) {
|
|
1293
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
1294
|
-
if (ar || !(i in from)) {
|
|
1295
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
1296
|
-
ar[i] = from[i];
|
|
1297
|
-
}
|
|
1298
|
-
}
|
|
1299
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
1300
|
-
};
|
|
1301
|
-
var NoopContextManager = (
|
|
1302
|
-
/** @class */
|
|
1303
|
-
function() {
|
|
1304
|
-
function NoopContextManager2() {
|
|
1305
|
-
}
|
|
1306
|
-
NoopContextManager2.prototype.active = function() {
|
|
1307
|
-
return ROOT_CONTEXT;
|
|
1308
|
-
};
|
|
1309
|
-
NoopContextManager2.prototype.with = function(_context, fn, thisArg) {
|
|
1310
|
-
var args = [];
|
|
1311
|
-
for (var _i = 3; _i < arguments.length; _i++) {
|
|
1312
|
-
args[_i - 3] = arguments[_i];
|
|
1313
|
-
}
|
|
1314
|
-
return fn.call.apply(fn, __spreadArray3([thisArg], __read3(args), false));
|
|
1315
|
-
};
|
|
1316
|
-
NoopContextManager2.prototype.bind = function(_context, target) {
|
|
1317
|
-
return target;
|
|
1318
|
-
};
|
|
1319
|
-
NoopContextManager2.prototype.enable = function() {
|
|
1320
|
-
return this;
|
|
1321
|
-
};
|
|
1322
|
-
NoopContextManager2.prototype.disable = function() {
|
|
1323
|
-
return this;
|
|
1324
|
-
};
|
|
1325
|
-
return NoopContextManager2;
|
|
1326
|
-
}()
|
|
1327
|
-
);
|
|
1328
|
-
|
|
1329
|
-
// node_modules/@opentelemetry/api/build/esm/api/context.js
|
|
1330
|
-
var __read4 = function(o, n) {
|
|
1331
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
1332
|
-
if (!m) return o;
|
|
1333
|
-
var i = m.call(o), r, ar = [], e;
|
|
1334
|
-
try {
|
|
1335
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
1336
|
-
} catch (error) {
|
|
1337
|
-
e = { error };
|
|
1338
|
-
} finally {
|
|
1339
|
-
try {
|
|
1340
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
1341
|
-
} finally {
|
|
1342
|
-
if (e) throw e.error;
|
|
1343
|
-
}
|
|
1344
|
-
}
|
|
1345
|
-
return ar;
|
|
1346
|
-
};
|
|
1347
|
-
var __spreadArray4 = function(to, from, pack) {
|
|
1348
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
1349
|
-
if (ar || !(i in from)) {
|
|
1350
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
1351
|
-
ar[i] = from[i];
|
|
1352
|
-
}
|
|
1353
|
-
}
|
|
1354
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
1355
|
-
};
|
|
1356
|
-
var API_NAME2 = "context";
|
|
1357
|
-
var NOOP_CONTEXT_MANAGER = new NoopContextManager();
|
|
1358
|
-
var ContextAPI = (
|
|
1359
|
-
/** @class */
|
|
1360
|
-
function() {
|
|
1361
|
-
function ContextAPI2() {
|
|
1362
|
-
}
|
|
1363
|
-
ContextAPI2.getInstance = function() {
|
|
1364
|
-
if (!this._instance) {
|
|
1365
|
-
this._instance = new ContextAPI2();
|
|
1366
|
-
}
|
|
1367
|
-
return this._instance;
|
|
1368
|
-
};
|
|
1369
|
-
ContextAPI2.prototype.setGlobalContextManager = function(contextManager) {
|
|
1370
|
-
return registerGlobal(API_NAME2, contextManager, DiagAPI.instance());
|
|
1371
|
-
};
|
|
1372
|
-
ContextAPI2.prototype.active = function() {
|
|
1373
|
-
return this._getContextManager().active();
|
|
1374
|
-
};
|
|
1375
|
-
ContextAPI2.prototype.with = function(context2, fn, thisArg) {
|
|
1376
|
-
var _a;
|
|
1377
|
-
var args = [];
|
|
1378
|
-
for (var _i = 3; _i < arguments.length; _i++) {
|
|
1379
|
-
args[_i - 3] = arguments[_i];
|
|
1380
|
-
}
|
|
1381
|
-
return (_a = this._getContextManager()).with.apply(_a, __spreadArray4([context2, fn, thisArg], __read4(args), false));
|
|
1382
|
-
};
|
|
1383
|
-
ContextAPI2.prototype.bind = function(context2, target) {
|
|
1384
|
-
return this._getContextManager().bind(context2, target);
|
|
1385
|
-
};
|
|
1386
|
-
ContextAPI2.prototype._getContextManager = function() {
|
|
1387
|
-
return getGlobal(API_NAME2) || NOOP_CONTEXT_MANAGER;
|
|
1388
|
-
};
|
|
1389
|
-
ContextAPI2.prototype.disable = function() {
|
|
1390
|
-
this._getContextManager().disable();
|
|
1391
|
-
unregisterGlobal(API_NAME2, DiagAPI.instance());
|
|
1392
|
-
};
|
|
1393
|
-
return ContextAPI2;
|
|
1394
|
-
}()
|
|
1395
|
-
);
|
|
1396
|
-
|
|
1397
|
-
// node_modules/@opentelemetry/api/build/esm/trace/trace_flags.js
|
|
1398
|
-
var TraceFlags;
|
|
1399
|
-
(function(TraceFlags2) {
|
|
1400
|
-
TraceFlags2[TraceFlags2["NONE"] = 0] = "NONE";
|
|
1401
|
-
TraceFlags2[TraceFlags2["SAMPLED"] = 1] = "SAMPLED";
|
|
1402
|
-
})(TraceFlags || (TraceFlags = {}));
|
|
1403
|
-
|
|
1404
|
-
// node_modules/@opentelemetry/api/build/esm/trace/invalid-span-constants.js
|
|
1405
|
-
var INVALID_SPANID = "0000000000000000";
|
|
1406
|
-
var INVALID_TRACEID = "00000000000000000000000000000000";
|
|
1407
|
-
var INVALID_SPAN_CONTEXT = {
|
|
1408
|
-
traceId: INVALID_TRACEID,
|
|
1409
|
-
spanId: INVALID_SPANID,
|
|
1410
|
-
traceFlags: TraceFlags.NONE
|
|
1411
|
-
};
|
|
1412
|
-
|
|
1413
|
-
// node_modules/@opentelemetry/api/build/esm/trace/NonRecordingSpan.js
|
|
1414
|
-
var NonRecordingSpan = (
|
|
1415
|
-
/** @class */
|
|
1416
|
-
function() {
|
|
1417
|
-
function NonRecordingSpan2(_spanContext) {
|
|
1418
|
-
if (_spanContext === void 0) {
|
|
1419
|
-
_spanContext = INVALID_SPAN_CONTEXT;
|
|
1420
|
-
}
|
|
1421
|
-
this._spanContext = _spanContext;
|
|
1422
|
-
}
|
|
1423
|
-
NonRecordingSpan2.prototype.spanContext = function() {
|
|
1424
|
-
return this._spanContext;
|
|
1425
|
-
};
|
|
1426
|
-
NonRecordingSpan2.prototype.setAttribute = function(_key, _value) {
|
|
1427
|
-
return this;
|
|
1428
|
-
};
|
|
1429
|
-
NonRecordingSpan2.prototype.setAttributes = function(_attributes) {
|
|
1430
|
-
return this;
|
|
1431
|
-
};
|
|
1432
|
-
NonRecordingSpan2.prototype.addEvent = function(_name, _attributes) {
|
|
1433
|
-
return this;
|
|
1434
|
-
};
|
|
1435
|
-
NonRecordingSpan2.prototype.setStatus = function(_status) {
|
|
1436
|
-
return this;
|
|
1437
|
-
};
|
|
1438
|
-
NonRecordingSpan2.prototype.updateName = function(_name) {
|
|
1439
|
-
return this;
|
|
1440
|
-
};
|
|
1441
|
-
NonRecordingSpan2.prototype.end = function(_endTime) {
|
|
1442
|
-
};
|
|
1443
|
-
NonRecordingSpan2.prototype.isRecording = function() {
|
|
1444
|
-
return false;
|
|
1445
|
-
};
|
|
1446
|
-
NonRecordingSpan2.prototype.recordException = function(_exception, _time) {
|
|
1447
|
-
};
|
|
1448
|
-
return NonRecordingSpan2;
|
|
1449
|
-
}()
|
|
1450
|
-
);
|
|
1451
|
-
|
|
1452
|
-
// node_modules/@opentelemetry/api/build/esm/trace/context-utils.js
|
|
1453
|
-
var SPAN_KEY = createContextKey("OpenTelemetry Context Key SPAN");
|
|
1454
|
-
function getSpan(context2) {
|
|
1455
|
-
return context2.getValue(SPAN_KEY) || void 0;
|
|
1456
|
-
}
|
|
1457
|
-
function getActiveSpan() {
|
|
1458
|
-
return getSpan(ContextAPI.getInstance().active());
|
|
1459
|
-
}
|
|
1460
|
-
function setSpan(context2, span) {
|
|
1461
|
-
return context2.setValue(SPAN_KEY, span);
|
|
1462
|
-
}
|
|
1463
|
-
function deleteSpan(context2) {
|
|
1464
|
-
return context2.deleteValue(SPAN_KEY);
|
|
1465
|
-
}
|
|
1466
|
-
function setSpanContext(context2, spanContext) {
|
|
1467
|
-
return setSpan(context2, new NonRecordingSpan(spanContext));
|
|
1468
|
-
}
|
|
1469
|
-
function getSpanContext(context2) {
|
|
1470
|
-
var _a;
|
|
1471
|
-
return (_a = getSpan(context2)) === null || _a === void 0 ? void 0 : _a.spanContext();
|
|
1472
|
-
}
|
|
1473
|
-
|
|
1474
|
-
// node_modules/@opentelemetry/api/build/esm/trace/spancontext-utils.js
|
|
1475
|
-
var VALID_TRACEID_REGEX = /^([0-9a-f]{32})$/i;
|
|
1476
|
-
var VALID_SPANID_REGEX = /^[0-9a-f]{16}$/i;
|
|
1477
|
-
function isValidTraceId(traceId) {
|
|
1478
|
-
return VALID_TRACEID_REGEX.test(traceId) && traceId !== INVALID_TRACEID;
|
|
1479
|
-
}
|
|
1480
|
-
function isValidSpanId(spanId) {
|
|
1481
|
-
return VALID_SPANID_REGEX.test(spanId) && spanId !== INVALID_SPANID;
|
|
1482
|
-
}
|
|
1483
|
-
function isSpanContextValid(spanContext) {
|
|
1484
|
-
return isValidTraceId(spanContext.traceId) && isValidSpanId(spanContext.spanId);
|
|
1485
|
-
}
|
|
1486
|
-
function wrapSpanContext(spanContext) {
|
|
1487
|
-
return new NonRecordingSpan(spanContext);
|
|
1488
|
-
}
|
|
1489
|
-
|
|
1490
|
-
// node_modules/@opentelemetry/api/build/esm/trace/NoopTracer.js
|
|
1491
|
-
var contextApi = ContextAPI.getInstance();
|
|
1492
|
-
var NoopTracer = (
|
|
1493
|
-
/** @class */
|
|
1494
|
-
function() {
|
|
1495
|
-
function NoopTracer2() {
|
|
1496
|
-
}
|
|
1497
|
-
NoopTracer2.prototype.startSpan = function(name2, options, context2) {
|
|
1498
|
-
if (context2 === void 0) {
|
|
1499
|
-
context2 = contextApi.active();
|
|
1500
|
-
}
|
|
1501
|
-
var root = Boolean(options === null || options === void 0 ? void 0 : options.root);
|
|
1502
|
-
if (root) {
|
|
1503
|
-
return new NonRecordingSpan();
|
|
1504
|
-
}
|
|
1505
|
-
var parentFromContext = context2 && getSpanContext(context2);
|
|
1506
|
-
if (isSpanContext(parentFromContext) && isSpanContextValid(parentFromContext)) {
|
|
1507
|
-
return new NonRecordingSpan(parentFromContext);
|
|
1508
|
-
} else {
|
|
1509
|
-
return new NonRecordingSpan();
|
|
1510
|
-
}
|
|
1511
|
-
};
|
|
1512
|
-
NoopTracer2.prototype.startActiveSpan = function(name2, arg2, arg3, arg4) {
|
|
1513
|
-
var opts;
|
|
1514
|
-
var ctx;
|
|
1515
|
-
var fn;
|
|
1516
|
-
if (arguments.length < 2) {
|
|
1517
|
-
return;
|
|
1518
|
-
} else if (arguments.length === 2) {
|
|
1519
|
-
fn = arg2;
|
|
1520
|
-
} else if (arguments.length === 3) {
|
|
1521
|
-
opts = arg2;
|
|
1522
|
-
fn = arg3;
|
|
1523
|
-
} else {
|
|
1524
|
-
opts = arg2;
|
|
1525
|
-
ctx = arg3;
|
|
1526
|
-
fn = arg4;
|
|
1527
|
-
}
|
|
1528
|
-
var parentContext = ctx !== null && ctx !== void 0 ? ctx : contextApi.active();
|
|
1529
|
-
var span = this.startSpan(name2, opts, parentContext);
|
|
1530
|
-
var contextWithSpanSet = setSpan(parentContext, span);
|
|
1531
|
-
return contextApi.with(contextWithSpanSet, fn, void 0, span);
|
|
1532
|
-
};
|
|
1533
|
-
return NoopTracer2;
|
|
1534
|
-
}()
|
|
1535
|
-
);
|
|
1536
|
-
function isSpanContext(spanContext) {
|
|
1537
|
-
return typeof spanContext === "object" && typeof spanContext["spanId"] === "string" && typeof spanContext["traceId"] === "string" && typeof spanContext["traceFlags"] === "number";
|
|
1538
|
-
}
|
|
1539
|
-
|
|
1540
|
-
// node_modules/@opentelemetry/api/build/esm/trace/ProxyTracer.js
|
|
1541
|
-
var NOOP_TRACER = new NoopTracer();
|
|
1542
|
-
var ProxyTracer = (
|
|
1543
|
-
/** @class */
|
|
1544
|
-
function() {
|
|
1545
|
-
function ProxyTracer2(_provider, name2, version2, options) {
|
|
1546
|
-
this._provider = _provider;
|
|
1547
|
-
this.name = name2;
|
|
1548
|
-
this.version = version2;
|
|
1549
|
-
this.options = options;
|
|
1550
|
-
}
|
|
1551
|
-
ProxyTracer2.prototype.startSpan = function(name2, options, context2) {
|
|
1552
|
-
return this._getTracer().startSpan(name2, options, context2);
|
|
1553
|
-
};
|
|
1554
|
-
ProxyTracer2.prototype.startActiveSpan = function(_name, _options, _context, _fn) {
|
|
1555
|
-
var tracer2 = this._getTracer();
|
|
1556
|
-
return Reflect.apply(tracer2.startActiveSpan, tracer2, arguments);
|
|
1557
|
-
};
|
|
1558
|
-
ProxyTracer2.prototype._getTracer = function() {
|
|
1559
|
-
if (this._delegate) {
|
|
1560
|
-
return this._delegate;
|
|
1561
|
-
}
|
|
1562
|
-
var tracer2 = this._provider.getDelegateTracer(this.name, this.version, this.options);
|
|
1563
|
-
if (!tracer2) {
|
|
1564
|
-
return NOOP_TRACER;
|
|
1565
|
-
}
|
|
1566
|
-
this._delegate = tracer2;
|
|
1567
|
-
return this._delegate;
|
|
1568
|
-
};
|
|
1569
|
-
return ProxyTracer2;
|
|
1570
|
-
}()
|
|
1571
|
-
);
|
|
1572
|
-
|
|
1573
|
-
// node_modules/@opentelemetry/api/build/esm/trace/NoopTracerProvider.js
|
|
1574
|
-
var NoopTracerProvider = (
|
|
1575
|
-
/** @class */
|
|
1576
|
-
function() {
|
|
1577
|
-
function NoopTracerProvider2() {
|
|
1578
|
-
}
|
|
1579
|
-
NoopTracerProvider2.prototype.getTracer = function(_name, _version, _options) {
|
|
1580
|
-
return new NoopTracer();
|
|
1581
|
-
};
|
|
1582
|
-
return NoopTracerProvider2;
|
|
1583
|
-
}()
|
|
1584
|
-
);
|
|
1585
|
-
|
|
1586
|
-
// node_modules/@opentelemetry/api/build/esm/trace/ProxyTracerProvider.js
|
|
1587
|
-
var NOOP_TRACER_PROVIDER = new NoopTracerProvider();
|
|
1588
|
-
var ProxyTracerProvider = (
|
|
1589
|
-
/** @class */
|
|
1590
|
-
function() {
|
|
1591
|
-
function ProxyTracerProvider2() {
|
|
1592
|
-
}
|
|
1593
|
-
ProxyTracerProvider2.prototype.getTracer = function(name2, version2, options) {
|
|
1594
|
-
var _a;
|
|
1595
|
-
return (_a = this.getDelegateTracer(name2, version2, options)) !== null && _a !== void 0 ? _a : new ProxyTracer(this, name2, version2, options);
|
|
1596
|
-
};
|
|
1597
|
-
ProxyTracerProvider2.prototype.getDelegate = function() {
|
|
1598
|
-
var _a;
|
|
1599
|
-
return (_a = this._delegate) !== null && _a !== void 0 ? _a : NOOP_TRACER_PROVIDER;
|
|
1600
|
-
};
|
|
1601
|
-
ProxyTracerProvider2.prototype.setDelegate = function(delegate) {
|
|
1602
|
-
this._delegate = delegate;
|
|
1603
|
-
};
|
|
1604
|
-
ProxyTracerProvider2.prototype.getDelegateTracer = function(name2, version2, options) {
|
|
1605
|
-
var _a;
|
|
1606
|
-
return (_a = this._delegate) === null || _a === void 0 ? void 0 : _a.getTracer(name2, version2, options);
|
|
1607
|
-
};
|
|
1608
|
-
return ProxyTracerProvider2;
|
|
1609
|
-
}()
|
|
1610
|
-
);
|
|
1611
|
-
|
|
1612
|
-
// node_modules/@opentelemetry/api/build/esm/trace/status.js
|
|
1613
|
-
var SpanStatusCode;
|
|
1614
|
-
(function(SpanStatusCode2) {
|
|
1615
|
-
SpanStatusCode2[SpanStatusCode2["UNSET"] = 0] = "UNSET";
|
|
1616
|
-
SpanStatusCode2[SpanStatusCode2["OK"] = 1] = "OK";
|
|
1617
|
-
SpanStatusCode2[SpanStatusCode2["ERROR"] = 2] = "ERROR";
|
|
1618
|
-
})(SpanStatusCode || (SpanStatusCode = {}));
|
|
1619
|
-
|
|
1620
|
-
// node_modules/@opentelemetry/api/build/esm/context-api.js
|
|
1621
|
-
var context = ContextAPI.getInstance();
|
|
1622
|
-
|
|
1623
|
-
// node_modules/@opentelemetry/api/build/esm/api/trace.js
|
|
1624
|
-
var API_NAME3 = "trace";
|
|
1625
|
-
var TraceAPI = (
|
|
1626
|
-
/** @class */
|
|
1627
|
-
function() {
|
|
1628
|
-
function TraceAPI2() {
|
|
1629
|
-
this._proxyTracerProvider = new ProxyTracerProvider();
|
|
1630
|
-
this.wrapSpanContext = wrapSpanContext;
|
|
1631
|
-
this.isSpanContextValid = isSpanContextValid;
|
|
1632
|
-
this.deleteSpan = deleteSpan;
|
|
1633
|
-
this.getSpan = getSpan;
|
|
1634
|
-
this.getActiveSpan = getActiveSpan;
|
|
1635
|
-
this.getSpanContext = getSpanContext;
|
|
1636
|
-
this.setSpan = setSpan;
|
|
1637
|
-
this.setSpanContext = setSpanContext;
|
|
1638
|
-
}
|
|
1639
|
-
TraceAPI2.getInstance = function() {
|
|
1640
|
-
if (!this._instance) {
|
|
1641
|
-
this._instance = new TraceAPI2();
|
|
1642
|
-
}
|
|
1643
|
-
return this._instance;
|
|
1644
|
-
};
|
|
1645
|
-
TraceAPI2.prototype.setGlobalTracerProvider = function(provider) {
|
|
1646
|
-
var success = registerGlobal(API_NAME3, this._proxyTracerProvider, DiagAPI.instance());
|
|
1647
|
-
if (success) {
|
|
1648
|
-
this._proxyTracerProvider.setDelegate(provider);
|
|
1649
|
-
}
|
|
1650
|
-
return success;
|
|
1651
|
-
};
|
|
1652
|
-
TraceAPI2.prototype.getTracerProvider = function() {
|
|
1653
|
-
return getGlobal(API_NAME3) || this._proxyTracerProvider;
|
|
1654
|
-
};
|
|
1655
|
-
TraceAPI2.prototype.getTracer = function(name2, version2) {
|
|
1656
|
-
return this.getTracerProvider().getTracer(name2, version2);
|
|
1657
|
-
};
|
|
1658
|
-
TraceAPI2.prototype.disable = function() {
|
|
1659
|
-
unregisterGlobal(API_NAME3, DiagAPI.instance());
|
|
1660
|
-
this._proxyTracerProvider = new ProxyTracerProvider();
|
|
1661
|
-
};
|
|
1662
|
-
return TraceAPI2;
|
|
1663
|
-
}()
|
|
1664
|
-
);
|
|
1665
|
-
|
|
1666
|
-
// node_modules/@opentelemetry/api/build/esm/trace-api.js
|
|
1667
|
-
var trace = TraceAPI.getInstance();
|
|
1668
|
-
|
|
1669
|
-
// node_modules/@opentelemetry/api/build/esm/experimental/trace/SugaredTracer.js
|
|
1670
|
-
var defaultOnException = function(e, span) {
|
|
1671
|
-
span.recordException(e);
|
|
1672
|
-
span.setStatus({
|
|
1673
|
-
code: SpanStatusCode.ERROR
|
|
1674
|
-
});
|
|
1675
|
-
};
|
|
1676
|
-
function wrapTracer(tracer2) {
|
|
1677
|
-
return new SugaredTracer(tracer2);
|
|
1678
|
-
}
|
|
1679
|
-
var SugaredTracer = (
|
|
1680
|
-
/** @class */
|
|
1681
|
-
function() {
|
|
1682
|
-
function SugaredTracer3(tracer2) {
|
|
1683
|
-
this._tracer = tracer2;
|
|
1684
|
-
this.startSpan = tracer2.startSpan.bind(this._tracer);
|
|
1685
|
-
this.startActiveSpan = tracer2.startActiveSpan.bind(this._tracer);
|
|
1686
|
-
}
|
|
1687
|
-
SugaredTracer3.prototype.withActiveSpan = function(name2, arg2, arg3, arg4) {
|
|
1688
|
-
var _a = massageParams(arg2, arg3, arg4), opts = _a.opts, ctx = _a.ctx, fn = _a.fn;
|
|
1689
|
-
return this._tracer.startActiveSpan(name2, opts, ctx, function(span) {
|
|
1690
|
-
return handleFn(span, opts, fn);
|
|
1691
|
-
});
|
|
1692
|
-
};
|
|
1693
|
-
SugaredTracer3.prototype.withSpan = function(name2, arg2, arg3, arg4) {
|
|
1694
|
-
var _a = massageParams(arg2, arg3, arg4), opts = _a.opts, ctx = _a.ctx, fn = _a.fn;
|
|
1695
|
-
var span = this._tracer.startSpan(name2, opts, ctx);
|
|
1696
|
-
return handleFn(span, opts, fn);
|
|
1697
|
-
};
|
|
1698
|
-
return SugaredTracer3;
|
|
1699
|
-
}()
|
|
1700
|
-
);
|
|
1701
|
-
function massageParams(arg, arg2, arg3) {
|
|
1702
|
-
var opts;
|
|
1703
|
-
var ctx;
|
|
1704
|
-
var fn;
|
|
1705
|
-
if (!arg2 && !arg3) {
|
|
1706
|
-
fn = arg;
|
|
1707
|
-
} else if (!arg3) {
|
|
1708
|
-
opts = arg;
|
|
1709
|
-
fn = arg2;
|
|
1710
|
-
} else {
|
|
1711
|
-
opts = arg;
|
|
1712
|
-
ctx = arg2;
|
|
1713
|
-
fn = arg3;
|
|
1714
|
-
}
|
|
1715
|
-
opts = opts !== null && opts !== void 0 ? opts : {};
|
|
1716
|
-
ctx = ctx !== null && ctx !== void 0 ? ctx : context.active();
|
|
1717
|
-
return { opts, ctx, fn };
|
|
1718
|
-
}
|
|
1719
|
-
function handleFn(span, opts, fn) {
|
|
1720
|
-
var _a;
|
|
1721
|
-
var onException = (_a = opts.onException) !== null && _a !== void 0 ? _a : defaultOnException;
|
|
1722
|
-
var errorHandler = function(e) {
|
|
1723
|
-
onException(e, span);
|
|
1724
|
-
span.end();
|
|
1725
|
-
throw e;
|
|
1726
|
-
};
|
|
1727
|
-
try {
|
|
1728
|
-
var ret = fn(span);
|
|
1729
|
-
if (typeof (ret === null || ret === void 0 ? void 0 : ret.then) === "function") {
|
|
1730
|
-
return ret.then(function(val) {
|
|
1731
|
-
span.end();
|
|
1732
|
-
return val;
|
|
1733
|
-
}, errorHandler);
|
|
1734
|
-
}
|
|
1735
|
-
span.end();
|
|
1736
|
-
return ret;
|
|
1737
|
-
} catch (e) {
|
|
1738
|
-
throw errorHandler(e);
|
|
1739
|
-
}
|
|
1740
|
-
}
|
|
1741
|
-
|
|
1742
|
-
// src/run/handlers/tracer.cts
|
|
1743
|
-
var spanMeta = /* @__PURE__ */ new WeakMap();
|
|
1744
|
-
var spanCounter = /* @__PURE__ */ new WeakMap();
|
|
1745
|
-
function spanHook(span) {
|
|
1746
|
-
const originalEnd = span.end.bind(span);
|
|
1747
|
-
span.end = (endTime) => {
|
|
1748
|
-
originalEnd(endTime);
|
|
1749
|
-
const meta = spanMeta.get(span);
|
|
1750
|
-
if (meta) {
|
|
1751
|
-
const requestContext = getRequestContext();
|
|
1752
|
-
if (requestContext?.captureServerTiming) {
|
|
1753
|
-
const duration = (typeof endTime === "number" ? endTime : performance.now()) - meta.start;
|
|
1754
|
-
const serverTiming = requestContext.serverTiming ?? "";
|
|
1755
|
-
const currentRequestSpanCounter = spanCounter.get(requestContext) ?? 1;
|
|
1756
|
-
requestContext.serverTiming = `${serverTiming}${serverTiming.length === 0 ? "" : ", "}s${currentRequestSpanCounter};dur=${duration};desc="${meta.name}"`;
|
|
1757
|
-
spanCounter.set(requestContext, currentRequestSpanCounter + 1);
|
|
1758
|
-
}
|
|
1759
|
-
}
|
|
1760
|
-
spanMeta.delete(span);
|
|
1761
|
-
};
|
|
1762
|
-
return span;
|
|
1763
|
-
}
|
|
1764
|
-
var tracer;
|
|
1765
|
-
function getTracer() {
|
|
1766
|
-
if (!tracer) {
|
|
1767
|
-
const baseTracer = trace.getTracer("Next.js Runtime");
|
|
1768
|
-
const startSpan = baseTracer.startSpan.bind(baseTracer);
|
|
1769
|
-
baseTracer.startSpan = (...args) => {
|
|
1770
|
-
const span = startSpan(...args);
|
|
1771
|
-
spanMeta.set(span, { start: performance.now(), name: args[0] });
|
|
1772
|
-
return spanHook(span);
|
|
1773
|
-
};
|
|
1774
|
-
const startActiveSpan = baseTracer.startActiveSpan.bind(baseTracer);
|
|
1775
|
-
baseTracer.startActiveSpan = (...args) => {
|
|
1776
|
-
const [name2, ...restOfArgs] = args;
|
|
1777
|
-
const augmentedArgs = restOfArgs.map((arg) => {
|
|
1778
|
-
if (typeof arg === "function") {
|
|
1779
|
-
return (span) => {
|
|
1780
|
-
spanMeta.set(span, { start: performance.now(), name: args[0] });
|
|
1781
|
-
spanHook(span);
|
|
1782
|
-
return arg(span);
|
|
1783
|
-
};
|
|
1784
|
-
}
|
|
1785
|
-
return arg;
|
|
1786
|
-
});
|
|
1787
|
-
return startActiveSpan(name2, ...augmentedArgs);
|
|
1788
|
-
};
|
|
1789
|
-
tracer = wrapTracer(baseTracer);
|
|
1790
|
-
}
|
|
1791
|
-
return tracer;
|
|
1792
|
-
}
|
|
178
|
+
var version = "5.10.1";
|
|
1793
179
|
|
|
1794
180
|
// src/run/handlers/cache.cts
|
|
181
|
+
var import_cache_types = require("../../shared/cache-types.cjs");
|
|
182
|
+
var import_regional_blob_store = require("../regional-blob-store.cjs");
|
|
183
|
+
var import_request_context = require("./request-context.cjs");
|
|
184
|
+
var import_tracer = require("./tracer.cjs");
|
|
1795
185
|
var purgeCacheUserAgent = `${name}@${version}`;
|
|
1796
186
|
var NetlifyCacheHandler = class {
|
|
1797
187
|
options;
|
|
1798
188
|
revalidatedTags;
|
|
1799
189
|
blobStore;
|
|
1800
|
-
tracer = getTracer();
|
|
190
|
+
tracer = (0, import_tracer.getTracer)();
|
|
1801
191
|
tagManifestsFetchedFromBlobStoreInCurrentRequest;
|
|
1802
192
|
constructor(options) {
|
|
1803
193
|
this.options = options;
|
|
1804
194
|
this.revalidatedTags = options.revalidatedTags;
|
|
1805
|
-
this.blobStore = getRegionalBlobStore({ consistency: "strong" });
|
|
195
|
+
this.blobStore = (0, import_regional_blob_store.getRegionalBlobStore)({ consistency: "strong" });
|
|
1806
196
|
this.tagManifestsFetchedFromBlobStoreInCurrentRequest = {};
|
|
1807
197
|
}
|
|
1808
198
|
async encodeBlobKey(key) {
|
|
1809
|
-
const { encodeBlobKey
|
|
1810
|
-
return await
|
|
199
|
+
const { encodeBlobKey } = await import("../../shared/blobkey.js");
|
|
200
|
+
return await encodeBlobKey(key);
|
|
1811
201
|
}
|
|
1812
202
|
getTTL(blob) {
|
|
1813
203
|
if (blob.value?.kind === "FETCH" || blob.value?.kind === "ROUTE" || blob.value?.kind === "APP_ROUTE" || blob.value?.kind === "PAGE" || blob.value?.kind === "PAGES" || blob.value?.kind === "APP_PAGE") {
|
|
@@ -1826,7 +216,7 @@ var NetlifyCacheHandler = class {
|
|
|
1826
216
|
if (cacheValue.value?.kind === "FETCH") {
|
|
1827
217
|
return;
|
|
1828
218
|
}
|
|
1829
|
-
const requestContext = getRequestContext();
|
|
219
|
+
const requestContext = (0, import_request_context.getRequestContext)();
|
|
1830
220
|
if (!requestContext) {
|
|
1831
221
|
getCacheKeySpan.recordException(
|
|
1832
222
|
new Error("CacheHandler was called without a request context")
|
|
@@ -1857,7 +247,7 @@ var NetlifyCacheHandler = class {
|
|
|
1857
247
|
}
|
|
1858
248
|
captureRouteRevalidateAndRemoveFromObject(cacheValue) {
|
|
1859
249
|
const { revalidate, ...restOfRouteValue } = cacheValue;
|
|
1860
|
-
const requestContext = getRequestContext();
|
|
250
|
+
const requestContext = (0, import_request_context.getRequestContext)();
|
|
1861
251
|
if (requestContext) {
|
|
1862
252
|
requestContext.routeHandlerRevalidate = revalidate;
|
|
1863
253
|
}
|
|
@@ -1867,7 +257,7 @@ var NetlifyCacheHandler = class {
|
|
|
1867
257
|
if (!cacheValue) {
|
|
1868
258
|
return;
|
|
1869
259
|
}
|
|
1870
|
-
const requestContext = getRequestContext();
|
|
260
|
+
const requestContext = (0, import_request_context.getRequestContext)();
|
|
1871
261
|
if (!requestContext) {
|
|
1872
262
|
return;
|
|
1873
263
|
}
|
|
@@ -1924,7 +314,7 @@ var NetlifyCacheHandler = class {
|
|
|
1924
314
|
async get(...args) {
|
|
1925
315
|
return this.tracer.withActiveSpan("get cache key", async (span) => {
|
|
1926
316
|
const [key, ctx = {}] = args;
|
|
1927
|
-
getLogger().debug(`[NetlifyCacheHandler.get]: ${key}`);
|
|
317
|
+
(0, import_request_context.getLogger)().debug(`[NetlifyCacheHandler.get]: ${key}`);
|
|
1928
318
|
const blobKey = await this.encodeBlobKey(key);
|
|
1929
319
|
span.setAttributes({ key, blobKey });
|
|
1930
320
|
const blob = await this.tracer.withActiveSpan("blobStore.get", async (blobGetSpan) => {
|
|
@@ -1938,13 +328,13 @@ var NetlifyCacheHandler = class {
|
|
|
1938
328
|
return null;
|
|
1939
329
|
}
|
|
1940
330
|
const ttl = this.getTTL(blob);
|
|
1941
|
-
if (getRequestContext()?.isBackgroundRevalidation && typeof ttl === "number" && ttl < 0) {
|
|
331
|
+
if ((0, import_request_context.getRequestContext)()?.isBackgroundRevalidation && typeof ttl === "number" && ttl < 0) {
|
|
1942
332
|
span.addEvent("Discarding stale entry due to SWR background revalidation request", {
|
|
1943
333
|
key,
|
|
1944
334
|
blobKey,
|
|
1945
335
|
ttl
|
|
1946
336
|
});
|
|
1947
|
-
getLogger().withFields({
|
|
337
|
+
(0, import_request_context.getLogger)().withFields({
|
|
1948
338
|
ttl,
|
|
1949
339
|
key
|
|
1950
340
|
}).debug(
|
|
@@ -1983,14 +373,14 @@ var NetlifyCacheHandler = class {
|
|
|
1983
373
|
lastModified: blob.lastModified,
|
|
1984
374
|
value: {
|
|
1985
375
|
...valueWithoutRevalidate,
|
|
1986
|
-
body:
|
|
376
|
+
body: import_node_buffer.Buffer.from(valueWithoutRevalidate.body, "base64")
|
|
1987
377
|
}
|
|
1988
378
|
};
|
|
1989
379
|
}
|
|
1990
380
|
case "PAGE":
|
|
1991
381
|
case "PAGES": {
|
|
1992
382
|
const { revalidate, ...restOfPageValue } = blob.value;
|
|
1993
|
-
const requestContext = getRequestContext();
|
|
383
|
+
const requestContext = (0, import_request_context.getRequestContext)();
|
|
1994
384
|
if (requestContext) {
|
|
1995
385
|
requestContext.pageHandlerRevalidate = revalidate;
|
|
1996
386
|
}
|
|
@@ -2009,7 +399,7 @@ var NetlifyCacheHandler = class {
|
|
|
2009
399
|
lastModified: blob.lastModified,
|
|
2010
400
|
value: {
|
|
2011
401
|
...restOfPageValue,
|
|
2012
|
-
rscData: rscData ?
|
|
402
|
+
rscData: rscData ? import_node_buffer.Buffer.from(rscData, "base64") : void 0
|
|
2013
403
|
}
|
|
2014
404
|
};
|
|
2015
405
|
}
|
|
@@ -2019,30 +409,30 @@ var NetlifyCacheHandler = class {
|
|
|
2019
409
|
return null;
|
|
2020
410
|
});
|
|
2021
411
|
}
|
|
2022
|
-
transformToStorableObject(data,
|
|
412
|
+
transformToStorableObject(data, context) {
|
|
2023
413
|
if (!data) {
|
|
2024
414
|
return null;
|
|
2025
415
|
}
|
|
2026
|
-
if (isCachedRouteValue(data)) {
|
|
416
|
+
if ((0, import_cache_types.isCachedRouteValue)(data)) {
|
|
2027
417
|
return {
|
|
2028
418
|
...data,
|
|
2029
|
-
revalidate:
|
|
2030
|
-
cacheControl:
|
|
419
|
+
revalidate: context.revalidate ?? context.cacheControl?.revalidate,
|
|
420
|
+
cacheControl: context.cacheControl,
|
|
2031
421
|
body: data.body.toString("base64")
|
|
2032
422
|
};
|
|
2033
423
|
}
|
|
2034
|
-
if (isCachedPageValue(data)) {
|
|
424
|
+
if ((0, import_cache_types.isCachedPageValue)(data)) {
|
|
2035
425
|
return {
|
|
2036
426
|
...data,
|
|
2037
|
-
revalidate:
|
|
2038
|
-
cacheControl:
|
|
427
|
+
revalidate: context.revalidate ?? context.cacheControl?.revalidate,
|
|
428
|
+
cacheControl: context.cacheControl
|
|
2039
429
|
};
|
|
2040
430
|
}
|
|
2041
431
|
if (data?.kind === "APP_PAGE") {
|
|
2042
432
|
return {
|
|
2043
433
|
...data,
|
|
2044
|
-
revalidate:
|
|
2045
|
-
cacheControl:
|
|
434
|
+
revalidate: context.revalidate ?? context.cacheControl?.revalidate,
|
|
435
|
+
cacheControl: context.cacheControl,
|
|
2046
436
|
rscData: data.rscData?.toString("base64")
|
|
2047
437
|
};
|
|
2048
438
|
}
|
|
@@ -2050,29 +440,29 @@ var NetlifyCacheHandler = class {
|
|
|
2050
440
|
}
|
|
2051
441
|
async set(...args) {
|
|
2052
442
|
return this.tracer.withActiveSpan("set cache key", async (span) => {
|
|
2053
|
-
const [key, data,
|
|
443
|
+
const [key, data, context] = args;
|
|
2054
444
|
const blobKey = await this.encodeBlobKey(key);
|
|
2055
445
|
const lastModified = Date.now();
|
|
2056
446
|
span.setAttributes({ key, lastModified, blobKey });
|
|
2057
|
-
getLogger().debug(`[NetlifyCacheHandler.set]: ${key}`);
|
|
2058
|
-
const value = this.transformToStorableObject(data,
|
|
447
|
+
(0, import_request_context.getLogger)().debug(`[NetlifyCacheHandler.set]: ${key}`);
|
|
448
|
+
const value = this.transformToStorableObject(data, context);
|
|
2059
449
|
this.captureCacheTags(value, key);
|
|
2060
450
|
await this.blobStore.setJSON(blobKey, {
|
|
2061
451
|
lastModified,
|
|
2062
452
|
value
|
|
2063
453
|
});
|
|
2064
454
|
if (data?.kind === "PAGE" || data?.kind === "PAGES") {
|
|
2065
|
-
const requestContext = getRequestContext();
|
|
455
|
+
const requestContext = (0, import_request_context.getRequestContext)();
|
|
2066
456
|
if (requestContext?.didPagesRouterOnDemandRevalidate) {
|
|
2067
457
|
const tag = `_N_T_${key === "/index" ? "/" : encodeURI(key)}`;
|
|
2068
458
|
const tags = tag.split(/,|%2c/gi).filter(Boolean);
|
|
2069
459
|
if (tags.length === 0) {
|
|
2070
460
|
return;
|
|
2071
461
|
}
|
|
2072
|
-
getLogger().debug(`Purging CDN cache for: [${tag}]`);
|
|
462
|
+
(0, import_request_context.getLogger)().debug(`Purging CDN cache for: [${tag}]`);
|
|
2073
463
|
requestContext.trackBackgroundWork(
|
|
2074
464
|
purgeCache({ tags, userAgent: purgeCacheUserAgent }).catch((error) => {
|
|
2075
|
-
getLogger().withError(error).error(`[NetlifyCacheHandler]: Purging the cache for tag ${tag} failed`);
|
|
465
|
+
(0, import_request_context.getLogger)().withError(error).error(`[NetlifyCacheHandler]: Purging the cache for tag ${tag} failed`);
|
|
2076
466
|
})
|
|
2077
467
|
);
|
|
2078
468
|
}
|
|
@@ -2082,7 +472,7 @@ var NetlifyCacheHandler = class {
|
|
|
2082
472
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2083
473
|
async revalidateTag(tagOrTags, ...args) {
|
|
2084
474
|
const revalidateTagPromise = this.doRevalidateTag(tagOrTags, ...args);
|
|
2085
|
-
const requestContext = getRequestContext();
|
|
475
|
+
const requestContext = (0, import_request_context.getRequestContext)();
|
|
2086
476
|
if (requestContext) {
|
|
2087
477
|
requestContext.trackBackgroundWork(revalidateTagPromise);
|
|
2088
478
|
}
|
|
@@ -2090,7 +480,7 @@ var NetlifyCacheHandler = class {
|
|
|
2090
480
|
}
|
|
2091
481
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2092
482
|
async doRevalidateTag(tagOrTags, ...args) {
|
|
2093
|
-
getLogger().withFields({ tagOrTags, args }).debug("NetlifyCacheHandler.revalidateTag");
|
|
483
|
+
(0, import_request_context.getLogger)().withFields({ tagOrTags, args }).debug("NetlifyCacheHandler.revalidateTag");
|
|
2094
484
|
const tags = (Array.isArray(tagOrTags) ? tagOrTags : [tagOrTags]).flatMap((tag) => tag.split(/,|%2c/gi)).filter(Boolean);
|
|
2095
485
|
if (tags.length === 0) {
|
|
2096
486
|
return;
|
|
@@ -2103,12 +493,12 @@ var NetlifyCacheHandler = class {
|
|
|
2103
493
|
try {
|
|
2104
494
|
await this.blobStore.setJSON(await this.encodeBlobKey(tag), data);
|
|
2105
495
|
} catch (error) {
|
|
2106
|
-
getLogger().withError(error).log(`Failed to update tag manifest for ${tag}`);
|
|
496
|
+
(0, import_request_context.getLogger)().withError(error).log(`Failed to update tag manifest for ${tag}`);
|
|
2107
497
|
}
|
|
2108
498
|
})
|
|
2109
499
|
);
|
|
2110
500
|
await purgeCache({ tags, userAgent: purgeCacheUserAgent }).catch((error) => {
|
|
2111
|
-
getLogger().withError(error).error(`[NetlifyCacheHandler]: Purging the cache for tags ${tags.join(", ")} failed`);
|
|
501
|
+
(0, import_request_context.getLogger)().withError(error).error(`[NetlifyCacheHandler]: Purging the cache for tags ${tags.join(", ")} failed`);
|
|
2112
502
|
});
|
|
2113
503
|
}
|
|
2114
504
|
resetRequestCache() {
|