@sanity/workflow-studio-plugin 0.5.0 → 0.20.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 +120 -0
- package/README.md +36 -62
- package/dist/_chunks-cjs/index.cjs +471 -248
- package/dist/_chunks-cjs/workflows-tool-root.cjs +47 -36
- package/dist/_chunks-es/index.js +475 -248
- package/dist/_chunks-es/workflows-tool-root.js +49 -38
- 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 +14 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,125 @@
|
|
|
1
1
|
# @sanity/workflow-studio-plugin
|
|
2
2
|
|
|
3
|
+
## 0.20.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 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.
|
|
8
|
+
- 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.
|
|
9
|
+
- 46b0285: **BREAKING:** Replace manually declared document applicability with automatic
|
|
10
|
+
discovery from deployed first-class subject fields.
|
|
11
|
+
|
|
12
|
+
Update Studio configuration as follows:
|
|
13
|
+
- `mappings` is optional. Omit it when every applicable definition declares a
|
|
14
|
+
first-class subject. A mapping may customize an automatically discovered
|
|
15
|
+
`(docType, definition)` binding or explicitly register a definition modeled
|
|
16
|
+
with a plain `doc.ref` instead of a first-class subject.
|
|
17
|
+
- Multiple workflows may target one document type. Use one mapping row for each
|
|
18
|
+
distinct `(docType, definition)` pair. An exact duplicate pair is a
|
|
19
|
+
configuration error rather than a last-row-wins override.
|
|
20
|
+
- Remove the top-level `autoStart` map or function. Put `autoStart: true` on
|
|
21
|
+
each mapping row that should start automatically. Configure workspace-specific
|
|
22
|
+
behavior in that workspace's mapping rows. This also works for explicitly
|
|
23
|
+
registered definitions using the `doc.ref` field named `subject` convention.
|
|
24
|
+
- Replace `workflowDefaultDocumentNode({mappings})` with
|
|
25
|
+
`workflowDefaultDocumentNode()`.
|
|
26
|
+
|
|
27
|
+
Before:
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
structureTool({defaultDocumentNode: workflowDefaultDocumentNode({mappings})})
|
|
31
|
+
workflowStudioPlugin({
|
|
32
|
+
tag: 'production',
|
|
33
|
+
mappings,
|
|
34
|
+
autoStart: {article: ['article-review', 'legal-review']},
|
|
35
|
+
})
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
After:
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
structureTool({defaultDocumentNode: workflowDefaultDocumentNode()})
|
|
42
|
+
workflowStudioPlugin({
|
|
43
|
+
tag: 'production',
|
|
44
|
+
mappings: [
|
|
45
|
+
{
|
|
46
|
+
docType: 'article',
|
|
47
|
+
definition: 'article-review',
|
|
48
|
+
label: 'Article review',
|
|
49
|
+
autoStart: true,
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
docType: 'article',
|
|
53
|
+
definition: 'legal-review',
|
|
54
|
+
label: 'Legal review',
|
|
55
|
+
autoStart: true,
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
})
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Also remove all per-schema Editorial Workflows preview wiring:
|
|
62
|
+
- Remove `components: {preview: WorkflowStagePreview}`.
|
|
63
|
+
- Remove `_id` added only for Editorial Workflows from `preview.select` and
|
|
64
|
+
stop passing it through `preview.prepare`.
|
|
65
|
+
- Remove imports of `WorkflowStagePreview`; that component is no longer a
|
|
66
|
+
public package export.
|
|
67
|
+
- Remove imports of `mappingForDocType` and `workflowDocTypes`; effective
|
|
68
|
+
mappings are resolved inside the plugin and those host-side helpers are no
|
|
69
|
+
longer exported.
|
|
70
|
+
- Keep each schema's native inferred or custom preview unchanged. The plugin
|
|
71
|
+
now installs preview middleware itself, consumes the document identity Studio
|
|
72
|
+
already supplies, and delegates title, subtitle, media, and custom preview
|
|
73
|
+
composition through `renderDefault`.
|
|
74
|
+
|
|
75
|
+
Workflow stage pills appear on Studio surfaces that invoke preview middleware,
|
|
76
|
+
including reference and array-item previews. Custom preview components that
|
|
77
|
+
replace Studio's layout must render the `status` prop they receive. Studio's
|
|
78
|
+
Structure document-list rows bypass both plugin and schema preview middleware,
|
|
79
|
+
so they do not show workflow stage pills. Workflow status remains available in
|
|
80
|
+
the document form, footer badge, Workflows view, and Workflows tool.
|
|
81
|
+
|
|
82
|
+
Document-reference GDRs for dataset content now reject stored draft IDs
|
|
83
|
+
(`drafts.<id>`) and Content Release version IDs
|
|
84
|
+
(`versions.<release>.<id>`). Use the stable document ID in the GDR and select
|
|
85
|
+
the draft or release through workflow perspective instead. The validation error
|
|
86
|
+
includes the corresponding stable ID so CLI and API callers can correct the
|
|
87
|
+
input before an unresolvable workflow instance is created.
|
|
88
|
+
|
|
89
|
+
Previously persisted draft/version GDRs remain invalid workflow identities.
|
|
90
|
+
Read-side Studio displays now tolerate them by showing the raw URI instead of
|
|
91
|
+
crashing, and query-sourced occurrences are discarded through the existing
|
|
92
|
+
fail-soft field-resolution path. Correct existing data by starting a new
|
|
93
|
+
instance with the stable document ID; perspective selects the desired draft or
|
|
94
|
+
release content.
|
|
95
|
+
|
|
96
|
+
- 98e488e: Stabilize Editorial Workflows discovery subscriptions and limit full reactive sessions to surfaces that need live evaluation.
|
|
97
|
+
- 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.
|
|
98
|
+
- 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.
|
|
99
|
+
|
|
100
|
+
### Patch Changes
|
|
101
|
+
|
|
102
|
+
- 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.
|
|
103
|
+
- ab5e454: Share projected project members and use indexed, memoized assignee display lookups.
|
|
104
|
+
- Updated dependencies [bce09fc]
|
|
105
|
+
- Updated dependencies [efb4cd9]
|
|
106
|
+
- Updated dependencies [ab5e454]
|
|
107
|
+
- Updated dependencies [46b0285]
|
|
108
|
+
- Updated dependencies [ab5e454]
|
|
109
|
+
- Updated dependencies [8a76c67]
|
|
110
|
+
- Updated dependencies [e3122cc]
|
|
111
|
+
- Updated dependencies [e3122cc]
|
|
112
|
+
- Updated dependencies [7e8f459]
|
|
113
|
+
- Updated dependencies [98e488e]
|
|
114
|
+
- Updated dependencies [7c4dd86]
|
|
115
|
+
- Updated dependencies [e860898]
|
|
116
|
+
- Updated dependencies [e3122cc]
|
|
117
|
+
- @sanity/workflow-engine@0.20.0
|
|
118
|
+
- @sanity/workflow-studio@0.20.0
|
|
119
|
+
- @sanity/workflow-react@0.20.0
|
|
120
|
+
- @sanity/workflow-components@0.20.0
|
|
121
|
+
- @sanity/workflow-diagram@0.20.0
|
|
122
|
+
|
|
3
123
|
## 0.5.0
|
|
4
124
|
|
|
5
125
|
### 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
|
|
|
@@ -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
|