@sanity/workflow-engine-test 0.6.0 → 0.7.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,3 +1,4 @@
1
+ import { ActivityStatus } from "@sanity/workflow-engine";
1
2
  import { Actor } from "@sanity/workflow-engine";
2
3
  import type { CompleteEffectArgs } from "@sanity/workflow-engine";
3
4
  import { DeployDefinitionsArgs } from "@sanity/workflow-engine";
@@ -6,13 +7,13 @@ import { DispatchResult } from "@sanity/workflow-engine";
6
7
  import type { EditFieldArgs } from "@sanity/workflow-engine";
7
8
  import type { EvaluateArgs } from "@sanity/workflow-engine";
8
9
  import type { FireActionArgs } from "@sanity/workflow-engine";
10
+ import { GdrUri } from "@sanity/workflow-engine";
9
11
  import type { Grant } from "@sanity/workflow-engine";
10
12
  import { MutationGuardAction } from "@sanity/workflow-engine";
11
13
  import { MutationGuardDoc } from "@sanity/workflow-engine";
12
14
  import type { OperationArgs } from "@sanity/workflow-engine";
13
15
  import { PendingEffect } from "@sanity/workflow-engine";
14
16
  import type { StartInstanceArgs } from "@sanity/workflow-engine";
15
- import { TaskStatus } from "@sanity/workflow-engine";
16
17
  import type { WorkflowAccess } from "@sanity/workflow-engine";
17
18
  import { WorkflowEvaluation } from "@sanity/workflow-engine";
18
19
  import { WorkflowInstance } from "@sanity/workflow-engine";
@@ -546,27 +547,27 @@ declare type ReadHelpers = {
546
547
  currentStage: (instanceId: string) => Promise<string>;
547
548
  /** Pending effects on an instance. */
548
549
  pendingEffects: (instanceId: string) => Promise<PendingEffect[]>;
549
- /** Status of a single task on an instance, or undefined if missing. */
550
- taskStatus: (
550
+ /** Status of a single activity on an instance, or undefined if missing. */
551
+ activityStatus: (
551
552
  instanceId: string,
552
- task: string,
553
- ) => Promise<TaskStatus | undefined>;
553
+ activity: string,
554
+ ) => Promise<ActivityStatus | undefined>;
554
555
  /** The rendered `$effects` map — context entries keyed by `name`,
555
556
  * completed-effect outputs namespaced under the effect's name. */
556
557
  effectsContextMap: (instanceId: string) => Promise<Record<string, unknown>>;
557
558
  /**
558
- * Spawned children of `parentInstanceId`. If `task` is provided,
559
- * only children spawned by that specific task on the parent.
559
+ * Spawned children of `parentInstanceId`. If `activity` is provided,
560
+ * only children spawned by that specific activity on the parent.
560
561
  *
561
562
  * Walks `history.spawned` entries on the parent — this is the durable
562
- * record. (The per-task `spawnedInstances` field only lives on the
563
- * open StageEntry's tasks; history survives transitions.)
563
+ * record. (The per-activity `spawnedInstances` field only lives on the
564
+ * open StageEntry's activities; history survives transitions.)
564
565
  *
565
566
  * Returns children ordered by `startedAt` ascending.
566
567
  */
567
568
  children: (
568
569
  parentInstanceId: string,
569
- task?: string,
570
+ activity?: string,
570
571
  ) => Promise<WorkflowInstance[]>;
571
572
  /**
572
573
  * All workflow instances whose `doc.ref` field entry named
@@ -590,6 +591,13 @@ declare type ReadHelpers = {
590
591
  openOnly?: boolean;
591
592
  },
592
593
  ) => Promise<WorkflowInstance[]>;
594
+ /**
595
+ * Every in-flight instance whose reactive watch-set includes `document`
596
+ * (a resource-qualified GDR URI) — the reverse of the forward watch-set.
597
+ * Answers "which instances should this changed doc `tick`?" the way a
598
+ * non-reactive content forwarder needs. Sorted by `startedAt` ascending.
599
+ */
600
+ instancesForDocument: (document: GdrUri) => Promise<WorkflowInstance[]>;
593
601
  /** Snapshot of all documents in the store — for inspecting the world. */
594
602
  snapshot: () => readonly StoreDocument[];
595
603
  };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { ActivityStatus } from "@sanity/workflow-engine";
1
2
  import { Actor } from "@sanity/workflow-engine";
2
3
  import type { CompleteEffectArgs } from "@sanity/workflow-engine";
3
4
  import { DeployDefinitionsArgs } from "@sanity/workflow-engine";
@@ -6,13 +7,13 @@ import { DispatchResult } from "@sanity/workflow-engine";
6
7
  import type { EditFieldArgs } from "@sanity/workflow-engine";
7
8
  import type { EvaluateArgs } from "@sanity/workflow-engine";
8
9
  import type { FireActionArgs } from "@sanity/workflow-engine";
10
+ import { GdrUri } from "@sanity/workflow-engine";
9
11
  import type { Grant } from "@sanity/workflow-engine";
10
12
  import { MutationGuardAction } from "@sanity/workflow-engine";
11
13
  import { MutationGuardDoc } from "@sanity/workflow-engine";
12
14
  import type { OperationArgs } from "@sanity/workflow-engine";
13
15
  import { PendingEffect } from "@sanity/workflow-engine";
14
16
  import type { StartInstanceArgs } from "@sanity/workflow-engine";
15
- import { TaskStatus } from "@sanity/workflow-engine";
16
17
  import type { WorkflowAccess } from "@sanity/workflow-engine";
17
18
  import { WorkflowEvaluation } from "@sanity/workflow-engine";
18
19
  import { WorkflowInstance } from "@sanity/workflow-engine";
@@ -546,27 +547,27 @@ declare type ReadHelpers = {
546
547
  currentStage: (instanceId: string) => Promise<string>;
547
548
  /** Pending effects on an instance. */
548
549
  pendingEffects: (instanceId: string) => Promise<PendingEffect[]>;
549
- /** Status of a single task on an instance, or undefined if missing. */
550
- taskStatus: (
550
+ /** Status of a single activity on an instance, or undefined if missing. */
551
+ activityStatus: (
551
552
  instanceId: string,
552
- task: string,
553
- ) => Promise<TaskStatus | undefined>;
553
+ activity: string,
554
+ ) => Promise<ActivityStatus | undefined>;
554
555
  /** The rendered `$effects` map — context entries keyed by `name`,
555
556
  * completed-effect outputs namespaced under the effect's name. */
556
557
  effectsContextMap: (instanceId: string) => Promise<Record<string, unknown>>;
557
558
  /**
558
- * Spawned children of `parentInstanceId`. If `task` is provided,
559
- * only children spawned by that specific task on the parent.
559
+ * Spawned children of `parentInstanceId`. If `activity` is provided,
560
+ * only children spawned by that specific activity on the parent.
560
561
  *
561
562
  * Walks `history.spawned` entries on the parent — this is the durable
562
- * record. (The per-task `spawnedInstances` field only lives on the
563
- * open StageEntry's tasks; history survives transitions.)
563
+ * record. (The per-activity `spawnedInstances` field only lives on the
564
+ * open StageEntry's activities; history survives transitions.)
564
565
  *
565
566
  * Returns children ordered by `startedAt` ascending.
566
567
  */
567
568
  children: (
568
569
  parentInstanceId: string,
569
- task?: string,
570
+ activity?: string,
570
571
  ) => Promise<WorkflowInstance[]>;
571
572
  /**
572
573
  * All workflow instances whose `doc.ref` field entry named
@@ -590,6 +591,13 @@ declare type ReadHelpers = {
590
591
  openOnly?: boolean;
591
592
  },
592
593
  ) => Promise<WorkflowInstance[]>;
594
+ /**
595
+ * Every in-flight instance whose reactive watch-set includes `document`
596
+ * (a resource-qualified GDR URI) — the reverse of the forward watch-set.
597
+ * Answers "which instances should this changed doc `tick`?" the way a
598
+ * non-reactive content forwarder needs. Sorted by `startedAt` ascending.
599
+ */
600
+ instancesForDocument: (document: GdrUri) => Promise<WorkflowInstance[]>;
593
601
  /** Snapshot of all documents in the store — for inspecting the world. */
594
602
  snapshot: () => readonly StoreDocument[];
595
603
  };
package/dist/index.js CHANGED
@@ -5144,17 +5144,17 @@ function createReadHelpers(scope) {
5144
5144
  getInstance,
5145
5145
  currentStage: async (instanceId) => (await getInstance(instanceId)).currentStage,
5146
5146
  pendingEffects: async (instanceId) => (await getInstance(instanceId)).pendingEffects,
5147
- taskStatus: async (instanceId, task) => {
5147
+ activityStatus: async (instanceId, activity) => {
5148
5148
  const instance = await getInstance(instanceId);
5149
5149
  return instance.stages.find(
5150
5150
  (s) => s.name === instance.currentStage && s.exitedAt === void 0
5151
- )?.tasks.find((t) => t.name === task)?.status;
5151
+ )?.activities.find((t) => t.name === activity)?.status;
5152
5152
  },
5153
5153
  effectsContextMap: async (instanceId) => effectsContextMap(await getInstance(instanceId)),
5154
- children: async (parentInstanceId, task) => workflow.children({
5154
+ children: async (parentInstanceId, activity) => workflow.children({
5155
5155
  ...scope,
5156
5156
  instanceId: parentInstanceId,
5157
- ...task !== void 0 ? { task } : {}
5157
+ ...activity !== void 0 ? { activity } : {}
5158
5158
  }),
5159
5159
  instancesForSubject: async (subjectRef, entryName = "subject") => (
5160
5160
  // Subjects live on a workflow-scope `doc.ref` field entry. Match
@@ -5176,6 +5176,7 @@ function createReadHelpers(scope) {
5176
5176
  { wf: workflowName, stage, tag }
5177
5177
  );
5178
5178
  },
5179
+ instancesForDocument: async (document2) => workflow.instancesForDocument({ ...scope, document: document2 }),
5179
5180
  snapshot: () => client.snapshot()
5180
5181
  };
5181
5182
  }