@kubb/core 4.23.0 → 4.24.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,35 @@
1
+ import { t as __name } from "./chunk-iVr_oF3V.js";
2
+ import { f as Plugin, t as BarrelType } from "./types-Cn3Gwsf3.js";
3
+ import { KubbFile } from "@kubb/fabric-core/types";
4
+
5
+ //#region src/utils/getBarrelFiles.d.ts
6
+ type FileMetaBase = {
7
+ pluginKey?: Plugin['key'];
8
+ };
9
+ type AddIndexesProps = {
10
+ type: BarrelType | false | undefined;
11
+ /**
12
+ * Root based on root and output.path specified in the config
13
+ */
14
+ root: string;
15
+ /**
16
+ * Output for plugin
17
+ */
18
+ output: {
19
+ path: string;
20
+ };
21
+ group?: {
22
+ output: string;
23
+ exportAs: string;
24
+ };
25
+ meta?: FileMetaBase;
26
+ };
27
+ declare function getBarrelFiles(files: Array<KubbFile.ResolvedFile>, {
28
+ type,
29
+ meta,
30
+ root,
31
+ output
32
+ }: AddIndexesProps): Promise<KubbFile.File[]>;
33
+ //#endregion
34
+ export { getBarrelFiles as n, FileMetaBase as t };
35
+ //# sourceMappingURL=getBarrelFiles-CvaEQ7z_.d.ts.map
@@ -0,0 +1,35 @@
1
+ import { t as __name } from "./chunk-DlpkT3g-.cjs";
2
+ import { f as Plugin, t as BarrelType } from "./types-ulibr7zw.cjs";
3
+ import { KubbFile } from "@kubb/fabric-core/types";
4
+
5
+ //#region src/utils/getBarrelFiles.d.ts
6
+ type FileMetaBase = {
7
+ pluginKey?: Plugin['key'];
8
+ };
9
+ type AddIndexesProps = {
10
+ type: BarrelType | false | undefined;
11
+ /**
12
+ * Root based on root and output.path specified in the config
13
+ */
14
+ root: string;
15
+ /**
16
+ * Output for plugin
17
+ */
18
+ output: {
19
+ path: string;
20
+ };
21
+ group?: {
22
+ output: string;
23
+ exportAs: string;
24
+ };
25
+ meta?: FileMetaBase;
26
+ };
27
+ declare function getBarrelFiles(files: Array<KubbFile.ResolvedFile>, {
28
+ type,
29
+ meta,
30
+ root,
31
+ output
32
+ }: AddIndexesProps): Promise<KubbFile.File[]>;
33
+ //#endregion
34
+ export { getBarrelFiles as n, FileMetaBase as t };
35
+ //# sourceMappingURL=getBarrelFiles-D9yKoizv.d.cts.map
@@ -5,13 +5,6 @@ let node_path = require("node:path");
5
5
  node_path = require_chunk.__toESM(node_path);
6
6
  let node_perf_hooks = require("node:perf_hooks");
7
7
  let node_events = require("node:events");
8
- let natural_orderby = require("natural-orderby");
9
- let node_url = require("node:url");
10
- let node_fs = require("node:fs");
11
- let node_dns = require("node:dns");
12
- node_dns = require_chunk.__toESM(node_dns);
13
- let jiti = require("jiti");
14
- jiti = require_chunk.__toESM(jiti);
15
8
 
16
9
  //#region src/errors.ts
17
10
  var ValidationPluginError = class extends Error {};
@@ -204,10 +197,9 @@ var PromiseManager = class {
204
197
  throw new Error(`${strategy} not implemented`);
205
198
  }
206
199
  };
207
- function isPromiseRejectedResult$1(result) {
200
+ function isPromiseRejectedResult(result) {
208
201
  return result.status === "rejected";
209
202
  }
210
- require_chunk.__name(isPromiseRejectedResult$1, "isPromiseRejectedResult");
211
203
 
212
204
  //#endregion
213
205
  //#region src/utils/uniqueName.ts
@@ -286,15 +278,15 @@ var PluginManager = class {
286
278
  }
287
279
  getFile({ name, mode, extname, pluginKey, options }) {
288
280
  const baseName = `${name}${extname}`;
289
- const path$2 = this.resolvePath({
281
+ const path$1 = this.resolvePath({
290
282
  baseName,
291
283
  mode,
292
284
  pluginKey,
293
285
  options
294
286
  });
295
- if (!path$2) throw new Error(`Filepath should be defined for resolvedName "${name}" and pluginKey [${JSON.stringify(pluginKey)}]`);
287
+ if (!path$1) throw new Error(`Filepath should be defined for resolvedName "${name}" and pluginKey [${JSON.stringify(pluginKey)}]`);
296
288
  return {
297
- path: path$2,
289
+ path: path$1,
298
290
  baseName,
299
291
  meta: { pluginKey },
300
292
  sources: [],
@@ -443,7 +435,7 @@ var PluginManager = class {
443
435
  });
444
436
  const results = await this.#promiseManager.run("parallel", promises, { concurrency: this.options.concurrency });
445
437
  results.forEach((result, index) => {
446
- if (isPromiseRejectedResult$1(result)) {
438
+ if (isPromiseRejectedResult(result)) {
447
439
  const plugin = this.#getSortedPlugins(hookName)[index];
448
440
  if (plugin) this.events.emit("error", result.reason, {
449
441
  plugin,
@@ -708,8 +700,8 @@ function formatHrtime(hrStart) {
708
700
  var URLPath = class {
709
701
  path;
710
702
  #options;
711
- constructor(path$2, options = {}) {
712
- this.path = path$2;
703
+ constructor(path$1, options = {}) {
704
+ this.path = path$1;
713
705
  this.#options = options;
714
706
  return this;
715
707
  }
@@ -764,11 +756,11 @@ var URLPath = class {
764
756
  toTemplateString({ prefix = "", replacer } = {}) {
765
757
  const found = this.path.match(/{(\w|-)*}/g);
766
758
  let newPath = this.path.replaceAll("{", "${");
767
- if (found) newPath = found.reduce((prev, path$2) => {
768
- const pathWithoutBrackets = path$2.replaceAll("{", "").replaceAll("}", "");
759
+ if (found) newPath = found.reduce((prev, path$1) => {
760
+ const pathWithoutBrackets = path$1.replaceAll("{", "").replaceAll("}", "");
769
761
  let param = require_transformers.isValidVarName(pathWithoutBrackets) ? pathWithoutBrackets : require_transformers.camelCase(pathWithoutBrackets);
770
762
  if (this.#options.casing === "camelcase") param = require_transformers.camelCase(param);
771
- return prev.replace(path$2, `\${${replacer ? replacer(param) : param}}`);
763
+ return prev.replace(path$1, `\${${replacer ? replacer(param) : param}}`);
772
764
  }, this.path);
773
765
  return `\`${prefix}${newPath}\``;
774
766
  }
@@ -794,160 +786,6 @@ var URLPath = class {
794
786
  }
795
787
  };
796
788
 
797
- //#endregion
798
- //#region src/utils/buildJSDoc.ts
799
- /**
800
- * Builds a JSDoc comment block with custom indentation.
801
- * @param comments - Array of comment strings to include in the JSDoc block
802
- * @param options - Configuration options for formatting
803
- * @returns Formatted JSDoc string or fallback string if no comments
804
- */
805
- function buildJSDoc(comments, options = {}) {
806
- const { indent = " * ", suffix = "\n ", fallback = " " } = options;
807
- if (comments.length === 0) return fallback;
808
- return `/**\n${comments.map((c) => `${indent}${c}`).join("\n")}\n */${suffix}`;
809
- }
810
-
811
- //#endregion
812
- //#region src/utils/Cache.ts
813
- var Cache = class {
814
- #buffer = /* @__PURE__ */ new Map();
815
- async get(key) {
816
- return this.#buffer.get(key) ?? null;
817
- }
818
- async set(key, value) {
819
- this.#buffer.set(key, value);
820
- }
821
- async delete(key) {
822
- this.#buffer.delete(key);
823
- }
824
- async clear() {
825
- this.#buffer.clear();
826
- }
827
- async keys() {
828
- return [...this.#buffer.keys()];
829
- }
830
- async values() {
831
- return [...this.#buffer.values()];
832
- }
833
- async flush() {}
834
- };
835
-
836
- //#endregion
837
- //#region src/utils/checkOnlineStatus.ts
838
- /**
839
- * Check if the system has internet connectivity
840
- * Uses DNS lookup to well-known stable domains as a lightweight connectivity test
841
- */
842
- async function isOnline() {
843
- for (const domain of [
844
- "dns.google.com",
845
- "cloudflare.com",
846
- "one.one.one.one"
847
- ]) try {
848
- await node_dns.default.promises.resolve(domain);
849
- return true;
850
- } catch {}
851
- return false;
852
- }
853
- /**
854
- * Execute a function only if online, otherwise silently skip
855
- */
856
- async function executeIfOnline(fn) {
857
- if (!await isOnline()) return null;
858
- try {
859
- return await fn();
860
- } catch {
861
- return null;
862
- }
863
- }
864
-
865
- //#endregion
866
- //#region src/utils/FunctionParams.ts
867
- /**
868
- * @deprecated
869
- */
870
- var FunctionParams = class FunctionParams {
871
- #items = [];
872
- constructor() {
873
- return this;
874
- }
875
- get items() {
876
- return this.#items.flat();
877
- }
878
- add(item) {
879
- if (!item) return this;
880
- if (Array.isArray(item)) {
881
- item.filter(Boolean).forEach((it) => {
882
- this.#items.push(it);
883
- });
884
- return this;
885
- }
886
- this.#items.push(item);
887
- return this;
888
- }
889
- static #orderItems(items) {
890
- return (0, natural_orderby.orderBy)(items.filter(Boolean), [(v) => {
891
- if (Array.isArray(v)) return;
892
- return !v.default;
893
- }, (v) => {
894
- if (Array.isArray(v)) return;
895
- return v.required ?? true;
896
- }], ["desc", "desc"]);
897
- }
898
- static #addParams(acc, item) {
899
- const { enabled = true, name, type, required = true, ...rest } = item;
900
- if (!enabled) return acc;
901
- if (!name) {
902
- acc.push(`${type}${rest.default ? ` = ${rest.default}` : ""}`);
903
- return acc;
904
- }
905
- const parameterName = name.startsWith("{") ? name : require_transformers.camelCase(name);
906
- if (type) if (required) acc.push(`${parameterName}: ${type}${rest.default ? ` = ${rest.default}` : ""}`);
907
- else acc.push(`${parameterName}?: ${type}`);
908
- else acc.push(`${parameterName}`);
909
- return acc;
910
- }
911
- static toObject(items) {
912
- let type = [];
913
- let name = [];
914
- const enabled = items.every((item) => item.enabled) ? items.at(0)?.enabled : true;
915
- const required = items.every((item) => item.required) ?? true;
916
- items.forEach((item) => {
917
- name = FunctionParams.#addParams(name, {
918
- ...item,
919
- type: void 0
920
- });
921
- if (items.some((item$1) => item$1.type)) type = FunctionParams.#addParams(type, item);
922
- });
923
- return {
924
- name: `{ ${name.join(", ")} }`,
925
- type: type.length ? `{ ${type.join("; ")} }` : void 0,
926
- enabled,
927
- required
928
- };
929
- }
930
- toObject() {
931
- const items = FunctionParams.#orderItems(this.#items).flat();
932
- return FunctionParams.toObject(items);
933
- }
934
- static toString(items) {
935
- return FunctionParams.#orderItems(items).reduce((acc, item) => {
936
- if (Array.isArray(item)) {
937
- if (item.length <= 0) return acc;
938
- const subItems = FunctionParams.#orderItems(item);
939
- const objectItem = FunctionParams.toObject(subItems);
940
- return FunctionParams.#addParams(acc, objectItem);
941
- }
942
- return FunctionParams.#addParams(acc, item);
943
- }, []).join(", ");
944
- }
945
- toString() {
946
- const items = FunctionParams.#orderItems(this.#items);
947
- return FunctionParams.toString(items);
948
- }
949
- };
950
-
951
789
  //#endregion
952
790
  //#region src/utils/TreeNode.ts
953
791
  var TreeNode = class TreeNode {
@@ -1158,105 +996,6 @@ async function getBarrelFiles(files, { type, meta = {}, root, output }) {
1158
996
  });
1159
997
  }
1160
998
 
1161
- //#endregion
1162
- //#region src/utils/getNestedAccessor.ts
1163
- /**
1164
- * Converts a param path (string with dot notation or array of strings) to a JavaScript accessor expression.
1165
- * @param param - The param path, e.g., 'pagination.next.id' or ['pagination', 'next', 'id']
1166
- * @param accessor - The base accessor, e.g., 'lastPage' or 'firstPage'
1167
- * @returns A JavaScript accessor expression, e.g., "lastPage?.['pagination']?.['next']?.['id']", or undefined if param is empty
1168
- *
1169
- * @example
1170
- * ```ts
1171
- * getNestedAccessor('pagination.next.id', 'lastPage')
1172
- * // returns: "lastPage?.['pagination']?.['next']?.['id']"
1173
- *
1174
- * getNestedAccessor(['pagination', 'next', 'id'], 'lastPage')
1175
- * // returns: "lastPage?.['pagination']?.['next']?.['id']"
1176
- *
1177
- * getNestedAccessor('', 'lastPage')
1178
- * // returns: undefined
1179
- * ```
1180
- */
1181
- function getNestedAccessor(param, accessor) {
1182
- const parts = Array.isArray(param) ? param : param.split(".");
1183
- if (parts.length === 0 || parts.length === 1 && parts[0] === "") return;
1184
- return parts.reduce((acc, part) => `${acc}?.['${part}']`, accessor);
1185
- }
1186
-
1187
- //#endregion
1188
- //#region src/utils/promise.ts
1189
- function isPromise(result) {
1190
- return !!result && typeof result?.then === "function";
1191
- }
1192
- function isPromiseFulfilledResult(result) {
1193
- return result.status === "fulfilled";
1194
- }
1195
- function isPromiseRejectedResult(result) {
1196
- return result.status === "rejected";
1197
- }
1198
-
1199
- //#endregion
1200
- //#region src/utils/renderTemplate.ts
1201
- function renderTemplate(template, data = void 0) {
1202
- if (!data || !Object.keys(data).length) return template.replace(/{{(.*?)}}/g, "");
1203
- return template.match(/{{(.*?)}}/g)?.reduce((prev, curr) => {
1204
- const index = curr.split(/{{|}}/).filter(Boolean)[0]?.trim();
1205
- if (index === void 0) return prev;
1206
- const value = data[index];
1207
- if (value === void 0) return prev;
1208
- return prev.replace(curr, () => {
1209
- if (typeof value === "boolean") return `${value.toString()}` || "false";
1210
- return value || "";
1211
- }).trim();
1212
- }, template) || "";
1213
- }
1214
-
1215
- //#endregion
1216
- //#region src/utils/resolveModuleSource.ts
1217
- function resolveModuleSource(pkgName) {
1218
- const parentURL = require("url").pathToFileURL(__filename).href;
1219
- const resolved = (0, jiti.default)(parentURL).esmResolve(pkgName, parentURL);
1220
- const filePath = resolved.startsWith("file:") ? (0, node_url.fileURLToPath)(resolved) : resolved;
1221
- return {
1222
- path: filePath,
1223
- source: (0, node_fs.readFileSync)(filePath, { encoding: "utf-8" }),
1224
- ext: node_path.default.extname(filePath)
1225
- };
1226
- }
1227
-
1228
- //#endregion
1229
- //#region src/utils/serializePluginOptions.ts
1230
- /**
1231
- * Serialize plugin options for safe JSON transport.
1232
- * Strips functions, symbols, and undefined values recursively.
1233
- */
1234
- function serializePluginOptions(options) {
1235
- if (options === null || options === void 0) return {};
1236
- if (typeof options !== "object") return options;
1237
- if (Array.isArray(options)) return options.map(serializePluginOptions);
1238
- const serialized = {};
1239
- for (const [key, value] of Object.entries(options)) {
1240
- if (typeof value === "function" || typeof value === "symbol" || value === void 0) continue;
1241
- if (typeof value === "object" && value !== null) serialized[key] = serializePluginOptions(value);
1242
- else serialized[key] = value;
1243
- }
1244
- return serialized;
1245
- }
1246
-
1247
- //#endregion
1248
- //#region src/utils/timeout.ts
1249
- async function timeout(ms) {
1250
- return new Promise((resolve) => {
1251
- const timeout$1 = setTimeout(() => {
1252
- resolve(timeout$1);
1253
- }, ms);
1254
- }).then((timeout$1) => {
1255
- clearTimeout(timeout$1);
1256
- return true;
1257
- });
1258
- }
1259
-
1260
999
  //#endregion
1261
1000
  Object.defineProperty(exports, 'AsyncEventEmitter', {
1262
1001
  enumerable: true,
@@ -1270,18 +1009,6 @@ Object.defineProperty(exports, 'BuildError', {
1270
1009
  return BuildError;
1271
1010
  }
1272
1011
  });
1273
- Object.defineProperty(exports, 'Cache', {
1274
- enumerable: true,
1275
- get: function () {
1276
- return Cache;
1277
- }
1278
- });
1279
- Object.defineProperty(exports, 'FunctionParams', {
1280
- enumerable: true,
1281
- get: function () {
1282
- return FunctionParams;
1283
- }
1284
- });
1285
1012
  Object.defineProperty(exports, 'PluginManager', {
1286
1013
  enumerable: true,
1287
1014
  get: function () {
@@ -1306,18 +1033,6 @@ Object.defineProperty(exports, 'URLPath', {
1306
1033
  return URLPath;
1307
1034
  }
1308
1035
  });
1309
- Object.defineProperty(exports, 'buildJSDoc', {
1310
- enumerable: true,
1311
- get: function () {
1312
- return buildJSDoc;
1313
- }
1314
- });
1315
- Object.defineProperty(exports, 'executeIfOnline', {
1316
- enumerable: true,
1317
- get: function () {
1318
- return executeIfOnline;
1319
- }
1320
- });
1321
1036
  Object.defineProperty(exports, 'formatHrtime', {
1322
1037
  enumerable: true,
1323
1038
  get: function () {
@@ -1348,70 +1063,16 @@ Object.defineProperty(exports, 'getMode', {
1348
1063
  return getMode;
1349
1064
  }
1350
1065
  });
1351
- Object.defineProperty(exports, 'getNestedAccessor', {
1352
- enumerable: true,
1353
- get: function () {
1354
- return getNestedAccessor;
1355
- }
1356
- });
1357
1066
  Object.defineProperty(exports, 'getUniqueName', {
1358
1067
  enumerable: true,
1359
1068
  get: function () {
1360
1069
  return getUniqueName;
1361
1070
  }
1362
1071
  });
1363
- Object.defineProperty(exports, 'isOnline', {
1364
- enumerable: true,
1365
- get: function () {
1366
- return isOnline;
1367
- }
1368
- });
1369
- Object.defineProperty(exports, 'isPromise', {
1370
- enumerable: true,
1371
- get: function () {
1372
- return isPromise;
1373
- }
1374
- });
1375
- Object.defineProperty(exports, 'isPromiseFulfilledResult', {
1376
- enumerable: true,
1377
- get: function () {
1378
- return isPromiseFulfilledResult;
1379
- }
1380
- });
1381
- Object.defineProperty(exports, 'isPromiseRejectedResult', {
1382
- enumerable: true,
1383
- get: function () {
1384
- return isPromiseRejectedResult;
1385
- }
1386
- });
1387
- Object.defineProperty(exports, 'renderTemplate', {
1388
- enumerable: true,
1389
- get: function () {
1390
- return renderTemplate;
1391
- }
1392
- });
1393
- Object.defineProperty(exports, 'resolveModuleSource', {
1394
- enumerable: true,
1395
- get: function () {
1396
- return resolveModuleSource;
1397
- }
1398
- });
1399
- Object.defineProperty(exports, 'serializePluginOptions', {
1400
- enumerable: true,
1401
- get: function () {
1402
- return serializePluginOptions;
1403
- }
1404
- });
1405
1072
  Object.defineProperty(exports, 'setUniqueName', {
1406
1073
  enumerable: true,
1407
1074
  get: function () {
1408
1075
  return setUniqueName;
1409
1076
  }
1410
1077
  });
1411
- Object.defineProperty(exports, 'timeout', {
1412
- enumerable: true,
1413
- get: function () {
1414
- return timeout;
1415
- }
1416
- });
1417
- //# sourceMappingURL=utils-BclJP5UT.cjs.map
1078
+ //# sourceMappingURL=getBarrelFiles-DCNjiX2W.cjs.map