@kubb/oas 4.12.6 → 4.12.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -50,198 +50,12 @@ let oas_normalize = require("oas-normalize");
50
50
  oas_normalize = __toESM(oas_normalize);
51
51
  let node_path = require("node:path");
52
52
  node_path = __toESM(node_path);
53
- let remeda = require("remeda");
53
+ let _kubb_core_utils = require("@kubb/core/utils");
54
54
  let oas_types = require("oas/types");
55
+ let remeda = require("remeda");
55
56
  let swagger2openapi = require("swagger2openapi");
56
57
  swagger2openapi = __toESM(swagger2openapi);
57
58
 
58
- //#region ../../node_modules/.pnpm/camelcase@8.0.0/node_modules/camelcase/index.js
59
- const UPPERCASE = /[\p{Lu}]/u;
60
- const LOWERCASE = /[\p{Ll}]/u;
61
- const LEADING_CAPITAL = /^[\p{Lu}](?![\p{Lu}])/gu;
62
- const IDENTIFIER = /([\p{Alpha}\p{N}_]|$)/u;
63
- const SEPARATORS = /[_.\- ]+/;
64
- const LEADING_SEPARATORS = /* @__PURE__ */ new RegExp("^" + SEPARATORS.source);
65
- const SEPARATORS_AND_IDENTIFIER = new RegExp(SEPARATORS.source + IDENTIFIER.source, "gu");
66
- const NUMBERS_AND_IDENTIFIER = new RegExp("\\d+" + IDENTIFIER.source, "gu");
67
- const preserveCamelCase = (string, toLowerCase, toUpperCase, preserveConsecutiveUppercase$1) => {
68
- let isLastCharLower = false;
69
- let isLastCharUpper = false;
70
- let isLastLastCharUpper = false;
71
- let isLastLastCharPreserved = false;
72
- for (let index = 0; index < string.length; index++) {
73
- const character = string[index];
74
- isLastLastCharPreserved = index > 2 ? string[index - 3] === "-" : true;
75
- if (isLastCharLower && UPPERCASE.test(character)) {
76
- string = string.slice(0, index) + "-" + string.slice(index);
77
- isLastCharLower = false;
78
- isLastLastCharUpper = isLastCharUpper;
79
- isLastCharUpper = true;
80
- index++;
81
- } else if (isLastCharUpper && isLastLastCharUpper && LOWERCASE.test(character) && (!isLastLastCharPreserved || preserveConsecutiveUppercase$1)) {
82
- string = string.slice(0, index - 1) + "-" + string.slice(index - 1);
83
- isLastLastCharUpper = isLastCharUpper;
84
- isLastCharUpper = false;
85
- isLastCharLower = true;
86
- } else {
87
- isLastCharLower = toLowerCase(character) === character && toUpperCase(character) !== character;
88
- isLastLastCharUpper = isLastCharUpper;
89
- isLastCharUpper = toUpperCase(character) === character && toLowerCase(character) !== character;
90
- }
91
- }
92
- return string;
93
- };
94
- const preserveConsecutiveUppercase = (input, toLowerCase) => {
95
- LEADING_CAPITAL.lastIndex = 0;
96
- return input.replaceAll(LEADING_CAPITAL, (match) => toLowerCase(match));
97
- };
98
- const postProcess = (input, toUpperCase) => {
99
- SEPARATORS_AND_IDENTIFIER.lastIndex = 0;
100
- NUMBERS_AND_IDENTIFIER.lastIndex = 0;
101
- return input.replaceAll(NUMBERS_AND_IDENTIFIER, (match, pattern, offset) => ["_", "-"].includes(input.charAt(offset + match.length)) ? match : toUpperCase(match)).replaceAll(SEPARATORS_AND_IDENTIFIER, (_, identifier) => toUpperCase(identifier));
102
- };
103
- function camelCase$1(input, options) {
104
- if (!(typeof input === "string" || Array.isArray(input))) throw new TypeError("Expected the input to be `string | string[]`");
105
- options = {
106
- pascalCase: false,
107
- preserveConsecutiveUppercase: false,
108
- ...options
109
- };
110
- if (Array.isArray(input)) input = input.map((x) => x.trim()).filter((x) => x.length).join("-");
111
- else input = input.trim();
112
- if (input.length === 0) return "";
113
- const toLowerCase = options.locale === false ? (string) => string.toLowerCase() : (string) => string.toLocaleLowerCase(options.locale);
114
- const toUpperCase = options.locale === false ? (string) => string.toUpperCase() : (string) => string.toLocaleUpperCase(options.locale);
115
- if (input.length === 1) {
116
- if (SEPARATORS.test(input)) return "";
117
- return options.pascalCase ? toUpperCase(input) : toLowerCase(input);
118
- }
119
- if (input !== toLowerCase(input)) input = preserveCamelCase(input, toLowerCase, toUpperCase, options.preserveConsecutiveUppercase);
120
- input = input.replace(LEADING_SEPARATORS, "");
121
- input = options.preserveConsecutiveUppercase ? preserveConsecutiveUppercase(input, toLowerCase) : toLowerCase(input);
122
- if (options.pascalCase) input = toUpperCase(input.charAt(0)) + input.slice(1);
123
- return postProcess(input, toUpperCase);
124
- }
125
-
126
- //#endregion
127
- //#region ../core/src/transformers/casing.ts
128
- function camelCase(text, { isFile, prefix = "", suffix = "" } = {}) {
129
- if (isFile) {
130
- const splitArray = text.split(".");
131
- return splitArray.map((item, i) => i === splitArray.length - 1 ? camelCase(item, {
132
- prefix,
133
- suffix
134
- }) : camelCase(item)).join("/");
135
- }
136
- return camelCase$1(`${prefix} ${text} ${suffix}`, {
137
- pascalCase: false,
138
- preserveConsecutiveUppercase: true
139
- }).replace(/[^a-zA-Z0-9]/g, "");
140
- }
141
-
142
- //#endregion
143
- //#region ../core/src/transformers/transformReservedWord.ts
144
- function isValidVarName(name) {
145
- try {
146
- Function(`var ${name}`);
147
- } catch (_e) {
148
- return false;
149
- }
150
- return true;
151
- }
152
-
153
- //#endregion
154
- //#region ../core/src/utils/URLPath.ts
155
- var URLPath = class {
156
- path;
157
- #options;
158
- constructor(path$1, options = {}) {
159
- this.path = path$1;
160
- this.#options = options;
161
- return this;
162
- }
163
- /**
164
- * Convert Swagger path to URLPath(syntax of Express)
165
- * @example /pet/{petId} => /pet/:petId
166
- */
167
- get URL() {
168
- return this.toURLPath();
169
- }
170
- get isURL() {
171
- try {
172
- if (new URL(this.path)?.href) return true;
173
- } catch (_error) {
174
- return false;
175
- }
176
- return false;
177
- }
178
- /**
179
- * Convert Swagger path to template literals/ template strings(camelcase)
180
- * @example /pet/{petId} => `/pet/${petId}`
181
- * @example /account/monetary-accountID => `/account/${monetaryAccountId}`
182
- * @example /account/userID => `/account/${userId}`
183
- */
184
- get template() {
185
- return this.toTemplateString();
186
- }
187
- get object() {
188
- return this.toObject();
189
- }
190
- get params() {
191
- return this.getParams();
192
- }
193
- toObject({ type = "path", replacer, stringify } = {}) {
194
- const object = {
195
- url: type === "path" ? this.toURLPath() : this.toTemplateString({ replacer }),
196
- params: this.getParams()
197
- };
198
- if (stringify) {
199
- if (type === "template") return JSON.stringify(object).replaceAll("'", "").replaceAll(`"`, "");
200
- if (object.params) return `{ url: '${object.url}', params: ${JSON.stringify(object.params).replaceAll("'", "").replaceAll(`"`, "")} }`;
201
- return `{ url: '${object.url}' }`;
202
- }
203
- return object;
204
- }
205
- /**
206
- * Convert Swagger path to template literals/ template strings(camelcase)
207
- * @example /pet/{petId} => `/pet/${petId}`
208
- * @example /account/monetary-accountID => `/account/${monetaryAccountId}`
209
- * @example /account/userID => `/account/${userId}`
210
- */
211
- toTemplateString({ prefix = "", replacer } = {}) {
212
- const found = this.path.match(/{(\w|-)*}/g);
213
- let newPath = this.path.replaceAll("{", "${");
214
- if (found) newPath = found.reduce((prev, path$1) => {
215
- const pathWithoutBrackets = path$1.replaceAll("{", "").replaceAll("}", "");
216
- let param = isValidVarName(pathWithoutBrackets) ? pathWithoutBrackets : camelCase(pathWithoutBrackets);
217
- if (this.#options.casing === "camelcase") param = camelCase(param);
218
- return prev.replace(path$1, `\${${replacer ? replacer(param) : param}}`);
219
- }, this.path);
220
- return `\`${prefix}${newPath}\``;
221
- }
222
- getParams(replacer) {
223
- const found = this.path.match(/{(\w|-)*}/g);
224
- if (!found) return;
225
- const params = {};
226
- found.forEach((item) => {
227
- item = item.replaceAll("{", "").replaceAll("}", "");
228
- let param = isValidVarName(item) ? item : camelCase(item);
229
- if (this.#options.casing === "camelcase") param = camelCase(param);
230
- const key = replacer ? replacer(param) : param;
231
- params[key] = key;
232
- }, this.path);
233
- return params;
234
- }
235
- /**
236
- * Convert Swagger path to URLPath(syntax of Express)
237
- * @example /pet/{petId} => /pet/:petId
238
- */
239
- toURLPath() {
240
- return this.path.replaceAll("{", ":").replaceAll("}", "");
241
- }
242
- };
243
-
244
- //#endregion
245
59
  //#region ../../node_modules/.pnpm/tslib@2.8.1/node_modules/tslib/tslib.es6.mjs
246
60
  var tslib_es6_exports = /* @__PURE__ */ __export({
247
61
  __addDisposableResource: () => __addDisposableResource,
@@ -4403,7 +4217,7 @@ function parseFromConfig(config, oasClass = Oas) {
4403
4217
  }
4404
4218
  }
4405
4219
  if (Array.isArray(config.input)) return merge(config.input.map((input) => node_path.default.resolve(config.root, input.path)), { oasClass });
4406
- if (new URLPath(config.input.path).isURL) return parse(config.input.path, { oasClass });
4220
+ if (new _kubb_core_utils.URLPath(config.input.path).isURL) return parse(config.input.path, { oasClass });
4407
4221
  return parse(node_path.default.resolve(config.root, config.input.path), { oasClass });
4408
4222
  }
4409
4223