@owlmeans/api-config-client 0.1.18-rc.3 → 0.1.18-rc.31

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/README.md CHANGED
@@ -5,13 +5,13 @@ Client-side middleware that fetches server config from `GET /assets/config.json`
5
5
  ## Overview
6
6
 
7
7
  - `apiConfigMiddleware` — context middleware that calls the config endpoint on startup
8
- - Elevates `@owlmeans/api-config` modules into the client module system
8
+ - Binds the `@owlmeans/api-config` `advertise` protocol into the client entrypoint system
9
9
  - Merges the server `ApiConfig` into the client's `CommonConfig` at initialization time
10
10
 
11
11
  ## Installation
12
12
 
13
13
  ```bash
14
- bun add @owlmeans/api-config-client
14
+ bun add @owlmeans/api-config-client@^0.1.18-rc.31
15
15
  ```
16
16
 
17
17
  ## Usage
@@ -24,13 +24,16 @@ import { apiConfigMiddleware } from '@owlmeans/api-config-client'
24
24
  context.registerMiddleware(apiConfigMiddleware)
25
25
  ```
26
26
 
27
- On initialization, the middleware calls the `API_CONFIG` module and merges the response into the context config.
27
+ On initialization, the middleware calls the bound `advertise` protocol and merges the response into
28
+ the context config. If this package's local `entrypoints` bindings are not registered, initialization
29
+ fails rather than silently falling back to alias-based calls.
28
30
 
29
31
  ## API
30
32
 
31
33
  ### `apiConfigMiddleware: Middleware`
32
34
 
33
- A context initialization middleware. Calls `API_CONFIG` module, receives `ApiConfig`, and applies it to the context via `mergeConfig`.
35
+ A context initialization middleware. Calls the `advertise` protocol, receives `ApiConfig`, and
36
+ applies it to the context via `mergeConfig`.
34
37
 
35
38
  ## Related Packages
36
39
 
@@ -45,7 +48,7 @@ This package ships embedded agent skills under `agent-meta/`. After installing y
45
48
  your project's skill store (`.agents/skills/`):
46
49
 
47
50
  ```sh
48
- npx @owlmeans/agent-skills
51
+ npx @owlmeans/agent-skills@^0.1.18-rc.33
49
52
  ```
50
53
 
51
54
  The embedded files are version-matched to this package release. Do not edit them
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "schemaVersion": 2,
3
3
  "package": "@owlmeans/api-config-client",
4
- "version": "0.1.18-rc.0",
5
- "generatedAt": "2026-08-16T22:20:50.510Z",
4
+ "version": "0.1.18-rc.31",
5
+ "generatedAt": "2026-09-22T17:37:10.920Z",
6
6
  "canonicalRepo": "https://github.com/owlmeans/common",
7
7
  "entries": [
8
8
  {
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: api-config-client
3
- description: How to use @owlmeans/api-config-client — client-side middleware and modules for fetching the API config served by api-config-server. Auto-invoked when wiring runtime API config into a client app.
3
+ description: How to use @owlmeans/api-config-client — the browser half of the runtime config flow, a loading-stage middleware that fetches the config a backend advertises and merges it into the client config. Auto-invoked when wiring runtime API config into a client app or debugging a client that boots with an incomplete config.
4
4
  user-invocable: false
5
5
  ---
6
6
  <!-- AUTO-GENERATED — do not edit. Regenerate via sync-agent-meta. -->
@@ -8,22 +8,71 @@ user-invocable: false
8
8
  # @owlmeans/api-config-client
9
9
 
10
10
  **Layer:** Client
11
- **Install:** `"@owlmeans/api-config-client": "^0.1.18-rc.0"` in `dependencies`
11
+ **Install:** `"@owlmeans/api-config-client": "^0.1.18-rc.31"` in `dependencies`
12
+
13
+ Consumes the declaration shared by `@owlmeans/api-config` and answered by
14
+ `@owlmeans/api-config-server`.
12
15
 
13
16
  ## Key Exports
14
17
 
15
18
  | Export | Description |
16
19
  |--------|-------------|
17
- | `apiConfigMiddleware` | Middleware to fetch and apply remote API config at startup |
18
- | `modules` | Client-side api-config module declarations |
20
+ | `apiConfigMiddleware` | Context middleware, `Loading` stage — fetches the advertised config and merges it into `context.cfg` |
21
+ | `entrypoints` | The `API_CONFIG` protocol bound for client use, so the middleware can call it |
19
22
 
20
23
  ## Usage
21
24
 
25
+ Both halves are needed: the middleware does the work, the entrypoint is what it calls.
26
+
22
27
  ```typescript
23
- import { modules as apiConfigClientModules } from '@owlmeans/api-config-client'
24
- context.registerEntrypoints([...apiConfigClientModules, ...appModules])
28
+ import { apiConfigMiddleware, entrypoints as apiConfigBindings } from '@owlmeans/api-config-client'
29
+
30
+ export const makeContext = <C extends AppConfig, T extends AppContext<C>>(cfg: C): T => {
31
+ const context = makeClientContext(cfg) as T
32
+ context.registerMiddleware(apiConfigMiddleware)
33
+ return context
34
+ }
35
+
36
+ export const clientBindings = [...apiConfigBindings, ...myClientBindings]
25
37
  ```
26
38
 
39
+ A panel app on `@owlmeans/web-panel` or `@owlmeans/mui-panel` already registers both — do it again
40
+ only in a context built from a lower layer.
41
+
42
+ ## What the middleware does
43
+
44
+ It runs once during `init()`, as a `Context`/`Loading` middleware — after every service and
45
+ resource has initialized and just before the context is marked ready. So the merged values are
46
+ there for anything that reads `cfg` at request or render time, but **not** for a value a service
47
+ captured while initializing: that one still holds what the bundle shipped.
48
+
49
+ - **Both halves, or the boot dies.** The middleware resolves `API_CONFIG` against the context
50
+ before it tests anything else, so a context that registers `apiConfigMiddleware` without also
51
+ registering local `entrypoints` bindings fails `init()` with `SyntaxError: Entrypoint api-config:advertise not
52
+ found`. That failure is outside the swallowing below — it is a hard boot error, not a missing
53
+ value discovered later.
54
+ - **It is a no-op unless `cfg.primaryHost` is set.** A build without it keeps whatever the bundle
55
+ was compiled with, silently. That is the first thing to check when a client boots with a config
56
+ the backend does not agree with.
57
+ - `cfg.primaryHost` (and `cfg.primaryPort`, when given) are written onto the entrypoint's route
58
+ before the call, so the config is fetched from the primary backend rather than from wherever the
59
+ entrypoint would otherwise resolve.
60
+ - The answer is merged into `context.cfg` in place by `mergeConfig` from `@owlmeans/config`:
61
+ objects are merged key by key, two arrays are **appended**, and the server's value replaces the
62
+ built-in one only where that built-in is a scalar, `null` or absent. Where the built-in is an
63
+ object or an array and the server sends a scalar, the merge recurses into that pair, matches
64
+ neither branch and returns the built-in untouched — **the server's value is silently dropped**.
65
+ An array the bundle already carries therefore grows on every merge, and can be neither replaced
66
+ nor emptied from the server.
67
+ - A failed **fetch** is logged and swallowed — only the call and the merge are inside the
68
+ try/catch. The app continues on its built-in config, so a misconfigured or unreachable primary
69
+ host shows up as missing values later, never as a boot error.
70
+
27
71
  ## Depends On
28
72
 
29
- - `@owlmeans/api-config`, `@owlmeans/client-entrypoint`, `@owlmeans/client-context`
73
+ Declared: `@owlmeans/api-config`, `@owlmeans/client-entrypoint`, `@owlmeans/client-context`,
74
+ `@owlmeans/context`.
75
+
76
+ Imported but **not** declared in this package's manifest: `@owlmeans/config` (`mergeConfig`, which
77
+ does the merging described above). A workspace resolves it anyway; a standalone install has to name
78
+ it in its own dependencies.
@@ -0,0 +1,3 @@
1
+ /** The browser-local binding of the shared runtime-config protocol. */
2
+ export declare const entrypoints: import("@owlmeans/client-entrypoint").ClientProtocolEntrypoint<import("@owlmeans/entrypoint").EntrypointProtocol<import("@owlmeans/entrypoint").OpenRequest, import("@owlmeans/entrypoint").OpenValue>>[];
3
+ //# sourceMappingURL=entrypoints.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entrypoints.d.ts","sourceRoot":"","sources":["../src/entrypoints.ts"],"names":[],"mappings":"AAIA,uEAAuE;AACvE,eAAO,MAAM,WAAW,2MAAoB,CAAA"}
@@ -0,0 +1,5 @@
1
+ import { advertise } from '@owlmeans/api-config';
2
+ import { bind } from '@owlmeans/client-entrypoint';
3
+ /** The browser-local binding of the shared runtime-config protocol. */
4
+ export const entrypoints = [bind(advertise)];
5
+ //# sourceMappingURL=entrypoints.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entrypoints.js","sourceRoot":"","sources":["../src/entrypoints.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAA;AAElD,uEAAuE;AACvE,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAA"}
package/build/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export * from './middleware.js';
2
- export * from './modules.js';
2
+ export * from './entrypoints.js';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,cAAc,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA"}
package/build/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  export * from './middleware.js';
2
- export * from './modules.js';
2
+ export * from './entrypoints.js';
3
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,cAAc,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA"}
@@ -13,7 +13,7 @@ export const apiConfigMiddleware = {
13
13
  module.route.route.port = context.cfg.primaryPort;
14
14
  }
15
15
  try {
16
- const [config] = await module.call();
16
+ const config = await module.call();
17
17
  const target = context.cfg;
18
18
  mergeConfig(target, config);
19
19
  }
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.js","sourceRoot":"","sources":["../src/middleware.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAGlF,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAI9C,MAAM,CAAC,MAAM,mBAAmB,GAAe;IAC7C,IAAI,EAAE,cAAc,CAAC,OAAO;IAC5B,KAAK,EAAE,eAAe,CAAC,OAAO;IAC9B,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,E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,CAC3B,GAAU,EAAE,uBAAuB,CACpC,CAAA;QACD,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,CAA8B,UAAU,CAAC,CAAA;QAC1E,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,IAAI,EAAE,CAAC;YACpC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,CAAA;YACjD,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,IAAI,EAAE,CAAC;gBACpC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,CAAA;YACnD,CAAC;YACD,IAAI,CAAC;gBACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAA;gBAClC,MAAM,MAAM,GAAiB,OAAO,CAAC,GAA8B,CAAA;gBACnE,WAAW,CAAC,MAAM,EAAE,MAAsB,CAAC,CAAA;YAC7C,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;YAClB,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@owlmeans/api-config-client",
3
- "version": "0.1.18-rc.3",
3
+ "version": "0.1.18-rc.31",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -21,10 +21,10 @@
21
21
  }
22
22
  },
23
23
  "dependencies": {
24
- "@owlmeans/api-config": "^0.1.18-rc.3",
25
- "@owlmeans/client-context": "^0.1.18-rc.3",
26
- "@owlmeans/client-entrypoint": "^0.1.18-rc.3",
27
- "@owlmeans/context": "^0.1.18-rc.3"
24
+ "@owlmeans/api-config": "^0.1.18-rc.32",
25
+ "@owlmeans/client-context": "^0.1.18-rc.34",
26
+ "@owlmeans/client-entrypoint": "^0.1.18-rc.33",
27
+ "@owlmeans/context": "^0.1.18-rc.29"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@owlmeans/dep-config": "workspace:*",
@@ -0,0 +1,6 @@
1
+
2
+ import { advertise } from '@owlmeans/api-config'
3
+ import { bind } from '@owlmeans/client-entrypoint'
4
+
5
+ /** The browser-local binding of the shared runtime-config protocol. */
6
+ export const entrypoints = [bind(advertise)]
package/src/index.ts CHANGED
@@ -1,3 +1,3 @@
1
1
 
2
2
  export * from './middleware.js'
3
- export * from './modules.js'
3
+ export * from './entrypoints.js'
package/src/middleware.ts CHANGED
@@ -21,7 +21,7 @@ export const apiConfigMiddleware: Middleware = {
21
21
  module.route.route.port = context.cfg.primaryPort
22
22
  }
23
23
  try {
24
- const [config] = await module.call()
24
+ const config = await module.call()
25
25
  const target: CommonConfig = context.cfg as unknown as CommonConfig
26
26
  mergeConfig(target, config as CommonConfig)
27
27
  } catch (e) {
package/build/.gitkeep DELETED
File without changes
@@ -1,2 +0,0 @@
1
- export declare const modules: import("@owlmeans/entrypoint").CommonEntrypoint[];
2
- //# sourceMappingURL=modules.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"modules.d.ts","sourceRoot":"","sources":["../src/modules.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,OAAO,mDAAS,CAAA"}
package/build/modules.js DELETED
@@ -1,5 +0,0 @@
1
- import { modules as config, API_CONFIG } from '@owlmeans/api-config';
2
- import { elevate } from '@owlmeans/client-entrypoint';
3
- elevate(config, API_CONFIG);
4
- export const modules = config;
5
- //# sourceMappingURL=modules.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"modules.js","sourceRoot":"","sources":["../src/modules.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAA;AAErD,OAAO,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;AAE3B,MAAM,CAAC,MAAM,OAAO,GAAG,MAAM,CAAA"}
package/src/modules.ts DELETED
@@ -1,7 +0,0 @@
1
-
2
- import { modules as config, API_CONFIG } from '@owlmeans/api-config'
3
- import { elevate } from '@owlmeans/client-entrypoint'
4
-
5
- elevate(config, API_CONFIG)
6
-
7
- export const modules = config