@sanity/workflow-engine-test 0.4.2 → 0.6.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.cjs +3 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +21 -6
- package/dist/index.d.ts +21 -6
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -3,6 +3,7 @@ import type { CompleteEffectArgs } from "@sanity/workflow-engine";
|
|
|
3
3
|
import { DeployDefinitionsArgs } from "@sanity/workflow-engine";
|
|
4
4
|
import { DeployDefinitionsResult } from "@sanity/workflow-engine";
|
|
5
5
|
import { DispatchResult } from "@sanity/workflow-engine";
|
|
6
|
+
import type { EditFieldArgs } from "@sanity/workflow-engine";
|
|
6
7
|
import type { EvaluateArgs } from "@sanity/workflow-engine";
|
|
7
8
|
import type { FireActionArgs } from "@sanity/workflow-engine";
|
|
8
9
|
import type { Grant } from "@sanity/workflow-engine";
|
|
@@ -35,11 +36,13 @@ declare interface ActionResult {
|
|
|
35
36
|
export declare const ALL_ACCESS: WorkflowAccess;
|
|
36
37
|
|
|
37
38
|
/**
|
|
38
|
-
* The default actor used when tests don't specify one.
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
39
|
+
* The default actor used when tests don't specify one. Its `"*"` role is an
|
|
40
|
+
* inert placeholder, NOT a wildcard: role matching is literal membership, so
|
|
41
|
+
* this actor satisfies no `Action.roles` gate or `{kind: "role"}` assignee on
|
|
42
|
+
* its own — a test that exercises a role gate passes an actor carrying the
|
|
43
|
+
* real role (and the definition's `roleAliases` decide what fulfills it). The
|
|
44
|
+
* bench's all-access default is really {@link WILDCARD_GRANTS}, which feeds
|
|
45
|
+
* `$can`. Production code should never see this id.
|
|
43
46
|
*/
|
|
44
47
|
export declare const ALL_ACCESS_USER: Actor;
|
|
45
48
|
|
|
@@ -58,6 +61,17 @@ declare type BenchCompleteEffectArgs = Omit<
|
|
|
58
61
|
actor?: Actor;
|
|
59
62
|
};
|
|
60
63
|
|
|
64
|
+
declare type BenchEditFieldArgs = Omit<
|
|
65
|
+
EditFieldArgs,
|
|
66
|
+
"client" | "tag" | "workflowResource" | "access"
|
|
67
|
+
> & {
|
|
68
|
+
access?: WorkflowAccess;
|
|
69
|
+
/** Shortcut for `access.actor`. */
|
|
70
|
+
actor?: Actor;
|
|
71
|
+
/** Shortcut for `access.grants`. */
|
|
72
|
+
grants?: Grant[];
|
|
73
|
+
};
|
|
74
|
+
|
|
61
75
|
declare type BenchEvaluateArgs = Omit<
|
|
62
76
|
EvaluateArgs,
|
|
63
77
|
"client" | "tag" | "workflowResource" | "access"
|
|
@@ -271,6 +285,7 @@ declare type EngineWrappers = {
|
|
|
271
285
|
) => Promise<DeployDefinitionsResult>;
|
|
272
286
|
startInstance: (args: BenchStartInstanceArgs) => Promise<WorkflowInstance>;
|
|
273
287
|
fireAction: (args: BenchFireActionArgs) => Promise<DispatchResult>;
|
|
288
|
+
editField: (args: BenchEditFieldArgs) => Promise<DispatchResult>;
|
|
274
289
|
completeEffect: (args: BenchCompleteEffectArgs) => Promise<DispatchResult>;
|
|
275
290
|
tick: (args: BenchTickArgs) => Promise<DispatchResult>;
|
|
276
291
|
evaluate: (args: BenchEvaluateArgs) => Promise<WorkflowEvaluation>;
|
|
@@ -554,7 +569,7 @@ declare type ReadHelpers = {
|
|
|
554
569
|
task?: string,
|
|
555
570
|
) => Promise<WorkflowInstance[]>;
|
|
556
571
|
/**
|
|
557
|
-
* All workflow instances whose `doc.ref`
|
|
572
|
+
* All workflow instances whose `doc.ref` field entry named
|
|
558
573
|
* `entryName` (default `"subject"`) matches the given doc id. Useful
|
|
559
574
|
* for "what workflow is running on this document?" questions. Pass
|
|
560
575
|
* `entryName` for workflows whose subject entry uses a different name.
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { CompleteEffectArgs } from "@sanity/workflow-engine";
|
|
|
3
3
|
import { DeployDefinitionsArgs } from "@sanity/workflow-engine";
|
|
4
4
|
import { DeployDefinitionsResult } from "@sanity/workflow-engine";
|
|
5
5
|
import { DispatchResult } from "@sanity/workflow-engine";
|
|
6
|
+
import type { EditFieldArgs } from "@sanity/workflow-engine";
|
|
6
7
|
import type { EvaluateArgs } from "@sanity/workflow-engine";
|
|
7
8
|
import type { FireActionArgs } from "@sanity/workflow-engine";
|
|
8
9
|
import type { Grant } from "@sanity/workflow-engine";
|
|
@@ -35,11 +36,13 @@ declare interface ActionResult {
|
|
|
35
36
|
export declare const ALL_ACCESS: WorkflowAccess;
|
|
36
37
|
|
|
37
38
|
/**
|
|
38
|
-
* The default actor used when tests don't specify one.
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
39
|
+
* The default actor used when tests don't specify one. Its `"*"` role is an
|
|
40
|
+
* inert placeholder, NOT a wildcard: role matching is literal membership, so
|
|
41
|
+
* this actor satisfies no `Action.roles` gate or `{kind: "role"}` assignee on
|
|
42
|
+
* its own — a test that exercises a role gate passes an actor carrying the
|
|
43
|
+
* real role (and the definition's `roleAliases` decide what fulfills it). The
|
|
44
|
+
* bench's all-access default is really {@link WILDCARD_GRANTS}, which feeds
|
|
45
|
+
* `$can`. Production code should never see this id.
|
|
43
46
|
*/
|
|
44
47
|
export declare const ALL_ACCESS_USER: Actor;
|
|
45
48
|
|
|
@@ -58,6 +61,17 @@ declare type BenchCompleteEffectArgs = Omit<
|
|
|
58
61
|
actor?: Actor;
|
|
59
62
|
};
|
|
60
63
|
|
|
64
|
+
declare type BenchEditFieldArgs = Omit<
|
|
65
|
+
EditFieldArgs,
|
|
66
|
+
"client" | "tag" | "workflowResource" | "access"
|
|
67
|
+
> & {
|
|
68
|
+
access?: WorkflowAccess;
|
|
69
|
+
/** Shortcut for `access.actor`. */
|
|
70
|
+
actor?: Actor;
|
|
71
|
+
/** Shortcut for `access.grants`. */
|
|
72
|
+
grants?: Grant[];
|
|
73
|
+
};
|
|
74
|
+
|
|
61
75
|
declare type BenchEvaluateArgs = Omit<
|
|
62
76
|
EvaluateArgs,
|
|
63
77
|
"client" | "tag" | "workflowResource" | "access"
|
|
@@ -271,6 +285,7 @@ declare type EngineWrappers = {
|
|
|
271
285
|
) => Promise<DeployDefinitionsResult>;
|
|
272
286
|
startInstance: (args: BenchStartInstanceArgs) => Promise<WorkflowInstance>;
|
|
273
287
|
fireAction: (args: BenchFireActionArgs) => Promise<DispatchResult>;
|
|
288
|
+
editField: (args: BenchEditFieldArgs) => Promise<DispatchResult>;
|
|
274
289
|
completeEffect: (args: BenchCompleteEffectArgs) => Promise<DispatchResult>;
|
|
275
290
|
tick: (args: BenchTickArgs) => Promise<DispatchResult>;
|
|
276
291
|
evaluate: (args: BenchEvaluateArgs) => Promise<WorkflowEvaluation>;
|
|
@@ -554,7 +569,7 @@ declare type ReadHelpers = {
|
|
|
554
569
|
task?: string,
|
|
555
570
|
) => Promise<WorkflowInstance[]>;
|
|
556
571
|
/**
|
|
557
|
-
* All workflow instances whose `doc.ref`
|
|
572
|
+
* All workflow instances whose `doc.ref` field entry named
|
|
558
573
|
* `entryName` (default `"subject"`) matches the given doc id. Useful
|
|
559
574
|
* for "what workflow is running on this document?" questions. Pass
|
|
560
575
|
* `entryName` for workflows whose subject entry uses a different name.
|
package/dist/index.js
CHANGED
|
@@ -5093,6 +5093,7 @@ function createEngineWrappers(scope, access, clock) {
|
|
|
5093
5093
|
deployDefinitions: (args) => workflow.deployDefinitions({ ...scope, ...args }),
|
|
5094
5094
|
startInstance: (args) => workflow.startInstance(withAccess(args)),
|
|
5095
5095
|
fireAction: (args) => workflow.fireAction(withAccess(args)),
|
|
5096
|
+
editField: (args) => workflow.editField(withAccess(args)),
|
|
5096
5097
|
completeEffect: (args) => workflow.completeEffect(withAccess(args)),
|
|
5097
5098
|
tick: (args) => workflow.tick(withAccess(args)),
|
|
5098
5099
|
evaluate: (args) => workflow.evaluate(withAccess(args)),
|
|
@@ -5156,13 +5157,13 @@ function createReadHelpers(scope) {
|
|
|
5156
5157
|
...task !== void 0 ? { task } : {}
|
|
5157
5158
|
}),
|
|
5158
5159
|
instancesForSubject: async (subjectRef, entryName = "subject") => (
|
|
5159
|
-
// Subjects live on a workflow-scope `doc.ref`
|
|
5160
|
+
// Subjects live on a workflow-scope `doc.ref` field entry. Match
|
|
5160
5161
|
// instances whose entry's value.id equals the supplied ref. The
|
|
5161
5162
|
// entry name is conventionally "subject" but workflows may name
|
|
5162
5163
|
// it otherwise.
|
|
5163
5164
|
client.fetch(
|
|
5164
5165
|
`*[_type == "${WORKFLOW_INSTANCE_TYPE}"
|
|
5165
|
-
&&
|
|
5166
|
+
&& fields[_type == "doc.ref" && name == $entry][0].value.id == $ref
|
|
5166
5167
|
&& ${tagScopeFilter()}] | order(startedAt asc)`,
|
|
5167
5168
|
{ ref: subjectRef, entry: entryName, tag }
|
|
5168
5169
|
)
|