@kubb/plugin-oas 3.0.0-alpha.2 → 3.0.0-alpha.21

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.
Files changed (101) hide show
  1. package/README.md +13 -4
  2. package/dist/OperationGenerator-CHXolL0o.d.cts +553 -0
  3. package/dist/OperationGenerator-CHXolL0o.d.ts +553 -0
  4. package/dist/Schema-Ch0dHkM5.d.ts +22 -0
  5. package/dist/Schema-ClNodlyP.d.cts +22 -0
  6. package/dist/chunk-6UWOTOZJ.cjs +92 -0
  7. package/dist/chunk-6UWOTOZJ.cjs.map +1 -0
  8. package/dist/chunk-AZKUU24F.js +700 -0
  9. package/dist/chunk-AZKUU24F.js.map +1 -0
  10. package/dist/chunk-DFQJ57GH.js +45 -0
  11. package/dist/chunk-DFQJ57GH.js.map +1 -0
  12. package/dist/chunk-GF26SDHQ.js +28 -0
  13. package/dist/chunk-GF26SDHQ.js.map +1 -0
  14. package/dist/chunk-HP5WAFBU.cjs +48 -0
  15. package/dist/chunk-HP5WAFBU.cjs.map +1 -0
  16. package/dist/chunk-JNGUNN72.cjs +708 -0
  17. package/dist/chunk-JNGUNN72.cjs.map +1 -0
  18. package/dist/chunk-PADR76WZ.cjs +4 -0
  19. package/dist/chunk-PADR76WZ.cjs.map +1 -0
  20. package/dist/chunk-R47XMJ32.js +3 -0
  21. package/dist/chunk-R47XMJ32.js.map +1 -0
  22. package/dist/{chunk-Y4V7HHX7.js → chunk-THGCWF2O.js} +8 -13
  23. package/dist/{chunk-Y4V7HHX7.js.map → chunk-THGCWF2O.js.map} +1 -1
  24. package/dist/chunk-TRA5BTWI.js +88 -0
  25. package/dist/chunk-TRA5BTWI.js.map +1 -0
  26. package/dist/chunk-UO57DZPV.cjs +36 -0
  27. package/dist/chunk-UO57DZPV.cjs.map +1 -0
  28. package/dist/chunk-ZWHQ54JM.cjs +32 -0
  29. package/dist/chunk-ZWHQ54JM.cjs.map +1 -0
  30. package/dist/components.cjs +20 -17
  31. package/dist/components.cjs.map +1 -1
  32. package/dist/components.d.cts +12 -8
  33. package/dist/components.d.ts +12 -8
  34. package/dist/components.js +3 -17
  35. package/dist/components.js.map +1 -1
  36. package/dist/generators.cjs +14 -0
  37. package/dist/generators.cjs.map +1 -0
  38. package/dist/generators.d.cts +10 -0
  39. package/dist/generators.d.ts +10 -0
  40. package/dist/generators.js +5 -0
  41. package/dist/generators.js.map +1 -0
  42. package/dist/hooks.cjs +101 -57
  43. package/dist/hooks.cjs.map +1 -1
  44. package/dist/hooks.d.cts +40 -8
  45. package/dist/hooks.d.ts +40 -8
  46. package/dist/hooks.js +90 -53
  47. package/dist/hooks.js.map +1 -1
  48. package/dist/index.cjs +283 -261
  49. package/dist/index.cjs.map +1 -1
  50. package/dist/index.d.cts +6 -77
  51. package/dist/index.d.ts +6 -77
  52. package/dist/index.js +235 -240
  53. package/dist/index.js.map +1 -1
  54. package/dist/utils.cjs +32 -87
  55. package/dist/utils.cjs.map +1 -1
  56. package/dist/utils.d.cts +7 -41
  57. package/dist/utils.d.ts +7 -41
  58. package/dist/utils.js +8 -86
  59. package/dist/utils.js.map +1 -1
  60. package/package.json +20 -14
  61. package/src/OperationGenerator.ts +75 -43
  62. package/src/SchemaGenerator.ts +44 -18
  63. package/src/SchemaMapper.ts +1 -1
  64. package/src/components/Oas.tsx +9 -3
  65. package/src/components/Operation.tsx +1 -1
  66. package/src/components/Schema.tsx +2 -102
  67. package/src/generator.tsx +133 -0
  68. package/src/generators/index.ts +1 -0
  69. package/src/generators/jsonGenerator.ts +32 -0
  70. package/src/hooks/index.ts +2 -0
  71. package/src/hooks/useOperationManager.ts +76 -28
  72. package/src/hooks/useSchemaManager.ts +77 -0
  73. package/src/index.ts +3 -9
  74. package/src/plugin.ts +64 -47
  75. package/src/types.ts +23 -12
  76. package/src/utils/getParams.ts +2 -2
  77. package/src/utils/index.ts +2 -2
  78. package/dist/OperationGenerator-CeM_9pxW.d.cts +0 -60
  79. package/dist/OperationGenerator-DhUhvRJE.d.ts +0 -60
  80. package/dist/Schema-DefwBJMc.d.ts +0 -35
  81. package/dist/Schema-an5hOrjZ.d.cts +0 -35
  82. package/dist/SchemaMapper-CsBQ6eEx.d.cts +0 -248
  83. package/dist/SchemaMapper-CsBQ6eEx.d.ts +0 -248
  84. package/dist/chunk-CJXRFYEF.cjs +0 -698
  85. package/dist/chunk-CJXRFYEF.cjs.map +0 -1
  86. package/dist/chunk-DRLYORTT.cjs +0 -3265
  87. package/dist/chunk-DRLYORTT.cjs.map +0 -1
  88. package/dist/chunk-K6KUETAI.js +0 -698
  89. package/dist/chunk-K6KUETAI.js.map +0 -1
  90. package/dist/chunk-LEACSHKT.js +0 -3265
  91. package/dist/chunk-LEACSHKT.js.map +0 -1
  92. package/dist/chunk-P42X362U.cjs +0 -101
  93. package/dist/chunk-P42X362U.cjs.map +0 -1
  94. package/dist/chunk-QLJIL3U5.cjs +0 -35
  95. package/dist/chunk-QLJIL3U5.cjs.map +0 -1
  96. package/dist/chunk-UB552H4J.js +0 -101
  97. package/dist/chunk-UB552H4J.js.map +0 -1
  98. package/dist/types-Dte3MA6H.d.cts +0 -143
  99. package/dist/types-Dte3MA6H.d.ts +0 -143
  100. package/src/utils/getGroupedByTagFiles.ts +0 -82
  101. package/src/utils/refSorter.ts +0 -13
@@ -1,101 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __typeError = (msg) => {
8
- throw TypeError(msg);
9
- };
10
- var __esm = (fn, res) => function __init() {
11
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
12
- };
13
- var __commonJS = (cb, mod) => function __require() {
14
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
15
- };
16
- var __copyProps = (to, from, except, desc) => {
17
- if (from && typeof from === "object" || typeof from === "function") {
18
- for (let key of __getOwnPropNames(from))
19
- if (!__hasOwnProp.call(to, key) && key !== except)
20
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
21
- }
22
- return to;
23
- };
24
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25
- // If the importer is in node compatibility mode or this is not an ESM
26
- // file that has been converted to a CommonJS file using a Babel-
27
- // compatible transform (i.e. "__esModule" has not been set), then set
28
- // "default" to the CommonJS "module.exports" for node compatibility.
29
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
30
- mod
31
- ));
32
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
33
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
34
- var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
35
- var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
36
- var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
37
-
38
- // ../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.7_@types+node@20.16.1__jiti@1.21.6_postcss@8.4.41_typescript@5.5.4_yaml@2.4.5/node_modules/tsup/assets/cjs_shims.js
39
- var init_cjs_shims = __esm({
40
- "../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.7_@types+node@20.16.1__jiti@1.21.6_postcss@8.4.41_typescript@5.5.4_yaml@2.4.5/node_modules/tsup/assets/cjs_shims.js"() {
41
- "use strict";
42
- }
43
- });
44
-
45
- // src/utils/getSchemas.ts
46
- init_cjs_shims();
47
- function getSchemas({ oas, contentType, includes = ["schemas", "requestBodies", "responses"] }) {
48
- const components = oas.getDefinition().components;
49
- let schemas = {};
50
- if (includes.includes("schemas")) {
51
- schemas = {
52
- ...schemas,
53
- ..._optionalChain([components, 'optionalAccess', _ => _.schemas]) || {}
54
- };
55
- }
56
- const requestBodies = _optionalChain([components, 'optionalAccess', _2 => _2.requestBodies]) || {};
57
- if (includes.includes("responses")) {
58
- const responses = _optionalChain([components, 'optionalAccess', _3 => _3.responses]) || {};
59
- Object.entries(responses).forEach(([name, response]) => {
60
- if (response.content && !schemas[name]) {
61
- const firstContentType = Object.keys(response.content)[0] || "application/json";
62
- schemas[name] = _optionalChain([response, 'access', _4 => _4.content, 'optionalAccess', _5 => _5[contentType || firstContentType], 'optionalAccess', _6 => _6.schema]);
63
- }
64
- });
65
- }
66
- if (includes.includes("requestBodies")) {
67
- Object.entries(requestBodies).forEach(([name, request]) => {
68
- if (request.content && !schemas[name]) {
69
- const firstContentType = Object.keys(request.content)[0] || "application/json";
70
- schemas[name] = _optionalChain([request, 'access', _7 => _7.content, 'optionalAccess', _8 => _8[contentType || firstContentType], 'optionalAccess', _9 => _9.schema]);
71
- }
72
- });
73
- }
74
- return schemas;
75
- }
76
-
77
- // src/utils/getSchemaFactory.ts
78
- init_cjs_shims();
79
- var _oas = require('@kubb/oas');
80
- function getSchemaFactory(oas) {
81
- return (schema) => {
82
- const version = _oas.isOpenApiV3_1Document.call(void 0, oas.api) ? "3.1" : "3.0";
83
- return {
84
- schema,
85
- version
86
- };
87
- };
88
- }
89
-
90
-
91
-
92
-
93
-
94
-
95
-
96
-
97
-
98
-
99
-
100
- exports.__commonJS = __commonJS; exports.__toESM = __toESM; exports.__privateGet = __privateGet; exports.__privateAdd = __privateAdd; exports.__privateSet = __privateSet; exports.__privateMethod = __privateMethod; exports.init_cjs_shims = init_cjs_shims; exports.getSchemas = getSchemas; exports.getSchemaFactory = getSchemaFactory;
101
- //# sourceMappingURL=chunk-P42X362U.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-oas/dist/chunk-P42X362U.cjs","../../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.7_@types+node@20.16.1__jiti@1.21.6_postcss@8.4.41_typescript@5.5.4_yaml@2.4.5/node_modules/tsup/assets/cjs_shims.js","../src/utils/getSchemas.ts","../src/utils/getSchemaFactory.ts"],"names":[],"mappings":"AAAA,ilBAAI,SAAS,EAAE,MAAM,CAAC,MAAM;AAC5B,IAAI,UAAU,EAAE,MAAM,CAAC,cAAc;AACrC,IAAI,iBAAiB,EAAE,MAAM,CAAC,wBAAwB;AACtD,IAAI,kBAAkB,EAAE,MAAM,CAAC,mBAAmB;AAClD,IAAI,aAAa,EAAE,MAAM,CAAC,cAAc;AACxC,IAAI,aAAa,EAAE,MAAM,CAAC,SAAS,CAAC,cAAc;AAClD,IAAI,YAAY,EAAE,CAAC,GAAG,EAAE,GAAG;AAC3B,EAAE,MAAM,SAAS,CAAC,GAAG,CAAC;AACtB,CAAC;AACD,IAAI,MAAM,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,SAAS,MAAM,CAAC,EAAE;AAC3C,EAAE,OAAO,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG;AACrE,CAAC;AACD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A,MACvE;AAAA,IACF,CAAC,CAAA;AAAA,EACH;AAEA,EAAA,GAAA,CAAI,QAAA,CAAS,QAAA,CAAS,eAAe,CAAA,EAAG;AACtC,IAAA,MAAA,CAAO,OAAA,CAAQ,aAAa,CAAA,CAAE,OAAA,CAAQ,CAAC,CAAC,IAAA,EAAM,OAAO,CAAA,EAAA,GAA4C;AAC/F,MAAA,GAAA,CAAI,OAAA,CAAQ,QAAA,GAAW,CAAC,OAAA,CAAQ,IAAI,CAAA,EAAG;AACrC,QAAA,MAAM,iBAAA,EAAmB,MAAA,CAAO,IAAA,CAAK,OAAA,CAAQ,OAAO,CAAA,CAAE,CAAC,EAAA,GAAK,kBAAA;AAC5D,QAAA,OAAA,CAAQ,IAAI,EAAA,kBAAI,OAAA,qBAAQ,OAAA,4BAAA,CAAU,YAAA,GAAe,gBAAgB,CAAA,6BAAG,QAAA;AAAA,MACtE;AAAA,IACF,CAAC,CAAA;AAAA,EACH;AAEA,EAAA,OAAO,OAAA;AACT;AF+BA;AACA;AG5EA,cAAA,CAAA,CAAA;AAAA,gCAAsC;AAuB/B,SAAS,gBAAA,CAAmD,GAAA,EAA6D;AAC9H,EAAA,OAAO,CAAC,MAAA,EAAA,GAA0B;AAChC,IAAA,MAAM,QAAA,EAAU,wCAAA,GAAsB,CAAI,GAAG,EAAA,EAAI,MAAA,EAAQ,KAAA;AAEzD,IAAA,OAAO;AAAA,MACL,MAAA;AAAA,MACA;AAAA,IACF,CAAA;AAAA,EACF,CAAA;AACF;AHwDA;AACA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,4UAAC","file":"/home/runner/work/kubb/kubb/packages/plugin-oas/dist/chunk-P42X362U.cjs","sourcesContent":[null,"// Shim globals in cjs bundle\n// There's a weird bug that esbuild will always inject importMetaUrl\n// if we export it as `const importMetaUrl = ... __filename ...`\n// But using a function will not cause this issue\n\nconst getImportMetaUrl = () =>\n typeof document === 'undefined'\n ? new URL(`file:${__filename}`).href\n : (document.currentScript && document.currentScript.src) ||\n new URL('main.js', document.baseURI).href\n\nexport const importMetaUrl = /* @__PURE__ */ getImportMetaUrl()\n","import type { Oas, OasTypes, contentType } from '@kubb/oas'\n\ntype Mode = 'schemas' | 'responses' | 'requestBodies'\n\nexport type GetSchemasProps = {\n oas: Oas\n contentType?: contentType\n includes?: Mode[]\n}\n\nexport function getSchemas({ oas, contentType, includes = ['schemas', 'requestBodies', 'responses'] }: GetSchemasProps): Record<string, OasTypes.SchemaObject> {\n const components = oas.getDefinition().components\n\n let schemas: Record<string, OasTypes.SchemaObject> = {}\n\n if (includes.includes('schemas')) {\n schemas = {\n ...schemas,\n ...((components?.schemas as Record<string, OasTypes.SchemaObject>) || {}),\n }\n }\n\n const requestBodies = components?.requestBodies || {}\n if (includes.includes('responses')) {\n const responses = components?.responses || {}\n\n Object.entries(responses).forEach(([name, response]: [string, OasTypes.ResponseObject]) => {\n if (response.content && !schemas[name]) {\n const firstContentType = Object.keys(response.content)[0] || 'application/json'\n schemas[name] = response.content?.[contentType || firstContentType]?.schema as OasTypes.SchemaObject\n }\n })\n }\n\n if (includes.includes('requestBodies')) {\n Object.entries(requestBodies).forEach(([name, request]: [string, OasTypes.RequestBodyObject]) => {\n if (request.content && !schemas[name]) {\n const firstContentType = Object.keys(request.content)[0] || 'application/json'\n schemas[name] = request.content?.[contentType || firstContentType]?.schema as OasTypes.SchemaObject\n }\n })\n }\n\n return schemas\n}\n","import { isOpenApiV3_1Document } from '@kubb/oas'\n\nimport type { Oas, OpenAPIV3, OpenAPIV3_1, SchemaObject } from '@kubb/oas'\n\n/**\n * Make it possible to narrow down the schema based on a specific version(3 or 3.1)\n */\ntype SchemaResult<TWithRef extends boolean = false> =\n | {\n schema?: (TWithRef extends true ? OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject : OpenAPIV3.SchemaObject) & {\n nullable?: boolean\n 'x-nullable'?: boolean\n }\n version: '3.0'\n }\n | {\n schema?: (TWithRef extends true ? OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject : OpenAPIV3_1.SchemaObject) & {\n nullable?: boolean\n 'x-nullable'?: boolean\n }\n version: '3.1'\n }\n\nexport function getSchemaFactory<TWithRef extends boolean = false>(oas: Oas): (schema?: SchemaObject) => SchemaResult<TWithRef> {\n return (schema?: SchemaObject) => {\n const version = isOpenApiV3_1Document(oas.api) ? '3.1' : '3.0'\n\n return {\n schema,\n version,\n } as SchemaResult<TWithRef>\n }\n}\n"]}
@@ -1,35 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2
-
3
- var _chunkP42X362Ucjs = require('./chunk-P42X362U.cjs');
4
-
5
- // src/utils/parseFromConfig.ts
6
- _chunkP42X362Ucjs.init_cjs_shims.call(void 0, );
7
- var _path = require('path');
8
- var _utils = require('@kubb/core/utils');
9
- var _parser = require('@kubb/oas/parser');
10
- var _oas = require('@kubb/oas');
11
- var _yaml = require('@stoplight/yaml'); var _yaml2 = _interopRequireDefault(_yaml);
12
- function parseFromConfig(config, options = {}, oasClass = _oas.Oas) {
13
- if ("data" in config.input) {
14
- if (typeof config.input.data === "object") {
15
- const api2 = JSON.parse(JSON.stringify(config.input.data));
16
- return _parser.parse.call(void 0, api2, options, oasClass);
17
- }
18
- try {
19
- const api2 = _yaml2.default.parse(config.input.data);
20
- return _parser.parse.call(void 0, api2, options, oasClass);
21
- } catch (e) {
22
- }
23
- const api = JSON.parse(JSON.stringify(config.input.data));
24
- return _parser.parse.call(void 0, api, options, oasClass);
25
- }
26
- if (new (0, _utils.URLPath)(config.input.path).isURL) {
27
- return _parser.parse.call(void 0, config.input.path, options, oasClass);
28
- }
29
- return _parser.parse.call(void 0, _path.resolve.call(void 0, config.root, config.input.path), options, oasClass);
30
- }
31
-
32
-
33
-
34
- exports.parseFromConfig = parseFromConfig;
35
- //# sourceMappingURL=chunk-QLJIL3U5.cjs.map
@@ -1 +0,0 @@
1
- {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,KAAA,CAAM,IAAA,EAAM,OAAA,EAAS,QAAQ,CAAA;AAAA,EACnD;AAEA,EAAA,OAAO,2BAAA,2BAAM,MAAQ,CAAO,IAAA,EAAM,MAAA,CAAO,KAAA,CAAM,IAAI,CAAA,EAAG,OAAA,EAAS,QAAQ,CAAA;AACzE;ADLA;AACA;AACE;AACF,0CAAC","file":"/home/runner/work/kubb/kubb/packages/plugin-oas/dist/chunk-QLJIL3U5.cjs","sourcesContent":[null,"import { resolve } from 'node:path'\n\nimport { URLPath } from '@kubb/core/utils'\n\nimport { type FormatOptions, parse } from '@kubb/oas/parser'\n\nimport type { Config } from '@kubb/core'\nimport { Oas, type OasTypes } from '@kubb/oas'\nimport yaml from '@stoplight/yaml'\n\nexport function parseFromConfig(config: Config, options: FormatOptions = {}, oasClass: typeof Oas = Oas): Promise<Oas> {\n if ('data' in config.input) {\n if (typeof config.input.data === 'object') {\n const api: OasTypes.OASDocument = JSON.parse(JSON.stringify(config.input.data)) as OasTypes.OASDocument\n return parse(api, options, oasClass)\n }\n\n try {\n const api: string = yaml.parse(config.input.data as string) as string\n\n return parse(api, options, oasClass)\n } catch (e) {\n /* empty */\n }\n\n const api: OasTypes.OASDocument = JSON.parse(JSON.stringify(config.input.data)) as OasTypes.OASDocument\n\n return parse(api, options, oasClass)\n }\n\n if (new URLPath(config.input.path).isURL) {\n return parse(config.input.path, options, oasClass)\n }\n\n return parse(resolve(config.root, config.input.path), options, oasClass)\n}\n"]}
@@ -1,101 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __typeError = (msg) => {
8
- throw TypeError(msg);
9
- };
10
- var __esm = (fn, res) => function __init() {
11
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
12
- };
13
- var __commonJS = (cb, mod) => function __require() {
14
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
15
- };
16
- var __copyProps = (to, from, except, desc) => {
17
- if (from && typeof from === "object" || typeof from === "function") {
18
- for (let key of __getOwnPropNames(from))
19
- if (!__hasOwnProp.call(to, key) && key !== except)
20
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
21
- }
22
- return to;
23
- };
24
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25
- // If the importer is in node compatibility mode or this is not an ESM
26
- // file that has been converted to a CommonJS file using a Babel-
27
- // compatible transform (i.e. "__esModule" has not been set), then set
28
- // "default" to the CommonJS "module.exports" for node compatibility.
29
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
30
- mod
31
- ));
32
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
33
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
34
- var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
35
- var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
36
- var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
37
-
38
- // ../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.7_@types+node@20.16.1__jiti@1.21.6_postcss@8.4.41_typescript@5.5.4_yaml@2.4.5/node_modules/tsup/assets/esm_shims.js
39
- var init_esm_shims = __esm({
40
- "../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.7_@types+node@20.16.1__jiti@1.21.6_postcss@8.4.41_typescript@5.5.4_yaml@2.4.5/node_modules/tsup/assets/esm_shims.js"() {
41
- "use strict";
42
- }
43
- });
44
-
45
- // src/utils/getSchemas.ts
46
- init_esm_shims();
47
- function getSchemas({ oas, contentType, includes = ["schemas", "requestBodies", "responses"] }) {
48
- const components = oas.getDefinition().components;
49
- let schemas = {};
50
- if (includes.includes("schemas")) {
51
- schemas = {
52
- ...schemas,
53
- ...components?.schemas || {}
54
- };
55
- }
56
- const requestBodies = components?.requestBodies || {};
57
- if (includes.includes("responses")) {
58
- const responses = components?.responses || {};
59
- Object.entries(responses).forEach(([name, response]) => {
60
- if (response.content && !schemas[name]) {
61
- const firstContentType = Object.keys(response.content)[0] || "application/json";
62
- schemas[name] = response.content?.[contentType || firstContentType]?.schema;
63
- }
64
- });
65
- }
66
- if (includes.includes("requestBodies")) {
67
- Object.entries(requestBodies).forEach(([name, request]) => {
68
- if (request.content && !schemas[name]) {
69
- const firstContentType = Object.keys(request.content)[0] || "application/json";
70
- schemas[name] = request.content?.[contentType || firstContentType]?.schema;
71
- }
72
- });
73
- }
74
- return schemas;
75
- }
76
-
77
- // src/utils/getSchemaFactory.ts
78
- init_esm_shims();
79
- import { isOpenApiV3_1Document } from "@kubb/oas";
80
- function getSchemaFactory(oas) {
81
- return (schema) => {
82
- const version = isOpenApiV3_1Document(oas.api) ? "3.1" : "3.0";
83
- return {
84
- schema,
85
- version
86
- };
87
- };
88
- }
89
-
90
- export {
91
- __commonJS,
92
- __toESM,
93
- __privateGet,
94
- __privateAdd,
95
- __privateSet,
96
- __privateMethod,
97
- init_esm_shims,
98
- getSchemas,
99
- getSchemaFactory
100
- };
101
- //# sourceMappingURL=chunk-UB552H4J.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.7_@types+node@20.16.1__jiti@1.21.6_postcss@8.4.41_typescript@5.5.4_yaml@2.4.5/node_modules/tsup/assets/esm_shims.js","../src/utils/getSchemas.ts","../src/utils/getSchemaFactory.ts"],"sourcesContent":["// Shim globals in esm bundle\nimport { fileURLToPath } from 'url'\nimport path from 'path'\n\nconst getFilename = () => fileURLToPath(import.meta.url)\nconst getDirname = () => path.dirname(getFilename())\n\nexport const __dirname = /* @__PURE__ */ getDirname()\nexport const __filename = /* @__PURE__ */ getFilename()\n","import type { Oas, OasTypes, contentType } from '@kubb/oas'\n\ntype Mode = 'schemas' | 'responses' | 'requestBodies'\n\nexport type GetSchemasProps = {\n oas: Oas\n contentType?: contentType\n includes?: Mode[]\n}\n\nexport function getSchemas({ oas, contentType, includes = ['schemas', 'requestBodies', 'responses'] }: GetSchemasProps): Record<string, OasTypes.SchemaObject> {\n const components = oas.getDefinition().components\n\n let schemas: Record<string, OasTypes.SchemaObject> = {}\n\n if (includes.includes('schemas')) {\n schemas = {\n ...schemas,\n ...((components?.schemas as Record<string, OasTypes.SchemaObject>) || {}),\n }\n }\n\n const requestBodies = components?.requestBodies || {}\n if (includes.includes('responses')) {\n const responses = components?.responses || {}\n\n Object.entries(responses).forEach(([name, response]: [string, OasTypes.ResponseObject]) => {\n if (response.content && !schemas[name]) {\n const firstContentType = Object.keys(response.content)[0] || 'application/json'\n schemas[name] = response.content?.[contentType || firstContentType]?.schema as OasTypes.SchemaObject\n }\n })\n }\n\n if (includes.includes('requestBodies')) {\n Object.entries(requestBodies).forEach(([name, request]: [string, OasTypes.RequestBodyObject]) => {\n if (request.content && !schemas[name]) {\n const firstContentType = Object.keys(request.content)[0] || 'application/json'\n schemas[name] = request.content?.[contentType || firstContentType]?.schema as OasTypes.SchemaObject\n }\n })\n }\n\n return schemas\n}\n","import { isOpenApiV3_1Document } from '@kubb/oas'\n\nimport type { Oas, OpenAPIV3, OpenAPIV3_1, SchemaObject } from '@kubb/oas'\n\n/**\n * Make it possible to narrow down the schema based on a specific version(3 or 3.1)\n */\ntype SchemaResult<TWithRef extends boolean = false> =\n | {\n schema?: (TWithRef extends true ? OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject : OpenAPIV3.SchemaObject) & {\n nullable?: boolean\n 'x-nullable'?: boolean\n }\n version: '3.0'\n }\n | {\n schema?: (TWithRef extends true ? OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject : OpenAPIV3_1.SchemaObject) & {\n nullable?: boolean\n 'x-nullable'?: boolean\n }\n version: '3.1'\n }\n\nexport function getSchemaFactory<TWithRef extends boolean = false>(oas: Oas): (schema?: SchemaObject) => SchemaResult<TWithRef> {\n return (schema?: SchemaObject) => {\n const version = isOpenApiV3_1Document(oas.api) ? '3.1' : '3.0'\n\n return {\n schema,\n version,\n } as SchemaResult<TWithRef>\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAUO,SAAS,WAAW,EAAE,KAAK,aAAa,WAAW,CAAC,WAAW,iBAAiB,WAAW,EAAE,GAA2D;AAC7J,QAAM,aAAa,IAAI,cAAc,EAAE;AAEvC,MAAI,UAAiD,CAAC;AAEtD,MAAI,SAAS,SAAS,SAAS,GAAG;AAChC,cAAU;AAAA,MACR,GAAG;AAAA,MACH,GAAK,YAAY,WAAqD,CAAC;AAAA,IACzE;AAAA,EACF;AAEA,QAAM,gBAAgB,YAAY,iBAAiB,CAAC;AACpD,MAAI,SAAS,SAAS,WAAW,GAAG;AAClC,UAAM,YAAY,YAAY,aAAa,CAAC;AAE5C,WAAO,QAAQ,SAAS,EAAE,QAAQ,CAAC,CAAC,MAAM,QAAQ,MAAyC;AACzF,UAAI,SAAS,WAAW,CAAC,QAAQ,IAAI,GAAG;AACtC,cAAM,mBAAmB,OAAO,KAAK,SAAS,OAAO,EAAE,CAAC,KAAK;AAC7D,gBAAQ,IAAI,IAAI,SAAS,UAAU,eAAe,gBAAgB,GAAG;AAAA,MACvE;AAAA,IACF,CAAC;AAAA,EACH;AAEA,MAAI,SAAS,SAAS,eAAe,GAAG;AACtC,WAAO,QAAQ,aAAa,EAAE,QAAQ,CAAC,CAAC,MAAM,OAAO,MAA4C;AAC/F,UAAI,QAAQ,WAAW,CAAC,QAAQ,IAAI,GAAG;AACrC,cAAM,mBAAmB,OAAO,KAAK,QAAQ,OAAO,EAAE,CAAC,KAAK;AAC5D,gBAAQ,IAAI,IAAI,QAAQ,UAAU,eAAe,gBAAgB,GAAG;AAAA,MACtE;AAAA,IACF,CAAC;AAAA,EACH;AAEA,SAAO;AACT;;;AC5CA;AAAA,SAAS,6BAA6B;AAuB/B,SAAS,iBAAmD,KAA6D;AAC9H,SAAO,CAAC,WAA0B;AAChC,UAAM,UAAU,sBAAsB,IAAI,GAAG,IAAI,QAAQ;AAEzD,WAAO;AAAA,MACL;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -1,143 +0,0 @@
1
- import { Plugin, ResolveNameParams, PluginFactoryOptions } from '@kubb/core';
2
- import * as KubbFile from '@kubb/fs/types';
3
- import { Oas, contentType, OasTypes, SchemaObject, Operation, HttpMethod } from '@kubb/oas';
4
- import { FormatOptions } from '@kubb/oas/parser';
5
-
6
- type Mode = 'schemas' | 'responses' | 'requestBodies';
7
- type GetSchemasProps = {
8
- oas: Oas;
9
- contentType?: contentType;
10
- includes?: Mode[];
11
- };
12
- declare function getSchemas({ oas, contentType, includes }: GetSchemasProps): Record<string, OasTypes.SchemaObject>;
13
-
14
- type ResolvePathOptions = {
15
- pluginKey?: Plugin['key'];
16
- tag?: string;
17
- type?: ResolveNameParams['type'];
18
- };
19
- type API = {
20
- getOas: (formatOptions?: FormatOptions) => Promise<Oas>;
21
- getSchemas: (options?: Pick<GetSchemasProps, 'includes'>) => Promise<Record<string, SchemaObject>>;
22
- getBaseURL: () => Promise<string | undefined>;
23
- contentType?: contentType;
24
- };
25
- type Options = {
26
- /**
27
- * Validate your input(see kubb.config) based on '@readme/openapi-parser'.
28
- * @default true
29
- */
30
- validate?: boolean;
31
- output?: {
32
- /**
33
- * Relative path to save the JSON models.
34
- * False will not generate the schema JSON's.
35
- * @default 'schemas'
36
- */
37
- path: string;
38
- } | false;
39
- /**
40
- * Which server to use from the array of `servers.url[serverIndex]`
41
- * @example
42
- * - `0` will return `http://petstore.swagger.io/api`
43
- * - `1` will return `http://localhost:3000`
44
- * @default 0
45
- */
46
- serverIndex?: number;
47
- /**
48
- * Define which contentType should be used.
49
- * By default, this is set based on the first used contentType..
50
- */
51
- contentType?: contentType;
52
- experimentalFilter?: FormatOptions['filterSet'];
53
- experimentalSort?: FormatOptions['sortSet'];
54
- oasClass?: typeof Oas;
55
- };
56
- /**
57
- * `propertyName` is the ref name + resolved with the nameResolver
58
- * @example `import { Pet } from './Pet'`
59
- *
60
- * `originalName` is the original name used(in PascalCase), only used to remove duplicates
61
- *
62
- * `pluginKey` can be used to override the current plugin being used, handy when you want to import a type/schema out of another plugin
63
- * @example import a type(plugin-ts) for a mock file(swagger-faker)
64
- */
65
- type Ref = {
66
- propertyName: string;
67
- originalName: string;
68
- path: KubbFile.OptionalPath;
69
- pluginKey?: Plugin['key'];
70
- };
71
- type Refs = Record<string, Ref>;
72
- type Resolver = {
73
- /**
74
- * Original name or name resolved by `resolveName({ name: operation?.getOperationId() as string, pluginName })`
75
- */
76
- name: string;
77
- baseName: KubbFile.BaseName;
78
- path: KubbFile.Path;
79
- };
80
- type OperationSchema = {
81
- /**
82
- * Converted name, contains already `PathParams`, `QueryParams`, ...
83
- */
84
- name: string;
85
- schema: SchemaObject;
86
- operation?: Operation;
87
- /**
88
- * OperationName in PascalCase, only being used in OperationGenerator
89
- */
90
- operationName?: string;
91
- description?: string;
92
- statusCode?: number;
93
- keys?: string[];
94
- keysToOmit?: string[];
95
- withData?: boolean;
96
- };
97
- type OperationSchemas = {
98
- pathParams?: OperationSchema & {
99
- keysToOmit?: never;
100
- };
101
- queryParams?: OperationSchema & {
102
- keysToOmit?: never;
103
- };
104
- headerParams?: OperationSchema & {
105
- keysToOmit?: never;
106
- };
107
- request?: OperationSchema;
108
- response: OperationSchema;
109
- statusCodes?: Array<OperationSchema>;
110
- errors?: Array<OperationSchema>;
111
- };
112
- type OperationsByMethod = Record<string, Record<HttpMethod, {
113
- operation: Operation;
114
- schemas: OperationSchemas;
115
- }>>;
116
- type ByTag = {
117
- type: 'tag';
118
- pattern: string | RegExp;
119
- };
120
- type ByOperationId = {
121
- type: 'operationId';
122
- pattern: string | RegExp;
123
- };
124
- type ByPath = {
125
- type: 'path';
126
- pattern: string | RegExp;
127
- };
128
- type ByMethod = {
129
- type: 'method';
130
- pattern: HttpMethod | RegExp;
131
- };
132
- type BySchemaName = {
133
- type: 'schemaName';
134
- pattern: string | RegExp;
135
- };
136
- type Exclude = ByTag | ByOperationId | ByPath | ByMethod;
137
- type Include = ByTag | ByOperationId | ByPath | ByMethod;
138
- type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName) & {
139
- options: Partial<TOptions>;
140
- };
141
- type PluginOas = PluginFactoryOptions<'plugin-oas', Options, Options, API, never>;
142
-
143
- export { type API as A, type Exclude as E, type GetSchemasProps as G, type Include as I, type Options as O, type PluginOas as P, type Refs as R, type OperationSchema as a, type Override as b, type ResolvePathOptions as c, type Ref as d, type Resolver as e, type OperationSchemas as f, type OperationsByMethod as g, getSchemas as h };
@@ -1,143 +0,0 @@
1
- import { Plugin, ResolveNameParams, PluginFactoryOptions } from '@kubb/core';
2
- import * as KubbFile from '@kubb/fs/types';
3
- import { Oas, contentType, OasTypes, SchemaObject, Operation, HttpMethod } from '@kubb/oas';
4
- import { FormatOptions } from '@kubb/oas/parser';
5
-
6
- type Mode = 'schemas' | 'responses' | 'requestBodies';
7
- type GetSchemasProps = {
8
- oas: Oas;
9
- contentType?: contentType;
10
- includes?: Mode[];
11
- };
12
- declare function getSchemas({ oas, contentType, includes }: GetSchemasProps): Record<string, OasTypes.SchemaObject>;
13
-
14
- type ResolvePathOptions = {
15
- pluginKey?: Plugin['key'];
16
- tag?: string;
17
- type?: ResolveNameParams['type'];
18
- };
19
- type API = {
20
- getOas: (formatOptions?: FormatOptions) => Promise<Oas>;
21
- getSchemas: (options?: Pick<GetSchemasProps, 'includes'>) => Promise<Record<string, SchemaObject>>;
22
- getBaseURL: () => Promise<string | undefined>;
23
- contentType?: contentType;
24
- };
25
- type Options = {
26
- /**
27
- * Validate your input(see kubb.config) based on '@readme/openapi-parser'.
28
- * @default true
29
- */
30
- validate?: boolean;
31
- output?: {
32
- /**
33
- * Relative path to save the JSON models.
34
- * False will not generate the schema JSON's.
35
- * @default 'schemas'
36
- */
37
- path: string;
38
- } | false;
39
- /**
40
- * Which server to use from the array of `servers.url[serverIndex]`
41
- * @example
42
- * - `0` will return `http://petstore.swagger.io/api`
43
- * - `1` will return `http://localhost:3000`
44
- * @default 0
45
- */
46
- serverIndex?: number;
47
- /**
48
- * Define which contentType should be used.
49
- * By default, this is set based on the first used contentType..
50
- */
51
- contentType?: contentType;
52
- experimentalFilter?: FormatOptions['filterSet'];
53
- experimentalSort?: FormatOptions['sortSet'];
54
- oasClass?: typeof Oas;
55
- };
56
- /**
57
- * `propertyName` is the ref name + resolved with the nameResolver
58
- * @example `import { Pet } from './Pet'`
59
- *
60
- * `originalName` is the original name used(in PascalCase), only used to remove duplicates
61
- *
62
- * `pluginKey` can be used to override the current plugin being used, handy when you want to import a type/schema out of another plugin
63
- * @example import a type(plugin-ts) for a mock file(swagger-faker)
64
- */
65
- type Ref = {
66
- propertyName: string;
67
- originalName: string;
68
- path: KubbFile.OptionalPath;
69
- pluginKey?: Plugin['key'];
70
- };
71
- type Refs = Record<string, Ref>;
72
- type Resolver = {
73
- /**
74
- * Original name or name resolved by `resolveName({ name: operation?.getOperationId() as string, pluginName })`
75
- */
76
- name: string;
77
- baseName: KubbFile.BaseName;
78
- path: KubbFile.Path;
79
- };
80
- type OperationSchema = {
81
- /**
82
- * Converted name, contains already `PathParams`, `QueryParams`, ...
83
- */
84
- name: string;
85
- schema: SchemaObject;
86
- operation?: Operation;
87
- /**
88
- * OperationName in PascalCase, only being used in OperationGenerator
89
- */
90
- operationName?: string;
91
- description?: string;
92
- statusCode?: number;
93
- keys?: string[];
94
- keysToOmit?: string[];
95
- withData?: boolean;
96
- };
97
- type OperationSchemas = {
98
- pathParams?: OperationSchema & {
99
- keysToOmit?: never;
100
- };
101
- queryParams?: OperationSchema & {
102
- keysToOmit?: never;
103
- };
104
- headerParams?: OperationSchema & {
105
- keysToOmit?: never;
106
- };
107
- request?: OperationSchema;
108
- response: OperationSchema;
109
- statusCodes?: Array<OperationSchema>;
110
- errors?: Array<OperationSchema>;
111
- };
112
- type OperationsByMethod = Record<string, Record<HttpMethod, {
113
- operation: Operation;
114
- schemas: OperationSchemas;
115
- }>>;
116
- type ByTag = {
117
- type: 'tag';
118
- pattern: string | RegExp;
119
- };
120
- type ByOperationId = {
121
- type: 'operationId';
122
- pattern: string | RegExp;
123
- };
124
- type ByPath = {
125
- type: 'path';
126
- pattern: string | RegExp;
127
- };
128
- type ByMethod = {
129
- type: 'method';
130
- pattern: HttpMethod | RegExp;
131
- };
132
- type BySchemaName = {
133
- type: 'schemaName';
134
- pattern: string | RegExp;
135
- };
136
- type Exclude = ByTag | ByOperationId | ByPath | ByMethod;
137
- type Include = ByTag | ByOperationId | ByPath | ByMethod;
138
- type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName) & {
139
- options: Partial<TOptions>;
140
- };
141
- type PluginOas = PluginFactoryOptions<'plugin-oas', Options, Options, API, never>;
142
-
143
- export { type API as A, type Exclude as E, type GetSchemasProps as G, type Include as I, type Options as O, type PluginOas as P, type Refs as R, type OperationSchema as a, type Override as b, type ResolvePathOptions as c, type Ref as d, type Resolver as e, type OperationSchemas as f, type OperationsByMethod as g, getSchemas as h };
@@ -1,82 +0,0 @@
1
- import { resolve } from 'node:path'
2
-
3
- import { FileManager } from '@kubb/core'
4
- import transformers from '@kubb/core/transformers'
5
- import { renderTemplate } from '@kubb/core/utils'
6
- import { getRelativePath } from '@kubb/fs'
7
-
8
- import type { Plugin } from '@kubb/core'
9
- import type { Logger } from '@kubb/core/logger'
10
- import type * as KubbFile from '@kubb/fs/types'
11
-
12
- type Options = {
13
- logger: Logger
14
- files: Array<KubbFile.File<FileMeta>>
15
- plugin: Plugin
16
- template: string
17
- exportAs: string
18
- /**
19
- * Root based on root and output.path specified in the config
20
- */
21
- root: string
22
- /**
23
- * Output for plugin
24
- */
25
- output: {
26
- path: string
27
- exportAs?: string
28
- extName?: KubbFile.Extname
29
- exportType?: 'barrel' | 'barrelNamed' | false
30
- }
31
- }
32
-
33
- type FileMeta = {
34
- pluginKey?: Plugin['key']
35
- tag?: string
36
- }
37
-
38
- export async function getGroupedByTagFiles({ logger, files, plugin, template, exportAs, root, output }: Options): Promise<KubbFile.File<FileMeta>[]> {
39
- const { path, exportType = 'barrel' } = output
40
- const mode = FileManager.getMode(resolve(root, path))
41
-
42
- if (mode === 'single' || exportType === false) {
43
- return []
44
- }
45
-
46
- return files
47
- .filter((file) => {
48
- const name = file.meta?.pluginKey?.[0]
49
- return name === plugin.name
50
- })
51
- .map((file: KubbFile.File<FileMeta>) => {
52
- if (!file.meta?.tag) {
53
- logger?.emit('debug', [`Could not find a tagName for ${JSON.stringify(file, undefined, 2)}`])
54
-
55
- return
56
- }
57
-
58
- const tag = file.meta?.tag && transformers.camelCase(file.meta.tag)
59
- const tagPath = getRelativePath(resolve(root, output.path), resolve(root, renderTemplate(template, { tag })))
60
- const tagName = renderTemplate(exportAs, { tag })
61
-
62
- if (tagName) {
63
- return {
64
- baseName: 'index.ts' as const,
65
- path: resolve(root, output.path, 'index.ts'),
66
- source: '',
67
- exports: [
68
- {
69
- path: output.extName ? `${tagPath}/index${output.extName}` : `${tagPath}/index`,
70
- asAlias: true,
71
- name: tagName,
72
- },
73
- ],
74
- meta: {
75
- pluginKey: plugin.key,
76
- },
77
- exportable: true,
78
- }
79
- }
80
- })
81
- .filter(Boolean)
82
- }
@@ -1,13 +0,0 @@
1
- import type { Refs } from '../types.ts'
2
-
3
- type Generated = { import: { refs: Refs; name: string } }
4
-
5
- export function refsSorter<T extends Generated>(a: T, b: T): number {
6
- if (Object.keys(a.import.refs)?.length < Object.keys(b.import.refs)?.length) {
7
- return -1
8
- }
9
- if (Object.keys(a.import.refs)?.length > Object.keys(b.import.refs)?.length) {
10
- return 1
11
- }
12
- return 0
13
- }