@sanity/workflow-studio-plugin 0.1.0 → 0.3.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
@@ -1,14 +1,17 @@
1
1
  import type { DefaultDocumentNodeResolver } from "sanity/structure";
2
2
  import { EffectHandler } from "@sanity/workflow-engine";
3
- import { EffectsContext } from "@sanity/workflow-engine";
4
3
  import { GlobalDocumentReference } from "@sanity/workflow-engine";
5
4
  import { InitialFieldValue } from "@sanity/workflow-engine";
6
5
  import { JSX } from "react";
7
6
  import { Plugin as Plugin_2 } from "sanity";
8
7
  import { PreviewProps } from "sanity";
8
+ import { ResourceClientResolver } from "@sanity/workflow-engine";
9
+ import { StartContext } from "@sanity/workflow-engine";
9
10
  import type { StructureBuilder } from "sanity/structure";
10
11
  import type { ViewBuilder } from "sanity/structure";
11
12
 
13
+ /** The first mapping row for a document type — the tie-break wherever a
14
+ * surface binds to exactly one row. */
12
15
  export declare function mappingForDocType(
13
16
  mappings: readonly WorkflowMapping[],
14
17
  docType: string,
@@ -43,9 +46,11 @@ export declare interface WorkflowMapping {
43
46
  readonly docType: string;
44
47
  /**
45
48
  * 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
+ * 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.
49
54
  */
50
55
  readonly mandatory?: boolean;
51
56
  /** The definition `name` the engine deployed under. */
@@ -61,10 +66,10 @@ export declare interface WorkflowMapping {
61
66
  readonly initialStateBuilder?: (
62
67
  subjectGdr: GlobalDocumentReference,
63
68
  ) => InitialFieldValue[];
64
- /** Optional effectsContext seed. */
65
- readonly effectsContextBuilder?: (
69
+ /** Optional `$context` seed passed to `startInstance` as its `context`. */
70
+ readonly contextBuilder?: (
66
71
  subjectGdr: GlobalDocumentReference,
67
- ) => EffectsContext;
72
+ ) => StartContext;
68
73
  /**
69
74
  * When set, the Start action reads Studio's `usePerspective()` to pull the
70
75
  * active release. If a release is selected, the named `release.ref` field
@@ -100,6 +105,15 @@ export declare interface WorkflowPluginConfig {
100
105
  * runtime to claim.
101
106
  */
102
107
  readonly effectHandlers?: Record<string, EffectHandler>;
108
+ /**
109
+ * Routing override for cross-resource reads, replacing the Studio's
110
+ * default per-dataset routing — see `useWorkflowEngine`. A served resource
111
+ * is also part of the declared surface for written refs, so this is how a
112
+ * plugin setup admits runtime-supplied `doc.ref` values to a foreign
113
+ * resource (media-library, canvas, another dataset). Keep the value
114
+ * stable (module scope or memoized).
115
+ */
116
+ readonly resourceClients?: ResourceClientResolver;
103
117
  }
104
118
 
105
119
  declare interface WorkflowPreviewProps extends PreviewProps {
package/dist/index.d.ts CHANGED
@@ -1,14 +1,17 @@
1
1
  import type { DefaultDocumentNodeResolver } from "sanity/structure";
2
2
  import { EffectHandler } from "@sanity/workflow-engine";
3
- import { EffectsContext } from "@sanity/workflow-engine";
4
3
  import { GlobalDocumentReference } from "@sanity/workflow-engine";
5
4
  import { InitialFieldValue } from "@sanity/workflow-engine";
6
5
  import { JSX } from "react";
7
6
  import { Plugin as Plugin_2 } from "sanity";
8
7
  import { PreviewProps } from "sanity";
8
+ import { ResourceClientResolver } from "@sanity/workflow-engine";
9
+ import { StartContext } from "@sanity/workflow-engine";
9
10
  import type { StructureBuilder } from "sanity/structure";
10
11
  import type { ViewBuilder } from "sanity/structure";
11
12
 
13
+ /** The first mapping row for a document type — the tie-break wherever a
14
+ * surface binds to exactly one row. */
12
15
  export declare function mappingForDocType(
13
16
  mappings: readonly WorkflowMapping[],
14
17
  docType: string,
@@ -43,9 +46,11 @@ export declare interface WorkflowMapping {
43
46
  readonly docType: string;
44
47
  /**
45
48
  * 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
+ * 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.
49
54
  */
50
55
  readonly mandatory?: boolean;
51
56
  /** The definition `name` the engine deployed under. */
@@ -61,10 +66,10 @@ export declare interface WorkflowMapping {
61
66
  readonly initialStateBuilder?: (
62
67
  subjectGdr: GlobalDocumentReference,
63
68
  ) => InitialFieldValue[];
64
- /** Optional effectsContext seed. */
65
- readonly effectsContextBuilder?: (
69
+ /** Optional `$context` seed passed to `startInstance` as its `context`. */
70
+ readonly contextBuilder?: (
66
71
  subjectGdr: GlobalDocumentReference,
67
- ) => EffectsContext;
72
+ ) => StartContext;
68
73
  /**
69
74
  * When set, the Start action reads Studio's `usePerspective()` to pull the
70
75
  * active release. If a release is selected, the named `release.ref` field
@@ -100,6 +105,15 @@ export declare interface WorkflowPluginConfig {
100
105
  * runtime to claim.
101
106
  */
102
107
  readonly effectHandlers?: Record<string, EffectHandler>;
108
+ /**
109
+ * Routing override for cross-resource reads, replacing the Studio's
110
+ * default per-dataset routing — see `useWorkflowEngine`. A served resource
111
+ * is also part of the declared surface for written refs, so this is how a
112
+ * plugin setup admits runtime-supplied `doc.ref` values to a foreign
113
+ * resource (media-library, canvas, another dataset). Keep the value
114
+ * stable (module scope or memoized).
115
+ */
116
+ readonly resourceClients?: ResourceClientResolver;
103
117
  }
104
118
 
105
119
  declare interface WorkflowPreviewProps extends PreviewProps {