@aventara/client 0.1.0-pilot.4 → 1.0.0-rc.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.
Files changed (65) hide show
  1. package/CHANGELOG.md +679 -0
  2. package/README.md +168 -132
  3. package/dist/cli/command.parser.d.ts +6 -4
  4. package/dist/cli/command.parser.js +22 -11
  5. package/dist/cli/generate.command.d.ts +6 -1
  6. package/dist/cli/generate.command.js +12 -1
  7. package/dist/cli/generation-failure.renderer.js +24 -24
  8. package/dist/cli/step.reporter.d.ts +31 -0
  9. package/dist/cli/step.reporter.js +87 -0
  10. package/dist/cli.js +2 -0
  11. package/dist/config/client-config.interface.d.ts +7 -7
  12. package/dist/config/config.loader.d.ts +4 -4
  13. package/dist/config/config.loader.js +7 -7
  14. package/dist/config/config.resolver.d.ts +7 -7
  15. package/dist/config/config.resolver.js +12 -12
  16. package/dist/config/env.cascade.d.ts +2 -2
  17. package/dist/config/env.cascade.js +4 -4
  18. package/dist/config/module-style.resolver.d.ts +1 -1
  19. package/dist/config/module-style.resolver.js +2 -2
  20. package/dist/config/tsconfig.locator.d.ts +1 -1
  21. package/dist/config/tsconfig.locator.js +2 -2
  22. package/dist/contract/contract.acceptance.d.ts +4 -4
  23. package/dist/contract/contract.acceptance.js +4 -4
  24. package/dist/contract/contract.fetcher.d.ts +3 -3
  25. package/dist/contract/contract.fetcher.js +6 -6
  26. package/dist/contract/contract.loader.d.ts +6 -6
  27. package/dist/contract/contract.loader.js +2 -2
  28. package/dist/emit/client-surface.emitter.d.ts +2 -2
  29. package/dist/emit/client-surface.emitter.js +77 -43
  30. package/dist/emit/client-tree.emitter.d.ts +3 -3
  31. package/dist/emit/client-tree.emitter.js +8 -5
  32. package/dist/emit/contract-carrier.emitter.d.ts +3 -3
  33. package/dist/emit/contract-carrier.emitter.js +1 -1
  34. package/dist/emit/derivation.emitter.js +1 -0
  35. package/dist/emit/descriptor.emitter.d.ts +2 -2
  36. package/dist/emit/descriptor.emitter.js +2 -2
  37. package/dist/emit/emitted-tree.interface.d.ts +1 -1
  38. package/dist/emit/enum.emitter.d.ts +2 -2
  39. package/dist/emit/field-check.emitter.d.ts +21 -0
  40. package/dist/emit/field-check.emitter.js +603 -0
  41. package/dist/emit/json-shape.emitter.d.ts +16 -0
  42. package/dist/emit/json-shape.emitter.js +88 -0
  43. package/dist/emit/name.deriver.d.ts +6 -6
  44. package/dist/emit/name.deriver.js +15 -15
  45. package/dist/emit/named-type.emitter.d.ts +2 -2
  46. package/dist/emit/runtime.emitter.d.ts +2 -2
  47. package/dist/emit/runtime.emitter.js +117 -112
  48. package/dist/emit/scalar.codec.d.ts +1 -1
  49. package/dist/emit/scalar.codec.js +78 -35
  50. package/dist/emit/transaction.emitter.js +131 -83
  51. package/dist/generate.d.ts +11 -3
  52. package/dist/generate.js +40 -26
  53. package/dist/index.d.ts +1 -1
  54. package/dist/init/client-init.errors.d.ts +4 -4
  55. package/dist/init/client-init.errors.js +4 -4
  56. package/dist/init/client-init.orchestrator.js +37 -22
  57. package/dist/init/client-init.questions.d.ts +5 -5
  58. package/dist/init/client-init.questions.js +10 -10
  59. package/dist/init/client-project.inspector.d.ts +2 -2
  60. package/dist/init/client-project.inspector.js +3 -3
  61. package/dist/init/command.runner.d.ts +2 -0
  62. package/dist/init/command.runner.js +4 -1
  63. package/dist/output/output.writer.d.ts +5 -5
  64. package/dist/output/output.writer.js +12 -12
  65. package/package.json +6 -5
@@ -1,14 +1,24 @@
1
1
  import { generateClient } from "../generate.js";
2
2
  import { FOREIGN_CONTENT_QUESTION, renderForeignContentCancellation, renderForeignContentWarning, renderGenerationSuccess, renderUpToDate, } from "./generation-success.renderer.js";
3
- export async function runGenerate(io, yes) {
3
+ import { createStepReporter, } from "./step.reporter.js";
4
+ export const GENERATION_STEPS = 4;
5
+ export async function runGenerate(io, yes, reporter) {
6
+ const progress = reporter ??
7
+ createStepReporter({
8
+ write: io.stderr,
9
+ mode: io.progress ?? "off",
10
+ total: GENERATION_STEPS,
11
+ });
4
12
  const outcome = await generateClient({
5
13
  directory: io.cwd,
6
14
  processEnv: io.env,
7
15
  overrideForeign: yes,
16
+ step: progress.step,
8
17
  });
9
18
  if (outcome.kind === "up-to-date") {
10
19
  const report = renderUpToDate(outcome);
11
20
  io.stderr(report.stderr);
21
+ progress.finish("avclient", "done");
12
22
  io.stdout(report.stdout);
13
23
  return 0;
14
24
  }
@@ -30,6 +40,7 @@ export async function runGenerate(io, yes) {
30
40
  }
31
41
  const report = renderGenerationSuccess(result);
32
42
  io.stderr(report.stderr);
43
+ progress.finish("avclient", "done");
33
44
  io.stdout(report.stdout);
34
45
  return 0;
35
46
  }
@@ -1,33 +1,33 @@
1
- import { ClientConfigError } from "../config/config.resolver.js";
2
- import { EnvFileError } from "../config/env.cascade.js";
3
- import { ContractProtocolError } from "../contract/contract.acceptance.js";
4
- import { ContractTransportError } from "../contract/contract.fetcher.js";
5
- import { GeneratedNameError } from "../emit/name.deriver.js";
6
- import { ClientInitNotConfirmedError, ClientInitStepError, } from "../init/client-init.errors.js";
7
- import { ClientInitAnswerError, ClientInitUnansweredError, } from "../init/client-init.questions.js";
8
- import { ClientProjectRefusedError } from "../init/client-project.inspector.js";
9
- import { OutputWriteError, warningsRaisedBeforeDefect, } from "../output/output.writer.js";
10
- import { CliCommandError } from "./command.parser.js";
1
+ import { AvClientConfigError } from "../config/config.resolver.js";
2
+ import { AvEnvFileError } from "../config/env.cascade.js";
3
+ import { AvContractProtocolError } from "../contract/contract.acceptance.js";
4
+ import { AvContractTransportError } from "../contract/contract.fetcher.js";
5
+ import { AvGeneratedNameError } from "../emit/name.deriver.js";
6
+ import { AvClientInitNotConfirmedError, AvClientInitStepError, } from "../init/client-init.errors.js";
7
+ import { AvClientInitAnswerError, AvClientInitUnansweredError, } from "../init/client-init.questions.js";
8
+ import { AvClientProjectRefusedError } from "../init/client-project.inspector.js";
9
+ import { AvOutputWriteError, warningsRaisedBeforeDefect, } from "../output/output.writer.js";
10
+ import { AvCliCommandError } from "./command.parser.js";
11
11
  import { renderWarningLines } from "./warning.renderer.js";
12
12
  const REFUSALS = [
13
- CliCommandError,
14
- ClientConfigError,
15
- EnvFileError,
16
- ContractTransportError,
17
- ContractProtocolError,
18
- GeneratedNameError,
19
- OutputWriteError,
20
- ClientInitAnswerError,
21
- ClientInitUnansweredError,
22
- ClientProjectRefusedError,
23
- ClientInitNotConfirmedError,
24
- ClientInitStepError,
13
+ AvCliCommandError,
14
+ AvClientConfigError,
15
+ AvEnvFileError,
16
+ AvContractTransportError,
17
+ AvContractProtocolError,
18
+ AvGeneratedNameError,
19
+ AvOutputWriteError,
20
+ AvClientInitAnswerError,
21
+ AvClientInitUnansweredError,
22
+ AvClientProjectRefusedError,
23
+ AvClientInitNotConfirmedError,
24
+ AvClientInitStepError,
25
25
  ];
26
26
  export function renderGenerationFailure(error) {
27
27
  if (REFUSALS.some((refusal) => error instanceof refusal)) {
28
- const carried = error instanceof OutputWriteError ? error.warnings : [];
28
+ const carried = error instanceof AvOutputWriteError ? error.warnings : [];
29
29
  return {
30
- exitCode: error instanceof ContractProtocolError ? error.exitCode : 1,
30
+ exitCode: error instanceof AvContractProtocolError ? error.exitCode : 1,
31
31
  text: `${renderWarningLines(carried)}avclient: ${error.message}\n`,
32
32
  };
33
33
  }
@@ -0,0 +1,31 @@
1
+ export type ProgressMode = "live" | "plain" | "off";
2
+ /** `live` only on a terminal that is not CI and accepts control sequences. */
3
+ export declare function progressModeOf(isTTY: boolean | undefined, env: Readonly<Record<string, string | undefined>>): Exclude<ProgressMode, "off">;
4
+ export type StepReporterOptions = {
5
+ /** Where the lines go: the tool's stderr, so its stdout stays its result. */
6
+ readonly write: (text: string) => void;
7
+ readonly mode: ProgressMode;
8
+ /** How many steps this run takes, for `[n/total]`. */
9
+ readonly total: number;
10
+ /** Each child's output streams between a step's start and end lines. */
11
+ readonly verbose?: boolean;
12
+ /** Milliseconds now; `Date.now` by default. */
13
+ readonly now?: () => number;
14
+ /** Redraw interval of the live line, in milliseconds. */
15
+ readonly interval?: number;
16
+ };
17
+ export type StepReporter = {
18
+ /**
19
+ * Runs one step under its numbered line. Its outcome — `done`, or `failed`
20
+ * when `body` throws — ends the line; the error is rethrown unchanged.
21
+ */
22
+ readonly step: <T>(title: string, body: () => Promise<T> | T) => Promise<T>;
23
+ /** Streams a child's output, in `verbose` mode only. */
24
+ readonly output: (chunk: string) => void;
25
+ /** The closing line: `<prefix>: <what> in <time>.` */
26
+ readonly finish: (prefix: string, what: string) => void;
27
+ readonly verbose: boolean;
28
+ };
29
+ /** `12.4s`, or `1m 02s` from a minute. */
30
+ export declare function formatElapsed(milliseconds: number): string;
31
+ export declare function createStepReporter(options: StepReporterOptions): StepReporter;
@@ -0,0 +1,87 @@
1
+ export function progressModeOf(isTTY, env) {
2
+ const ci = env.CI;
3
+ if (isTTY !== true ||
4
+ (ci !== undefined && ci !== "" && ci !== "0" && ci !== "false") ||
5
+ (env.NO_COLOR !== undefined && env.NO_COLOR !== "") ||
6
+ env.TERM === "dumb") {
7
+ return "plain";
8
+ }
9
+ return "live";
10
+ }
11
+ const SPINNER = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
12
+ const CLEAR_LINE = "\r\u001b[2K";
13
+ const GREEN = (text) => `\u001b[32m${text}\u001b[39m`;
14
+ const RED = (text) => `\u001b[31m${text}\u001b[39m`;
15
+ const DIM = (text) => `\u001b[2m${text}\u001b[22m`;
16
+ export function formatElapsed(milliseconds) {
17
+ const seconds = milliseconds / 1000;
18
+ if (seconds < 60) {
19
+ return `${seconds.toFixed(1)}s`;
20
+ }
21
+ const whole = Math.round(seconds);
22
+ return `${Math.floor(whole / 60)}m ${String(whole % 60).padStart(2, "0")}s`;
23
+ }
24
+ export function createStepReporter(options) {
25
+ const now = options.now ?? Date.now;
26
+ const started = now();
27
+ const verbose = options.verbose === true && options.mode !== "off";
28
+ const mode = verbose ? "plain" : options.mode;
29
+ let index = 0;
30
+ const step = async (title, body) => {
31
+ index += 1;
32
+ const label = `[${index}/${options.total}] ${title}`;
33
+ const at = now();
34
+ const elapsed = () => formatElapsed(now() - at);
35
+ if (mode === "off") {
36
+ return await body();
37
+ }
38
+ if (mode === "plain") {
39
+ options.write(verbose ? `${label}…\n` : `${label}… `);
40
+ try {
41
+ const value = await body();
42
+ options.write(verbose ? `${label}… done (${elapsed()})\n` : `done (${elapsed()})\n`);
43
+ return value;
44
+ }
45
+ catch (error) {
46
+ options.write(verbose
47
+ ? `${label}… failed (${elapsed()})\n`
48
+ : `failed (${elapsed()})\n`);
49
+ throw error;
50
+ }
51
+ }
52
+ let frame = 0;
53
+ const draw = () => {
54
+ const seconds = Math.floor((now() - at) / 1000);
55
+ options.write(`${CLEAR_LINE}${SPINNER[frame % SPINNER.length]} ${label}…${seconds > 0 ? DIM(` ${seconds}s`) : ""}`);
56
+ frame += 1;
57
+ };
58
+ draw();
59
+ const timer = setInterval(draw, options.interval ?? 80);
60
+ timer.unref?.();
61
+ try {
62
+ const value = await body();
63
+ clearInterval(timer);
64
+ options.write(`${CLEAR_LINE}${GREEN("✓")} ${label} ${DIM(elapsed())}\n`);
65
+ return value;
66
+ }
67
+ catch (error) {
68
+ clearInterval(timer);
69
+ options.write(`${CLEAR_LINE}${RED("✗")} ${label} ${DIM(elapsed())}\n`);
70
+ throw error;
71
+ }
72
+ };
73
+ return {
74
+ step,
75
+ output: (chunk) => {
76
+ if (verbose) {
77
+ options.write(chunk);
78
+ }
79
+ },
80
+ finish: (prefix, what) => {
81
+ if (mode !== "off") {
82
+ options.write(`${prefix}: ${what} in ${formatElapsed(now() - started)}.\n`);
83
+ }
84
+ },
85
+ verbose,
86
+ };
87
+ }
package/dist/cli.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { GENERATE_USAGE, INIT_USAGE, parseCliCommand, USAGE, } from "./cli/command.parser.js";
2
2
  import { runGenerate } from "./cli/generate.command.js";
3
3
  import { renderGenerationFailure } from "./cli/generation-failure.renderer.js";
4
+ import { progressModeOf } from "./cli/step.reporter.js";
4
5
  import { createTerminalPrompter } from "./cli/terminal.prompter.js";
5
6
  import { AVENTARA_CLIENT_GENERATOR_VERSION } from "./index.js";
6
7
  import { runClientInit } from "./init/client-init.orchestrator.js";
@@ -47,6 +48,7 @@ export async function runFromProcess() {
47
48
  confirm: terminal.confirm,
48
49
  ask: terminal.ask,
49
50
  run: runCommand,
51
+ progress: progressModeOf(process.stderr.isTTY, process.env),
50
52
  });
51
53
  }
52
54
  finally {
@@ -1,29 +1,29 @@
1
1
  /** A deferred read of one environment variable from the resolved cascade. */
2
- export interface EnvReference {
2
+ export interface AvEnvReference {
3
3
  /** Always `"env"`. */
4
4
  readonly kind: "env";
5
5
  /** The environment variable's name. */
6
6
  readonly name: string;
7
7
  }
8
8
  /** A value written literally, or read from the resolved environment. */
9
- export type ConfigValue = string | EnvReference;
9
+ export type AvClientConfigValue = string | AvEnvReference;
10
10
  /**
11
11
  * What a `framework.client.ts` default-exports through `defineClientConfig`.
12
- * Plain data: an environment variable appears as an `EnvReference` (`env("NAME")`),
12
+ * Plain data: an environment variable appears as an `AvEnvReference` (`env("NAME")`),
13
13
  * a name to look up, so the file can be evaluated before the environment is loaded.
14
14
  */
15
- export interface ClientConfigInput {
15
+ export interface AvClientConfigInput {
16
16
  /** The full deployed framework entrypoint: origin plus mount path. */
17
- readonly entrypoint: ConfigValue;
17
+ readonly entrypoint: AvClientConfigValue;
18
18
  /**
19
19
  * The directory the client is generated into, relative to the config file's
20
20
  * directory. It is shared: the generator writes only `AvClient.ts` and
21
21
  * `generated/` in it, and never touches anything else there.
22
22
  */
23
- readonly generateAt: ConfigValue;
23
+ readonly generateAt: AvClientConfigValue;
24
24
  /**
25
25
  * The `tsconfig.json` the generated client is written for, relative to the
26
- * config file's directory — only for a layout the discovery gets wrong (a
26
+ * config file's directory. Set it only for a layout the discovery gets wrong (a
27
27
  * monorepo, a non-standard name). Absent, the nearest `tsconfig.json` above
28
28
  * `generateAt` is used.
29
29
  */
@@ -1,4 +1,4 @@
1
- import type { ClientConfigInput } from "./client-config.interface.js";
1
+ import type { AvClientConfigInput } from "./client-config.interface.js";
2
2
  /** Prisma's `SUPPORTED_EXTENSIONS`, in its order. */
3
3
  export declare const CLIENT_CONFIG_FILE_EXTENSIONS: readonly [".js", ".ts", ".mjs", ".cjs", ".mts", ".cts"];
4
4
  /** The config's name, before its extension. */
@@ -8,7 +8,7 @@ export declare const CLIENT_CONFIG_FILE = "framework.client.ts";
8
8
  export interface LoadedClientConfig {
9
9
  /** The config file's absolute path; `generateAt` resolves against its directory. */
10
10
  readonly file: string;
11
- readonly config: ClientConfigInput;
11
+ readonly config: AvClientConfigInput;
12
12
  }
13
13
  /**
14
14
  * The config files present in `directory`, by name, in
@@ -20,13 +20,13 @@ export declare function clientConfigFilesIn(directory: string): readonly string[
20
20
  * The one config file in `directory`, by name, or `undefined` when there is
21
21
  * none.
22
22
  *
23
- * @throws ClientConfigError when there is more than one, naming each.
23
+ * @throws AvClientConfigError when there is more than one, naming each.
24
24
  */
25
25
  export declare function findClientConfigFile(directory: string): string | undefined;
26
26
  /**
27
27
  * Evaluates the one `framework.client.<ext>` in `directory`.
28
28
  *
29
- * @throws ClientConfigError, in one line, when there is none or more than one,
29
+ * @throws AvClientConfigError, in one line, when there is none or more than one,
30
30
  * or the file does not evaluate, or does not default-export a client config.
31
31
  */
32
32
  export declare function loadClientConfigFile(directory: string): Promise<LoadedClientConfig>;
@@ -1,6 +1,6 @@
1
1
  import { statSync } from "node:fs";
2
2
  import path from "node:path";
3
- import { ClientConfigError } from "./config.resolver.js";
3
+ import { AvClientConfigError } from "./config.resolver.js";
4
4
  export const CLIENT_CONFIG_FILE_EXTENSIONS = [
5
5
  ".js",
6
6
  ".ts",
@@ -20,14 +20,14 @@ export function findClientConfigFile(directory) {
20
20
  const present = clientConfigFilesIn(directory);
21
21
  if (present.length > 1) {
22
22
  const named = `${present.slice(0, -1).join(", ")} and ${present.at(-1)}`;
23
- throw new ClientConfigError(`${named} are ${present.length === 2 ? "both" : "all"} in ${path.resolve(directory)}, and only one may configure the generator; keep one and delete the other${present.length > 2 ? "s" : ""}.`);
23
+ throw new AvClientConfigError(`${named} are ${present.length === 2 ? "both" : "all"} in ${path.resolve(directory)}, and only one may configure the generator; keep one and delete the other${present.length > 2 ? "s" : ""}.`);
24
24
  }
25
25
  return present[0];
26
26
  }
27
27
  export async function loadClientConfigFile(directory) {
28
28
  const name = findClientConfigFile(directory);
29
29
  if (name === undefined) {
30
- throw new ClientConfigError(`no ${CLIENT_CONFIG_BASENAME}.{${CLIENT_CONFIG_FILE_EXTENSIONS.map((extension) => extension.slice(1)).join(",")}} in ${path.resolve(directory)}; create ${CLIENT_CONFIG_FILE} with ` +
30
+ throw new AvClientConfigError(`no ${CLIENT_CONFIG_BASENAME}.{${CLIENT_CONFIG_FILE_EXTENSIONS.map((extension) => extension.slice(1)).join(",")}} in ${path.resolve(directory)}; create ${CLIENT_CONFIG_FILE} with ` +
31
31
  "`export default defineClientConfig({ entrypoint, generateAt })` (or run `avclient init`) and run the generator from its directory.");
32
32
  }
33
33
  const file = path.resolve(directory, name);
@@ -52,19 +52,19 @@ export async function loadClientConfigFile(directory) {
52
52
  evaluated = loaded.layers?.find((layer) => layer.configFile === file)?.config;
53
53
  }
54
54
  catch (error) {
55
- throw new ClientConfigError(`${file} could not be evaluated: ${firstLineOf(error)}`, { cause: error });
55
+ throw new AvClientConfigError(`${file} could not be evaluated: ${firstLineOf(error)}`, { cause: error });
56
56
  }
57
57
  return { file, config: clientConfigOf(file, evaluated) };
58
58
  }
59
59
  function clientConfigOf(file, config) {
60
60
  const shape = "`export default defineClientConfig({ entrypoint, generateAt })`";
61
61
  if (typeof config !== "object" || config === null || Array.isArray(config)) {
62
- throw new ClientConfigError(`${file}'s default export is not an object; it must be ${shape}.`);
62
+ throw new AvClientConfigError(`${file}'s default export is not an object; it must be ${shape}.`);
63
63
  }
64
64
  const members = config;
65
65
  const tsconfigFile = members.tsconfigFile;
66
66
  if (tsconfigFile !== undefined && typeof tsconfigFile !== "string") {
67
- throw new ClientConfigError(`${file}'s tsconfigFile must be a string, a path relative to ${path.dirname(file)}.`);
67
+ throw new AvClientConfigError(`${file}'s tsconfigFile must be a string, a path relative to ${path.dirname(file)}.`);
68
68
  }
69
69
  return {
70
70
  entrypoint: configValueOf(file, "entrypoint", members.entrypoint),
@@ -84,7 +84,7 @@ function configValueOf(file, member, value) {
84
84
  return { kind: "env", name };
85
85
  }
86
86
  }
87
- throw new ClientConfigError(`${file}'s ${member} must be a string or env("NAME"), and it is ${value === undefined ? "missing" : "neither"}.`);
87
+ throw new AvClientConfigError(`${file}'s ${member} must be a string or env("NAME"), and it is ${value === undefined ? "missing" : "neither"}.`);
88
88
  }
89
89
  function firstLineOf(error) {
90
90
  const message = error instanceof Error ? error.message : String(error);
@@ -1,18 +1,18 @@
1
- import type { ClientConfigInput, ClientEntrypoint, EnvReference, ResolvedClientConfig } from "./client-config.interface.js";
1
+ import type { AvClientConfigInput, AvEnvReference, ClientEntrypoint, ResolvedClientConfig } from "./client-config.interface.js";
2
2
  import type { EnvCascadeResolution } from "./env.cascade.js";
3
3
  /** Gives a `framework.client.ts` its type: returns `config` unchanged. */
4
- export declare function defineClientConfig(config: ClientConfigInput): ClientConfigInput;
4
+ export declare function defineClientConfig(config: AvClientConfigInput): AvClientConfigInput;
5
5
  /** Names an environment variable to be read from the resolved environment. */
6
- export declare function env(name: string): EnvReference;
6
+ export declare function env(name: string): AvEnvReference;
7
7
  /**
8
8
  * The configuration cannot be resolved. The message is the whole diagnosis — the
9
9
  * CLI prints it and exits non-zero; no stack is owed for a user's mistake.
10
10
  */
11
- export declare class ClientConfigError extends Error {
12
- readonly name = "ClientConfigError";
11
+ export declare class AvClientConfigError extends Error {
12
+ readonly name = "AvClientConfigError";
13
13
  }
14
14
  export interface ClientConfigResolutionInput {
15
- readonly config: ClientConfigInput;
15
+ readonly config: AvClientConfigInput;
16
16
  readonly cascade: EnvCascadeResolution;
17
17
  /** The directory holding the config file; `generateAt` resolves against it. */
18
18
  readonly configDirectory: string;
@@ -23,7 +23,7 @@ export interface ClientConfigResolutionInput {
23
23
  */
24
24
  export declare function resolveClientConfig(input: ClientConfigResolutionInput): ResolvedClientConfig;
25
25
  /**
26
- * @throws ClientConfigError in one sentence that does not echo the value.
26
+ * @throws AvClientConfigError in one sentence that does not echo the value.
27
27
  */
28
28
  export declare function resolveEntrypoint(value: string): ClientEntrypoint;
29
29
  export declare function entrypointHref(entrypoint: ClientEntrypoint): string;
@@ -6,15 +6,15 @@ export function defineClientConfig(config) {
6
6
  export function env(name) {
7
7
  return { kind: "env", name };
8
8
  }
9
- export class ClientConfigError extends Error {
10
- name = "ClientConfigError";
9
+ export class AvClientConfigError extends Error {
10
+ name = "AvClientConfigError";
11
11
  }
12
12
  export function resolveClientConfig(input) {
13
13
  const entrypoint = resolveValue("entrypoint", input.config.entrypoint, input.cascade);
14
14
  const generateAt = resolveValue("generateAt", input.config.generateAt, input.cascade);
15
15
  const tsconfigFile = input.config.tsconfigFile;
16
16
  if (tsconfigFile === "") {
17
- throw new ClientConfigError("tsconfigFile is empty.");
17
+ throw new AvClientConfigError("tsconfigFile is empty.");
18
18
  }
19
19
  return {
20
20
  entrypoint: resolveEntrypoint(entrypoint),
@@ -30,12 +30,12 @@ export function resolveClientConfig(input) {
30
30
  function resolveValue(field, value, cascade) {
31
31
  if (typeof value === "string") {
32
32
  if (value === "")
33
- throw new ClientConfigError(`${field} is empty.`);
33
+ throw new AvClientConfigError(`${field} is empty.`);
34
34
  return value;
35
35
  }
36
36
  const resolved = cascade.env[value.name];
37
37
  if (resolved === undefined || resolved === "") {
38
- throw new ClientConfigError(`${field} reads ${value.name}, which is not set in the process environment ` +
38
+ throw new AvClientConfigError(`${field} reads ${value.name}, which is not set in the process environment ` +
39
39
  `or in any of ${cascade.candidates.join(", ")} (mode "${cascade.mode}").`);
40
40
  }
41
41
  return resolved;
@@ -43,32 +43,32 @@ function resolveValue(field, value, cascade) {
43
43
  const ENTRYPOINT_IS = "it must be the origin plus a mount path";
44
44
  export function resolveEntrypoint(value) {
45
45
  if (/\s/u.test(value)) {
46
- throw new ClientConfigError(`entrypoint contains whitespace; ${ENTRYPOINT_IS}, written without spaces, tabs or line breaks.`);
46
+ throw new AvClientConfigError(`entrypoint contains whitespace; ${ENTRYPOINT_IS}, written without spaces, tabs or line breaks.`);
47
47
  }
48
48
  let url;
49
49
  try {
50
50
  url = new URL(value);
51
51
  }
52
52
  catch {
53
- throw new ClientConfigError("entrypoint is not an absolute URL; it must be the deployed origin plus mount path.");
53
+ throw new AvClientConfigError("entrypoint is not an absolute URL; it must be the deployed origin plus mount path.");
54
54
  }
55
55
  if (url.protocol !== "http:" && url.protocol !== "https:") {
56
- throw new ClientConfigError(`entrypoint must use http: or https:, not ${url.protocol}`);
56
+ throw new AvClientConfigError(`entrypoint must use http: or https:, not ${url.protocol}`);
57
57
  }
58
58
  if (url.username !== "" || url.password !== "") {
59
- throw new ClientConfigError("entrypoint must not carry credentials: the platform's fetch refuses a URL that " +
59
+ throw new AvClientConfigError("entrypoint must not carry credentials: the platform's fetch refuses a URL that " +
60
60
  "includes them, and the entrypoint is embedded in the generated client, which ships — " +
61
61
  "authenticate through a custom fetch instead.");
62
62
  }
63
63
  if (value.includes("?") || value.includes("#")) {
64
- throw new ClientConfigError("entrypoint must not carry a query or fragment; it is the origin plus mount path only.");
64
+ throw new AvClientConfigError("entrypoint must not carry a query or fragment; it is the origin plus mount path only.");
65
65
  }
66
66
  if (value.split(/[/\\]/u).some(isDotDotSegment)) {
67
- throw new ClientConfigError(`entrypoint's mount path has a .. segment; ${ENTRYPOINT_IS}, with no dot segments.`);
67
+ throw new AvClientConfigError(`entrypoint's mount path has a .. segment; ${ENTRYPOINT_IS}, with no dot segments.`);
68
68
  }
69
69
  const normalized = AvProtocol.normalizeEntrypoint(writtenMountPath(value));
70
70
  if (!normalized.ok) {
71
- throw new ClientConfigError(`entrypoint's mount path ${normalized.message}.`);
71
+ throw new AvClientConfigError(`entrypoint's mount path ${normalized.message}.`);
72
72
  }
73
73
  const deployment = new URL(url.href);
74
74
  deployment.pathname = "/";
@@ -23,10 +23,10 @@ export interface EnvCascadeResolution {
23
23
  readonly loaded: readonly string[];
24
24
  }
25
25
  /** A candidate exists but could not be read, or contains a discarded line. */
26
- export declare class EnvFileError extends Error {
26
+ export declare class AvEnvFileError extends Error {
27
27
  readonly filePath: string;
28
28
  readonly reason: "unreadable" | "malformed";
29
- readonly name = "EnvFileError";
29
+ readonly name = "AvEnvFileError";
30
30
  constructor(filePath: string, reason: "unreadable" | "malformed", detail: string);
31
31
  }
32
32
  /** The four file candidates for a mode, highest precedence first. */
@@ -2,10 +2,10 @@ import { readFileSync } from "node:fs";
2
2
  import path from "node:path";
3
3
  import { parseEnv } from "node:util";
4
4
  export const DEFAULT_ENV_MODE = "development";
5
- export class EnvFileError extends Error {
5
+ export class AvEnvFileError extends Error {
6
6
  filePath;
7
7
  reason;
8
- name = "EnvFileError";
8
+ name = "AvEnvFileError";
9
9
  constructor(filePath, reason, detail) {
10
10
  super(`${filePath}: ${detail}`);
11
11
  this.filePath = filePath;
@@ -52,14 +52,14 @@ export function readEnvFileFromDisk(filePath) {
52
52
  if (isErrnoException(error) && error.code === "ENOENT")
53
53
  return undefined;
54
54
  const code = isErrnoException(error) ? error.code : undefined;
55
- throw new EnvFileError(filePath, "unreadable", `exists but cannot be read (${code ?? "unknown error"})`);
55
+ throw new AvEnvFileError(filePath, "unreadable", `exists but cannot be read (${code ?? "unknown error"})`);
56
56
  }
57
57
  }
58
58
  export function parseEnvFile(filePath, content) {
59
59
  const source = content.startsWith("") ? content.slice(1) : content;
60
60
  const discarded = firstDiscardedLine(source);
61
61
  if (discarded !== undefined) {
62
- throw new EnvFileError(filePath, "malformed", `line ${discarded} is not a NAME=value assignment and would be ignored`);
62
+ throw new AvEnvFileError(filePath, "malformed", `line ${discarded} is not a NAME=value assignment and would be ignored`);
63
63
  }
64
64
  return parseEnv(source);
65
65
  }
@@ -17,7 +17,7 @@ export interface ModuleStyleInput {
17
17
  /**
18
18
  * The style the project's tsconfig asks for.
19
19
  *
20
- * @throws ClientConfigError when there is no tsconfig to follow, or the named
20
+ * @throws AvClientConfigError when there is no tsconfig to follow, or the named
21
21
  * `tsconfigFile` cannot be read.
22
22
  */
23
23
  export declare function resolveModuleStyle(input: ModuleStyleInput): ResolvedModuleStyle;
@@ -1,11 +1,11 @@
1
1
  import { readFileSync, statSync } from "node:fs";
2
2
  import path from "node:path";
3
- import { ClientConfigError } from "./config.resolver.js";
3
+ import { AvClientConfigError } from "./config.resolver.js";
4
4
  import { locateTsconfig } from "./tsconfig.locator.js";
5
5
  export function resolveModuleStyle(input) {
6
6
  const located = locateTsconfig(input);
7
7
  if (located === undefined) {
8
- throw new ClientConfigError(noTsconfigRefusal(input.generateAt));
8
+ throw new AvClientConfigError(noTsconfigRefusal(input.generateAt));
9
9
  }
10
10
  return {
11
11
  tsconfig: located.path,
@@ -16,6 +16,6 @@ export interface TsconfigLocation {
16
16
  * The tsconfig `location` names, or `undefined` when no `tsconfig.json` is in
17
17
  * `generateAt` or any directory above it (and none was named).
18
18
  *
19
- * @throws ClientConfigError when the named `tsconfigFile` is missing or unreadable.
19
+ * @throws AvClientConfigError when the named `tsconfigFile` is missing or unreadable.
20
20
  */
21
21
  export declare function locateTsconfig(location: TsconfigLocation): LocatedTsconfig | undefined;
@@ -1,7 +1,7 @@
1
1
  import { readFileSync } from "node:fs";
2
2
  import path from "node:path";
3
3
  import { createFilesMatcher, getTsconfig, parseTsconfig, } from "get-tsconfig";
4
- import { ClientConfigError } from "./config.resolver.js";
4
+ import { AvClientConfigError } from "./config.resolver.js";
5
5
  export function locateTsconfig(location) {
6
6
  if (location.tsconfigFile !== undefined) {
7
7
  return namedTsconfig(location.tsconfigFile);
@@ -34,7 +34,7 @@ function namedTsconfig(file) {
34
34
  : error instanceof Error
35
35
  ? error.message
36
36
  : String(error);
37
- throw new ClientConfigError(`tsconfigFile names ${file}, which could not be read (${reason}); it must name the tsconfig.json your project compiles the generated client with.`);
37
+ throw new AvClientConfigError(`tsconfigFile names ${file}, which could not be read (${reason}); it must name the tsconfig.json your project compiles the generated client with.`);
38
38
  }
39
39
  }
40
40
  function referencedTsconfig(from, reference) {
@@ -1,9 +1,9 @@
1
- import { type ClientContract } from "@aventara/core";
1
+ import type { AvContractClient } from "@aventara/core";
2
2
  export declare const SUPPORTED_PROTOCOL_VERSIONS: ReadonlySet<number>;
3
3
  export type ContractRejectionReason = "protocol-unsupported" | "hash-mismatch" | "structure-invalid";
4
4
  export type ContractAccepted = {
5
5
  readonly accepted: true;
6
- readonly contract: ClientContract;
6
+ readonly contract: AvContractClient;
7
7
  };
8
8
  export type ContractRejected = {
9
9
  readonly accepted: false;
@@ -16,8 +16,8 @@ export type ContractRejected = {
16
16
  export type ContractAcceptance = ContractAccepted | ContractRejected;
17
17
  export declare function acceptClientContract(body: unknown): Promise<ContractAcceptance>;
18
18
  /** The refusal that stops generation, carrying the rejection's reason and sentence. */
19
- export declare class ContractProtocolError extends Error {
20
- readonly name = "ContractProtocolError";
19
+ export declare class AvContractProtocolError extends Error {
20
+ readonly name = "AvContractProtocolError";
21
21
  readonly reason: ContractRejectionReason;
22
22
  readonly exitCode: number;
23
23
  constructor(rejection: ContractRejected, contractUrl: string);
@@ -1,4 +1,4 @@
1
- import { AVENTARA_PROTOCOL_VERSION, CanonicalJsonError, computeClientContractHash, validateClientContractStructure, } from "@aventara/core";
1
+ import { AVENTARA_PROTOCOL_VERSION, AvCanonicalJsonError, computeClientContractHash, validateClientContractStructure, } from "@aventara/core/internal";
2
2
  export const SUPPORTED_PROTOCOL_VERSIONS = new Set([
3
3
  AVENTARA_PROTOCOL_VERSION,
4
4
  ]);
@@ -22,7 +22,7 @@ export async function acceptClientContract(body) {
22
22
  recomputed = await computeClientContractHash(contract);
23
23
  }
24
24
  catch (error) {
25
- if (!(error instanceof CanonicalJsonError)) {
25
+ if (!(error instanceof AvCanonicalJsonError)) {
26
26
  throw error;
27
27
  }
28
28
  return reject("hash-mismatch", `it holds a value canonical JSON cannot represent (${error.message}), so its ` +
@@ -36,8 +36,8 @@ export async function acceptClientContract(body) {
36
36
  }
37
37
  return { accepted: true, contract };
38
38
  }
39
- export class ContractProtocolError extends Error {
40
- name = "ContractProtocolError";
39
+ export class AvContractProtocolError extends Error {
40
+ name = "AvContractProtocolError";
41
41
  reason;
42
42
  exitCode;
43
43
  constructor(rejection, contractUrl) {
@@ -16,15 +16,15 @@ export type ContractTransportFailureReason =
16
16
  | "body-unreadable"
17
17
  /** A body that is not JSON — an HTML page, an empty body, a truncation. */
18
18
  | "body-not-json";
19
- export declare class ContractTransportError extends Error {
19
+ export declare class AvContractTransportError extends Error {
20
20
  readonly reason: ContractTransportFailureReason;
21
- readonly name = "ContractTransportError";
21
+ readonly name = "AvContractTransportError";
22
22
  constructor(reason: ContractTransportFailureReason, message: string, options?: ErrorOptions);
23
23
  }
24
24
  export declare function contractUrlOf(entrypoint: ClientEntrypoint): URL;
25
25
  /** The URL as it may be printed: credentials in the entrypoint never are. */
26
26
  export declare function displayUrl(url: URL): string;
27
27
  /**
28
- * @throws ContractTransportError when no JSON value arrives.
28
+ * @throws AvContractTransportError when no JSON value arrives.
29
29
  */
30
30
  export declare function fetchClientContractBody(entrypoint: ClientEntrypoint, fetch?: ContractFetch, ifNoneMatch?: string): Promise<unknown>;