@odg/message 1.18.0 → 1.19.0
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/agents.md +18 -31
- package/package.json +11 -11
package/agents.md
CHANGED
|
@@ -1,39 +1,26 @@
|
|
|
1
1
|
# ODG Message - Consumer Guide
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Use this file as the package-level source of truth for AI agents and developers integrating `@odg/message`.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
- Permitir que apps consumam uma implementação própria via `MessageInterface`.
|
|
7
|
-
- Fornecer tipos de erro e type guards unificados para tratamento de falhas.
|
|
5
|
+
## Purpose
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
- Standardize TypeScript request/response contracts for HTTP or messaging clients.
|
|
8
|
+
- Allow applications to plug in their own implementation through `MessageInterface`.
|
|
9
|
+
- Example plug in `AxiosMessage` in `@odg/axios` to message with axios package.
|
|
10
|
+
- Provide unified exceptions and type guards for safe error handling.
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
- Contrato central: `MessageInterface<RequestData, ResponseData>` com `request`, `interceptors`, `getDefaultOptions`, `setDefaultOptions`.
|
|
13
|
-
- Request: `RequestInterface`, `RequestOptionsParametersInterface`, `ParametersInterface`, `ProxyConfigInterface`.
|
|
14
|
-
- Response: `ResponseInterface`, `ResponseType`, `HttpHeadersInterface`, `MessageResponse`.
|
|
15
|
-
- Interceptors: `InterceptorsInterface`, `InterceptorManager`, `onFulfilledType`, `onRejectedType`.
|
|
16
|
-
- DNS cache opcional: `CacheableLookupConfig`, `LookupCacheType`, `LookupKeyType`, `LookupPromiseResult`.
|
|
12
|
+
## Integration/Review Rules
|
|
17
13
|
|
|
18
|
-
|
|
14
|
+
- All messages is typed with `MessageInterface<Req, Res>`
|
|
15
|
+
- In `RequestInterface<RequestData>`:
|
|
16
|
+
- `RequestInterface.method` **MUST** use `Methods` enum when available, **MAY** use `string` for non-standard/custom verbs.
|
|
17
|
+
- `RequestInterface.baseUrl` **MUST** be domain-only and **MUST NOT** include a `/` at the end.
|
|
18
|
+
- `RequestInterface.url` **MUST** be a path that starts with `/` and represents the endpoint path to call.
|
|
19
|
+
- Interceptor IDs returned by `use(...)` **MUST** be stored when lifecycle cleanup is needed, then removed with `eject(id)`.
|
|
20
|
+
- Unknown types **MUST** be narrowed with `ODGMessage.isMessage(...)` or `ODGMessage.isMessageError(...)` before accessing message-specific fields, **MUST NOT** use instanceof.
|
|
19
21
|
|
|
20
|
-
|
|
21
|
-
- Tipar chamadas com `MessageInterface<Req, Res>` e `RequestInterface<Req>`.
|
|
22
|
-
- Usar `Methods` para padronizar verbos HTTP no campo `method`.
|
|
23
|
-
- Em interceptors, persistir o id retornado por `use(...)` para remoção com `eject(id)`.
|
|
24
|
-
- Para tratamento seguro de `unknown`, usar `ODGMessage.isMessage(...)` ou `ODGMessage.isMessageError(...)`.
|
|
25
|
-
- Ao usar `CacheableLookup`, fornecer uma implementação compatível com `CacheInterface<LookupCacheType>`.
|
|
22
|
+
## Known Integration Pitfalls
|
|
26
23
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
- `
|
|
30
|
-
- `MessageUnknownException<RequestData, ResponseData>`: erro não mapeado conhecido pela camada de mensagem, com mesma estrutura de contexto.
|
|
31
|
-
- Quando há `request` e `response`, ambas oferecem `getMessage(): MessageResponse | undefined`.
|
|
32
|
-
- Tratamento recomendado: capturar `unknown`, validar com `ODGMessage.isMessageError`, então usar `message`, `code` e `getMessage()` quando disponível.
|
|
33
|
-
|
|
34
|
-
## ⚠️ Integration Pitfalls
|
|
35
|
-
|
|
36
|
-
- `getMessageResponse()` nas exceptions retorna `MessageResponse` opcional caso não tenha `request` ou `response`.
|
|
37
|
-
- `method` aceita `Methods | string`; valores fora do padrão podem passar na tipagem e falhar no cliente concreto.
|
|
38
|
-
- `RequestInterface` possui campos opcionais amplos; dependências de validação ficam no implementador concreto.
|
|
39
|
-
- `CacheableLookup` depende de `@odg/cache`; exceptions dependem de `@odg/exception` quando esses recursos forem usados.
|
|
24
|
+
- `getMessageResponse()` can be `undefined` when `request` or `response` is absent.
|
|
25
|
+
- `RequestInterface` is intentionally flexible; concrete clients **SHOULD** validate required fields.
|
|
26
|
+
- `CacheableLookup` depends on `@odg/cache`; exception flows depend on `@odg/exception` when those features are used.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@odg/message",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.19.0",
|
|
4
4
|
"description": "Interface request fo inversion of control",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -36,25 +36,25 @@
|
|
|
36
36
|
"author": "Dragons Gamers <https://www.linkedin.com/in/victor-alves-odgodinho>",
|
|
37
37
|
"license": "MIT",
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@odg/eslint-config": "^3.
|
|
39
|
+
"@odg/eslint-config": "^3.9.0",
|
|
40
40
|
"@odg/tsconfig": "^1.5.0",
|
|
41
41
|
"@types/node": ">=24",
|
|
42
|
-
"@vitest/coverage-istanbul": "^4.1.
|
|
43
|
-
"concurrently": "^10.0.
|
|
42
|
+
"@vitest/coverage-istanbul": "^4.1.8",
|
|
43
|
+
"concurrently": "^10.0.3",
|
|
44
44
|
"rimraf": "^6.1.3",
|
|
45
45
|
"tsc-alias": "^1.8.17",
|
|
46
|
-
"tsx": "^4.22.
|
|
46
|
+
"tsx": "^4.22.4",
|
|
47
47
|
"typescript": "^6.0.3",
|
|
48
|
-
"vite": "^8.0.
|
|
49
|
-
"vitest": "^4.1.
|
|
48
|
+
"vite": "^8.0.16",
|
|
49
|
+
"vitest": "^4.1.8"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@odg/cache": "^1.
|
|
53
|
-
"@odg/exception": "^1.
|
|
52
|
+
"@odg/cache": "^1.8.0",
|
|
53
|
+
"@odg/exception": "^1.15.0"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@odg/cache": "^1.
|
|
57
|
-
"@odg/exception": "^1.
|
|
56
|
+
"@odg/cache": "^1.8.0",
|
|
57
|
+
"@odg/exception": "^1.15.0"
|
|
58
58
|
},
|
|
59
59
|
"peerDependenciesMeta": {
|
|
60
60
|
"@odg/cache": {
|