@typeonce/effect-machine-devtools 0.38.1 → 0.40.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.
@@ -104,7 +104,6 @@ const ParallelStates = Machine.state({
104
104
  Cancelled: OrderCancelled
105
105
  }
106
106
  })
107
- const targets1 = Machine.targets(ParallelStates)
108
107
  export const parallelCompletionMachine = Machine.make({
109
108
  timers: { source1: "5 seconds" },
110
109
  id: "parallel-completion",
@@ -122,7 +121,7 @@ export const parallelCompletionMachine = Machine.make({
122
121
  internalEvents: ParallelInternalEvents
123
122
  }).handle({
124
123
  initial: {
125
- target: Machine.targets(ParallelStates).root.Cart,
124
+ target: "Cart",
126
125
  decoded: true,
127
126
  data: new Cart({ items: 2 })
128
127
  },
@@ -130,7 +129,7 @@ export const parallelCompletionMachine = Machine.make({
130
129
  Cart: {
131
130
  on: {
132
131
  Checkout: {
133
- target: targets1.root.Order,
132
+ target: "Order",
134
133
  decoded: true,
135
134
  data: ({ event }) => (new Order({ orderId: event.orderId, total: event.total }))
136
135
  }
@@ -140,36 +139,36 @@ export const parallelCompletionMachine = Machine.make({
140
139
  initial: { payment: ({}) => ({ attempts: 0 }), fulfillment: ({}) => ({ warehouse: "north" }) },
141
140
  on: {
142
141
  CancelOrder: {
143
- target: targets1.root.Cancelled,
142
+ target: "Cancelled",
144
143
  decoded: true,
145
144
  data: ({ event }) => (new OrderCancelled({ reason: event.reason }))
146
145
  }
147
146
  },
148
147
  onDone: {
149
- target: targets1.root.Complete,
148
+ target: "Complete",
150
149
  decoded: true,
151
150
  data: () => (new OrderComplete({ orderId: "completed-order" }))
152
151
  },
153
152
  states: {
154
153
  payment: {
155
154
  initial: {
156
- target: Machine.targets(ParallelStates).root.Order.payment.AwaitingAuthorization
155
+ target: "Order.payment.AwaitingAuthorization"
157
156
  },
158
157
  states: {
159
158
  AwaitingAuthorization: {
160
159
  on: {
161
160
  Authorize: {
162
- target: targets1.root.Order.payment.Authorized,
161
+ target: "Order.payment.Authorized",
163
162
  decoded: true,
164
163
  data: ({ event }) => (new Authorized({ authorizationId: event.authorizationId }))
165
164
  },
166
165
  CompleteAll: {
167
- target: targets1.root.Order.payment.Authorized,
166
+ target: "Order.payment.Authorized",
168
167
  decoded: true,
169
168
  data: ({ event }) => (new Authorized({ authorizationId: event.authorizationId }))
170
169
  },
171
170
  DeclinePayment: {
172
- target: targets1.root.Cancelled,
171
+ target: "Cancelled",
173
172
  decoded: true,
174
173
  data: ({ event }) => (new OrderCancelled({ reason: event.reason }))
175
174
  }
@@ -180,23 +179,23 @@ export const parallelCompletionMachine = Machine.make({
180
179
  },
181
180
  fulfillment: {
182
181
  initial: {
183
- target: Machine.targets(ParallelStates).root.Order.fulfillment.WaitingForPayment
182
+ target: "Order.fulfillment.WaitingForPayment"
184
183
  },
185
184
  states: {
186
185
  WaitingForPayment: {
187
186
  on: {
188
187
  Authorize: {
189
- target: targets1.root.Order.fulfillment.Packing,
188
+ target: "Order.fulfillment.Packing",
190
189
  decoded: true,
191
190
  data: () => (new Packing({ packageCount: 1 }))
192
191
  },
193
192
  Pack: {
194
- target: targets1.root.Order.fulfillment.Packing,
193
+ target: "Order.fulfillment.Packing",
195
194
  decoded: true,
196
195
  data: ({ event }) => (new Packing({ packageCount: event.packages }))
197
196
  },
198
197
  CompleteAll: {
199
- target: targets1.root.Order.fulfillment.Shipped,
198
+ target: "Order.fulfillment.Shipped",
200
199
  decoded: true,
201
200
  data: ({ event }) => (new Shipped({ trackingCode: event.trackingCode }))
202
201
  }
@@ -215,17 +214,17 @@ export const parallelCompletionMachine = Machine.make({
215
214
  },
216
215
  on: {
217
216
  AutoShip: {
218
- target: targets1.root.Order.fulfillment.Shipped,
217
+ target: "Order.fulfillment.Shipped",
219
218
  decoded: true,
220
219
  data: () => (new Shipped({ trackingCode: "automatic" }))
221
220
  },
222
221
  Ship: {
223
- target: targets1.root.Order.fulfillment.Shipped,
222
+ target: "Order.fulfillment.Shipped",
224
223
  decoded: true,
225
224
  data: ({ event }) => (new Shipped({ trackingCode: event.trackingCode }))
226
225
  },
227
226
  CompleteAll: {
228
- target: targets1.root.Order.fulfillment.Shipped,
227
+ target: "Order.fulfillment.Shipped",
229
228
  decoded: true,
230
229
  data: ({ event }) => (new Shipped({ trackingCode: event.trackingCode }))
231
230
  }
@@ -242,7 +241,7 @@ export const parallelCompletionMachine = Machine.make({
242
241
  Cancelled: {
243
242
  on: {
244
243
  RetryOrder: {
245
- target: targets1.root.Order,
244
+ target: "Order",
246
245
  decoded: true,
247
246
  data: () => (new Order({ orderId: "retry", total: 0 }))
248
247
  }
@@ -51,7 +51,7 @@ export const parallelOwnerRoutingChildMachine = Machine.make({
51
51
  parent: Machine.parent(ChildParentEvents)
52
52
  }).handle({
53
53
  initial: {
54
- target: Machine.targets(ParallelOwnerChildStates).root.Idle,
54
+ target: "Idle",
55
55
  decoded: true,
56
56
  data: new ChildIdle({})
57
57
  },
@@ -91,7 +91,6 @@ const ParallelOwnerStates = Machine.state({
91
91
  }
92
92
  }
93
93
  })
94
- const targets2 = Machine.targets(ParallelOwnerStates)
95
94
  export const parallelOwnerRoutingMachine = Machine.make({
96
95
  children: { source1: ParallelOwnerChild },
97
96
  id: "parallel-owner-routing",
@@ -99,7 +98,7 @@ export const parallelOwnerRoutingMachine = Machine.make({
99
98
  events: Machine.eventsFromSchemas(PrintRequested, ChildParentEvents)
100
99
  }).handle({
101
100
  initial: {
102
- target: Machine.targets(ParallelOwnerStates).root.Print,
101
+ target: "Print",
103
102
  decoded: true,
104
103
  data: new Print({})
105
104
  },
@@ -108,11 +107,11 @@ export const parallelOwnerRoutingMachine = Machine.make({
108
107
  initial: { Options: ({}) => ({}), Operation: ({}) => ({}) },
109
108
  invoke: {
110
109
  src: "source1",
111
- onFailure: { target: targets2.root.Print.Operation.Active, decoded: true, data: () => (new Active({})) }
110
+ onFailure: { target: "Print.Operation.Active", decoded: true, data: () => (new Active({})) }
112
111
  },
113
112
  on: {
114
113
  PrintRequested: {
115
- target: targets2.root.Print.Operation.Printing,
114
+ target: "Print.Operation.Printing",
116
115
  decoded: true,
117
116
  data: () => (new Printing({}))
118
117
  }
@@ -120,7 +119,7 @@ export const parallelOwnerRoutingMachine = Machine.make({
120
119
  states: {
121
120
  Options: {
122
121
  initial: {
123
- target: Machine.targets(ParallelOwnerStates).root.Print.Options.Ready,
122
+ target: "Print.Options.Ready",
124
123
  data: ({}) => ({})
125
124
  },
126
125
  states: {
@@ -129,7 +128,7 @@ export const parallelOwnerRoutingMachine = Machine.make({
129
128
  },
130
129
  Operation: {
131
130
  initial: {
132
- target: Machine.targets(ParallelOwnerStates).root.Print.Operation.Active,
131
+ target: "Print.Operation.Active",
133
132
  data: ({}) => ({})
134
133
  },
135
134
  states: {
@@ -18,7 +18,7 @@ const Attempts = Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 5 })).
18
18
  title: "Attempts",
19
19
  description: "An integer between one and five."
20
20
  })
21
- const Labels = Schema.Array(Schema.NonEmptyString).check(Schema.isLengthBetween(1, 3)).annotate({
21
+ const Labels = Schema.Array(Schema.NonEmptyString).check(Schema.isBetweenLength(1, 3)).annotate({
22
22
  title: "Labels",
23
23
  description: "One to three non-empty labels."
24
24
  })
@@ -109,12 +109,11 @@ const States = Machine.state({
109
109
  Finished: { schema: Finished, type: "final", output: Schema.String }
110
110
  }
111
111
  })
112
- const targets1 = Machine.targets(States)
113
112
  export const plannerMachine = Machine.make({
114
113
  branches: {
115
114
  transition1: {
116
- urgent: { target: targets1.root.Working, title: "Finish immediately" },
117
- normal: { target: targets1.root.Working, title: "Wait in working" }
115
+ urgent: { target: "Working", title: "Finish immediately" },
116
+ normal: { target: "Working", title: "Wait in working" }
118
117
  }
119
118
  },
120
119
  effects: { source1: Effect.suspend(() => Effect.never) },
@@ -155,7 +154,7 @@ export const plannerMachine = Machine.make({
155
154
  })
156
155
  }).handle({
157
156
  initial: {
158
- target: Machine.targets(States).root.Idle,
157
+ target: "Idle",
159
158
  decoded: true,
160
159
  data: ({ root: { input: input } }) => new Idle({ owner: input.owner })
161
160
  },
@@ -183,12 +182,12 @@ export const plannerMachine = Machine.make({
183
182
  invoke: { src: "source1", id: "monitor-job" },
184
183
  on: {
185
184
  AutoFinish: {
186
- target: targets1.root.Finished,
185
+ target: "Finished",
187
186
  decoded: true,
188
187
  data: ({ state }) => (new Finished({ job: state.job }))
189
188
  },
190
189
  Cancel: {
191
- target: targets1.root.Idle,
190
+ target: "Idle",
192
191
  decoded: true,
193
192
  data: ({ event, state }) => (new Idle({ owner: `${state.owner} · ${event.reason}` }))
194
193
  }
@@ -57,11 +57,10 @@ const ChildStates = Machine.state({
57
57
  Cancelled: { schema: ChildCancelled, type: "final", output: Schema.String }
58
58
  }
59
59
  })
60
- const targets1 = Machine.targets(ChildStates)
61
60
  export const requiredParentChildMachine = Machine.make({
62
61
  branches: {
63
- transition1: { destination: { target: targets1.root.Working } },
64
- transition3: { destination: { target: targets1.root.Working } }
62
+ transition1: { destination: { target: "Working" } },
63
+ transition3: { destination: { target: "Working" } }
65
64
  },
66
65
  effects: {
67
66
  source1: ({ parent, state }: {
@@ -77,7 +76,7 @@ export const requiredParentChildMachine = Machine.make({
77
76
  parent: Machine.parent(ParentEvents)
78
77
  }).handle({
79
78
  initial: {
80
- target: Machine.targets(ChildStates).root.Idle,
79
+ target: "Idle",
81
80
  decoded: true,
82
81
  data: new ChildIdle({})
83
82
  },
@@ -101,7 +100,7 @@ export const requiredParentChildMachine = Machine.make({
101
100
  input: (context) => context,
102
101
  onDone: { none: true },
103
102
  onFailure: {
104
- target: targets1.root.Cancelled,
103
+ target: "Cancelled",
105
104
  decoded: true,
106
105
  data: ({ error }) => (new ChildCancelled({ reason: String(error) }))
107
106
  }
@@ -115,12 +114,12 @@ export const requiredParentChildMachine = Machine.make({
115
114
  }
116
115
  },
117
116
  CommitChildWork: {
118
- target: targets1.root.Done,
117
+ target: "Done",
119
118
  decoded: true,
120
119
  data: ({ state }) => (new ChildDone({ result: `${state.job}:complete` }))
121
120
  },
122
121
  CancelChildWork: {
123
- target: targets1.root.Cancelled,
122
+ target: "Cancelled",
124
123
  decoded: true,
125
124
  data: ({ event }) => (new ChildCancelled({ reason: event.reason }))
126
125
  }
@@ -161,11 +160,10 @@ const ParentStates = Machine.state({
161
160
  Failed: ParentFailed
162
161
  }
163
162
  })
164
- const targets2 = Machine.targets(ParentStates)
165
163
  export const parentProtocolMachine = Machine.make({
166
164
  branches: {
167
- transition1: { destination: { target: targets2.root.Supervising } },
168
- transition3: { destination: { target: targets2.root.Complete } }
165
+ transition1: { destination: { target: "Supervising" } },
166
+ transition3: { destination: { target: "Complete" } }
169
167
  },
170
168
  children: { source1: ProtocolChild },
171
169
  id: "parent-child-protocol",
@@ -173,7 +171,7 @@ export const parentProtocolMachine = Machine.make({
173
171
  events: Machine.eventsFromSchemas(LaunchChild, ResetParent, ParentEvents)
174
172
  }).handle({
175
173
  initial: {
176
- target: Machine.targets(ParentStates).root.Idle,
174
+ target: "Idle",
177
175
  decoded: true,
178
176
  data: new ParentIdle({})
179
177
  },
@@ -181,7 +179,7 @@ export const parentProtocolMachine = Machine.make({
181
179
  Idle: {
182
180
  on: {
183
181
  LaunchChild: {
184
- target: targets2.root.Supervising,
182
+ target: "Supervising",
185
183
  decoded: true,
186
184
  data: () => (new Supervising({ latestProgress: 0 }))
187
185
  }
@@ -191,33 +189,33 @@ export const parentProtocolMachine = Machine.make({
191
189
  invoke: {
192
190
  src: "source1",
193
191
  onDone: {
194
- target: targets2.root.Complete,
192
+ target: "Complete",
195
193
  decoded: true,
196
194
  data: ({ output }) => (new ParentComplete({ result: output }))
197
195
  },
198
196
  onFailure: {
199
- target: targets2.root.Failed,
197
+ target: "Failed",
200
198
  decoded: true,
201
199
  data: ({ error }) => (new ParentFailed({ message: String(error) }))
202
200
  }
203
201
  },
204
202
  on: {
205
203
  ChildProgress: {
206
- target: targets2.root.Supervising,
204
+ target: "Supervising",
207
205
  decoded: true,
208
206
  data: ({ event }) => (new Supervising({ latestProgress: event.percent }))
209
207
  },
210
208
  ChildFinished: {
211
- target: targets2.root.Complete,
209
+ target: "Complete",
212
210
  decoded: true,
213
211
  data: ({ event }) => (new ParentComplete({ result: event.result }))
214
212
  },
215
213
  ChildProblem: {
216
- target: targets2.root.Failed,
214
+ target: "Failed",
217
215
  decoded: true,
218
216
  data: ({ event }) => (new ParentFailed({ message: event.message }))
219
217
  },
220
- ResetParent: { target: targets2.root.Idle, decoded: true, data: () => (new ParentIdle({})) }
218
+ ResetParent: { target: "Idle", decoded: true, data: () => (new ParentIdle({})) }
221
219
  }
222
220
  },
223
221
  Complete: {
@@ -225,7 +223,7 @@ export const parentProtocolMachine = Machine.make({
225
223
  },
226
224
  Failed: {
227
225
  on: {
228
- ResetParent: { target: targets2.root.Idle, decoded: true, data: () => (new ParentIdle({})) }
226
+ ResetParent: { target: "Idle", decoded: true, data: () => (new ParentIdle({})) }
229
227
  }
230
228
  }
231
229
  }
@@ -241,16 +239,15 @@ class PublishOutside extends Schema.TaggedClass<PublishOutside>("OptionalParentP
241
239
  }) {
242
240
  }
243
241
  const OptionalParentStates = Machine.state({ states: { Detached, Published } })
244
- const targets3 = Machine.targets(OptionalParentStates)
245
242
  export const optionalParentMachine = Machine.make({
246
- branches: { transition1: { destination: { target: targets3.root.Published } } },
243
+ branches: { transition1: { destination: { target: "Published" } } },
247
244
  id: "optional-parent-protocol",
248
245
  root: OptionalParentStates,
249
246
  events: Machine.eventsFromSchemas(PublishOutside),
250
247
  parent: Machine.optionalParent(ParentEvents)
251
248
  }).handle({
252
249
  initial: {
253
- target: Machine.targets(OptionalParentStates).root.Detached,
250
+ target: "Detached",
254
251
  decoded: true,
255
252
  data: new Detached({})
256
253
  },
@@ -23,7 +23,6 @@ const ReplicationEvents = Machine.eventsFromSchemas(Schema.TaggedUnion({
23
23
  StopRequested: {}
24
24
  }))
25
25
  const operation: Effect.Effect<void, string> = Effect.succeed(undefined)
26
- const targets1 = Machine.targets(ReplicationStates)
27
26
  export const sharedTerminalRoutingMachine = Machine.make({
28
27
  effects: {
29
28
  source1: operation,
@@ -41,130 +40,130 @@ export const sharedTerminalRoutingMachine = Machine.make({
41
40
  events: ReplicationEvents
42
41
  }).handle({
43
42
  initial: {
44
- target: Machine.targets(ReplicationStates).root.Connecting
43
+ target: "Connecting"
45
44
  },
46
45
  states: {
47
46
  Connecting: {
48
47
  invoke: {
49
48
  src: "source1",
50
49
  id: "connect",
51
- onDone: { target: targets1.root.IdentifyingSource },
52
- onFailure: { target: targets1.root.Failed }
50
+ onDone: { target: "IdentifyingSource" },
51
+ onFailure: { target: "Failed" }
53
52
  },
54
53
  on: {
55
- SessionUnavailable: { target: targets1.root.SessionUnavailable },
56
- StopRequested: { target: targets1.root.Stopping }
54
+ SessionUnavailable: { target: "SessionUnavailable" },
55
+ StopRequested: { target: "Stopping" }
57
56
  }
58
57
  },
59
58
  IdentifyingSource: {
60
59
  invoke: {
61
60
  src: "source2",
62
61
  id: "identify-source",
63
- onDone: { target: targets1.root.ReadingServerInfo },
64
- onFailure: { target: targets1.root.Failed }
62
+ onDone: { target: "ReadingServerInfo" },
63
+ onFailure: { target: "Failed" }
65
64
  },
66
65
  on: {
67
- SessionUnavailable: { target: targets1.root.SessionUnavailable },
68
- StopRequested: { target: targets1.root.Stopping }
66
+ SessionUnavailable: { target: "SessionUnavailable" },
67
+ StopRequested: { target: "Stopping" }
69
68
  }
70
69
  },
71
70
  ReadingServerInfo: {
72
71
  invoke: {
73
72
  src: "source3",
74
73
  id: "read-server-info",
75
- onDone: { target: targets1.root.ReadingSlot },
76
- onFailure: { target: targets1.root.Failed }
74
+ onDone: { target: "ReadingSlot" },
75
+ onFailure: { target: "Failed" }
77
76
  },
78
77
  on: {
79
- SessionUnavailable: { target: targets1.root.SessionUnavailable },
80
- StopRequested: { target: targets1.root.Stopping }
78
+ SessionUnavailable: { target: "SessionUnavailable" },
79
+ StopRequested: { target: "Stopping" }
81
80
  }
82
81
  },
83
82
  ReadingSlot: {
84
83
  invoke: {
85
84
  src: "source4",
86
85
  id: "read-slot",
87
- onDone: { target: targets1.root.CreatingSlot },
88
- onFailure: { target: targets1.root.Failed }
86
+ onDone: { target: "CreatingSlot" },
87
+ onFailure: { target: "Failed" }
89
88
  },
90
89
  on: {
91
- SessionUnavailable: { target: targets1.root.SessionUnavailable },
92
- StopRequested: { target: targets1.root.Stopping }
90
+ SessionUnavailable: { target: "SessionUnavailable" },
91
+ StopRequested: { target: "Stopping" }
93
92
  }
94
93
  },
95
94
  CreatingSlot: {
96
95
  invoke: {
97
96
  src: "source5",
98
97
  id: "create-slot",
99
- onDone: { target: targets1.root.CopyingSnapshot },
100
- onFailure: { target: targets1.root.Failed }
98
+ onDone: { target: "CopyingSnapshot" },
99
+ onFailure: { target: "Failed" }
101
100
  },
102
101
  on: {
103
- SessionUnavailable: { target: targets1.root.SessionUnavailable },
104
- StopRequested: { target: targets1.root.Stopping }
102
+ SessionUnavailable: { target: "SessionUnavailable" },
103
+ StopRequested: { target: "Stopping" }
105
104
  }
106
105
  },
107
106
  CopyingSnapshot: {
108
107
  invoke: {
109
108
  src: "source6",
110
109
  id: "copy-snapshot",
111
- onDone: { target: targets1.root.CatchingUp },
112
- onFailure: { target: targets1.root.Failed }
110
+ onDone: { target: "CatchingUp" },
111
+ onFailure: { target: "Failed" }
113
112
  },
114
113
  on: {
115
- SessionUnavailable: { target: targets1.root.SessionUnavailable },
116
- StopRequested: { target: targets1.root.Stopping }
114
+ SessionUnavailable: { target: "SessionUnavailable" },
115
+ StopRequested: { target: "Stopping" }
117
116
  }
118
117
  },
119
118
  CatchingUp: {
120
119
  invoke: {
121
120
  src: "source7",
122
121
  id: "catch-up",
123
- onDone: { target: targets1.root.ApplyingChanges },
124
- onFailure: { target: targets1.root.Failed }
122
+ onDone: { target: "ApplyingChanges" },
123
+ onFailure: { target: "Failed" }
125
124
  },
126
125
  on: {
127
- SessionUnavailable: { target: targets1.root.SessionUnavailable },
128
- StopRequested: { target: targets1.root.Stopping }
126
+ SessionUnavailable: { target: "SessionUnavailable" },
127
+ StopRequested: { target: "Stopping" }
129
128
  }
130
129
  },
131
130
  ApplyingChanges: {
132
131
  invoke: {
133
132
  src: "source8",
134
133
  id: "apply-changes",
135
- onDone: { target: targets1.root.Ready },
136
- onFailure: { target: targets1.root.Failed }
134
+ onDone: { target: "Ready" },
135
+ onFailure: { target: "Failed" }
137
136
  },
138
137
  on: {
139
- SessionUnavailable: { target: targets1.root.SessionUnavailable },
140
- StopRequested: { target: targets1.root.Stopping }
138
+ SessionUnavailable: { target: "SessionUnavailable" },
139
+ StopRequested: { target: "Stopping" }
141
140
  }
142
141
  },
143
142
  Ready: {
144
143
  on: {
145
- SessionUnavailable: { target: targets1.root.SessionUnavailable },
146
- StopRequested: { target: targets1.root.Stopping }
144
+ SessionUnavailable: { target: "SessionUnavailable" },
145
+ StopRequested: { target: "Stopping" }
147
146
  }
148
147
  },
149
148
  SessionUnavailable: {
150
149
  on: {
151
- Retry: { target: targets1.root.Connecting },
152
- StopRequested: { target: targets1.root.Stopping }
150
+ Retry: { target: "Connecting" },
151
+ StopRequested: { target: "Stopping" }
153
152
  }
154
153
  },
155
154
  Stopping: {
156
155
  invoke: {
157
156
  src: "source9",
158
157
  id: "stop-session",
159
- onDone: { target: targets1.root.Stopped },
160
- onFailure: { target: targets1.root.Failed }
158
+ onDone: { target: "Stopped" },
159
+ onFailure: { target: "Failed" }
161
160
  }
162
161
  },
163
162
  Stopped: {},
164
163
  Failed: {
165
164
  on: {
166
- Retry: { target: targets1.root.Connecting },
167
- StopRequested: { target: targets1.root.Stopping }
165
+ Retry: { target: "Connecting" },
166
+ StopRequested: { target: "Stopping" }
168
167
  }
169
168
  }
170
169
  }