@sanity/workflow-studio-plugin 0.5.0 → 0.20.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 +120 -0
- package/README.md +36 -62
- package/dist/_chunks-cjs/index.cjs +471 -248
- package/dist/_chunks-cjs/workflows-tool-root.cjs +47 -36
- package/dist/_chunks-es/index.js +475 -248
- package/dist/_chunks-es/workflows-tool-root.js +49 -38
- 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 +14 -9
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { Stack, Box, Flex, Text, Button, Card, TextInput, Dialog, Badge, useTheme_v2, Container, TabPanel } from "@sanity/ui";
|
|
4
4
|
|
|
5
5
|
import { useState, useEffect, useMemo, useRef } from "react";
|
|
6
6
|
|
|
7
7
|
import { useRouter } from "sanity/router";
|
|
8
8
|
|
|
9
|
-
import { instanceNotice, StaleLock, ActivitiesList, TodoItemsList, isEvaluationStale, useWorkflowInstanceEntry, InvalidDocNotice, LoadingRow, useDefinition, openActivityGone, GroupHeading, ActivityDetailDialog, instanceBreadcrumb, HoverHint, instanceTitle, formatDate, StageChip, stageTitle, AbortedBadge, DocPreviewLink, useWorkflowContext, readDeployedDefinitions, describeError, DismissablePopover, definitionSnapshotOf, findActivity, stateByActivity, findActivityNode, rowDateControlState, rowAssignControlState, isActivityAssignedTo, assigneeUserIdsOf, isOpenActivityStatus, committedRowFace, activityRowProps, parseStoredDateValue, gdrLocality, useUserDisplays, useProjectMembers, DocRefFace, useSaveField, dateControlValue, stopRowMouseDown, stopRowClick, parseDateFieldValue, serializeDateFieldValue, dateControlKind, editTargetOf, CollapsibleBand, LinkChip, BreadcrumbTail, StageFace, TrailingHairline, ActivityRow, UnreadableDocsNote, useAssignmentIdentity, TabSwitch, workflowsTabCodec } from "./index.js";
|
|
9
|
+
import { instanceNotice, StaleLock, ActivitiesList, TodoItemsList, isEvaluationStale, useWorkflowInstanceEntry, InvalidDocNotice, LoadingRow, useDefinition, openActivityGone, GroupHeading, ActivityDetailDialog, instanceBreadcrumb, HoverHint, instanceTitle, formatDate, StageChip, stageTitle, AbortedBadge, SpinnerSlot, DocPreviewLink, useWorkflowContext, readDeployedDefinitions, describeError, DismissablePopover, definitionSnapshotOf, findActivity, stateByActivity, findActivityNode, rowDateControlState, rowAssignControlState, isActivityAssignedTo, assigneeUserIdsOf, isOpenActivityStatus, committedRowFace, activityRowProps, parseStoredDateValue, gdrLocality, useUserDisplays, useProjectMembers, DocRefFace, useSaveField, dateControlValue, stopRowMouseDown, stopRowClick, parseDateFieldValue, serializeDateFieldValue, dateControlKind, editTargetOf, CollapsibleBand, LinkChip, BreadcrumbTail, StageFace, TrailingHairline, ActivityRow, UnreadableDocsNote, useAssignmentIdentity, TabSwitch, workflowsTabCodec } from "./index.js";
|
|
10
10
|
|
|
11
11
|
import { ArrowLeftIcon } from "@sanity/icons/ArrowLeft";
|
|
12
12
|
|
|
13
13
|
import { WorkflowDiagram } from "@sanity/workflow-diagram";
|
|
14
14
|
|
|
15
|
-
import { entryDocRefs, terminalState, latestDeployedDefinitions, isStartableDefinition,
|
|
15
|
+
import { entryDocRefs, terminalState, latestDeployedDefinitions, isStartableDefinition, toBareId, findOpenStageEntry } from "@sanity/workflow-engine";
|
|
16
16
|
|
|
17
17
|
import { AddIcon } from "@sanity/icons/Add";
|
|
18
18
|
|
|
@@ -36,22 +36,6 @@ import { CalendarIcon } from "@sanity/icons/Calendar";
|
|
|
36
36
|
|
|
37
37
|
import { useWorkflowInstances } from "@sanity/workflow-studio";
|
|
38
38
|
|
|
39
|
-
function SpinnerSlot({busy: busy}) {
|
|
40
|
-
/* @__PURE__ */
|
|
41
|
-
return jsx(Flex, {
|
|
42
|
-
align: "center",
|
|
43
|
-
flex: "none",
|
|
44
|
-
justify: "center",
|
|
45
|
-
style: {
|
|
46
|
-
width: 19,
|
|
47
|
-
height: 19
|
|
48
|
-
},
|
|
49
|
-
children: busy ? /* @__PURE__ */ jsx(Spinner, {
|
|
50
|
-
muted: !0
|
|
51
|
-
}) : null
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
39
|
function documentRefsOf(instance) {
|
|
56
40
|
const seen = /* @__PURE__ */ new Map;
|
|
57
41
|
for (const ref of entryDocRefs(instance.fields)) seen.has(ref.id) || seen.set(ref.id, ref);
|
|
@@ -438,7 +422,7 @@ function datesOf(state) {
|
|
|
438
422
|
|
|
439
423
|
function spawnOrigins(instances) {
|
|
440
424
|
const origins = /* @__PURE__ */ new Map;
|
|
441
|
-
for (const parent of instances) for (const row of parent.subworkflows ?? []) origins.set(
|
|
425
|
+
for (const parent of instances) for (const row of parent.subworkflows ?? []) origins.set(toBareId(row.ref.id), {
|
|
442
426
|
parent: parent,
|
|
443
427
|
activityName: row.activity,
|
|
444
428
|
cohortStage: row.cohortStage
|
|
@@ -448,7 +432,7 @@ function spawnOrigins(instances) {
|
|
|
448
432
|
|
|
449
433
|
function rootOf(instance, byId) {
|
|
450
434
|
const rootRef = instance.ancestors[0];
|
|
451
|
-
return rootRef ? byId.get(
|
|
435
|
+
return rootRef ? byId.get(toBareId(rootRef.id)) ?? instance : instance;
|
|
452
436
|
}
|
|
453
437
|
|
|
454
438
|
function taskRowsOf(args) {
|
|
@@ -1122,7 +1106,7 @@ function DocumentField({documents: documents, activeIds: activeIds, onToggle: on
|
|
|
1122
1106
|
if (documents.length === 0) return null;
|
|
1123
1107
|
const rows = documents.map(doc => ({
|
|
1124
1108
|
key: doc.id,
|
|
1125
|
-
text: `${titles.get(doc.id) ?? ""} ${doc.type} ${
|
|
1109
|
+
text: `${titles.get(doc.id) ?? ""} ${doc.type} ${toBareId(doc.id)}`,
|
|
1126
1110
|
node: /* @__PURE__ */ jsx(DocRefFace, {
|
|
1127
1111
|
gdr: doc
|
|
1128
1112
|
})
|
|
@@ -1207,7 +1191,7 @@ function useDocumentChipLabels(documentIds, documents) {
|
|
|
1207
1191
|
const schema = useSchema(), activeDocs = documents.filter(doc => documentIds.includes(doc.id)), {titles: titles, resolved: resolved} = useDocPreviewTitles(activeDocs), labels = /* @__PURE__ */ new Map;
|
|
1208
1192
|
for (const doc of activeDocs) {
|
|
1209
1193
|
if (!resolved.has(doc.id)) continue;
|
|
1210
|
-
const label = titles.get(doc.id) ?? schemaTypeTitle(schema, doc.type) ??
|
|
1194
|
+
const label = titles.get(doc.id) ?? schemaTypeTitle(schema, doc.type) ?? toBareId(doc.id);
|
|
1211
1195
|
labels.set(doc.id, label);
|
|
1212
1196
|
}
|
|
1213
1197
|
return labels;
|
|
@@ -1334,6 +1318,28 @@ function ActivityDateControl({instanceId: instanceId, state: state, dates: dates
|
|
|
1334
1318
|
});
|
|
1335
1319
|
}
|
|
1336
1320
|
|
|
1321
|
+
const PREWARM_MARGIN = "600px 0px";
|
|
1322
|
+
|
|
1323
|
+
function useNearViewport() {
|
|
1324
|
+
const [element, setElement] = useState(null), [near, setNear] = useState(!1);
|
|
1325
|
+
return useEffect(() => {
|
|
1326
|
+
if (element === null) return;
|
|
1327
|
+
if (typeof IntersectionObserver > "u") {
|
|
1328
|
+
setNear(!0);
|
|
1329
|
+
return;
|
|
1330
|
+
}
|
|
1331
|
+
const observer = new IntersectionObserver(entries => {
|
|
1332
|
+
setNear(entries.at(-1)?.isIntersecting ?? !1);
|
|
1333
|
+
}, {
|
|
1334
|
+
rootMargin: PREWARM_MARGIN
|
|
1335
|
+
});
|
|
1336
|
+
return observer.observe(element), () => observer.disconnect();
|
|
1337
|
+
}, [ element ]), {
|
|
1338
|
+
ref: setElement,
|
|
1339
|
+
near: near
|
|
1340
|
+
};
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1337
1343
|
function RefChips({refs: refs, max: max = 2}) {
|
|
1338
1344
|
if (refs.length === 0) return null;
|
|
1339
1345
|
const shown = refs.slice(0, max), overflow = refs.length - shown.length;
|
|
@@ -1363,7 +1369,7 @@ function TaskGroupList({groups: groups, onOpenTask: onOpenTask, onOpenWorkflow:
|
|
|
1363
1369
|
children: [ groups.withDocuments.map(group => /* @__PURE__ */ jsx(CollapsibleBand, {
|
|
1364
1370
|
background: !0,
|
|
1365
1371
|
sticky: !0,
|
|
1366
|
-
title:
|
|
1372
|
+
title: toBareId(group.document.id),
|
|
1367
1373
|
header: /* @__PURE__ */ jsx(Flex, {
|
|
1368
1374
|
align: "center",
|
|
1369
1375
|
flex: "none",
|
|
@@ -1486,22 +1492,27 @@ function TaskRows({rows: rows, onOpenTask: onOpenTask, showTerminalActions: show
|
|
|
1486
1492
|
}
|
|
1487
1493
|
|
|
1488
1494
|
function TaskActivityRow({row: row, onOpen: onOpen, showTerminalActions: showTerminalActions}) {
|
|
1489
|
-
const
|
|
1495
|
+
const {ref: ref, near: near} = useNearViewport(), entry = useWorkflowInstanceEntry(row.instanceId, {
|
|
1496
|
+
evaluate: near
|
|
1497
|
+
}), render = taskRowRender(row, entry);
|
|
1490
1498
|
/* @__PURE__ */
|
|
1491
|
-
return jsx(
|
|
1492
|
-
|
|
1493
|
-
children: /* @__PURE__ */ jsx(
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1499
|
+
return jsx(Box, {
|
|
1500
|
+
ref: ref,
|
|
1501
|
+
children: /* @__PURE__ */ jsx(StaleLock, {
|
|
1502
|
+
stale: render.stale,
|
|
1503
|
+
children: /* @__PURE__ */ jsx(ActivityRow, {
|
|
1504
|
+
assignState: render.assignState,
|
|
1505
|
+
assigneeIds: render.assigneeIds,
|
|
1506
|
+
dateControl: /* @__PURE__ */ jsx(ActivityDateControl, {
|
|
1507
|
+
dates: render.dates,
|
|
1508
|
+
instanceId: row.instanceId,
|
|
1509
|
+
state: render.dateState
|
|
1510
|
+
}),
|
|
1511
|
+
face: render.face,
|
|
1498
1512
|
instanceId: row.instanceId,
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
instanceId: row.instanceId,
|
|
1503
|
-
onOpen: onOpen,
|
|
1504
|
-
terminalActions: showTerminalActions ? render.terminalActions : []
|
|
1513
|
+
onOpen: onOpen,
|
|
1514
|
+
terminalActions: showTerminalActions ? render.terminalActions : []
|
|
1515
|
+
})
|
|
1505
1516
|
})
|
|
1506
1517
|
});
|
|
1507
1518
|
}
|
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.20.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",
|
|
@@ -48,12 +48,7 @@
|
|
|
48
48
|
"@sanity/ui": "^3.3.0",
|
|
49
49
|
"@sanity/util": "^6.3.0",
|
|
50
50
|
"date-fns": "^4.4.0",
|
|
51
|
-
"pluralize-esm": "^9.0.5"
|
|
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"
|
|
51
|
+
"pluralize-esm": "^9.0.5"
|
|
57
52
|
},
|
|
58
53
|
"devDependencies": {
|
|
59
54
|
"@sanity/pkg-utils": "^10.5.3",
|
|
@@ -68,14 +63,24 @@
|
|
|
68
63
|
"sanity": "^6",
|
|
69
64
|
"styled-components": "^6.4.2",
|
|
70
65
|
"vitest": "^4.1.8",
|
|
71
|
-
"@sanity/workflow-
|
|
66
|
+
"@sanity/workflow-diagram": "0.20.0",
|
|
67
|
+
"@sanity/workflow-engine": "0.20.0",
|
|
68
|
+
"@sanity/workflow-components": "0.20.0",
|
|
69
|
+
"@sanity/workflow-react": "0.20.0",
|
|
70
|
+
"@sanity/workflow-engine-test": "0.20.0",
|
|
71
|
+
"@sanity/workflow-studio": "0.20.0"
|
|
72
72
|
},
|
|
73
73
|
"peerDependencies": {
|
|
74
74
|
"@sanity/sdk": "^2.12.0",
|
|
75
75
|
"react": "^19.2.7",
|
|
76
76
|
"react-dom": "^19.2.7",
|
|
77
77
|
"sanity": "^6",
|
|
78
|
-
"styled-components": "^6.4.2"
|
|
78
|
+
"styled-components": "^6.4.2",
|
|
79
|
+
"@sanity/workflow-components": "0.20.0",
|
|
80
|
+
"@sanity/workflow-diagram": "0.20.0",
|
|
81
|
+
"@sanity/workflow-engine": "0.20.0",
|
|
82
|
+
"@sanity/workflow-react": "0.20.0",
|
|
83
|
+
"@sanity/workflow-studio": "0.20.0"
|
|
79
84
|
},
|
|
80
85
|
"engines": {
|
|
81
86
|
"node": ">=20"
|