@kubb/core 5.0.0-beta.93 → 5.0.0-beta.95
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 +44 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -10
- package/dist/index.js +45 -16
- package/dist/index.js.map +1 -1
- package/dist/mocks.cjs +4 -8
- package/dist/mocks.cjs.map +1 -1
- package/dist/mocks.d.ts +1 -4
- package/dist/mocks.js +6 -10
- package/dist/mocks.js.map +1 -1
- package/dist/{types-BLFyAJLZ.d.ts → types-Bl0feoGY.d.ts} +101 -64
- package/dist/usingCtx-BriKju-v.js.map +1 -1
- package/dist/usingCtx-eyNeehd2.cjs.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -33,7 +33,6 @@ node_process = require_usingCtx.__toESM(node_process, 1);
|
|
|
33
33
|
* // Convert the source (path or inline data) into an InputNode.
|
|
34
34
|
* return ast.factory.createInput()
|
|
35
35
|
* },
|
|
36
|
-
* getImports: () => [],
|
|
37
36
|
* async validate() {
|
|
38
37
|
* // Throw here when the spec is invalid.
|
|
39
38
|
* },
|
|
@@ -192,7 +191,7 @@ function memoize(store, factory) {
|
|
|
192
191
|
}
|
|
193
192
|
//#endregion
|
|
194
193
|
//#region package.json
|
|
195
|
-
var version = "5.0.0-beta.
|
|
194
|
+
var version = "5.0.0-beta.95";
|
|
196
195
|
//#endregion
|
|
197
196
|
//#region src/constants.ts
|
|
198
197
|
/**
|
|
@@ -813,9 +812,9 @@ function toBaseName({ name, extname }) {
|
|
|
813
812
|
/**
|
|
814
813
|
* Base constraint for all plugin resolver objects.
|
|
815
814
|
*
|
|
816
|
-
* The built-in machinery lives under `default`. Generators call the top-level `name`
|
|
817
|
-
* `
|
|
818
|
-
* (`typeName`, …) and/or grouped namespaces (`query`, `schema`, …).
|
|
815
|
+
* The built-in machinery lives under `default`. Generators call the top-level `name`, `file`,
|
|
816
|
+
* and `imports`, and a plugin overrides `name` and `file` to set its conventions. Extend with
|
|
817
|
+
* top-level helpers (`typeName`, …) and/or grouped namespaces (`query`, `schema`, …).
|
|
819
818
|
*
|
|
820
819
|
* @example Top-level helper
|
|
821
820
|
* ```ts
|
|
@@ -873,6 +872,35 @@ var Resolver = class Resolver {
|
|
|
873
872
|
return this.#resolveFile(options);
|
|
874
873
|
}
|
|
875
874
|
/**
|
|
875
|
+
* Builds one `ImportNode` per unique schema referenced in the tree, in first-occurrence
|
|
876
|
+
* order. Each ref's target resolves through `resolveRefName`, so collision- or macro-renamed
|
|
877
|
+
* schemas (`targetName`) import the emitted name. Names and paths go through the top-level
|
|
878
|
+
* `name` and `file`, so import entries follow the plugin's conventions, and a per-call
|
|
879
|
+
* `name` override wins over both.
|
|
880
|
+
*/
|
|
881
|
+
imports(options) {
|
|
882
|
+
const { node, root, output, group, extname = ".ts", name } = options;
|
|
883
|
+
const resolveName = name ?? ((schemaName) => this.name(schemaName));
|
|
884
|
+
const seen = /* @__PURE__ */ new Set();
|
|
885
|
+
return (0, _kubb_ast.collect)(node, { schema: (schemaNode) => {
|
|
886
|
+
const schemaRef = (0, _kubb_ast.narrowSchema)(schemaNode, "ref");
|
|
887
|
+
if (!schemaRef?.ref) return null;
|
|
888
|
+
const schemaName = (0, _kubb_ast.resolveRefName)(schemaRef);
|
|
889
|
+
if (!schemaName || seen.has(schemaName)) return null;
|
|
890
|
+
seen.add(schemaName);
|
|
891
|
+
return _kubb_ast.ast.factory.createImport({
|
|
892
|
+
name: [resolveName(schemaName)],
|
|
893
|
+
path: this.file({
|
|
894
|
+
name: schemaName,
|
|
895
|
+
extname,
|
|
896
|
+
root,
|
|
897
|
+
output,
|
|
898
|
+
group
|
|
899
|
+
}).path
|
|
900
|
+
});
|
|
901
|
+
} });
|
|
902
|
+
}
|
|
903
|
+
/**
|
|
876
904
|
* Merges `override` over `base` and returns a new resolver with helpers re-bound. Top-level
|
|
877
905
|
* keys replace, and a namespace (or `file`) merges per method, so overriding `query.name`
|
|
878
906
|
* keeps the base `query.keyName`. Used when applying `setResolver` partial overrides. Reads a
|
|
@@ -1303,7 +1331,8 @@ var KubbDriver = class {
|
|
|
1303
1331
|
},
|
|
1304
1332
|
exclude: [],
|
|
1305
1333
|
override: []
|
|
1306
|
-
}
|
|
1334
|
+
},
|
|
1335
|
+
resolver: this.#getDefaultResolver(rawPlugin.name)
|
|
1307
1336
|
};
|
|
1308
1337
|
}));
|
|
1309
1338
|
for (const plugin of normalized) {
|
|
@@ -2143,10 +2172,10 @@ const logLevel = {
|
|
|
2143
2172
|
verbose: 4
|
|
2144
2173
|
};
|
|
2145
2174
|
/**
|
|
2146
|
-
* Defines a reporter.
|
|
2147
|
-
*
|
|
2148
|
-
*
|
|
2149
|
-
*
|
|
2175
|
+
* Defines a reporter. The returned reporter buffers each value `report` returns in order and, when
|
|
2176
|
+
* the definition has a `drain`, hands the array to `drain` once and then clears it. Wiring the
|
|
2177
|
+
* reporter onto the run's hooks is the host's job, so the reporter only ever deals with a
|
|
2178
|
+
* {@link GenerationResult}.
|
|
2150
2179
|
*
|
|
2151
2180
|
* @example
|
|
2152
2181
|
* ```ts
|
|
@@ -2164,19 +2193,19 @@ const logLevel = {
|
|
|
2164
2193
|
* ```
|
|
2165
2194
|
*/
|
|
2166
2195
|
function createReporter(reporter) {
|
|
2167
|
-
const reports =
|
|
2196
|
+
const reports = [];
|
|
2168
2197
|
return {
|
|
2169
2198
|
name: reporter.name,
|
|
2170
2199
|
async report(result, context) {
|
|
2171
2200
|
const report = await reporter.report(result, context);
|
|
2172
|
-
reports.
|
|
2201
|
+
if (reporter.drain) reports.push(report);
|
|
2173
2202
|
},
|
|
2174
2203
|
async drain(context) {
|
|
2175
|
-
await reporter.drain?.(context,
|
|
2176
|
-
reports.
|
|
2204
|
+
await reporter.drain?.(context, [...reports]);
|
|
2205
|
+
reports.length = 0;
|
|
2177
2206
|
},
|
|
2178
2207
|
[Symbol.dispose]() {
|
|
2179
|
-
reports.
|
|
2208
|
+
reports.length = 0;
|
|
2180
2209
|
}
|
|
2181
2210
|
};
|
|
2182
2211
|
}
|