@sanity/workflow-studio-plugin 0.0.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.
@@ -0,0 +1,119 @@
1
+ import type { DefaultDocumentNodeResolver } from "sanity/structure";
2
+ import { EffectHandler } from "@sanity/workflow-engine";
3
+ import { EffectsContext } from "@sanity/workflow-engine";
4
+ import { GlobalDocumentReference } from "@sanity/workflow-engine";
5
+ import { InitialFieldValue } from "@sanity/workflow-engine";
6
+ import { JSX } from "react";
7
+ import { Plugin as Plugin_2 } from "sanity";
8
+ import { PreviewProps } from "sanity";
9
+ import type { StructureBuilder } from "sanity/structure";
10
+ import type { ViewBuilder } from "sanity/structure";
11
+
12
+ export declare function mappingForDocType(
13
+ mappings: readonly WorkflowMapping[],
14
+ docType: string,
15
+ ): WorkflowMapping | undefined;
16
+
17
+ /**
18
+ * Convenience `defaultDocumentNode`: mapped document types get the form view
19
+ * plus the Workflows view; everything else keeps the structure default.
20
+ *
21
+ * ```ts
22
+ * structureTool({defaultDocumentNode: workflowDefaultDocumentNode({mappings})})
23
+ * ```
24
+ */
25
+ export declare function workflowDefaultDocumentNode(options: {
26
+ mappings: readonly WorkflowMapping[];
27
+ }): DefaultDocumentNodeResolver;
28
+
29
+ /** The schema types the plugin contributes workflow surfaces to. */
30
+ export declare function workflowDocTypes(
31
+ mappings: readonly WorkflowMapping[],
32
+ ): ReadonlySet<string>;
33
+
34
+ /**
35
+ * Doctype → workflow binding. Drives every per-doctype contribution the
36
+ * plugin makes: which document actions and badges to add, which document
37
+ * view to offer, what to project as the subject when starting an instance.
38
+ * Adding a workflow-driven doctype to a studio is one entry in the host's
39
+ * mapping table.
40
+ */
41
+ export declare interface WorkflowMapping {
42
+ /** Studio schema type. */
43
+ readonly docType: string;
44
+ /**
45
+ * The document type must have a workflow: the editor form is gated until
46
+ * an instance references the document. Advisory, UI-only enforcement —
47
+ * any raw API client can still write; the Content Lake is the only
48
+ * enforcement point.
49
+ */
50
+ readonly mandatory?: boolean;
51
+ /** The definition `name` the engine deployed under. */
52
+ readonly definition: string;
53
+ /** Logical role of the doc — sets the GDR `type` discriminator in the
54
+ * builders. Subject lives on a field `doc.ref` entry, not an envelope. */
55
+ readonly subjectKind: "document" | "release";
56
+ /** Schema type stamped into the `doc.ref` field entry's `value.type`. */
57
+ readonly subjectGdrType: string;
58
+ /** Human-readable label for menus and dialogs. */
59
+ readonly label: string;
60
+ /** Optional initial workflow field entries to seed on Start. */
61
+ readonly initialStateBuilder?: (
62
+ subjectGdr: GlobalDocumentReference,
63
+ ) => InitialFieldValue[];
64
+ /** Optional effectsContext seed. */
65
+ readonly effectsContextBuilder?: (
66
+ subjectGdr: GlobalDocumentReference,
67
+ ) => EffectsContext;
68
+ /**
69
+ * When set, the Start action reads Studio's `usePerspective()` to pull the
70
+ * active release. If a release is selected, the named `release.ref` field
71
+ * entry is seeded with the release's system-document GDR plus its bare
72
+ * `releaseName`, and the engine derives the instance's perspective from
73
+ * it — so editors can pick a release in the Studio header and start the
74
+ * workflow against it.
75
+ */
76
+ readonly perspectiveField?: {
77
+ /** Field entry name on the workflow definition (e.g. "release"). */
78
+ readonly name: string;
79
+ /**
80
+ * If true, the Start action stays disabled until a release is selected
81
+ * in Studio's perspective. If false (default), the action runs without
82
+ * perspective and the workflow uses its defaults.
83
+ */
84
+ readonly required?: boolean;
85
+ };
86
+ }
87
+
88
+ export declare interface WorkflowPluginConfig {
89
+ /** Engine tag partition — scopes every workflow read and write. */
90
+ readonly tag: string;
91
+ /** Dataset holding workflow definitions + instances. Defaults to the
92
+ * workspace's own dataset (single-dataset setup). */
93
+ readonly workflowDataset?: string;
94
+ /** Document type → workflow definition bindings. */
95
+ readonly mappings: readonly WorkflowMapping[];
96
+ /**
97
+ * Browser-side effect handlers keyed by effect name (the engine's
98
+ * {@link EffectHandler}). Registered handlers drain in the Studio after
99
+ * each committed action; anything unregistered stays pending for another
100
+ * runtime to claim.
101
+ */
102
+ readonly effectHandlers?: Record<string, EffectHandler>;
103
+ }
104
+
105
+ declare interface WorkflowPreviewProps extends PreviewProps {
106
+ readonly _id?: string;
107
+ readonly documentId?: string;
108
+ }
109
+
110
+ export declare function WorkflowStagePreview(
111
+ props: WorkflowPreviewProps,
112
+ ): JSX.Element;
113
+
114
+ export declare const workflowStudioPlugin: Plugin_2<WorkflowPluginConfig>;
115
+
116
+ /** The Workflows view for one document — append it to any `views([...])`. */
117
+ export declare function workflowsView(S: StructureBuilder): ViewBuilder;
118
+
119
+ export {};
@@ -0,0 +1,119 @@
1
+ import type { DefaultDocumentNodeResolver } from "sanity/structure";
2
+ import { EffectHandler } from "@sanity/workflow-engine";
3
+ import { EffectsContext } from "@sanity/workflow-engine";
4
+ import { GlobalDocumentReference } from "@sanity/workflow-engine";
5
+ import { InitialFieldValue } from "@sanity/workflow-engine";
6
+ import { JSX } from "react";
7
+ import { Plugin as Plugin_2 } from "sanity";
8
+ import { PreviewProps } from "sanity";
9
+ import type { StructureBuilder } from "sanity/structure";
10
+ import type { ViewBuilder } from "sanity/structure";
11
+
12
+ export declare function mappingForDocType(
13
+ mappings: readonly WorkflowMapping[],
14
+ docType: string,
15
+ ): WorkflowMapping | undefined;
16
+
17
+ /**
18
+ * Convenience `defaultDocumentNode`: mapped document types get the form view
19
+ * plus the Workflows view; everything else keeps the structure default.
20
+ *
21
+ * ```ts
22
+ * structureTool({defaultDocumentNode: workflowDefaultDocumentNode({mappings})})
23
+ * ```
24
+ */
25
+ export declare function workflowDefaultDocumentNode(options: {
26
+ mappings: readonly WorkflowMapping[];
27
+ }): DefaultDocumentNodeResolver;
28
+
29
+ /** The schema types the plugin contributes workflow surfaces to. */
30
+ export declare function workflowDocTypes(
31
+ mappings: readonly WorkflowMapping[],
32
+ ): ReadonlySet<string>;
33
+
34
+ /**
35
+ * Doctype → workflow binding. Drives every per-doctype contribution the
36
+ * plugin makes: which document actions and badges to add, which document
37
+ * view to offer, what to project as the subject when starting an instance.
38
+ * Adding a workflow-driven doctype to a studio is one entry in the host's
39
+ * mapping table.
40
+ */
41
+ export declare interface WorkflowMapping {
42
+ /** Studio schema type. */
43
+ readonly docType: string;
44
+ /**
45
+ * The document type must have a workflow: the editor form is gated until
46
+ * an instance references the document. Advisory, UI-only enforcement —
47
+ * any raw API client can still write; the Content Lake is the only
48
+ * enforcement point.
49
+ */
50
+ readonly mandatory?: boolean;
51
+ /** The definition `name` the engine deployed under. */
52
+ readonly definition: string;
53
+ /** Logical role of the doc — sets the GDR `type` discriminator in the
54
+ * builders. Subject lives on a field `doc.ref` entry, not an envelope. */
55
+ readonly subjectKind: "document" | "release";
56
+ /** Schema type stamped into the `doc.ref` field entry's `value.type`. */
57
+ readonly subjectGdrType: string;
58
+ /** Human-readable label for menus and dialogs. */
59
+ readonly label: string;
60
+ /** Optional initial workflow field entries to seed on Start. */
61
+ readonly initialStateBuilder?: (
62
+ subjectGdr: GlobalDocumentReference,
63
+ ) => InitialFieldValue[];
64
+ /** Optional effectsContext seed. */
65
+ readonly effectsContextBuilder?: (
66
+ subjectGdr: GlobalDocumentReference,
67
+ ) => EffectsContext;
68
+ /**
69
+ * When set, the Start action reads Studio's `usePerspective()` to pull the
70
+ * active release. If a release is selected, the named `release.ref` field
71
+ * entry is seeded with the release's system-document GDR plus its bare
72
+ * `releaseName`, and the engine derives the instance's perspective from
73
+ * it — so editors can pick a release in the Studio header and start the
74
+ * workflow against it.
75
+ */
76
+ readonly perspectiveField?: {
77
+ /** Field entry name on the workflow definition (e.g. "release"). */
78
+ readonly name: string;
79
+ /**
80
+ * If true, the Start action stays disabled until a release is selected
81
+ * in Studio's perspective. If false (default), the action runs without
82
+ * perspective and the workflow uses its defaults.
83
+ */
84
+ readonly required?: boolean;
85
+ };
86
+ }
87
+
88
+ export declare interface WorkflowPluginConfig {
89
+ /** Engine tag partition — scopes every workflow read and write. */
90
+ readonly tag: string;
91
+ /** Dataset holding workflow definitions + instances. Defaults to the
92
+ * workspace's own dataset (single-dataset setup). */
93
+ readonly workflowDataset?: string;
94
+ /** Document type → workflow definition bindings. */
95
+ readonly mappings: readonly WorkflowMapping[];
96
+ /**
97
+ * Browser-side effect handlers keyed by effect name (the engine's
98
+ * {@link EffectHandler}). Registered handlers drain in the Studio after
99
+ * each committed action; anything unregistered stays pending for another
100
+ * runtime to claim.
101
+ */
102
+ readonly effectHandlers?: Record<string, EffectHandler>;
103
+ }
104
+
105
+ declare interface WorkflowPreviewProps extends PreviewProps {
106
+ readonly _id?: string;
107
+ readonly documentId?: string;
108
+ }
109
+
110
+ export declare function WorkflowStagePreview(
111
+ props: WorkflowPreviewProps,
112
+ ): JSX.Element;
113
+
114
+ export declare const workflowStudioPlugin: Plugin_2<WorkflowPluginConfig>;
115
+
116
+ /** The Workflows view for one document — append it to any `views([...])`. */
117
+ export declare function workflowsView(S: StructureBuilder): ViewBuilder;
118
+
119
+ export {};