@diagonal-hq/cli 0.22.4 → 0.23.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.
@@ -6480,7 +6480,7 @@ type SdkHooks = {
6480
6480
  * Keys are isolated from the app's other React Query caches. Begin a key with
6481
6481
  * `'records'` when the endpoint's result depends on resource records, for example
6482
6482
  * `['records', resource.id, 'summary']`; successful resource create/update/delete/restore
6483
- * operations then invalidate it automatically. Other keys refresh only through their
6483
+ * operations and record form submits then invalidate it automatically. Other keys refresh only through their
6484
6484
  * returned `invalidate` function.
6485
6485
  *
6486
6486
  * Keep the key the same between renders. A clock read such as `Date.now()` in the key
@@ -7719,6 +7719,9 @@ type SdkHooks = {
7719
7719
  * `form.errors` contains only 422 field validation. Other failures are available
7720
7720
  * as `form.failure`; for example, branch on
7721
7721
  * `Sdk.utils.error.isConflict(form.failure)` without inspecting status codes.
7722
+ * A successful submit refreshes no other page data. Call the `invalidate()` of the
7723
+ * data that the workflow changed in `onSuccess`, or `Sdk.hooks.useInvalidateAll()`
7724
+ * when the page cannot name it.
7722
7725
  * Success callbacks receive the parsed workflow body directly. Synchronous
7723
7726
  * output can be a scalar, list, record, or object; asynchronous workflows return
7724
7727
  * `{ execution_id }`. Narrow the value before reading authored output fields.
@@ -7804,12 +7807,20 @@ type SdkHooks = {
7804
7807
  * `reset()` also starts a fresh key lifecycle. The hook does not poll asynchronous
7805
7808
  * executions.
7806
7809
  *
7810
+ * A successful run refreshes no other page data. When the workflow changes data that
7811
+ * the page shows, call that data's `invalidate()` in `onSuccess`. Use
7812
+ * `Sdk.hooks.useInvalidateAll()` only when the page cannot name what changed. A
7813
+ * workflow that only reads, such as a search called inside a `Sdk.hooks.useApi`
7814
+ * fetcher, needs no `onSuccess`.
7815
+ *
7807
7816
  * @example
7808
7817
  * ```tsx
7809
7818
  * function ReserveButton({ slotId }) {
7819
+ * const slots = Sdk.hooks.useApi(['slots'], (api) => api.get('/api/slots'));
7810
7820
  * const action = Sdk.hooks.useWorkflowAction({
7811
7821
  * workflowId: 'reserve-slot',
7812
- * idempotent: true
7822
+ * idempotent: true,
7823
+ * onSuccess: () => slots.invalidate()
7813
7824
  * });
7814
7825
  *
7815
7826
  * return (
@@ -7839,8 +7850,28 @@ type SdkHooks = {
7839
7850
  params?: Record<string, any>;
7840
7851
  /** Generate and manage the conventional `idempotency_key` input. */
7841
7852
  idempotent?: boolean;
7853
+ /** Called with the parsed response after every successful run, including a run
7854
+ * that a later run replaced. Refresh the data that the workflow changed here. */
7855
+ onSuccess?: (response: SdkWorkflowResponse) => void;
7842
7856
  }): UseWorkflowActionResult;
7843
7857
 
7858
+ /**
7859
+ * Returns a function that refreshes every data query on the page. Use it after a
7860
+ * write when the page cannot name the data that the write changed. Prefer the
7861
+ * `invalidate()` of each affected data hook, because a full refresh refetches
7862
+ * every query on the page.
7863
+ *
7864
+ * @example
7865
+ * ```tsx
7866
+ * const invalidateAll = Sdk.hooks.useInvalidateAll();
7867
+ * const importMembers = Sdk.hooks.useWorkflowAction({
7868
+ * workflowId: 'import-members',
7869
+ * onSuccess: () => invalidateAll()
7870
+ * });
7871
+ * ```
7872
+ */
7873
+ useInvalidateAll(): () => Promise<void>;
7874
+
7844
7875
  /**
7845
7876
  * Reactive timelines of a record's schedule workflow runs, the data behind
7846
7877
  * `Sdk.Components.RecordScheduleDisplay`, for pages that render a custom
@@ -14155,7 +14186,9 @@ type WorkflowFormProps = {
14155
14186
  * suppress. */
14156
14187
  successMessage?: string | null;
14157
14188
 
14158
- /** Called after a successful submission with the workflow's response payload. */
14189
+ /** Called after a successful submission with the workflow's response payload. A
14190
+ * submission refreshes no other page data, so call the `invalidate()` of the data
14191
+ * that the workflow changed here. */
14159
14192
  onSuccess?: (response: SdkWorkflowResponse) => void;
14160
14193
 
14161
14194
  /** Called when the submission resolves with a non-2xx response, with
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diagonal-hq/cli",
3
- "version": "0.22.4",
3
+ "version": "0.23.0",
4
4
  "description": "The diagonal CLI and the configuration helpers for file-based Diagonal workspaces.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "repository": {