@owlmeans/api-config-client 0.1.18-rc.5 → 0.1.18-rc.50
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 +87 -17
- package/agent-meta/manifest.json +3 -3
- package/agent-meta/skills/api-config-client/SKILL.md +56 -7
- package/build/entrypoints.d.ts +3 -0
- package/build/entrypoints.d.ts.map +1 -0
- package/build/entrypoints.js +5 -0
- package/build/entrypoints.js.map +1 -0
- package/build/index.d.ts +1 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -1
- package/build/index.js.map +1 -1
- package/build/middleware.d.ts.map +1 -1
- package/build/middleware.js +6 -4
- package/build/middleware.js.map +1 -1
- package/package.json +6 -5
- package/src/entrypoints.ts +6 -0
- package/src/index.ts +1 -1
- package/src/middleware.ts +7 -4
- package/build/.gitkeep +0 -0
- package/build/modules.d.ts +0 -2
- package/build/modules.d.ts.map +0 -1
- package/build/modules.js +0 -5
- package/build/modules.js.map +0 -1
- package/src/modules.ts +0 -7
package/README.md
CHANGED
|
@@ -1,41 +1,111 @@
|
|
|
1
1
|
# @owlmeans/api-config-client
|
|
2
2
|
|
|
3
|
-
Client-side middleware that fetches server config from `GET /assets/config.json` and merges it into
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
- `
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
Client-side middleware that fetches server config from `GET /assets/config.json` and merges it into
|
|
4
|
+
the client context. It is the browser half of the runtime config flow: `@owlmeans/api-config`
|
|
5
|
+
declares the `advertise` protocol and the public-field allowlist, `@owlmeans/api-config-server`
|
|
6
|
+
answers it, and this package binds and calls it during `init()`. An app built on
|
|
7
|
+
`@owlmeans/web-panel` or `@owlmeans/mui-panel` already has both halves wired and does not touch
|
|
8
|
+
this package; a client context built from a lower layer registers it itself. Config that is fixed at
|
|
9
|
+
build time needs no runtime fetch — use `@owlmeans/client-config` for that. The package's skill is
|
|
10
|
+
`api-config-client`.
|
|
10
11
|
|
|
11
12
|
## Installation
|
|
12
13
|
|
|
13
14
|
```bash
|
|
14
|
-
bun add @owlmeans/api-config-client
|
|
15
|
+
bun add @owlmeans/api-config-client@^0.1.18-rc.50
|
|
15
16
|
```
|
|
16
17
|
|
|
18
|
+
The middleware imports `mergeConfig` from `@owlmeans/config`, which this package's manifest does not
|
|
19
|
+
declare; a standalone install adds `@owlmeans/config` to its own dependencies.
|
|
20
|
+
|
|
21
|
+
## Concepts
|
|
22
|
+
|
|
23
|
+
- **Advertise protocol** — `advertise` from `@owlmeans/api-config`, alias `API_CONFIG`
|
|
24
|
+
(`'api-config:advertise'`), an open sticky route at `/assets/config.json`.
|
|
25
|
+
- **Binding** — `entrypoints`, this package's `[bind(advertise)]`: the client entrypoint the
|
|
26
|
+
middleware resolves by alias.
|
|
27
|
+
- **Middleware** — `apiConfigMiddleware`, a `Context` / `Loading` middleware: it runs once during
|
|
28
|
+
`init()`, after every service and resource has initialized and before the context becomes ready.
|
|
29
|
+
- **Primary host** — `cfg.primaryHost` / `cfg.primaryPort`: where the config is fetched from. The
|
|
30
|
+
fetch happens only when `primaryHost` is set; `@owlmeans/web-client` fills both from
|
|
31
|
+
`window.location`.
|
|
32
|
+
- **Merge** — the answer is merged into `context.cfg` in place with `configHelper.mergeConfig`.
|
|
33
|
+
|
|
17
34
|
## Usage
|
|
18
35
|
|
|
19
|
-
|
|
36
|
+
### Wire both halves in a lower-layer client context
|
|
37
|
+
|
|
38
|
+
The middleware does the work; the binding is what it calls. Registering one without the other fails
|
|
39
|
+
the boot.
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
import { makeClientContext } from '@owlmeans/client-context'
|
|
43
|
+
import { apiConfigMiddleware, entrypoints as apiConfigBindings } from '@owlmeans/api-config-client'
|
|
44
|
+
|
|
45
|
+
export const makeContext = <C extends AppConfig, T extends AppContext<C>>(cfg: C): T => {
|
|
46
|
+
const context = makeClientContext<C, T>(cfg)
|
|
47
|
+
context.registerMiddleware(apiConfigMiddleware)
|
|
48
|
+
|
|
49
|
+
return context
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export const clientBindings = [...apiConfigBindings, ...myClientBindings]
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Point the fetch at a backend
|
|
20
56
|
|
|
21
57
|
```typescript
|
|
22
|
-
|
|
58
|
+
const context = makeContext({
|
|
59
|
+
...config,
|
|
60
|
+
primaryHost: 'app.example.com',
|
|
61
|
+
primaryPort: 8443,
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
await context.configure().init() // fetches /assets/config.json from app.example.com:8443 and merges it
|
|
65
|
+
```
|
|
23
66
|
|
|
24
|
-
|
|
67
|
+
### Read merged values at render or request time
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
const brand = context.cfg.brand // the server's value once init() has resolved
|
|
25
71
|
```
|
|
26
72
|
|
|
27
|
-
|
|
73
|
+
A service that copied a config value during its own `init()` keeps the bundled value — the merge
|
|
74
|
+
happens after service initialization.
|
|
28
75
|
|
|
29
76
|
## API
|
|
30
77
|
|
|
31
|
-
|
|
78
|
+
| Symbol | Kind | Purpose |
|
|
79
|
+
|---|---|---|
|
|
80
|
+
| `apiConfigMiddleware` | `Middleware` | `Context` / `Loading`; resolves `API_CONFIG`, sets the route's `host`/`port` from `cfg.primaryHost`/`cfg.primaryPort`, calls it and merges the `ApiConfig` answer into `context.cfg` |
|
|
81
|
+
| `entrypoints` | `ClientEntrypoint[]` | `[bind(advertise)]` — the browser-local binding of the shared runtime-config protocol |
|
|
82
|
+
|
|
83
|
+
### Merge behaviour
|
|
84
|
+
|
|
85
|
+
`configHelper.mergeConfig` merges objects key by key and appends arrays. A server value replaces the
|
|
86
|
+
bundled one only where the bundled value is a scalar, `null` or absent; a scalar sent for a bundled
|
|
87
|
+
object or array is dropped silently, and a bundled array grows on every merge.
|
|
88
|
+
|
|
89
|
+
## Common pitfalls
|
|
32
90
|
|
|
33
|
-
|
|
91
|
+
- Registering `apiConfigMiddleware` without the `entrypoints` bindings — `init()` throws
|
|
92
|
+
`SyntaxError: Entrypoint api-config:advertise not found` rather than silently falling back.
|
|
93
|
+
- No `cfg.primaryHost` — the middleware does nothing and the app runs on the bundled config.
|
|
94
|
+
- A failed fetch is logged (`API config not loaded`) and swallowed; an unreachable backend shows up
|
|
95
|
+
as missing values later, never as a boot error.
|
|
96
|
+
- Registering the pair again on a `web-panel` / `mui-panel` context — those factories already do it.
|
|
97
|
+
- Expecting the server to empty or replace a bundled array — the merge only appends.
|
|
98
|
+
- Only fields an `apiConfigPlugin` allows are advertised; a value missing on the client may simply
|
|
99
|
+
not be exposed by the server.
|
|
34
100
|
|
|
35
|
-
## Related
|
|
101
|
+
## Related packages
|
|
36
102
|
|
|
37
|
-
- [`@owlmeans/api-config`](../api-config) — `API_CONFIG`
|
|
103
|
+
- [`@owlmeans/api-config`](../api-config) — `API_CONFIG`, the `advertise` protocol, `ApiConfig` and the field allowlist
|
|
38
104
|
- [`@owlmeans/api-config-server`](../api-config-server) — server that serves the config endpoint
|
|
105
|
+
- [`@owlmeans/config`](../config) — `configHelper.mergeConfig`
|
|
106
|
+
- [`@owlmeans/client-entrypoint`](../client-entrypoint) — `bind`, the client entrypoint binding
|
|
107
|
+
- [`@owlmeans/client-context`](../client-context) — the client context and `primaryHost` / `primaryPort`
|
|
108
|
+
- [`@owlmeans/web-panel`](../web-panel) — a panel factory that already wires this package
|
|
39
109
|
|
|
40
110
|
<!-- owlmeans:agent-guidance:start -->
|
|
41
111
|
## Agent guidance
|
|
@@ -45,7 +115,7 @@ This package ships embedded agent skills under `agent-meta/`. After installing y
|
|
|
45
115
|
your project's skill store (`.agents/skills/`):
|
|
46
116
|
|
|
47
117
|
```sh
|
|
48
|
-
npx @owlmeans/agent-skills
|
|
118
|
+
npx @owlmeans/agent-skills@^0.1.18-rc.57
|
|
49
119
|
```
|
|
50
120
|
|
|
51
121
|
The embedded files are version-matched to this package release. Do not edit them
|
package/agent-meta/manifest.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
-
"schemaVersion":
|
|
2
|
+
"schemaVersion": 3,
|
|
3
3
|
"package": "@owlmeans/api-config-client",
|
|
4
|
-
"version": "0.1.18-rc.
|
|
5
|
-
"generatedAt": "2026-
|
|
4
|
+
"version": "0.1.18-rc.50",
|
|
5
|
+
"generatedAt": "2026-10-20T23:19:58.630Z",
|
|
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 —
|
|
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.
|
|
11
|
+
**Install:** `"@owlmeans/api-config-client": "^0.1.18-rc.50"` 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` |
|
|
18
|
-
| `
|
|
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 {
|
|
24
|
-
|
|
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
|
-
|
|
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 @@
|
|
|
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
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,
|
|
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
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../src/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../src/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAYnD,eAAO,MAAM,mBAAmB,EAAE,UAsBjC,CAAA"}
|
package/build/middleware.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { MiddlewareType, MiddlewareStage, assertContext } from '@owlmeans/context';
|
|
2
2
|
import { API_CONFIG } from '@owlmeans/api-config';
|
|
3
|
-
import {
|
|
3
|
+
import { configHelper } from '@owlmeans/config';
|
|
4
|
+
import { logger } from '@owlmeans/log';
|
|
5
|
+
const log = logger('api-config-client');
|
|
4
6
|
export const apiConfigMiddleware = {
|
|
5
7
|
type: MiddlewareType.Context,
|
|
6
8
|
stage: MiddlewareStage.Loading,
|
|
@@ -13,12 +15,12 @@ export const apiConfigMiddleware = {
|
|
|
13
15
|
module.route.route.port = context.cfg.primaryPort;
|
|
14
16
|
}
|
|
15
17
|
try {
|
|
16
|
-
const
|
|
18
|
+
const config = await module.call();
|
|
17
19
|
const target = context.cfg;
|
|
18
|
-
mergeConfig(target, config);
|
|
20
|
+
configHelper.mergeConfig(target, config);
|
|
19
21
|
}
|
|
20
22
|
catch (e) {
|
|
21
|
-
|
|
23
|
+
log.warn('API config not loaded', e);
|
|
22
24
|
}
|
|
23
25
|
}
|
|
24
26
|
}
|
package/build/middleware.js.map
CHANGED
|
@@ -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,
|
|
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,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAG/C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAEtC,MAAM,GAAG,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAA;AAEvC,MAAM,CAAC,MAAM,mBAAmB,GAAe;IAC7C,IAAI,EAAE,cAAc,CAAC,OAAO;IAC5B,KAAK,EAAE,eAAe,CAAC,OAAO;IAC9B,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;QACnB,MAAM,OAAO,GAAG,aAAa,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,YAAY,CAAC,WAAW,CAAC,MAAM,EAAE,MAAsB,CAAC,CAAA;YAC1D,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,GAAG,CAAC,IAAI,CAAC,uBAAuB,EAAE,CAAC,CAAC,CAAA;YACtC,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
|
+
"version": "0.1.18-rc.50",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -21,10 +21,11 @@
|
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@owlmeans/api-config": "^0.1.18-rc.
|
|
25
|
-
"@owlmeans/client-context": "^0.1.18-rc.
|
|
26
|
-
"@owlmeans/client-entrypoint": "^0.1.18-rc.
|
|
27
|
-
"@owlmeans/context": "^0.1.18-rc.
|
|
24
|
+
"@owlmeans/api-config": "^0.1.18-rc.44",
|
|
25
|
+
"@owlmeans/client-context": "^0.1.18-rc.53",
|
|
26
|
+
"@owlmeans/client-entrypoint": "^0.1.18-rc.52",
|
|
27
|
+
"@owlmeans/context": "^0.1.18-rc.35",
|
|
28
|
+
"@owlmeans/log": "^0.1.18-rc.4"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|
|
30
31
|
"@owlmeans/dep-config": "workspace:*",
|
package/src/index.ts
CHANGED
package/src/middleware.ts
CHANGED
|
@@ -3,9 +3,12 @@ import { MiddlewareType, MiddlewareStage, assertContext } from '@owlmeans/contex
|
|
|
3
3
|
import type { ClientEntrypoint } from '@owlmeans/client-entrypoint'
|
|
4
4
|
import type { ApiConfig } from '@owlmeans/api-config'
|
|
5
5
|
import { API_CONFIG } from '@owlmeans/api-config'
|
|
6
|
-
import {
|
|
6
|
+
import { configHelper } from '@owlmeans/config'
|
|
7
7
|
import type { CommonConfig } from '@owlmeans/config'
|
|
8
8
|
import type { ClientContext, ClientConfig } from '@owlmeans/client-context'
|
|
9
|
+
import { logger } from '@owlmeans/log'
|
|
10
|
+
|
|
11
|
+
const log = logger('api-config-client')
|
|
9
12
|
|
|
10
13
|
export const apiConfigMiddleware: Middleware = {
|
|
11
14
|
type: MiddlewareType.Context,
|
|
@@ -21,11 +24,11 @@ export const apiConfigMiddleware: Middleware = {
|
|
|
21
24
|
module.route.route.port = context.cfg.primaryPort
|
|
22
25
|
}
|
|
23
26
|
try {
|
|
24
|
-
const
|
|
27
|
+
const config = await module.call()
|
|
25
28
|
const target: CommonConfig = context.cfg as unknown as CommonConfig
|
|
26
|
-
mergeConfig(target, config as CommonConfig)
|
|
29
|
+
configHelper.mergeConfig(target, config as CommonConfig)
|
|
27
30
|
} catch (e) {
|
|
28
|
-
|
|
31
|
+
log.warn('API config not loaded', e)
|
|
29
32
|
}
|
|
30
33
|
}
|
|
31
34
|
}
|
package/build/.gitkeep
DELETED
|
File without changes
|
package/build/modules.d.ts
DELETED
package/build/modules.d.ts.map
DELETED
|
@@ -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
package/build/modules.js.map
DELETED
|
@@ -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"}
|