@sanity/workflow-studio 0.7.0 → 0.7.1
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 +23 -0
- package/README.md +7 -7
- package/dist/index.cjs +12 -5
- package/dist/index.js +13 -6
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @sanity/workflow-studio
|
|
2
2
|
|
|
3
|
+
## 0.7.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 79c54db: Reactive session reads now match the engine's own reads.
|
|
8
|
+
- The session feeder projects every observed doc onto its watch ref's identity the way the lake's perspective reads do: the published-form id becomes `_id` (Studio/SDK stores resolve drafts and release versions under `drafts.*`/`versions.*` ids, which keyed the session's overlay and snapshot where no transition `when` condition or `$fields.<docref>` deref ever looks — an editor's uncommitted draft could not satisfy a condition the engine's `tick()` would read as satisfied), and a draft/version's stored id rides along as `_originalId`, so conditions like `_originalId in path("versions.**")` read what the engine's own hydration returns. The projection is an engine export (`projectToWatchRef`), one encoding beside `contentDraftFallback`/`contentDocQuery`, and it is strict: only the exact representations a store may legitimately resolve under the instance's perspective are accepted — anything else (another doc's dotted id under a version prefix, a version from an unbound release, a draft the perspective makes invisible) fails loudly instead of being fed under the watched identity.
|
|
9
|
+
- Watches whose perspective makes drafts invisible to the engine no longer fall back to the draft. The engine hydrates a `[release]` stack as version-over-published (and `'published'`/`'raw'` scalars as published/raw) with drafts invisible; the Studio adapter resolved `version ?? draft ?? published` and the SDK's per-doc store has the same fallback built in. The Studio adapter now skips the draft arm unless the effective perspective names `'drafts'`, and the SDK adapter observes such refs through the query store under the instance's exact perspective stack. The SDK's query-store route reads committed state (live), so local uncommitted edits to a release version doc no longer feed the session there — Studio keeps its optimistic `editState` reads. New engine helpers `contentDraftFallback` and `contentDocQuery` are the single encoding of the rule, shared with the engine's own hydration.
|
|
10
|
+
- `useWorkflowSession` resets its surfaced `evaluation` to `undefined` on an `instanceId` swap, as the contract promises, instead of leaving the previous instance's projection visible until the new instance first evaluates.
|
|
11
|
+
|
|
12
|
+
- Updated dependencies [11e2d6f]
|
|
13
|
+
- Updated dependencies [7510fd5]
|
|
14
|
+
- Updated dependencies [01e8042]
|
|
15
|
+
- Updated dependencies [79c54db]
|
|
16
|
+
- Updated dependencies [9dc592d]
|
|
17
|
+
- Updated dependencies [1a4712a]
|
|
18
|
+
- Updated dependencies [6a46db1]
|
|
19
|
+
- Updated dependencies [35b9b85]
|
|
20
|
+
- Updated dependencies [e5f5b77]
|
|
21
|
+
- Updated dependencies [01e8042]
|
|
22
|
+
- @sanity/workflow-engine@0.16.0
|
|
23
|
+
- @sanity/workflow-react@0.11.0
|
|
24
|
+
- @sanity/workflow-sdk@0.8.0
|
|
25
|
+
|
|
3
26
|
## 0.7.0
|
|
4
27
|
|
|
5
28
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -29,13 +29,13 @@ Studio source context (`useDocumentStore` / `useSource` / `useClient`).
|
|
|
29
29
|
Each ref in the watch-set is classified against the workspace's own
|
|
30
30
|
project + dataset and observed by the store that can actually address it:
|
|
31
31
|
|
|
32
|
-
| Ref
|
|
33
|
-
|
|
|
34
|
-
| **Mounted workspace dataset**
|
|
35
|
-
| **Engine state dataset** (instance doc)
|
|
36
|
-
| **Guards** (`observeGuards`)
|
|
37
|
-
| **Any other dataset / project**
|
|
38
|
-
|
|
|
32
|
+
| Ref | Observed via |
|
|
33
|
+
| ---------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
34
|
+
| **Mounted workspace dataset** | `documentStore.pair.editState` — Studio's optimistic pair store, **including local uncommitted edits** (the one stream only Studio has). Non-public Studio surface — see **Private Studio seam** below |
|
|
35
|
+
| **Engine state dataset** (instance doc) | The workspace's `documentStore` when the engine dataset IS the workspace; otherwise the **App SDK store** (`sdkInstanceDocStore` from `@sanity/workflow-sdk/observer`) |
|
|
36
|
+
| **Guards** (`observeGuards`) | Fanned per-resource across the datasets the instance's GDRs name: mounted-dataset guards via `documentStore.listenQuery`, any foreign dataset (engine's or a subject's) via `sdkGuardStore`, merged by `combineGuardStores` |
|
|
37
|
+
| **Any other dataset / project** | The **App SDK document store** (`sdkContentDocStore` from `@sanity/workflow-sdk/observer`) — live, GDR-routed per-resource — through the bootstrapped or supplied SDK instance (see below) |
|
|
38
|
+
| **`canvas:` / `media-library:` schemes** | Routed like foreign resources through the **App SDK store**, observed live via the handle's `resource` field (`{canvasId}` / `{mediaLibraryId}`) — the same path the Canvas app uses. `dashboard:` is the exception: the App SDK store has no dashboard resource, so a `dashboard:` ref **throws** and a workflow with a dashboard subject can't be driven reactively — run it engine-direct instead |
|
|
39
39
|
|
|
40
40
|
There is **no silent fallback**: a ref the configured stores can't address
|
|
41
41
|
throws, instead of being misread from the workspace dataset under the same
|
package/dist/index.cjs
CHANGED
|
@@ -33,9 +33,9 @@ function observableStore({observable: observable, resolve: resolve, initial: ini
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
function makeStudioObserver(documentStore, options) {
|
|
36
|
-
const {mounted: mounted, engineResource: engineResource, sdk: sdk2, client: client} = options, engineIsMounted = observer.sameDataset(engineResource, mounted), editStateStore = ({id: id, type: type, release: release}) => observableStore({
|
|
36
|
+
const {mounted: mounted, engineResource: engineResource, sdk: sdk2, client: client} = options, engineIsMounted = observer.sameDataset(engineResource, mounted), editStateStore = ({id: id, type: type, release: release, draftFallback: draftFallback}) => observableStore({
|
|
37
37
|
observable: documentStore.pair.editState(id, type, release),
|
|
38
|
-
resolve: resolveEditState,
|
|
38
|
+
resolve: editState => resolveEditState(editState, draftFallback),
|
|
39
39
|
initial: void 0,
|
|
40
40
|
name: `the edit state of "${id}"`
|
|
41
41
|
}), requireSdk = what => {
|
|
@@ -46,7 +46,8 @@ function makeStudioObserver(documentStore, options) {
|
|
|
46
46
|
observeInstance: instanceId => engineIsMounted ? editStateStore({
|
|
47
47
|
id: instanceId,
|
|
48
48
|
type: workflowEngine.WORKFLOW_INSTANCE_TYPE,
|
|
49
|
-
release: void 0
|
|
49
|
+
release: void 0,
|
|
50
|
+
draftFallback: !0
|
|
50
51
|
}) : observer$1.sdkInstanceDocStore({
|
|
51
52
|
sdk: requireSdk(`instance "${instanceId}" lives in the engine dataset ${engineResource.projectId}.${engineResource.dataset}`),
|
|
52
53
|
instanceId: instanceId,
|
|
@@ -60,6 +61,10 @@ function makeStudioObserver(documentStore, options) {
|
|
|
60
61
|
release: workflowEngine.contentReleaseName({
|
|
61
62
|
ref: ref,
|
|
62
63
|
perspective: perspective
|
|
64
|
+
}),
|
|
65
|
+
draftFallback: workflowEngine.contentDraftFallback({
|
|
66
|
+
ref: ref,
|
|
67
|
+
perspective: perspective
|
|
63
68
|
})
|
|
64
69
|
})
|
|
65
70
|
} : {
|
|
@@ -100,8 +105,10 @@ function makeStudioObserver(documentStore, options) {
|
|
|
100
105
|
};
|
|
101
106
|
}
|
|
102
107
|
|
|
103
|
-
function resolveEditState(editState) {
|
|
104
|
-
if (editState.ready) return
|
|
108
|
+
function resolveEditState(editState, draftFallback) {
|
|
109
|
+
if (!editState.ready) return;
|
|
110
|
+
const draft = draftFallback ? editState.draft : null;
|
|
111
|
+
return editState.version ?? draft ?? editState.published;
|
|
105
112
|
}
|
|
106
113
|
|
|
107
114
|
const SESSION_CLIENT_OPTIONS = {
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { instanceGuardQuery, contentReleaseName, WORKFLOW_INSTANCE_TYPE, ENGINE_API_VERSION, createEngine, EXECUTION_KINDS } from "@sanity/workflow-engine";
|
|
1
|
+
import { instanceGuardQuery, contentDraftFallback, contentReleaseName, WORKFLOW_INSTANCE_TYPE, ENGINE_API_VERSION, createEngine, EXECUTION_KINDS } from "@sanity/workflow-engine";
|
|
2
2
|
|
|
3
3
|
import { sameDataset, ensureDocumentExists, combineGuardStores, combineDocStores, classifyRef, datasetResourceId, useKeyed } from "@sanity/workflow-react/observer";
|
|
4
4
|
|
|
@@ -39,9 +39,9 @@ function observableStore({observable: observable, resolve: resolve, initial: ini
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
function makeStudioObserver(documentStore, options) {
|
|
42
|
-
const {mounted: mounted, engineResource: engineResource, sdk: sdk, client: client} = options, engineIsMounted = sameDataset(engineResource, mounted), editStateStore = ({id: id, type: type, release: release}) => observableStore({
|
|
42
|
+
const {mounted: mounted, engineResource: engineResource, sdk: sdk, client: client} = options, engineIsMounted = sameDataset(engineResource, mounted), editStateStore = ({id: id, type: type, release: release, draftFallback: draftFallback}) => observableStore({
|
|
43
43
|
observable: documentStore.pair.editState(id, type, release),
|
|
44
|
-
resolve: resolveEditState,
|
|
44
|
+
resolve: editState => resolveEditState(editState, draftFallback),
|
|
45
45
|
initial: void 0,
|
|
46
46
|
name: `the edit state of "${id}"`
|
|
47
47
|
}), requireSdk = what => {
|
|
@@ -52,7 +52,8 @@ function makeStudioObserver(documentStore, options) {
|
|
|
52
52
|
observeInstance: instanceId => engineIsMounted ? editStateStore({
|
|
53
53
|
id: instanceId,
|
|
54
54
|
type: WORKFLOW_INSTANCE_TYPE,
|
|
55
|
-
release: void 0
|
|
55
|
+
release: void 0,
|
|
56
|
+
draftFallback: !0
|
|
56
57
|
}) : sdkInstanceDocStore({
|
|
57
58
|
sdk: requireSdk(`instance "${instanceId}" lives in the engine dataset ${engineResource.projectId}.${engineResource.dataset}`),
|
|
58
59
|
instanceId: instanceId,
|
|
@@ -66,6 +67,10 @@ function makeStudioObserver(documentStore, options) {
|
|
|
66
67
|
release: contentReleaseName({
|
|
67
68
|
ref: ref,
|
|
68
69
|
perspective: perspective
|
|
70
|
+
}),
|
|
71
|
+
draftFallback: contentDraftFallback({
|
|
72
|
+
ref: ref,
|
|
73
|
+
perspective: perspective
|
|
69
74
|
})
|
|
70
75
|
})
|
|
71
76
|
} : {
|
|
@@ -106,8 +111,10 @@ function makeStudioObserver(documentStore, options) {
|
|
|
106
111
|
};
|
|
107
112
|
}
|
|
108
113
|
|
|
109
|
-
function resolveEditState(editState) {
|
|
110
|
-
if (editState.ready) return
|
|
114
|
+
function resolveEditState(editState, draftFallback) {
|
|
115
|
+
if (!editState.ready) return;
|
|
116
|
+
const draft = draftFallback ? editState.draft : null;
|
|
117
|
+
return editState.version ?? draft ?? editState.published;
|
|
111
118
|
}
|
|
112
119
|
|
|
113
120
|
const SESSION_CLIENT_OPTIONS = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/workflow-studio",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "React adapter that drives the @sanity/workflow-engine reactive session from the Sanity Studio document store.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -41,9 +41,9 @@
|
|
|
41
41
|
"access": "public"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@sanity/workflow-engine": "0.
|
|
45
|
-
"@sanity/workflow-react": "0.
|
|
46
|
-
"@sanity/workflow-sdk": "0.
|
|
44
|
+
"@sanity/workflow-engine": "0.16.0",
|
|
45
|
+
"@sanity/workflow-react": "0.11.0",
|
|
46
|
+
"@sanity/workflow-sdk": "0.8.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@sanity/pkg-utils": "^10.5.2",
|