@shivaedev/contract 0.48.0 → 0.50.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 (101) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/README.md +167 -143
  3. package/dist/adapters/erasedClient.d.ts +18 -0
  4. package/dist/adapters/erasedClient.d.ts.map +1 -0
  5. package/dist/adapters/erasedClient.js +10 -0
  6. package/dist/adapters/erasedClient.js.map +1 -0
  7. package/dist/automaticLive.d.ts +2 -10
  8. package/dist/automaticLive.d.ts.map +1 -1
  9. package/dist/automaticLive.js +3 -1
  10. package/dist/automaticLive.js.map +1 -1
  11. package/dist/bind.d.ts +12 -5
  12. package/dist/bind.d.ts.map +1 -1
  13. package/dist/bind.js +2 -1
  14. package/dist/bind.js.map +1 -1
  15. package/dist/catchUp.d.ts +2 -1
  16. package/dist/catchUp.d.ts.map +1 -1
  17. package/dist/catchUp.js.map +1 -1
  18. package/dist/clientContract.d.ts +3 -3
  19. package/dist/clientContract.d.ts.map +1 -1
  20. package/dist/clientContract.js +1 -1
  21. package/dist/clientContract.js.map +1 -1
  22. package/dist/clientOperations.d.ts +5 -1
  23. package/dist/clientOperations.d.ts.map +1 -1
  24. package/dist/clientOperations.js +7 -2
  25. package/dist/clientOperations.js.map +1 -1
  26. package/dist/contract.d.ts +1 -0
  27. package/dist/contract.d.ts.map +1 -1
  28. package/dist/contract.js +1 -0
  29. package/dist/contract.js.map +1 -1
  30. package/dist/defineModule.d.ts +6 -8
  31. package/dist/defineModule.d.ts.map +1 -1
  32. package/dist/defineModule.js +1 -1
  33. package/dist/defineModule.js.map +1 -1
  34. package/dist/failureKind.d.ts +10 -0
  35. package/dist/failureKind.d.ts.map +1 -0
  36. package/dist/failureKind.js +20 -0
  37. package/dist/failureKind.js.map +1 -0
  38. package/dist/liveSyncRequest.d.ts +2 -2
  39. package/dist/liveSyncRequest.d.ts.map +1 -1
  40. package/dist/liveSyncRequest.js +1 -2
  41. package/dist/liveSyncRequest.js.map +1 -1
  42. package/dist/liveSyncRpc.d.ts +1 -0
  43. package/dist/liveSyncRpc.d.ts.map +1 -1
  44. package/dist/moduleHandlers.d.ts +3 -3
  45. package/dist/moduleHandlers.d.ts.map +1 -1
  46. package/dist/moduleHandlers.js.map +1 -1
  47. package/dist/moduleProof.d.ts +16 -33
  48. package/dist/moduleProof.d.ts.map +1 -1
  49. package/dist/operation.d.ts +4 -5
  50. package/dist/operation.d.ts.map +1 -1
  51. package/dist/operation.js +2 -2
  52. package/dist/operation.js.map +1 -1
  53. package/dist/operationKind.d.ts +3 -0
  54. package/dist/operationKind.d.ts.map +1 -0
  55. package/dist/operationKind.js +14 -0
  56. package/dist/operationKind.js.map +1 -0
  57. package/dist/rpcClient.d.ts +2 -1
  58. package/dist/rpcClient.d.ts.map +1 -1
  59. package/dist/rpcClient.js.map +1 -1
  60. package/dist/runProof.d.ts +3 -41
  61. package/dist/runProof.d.ts.map +1 -1
  62. package/dist/servedOperation.d.ts +28 -25
  63. package/dist/servedOperation.d.ts.map +1 -1
  64. package/dist/servedOperation.js +9 -3
  65. package/dist/servedOperation.js.map +1 -1
  66. package/dist/subject.d.ts +1 -1
  67. package/dist/subject.d.ts.map +1 -1
  68. package/dist/subjectLayers.d.ts +1 -1
  69. package/dist/subjectLayers.d.ts.map +1 -1
  70. package/dist/subjectLayers.js.map +1 -1
  71. package/dist/wireProof.d.ts +48 -0
  72. package/dist/wireProof.d.ts.map +1 -0
  73. package/dist/wireProof.js +2 -0
  74. package/dist/wireProof.js.map +1 -0
  75. package/package.json +15 -15
  76. package/src/adapters/erasedClient.ts +43 -0
  77. package/src/automaticLive.ts +5 -15
  78. package/src/bind.ts +15 -14
  79. package/src/catchUp.ts +2 -1
  80. package/src/clientContract.ts +5 -5
  81. package/src/clientOperations.ts +8 -10
  82. package/src/contract.ts +2 -0
  83. package/src/defineModule.ts +17 -14
  84. package/src/failureKind.ts +33 -0
  85. package/src/liveSyncRequest.ts +3 -11
  86. package/src/liveSyncRpc.ts +2 -0
  87. package/src/moduleHandlers.ts +3 -3
  88. package/src/moduleProof.ts +29 -46
  89. package/src/operation.ts +8 -16
  90. package/src/operationKind.ts +15 -0
  91. package/src/rpcClient.ts +3 -3
  92. package/src/runProof.ts +3 -61
  93. package/src/servedOperation.ts +47 -47
  94. package/src/subject.ts +1 -1
  95. package/src/subjectLayers.ts +6 -2
  96. package/src/wireProof.ts +104 -0
  97. package/dist/successProof.d.ts +0 -51
  98. package/dist/successProof.d.ts.map +0 -1
  99. package/dist/successProof.js +0 -2
  100. package/dist/successProof.js.map +0 -1
  101. package/src/successProof.ts +0 -120
package/CHANGELOG.md CHANGED
@@ -1,5 +1,38 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.50.0 - 2026-11-20
4
+
5
+ ### Added
6
+
7
+ - `failureKind(error)` in `failureKind.ts` returns `"request"`, `"framework"` or `"app"`, with the `FrameworkFailure` and `AppRejection<E>` types and the `isFrameworkFailure` guard.
8
+ - a bound command carries `runtime`, the atom runtime of its client, and `payload`, its declared payload schema. Bound queries and streams carry `runtime` too.
9
+
10
+ ### Breaking
11
+
12
+ - `defineModule` no longer takes `requires`: delete the `requires` line from every `defineModule({ ... })`, and the imports only it used. The module's type now carries, for each operation, the services its `run` and read policy yield, less what its middleware and subject provide per call, and `moduleHandlers(module)` requires exactly those services. An operation that starts to yield another service needs no other edit.
13
+ - `OperationNeedsUndeclaredServices` and `Allowed` are removed from `@shivaedev/contract/moduleProof.ts`, and `NameProof` takes the operations and the wire only. A module's `"~requires"` is now a record from each operation's name to the services it needs, and `AnyModule["~requires"]` is `ModuleServices`.
14
+
15
+ ## 0.49.0 - 2026-11-20
16
+
17
+ ### Added
18
+
19
+ - `operationKind(rpc)` from `@shivaedev/contract/operationKind.ts` tells whether an RPC reads or writes.
20
+ - a contract's `declaration.subject` records the subject declaration it names.
21
+
22
+ ### Changed
23
+
24
+ - Require Effect 4.1.4 and its matching platform packages.
25
+ - a handler may also fail with an error that one of its contract's RPC middleware declares, as native Effect 4.1.4 `Rpc` handlers do. Any other undeclared error still fails compilation.
26
+
27
+ ### Breaking
28
+
29
+ - `ChangesClient` moves from `automaticLive.ts` to `adapters/erasedClient.ts`, and `automaticLive` takes the contract's `AtomRpcClient<unknown, string, Rpc.Any>`. `liveSyncRequest` takes a flat client of `Rpc.Any | LiveSyncRpc` (`LiveSyncRpc` from `liveSyncRpc.ts`) and returns the sync command's typed Effect. Import `ChangesClient` from its new module; a client made by `makeClient` or `RpcClient.make` over a group that includes `liveSyncRpc` already has the new type.
30
+ - `SubjectDeclaration["middleware"]` may now fail, and `subjectLayers(group)` carries that failure in its error channel. A custom native RPC host that builds `subjectLayers(group)` handles or propagates the declarations' start-time failures, such as `DelegationRuleMissing`; hosts built with `appHost` need no change.
31
+ - An operation written with `run` no longer accepts `success` or `rejections`; its module's wire supplies both. Delete the two fields from every `query(name, { ..., *run })` and `command(name, { ..., *run })`. An operation declared without `run` keeps them, as before.
32
+ - A run-form command's `invalidates` no longer receives the result: it is `invalidates(payload, viewer?)`. Move keys computed from the result into `run` and return through `commandResult` from `@shivaedev/contract/commandResult.ts`: change `invalidates: (_draft, note) => [notes.item(note.id)]` to `return yield* commandResult({ invalidates: [notes.item(note.id)], result: note })` at the end of `run`. Those keys are published on the server after success and reach live subscriptions; they do not enter the browser's `invalidates`. A command whose `invalidates` read the viewer from its third argument reads it from the second. `clientContract`'s `commands` take the same `invalidates(payload, viewer?)`; files written by `@shivaedev/build` copy the operation's `invalidates` and need only `pnpm generate`.
33
+ - `defineModule` requires `wire`. A module without one passes its generated wire, as in `defineModule({ ..., wire: notesWire })` with `notesWire` from `#generated/modules/<module>/<Module>.ts`, or writes `wire: { <operation>: { rejections: { ... }, success: <schema> } }` by hand for each operation that returns a value or raises a rejection. An operation missing from the wire is `OperationMissingFromWire` when its `run` returns a value or raises a rejection; `OperationFailsOutsideItsRejections` no longer exists.
34
+ - `ResultNeedsDeclaredSuccess`, `RunDeclaration`'s success and rejection parameters, `SuccessSchema`, `Pending`, `RejectionProblem` and the problems `SuccessDiffersFromRun`, `SuccessClassNotReturned`, `ArrayMutabilityDiffers`, `RunFailsOutsideRejections`, `RejectionsRunNeverRaises`, `RejectionClassDiffers` and `RejectionAutomatic` are removed; a stale wire still reports `WireSuccessStale` or `WireRejectionsStale`. `successProof.ts` is now `wireProof.ts`, exporting `SuccessDiffers` and `RejectionsDiffer`.
35
+
3
36
  ## 0.48.0 - 2026-11-19
4
37
 
5
38
  ### Added