@aventara/client 1.0.0-rc.0 → 1.0.0-rc.2

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 (58) hide show
  1. package/CHANGELOG.md +504 -0
  2. package/README.md +159 -141
  3. package/dist/cli/command.parser.d.ts +5 -5
  4. package/dist/cli/command.parser.js +13 -13
  5. package/dist/cli/generation-failure.renderer.js +24 -24
  6. package/dist/config/client-config.interface.d.ts +7 -7
  7. package/dist/config/config.loader.d.ts +10 -4
  8. package/dist/config/config.loader.js +16 -7
  9. package/dist/config/config.resolver.d.ts +7 -7
  10. package/dist/config/config.resolver.js +12 -12
  11. package/dist/config/env.cascade.d.ts +2 -2
  12. package/dist/config/env.cascade.js +4 -4
  13. package/dist/config/module-style.resolver.d.ts +1 -1
  14. package/dist/config/module-style.resolver.js +2 -2
  15. package/dist/config/tsconfig.locator.d.ts +1 -1
  16. package/dist/config/tsconfig.locator.js +2 -2
  17. package/dist/contract/contract.acceptance.d.ts +4 -4
  18. package/dist/contract/contract.acceptance.js +4 -4
  19. package/dist/contract/contract.fetcher.d.ts +3 -3
  20. package/dist/contract/contract.fetcher.js +6 -6
  21. package/dist/contract/contract.loader.d.ts +6 -6
  22. package/dist/contract/contract.loader.js +2 -2
  23. package/dist/emit/client-surface.emitter.d.ts +2 -2
  24. package/dist/emit/client-surface.emitter.js +61 -40
  25. package/dist/emit/client-tree.emitter.d.ts +3 -3
  26. package/dist/emit/client-tree.emitter.js +8 -5
  27. package/dist/emit/contract-carrier.emitter.d.ts +3 -3
  28. package/dist/emit/derivation.emitter.js +1 -0
  29. package/dist/emit/descriptor.emitter.d.ts +2 -2
  30. package/dist/emit/descriptor.emitter.js +1 -1
  31. package/dist/emit/emitted-tree.interface.d.ts +1 -1
  32. package/dist/emit/enum.emitter.d.ts +2 -2
  33. package/dist/emit/field-check.emitter.d.ts +21 -0
  34. package/dist/emit/field-check.emitter.js +592 -0
  35. package/dist/emit/json-shape.emitter.d.ts +2 -2
  36. package/dist/emit/name.deriver.d.ts +6 -6
  37. package/dist/emit/name.deriver.js +14 -14
  38. package/dist/emit/named-type.emitter.d.ts +2 -2
  39. package/dist/emit/runtime.emitter.d.ts +2 -2
  40. package/dist/emit/runtime.emitter.js +166 -112
  41. package/dist/emit/scalar.codec.d.ts +1 -1
  42. package/dist/emit/scalar.codec.js +246 -29
  43. package/dist/emit/transaction.emitter.js +30 -14
  44. package/dist/generate.d.ts +2 -2
  45. package/dist/generate.js +2 -2
  46. package/dist/index.d.ts +1 -1
  47. package/dist/init/client-init.errors.d.ts +4 -4
  48. package/dist/init/client-init.errors.js +4 -4
  49. package/dist/init/client-init.orchestrator.js +7 -7
  50. package/dist/init/client-init.questions.d.ts +5 -5
  51. package/dist/init/client-init.questions.js +10 -10
  52. package/dist/init/client-project.inspector.d.ts +2 -2
  53. package/dist/init/client-project.inspector.js +3 -3
  54. package/dist/output/output.validator.d.ts +3 -4
  55. package/dist/output/output.validator.js +2 -2
  56. package/dist/output/output.writer.d.ts +5 -5
  57. package/dist/output/output.writer.js +12 -12
  58. package/package.json +4 -4
@@ -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
  }
@@ -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,6 +1,12 @@
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
+ /**
5
+ * The same extensions as the docs and `avclient --help` list them, TypeScript
6
+ * first: the order a sentence to the developer names them in. Lookup keeps
7
+ * {@link CLIENT_CONFIG_FILE_EXTENSIONS}' order, Prisma's.
8
+ */
9
+ export declare const CLIENT_CONFIG_FILE_EXTENSIONS_AS_LISTED: readonly [".ts", ".mts", ".cts", ".js", ".mjs", ".cjs"];
4
10
  /** The config's name, before its extension. */
5
11
  export declare const CLIENT_CONFIG_BASENAME = "framework.client";
6
12
  /** The config file `avclient init` writes when the project has none. */
@@ -8,7 +14,7 @@ export declare const CLIENT_CONFIG_FILE = "framework.client.ts";
8
14
  export interface LoadedClientConfig {
9
15
  /** The config file's absolute path; `generateAt` resolves against its directory. */
10
16
  readonly file: string;
11
- readonly config: ClientConfigInput;
17
+ readonly config: AvClientConfigInput;
12
18
  }
13
19
  /**
14
20
  * The config files present in `directory`, by name, in
@@ -20,13 +26,13 @@ export declare function clientConfigFilesIn(directory: string): readonly string[
20
26
  * The one config file in `directory`, by name, or `undefined` when there is
21
27
  * none.
22
28
  *
23
- * @throws ClientConfigError when there is more than one, naming each.
29
+ * @throws AvClientConfigError when there is more than one, naming each.
24
30
  */
25
31
  export declare function findClientConfigFile(directory: string): string | undefined;
26
32
  /**
27
33
  * Evaluates the one `framework.client.<ext>` in `directory`.
28
34
  *
29
- * @throws ClientConfigError, in one line, when there is none or more than one,
35
+ * @throws AvClientConfigError, in one line, when there is none or more than one,
30
36
  * or the file does not evaluate, or does not default-export a client config.
31
37
  */
32
38
  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",
@@ -9,6 +9,14 @@ export const CLIENT_CONFIG_FILE_EXTENSIONS = [
9
9
  ".mts",
10
10
  ".cts",
11
11
  ];
12
+ export const CLIENT_CONFIG_FILE_EXTENSIONS_AS_LISTED = [
13
+ ".ts",
14
+ ".mts",
15
+ ".cts",
16
+ ".js",
17
+ ".mjs",
18
+ ".cjs",
19
+ ];
12
20
  export const CLIENT_CONFIG_BASENAME = "framework.client";
13
21
  export const CLIENT_CONFIG_FILE = `${CLIENT_CONFIG_BASENAME}.ts`;
14
22
  export function clientConfigFilesIn(directory) {
@@ -20,14 +28,15 @@ export function findClientConfigFile(directory) {
20
28
  const present = clientConfigFilesIn(directory);
21
29
  if (present.length > 1) {
22
30
  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" : ""}.`);
31
+ 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
32
  }
25
33
  return present[0];
26
34
  }
27
35
  export async function loadClientConfigFile(directory) {
28
36
  const name = findClientConfigFile(directory);
29
37
  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 ` +
38
+ const [first, ...others] = CLIENT_CONFIG_FILE_EXTENSIONS_AS_LISTED;
39
+ throw new AvClientConfigError(`no ${CLIENT_CONFIG_BASENAME}${first}, ${others.slice(0, -1).join(", ")} or ${others.at(-1)} in ${path.resolve(directory)}; create ${CLIENT_CONFIG_FILE} with ` +
31
40
  "`export default defineClientConfig({ entrypoint, generateAt })` (or run `avclient init`) and run the generator from its directory.");
32
41
  }
33
42
  const file = path.resolve(directory, name);
@@ -52,19 +61,19 @@ export async function loadClientConfigFile(directory) {
52
61
  evaluated = loaded.layers?.find((layer) => layer.configFile === file)?.config;
53
62
  }
54
63
  catch (error) {
55
- throw new ClientConfigError(`${file} could not be evaluated: ${firstLineOf(error)}`, { cause: error });
64
+ throw new AvClientConfigError(`${file} could not be evaluated: ${firstLineOf(error)}`, { cause: error });
56
65
  }
57
66
  return { file, config: clientConfigOf(file, evaluated) };
58
67
  }
59
68
  function clientConfigOf(file, config) {
60
69
  const shape = "`export default defineClientConfig({ entrypoint, generateAt })`";
61
70
  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}.`);
71
+ throw new AvClientConfigError(`${file}'s default export is not an object; it must be ${shape}.`);
63
72
  }
64
73
  const members = config;
65
74
  const tsconfigFile = members.tsconfigFile;
66
75
  if (tsconfigFile !== undefined && typeof tsconfigFile !== "string") {
67
- throw new ClientConfigError(`${file}'s tsconfigFile must be a string, a path relative to ${path.dirname(file)}.`);
76
+ throw new AvClientConfigError(`${file}'s tsconfigFile must be a string, a path relative to ${path.dirname(file)}.`);
68
77
  }
69
78
  return {
70
79
  entrypoint: configValueOf(file, "entrypoint", members.entrypoint),
@@ -84,7 +93,7 @@ function configValueOf(file, member, value) {
84
93
  return { kind: "env", name };
85
94
  }
86
95
  }
87
- throw new ClientConfigError(`${file}'s ${member} must be a string or env("NAME"), and it is ${value === undefined ? "missing" : "neither"}.`);
96
+ throw new AvClientConfigError(`${file}'s ${member} must be a string or env("NAME"), and it is ${value === undefined ? "missing" : "neither"}.`);
88
97
  }
89
98
  function firstLineOf(error) {
90
99
  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/internal";
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>;
@@ -1,7 +1,7 @@
1
1
  export const CONTRACT_NOT_MODIFIED = Symbol("aventara.contract-not-modified");
2
- export class ContractTransportError extends Error {
2
+ export class AvContractTransportError extends Error {
3
3
  reason;
4
- name = "ContractTransportError";
4
+ name = "AvContractTransportError";
5
5
  constructor(reason, message, options) {
6
6
  super(message, options);
7
7
  this.reason = reason;
@@ -29,26 +29,26 @@ export async function fetchClientContractBody(entrypoint, fetch = globalThis.fet
29
29
  : { method: "GET", headers: { "If-None-Match": ifNoneMatch } });
30
30
  }
31
31
  catch (error) {
32
- throw new ContractTransportError("request-failed", `Could not fetch the ClientContract from ${shown}: ${describeCause(error)}. ${remedy}`, { cause: error });
32
+ throw new AvContractTransportError("request-failed", `Could not fetch the ClientContract from ${shown}: ${describeCause(error)}. ${remedy}`, { cause: error });
33
33
  }
34
34
  if (response.status === 304 && ifNoneMatch !== undefined) {
35
35
  return CONTRACT_NOT_MODIFIED;
36
36
  }
37
37
  if (!response.ok) {
38
- throw new ContractTransportError("http-status", `GET ${shown} answered HTTP ${response.status}, not the ClientContract. ${remedy}`);
38
+ throw new AvContractTransportError("http-status", `GET ${shown} answered HTTP ${response.status}, not the ClientContract. ${remedy}`);
39
39
  }
40
40
  let text;
41
41
  try {
42
42
  text = await response.text();
43
43
  }
44
44
  catch (error) {
45
- throw new ContractTransportError("body-unreadable", `The response from ${shown} could not be read: ${describeCause(error)}. ${remedy}`, { cause: error });
45
+ throw new AvContractTransportError("body-unreadable", `The response from ${shown} could not be read: ${describeCause(error)}. ${remedy}`, { cause: error });
46
46
  }
47
47
  try {
48
48
  return JSON.parse(text);
49
49
  }
50
50
  catch (error) {
51
- throw new ContractTransportError("body-not-json", `The response from ${shown} is not JSON, so it is not a ClientContract. ${remedy}`, { cause: error });
51
+ throw new AvContractTransportError("body-not-json", `The response from ${shown} is not JSON, so it is not a ClientContract. ${remedy}`, { cause: error });
52
52
  }
53
53
  }
54
54
  function describeCause(error) {
@@ -1,4 +1,4 @@
1
- import type { ClientContract } from "@aventara/core";
1
+ import type { AvContractClient } from "@aventara/core";
2
2
  import type { ClientEntrypoint } from "../config/client-config.interface.js";
3
3
  import { type ContractFetch } from "./contract.fetcher.js";
4
4
  export interface ClientContractLoadInput {
@@ -6,12 +6,12 @@ export interface ClientContractLoadInput {
6
6
  readonly fetch?: ContractFetch;
7
7
  }
8
8
  /**
9
- * @throws ContractTransportError when no JSON value arrives.
10
- * @throws ContractProtocolError when what arrived is refused.
9
+ * @throws AvContractTransportError when no JSON value arrives.
10
+ * @throws AvContractProtocolError when what arrived is refused.
11
11
  */
12
- export declare function loadClientContract(input: ClientContractLoadInput): Promise<ClientContract>;
12
+ export declare function loadClientContract(input: ClientContractLoadInput): Promise<AvContractClient>;
13
13
  export interface ClientContractSince {
14
- readonly contract: ClientContract;
14
+ readonly contract: AvContractClient;
15
15
  /** The deployment answered `304`: `contract` is the one the caller held. */
16
16
  readonly notModified: boolean;
17
17
  }
@@ -21,4 +21,4 @@ export interface ClientContractSince {
21
21
  * `If-None-Match: "<its hash>"`, and a `304` answers with `stored` itself. Without
22
22
  * `stored` the GET is unconditional.
23
23
  */
24
- export declare function loadClientContractSince(input: ClientContractLoadInput, stored: ClientContract | undefined): Promise<ClientContractSince>;
24
+ export declare function loadClientContractSince(input: ClientContractLoadInput, stored: AvContractClient | undefined): Promise<ClientContractSince>;
@@ -1,4 +1,4 @@
1
- import { acceptClientContract, ContractProtocolError, } from "./contract.acceptance.js";
1
+ import { AvContractProtocolError, acceptClientContract, } from "./contract.acceptance.js";
2
2
  import { CONTRACT_NOT_MODIFIED, contractUrlOf, displayUrl, fetchClientContractBody, } from "./contract.fetcher.js";
3
3
  export async function loadClientContract(input) {
4
4
  return accepted(await fetchClientContractBody(input.entrypoint, input.fetch), input);
@@ -16,7 +16,7 @@ export async function loadClientContractSince(input, stored) {
16
16
  async function accepted(body, input) {
17
17
  const acceptance = await acceptClientContract(body);
18
18
  if (!acceptance.accepted) {
19
- throw new ContractProtocolError(acceptance, displayUrl(contractUrlOf(input.entrypoint)));
19
+ throw new AvContractProtocolError(acceptance, displayUrl(contractUrlOf(input.entrypoint)));
20
20
  }
21
21
  return acceptance.contract;
22
22
  }
@@ -1,5 +1,5 @@
1
- import type { ClientContract } from "@aventara/core";
1
+ import type { AvContractClient } from "@aventara/core";
2
2
  import type { EmittedModule } from "./emitted-tree.interface.js";
3
3
  import { type ClientModuleStyle } from "./module-style.interface.js";
4
4
  import { type EmittedNames } from "./name.deriver.js";
5
- export declare function emitClientSurfaceModule(contract: ClientContract, names: EmittedNames, style: ClientModuleStyle): EmittedModule;
5
+ export declare function emitClientSurfaceModule(contract: AvContractClient, names: EmittedNames, style: ClientModuleStyle): EmittedModule;