@kubb/core 5.0.0-beta.69 → 5.0.0-beta.70
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 +17 -57
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +17 -57
- package/dist/index.js.map +1 -1
- package/dist/memoryStorage-B4VTTIpQ.js.map +1 -1
- package/dist/memoryStorage-CfycFGzX.cjs.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -97,47 +97,6 @@ function randomCliColor(text) {
|
|
|
97
97
|
}
|
|
98
98
|
//#endregion
|
|
99
99
|
//#region ../../internals/utils/src/promise.ts
|
|
100
|
-
function* chunks(arr, size) {
|
|
101
|
-
for (let i = 0; i < arr.length; i += size) yield arr.slice(i, i + size);
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Slices `source` into batches of `concurrency` items and awaits `process` for each batch.
|
|
105
|
-
* Accepts both plain arrays (sync) and `AsyncIterable` (streaming).
|
|
106
|
-
*
|
|
107
|
-
* `process` controls whether items inside a batch run in parallel; this helper only
|
|
108
|
-
* controls batch size and per-batch flushing.
|
|
109
|
-
*
|
|
110
|
-
* @example
|
|
111
|
-
* ```ts
|
|
112
|
-
* // parallel dispatch inside each batch
|
|
113
|
-
* await forBatches(schemas, (batch) => Promise.all(batch.map(process)), { concurrency: 8 })
|
|
114
|
-
*
|
|
115
|
-
* // async iterable with a flush after every batch
|
|
116
|
-
* await forBatches(stream.schemas, (batch) => dispatch(batch), { concurrency: 8, flush })
|
|
117
|
-
* ```
|
|
118
|
-
*/
|
|
119
|
-
async function forBatches(source, process, options) {
|
|
120
|
-
const { concurrency, flush } = options;
|
|
121
|
-
if (Array.isArray(source)) {
|
|
122
|
-
for (const batch of chunks(source, concurrency)) {
|
|
123
|
-
await process(batch);
|
|
124
|
-
if (flush) await flush();
|
|
125
|
-
}
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
const batch = [];
|
|
129
|
-
for await (const item of source) {
|
|
130
|
-
batch.push(item);
|
|
131
|
-
if (batch.length >= concurrency) {
|
|
132
|
-
await process(batch.splice(0));
|
|
133
|
-
if (flush) await flush();
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
if (batch.length > 0) {
|
|
137
|
-
await process(batch.splice(0));
|
|
138
|
-
if (flush) await flush();
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
100
|
/** Returns `true` when `result` is a thenable `Promise`.
|
|
142
101
|
*
|
|
143
102
|
* @example
|
|
@@ -447,7 +406,7 @@ function createAdapter(build) {
|
|
|
447
406
|
/**
|
|
448
407
|
* Docs major version, derived from the package version so the link tracks the published major.
|
|
449
408
|
*/
|
|
450
|
-
const docsMajor = "5.0.0-beta.
|
|
409
|
+
const docsMajor = "5.0.0-beta.70".split(".")[0] ?? "5";
|
|
451
410
|
/**
|
|
452
411
|
* Narrows a {@link Diagnostic} to the variant for `code`, or `null` when it does not match.
|
|
453
412
|
*
|
|
@@ -1912,27 +1871,28 @@ var KubbDriver = class {
|
|
|
1912
1871
|
checkAllowedNames: false,
|
|
1913
1872
|
emit: emitsOperationHook ? (node, ctx) => this.hooks.emit("kubb:generate:operation", node, ctx) : null
|
|
1914
1873
|
};
|
|
1874
|
+
const dispatchPass = async (state, nodes, dispatch) => {
|
|
1875
|
+
let sinceFlush = 0;
|
|
1876
|
+
for (const node of nodes) {
|
|
1877
|
+
await dispatchNode(state, node, dispatch);
|
|
1878
|
+
if (++sinceFlush >= 8) {
|
|
1879
|
+
sinceFlush = 0;
|
|
1880
|
+
await flushPending();
|
|
1881
|
+
}
|
|
1882
|
+
}
|
|
1883
|
+
if (sinceFlush > 0) await flushPending();
|
|
1884
|
+
};
|
|
1915
1885
|
for (const state of states) {
|
|
1916
|
-
const
|
|
1917
|
-
|
|
1918
|
-
await
|
|
1919
|
-
|
|
1920
|
-
flush: flushPending
|
|
1921
|
-
});
|
|
1922
|
-
await forBatches(operationsBuffer, (nodes) => {
|
|
1923
|
-
if (needsCollectedOperations) collectedOperations?.push(...nodes);
|
|
1924
|
-
return Promise.all(nodes.map((node) => dispatchNode(state, node, operationDispatch)));
|
|
1925
|
-
}, {
|
|
1926
|
-
concurrency: 8,
|
|
1927
|
-
flush: flushPending
|
|
1928
|
-
});
|
|
1929
|
-
if (!state.failed && needsCollectedOperations) try {
|
|
1886
|
+
const needsOperationsAggregate = emitsOperationsHook || state.generators.some((gen) => !!gen.operations);
|
|
1887
|
+
await dispatchPass(state, schemasBuffer, schemaDispatch);
|
|
1888
|
+
await dispatchPass(state, operationsBuffer, operationDispatch);
|
|
1889
|
+
if (!state.failed && needsOperationsAggregate) try {
|
|
1930
1890
|
const { plugin, generatorContext, generators } = state;
|
|
1931
1891
|
const ctx = {
|
|
1932
1892
|
...generatorContext,
|
|
1933
1893
|
options: plugin.options
|
|
1934
1894
|
};
|
|
1935
|
-
const pluginOperations =
|
|
1895
|
+
const pluginOperations = operationsBuffer.reduce((acc, node) => {
|
|
1936
1896
|
const resolved = resolveForPlugin(state, node);
|
|
1937
1897
|
if (resolved) acc.push(resolved.transformedNode);
|
|
1938
1898
|
return acc;
|