@typeonce/effect-machine-devtools 0.33.0 → 0.35.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.
@@ -1,8 +1,6 @@
1
1
  import { Machine } from "@typeonce/effect-machine"
2
2
  import { Effect, Schema } from "effect"
3
-
4
3
  const ReplicationStates = Machine.state({
5
- initial: "Connecting",
6
4
  states: {
7
5
  Connecting: {},
8
6
  IdentifyingSource: {},
@@ -19,127 +17,154 @@ const ReplicationStates = Machine.state({
19
17
  Failed: {}
20
18
  }
21
19
  })
22
-
23
- const ReplicationEvents = Machine.eventsFromSchemas(
24
- Schema.TaggedUnion({
25
- Retry: {},
26
- SessionUnavailable: {},
27
- StopRequested: {}
28
- })
29
- )
30
-
31
- const operation = (): Effect.Effect<void, string> => Effect.succeed(undefined)
32
-
20
+ const ReplicationEvents = Machine.eventsFromSchemas(Schema.TaggedUnion({
21
+ Retry: {},
22
+ SessionUnavailable: {},
23
+ StopRequested: {}
24
+ }))
25
+ const operation: Effect.Effect<void, string> = Effect.succeed(undefined)
26
+ const targets1 = Machine.targets(ReplicationStates)
33
27
  export const sharedTerminalRoutingMachine = Machine.make({
28
+ effects: {
29
+ source1: operation,
30
+ source2: operation,
31
+ source3: operation,
32
+ source4: operation,
33
+ source5: operation,
34
+ source6: operation,
35
+ source7: operation,
36
+ source8: operation,
37
+ source9: operation
38
+ },
34
39
  id: "shared-terminal-routing",
35
40
  root: ReplicationStates,
36
- events: ReplicationEvents,
37
- initialConfiguration: (root) => root.resolve(({ target }) => target.from((to) => to.Connecting.from()))
41
+ events: ReplicationEvents
38
42
  }).handle({
43
+ initial: {
44
+ target: Machine.targets(ReplicationStates).root.Connecting
45
+ },
39
46
  states: {
40
47
  Connecting: {
41
- invoke: (from) =>
42
- from.effect("connect", operation)
43
- .onDone((to) => to.branch.IdentifyingSource())
44
- .onFailure((to) => to.branch.Failed()),
48
+ invoke: {
49
+ src: "source1",
50
+ id: "connect",
51
+ onDone: { target: targets1.root.IdentifyingSource },
52
+ onFailure: { target: targets1.root.Failed }
53
+ },
45
54
  on: {
46
- SessionUnavailable: (to) => to.branch.SessionUnavailable(),
47
- StopRequested: (to) => to.branch.Stopping()
55
+ SessionUnavailable: { target: targets1.root.SessionUnavailable },
56
+ StopRequested: { target: targets1.root.Stopping }
48
57
  }
49
58
  },
50
59
  IdentifyingSource: {
51
- invoke: (from) =>
52
- from.effect("identify-source", operation)
53
- .onDone((to) => to.branch.ReadingServerInfo())
54
- .onFailure((to) => to.branch.Failed()),
60
+ invoke: {
61
+ src: "source2",
62
+ id: "identify-source",
63
+ onDone: { target: targets1.root.ReadingServerInfo },
64
+ onFailure: { target: targets1.root.Failed }
65
+ },
55
66
  on: {
56
- SessionUnavailable: (to) => to.branch.SessionUnavailable(),
57
- StopRequested: (to) => to.branch.Stopping()
67
+ SessionUnavailable: { target: targets1.root.SessionUnavailable },
68
+ StopRequested: { target: targets1.root.Stopping }
58
69
  }
59
70
  },
60
71
  ReadingServerInfo: {
61
- invoke: (from) =>
62
- from.effect("read-server-info", operation)
63
- .onDone((to) => to.branch.ReadingSlot())
64
- .onFailure((to) => to.branch.Failed()),
72
+ invoke: {
73
+ src: "source3",
74
+ id: "read-server-info",
75
+ onDone: { target: targets1.root.ReadingSlot },
76
+ onFailure: { target: targets1.root.Failed }
77
+ },
65
78
  on: {
66
- SessionUnavailable: (to) => to.branch.SessionUnavailable(),
67
- StopRequested: (to) => to.branch.Stopping()
79
+ SessionUnavailable: { target: targets1.root.SessionUnavailable },
80
+ StopRequested: { target: targets1.root.Stopping }
68
81
  }
69
82
  },
70
83
  ReadingSlot: {
71
- invoke: (from) =>
72
- from.effect("read-slot", operation)
73
- .onDone((to) => to.branch.CreatingSlot())
74
- .onFailure((to) => to.branch.Failed()),
84
+ invoke: {
85
+ src: "source4",
86
+ id: "read-slot",
87
+ onDone: { target: targets1.root.CreatingSlot },
88
+ onFailure: { target: targets1.root.Failed }
89
+ },
75
90
  on: {
76
- SessionUnavailable: (to) => to.branch.SessionUnavailable(),
77
- StopRequested: (to) => to.branch.Stopping()
91
+ SessionUnavailable: { target: targets1.root.SessionUnavailable },
92
+ StopRequested: { target: targets1.root.Stopping }
78
93
  }
79
94
  },
80
95
  CreatingSlot: {
81
- invoke: (from) =>
82
- from.effect("create-slot", operation)
83
- .onDone((to) => to.branch.CopyingSnapshot())
84
- .onFailure((to) => to.branch.Failed()),
96
+ invoke: {
97
+ src: "source5",
98
+ id: "create-slot",
99
+ onDone: { target: targets1.root.CopyingSnapshot },
100
+ onFailure: { target: targets1.root.Failed }
101
+ },
85
102
  on: {
86
- SessionUnavailable: (to) => to.branch.SessionUnavailable(),
87
- StopRequested: (to) => to.branch.Stopping()
103
+ SessionUnavailable: { target: targets1.root.SessionUnavailable },
104
+ StopRequested: { target: targets1.root.Stopping }
88
105
  }
89
106
  },
90
107
  CopyingSnapshot: {
91
- invoke: (from) =>
92
- from.effect("copy-snapshot", operation)
93
- .onDone((to) => to.branch.CatchingUp())
94
- .onFailure((to) => to.branch.Failed()),
108
+ invoke: {
109
+ src: "source6",
110
+ id: "copy-snapshot",
111
+ onDone: { target: targets1.root.CatchingUp },
112
+ onFailure: { target: targets1.root.Failed }
113
+ },
95
114
  on: {
96
- SessionUnavailable: (to) => to.branch.SessionUnavailable(),
97
- StopRequested: (to) => to.branch.Stopping()
115
+ SessionUnavailable: { target: targets1.root.SessionUnavailable },
116
+ StopRequested: { target: targets1.root.Stopping }
98
117
  }
99
118
  },
100
119
  CatchingUp: {
101
- invoke: (from) =>
102
- from.effect("catch-up", operation)
103
- .onDone((to) => to.branch.ApplyingChanges())
104
- .onFailure((to) => to.branch.Failed()),
120
+ invoke: {
121
+ src: "source7",
122
+ id: "catch-up",
123
+ onDone: { target: targets1.root.ApplyingChanges },
124
+ onFailure: { target: targets1.root.Failed }
125
+ },
105
126
  on: {
106
- SessionUnavailable: (to) => to.branch.SessionUnavailable(),
107
- StopRequested: (to) => to.branch.Stopping()
127
+ SessionUnavailable: { target: targets1.root.SessionUnavailable },
128
+ StopRequested: { target: targets1.root.Stopping }
108
129
  }
109
130
  },
110
131
  ApplyingChanges: {
111
- invoke: (from) =>
112
- from.effect("apply-changes", operation)
113
- .onDone((to) => to.branch.Ready())
114
- .onFailure((to) => to.branch.Failed()),
132
+ invoke: {
133
+ src: "source8",
134
+ id: "apply-changes",
135
+ onDone: { target: targets1.root.Ready },
136
+ onFailure: { target: targets1.root.Failed }
137
+ },
115
138
  on: {
116
- SessionUnavailable: (to) => to.branch.SessionUnavailable(),
117
- StopRequested: (to) => to.branch.Stopping()
139
+ SessionUnavailable: { target: targets1.root.SessionUnavailable },
140
+ StopRequested: { target: targets1.root.Stopping }
118
141
  }
119
142
  },
120
143
  Ready: {
121
144
  on: {
122
- SessionUnavailable: (to) => to.branch.SessionUnavailable(),
123
- StopRequested: (to) => to.branch.Stopping()
145
+ SessionUnavailable: { target: targets1.root.SessionUnavailable },
146
+ StopRequested: { target: targets1.root.Stopping }
124
147
  }
125
148
  },
126
149
  SessionUnavailable: {
127
150
  on: {
128
- Retry: (to) => to.branch.Connecting(),
129
- StopRequested: (to) => to.branch.Stopping()
151
+ Retry: { target: targets1.root.Connecting },
152
+ StopRequested: { target: targets1.root.Stopping }
130
153
  }
131
154
  },
132
155
  Stopping: {
133
- invoke: (from) =>
134
- from.effect("stop-session", operation)
135
- .onDone((to) => to.branch.Stopped())
136
- .onFailure((to) => to.branch.Failed())
156
+ invoke: {
157
+ src: "source9",
158
+ id: "stop-session",
159
+ onDone: { target: targets1.root.Stopped },
160
+ onFailure: { target: targets1.root.Failed }
161
+ }
137
162
  },
138
163
  Stopped: {},
139
164
  Failed: {
140
165
  on: {
141
- Retry: (to) => to.branch.Connecting(),
142
- StopRequested: (to) => to.branch.Stopping()
166
+ Retry: { target: targets1.root.Connecting },
167
+ StopRequested: { target: targets1.root.Stopping }
143
168
  }
144
169
  }
145
170
  }
@@ -1,92 +1,105 @@
1
1
  import { Machine } from "@typeonce/effect-machine"
2
2
  import { Schema } from "effect"
3
-
4
3
  class Workspace extends Schema.TaggedClass<Workspace>("TransitionWorkspace")("Workspace", {
5
4
  revision: Schema.Number,
6
5
  preferredRoute: Schema.Literals(["draft", "review"])
7
- }) {}
6
+ }) {
7
+ }
8
8
  class Draft extends Schema.TaggedClass<Draft>("TransitionDraft")("Draft", {
9
9
  text: Schema.String,
10
10
  autosaves: Schema.Number
11
- }) {}
12
- class AutoSaving extends Schema.TaggedClass<AutoSaving>("TransitionAutoSaving")("AutoSaving", {}) {}
11
+ }) {
12
+ }
13
+ class AutoSaving extends Schema.TaggedClass<AutoSaving>("TransitionAutoSaving")("AutoSaving", {}) {
14
+ }
13
15
  class Review extends Schema.TaggedClass<Review>("TransitionReview")("Review", {
14
16
  requestedBy: Schema.String
15
- }) {}
17
+ }) {
18
+ }
16
19
  class Checking extends Schema.TaggedClass<Checking>("TransitionChecking")("Checking", {
17
20
  checks: Schema.Array(Schema.String)
18
- }) {}
19
- class ChangesRequested extends Schema.TaggedClass<ChangesRequested>("TransitionChangesRequested")(
20
- "ChangesRequested",
21
- { reason: Schema.String }
22
- ) {}
21
+ }) {
22
+ }
23
+ class ChangesRequested extends Schema.TaggedClass<ChangesRequested>("TransitionChangesRequested")("ChangesRequested", {
24
+ reason: Schema.String
25
+ }) {
26
+ }
23
27
  class Approved extends Schema.TaggedClass<Approved>("TransitionApproved")("Approved", {
24
28
  reviewer: Schema.String
25
- }) {}
26
- class WorkspaceFinished extends Schema.TaggedClass<WorkspaceFinished>("TransitionWorkspaceFinished")(
27
- "Finished",
28
- { result: Schema.String }
29
- ) {}
29
+ }) {
30
+ }
31
+ class WorkspaceFinished
32
+ extends Schema.TaggedClass<WorkspaceFinished>("TransitionWorkspaceFinished")("Finished", { result: Schema.String })
33
+ {
34
+ }
30
35
  class Paused extends Schema.TaggedClass<Paused>("TransitionPaused")("Paused", {
31
36
  reason: Schema.String
32
- }) {}
37
+ }) {
38
+ }
33
39
  class Published extends Schema.TaggedClass<Published>("TransitionPublished")("Published", {
34
40
  result: Schema.String
35
- }) {}
41
+ }) {
42
+ }
36
43
  class Disabled extends Schema.TaggedClass<Disabled>("TransitionDisabled")("Disabled", {
37
44
  reason: Schema.String
38
- }) {}
39
-
45
+ }) {
46
+ }
40
47
  class Create extends Schema.TaggedClass<Create>("TransitionCreate")("Create", {
41
48
  text: Schema.String,
42
49
  route: Schema.Literals(["draft", "review"])
43
- }) {}
44
- class Edit extends Schema.TaggedClass<Edit>("TransitionEdit")("Edit", { text: Schema.String }) {}
45
- class Save extends Schema.TaggedClass<Save>("TransitionSave")("Save", {}) {}
50
+ }) {
51
+ }
52
+ class Edit extends Schema.TaggedClass<Edit>("TransitionEdit")("Edit", { text: Schema.String }) {
53
+ }
54
+ class Save extends Schema.TaggedClass<Save>("TransitionSave")("Save", {}) {
55
+ }
46
56
  class Submit extends Schema.TaggedClass<Submit>("TransitionSubmit")("Submit", {
47
57
  mode: Schema.Literals(["review", "publish"]),
48
58
  requestedBy: Schema.String
49
- }) {}
59
+ }) {
60
+ }
50
61
  class Approve extends Schema.TaggedClass<Approve>("TransitionApprove")("Approve", {
51
62
  reviewer: Schema.String
52
- }) {}
63
+ }) {
64
+ }
53
65
  class Reject extends Schema.TaggedClass<Reject>("TransitionReject")("Reject", {
54
66
  reason: Schema.String
55
- }) {}
56
- class Revise extends Schema.TaggedClass<Revise>("TransitionRevise")("Revise", {}) {}
57
- class Pause extends Schema.TaggedClass<Pause>("TransitionPause")("Pause", { reason: Schema.String }) {}
58
- class ResumeShallow extends Schema.TaggedClass<ResumeShallow>("TransitionResumeShallow")(
59
- "ResumeShallow",
60
- {}
61
- ) {}
62
- class ResumeDeep extends Schema.TaggedClass<ResumeDeep>("TransitionResumeDeep")("ResumeDeep", {}) {}
63
- class Restart extends Schema.TaggedClass<Restart>("TransitionRestart")("Restart", {}) {}
64
- class Refresh extends Schema.TaggedClass<Refresh>("TransitionRefresh")("Refresh", {}) {}
65
- class Ignore extends Schema.TaggedClass<Ignore>("TransitionIgnore")("Ignore", {}) {}
67
+ }) {
68
+ }
69
+ class Revise extends Schema.TaggedClass<Revise>("TransitionRevise")("Revise", {}) {
70
+ }
71
+ class Pause extends Schema.TaggedClass<Pause>("TransitionPause")("Pause", { reason: Schema.String }) {
72
+ }
73
+ class ResumeShallow extends Schema.TaggedClass<ResumeShallow>("TransitionResumeShallow")("ResumeShallow", {}) {
74
+ }
75
+ class ResumeDeep extends Schema.TaggedClass<ResumeDeep>("TransitionResumeDeep")("ResumeDeep", {}) {
76
+ }
77
+ class Restart extends Schema.TaggedClass<Restart>("TransitionRestart")("Restart", {}) {
78
+ }
79
+ class Refresh extends Schema.TaggedClass<Refresh>("TransitionRefresh")("Refresh", {}) {
80
+ }
81
+ class Ignore extends Schema.TaggedClass<Ignore>("TransitionIgnore")("Ignore", {}) {
82
+ }
66
83
  class MaybeHandle extends Schema.TaggedClass<MaybeHandle>("TransitionMaybeHandle")("MaybeHandle", {
67
84
  accept: Schema.Boolean
68
- }) {}
69
- class BumpWorkspace extends Schema.TaggedClass<BumpWorkspace>("TransitionBumpWorkspace")(
70
- "BumpWorkspace",
71
- {}
72
- ) {}
85
+ }) {
86
+ }
87
+ class BumpWorkspace extends Schema.TaggedClass<BumpWorkspace>("TransitionBumpWorkspace")("BumpWorkspace", {}) {
88
+ }
73
89
  class Archive extends Schema.TaggedClass<Archive>("TransitionArchive")("Archive", {
74
90
  reason: Schema.String
75
- }) {}
76
-
91
+ }) {
92
+ }
77
93
  const TransitionStates = Machine.state({
78
- initial: "Paused",
79
94
  states: {
80
95
  Workspace: {
81
96
  schema: Workspace,
82
- initial: "Routing",
83
97
  states: {
84
98
  Routing: { type: "choice" },
85
99
  Draft,
86
100
  AutoSaving,
87
101
  Review: {
88
102
  schema: Review,
89
- initial: "Checking",
90
103
  states: {
91
104
  Checking,
92
105
  ChangesRequested,
@@ -103,7 +116,6 @@ const TransitionStates = Machine.state({
103
116
  Published: { schema: Published, type: "final", output: Schema.String }
104
117
  }
105
118
  })
106
-
107
119
  const defaultWorkspaceSnapshot = () => ({
108
120
  path: "" as const,
109
121
  value: undefined,
@@ -116,8 +128,20 @@ const defaultWorkspaceSnapshot = () => ({
116
128
  }
117
129
  }
118
130
  })
119
-
131
+ const targets1 = Machine.targets(TransitionStates)
120
132
  export const transitionSemanticsMachine = Machine.make({
133
+ branches: {
134
+ transition4: {
135
+ draft: { target: targets1.root.Workspace.Draft, title: "Preferred route is draft" },
136
+ review: { initial: targets1.root.Workspace.Review, title: "Preferred route is review" }
137
+ },
138
+ transition7: {
139
+ review: { initial: targets1.root.Workspace.Review, title: "Enter the review flow" },
140
+ publish: { target: targets1.root.Workspace.Finished, title: "Publish without review" }
141
+ },
142
+ transition14: { destination: { history: targets1.root.Workspace.recent } },
143
+ transition15: { destination: { history: targets1.root.Workspace.exact } }
144
+ },
121
145
  id: "transition-semantics",
122
146
  root: TransitionStates,
123
147
  events: Machine.eventsFromSchemas(
@@ -137,116 +161,138 @@ export const transitionSemanticsMachine = Machine.make({
137
161
  MaybeHandle,
138
162
  BumpWorkspace,
139
163
  Archive
140
- ),
141
- initialConfiguration: (root) =>
142
- root.resolve(({ target }) => target.from((to) => to.Paused.decoded(new Paused({ reason: "not started" }))))
164
+ )
143
165
  }).handle({
166
+ initial: {
167
+ target: Machine.targets(TransitionStates).root.Paused,
168
+ decoded: true,
169
+ data: new Paused({ reason: "not started" })
170
+ },
144
171
  states: {
145
172
  Workspace: {
173
+ initial: {
174
+ target: Machine.targets(TransitionStates).root.Workspace.Routing
175
+ },
146
176
  history: {
147
177
  recent: { default: defaultWorkspaceSnapshot },
148
178
  exact: { default: defaultWorkspaceSnapshot }
149
179
  },
150
180
  on: {
151
- Pause: (to) =>
152
- to.branch.Paused().resolve(({ event, target }) => target.decoded(new Paused({ reason: event.reason }))),
153
- BumpWorkspace: (to) =>
154
- to.branch.Workspace.update.resolve(({ current, owner }) =>
155
- owner.decoded(
156
- new Workspace({
157
- revision: current.revision + 1,
158
- preferredRoute: current.preferredRoute
159
- })
160
- )
161
- )
181
+ Pause: {
182
+ target: targets1.root.Paused,
183
+ decoded: true,
184
+ data: ({ event }) => (new Paused({ reason: event.reason }))
185
+ },
186
+ BumpWorkspace: {
187
+ update: targets1.root.Workspace,
188
+ decoded: true,
189
+ data: ({ state: current }) => (new Workspace({
190
+ revision: current.revision + 1,
191
+ preferredRoute: current.preferredRoute
192
+ }))
193
+ }
194
+ },
195
+ onDone: {
196
+ target: targets1.root.Published,
197
+ decoded: true,
198
+ data: () => (new Published({ result: "workspace published" }))
162
199
  },
163
- onDone: (to) =>
164
- to.branch.Published().resolve(({ target }) => target.decoded(new Published({ result: "workspace published" }))),
165
200
  states: {
166
201
  Routing: {
167
- choice: (to) =>
168
- to.branches({
169
- draft: { title: "Preferred route is draft", target: to.local.Draft() },
170
- review: { title: "Preferred route is review", target: to.local.Review.initial }
171
- }).resolve(({ containingState, select }) =>
202
+ choice: {
203
+ branches: "transition4",
204
+ resolve: ({ containingState, select }) =>
172
205
  containingState.preferredRoute === "review"
173
206
  ? select.review.decoded(new Review({ requestedBy: "initial route" }))
174
207
  : select.draft.decoded(new Draft({ text: "", autosaves: 0 }))
175
- )
208
+ }
176
209
  },
177
210
  Draft: {
178
211
  on: {
179
- Edit: (to) =>
180
- to.local.Draft().resolve(({ event, state, target }) =>
181
- target.decoded(new Draft({ text: event.text, autosaves: state.autosaves }))
182
- ),
183
- Save: (to) => to.local.AutoSaving().resolve(({ target }) => target.decoded(new AutoSaving({}))),
184
- Submit: (to) =>
185
- to.branches({
186
- review: { title: "Enter the review flow", target: to.local.Review.initial },
187
- publish: { title: "Publish without review", target: to.local.Finished() }
188
- }).resolve(({ event, select }) =>
212
+ Edit: {
213
+ target: targets1.root.Workspace.Draft,
214
+ decoded: true,
215
+ data: ({ event, state }) => (new Draft({ text: event.text, autosaves: state.autosaves }))
216
+ },
217
+ Save: { target: targets1.root.Workspace.AutoSaving, decoded: true, data: () => (new AutoSaving({})) },
218
+ Submit: {
219
+ branches: "transition7",
220
+ resolve: ({ event, select }) =>
189
221
  event.mode === "publish"
190
222
  ? select.publish.decoded(new WorkspaceFinished({ result: "published directly" }))
191
223
  : select.review.decoded(new Review({ requestedBy: event.requestedBy }))
192
- ),
193
- Refresh: (to) => to.none.reenter(),
194
- Ignore: (to) => to.none,
195
- MaybeHandle: (to) =>
196
- to.none.resolve(({ decline, event }) => event.accept ? undefined : decline(), {
197
- declinable: true
198
- })
224
+ },
225
+ Refresh: { none: true, reenter: true },
226
+ Ignore: { none: true },
227
+ MaybeHandle: {
228
+ none: true,
229
+ resolve: ({ decline, event }) => event.accept ? undefined : decline(),
230
+ declinable: true
231
+ }
199
232
  }
200
233
  },
201
234
  AutoSaving: {
202
- always: (to) =>
203
- to.local.Draft().resolve(({ target }) =>
204
- target.decoded(new Draft({ text: "Autosaved draft", autosaves: 1 }))
205
- )
235
+ always: {
236
+ target: targets1.root.Workspace.Draft,
237
+ decoded: true,
238
+ data: () => (new Draft({ text: "Autosaved draft", autosaves: 1 }))
239
+ }
206
240
  },
207
241
  Review: {
208
- initialize: ({ builder }) => builder.decoded(new Checking({ checks: ["types", "tests"] })),
209
- onDone: (to) =>
210
- to.branch.Workspace.Finished().resolve(({ target }) =>
211
- target.decoded(new WorkspaceFinished({ result: "approved review" }))
212
- ),
242
+ initial: {
243
+ target: Machine.targets(TransitionStates).root.Workspace.Review.Checking,
244
+ decoded: true,
245
+ data: ({}) => new Checking({ checks: ["types", "tests"] })
246
+ },
247
+ onDone: {
248
+ target: targets1.root.Workspace.Finished,
249
+ decoded: true,
250
+ data: () => (new WorkspaceFinished({ result: "approved review" }))
251
+ },
213
252
  states: {
214
253
  Checking: {
215
254
  on: {
216
- Approve: (to) =>
217
- to.local.Approved().resolve(({ event, target }) =>
218
- target.decoded(new Approved({ reviewer: event.reviewer }))
219
- ),
220
- Reject: (to) =>
221
- to.local.ChangesRequested().resolve(({ event, target }) =>
222
- target.decoded(new ChangesRequested({ reason: event.reason }))
223
- )
255
+ Approve: {
256
+ target: targets1.root.Workspace.Review.Approved,
257
+ decoded: true,
258
+ data: ({ event }) => (new Approved({ reviewer: event.reviewer }))
259
+ },
260
+ Reject: {
261
+ target: targets1.root.Workspace.Review.ChangesRequested,
262
+ decoded: true,
263
+ data: ({ event }) => (new ChangesRequested({ reason: event.reason }))
264
+ }
224
265
  }
225
266
  },
226
267
  ChangesRequested: {
227
268
  on: {
228
- Revise: (to) =>
229
- to.branch.Workspace.Draft().resolve(({ target }) =>
230
- target.decoded(new Draft({ text: "Revised draft", autosaves: 0 }))
231
- )
269
+ Revise: {
270
+ target: targets1.root.Workspace.Draft,
271
+ decoded: true,
272
+ data: () => (new Draft({ text: "Revised draft", autosaves: 0 }))
273
+ }
232
274
  }
233
- }
275
+ },
276
+ Approved: {}
234
277
  }
235
- }
278
+ },
279
+ Finished: {}
236
280
  }
237
281
  },
238
282
  Paused: {
239
283
  on: {
240
- Create: (to) =>
241
- to.branch.Workspace.initial.resolve(({ event, target }) =>
242
- target.decoded(new Workspace({ revision: 0, preferredRoute: event.route }))
243
- ),
244
- ResumeShallow: (to) => to.history.Workspace.recent.resolve(({ target }) => target()),
245
- ResumeDeep: (to) => to.history.Workspace.exact.resolve(({ target }) => target()),
246
- Restart: (to) =>
247
- to.branch.Workspace.initial.resolve(({ target }) =>
248
- target.decoded(new Workspace({ revision: 0, preferredRoute: "draft" }))
249
- )
284
+ Create: {
285
+ initial: targets1.root.Workspace,
286
+ decoded: true,
287
+ data: ({ event }) => (new Workspace({ revision: 0, preferredRoute: event.route }))
288
+ },
289
+ ResumeShallow: { branches: "transition14", resolve: ({ select: { destination: target } }) => target() },
290
+ ResumeDeep: { branches: "transition15", resolve: ({ select: { destination: target } }) => target() },
291
+ Restart: {
292
+ initial: targets1.root.Workspace,
293
+ decoded: true,
294
+ data: () => (new Workspace({ revision: 0, preferredRoute: "draft" }))
295
+ }
250
296
  }
251
297
  },
252
298
  Disabled: {},