@kubb/studio 5.11.5 → 5.11.6
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 +69 -34
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.js +69 -34
- package/dist/index.js.map +1 -1
- package/dist/{protocol--vpA4DkB.d.ts → protocol-dCzUP4dH.d.cts} +42 -32
- package/dist/{protocol--vpA4DkB.d.cts → protocol-dCzUP4dH.d.ts} +42 -32
- package/dist/protocol.cjs +1 -0
- package/dist/protocol.cjs.map +1 -1
- package/dist/protocol.d.cts +2 -2
- package/dist/protocol.d.ts +2 -2
- package/dist/protocol.js +1 -0
- package/dist/protocol.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { F as PublishedSnapshot, G as SnapshotUploadMetadata, O as InstalledExtensions, a as AgentConnectInfo, c as AgentPermissions, d as ConfigEditOutcome, s as AgentPermission, u as ConfigEdit } from "./protocol-dCzUP4dH.cjs";
|
|
2
2
|
import { Config, Hookable, KubbHooks } from "@kubb/core";
|
|
3
3
|
//#region src/connect.d.ts
|
|
4
4
|
/**
|
|
@@ -80,9 +80,10 @@ type ConnectAgentOptions = {
|
|
|
80
80
|
*/
|
|
81
81
|
configPath: string;
|
|
82
82
|
/**
|
|
83
|
-
* Called for every handshake and every generation, so edits on disk show up.
|
|
83
|
+
* Called for every handshake and every generation, so edits on disk show up. One entry per
|
|
84
|
+
* `defineConfig(...)` entry, and a generation names the one it runs.
|
|
84
85
|
*/
|
|
85
|
-
|
|
86
|
+
loadConfigs: () => Promise<Array<Config>>;
|
|
86
87
|
/**
|
|
87
88
|
* The host's own version, reported to Studio next to the runtime's.
|
|
88
89
|
*/
|
|
@@ -122,7 +123,7 @@ type ConnectAgentOptions = {
|
|
|
122
123
|
* const hooks = new Hookable<KubbHooks>()
|
|
123
124
|
* hooks.hook('studio:connected', ({ agentSlug }) => console.log(`Connected as ${agentSlug}`))
|
|
124
125
|
*
|
|
125
|
-
* await connectAgent({ token, configPath: 'kubb.config.ts',
|
|
126
|
+
* await connectAgent({ token, configPath: 'kubb.config.ts', loadConfigs, version: '1.0.0', hooks, signal })
|
|
126
127
|
* ```
|
|
127
128
|
*/
|
|
128
129
|
export declare function connectAgent(options: ConnectAgentOptions): Promise<void>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { F as PublishedSnapshot, G as SnapshotUploadMetadata, O as InstalledExtensions, a as AgentConnectInfo, c as AgentPermissions, d as ConfigEditOutcome, s as AgentPermission, u as ConfigEdit } from "./protocol-dCzUP4dH.js";
|
|
2
2
|
import { Config, Hookable, KubbHooks } from "@kubb/core";
|
|
3
3
|
//#region src/connect.d.ts
|
|
4
4
|
/**
|
|
@@ -80,9 +80,10 @@ type ConnectAgentOptions = {
|
|
|
80
80
|
*/
|
|
81
81
|
configPath: string;
|
|
82
82
|
/**
|
|
83
|
-
* Called for every handshake and every generation, so edits on disk show up.
|
|
83
|
+
* Called for every handshake and every generation, so edits on disk show up. One entry per
|
|
84
|
+
* `defineConfig(...)` entry, and a generation names the one it runs.
|
|
84
85
|
*/
|
|
85
|
-
|
|
86
|
+
loadConfigs: () => Promise<Array<Config>>;
|
|
86
87
|
/**
|
|
87
88
|
* The host's own version, reported to Studio next to the runtime's.
|
|
88
89
|
*/
|
|
@@ -122,7 +123,7 @@ type ConnectAgentOptions = {
|
|
|
122
123
|
* const hooks = new Hookable<KubbHooks>()
|
|
123
124
|
* hooks.hook('studio:connected', ({ agentSlug }) => console.log(`Connected as ${agentSlug}`))
|
|
124
125
|
*
|
|
125
|
-
* await connectAgent({ token, configPath: 'kubb.config.ts',
|
|
126
|
+
* await connectAgent({ token, configPath: 'kubb.config.ts', loadConfigs, version: '1.0.0', hooks, signal })
|
|
126
127
|
* ```
|
|
127
128
|
*/
|
|
128
129
|
export declare function connectAgent(options: ConnectAgentOptions): Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -196,7 +196,7 @@ function getElapsedMs(hrStart) {
|
|
|
196
196
|
}
|
|
197
197
|
//#endregion
|
|
198
198
|
//#region package.json
|
|
199
|
-
var version = "5.11.
|
|
199
|
+
var version = "5.11.6";
|
|
200
200
|
//#endregion
|
|
201
201
|
//#region src/resolveConfig.ts
|
|
202
202
|
/**
|
|
@@ -2045,19 +2045,25 @@ var Agent = class extends RpcTarget {
|
|
|
2045
2045
|
}
|
|
2046
2046
|
async connect(info) {
|
|
2047
2047
|
this.#session.info = info;
|
|
2048
|
-
const { configPath, root, version: version$1,
|
|
2048
|
+
const { configPath, root, version: version$1, loadConfigs, configFile } = this.#options;
|
|
2049
2049
|
const source = read(configFile);
|
|
2050
|
-
const [
|
|
2051
|
-
|
|
2050
|
+
const [configs, file, extensions] = await Promise.all([
|
|
2051
|
+
loadConfigs(),
|
|
2052
2052
|
this.#readConfigFileView(source),
|
|
2053
2053
|
this.#installedExtensions(source)
|
|
2054
2054
|
]);
|
|
2055
|
-
const
|
|
2056
|
-
|
|
2057
|
-
|
|
2055
|
+
const entries = [];
|
|
2056
|
+
for (const config of configs) {
|
|
2057
|
+
const disk = await this.#readDiskOutput(config).catch(async (error) => {
|
|
2058
|
+
await this.#warn({ message: `Could not read the output directory: ${getErrorMessage(error)}` });
|
|
2059
|
+
});
|
|
2060
|
+
entries.push({
|
|
2061
|
+
...toEntryView(config, extensions),
|
|
2062
|
+
...disk && { disk }
|
|
2063
|
+
});
|
|
2064
|
+
}
|
|
2058
2065
|
this.#session.connected.resolve(info);
|
|
2059
2066
|
return {
|
|
2060
|
-
output,
|
|
2061
2067
|
versions: {
|
|
2062
2068
|
kubb: version,
|
|
2063
2069
|
agent: version$1
|
|
@@ -2066,30 +2072,8 @@ var Agent = class extends RpcTarget {
|
|
|
2066
2072
|
config: {
|
|
2067
2073
|
path: configPath,
|
|
2068
2074
|
file,
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
name: resolveMeta(plugin).name,
|
|
2072
|
-
extensions
|
|
2073
|
-
}),
|
|
2074
|
-
options: toJSONOptions(plugin.options)
|
|
2075
|
-
})),
|
|
2076
|
-
adapter: config.adapter && {
|
|
2077
|
-
name: toStudioName({
|
|
2078
|
-
name: resolveMeta(config.adapter).name,
|
|
2079
|
-
extensions,
|
|
2080
|
-
kind: "adapter"
|
|
2081
|
-
}),
|
|
2082
|
-
options: toJSONOptions(config.adapter.options)
|
|
2083
|
-
},
|
|
2084
|
-
parsers: config.parsers.map((parser) => ({
|
|
2085
|
-
name: toStudioName({
|
|
2086
|
-
name: resolveMeta(parser).name,
|
|
2087
|
-
extensions,
|
|
2088
|
-
kind: "parser"
|
|
2089
|
-
}),
|
|
2090
|
-
options: toJSONOptions(parser.options)
|
|
2091
|
-
})),
|
|
2092
|
-
extensions: [...extensions.values()]
|
|
2075
|
+
extensions: [...extensions.values()],
|
|
2076
|
+
configs: entries
|
|
2093
2077
|
},
|
|
2094
2078
|
permissions: this.#permissions
|
|
2095
2079
|
};
|
|
@@ -2177,7 +2161,9 @@ var Agent = class extends RpcTarget {
|
|
|
2177
2161
|
const { jobId, config: patch } = input;
|
|
2178
2162
|
const studioInput = this.#sandbox ? patch?.input : void 0;
|
|
2179
2163
|
if (this.#sandbox && (typeof studioInput !== "string" || !studioInput.trim() || getInputKind(studioInput) !== "inline")) return this.#refuse({ message: AgentMessage.SANDBOX_INPUT_ONLY });
|
|
2180
|
-
const [
|
|
2164
|
+
const [configs, extensions] = await Promise.all([this.#options.loadConfigs(), this.#installedExtensions()]);
|
|
2165
|
+
const config = pickConfig(configs, patch?.config);
|
|
2166
|
+
if (!config) return this.#refuse({ message: AgentMessage.CONFIG_ENTRY_NOT_FOUND });
|
|
2181
2167
|
const [plugins, adapter, parsers] = await Promise.all([
|
|
2182
2168
|
mergePlugins({
|
|
2183
2169
|
diskPlugins: config.plugins,
|
|
@@ -2481,6 +2467,55 @@ async function runSession({ options, openRpc, url, instanceId }) {
|
|
|
2481
2467
|
/**
|
|
2482
2468
|
* The connection loop with a swappable transport. {@link connectAgent} passes a real WebSocket.
|
|
2483
2469
|
*/
|
|
2470
|
+
/** The entry Studio named by position or `name`, else the first. `undefined` for one the file does not have. */
|
|
2471
|
+
function pickConfig(configs, ref) {
|
|
2472
|
+
if (typeof ref === "string") return configs.find((config) => config.name === ref);
|
|
2473
|
+
if (ref !== void 0 && !Number.isSafeInteger(ref)) return void 0;
|
|
2474
|
+
return configs[ref ?? 0];
|
|
2475
|
+
}
|
|
2476
|
+
/** The input path or URL Studio may show: no inline document, and no credentials from a URL. */
|
|
2477
|
+
function reportedInput(input) {
|
|
2478
|
+
if (typeof input !== "string") return void 0;
|
|
2479
|
+
const kind = getInputKind(input);
|
|
2480
|
+
if (kind === "inline") return void 0;
|
|
2481
|
+
if (kind !== "url") return input;
|
|
2482
|
+
const url = new URL(input);
|
|
2483
|
+
url.username = "";
|
|
2484
|
+
url.password = "";
|
|
2485
|
+
return url.href;
|
|
2486
|
+
}
|
|
2487
|
+
/** A JSON copy of one resolved entry, each extension named by the package its manifest is in. */
|
|
2488
|
+
function toEntryView(config, extensions) {
|
|
2489
|
+
const input = reportedInput(config.input);
|
|
2490
|
+
return {
|
|
2491
|
+
...config.name !== void 0 && { name: config.name },
|
|
2492
|
+
...input !== void 0 && { input },
|
|
2493
|
+
output: config.output.path,
|
|
2494
|
+
plugins: config.plugins.map((plugin) => ({
|
|
2495
|
+
name: toStudioName({
|
|
2496
|
+
name: resolveMeta(plugin).name,
|
|
2497
|
+
extensions
|
|
2498
|
+
}),
|
|
2499
|
+
options: toJSONOptions(plugin.options)
|
|
2500
|
+
})),
|
|
2501
|
+
adapter: config.adapter && {
|
|
2502
|
+
name: toStudioName({
|
|
2503
|
+
name: resolveMeta(config.adapter).name,
|
|
2504
|
+
extensions,
|
|
2505
|
+
kind: "adapter"
|
|
2506
|
+
}),
|
|
2507
|
+
options: toJSONOptions(config.adapter.options)
|
|
2508
|
+
},
|
|
2509
|
+
parsers: config.parsers.map((parser) => ({
|
|
2510
|
+
name: toStudioName({
|
|
2511
|
+
name: resolveMeta(parser).name,
|
|
2512
|
+
extensions,
|
|
2513
|
+
kind: "parser"
|
|
2514
|
+
}),
|
|
2515
|
+
options: toJSONOptions(parser.options)
|
|
2516
|
+
}))
|
|
2517
|
+
};
|
|
2518
|
+
}
|
|
2484
2519
|
async function runAgent({ options, openRpc }) {
|
|
2485
2520
|
const root = options.root ?? process$1.cwd();
|
|
2486
2521
|
const resolved = {
|
|
@@ -2542,7 +2577,7 @@ async function runAgent({ options, openRpc }) {
|
|
|
2542
2577
|
* const hooks = new Hookable<KubbHooks>()
|
|
2543
2578
|
* hooks.hook('studio:connected', ({ agentSlug }) => console.log(`Connected as ${agentSlug}`))
|
|
2544
2579
|
*
|
|
2545
|
-
* await connectAgent({ token, configPath: 'kubb.config.ts',
|
|
2580
|
+
* await connectAgent({ token, configPath: 'kubb.config.ts', loadConfigs, version: '1.0.0', hooks, signal })
|
|
2546
2581
|
* ```
|
|
2547
2582
|
*/
|
|
2548
2583
|
function connectAgent(options) {
|