@netlify/plugin-nextjs 5.10.0-fetch-patch-logs → 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 +18 -39
- package/dist/run/config.js +1 -4
- package/dist/run/constants.js +7 -5
- package/dist/run/handlers/cache.cjs +44 -1655
- 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 -1624
- package/dist/run/regional-blob-store.cjs +37 -5
- 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-DLVROEVU.js +0 -144
- package/dist/esm-chunks/chunk-GFYWJNQR.js +0 -305
- package/dist/esm-chunks/chunk-HXVWGXWM.js +0 -218
- package/dist/esm-chunks/chunk-IJZEDP6B.js +0 -235
- package/dist/esm-chunks/chunk-JPTD4GEB.js +0 -309
- package/dist/esm-chunks/chunk-MKMK7FBF.js +0 -132
- package/dist/esm-chunks/chunk-RYJYZQ4X.js +0 -610
- 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-WHUPSPWV.js +0 -73
- package/dist/esm-chunks/chunk-XS27YRA5.js +0 -34
- package/dist/esm-chunks/chunk-ZENB67PD.js +0 -148
- package/dist/esm-chunks/chunk-ZSVHJNNY.js +0 -120
- package/dist/esm-chunks/next-LDOXJ7XH.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,1612 +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
|
-
console.log("Blob store fetch patched", fetchBeforeNextPatchedIt.__nextPatched);
|
|
805
|
-
return getDeployStore({
|
|
806
|
-
...args,
|
|
807
|
-
fetch: fetchBeforeNextPatchedIt,
|
|
808
|
-
region: process.env.USE_REGIONAL_BLOBS?.toUpperCase() === "TRUE" ? void 0 : "us-east-2"
|
|
809
|
-
});
|
|
810
|
-
};
|
|
811
|
-
|
|
812
|
-
// src/run/handlers/request-context.cts
|
|
813
|
-
var import_node_async_hooks = require("node:async_hooks");
|
|
814
|
-
|
|
815
|
-
// node_modules/@netlify/functions/dist/chunk-ATZ7N7EG.mjs
|
|
816
|
-
var import_process2 = require("process");
|
|
817
|
-
var systemLogTag;
|
|
818
|
-
var serializeError;
|
|
819
|
-
var LogLevel;
|
|
820
|
-
var SystemLogger;
|
|
821
|
-
var systemLogger;
|
|
822
|
-
var init_system_logger = __esm2({
|
|
823
|
-
"src/lib/system_logger.ts"() {
|
|
824
|
-
systemLogTag = "__nfSystemLog";
|
|
825
|
-
serializeError = (error) => {
|
|
826
|
-
const cause = error?.cause instanceof Error ? serializeError(error.cause) : error.cause;
|
|
827
|
-
return {
|
|
828
|
-
error: error.message,
|
|
829
|
-
error_cause: cause,
|
|
830
|
-
error_stack: error.stack
|
|
831
|
-
};
|
|
832
|
-
};
|
|
833
|
-
LogLevel = /* @__PURE__ */ ((LogLevel2) => {
|
|
834
|
-
LogLevel2[LogLevel2["Debug"] = 1] = "Debug";
|
|
835
|
-
LogLevel2[LogLevel2["Log"] = 2] = "Log";
|
|
836
|
-
LogLevel2[LogLevel2["Error"] = 3] = "Error";
|
|
837
|
-
return LogLevel2;
|
|
838
|
-
})(LogLevel || {});
|
|
839
|
-
SystemLogger = class _SystemLogger {
|
|
840
|
-
fields;
|
|
841
|
-
logLevel;
|
|
842
|
-
constructor(fields = {}, logLevel = 2) {
|
|
843
|
-
this.fields = fields;
|
|
844
|
-
this.logLevel = logLevel;
|
|
845
|
-
}
|
|
846
|
-
doLog(logger, message) {
|
|
847
|
-
if (import_process2.env.NETLIFY_DEV && !import_process2.env.NETLIFY_ENABLE_SYSTEM_LOGGING) {
|
|
848
|
-
return;
|
|
849
|
-
}
|
|
850
|
-
logger(systemLogTag, JSON.stringify({ msg: message, fields: this.fields }));
|
|
851
|
-
}
|
|
852
|
-
log(message) {
|
|
853
|
-
if (this.logLevel > 2) {
|
|
854
|
-
return;
|
|
855
|
-
}
|
|
856
|
-
this.doLog(console.log, message);
|
|
857
|
-
}
|
|
858
|
-
debug(message) {
|
|
859
|
-
if (this.logLevel > 1) {
|
|
860
|
-
return;
|
|
861
|
-
}
|
|
862
|
-
this.doLog(console.debug, message);
|
|
863
|
-
}
|
|
864
|
-
error(message) {
|
|
865
|
-
if (this.logLevel > 3) {
|
|
866
|
-
return;
|
|
867
|
-
}
|
|
868
|
-
this.doLog(console.error, message);
|
|
869
|
-
}
|
|
870
|
-
withLogLevel(level) {
|
|
871
|
-
return new _SystemLogger(this.fields, level);
|
|
872
|
-
}
|
|
873
|
-
withFields(fields) {
|
|
874
|
-
return new _SystemLogger(
|
|
875
|
-
{
|
|
876
|
-
...this.fields,
|
|
877
|
-
...fields
|
|
878
|
-
},
|
|
879
|
-
this.logLevel
|
|
880
|
-
);
|
|
881
|
-
}
|
|
882
|
-
withError(error) {
|
|
883
|
-
const fields = error instanceof Error ? serializeError(error) : { error };
|
|
884
|
-
return this.withFields(fields);
|
|
885
|
-
}
|
|
886
|
-
};
|
|
887
|
-
systemLogger = new SystemLogger();
|
|
888
|
-
}
|
|
889
|
-
});
|
|
890
|
-
|
|
891
|
-
// node_modules/@netlify/functions/dist/chunk-7ANA32NV.mjs
|
|
892
|
-
var init_internal = __esm2({
|
|
893
|
-
"src/internal.ts"() {
|
|
894
|
-
init_system_logger();
|
|
895
|
-
}
|
|
896
|
-
});
|
|
897
|
-
|
|
898
|
-
// node_modules/@netlify/functions/dist/internal.mjs
|
|
899
|
-
init_internal();
|
|
900
|
-
|
|
901
|
-
// src/run/handlers/request-context.cts
|
|
902
|
-
var REQUEST_CONTEXT_GLOBAL_KEY = Symbol.for("nf-request-context-async-local-storage");
|
|
903
|
-
var requestContextAsyncLocalStorage;
|
|
904
|
-
function getRequestContextAsyncLocalStorage() {
|
|
905
|
-
if (requestContextAsyncLocalStorage) {
|
|
906
|
-
return requestContextAsyncLocalStorage;
|
|
907
|
-
}
|
|
908
|
-
const extendedGlobalThis = globalThis;
|
|
909
|
-
if (extendedGlobalThis[REQUEST_CONTEXT_GLOBAL_KEY]) {
|
|
910
|
-
return extendedGlobalThis[REQUEST_CONTEXT_GLOBAL_KEY];
|
|
911
|
-
}
|
|
912
|
-
const storage = new import_node_async_hooks.AsyncLocalStorage();
|
|
913
|
-
requestContextAsyncLocalStorage = storage;
|
|
914
|
-
extendedGlobalThis[REQUEST_CONTEXT_GLOBAL_KEY] = storage;
|
|
915
|
-
return storage;
|
|
916
|
-
}
|
|
917
|
-
var getRequestContext = () => getRequestContextAsyncLocalStorage().getStore();
|
|
918
|
-
function getLogger() {
|
|
919
|
-
return getRequestContext()?.logger ?? systemLogger;
|
|
920
|
-
}
|
|
921
|
-
|
|
922
|
-
// node_modules/@opentelemetry/api/build/esm/platform/node/globalThis.js
|
|
923
|
-
var _globalThis = typeof globalThis === "object" ? globalThis : global;
|
|
924
|
-
|
|
925
|
-
// node_modules/@opentelemetry/api/build/esm/version.js
|
|
926
|
-
var VERSION = "1.8.0";
|
|
927
|
-
|
|
928
|
-
// node_modules/@opentelemetry/api/build/esm/internal/semver.js
|
|
929
|
-
var re = /^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;
|
|
930
|
-
function _makeCompatibilityCheck(ownVersion) {
|
|
931
|
-
var acceptedVersions = /* @__PURE__ */ new Set([ownVersion]);
|
|
932
|
-
var rejectedVersions = /* @__PURE__ */ new Set();
|
|
933
|
-
var myVersionMatch = ownVersion.match(re);
|
|
934
|
-
if (!myVersionMatch) {
|
|
935
|
-
return function() {
|
|
936
|
-
return false;
|
|
937
|
-
};
|
|
938
|
-
}
|
|
939
|
-
var ownVersionParsed = {
|
|
940
|
-
major: +myVersionMatch[1],
|
|
941
|
-
minor: +myVersionMatch[2],
|
|
942
|
-
patch: +myVersionMatch[3],
|
|
943
|
-
prerelease: myVersionMatch[4]
|
|
944
|
-
};
|
|
945
|
-
if (ownVersionParsed.prerelease != null) {
|
|
946
|
-
return function isExactmatch(globalVersion) {
|
|
947
|
-
return globalVersion === ownVersion;
|
|
948
|
-
};
|
|
949
|
-
}
|
|
950
|
-
function _reject(v) {
|
|
951
|
-
rejectedVersions.add(v);
|
|
952
|
-
return false;
|
|
953
|
-
}
|
|
954
|
-
function _accept(v) {
|
|
955
|
-
acceptedVersions.add(v);
|
|
956
|
-
return true;
|
|
957
|
-
}
|
|
958
|
-
return function isCompatible2(globalVersion) {
|
|
959
|
-
if (acceptedVersions.has(globalVersion)) {
|
|
960
|
-
return true;
|
|
961
|
-
}
|
|
962
|
-
if (rejectedVersions.has(globalVersion)) {
|
|
963
|
-
return false;
|
|
964
|
-
}
|
|
965
|
-
var globalVersionMatch = globalVersion.match(re);
|
|
966
|
-
if (!globalVersionMatch) {
|
|
967
|
-
return _reject(globalVersion);
|
|
968
|
-
}
|
|
969
|
-
var globalVersionParsed = {
|
|
970
|
-
major: +globalVersionMatch[1],
|
|
971
|
-
minor: +globalVersionMatch[2],
|
|
972
|
-
patch: +globalVersionMatch[3],
|
|
973
|
-
prerelease: globalVersionMatch[4]
|
|
974
|
-
};
|
|
975
|
-
if (globalVersionParsed.prerelease != null) {
|
|
976
|
-
return _reject(globalVersion);
|
|
977
|
-
}
|
|
978
|
-
if (ownVersionParsed.major !== globalVersionParsed.major) {
|
|
979
|
-
return _reject(globalVersion);
|
|
980
|
-
}
|
|
981
|
-
if (ownVersionParsed.major === 0) {
|
|
982
|
-
if (ownVersionParsed.minor === globalVersionParsed.minor && ownVersionParsed.patch <= globalVersionParsed.patch) {
|
|
983
|
-
return _accept(globalVersion);
|
|
984
|
-
}
|
|
985
|
-
return _reject(globalVersion);
|
|
986
|
-
}
|
|
987
|
-
if (ownVersionParsed.minor <= globalVersionParsed.minor) {
|
|
988
|
-
return _accept(globalVersion);
|
|
989
|
-
}
|
|
990
|
-
return _reject(globalVersion);
|
|
991
|
-
};
|
|
992
|
-
}
|
|
993
|
-
var isCompatible = _makeCompatibilityCheck(VERSION);
|
|
994
|
-
|
|
995
|
-
// node_modules/@opentelemetry/api/build/esm/internal/global-utils.js
|
|
996
|
-
var major = VERSION.split(".")[0];
|
|
997
|
-
var GLOBAL_OPENTELEMETRY_API_KEY = Symbol.for("opentelemetry.js.api." + major);
|
|
998
|
-
var _global = _globalThis;
|
|
999
|
-
function registerGlobal(type, instance, diag, allowOverride) {
|
|
1000
|
-
var _a;
|
|
1001
|
-
if (allowOverride === void 0) {
|
|
1002
|
-
allowOverride = false;
|
|
1003
|
-
}
|
|
1004
|
-
var api = _global[GLOBAL_OPENTELEMETRY_API_KEY] = (_a = _global[GLOBAL_OPENTELEMETRY_API_KEY]) !== null && _a !== void 0 ? _a : {
|
|
1005
|
-
version: VERSION
|
|
1006
|
-
};
|
|
1007
|
-
if (!allowOverride && api[type]) {
|
|
1008
|
-
var err = new Error("@opentelemetry/api: Attempted duplicate registration of API: " + type);
|
|
1009
|
-
diag.error(err.stack || err.message);
|
|
1010
|
-
return false;
|
|
1011
|
-
}
|
|
1012
|
-
if (api.version !== VERSION) {
|
|
1013
|
-
var err = new Error("@opentelemetry/api: Registration of version v" + api.version + " for " + type + " does not match previously registered API v" + VERSION);
|
|
1014
|
-
diag.error(err.stack || err.message);
|
|
1015
|
-
return false;
|
|
1016
|
-
}
|
|
1017
|
-
api[type] = instance;
|
|
1018
|
-
diag.debug("@opentelemetry/api: Registered a global for " + type + " v" + VERSION + ".");
|
|
1019
|
-
return true;
|
|
1020
|
-
}
|
|
1021
|
-
function getGlobal(type) {
|
|
1022
|
-
var _a, _b;
|
|
1023
|
-
var globalVersion = (_a = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _a === void 0 ? void 0 : _a.version;
|
|
1024
|
-
if (!globalVersion || !isCompatible(globalVersion)) {
|
|
1025
|
-
return;
|
|
1026
|
-
}
|
|
1027
|
-
return (_b = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _b === void 0 ? void 0 : _b[type];
|
|
1028
|
-
}
|
|
1029
|
-
function unregisterGlobal(type, diag) {
|
|
1030
|
-
diag.debug("@opentelemetry/api: Unregistering a global for " + type + " v" + VERSION + ".");
|
|
1031
|
-
var api = _global[GLOBAL_OPENTELEMETRY_API_KEY];
|
|
1032
|
-
if (api) {
|
|
1033
|
-
delete api[type];
|
|
1034
|
-
}
|
|
1035
|
-
}
|
|
1036
|
-
|
|
1037
|
-
// node_modules/@opentelemetry/api/build/esm/diag/ComponentLogger.js
|
|
1038
|
-
var __read = function(o, n) {
|
|
1039
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
1040
|
-
if (!m) return o;
|
|
1041
|
-
var i = m.call(o), r, ar = [], e;
|
|
1042
|
-
try {
|
|
1043
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
1044
|
-
} catch (error) {
|
|
1045
|
-
e = { error };
|
|
1046
|
-
} finally {
|
|
1047
|
-
try {
|
|
1048
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
1049
|
-
} finally {
|
|
1050
|
-
if (e) throw e.error;
|
|
1051
|
-
}
|
|
1052
|
-
}
|
|
1053
|
-
return ar;
|
|
1054
|
-
};
|
|
1055
|
-
var __spreadArray = function(to, from, pack) {
|
|
1056
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
1057
|
-
if (ar || !(i in from)) {
|
|
1058
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
1059
|
-
ar[i] = from[i];
|
|
1060
|
-
}
|
|
1061
|
-
}
|
|
1062
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
1063
|
-
};
|
|
1064
|
-
var DiagComponentLogger = (
|
|
1065
|
-
/** @class */
|
|
1066
|
-
function() {
|
|
1067
|
-
function DiagComponentLogger2(props) {
|
|
1068
|
-
this._namespace = props.namespace || "DiagComponentLogger";
|
|
1069
|
-
}
|
|
1070
|
-
DiagComponentLogger2.prototype.debug = function() {
|
|
1071
|
-
var args = [];
|
|
1072
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1073
|
-
args[_i] = arguments[_i];
|
|
1074
|
-
}
|
|
1075
|
-
return logProxy("debug", this._namespace, args);
|
|
1076
|
-
};
|
|
1077
|
-
DiagComponentLogger2.prototype.error = function() {
|
|
1078
|
-
var args = [];
|
|
1079
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1080
|
-
args[_i] = arguments[_i];
|
|
1081
|
-
}
|
|
1082
|
-
return logProxy("error", this._namespace, args);
|
|
1083
|
-
};
|
|
1084
|
-
DiagComponentLogger2.prototype.info = function() {
|
|
1085
|
-
var args = [];
|
|
1086
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1087
|
-
args[_i] = arguments[_i];
|
|
1088
|
-
}
|
|
1089
|
-
return logProxy("info", this._namespace, args);
|
|
1090
|
-
};
|
|
1091
|
-
DiagComponentLogger2.prototype.warn = function() {
|
|
1092
|
-
var args = [];
|
|
1093
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1094
|
-
args[_i] = arguments[_i];
|
|
1095
|
-
}
|
|
1096
|
-
return logProxy("warn", this._namespace, args);
|
|
1097
|
-
};
|
|
1098
|
-
DiagComponentLogger2.prototype.verbose = function() {
|
|
1099
|
-
var args = [];
|
|
1100
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1101
|
-
args[_i] = arguments[_i];
|
|
1102
|
-
}
|
|
1103
|
-
return logProxy("verbose", this._namespace, args);
|
|
1104
|
-
};
|
|
1105
|
-
return DiagComponentLogger2;
|
|
1106
|
-
}()
|
|
1107
|
-
);
|
|
1108
|
-
function logProxy(funcName, namespace, args) {
|
|
1109
|
-
var logger = getGlobal("diag");
|
|
1110
|
-
if (!logger) {
|
|
1111
|
-
return;
|
|
1112
|
-
}
|
|
1113
|
-
args.unshift(namespace);
|
|
1114
|
-
return logger[funcName].apply(logger, __spreadArray([], __read(args), false));
|
|
1115
|
-
}
|
|
1116
|
-
|
|
1117
|
-
// node_modules/@opentelemetry/api/build/esm/diag/types.js
|
|
1118
|
-
var DiagLogLevel;
|
|
1119
|
-
(function(DiagLogLevel2) {
|
|
1120
|
-
DiagLogLevel2[DiagLogLevel2["NONE"] = 0] = "NONE";
|
|
1121
|
-
DiagLogLevel2[DiagLogLevel2["ERROR"] = 30] = "ERROR";
|
|
1122
|
-
DiagLogLevel2[DiagLogLevel2["WARN"] = 50] = "WARN";
|
|
1123
|
-
DiagLogLevel2[DiagLogLevel2["INFO"] = 60] = "INFO";
|
|
1124
|
-
DiagLogLevel2[DiagLogLevel2["DEBUG"] = 70] = "DEBUG";
|
|
1125
|
-
DiagLogLevel2[DiagLogLevel2["VERBOSE"] = 80] = "VERBOSE";
|
|
1126
|
-
DiagLogLevel2[DiagLogLevel2["ALL"] = 9999] = "ALL";
|
|
1127
|
-
})(DiagLogLevel || (DiagLogLevel = {}));
|
|
1128
|
-
|
|
1129
|
-
// node_modules/@opentelemetry/api/build/esm/diag/internal/logLevelLogger.js
|
|
1130
|
-
function createLogLevelDiagLogger(maxLevel, logger) {
|
|
1131
|
-
if (maxLevel < DiagLogLevel.NONE) {
|
|
1132
|
-
maxLevel = DiagLogLevel.NONE;
|
|
1133
|
-
} else if (maxLevel > DiagLogLevel.ALL) {
|
|
1134
|
-
maxLevel = DiagLogLevel.ALL;
|
|
1135
|
-
}
|
|
1136
|
-
logger = logger || {};
|
|
1137
|
-
function _filterFunc(funcName, theLevel) {
|
|
1138
|
-
var theFunc = logger[funcName];
|
|
1139
|
-
if (typeof theFunc === "function" && maxLevel >= theLevel) {
|
|
1140
|
-
return theFunc.bind(logger);
|
|
1141
|
-
}
|
|
1142
|
-
return function() {
|
|
1143
|
-
};
|
|
1144
|
-
}
|
|
1145
|
-
return {
|
|
1146
|
-
error: _filterFunc("error", DiagLogLevel.ERROR),
|
|
1147
|
-
warn: _filterFunc("warn", DiagLogLevel.WARN),
|
|
1148
|
-
info: _filterFunc("info", DiagLogLevel.INFO),
|
|
1149
|
-
debug: _filterFunc("debug", DiagLogLevel.DEBUG),
|
|
1150
|
-
verbose: _filterFunc("verbose", DiagLogLevel.VERBOSE)
|
|
1151
|
-
};
|
|
1152
|
-
}
|
|
1153
|
-
|
|
1154
|
-
// node_modules/@opentelemetry/api/build/esm/api/diag.js
|
|
1155
|
-
var __read2 = function(o, n) {
|
|
1156
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
1157
|
-
if (!m) return o;
|
|
1158
|
-
var i = m.call(o), r, ar = [], e;
|
|
1159
|
-
try {
|
|
1160
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
1161
|
-
} catch (error) {
|
|
1162
|
-
e = { error };
|
|
1163
|
-
} finally {
|
|
1164
|
-
try {
|
|
1165
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
1166
|
-
} finally {
|
|
1167
|
-
if (e) throw e.error;
|
|
1168
|
-
}
|
|
1169
|
-
}
|
|
1170
|
-
return ar;
|
|
1171
|
-
};
|
|
1172
|
-
var __spreadArray2 = function(to, from, pack) {
|
|
1173
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
1174
|
-
if (ar || !(i in from)) {
|
|
1175
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
1176
|
-
ar[i] = from[i];
|
|
1177
|
-
}
|
|
1178
|
-
}
|
|
1179
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
1180
|
-
};
|
|
1181
|
-
var API_NAME = "diag";
|
|
1182
|
-
var DiagAPI = (
|
|
1183
|
-
/** @class */
|
|
1184
|
-
function() {
|
|
1185
|
-
function DiagAPI2() {
|
|
1186
|
-
function _logProxy(funcName) {
|
|
1187
|
-
return function() {
|
|
1188
|
-
var args = [];
|
|
1189
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1190
|
-
args[_i] = arguments[_i];
|
|
1191
|
-
}
|
|
1192
|
-
var logger = getGlobal("diag");
|
|
1193
|
-
if (!logger)
|
|
1194
|
-
return;
|
|
1195
|
-
return logger[funcName].apply(logger, __spreadArray2([], __read2(args), false));
|
|
1196
|
-
};
|
|
1197
|
-
}
|
|
1198
|
-
var self = this;
|
|
1199
|
-
var setLogger = function(logger, optionsOrLogLevel) {
|
|
1200
|
-
var _a, _b, _c;
|
|
1201
|
-
if (optionsOrLogLevel === void 0) {
|
|
1202
|
-
optionsOrLogLevel = { logLevel: DiagLogLevel.INFO };
|
|
1203
|
-
}
|
|
1204
|
-
if (logger === self) {
|
|
1205
|
-
var err = new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
|
|
1206
|
-
self.error((_a = err.stack) !== null && _a !== void 0 ? _a : err.message);
|
|
1207
|
-
return false;
|
|
1208
|
-
}
|
|
1209
|
-
if (typeof optionsOrLogLevel === "number") {
|
|
1210
|
-
optionsOrLogLevel = {
|
|
1211
|
-
logLevel: optionsOrLogLevel
|
|
1212
|
-
};
|
|
1213
|
-
}
|
|
1214
|
-
var oldLogger = getGlobal("diag");
|
|
1215
|
-
var newLogger = createLogLevelDiagLogger((_b = optionsOrLogLevel.logLevel) !== null && _b !== void 0 ? _b : DiagLogLevel.INFO, logger);
|
|
1216
|
-
if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
|
|
1217
|
-
var stack = (_c = new Error().stack) !== null && _c !== void 0 ? _c : "<failed to generate stacktrace>";
|
|
1218
|
-
oldLogger.warn("Current logger will be overwritten from " + stack);
|
|
1219
|
-
newLogger.warn("Current logger will overwrite one already registered from " + stack);
|
|
1220
|
-
}
|
|
1221
|
-
return registerGlobal("diag", newLogger, self, true);
|
|
1222
|
-
};
|
|
1223
|
-
self.setLogger = setLogger;
|
|
1224
|
-
self.disable = function() {
|
|
1225
|
-
unregisterGlobal(API_NAME, self);
|
|
1226
|
-
};
|
|
1227
|
-
self.createComponentLogger = function(options) {
|
|
1228
|
-
return new DiagComponentLogger(options);
|
|
1229
|
-
};
|
|
1230
|
-
self.verbose = _logProxy("verbose");
|
|
1231
|
-
self.debug = _logProxy("debug");
|
|
1232
|
-
self.info = _logProxy("info");
|
|
1233
|
-
self.warn = _logProxy("warn");
|
|
1234
|
-
self.error = _logProxy("error");
|
|
1235
|
-
}
|
|
1236
|
-
DiagAPI2.instance = function() {
|
|
1237
|
-
if (!this._instance) {
|
|
1238
|
-
this._instance = new DiagAPI2();
|
|
1239
|
-
}
|
|
1240
|
-
return this._instance;
|
|
1241
|
-
};
|
|
1242
|
-
return DiagAPI2;
|
|
1243
|
-
}()
|
|
1244
|
-
);
|
|
1245
|
-
|
|
1246
|
-
// node_modules/@opentelemetry/api/build/esm/context/context.js
|
|
1247
|
-
function createContextKey(description) {
|
|
1248
|
-
return Symbol.for(description);
|
|
1249
|
-
}
|
|
1250
|
-
var BaseContext = (
|
|
1251
|
-
/** @class */
|
|
1252
|
-
/* @__PURE__ */ function() {
|
|
1253
|
-
function BaseContext2(parentContext) {
|
|
1254
|
-
var self = this;
|
|
1255
|
-
self._currentContext = parentContext ? new Map(parentContext) : /* @__PURE__ */ new Map();
|
|
1256
|
-
self.getValue = function(key) {
|
|
1257
|
-
return self._currentContext.get(key);
|
|
1258
|
-
};
|
|
1259
|
-
self.setValue = function(key, value) {
|
|
1260
|
-
var context2 = new BaseContext2(self._currentContext);
|
|
1261
|
-
context2._currentContext.set(key, value);
|
|
1262
|
-
return context2;
|
|
1263
|
-
};
|
|
1264
|
-
self.deleteValue = function(key) {
|
|
1265
|
-
var context2 = new BaseContext2(self._currentContext);
|
|
1266
|
-
context2._currentContext.delete(key);
|
|
1267
|
-
return context2;
|
|
1268
|
-
};
|
|
1269
|
-
}
|
|
1270
|
-
return BaseContext2;
|
|
1271
|
-
}()
|
|
1272
|
-
);
|
|
1273
|
-
var ROOT_CONTEXT = new BaseContext();
|
|
1274
|
-
|
|
1275
|
-
// node_modules/@opentelemetry/api/build/esm/context/NoopContextManager.js
|
|
1276
|
-
var __read3 = function(o, n) {
|
|
1277
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
1278
|
-
if (!m) return o;
|
|
1279
|
-
var i = m.call(o), r, ar = [], e;
|
|
1280
|
-
try {
|
|
1281
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
1282
|
-
} catch (error) {
|
|
1283
|
-
e = { error };
|
|
1284
|
-
} finally {
|
|
1285
|
-
try {
|
|
1286
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
1287
|
-
} finally {
|
|
1288
|
-
if (e) throw e.error;
|
|
1289
|
-
}
|
|
1290
|
-
}
|
|
1291
|
-
return ar;
|
|
1292
|
-
};
|
|
1293
|
-
var __spreadArray3 = function(to, from, pack) {
|
|
1294
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
1295
|
-
if (ar || !(i in from)) {
|
|
1296
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
1297
|
-
ar[i] = from[i];
|
|
1298
|
-
}
|
|
1299
|
-
}
|
|
1300
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
1301
|
-
};
|
|
1302
|
-
var NoopContextManager = (
|
|
1303
|
-
/** @class */
|
|
1304
|
-
function() {
|
|
1305
|
-
function NoopContextManager2() {
|
|
1306
|
-
}
|
|
1307
|
-
NoopContextManager2.prototype.active = function() {
|
|
1308
|
-
return ROOT_CONTEXT;
|
|
1309
|
-
};
|
|
1310
|
-
NoopContextManager2.prototype.with = function(_context, fn, thisArg) {
|
|
1311
|
-
var args = [];
|
|
1312
|
-
for (var _i = 3; _i < arguments.length; _i++) {
|
|
1313
|
-
args[_i - 3] = arguments[_i];
|
|
1314
|
-
}
|
|
1315
|
-
return fn.call.apply(fn, __spreadArray3([thisArg], __read3(args), false));
|
|
1316
|
-
};
|
|
1317
|
-
NoopContextManager2.prototype.bind = function(_context, target) {
|
|
1318
|
-
return target;
|
|
1319
|
-
};
|
|
1320
|
-
NoopContextManager2.prototype.enable = function() {
|
|
1321
|
-
return this;
|
|
1322
|
-
};
|
|
1323
|
-
NoopContextManager2.prototype.disable = function() {
|
|
1324
|
-
return this;
|
|
1325
|
-
};
|
|
1326
|
-
return NoopContextManager2;
|
|
1327
|
-
}()
|
|
1328
|
-
);
|
|
1329
|
-
|
|
1330
|
-
// node_modules/@opentelemetry/api/build/esm/api/context.js
|
|
1331
|
-
var __read4 = function(o, n) {
|
|
1332
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
1333
|
-
if (!m) return o;
|
|
1334
|
-
var i = m.call(o), r, ar = [], e;
|
|
1335
|
-
try {
|
|
1336
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
1337
|
-
} catch (error) {
|
|
1338
|
-
e = { error };
|
|
1339
|
-
} finally {
|
|
1340
|
-
try {
|
|
1341
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
1342
|
-
} finally {
|
|
1343
|
-
if (e) throw e.error;
|
|
1344
|
-
}
|
|
1345
|
-
}
|
|
1346
|
-
return ar;
|
|
1347
|
-
};
|
|
1348
|
-
var __spreadArray4 = function(to, from, pack) {
|
|
1349
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
1350
|
-
if (ar || !(i in from)) {
|
|
1351
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
1352
|
-
ar[i] = from[i];
|
|
1353
|
-
}
|
|
1354
|
-
}
|
|
1355
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
1356
|
-
};
|
|
1357
|
-
var API_NAME2 = "context";
|
|
1358
|
-
var NOOP_CONTEXT_MANAGER = new NoopContextManager();
|
|
1359
|
-
var ContextAPI = (
|
|
1360
|
-
/** @class */
|
|
1361
|
-
function() {
|
|
1362
|
-
function ContextAPI2() {
|
|
1363
|
-
}
|
|
1364
|
-
ContextAPI2.getInstance = function() {
|
|
1365
|
-
if (!this._instance) {
|
|
1366
|
-
this._instance = new ContextAPI2();
|
|
1367
|
-
}
|
|
1368
|
-
return this._instance;
|
|
1369
|
-
};
|
|
1370
|
-
ContextAPI2.prototype.setGlobalContextManager = function(contextManager) {
|
|
1371
|
-
return registerGlobal(API_NAME2, contextManager, DiagAPI.instance());
|
|
1372
|
-
};
|
|
1373
|
-
ContextAPI2.prototype.active = function() {
|
|
1374
|
-
return this._getContextManager().active();
|
|
1375
|
-
};
|
|
1376
|
-
ContextAPI2.prototype.with = function(context2, fn, thisArg) {
|
|
1377
|
-
var _a;
|
|
1378
|
-
var args = [];
|
|
1379
|
-
for (var _i = 3; _i < arguments.length; _i++) {
|
|
1380
|
-
args[_i - 3] = arguments[_i];
|
|
1381
|
-
}
|
|
1382
|
-
return (_a = this._getContextManager()).with.apply(_a, __spreadArray4([context2, fn, thisArg], __read4(args), false));
|
|
1383
|
-
};
|
|
1384
|
-
ContextAPI2.prototype.bind = function(context2, target) {
|
|
1385
|
-
return this._getContextManager().bind(context2, target);
|
|
1386
|
-
};
|
|
1387
|
-
ContextAPI2.prototype._getContextManager = function() {
|
|
1388
|
-
return getGlobal(API_NAME2) || NOOP_CONTEXT_MANAGER;
|
|
1389
|
-
};
|
|
1390
|
-
ContextAPI2.prototype.disable = function() {
|
|
1391
|
-
this._getContextManager().disable();
|
|
1392
|
-
unregisterGlobal(API_NAME2, DiagAPI.instance());
|
|
1393
|
-
};
|
|
1394
|
-
return ContextAPI2;
|
|
1395
|
-
}()
|
|
1396
|
-
);
|
|
1397
|
-
|
|
1398
|
-
// node_modules/@opentelemetry/api/build/esm/trace/trace_flags.js
|
|
1399
|
-
var TraceFlags;
|
|
1400
|
-
(function(TraceFlags2) {
|
|
1401
|
-
TraceFlags2[TraceFlags2["NONE"] = 0] = "NONE";
|
|
1402
|
-
TraceFlags2[TraceFlags2["SAMPLED"] = 1] = "SAMPLED";
|
|
1403
|
-
})(TraceFlags || (TraceFlags = {}));
|
|
1404
|
-
|
|
1405
|
-
// node_modules/@opentelemetry/api/build/esm/trace/invalid-span-constants.js
|
|
1406
|
-
var INVALID_SPANID = "0000000000000000";
|
|
1407
|
-
var INVALID_TRACEID = "00000000000000000000000000000000";
|
|
1408
|
-
var INVALID_SPAN_CONTEXT = {
|
|
1409
|
-
traceId: INVALID_TRACEID,
|
|
1410
|
-
spanId: INVALID_SPANID,
|
|
1411
|
-
traceFlags: TraceFlags.NONE
|
|
1412
|
-
};
|
|
1413
|
-
|
|
1414
|
-
// node_modules/@opentelemetry/api/build/esm/trace/NonRecordingSpan.js
|
|
1415
|
-
var NonRecordingSpan = (
|
|
1416
|
-
/** @class */
|
|
1417
|
-
function() {
|
|
1418
|
-
function NonRecordingSpan2(_spanContext) {
|
|
1419
|
-
if (_spanContext === void 0) {
|
|
1420
|
-
_spanContext = INVALID_SPAN_CONTEXT;
|
|
1421
|
-
}
|
|
1422
|
-
this._spanContext = _spanContext;
|
|
1423
|
-
}
|
|
1424
|
-
NonRecordingSpan2.prototype.spanContext = function() {
|
|
1425
|
-
return this._spanContext;
|
|
1426
|
-
};
|
|
1427
|
-
NonRecordingSpan2.prototype.setAttribute = function(_key, _value) {
|
|
1428
|
-
return this;
|
|
1429
|
-
};
|
|
1430
|
-
NonRecordingSpan2.prototype.setAttributes = function(_attributes) {
|
|
1431
|
-
return this;
|
|
1432
|
-
};
|
|
1433
|
-
NonRecordingSpan2.prototype.addEvent = function(_name, _attributes) {
|
|
1434
|
-
return this;
|
|
1435
|
-
};
|
|
1436
|
-
NonRecordingSpan2.prototype.setStatus = function(_status) {
|
|
1437
|
-
return this;
|
|
1438
|
-
};
|
|
1439
|
-
NonRecordingSpan2.prototype.updateName = function(_name) {
|
|
1440
|
-
return this;
|
|
1441
|
-
};
|
|
1442
|
-
NonRecordingSpan2.prototype.end = function(_endTime) {
|
|
1443
|
-
};
|
|
1444
|
-
NonRecordingSpan2.prototype.isRecording = function() {
|
|
1445
|
-
return false;
|
|
1446
|
-
};
|
|
1447
|
-
NonRecordingSpan2.prototype.recordException = function(_exception, _time) {
|
|
1448
|
-
};
|
|
1449
|
-
return NonRecordingSpan2;
|
|
1450
|
-
}()
|
|
1451
|
-
);
|
|
1452
|
-
|
|
1453
|
-
// node_modules/@opentelemetry/api/build/esm/trace/context-utils.js
|
|
1454
|
-
var SPAN_KEY = createContextKey("OpenTelemetry Context Key SPAN");
|
|
1455
|
-
function getSpan(context2) {
|
|
1456
|
-
return context2.getValue(SPAN_KEY) || void 0;
|
|
1457
|
-
}
|
|
1458
|
-
function getActiveSpan() {
|
|
1459
|
-
return getSpan(ContextAPI.getInstance().active());
|
|
1460
|
-
}
|
|
1461
|
-
function setSpan(context2, span) {
|
|
1462
|
-
return context2.setValue(SPAN_KEY, span);
|
|
1463
|
-
}
|
|
1464
|
-
function deleteSpan(context2) {
|
|
1465
|
-
return context2.deleteValue(SPAN_KEY);
|
|
1466
|
-
}
|
|
1467
|
-
function setSpanContext(context2, spanContext) {
|
|
1468
|
-
return setSpan(context2, new NonRecordingSpan(spanContext));
|
|
1469
|
-
}
|
|
1470
|
-
function getSpanContext(context2) {
|
|
1471
|
-
var _a;
|
|
1472
|
-
return (_a = getSpan(context2)) === null || _a === void 0 ? void 0 : _a.spanContext();
|
|
1473
|
-
}
|
|
1474
|
-
|
|
1475
|
-
// node_modules/@opentelemetry/api/build/esm/trace/spancontext-utils.js
|
|
1476
|
-
var VALID_TRACEID_REGEX = /^([0-9a-f]{32})$/i;
|
|
1477
|
-
var VALID_SPANID_REGEX = /^[0-9a-f]{16}$/i;
|
|
1478
|
-
function isValidTraceId(traceId) {
|
|
1479
|
-
return VALID_TRACEID_REGEX.test(traceId) && traceId !== INVALID_TRACEID;
|
|
1480
|
-
}
|
|
1481
|
-
function isValidSpanId(spanId) {
|
|
1482
|
-
return VALID_SPANID_REGEX.test(spanId) && spanId !== INVALID_SPANID;
|
|
1483
|
-
}
|
|
1484
|
-
function isSpanContextValid(spanContext) {
|
|
1485
|
-
return isValidTraceId(spanContext.traceId) && isValidSpanId(spanContext.spanId);
|
|
1486
|
-
}
|
|
1487
|
-
function wrapSpanContext(spanContext) {
|
|
1488
|
-
return new NonRecordingSpan(spanContext);
|
|
1489
|
-
}
|
|
1490
|
-
|
|
1491
|
-
// node_modules/@opentelemetry/api/build/esm/trace/NoopTracer.js
|
|
1492
|
-
var contextApi = ContextAPI.getInstance();
|
|
1493
|
-
var NoopTracer = (
|
|
1494
|
-
/** @class */
|
|
1495
|
-
function() {
|
|
1496
|
-
function NoopTracer2() {
|
|
1497
|
-
}
|
|
1498
|
-
NoopTracer2.prototype.startSpan = function(name2, options, context2) {
|
|
1499
|
-
if (context2 === void 0) {
|
|
1500
|
-
context2 = contextApi.active();
|
|
1501
|
-
}
|
|
1502
|
-
var root = Boolean(options === null || options === void 0 ? void 0 : options.root);
|
|
1503
|
-
if (root) {
|
|
1504
|
-
return new NonRecordingSpan();
|
|
1505
|
-
}
|
|
1506
|
-
var parentFromContext = context2 && getSpanContext(context2);
|
|
1507
|
-
if (isSpanContext(parentFromContext) && isSpanContextValid(parentFromContext)) {
|
|
1508
|
-
return new NonRecordingSpan(parentFromContext);
|
|
1509
|
-
} else {
|
|
1510
|
-
return new NonRecordingSpan();
|
|
1511
|
-
}
|
|
1512
|
-
};
|
|
1513
|
-
NoopTracer2.prototype.startActiveSpan = function(name2, arg2, arg3, arg4) {
|
|
1514
|
-
var opts;
|
|
1515
|
-
var ctx;
|
|
1516
|
-
var fn;
|
|
1517
|
-
if (arguments.length < 2) {
|
|
1518
|
-
return;
|
|
1519
|
-
} else if (arguments.length === 2) {
|
|
1520
|
-
fn = arg2;
|
|
1521
|
-
} else if (arguments.length === 3) {
|
|
1522
|
-
opts = arg2;
|
|
1523
|
-
fn = arg3;
|
|
1524
|
-
} else {
|
|
1525
|
-
opts = arg2;
|
|
1526
|
-
ctx = arg3;
|
|
1527
|
-
fn = arg4;
|
|
1528
|
-
}
|
|
1529
|
-
var parentContext = ctx !== null && ctx !== void 0 ? ctx : contextApi.active();
|
|
1530
|
-
var span = this.startSpan(name2, opts, parentContext);
|
|
1531
|
-
var contextWithSpanSet = setSpan(parentContext, span);
|
|
1532
|
-
return contextApi.with(contextWithSpanSet, fn, void 0, span);
|
|
1533
|
-
};
|
|
1534
|
-
return NoopTracer2;
|
|
1535
|
-
}()
|
|
1536
|
-
);
|
|
1537
|
-
function isSpanContext(spanContext) {
|
|
1538
|
-
return typeof spanContext === "object" && typeof spanContext["spanId"] === "string" && typeof spanContext["traceId"] === "string" && typeof spanContext["traceFlags"] === "number";
|
|
1539
|
-
}
|
|
1540
|
-
|
|
1541
|
-
// node_modules/@opentelemetry/api/build/esm/trace/ProxyTracer.js
|
|
1542
|
-
var NOOP_TRACER = new NoopTracer();
|
|
1543
|
-
var ProxyTracer = (
|
|
1544
|
-
/** @class */
|
|
1545
|
-
function() {
|
|
1546
|
-
function ProxyTracer2(_provider, name2, version2, options) {
|
|
1547
|
-
this._provider = _provider;
|
|
1548
|
-
this.name = name2;
|
|
1549
|
-
this.version = version2;
|
|
1550
|
-
this.options = options;
|
|
1551
|
-
}
|
|
1552
|
-
ProxyTracer2.prototype.startSpan = function(name2, options, context2) {
|
|
1553
|
-
return this._getTracer().startSpan(name2, options, context2);
|
|
1554
|
-
};
|
|
1555
|
-
ProxyTracer2.prototype.startActiveSpan = function(_name, _options, _context, _fn) {
|
|
1556
|
-
var tracer2 = this._getTracer();
|
|
1557
|
-
return Reflect.apply(tracer2.startActiveSpan, tracer2, arguments);
|
|
1558
|
-
};
|
|
1559
|
-
ProxyTracer2.prototype._getTracer = function() {
|
|
1560
|
-
if (this._delegate) {
|
|
1561
|
-
return this._delegate;
|
|
1562
|
-
}
|
|
1563
|
-
var tracer2 = this._provider.getDelegateTracer(this.name, this.version, this.options);
|
|
1564
|
-
if (!tracer2) {
|
|
1565
|
-
return NOOP_TRACER;
|
|
1566
|
-
}
|
|
1567
|
-
this._delegate = tracer2;
|
|
1568
|
-
return this._delegate;
|
|
1569
|
-
};
|
|
1570
|
-
return ProxyTracer2;
|
|
1571
|
-
}()
|
|
1572
|
-
);
|
|
1573
|
-
|
|
1574
|
-
// node_modules/@opentelemetry/api/build/esm/trace/NoopTracerProvider.js
|
|
1575
|
-
var NoopTracerProvider = (
|
|
1576
|
-
/** @class */
|
|
1577
|
-
function() {
|
|
1578
|
-
function NoopTracerProvider2() {
|
|
1579
|
-
}
|
|
1580
|
-
NoopTracerProvider2.prototype.getTracer = function(_name, _version, _options) {
|
|
1581
|
-
return new NoopTracer();
|
|
1582
|
-
};
|
|
1583
|
-
return NoopTracerProvider2;
|
|
1584
|
-
}()
|
|
1585
|
-
);
|
|
1586
|
-
|
|
1587
|
-
// node_modules/@opentelemetry/api/build/esm/trace/ProxyTracerProvider.js
|
|
1588
|
-
var NOOP_TRACER_PROVIDER = new NoopTracerProvider();
|
|
1589
|
-
var ProxyTracerProvider = (
|
|
1590
|
-
/** @class */
|
|
1591
|
-
function() {
|
|
1592
|
-
function ProxyTracerProvider2() {
|
|
1593
|
-
}
|
|
1594
|
-
ProxyTracerProvider2.prototype.getTracer = function(name2, version2, options) {
|
|
1595
|
-
var _a;
|
|
1596
|
-
return (_a = this.getDelegateTracer(name2, version2, options)) !== null && _a !== void 0 ? _a : new ProxyTracer(this, name2, version2, options);
|
|
1597
|
-
};
|
|
1598
|
-
ProxyTracerProvider2.prototype.getDelegate = function() {
|
|
1599
|
-
var _a;
|
|
1600
|
-
return (_a = this._delegate) !== null && _a !== void 0 ? _a : NOOP_TRACER_PROVIDER;
|
|
1601
|
-
};
|
|
1602
|
-
ProxyTracerProvider2.prototype.setDelegate = function(delegate) {
|
|
1603
|
-
this._delegate = delegate;
|
|
1604
|
-
};
|
|
1605
|
-
ProxyTracerProvider2.prototype.getDelegateTracer = function(name2, version2, options) {
|
|
1606
|
-
var _a;
|
|
1607
|
-
return (_a = this._delegate) === null || _a === void 0 ? void 0 : _a.getTracer(name2, version2, options);
|
|
1608
|
-
};
|
|
1609
|
-
return ProxyTracerProvider2;
|
|
1610
|
-
}()
|
|
1611
|
-
);
|
|
1612
|
-
|
|
1613
|
-
// node_modules/@opentelemetry/api/build/esm/trace/status.js
|
|
1614
|
-
var SpanStatusCode;
|
|
1615
|
-
(function(SpanStatusCode2) {
|
|
1616
|
-
SpanStatusCode2[SpanStatusCode2["UNSET"] = 0] = "UNSET";
|
|
1617
|
-
SpanStatusCode2[SpanStatusCode2["OK"] = 1] = "OK";
|
|
1618
|
-
SpanStatusCode2[SpanStatusCode2["ERROR"] = 2] = "ERROR";
|
|
1619
|
-
})(SpanStatusCode || (SpanStatusCode = {}));
|
|
1620
|
-
|
|
1621
|
-
// node_modules/@opentelemetry/api/build/esm/context-api.js
|
|
1622
|
-
var context = ContextAPI.getInstance();
|
|
1623
|
-
|
|
1624
|
-
// node_modules/@opentelemetry/api/build/esm/api/trace.js
|
|
1625
|
-
var API_NAME3 = "trace";
|
|
1626
|
-
var TraceAPI = (
|
|
1627
|
-
/** @class */
|
|
1628
|
-
function() {
|
|
1629
|
-
function TraceAPI2() {
|
|
1630
|
-
this._proxyTracerProvider = new ProxyTracerProvider();
|
|
1631
|
-
this.wrapSpanContext = wrapSpanContext;
|
|
1632
|
-
this.isSpanContextValid = isSpanContextValid;
|
|
1633
|
-
this.deleteSpan = deleteSpan;
|
|
1634
|
-
this.getSpan = getSpan;
|
|
1635
|
-
this.getActiveSpan = getActiveSpan;
|
|
1636
|
-
this.getSpanContext = getSpanContext;
|
|
1637
|
-
this.setSpan = setSpan;
|
|
1638
|
-
this.setSpanContext = setSpanContext;
|
|
1639
|
-
}
|
|
1640
|
-
TraceAPI2.getInstance = function() {
|
|
1641
|
-
if (!this._instance) {
|
|
1642
|
-
this._instance = new TraceAPI2();
|
|
1643
|
-
}
|
|
1644
|
-
return this._instance;
|
|
1645
|
-
};
|
|
1646
|
-
TraceAPI2.prototype.setGlobalTracerProvider = function(provider) {
|
|
1647
|
-
var success = registerGlobal(API_NAME3, this._proxyTracerProvider, DiagAPI.instance());
|
|
1648
|
-
if (success) {
|
|
1649
|
-
this._proxyTracerProvider.setDelegate(provider);
|
|
1650
|
-
}
|
|
1651
|
-
return success;
|
|
1652
|
-
};
|
|
1653
|
-
TraceAPI2.prototype.getTracerProvider = function() {
|
|
1654
|
-
return getGlobal(API_NAME3) || this._proxyTracerProvider;
|
|
1655
|
-
};
|
|
1656
|
-
TraceAPI2.prototype.getTracer = function(name2, version2) {
|
|
1657
|
-
return this.getTracerProvider().getTracer(name2, version2);
|
|
1658
|
-
};
|
|
1659
|
-
TraceAPI2.prototype.disable = function() {
|
|
1660
|
-
unregisterGlobal(API_NAME3, DiagAPI.instance());
|
|
1661
|
-
this._proxyTracerProvider = new ProxyTracerProvider();
|
|
1662
|
-
};
|
|
1663
|
-
return TraceAPI2;
|
|
1664
|
-
}()
|
|
1665
|
-
);
|
|
1666
|
-
|
|
1667
|
-
// node_modules/@opentelemetry/api/build/esm/trace-api.js
|
|
1668
|
-
var trace = TraceAPI.getInstance();
|
|
1669
|
-
|
|
1670
|
-
// node_modules/@opentelemetry/api/build/esm/experimental/trace/SugaredTracer.js
|
|
1671
|
-
var defaultOnException = function(e, span) {
|
|
1672
|
-
span.recordException(e);
|
|
1673
|
-
span.setStatus({
|
|
1674
|
-
code: SpanStatusCode.ERROR
|
|
1675
|
-
});
|
|
1676
|
-
};
|
|
1677
|
-
function wrapTracer(tracer2) {
|
|
1678
|
-
return new SugaredTracer(tracer2);
|
|
1679
|
-
}
|
|
1680
|
-
var SugaredTracer = (
|
|
1681
|
-
/** @class */
|
|
1682
|
-
function() {
|
|
1683
|
-
function SugaredTracer3(tracer2) {
|
|
1684
|
-
this._tracer = tracer2;
|
|
1685
|
-
this.startSpan = tracer2.startSpan.bind(this._tracer);
|
|
1686
|
-
this.startActiveSpan = tracer2.startActiveSpan.bind(this._tracer);
|
|
1687
|
-
}
|
|
1688
|
-
SugaredTracer3.prototype.withActiveSpan = function(name2, arg2, arg3, arg4) {
|
|
1689
|
-
var _a = massageParams(arg2, arg3, arg4), opts = _a.opts, ctx = _a.ctx, fn = _a.fn;
|
|
1690
|
-
return this._tracer.startActiveSpan(name2, opts, ctx, function(span) {
|
|
1691
|
-
return handleFn(span, opts, fn);
|
|
1692
|
-
});
|
|
1693
|
-
};
|
|
1694
|
-
SugaredTracer3.prototype.withSpan = function(name2, arg2, arg3, arg4) {
|
|
1695
|
-
var _a = massageParams(arg2, arg3, arg4), opts = _a.opts, ctx = _a.ctx, fn = _a.fn;
|
|
1696
|
-
var span = this._tracer.startSpan(name2, opts, ctx);
|
|
1697
|
-
return handleFn(span, opts, fn);
|
|
1698
|
-
};
|
|
1699
|
-
return SugaredTracer3;
|
|
1700
|
-
}()
|
|
1701
|
-
);
|
|
1702
|
-
function massageParams(arg, arg2, arg3) {
|
|
1703
|
-
var opts;
|
|
1704
|
-
var ctx;
|
|
1705
|
-
var fn;
|
|
1706
|
-
if (!arg2 && !arg3) {
|
|
1707
|
-
fn = arg;
|
|
1708
|
-
} else if (!arg3) {
|
|
1709
|
-
opts = arg;
|
|
1710
|
-
fn = arg2;
|
|
1711
|
-
} else {
|
|
1712
|
-
opts = arg;
|
|
1713
|
-
ctx = arg2;
|
|
1714
|
-
fn = arg3;
|
|
1715
|
-
}
|
|
1716
|
-
opts = opts !== null && opts !== void 0 ? opts : {};
|
|
1717
|
-
ctx = ctx !== null && ctx !== void 0 ? ctx : context.active();
|
|
1718
|
-
return { opts, ctx, fn };
|
|
1719
|
-
}
|
|
1720
|
-
function handleFn(span, opts, fn) {
|
|
1721
|
-
var _a;
|
|
1722
|
-
var onException = (_a = opts.onException) !== null && _a !== void 0 ? _a : defaultOnException;
|
|
1723
|
-
var errorHandler = function(e) {
|
|
1724
|
-
onException(e, span);
|
|
1725
|
-
span.end();
|
|
1726
|
-
throw e;
|
|
1727
|
-
};
|
|
1728
|
-
try {
|
|
1729
|
-
var ret = fn(span);
|
|
1730
|
-
if (typeof (ret === null || ret === void 0 ? void 0 : ret.then) === "function") {
|
|
1731
|
-
return ret.then(function(val) {
|
|
1732
|
-
span.end();
|
|
1733
|
-
return val;
|
|
1734
|
-
}, errorHandler);
|
|
1735
|
-
}
|
|
1736
|
-
span.end();
|
|
1737
|
-
return ret;
|
|
1738
|
-
} catch (e) {
|
|
1739
|
-
throw errorHandler(e);
|
|
1740
|
-
}
|
|
1741
|
-
}
|
|
1742
|
-
|
|
1743
|
-
// src/run/handlers/tracer.cts
|
|
1744
|
-
var spanMeta = /* @__PURE__ */ new WeakMap();
|
|
1745
|
-
var spanCounter = /* @__PURE__ */ new WeakMap();
|
|
1746
|
-
function spanHook(span) {
|
|
1747
|
-
const originalEnd = span.end.bind(span);
|
|
1748
|
-
span.end = (endTime) => {
|
|
1749
|
-
originalEnd(endTime);
|
|
1750
|
-
const meta = spanMeta.get(span);
|
|
1751
|
-
if (meta) {
|
|
1752
|
-
const requestContext = getRequestContext();
|
|
1753
|
-
if (requestContext?.captureServerTiming) {
|
|
1754
|
-
const duration = (typeof endTime === "number" ? endTime : performance.now()) - meta.start;
|
|
1755
|
-
const serverTiming = requestContext.serverTiming ?? "";
|
|
1756
|
-
const currentRequestSpanCounter = spanCounter.get(requestContext) ?? 1;
|
|
1757
|
-
requestContext.serverTiming = `${serverTiming}${serverTiming.length === 0 ? "" : ", "}s${currentRequestSpanCounter};dur=${duration};desc="${meta.name}"`;
|
|
1758
|
-
spanCounter.set(requestContext, currentRequestSpanCounter + 1);
|
|
1759
|
-
}
|
|
1760
|
-
}
|
|
1761
|
-
spanMeta.delete(span);
|
|
1762
|
-
};
|
|
1763
|
-
return span;
|
|
1764
|
-
}
|
|
1765
|
-
var tracer;
|
|
1766
|
-
function getTracer() {
|
|
1767
|
-
if (!tracer) {
|
|
1768
|
-
const baseTracer = trace.getTracer("Next.js Runtime");
|
|
1769
|
-
const startSpan = baseTracer.startSpan.bind(baseTracer);
|
|
1770
|
-
baseTracer.startSpan = (...args) => {
|
|
1771
|
-
const span = startSpan(...args);
|
|
1772
|
-
spanMeta.set(span, { start: performance.now(), name: args[0] });
|
|
1773
|
-
return spanHook(span);
|
|
1774
|
-
};
|
|
1775
|
-
const startActiveSpan = baseTracer.startActiveSpan.bind(baseTracer);
|
|
1776
|
-
baseTracer.startActiveSpan = (...args) => {
|
|
1777
|
-
const [name2, ...restOfArgs] = args;
|
|
1778
|
-
const augmentedArgs = restOfArgs.map((arg) => {
|
|
1779
|
-
if (typeof arg === "function") {
|
|
1780
|
-
return (span) => {
|
|
1781
|
-
spanMeta.set(span, { start: performance.now(), name: args[0] });
|
|
1782
|
-
spanHook(span);
|
|
1783
|
-
return arg(span);
|
|
1784
|
-
};
|
|
1785
|
-
}
|
|
1786
|
-
return arg;
|
|
1787
|
-
});
|
|
1788
|
-
return startActiveSpan(name2, ...augmentedArgs);
|
|
1789
|
-
};
|
|
1790
|
-
tracer = wrapTracer(baseTracer);
|
|
1791
|
-
}
|
|
1792
|
-
return tracer;
|
|
1793
|
-
}
|
|
178
|
+
var version = "5.10.1";
|
|
1794
179
|
|
|
1795
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");
|
|
1796
185
|
var purgeCacheUserAgent = `${name}@${version}`;
|
|
1797
186
|
var NetlifyCacheHandler = class {
|
|
1798
187
|
options;
|
|
1799
188
|
revalidatedTags;
|
|
1800
189
|
blobStore;
|
|
1801
|
-
tracer = getTracer();
|
|
190
|
+
tracer = (0, import_tracer.getTracer)();
|
|
1802
191
|
tagManifestsFetchedFromBlobStoreInCurrentRequest;
|
|
1803
192
|
constructor(options) {
|
|
1804
193
|
this.options = options;
|
|
1805
194
|
this.revalidatedTags = options.revalidatedTags;
|
|
1806
|
-
this.blobStore = getRegionalBlobStore({ consistency: "strong" });
|
|
195
|
+
this.blobStore = (0, import_regional_blob_store.getRegionalBlobStore)({ consistency: "strong" });
|
|
1807
196
|
this.tagManifestsFetchedFromBlobStoreInCurrentRequest = {};
|
|
1808
197
|
}
|
|
1809
198
|
async encodeBlobKey(key) {
|
|
1810
|
-
const { encodeBlobKey
|
|
1811
|
-
return await
|
|
199
|
+
const { encodeBlobKey } = await import("../../shared/blobkey.js");
|
|
200
|
+
return await encodeBlobKey(key);
|
|
1812
201
|
}
|
|
1813
202
|
getTTL(blob) {
|
|
1814
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") {
|
|
@@ -1827,7 +216,7 @@ var NetlifyCacheHandler = class {
|
|
|
1827
216
|
if (cacheValue.value?.kind === "FETCH") {
|
|
1828
217
|
return;
|
|
1829
218
|
}
|
|
1830
|
-
const requestContext = getRequestContext();
|
|
219
|
+
const requestContext = (0, import_request_context.getRequestContext)();
|
|
1831
220
|
if (!requestContext) {
|
|
1832
221
|
getCacheKeySpan.recordException(
|
|
1833
222
|
new Error("CacheHandler was called without a request context")
|
|
@@ -1858,7 +247,7 @@ var NetlifyCacheHandler = class {
|
|
|
1858
247
|
}
|
|
1859
248
|
captureRouteRevalidateAndRemoveFromObject(cacheValue) {
|
|
1860
249
|
const { revalidate, ...restOfRouteValue } = cacheValue;
|
|
1861
|
-
const requestContext = getRequestContext();
|
|
250
|
+
const requestContext = (0, import_request_context.getRequestContext)();
|
|
1862
251
|
if (requestContext) {
|
|
1863
252
|
requestContext.routeHandlerRevalidate = revalidate;
|
|
1864
253
|
}
|
|
@@ -1868,7 +257,7 @@ var NetlifyCacheHandler = class {
|
|
|
1868
257
|
if (!cacheValue) {
|
|
1869
258
|
return;
|
|
1870
259
|
}
|
|
1871
|
-
const requestContext = getRequestContext();
|
|
260
|
+
const requestContext = (0, import_request_context.getRequestContext)();
|
|
1872
261
|
if (!requestContext) {
|
|
1873
262
|
return;
|
|
1874
263
|
}
|
|
@@ -1925,7 +314,7 @@ var NetlifyCacheHandler = class {
|
|
|
1925
314
|
async get(...args) {
|
|
1926
315
|
return this.tracer.withActiveSpan("get cache key", async (span) => {
|
|
1927
316
|
const [key, ctx = {}] = args;
|
|
1928
|
-
getLogger().debug(`[NetlifyCacheHandler.get]: ${key}`);
|
|
317
|
+
(0, import_request_context.getLogger)().debug(`[NetlifyCacheHandler.get]: ${key}`);
|
|
1929
318
|
const blobKey = await this.encodeBlobKey(key);
|
|
1930
319
|
span.setAttributes({ key, blobKey });
|
|
1931
320
|
const blob = await this.tracer.withActiveSpan("blobStore.get", async (blobGetSpan) => {
|
|
@@ -1939,13 +328,13 @@ var NetlifyCacheHandler = class {
|
|
|
1939
328
|
return null;
|
|
1940
329
|
}
|
|
1941
330
|
const ttl = this.getTTL(blob);
|
|
1942
|
-
if (getRequestContext()?.isBackgroundRevalidation && typeof ttl === "number" && ttl < 0) {
|
|
331
|
+
if ((0, import_request_context.getRequestContext)()?.isBackgroundRevalidation && typeof ttl === "number" && ttl < 0) {
|
|
1943
332
|
span.addEvent("Discarding stale entry due to SWR background revalidation request", {
|
|
1944
333
|
key,
|
|
1945
334
|
blobKey,
|
|
1946
335
|
ttl
|
|
1947
336
|
});
|
|
1948
|
-
getLogger().withFields({
|
|
337
|
+
(0, import_request_context.getLogger)().withFields({
|
|
1949
338
|
ttl,
|
|
1950
339
|
key
|
|
1951
340
|
}).debug(
|
|
@@ -1984,14 +373,14 @@ var NetlifyCacheHandler = class {
|
|
|
1984
373
|
lastModified: blob.lastModified,
|
|
1985
374
|
value: {
|
|
1986
375
|
...valueWithoutRevalidate,
|
|
1987
|
-
body:
|
|
376
|
+
body: import_node_buffer.Buffer.from(valueWithoutRevalidate.body, "base64")
|
|
1988
377
|
}
|
|
1989
378
|
};
|
|
1990
379
|
}
|
|
1991
380
|
case "PAGE":
|
|
1992
381
|
case "PAGES": {
|
|
1993
382
|
const { revalidate, ...restOfPageValue } = blob.value;
|
|
1994
|
-
const requestContext = getRequestContext();
|
|
383
|
+
const requestContext = (0, import_request_context.getRequestContext)();
|
|
1995
384
|
if (requestContext) {
|
|
1996
385
|
requestContext.pageHandlerRevalidate = revalidate;
|
|
1997
386
|
}
|
|
@@ -2010,7 +399,7 @@ var NetlifyCacheHandler = class {
|
|
|
2010
399
|
lastModified: blob.lastModified,
|
|
2011
400
|
value: {
|
|
2012
401
|
...restOfPageValue,
|
|
2013
|
-
rscData: rscData ?
|
|
402
|
+
rscData: rscData ? import_node_buffer.Buffer.from(rscData, "base64") : void 0
|
|
2014
403
|
}
|
|
2015
404
|
};
|
|
2016
405
|
}
|
|
@@ -2020,30 +409,30 @@ var NetlifyCacheHandler = class {
|
|
|
2020
409
|
return null;
|
|
2021
410
|
});
|
|
2022
411
|
}
|
|
2023
|
-
transformToStorableObject(data,
|
|
412
|
+
transformToStorableObject(data, context) {
|
|
2024
413
|
if (!data) {
|
|
2025
414
|
return null;
|
|
2026
415
|
}
|
|
2027
|
-
if (isCachedRouteValue(data)) {
|
|
416
|
+
if ((0, import_cache_types.isCachedRouteValue)(data)) {
|
|
2028
417
|
return {
|
|
2029
418
|
...data,
|
|
2030
|
-
revalidate:
|
|
2031
|
-
cacheControl:
|
|
419
|
+
revalidate: context.revalidate ?? context.cacheControl?.revalidate,
|
|
420
|
+
cacheControl: context.cacheControl,
|
|
2032
421
|
body: data.body.toString("base64")
|
|
2033
422
|
};
|
|
2034
423
|
}
|
|
2035
|
-
if (isCachedPageValue(data)) {
|
|
424
|
+
if ((0, import_cache_types.isCachedPageValue)(data)) {
|
|
2036
425
|
return {
|
|
2037
426
|
...data,
|
|
2038
|
-
revalidate:
|
|
2039
|
-
cacheControl:
|
|
427
|
+
revalidate: context.revalidate ?? context.cacheControl?.revalidate,
|
|
428
|
+
cacheControl: context.cacheControl
|
|
2040
429
|
};
|
|
2041
430
|
}
|
|
2042
431
|
if (data?.kind === "APP_PAGE") {
|
|
2043
432
|
return {
|
|
2044
433
|
...data,
|
|
2045
|
-
revalidate:
|
|
2046
|
-
cacheControl:
|
|
434
|
+
revalidate: context.revalidate ?? context.cacheControl?.revalidate,
|
|
435
|
+
cacheControl: context.cacheControl,
|
|
2047
436
|
rscData: data.rscData?.toString("base64")
|
|
2048
437
|
};
|
|
2049
438
|
}
|
|
@@ -2051,29 +440,29 @@ var NetlifyCacheHandler = class {
|
|
|
2051
440
|
}
|
|
2052
441
|
async set(...args) {
|
|
2053
442
|
return this.tracer.withActiveSpan("set cache key", async (span) => {
|
|
2054
|
-
const [key, data,
|
|
443
|
+
const [key, data, context] = args;
|
|
2055
444
|
const blobKey = await this.encodeBlobKey(key);
|
|
2056
445
|
const lastModified = Date.now();
|
|
2057
446
|
span.setAttributes({ key, lastModified, blobKey });
|
|
2058
|
-
getLogger().debug(`[NetlifyCacheHandler.set]: ${key}`);
|
|
2059
|
-
const value = this.transformToStorableObject(data,
|
|
447
|
+
(0, import_request_context.getLogger)().debug(`[NetlifyCacheHandler.set]: ${key}`);
|
|
448
|
+
const value = this.transformToStorableObject(data, context);
|
|
2060
449
|
this.captureCacheTags(value, key);
|
|
2061
450
|
await this.blobStore.setJSON(blobKey, {
|
|
2062
451
|
lastModified,
|
|
2063
452
|
value
|
|
2064
453
|
});
|
|
2065
454
|
if (data?.kind === "PAGE" || data?.kind === "PAGES") {
|
|
2066
|
-
const requestContext = getRequestContext();
|
|
455
|
+
const requestContext = (0, import_request_context.getRequestContext)();
|
|
2067
456
|
if (requestContext?.didPagesRouterOnDemandRevalidate) {
|
|
2068
457
|
const tag = `_N_T_${key === "/index" ? "/" : encodeURI(key)}`;
|
|
2069
458
|
const tags = tag.split(/,|%2c/gi).filter(Boolean);
|
|
2070
459
|
if (tags.length === 0) {
|
|
2071
460
|
return;
|
|
2072
461
|
}
|
|
2073
|
-
getLogger().debug(`Purging CDN cache for: [${tag}]`);
|
|
462
|
+
(0, import_request_context.getLogger)().debug(`Purging CDN cache for: [${tag}]`);
|
|
2074
463
|
requestContext.trackBackgroundWork(
|
|
2075
464
|
purgeCache({ tags, userAgent: purgeCacheUserAgent }).catch((error) => {
|
|
2076
|
-
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`);
|
|
2077
466
|
})
|
|
2078
467
|
);
|
|
2079
468
|
}
|
|
@@ -2083,7 +472,7 @@ var NetlifyCacheHandler = class {
|
|
|
2083
472
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2084
473
|
async revalidateTag(tagOrTags, ...args) {
|
|
2085
474
|
const revalidateTagPromise = this.doRevalidateTag(tagOrTags, ...args);
|
|
2086
|
-
const requestContext = getRequestContext();
|
|
475
|
+
const requestContext = (0, import_request_context.getRequestContext)();
|
|
2087
476
|
if (requestContext) {
|
|
2088
477
|
requestContext.trackBackgroundWork(revalidateTagPromise);
|
|
2089
478
|
}
|
|
@@ -2091,7 +480,7 @@ var NetlifyCacheHandler = class {
|
|
|
2091
480
|
}
|
|
2092
481
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2093
482
|
async doRevalidateTag(tagOrTags, ...args) {
|
|
2094
|
-
getLogger().withFields({ tagOrTags, args }).debug("NetlifyCacheHandler.revalidateTag");
|
|
483
|
+
(0, import_request_context.getLogger)().withFields({ tagOrTags, args }).debug("NetlifyCacheHandler.revalidateTag");
|
|
2095
484
|
const tags = (Array.isArray(tagOrTags) ? tagOrTags : [tagOrTags]).flatMap((tag) => tag.split(/,|%2c/gi)).filter(Boolean);
|
|
2096
485
|
if (tags.length === 0) {
|
|
2097
486
|
return;
|
|
@@ -2104,12 +493,12 @@ var NetlifyCacheHandler = class {
|
|
|
2104
493
|
try {
|
|
2105
494
|
await this.blobStore.setJSON(await this.encodeBlobKey(tag), data);
|
|
2106
495
|
} catch (error) {
|
|
2107
|
-
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}`);
|
|
2108
497
|
}
|
|
2109
498
|
})
|
|
2110
499
|
);
|
|
2111
500
|
await purgeCache({ tags, userAgent: purgeCacheUserAgent }).catch((error) => {
|
|
2112
|
-
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`);
|
|
2113
502
|
});
|
|
2114
503
|
}
|
|
2115
504
|
resetRequestCache() {
|