@kubb/studio 5.14.6 → 5.15.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.
package/dist/index.d.cts CHANGED
@@ -1,6 +1,5 @@
1
- import { B as SnapshotUploadMetadata, G as editConfig, K as editConfigFile, O as PublishedSnapshot, a as AgentConnectInfo, c as AgentPermissions, s as AgentPermission } from "./protocol-DQTwqmNO.cjs";
1
+ import { K as editConfig, V as SnapshotUploadMetadata, a as AgentConnectInfo, c as AgentPermissions, k as PublishedSnapshot, q as editConfigFile, s as AgentPermission } from "./protocol-D2As08Ww.cjs";
2
2
  import { Config, Hookable, KubbHooks } from "@kubb/core";
3
- //#region src/connect.d.ts
4
3
  /**
5
4
  * Studio closed with {@link AgentCloseCode.UNAUTHORIZED}. Hosts forget the token and pair again.
6
5
  */
@@ -129,8 +128,6 @@ type ConnectAgentOptions = {
129
128
  * ```
130
129
  */
131
130
  export declare function connectAgent(options: ConnectAgentOptions): Promise<void>;
132
- //#endregion
133
- //#region src/pair.d.ts
134
131
  /**
135
132
  * RFC 8628 device-authorization response from Studio's `/api/auth/device/code` endpoint.
136
133
  * Field names match the RFC; the CLI polls with `device_code` and shows `user_code` to the user.
@@ -221,8 +218,6 @@ type PairAgentOptions = StartPairingOptions & {
221
218
  * Pairs this machine with Studio: asks for a code, hands it to the host to show, and waits for approval.
222
219
  */
223
220
  export declare function pairAgent({ onCode, onRetry, maxAttempts, ...options }: PairAgentOptions): Promise<PairingResult>;
224
- //#endregion
225
- //#region src/snapshot.d.ts
226
221
  type CreateSnapshotOptions = Omit<SnapshotUploadMetadata, 'hashes' | 'peerDependencies'> & {
227
222
  studioUrl?: string;
228
223
  /**
@@ -245,12 +240,9 @@ type CreateSnapshotOptions = Omit<SnapshotUploadMetadata, 'hashes' | 'peerDepend
245
240
  * ```
246
241
  */
247
242
  export declare function createSnapshot({ studioUrl, apiKey, config, hooks, signal, ...metadata }: CreateSnapshotOptions): Promise<PublishedSnapshot>;
248
- //#endregion
249
- //#region src/url.d.ts
250
243
  /**
251
244
  * Hosted Kubb Studio URL, used when a host passes none.
252
245
  */
253
246
  export declare const defaultStudioUrl = "https://kubb.studio";
254
- //#endregion
255
247
  export { type ConnectAgentOptions, type StudioConnectedContext, editConfig, editConfigFile };
256
248
  //# sourceMappingURL=index.d.cts.map
package/dist/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
- import { B as SnapshotUploadMetadata, G as editConfig, K as editConfigFile, O as PublishedSnapshot, a as AgentConnectInfo, c as AgentPermissions, s as AgentPermission } from "./protocol-DQTwqmNO.js";
1
+ import { K as editConfig, V as SnapshotUploadMetadata, a as AgentConnectInfo, c as AgentPermissions, k as PublishedSnapshot, q as editConfigFile, s as AgentPermission } from "./protocol-D2As08Ww.js";
2
2
  import { Config, Hookable, KubbHooks } from "@kubb/core";
3
- //#region src/connect.d.ts
4
3
  /**
5
4
  * Studio closed with {@link AgentCloseCode.UNAUTHORIZED}. Hosts forget the token and pair again.
6
5
  */
@@ -129,8 +128,6 @@ type ConnectAgentOptions = {
129
128
  * ```
130
129
  */
131
130
  export declare function connectAgent(options: ConnectAgentOptions): Promise<void>;
132
- //#endregion
133
- //#region src/pair.d.ts
134
131
  /**
135
132
  * RFC 8628 device-authorization response from Studio's `/api/auth/device/code` endpoint.
136
133
  * Field names match the RFC; the CLI polls with `device_code` and shows `user_code` to the user.
@@ -221,8 +218,6 @@ type PairAgentOptions = StartPairingOptions & {
221
218
  * Pairs this machine with Studio: asks for a code, hands it to the host to show, and waits for approval.
222
219
  */
223
220
  export declare function pairAgent({ onCode, onRetry, maxAttempts, ...options }: PairAgentOptions): Promise<PairingResult>;
224
- //#endregion
225
- //#region src/snapshot.d.ts
226
221
  type CreateSnapshotOptions = Omit<SnapshotUploadMetadata, 'hashes' | 'peerDependencies'> & {
227
222
  studioUrl?: string;
228
223
  /**
@@ -245,12 +240,9 @@ type CreateSnapshotOptions = Omit<SnapshotUploadMetadata, 'hashes' | 'peerDepend
245
240
  * ```
246
241
  */
247
242
  export declare function createSnapshot({ studioUrl, apiKey, config, hooks, signal, ...metadata }: CreateSnapshotOptions): Promise<PublishedSnapshot>;
248
- //#endregion
249
- //#region src/url.d.ts
250
243
  /**
251
244
  * Hosted Kubb Studio URL, used when a host passes none.
252
245
  */
253
246
  export declare const defaultStudioUrl = "https://kubb.studio";
254
- //#endregion
255
247
  export { type ConnectAgentOptions, type StudioConnectedContext, editConfig, editConfigFile };
256
248
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as AgentPermission, c as MAX_SNAPSHOT_BYTES, d as extensionKinds, i as AgentMessage, l as generationEventTypes, n as AGENT_SOCKET_PATH, r as AgentCloseCode, t as AGENT_INSTANCE_HEADER, u as ConfigEditOperation } from "./protocol-DQnAN8NE.js";
1
+ import { a as AgentPermission, c as MAX_SNAPSHOT_BYTES, d as extensionKinds, i as AgentMessage, l as generationEventTypes, n as AGENT_SOCKET_PATH, r as AgentCloseCode, t as AGENT_INSTANCE_HEADER, u as ConfigEditOperation } from "./protocol-B6oWLc7W.js";
2
2
  import { createRequire } from "node:module";
3
3
  import { createHash, hash, randomUUID } from "node:crypto";
4
4
  import { existsSync } from "node:fs";
@@ -22,8 +22,7 @@ import net from "node:net";
22
22
  import { Readable, Transform } from "node:stream";
23
23
  import { ofetch } from "ofetch";
24
24
  import { gzipSync } from "node:zlib";
25
- //#endregion
26
- //#region ../../internals/utils/src/casing.ts
25
+ // ../../internals/utils/src/casing.ts
27
26
  /**
28
27
  * Shared implementation for camelCase and PascalCase conversion.
29
28
  * Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)
@@ -38,7 +37,7 @@ function convert(text, pascal) {
38
37
  }).join("").replace(/[^a-zA-Z0-9]/g, "");
39
38
  }
40
39
  const cache = /* @__PURE__ */ new Map();
41
- const cacheLimit = 1e4;
40
+ const cacheLimit = 1e5;
42
41
  function toCamelOrPascal(text, pascal) {
43
42
  const key = `${pascal ? "P" : "c"}${text}`;
44
43
  const cached = cache.get(key);
@@ -60,8 +59,7 @@ function toCamelOrPascal(text, pascal) {
60
59
  function camelCase(text, { prefix = "", suffix = "" } = {}) {
61
60
  return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false);
62
61
  }
63
- //#endregion
64
- //#region ../../internals/utils/src/errors.ts
62
+ // ../../internals/utils/src/errors.ts
65
63
  /**
66
64
  * Coerces an unknown thrown value to an `Error` instance.
67
65
  * Returns the value as-is when it is already an `Error`; otherwise wraps it with `String(value)`.
@@ -88,8 +86,7 @@ function toError(value) {
88
86
  function getErrorMessage(value) {
89
87
  return value instanceof Error ? value.message : String(value);
90
88
  }
91
- //#endregion
92
- //#region ../../internals/utils/src/runtime.ts
89
+ // ../../internals/utils/src/runtime.ts
93
90
  const isBun = typeof Bun !== "undefined";
94
91
  const isDeno = "Deno" in globalThis;
95
92
  /**
@@ -118,8 +115,7 @@ function detect() {
118
115
  version: process.versions?.node ?? ""
119
116
  };
120
117
  }
121
- //#endregion
122
- //#region ../../internals/utils/src/fs.ts
118
+ // ../../internals/utils/src/fs.ts
123
119
  /**
124
120
  * Reads the file at `path` as a UTF-8 string.
125
121
  * Uses `Bun.file().text()` when running under Bun, `fs.readFile` otherwise.
@@ -175,8 +171,7 @@ function isPathInside(path, parent) {
175
171
  const rel = relative(resolvedParent, resolvedPath);
176
172
  return rel !== "" && !rel.startsWith("..") && !isAbsolute(rel);
177
173
  }
178
- //#endregion
179
- //#region ../../internals/utils/src/promise.ts
174
+ // ../../internals/utils/src/promise.ts
180
175
  /**
181
176
  * Runs `run` over every item with at most `limit` in flight. Workers share one iterator, so each
182
177
  * takes the next item the moment it frees up instead of waiting for a batch to drain.
@@ -193,8 +188,7 @@ async function inParallel({ items, limit, run }) {
193
188
  };
194
189
  await Promise.all(Array.from({ length: Math.min(limit, items.length) }, () => worker()));
195
190
  }
196
- //#endregion
197
- //#region ../../internals/utils/src/time.ts
191
+ // ../../internals/utils/src/time.ts
198
192
  /**
199
193
  * Calculates elapsed time in milliseconds from a high-resolution `process.hrtime` start time.
200
194
  * Rounds to 2 decimal places for sub-millisecond precision without noise.
@@ -211,11 +205,9 @@ function getElapsedMs(hrStart) {
211
205
  const ms = seconds * 1e3 + nanoseconds / 1e6;
212
206
  return Math.round(ms * 100) / 100;
213
207
  }
214
- //#endregion
215
- //#region package.json
216
- var version = "5.14.6";
217
- //#endregion
218
- //#region ../../internals/shared/src/constants.ts
208
+ // package.json
209
+ var version = "5.15.1";
210
+ // ../../internals/shared/src/constants.ts
219
211
  /**
220
212
  * Extensions `kubb` ships at its own version, so they count as installed without being a direct
221
213
  * dependency. `constants.test.ts` checks it against the `kubb` package's dependencies.
@@ -226,8 +218,7 @@ const BUNDLED_PACKAGES = [
226
218
  "@kubb/parser-md",
227
219
  "@kubb/plugin-barrel"
228
220
  ];
229
- //#endregion
230
- //#region ../../internals/shared/src/configFile/ast.ts
221
+ // ../../internals/shared/src/configFile/ast.ts
231
222
  /** Node types the config editor reads from the yuku AST. */
232
223
  const nodeTypes = {
233
224
  arrayExpression: "ArrayExpression",
@@ -288,8 +279,7 @@ function parseExpression(source) {
288
279
  const [statement] = parsed.program.body;
289
280
  return parsed.program.body.length === 1 && statement?.type === nodeTypes.expressionStatement ? statement.expression : void 0;
290
281
  }
291
- //#endregion
292
- //#region ../../internals/shared/src/configFile/rules.ts
282
+ // ../../internals/shared/src/configFile/rules.ts
293
283
  /** `@kubb/plugin-ts` becomes `plugin-ts`, the `name` Kubb plugin factories use. */
294
284
  function toPluginName(packageName) {
295
285
  return packageName.split("/").pop() ?? packageName;
@@ -353,8 +343,7 @@ function isOutputValue({ key, value }) {
353
343
  function pickOutput(output) {
354
344
  return Object.fromEntries(Object.entries(output).filter(([key]) => isOutputKey(key)));
355
345
  }
356
- //#endregion
357
- //#region ../../internals/shared/src/configFile/text.ts
346
+ // ../../internals/shared/src/configFile/text.ts
358
347
  /**
359
348
  * A valid JavaScript identifier, so an import name can only ever print as `import { name } from`,
360
349
  * never as source that breaks out of the import statement.
@@ -426,8 +415,7 @@ function removeItem(source, node, index) {
426
415
  const next = items[index + 1];
427
416
  return next ? replaceText(source, start, next.start) : replaceText(source, items[index - 1].end, end);
428
417
  }
429
- //#endregion
430
- //#region ../../internals/shared/src/configFile/configFile.ts
418
+ // ../../internals/shared/src/configFile/configFile.ts
431
419
  /** The marker `disable-plugin` writes, with the block's line count so `enable-plugin` restores exactly those lines. */
432
420
  const DISABLED_MARKER_PATTERN = /^kubb:disabled (.+)\s+(\d+)$/;
433
421
  const OPERATIONS = new Set(Object.values(ConfigEditOperation));
@@ -1161,8 +1149,7 @@ async function editConfigFile({ filePath, edits, extensions }) {
1161
1149
  if (result.changed) await writeRaw(filePath, result.source);
1162
1150
  return result;
1163
1151
  }
1164
- //#endregion
1165
- //#region src/diff.ts
1152
+ // src/diff.ts
1166
1153
  const CONTEXT_LINES = 3;
1167
1154
  const DIFF_TIMEOUT_MS = 1e3;
1168
1155
  const splitLines = (text) => text === "" ? [] : text.split(/(?<=\n)/);
@@ -1314,8 +1301,7 @@ function pageHunks({ hunks, cursor, limit }) {
1314
1301
  nextCursor: cursor + used < total ? cursor + used : null
1315
1302
  };
1316
1303
  }
1317
- //#endregion
1318
- //#region src/generations.ts
1304
+ // src/generations.ts
1319
1305
  const READ_CONCURRENCY = 50;
1320
1306
  const MB = 1048576;
1321
1307
  const INDEX_KEY = "studio/generations.json";
@@ -1410,6 +1396,19 @@ async function listDisk({ root, outputPath, maxFiles }) {
1410
1396
  };
1411
1397
  }
1412
1398
  /**
1399
+ * The input as Studio stores and receives it. `JSON.stringify` writes a `Set` as `{}`, so the `meta` name sets become arrays.
1400
+ */
1401
+ function toInputJson(input) {
1402
+ return {
1403
+ ...input,
1404
+ meta: {
1405
+ ...input.meta,
1406
+ circularNames: [...input.meta.circularNames],
1407
+ enumNames: [...input.meta.enumNames]
1408
+ }
1409
+ };
1410
+ }
1411
+ /**
1413
1412
  * Keeps recent generations by job id in `storage`, with an index next to them so a store on disk
1414
1413
  * survives a restart. A generation is only ever looked up by its job id, so on a pooled sandbox one
1415
1414
  * tenant never reaches another's output. Initial disk output and generated jobs each get their
@@ -1516,10 +1515,10 @@ function createGenerationStore({ storage, maxCount, maxMb, ttlMs, now = Date.now
1516
1515
  if (!input) return 0;
1517
1516
  let json;
1518
1517
  try {
1519
- json = JSON.stringify(ast.transform(input, { schema: (node) => node.type === "ref" && node.schema ? {
1518
+ json = JSON.stringify(toInputJson(ast.transform(input, { schema: (node) => node.type === "ref" && node.schema ? {
1520
1519
  ...node,
1521
1520
  schema: void 0
1522
- } : void 0 }));
1521
+ } : void 0 })));
1523
1522
  } catch {
1524
1523
  return 0;
1525
1524
  }
@@ -1570,8 +1569,7 @@ function createGenerationStore({ storage, maxCount, maxMb, ttlMs, now = Date.now
1570
1569
  }
1571
1570
  };
1572
1571
  }
1573
- //#endregion
1574
- //#region src/generationEvents.ts
1572
+ // src/generationEvents.ts
1575
1573
  const MAX_QUEUED_EVENTS = 1024;
1576
1574
  const RESERVED_EVENTS = 64;
1577
1575
  const isDiscardable = (type) => type === "kubb:files:processing:update" || type === "kubb:info" || type === "kubb:success";
@@ -1753,8 +1751,7 @@ function createGenerationStream(hooks, jobId) {
1753
1751
  fail
1754
1752
  };
1755
1753
  }
1756
- //#endregion
1757
- //#region src/publicFetch.ts
1754
+ // src/publicFetch.ts
1758
1755
  const MAX_REDIRECTS = 5;
1759
1756
  const MAX_BYTES = 52428800;
1760
1757
  const REDIRECTS = /* @__PURE__ */ new Set([
@@ -1853,8 +1850,7 @@ async function withPublicFetch(run) {
1853
1850
  globalThis.fetch = original;
1854
1851
  }
1855
1852
  }
1856
- //#endregion
1857
- //#region src/resolveConfig.ts
1853
+ // src/resolveConfig.ts
1858
1854
  /**
1859
1855
  * Turns the JSON config Studio sends back into live Kubb objects.
1860
1856
  *
@@ -2178,8 +2174,7 @@ async function mergeParsers({ diskParsers, studioParsers, extensions = /* @__PUR
2178
2174
  extensions
2179
2175
  })));
2180
2176
  }
2181
- //#endregion
2182
- //#region src/url.ts
2177
+ // src/url.ts
2183
2178
  /**
2184
2179
  * Hosted Kubb Studio URL, used when a host passes none.
2185
2180
  */
@@ -2206,8 +2201,7 @@ function secureUrl({ studioUrl, path, socket = false }) {
2206
2201
  if (socket) url.protocol = url.protocol === "https:" ? "wss:" : "ws:";
2207
2202
  return url;
2208
2203
  }
2209
- //#endregion
2210
- //#region src/connect.ts
2204
+ // src/connect.ts
2211
2205
  const HEARTBEAT_INTERVAL_MS = 3e4;
2212
2206
  const MAX_HEARTBEAT_INTERVAL_MS = 6e4;
2213
2207
  const PING_TIMEOUT_MS = 1e4;
@@ -3187,8 +3181,7 @@ function connectAgent(options) {
3187
3181
  openRpc: openWebSocketRpc
3188
3182
  });
3189
3183
  }
3190
- //#endregion
3191
- //#region src/pair.ts
3184
+ // src/pair.ts
3192
3185
  /** Labels, not secrets: a person approving the code in the browser is what authorizes a pairing. */
3193
3186
  const CLIENT_IDS = {
3194
3187
  cli: "kubb-cli",
@@ -3337,8 +3330,7 @@ async function pairAgent({ onCode, onRetry, maxAttempts = 1, ...options }) {
3337
3330
  }
3338
3331
  }
3339
3332
  }
3340
- //#endregion
3341
- //#region src/snapshot.ts
3333
+ // src/snapshot.ts
3342
3334
  const UPLOAD_TIMEOUT_MS = 12e4;
3343
3335
  const BUNDLED_DEPENDENCIES = ["@kubb/plugin-barrel"];
3344
3336
  /**
@@ -3586,7 +3578,6 @@ async function createSnapshot({ studioUrl = defaultStudioUrl, apiKey, config, ho
3586
3578
  });
3587
3579
  return _data.snapshot;
3588
3580
  }
3589
- //#endregion
3590
3581
  export { IncompatibleAgentError, InvalidAgentTokenError, PairingCanceledError, PairingDeniedError, PairingExpiredError, connectAgent, createSnapshot, defaultStudioUrl, editConfig, editConfigFile, pairAgent };
3591
3582
 
3592
3583
  //# sourceMappingURL=index.js.map