@owlmeans/api 0.1.18-rc.10 → 0.1.18-rc.11
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 +2 -2
- package/agent-meta/manifest.json +2 -2
- package/agent-meta/skills/api/SKILL.md +33 -10
- package/build/errors.d.ts.map +1 -1
- package/build/errors.js.map +1 -1
- package/build/service.d.ts.map +1 -1
- package/build/service.js +4 -6
- package/build/service.js.map +1 -1
- package/build/utils/handler.d.ts.map +1 -1
- package/package.json +9 -9
- package/src/service.ts +7 -6
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @owlmeans/api
|
|
2
2
|
|
|
3
|
-
HTTP API client service for OwlMeans client contexts —
|
|
3
|
+
HTTP API client service for OwlMeans client contexts — carries entrypoint calls with auth token injection.
|
|
4
4
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
@@ -54,7 +54,7 @@ Registers the API client in the context.
|
|
|
54
54
|
|
|
55
55
|
## Related Packages
|
|
56
56
|
|
|
57
|
-
- [`@owlmeans/client-
|
|
57
|
+
- [`@owlmeans/client-entrypoint`](../client-entrypoint) — `ClientEntrypoint<T>` uses this service to make requests
|
|
58
58
|
- [`@owlmeans/web-client`](../web-client) — registers this service via `makeContext`
|
|
59
59
|
|
|
60
60
|
<!-- owlmeans:agent-guidance:start -->
|
package/agent-meta/manifest.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 2,
|
|
3
3
|
"package": "@owlmeans/api",
|
|
4
|
-
"version": "0.1.18-rc.
|
|
5
|
-
"generatedAt": "2026-09-
|
|
4
|
+
"version": "0.1.18-rc.11",
|
|
5
|
+
"generatedAt": "2026-09-01T16:28:56.999Z",
|
|
6
6
|
"canonicalRepo": "https://github.com/owlmeans/common",
|
|
7
7
|
"entries": [
|
|
8
8
|
{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: api
|
|
3
|
-
description: How to use @owlmeans/api — HTTP client service
|
|
3
|
+
description: How to use @owlmeans/api — the axios-based HTTP client service that carries entrypoint calls between services. Auto-invoked when importing the API client or when ctx.entrypoint(...).call() under the hood is involved.
|
|
4
4
|
user-invocable: false
|
|
5
5
|
---
|
|
6
6
|
<!-- AUTO-GENERATED — do not edit. Regenerate via sync-agent-meta. -->
|
|
@@ -8,28 +8,51 @@ user-invocable: false
|
|
|
8
8
|
# @owlmeans/api
|
|
9
9
|
|
|
10
10
|
**Layer:** Core
|
|
11
|
-
**Install:** `"@owlmeans/api": "^0.1.18-rc.
|
|
11
|
+
**Install:** `"@owlmeans/api": "^0.1.18-rc.11"` in `dependencies`
|
|
12
12
|
|
|
13
13
|
## Key Exports
|
|
14
14
|
|
|
15
15
|
| Export | Description |
|
|
16
16
|
|--------|-------------|
|
|
17
|
-
| `
|
|
18
|
-
| `
|
|
19
|
-
|
|
|
20
|
-
|
|
|
17
|
+
| `createApiService(alias?)` | Factory for the HTTP client service (axios) |
|
|
18
|
+
| `appendApiClient(ctx, alias?)` | Register it and make it the context's default `webService` |
|
|
19
|
+
| `ApiClient` | Service interface — a single `handler(req, reply)` |
|
|
20
|
+
| `ApiError`, `ApiClientError`, `ServerCrashedError`, `ServerAuthError` | Typed transport errors |
|
|
21
|
+
| Constants | Status codes (`OK`, `CREATED`, `ACCEPTED`, `FINISHED`, `UNAUTHORIZED_ERROR`, `FORBIDDEN_ERROR`, `SERVER_ERROR`), `DEFAULT_ALIAS` (`web-client`) |
|
|
22
|
+
|
|
23
|
+
## How a call is carried
|
|
24
|
+
|
|
25
|
+
`ep.call(...)` / `ep.invoke(...)` hand the request to whatever is bound to the route's protocol. When
|
|
26
|
+
a transport service is registered under `transportAlias(protocol)` it takes the call; otherwise this
|
|
27
|
+
package's client does, over HTTP. Either way the consumer writes the same line and never learns which
|
|
28
|
+
one ran.
|
|
29
|
+
|
|
30
|
+
When it is this client, the entrypoint answers where it lives — `path()` for the path, `address()` for
|
|
31
|
+
host, port, base, protocol and whether the hop is TLS — and `makeSecurityHelper` assembles the URL from
|
|
32
|
+
that. A per-request `host`, `base` or `unsecure` still overrides it. `:params` come from
|
|
33
|
+
`request.params` and a missing one is a `SyntaxError`, not a literal `:id` in the URL.
|
|
34
|
+
|
|
35
|
+
Replies map by status: 200/202 resolve with an outcome, 201/204 resolve with the body or the response
|
|
36
|
+
headers when the body is empty, and anything else rejects — a text body is rehydrated into the original
|
|
37
|
+
`ResilientError`, otherwise it becomes `ServerCrashedError` (500), `ServerAuthError` (401) or
|
|
38
|
+
`ApiClientError` (403 and the rest).
|
|
39
|
+
|
|
40
|
+
Building a URL without making the call is a different question — that is `entrypointUrl` from
|
|
41
|
+
`@owlmeans/client-entrypoint/utils`, or `ep.url(req, { absolute })`.
|
|
21
42
|
|
|
22
43
|
## Usage
|
|
23
44
|
|
|
24
|
-
|
|
45
|
+
Most apps don't import this directly — they register it once in their context factory:
|
|
25
46
|
|
|
26
47
|
```typescript
|
|
27
|
-
import {
|
|
28
|
-
context
|
|
48
|
+
import { appendApiClient } from '@owlmeans/api'
|
|
49
|
+
appendApiClient(context)
|
|
29
50
|
```
|
|
30
51
|
|
|
31
52
|
## Depends On
|
|
32
53
|
|
|
33
54
|
- `@owlmeans/context` — service registration
|
|
55
|
+
- `@owlmeans/entrypoint` — the entrypoint being addressed, `@owlmeans/client-route` — `extractParams`
|
|
56
|
+
- `@owlmeans/config` — `makeSecurityHelper`
|
|
34
57
|
- `@owlmeans/error`, `@owlmeans/i18n`
|
|
35
|
-
- `axios` (runtime)
|
|
58
|
+
- `axios`, `qs` (runtime)
|
package/build/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAEhD,qBAAa,QAAS,SAAQ,cAAc;IAC1C,OAAuB,QAAQ,SAAa;
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAEhD,qBAAa,QAAS,SAAQ,cAAc;IAC1C,OAAuB,QAAQ,SAAa;gBAEhC,OAAO,GAAE,MAAgB;CAGtC;AAED,qBAAa,cAAe,SAAQ,QAAQ;IAC1C,OAAuB,QAAQ,SAAmB;gBAEtC,OAAO,GAAE,MAAgB;CAItC;AAED,qBAAa,kBAAmB,SAAQ,cAAc;IACpD,OAAuB,QAAQ,SAA4C;gBAE/D,OAAO,GAAE,MAAgB;CAItC;AAED,qBAAa,eAAgB,SAAQ,cAAc;IACjD,OAAuB,QAAQ,SAAyC;gBAE5D,OAAO,GAAE,MAAgB;CAItC"}
|
package/build/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAEhD,MAAM,OAAO,QAAS,SAAQ,cAAc;IACnC,MAAM,CAAU,QAAQ,GAAG,UAAU,CAAA;IAE5C,YAAY,
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAEhD,MAAM,OAAO,QAAS,SAAQ,cAAc;IACnC,MAAM,CAAU,QAAQ,GAAG,UAAU,CAAA;IAE5C,YAAY,UAAkB,OAAO;QACnC,KAAK,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,OAAO,EAAE,CAAC,CAAA;IAC5C,CAAC;;AAGH,MAAM,OAAO,cAAe,SAAQ,QAAQ;IACnC,MAAM,CAAU,QAAQ,GAAG,gBAAgB,CAAA;IAElD,YAAY,UAAkB,OAAO;QACnC,KAAK,CAAC,UAAU,OAAO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AO,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAErD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAM3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAO3D,KAAK,MAAM,GAAG,iBAAiB,CAAA;AAE/B,UAAU,OAAO,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,CAAE,SAAQ,YAAY,CAAC,CAAC,CAAC;CACnE;AAED,eAAO,MAAM,gBAAgB,GAAI,QAAO,MAAsB,KAAG,SA6EhE,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,OAAO,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,QAAO,MAAsB,KAAG,CAU/G,CAAA"}
|
package/build/service.js
CHANGED
|
@@ -16,9 +16,8 @@ export const createApiService = (alias = DEFAULT_ALIAS) => {
|
|
|
16
16
|
}
|
|
17
17
|
const context = assertContext(client.ctx, location);
|
|
18
18
|
const module = context.entrypoint(request.alias);
|
|
19
|
-
await module.resolve();
|
|
20
19
|
const route = module.route.route;
|
|
21
|
-
let path = module.
|
|
20
|
+
let path = module.path();
|
|
22
21
|
const params = extractParams(path);
|
|
23
22
|
path = params.reduce((path, param) => {
|
|
24
23
|
if (request.params[param] == null) {
|
|
@@ -26,11 +25,10 @@ export const createApiService = (alias = DEFAULT_ALIAS) => {
|
|
|
26
25
|
}
|
|
27
26
|
return path.replace(`:${param}`, `${request.params[param]}`);
|
|
28
27
|
}, path);
|
|
29
|
-
if (route.host == null && request.host == null) {
|
|
30
|
-
throw new SyntaxError(`No host provided in ${module.alias} route`);
|
|
31
|
-
}
|
|
32
28
|
const helper = makeSecurityHelper(context);
|
|
33
|
-
|
|
29
|
+
// The entrypoint answers where it lives — host, port, base, protocol and whether the hop is
|
|
30
|
+
// TLS — from its declaration and the service it names. A per-request host still overrides it.
|
|
31
|
+
const url = helper.makeUrl(module.address(), path, { host: request.host, base: request.base, forceUnsecure: request.unsecure });
|
|
34
32
|
let transformer = undefined;
|
|
35
33
|
let body = request.body != null && Object.entries((request.headers ?? {})).find(([key, value]) => key.toLowerCase() === 'content-type' && value?.includes('application/x-www-form-urlencoded')) ? qs.stringify(request.body) : request.body;
|
|
36
34
|
// @TODO Probably this hack needs to be made a little bit less dirty
|
package/build/service.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAEhE,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAEtD,OAAO,KAAuB,MAAM,OAAO,CAAA;AAG3C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAEpD,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAQlE,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAEhE,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAEtD,OAAO,KAAuB,MAAM,OAAO,CAAA;AAG3C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,eAAe,E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AgB,aAAa,EAAK,EAAE;IAClH,MAAM,OAAO,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAA;IAEvC,GAAG,CAAC,eAAe,CAAC,OAAO,CAAC,CAAA;IAE5B,IAAI,GAAG,CAAC,GAAG,CAAC,UAAU,IAAI,IAAI,EAAE,CAAC;QAC/B,GAAG,CAAC,GAAG,CAAC,UAAU,GAAG,KAAK,CAAA;IAC5B,CAAC;IAED,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/utils/handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAE5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAK1C,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/utils/handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAE5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAK1C,eAAO,MAAM,eAAe,GAAI,UAAU,aAAa,EAAE,OAAO,gBAAgB,CAAC,GAAG,CAAC,SAyCpF,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@owlmeans/api",
|
|
3
|
-
"version": "0.1.18-rc.
|
|
3
|
+
"version": "0.1.18-rc.11",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -21,14 +21,14 @@
|
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@owlmeans/auth-common": "^0.1.18-rc.
|
|
25
|
-
"@owlmeans/client-config": "^0.1.18-rc.
|
|
26
|
-
"@owlmeans/client-route": "^0.1.18-rc.
|
|
27
|
-
"@owlmeans/config": "^0.1.18-rc.
|
|
28
|
-
"@owlmeans/context": "^0.1.18-rc.
|
|
29
|
-
"@owlmeans/error": "^0.1.18-rc.
|
|
30
|
-
"@owlmeans/entrypoint": "^0.1.18-rc.
|
|
31
|
-
"@owlmeans/route": "^0.1.18-rc.
|
|
24
|
+
"@owlmeans/auth-common": "^0.1.18-rc.11",
|
|
25
|
+
"@owlmeans/client-config": "^0.1.18-rc.10",
|
|
26
|
+
"@owlmeans/client-route": "^0.1.18-rc.11",
|
|
27
|
+
"@owlmeans/config": "^0.1.18-rc.10",
|
|
28
|
+
"@owlmeans/context": "^0.1.18-rc.7",
|
|
29
|
+
"@owlmeans/error": "^0.1.18-rc.7",
|
|
30
|
+
"@owlmeans/entrypoint": "^0.1.18-rc.9",
|
|
31
|
+
"@owlmeans/route": "^0.1.18-rc.7",
|
|
32
32
|
"axios": "^1.7.7",
|
|
33
33
|
"qs": "^6.13.0"
|
|
34
34
|
},
|
package/src/service.ts
CHANGED
|
@@ -28,9 +28,8 @@ export const createApiService = (alias: string = DEFAULT_ALIAS): ApiClient => {
|
|
|
28
28
|
}
|
|
29
29
|
const context = assertContext<Config, Context>(client.ctx, location)
|
|
30
30
|
const module = context.entrypoint<CommonEntrypoint>(request.alias)
|
|
31
|
-
await module.resolve()
|
|
32
31
|
const route = module.route.route
|
|
33
|
-
let path = module.
|
|
32
|
+
let path = module.path()
|
|
34
33
|
const params = extractParams(path)
|
|
35
34
|
path = params.reduce((path, param) => {
|
|
36
35
|
type Key = keyof typeof request.params
|
|
@@ -39,13 +38,15 @@ export const createApiService = (alias: string = DEFAULT_ALIAS): ApiClient => {
|
|
|
39
38
|
}
|
|
40
39
|
return path.replace(`:${param}`, `${request.params[param as Key]}`)
|
|
41
40
|
}, path)
|
|
42
|
-
if (route.host == null && request.host == null) {
|
|
43
|
-
throw new SyntaxError(`No host provided in ${module.alias} route`)
|
|
44
|
-
}
|
|
45
41
|
|
|
46
42
|
const helper = makeSecurityHelper(context)
|
|
47
43
|
|
|
48
|
-
|
|
44
|
+
// The entrypoint answers where it lives — host, port, base, protocol and whether the hop is
|
|
45
|
+
// TLS — from its declaration and the service it names. A per-request host still overrides it.
|
|
46
|
+
const url = helper.makeUrl(
|
|
47
|
+
module.address(), path,
|
|
48
|
+
{ host: request.host, base: request.base, forceUnsecure: request.unsecure }
|
|
49
|
+
)
|
|
49
50
|
|
|
50
51
|
let transformer: AxiosRequestTransformer | undefined = undefined
|
|
51
52
|
|