@sanity/workflow-studio-plugin 0.5.0 → 0.21.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.
- package/CHANGELOG.md +232 -0
- package/README.md +45 -63
- package/dist/_chunks-cjs/index.cjs +1046 -502
- package/dist/_chunks-cjs/workflows-tool-root.cjs +551 -59
- package/dist/_chunks-es/index.js +1064 -522
- package/dist/_chunks-es/workflows-tool-root.js +556 -62
- package/dist/index.cjs +0 -6
- package/dist/index.d.cts +16 -74
- package/dist/index.d.ts +16 -74
- package/dist/index.js +2 -2
- package/package.json +16 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,237 @@
|
|
|
1
1
|
# @sanity/workflow-studio-plugin
|
|
2
2
|
|
|
3
|
+
## 0.21.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- cdba5dc: The Workflows tool's task list now starts instance bands collapsed in the Overview segment (For me keeps them open; document groups stay open in both), and remembers explicit expand/collapse toggles across sessions — tracked per segment, stored in localStorage namespaced by engine resource with a versioned payload and a least-recently-toggled cap, degrading to session-only in-memory state when storage is unavailable. Untouched bands always follow the current defaults.
|
|
8
|
+
- 9b7e918: **BREAKING:** the `sanity` peer dependency floor rises from `^6` to `^6.3.0` — the doc-link verdict rides preview-store APIs first published in Studio 6.3.0.
|
|
9
|
+
|
|
10
|
+
Doc-ref faces resolve the referenced document's actual `_type` through one live session store instead of issuing a query per mounted face: every face reading the same document shares a single verdict pipeline into the Studio preview store, which multiplexes all observation over its one global dataset listener with batched hydration. Verdicts are real-time — a document created, published, or deleted mid-session upgrades or demotes its faces as it happens — and remounts (tab switches, dialog opens, list repaints) paint the last verdict instantly while the pipeline re-syncs. Readability gates the verdict: a representation that exists but is unreadable to the current actor fails open (the face is never demoted to "unavailable"), and a document persisted only as a release version resolves through its version document instead of reading as missing.
|
|
11
|
+
|
|
12
|
+
The Workflows tool's orphan detection reads the same live store, so it now agrees with the doc-link faces and with a reloaded tool in real time: deleting a document while the tool is open removes its workflow group from the task views and raises the clean-up banner as it happens, and a restored document re-enters the views the same way. Detection stays conservative — only a confirmed no-representation verdict hides a group; in-flight and unreadable observations report nothing, and a failed one keeps its last confirmed verdict — and the settle flow still re-confirms absence with a fresh lake read before anything irreversible fires.
|
|
13
|
+
|
|
14
|
+
- 809faca: The Workflows tool now detects workflows whose documents have been deleted. Their groups leave the task views (and the document filter), and a banner names how many there are and offers to clean them up after confirmation — under the hood each workflow is aborted where it stands. Detection is conservative: a group counts as orphaned only when every document it presents targets this Studio's content dataset and a lake probe confirms no representation (published, draft, or release version) exists; foreign refs and failed reads keep the group visible. Settling re-confirms absence at run time — a document restored since detection leaves its workflows running, and a failed recheck settles nothing. The summary toast reports each skipped or failed workflow by name, and the run re-probes detection: failed workflows stay detected by the banner for another pass, while a workflow whose document exists again returns to the task views.
|
|
15
|
+
- 38cb271: The plugin logs a UI-engagement telemetry vocabulary through the host Studio's telemetry store — eleven `Editorial Workflows Studio Plugin` events (the surface-qualified prefix keeps them separable from the engine's `Editorial Workflows` outcome events in downstream queries) complementing the engine's outcome vocabulary: surface views (tool and document view with tab attribution, the activity dialog with source attribution, instance detail keyed by instance), the start-dialog funnel (opened vs submitted per entry point, resumes flagged), auto-start runs (silent vs collect, request count), action-control use attributed to its physical surface and overflow-menu path with the UI-visible success flag, todo toggles attributed to their surface and write seam (tick action vs field edit), form-strip clicks, and applied task filters (category keys and value counts only). Payloads carry enums, counts, flags, and the instance id — never customer-authored strings. Events share the host store's session with the engine events, no-op in hosts without a telemetry provider, and a once-per-mount guard keeps StrictMode double-effects from double-counting views.
|
|
16
|
+
|
|
17
|
+
Internally, `StartWorkflowRequest` gains a required `source`, and the start controls, `useFireAction`, and `ActivityDetailDialog` gain surface/source props (none are exported package API). Two reads are deliberately not covered: field-editor opens (the per-kind editors share no open seam; the engine's sampled field-edited event covers actual edits) and the instance-detail entry path (tool list, document-view jump-out, and deep link collapse to one router state).
|
|
18
|
+
|
|
19
|
+
- fa9c796: **BREAKING:** Replace the singular `start.allowed` and activity requirement record with ordered, named requirement arrays.
|
|
20
|
+
|
|
21
|
+
Start readiness now accepts polymorphic `groq` and `singleSubject` nodes:
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
// Before
|
|
25
|
+
start: {allowed: '$fields.approved == true'}
|
|
26
|
+
|
|
27
|
+
// After
|
|
28
|
+
start: {
|
|
29
|
+
requirements: [
|
|
30
|
+
{type: 'groq', name: 'approved', title: 'Approval required', query: '$fields.approved == true'},
|
|
31
|
+
],
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Use `singleSubject` instead of `$subjectHasInFlightInstance` to allow at most one in-flight run of the same definition for a subject. The requirement is definition-scoped and version-blind across deployments:
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
// Before
|
|
39
|
+
start: {allowed: '!$subjectHasInFlightInstance'}
|
|
40
|
+
|
|
41
|
+
// After
|
|
42
|
+
start: {
|
|
43
|
+
requirements: [
|
|
44
|
+
{type: 'singleSubject', name: 'single-subject', description: 'Finish the existing run first.'},
|
|
45
|
+
],
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Activity readiness uses the same ordered descriptor model with `groq` nodes:
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
// Before
|
|
53
|
+
requirements: {
|
|
54
|
+
approved: 'defined($fields.approval)'
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// After
|
|
58
|
+
requirements: [{type: 'groq', name: 'approved', query: 'defined($fields.approval)'}]
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Requirement names must be unique within their owning array. Evaluation preserves author order and reports every unmet requirement with its `name` and optional editor-facing `title` and `description`. Fresh standalone starts enforce the requirements after validating inputs. Resuming an unfinished start and parent-owned spawning continue to bypass start requirements.
|
|
62
|
+
|
|
63
|
+
`evaluateStart()` now returns ordered `requirements` entries containing each descriptor, outcome, and GROQ insight where applicable. Its singular top-level `insight` is removed. `StartNotAllowedError.insight` is replaced by `StartNotAllowedError.unmetRequirements`. Activity evaluation likewise reports unmet requirement descriptors instead of names alone.
|
|
64
|
+
|
|
65
|
+
Rename the public start-requirement analysis helpers and constants:
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
// Before
|
|
69
|
+
explainStartAllowed(args)
|
|
70
|
+
unboundAllowedReads(query, fields)
|
|
71
|
+
START_ALLOWED_VARS
|
|
72
|
+
|
|
73
|
+
// After
|
|
74
|
+
explainStartRequirement(args)
|
|
75
|
+
unboundRequirementReads(query, fields)
|
|
76
|
+
START_REQUIREMENT_VARS
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
`definitionsForDocument({document, subject})` becomes `definitionsForDocument({document})`. Start applicability no longer needs a separately supplied subject. The engine-owned start dataset projection exposes only `definition`, `subject`, and `completedAt`; authors no longer query raw instance storage for deduplication.
|
|
80
|
+
|
|
81
|
+
Studio pre-flights both requirement kinds against the live document session, disables starts whose requirements are unmet, and renders the authored description or title with a humanized requirement-name fallback. Controls re-enable on the same mount when a blocking run completes.
|
|
82
|
+
|
|
83
|
+
Persisted data model 4 unconditionally raises `minReaderModel` to 4 for new definitions and instances because older readers would ignore readiness arrays and could commit invalid transitions. Upgrade every reader and Function before deploying model-4 writers. Legacy deployed definitions are not normalized; prerelease environments with incompatible definitions may use `sanity-workflows nuke` before redeploying.
|
|
84
|
+
|
|
85
|
+
- bcc30fe: **BREAKING:** Every surface emits and matches the account-global user id (`sanityUserId`) — the one identity namespace the engine stores. Studio member records carry `sanityUserId` alongside the project-scoped id; the plugin's member/picker views, `useAssignmentIdentity()`, display resolution, and the new `useSelfActor()` join through it once, so pickers, "for me" matching, and self-authored actor stamps all speak global ids. `@sanity/workflow-sdk` gains `useProjectMembers(projectId)`, loading the configured project's human members as assignment rows whose `id` is the global user id (display from project profiles). `@sanity/workflow-components`' `ProjectMember.id` is documented as the account-global id, and the new `projectMemberRow` builder is the one place member-row semantics live (global id preferred, membership-id fallback) — both integrations delegate to it. "For me" and assignment matching compare global ids: instances stored with project-scoped assignees stop matching until their next engine commit self-heals them.
|
|
86
|
+
|
|
87
|
+
### Patch Changes
|
|
88
|
+
|
|
89
|
+
- a5b327d: Adapt Studio assignee controls to the reusable picker's controlled value contract.
|
|
90
|
+
- f4bc057: **BREAKING:** `list_workflow_instances` now returns one page with `has_more` and an optional `next_cursor`; callers that need every match must continue with the cursor. The optional `limit` accepts 1–100 rows and defaults to 25.
|
|
91
|
+
|
|
92
|
+
Bound instance and definition list reads with lake-side filtering and consumer-specific projections.
|
|
93
|
+
|
|
94
|
+
Document filtering now excludes exited-stage references and includes live unresolved child-workflow references. Definition discovery selects and model-gates only the latest deployed version of each workflow name; historical versions remain stored and available to history-oriented APIs.
|
|
95
|
+
|
|
96
|
+
The MCP eval suite now verifies that agents follow list cursors to find a target beyond the first default page, including in persisted Braintrust runs.
|
|
97
|
+
|
|
98
|
+
MCP tool telemetry reports a `cursorUsed` boolean so continued list-page adoption is measurable without sending cursor values, arguments, or results.
|
|
99
|
+
|
|
100
|
+
- Updated dependencies [d9394e5]
|
|
101
|
+
- Updated dependencies [a5b327d]
|
|
102
|
+
- Updated dependencies [a5b327d]
|
|
103
|
+
- Updated dependencies [92e28bd]
|
|
104
|
+
- Updated dependencies [f4bc057]
|
|
105
|
+
- Updated dependencies [bcc30fe]
|
|
106
|
+
- Updated dependencies [e7392af]
|
|
107
|
+
- Updated dependencies [fa9c796]
|
|
108
|
+
- Updated dependencies [bcc30fe]
|
|
109
|
+
- @sanity/workflow-engine@0.21.0
|
|
110
|
+
- @sanity/workflow-components@0.21.0
|
|
111
|
+
- @sanity/workflow-react@0.21.0
|
|
112
|
+
- @sanity/workflow-studio@0.21.0
|
|
113
|
+
- @sanity/workflow-diagram@0.21.0
|
|
114
|
+
|
|
115
|
+
## 0.20.0
|
|
116
|
+
|
|
117
|
+
### Minor Changes
|
|
118
|
+
|
|
119
|
+
- 419cd5e: Action buttons and action-menu items take their face from declared decision semantics: `decision.accept` renders positive with a checkmark icon, `decision.decline` renders caution with a cross icon, in the quiet top-row, the concluding footer, and the "Select action" menu treatments alike — the icon doubles the tone as a non-color channel. A declared `failed` status keeps its bare critical face and outranks the semantics; actions without semantics render as before.
|
|
120
|
+
- e3122cc: The document view's boot indicators consolidate: section headers no longer spin while sessions boot — the Active Workflows heading carries one spinner for the group (held back 400ms so warm boots paint nothing), since a document's sections boot together over shared discovery and one consolidated guard query. A section speaks up individually only when it diverges: its invalid notice, or its stage body's loading row — now shaped as a work row (spinner in the status glyph's slot) so a one-activity stage swaps loading for content with zero layout shift.
|
|
121
|
+
- 46b0285: **BREAKING:** Replace manually declared document applicability with automatic
|
|
122
|
+
discovery from deployed first-class subject fields.
|
|
123
|
+
|
|
124
|
+
Update Studio configuration as follows:
|
|
125
|
+
- `mappings` is optional. Omit it when every applicable definition declares a
|
|
126
|
+
first-class subject. A mapping may customize an automatically discovered
|
|
127
|
+
`(docType, definition)` binding or explicitly register a definition modeled
|
|
128
|
+
with a plain `doc.ref` instead of a first-class subject.
|
|
129
|
+
- Multiple workflows may target one document type. Use one mapping row for each
|
|
130
|
+
distinct `(docType, definition)` pair. An exact duplicate pair is a
|
|
131
|
+
configuration error rather than a last-row-wins override.
|
|
132
|
+
- Remove the top-level `autoStart` map or function. Put `autoStart: true` on
|
|
133
|
+
each mapping row that should start automatically. Configure workspace-specific
|
|
134
|
+
behavior in that workspace's mapping rows. This also works for explicitly
|
|
135
|
+
registered definitions using the `doc.ref` field named `subject` convention.
|
|
136
|
+
- Replace `workflowDefaultDocumentNode({mappings})` with
|
|
137
|
+
`workflowDefaultDocumentNode()`.
|
|
138
|
+
|
|
139
|
+
Before:
|
|
140
|
+
|
|
141
|
+
```ts
|
|
142
|
+
structureTool({defaultDocumentNode: workflowDefaultDocumentNode({mappings})})
|
|
143
|
+
workflowStudioPlugin({
|
|
144
|
+
tag: 'production',
|
|
145
|
+
mappings,
|
|
146
|
+
autoStart: {article: ['article-review', 'legal-review']},
|
|
147
|
+
})
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
After:
|
|
151
|
+
|
|
152
|
+
```ts
|
|
153
|
+
structureTool({defaultDocumentNode: workflowDefaultDocumentNode()})
|
|
154
|
+
workflowStudioPlugin({
|
|
155
|
+
tag: 'production',
|
|
156
|
+
mappings: [
|
|
157
|
+
{
|
|
158
|
+
docType: 'article',
|
|
159
|
+
definition: 'article-review',
|
|
160
|
+
label: 'Article review',
|
|
161
|
+
autoStart: true,
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
docType: 'article',
|
|
165
|
+
definition: 'legal-review',
|
|
166
|
+
label: 'Legal review',
|
|
167
|
+
autoStart: true,
|
|
168
|
+
},
|
|
169
|
+
],
|
|
170
|
+
})
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
Also remove all per-schema Editorial Workflows preview wiring:
|
|
174
|
+
- Remove `components: {preview: WorkflowStagePreview}`.
|
|
175
|
+
- Remove `_id` added only for Editorial Workflows from `preview.select` and
|
|
176
|
+
stop passing it through `preview.prepare`.
|
|
177
|
+
- Remove imports of `WorkflowStagePreview`; that component is no longer a
|
|
178
|
+
public package export.
|
|
179
|
+
- Remove imports of `mappingForDocType` and `workflowDocTypes`; effective
|
|
180
|
+
mappings are resolved inside the plugin and those host-side helpers are no
|
|
181
|
+
longer exported.
|
|
182
|
+
- Keep each schema's native inferred or custom preview unchanged. The plugin
|
|
183
|
+
now installs preview middleware itself, consumes the document identity Studio
|
|
184
|
+
already supplies, and delegates title, subtitle, media, and custom preview
|
|
185
|
+
composition through `renderDefault`.
|
|
186
|
+
|
|
187
|
+
Workflow stage pills appear on Studio surfaces that invoke preview middleware,
|
|
188
|
+
including reference and array-item previews. Custom preview components that
|
|
189
|
+
replace Studio's layout must render the `status` prop they receive. Studio's
|
|
190
|
+
Structure document-list rows bypass both plugin and schema preview middleware,
|
|
191
|
+
so they do not show workflow stage pills. Workflow status remains available in
|
|
192
|
+
the document form, footer badge, Workflows view, and Workflows tool.
|
|
193
|
+
|
|
194
|
+
Document-reference GDRs for dataset content now reject stored draft IDs
|
|
195
|
+
(`drafts.<id>`) and Content Release version IDs
|
|
196
|
+
(`versions.<release>.<id>`). Use the stable document ID in the GDR and select
|
|
197
|
+
the draft or release through workflow perspective instead. The validation error
|
|
198
|
+
includes the corresponding stable ID so CLI and API callers can correct the
|
|
199
|
+
input before an unresolvable workflow instance is created.
|
|
200
|
+
|
|
201
|
+
Previously persisted draft/version GDRs remain invalid workflow identities.
|
|
202
|
+
Read-side Studio displays now tolerate them by showing the raw URI instead of
|
|
203
|
+
crashing, and query-sourced occurrences are discarded through the existing
|
|
204
|
+
fail-soft field-resolution path. Correct existing data by starting a new
|
|
205
|
+
instance with the stable document ID; perspective selects the desired draft or
|
|
206
|
+
release content.
|
|
207
|
+
|
|
208
|
+
- 98e488e: Stabilize Editorial Workflows discovery subscriptions and limit full reactive sessions to surfaces that need live evaluation.
|
|
209
|
+
- e3122cc: Settled workflow runs no longer boot reactive sessions. The provider mounts an evaluator only for in-flight discovered instances (plus any instance explicitly pulled in through the refcounted request seam, settled or not); settled entries render from committed documents and are vacuously `ready`, so the accordion header no longer spins for finished sections. The mounted sessions share one consolidated guard live query per resource (the plan's `guardScope`), so opening a document costs one discovery subscription plus guard machinery that doesn't grow with its active-run count.
|
|
210
|
+
- e860898: **BREAKING:** Published Editorial Workflows packages now ship as one fixed release stack and require exact-version peers for every shared runtime package. Install the matching stack so the engine, reactive core, adapters, tools, and UI cannot silently load private or version-skewed copies.
|
|
211
|
+
|
|
212
|
+
### Patch Changes
|
|
213
|
+
|
|
214
|
+
- 8a76c67: Add incremental reactive-session document feeds, coalesce watched-document emissions, and reuse discovery derivations and Studio layout output. Deleted watched documents now leave the held snapshot instead of remaining as stale evaluation input. The component test runner also has aggregate-suite timeout headroom.
|
|
215
|
+
- ab5e454: Share projected project members and use indexed, memoized assignee display lookups.
|
|
216
|
+
- Updated dependencies [bce09fc]
|
|
217
|
+
- Updated dependencies [efb4cd9]
|
|
218
|
+
- Updated dependencies [ab5e454]
|
|
219
|
+
- Updated dependencies [46b0285]
|
|
220
|
+
- Updated dependencies [ab5e454]
|
|
221
|
+
- Updated dependencies [8a76c67]
|
|
222
|
+
- Updated dependencies [e3122cc]
|
|
223
|
+
- Updated dependencies [e3122cc]
|
|
224
|
+
- Updated dependencies [7e8f459]
|
|
225
|
+
- Updated dependencies [98e488e]
|
|
226
|
+
- Updated dependencies [7c4dd86]
|
|
227
|
+
- Updated dependencies [e860898]
|
|
228
|
+
- Updated dependencies [e3122cc]
|
|
229
|
+
- @sanity/workflow-engine@0.20.0
|
|
230
|
+
- @sanity/workflow-studio@0.20.0
|
|
231
|
+
- @sanity/workflow-react@0.20.0
|
|
232
|
+
- @sanity/workflow-components@0.20.0
|
|
233
|
+
- @sanity/workflow-diagram@0.20.0
|
|
234
|
+
|
|
3
235
|
## 0.5.0
|
|
4
236
|
|
|
5
237
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -33,11 +33,10 @@ treat plugin-side checks as a security boundary.
|
|
|
33
33
|
## 1. Install
|
|
34
34
|
|
|
35
35
|
```sh
|
|
36
|
-
npm install @sanity/workflow-studio-plugin @sanity/workflow-engine @sanity/workflow-cli
|
|
36
|
+
npm install @sanity/workflow-studio-plugin @sanity/workflow-components @sanity/workflow-diagram @sanity/workflow-engine @sanity/workflow-react @sanity/workflow-sdk @sanity/workflow-studio @sanity/workflow-cli
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
`styled-components ^6`, `@sanity/sdk ^2.12` — the usual studio peers).
|
|
39
|
+
Use one matching version for every `@sanity/workflow-*` package in that command; they publish as a fixed runtime stack. The plugin also requires a Studio v6 project (`sanity ^6`, `react ^19`, `styled-components ^6`, `@sanity/sdk ^2.12` — the usual Studio peers).
|
|
41
40
|
|
|
42
41
|
## 2. Define a workflow
|
|
43
42
|
|
|
@@ -103,7 +102,7 @@ import {articleReview} from './workflows/article-review'
|
|
|
103
102
|
export default defineWorkflowConfig({
|
|
104
103
|
deployments: [
|
|
105
104
|
{
|
|
106
|
-
expectedMinReaderModel:
|
|
105
|
+
expectedMinReaderModel: 4,
|
|
107
106
|
name: 'production',
|
|
108
107
|
// The tag namespaces all workflow data — the plugin only sees
|
|
109
108
|
// definitions and instances deployed under the tag it's configured with.
|
|
@@ -125,100 +124,76 @@ no-op.
|
|
|
125
124
|
|
|
126
125
|
## 4. Wire the studio
|
|
127
126
|
|
|
128
|
-
Add to your `sanity.config.ts
|
|
129
|
-
document types:
|
|
127
|
+
Add to your `sanity.config.ts`:
|
|
130
128
|
|
|
131
129
|
```ts
|
|
132
130
|
import {defineConfig} from 'sanity'
|
|
133
131
|
import {structureTool} from 'sanity/structure'
|
|
134
|
-
import {
|
|
135
|
-
workflowDefaultDocumentNode,
|
|
136
|
-
workflowStudioPlugin,
|
|
137
|
-
type WorkflowMapping,
|
|
138
|
-
} from '@sanity/workflow-studio-plugin'
|
|
139
|
-
|
|
140
|
-
const workflowMappings: readonly WorkflowMapping[] = [
|
|
141
|
-
{
|
|
142
|
-
docType: 'article', // your schema type
|
|
143
|
-
definition: 'article-review', // the deployed definition's `name`
|
|
144
|
-
label: 'Article review',
|
|
145
|
-
},
|
|
146
|
-
]
|
|
132
|
+
import {workflowDefaultDocumentNode, workflowStudioPlugin} from '@sanity/workflow-studio-plugin'
|
|
147
133
|
|
|
148
134
|
export default defineConfig({
|
|
149
135
|
// ...your projectId, dataset, schema...
|
|
150
136
|
plugins: [
|
|
151
137
|
structureTool({
|
|
152
|
-
// Adds the "Workflows" tab next to
|
|
153
|
-
defaultDocumentNode: workflowDefaultDocumentNode(
|
|
138
|
+
// Adds the "Workflows" tab next to document editors.
|
|
139
|
+
defaultDocumentNode: workflowDefaultDocumentNode(),
|
|
154
140
|
}),
|
|
155
141
|
workflowStudioPlugin({
|
|
156
142
|
tag: 'production', // must match the deploy tag
|
|
157
|
-
mappings: workflowMappings,
|
|
158
143
|
}),
|
|
159
144
|
],
|
|
160
145
|
})
|
|
161
146
|
```
|
|
162
147
|
|
|
163
|
-
|
|
148
|
+
The plugin discovers deployed definitions whose caller-provided subject accepts
|
|
149
|
+
a document type in this Studio schema. Start the studio and open an `article`:
|
|
150
|
+
the workflow strip above the form
|
|
164
151
|
offers **Start workflow**. Once started, the strip shows the current
|
|
165
152
|
stage, the document footer shows an **active workflow** chip, and the
|
|
166
153
|
**Workflows** tab lists the stage's activities — click one to open it and
|
|
167
154
|
fire _Submit for review_, then _Approve_, and watch it reach Approved.
|
|
168
155
|
|
|
169
|
-
|
|
156
|
+
Mappings customize discovered subject bindings or explicitly bind definitions
|
|
157
|
+
that use a plain `doc.ref` instead of a first-class subject. Multiple
|
|
158
|
+
definitions for the same `docType` remain separate workflows. A mapping row
|
|
159
|
+
replaces the discovered defaults for its exact `(docType, definition)` pair or
|
|
160
|
+
adds that pair when discovery did not produce it. Duplicate rows for the same
|
|
161
|
+
pair are rejected as configuration errors.
|
|
170
162
|
|
|
171
|
-
|
|
172
|
-
status slot (it defers to the default preview for everything else). Wire it
|
|
173
|
-
per mapped schema type via `components.preview`, and select `_id` in the
|
|
174
|
-
type's `preview` so the component knows which document to look up — a custom
|
|
175
|
-
`prepare` must pass `_id` through:
|
|
163
|
+
### Workflow status in previews
|
|
176
164
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
165
|
+
Editorial Workflows status does not require `components.preview`, a projected
|
|
166
|
+
`_id`, or changes to `preview.select` / `preview.prepare`. Studio already
|
|
167
|
+
supplies document identity to preview middleware, and the plugin uses it while delegating
|
|
168
|
+
the document's title, subtitle, media, and custom preview component unchanged.
|
|
180
169
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
prepare: ({_id, title}) => ({_id, title}),
|
|
190
|
-
},
|
|
191
|
-
components: {preview: WorkflowStagePreview},
|
|
192
|
-
})
|
|
193
|
-
```
|
|
170
|
+
The status pill appears on Studio surfaces that invoke preview middleware,
|
|
171
|
+
including reference and array-item previews. A custom preview component must
|
|
172
|
+
render the `status` prop it receives if it replaces Studio's default layout.
|
|
173
|
+
|
|
174
|
+
Studio's Structure document-list rows bypass plugin preview middleware, so
|
|
175
|
+
those rows do not render workflow stage status. Their native previews remain
|
|
176
|
+
unchanged; workflow status is available in
|
|
177
|
+
the document form, footer badge, and Workflows tab.
|
|
194
178
|
|
|
195
179
|
### Auto-start a workflow on new documents
|
|
196
180
|
|
|
197
|
-
`autoStart` starts a workflow the moment an editor opens a **fresh** document
|
|
181
|
+
`autoStart` on a mapping override starts a workflow the moment an editor opens a **fresh** document
|
|
198
182
|
of a given type — the document is born with its workflow instead of relying on
|
|
199
|
-
someone to press "Start".
|
|
200
|
-
|
|
183
|
+
someone to press "Start". Add one override row for each definition that should
|
|
184
|
+
start automatically:
|
|
201
185
|
|
|
202
186
|
```ts
|
|
203
187
|
workflowStudioPlugin({
|
|
204
188
|
tag: 'production',
|
|
205
189
|
mappings: [
|
|
206
|
-
|
|
190
|
+
{docType: 'article', definition: 'article-review', label: 'Article review', autoStart: true},
|
|
191
|
+
{docType: 'campaign', definition: 'legal-review', label: 'Legal review', autoStart: true},
|
|
192
|
+
{docType: 'campaign', definition: 'brand-review', label: 'Brand review', autoStart: true},
|
|
207
193
|
],
|
|
208
|
-
autoStart: {
|
|
209
|
-
article: 'article-review', // one workflow
|
|
210
|
-
campaign: ['legal-review', 'brand-review'], // several, started together
|
|
211
|
-
},
|
|
212
194
|
})
|
|
213
195
|
```
|
|
214
196
|
|
|
215
|
-
Pass a function instead of a map to vary it by workspace (its name, or the
|
|
216
|
-
schema):
|
|
217
|
-
|
|
218
|
-
```ts
|
|
219
|
-
autoStart: ({workspaceName}) => (workspaceName === 'editorial' ? {article: 'article-review'} : {})
|
|
220
|
-
```
|
|
221
|
-
|
|
222
197
|
How it behaves:
|
|
223
198
|
|
|
224
199
|
- **Fresh only.** Studio doesn't persist a new document until its first edit,
|
|
@@ -246,9 +221,8 @@ How it behaves:
|
|
|
246
221
|
type, undeployed or spawn-only workflow, a subject that doesn't accept the
|
|
247
222
|
type) is dropped with a `console.warn`, never a crash.
|
|
248
223
|
|
|
249
|
-
|
|
250
|
-
from the deployed definition
|
|
251
|
-
same document also carries the workflow strip and views.
|
|
224
|
+
Each auto-start workflow needs a mapping override with `autoStart: true`; its
|
|
225
|
+
inputs still come from the deployed definition.
|
|
252
226
|
|
|
253
227
|
Plugin options, for later: `workflowDataset` (keep workflow state in a
|
|
254
228
|
separate dataset), `effectHandlers` (run effect side-effects in the browser
|
|
@@ -402,6 +376,14 @@ stack — see Sanity's Functions documentation for stack setup. Concurrent
|
|
|
402
376
|
runtimes are safe: ticks are idempotent, pending effects carry claims, and
|
|
403
377
|
`missingHandler: 'skip'` keeps runtimes out of each other's effects.
|
|
404
378
|
|
|
379
|
+
A third function is worth considering: deleting a document does not cascade
|
|
380
|
+
into its workflows, so instances whose documents are gone stay in-flight
|
|
381
|
+
until something settles them. The Workflows tool detects these and offers
|
|
382
|
+
to settle them all, but that needs an editor looking; a document-delete
|
|
383
|
+
function settles them the moment the deletion happens, on the robot token —
|
|
384
|
+
see the cookbook recipe
|
|
385
|
+
[Handle a deleted subject document](https://www.sanity.io/docs/editorial-workflows/cookbook-handle-deleted-subject).
|
|
386
|
+
|
|
405
387
|
## Limitations
|
|
406
388
|
|
|
407
389
|
- **Advisory enforcement.** The plugin's gates and locks are UI; only
|