@kubb/core 5.19.0 → 5.19.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
@@ -974,6 +974,7 @@ type Memo = <TKey extends MemoKey, TValue extends MemoValue<TKey>>(key: TKey, co
974
974
  type Options = {
975
975
  hooks: Hookable<KubbHooks>;
976
976
  signal?: AbortSignal;
977
+ fileRefs?: Array<string>;
977
978
  /**
978
979
  * Passed to `fileManager.write` so files the output passes already normalized are left alone.
979
980
  */
@@ -3301,9 +3302,13 @@ type Adapter<TOptions extends AdapterFactoryOptions = AdapterFactoryOptions> = {
3301
3302
  * every ref node pointing at a renamed schema, so `ast.ref.getName` and `resolver.imports`
3302
3303
  * resolve a `$ref` to the file that is actually generated. Refs that keep their pointer's
3303
3304
  * last segment need no stamp.
3305
+ *
3306
+ * With `fileRefs`, a `$ref` may only read local files inside those folders, for a host that does
3307
+ * not trust the spec. An empty list allows none. Unset, a `$ref` reads any file.
3304
3308
  */
3305
3309
  parse: (source: AdapterSource, options?: {
3306
3310
  signal?: AbortSignal;
3311
+ fileRefs?: Array<string>;
3307
3312
  }) => PossiblePromise<InputNode>;
3308
3313
  /**
3309
3314
  * Validate the document at the given path or URL.
@@ -3461,6 +3466,10 @@ type CreateKubbOptions = {
3461
3466
  * Stops the build at the next safe checkpoint.
3462
3467
  */
3463
3468
  signal?: AbortSignal;
3469
+ /**
3470
+ * The only folders a `$ref` in the input may read local files from. Unset, a `$ref` reads any file.
3471
+ */
3472
+ fileRefs?: Array<string>;
3464
3473
  };
3465
3474
  type ConfigGenerateResult = GenerateResult & {
3466
3475
  kubb: Kubb$1;
@@ -3691,7 +3700,7 @@ export declare function createResolver<T extends PluginType>(options: ResolverOp
3691
3700
  /**
3692
3701
  * Fetches one commit of a git repository into a temporary directory with a shallow `git fetch`,
3693
3702
  * so any host and the user's own git credentials work, and relative `$ref` files resolve.
3694
- * Resolves to the spec path on disk and a `dispose` that deletes the checkout.
3703
+ * Resolves to the spec path on disk, the checkout `dir`, and a `dispose` that deletes the checkout.
3695
3704
  *
3696
3705
  * With `publicOnly`, the repository must be an https URL on public addresses, the fetch connects to
3697
3706
  * the addresses checked, and it does not follow a redirect. `authorization` adds that header to this
@@ -3702,6 +3711,7 @@ export declare function checkoutGitInput(input: string, signal?: AbortSignal, {
3702
3711
  authorization?: string;
3703
3712
  }): Promise<{
3704
3713
  path: string;
3714
+ dir: string;
3705
3715
  dispose: () => Promise<void>;
3706
3716
  }>;
3707
3717
  /**
package/dist/index.d.ts CHANGED
@@ -974,6 +974,7 @@ type Memo = <TKey extends MemoKey, TValue extends MemoValue<TKey>>(key: TKey, co
974
974
  type Options = {
975
975
  hooks: Hookable<KubbHooks>;
976
976
  signal?: AbortSignal;
977
+ fileRefs?: Array<string>;
977
978
  /**
978
979
  * Passed to `fileManager.write` so files the output passes already normalized are left alone.
979
980
  */
@@ -3301,9 +3302,13 @@ type Adapter<TOptions extends AdapterFactoryOptions = AdapterFactoryOptions> = {
3301
3302
  * every ref node pointing at a renamed schema, so `ast.ref.getName` and `resolver.imports`
3302
3303
  * resolve a `$ref` to the file that is actually generated. Refs that keep their pointer's
3303
3304
  * last segment need no stamp.
3305
+ *
3306
+ * With `fileRefs`, a `$ref` may only read local files inside those folders, for a host that does
3307
+ * not trust the spec. An empty list allows none. Unset, a `$ref` reads any file.
3304
3308
  */
3305
3309
  parse: (source: AdapterSource, options?: {
3306
3310
  signal?: AbortSignal;
3311
+ fileRefs?: Array<string>;
3307
3312
  }) => PossiblePromise<InputNode>;
3308
3313
  /**
3309
3314
  * Validate the document at the given path or URL.
@@ -3461,6 +3466,10 @@ type CreateKubbOptions = {
3461
3466
  * Stops the build at the next safe checkpoint.
3462
3467
  */
3463
3468
  signal?: AbortSignal;
3469
+ /**
3470
+ * The only folders a `$ref` in the input may read local files from. Unset, a `$ref` reads any file.
3471
+ */
3472
+ fileRefs?: Array<string>;
3464
3473
  };
3465
3474
  type ConfigGenerateResult = GenerateResult & {
3466
3475
  kubb: Kubb$1;
@@ -3691,7 +3700,7 @@ export declare function createResolver<T extends PluginType>(options: ResolverOp
3691
3700
  /**
3692
3701
  * Fetches one commit of a git repository into a temporary directory with a shallow `git fetch`,
3693
3702
  * so any host and the user's own git credentials work, and relative `$ref` files resolve.
3694
- * Resolves to the spec path on disk and a `dispose` that deletes the checkout.
3703
+ * Resolves to the spec path on disk, the checkout `dir`, and a `dispose` that deletes the checkout.
3695
3704
  *
3696
3705
  * With `publicOnly`, the repository must be an https URL on public addresses, the fetch connects to
3697
3706
  * the addresses checked, and it does not follow a redirect. `authorization` adds that header to this
@@ -3702,6 +3711,7 @@ export declare function checkoutGitInput(input: string, signal?: AbortSignal, {
3702
3711
  authorization?: string;
3703
3712
  }): Promise<{
3704
3713
  path: string;
3714
+ dir: string;
3705
3715
  dispose: () => Promise<void>;
3706
3716
  }>;
3707
3717
  /**
package/dist/index.js CHANGED
@@ -21,7 +21,7 @@ var __name = (target, value) => __defProp(target, "name", {
21
21
  configurable: true
22
22
  });
23
23
  // package.json
24
- var version = "5.19.0";
24
+ var version = "5.19.1";
25
25
  // ../../internals/utils/src/promise.ts
26
26
  /**
27
27
  * Returns the value cached under `key` in `store`, computing and storing it on the first call.
@@ -1610,7 +1610,7 @@ function gitAuthEnv(env, { repo, authorization }) {
1610
1610
  /**
1611
1611
  * Fetches one commit of a git repository into a temporary directory with a shallow `git fetch`,
1612
1612
  * so any host and the user's own git credentials work, and relative `$ref` files resolve.
1613
- * Resolves to the spec path on disk and a `dispose` that deletes the checkout.
1613
+ * Resolves to the spec path on disk, the checkout `dir`, and a `dispose` that deletes the checkout.
1614
1614
  *
1615
1615
  * With `publicOnly`, the repository must be an https URL on public addresses, the fetch connects to
1616
1616
  * the addresses checked, and it does not follow a redirect. `authorization` adds that header to this
@@ -1685,6 +1685,7 @@ async function checkoutGitInput(input, signal, { publicOnly = false, authorizati
1685
1685
  }
1686
1686
  return {
1687
1687
  path: specPath,
1688
+ dir,
1688
1689
  dispose
1689
1690
  };
1690
1691
  }
@@ -2816,7 +2817,10 @@ var KubbDriver = class {
2816
2817
  this.inputNode = await this.adapter.parse(checkout ? {
2817
2818
  type: "path",
2818
2819
  path: checkout.path
2819
- } : source, { signal: this.options.signal });
2820
+ } : source, {
2821
+ signal: this.options.signal,
2822
+ fileRefs: checkout && this.options.fileRefs ? [...this.options.fileRefs, checkout.dir] : this.options.fileRefs
2823
+ });
2820
2824
  } catch (caughtError) {
2821
2825
  throw new Diagnostics.Error(Diagnostics.fromExtension(caughtError, {
2822
2826
  kind: "adapter",
@@ -3885,10 +3889,12 @@ var Kubb = class Kubb {
3885
3889
  #driver = null;
3886
3890
  #manifest = null;
3887
3891
  #signal;
3892
+ #fileRefs;
3888
3893
  constructor(userConfig, options = {}) {
3889
3894
  this.config = resolveConfig(userConfig);
3890
3895
  this.hooks = options.hooks ?? new Hookable();
3891
3896
  this.#signal = options.signal;
3897
+ this.#fileRefs = options.fileRefs;
3892
3898
  }
3893
3899
  /**
3894
3900
  * Generates every config of a `defineConfig([...])` array in order and yields each result as its config finishes, so
@@ -3952,7 +3958,8 @@ var Kubb = class Kubb {
3952
3958
  hooks: this.hooks,
3953
3959
  manifest,
3954
3960
  signal,
3955
- cleanPath
3961
+ cleanPath,
3962
+ fileRefs: this.#fileRefs
3956
3963
  });
3957
3964
  await driver.setup();
3958
3965
  this.#driver = driver;