@owlmeans/api 0.1.18-rc.48 → 0.1.18-rc.49
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
|
@@ -12,7 +12,7 @@ HTTP API client service for OwlMeans client contexts — carries entrypoint call
|
|
|
12
12
|
## Installation
|
|
13
13
|
|
|
14
14
|
```bash
|
|
15
|
-
bun add @owlmeans/api@^0.1.18-rc.
|
|
15
|
+
bun add @owlmeans/api@^0.1.18-rc.49
|
|
16
16
|
```
|
|
17
17
|
|
|
18
18
|
## Usage
|
|
@@ -73,7 +73,7 @@ This package ships embedded agent skills under `agent-meta/`. After installing y
|
|
|
73
73
|
your project's skill store (`.agents/skills/`):
|
|
74
74
|
|
|
75
75
|
```sh
|
|
76
|
-
npx @owlmeans/agent-skills@^0.1.18-rc.
|
|
76
|
+
npx @owlmeans/agent-skills@^0.1.18-rc.52
|
|
77
77
|
```
|
|
78
78
|
|
|
79
79
|
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
2
|
"schemaVersion": 2,
|
|
3
3
|
"package": "@owlmeans/api",
|
|
4
|
-
"version": "0.1.18-rc.
|
|
5
|
-
"generatedAt": "2026-10-
|
|
4
|
+
"version": "0.1.18-rc.49",
|
|
5
|
+
"generatedAt": "2026-10-08T21:27:54.324Z",
|
|
6
6
|
"canonicalRepo": "https://github.com/owlmeans/common",
|
|
7
7
|
"entries": [
|
|
8
8
|
{
|
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.49",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -29,14 +29,14 @@
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@owlmeans/auth-common": "^0.1.18-rc.
|
|
33
|
-
"@owlmeans/client-config": "^0.1.18-rc.
|
|
34
|
-
"@owlmeans/client-route": "^0.1.18-rc.
|
|
32
|
+
"@owlmeans/auth-common": "^0.1.18-rc.49",
|
|
33
|
+
"@owlmeans/client-config": "^0.1.18-rc.45",
|
|
34
|
+
"@owlmeans/client-route": "^0.1.18-rc.50",
|
|
35
35
|
"@owlmeans/config": "^0.1.18-rc.44",
|
|
36
36
|
"@owlmeans/context": "^0.1.18-rc.34",
|
|
37
37
|
"@owlmeans/entrypoint": "^0.1.18-rc.41",
|
|
38
38
|
"@owlmeans/error": "^0.1.18-rc.38",
|
|
39
|
-
"@owlmeans/log": "^0.1.18-rc.
|
|
39
|
+
"@owlmeans/log": "^0.1.18-rc.3",
|
|
40
40
|
"@owlmeans/route": "^0.1.18-rc.35",
|
|
41
41
|
"axios": "^1.20.0",
|
|
42
42
|
"qs": "^6.16.0"
|
package/build/utils/handler.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { AbstractResponse } from '@owlmeans/entrypoint';
|
|
2
|
-
import type { AxiosResponse } from 'axios';
|
|
3
|
-
import { ApiClientError } from '../errors.js';
|
|
4
|
-
export declare const processResponse: (response: AxiosResponse, reply: AbstractResponse<any>) => void;
|
|
5
|
-
/**
|
|
6
|
-
* The typed error of a bare status: `ServerCrashedError` (500), `ServerAuthError` (401),
|
|
7
|
-
* `ApiClientError('forbidden[:<id>]')` (403), `ApiStatusError` (`api:client:status:<n>[:<id>]`)
|
|
8
|
-
* for every other one.
|
|
9
|
-
*/
|
|
10
|
-
export declare const statusError: (status: number, incidentId?: string) => ApiClientError;
|
|
11
|
-
//# sourceMappingURL=handler.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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;AAM1C,OAAO,EAAE,cAAc,EAAuD,MAAM,cAAc,CAAA;AAOlG,eAAO,MAAM,eAAe,aAAc,aAAa,SAAS,gBAAgB,CAAC,GAAG,CAAC,SAqBpF,CAAA;AAkCD;;;;GAIG;AACH,eAAO,MAAM,WAAW,WAAY,MAAM,eAAe,MAAM,KAAG,cAUjE,CAAA"}
|
package/build/utils/handler.js
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { EntrypointOutcome } from '@owlmeans/entrypoint';
|
|
2
|
-
import { ACCEPTED, CREATED, FINISHED, FORBIDDEN_ERROR, INCIDENT_ID_HEADER, DENIAL_KIND_HEADER, ACCESS_DENIED_KIND, OK, SERVER_ERROR, UNAUTHORIZED_ERROR, } from '../consts.js';
|
|
3
|
-
import { ResilientError } from '@owlmeans/error';
|
|
4
|
-
import { ApiClientError, ApiStatusError, ServerAuthError, ServerCrashedError } from '../errors.js';
|
|
5
|
-
import { isIncidentBody } from '../status/index.js';
|
|
6
|
-
import { logger } from '@owlmeans/log';
|
|
7
|
-
const log = logger('api');
|
|
8
|
-
export const processResponse = (response, reply) => {
|
|
9
|
-
switch (response.status) {
|
|
10
|
-
case OK:
|
|
11
|
-
reply.resolve(response.data, EntrypointOutcome.Ok);
|
|
12
|
-
return;
|
|
13
|
-
case ACCEPTED:
|
|
14
|
-
reply.resolve(response.data, EntrypointOutcome.Accepted);
|
|
15
|
-
return;
|
|
16
|
-
case CREATED:
|
|
17
|
-
return processEmptyResponse(response, reply, EntrypointOutcome.Created);
|
|
18
|
-
case FINISHED:
|
|
19
|
-
return processEmptyResponse(response, reply, EntrypointOutcome.Finished);
|
|
20
|
-
default:
|
|
21
|
-
// A refusal is ordinary traffic (401, 403, 409, 428): debug, and never the headers.
|
|
22
|
-
log.debug('Request answered with a failure', {
|
|
23
|
-
status: response.status, statusText: response.statusText, url: response.config?.url,
|
|
24
|
-
incidentId: headerOf(response.headers, INCIDENT_ID_HEADER),
|
|
25
|
-
});
|
|
26
|
-
reply.reject(failureOf(response));
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* The error a non-2xx answer rejects with — always carrying the HTTP status and, when the server
|
|
31
|
-
* sent one, its incident id.
|
|
32
|
-
*
|
|
33
|
-
* A development body is the marshaled `ResilientError`: it is rebuilt into its own class and
|
|
34
|
-
* stamped with `responseStatus`. Anything else — the bare incident id of a production body, a
|
|
35
|
-
* proxy's HTML, a framework's JSON — becomes the status error of {@link statusError}.
|
|
36
|
-
*/
|
|
37
|
-
const failureOf = (response) => {
|
|
38
|
-
const incidentId = headerOf(response.headers, INCIDENT_ID_HEADER)
|
|
39
|
-
?? (isIncidentBody(response.data) ? response.data.trim() : undefined);
|
|
40
|
-
const denialKind = response.status === FORBIDDEN_ERROR
|
|
41
|
-
&& headerOf(response.headers, DENIAL_KIND_HEADER) === ACCESS_DENIED_KIND
|
|
42
|
-
? ACCESS_DENIED_KIND : undefined;
|
|
43
|
-
if (typeof response.data === 'string' && response.data.includes(ResilientError.separator)) {
|
|
44
|
-
try {
|
|
45
|
-
const error = ResilientError.ensure(response.data, true);
|
|
46
|
-
error.incidentId ??= incidentId;
|
|
47
|
-
Object.assign(error, {
|
|
48
|
-
responseStatus: response.status, denialKind,
|
|
49
|
-
});
|
|
50
|
-
return error;
|
|
51
|
-
}
|
|
52
|
-
catch {
|
|
53
|
-
log.warn('Server returned an unrecognizable text error', { status: response.status, body: response.data });
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return Object.assign(statusError(response.status, incidentId), { denialKind });
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* The typed error of a bare status: `ServerCrashedError` (500), `ServerAuthError` (401),
|
|
60
|
-
* `ApiClientError('forbidden[:<id>]')` (403), `ApiStatusError` (`api:client:status:<n>[:<id>]`)
|
|
61
|
-
* for every other one.
|
|
62
|
-
*/
|
|
63
|
-
export const statusError = (status, incidentId) => {
|
|
64
|
-
const error = status === SERVER_ERROR ? new ServerCrashedError(incidentId)
|
|
65
|
-
: status === UNAUTHORIZED_ERROR ? new ServerAuthError(incidentId)
|
|
66
|
-
: status === FORBIDDEN_ERROR ? new ApiClientError(incidentId != null ? `forbidden:${incidentId}` : 'forbidden')
|
|
67
|
-
: new ApiStatusError(status, incidentId);
|
|
68
|
-
if (incidentId != null) {
|
|
69
|
-
error.incidentId = incidentId;
|
|
70
|
-
}
|
|
71
|
-
return Object.assign(error, { responseStatus: status });
|
|
72
|
-
};
|
|
73
|
-
/** One response header, from an `AxiosHeaders` instance or a plain header object alike. */
|
|
74
|
-
const headerOf = (headers, name) => {
|
|
75
|
-
if (headers == null || typeof headers !== 'object') {
|
|
76
|
-
return undefined;
|
|
77
|
-
}
|
|
78
|
-
const get = headers.get;
|
|
79
|
-
const viaGet = typeof get === 'function' ? get.call(headers, name) : undefined;
|
|
80
|
-
const value = viaGet ?? Object.entries(headers).find(([key]) => key.toLowerCase() === name.toLowerCase())?.[1];
|
|
81
|
-
const first = Array.isArray(value) ? value[0] : value;
|
|
82
|
-
return typeof first === 'string' && first.trim() !== '' ? first.trim() : undefined;
|
|
83
|
-
};
|
|
84
|
-
const processEmptyResponse = (response, reply, outcome) => {
|
|
85
|
-
if (response.data != null && response.data != '') {
|
|
86
|
-
reply.resolve(response.data, outcome);
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
if (response.headers.toJSON != null && typeof response.headers.toJSON === 'function') {
|
|
90
|
-
reply.resolve(response.headers.toJSON(), outcome);
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
reply.resolve(response.headers, outcome);
|
|
94
|
-
};
|
|
95
|
-
//# sourceMappingURL=handler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../src/utils/handler.ts"],"names":[],"mappings":"AACA,O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