@procedures/client 0.17.4 → 0.18.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.
Files changed (40) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/adapters/http/client/transport.d.ts.map +1 -1
  4. package/dist/adapters/http/client/transport.js +9 -6
  5. package/dist/adapters/http/client/transport.js.map +1 -1
  6. package/dist/adapters/http/server/handler.d.ts.map +1 -1
  7. package/dist/adapters/http/server/handler.js +5 -23
  8. package/dist/adapters/http/server/handler.js.map +1 -1
  9. package/dist/adapters/http/server/transport.d.ts +2 -2
  10. package/dist/adapters/http/server/transport.js +2 -2
  11. package/dist/adapters/websocket/shared/rpc.d.ts.map +1 -1
  12. package/dist/adapters/websocket/shared/rpc.js +4 -2
  13. package/dist/adapters/websocket/shared/rpc.js.map +1 -1
  14. package/dist/client/middleware/items.d.ts.map +1 -1
  15. package/dist/client/middleware/items.js +2 -0
  16. package/dist/client/middleware/items.js.map +1 -1
  17. package/dist/protocol.d.ts.map +1 -1
  18. package/dist/protocol.js +24 -0
  19. package/dist/protocol.js.map +1 -1
  20. package/dist/server/browser-guard.d.ts +13 -3
  21. package/dist/server/browser-guard.d.ts.map +1 -1
  22. package/dist/server/browser-guard.js +11 -5
  23. package/dist/server/browser-guard.js.map +1 -1
  24. package/dist/server/server.d.ts.map +1 -1
  25. package/dist/server/server.js +3 -2
  26. package/dist/server/server.js.map +1 -1
  27. package/dist/server/types.d.ts +2 -1
  28. package/dist/server/types.d.ts.map +1 -1
  29. package/dist/server/types.js +3 -2
  30. package/dist/server/types.js.map +1 -1
  31. package/package.json +1 -1
  32. package/src/adapters/http/client/transport.ts +9 -6
  33. package/src/adapters/http/server/handler.ts +9 -28
  34. package/src/adapters/http/server/transport.ts +2 -2
  35. package/src/adapters/websocket/shared/rpc.ts +4 -2
  36. package/src/client/middleware/items.ts +2 -0
  37. package/src/protocol.ts +26 -0
  38. package/src/server/browser-guard.ts +27 -7
  39. package/src/server/server.ts +3 -2
  40. package/src/server/types.ts +3 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,49 @@
1
1
  # @procedures/client
2
2
 
3
+ ## 0.18.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 5e68b6a: Each face gives only the error codes of wire v1 (server stack CLI-4). The stray codes fold into `UNAVAILABLE`, `FORBIDDEN` and `INTERNAL_ERROR`. This change is a break of the server stack, thus it is its own MINOR (decision D13).
8
+
9
+ Before, `procedureHandler` gave the codes of wire v1, but other paths kept their former codes. `HttpServerTransport` answered `SERVER_STOPPED` after `stop()`. The browser checks gave `FORBIDDEN_HOST`, `FORBIDDEN_ORIGIN`, `METHOD_NOT_ALLOWED` (405) and `UNSUPPORTED_MEDIA_TYPE` (415). `Server` and `ServerError` gave the code `"500"`.
10
+
11
+ The behavior that changes:
12
+
13
+ | Former code | Former status | Code of wire v1 | Status | Reason |
14
+ |---|---|---|---|---|
15
+ | `SERVER_STOPPED` | 503 | `UNAVAILABLE` | 503 | — |
16
+ | `FORBIDDEN_HOST` | 403 | `FORBIDDEN` | 403 | `host-header-not-allowed` |
17
+ | `FORBIDDEN_ORIGIN` | 403 | `FORBIDDEN` | 403 | `origin-not-allowed` |
18
+ | `METHOD_NOT_ALLOWED` | 405 | `FORBIDDEN` | 403 | `method-not-allowed` |
19
+ | `UNSUPPORTED_MEDIA_TYPE` | 415 | `FORBIDDEN` | 403 | `media-type-not-allowed` |
20
+ | `"500"` | 500 | `INTERNAL_ERROR` | 500 | — |
21
+
22
+ - `HttpServerTransport` answers a request after `stop()` with `UNAVAILABLE` (503, retryable), as `procedureHandler` does. The message is "The server is stopping".
23
+ - `HttpServerTransport` refuses a browser request with `FORBIDDEN` (403) and the field `reason` in the body, as `procedureHandler` does. A `GET` without `allowGet` and a body that is not JSON get 403, not 405 or 415.
24
+ - `checkBrowserRequest()` gives `{ ok: false, status: 403, code: "FORBIDDEN", reason, message }`. The type `GuardResult` has the new field `reason`. The MCP endpoint of `@procedures/mcp-server` uses it, so its refusal has `data.code` `FORBIDDEN`.
25
+ - `Server` answers an error outside a handler with `INTERNAL_ERROR`. `new ServerError(message)` has the default code `INTERNAL_ERROR`.
26
+ - The message of the refusals of the method and of the body starts with "Forbidden:".
27
+
28
+ For one release, the client reads the former codes of an older server:
29
+
30
+ - `HttpTransport` and the WebSocket transports read `SERVER_STOPPED` as `UNAVAILABLE` and `"500"` as `INTERNAL_ERROR`.
31
+ - `HttpTransport` reads `FORBIDDEN_HOST` and `FORBIDDEN_ORIGIN` as `FORBIDDEN`, and sets the metadata key `reason`.
32
+ - `isAvailabilityFailure()` still counts `SERVER_STOPPED`.
33
+ - The client keeps `METHOD_NOT_ALLOWED` and `UNSUPPORTED_MEDIA_TYPE`. They are also the codes of the HTTP statuses 405 and 415 of each server.
34
+ - The next breaking release of the client group removes these aliases.
35
+
36
+ Migration steps:
37
+
38
+ - Code that matches `SERVER_STOPPED`: match `UNAVAILABLE`. The flag `retryable` stays true.
39
+ - Code that matches `FORBIDDEN_HOST` or `FORBIDDEN_ORIGIN`: match `FORBIDDEN`, then read `reason` (the body field, or the metadata key `reason`).
40
+ - Code that matches the status 405 or 415 of a procedure server: match the status 403 and the reasons `method-not-allowed` and `media-type-not-allowed`.
41
+ - Code that reads `GuardResult.code` of `checkBrowserRequest()`: read `reason`.
42
+ - Code that matches the code `"500"` or the default code of `ServerError`: match `INTERNAL_ERROR`.
43
+ - The site, MiniMongo, Graph and jarvis: no code of theirs matches a former code, so no change is necessary.
44
+ - MiniMongo: its dev server uses `HttpServerTransport`, and its answers change only as the table says.
45
+ - jarvis: its host uses `procedureHandler`, which gave the codes of wire v1 already.
46
+
3
47
  ## 0.17.4
4
48
 
5
49
  No changes in this release.