@sanity/workflow-studio 0.7.1 → 0.8.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 +26 -0
- package/README.md +12 -3
- package/dist/index.cjs +8 -8
- package/dist/index.js +9 -9
- package/package.json +6 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @sanity/workflow-studio
|
|
2
2
|
|
|
3
|
+
## 0.8.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 5a1a9fe: The observers validate every engine-owned stream (instance doc, guards, instance lists) at the store boundary — the engine's read discipline (data-model gate + shape parse) instead of a cast, with a failure surfaced as the session's explicit `invalid` state. Content-doc streams are foreign and pass through unvalidated, as before.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [f9389e5]
|
|
12
|
+
- Updated dependencies [d0c62ea]
|
|
13
|
+
- Updated dependencies [c3eed2e]
|
|
14
|
+
- Updated dependencies [df4bd80]
|
|
15
|
+
- Updated dependencies [092a0d4]
|
|
16
|
+
- Updated dependencies [5a1a9fe]
|
|
17
|
+
- Updated dependencies [5a1a9fe]
|
|
18
|
+
- Updated dependencies [5a1a9fe]
|
|
19
|
+
- Updated dependencies [e3a7ba2]
|
|
20
|
+
- Updated dependencies [30fed9e]
|
|
21
|
+
- Updated dependencies [c3eed2e]
|
|
22
|
+
- Updated dependencies [1321ba5]
|
|
23
|
+
- Updated dependencies [e683875]
|
|
24
|
+
- Updated dependencies [a8ace4d]
|
|
25
|
+
- @sanity/workflow-engine@0.17.0
|
|
26
|
+
- @sanity/workflow-sdk@0.9.0
|
|
27
|
+
- @sanity/workflow-react@0.12.0
|
|
28
|
+
|
|
3
29
|
## 0.7.1
|
|
4
30
|
|
|
5
31
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -10,14 +10,23 @@ Studio source context (`useDocumentStore` / `useSource` / `useClient`).
|
|
|
10
10
|
exported) as the default per-resource routing that reaches any `dataset:`
|
|
11
11
|
GDR by rebinding the same client, pinned to the engine version too. A custom `resourceClients` replaces the default — delegate
|
|
12
12
|
to `studioResourceClients` for the dataset arm; schemes it returns
|
|
13
|
-
`undefined` for (media-library, canvas) are
|
|
13
|
+
`undefined` for (media-library, canvas) are READ by the engine itself,
|
|
14
14
|
which derives a sibling client from the engine client's credentials.
|
|
15
|
+
Writing a runtime-supplied ref to such a scheme into field state
|
|
16
|
+
additionally needs the resolver to SERVE that resource — serving is what
|
|
17
|
+
declares it on the engine's written-ref surface; an undeclared
|
|
18
|
+
media-library/canvas ref is rejected at the write with
|
|
19
|
+
`RefResourceUndeclaredError`. (Definition content is unaffected — deploy
|
|
20
|
+
vets it.)
|
|
15
21
|
- `useWorkflowSession` — drives an engine session for one instance and
|
|
16
22
|
returns
|
|
17
|
-
`{evaluation, ready, guards, tick, fireAction, editField, previewField, discardFieldPreview}`.
|
|
23
|
+
`{evaluation, ready, invalid, guards, tick, fireAction, editField, previewField, discardFieldPreview}`.
|
|
24
|
+
The observer validates every engine-owned stream, so a model-ahead or
|
|
25
|
+
corrupt doc surfaces as the explicit `invalid` state (never `ready` while
|
|
26
|
+
set) instead of an eternal spinner.
|
|
18
27
|
- `useWorkflowInstances` / `useDocumentWorkflows` — live instance lists
|
|
19
28
|
(filterable collection / per-document discovery), each returning
|
|
20
|
-
`{instances, loading}`. The list observes `documentStore.listenQuery` when
|
|
29
|
+
`{instances, loading, invalid}`. The list observes `documentStore.listenQuery` when
|
|
21
30
|
the engine dataset is the workspace's own, else the App SDK store — same
|
|
22
31
|
routing (and same `sdk` rules) as the instance doc below. On multi-hook
|
|
23
32
|
surfaces (a board with per-row `useWorkflowSession`), pass one shared
|
package/dist/index.cjs
CHANGED
|
@@ -43,16 +43,16 @@ function makeStudioObserver(documentStore, options) {
|
|
|
43
43
|
throw new Error(`@sanity/workflow-studio: ${what} — Studio's document store is bound to ${mounted.projectId}.${mounted.dataset} and cannot observe it. Pass an App SDK instance via the hook's \`sdk\` option (e.g. \`useWorkflowSession({engine, instanceId, sdk})\`) to observe foreign resources.`);
|
|
44
44
|
};
|
|
45
45
|
return {
|
|
46
|
-
observeInstance: instanceId => engineIsMounted ? editStateStore({
|
|
46
|
+
observeInstance: instanceId => engineIsMounted ? observer.validatedInstanceStore(editStateStore({
|
|
47
47
|
id: instanceId,
|
|
48
48
|
type: workflowEngine.WORKFLOW_INSTANCE_TYPE,
|
|
49
49
|
release: void 0,
|
|
50
50
|
draftFallback: !0
|
|
51
|
-
}) : observer$1.sdkInstanceDocStore({
|
|
51
|
+
})) : observer.validatedInstanceStore(observer$1.sdkInstanceDocStore({
|
|
52
52
|
sdk: requireSdk(`instance "${instanceId}" lives in the engine dataset ${engineResource.projectId}.${engineResource.dataset}`),
|
|
53
53
|
instanceId: instanceId,
|
|
54
54
|
engineResource: engineResource
|
|
55
|
-
}),
|
|
55
|
+
})),
|
|
56
56
|
observeDocs: (documents, perspective) => observer.combineDocStores(documents.map(ref => observer.classifyRef(ref, mounted) === "mounted-dataset" ? {
|
|
57
57
|
key: ref.globalDocumentId,
|
|
58
58
|
store: editStateStore({
|
|
@@ -75,7 +75,7 @@ function makeStudioObserver(documentStore, options) {
|
|
|
75
75
|
perspective: perspective
|
|
76
76
|
})
|
|
77
77
|
})),
|
|
78
|
-
observeGuards: (instanceId, resources) => observer.combineGuardStores(resources.map(resource => {
|
|
78
|
+
observeGuards: (instanceId, resources) => observer.validatedGuardsStore(observer.combineGuardStores(resources.map(resource => {
|
|
79
79
|
if (observer.sameDataset(resource, mounted)) {
|
|
80
80
|
const {query: query, params: params} = workflowEngine.instanceGuardQuery(instanceId);
|
|
81
81
|
return observableStore({
|
|
@@ -90,17 +90,17 @@ function makeStudioObserver(documentStore, options) {
|
|
|
90
90
|
instanceId: instanceId,
|
|
91
91
|
resource: resource
|
|
92
92
|
});
|
|
93
|
-
})),
|
|
94
|
-
observeInstances: query => engineIsMounted ? observableStore({
|
|
93
|
+
}))),
|
|
94
|
+
observeInstances: query => engineIsMounted ? observer.validatedInstancesStore(observableStore({
|
|
95
95
|
observable: documentStore.listenQuery(query.query, query.params, {}),
|
|
96
96
|
resolve: docs => docs,
|
|
97
97
|
initial: void 0,
|
|
98
98
|
name: "the instance list"
|
|
99
|
-
}) : observer$1.sdkInstancesStore({
|
|
99
|
+
})) : observer.validatedInstancesStore(observer$1.sdkInstancesStore({
|
|
100
100
|
sdk: requireSdk(`the instance list lives in the engine dataset ${engineResource.projectId}.${engineResource.dataset}`),
|
|
101
101
|
query: query,
|
|
102
102
|
resource: engineResource
|
|
103
|
-
}),
|
|
103
|
+
})),
|
|
104
104
|
ensureDocumentExists: args => observer.ensureDocumentExists(client, args)
|
|
105
105
|
};
|
|
106
106
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { instanceGuardQuery, contentDraftFallback, contentReleaseName, WORKFLOW_INSTANCE_TYPE, ENGINE_API_VERSION, createEngine, EXECUTION_KINDS } from "@sanity/workflow-engine";
|
|
2
2
|
|
|
3
|
-
import { sameDataset, ensureDocumentExists, combineGuardStores, combineDocStores, classifyRef, datasetResourceId, useKeyed } from "@sanity/workflow-react/observer";
|
|
3
|
+
import { sameDataset, ensureDocumentExists, validatedInstancesStore, validatedGuardsStore, combineGuardStores, combineDocStores, classifyRef, validatedInstanceStore, datasetResourceId, useKeyed } from "@sanity/workflow-react/observer";
|
|
4
4
|
|
|
5
5
|
import { sdkInstancesStore, sdkGuardStore, sdkContentDocStore, sdkInstanceDocStore } from "@sanity/workflow-sdk/observer";
|
|
6
6
|
|
|
@@ -49,16 +49,16 @@ function makeStudioObserver(documentStore, options) {
|
|
|
49
49
|
throw new Error(`@sanity/workflow-studio: ${what} — Studio's document store is bound to ${mounted.projectId}.${mounted.dataset} and cannot observe it. Pass an App SDK instance via the hook's \`sdk\` option (e.g. \`useWorkflowSession({engine, instanceId, sdk})\`) to observe foreign resources.`);
|
|
50
50
|
};
|
|
51
51
|
return {
|
|
52
|
-
observeInstance: instanceId => engineIsMounted ? editStateStore({
|
|
52
|
+
observeInstance: instanceId => engineIsMounted ? validatedInstanceStore(editStateStore({
|
|
53
53
|
id: instanceId,
|
|
54
54
|
type: WORKFLOW_INSTANCE_TYPE,
|
|
55
55
|
release: void 0,
|
|
56
56
|
draftFallback: !0
|
|
57
|
-
}) : sdkInstanceDocStore({
|
|
57
|
+
})) : validatedInstanceStore(sdkInstanceDocStore({
|
|
58
58
|
sdk: requireSdk(`instance "${instanceId}" lives in the engine dataset ${engineResource.projectId}.${engineResource.dataset}`),
|
|
59
59
|
instanceId: instanceId,
|
|
60
60
|
engineResource: engineResource
|
|
61
|
-
}),
|
|
61
|
+
})),
|
|
62
62
|
observeDocs: (documents, perspective) => combineDocStores(documents.map(ref => classifyRef(ref, mounted) === "mounted-dataset" ? {
|
|
63
63
|
key: ref.globalDocumentId,
|
|
64
64
|
store: editStateStore({
|
|
@@ -81,7 +81,7 @@ function makeStudioObserver(documentStore, options) {
|
|
|
81
81
|
perspective: perspective
|
|
82
82
|
})
|
|
83
83
|
})),
|
|
84
|
-
observeGuards: (instanceId, resources) => combineGuardStores(resources.map(resource => {
|
|
84
|
+
observeGuards: (instanceId, resources) => validatedGuardsStore(combineGuardStores(resources.map(resource => {
|
|
85
85
|
if (sameDataset(resource, mounted)) {
|
|
86
86
|
const {query: query, params: params} = instanceGuardQuery(instanceId);
|
|
87
87
|
return observableStore({
|
|
@@ -96,17 +96,17 @@ function makeStudioObserver(documentStore, options) {
|
|
|
96
96
|
instanceId: instanceId,
|
|
97
97
|
resource: resource
|
|
98
98
|
});
|
|
99
|
-
})),
|
|
100
|
-
observeInstances: query => engineIsMounted ? observableStore({
|
|
99
|
+
}))),
|
|
100
|
+
observeInstances: query => engineIsMounted ? validatedInstancesStore(observableStore({
|
|
101
101
|
observable: documentStore.listenQuery(query.query, query.params, {}),
|
|
102
102
|
resolve: docs => docs,
|
|
103
103
|
initial: void 0,
|
|
104
104
|
name: "the instance list"
|
|
105
|
-
}) : sdkInstancesStore({
|
|
105
|
+
})) : validatedInstancesStore(sdkInstancesStore({
|
|
106
106
|
sdk: requireSdk(`the instance list lives in the engine dataset ${engineResource.projectId}.${engineResource.dataset}`),
|
|
107
107
|
query: query,
|
|
108
108
|
resource: engineResource
|
|
109
|
-
}),
|
|
109
|
+
})),
|
|
110
110
|
ensureDocumentExists: args => ensureDocumentExists(client, args)
|
|
111
111
|
};
|
|
112
112
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/workflow-studio",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
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.17.0",
|
|
45
|
+
"@sanity/workflow-react": "0.12.0",
|
|
46
|
+
"@sanity/workflow-sdk": "0.9.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@sanity/pkg-utils": "^10.5.2",
|
|
@@ -54,7 +54,8 @@
|
|
|
54
54
|
"react": "^19.2.7",
|
|
55
55
|
"react-dom": "^19.2.7",
|
|
56
56
|
"sanity": "^5.30.0",
|
|
57
|
-
"vitest": "^4.1.8"
|
|
57
|
+
"vitest": "^4.1.8",
|
|
58
|
+
"@sanity/workflow-engine-test": "0.12.0"
|
|
58
59
|
},
|
|
59
60
|
"peerDependencies": {
|
|
60
61
|
"@sanity/sdk": "^2.12.0",
|