@procedures/client 0.41.1 → 0.43.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 (63) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/adapters/http/client/batch.d.ts +98 -0
  4. package/dist/adapters/http/client/batch.d.ts.map +1 -0
  5. package/dist/adapters/http/client/batch.js +414 -0
  6. package/dist/adapters/http/client/batch.js.map +1 -0
  7. package/dist/adapters/http/client/index.d.ts +1 -0
  8. package/dist/adapters/http/client/index.d.ts.map +1 -1
  9. package/dist/adapters/http/client/index.js.map +1 -1
  10. package/dist/adapters/http/client/transport.d.ts +7 -0
  11. package/dist/adapters/http/client/transport.d.ts.map +1 -1
  12. package/dist/adapters/http/client/transport.js +27 -1
  13. package/dist/adapters/http/client/transport.js.map +1 -1
  14. package/dist/adapters/http/client/types.d.ts +9 -0
  15. package/dist/adapters/http/client/types.d.ts.map +1 -1
  16. package/dist/adapters/http/server/addressing.d.ts +5 -0
  17. package/dist/adapters/http/server/addressing.d.ts.map +1 -1
  18. package/dist/adapters/http/server/addressing.js +1 -1
  19. package/dist/adapters/http/server/addressing.js.map +1 -1
  20. package/dist/adapters/http/server/batch.d.ts +105 -0
  21. package/dist/adapters/http/server/batch.d.ts.map +1 -0
  22. package/dist/adapters/http/server/batch.js +172 -0
  23. package/dist/adapters/http/server/batch.js.map +1 -0
  24. package/dist/adapters/http/server/handler.d.ts +8 -0
  25. package/dist/adapters/http/server/handler.d.ts.map +1 -1
  26. package/dist/adapters/http/server/handler.js +103 -16
  27. package/dist/adapters/http/server/handler.js.map +1 -1
  28. package/dist/adapters/http/server/transport.d.ts.map +1 -1
  29. package/dist/adapters/http/server/transport.js +13 -2
  30. package/dist/adapters/http/server/transport.js.map +1 -1
  31. package/dist/adapters/http/server/types.d.ts +7 -0
  32. package/dist/adapters/http/server/types.d.ts.map +1 -1
  33. package/dist/adapters/http/shared/errors.d.ts +6 -8
  34. package/dist/adapters/http/shared/errors.d.ts.map +1 -1
  35. package/dist/adapters/http/shared/errors.js +10 -9
  36. package/dist/adapters/http/shared/errors.js.map +1 -1
  37. package/dist/adapters/http/shared/status-codes.d.ts +13 -9
  38. package/dist/adapters/http/shared/status-codes.d.ts.map +1 -1
  39. package/dist/adapters/http/shared/status-codes.js +21 -19
  40. package/dist/adapters/http/shared/status-codes.js.map +1 -1
  41. package/dist/browser.d.ts +1 -1
  42. package/dist/browser.d.ts.map +1 -1
  43. package/dist/browser.js.map +1 -1
  44. package/dist/client/index.d.ts +1 -1
  45. package/dist/client/index.d.ts.map +1 -1
  46. package/dist/node.d.ts +1 -0
  47. package/dist/node.d.ts.map +1 -1
  48. package/dist/node.js.map +1 -1
  49. package/package.json +3 -3
  50. package/src/adapters/http/client/batch.ts +463 -0
  51. package/src/adapters/http/client/index.ts +1 -0
  52. package/src/adapters/http/client/transport.ts +31 -1
  53. package/src/adapters/http/client/types.ts +10 -0
  54. package/src/adapters/http/server/addressing.ts +1 -1
  55. package/src/adapters/http/server/batch.ts +237 -0
  56. package/src/adapters/http/server/handler.ts +119 -17
  57. package/src/adapters/http/server/transport.ts +15 -4
  58. package/src/adapters/http/server/types.ts +8 -0
  59. package/src/adapters/http/shared/errors.ts +10 -9
  60. package/src/adapters/http/shared/status-codes.ts +21 -21
  61. package/src/browser.ts +1 -0
  62. package/src/client/index.ts +1 -1
  63. package/src/node.ts +2 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,66 @@
1
1
  # @procedures/client
2
2
 
3
+ ## 0.43.0
4
+
5
+ No changes in this release.
6
+
7
+ ## 0.42.0
8
+
9
+ ### Minor Changes
10
+
11
+ - 226ae02: `createHTTPStatusError()` gives the codes of `ERROR_REGISTRY`, as `httpStatusToErrorCode()` does. The retryable flag of `isRetryableStatus()` agrees with `ERROR_REGISTRY` (O74). This change is a break of the client group (decision D13).
12
+
13
+ `HttpTransport` uses these values when the body of an error response has no string code, for example the response of a proxy. A body with a string code keeps its code and its flag.
14
+
15
+ The codes that change:
16
+
17
+ | Status | Old code | New code | Old retryable | New retryable |
18
+ |---|---|---|---|---|
19
+ | 408 | `REQUEST_TIMEOUT` | `TIMEOUT` | true | true |
20
+ | 500 | `INTERNAL_SERVER_ERROR` | `INTERNAL_ERROR` | true | false |
21
+ | 599 | `HTTP_NETWORK_CONNECT_TIMEOUT_ERROR` | `HTTP_NETWORK_CONNECT_TIMEOUT` | true | true |
22
+
23
+ The retryable flags that change. The code of each status stays the same.
24
+
25
+ | Status | Code | Old retryable | New retryable |
26
+ |---|---|---|---|
27
+ | 421 | `MISDIRECTED_REQUEST` | false | true |
28
+ | 425 | `TOO_EARLY` | false | true |
29
+ | 501 | `NOT_IMPLEMENTED` | true | false |
30
+ | 505 | `HTTP_VERSION_NOT_SUPPORTED` | true | false |
31
+ | 506 | `VARIANT_ALSO_NEGOTIATES` | true | false |
32
+ | 508 | `LOOP_DETECTED` | true | false |
33
+ | 510 | `NOT_EXTENDED` | true | false |
34
+ | 511 | `NETWORK_AUTHENTICATION_REQUIRED` | true | false |
35
+
36
+ - 408 stays retryable: the server did not read the full request, so the call did not start. The entry `TIMEOUT` of the registry has the status 504 and `retryable: false`, because the deadline of that call passed.
37
+ - 500 is not retryable: the call can have had its effect.
38
+ - A status without an entry in the registry keeps its name from `HTTPStatusToCode`, for example `NOT_MODIFIED` for 304. A server error (5xx) without an entry stays retryable.
39
+ - `HTTPStatusToCode` stays as the names of the statuses. This release removes the `@deprecated` marks of O72 from three of its names.
40
+ - The retry middleware of the client reads the `retryable` flag. Thus it retries a 421 and a 425 without a code in the body. It does not retry a 500, 501, 505, 506, 508, 510 or 511 without a code in the body.
41
+ - `HybridStorage` of `@procedures/store` reads the flag in its default `isUnavailable`. A 500 without a code in the body does not make the storage offline at this time. The queued write stays at the head of the queue, and the next push sends it again.
42
+
43
+ Migration steps:
44
+
45
+ - Each app: search the code for `REQUEST_TIMEOUT`, `INTERNAL_SERVER_ERROR` and `HTTP_NETWORK_CONNECT_TIMEOUT_ERROR` as string error codes. Change them to `TIMEOUT`, `INTERNAL_ERROR` and `HTTP_NETWORK_CONNECT_TIMEOUT`.
46
+ - Each app: do not change `HTTPStatus.REQUEST_TIMEOUT` and the other members of the `HTTPStatus` enum. They are numbers, not error codes.
47
+ - Each app: examine each retry rule that reads the `retryable` flag of an error. Such a rule sees the new flags of the tables. To retry a 500 of a proxy, give the retry middleware a `shouldRetry` function that matches the code `INTERNAL_ERROR`.
48
+ - Each app with `HybridStorage` over HTTP: to make a 500 of a proxy offline again, give an `isUnavailable` option that also matches the code `INTERNAL_ERROR`.
49
+ - The site (`packages/site`): no step. It does not match on the three old codes, and it has no retry rule for a status.
50
+ - MiniMongo: do the steps of each app in its dev host and in its client code. Then examine the retry rules of its HTTP requests to the procedures server.
51
+ - Graph: do the steps of each app.
52
+ - jarvis: do the steps of each app in each client of `@procedures/client` that it has.
53
+ - e4cb0cf: The release train: the ranges of @mark1russell7/algebra, @mark1russell7/service change to a version outside the old range.
54
+
55
+ ### Patch Changes
56
+
57
+ - 7ca9953: A batch of calls in one HTTP request (roadmap CLI-32). Refer to "A batch of calls" in WIRE-PROTOCOL.md.
58
+
59
+ - `procedureHandler` and `HttpServerTransport` take `POST {base}` with the header `Procedures-Batch: 1` and the body `{"calls": [{"id", "path", "input", "headers", "metadata"}]}`. The answer is one NDJSON stream. Each item is a frame that names its call: `response`, `item`, `done` or `error`. Each call goes through `handle()` as a call of its own. Thus the request hook, the token check, the limits and the error policy apply to each call.
60
+ - The new option `batch` (`HandlerBatchOptions`: `maxCalls`, default 64, and `concurrency`, default 8) sets the limits. The default is on. `batch: false` turns batches off.
61
+ - `HttpTransport` has the new option `batch` (`HttpBatchOptions`), default off. With it, the `POST` calls that start in the same turn of the event loop go in one request. Calls with other secret headers go in another batch. A server without batches gets each call alone.
62
+ - SemVer: PATCH. Before 1.0, a backward-compatible feature raises PATCH. A request without the new header gets the same answer as before, and the client option is off by default.
63
+
3
64
  ## 0.41.1
4
65
 
5
66
  ### Patch Changes