@owlmeans/api-config-client 0.1.18-rc.12 → 0.1.18-rc.13

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
@@ -11,7 +11,7 @@ Client-side middleware that fetches server config from `GET /assets/config.json`
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.12
15
15
  ```
16
16
 
17
17
  ## Usage
@@ -45,7 +45,7 @@ This package ships embedded agent skills under `agent-meta/`. After installing y
45
45
  your project's skill store (`.agents/skills/`):
46
46
 
47
47
  ```sh
48
- npx @owlmeans/agent-skills
48
+ npx @owlmeans/agent-skills@^0.1.18-rc.12
49
49
  ```
50
50
 
51
51
  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.12",
5
- "generatedAt": "2026-09-01T17:39:40.765Z",
4
+ "version": "0.1.18-rc.13",
5
+ "generatedAt": "2026-09-04T22:43:25.446Z",
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.12"` in `dependencies`
11
+ **Install:** `"@owlmeans/api-config-client": "^0.1.18-rc.13"` 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` declaration elevated 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 apiConfigEntrypoints } 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 appEntrypoints = [...apiConfigEntrypoints, ...myEntrypoints]
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
+ spreading `entrypoints` 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.
@@ -1,2 +1,2 @@
1
- export declare const entrypoints: any[];
1
+ export declare const entrypoints: import("@owlmeans/entrypoint").CommonEntrypoint[];
2
2
  //# sourceMappingURL=entrypoints.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"entrypoints.d.ts","sourceRoot":"","sources":["../src/entrypoints.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,WAAW,OAAS,CAAA"}
1
+ {"version":3,"file":"entrypoints.d.ts","sourceRoot":"","sources":["../src/entrypoints.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,WAAW,mDAAS,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@owlmeans/api-config-client",
3
- "version": "0.1.18-rc.12",
3
+ "version": "0.1.18-rc.13",
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.11",
25
- "@owlmeans/client-context": "^0.1.18-rc.12",
26
- "@owlmeans/client-entrypoint": "^0.1.18-rc.12",
27
- "@owlmeans/context": "^0.1.18-rc.7"
24
+ "@owlmeans/api-config": "^0.1.18-rc.12",
25
+ "@owlmeans/client-context": "^0.1.18-rc.13",
26
+ "@owlmeans/client-entrypoint": "^0.1.18-rc.13",
27
+ "@owlmeans/context": "^0.1.18-rc.8"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@owlmeans/dep-config": "workspace:*",