@shivaedev/react 0.49.2 → 0.51.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 (151) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/README.md +188 -186
  3. package/dist/adapters/permissionGuard.d.ts +4 -3
  4. package/dist/adapters/permissionGuard.d.ts.map +1 -1
  5. package/dist/adapters/permissionGuard.js +3 -4
  6. package/dist/adapters/permissionGuard.js.map +1 -1
  7. package/dist/adapters/signInRedirect.d.ts +4 -0
  8. package/dist/adapters/signInRedirect.d.ts.map +1 -0
  9. package/dist/adapters/signInRedirect.js +6 -0
  10. package/dist/adapters/signInRedirect.js.map +1 -0
  11. package/dist/client/FailureHostContext.d.ts +3 -0
  12. package/dist/client/FailureHostContext.d.ts.map +1 -0
  13. package/dist/client/FailureHostContext.js +3 -0
  14. package/dist/client/FailureHostContext.js.map +1 -0
  15. package/dist/client/NoticeContext.d.ts +1 -1
  16. package/dist/client/QueryView.d.ts +20 -5
  17. package/dist/client/QueryView.d.ts.map +1 -1
  18. package/dist/client/QueryView.js +23 -3
  19. package/dist/client/QueryView.js.map +1 -1
  20. package/dist/client/actionCompletion.d.ts +6 -5
  21. package/dist/client/actionCompletion.d.ts.map +1 -1
  22. package/dist/client/actionCompletion.js +19 -18
  23. package/dist/client/actionCompletion.js.map +1 -1
  24. package/dist/client/adapters/formFields.d.ts +4 -0
  25. package/dist/client/adapters/formFields.d.ts.map +1 -0
  26. package/dist/client/adapters/formFields.js +30 -0
  27. package/dist/client/adapters/formFields.js.map +1 -0
  28. package/dist/client/adapters/operationHooks.d.ts +5 -0
  29. package/dist/client/adapters/operationHooks.d.ts.map +1 -0
  30. package/dist/client/adapters/operationHooks.js +7 -0
  31. package/dist/client/adapters/operationHooks.js.map +1 -0
  32. package/dist/{adapters → client/adapters}/queryRoute.d.ts +12 -5
  33. package/dist/client/adapters/queryRoute.d.ts.map +1 -0
  34. package/dist/{adapters → client/adapters}/queryRoute.js +14 -1
  35. package/dist/client/adapters/queryRoute.js.map +1 -0
  36. package/dist/client/adapters/rowValues.d.ts +7 -0
  37. package/dist/client/adapters/rowValues.d.ts.map +1 -0
  38. package/dist/client/adapters/rowValues.js +17 -0
  39. package/dist/client/adapters/rowValues.js.map +1 -0
  40. package/dist/client/adapters/useFeedback.d.ts +11 -0
  41. package/dist/client/adapters/useFeedback.d.ts.map +1 -0
  42. package/dist/client/adapters/useFeedback.js +38 -0
  43. package/dist/client/adapters/useFeedback.js.map +1 -0
  44. package/dist/client/adapters/useQueryNotice.js +1 -1
  45. package/dist/client/adapters/useQueryNotice.js.map +1 -1
  46. package/dist/client/adapters/useStableRun.js +1 -1
  47. package/dist/client/adapters/useStableRun.js.map +1 -1
  48. package/dist/client/adapters/useSubmissionCallbacks.d.ts +4 -5
  49. package/dist/client/adapters/useSubmissionCallbacks.d.ts.map +1 -1
  50. package/dist/client/adapters/useSubmissionCallbacks.js +37 -17
  51. package/dist/client/adapters/useSubmissionCallbacks.js.map +1 -1
  52. package/dist/client/adapters/useUndoableChange.d.ts +13 -12
  53. package/dist/client/adapters/useUndoableChange.d.ts.map +1 -1
  54. package/dist/client/adapters/useUndoableChange.js +16 -4
  55. package/dist/client/adapters/useUndoableChange.js.map +1 -1
  56. package/dist/client/boundOperation.d.ts +12 -0
  57. package/dist/client/boundOperation.d.ts.map +1 -0
  58. package/dist/client/boundOperation.js +2 -0
  59. package/dist/client/boundOperation.js.map +1 -0
  60. package/dist/client/create.d.ts +15 -11
  61. package/dist/client/create.d.ts.map +1 -1
  62. package/dist/client/create.js +12 -5
  63. package/dist/client/create.js.map +1 -1
  64. package/dist/client/editor.d.ts +25 -18
  65. package/dist/client/editor.d.ts.map +1 -1
  66. package/dist/client/editor.js +14 -8
  67. package/dist/client/editor.js.map +1 -1
  68. package/dist/client/failureDecision.d.ts +16 -0
  69. package/dist/client/failureDecision.d.ts.map +1 -0
  70. package/dist/client/failureDecision.js +49 -0
  71. package/dist/client/failureDecision.js.map +1 -0
  72. package/dist/client/failures.d.ts +45 -0
  73. package/dist/client/failures.d.ts.map +1 -0
  74. package/dist/client/failures.js +2 -0
  75. package/dist/client/failures.js.map +1 -0
  76. package/dist/client/notices.d.ts +9 -4
  77. package/dist/client/notices.d.ts.map +1 -1
  78. package/dist/client/notices.js +22 -3
  79. package/dist/client/notices.js.map +1 -1
  80. package/dist/client/operationForm.d.ts +40 -0
  81. package/dist/client/operationForm.d.ts.map +1 -0
  82. package/dist/client/operationForm.js +2 -0
  83. package/dist/client/operationForm.js.map +1 -0
  84. package/dist/client/pendingCommand.d.ts +6 -9
  85. package/dist/client/pendingCommand.d.ts.map +1 -1
  86. package/dist/client/pendingCommand.js +3 -3
  87. package/dist/client/pendingCommand.js.map +1 -1
  88. package/dist/client/resultState.d.ts +7 -4
  89. package/dist/client/resultState.d.ts.map +1 -1
  90. package/dist/client/resultState.js +6 -3
  91. package/dist/client/resultState.js.map +1 -1
  92. package/dist/client/unexpectedFailure.d.ts +8 -0
  93. package/dist/client/unexpectedFailure.d.ts.map +1 -0
  94. package/dist/client/unexpectedFailure.js +17 -0
  95. package/dist/client/unexpectedFailure.js.map +1 -0
  96. package/dist/client/useDebouncedValue.js +1 -1
  97. package/dist/client/useDebouncedValue.js.map +1 -1
  98. package/dist/client/useDelay.js +1 -1
  99. package/dist/client/useDelay.js.map +1 -1
  100. package/dist/noticeEntry.d.ts +3 -1
  101. package/dist/noticeEntry.d.ts.map +1 -1
  102. package/dist/noticeEntry.js +2 -1
  103. package/dist/noticeEntry.js.map +1 -1
  104. package/dist/noticeStore.d.ts +3 -3
  105. package/dist/noticeStore.d.ts.map +1 -1
  106. package/dist/noticeStore.js +4 -4
  107. package/dist/noticeStore.js.map +1 -1
  108. package/dist/noticeTypes.d.ts +1 -2
  109. package/dist/noticeTypes.d.ts.map +1 -1
  110. package/dist/submission.d.ts +2 -4
  111. package/dist/submission.d.ts.map +1 -1
  112. package/dist/submission.js +1 -3
  113. package/dist/submission.js.map +1 -1
  114. package/package.json +13 -13
  115. package/src/adapters/permissionGuard.ts +6 -5
  116. package/src/adapters/signInRedirect.ts +7 -0
  117. package/src/client/FailureHostContext.ts +4 -0
  118. package/src/client/QueryView.ts +50 -7
  119. package/src/client/actionCompletion.ts +33 -23
  120. package/src/client/adapters/formFields.ts +33 -0
  121. package/src/client/adapters/operationHooks.ts +14 -0
  122. package/src/{adapters → client/adapters}/queryRoute.ts +24 -9
  123. package/src/client/adapters/rowValues.ts +25 -0
  124. package/src/client/adapters/useFeedback.ts +50 -0
  125. package/src/client/adapters/useQueryNotice.ts +1 -1
  126. package/src/client/adapters/useStableRun.ts +1 -1
  127. package/src/client/adapters/useSubmissionCallbacks.ts +44 -21
  128. package/src/client/adapters/useUndoableChange.ts +66 -30
  129. package/src/client/boundOperation.ts +13 -0
  130. package/src/client/create.ts +50 -20
  131. package/src/client/editor.ts +98 -38
  132. package/src/client/failureDecision.ts +70 -0
  133. package/src/client/failures.ts +56 -0
  134. package/src/client/notices.ts +44 -6
  135. package/src/client/operationForm.ts +52 -0
  136. package/src/client/pendingCommand.ts +12 -14
  137. package/src/client/resultState.ts +20 -11
  138. package/src/client/unexpectedFailure.ts +24 -0
  139. package/src/client/useDebouncedValue.ts +1 -1
  140. package/src/client/useDelay.ts +1 -1
  141. package/src/noticeEntry.ts +5 -0
  142. package/src/noticeStore.ts +9 -4
  143. package/src/noticeTypes.ts +1 -2
  144. package/src/submission.ts +4 -6
  145. package/dist/adapters/queryRoute.d.ts.map +0 -1
  146. package/dist/adapters/queryRoute.js.map +0 -1
  147. package/dist/client/adapters/useNoticePublisher.d.ts +0 -4
  148. package/dist/client/adapters/useNoticePublisher.d.ts.map +0 -1
  149. package/dist/client/adapters/useNoticePublisher.js +0 -8
  150. package/dist/client/adapters/useNoticePublisher.js.map +0 -1
  151. package/src/client/adapters/useNoticePublisher.ts +0 -10
package/CHANGELOG.md CHANGED
@@ -1,5 +1,42 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.51.0 - 2026-11-20
4
+
5
+ ### Added
6
+
7
+ - the result of `queryRoute(buildQuery)` has `useQuery(options?)`, which reads the route's query with the current match's params, decoded search, context and loader value, so a route's component no longer names the operation and its arguments again. `useLoaded()` returns the same atom as `query` and the loader value as `loaded`, to spread into a loader-backed `useEditor`. Replace `useLoaderQuery(api.get.query({ id }), route.useLoaderData())` in a route's component with `noteQuery.useQuery()`, keeping the `queryRoute` result as `noteQuery`; `useLoaderQuery` stays for loaders written with `loadQuery`.
8
+ - a query route reads `redirects` from the router context, so `redirects.signedOut` and `redirects.refused` are stated once for every query route. A route's own `queryRoute(buildQuery, { redirects })` still overrides them for its query.
9
+ - `signInRedirect(path)` in `adapters/signInRedirect.ts` builds a signed-out redirect to `path` that carries the requested location in `returnTo`.
10
+
11
+ ### Changed
12
+
13
+ - from this version, with the `@shivaedev/quality` release of this change, write a `failures` handler inline in the component: `useEditor(api.retitle, { query, fixed: { id }, failures: { SubtitleRejected: (error) => ({ field: "title", message: error.message }) } })`. The 0.50.0 note said to declare a handler such as `onTitle` or `couldNotRemove` outside the component because Biome's `noNestedComponentDefinitions` read it as a component; that is no longer needed, and the README now shows the inline form.
14
+
15
+ ### Breaking
16
+
17
+ - `queryRoute` moves to `client/adapters/queryRoute.ts`, beside the client hooks its `useQuery()` uses. Change `@shivaedev/react/adapters/queryRoute.ts` imports to `@shivaedev/react/client/adapters/queryRoute.ts`.
18
+ - `permissionGuard` takes `signedOut`, the redirect callback, in place of the `signIn` path. Before: `permissionGuard({ session, signIn: "/sign-in" })`. After: put `redirects: { signedOut: signInRedirect("/sign-in") }` in the router context and pass it to the guard: `beforeLoad: ({ context, ...route }) => permissionGuard({ session, signedOut: context.redirects.signedOut })(route)`.
19
+
20
+ ## 0.50.0 - 2026-11-20
21
+
22
+ ### Added
23
+
24
+ - `NoticeHost` takes `failure(unexpected)`, the application's one wording for a lost connection, a server outage, an `InternalServerError`, a defect or an untagged failure, called once per failed invocation. Without it the host shows `Could not reach the server. Check your connection and try again.`, the server's redacted message, or `Something went wrong. Try again.`, never a cause. Without `render`, notices render with `role="alert"` or `role="status"` and a Dismiss button. A `Notice` carries `kind`: `"success"`, `"rejection"` or `"failure"`.
25
+ - `QueryViewDefaults` in `client/QueryView.ts` sets the application's default `failure` and `loading` rendering for every `QueryView` below it.
26
+ - `useCreate` and `useEditor` take their form fields from the command's payload schema when `fields` is omitted, and `useEditor` fills its inputs by encoding each row with those fields when `values` is omitted. `fixed` supplies the payload fields the form does not edit, and every save sends `{ ...fixed, ...values }`. `fixed` and the form's fields must cover the payload exactly: a missing key, a key outside the payload or a value of the wrong type does not compile, and the error names the key. Passing a bound query where a command belongs reports `a bound query only reads: read it with useQuery, and pass a command here`.
27
+
28
+ ### Breaking
29
+
30
+ - a bound command given to `useAction`, `usePendingCommand` or `useUndoableChange`, and the save of `useCreate` or `useEditor`, now show their failures without screen code. A shared rejection from `@shivaedev/errors/taxonomy.ts` publishes its server message through the mounted `NoticeHost`; a rejection whose `field` names a form field still lands on that field; `Unauthorized` still rechecks the session and now also shows its message; interrupted work publishes nothing. Delete screen-local alerts that only repeated the message, such as `{Option.isSome(editor.failure) && <p role="alert">{editor.failure.value.message}</p>}`.
31
+ - `notices.onFailure` and `rejectField` are removed in favour of one per-tag `failures` option. Before: `useAction(api.remove, { notices: { onFailure: () => ({ message: "Could not remove" }) } })`. After: `useAction(api.remove, { failures: { Conflict: couldNotRemove } })` with `function couldNotRemove() { return { message: "Could not remove" }; }` declared outside the component, or leave it out to show the server's message. Before: `useEditor(api.retitle, { query, fixed: { id }, rejectField: (error) => ({ field: "title", message: error.message }) })`. After: `useEditor(api.retitle, { query, fixed: { id }, failures: { SubtitleRejected: onTitle } })` with `function onTitle(error: SubtitleRejected) { return { field: "title" as const, message: error.message }; }` declared outside the component, because Biome's `noNestedComponentDefinitions` reads a one-parameter function under a PascalCase key inside a component as a component. A handler receives the error and the invocation's input and returns a notice descriptor, a field rejection (form hooks only) or `"silent"`; `"message"` shows the error's own message and `"silent"` shows nothing for that tag. `silent: true` shows nothing for any failure of the call.
32
+ - a command or save that can fail with a rejection the application declared for itself does not compile until `failures` names it; the error names the tag, for example `Property '"failures.SubtitleRejected"' is missing`. Add `failures: { SubtitleRejected: "message" }`, or a handler, to each such call.
33
+ - `QueryView`'s `loading` and `failure` are optional. Without them the view renders the application's `QueryViewDefaults`, or a `Loading…` status and the failure's message with a Retry button that calls `refresh`. A query that can fail with an application-declared rejection still requires `failure`. Remove `loading` and `failure` renderers that repeated the default.
34
+ - `useAction` takes the bound command instead of a runtime and its `run`. The plain action atom form `useAction(atom)` is unchanged. Before: `useAction(NotesClient.runtime, api.remove.run, { onSuccess })`. After: `useAction(api.remove, { onSuccess })`. For an Effect that is not a single bound command, pass `{ run, runtime }`: `useAction({ run: save, runtime: NotesClient.runtime })`.
35
+ - `useCreate` takes the operation first and its options second; the `create` and `runtime` options are gone, and `fields` is optional. Before: `useCreate({ fields: NoteFields, initialValues: { title: "" }, create: api.create.run, runtime: NotesClient.runtime })`. After: `useCreate(api.create, { initialValues: { title: "" } })`. Keep `fields` when an input holds another encoding than the payload, such as `Schema.NumberFromString` for a number typed as text.
36
+ - `useEditor` takes the operation first and its options second; the `save` and `runtime` options are gone, and `fields` and `values` are optional. Before: `useEditor({ query: api.get.query({ id }), fields: NoteFields, values: (note) => ({ title: note.title }), save: (values) => api.update.run({ id, ...values }), runtime: NotesClient.runtime })`. After: `useEditor(api.update, { query: api.get.query({ id }), fixed: { id } })`. Pass `values(row)` when the row's shape differs from the fields; a payload field the row lacks, such as an expected version, goes in `fixed`. A save that composes several Effects passes `{ run, runtime }` as the operation: `useEditor({ run: (values) => save(id, values), runtime }, { fields, query, values })`.
37
+ - `useUndoableChange` and `usePendingCommand` take the bound command itself, and `useUndoableChange` takes `update` in its options. Before: `useUndoableChange({ ...api.change, runtime: NotesClient.runtime, update }, { describe })` and `usePendingCommand({ ...api.toggle, runtime: ItemsClient.runtime }, { value, wanted })`. After: `useUndoableChange(api.change, { describe, update })` and `usePendingCommand(api.toggle, { value, wanted })`. The `VersionedChangeCommand` and `PendingCommand` types are removed; both hooks accept any `{ run, runtime }`.
38
+ - the `CreateConfig` and `EditorConfig` types are now `CreateOptions` and `EditorOptions`, without the operation's members.
39
+
3
40
  ## 0.49.2 - 2026-11-20
4
41
 
5
42
  ### Changed