@kubb/agent 5.0.0-beta.1 → 5.0.0-beta.11
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/.output/nitro.json +1 -1
- package/.output/server/chunks/nitro/nitro.mjs +464 -476
- package/.output/server/chunks/nitro/nitro.mjs.map +1 -1
- package/.output/server/chunks/routes/api/health.get.mjs +1 -1
- package/.output/server/index.mjs +1 -1
- package/.output/server/node_modules/ajv/dist/2019.d.ts +1 -1
- package/.output/server/node_modules/ajv/dist/2019.js.map +1 -1
- package/.output/server/node_modules/ajv/dist/2020.d.ts +1 -1
- package/.output/server/node_modules/ajv/dist/2020.js.map +1 -1
- package/.output/server/node_modules/ajv/dist/ajv.d.ts +1 -1
- package/.output/server/node_modules/ajv/dist/ajv.js.map +1 -1
- package/.output/server/node_modules/ajv/dist/compile/index.d.ts +2 -1
- package/.output/server/node_modules/ajv/dist/compile/index.js +10 -3
- package/.output/server/node_modules/ajv/dist/compile/index.js.map +1 -1
- package/.output/server/node_modules/ajv/dist/compile/jtd/parse.js +1 -1
- package/.output/server/node_modules/ajv/dist/compile/jtd/parse.js.map +1 -1
- package/.output/server/node_modules/ajv/dist/compile/jtd/serialize.js +1 -1
- package/.output/server/node_modules/ajv/dist/compile/jtd/serialize.js.map +1 -1
- package/.output/server/node_modules/ajv/dist/compile/names.d.ts +1 -0
- package/.output/server/node_modules/ajv/dist/compile/names.js +1 -0
- package/.output/server/node_modules/ajv/dist/compile/names.js.map +1 -1
- package/.output/server/node_modules/ajv/dist/compile/validate/index.d.ts +1 -1
- package/.output/server/node_modules/ajv/dist/compile/validate/index.js +18 -4
- package/.output/server/node_modules/ajv/dist/compile/validate/index.js.map +1 -1
- package/.output/server/node_modules/ajv/dist/core.d.ts +4 -0
- package/.output/server/node_modules/ajv/dist/core.js +15 -1
- package/.output/server/node_modules/ajv/dist/core.js.map +1 -1
- package/.output/server/node_modules/ajv/dist/draft4.d.ts +19 -0
- package/.output/server/node_modules/ajv/dist/draft4.js +57 -0
- package/.output/server/node_modules/ajv/dist/draft4.js.map +1 -0
- package/.output/server/node_modules/ajv/dist/refs/json-schema-draft-04.json +138 -0
- package/.output/server/node_modules/ajv/dist/types/index.d.ts +3 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +2 -1
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js.map +1 -1
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/allOf.js +1 -1
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/allOf.js.map +1 -1
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/properties.js +2 -1
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/properties.js.map +1 -1
- package/.output/server/node_modules/ajv/dist/vocabularies/code.d.ts +1 -1
- package/.output/server/node_modules/ajv/dist/vocabularies/code.js +10 -3
- package/.output/server/node_modules/ajv/dist/vocabularies/code.js.map +1 -1
- package/.output/server/node_modules/ajv/dist/vocabularies/core/ref.js +12 -2
- package/.output/server/node_modules/ajv/dist/vocabularies/core/ref.js.map +1 -1
- package/.output/server/node_modules/ajv/dist/vocabularies/discriminator/index.js +56 -21
- package/.output/server/node_modules/ajv/dist/vocabularies/discriminator/index.js.map +1 -1
- package/.output/server/node_modules/ajv/dist/vocabularies/draft4.d.ts +3 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/draft4.js +29 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/draft4.js.map +1 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/metadata.js +10 -2
- package/.output/server/node_modules/ajv/dist/vocabularies/metadata.js.map +1 -1
- package/.output/server/node_modules/ajv/dist/vocabularies/oasContext.d.ts +3 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/oasContext.js +26 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/oasContext.js.map +1 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedProperties.js +22 -3
- package/.output/server/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedProperties.js.map +1 -1
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/draft04/limitNumber.d.ts +12 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/draft04/limitNumber.js +43 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/draft04/limitNumber.js.map +1 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/draft04/limitNumberExclusive.d.ts +3 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/draft04/limitNumberExclusive.js +19 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/draft04/limitNumberExclusive.js.map +1 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/index.js +4 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/index.js.map +1 -1
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/readOnly.d.ts +3 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/readOnly.js +20 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/readOnly.js.map +1 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/required.js +8 -1
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/required.js.map +1 -1
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/writeOnly.d.ts +3 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/writeOnly.js +20 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/writeOnly.js.map +1 -0
- package/.output/server/node_modules/ajv/lib/2019.ts +1 -0
- package/.output/server/node_modules/ajv/lib/2020.ts +1 -0
- package/.output/server/node_modules/ajv/lib/ajv.ts +1 -0
- package/.output/server/node_modules/ajv/lib/compile/index.ts +16 -3
- package/.output/server/node_modules/ajv/lib/compile/jtd/parse.ts +3 -1
- package/.output/server/node_modules/ajv/lib/compile/jtd/serialize.ts +3 -1
- package/.output/server/node_modules/ajv/lib/compile/names.ts +1 -0
- package/.output/server/node_modules/ajv/lib/compile/validate/index.ts +21 -4
- package/.output/server/node_modules/ajv/lib/core.ts +20 -1
- package/.output/server/node_modules/ajv/lib/draft4.ts +79 -0
- package/.output/server/node_modules/ajv/lib/refs/json-schema-draft-04.json +138 -0
- package/.output/server/node_modules/ajv/lib/types/index.ts +4 -0
- package/.output/server/node_modules/ajv/lib/vocabularies/applicator/additionalProperties.ts +2 -1
- package/.output/server/node_modules/ajv/lib/vocabularies/applicator/allOf.ts +1 -1
- package/.output/server/node_modules/ajv/lib/vocabularies/applicator/properties.ts +4 -1
- package/.output/server/node_modules/ajv/lib/vocabularies/code.ts +10 -3
- package/.output/server/node_modules/ajv/lib/vocabularies/core/ref.ts +21 -5
- package/.output/server/node_modules/ajv/lib/vocabularies/discriminator/index.ts +69 -19
- package/.output/server/node_modules/ajv/lib/vocabularies/draft4.ts +32 -0
- package/.output/server/node_modules/ajv/lib/vocabularies/metadata.ts +10 -2
- package/.output/server/node_modules/ajv/lib/vocabularies/oasContext.ts +27 -0
- package/.output/server/node_modules/ajv/lib/vocabularies/unevaluated/unevaluatedProperties.ts +29 -7
- package/.output/server/node_modules/ajv/lib/vocabularies/validation/draft04/limitNumber.ts +75 -0
- package/.output/server/node_modules/ajv/lib/vocabularies/validation/draft04/limitNumberExclusive.ts +26 -0
- package/.output/server/node_modules/ajv/lib/vocabularies/validation/index.ts +4 -0
- package/.output/server/node_modules/ajv/lib/vocabularies/validation/readOnly.ts +23 -0
- package/.output/server/node_modules/ajv/lib/vocabularies/validation/required.ts +7 -1
- package/.output/server/node_modules/ajv/lib/vocabularies/validation/writeOnly.ts +22 -0
- package/.output/server/node_modules/ajv/package.json +9 -6
- package/.output/server/node_modules/jiti/LICENSE +21 -0
- package/.output/server/node_modules/jiti/README.md +258 -0
- package/.output/server/node_modules/jiti/dist/babel.cjs +257 -0
- package/.output/server/node_modules/jiti/dist/jiti.cjs +1 -0
- package/.output/server/node_modules/jiti/lib/jiti-cli.mjs +34 -0
- package/.output/server/node_modules/jiti/lib/jiti-hooks.mjs +124 -0
- package/.output/server/node_modules/jiti/lib/jiti-native.mjs +121 -0
- package/.output/server/node_modules/jiti/lib/jiti-register.d.mts +1 -0
- package/.output/server/node_modules/jiti/lib/jiti-register.mjs +4 -0
- package/.output/server/node_modules/jiti/lib/jiti-static.mjs +23 -0
- package/.output/server/node_modules/jiti/lib/jiti.cjs +30 -0
- package/.output/server/node_modules/jiti/lib/jiti.d.cts +8 -0
- package/.output/server/node_modules/jiti/lib/jiti.d.mts +8 -0
- package/.output/server/node_modules/jiti/lib/jiti.mjs +29 -0
- package/.output/server/node_modules/jiti/lib/types.d.ts +420 -0
- package/.output/server/node_modules/jiti/package.json +146 -0
- package/.output/server/package.json +2 -5
- package/README.md +62 -27
- package/package.json +13 -12
- package/.output/server/node_modules/@rolldown/binding-linux-x64-gnu/package.json +0 -40
- package/.output/server/node_modules/@rolldown/binding-linux-x64-gnu/rolldown-binding.linux-x64-gnu.node +0 -0
- package/.output/server/node_modules/@rolldown/pluginutils/dist/filter/composable-filters.js +0 -256
- package/.output/server/node_modules/@rolldown/pluginutils/dist/filter/filter-vite-plugins.js +0 -75
- package/.output/server/node_modules/@rolldown/pluginutils/dist/filter/index.js +0 -3
- package/.output/server/node_modules/@rolldown/pluginutils/dist/filter/simple-filters.js +0 -70
- package/.output/server/node_modules/@rolldown/pluginutils/dist/index.js +0 -1
- package/.output/server/node_modules/@rolldown/pluginutils/dist/utils.js +0 -17
- package/.output/server/node_modules/@rolldown/pluginutils/package.json +0 -37
- package/.output/server/node_modules/rolldown/dist/index.mjs +0 -50
- package/.output/server/node_modules/rolldown/dist/parse-ast-index.mjs +0 -60
- package/.output/server/node_modules/rolldown/dist/shared/binding-BeU_1iEk.mjs +0 -582
- package/.output/server/node_modules/rolldown/dist/shared/bindingify-input-options-DbbBhzky.mjs +0 -2211
- package/.output/server/node_modules/rolldown/dist/shared/define-config-DJOr6Iwt.mjs +0 -6
- package/.output/server/node_modules/rolldown/dist/shared/error-DL-e8-oE.mjs +0 -85
- package/.output/server/node_modules/rolldown/dist/shared/logs-D80CXhvg.mjs +0 -180
- package/.output/server/node_modules/rolldown/dist/shared/misc-DJYbNKZX.mjs +0 -21
- package/.output/server/node_modules/rolldown/dist/shared/normalize-string-or-regex-CbQQ69gT.mjs +0 -66
- package/.output/server/node_modules/rolldown/dist/shared/parse-B_ZnWxLZ.mjs +0 -74
- package/.output/server/node_modules/rolldown/dist/shared/prompt-U5ajztzG.mjs +0 -847
- package/.output/server/node_modules/rolldown/dist/shared/rolldown-D3JZ9rMt.mjs +0 -40
- package/.output/server/node_modules/rolldown/dist/shared/rolldown-build-DSxL8qiP.mjs +0 -3325
- package/.output/server/node_modules/rolldown/dist/shared/watch-Bd8v9ewv.mjs +0 -374
- package/.output/server/node_modules/rolldown/package.json +0 -153
- package/.output/server/node_modules/unrun/dist/index.mjs +0 -2
- package/.output/server/node_modules/unrun/dist/src-GU5PtktT.mjs +0 -887
- package/.output/server/node_modules/unrun/package.json +0 -125
|
@@ -18,7 +18,7 @@ import { deflateSync } from 'fflate';
|
|
|
18
18
|
import { x } from 'tinyexec';
|
|
19
19
|
import { access, rm, readFile as readFile$1, readdir as readdir$1, mkdir, writeFile as writeFile$1 } from 'node:fs/promises';
|
|
20
20
|
import { styleText } from 'node:util';
|
|
21
|
-
import {
|
|
21
|
+
import { createJiti } from 'jiti';
|
|
22
22
|
import { mergeDeep } from 'remeda';
|
|
23
23
|
import WebSocket from 'ws';
|
|
24
24
|
|
|
@@ -90,26 +90,26 @@ function destr(value, options = {}) {
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
const HASH_RE
|
|
94
|
-
const AMPERSAND_RE
|
|
95
|
-
const SLASH_RE
|
|
96
|
-
const EQUAL_RE
|
|
97
|
-
const PLUS_RE
|
|
98
|
-
const ENC_CARET_RE
|
|
99
|
-
const ENC_BACKTICK_RE
|
|
100
|
-
const ENC_PIPE_RE
|
|
101
|
-
const ENC_SPACE_RE
|
|
93
|
+
const HASH_RE = /#/g;
|
|
94
|
+
const AMPERSAND_RE = /&/g;
|
|
95
|
+
const SLASH_RE = /\//g;
|
|
96
|
+
const EQUAL_RE = /=/g;
|
|
97
|
+
const PLUS_RE = /\+/g;
|
|
98
|
+
const ENC_CARET_RE = /%5e/gi;
|
|
99
|
+
const ENC_BACKTICK_RE = /%60/gi;
|
|
100
|
+
const ENC_PIPE_RE = /%7c/gi;
|
|
101
|
+
const ENC_SPACE_RE = /%20/gi;
|
|
102
102
|
const ENC_SLASH_RE = /%2f/gi;
|
|
103
|
-
function encode
|
|
104
|
-
return encodeURI("" + text).replace(ENC_PIPE_RE
|
|
103
|
+
function encode(text) {
|
|
104
|
+
return encodeURI("" + text).replace(ENC_PIPE_RE, "|");
|
|
105
105
|
}
|
|
106
|
-
function encodeQueryValue
|
|
107
|
-
return encode
|
|
106
|
+
function encodeQueryValue(input) {
|
|
107
|
+
return encode(typeof input === "string" ? input : JSON.stringify(input)).replace(PLUS_RE, "%2B").replace(ENC_SPACE_RE, "+").replace(HASH_RE, "%23").replace(AMPERSAND_RE, "%26").replace(ENC_BACKTICK_RE, "`").replace(ENC_CARET_RE, "^").replace(SLASH_RE, "%2F");
|
|
108
108
|
}
|
|
109
|
-
function encodeQueryKey
|
|
110
|
-
return encodeQueryValue
|
|
109
|
+
function encodeQueryKey(text) {
|
|
110
|
+
return encodeQueryValue(text).replace(EQUAL_RE, "%3D");
|
|
111
111
|
}
|
|
112
|
-
function decode
|
|
112
|
+
function decode(text = "") {
|
|
113
113
|
try {
|
|
114
114
|
return decodeURIComponent("" + text);
|
|
115
115
|
} catch {
|
|
@@ -117,16 +117,16 @@ function decode$1(text = "") {
|
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
function decodePath(text) {
|
|
120
|
-
return decode
|
|
120
|
+
return decode(text.replace(ENC_SLASH_RE, "%252F"));
|
|
121
121
|
}
|
|
122
|
-
function decodeQueryKey
|
|
123
|
-
return decode
|
|
122
|
+
function decodeQueryKey(text) {
|
|
123
|
+
return decode(text.replace(PLUS_RE, " "));
|
|
124
124
|
}
|
|
125
|
-
function decodeQueryValue
|
|
126
|
-
return decode
|
|
125
|
+
function decodeQueryValue(text) {
|
|
126
|
+
return decode(text.replace(PLUS_RE, " "));
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
function parseQuery
|
|
129
|
+
function parseQuery(parametersString = "") {
|
|
130
130
|
const object = /* @__PURE__ */ Object.create(null);
|
|
131
131
|
if (parametersString[0] === "?") {
|
|
132
132
|
parametersString = parametersString.slice(1);
|
|
@@ -136,11 +136,11 @@ function parseQuery$1(parametersString = "") {
|
|
|
136
136
|
if (s.length < 2) {
|
|
137
137
|
continue;
|
|
138
138
|
}
|
|
139
|
-
const key = decodeQueryKey
|
|
139
|
+
const key = decodeQueryKey(s[1]);
|
|
140
140
|
if (key === "__proto__" || key === "constructor") {
|
|
141
141
|
continue;
|
|
142
142
|
}
|
|
143
|
-
const value = decodeQueryValue
|
|
143
|
+
const value = decodeQueryValue(s[2] || "");
|
|
144
144
|
if (object[key] === void 0) {
|
|
145
145
|
object[key] = value;
|
|
146
146
|
} else if (Array.isArray(object[key])) {
|
|
@@ -151,48 +151,48 @@ function parseQuery$1(parametersString = "") {
|
|
|
151
151
|
}
|
|
152
152
|
return object;
|
|
153
153
|
}
|
|
154
|
-
function encodeQueryItem
|
|
154
|
+
function encodeQueryItem(key, value) {
|
|
155
155
|
if (typeof value === "number" || typeof value === "boolean") {
|
|
156
156
|
value = String(value);
|
|
157
157
|
}
|
|
158
158
|
if (!value) {
|
|
159
|
-
return encodeQueryKey
|
|
159
|
+
return encodeQueryKey(key);
|
|
160
160
|
}
|
|
161
161
|
if (Array.isArray(value)) {
|
|
162
162
|
return value.map(
|
|
163
|
-
(_value) => `${encodeQueryKey
|
|
163
|
+
(_value) => `${encodeQueryKey(key)}=${encodeQueryValue(_value)}`
|
|
164
164
|
).join("&");
|
|
165
165
|
}
|
|
166
|
-
return `${encodeQueryKey
|
|
166
|
+
return `${encodeQueryKey(key)}=${encodeQueryValue(value)}`;
|
|
167
167
|
}
|
|
168
|
-
function stringifyQuery
|
|
169
|
-
return Object.keys(query).filter((k) => query[k] !== void 0).map((k) => encodeQueryItem
|
|
168
|
+
function stringifyQuery(query) {
|
|
169
|
+
return Object.keys(query).filter((k) => query[k] !== void 0).map((k) => encodeQueryItem(k, query[k])).filter(Boolean).join("&");
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
const PROTOCOL_STRICT_REGEX
|
|
173
|
-
const PROTOCOL_REGEX
|
|
174
|
-
const PROTOCOL_RELATIVE_REGEX
|
|
175
|
-
const JOIN_LEADING_SLASH_RE
|
|
176
|
-
function hasProtocol
|
|
172
|
+
const PROTOCOL_STRICT_REGEX = /^[\s\w\0+.-]{2,}:([/\\]{1,2})/;
|
|
173
|
+
const PROTOCOL_REGEX = /^[\s\w\0+.-]{2,}:([/\\]{2})?/;
|
|
174
|
+
const PROTOCOL_RELATIVE_REGEX = /^([/\\]\s*){2,}[^/\\]/;
|
|
175
|
+
const JOIN_LEADING_SLASH_RE = /^\.?\//;
|
|
176
|
+
function hasProtocol(inputString, opts = {}) {
|
|
177
177
|
if (typeof opts === "boolean") {
|
|
178
178
|
opts = { acceptRelative: opts };
|
|
179
179
|
}
|
|
180
180
|
if (opts.strict) {
|
|
181
|
-
return PROTOCOL_STRICT_REGEX
|
|
181
|
+
return PROTOCOL_STRICT_REGEX.test(inputString);
|
|
182
182
|
}
|
|
183
|
-
return PROTOCOL_REGEX
|
|
183
|
+
return PROTOCOL_REGEX.test(inputString) || (opts.acceptRelative ? PROTOCOL_RELATIVE_REGEX.test(inputString) : false);
|
|
184
184
|
}
|
|
185
|
-
function hasTrailingSlash
|
|
185
|
+
function hasTrailingSlash(input = "", respectQueryAndFragment) {
|
|
186
186
|
{
|
|
187
187
|
return input.endsWith("/");
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
|
-
function withoutTrailingSlash
|
|
190
|
+
function withoutTrailingSlash(input = "", respectQueryAndFragment) {
|
|
191
191
|
{
|
|
192
|
-
return (hasTrailingSlash
|
|
192
|
+
return (hasTrailingSlash(input) ? input.slice(0, -1) : input) || "/";
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
|
-
function withTrailingSlash
|
|
195
|
+
function withTrailingSlash(input = "", respectQueryAndFragment) {
|
|
196
196
|
{
|
|
197
197
|
return input.endsWith("/") ? input : input + "/";
|
|
198
198
|
}
|
|
@@ -204,36 +204,54 @@ function withLeadingSlash(input = "") {
|
|
|
204
204
|
return hasLeadingSlash(input) ? input : "/" + input;
|
|
205
205
|
}
|
|
206
206
|
function withBase(input, base) {
|
|
207
|
-
if (isEmptyURL
|
|
207
|
+
if (isEmptyURL(base) || hasProtocol(input)) {
|
|
208
208
|
return input;
|
|
209
209
|
}
|
|
210
|
-
const _base = withoutTrailingSlash
|
|
210
|
+
const _base = withoutTrailingSlash(base);
|
|
211
211
|
if (input.startsWith(_base)) {
|
|
212
212
|
const nextChar = input[_base.length];
|
|
213
213
|
if (!nextChar || nextChar === "/" || nextChar === "?") {
|
|
214
214
|
return input;
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
|
-
return joinURL
|
|
217
|
+
return joinURL(_base, input);
|
|
218
|
+
}
|
|
219
|
+
function withoutBase(input, base) {
|
|
220
|
+
if (isEmptyURL(base)) {
|
|
221
|
+
return input;
|
|
222
|
+
}
|
|
223
|
+
const _base = withoutTrailingSlash(base);
|
|
224
|
+
if (!input.startsWith(_base)) {
|
|
225
|
+
return input;
|
|
226
|
+
}
|
|
227
|
+
const nextChar = input[_base.length];
|
|
228
|
+
if (nextChar && nextChar !== "/" && nextChar !== "?") {
|
|
229
|
+
return input;
|
|
230
|
+
}
|
|
231
|
+
const trimmed = input.slice(_base.length).replace(/^\/+/, "");
|
|
232
|
+
return "/" + trimmed;
|
|
233
|
+
}
|
|
234
|
+
function withQuery(input, query) {
|
|
235
|
+
const parsed = parseURL(input);
|
|
236
|
+
const mergedQuery = { ...parseQuery(parsed.search), ...query };
|
|
237
|
+
parsed.search = stringifyQuery(mergedQuery);
|
|
238
|
+
return stringifyParsedURL(parsed);
|
|
218
239
|
}
|
|
219
|
-
function
|
|
220
|
-
|
|
221
|
-
const mergedQuery = { ...parseQuery$1(parsed.search), ...query };
|
|
222
|
-
parsed.search = stringifyQuery$1(mergedQuery);
|
|
223
|
-
return stringifyParsedURL$1(parsed);
|
|
240
|
+
function getQuery(input) {
|
|
241
|
+
return parseQuery(parseURL(input).search);
|
|
224
242
|
}
|
|
225
|
-
function isEmptyURL
|
|
243
|
+
function isEmptyURL(url) {
|
|
226
244
|
return !url || url === "/";
|
|
227
245
|
}
|
|
228
|
-
function isNonEmptyURL
|
|
246
|
+
function isNonEmptyURL(url) {
|
|
229
247
|
return url && url !== "/";
|
|
230
248
|
}
|
|
231
|
-
function joinURL
|
|
249
|
+
function joinURL(base, ...input) {
|
|
232
250
|
let url = base || "";
|
|
233
|
-
for (const segment of input.filter((url2) => isNonEmptyURL
|
|
251
|
+
for (const segment of input.filter((url2) => isNonEmptyURL(url2))) {
|
|
234
252
|
if (url) {
|
|
235
|
-
const _segment = segment.replace(JOIN_LEADING_SLASH_RE
|
|
236
|
-
url = withTrailingSlash
|
|
253
|
+
const _segment = segment.replace(JOIN_LEADING_SLASH_RE, "");
|
|
254
|
+
url = withTrailingSlash(url) + _segment;
|
|
237
255
|
} else {
|
|
238
256
|
url = segment;
|
|
239
257
|
}
|
|
@@ -241,8 +259,8 @@ function joinURL$1(base, ...input) {
|
|
|
241
259
|
return url;
|
|
242
260
|
}
|
|
243
261
|
|
|
244
|
-
const protocolRelative
|
|
245
|
-
function parseURL
|
|
262
|
+
const protocolRelative = Symbol.for("ufo:protocolRelative");
|
|
263
|
+
function parseURL(input = "", defaultProto) {
|
|
246
264
|
const _specialProtoMatch = input.match(
|
|
247
265
|
/^[\s\0]*(blob:|data:|javascript:|vbscript:)(.*)/i
|
|
248
266
|
);
|
|
@@ -258,15 +276,15 @@ function parseURL$1(input = "", defaultProto) {
|
|
|
258
276
|
hash: ""
|
|
259
277
|
};
|
|
260
278
|
}
|
|
261
|
-
if (!hasProtocol
|
|
262
|
-
return parsePath
|
|
279
|
+
if (!hasProtocol(input, { acceptRelative: true })) {
|
|
280
|
+
return parsePath(input);
|
|
263
281
|
}
|
|
264
282
|
const [, protocol = "", auth, hostAndPath = ""] = input.replace(/\\/g, "/").match(/^[\s\0]*([\w+.-]{2,}:)?\/\/([^/@]+@)?(.*)/) || [];
|
|
265
283
|
let [, host = "", path = ""] = hostAndPath.match(/([^#/?]*)(.*)?/) || [];
|
|
266
284
|
if (protocol === "file:") {
|
|
267
285
|
path = path.replace(/\/(?=[A-Za-z]:)/, "");
|
|
268
286
|
}
|
|
269
|
-
const { pathname, search, hash } = parsePath
|
|
287
|
+
const { pathname, search, hash } = parsePath(path);
|
|
270
288
|
return {
|
|
271
289
|
protocol: protocol.toLowerCase(),
|
|
272
290
|
auth: auth ? auth.slice(0, Math.max(0, auth.length - 1)) : "",
|
|
@@ -274,10 +292,10 @@ function parseURL$1(input = "", defaultProto) {
|
|
|
274
292
|
pathname,
|
|
275
293
|
search,
|
|
276
294
|
hash,
|
|
277
|
-
[protocolRelative
|
|
295
|
+
[protocolRelative]: !protocol
|
|
278
296
|
};
|
|
279
297
|
}
|
|
280
|
-
function parsePath
|
|
298
|
+
function parsePath(input = "") {
|
|
281
299
|
const [pathname = "", search = "", hash = ""] = (input.match(/([^#?]*)(\?[^#]*)?(#.*)?/) || []).splice(1);
|
|
282
300
|
return {
|
|
283
301
|
pathname,
|
|
@@ -285,13 +303,13 @@ function parsePath$1(input = "") {
|
|
|
285
303
|
hash
|
|
286
304
|
};
|
|
287
305
|
}
|
|
288
|
-
function stringifyParsedURL
|
|
306
|
+
function stringifyParsedURL(parsed) {
|
|
289
307
|
const pathname = parsed.pathname || "";
|
|
290
308
|
const search = parsed.search ? (parsed.search.startsWith("?") ? "" : "?") + parsed.search : "";
|
|
291
309
|
const hash = parsed.hash || "";
|
|
292
310
|
const auth = parsed.auth ? parsed.auth + "@" : "";
|
|
293
311
|
const host = parsed.host || "";
|
|
294
|
-
const proto = parsed.protocol || parsed[protocolRelative
|
|
312
|
+
const proto = parsed.protocol || parsed[protocolRelative] ? (parsed.protocol || "") + "//" : "";
|
|
295
313
|
return proto + auth + host + pathname + search + hash;
|
|
296
314
|
}
|
|
297
315
|
|
|
@@ -1591,7 +1609,7 @@ function createResolver(stack) {
|
|
|
1591
1609
|
res = {
|
|
1592
1610
|
...res,
|
|
1593
1611
|
..._res,
|
|
1594
|
-
route: joinURL
|
|
1612
|
+
route: joinURL(res.route || "/", _res.route || "/")
|
|
1595
1613
|
};
|
|
1596
1614
|
}
|
|
1597
1615
|
return res;
|
|
@@ -1609,7 +1627,7 @@ function normalizeLayer(input) {
|
|
|
1609
1627
|
handler = toEventHandler(handler, void 0, input.route);
|
|
1610
1628
|
}
|
|
1611
1629
|
return {
|
|
1612
|
-
route: withoutTrailingSlash
|
|
1630
|
+
route: withoutTrailingSlash(input.route),
|
|
1613
1631
|
match: input.match,
|
|
1614
1632
|
handler
|
|
1615
1633
|
};
|
|
@@ -1676,7 +1694,7 @@ function websocketOptions(evResolver, appOptions) {
|
|
|
1676
1694
|
...appOptions.websocket,
|
|
1677
1695
|
async resolve(info) {
|
|
1678
1696
|
const url = info.request?.url || info.url || "/";
|
|
1679
|
-
const { pathname } = typeof url === "string" ? parseURL
|
|
1697
|
+
const { pathname } = typeof url === "string" ? parseURL(url) : url;
|
|
1680
1698
|
const resolved = await evResolver(pathname);
|
|
1681
1699
|
return resolved?.handler?.__websocket__ || {};
|
|
1682
1700
|
}
|
|
@@ -2268,7 +2286,7 @@ function createFetch(globalOptions = {}) {
|
|
|
2268
2286
|
context.request = withBase(context.request, context.options.baseURL);
|
|
2269
2287
|
}
|
|
2270
2288
|
if (context.options.query) {
|
|
2271
|
-
context.request = withQuery
|
|
2289
|
+
context.request = withQuery(context.request, context.options.query);
|
|
2272
2290
|
delete context.options.query;
|
|
2273
2291
|
}
|
|
2274
2292
|
if ("query" in context.options) {
|
|
@@ -2413,206 +2431,6 @@ const Headers$1 = globalThis.Headers || s$1;
|
|
|
2413
2431
|
const AbortController = globalThis.AbortController || i;
|
|
2414
2432
|
createFetch({ fetch, Headers: Headers$1, AbortController });
|
|
2415
2433
|
|
|
2416
|
-
const HASH_RE = /#/g;
|
|
2417
|
-
const AMPERSAND_RE = /&/g;
|
|
2418
|
-
const SLASH_RE = /\//g;
|
|
2419
|
-
const EQUAL_RE = /=/g;
|
|
2420
|
-
const PLUS_RE = /\+/g;
|
|
2421
|
-
const ENC_CARET_RE = /%5e/gi;
|
|
2422
|
-
const ENC_BACKTICK_RE = /%60/gi;
|
|
2423
|
-
const ENC_PIPE_RE = /%7c/gi;
|
|
2424
|
-
const ENC_SPACE_RE = /%20/gi;
|
|
2425
|
-
function encode(text) {
|
|
2426
|
-
return encodeURI("" + text).replace(ENC_PIPE_RE, "|");
|
|
2427
|
-
}
|
|
2428
|
-
function encodeQueryValue(input) {
|
|
2429
|
-
return encode(typeof input === "string" ? input : JSON.stringify(input)).replace(PLUS_RE, "%2B").replace(ENC_SPACE_RE, "+").replace(HASH_RE, "%23").replace(AMPERSAND_RE, "%26").replace(ENC_BACKTICK_RE, "`").replace(ENC_CARET_RE, "^").replace(SLASH_RE, "%2F");
|
|
2430
|
-
}
|
|
2431
|
-
function encodeQueryKey(text) {
|
|
2432
|
-
return encodeQueryValue(text).replace(EQUAL_RE, "%3D");
|
|
2433
|
-
}
|
|
2434
|
-
function decode(text = "") {
|
|
2435
|
-
try {
|
|
2436
|
-
return decodeURIComponent("" + text);
|
|
2437
|
-
} catch {
|
|
2438
|
-
return "" + text;
|
|
2439
|
-
}
|
|
2440
|
-
}
|
|
2441
|
-
function decodeQueryKey(text) {
|
|
2442
|
-
return decode(text.replace(PLUS_RE, " "));
|
|
2443
|
-
}
|
|
2444
|
-
function decodeQueryValue(text) {
|
|
2445
|
-
return decode(text.replace(PLUS_RE, " "));
|
|
2446
|
-
}
|
|
2447
|
-
|
|
2448
|
-
function parseQuery(parametersString = "") {
|
|
2449
|
-
const object = /* @__PURE__ */ Object.create(null);
|
|
2450
|
-
if (parametersString[0] === "?") {
|
|
2451
|
-
parametersString = parametersString.slice(1);
|
|
2452
|
-
}
|
|
2453
|
-
for (const parameter of parametersString.split("&")) {
|
|
2454
|
-
const s = parameter.match(/([^=]+)=?(.*)/) || [];
|
|
2455
|
-
if (s.length < 2) {
|
|
2456
|
-
continue;
|
|
2457
|
-
}
|
|
2458
|
-
const key = decodeQueryKey(s[1]);
|
|
2459
|
-
if (key === "__proto__" || key === "constructor") {
|
|
2460
|
-
continue;
|
|
2461
|
-
}
|
|
2462
|
-
const value = decodeQueryValue(s[2] || "");
|
|
2463
|
-
if (object[key] === void 0) {
|
|
2464
|
-
object[key] = value;
|
|
2465
|
-
} else if (Array.isArray(object[key])) {
|
|
2466
|
-
object[key].push(value);
|
|
2467
|
-
} else {
|
|
2468
|
-
object[key] = [object[key], value];
|
|
2469
|
-
}
|
|
2470
|
-
}
|
|
2471
|
-
return object;
|
|
2472
|
-
}
|
|
2473
|
-
function encodeQueryItem(key, value) {
|
|
2474
|
-
if (typeof value === "number" || typeof value === "boolean") {
|
|
2475
|
-
value = String(value);
|
|
2476
|
-
}
|
|
2477
|
-
if (!value) {
|
|
2478
|
-
return encodeQueryKey(key);
|
|
2479
|
-
}
|
|
2480
|
-
if (Array.isArray(value)) {
|
|
2481
|
-
return value.map(
|
|
2482
|
-
(_value) => `${encodeQueryKey(key)}=${encodeQueryValue(_value)}`
|
|
2483
|
-
).join("&");
|
|
2484
|
-
}
|
|
2485
|
-
return `${encodeQueryKey(key)}=${encodeQueryValue(value)}`;
|
|
2486
|
-
}
|
|
2487
|
-
function stringifyQuery(query) {
|
|
2488
|
-
return Object.keys(query).filter((k) => query[k] !== void 0).map((k) => encodeQueryItem(k, query[k])).filter(Boolean).join("&");
|
|
2489
|
-
}
|
|
2490
|
-
|
|
2491
|
-
const PROTOCOL_STRICT_REGEX = /^[\s\w\0+.-]{2,}:([/\\]{1,2})/;
|
|
2492
|
-
const PROTOCOL_REGEX = /^[\s\w\0+.-]{2,}:([/\\]{2})?/;
|
|
2493
|
-
const PROTOCOL_RELATIVE_REGEX = /^([/\\]\s*){2,}[^/\\]/;
|
|
2494
|
-
const JOIN_LEADING_SLASH_RE = /^\.?\//;
|
|
2495
|
-
function hasProtocol(inputString, opts = {}) {
|
|
2496
|
-
if (typeof opts === "boolean") {
|
|
2497
|
-
opts = { acceptRelative: opts };
|
|
2498
|
-
}
|
|
2499
|
-
if (opts.strict) {
|
|
2500
|
-
return PROTOCOL_STRICT_REGEX.test(inputString);
|
|
2501
|
-
}
|
|
2502
|
-
return PROTOCOL_REGEX.test(inputString) || (opts.acceptRelative ? PROTOCOL_RELATIVE_REGEX.test(inputString) : false);
|
|
2503
|
-
}
|
|
2504
|
-
function hasTrailingSlash(input = "", respectQueryAndFragment) {
|
|
2505
|
-
{
|
|
2506
|
-
return input.endsWith("/");
|
|
2507
|
-
}
|
|
2508
|
-
}
|
|
2509
|
-
function withoutTrailingSlash(input = "", respectQueryAndFragment) {
|
|
2510
|
-
{
|
|
2511
|
-
return (hasTrailingSlash(input) ? input.slice(0, -1) : input) || "/";
|
|
2512
|
-
}
|
|
2513
|
-
}
|
|
2514
|
-
function withTrailingSlash(input = "", respectQueryAndFragment) {
|
|
2515
|
-
{
|
|
2516
|
-
return input.endsWith("/") ? input : input + "/";
|
|
2517
|
-
}
|
|
2518
|
-
}
|
|
2519
|
-
function withoutBase(input, base) {
|
|
2520
|
-
if (isEmptyURL(base)) {
|
|
2521
|
-
return input;
|
|
2522
|
-
}
|
|
2523
|
-
const _base = withoutTrailingSlash(base);
|
|
2524
|
-
if (!input.startsWith(_base)) {
|
|
2525
|
-
return input;
|
|
2526
|
-
}
|
|
2527
|
-
const nextChar = input[_base.length];
|
|
2528
|
-
if (nextChar && nextChar !== "/" && nextChar !== "?") {
|
|
2529
|
-
return input;
|
|
2530
|
-
}
|
|
2531
|
-
const trimmed = input.slice(_base.length).replace(/^\/+/, "");
|
|
2532
|
-
return "/" + trimmed;
|
|
2533
|
-
}
|
|
2534
|
-
function withQuery(input, query) {
|
|
2535
|
-
const parsed = parseURL(input);
|
|
2536
|
-
const mergedQuery = { ...parseQuery(parsed.search), ...query };
|
|
2537
|
-
parsed.search = stringifyQuery(mergedQuery);
|
|
2538
|
-
return stringifyParsedURL(parsed);
|
|
2539
|
-
}
|
|
2540
|
-
function getQuery(input) {
|
|
2541
|
-
return parseQuery(parseURL(input).search);
|
|
2542
|
-
}
|
|
2543
|
-
function isEmptyURL(url) {
|
|
2544
|
-
return !url || url === "/";
|
|
2545
|
-
}
|
|
2546
|
-
function isNonEmptyURL(url) {
|
|
2547
|
-
return url && url !== "/";
|
|
2548
|
-
}
|
|
2549
|
-
function joinURL(base, ...input) {
|
|
2550
|
-
let url = base || "";
|
|
2551
|
-
for (const segment of input.filter((url2) => isNonEmptyURL(url2))) {
|
|
2552
|
-
if (url) {
|
|
2553
|
-
const _segment = segment.replace(JOIN_LEADING_SLASH_RE, "");
|
|
2554
|
-
url = withTrailingSlash(url) + _segment;
|
|
2555
|
-
} else {
|
|
2556
|
-
url = segment;
|
|
2557
|
-
}
|
|
2558
|
-
}
|
|
2559
|
-
return url;
|
|
2560
|
-
}
|
|
2561
|
-
|
|
2562
|
-
const protocolRelative = Symbol.for("ufo:protocolRelative");
|
|
2563
|
-
function parseURL(input = "", defaultProto) {
|
|
2564
|
-
const _specialProtoMatch = input.match(
|
|
2565
|
-
/^[\s\0]*(blob:|data:|javascript:|vbscript:)(.*)/i
|
|
2566
|
-
);
|
|
2567
|
-
if (_specialProtoMatch) {
|
|
2568
|
-
const [, _proto, _pathname = ""] = _specialProtoMatch;
|
|
2569
|
-
return {
|
|
2570
|
-
protocol: _proto.toLowerCase(),
|
|
2571
|
-
pathname: _pathname,
|
|
2572
|
-
href: _proto + _pathname,
|
|
2573
|
-
auth: "",
|
|
2574
|
-
host: "",
|
|
2575
|
-
search: "",
|
|
2576
|
-
hash: ""
|
|
2577
|
-
};
|
|
2578
|
-
}
|
|
2579
|
-
if (!hasProtocol(input, { acceptRelative: true })) {
|
|
2580
|
-
return defaultProto ? parseURL(defaultProto + input) : parsePath(input);
|
|
2581
|
-
}
|
|
2582
|
-
const [, protocol = "", auth, hostAndPath = ""] = input.replace(/\\/g, "/").match(/^[\s\0]*([\w+.-]{2,}:)?\/\/([^/@]+@)?(.*)/) || [];
|
|
2583
|
-
let [, host = "", path = ""] = hostAndPath.match(/([^#/?]*)(.*)?/) || [];
|
|
2584
|
-
if (protocol === "file:") {
|
|
2585
|
-
path = path.replace(/\/(?=[A-Za-z]:)/, "");
|
|
2586
|
-
}
|
|
2587
|
-
const { pathname, search, hash } = parsePath(path);
|
|
2588
|
-
return {
|
|
2589
|
-
protocol: protocol.toLowerCase(),
|
|
2590
|
-
auth: auth ? auth.slice(0, Math.max(0, auth.length - 1)) : "",
|
|
2591
|
-
host,
|
|
2592
|
-
pathname,
|
|
2593
|
-
search,
|
|
2594
|
-
hash,
|
|
2595
|
-
[protocolRelative]: !protocol
|
|
2596
|
-
};
|
|
2597
|
-
}
|
|
2598
|
-
function parsePath(input = "") {
|
|
2599
|
-
const [pathname = "", search = "", hash = ""] = (input.match(/([^#?]*)(\?[^#]*)?(#.*)?/) || []).splice(1);
|
|
2600
|
-
return {
|
|
2601
|
-
pathname,
|
|
2602
|
-
search,
|
|
2603
|
-
hash
|
|
2604
|
-
};
|
|
2605
|
-
}
|
|
2606
|
-
function stringifyParsedURL(parsed) {
|
|
2607
|
-
const pathname = parsed.pathname || "";
|
|
2608
|
-
const search = parsed.search ? (parsed.search.startsWith("?") ? "" : "?") + parsed.search : "";
|
|
2609
|
-
const hash = parsed.hash || "";
|
|
2610
|
-
const auth = parsed.auth ? parsed.auth + "@" : "";
|
|
2611
|
-
const host = parsed.host || "";
|
|
2612
|
-
const proto = parsed.protocol || parsed[protocolRelative] ? (parsed.protocol || "") + "//" : "";
|
|
2613
|
-
return proto + auth + host + pathname + search + hash;
|
|
2614
|
-
}
|
|
2615
|
-
|
|
2616
2434
|
function wrapToPromise(value) {
|
|
2617
2435
|
if (!value || typeof value.then !== "function") {
|
|
2618
2436
|
return Promise.resolve(value);
|
|
@@ -4608,11 +4426,14 @@ function sendToBetterStack(level, tag, message, ctx) {
|
|
|
4608
4426
|
const fullMessage = message !== void 0 ? `[${tag}] ${message}` : tag;
|
|
4609
4427
|
const context = toBetterStackContext(ctx);
|
|
4610
4428
|
if (level === "error") {
|
|
4611
|
-
client.error(fullMessage, context).then(() => client.flush())
|
|
4429
|
+
client.error(fullMessage, context).then(() => client.flush()).catch(() => {
|
|
4430
|
+
});
|
|
4612
4431
|
} else if (level === "warn") {
|
|
4613
|
-
client.warn(fullMessage, context).then(() => client.flush())
|
|
4432
|
+
client.warn(fullMessage, context).then(() => client.flush()).catch(() => {
|
|
4433
|
+
});
|
|
4614
4434
|
} else {
|
|
4615
|
-
client.info(fullMessage, context).then(() => client.flush())
|
|
4435
|
+
client.info(fullMessage, context).then(() => client.flush()).catch(() => {
|
|
4436
|
+
});
|
|
4616
4437
|
}
|
|
4617
4438
|
} catch (_e) {
|
|
4618
4439
|
}
|
|
@@ -4906,6 +4727,10 @@ function isKind(kind) {
|
|
|
4906
4727
|
}
|
|
4907
4728
|
const isOperationNode = isKind("Operation");
|
|
4908
4729
|
const isSchemaNode = isKind("Schema");
|
|
4730
|
+
function extractRefName(ref) {
|
|
4731
|
+
var _a;
|
|
4732
|
+
return (_a = ref.split("/").at(-1)) != null ? _a : ref;
|
|
4733
|
+
}
|
|
4909
4734
|
function createLimit(concurrency) {
|
|
4910
4735
|
let active = 0;
|
|
4911
4736
|
const queue = [];
|
|
@@ -5130,6 +4955,42 @@ function transform(node, options) {
|
|
|
5130
4955
|
return node;
|
|
5131
4956
|
}
|
|
5132
4957
|
}
|
|
4958
|
+
function collect(node, options) {
|
|
4959
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
4960
|
+
const { depth, parent, ...visitor } = options;
|
|
4961
|
+
const recurse = (depth != null ? depth : visitorDepths.deep) === visitorDepths.deep;
|
|
4962
|
+
const results = [];
|
|
4963
|
+
let v;
|
|
4964
|
+
switch (node.kind) {
|
|
4965
|
+
case "Input":
|
|
4966
|
+
v = (_a = visitor.input) == null ? void 0 : _a.call(visitor, node, { parent });
|
|
4967
|
+
break;
|
|
4968
|
+
case "Output":
|
|
4969
|
+
v = (_b = visitor.output) == null ? void 0 : _b.call(visitor, node, { parent });
|
|
4970
|
+
break;
|
|
4971
|
+
case "Operation":
|
|
4972
|
+
v = (_c = visitor.operation) == null ? void 0 : _c.call(visitor, node, { parent });
|
|
4973
|
+
break;
|
|
4974
|
+
case "Schema":
|
|
4975
|
+
v = (_d = visitor.schema) == null ? void 0 : _d.call(visitor, node, { parent });
|
|
4976
|
+
break;
|
|
4977
|
+
case "Property":
|
|
4978
|
+
v = (_e = visitor.property) == null ? void 0 : _e.call(visitor, node, { parent });
|
|
4979
|
+
break;
|
|
4980
|
+
case "Parameter":
|
|
4981
|
+
v = (_f = visitor.parameter) == null ? void 0 : _f.call(visitor, node, { parent });
|
|
4982
|
+
break;
|
|
4983
|
+
case "Response":
|
|
4984
|
+
v = (_g = visitor.response) == null ? void 0 : _g.call(visitor, node, { parent });
|
|
4985
|
+
break;
|
|
4986
|
+
}
|
|
4987
|
+
if (v !== void 0) results.push(v);
|
|
4988
|
+
for (const child of getChildren(node, recurse)) for (const item of collect(child, {
|
|
4989
|
+
...options,
|
|
4990
|
+
parent: node
|
|
4991
|
+
})) results.push(item);
|
|
4992
|
+
return results;
|
|
4993
|
+
}
|
|
5133
4994
|
function sourceKey(source) {
|
|
5134
4995
|
var _a, _b, _c;
|
|
5135
4996
|
return `${(_a = source.name) != null ? _a : extractStringsFromNodes(source.nodes)}:${(_b = source.isExportable) != null ? _b : false}:${(_c = source.isTypeOnly) != null ? _c : false}`;
|
|
@@ -5159,11 +5020,11 @@ function combineSources(sources) {
|
|
|
5159
5020
|
}
|
|
5160
5021
|
return [...seen.values()];
|
|
5161
5022
|
}
|
|
5162
|
-
function combineExports(exports
|
|
5023
|
+
function combineExports(exports) {
|
|
5163
5024
|
const result = [];
|
|
5164
5025
|
const namedByPath = /* @__PURE__ */ new Map();
|
|
5165
5026
|
const seen = /* @__PURE__ */ new Set();
|
|
5166
|
-
const keyed = exports
|
|
5027
|
+
const keyed = exports.map((node) => ({
|
|
5167
5028
|
node,
|
|
5168
5029
|
key: sortKey(node)
|
|
5169
5030
|
}));
|
|
@@ -5196,9 +5057,17 @@ function combineExports(exports$1) {
|
|
|
5196
5057
|
}
|
|
5197
5058
|
return result;
|
|
5198
5059
|
}
|
|
5199
|
-
function combineImports(imports, exports
|
|
5200
|
-
const exportedNames = new Set(exports
|
|
5060
|
+
function combineImports(imports, exports, source) {
|
|
5061
|
+
const exportedNames = new Set(exports.flatMap((e) => Array.isArray(e.name) ? e.name : e.name ? [e.name] : []));
|
|
5201
5062
|
const isUsed = (importName) => !source || source.includes(importName) || exportedNames.has(importName);
|
|
5063
|
+
const importNameMemo = /* @__PURE__ */ new Map();
|
|
5064
|
+
const canonicalizeName = (n) => {
|
|
5065
|
+
var _a;
|
|
5066
|
+
if (typeof n === "string") return n;
|
|
5067
|
+
const key = `${n.propertyName}:${(_a = n.name) != null ? _a : ""}`;
|
|
5068
|
+
if (!importNameMemo.has(key)) importNameMemo.set(key, n);
|
|
5069
|
+
return importNameMemo.get(key);
|
|
5070
|
+
};
|
|
5202
5071
|
const result = [];
|
|
5203
5072
|
const namedByPath = /* @__PURE__ */ new Map();
|
|
5204
5073
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -5212,7 +5081,10 @@ function combineImports(imports, exports$1, source) {
|
|
|
5212
5081
|
const { path: path2, isTypeOnly } = curr;
|
|
5213
5082
|
let { name } = curr;
|
|
5214
5083
|
if (Array.isArray(name)) {
|
|
5215
|
-
name = [...new Set(name)].filter((item) =>
|
|
5084
|
+
name = [...new Set(name.map(canonicalizeName))].filter((item) => {
|
|
5085
|
+
var _a;
|
|
5086
|
+
return typeof item === "string" ? isUsed(item) : isUsed((_a = item.name) != null ? _a : item.propertyName);
|
|
5087
|
+
});
|
|
5216
5088
|
if (!name.length) continue;
|
|
5217
5089
|
const key = pathTypeKey(path2, isTypeOnly);
|
|
5218
5090
|
const existing = namedByPath.get(key);
|
|
@@ -5256,6 +5128,40 @@ function extractStringsFromNodes(nodes) {
|
|
|
5256
5128
|
return parts.join("\n");
|
|
5257
5129
|
}).filter(Boolean).join("\n");
|
|
5258
5130
|
}
|
|
5131
|
+
function resolveRefName(node) {
|
|
5132
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
5133
|
+
if (!node || node.type !== "ref") return void 0;
|
|
5134
|
+
if (node.ref) return (_d = (_c = (_a = extractRefName(node.ref)) != null ? _a : node.name) != null ? _c : (_b = node.schema) == null ? void 0 : _b.name) != null ? _d : void 0;
|
|
5135
|
+
return (_g = (_f = node.name) != null ? _f : (_e = node.schema) == null ? void 0 : _e.name) != null ? _g : void 0;
|
|
5136
|
+
}
|
|
5137
|
+
function collectReferencedSchemaNames(node, out = /* @__PURE__ */ new Set()) {
|
|
5138
|
+
if (!node) return out;
|
|
5139
|
+
collect(node, { schema(child) {
|
|
5140
|
+
if (child.type === "ref") {
|
|
5141
|
+
const name = resolveRefName(child);
|
|
5142
|
+
if (name) out.add(name);
|
|
5143
|
+
}
|
|
5144
|
+
} });
|
|
5145
|
+
return out;
|
|
5146
|
+
}
|
|
5147
|
+
function collectUsedSchemaNames(operations, schemas) {
|
|
5148
|
+
const schemaMap = /* @__PURE__ */ new Map();
|
|
5149
|
+
for (const schema of schemas) if (schema.name) schemaMap.set(schema.name, schema);
|
|
5150
|
+
const result = /* @__PURE__ */ new Set();
|
|
5151
|
+
function visitSchema(schema) {
|
|
5152
|
+
const directRefs = collectReferencedSchemaNames(schema);
|
|
5153
|
+
for (const name of directRefs) if (!result.has(name)) {
|
|
5154
|
+
result.add(name);
|
|
5155
|
+
const namedSchema = schemaMap.get(name);
|
|
5156
|
+
if (namedSchema) visitSchema(namedSchema);
|
|
5157
|
+
}
|
|
5158
|
+
}
|
|
5159
|
+
for (const op of operations) for (const schema of collect(op, {
|
|
5160
|
+
depth: "shallow",
|
|
5161
|
+
schema: (node) => node
|
|
5162
|
+
})) visitSchema(schema);
|
|
5163
|
+
return result;
|
|
5164
|
+
}
|
|
5259
5165
|
function syncOptionality(schema, required) {
|
|
5260
5166
|
var _a;
|
|
5261
5167
|
const nullable = (_a = schema.nullable) != null ? _a : false;
|
|
@@ -5346,9 +5252,13 @@ function pascalCase(text, { isFile, prefix = "", suffix = "" } = {}) {
|
|
|
5346
5252
|
}) : camelCase(part));
|
|
5347
5253
|
return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true);
|
|
5348
5254
|
}
|
|
5349
|
-
const DEFAULT_STUDIO_URL = "https://
|
|
5255
|
+
const DEFAULT_STUDIO_URL = "https://kubb.studio";
|
|
5350
5256
|
const DEFAULT_BANNER = "simple";
|
|
5351
5257
|
const DEFAULT_EXTENSION = { ".ts": ".ts" };
|
|
5258
|
+
function getMode(fileOrFolder) {
|
|
5259
|
+
if (!fileOrFolder) return "split";
|
|
5260
|
+
return extname(fileOrFolder) ? "single" : "split";
|
|
5261
|
+
}
|
|
5352
5262
|
const stringPatternCache = /* @__PURE__ */ new Map();
|
|
5353
5263
|
function testPattern(value, pattern) {
|
|
5354
5264
|
if (typeof pattern === "string") {
|
|
@@ -5419,7 +5329,7 @@ function defaultResolveOptions(node, { options, exclude = [], include, override
|
|
|
5419
5329
|
}
|
|
5420
5330
|
function defaultResolvePath({ baseName, pathMode, tag, path: groupPath }, { root, output, group }) {
|
|
5421
5331
|
var _a2;
|
|
5422
|
-
if ((pathMode != null ? pathMode :
|
|
5332
|
+
if ((pathMode != null ? pathMode : getMode(path$1.resolve(root, output.path))) === "single") return path$1.resolve(root, output.path);
|
|
5423
5333
|
let result;
|
|
5424
5334
|
if (group && (groupPath || tag)) {
|
|
5425
5335
|
const groupValue = group.type === "path" ? groupPath : tag;
|
|
@@ -5435,10 +5345,10 @@ function defaultResolvePath({ baseName, pathMode, tag, path: groupPath }, { root
|
|
|
5435
5345
|
if (result !== outputDir && !result.startsWith(outputDirWithSep)) throw new Error(`[Kubb] Resolved path "${result}" is outside the output directory "${outputDir}". This may indicate a path traversal attempt in the OpenAPI specification or a misconfigured group.name function.`);
|
|
5436
5346
|
return result;
|
|
5437
5347
|
}
|
|
5438
|
-
function defaultResolveFile({ name, extname: extname2, tag, path: groupPath }, context
|
|
5439
|
-
const pathMode =
|
|
5440
|
-
const baseName = `${pathMode === "single" ? "" :
|
|
5441
|
-
const filePath =
|
|
5348
|
+
function defaultResolveFile({ name, extname: extname2, tag, path: groupPath }, context) {
|
|
5349
|
+
const pathMode = getMode(path$1.resolve(context.root, context.output.path));
|
|
5350
|
+
const baseName = `${pathMode === "single" ? "" : this.default(name, "file")}${extname2}`;
|
|
5351
|
+
const filePath = this.resolvePath({
|
|
5442
5352
|
baseName,
|
|
5443
5353
|
pathMode,
|
|
5444
5354
|
tag,
|
|
@@ -5447,7 +5357,7 @@ function defaultResolveFile({ name, extname: extname2, tag, path: groupPath }, c
|
|
|
5447
5357
|
return createFile({
|
|
5448
5358
|
path: filePath,
|
|
5449
5359
|
baseName: path$1.basename(filePath),
|
|
5450
|
-
meta: { pluginName:
|
|
5360
|
+
meta: { pluginName: this.pluginName },
|
|
5451
5361
|
sources: [],
|
|
5452
5362
|
imports: [],
|
|
5453
5363
|
exports: []
|
|
@@ -5459,8 +5369,8 @@ function buildDefaultBanner({ title, description, version, config }) {
|
|
|
5459
5369
|
if (Array.isArray(config.input)) {
|
|
5460
5370
|
const first = config.input[0];
|
|
5461
5371
|
if (first && "path" in first) source = path$1.basename(first.path);
|
|
5462
|
-
} else if ("path" in config.input) source = path$1.basename(config.input.path);
|
|
5463
|
-
else if ("data" in config.input) source = "text content";
|
|
5372
|
+
} else if (config.input && "path" in config.input) source = path$1.basename(config.input.path);
|
|
5373
|
+
else if (config.input && "data" in config.input) source = "text content";
|
|
5464
5374
|
let banner = "/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n";
|
|
5465
5375
|
if (config.output.defaultBanner === "simple") {
|
|
5466
5376
|
banner += "*/\n";
|
|
@@ -5499,16 +5409,16 @@ function defaultResolveFooter(node, { output }) {
|
|
|
5499
5409
|
if (typeof (output == null ? void 0 : output.footer) === "string") return output.footer;
|
|
5500
5410
|
}
|
|
5501
5411
|
function defineResolver(build) {
|
|
5502
|
-
|
|
5503
|
-
|
|
5412
|
+
let resolver;
|
|
5413
|
+
resolver = {
|
|
5504
5414
|
default: defaultResolver,
|
|
5505
5415
|
resolveOptions: defaultResolveOptions,
|
|
5506
5416
|
resolvePath: defaultResolvePath,
|
|
5507
|
-
resolveFile: (params, context) => defaultResolveFile(params, context
|
|
5417
|
+
resolveFile: (params, context) => defaultResolveFile.call(resolver, params, context),
|
|
5508
5418
|
resolveBanner: defaultResolveBanner,
|
|
5509
5419
|
resolveFooter: defaultResolveFooter,
|
|
5510
|
-
...build(
|
|
5511
|
-
}
|
|
5420
|
+
...build()
|
|
5421
|
+
};
|
|
5512
5422
|
return resolver;
|
|
5513
5423
|
}
|
|
5514
5424
|
function encodeAst(input) {
|
|
@@ -5588,6 +5498,13 @@ var FileManager = (_a$1 = class {
|
|
|
5588
5498
|
__privateSet$1(this, _filesCache, null);
|
|
5589
5499
|
}
|
|
5590
5500
|
/**
|
|
5501
|
+
* Releases all stored files. Called by the core after `kubb:build:end` to
|
|
5502
|
+
* free the per-plugin FileNode caches for the rest of the process lifetime.
|
|
5503
|
+
*/
|
|
5504
|
+
dispose() {
|
|
5505
|
+
this.clear();
|
|
5506
|
+
}
|
|
5507
|
+
/**
|
|
5591
5508
|
* All stored files, sorted by path length (shorter paths first).
|
|
5592
5509
|
*/
|
|
5593
5510
|
get files() {
|
|
@@ -5614,18 +5531,6 @@ var FileManager = (_a$1 = class {
|
|
|
5614
5531
|
__privateSet$1(this, _filesCache, null);
|
|
5615
5532
|
return resolvedFiles;
|
|
5616
5533
|
}, _a$1);
|
|
5617
|
-
async function applyHookResult(result, driver, rendererFactory) {
|
|
5618
|
-
if (!result) return;
|
|
5619
|
-
if (Array.isArray(result)) {
|
|
5620
|
-
driver.fileManager.upsert(...result);
|
|
5621
|
-
return;
|
|
5622
|
-
}
|
|
5623
|
-
if (!rendererFactory) return;
|
|
5624
|
-
const renderer = rendererFactory();
|
|
5625
|
-
await renderer.render(result);
|
|
5626
|
-
driver.fileManager.upsert(...renderer.files);
|
|
5627
|
-
renderer.unmount();
|
|
5628
|
-
}
|
|
5629
5534
|
function enforceOrder(enforce) {
|
|
5630
5535
|
return enforce === "pre" ? -1 : enforce === "post" ? 1 : 0;
|
|
5631
5536
|
}
|
|
@@ -5680,8 +5585,7 @@ var PluginDriver = (_b$1 = class {
|
|
|
5680
5585
|
* ```
|
|
5681
5586
|
*/
|
|
5682
5587
|
static getMode(fileOrFolder) {
|
|
5683
|
-
|
|
5684
|
-
return extname(fileOrFolder) ? "single" : "split";
|
|
5588
|
+
return getMode(fileOrFolder);
|
|
5685
5589
|
}
|
|
5686
5590
|
get hooks() {
|
|
5687
5591
|
return this.options.hooks;
|
|
@@ -5703,6 +5607,7 @@ var PluginDriver = (_b$1 = class {
|
|
|
5703
5607
|
*/
|
|
5704
5608
|
registerPluginHooks(hookPlugin, normalizedPlugin) {
|
|
5705
5609
|
const { hooks } = hookPlugin;
|
|
5610
|
+
if (!hooks) return;
|
|
5706
5611
|
if (hooks["kubb:plugin:setup"]) {
|
|
5707
5612
|
const setupHandler = (globalCtx) => {
|
|
5708
5613
|
var _a2;
|
|
@@ -5829,6 +5734,10 @@ var PluginDriver = (_b$1 = class {
|
|
|
5829
5734
|
for (const [event, handlers] of __privateGet$1(this, _hookListeners)) for (const handler of handlers) this.hooks.off(event, handler);
|
|
5830
5735
|
__privateGet$1(this, _hookListeners).clear();
|
|
5831
5736
|
__privateGet$1(this, _pluginsWithEventGenerators).clear();
|
|
5737
|
+
__privateGet$1(this, _resolvers).clear();
|
|
5738
|
+
__privateGet$1(this, _defaultResolvers).clear();
|
|
5739
|
+
this.fileManager.dispose();
|
|
5740
|
+
this.inputNode = void 0;
|
|
5832
5741
|
}
|
|
5833
5742
|
/**
|
|
5834
5743
|
* Merges `partial` with the plugin's default resolver and stores the result.
|
|
@@ -5897,7 +5806,7 @@ var PluginDriver = (_b$1 = class {
|
|
|
5897
5806
|
if (typeof driver.config.devtools !== "object") throw new Error("Devtools must be an object");
|
|
5898
5807
|
if (!driver.inputNode || !driver.adapter) throw new Error("adapter is not defined, make sure you have set the parser in kubb.config.ts");
|
|
5899
5808
|
__privateSet$1(driver, _studioIsOpen, true);
|
|
5900
|
-
const studioUrl = (_b2 = (_a2 = driver.config.devtools) == null ? void 0 : _a2.studioUrl) != null ? _b2 : "https://
|
|
5809
|
+
const studioUrl = (_b2 = (_a2 = driver.config.devtools) == null ? void 0 : _a2.studioUrl) != null ? _b2 : "https://kubb.studio";
|
|
5901
5810
|
return openInStudio(driver.inputNode, studioUrl, options);
|
|
5902
5811
|
}
|
|
5903
5812
|
};
|
|
@@ -5937,13 +5846,25 @@ normalizePlugin_fn = function(hookPlugin) {
|
|
|
5937
5846
|
}, createDefaultResolver_fn = function(pluginName) {
|
|
5938
5847
|
const existingResolver = __privateGet$1(this, _defaultResolvers).get(pluginName);
|
|
5939
5848
|
if (existingResolver) return existingResolver;
|
|
5940
|
-
const resolver = defineResolver((
|
|
5849
|
+
const resolver = defineResolver(() => ({
|
|
5941
5850
|
name: "default",
|
|
5942
5851
|
pluginName
|
|
5943
5852
|
}));
|
|
5944
5853
|
__privateGet$1(this, _defaultResolvers).set(pluginName, resolver);
|
|
5945
5854
|
return resolver;
|
|
5946
5855
|
}, _b$1);
|
|
5856
|
+
async function applyHookResult(result, driver, rendererFactory) {
|
|
5857
|
+
if (!result) return;
|
|
5858
|
+
if (Array.isArray(result)) {
|
|
5859
|
+
driver.fileManager.upsert(...result);
|
|
5860
|
+
return;
|
|
5861
|
+
}
|
|
5862
|
+
if (!rendererFactory) return;
|
|
5863
|
+
const renderer = rendererFactory();
|
|
5864
|
+
await renderer.render(result);
|
|
5865
|
+
driver.fileManager.upsert(...renderer.files);
|
|
5866
|
+
renderer.unmount();
|
|
5867
|
+
}
|
|
5947
5868
|
|
|
5948
5869
|
var __defProp = Object.defineProperty;
|
|
5949
5870
|
var __typeError = (msg) => {
|
|
@@ -6342,6 +6263,10 @@ eachParam_fn = function(fn) {
|
|
|
6342
6263
|
fn(raw, __privateMethod(this, _URLPath_instances, transformParam_fn).call(this, raw));
|
|
6343
6264
|
}
|
|
6344
6265
|
}, _b);
|
|
6266
|
+
var version$1 = "5.0.0-beta.11";
|
|
6267
|
+
function createStorage(build2) {
|
|
6268
|
+
return (options) => build2(options != null ? options : {});
|
|
6269
|
+
}
|
|
6345
6270
|
var Node$1 = (_c = class {
|
|
6346
6271
|
constructor(value) {
|
|
6347
6272
|
__publicField(this, "value");
|
|
@@ -6471,7 +6396,8 @@ function joinSources(file) {
|
|
|
6471
6396
|
}
|
|
6472
6397
|
var FileProcessor = (_e = class {
|
|
6473
6398
|
constructor() {
|
|
6474
|
-
|
|
6399
|
+
__publicField(this, "events", new AsyncEventEmitter());
|
|
6400
|
+
__privateAdd(this, _limit, pLimit(16));
|
|
6475
6401
|
}
|
|
6476
6402
|
async parse(file, { parsers, extension } = {}) {
|
|
6477
6403
|
const parseExtName = (extension == null ? void 0 : extension[file.extname]) || void 0;
|
|
@@ -6480,8 +6406,8 @@ var FileProcessor = (_e = class {
|
|
|
6480
6406
|
if (!parser) return joinSources(file);
|
|
6481
6407
|
return parser.parse(file, { extname: parseExtName });
|
|
6482
6408
|
}
|
|
6483
|
-
async run(files, { parsers, mode = "sequential", extension
|
|
6484
|
-
await (
|
|
6409
|
+
async run(files, { parsers, mode = "sequential", extension } = {}) {
|
|
6410
|
+
await this.events.emit("start", files);
|
|
6485
6411
|
const total = files.length;
|
|
6486
6412
|
let processed = 0;
|
|
6487
6413
|
const processOne = async (file) => {
|
|
@@ -6491,43 +6417,35 @@ var FileProcessor = (_e = class {
|
|
|
6491
6417
|
});
|
|
6492
6418
|
const currentProcessed = ++processed;
|
|
6493
6419
|
const percentage = currentProcessed / total * 100;
|
|
6494
|
-
await (
|
|
6420
|
+
await this.events.emit("update", {
|
|
6495
6421
|
file,
|
|
6496
6422
|
source,
|
|
6497
6423
|
processed: currentProcessed,
|
|
6498
6424
|
percentage,
|
|
6499
6425
|
total
|
|
6500
|
-
})
|
|
6426
|
+
});
|
|
6501
6427
|
};
|
|
6502
6428
|
if (mode === "sequential") for (const file of files) await processOne(file);
|
|
6503
6429
|
else await Promise.all(files.map((file) => __privateGet(this, _limit).call(this, () => processOne(file))));
|
|
6504
|
-
await (
|
|
6430
|
+
await this.events.emit("end", files);
|
|
6505
6431
|
return files;
|
|
6506
6432
|
}
|
|
6507
6433
|
}, _limit = new WeakMap(), _e);
|
|
6508
|
-
function createStorage(build2) {
|
|
6509
|
-
return (options) => build2(options != null ? options : {});
|
|
6510
|
-
}
|
|
6511
|
-
function isMissingPathError(error) {
|
|
6512
|
-
return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
|
|
6513
|
-
}
|
|
6514
6434
|
const fsStorage = createStorage(() => ({
|
|
6515
6435
|
name: "fs",
|
|
6516
6436
|
async hasItem(key) {
|
|
6517
6437
|
try {
|
|
6518
6438
|
await access(resolve(key));
|
|
6519
6439
|
return true;
|
|
6520
|
-
} catch (
|
|
6521
|
-
|
|
6522
|
-
throw new Error(`Failed to access storage item "${key}"`, { cause: error });
|
|
6440
|
+
} catch (_error) {
|
|
6441
|
+
return false;
|
|
6523
6442
|
}
|
|
6524
6443
|
},
|
|
6525
6444
|
async getItem(key) {
|
|
6526
6445
|
try {
|
|
6527
6446
|
return await readFile$1(resolve(key), "utf8");
|
|
6528
|
-
} catch (
|
|
6529
|
-
|
|
6530
|
-
throw new Error(`Failed to read storage item "${key}"`, { cause: error });
|
|
6447
|
+
} catch (_error) {
|
|
6448
|
+
return null;
|
|
6531
6449
|
}
|
|
6532
6450
|
},
|
|
6533
6451
|
async setItem(key, value) {
|
|
@@ -6543,9 +6461,8 @@ const fsStorage = createStorage(() => ({
|
|
|
6543
6461
|
let entries;
|
|
6544
6462
|
try {
|
|
6545
6463
|
entries = await readdir$1(dir, { withFileTypes: true });
|
|
6546
|
-
} catch (
|
|
6547
|
-
|
|
6548
|
-
throw new Error(`Failed to list storage keys under "${resolvedBase}"`, { cause: error });
|
|
6464
|
+
} catch (_error) {
|
|
6465
|
+
return;
|
|
6549
6466
|
}
|
|
6550
6467
|
for (const entry of entries) {
|
|
6551
6468
|
const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
@@ -6561,37 +6478,73 @@ const fsStorage = createStorage(() => ({
|
|
|
6561
6478
|
await clean(resolve(base));
|
|
6562
6479
|
}
|
|
6563
6480
|
}));
|
|
6564
|
-
|
|
6565
|
-
|
|
6566
|
-
return {
|
|
6567
|
-
|
|
6568
|
-
|
|
6569
|
-
|
|
6570
|
-
|
|
6571
|
-
|
|
6572
|
-
|
|
6573
|
-
}
|
|
6574
|
-
|
|
6575
|
-
|
|
6481
|
+
function createSourcesView(storage) {
|
|
6482
|
+
const paths = /* @__PURE__ */ new Set();
|
|
6483
|
+
return createStorage(() => ({
|
|
6484
|
+
name: `${storage.name}:sources`,
|
|
6485
|
+
async hasItem(key) {
|
|
6486
|
+
return paths.has(key) && await storage.hasItem(key);
|
|
6487
|
+
},
|
|
6488
|
+
async getItem(key) {
|
|
6489
|
+
return paths.has(key) ? storage.getItem(key) : null;
|
|
6490
|
+
},
|
|
6491
|
+
async setItem(key, value) {
|
|
6492
|
+
paths.add(key);
|
|
6493
|
+
await storage.setItem(key, value);
|
|
6494
|
+
},
|
|
6495
|
+
async removeItem(key) {
|
|
6496
|
+
paths.delete(key);
|
|
6497
|
+
await storage.removeItem(key);
|
|
6498
|
+
},
|
|
6499
|
+
async getKeys(base) {
|
|
6500
|
+
if (!base) return [...paths];
|
|
6501
|
+
const result = [];
|
|
6502
|
+
for (const key of paths) if (key.startsWith(base)) result.push(key);
|
|
6503
|
+
return result;
|
|
6504
|
+
},
|
|
6505
|
+
async clear() {
|
|
6506
|
+
paths.clear();
|
|
6507
|
+
await storage.clear();
|
|
6508
|
+
}
|
|
6509
|
+
}))();
|
|
6576
6510
|
}
|
|
6577
6511
|
async function setup(userConfig, options = {}) {
|
|
6578
6512
|
var _a2, _b2, _c2, _d2, _e2, _f, _g, _h, _i;
|
|
6579
6513
|
const hooks = (_a2 = options.hooks) != null ? _a2 : new AsyncEventEmitter();
|
|
6580
|
-
const
|
|
6514
|
+
const config = {
|
|
6515
|
+
...userConfig,
|
|
6516
|
+
root: userConfig.root || process.cwd(),
|
|
6517
|
+
parsers: (_b2 = userConfig.parsers) != null ? _b2 : [],
|
|
6518
|
+
adapter: userConfig.adapter,
|
|
6519
|
+
output: {
|
|
6520
|
+
format: false,
|
|
6521
|
+
lint: false,
|
|
6522
|
+
extension: DEFAULT_EXTENSION,
|
|
6523
|
+
defaultBanner: DEFAULT_BANNER,
|
|
6524
|
+
...userConfig.output
|
|
6525
|
+
},
|
|
6526
|
+
storage: (_c2 = userConfig.storage) != null ? _c2 : fsStorage(),
|
|
6527
|
+
devtools: userConfig.devtools ? {
|
|
6528
|
+
studioUrl: DEFAULT_STUDIO_URL,
|
|
6529
|
+
...typeof userConfig.devtools === "boolean" ? {} : userConfig.devtools
|
|
6530
|
+
} : void 0,
|
|
6531
|
+
plugins: (_d2 = userConfig.plugins) != null ? _d2 : []
|
|
6532
|
+
};
|
|
6533
|
+
const driver = new PluginDriver(config, { hooks });
|
|
6534
|
+
const storage = createSourcesView(config.storage);
|
|
6581
6535
|
const diagnosticInfo = getDiagnosticInfo();
|
|
6582
|
-
if (Array.isArray(userConfig.input)) await hooks.emit("kubb:warn", { message: "This feature is still under development \u2014 use with caution" });
|
|
6583
6536
|
await hooks.emit("kubb:debug", {
|
|
6584
6537
|
date: /* @__PURE__ */ new Date(),
|
|
6585
6538
|
logs: [
|
|
6586
6539
|
"Configuration:",
|
|
6587
6540
|
` \u2022 Name: ${userConfig.name || "unnamed"}`,
|
|
6588
6541
|
` \u2022 Root: ${userConfig.root || process.cwd()}`,
|
|
6589
|
-
` \u2022 Output: ${((
|
|
6590
|
-
` \u2022 Plugins: ${((
|
|
6542
|
+
` \u2022 Output: ${((_e2 = userConfig.output) == null ? void 0 : _e2.path) || "not specified"}`,
|
|
6543
|
+
` \u2022 Plugins: ${((_f = userConfig.plugins) == null ? void 0 : _f.length) || 0}`,
|
|
6591
6544
|
"Output Settings:",
|
|
6592
|
-
` \u2022 Storage: ${
|
|
6593
|
-
` \u2022 Formatter: ${((
|
|
6594
|
-
` \u2022 Linter: ${((
|
|
6545
|
+
` \u2022 Storage: ${config.storage.name}`,
|
|
6546
|
+
` \u2022 Formatter: ${((_g = userConfig.output) == null ? void 0 : _g.format) || "none"}`,
|
|
6547
|
+
` \u2022 Linter: ${((_h = userConfig.output) == null ? void 0 : _h.lint) || "none"}`,
|
|
6595
6548
|
"Environment:",
|
|
6596
6549
|
Object.entries(diagnosticInfo).map(([key, value]) => ` \u2022 ${key}: ${value}`).join("\n")
|
|
6597
6550
|
]
|
|
@@ -6610,73 +6563,50 @@ async function setup(userConfig, options = {}) {
|
|
|
6610
6563
|
throw new Error(`Cannot read file/URL defined in \`input.path\` or set with \`kubb generate PATH\` in the CLI of your Kubb config ${userConfig.input.path}`, { cause: error });
|
|
6611
6564
|
}
|
|
6612
6565
|
}
|
|
6613
|
-
if (!userConfig.adapter) throw new Error("Adapter should be defined");
|
|
6614
|
-
const config = {
|
|
6615
|
-
...userConfig,
|
|
6616
|
-
root: userConfig.root || process.cwd(),
|
|
6617
|
-
parsers: (_g = userConfig.parsers) != null ? _g : [],
|
|
6618
|
-
adapter: userConfig.adapter,
|
|
6619
|
-
output: {
|
|
6620
|
-
format: false,
|
|
6621
|
-
lint: false,
|
|
6622
|
-
write: true,
|
|
6623
|
-
extension: DEFAULT_EXTENSION,
|
|
6624
|
-
defaultBanner: DEFAULT_BANNER,
|
|
6625
|
-
...userConfig.output
|
|
6626
|
-
},
|
|
6627
|
-
devtools: userConfig.devtools ? {
|
|
6628
|
-
studioUrl: DEFAULT_STUDIO_URL,
|
|
6629
|
-
...typeof userConfig.devtools === "boolean" ? {} : userConfig.devtools
|
|
6630
|
-
} : void 0,
|
|
6631
|
-
plugins: userConfig.plugins
|
|
6632
|
-
};
|
|
6633
|
-
const storage = config.output.write === false ? null : (_h = config.storage) != null ? _h : fsStorage();
|
|
6634
6566
|
if (config.output.clean) {
|
|
6635
6567
|
await hooks.emit("kubb:debug", {
|
|
6636
6568
|
date: /* @__PURE__ */ new Date(),
|
|
6637
6569
|
logs: ["Cleaning output directories", ` \u2022 Output: ${config.output.path}`]
|
|
6638
6570
|
});
|
|
6639
|
-
await
|
|
6571
|
+
await config.storage.clear(resolve(config.root, config.output.path));
|
|
6640
6572
|
}
|
|
6641
|
-
const driver = new PluginDriver(config, { hooks });
|
|
6642
6573
|
function registerMiddlewareHook(event, middlewareHooks) {
|
|
6643
6574
|
const handler = middlewareHooks[event];
|
|
6644
6575
|
if (handler) hooks.on(event, handler);
|
|
6645
6576
|
}
|
|
6646
6577
|
for (const middleware of (_i = config.middleware) != null ? _i : []) for (const event of Object.keys(middleware.hooks)) registerMiddlewareHook(event, middleware.hooks);
|
|
6647
|
-
|
|
6648
|
-
|
|
6649
|
-
|
|
6650
|
-
|
|
6651
|
-
|
|
6652
|
-
|
|
6653
|
-
|
|
6654
|
-
|
|
6655
|
-
|
|
6656
|
-
|
|
6657
|
-
|
|
6658
|
-
|
|
6659
|
-
|
|
6660
|
-
|
|
6661
|
-
|
|
6662
|
-
|
|
6663
|
-
}
|
|
6578
|
+
if (config.adapter) {
|
|
6579
|
+
const source = inputToAdapterSource(config);
|
|
6580
|
+
await hooks.emit("kubb:debug", {
|
|
6581
|
+
date: /* @__PURE__ */ new Date(),
|
|
6582
|
+
logs: [`Running adapter: ${config.adapter.name}`]
|
|
6583
|
+
});
|
|
6584
|
+
driver.adapter = config.adapter;
|
|
6585
|
+
driver.inputNode = await config.adapter.parse(source);
|
|
6586
|
+
await hooks.emit("kubb:debug", {
|
|
6587
|
+
date: /* @__PURE__ */ new Date(),
|
|
6588
|
+
logs: [
|
|
6589
|
+
`\u2713 Adapter '${config.adapter.name}' resolved InputNode`,
|
|
6590
|
+
` \u2022 Schemas: ${driver.inputNode.schemas.length}`,
|
|
6591
|
+
` \u2022 Operations: ${driver.inputNode.operations.length}`
|
|
6592
|
+
]
|
|
6593
|
+
});
|
|
6594
|
+
}
|
|
6664
6595
|
return {
|
|
6665
6596
|
config,
|
|
6666
6597
|
hooks,
|
|
6667
6598
|
driver,
|
|
6668
|
-
sources,
|
|
6669
6599
|
storage
|
|
6670
6600
|
};
|
|
6671
6601
|
}
|
|
6672
6602
|
async function runPluginAstHooks(plugin, context) {
|
|
6673
|
-
var _a2;
|
|
6603
|
+
var _a2, _b2, _c2;
|
|
6674
6604
|
const { adapter, inputNode, resolver, driver } = context;
|
|
6675
6605
|
const { exclude, include, override } = plugin.options;
|
|
6676
|
-
if (!adapter || !inputNode) throw new Error(`[${plugin.name}] No adapter found. Add an OAS adapter (e.g.
|
|
6606
|
+
if (!adapter || !inputNode) throw new Error(`[${plugin.name}] No adapter found. Add an OAS adapter (e.g. adapterOas()) before this plugin in your Kubb config.`);
|
|
6677
6607
|
function resolveRenderer(gen) {
|
|
6678
|
-
var _a3,
|
|
6679
|
-
return gen.renderer === null ? void 0 : (
|
|
6608
|
+
var _a3, _b3;
|
|
6609
|
+
return gen.renderer === null ? void 0 : (_b3 = (_a3 = gen.renderer) != null ? _a3 : plugin.renderer) != null ? _b3 : context.config.renderer;
|
|
6680
6610
|
}
|
|
6681
6611
|
const generators = (_a2 = plugin.generators) != null ? _a2 : [];
|
|
6682
6612
|
const collectedOperations = [];
|
|
@@ -6684,10 +6614,27 @@ async function runPluginAstHooks(plugin, context) {
|
|
|
6684
6614
|
...context,
|
|
6685
6615
|
resolver: driver.getResolver(plugin.name)
|
|
6686
6616
|
};
|
|
6617
|
+
const operationFilterTypes = /* @__PURE__ */ new Set([
|
|
6618
|
+
"tag",
|
|
6619
|
+
"operationId",
|
|
6620
|
+
"path",
|
|
6621
|
+
"method",
|
|
6622
|
+
"contentType"
|
|
6623
|
+
]);
|
|
6624
|
+
const hasOperationBasedIncludes = (_b2 = include == null ? void 0 : include.some(({ type }) => operationFilterTypes.has(type))) != null ? _b2 : false;
|
|
6625
|
+
const hasSchemaNameIncludes = (_c2 = include == null ? void 0 : include.some(({ type }) => type === "schemaName")) != null ? _c2 : false;
|
|
6626
|
+
let allowedSchemaNames;
|
|
6627
|
+
if (hasOperationBasedIncludes && !hasSchemaNameIncludes) allowedSchemaNames = collectUsedSchemaNames(inputNode.operations.filter((op) => resolver.resolveOptions(op, {
|
|
6628
|
+
options: plugin.options,
|
|
6629
|
+
exclude,
|
|
6630
|
+
include,
|
|
6631
|
+
override
|
|
6632
|
+
}) !== null), inputNode.schemas);
|
|
6687
6633
|
await walk(inputNode, {
|
|
6688
6634
|
depth: "shallow",
|
|
6689
6635
|
async schema(node) {
|
|
6690
6636
|
const transformedNode = plugin.transformer ? transform(node, plugin.transformer) : node;
|
|
6637
|
+
if (allowedSchemaNames !== void 0 && transformedNode.name && !allowedSchemaNames.has(transformedNode.name)) return;
|
|
6691
6638
|
const options = resolver.resolveOptions(transformedNode, {
|
|
6692
6639
|
options: plugin.options,
|
|
6693
6640
|
exclude,
|
|
@@ -6741,10 +6688,49 @@ async function runPluginAstHooks(plugin, context) {
|
|
|
6741
6688
|
}
|
|
6742
6689
|
async function safeBuild(setupResult) {
|
|
6743
6690
|
var _a2;
|
|
6744
|
-
const { driver, hooks,
|
|
6691
|
+
const { driver, hooks, storage } = setupResult;
|
|
6745
6692
|
const failedPlugins = /* @__PURE__ */ new Set();
|
|
6746
6693
|
const pluginTimings = /* @__PURE__ */ new Map();
|
|
6747
6694
|
const config = driver.config;
|
|
6695
|
+
const writtenPaths = /* @__PURE__ */ new Set();
|
|
6696
|
+
const parsersMap = /* @__PURE__ */ new Map();
|
|
6697
|
+
for (const parser of config.parsers) if (parser.extNames) for (const extname of parser.extNames) parsersMap.set(extname, parser);
|
|
6698
|
+
const fileProcessor = new FileProcessor();
|
|
6699
|
+
fileProcessor.events.on("start", async (processingFiles) => {
|
|
6700
|
+
await hooks.emit("kubb:files:processing:start", { files: processingFiles });
|
|
6701
|
+
});
|
|
6702
|
+
fileProcessor.events.on("update", async ({ file, source, processed, total, percentage }) => {
|
|
6703
|
+
await hooks.emit("kubb:file:processing:update", {
|
|
6704
|
+
file,
|
|
6705
|
+
source,
|
|
6706
|
+
processed,
|
|
6707
|
+
total,
|
|
6708
|
+
percentage,
|
|
6709
|
+
config
|
|
6710
|
+
});
|
|
6711
|
+
if (source) await storage.setItem(file.path, source);
|
|
6712
|
+
});
|
|
6713
|
+
fileProcessor.events.on("end", async (processed) => {
|
|
6714
|
+
await hooks.emit("kubb:files:processing:end", { files: processed });
|
|
6715
|
+
await hooks.emit("kubb:debug", {
|
|
6716
|
+
date: /* @__PURE__ */ new Date(),
|
|
6717
|
+
logs: [`\u2713 File write process completed for ${processed.length} files`]
|
|
6718
|
+
});
|
|
6719
|
+
});
|
|
6720
|
+
async function flushPendingFiles() {
|
|
6721
|
+
const files = driver.fileManager.files.filter((f) => !writtenPaths.has(f.path));
|
|
6722
|
+
if (files.length === 0) return;
|
|
6723
|
+
await hooks.emit("kubb:debug", {
|
|
6724
|
+
date: /* @__PURE__ */ new Date(),
|
|
6725
|
+
logs: [`Writing ${files.length} files...`]
|
|
6726
|
+
});
|
|
6727
|
+
await fileProcessor.run(files, {
|
|
6728
|
+
parsers: parsersMap,
|
|
6729
|
+
mode: "parallel",
|
|
6730
|
+
extension: config.output.extension
|
|
6731
|
+
});
|
|
6732
|
+
for (const file of files) writtenPaths.add(file.path);
|
|
6733
|
+
}
|
|
6748
6734
|
try {
|
|
6749
6735
|
await driver.emitSetupHooks();
|
|
6750
6736
|
if (driver.adapter && driver.inputNode) await hooks.emit("kubb:build:start", {
|
|
@@ -6780,6 +6766,7 @@ async function safeBuild(setupResult) {
|
|
|
6780
6766
|
},
|
|
6781
6767
|
upsertFile: (...files2) => driver.fileManager.upsert(...files2)
|
|
6782
6768
|
});
|
|
6769
|
+
await flushPendingFiles();
|
|
6783
6770
|
await hooks.emit("kubb:debug", {
|
|
6784
6771
|
date: /* @__PURE__ */ new Date(),
|
|
6785
6772
|
logs: [`\u2713 Plugin started successfully (${formatMs(duration)})`]
|
|
@@ -6799,6 +6786,7 @@ async function safeBuild(setupResult) {
|
|
|
6799
6786
|
},
|
|
6800
6787
|
upsertFile: (...files2) => driver.fileManager.upsert(...files2)
|
|
6801
6788
|
});
|
|
6789
|
+
await flushPendingFiles();
|
|
6802
6790
|
await hooks.emit("kubb:debug", {
|
|
6803
6791
|
date: errorTimestamp,
|
|
6804
6792
|
logs: [
|
|
@@ -6822,42 +6810,8 @@ async function safeBuild(setupResult) {
|
|
|
6822
6810
|
},
|
|
6823
6811
|
upsertFile: (...files2) => driver.fileManager.upsert(...files2)
|
|
6824
6812
|
});
|
|
6813
|
+
await flushPendingFiles();
|
|
6825
6814
|
const files = driver.fileManager.files;
|
|
6826
|
-
const parsersMap = /* @__PURE__ */ new Map();
|
|
6827
|
-
for (const parser of config.parsers) if (parser.extNames) for (const extname of parser.extNames) parsersMap.set(extname, parser);
|
|
6828
|
-
const fileProcessor = new FileProcessor();
|
|
6829
|
-
await hooks.emit("kubb:debug", {
|
|
6830
|
-
date: /* @__PURE__ */ new Date(),
|
|
6831
|
-
logs: [`Writing ${files.length} files...`]
|
|
6832
|
-
});
|
|
6833
|
-
await fileProcessor.run(files, {
|
|
6834
|
-
parsers: parsersMap,
|
|
6835
|
-
extension: config.output.extension,
|
|
6836
|
-
onStart: async (processingFiles) => {
|
|
6837
|
-
await hooks.emit("kubb:files:processing:start", { files: processingFiles });
|
|
6838
|
-
},
|
|
6839
|
-
onUpdate: async ({ file, source, processed, total, percentage }) => {
|
|
6840
|
-
await hooks.emit("kubb:file:processing:update", {
|
|
6841
|
-
file,
|
|
6842
|
-
source,
|
|
6843
|
-
processed,
|
|
6844
|
-
total,
|
|
6845
|
-
percentage,
|
|
6846
|
-
config
|
|
6847
|
-
});
|
|
6848
|
-
if (source) {
|
|
6849
|
-
await (storage == null ? void 0 : storage.setItem(file.path, source));
|
|
6850
|
-
sources.set(file.path, source);
|
|
6851
|
-
}
|
|
6852
|
-
},
|
|
6853
|
-
onEnd: async (processedFiles) => {
|
|
6854
|
-
await hooks.emit("kubb:files:processing:end", { files: processedFiles });
|
|
6855
|
-
await hooks.emit("kubb:debug", {
|
|
6856
|
-
date: /* @__PURE__ */ new Date(),
|
|
6857
|
-
logs: [`\u2713 File write process completed for ${processedFiles.length} files`]
|
|
6858
|
-
});
|
|
6859
|
-
}
|
|
6860
|
-
});
|
|
6861
6815
|
await hooks.emit("kubb:build:end", {
|
|
6862
6816
|
files,
|
|
6863
6817
|
config,
|
|
@@ -6868,7 +6822,7 @@ async function safeBuild(setupResult) {
|
|
|
6868
6822
|
files,
|
|
6869
6823
|
driver,
|
|
6870
6824
|
pluginTimings,
|
|
6871
|
-
|
|
6825
|
+
storage
|
|
6872
6826
|
};
|
|
6873
6827
|
} catch (error) {
|
|
6874
6828
|
return {
|
|
@@ -6877,14 +6831,14 @@ async function safeBuild(setupResult) {
|
|
|
6877
6831
|
driver,
|
|
6878
6832
|
pluginTimings,
|
|
6879
6833
|
error,
|
|
6880
|
-
|
|
6834
|
+
storage
|
|
6881
6835
|
};
|
|
6882
6836
|
} finally {
|
|
6883
6837
|
driver.dispose();
|
|
6884
6838
|
}
|
|
6885
6839
|
}
|
|
6886
6840
|
async function build(setupResult) {
|
|
6887
|
-
const { files, driver, failedPlugins, pluginTimings, error,
|
|
6841
|
+
const { files, driver, failedPlugins, pluginTimings, error, storage } = await safeBuild(setupResult);
|
|
6888
6842
|
if (error) throw error;
|
|
6889
6843
|
if (failedPlugins.size > 0) {
|
|
6890
6844
|
const errors = [...failedPlugins].map(({ error: error2 }) => error2);
|
|
@@ -6896,25 +6850,35 @@ async function build(setupResult) {
|
|
|
6896
6850
|
driver,
|
|
6897
6851
|
pluginTimings,
|
|
6898
6852
|
error: void 0,
|
|
6899
|
-
|
|
6853
|
+
storage
|
|
6900
6854
|
};
|
|
6901
6855
|
}
|
|
6902
|
-
function
|
|
6903
|
-
|
|
6904
|
-
|
|
6905
|
-
|
|
6856
|
+
function getDiagnosticInfo() {
|
|
6857
|
+
return {
|
|
6858
|
+
nodeVersion: version$2,
|
|
6859
|
+
KubbVersion: version$1,
|
|
6860
|
+
platform: process.platform,
|
|
6861
|
+
arch: process.arch,
|
|
6862
|
+
cwd: process.cwd()
|
|
6906
6863
|
};
|
|
6907
|
-
|
|
6864
|
+
}
|
|
6865
|
+
function isInputPath(config) {
|
|
6866
|
+
return typeof (config == null ? void 0 : config.input) === "object" && config.input !== null && "path" in config.input;
|
|
6867
|
+
}
|
|
6868
|
+
function inputToAdapterSource(config) {
|
|
6869
|
+
const input = config.input;
|
|
6870
|
+
if (!input) throw new Error("[kubb] input is required when using an adapter. Provide input.path or input.data in your config.");
|
|
6871
|
+
if ("data" in input) return {
|
|
6908
6872
|
type: "data",
|
|
6909
|
-
data:
|
|
6873
|
+
data: input.data
|
|
6910
6874
|
};
|
|
6911
|
-
if (new URLPath(
|
|
6875
|
+
if (new URLPath(input.path).isURL) return {
|
|
6912
6876
|
type: "path",
|
|
6913
|
-
path:
|
|
6877
|
+
path: input.path
|
|
6914
6878
|
};
|
|
6915
6879
|
return {
|
|
6916
6880
|
type: "path",
|
|
6917
|
-
path: resolve(config.root,
|
|
6881
|
+
path: resolve(config.root, input.path)
|
|
6918
6882
|
};
|
|
6919
6883
|
}
|
|
6920
6884
|
function createKubb(userConfig, options = {}) {
|
|
@@ -6925,15 +6889,17 @@ function createKubb(userConfig, options = {}) {
|
|
|
6925
6889
|
get hooks() {
|
|
6926
6890
|
return hooks;
|
|
6927
6891
|
},
|
|
6928
|
-
get
|
|
6929
|
-
|
|
6930
|
-
return
|
|
6892
|
+
get storage() {
|
|
6893
|
+
if (!setupResult) throw new Error("[kubb] setup() must be called before accessing storage");
|
|
6894
|
+
return setupResult.storage;
|
|
6931
6895
|
},
|
|
6932
6896
|
get driver() {
|
|
6933
|
-
|
|
6897
|
+
if (!setupResult) throw new Error("[kubb] setup() must be called before accessing driver");
|
|
6898
|
+
return setupResult.driver;
|
|
6934
6899
|
},
|
|
6935
6900
|
get config() {
|
|
6936
|
-
|
|
6901
|
+
if (!setupResult) throw new Error("[kubb] setup() must be called before accessing config");
|
|
6902
|
+
return setupResult.config;
|
|
6937
6903
|
},
|
|
6938
6904
|
async setup() {
|
|
6939
6905
|
setupResult = await setup(userConfig, { hooks });
|
|
@@ -6980,7 +6946,7 @@ const memoryStorage = createStorage(() => {
|
|
|
6980
6946
|
};
|
|
6981
6947
|
});
|
|
6982
6948
|
|
|
6983
|
-
var version = "5.0.0-beta.
|
|
6949
|
+
var version = "5.0.0-beta.11";
|
|
6984
6950
|
|
|
6985
6951
|
function isCommandMessage(msg) {
|
|
6986
6952
|
return msg.type === "command";
|
|
@@ -7037,7 +7003,7 @@ async function generate({ config, hooks }) {
|
|
|
7037
7003
|
const kubb = createKubb(config, { hooks });
|
|
7038
7004
|
await kubb.setup();
|
|
7039
7005
|
await hooks.emit("kubb:info", { message: config.name ? `Build generation ${config.name}` : "Build generation" });
|
|
7040
|
-
const {
|
|
7006
|
+
const { failedPlugins, error } = await kubb.safeBuild();
|
|
7041
7007
|
await hooks.emit("kubb:info", { message: "Load summary" });
|
|
7042
7008
|
const hasFailures = failedPlugins.size > 0 || error;
|
|
7043
7009
|
if (hasFailures) {
|
|
@@ -7048,11 +7014,11 @@ async function generate({ config, hooks }) {
|
|
|
7048
7014
|
allErrors.forEach((err) => {
|
|
7049
7015
|
hooks.emit("kubb:error", { error: err });
|
|
7050
7016
|
});
|
|
7051
|
-
await hooks.emit("kubb:generation:end", { config,
|
|
7017
|
+
await hooks.emit("kubb:generation:end", { config, storage: kubb.storage });
|
|
7052
7018
|
throw new Error("Generation failed");
|
|
7053
7019
|
}
|
|
7054
7020
|
await hooks.emit("kubb:success", { message: "Generation successfully" });
|
|
7055
|
-
await hooks.emit("kubb:generation:end", { config,
|
|
7021
|
+
await hooks.emit("kubb:generation:end", { config, storage: kubb.storage });
|
|
7056
7022
|
if (config.output.format) {
|
|
7057
7023
|
await hooks.emit("kubb:format:start");
|
|
7058
7024
|
let formatter = config.output.format;
|
|
@@ -7127,20 +7093,15 @@ async function generate({ config, hooks }) {
|
|
|
7127
7093
|
}
|
|
7128
7094
|
}
|
|
7129
7095
|
|
|
7130
|
-
const
|
|
7131
|
-
|
|
7132
|
-
|
|
7133
|
-
|
|
7134
|
-
|
|
7135
|
-
|
|
7136
|
-
|
|
7137
|
-
};
|
|
7096
|
+
const jiti = createJiti(globalThis._importMeta_.url, {
|
|
7097
|
+
jsx: {
|
|
7098
|
+
runtime: "automatic",
|
|
7099
|
+
importSource: "@kubb/renderer-jsx"
|
|
7100
|
+
},
|
|
7101
|
+
moduleCache: false
|
|
7102
|
+
});
|
|
7138
7103
|
const tsLoader = async (configFile) => {
|
|
7139
|
-
|
|
7140
|
-
path: configFile,
|
|
7141
|
-
inputOptions: unrunInputOptions
|
|
7142
|
-
});
|
|
7143
|
-
return module;
|
|
7104
|
+
return jiti.import(configFile, { default: true });
|
|
7144
7105
|
};
|
|
7145
7106
|
async function getCosmiConfig(configPath) {
|
|
7146
7107
|
var _a;
|
|
@@ -7201,6 +7162,21 @@ async function resolvePlugins(plugins) {
|
|
|
7201
7162
|
})
|
|
7202
7163
|
);
|
|
7203
7164
|
}
|
|
7165
|
+
async function resolveMiddlewares(middlewares) {
|
|
7166
|
+
return Promise.all(
|
|
7167
|
+
middlewares.map(async ({ name, options }) => {
|
|
7168
|
+
const factory = await loadPluginFactory(name);
|
|
7169
|
+
return factory(options != null ? options : {});
|
|
7170
|
+
})
|
|
7171
|
+
);
|
|
7172
|
+
}
|
|
7173
|
+
async function checkPeerDependencies() {
|
|
7174
|
+
try {
|
|
7175
|
+
await import('@kubb/renderer-jsx');
|
|
7176
|
+
} catch {
|
|
7177
|
+
logger.warn("Missing peer dependency @kubb/renderer-jsx. Install it alongside kubb plugins.");
|
|
7178
|
+
}
|
|
7179
|
+
}
|
|
7204
7180
|
|
|
7205
7181
|
async function mergePlugins(diskPlugins, studioPlugins) {
|
|
7206
7182
|
if (!diskPlugins && !studioPlugins) return void 0;
|
|
@@ -7302,7 +7278,7 @@ function setupHookListener(hooks, root) {
|
|
|
7302
7278
|
}
|
|
7303
7279
|
|
|
7304
7280
|
const agentDefaults = {
|
|
7305
|
-
studioUrl: "https://
|
|
7281
|
+
studioUrl: "https://kubb.studio",
|
|
7306
7282
|
configPath: "kubb.config.ts",
|
|
7307
7283
|
retryIntervalMs: 3e4,
|
|
7308
7284
|
heartbeatIntervalMs: 3e4,
|
|
@@ -7347,14 +7323,14 @@ function setupEventsStream(ws, hooks, getSource) {
|
|
|
7347
7323
|
hooks.on("kubb:plugin:start", (ctx) => {
|
|
7348
7324
|
sendDataMessage({
|
|
7349
7325
|
type: "kubb:plugin:start",
|
|
7350
|
-
data: [ctx.plugin],
|
|
7326
|
+
data: [{ plugin: ctx.plugin }],
|
|
7351
7327
|
timestamp: Date.now()
|
|
7352
7328
|
});
|
|
7353
7329
|
});
|
|
7354
7330
|
hooks.on("kubb:plugin:end", (ctx) => {
|
|
7355
7331
|
sendDataMessage({
|
|
7356
7332
|
type: "kubb:plugin:end",
|
|
7357
|
-
data: [ctx.plugin,
|
|
7333
|
+
data: [{ plugin: ctx.plugin, duration: ctx.duration, success: ctx.success }],
|
|
7358
7334
|
timestamp: Date.now()
|
|
7359
7335
|
});
|
|
7360
7336
|
});
|
|
@@ -7389,21 +7365,21 @@ function setupEventsStream(ws, hooks, getSource) {
|
|
|
7389
7365
|
hooks.on("kubb:info", ({ message, info }) => {
|
|
7390
7366
|
sendDataMessage({
|
|
7391
7367
|
type: "kubb:info",
|
|
7392
|
-
data: [message, info],
|
|
7368
|
+
data: [{ message, info }],
|
|
7393
7369
|
timestamp: Date.now()
|
|
7394
7370
|
});
|
|
7395
7371
|
});
|
|
7396
7372
|
hooks.on("kubb:success", ({ message, info }) => {
|
|
7397
7373
|
sendDataMessage({
|
|
7398
7374
|
type: "kubb:success",
|
|
7399
|
-
data: [message, info],
|
|
7375
|
+
data: [{ message, info }],
|
|
7400
7376
|
timestamp: Date.now()
|
|
7401
7377
|
});
|
|
7402
7378
|
});
|
|
7403
7379
|
hooks.on("kubb:warn", ({ message, info }) => {
|
|
7404
7380
|
sendDataMessage({
|
|
7405
7381
|
type: "kubb:warn",
|
|
7406
|
-
data: [message, info],
|
|
7382
|
+
data: [{ message, info }],
|
|
7407
7383
|
timestamp: Date.now()
|
|
7408
7384
|
});
|
|
7409
7385
|
});
|
|
@@ -7419,14 +7395,17 @@ function setupEventsStream(ws, hooks, getSource) {
|
|
|
7419
7395
|
timestamp: Date.now()
|
|
7420
7396
|
});
|
|
7421
7397
|
});
|
|
7422
|
-
hooks.on("kubb:generation:end", ({ config,
|
|
7398
|
+
hooks.on("kubb:generation:end", async ({ config, storage }) => {
|
|
7423
7399
|
const sourcesRecord = {};
|
|
7424
|
-
|
|
7425
|
-
|
|
7426
|
-
|
|
7400
|
+
for (const key of await storage.getKeys()) {
|
|
7401
|
+
const value = await storage.getItem(key);
|
|
7402
|
+
if (value !== null) {
|
|
7403
|
+
sourcesRecord[key] = value;
|
|
7404
|
+
}
|
|
7405
|
+
}
|
|
7427
7406
|
sendDataMessage({
|
|
7428
7407
|
type: "kubb:generation:end",
|
|
7429
|
-
data: [config,
|
|
7408
|
+
data: [{ config, storage: sourcesRecord }],
|
|
7430
7409
|
timestamp: Date.now()
|
|
7431
7410
|
});
|
|
7432
7411
|
});
|
|
@@ -7549,6 +7528,7 @@ async function connectToStudio(options) {
|
|
|
7549
7528
|
const storedConfig = data.payload ? null : await getLatestStudioConfigFromStorage({ sessionId }).catch(() => null);
|
|
7550
7529
|
const patch = (_b = (_a2 = data.payload) != null ? _a2 : storedConfig) != null ? _b : void 0;
|
|
7551
7530
|
const plugins = await mergePlugins(config.plugins, patch == null ? void 0 : patch.plugins);
|
|
7531
|
+
const middleware = (patch == null ? void 0 : patch.middleware) ? await resolveMiddlewares(patch.middleware) : config.middleware;
|
|
7552
7532
|
const inputOverride = isSandbox ? { data: (_c = patch == null ? void 0 : patch.input) != null ? _c : "" } : void 0;
|
|
7553
7533
|
if (allowWrite && isSandbox) {
|
|
7554
7534
|
logger.warn(`[${maskedSessionId}] Agent is running in a sandbox environment, write will be disabled`);
|
|
@@ -7564,6 +7544,9 @@ async function connectToStudio(options) {
|
|
|
7564
7544
|
logger.warn(`[${maskedSessionId}] Failed to save studio config: ${err == null ? void 0 : err.message}`);
|
|
7565
7545
|
});
|
|
7566
7546
|
}
|
|
7547
|
+
const generationHooks = new AsyncEventEmitter();
|
|
7548
|
+
setupHookListener(generationHooks, root);
|
|
7549
|
+
setupEventsStream(ws, generationHooks, () => currentSource);
|
|
7567
7550
|
await generate({
|
|
7568
7551
|
config: {
|
|
7569
7552
|
...config,
|
|
@@ -7573,9 +7556,13 @@ async function connectToStudio(options) {
|
|
|
7573
7556
|
output: {
|
|
7574
7557
|
...config.output
|
|
7575
7558
|
},
|
|
7576
|
-
plugins
|
|
7559
|
+
plugins,
|
|
7560
|
+
middleware,
|
|
7561
|
+
// Studio may send an opaque adapter options blob; forward it unchanged to createKubb.
|
|
7562
|
+
// The adapter factory is responsible for validating and merging its own options.
|
|
7563
|
+
...(patch == null ? void 0 : patch.adapter) != null && { adapter: patch.adapter }
|
|
7577
7564
|
},
|
|
7578
|
-
hooks
|
|
7565
|
+
hooks: generationHooks
|
|
7579
7566
|
});
|
|
7580
7567
|
logger.success(`[${maskedSessionId}] Completed "${data.type}" from Studio`);
|
|
7581
7568
|
currentSource = void 0;
|
|
@@ -7677,6 +7664,7 @@ const _zcw7I4pYH8OiCfaDcjy_x7I6IH1tLDQR3W_yRZgP6E = defineNitroPlugin(async (nit
|
|
|
7677
7664
|
}
|
|
7678
7665
|
const maskedToken = maskString(token);
|
|
7679
7666
|
try {
|
|
7667
|
+
await checkPeerDependencies();
|
|
7680
7668
|
await registerAgent({ token, studioUrl, poolSize });
|
|
7681
7669
|
const baseOptions = {
|
|
7682
7670
|
token,
|