@redocly/cli 2.41.1 → 2.42.0
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/README.md +15 -0
- package/THIRD_PARTY_NOTICES +7 -6
- package/lib/chunks/32XCOMOR.js +7 -0
- package/lib/chunks/4S2W4DOH.js +7 -0
- package/lib/chunks/55GMSQDD.js +7 -0
- package/lib/chunks/62KMHHXM.js +93 -0
- package/lib/chunks/7J6QXKSL.js +59 -0
- package/lib/chunks/7TEHO26G.js +3132 -0
- package/lib/chunks/AE6JGTY4.js +7 -0
- package/lib/chunks/B62AKN6U.js +7 -0
- package/lib/chunks/BZ7PKRCP.js +2317 -0
- package/lib/chunks/D5T6ETPZ.js +8 -0
- package/lib/chunks/DNYSY7SK.js +8 -0
- package/lib/chunks/E2UJUSIU.js +11 -0
- package/lib/chunks/ECZUPR2N.js +7 -0
- package/lib/chunks/EU6GURJZ.js +7 -0
- package/lib/chunks/F4DGJH6G.js +8 -0
- package/lib/chunks/GELB6SHC.js +22 -0
- package/lib/chunks/HJ6KJBQG.js +9 -0
- package/lib/chunks/HXR6INJN.js +22 -0
- package/lib/chunks/IP2FG3VC.js +19 -0
- package/lib/chunks/KLY5RV3W.js +7 -0
- package/lib/chunks/LSG6IYBM.js +47 -0
- package/lib/chunks/NEWT5A6S.js +159 -0
- package/lib/chunks/O6MCQRCP.js +59 -0
- package/lib/chunks/O6PRCLSV.js +13 -0
- package/lib/chunks/OFAMJNQ6.js +7 -0
- package/lib/chunks/P26PQ2RU.js +7 -0
- package/lib/chunks/QQOKWPJZ.js +184 -0
- package/lib/chunks/RFWIIJFG.js +7 -0
- package/lib/chunks/RS5PUOTT.js +18 -0
- package/lib/chunks/SPVQTYE2.js +7 -0
- package/lib/chunks/TXOARWFE.js +7 -0
- package/lib/chunks/UPPWQBGX.js +7 -0
- package/lib/chunks/UYZXI3NO.js +7 -0
- package/lib/chunks/WZXA5XPB.js +7 -0
- package/lib/chunks/XYO6U5CE.js +31 -0
- package/lib/chunks/ZGSJFP2Z.js +8 -0
- package/lib/index.js +226 -13883
- package/package.json +1 -1
- package/lib/chunks/4FB5ZIPP.js +0 -1133
- package/lib/chunks/5ILQMFXK.js +0 -59
- package/lib/chunks/64PJUTGH.js +0 -79
- package/lib/chunks/A6JSOHCP.js +0 -41
- package/lib/chunks/AIT3U3JT.js +0 -22
- package/lib/chunks/CUWLBJXP.js +0 -17
- package/lib/chunks/FO6BDVGE.js +0 -25
- package/lib/chunks/GCAYTKJY.js +0 -681
- package/lib/chunks/HFIKZEXG.js +0 -175
- package/lib/chunks/ICPYP2LP.js +0 -401
- package/lib/chunks/JR2DXWZO.js +0 -17799
- package/lib/chunks/KWQEC5JF.js +0 -16
- package/lib/chunks/LZNQHR3A.js +0 -2416
- package/lib/chunks/OFNDHNJR.js +0 -1756
- package/lib/chunks/OYU4O47C.js +0 -13374
- package/lib/chunks/PU67EGEM.js +0 -496
- package/lib/chunks/Q7LC24EZ.js +0 -528
- package/lib/chunks/RLUKQFWZ.js +0 -92591
- package/lib/chunks/TS33ZDKX.js +0 -35
- package/lib/chunks/UQJWXLNC.js +0 -3614
- package/lib/chunks/UUU33DK3.js +0 -125
- package/lib/chunks/UV3RHVRI.js +0 -25
- package/lib/chunks/VUDTNFRL.js +0 -42
- package/lib/chunks/VXIQEZPR.js +0 -2564
- package/lib/chunks/W7G5WVPB.js +0 -44
- package/lib/chunks/XB6C62FW.js +0 -18497
- package/lib/chunks/XHPY6UJF.js +0 -1638
- package/lib/chunks/Y6DTFCLS.js +0 -15
- package/lib/chunks/Y7LKQTQ4.js +0 -414
- package/lib/chunks/YPFS42IW.js +0 -92
- package/lib/chunks/Z2I5YXYN.js +0 -20272
- package/lib/chunks/Z3EJWJEX.js +0 -39325
- package/lib/chunks/ZK3QRKL5.js +0 -129
package/lib/chunks/HFIKZEXG.js
DELETED
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
-
const require = __createRequire(import.meta.url);
|
|
3
|
-
import {
|
|
4
|
-
selectTrafficParser
|
|
5
|
-
} from "./Y7LKQTQ4.js";
|
|
6
|
-
import {
|
|
7
|
-
ValidationSession,
|
|
8
|
-
loadOpenApiIndex,
|
|
9
|
-
parseCsv,
|
|
10
|
-
renderReport
|
|
11
|
-
} from "./LZNQHR3A.js";
|
|
12
|
-
import {
|
|
13
|
-
listFilesRecursively,
|
|
14
|
-
normalizeFsPath
|
|
15
|
-
} from "./PU67EGEM.js";
|
|
16
|
-
import {
|
|
17
|
-
AbortFlowError,
|
|
18
|
-
exitWithError
|
|
19
|
-
} from "./CUWLBJXP.js";
|
|
20
|
-
import {
|
|
21
|
-
logger
|
|
22
|
-
} from "./Z3EJWJEX.js";
|
|
23
|
-
import "./Z2I5YXYN.js";
|
|
24
|
-
import "./5ILQMFXK.js";
|
|
25
|
-
|
|
26
|
-
// src/commands/drift/index.ts
|
|
27
|
-
import { mkdir, writeFile } from "node:fs/promises";
|
|
28
|
-
import path from "node:path";
|
|
29
|
-
|
|
30
|
-
// src/commands/drift/engine/runner.ts
|
|
31
|
-
async function runTrafficValidation(options) {
|
|
32
|
-
const trafficFiles = await listFilesRecursively(options.trafficPath);
|
|
33
|
-
if (trafficFiles.length === 0) {
|
|
34
|
-
throw new Error("No traffic files found in the provided traffic path.");
|
|
35
|
-
}
|
|
36
|
-
const session = ValidationSession.create({
|
|
37
|
-
openApiIndex: options.openApiIndex,
|
|
38
|
-
matchMode: options.matchMode,
|
|
39
|
-
ignoreCookies: options.ignoreCookies,
|
|
40
|
-
ignoreHeaders: options.ignoreHeaders,
|
|
41
|
-
previewFindingsLimit: options.previewFindingsLimit,
|
|
42
|
-
activeRules: options.activeRules,
|
|
43
|
-
server: options.server,
|
|
44
|
-
minSeverity: options.minSeverity
|
|
45
|
-
});
|
|
46
|
-
let supportedTrafficFileCount = 0;
|
|
47
|
-
let exchangeIndex = 0;
|
|
48
|
-
for (const trafficFile of trafficFiles) {
|
|
49
|
-
const parser = await selectTrafficParser(trafficFile, options.format);
|
|
50
|
-
if (!parser) {
|
|
51
|
-
logger.warn(`Skipping traffic file with unrecognized format: ${trafficFile}
|
|
52
|
-
`);
|
|
53
|
-
continue;
|
|
54
|
-
}
|
|
55
|
-
supportedTrafficFileCount += 1;
|
|
56
|
-
for await (const exchange of parser.parse(trafficFile)) {
|
|
57
|
-
await session.process({ ...exchange, index: exchangeIndex });
|
|
58
|
-
exchangeIndex += 1;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
if (supportedTrafficFileCount === 0) {
|
|
62
|
-
throw new Error(
|
|
63
|
-
"No supported traffic files found. In auto mode, files must match built-in traffic parser signatures."
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
if (exchangeIndex === 0) {
|
|
67
|
-
throw new Error("No HTTP exchanges were parsed from the provided traffic files.");
|
|
68
|
-
}
|
|
69
|
-
return session.finalize();
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// src/commands/drift/index.ts
|
|
73
|
-
var USE_COLOR = Boolean(process.stdout.isTTY) && process.env.NO_COLOR === void 0;
|
|
74
|
-
function collectSpecServerUrls(openApiIndex) {
|
|
75
|
-
const urls = /* @__PURE__ */ new Set();
|
|
76
|
-
for (const operations of openApiIndex.operationsByMethod.values()) {
|
|
77
|
-
for (const operation of operations) {
|
|
78
|
-
for (const server of operation.servers) {
|
|
79
|
-
urls.add(server.rawUrl);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return Array.from(urls).sort();
|
|
84
|
-
}
|
|
85
|
-
function warnWhenNothingMatched(summary, openApiIndex, server) {
|
|
86
|
-
const validatedExchanges = summary.totalExchanges - summary.skippedExchanges;
|
|
87
|
-
if (validatedExchanges === 0 && summary.skippedExchanges > 0) {
|
|
88
|
-
logger.warn(
|
|
89
|
-
`All ${summary.skippedExchanges} exchange(s) were outside the --server "${server}" and were skipped. Check that the server matches the traffic URLs.
|
|
90
|
-
`
|
|
91
|
-
);
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
if (summary.documentedExchanges > 0 || validatedExchanges === 0) {
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
const serverUrls = collectSpecServerUrls(openApiIndex);
|
|
98
|
-
const hint = server ? `Check that the --server "${server}" matches the traffic URLs and that the description paths align with the remainder.` : summary.hostCompatibleExchanges === validatedExchanges ? `The traffic hosts are compatible with the description servers (${serverUrls.join(
|
|
99
|
-
", "
|
|
100
|
-
)}), so the endpoints are likely undocumented; if they should be documented, check that the description base paths and paths align with the traffic URLs, or use --server to declare the server the traffic was captured against.` : `Check that the traffic host and base path match the description servers (${serverUrls.join(
|
|
101
|
-
", "
|
|
102
|
-
)}), or use --server to declare the server the traffic was captured against.`;
|
|
103
|
-
logger.warn(
|
|
104
|
-
`None of the ${validatedExchanges} validated exchange(s) matched a documented operation. ${hint}
|
|
105
|
-
`
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
async function writeOutput(outputPath, content) {
|
|
109
|
-
const resolved = normalizeFsPath(outputPath);
|
|
110
|
-
await mkdir(path.dirname(resolved), { recursive: true });
|
|
111
|
-
await writeFile(resolved, content, "utf8");
|
|
112
|
-
}
|
|
113
|
-
async function handleDrift({ argv, config }) {
|
|
114
|
-
const trafficPath = normalizeFsPath(argv.traffic);
|
|
115
|
-
const trafficFormat = argv["traffic-format"];
|
|
116
|
-
const activeRules = argv.rules ? parseCsv(argv.rules) : void 0;
|
|
117
|
-
const ignoreHeaders = argv["ignore-headers"] ? parseCsv(argv["ignore-headers"]) : void 0;
|
|
118
|
-
const server = argv.server;
|
|
119
|
-
if (server && argv["match-mode"]) {
|
|
120
|
-
return exitWithError(
|
|
121
|
-
"The --server and --match-mode options are mutually exclusive: --match-mode controls how requests are located via the description servers, while --server replaces the description servers with the one the traffic was captured against."
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
const matchMode = argv["match-mode"] ?? "strict-host";
|
|
125
|
-
const specPath = normalizeFsPath(argv.api);
|
|
126
|
-
const openApiIndex = await loadOpenApiIndex(specPath, config);
|
|
127
|
-
if (openApiIndex.loadedOperations === 0) {
|
|
128
|
-
return exitWithError(`No OpenAPI operations were loaded from: ${specPath}`);
|
|
129
|
-
}
|
|
130
|
-
const { runId, summary, findings } = await runTrafficValidation({
|
|
131
|
-
trafficPath,
|
|
132
|
-
format: trafficFormat,
|
|
133
|
-
matchMode,
|
|
134
|
-
ignoreCookies: argv["ignore-cookies"],
|
|
135
|
-
ignoreHeaders,
|
|
136
|
-
previewFindingsLimit: argv["max-findings"],
|
|
137
|
-
activeRules,
|
|
138
|
-
openApiIndex,
|
|
139
|
-
server,
|
|
140
|
-
minSeverity: argv["min-severity"]
|
|
141
|
-
});
|
|
142
|
-
warnWhenNothingMatched(summary, openApiIndex, server);
|
|
143
|
-
const report = renderReport(
|
|
144
|
-
{
|
|
145
|
-
runId,
|
|
146
|
-
summary,
|
|
147
|
-
findings,
|
|
148
|
-
meta: {
|
|
149
|
-
specSource: specPath,
|
|
150
|
-
trafficPath,
|
|
151
|
-
format: trafficFormat,
|
|
152
|
-
matchMode,
|
|
153
|
-
server
|
|
154
|
-
}
|
|
155
|
-
},
|
|
156
|
-
{
|
|
157
|
-
format: argv["report-format"],
|
|
158
|
-
color: USE_COLOR && argv["report-format"] === "pretty" && !argv.output,
|
|
159
|
-
maxFindings: argv["max-findings"]
|
|
160
|
-
}
|
|
161
|
-
);
|
|
162
|
-
if (argv.output) {
|
|
163
|
-
await writeOutput(argv.output, report);
|
|
164
|
-
logger.info(`Drift report written to: ${normalizeFsPath(argv.output)}
|
|
165
|
-
`);
|
|
166
|
-
} else {
|
|
167
|
-
logger.output(report);
|
|
168
|
-
}
|
|
169
|
-
if (summary.findingsBySeverity.error > 0) {
|
|
170
|
-
throw new AbortFlowError("Drift detected.");
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
export {
|
|
174
|
-
handleDrift
|
|
175
|
-
};
|
package/lib/chunks/ICPYP2LP.js
DELETED
|
@@ -1,401 +0,0 @@
|
|
|
1
|
-
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
-
const require = __createRequire(import.meta.url);
|
|
3
|
-
import {
|
|
4
|
-
__commonJS,
|
|
5
|
-
__require,
|
|
6
|
-
__toESM
|
|
7
|
-
} from "./5ILQMFXK.js";
|
|
8
|
-
|
|
9
|
-
// ../../node_modules/@redocly/cli-otel/node_modules/ulid/dist/index.umd.js
|
|
10
|
-
var require_index_umd = __commonJS({
|
|
11
|
-
"../../node_modules/@redocly/cli-otel/node_modules/ulid/dist/index.umd.js"(exports, module) {
|
|
12
|
-
(function(global2, factory) {
|
|
13
|
-
typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define(["exports"], factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, factory(global2.ULID = {}));
|
|
14
|
-
})(exports, (function(exports2) {
|
|
15
|
-
"use strict";
|
|
16
|
-
function createError(message) {
|
|
17
|
-
const err = new Error(message);
|
|
18
|
-
err.source = "ulid";
|
|
19
|
-
return err;
|
|
20
|
-
}
|
|
21
|
-
const ENCODING2 = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
22
|
-
const ENCODING_LEN2 = ENCODING2.length;
|
|
23
|
-
const TIME_MAX2 = Math.pow(2, 48) - 1;
|
|
24
|
-
const TIME_LEN2 = 10;
|
|
25
|
-
const RANDOM_LEN2 = 16;
|
|
26
|
-
function replaceCharAt(str, index, char) {
|
|
27
|
-
if (index > str.length - 1) {
|
|
28
|
-
return str;
|
|
29
|
-
}
|
|
30
|
-
return str.substr(0, index) + char + str.substr(index + 1);
|
|
31
|
-
}
|
|
32
|
-
function incrementBase32(str) {
|
|
33
|
-
let done = void 0;
|
|
34
|
-
let index = str.length;
|
|
35
|
-
let char;
|
|
36
|
-
let charIndex;
|
|
37
|
-
const maxCharIndex = ENCODING_LEN2 - 1;
|
|
38
|
-
while (!done && index-- >= 0) {
|
|
39
|
-
char = str[index];
|
|
40
|
-
charIndex = ENCODING2.indexOf(char);
|
|
41
|
-
if (charIndex === -1) {
|
|
42
|
-
throw createError("incorrectly encoded string");
|
|
43
|
-
}
|
|
44
|
-
if (charIndex === maxCharIndex) {
|
|
45
|
-
str = replaceCharAt(str, index, ENCODING2[0]);
|
|
46
|
-
continue;
|
|
47
|
-
}
|
|
48
|
-
done = replaceCharAt(str, index, ENCODING2[charIndex + 1]);
|
|
49
|
-
}
|
|
50
|
-
if (typeof done === "string") {
|
|
51
|
-
return done;
|
|
52
|
-
}
|
|
53
|
-
throw createError("cannot increment this string");
|
|
54
|
-
}
|
|
55
|
-
function randomChar2(prng) {
|
|
56
|
-
let rand = Math.floor(prng() * ENCODING_LEN2);
|
|
57
|
-
if (rand === ENCODING_LEN2) {
|
|
58
|
-
rand = ENCODING_LEN2 - 1;
|
|
59
|
-
}
|
|
60
|
-
return ENCODING2.charAt(rand);
|
|
61
|
-
}
|
|
62
|
-
function encodeTime2(now, len) {
|
|
63
|
-
if (isNaN(now)) {
|
|
64
|
-
throw new Error(now + " must be a number");
|
|
65
|
-
}
|
|
66
|
-
if (now > TIME_MAX2) {
|
|
67
|
-
throw createError("cannot encode time greater than " + TIME_MAX2);
|
|
68
|
-
}
|
|
69
|
-
if (now < 0) {
|
|
70
|
-
throw createError("time must be positive");
|
|
71
|
-
}
|
|
72
|
-
if (Number.isInteger(Number(now)) === false) {
|
|
73
|
-
throw createError("time must be an integer");
|
|
74
|
-
}
|
|
75
|
-
let mod;
|
|
76
|
-
let str = "";
|
|
77
|
-
for (; len > 0; len--) {
|
|
78
|
-
mod = now % ENCODING_LEN2;
|
|
79
|
-
str = ENCODING2.charAt(mod) + str;
|
|
80
|
-
now = (now - mod) / ENCODING_LEN2;
|
|
81
|
-
}
|
|
82
|
-
return str;
|
|
83
|
-
}
|
|
84
|
-
function encodeRandom2(len, prng) {
|
|
85
|
-
let str = "";
|
|
86
|
-
for (; len > 0; len--) {
|
|
87
|
-
str = randomChar2(prng) + str;
|
|
88
|
-
}
|
|
89
|
-
return str;
|
|
90
|
-
}
|
|
91
|
-
function decodeTime(id) {
|
|
92
|
-
if (id.length !== TIME_LEN2 + RANDOM_LEN2) {
|
|
93
|
-
throw createError("malformed ulid");
|
|
94
|
-
}
|
|
95
|
-
var time = id.substr(0, TIME_LEN2).split("").reverse().reduce((carry, char, index) => {
|
|
96
|
-
const encodingIndex = ENCODING2.indexOf(char);
|
|
97
|
-
if (encodingIndex === -1) {
|
|
98
|
-
throw createError("invalid character found: " + char);
|
|
99
|
-
}
|
|
100
|
-
return carry += encodingIndex * Math.pow(ENCODING_LEN2, index);
|
|
101
|
-
}, 0);
|
|
102
|
-
if (time > TIME_MAX2) {
|
|
103
|
-
throw createError("malformed ulid, timestamp too large");
|
|
104
|
-
}
|
|
105
|
-
return time;
|
|
106
|
-
}
|
|
107
|
-
function detectPrng(allowInsecure = false, root) {
|
|
108
|
-
if (!root) {
|
|
109
|
-
root = typeof window !== "undefined" ? window : null;
|
|
110
|
-
}
|
|
111
|
-
const browserCrypto = root && (root.crypto || root.msCrypto);
|
|
112
|
-
if (browserCrypto) {
|
|
113
|
-
return () => {
|
|
114
|
-
const buffer = new Uint8Array(1);
|
|
115
|
-
browserCrypto.getRandomValues(buffer);
|
|
116
|
-
return buffer[0] / 255;
|
|
117
|
-
};
|
|
118
|
-
} else {
|
|
119
|
-
try {
|
|
120
|
-
const nodeCrypto = __require("crypto");
|
|
121
|
-
return () => nodeCrypto.randomBytes(1).readUInt8() / 255;
|
|
122
|
-
} catch (e) {
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
if (allowInsecure) {
|
|
126
|
-
try {
|
|
127
|
-
console.error("secure crypto unusable, falling back to insecure Math.random()!");
|
|
128
|
-
} catch (e) {
|
|
129
|
-
}
|
|
130
|
-
return () => Math.random();
|
|
131
|
-
}
|
|
132
|
-
throw createError("secure crypto unusable, insecure Math.random not allowed");
|
|
133
|
-
}
|
|
134
|
-
function factory(currPrng) {
|
|
135
|
-
if (!currPrng) {
|
|
136
|
-
currPrng = detectPrng();
|
|
137
|
-
}
|
|
138
|
-
return function ulid3(seedTime) {
|
|
139
|
-
if (isNaN(seedTime)) {
|
|
140
|
-
seedTime = Date.now();
|
|
141
|
-
}
|
|
142
|
-
return encodeTime2(seedTime, TIME_LEN2) + encodeRandom2(RANDOM_LEN2, currPrng);
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
function monotonicFactory(currPrng) {
|
|
146
|
-
if (!currPrng) {
|
|
147
|
-
currPrng = detectPrng();
|
|
148
|
-
}
|
|
149
|
-
let lastTime = 0;
|
|
150
|
-
let lastRandom;
|
|
151
|
-
return function ulid3(seedTime) {
|
|
152
|
-
if (isNaN(seedTime)) {
|
|
153
|
-
seedTime = Date.now();
|
|
154
|
-
}
|
|
155
|
-
if (seedTime <= lastTime) {
|
|
156
|
-
const incrementedRandom = lastRandom = incrementBase32(lastRandom);
|
|
157
|
-
return encodeTime2(lastTime, TIME_LEN2) + incrementedRandom;
|
|
158
|
-
}
|
|
159
|
-
lastTime = seedTime;
|
|
160
|
-
const newRandom = lastRandom = encodeRandom2(RANDOM_LEN2, currPrng);
|
|
161
|
-
return encodeTime2(seedTime, TIME_LEN2) + newRandom;
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
const ulid2 = factory();
|
|
165
|
-
exports2.decodeTime = decodeTime;
|
|
166
|
-
exports2.detectPrng = detectPrng;
|
|
167
|
-
exports2.encodeRandom = encodeRandom2;
|
|
168
|
-
exports2.encodeTime = encodeTime2;
|
|
169
|
-
exports2.factory = factory;
|
|
170
|
-
exports2.incrementBase32 = incrementBase32;
|
|
171
|
-
exports2.monotonicFactory = monotonicFactory;
|
|
172
|
-
exports2.randomChar = randomChar2;
|
|
173
|
-
exports2.replaceCharAt = replaceCharAt;
|
|
174
|
-
exports2.ulid = ulid2;
|
|
175
|
-
}));
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
// ../../node_modules/@redocly/cli-otel/lib/index.js
|
|
180
|
-
var import_ulid = __toESM(require_index_umd(), 1);
|
|
181
|
-
var K = Object.defineProperty;
|
|
182
|
-
var q = (e, t) => {
|
|
183
|
-
for (var n in t) K(e, n, { get: t[n], enumerable: true });
|
|
184
|
-
};
|
|
185
|
-
var E = {};
|
|
186
|
-
q(E, { CLOUD_EVENT_STANDARD_KEYS: () => C, mapToCloudEvent: () => G });
|
|
187
|
-
var C = ["id", "specversion", "object", "datacontenttype", "type", "time", "origin", "env", "category", "signal", "source", "subject", "subjects", "data", "actor", "requestId", "clientIp", "organizationId", "organizationSlug", "projectId", "projectSlug", "osPlatform", "userAgent", "sessionId"];
|
|
188
|
-
function G(e) {
|
|
189
|
-
let { type: t, data: n, actor: o, requestId: s, clientIp: r, origin: i, env: c, source: u, organizationId: a, organizationSlug: g, projectId: d, projectSlug: I, category: N = "product", signal: $ = "log", osPlatform: B, userAgent: U, sessionId: W } = e, L = !!(n && Array.isArray(n)), m = o ? { id: o.id ?? `ann_${(0, import_ulid.ulid)()}`, object: o.object ?? "user", uri: o.uri ?? "" } : null, T = `evt_${(0, import_ulid.ulid)()}`.toLowerCase(), S = /* @__PURE__ */ new Date(), M = u ?? m?.uri ?? null, O = { ...a !== void 0 && { organizationId: a }, ...g !== void 0 && { organizationSlug: g }, ...d !== void 0 && { projectId: d }, ...I !== void 0 && { projectSlug: I } }, j = { specversion: "1.0", object: "event", datacontenttype: "application/json; charset=utf-8", origin: i, env: c, category: N, signal: $, osPlatform: B, userAgent: U, clientIp: r, sessionId: W };
|
|
190
|
-
if (L) {
|
|
191
|
-
let p = n, V = p.map((A) => ({ id: A.id ?? "", object: A.object ?? "", uri: A.uri ?? "" })), z = p[0]?.id ?? null;
|
|
192
|
-
Object.assign(j, { ...O, id: T, type: t, time: S, source: M, actor: m, subject: z, subjects: V, data: p, requestId: s ?? "" });
|
|
193
|
-
} else {
|
|
194
|
-
let p = (Array.isArray(n) ? n[0] : n)?.id ?? null;
|
|
195
|
-
Object.assign(j, { ...O, id: T, type: t, time: S, source: M, actor: m, subject: p, requestId: s ?? "", data: n, ...u != null && { request: { source: u } } });
|
|
196
|
-
}
|
|
197
|
-
return j;
|
|
198
|
-
}
|
|
199
|
-
function l(e) {
|
|
200
|
-
return e.replace(/([A-Z])/g, "_$1").toLowerCase();
|
|
201
|
-
}
|
|
202
|
-
function v(e) {
|
|
203
|
-
return e != null;
|
|
204
|
-
}
|
|
205
|
-
function y(e) {
|
|
206
|
-
return typeof e == "string" || typeof e == "number" || typeof e == "boolean";
|
|
207
|
-
}
|
|
208
|
-
function x(e, t, n, o = true, s) {
|
|
209
|
-
let r = s?.length ? new Set(s) : null;
|
|
210
|
-
for (let [i, c] of Object.entries(e)) if (!r?.has(i) && c !== void 0) {
|
|
211
|
-
let u = o ? l(i) : i;
|
|
212
|
-
n[`${t}${u}`] = c;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
function f(e, t, n, o) {
|
|
216
|
-
let s = o?.currentDepth ?? 0, r = o?.useSnakeCase ?? true, i = o?.maxNestingLevels ?? 3, c = t.endsWith(".") ? t.slice(0, -1) : t;
|
|
217
|
-
for (let [u, a] of Object.entries(e)) {
|
|
218
|
-
if (!v(a)) continue;
|
|
219
|
-
let g = r ? l(u) : u, d = `${c}.${g}`;
|
|
220
|
-
typeof a == "object" && !Array.isArray(a) ? s < i && f(a, d, n, { currentDepth: s + 1, useSnakeCase: r, maxNestingLevels: i }) : y(a) && (n[d] = a);
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
var _ = "context";
|
|
224
|
-
var h = [_];
|
|
225
|
-
function w(e) {
|
|
226
|
-
let t = { updated: [], notUpdated: [] };
|
|
227
|
-
for (let n of e) {
|
|
228
|
-
if (!n || typeof n != "object") continue;
|
|
229
|
-
let o = n.object;
|
|
230
|
-
if (typeof o != "string") continue;
|
|
231
|
-
let s = n, r = t.notUpdated.find((i) => i.object === o);
|
|
232
|
-
r ? (t.updated = [r, s], t.notUpdated = t.notUpdated.filter((i) => i.object !== o)) : t.updated.some((i) => i.object === o) || t.notUpdated.push(s);
|
|
233
|
-
}
|
|
234
|
-
return t;
|
|
235
|
-
}
|
|
236
|
-
function b(e, t, n) {
|
|
237
|
-
let o = n ? `${n}.` : "", s = t === "" ? "" : `${l(t)}.`;
|
|
238
|
-
return `${e}.${o}${s}`;
|
|
239
|
-
}
|
|
240
|
-
function P(e, t) {
|
|
241
|
-
let n = e[_];
|
|
242
|
-
return n === "before" || n === "after" ? n : t === 0 ? "after" : "before";
|
|
243
|
-
}
|
|
244
|
-
function k(e) {
|
|
245
|
-
let { [_]: t, ...n } = e;
|
|
246
|
-
return n;
|
|
247
|
-
}
|
|
248
|
-
function D(e) {
|
|
249
|
-
return e.endsWith(".") ? e : `${e}.`;
|
|
250
|
-
}
|
|
251
|
-
function Y(e, t, n) {
|
|
252
|
-
let o = t instanceof Date ? t.toISOString() : new Date(t).toISOString();
|
|
253
|
-
return { "cloudevents.event_id": e.id, "cloudevents.event_type": e.type, "cloudevents.event_source": e.source ?? void 0, "cloudevents.event_spec_version": e.specversion, "cloudevents.event_data_content_type": e.datacontenttype ?? "application/json; charset=utf-8", "cloudevents.event_time": o, "cloudevents.event_subject": e.subject ?? "", "cloudevents.event_version": n?.version, "cloudevents.event_origin": e.origin ?? n?.serviceName, "cloudevents.event_env": e.env, "cloudevents.event_client_ip": e.clientIp, "cloudevents.event_object": e.object || "event", "cloudevents.event_category": e.category, "cloudevents.event_signal": e.signal, "cloudevents.event_actor.id": e.actor?.id ?? void 0, "cloudevents.event_actor.object": e.actor?.object ?? void 0, "cloudevents.event_actor.uri": e.actor?.uri ?? void 0, "cloudevents.event_organization_id": e.organizationId, "cloudevents.event_organization_slug": e.organizationSlug, "cloudevents.event_project_id": e.projectId, "cloudevents.event_project_slug": e.projectSlug, "cloudevents.event_request_id": e.requestId, "cloudevents.event_os_platform": e.osPlatform, "cloudevents.event_user_agent": e.userAgent, "cloudevents.event_session_id": e.sessionId };
|
|
254
|
-
}
|
|
255
|
-
function F(e, t, n) {
|
|
256
|
-
let o = e.data, s = { ...Y(e, t, n) };
|
|
257
|
-
return X(o, s), ee(e, s), te(e, s), s;
|
|
258
|
-
}
|
|
259
|
-
function X(e, t) {
|
|
260
|
-
!e || typeof e != "object" || (Array.isArray(e) ? H(e, t) : Q(e, t));
|
|
261
|
-
}
|
|
262
|
-
function H(e, t) {
|
|
263
|
-
e.some((o) => o && typeof o == "object" && typeof o.object == "string") ? Z(e, t) : J(e, t);
|
|
264
|
-
}
|
|
265
|
-
function Z(e, t) {
|
|
266
|
-
let n = w(e);
|
|
267
|
-
n.updated.forEach((o, s) => {
|
|
268
|
-
let r = b("cloudevents.event_data", o.object, P(o, s));
|
|
269
|
-
f(k(o), D(r), t);
|
|
270
|
-
}), n.notUpdated.forEach((o) => {
|
|
271
|
-
let s = b("cloudevents.event_data", o.object, void 0);
|
|
272
|
-
f(k(o), D(s), t);
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
function J(e, t) {
|
|
276
|
-
for (let n of e) !n || typeof n != "object" || f(n, "cloudevents.event_data.", t);
|
|
277
|
-
}
|
|
278
|
-
function Q(e, t) {
|
|
279
|
-
for (let [n, o] of Object.entries(e)) {
|
|
280
|
-
if (!v(o)) continue;
|
|
281
|
-
let s = l(n);
|
|
282
|
-
if (typeof o == "object" && !Array.isArray(o)) for (let [r, i] of Object.entries(o)) v(i) && y(i) && (t[`cloudevents.event_data.${s}.${r}`] = i);
|
|
283
|
-
else y(o) && (t[`cloudevents.event_data.${s}`] = o);
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
function ee(e, t) {
|
|
287
|
-
if (!e.subjects || !Array.isArray(e.subjects)) return;
|
|
288
|
-
let n = w(e.subjects);
|
|
289
|
-
n.updated.forEach((o, s) => {
|
|
290
|
-
let r = b("cloudevents.event_subjects", o.object, P(o, s));
|
|
291
|
-
x(o, r, t, false, h);
|
|
292
|
-
}), n.notUpdated.forEach((o) => {
|
|
293
|
-
let s = b("cloudevents.event_subjects", o.object, void 0);
|
|
294
|
-
x(o, s, t, false, h);
|
|
295
|
-
});
|
|
296
|
-
}
|
|
297
|
-
function te(e, t) {
|
|
298
|
-
for (let [n, o] of Object.entries(e)) if (!(C.includes(n) || o === void 0)) if (o instanceof Object) for (let [s, r] of Object.entries(o)) r !== void 0 && (t[`cloudevents.${n}.${s}`] = r);
|
|
299
|
-
else t[`cloudevents.${n}`] = o;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
// ../../node_modules/ulid/dist/node/index.js
|
|
303
|
-
import crypto from "node:crypto";
|
|
304
|
-
var ENCODING = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
305
|
-
var ENCODING_LEN = 32;
|
|
306
|
-
var RANDOM_LEN = 16;
|
|
307
|
-
var TIME_LEN = 10;
|
|
308
|
-
var TIME_MAX = 281474976710655;
|
|
309
|
-
var ULIDErrorCode;
|
|
310
|
-
(function(ULIDErrorCode2) {
|
|
311
|
-
ULIDErrorCode2["Base32IncorrectEncoding"] = "B32_ENC_INVALID";
|
|
312
|
-
ULIDErrorCode2["DecodeTimeInvalidCharacter"] = "DEC_TIME_CHAR";
|
|
313
|
-
ULIDErrorCode2["DecodeTimeValueMalformed"] = "DEC_TIME_MALFORMED";
|
|
314
|
-
ULIDErrorCode2["EncodeTimeNegative"] = "ENC_TIME_NEG";
|
|
315
|
-
ULIDErrorCode2["EncodeTimeSizeExceeded"] = "ENC_TIME_SIZE_EXCEED";
|
|
316
|
-
ULIDErrorCode2["EncodeTimeValueMalformed"] = "ENC_TIME_MALFORMED";
|
|
317
|
-
ULIDErrorCode2["PRNGDetectFailure"] = "PRNG_DETECT";
|
|
318
|
-
ULIDErrorCode2["ULIDInvalid"] = "ULID_INVALID";
|
|
319
|
-
ULIDErrorCode2["Unexpected"] = "UNEXPECTED";
|
|
320
|
-
ULIDErrorCode2["UUIDInvalid"] = "UUID_INVALID";
|
|
321
|
-
})(ULIDErrorCode || (ULIDErrorCode = {}));
|
|
322
|
-
var ULIDError = class extends Error {
|
|
323
|
-
constructor(errorCode, message) {
|
|
324
|
-
super(`${message} (${errorCode})`);
|
|
325
|
-
this.name = "ULIDError";
|
|
326
|
-
this.code = errorCode;
|
|
327
|
-
}
|
|
328
|
-
};
|
|
329
|
-
function randomChar(prng) {
|
|
330
|
-
const randomPosition = Math.floor(prng() * ENCODING_LEN) % ENCODING_LEN;
|
|
331
|
-
return ENCODING.charAt(randomPosition);
|
|
332
|
-
}
|
|
333
|
-
function detectPRNG(root) {
|
|
334
|
-
const rootLookup = detectRoot();
|
|
335
|
-
const globalCrypto = rootLookup && (rootLookup.crypto || rootLookup.msCrypto) || (typeof crypto !== "undefined" ? crypto : null);
|
|
336
|
-
if (typeof globalCrypto?.getRandomValues === "function") {
|
|
337
|
-
return () => {
|
|
338
|
-
const buffer = new Uint8Array(1);
|
|
339
|
-
globalCrypto.getRandomValues(buffer);
|
|
340
|
-
return buffer[0] / 256;
|
|
341
|
-
};
|
|
342
|
-
} else if (typeof globalCrypto?.randomBytes === "function") {
|
|
343
|
-
return () => globalCrypto.randomBytes(1).readUInt8() / 256;
|
|
344
|
-
} else if (crypto?.randomBytes) {
|
|
345
|
-
return () => crypto.randomBytes(1).readUInt8() / 256;
|
|
346
|
-
}
|
|
347
|
-
throw new ULIDError(ULIDErrorCode.PRNGDetectFailure, "Failed to find a reliable PRNG");
|
|
348
|
-
}
|
|
349
|
-
function detectRoot() {
|
|
350
|
-
if (inWebWorker())
|
|
351
|
-
return self;
|
|
352
|
-
if (typeof window !== "undefined") {
|
|
353
|
-
return window;
|
|
354
|
-
}
|
|
355
|
-
if (typeof global !== "undefined") {
|
|
356
|
-
return global;
|
|
357
|
-
}
|
|
358
|
-
if (typeof globalThis !== "undefined") {
|
|
359
|
-
return globalThis;
|
|
360
|
-
}
|
|
361
|
-
return null;
|
|
362
|
-
}
|
|
363
|
-
function encodeRandom(len, prng) {
|
|
364
|
-
let str = "";
|
|
365
|
-
for (; len > 0; len--) {
|
|
366
|
-
str = randomChar(prng) + str;
|
|
367
|
-
}
|
|
368
|
-
return str;
|
|
369
|
-
}
|
|
370
|
-
function encodeTime(now, len = TIME_LEN) {
|
|
371
|
-
if (isNaN(now)) {
|
|
372
|
-
throw new ULIDError(ULIDErrorCode.EncodeTimeValueMalformed, `Time must be a number: ${now}`);
|
|
373
|
-
} else if (now > TIME_MAX) {
|
|
374
|
-
throw new ULIDError(ULIDErrorCode.EncodeTimeSizeExceeded, `Cannot encode a time larger than ${TIME_MAX}: ${now}`);
|
|
375
|
-
} else if (now < 0) {
|
|
376
|
-
throw new ULIDError(ULIDErrorCode.EncodeTimeNegative, `Time must be positive: ${now}`);
|
|
377
|
-
} else if (Number.isInteger(now) === false) {
|
|
378
|
-
throw new ULIDError(ULIDErrorCode.EncodeTimeValueMalformed, `Time must be an integer: ${now}`);
|
|
379
|
-
}
|
|
380
|
-
let mod, str = "";
|
|
381
|
-
for (let currentLen = len; currentLen > 0; currentLen--) {
|
|
382
|
-
mod = now % ENCODING_LEN;
|
|
383
|
-
str = ENCODING.charAt(mod) + str;
|
|
384
|
-
now = (now - mod) / ENCODING_LEN;
|
|
385
|
-
}
|
|
386
|
-
return str;
|
|
387
|
-
}
|
|
388
|
-
function inWebWorker() {
|
|
389
|
-
return typeof WorkerGlobalScope !== "undefined" && self instanceof WorkerGlobalScope;
|
|
390
|
-
}
|
|
391
|
-
function ulid(seedTime, prng) {
|
|
392
|
-
const currentPRNG = prng || detectPRNG();
|
|
393
|
-
const seed = !seedTime || isNaN(seedTime) ? Date.now() : seedTime;
|
|
394
|
-
return encodeTime(seed, TIME_LEN) + encodeRandom(RANDOM_LEN, currentPRNG);
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
export {
|
|
398
|
-
E,
|
|
399
|
-
F,
|
|
400
|
-
ulid
|
|
401
|
-
};
|