bazis 0.105.0 → 0.105.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.
@@ -10,9 +10,18 @@ export function registerNamedDependencyHint(hint: NamedDependencyHint): void {
10
10
  hints.push(hint);
11
11
  }
12
12
 
13
+ function hintFor(name: string): string {
14
+ const hint = hints.map((item) => item(name)).find((text) => text !== undefined);
15
+ return hint ? ` ${hint}` : "";
16
+ }
17
+
18
+ /** The graph-validation issue for a named dependency nobody registers, naming the service that needs it. */
19
+ export function missingNamedDependencyIssue(name: string, requester: string): string {
20
+ return `Missing dependency "${name}" for "${requester}".${hintFor(name)}`;
21
+ }
22
+
13
23
  export class NamedDependencyNotFoundError extends DiError {
14
24
  public constructor(name: string) {
15
- const hint = hints.map((item) => item(name)).find((text) => text !== undefined);
16
- super(`No provider token found for named dependency "${name}".${hint ? ` ${hint}` : ""}`);
25
+ super(`No provider token found for named dependency "${name}".${hintFor(name)}`);
17
26
  }
18
27
  }
@@ -1,4 +1,5 @@
1
1
  import { ServiceValidationError } from "../errors";
2
+ import { missingNamedDependencyIssue } from "../errors/NamedDependencyNotFoundError";
2
3
  import { isLazyDependency, isNamedDependency, isOptionalDependency } from "../provider";
3
4
  import type {
4
5
  KeyedDependency,
@@ -97,7 +98,8 @@ export class GraphValidator {
97
98
  const isOptional = isOptionalDependency(dependency);
98
99
  const inner = isLazy || isOptional ? dependency.inner : dependency;
99
100
  // An optional dependency on a name nothing registered is simply absent.
100
- if (isOptional && isNamedDependency(inner) && !this.context.hasName(inner.name)) {
101
+ if (isNamedDependency(inner) && !this.context.hasName(inner.name)) {
102
+ if (!isOptional) issues.add(missingNamedDependencyIssue(inner.name, tokenToDebugName(registration.token)));
101
103
  continue;
102
104
  }
103
105
  const descriptor = this.context.describeDependency(inner);
@@ -232,7 +232,7 @@ export class CodexAppServerClient implements CodexClient {
232
232
  if (method === "account/updated") this.modelCache = undefined;
233
233
  }, () => { this.clearLogin(); this.modelCache = undefined; });
234
234
  const initialized = await client.request("initialize", {
235
- clientInfo: { name: "bazis", title: "Bazis", version: "0.105.0" }, capabilities: { experimentalApi: true },
235
+ clientInfo: { name: "bazis", title: "Bazis", version: "0.105.1" }, capabilities: { experimentalApi: true },
236
236
  }, 15_000, signal);
237
237
  if (resolve(text(initialized.codexHome, 4096)) !== this.paths.home) throw new CodexError("PROTOCOL_ERROR");
238
238
  client.notify("initialized");
@@ -7,6 +7,16 @@ import { ENV_PREFIX } from "./sources";
7
7
  import { isSensitiveKey, redactSensitiveText } from "../../../library/redaction";
8
8
  import { ConfigValidationError, type ConfigIssue, type ConfigIssueKind } from "./ConfigValidationError";
9
9
  import { callerFile } from "./callerFile";
10
+ import { registerNamedDependencyHint } from "../../di/errors/NamedDependencyNotFoundError";
11
+
12
+ // `ConfigView<T>` is injected by the name of its config; a config that no
13
+ // module declares has no provider, and the start says where to declare it.
14
+ registerNamedDependencyHint((name) => {
15
+ const match = /^Config:(.+)$/.exec(name);
16
+ if (!match) return undefined;
17
+ const declaration = match[1] === "default" ? "defineConfig({ … })" : `defineConfig("${match[1]}", …)`;
18
+ return `The config ${declaration} is not declared in the application: add it to \`config\` of the module that uses it, or to runApp({ config }).`;
19
+ });
10
20
 
11
21
  type Stand = "development" | "test" | "production";
12
22
  type Primitive = string | number | boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bazis",
3
- "version": "0.105.0",
3
+ "version": "0.105.1",
4
4
  "description": "Modular backend framework for Bun in TypeScript: DI wired by codegen, HTTP, a PostgreSQL ORM, JWT, WebSocket, agents and a CLI.",
5
5
  "license": "MIT",
6
6
  "author": "Alexander Alenin",