@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/dist/index.cjs
CHANGED
|
@@ -6,14 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
|
|
7
7
|
var index = require("./_chunks-cjs/index.cjs");
|
|
8
8
|
|
|
9
|
-
exports.WorkflowStagePreview = index.WorkflowStagePreview;
|
|
10
|
-
|
|
11
|
-
exports.mappingForDocType = index.mappingForDocType;
|
|
12
|
-
|
|
13
9
|
exports.workflowDefaultDocumentNode = index.workflowDefaultDocumentNode;
|
|
14
10
|
|
|
15
|
-
exports.workflowDocTypes = index.workflowDocTypes;
|
|
16
|
-
|
|
17
11
|
exports.workflowStudioPlugin = index.workflowStudioPlugin;
|
|
18
12
|
|
|
19
13
|
exports.workflowsView = index.workflowsView;
|
package/dist/index.d.cts
CHANGED
|
@@ -2,73 +2,28 @@ import type { DefaultDocumentNodeResolver } from "sanity/structure";
|
|
|
2
2
|
import { EffectHandler } from "@sanity/workflow-engine";
|
|
3
3
|
import { GlobalDocumentReference } from "@sanity/workflow-engine";
|
|
4
4
|
import { InitialFieldValue } from "@sanity/workflow-engine";
|
|
5
|
-
import { JSX } from "react";
|
|
6
5
|
import { Plugin as Plugin_2 } from "sanity";
|
|
7
|
-
import { PreviewProps } from "sanity";
|
|
8
6
|
import { ResourceClientResolver } from "@sanity/workflow-engine";
|
|
9
7
|
import type { SanityClient } from "sanity";
|
|
10
|
-
import type { Schema } from "sanity";
|
|
11
8
|
import { StartContext } from "@sanity/workflow-engine";
|
|
12
9
|
import type { StructureBuilder } from "sanity/structure";
|
|
13
10
|
import type { ViewBuilder } from "sanity/structure";
|
|
14
11
|
|
|
15
12
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*/
|
|
20
|
-
declare type AutoStart =
|
|
21
|
-
| AutoStartMap
|
|
22
|
-
| ((context: AutoStartContext) => AutoStartMap);
|
|
23
|
-
|
|
24
|
-
/** What the plugin layout hands the function form of {@link AutoStart}. */
|
|
25
|
-
declare interface AutoStartContext {
|
|
26
|
-
/** The Studio workspace name. */
|
|
27
|
-
readonly workspaceName: string;
|
|
28
|
-
/** The workspace schema — to derive or gate on document types. */
|
|
29
|
-
readonly schema: Schema;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Document `_type` → the deployed workflow definition name(s) to auto-start on
|
|
34
|
-
* a fresh document of that type. Several names ⇒ all start together: one
|
|
35
|
-
* dialog collects the union of their required inputs, and the fresh document
|
|
36
|
-
* is the shared subject of each. Naming a workflow here does not require a
|
|
37
|
-
* {@link WorkflowMapping} entry — the required inputs come from the deployed
|
|
38
|
-
* definition itself.
|
|
39
|
-
*/
|
|
40
|
-
declare type AutoStartMap = Record<string, string | readonly string[]>;
|
|
41
|
-
|
|
42
|
-
/** The first mapping row for a document type — the tie-break wherever a
|
|
43
|
-
* surface binds to exactly one row. */
|
|
44
|
-
export declare function mappingForDocType(
|
|
45
|
-
mappings: readonly WorkflowMapping[],
|
|
46
|
-
docType: string,
|
|
47
|
-
): WorkflowMapping | undefined;
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Convenience `defaultDocumentNode`: mapped document types get the form view
|
|
51
|
-
* plus the Workflows view; everything else keeps the structure default.
|
|
13
|
+
* Convenience `defaultDocumentNode`: every content-document type gets the
|
|
14
|
+
* form view plus the Workflows view. Runtime definition discovery determines
|
|
15
|
+
* which workflows apply after the Studio mounts.
|
|
52
16
|
*
|
|
53
17
|
* ```ts
|
|
54
|
-
* structureTool({defaultDocumentNode: workflowDefaultDocumentNode(
|
|
18
|
+
* structureTool({defaultDocumentNode: workflowDefaultDocumentNode()})
|
|
55
19
|
* ```
|
|
56
20
|
*/
|
|
57
|
-
export declare function workflowDefaultDocumentNode(
|
|
58
|
-
mappings: readonly WorkflowMapping[];
|
|
59
|
-
}): DefaultDocumentNodeResolver;
|
|
60
|
-
|
|
61
|
-
/** The schema types the plugin contributes workflow surfaces to. */
|
|
62
|
-
export declare function workflowDocTypes(
|
|
63
|
-
mappings: readonly WorkflowMapping[],
|
|
64
|
-
): ReadonlySet<string>;
|
|
21
|
+
export declare function workflowDefaultDocumentNode(): DefaultDocumentNodeResolver;
|
|
65
22
|
|
|
66
23
|
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
* Adding a workflow-driven doctype to a studio is one entry in the host's
|
|
71
|
-
* mapping table.
|
|
24
|
+
* Studio-specific behavior for one `(docType, definition)` binding. A row may
|
|
25
|
+
* customize an automatically discovered subject binding or explicitly bind a
|
|
26
|
+
* definition modeled with a plain `doc.ref`.
|
|
72
27
|
*/
|
|
73
28
|
export declare interface WorkflowMapping {
|
|
74
29
|
/** Studio schema type. */
|
|
@@ -77,6 +32,8 @@ export declare interface WorkflowMapping {
|
|
|
77
32
|
readonly definition: string;
|
|
78
33
|
/** Human-readable label for menus and dialogs. */
|
|
79
34
|
readonly label: string;
|
|
35
|
+
/** Start this workflow when a fresh document of {@link docType} is created. */
|
|
36
|
+
readonly autoStart?: boolean;
|
|
80
37
|
/** Optional initial workflow field entries to seed on Start. */
|
|
81
38
|
readonly initialStateBuilder?: (
|
|
82
39
|
subjectGdr: GlobalDocumentReference,
|
|
@@ -111,8 +68,12 @@ export declare interface WorkflowPluginConfig {
|
|
|
111
68
|
/** Dataset holding workflow definitions + instances. Defaults to the
|
|
112
69
|
* workspace's own dataset (single-dataset setup). */
|
|
113
70
|
readonly workflowDataset?: string;
|
|
114
|
-
/**
|
|
115
|
-
|
|
71
|
+
/**
|
|
72
|
+
* Studio-specific bindings. Rows customize discovered first-class subjects
|
|
73
|
+
* or explicitly register definitions that use the `doc.ref` subject
|
|
74
|
+
* convention.
|
|
75
|
+
*/
|
|
76
|
+
readonly mappings?: readonly WorkflowMapping[];
|
|
116
77
|
/**
|
|
117
78
|
* Browser-side effect handlers keyed by effect name (the engine's
|
|
118
79
|
* {@link EffectHandler}). Registered handlers drain in the Studio after
|
|
@@ -129,27 +90,8 @@ export declare interface WorkflowPluginConfig {
|
|
|
129
90
|
* stable (module scope or memoized).
|
|
130
91
|
*/
|
|
131
92
|
readonly resourceClients?: ResourceClientResolver;
|
|
132
|
-
/**
|
|
133
|
-
* Auto-start workflows when a FRESH document of a configured type is created
|
|
134
|
-
* in this Studio — the plugin takes over the form until they've started
|
|
135
|
-
* (collecting any inputs the workflows need beyond the subject), so the
|
|
136
|
-
* document is born with its workflow. A starting *convenience*, not
|
|
137
|
-
* enforcement: a raw client or any non-Studio surface bypasses it entirely,
|
|
138
|
-
* and pre-existing documents are never touched. Studio-only. See
|
|
139
|
-
* {@link AutoStart}.
|
|
140
|
-
*/
|
|
141
|
-
readonly autoStart?: AutoStart;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
declare interface WorkflowPreviewProps extends PreviewProps {
|
|
145
|
-
readonly _id?: string;
|
|
146
|
-
readonly documentId?: string;
|
|
147
93
|
}
|
|
148
94
|
|
|
149
|
-
export declare function WorkflowStagePreview(
|
|
150
|
-
props: WorkflowPreviewProps,
|
|
151
|
-
): JSX.Element;
|
|
152
|
-
|
|
153
95
|
export declare const workflowStudioPlugin: Plugin_2<WorkflowPluginConfig>;
|
|
154
96
|
|
|
155
97
|
/** The Workflows view for one document — append it to any `views([...])`. */
|
package/dist/index.d.ts
CHANGED
|
@@ -2,73 +2,28 @@ import type { DefaultDocumentNodeResolver } from "sanity/structure";
|
|
|
2
2
|
import { EffectHandler } from "@sanity/workflow-engine";
|
|
3
3
|
import { GlobalDocumentReference } from "@sanity/workflow-engine";
|
|
4
4
|
import { InitialFieldValue } from "@sanity/workflow-engine";
|
|
5
|
-
import { JSX } from "react";
|
|
6
5
|
import { Plugin as Plugin_2 } from "sanity";
|
|
7
|
-
import { PreviewProps } from "sanity";
|
|
8
6
|
import { ResourceClientResolver } from "@sanity/workflow-engine";
|
|
9
7
|
import type { SanityClient } from "sanity";
|
|
10
|
-
import type { Schema } from "sanity";
|
|
11
8
|
import { StartContext } from "@sanity/workflow-engine";
|
|
12
9
|
import type { StructureBuilder } from "sanity/structure";
|
|
13
10
|
import type { ViewBuilder } from "sanity/structure";
|
|
14
11
|
|
|
15
12
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*/
|
|
20
|
-
declare type AutoStart =
|
|
21
|
-
| AutoStartMap
|
|
22
|
-
| ((context: AutoStartContext) => AutoStartMap);
|
|
23
|
-
|
|
24
|
-
/** What the plugin layout hands the function form of {@link AutoStart}. */
|
|
25
|
-
declare interface AutoStartContext {
|
|
26
|
-
/** The Studio workspace name. */
|
|
27
|
-
readonly workspaceName: string;
|
|
28
|
-
/** The workspace schema — to derive or gate on document types. */
|
|
29
|
-
readonly schema: Schema;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Document `_type` → the deployed workflow definition name(s) to auto-start on
|
|
34
|
-
* a fresh document of that type. Several names ⇒ all start together: one
|
|
35
|
-
* dialog collects the union of their required inputs, and the fresh document
|
|
36
|
-
* is the shared subject of each. Naming a workflow here does not require a
|
|
37
|
-
* {@link WorkflowMapping} entry — the required inputs come from the deployed
|
|
38
|
-
* definition itself.
|
|
39
|
-
*/
|
|
40
|
-
declare type AutoStartMap = Record<string, string | readonly string[]>;
|
|
41
|
-
|
|
42
|
-
/** The first mapping row for a document type — the tie-break wherever a
|
|
43
|
-
* surface binds to exactly one row. */
|
|
44
|
-
export declare function mappingForDocType(
|
|
45
|
-
mappings: readonly WorkflowMapping[],
|
|
46
|
-
docType: string,
|
|
47
|
-
): WorkflowMapping | undefined;
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Convenience `defaultDocumentNode`: mapped document types get the form view
|
|
51
|
-
* plus the Workflows view; everything else keeps the structure default.
|
|
13
|
+
* Convenience `defaultDocumentNode`: every content-document type gets the
|
|
14
|
+
* form view plus the Workflows view. Runtime definition discovery determines
|
|
15
|
+
* which workflows apply after the Studio mounts.
|
|
52
16
|
*
|
|
53
17
|
* ```ts
|
|
54
|
-
* structureTool({defaultDocumentNode: workflowDefaultDocumentNode(
|
|
18
|
+
* structureTool({defaultDocumentNode: workflowDefaultDocumentNode()})
|
|
55
19
|
* ```
|
|
56
20
|
*/
|
|
57
|
-
export declare function workflowDefaultDocumentNode(
|
|
58
|
-
mappings: readonly WorkflowMapping[];
|
|
59
|
-
}): DefaultDocumentNodeResolver;
|
|
60
|
-
|
|
61
|
-
/** The schema types the plugin contributes workflow surfaces to. */
|
|
62
|
-
export declare function workflowDocTypes(
|
|
63
|
-
mappings: readonly WorkflowMapping[],
|
|
64
|
-
): ReadonlySet<string>;
|
|
21
|
+
export declare function workflowDefaultDocumentNode(): DefaultDocumentNodeResolver;
|
|
65
22
|
|
|
66
23
|
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
* Adding a workflow-driven doctype to a studio is one entry in the host's
|
|
71
|
-
* mapping table.
|
|
24
|
+
* Studio-specific behavior for one `(docType, definition)` binding. A row may
|
|
25
|
+
* customize an automatically discovered subject binding or explicitly bind a
|
|
26
|
+
* definition modeled with a plain `doc.ref`.
|
|
72
27
|
*/
|
|
73
28
|
export declare interface WorkflowMapping {
|
|
74
29
|
/** Studio schema type. */
|
|
@@ -77,6 +32,8 @@ export declare interface WorkflowMapping {
|
|
|
77
32
|
readonly definition: string;
|
|
78
33
|
/** Human-readable label for menus and dialogs. */
|
|
79
34
|
readonly label: string;
|
|
35
|
+
/** Start this workflow when a fresh document of {@link docType} is created. */
|
|
36
|
+
readonly autoStart?: boolean;
|
|
80
37
|
/** Optional initial workflow field entries to seed on Start. */
|
|
81
38
|
readonly initialStateBuilder?: (
|
|
82
39
|
subjectGdr: GlobalDocumentReference,
|
|
@@ -111,8 +68,12 @@ export declare interface WorkflowPluginConfig {
|
|
|
111
68
|
/** Dataset holding workflow definitions + instances. Defaults to the
|
|
112
69
|
* workspace's own dataset (single-dataset setup). */
|
|
113
70
|
readonly workflowDataset?: string;
|
|
114
|
-
/**
|
|
115
|
-
|
|
71
|
+
/**
|
|
72
|
+
* Studio-specific bindings. Rows customize discovered first-class subjects
|
|
73
|
+
* or explicitly register definitions that use the `doc.ref` subject
|
|
74
|
+
* convention.
|
|
75
|
+
*/
|
|
76
|
+
readonly mappings?: readonly WorkflowMapping[];
|
|
116
77
|
/**
|
|
117
78
|
* Browser-side effect handlers keyed by effect name (the engine's
|
|
118
79
|
* {@link EffectHandler}). Registered handlers drain in the Studio after
|
|
@@ -129,27 +90,8 @@ export declare interface WorkflowPluginConfig {
|
|
|
129
90
|
* stable (module scope or memoized).
|
|
130
91
|
*/
|
|
131
92
|
readonly resourceClients?: ResourceClientResolver;
|
|
132
|
-
/**
|
|
133
|
-
* Auto-start workflows when a FRESH document of a configured type is created
|
|
134
|
-
* in this Studio — the plugin takes over the form until they've started
|
|
135
|
-
* (collecting any inputs the workflows need beyond the subject), so the
|
|
136
|
-
* document is born with its workflow. A starting *convenience*, not
|
|
137
|
-
* enforcement: a raw client or any non-Studio surface bypasses it entirely,
|
|
138
|
-
* and pre-existing documents are never touched. Studio-only. See
|
|
139
|
-
* {@link AutoStart}.
|
|
140
|
-
*/
|
|
141
|
-
readonly autoStart?: AutoStart;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
declare interface WorkflowPreviewProps extends PreviewProps {
|
|
145
|
-
readonly _id?: string;
|
|
146
|
-
readonly documentId?: string;
|
|
147
93
|
}
|
|
148
94
|
|
|
149
|
-
export declare function WorkflowStagePreview(
|
|
150
|
-
props: WorkflowPreviewProps,
|
|
151
|
-
): JSX.Element;
|
|
152
|
-
|
|
153
95
|
export declare const workflowStudioPlugin: Plugin_2<WorkflowPluginConfig>;
|
|
154
96
|
|
|
155
97
|
/** The Workflows view for one document — append it to any `views([...])`. */
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { workflowDefaultDocumentNode, workflowStudioPlugin, workflowsView } from "./_chunks-es/index.js";
|
|
2
2
|
|
|
3
|
-
export {
|
|
3
|
+
export { workflowDefaultDocumentNode, workflowStudioPlugin, workflowsView };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/workflow-studio-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"description": "Sanity Studio plugin for @sanity/workflow-engine: the form strip, a Workflows document view, stage badges, and the document-action lock.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -44,16 +44,13 @@
|
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@sanity/client": "^7.23.0",
|
|
46
46
|
"@sanity/icons": "^4.1.0",
|
|
47
|
+
"@sanity/telemetry": "^1.1.0",
|
|
47
48
|
"@sanity/types": "^6",
|
|
48
49
|
"@sanity/ui": "^3.3.0",
|
|
49
50
|
"@sanity/util": "^6.3.0",
|
|
50
51
|
"date-fns": "^4.4.0",
|
|
51
52
|
"pluralize-esm": "^9.0.5",
|
|
52
|
-
"
|
|
53
|
-
"@sanity/workflow-diagram": "0.4.1",
|
|
54
|
-
"@sanity/workflow-engine": "0.19.0",
|
|
55
|
-
"@sanity/workflow-react": "0.14.0",
|
|
56
|
-
"@sanity/workflow-studio": "0.10.0"
|
|
53
|
+
"rxjs": "^7.8.2"
|
|
57
54
|
},
|
|
58
55
|
"devDependencies": {
|
|
59
56
|
"@sanity/pkg-utils": "^10.5.3",
|
|
@@ -68,14 +65,24 @@
|
|
|
68
65
|
"sanity": "^6",
|
|
69
66
|
"styled-components": "^6.4.2",
|
|
70
67
|
"vitest": "^4.1.8",
|
|
71
|
-
"@sanity/workflow-
|
|
68
|
+
"@sanity/workflow-components": "0.21.0",
|
|
69
|
+
"@sanity/workflow-diagram": "0.21.0",
|
|
70
|
+
"@sanity/workflow-engine": "0.21.0",
|
|
71
|
+
"@sanity/workflow-engine-test": "0.21.0",
|
|
72
|
+
"@sanity/workflow-react": "0.21.0",
|
|
73
|
+
"@sanity/workflow-studio": "0.21.0"
|
|
72
74
|
},
|
|
73
75
|
"peerDependencies": {
|
|
74
76
|
"@sanity/sdk": "^2.12.0",
|
|
75
77
|
"react": "^19.2.7",
|
|
76
78
|
"react-dom": "^19.2.7",
|
|
77
|
-
"sanity": "^6",
|
|
78
|
-
"styled-components": "^6.4.2"
|
|
79
|
+
"sanity": "^6.3.0",
|
|
80
|
+
"styled-components": "^6.4.2",
|
|
81
|
+
"@sanity/workflow-components": "0.21.0",
|
|
82
|
+
"@sanity/workflow-diagram": "0.21.0",
|
|
83
|
+
"@sanity/workflow-react": "0.21.0",
|
|
84
|
+
"@sanity/workflow-engine": "0.21.0",
|
|
85
|
+
"@sanity/workflow-studio": "0.21.0"
|
|
79
86
|
},
|
|
80
87
|
"engines": {
|
|
81
88
|
"node": ">=20"
|