@procedures/client 0.17.4 → 0.18.1

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 (75) hide show
  1. package/CHANGELOG.md +77 -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/ndjson.d.ts +3 -1
  10. package/dist/adapters/http/server/ndjson.d.ts.map +1 -1
  11. package/dist/adapters/http/server/ndjson.js +3 -1
  12. package/dist/adapters/http/server/ndjson.js.map +1 -1
  13. package/dist/adapters/http/server/transport.d.ts +2 -2
  14. package/dist/adapters/http/server/transport.js +2 -2
  15. package/dist/adapters/websocket/shared/rpc.d.ts +5 -1
  16. package/dist/adapters/websocket/shared/rpc.d.ts.map +1 -1
  17. package/dist/adapters/websocket/shared/rpc.js +9 -3
  18. package/dist/adapters/websocket/shared/rpc.js.map +1 -1
  19. package/dist/browser.d.ts +1 -1
  20. package/dist/browser.d.ts.map +1 -1
  21. package/dist/browser.js +2 -0
  22. package/dist/browser.js.map +1 -1
  23. package/dist/client/middleware/items.d.ts.map +1 -1
  24. package/dist/client/middleware/items.js +2 -0
  25. package/dist/client/middleware/items.js.map +1 -1
  26. package/dist/procedures/collection/index.d.ts +1 -0
  27. package/dist/procedures/collection/index.d.ts.map +1 -1
  28. package/dist/procedures/collection/index.js +2 -0
  29. package/dist/procedures/collection/index.js.map +1 -1
  30. package/dist/procedures/collection/partition.d.ts +48 -0
  31. package/dist/procedures/collection/partition.d.ts.map +1 -1
  32. package/dist/procedures/collection/partition.js +66 -0
  33. package/dist/procedures/collection/partition.js.map +1 -1
  34. package/dist/procedures/collection/topic.d.ts +2 -0
  35. package/dist/procedures/collection/topic.d.ts.map +1 -1
  36. package/dist/procedures/collection/topic.js.map +1 -1
  37. package/dist/procedures/index.d.ts +1 -1
  38. package/dist/procedures/index.d.ts.map +1 -1
  39. package/dist/procedures/index.js +2 -0
  40. package/dist/procedures/index.js.map +1 -1
  41. package/dist/protocol.d.ts.map +1 -1
  42. package/dist/protocol.js +24 -0
  43. package/dist/protocol.js.map +1 -1
  44. package/dist/server/browser-guard.d.ts +13 -3
  45. package/dist/server/browser-guard.d.ts.map +1 -1
  46. package/dist/server/browser-guard.js +11 -5
  47. package/dist/server/browser-guard.js.map +1 -1
  48. package/dist/server/procedure-server.d.ts +24 -1
  49. package/dist/server/procedure-server.d.ts.map +1 -1
  50. package/dist/server/procedure-server.js +29 -1
  51. package/dist/server/procedure-server.js.map +1 -1
  52. package/dist/server/server.d.ts.map +1 -1
  53. package/dist/server/server.js +3 -2
  54. package/dist/server/server.js.map +1 -1
  55. package/dist/server/types.d.ts +2 -1
  56. package/dist/server/types.d.ts.map +1 -1
  57. package/dist/server/types.js +3 -2
  58. package/dist/server/types.js.map +1 -1
  59. package/package.json +1 -1
  60. package/src/adapters/http/client/transport.ts +9 -6
  61. package/src/adapters/http/server/handler.ts +9 -28
  62. package/src/adapters/http/server/ndjson.ts +3 -1
  63. package/src/adapters/http/server/transport.ts +2 -2
  64. package/src/adapters/websocket/shared/rpc.ts +9 -3
  65. package/src/browser.ts +2 -0
  66. package/src/client/middleware/items.ts +2 -0
  67. package/src/procedures/collection/index.ts +2 -0
  68. package/src/procedures/collection/partition.ts +75 -0
  69. package/src/procedures/collection/topic.ts +2 -0
  70. package/src/procedures/index.ts +2 -0
  71. package/src/protocol.ts +26 -0
  72. package/src/server/browser-guard.ts +27 -7
  73. package/src/server/procedure-server.ts +35 -2
  74. package/src/server/server.ts +3 -2
  75. package/src/server/types.ts +3 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,82 @@
1
1
  # @procedures/client
2
2
 
3
+ ## 0.18.1
4
+
5
+ ### Patch Changes
6
+
7
+ - d69c8cb: A host that serves a plain collection `a.b` and a collection `a` with partitions fails at registration. To correct it, rename the plain collection. Before, the two had the same topic `collections.a.b`. Thus the readers of `a.b` got the events of the tenant `b` of `a`, a leak across tenants (roadmap CLI-57, decision D23).
8
+
9
+ - The refusal is the new export `CollectionTopicCollisionError`. It names the two collections, the partition and the topic.
10
+ - `useStorage`, `useStorages`, the option `collections` of a host and `usePartitions` do the check. The check finds the pair in each order, also when the registrations come at different times.
11
+ - The check also refuses a deeper name, for example `a.b.c` next to `a` with partitions: `b.c` is a partition of `a`.
12
+ - The check also refuses a storage of `a.b` for the calls without a partition while `a` has partitions, also when `a.b` has partitions. That storage publishes on `collections.a.b`.
13
+ - A name without a dot does not change. A dotted name without a partitioned prefix does not change. Two collections with partitions, for example `a` and `a.b`, do not change, because the partitions of `a.b` encode its name.
14
+
15
+ PATCH (decision D23): the change refuses only a configuration that leaks events across tenants, so no caller can rely on it. Each correct configuration behaves as before.
16
+
17
+ Migration steps:
18
+
19
+ - When a host fails with `CollectionTopicCollisionError`, rename the plain collection, for example `a.b` to `a_b`. A name without a dot has no topic of a partition.
20
+ - The site: no change is necessary. It serves no collection.
21
+ - MiniMongo: no change is necessary. Its server serves no collection.
22
+ - Graph: no change is necessary. Its host gives partitions to each served collection (`examples`), and no collection has a plain storage.
23
+ - jarvis: no change is necessary. Its host serves no collection.
24
+ - 0379278: Docs and tests: the rule of the retryable flag of an in-band end (CLI-58). The behavior does not change, thus this change is a PATCH of the client group (decision D13).
25
+
26
+ - Before the stream starts, an error of a handler without a retryable flag gets the flag of its code in `ERROR_CODES` (CLI-48). Thus `UNAVAILABLE` without a flag is retryable, and the HTTP face answers 503.
27
+ - After the stream starts, an error ends the stream in-band. The in-band end is the `error` line of NDJSON, the `error` frame of WebSocket or the `_meta` of the MCP result.
28
+ - An in-band end without a retryable flag gets `retryable: false`, also when the stream gave no item. The reader can have items, and a retry can send them again.
29
+ - A handler gives `retryable: true` when a retry is safe. Then the in-band end is retryable too.
30
+ - The retry middleware of the client does not retry after an item reached the reader. Thus after the first item, the flag only tells the application.
31
+ - This rule agrees with the rule of a cut (CLI-48): the flag is false when the call can have had its effect.
32
+ - `WIRE-PROTOCOL.md` gives the rule in the section "Error codes". Tests pin it on the wire of HTTP and WebSocket, and on the HTTP, WebSocket and MCP faces of the procedures host.
33
+
34
+ The site, MiniMongo, Graph and jarvis: no change.
35
+
36
+ ## 0.18.0
37
+
38
+ ### Minor Changes
39
+
40
+ - 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).
41
+
42
+ 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"`.
43
+
44
+ The behavior that changes:
45
+
46
+ | Former code | Former status | Code of wire v1 | Status | Reason |
47
+ |---|---|---|---|---|
48
+ | `SERVER_STOPPED` | 503 | `UNAVAILABLE` | 503 | — |
49
+ | `FORBIDDEN_HOST` | 403 | `FORBIDDEN` | 403 | `host-header-not-allowed` |
50
+ | `FORBIDDEN_ORIGIN` | 403 | `FORBIDDEN` | 403 | `origin-not-allowed` |
51
+ | `METHOD_NOT_ALLOWED` | 405 | `FORBIDDEN` | 403 | `method-not-allowed` |
52
+ | `UNSUPPORTED_MEDIA_TYPE` | 415 | `FORBIDDEN` | 403 | `media-type-not-allowed` |
53
+ | `"500"` | 500 | `INTERNAL_ERROR` | 500 | — |
54
+
55
+ - `HttpServerTransport` answers a request after `stop()` with `UNAVAILABLE` (503, retryable), as `procedureHandler` does. The message is "The server is stopping".
56
+ - `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.
57
+ - `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`.
58
+ - `Server` answers an error outside a handler with `INTERNAL_ERROR`. `new ServerError(message)` has the default code `INTERNAL_ERROR`.
59
+ - The message of the refusals of the method and of the body starts with "Forbidden:".
60
+
61
+ For one release, the client reads the former codes of an older server:
62
+
63
+ - `HttpTransport` and the WebSocket transports read `SERVER_STOPPED` as `UNAVAILABLE` and `"500"` as `INTERNAL_ERROR`.
64
+ - `HttpTransport` reads `FORBIDDEN_HOST` and `FORBIDDEN_ORIGIN` as `FORBIDDEN`, and sets the metadata key `reason`.
65
+ - `isAvailabilityFailure()` still counts `SERVER_STOPPED`.
66
+ - 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.
67
+ - The next breaking release of the client group removes these aliases.
68
+
69
+ Migration steps:
70
+
71
+ - Code that matches `SERVER_STOPPED`: match `UNAVAILABLE`. The flag `retryable` stays true.
72
+ - Code that matches `FORBIDDEN_HOST` or `FORBIDDEN_ORIGIN`: match `FORBIDDEN`, then read `reason` (the body field, or the metadata key `reason`).
73
+ - 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`.
74
+ - Code that reads `GuardResult.code` of `checkBrowserRequest()`: read `reason`.
75
+ - Code that matches the code `"500"` or the default code of `ServerError`: match `INTERNAL_ERROR`.
76
+ - The site, MiniMongo, Graph and jarvis: no code of theirs matches a former code, so no change is necessary.
77
+ - MiniMongo: its dev server uses `HttpServerTransport`, and its answers change only as the table says.
78
+ - jarvis: its host uses `procedureHandler`, which gave the codes of wire v1 already.
79
+
3
80
  ## 0.17.4
4
81
 
5
82
  No changes in this release.