@sanity/workflow-studio-plugin 0.3.0 → 0.5.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/dist/index.d.cts CHANGED
@@ -6,10 +6,39 @@ import { JSX } from "react";
6
6
  import { Plugin as Plugin_2 } from "sanity";
7
7
  import { PreviewProps } from "sanity";
8
8
  import { ResourceClientResolver } from "@sanity/workflow-engine";
9
+ import type { SanityClient } from "sanity";
10
+ import type { Schema } from "sanity";
9
11
  import { StartContext } from "@sanity/workflow-engine";
10
12
  import type { StructureBuilder } from "sanity/structure";
11
13
  import type { ViewBuilder } from "sanity/structure";
12
14
 
15
+ /**
16
+ * The auto-start map, or a function computing it from the workspace at
17
+ * runtime (so it can vary by workspace name or schema). Resolved and
18
+ * validated in the plugin layout; see {@link resolveAutoStart}.
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
+
13
42
  /** The first mapping row for a document type — the tie-break wherever a
14
43
  * surface binds to exactly one row. */
15
44
  export declare function mappingForDocType(
@@ -44,22 +73,8 @@ export declare function workflowDocTypes(
44
73
  export declare interface WorkflowMapping {
45
74
  /** Studio schema type. */
46
75
  readonly docType: string;
47
- /**
48
- * The document type must have a workflow: the editor form is gated until
49
- * an instance references the document. Doctype-level: the flag on ANY
50
- * mapping row for a docType gates the form, and starting any mapped
51
- * workflow satisfies the gate. Advisory, UI-only enforcement — any raw
52
- * API client can still write; the Content Lake is the only enforcement
53
- * point.
54
- */
55
- readonly mandatory?: boolean;
56
76
  /** The definition `name` the engine deployed under. */
57
77
  readonly definition: string;
58
- /** Logical role of the doc — sets the GDR `type` discriminator in the
59
- * builders. Subject lives on a field `doc.ref` entry, not an envelope. */
60
- readonly subjectKind: "document" | "release";
61
- /** Schema type stamped into the `doc.ref` field entry's `value.type`. */
62
- readonly subjectGdrType: string;
63
78
  /** Human-readable label for menus and dialogs. */
64
79
  readonly label: string;
65
80
  /** Optional initial workflow field entries to seed on Start. */
@@ -104,7 +119,7 @@ export declare interface WorkflowPluginConfig {
104
119
  * each committed action; anything unregistered stays pending for another
105
120
  * runtime to claim.
106
121
  */
107
- readonly effectHandlers?: Record<string, EffectHandler>;
122
+ readonly effectHandlers?: Record<string, EffectHandler<SanityClient>>;
108
123
  /**
109
124
  * Routing override for cross-resource reads, replacing the Studio's
110
125
  * default per-dataset routing — see `useWorkflowEngine`. A served resource
@@ -114,6 +129,16 @@ export declare interface WorkflowPluginConfig {
114
129
  * stable (module scope or memoized).
115
130
  */
116
131
  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;
117
142
  }
118
143
 
119
144
  declare interface WorkflowPreviewProps extends PreviewProps {
package/dist/index.d.ts CHANGED
@@ -6,10 +6,39 @@ import { JSX } from "react";
6
6
  import { Plugin as Plugin_2 } from "sanity";
7
7
  import { PreviewProps } from "sanity";
8
8
  import { ResourceClientResolver } from "@sanity/workflow-engine";
9
+ import type { SanityClient } from "sanity";
10
+ import type { Schema } from "sanity";
9
11
  import { StartContext } from "@sanity/workflow-engine";
10
12
  import type { StructureBuilder } from "sanity/structure";
11
13
  import type { ViewBuilder } from "sanity/structure";
12
14
 
15
+ /**
16
+ * The auto-start map, or a function computing it from the workspace at
17
+ * runtime (so it can vary by workspace name or schema). Resolved and
18
+ * validated in the plugin layout; see {@link resolveAutoStart}.
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
+
13
42
  /** The first mapping row for a document type — the tie-break wherever a
14
43
  * surface binds to exactly one row. */
15
44
  export declare function mappingForDocType(
@@ -44,22 +73,8 @@ export declare function workflowDocTypes(
44
73
  export declare interface WorkflowMapping {
45
74
  /** Studio schema type. */
46
75
  readonly docType: string;
47
- /**
48
- * The document type must have a workflow: the editor form is gated until
49
- * an instance references the document. Doctype-level: the flag on ANY
50
- * mapping row for a docType gates the form, and starting any mapped
51
- * workflow satisfies the gate. Advisory, UI-only enforcement — any raw
52
- * API client can still write; the Content Lake is the only enforcement
53
- * point.
54
- */
55
- readonly mandatory?: boolean;
56
76
  /** The definition `name` the engine deployed under. */
57
77
  readonly definition: string;
58
- /** Logical role of the doc — sets the GDR `type` discriminator in the
59
- * builders. Subject lives on a field `doc.ref` entry, not an envelope. */
60
- readonly subjectKind: "document" | "release";
61
- /** Schema type stamped into the `doc.ref` field entry's `value.type`. */
62
- readonly subjectGdrType: string;
63
78
  /** Human-readable label for menus and dialogs. */
64
79
  readonly label: string;
65
80
  /** Optional initial workflow field entries to seed on Start. */
@@ -104,7 +119,7 @@ export declare interface WorkflowPluginConfig {
104
119
  * each committed action; anything unregistered stays pending for another
105
120
  * runtime to claim.
106
121
  */
107
- readonly effectHandlers?: Record<string, EffectHandler>;
122
+ readonly effectHandlers?: Record<string, EffectHandler<SanityClient>>;
108
123
  /**
109
124
  * Routing override for cross-resource reads, replacing the Studio's
110
125
  * default per-dataset routing — see `useWorkflowEngine`. A served resource
@@ -114,6 +129,16 @@ export declare interface WorkflowPluginConfig {
114
129
  * stable (module scope or memoized).
115
130
  */
116
131
  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;
117
142
  }
118
143
 
119
144
  declare interface WorkflowPreviewProps extends PreviewProps {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/workflow-studio-plugin",
3
- "version": "0.3.0",
3
+ "version": "0.5.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,32 +44,37 @@
44
44
  "dependencies": {
45
45
  "@sanity/client": "^7.23.0",
46
46
  "@sanity/icons": "^4.1.0",
47
+ "@sanity/types": "^6",
47
48
  "@sanity/ui": "^3.3.0",
48
49
  "@sanity/util": "^6.3.0",
49
50
  "date-fns": "^4.4.0",
50
51
  "pluralize-esm": "^9.0.5",
51
- "@sanity/workflow-diagram": "0.3.0",
52
- "@sanity/workflow-engine": "0.17.0",
53
- "@sanity/workflow-react": "0.12.0",
54
- "@sanity/workflow-studio": "0.8.0"
52
+ "@sanity/workflow-components": "0.2.0",
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"
55
57
  },
56
58
  "devDependencies": {
57
59
  "@sanity/pkg-utils": "^10.5.3",
60
+ "@sanity/schema": "^6",
58
61
  "@sanity/sdk": "^2.12.0",
59
62
  "@testing-library/react": "^16.3.2",
60
63
  "@types/react": "^19.2.17",
64
+ "@types/react-dom": "^19.2.3",
61
65
  "jsdom": "^29.1.1",
62
66
  "react": "^19.2.7",
63
67
  "react-dom": "^19.2.7",
64
- "sanity": "^5.30.0",
68
+ "sanity": "^6",
65
69
  "styled-components": "^6.4.2",
66
70
  "vitest": "^4.1.8",
67
- "@sanity/workflow-engine-test": "0.12.0"
71
+ "@sanity/workflow-engine-test": "0.13.1"
68
72
  },
69
73
  "peerDependencies": {
70
74
  "@sanity/sdk": "^2.12.0",
71
75
  "react": "^19.2.7",
72
- "sanity": "^5.30.0",
76
+ "react-dom": "^19.2.7",
77
+ "sanity": "^6",
73
78
  "styled-components": "^6.4.2"
74
79
  },
75
80
  "engines": {