@sanity/workflow-studio-plugin 0.2.0 → 0.4.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
@@ -5,10 +5,40 @@ import { InitialFieldValue } from "@sanity/workflow-engine";
5
5
  import { JSX } from "react";
6
6
  import { Plugin as Plugin_2 } from "sanity";
7
7
  import { PreviewProps } from "sanity";
8
+ import { ResourceClientResolver } from "@sanity/workflow-engine";
9
+ import type { SanityClient } from "sanity";
10
+ import type { Schema } from "sanity";
8
11
  import { StartContext } from "@sanity/workflow-engine";
9
12
  import type { StructureBuilder } from "sanity/structure";
10
13
  import type { ViewBuilder } from "sanity/structure";
11
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
+
12
42
  /** The first mapping row for a document type — the tie-break wherever a
13
43
  * surface binds to exactly one row. */
14
44
  export declare function mappingForDocType(
@@ -43,22 +73,8 @@ export declare function workflowDocTypes(
43
73
  export declare interface WorkflowMapping {
44
74
  /** Studio schema type. */
45
75
  readonly docType: string;
46
- /**
47
- * The document type must have a workflow: the editor form is gated until
48
- * an instance references the document. Doctype-level: the flag on ANY
49
- * mapping row for a docType gates the form, and starting any mapped
50
- * workflow satisfies the gate. Advisory, UI-only enforcement — any raw
51
- * API client can still write; the Content Lake is the only enforcement
52
- * point.
53
- */
54
- readonly mandatory?: boolean;
55
76
  /** The definition `name` the engine deployed under. */
56
77
  readonly definition: string;
57
- /** Logical role of the doc — sets the GDR `type` discriminator in the
58
- * builders. Subject lives on a field `doc.ref` entry, not an envelope. */
59
- readonly subjectKind: "document" | "release";
60
- /** Schema type stamped into the `doc.ref` field entry's `value.type`. */
61
- readonly subjectGdrType: string;
62
78
  /** Human-readable label for menus and dialogs. */
63
79
  readonly label: string;
64
80
  /** Optional initial workflow field entries to seed on Start. */
@@ -103,7 +119,26 @@ export declare interface WorkflowPluginConfig {
103
119
  * each committed action; anything unregistered stays pending for another
104
120
  * runtime to claim.
105
121
  */
106
- readonly effectHandlers?: Record<string, EffectHandler>;
122
+ readonly effectHandlers?: Record<string, EffectHandler<SanityClient>>;
123
+ /**
124
+ * Routing override for cross-resource reads, replacing the Studio's
125
+ * default per-dataset routing — see `useWorkflowEngine`. A served resource
126
+ * is also part of the declared surface for written refs, so this is how a
127
+ * plugin setup admits runtime-supplied `doc.ref` values to a foreign
128
+ * resource (media-library, canvas, another dataset). Keep the value
129
+ * stable (module scope or memoized).
130
+ */
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;
107
142
  }
108
143
 
109
144
  declare interface WorkflowPreviewProps extends PreviewProps {
package/dist/index.d.ts CHANGED
@@ -5,10 +5,40 @@ import { InitialFieldValue } from "@sanity/workflow-engine";
5
5
  import { JSX } from "react";
6
6
  import { Plugin as Plugin_2 } from "sanity";
7
7
  import { PreviewProps } from "sanity";
8
+ import { ResourceClientResolver } from "@sanity/workflow-engine";
9
+ import type { SanityClient } from "sanity";
10
+ import type { Schema } from "sanity";
8
11
  import { StartContext } from "@sanity/workflow-engine";
9
12
  import type { StructureBuilder } from "sanity/structure";
10
13
  import type { ViewBuilder } from "sanity/structure";
11
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
+
12
42
  /** The first mapping row for a document type — the tie-break wherever a
13
43
  * surface binds to exactly one row. */
14
44
  export declare function mappingForDocType(
@@ -43,22 +73,8 @@ export declare function workflowDocTypes(
43
73
  export declare interface WorkflowMapping {
44
74
  /** Studio schema type. */
45
75
  readonly docType: string;
46
- /**
47
- * The document type must have a workflow: the editor form is gated until
48
- * an instance references the document. Doctype-level: the flag on ANY
49
- * mapping row for a docType gates the form, and starting any mapped
50
- * workflow satisfies the gate. Advisory, UI-only enforcement — any raw
51
- * API client can still write; the Content Lake is the only enforcement
52
- * point.
53
- */
54
- readonly mandatory?: boolean;
55
76
  /** The definition `name` the engine deployed under. */
56
77
  readonly definition: string;
57
- /** Logical role of the doc — sets the GDR `type` discriminator in the
58
- * builders. Subject lives on a field `doc.ref` entry, not an envelope. */
59
- readonly subjectKind: "document" | "release";
60
- /** Schema type stamped into the `doc.ref` field entry's `value.type`. */
61
- readonly subjectGdrType: string;
62
78
  /** Human-readable label for menus and dialogs. */
63
79
  readonly label: string;
64
80
  /** Optional initial workflow field entries to seed on Start. */
@@ -103,7 +119,26 @@ export declare interface WorkflowPluginConfig {
103
119
  * each committed action; anything unregistered stays pending for another
104
120
  * runtime to claim.
105
121
  */
106
- readonly effectHandlers?: Record<string, EffectHandler>;
122
+ readonly effectHandlers?: Record<string, EffectHandler<SanityClient>>;
123
+ /**
124
+ * Routing override for cross-resource reads, replacing the Studio's
125
+ * default per-dataset routing — see `useWorkflowEngine`. A served resource
126
+ * is also part of the declared surface for written refs, so this is how a
127
+ * plugin setup admits runtime-supplied `doc.ref` values to a foreign
128
+ * resource (media-library, canvas, another dataset). Keep the value
129
+ * stable (module scope or memoized).
130
+ */
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;
107
142
  }
108
143
 
109
144
  declare interface WorkflowPreviewProps extends PreviewProps {