Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a1ea349

Browse files
committed
Lint
1 parent 7a90d62 commit a1ea349

File tree

1 file changed

+78
-80
lines changed

1 file changed

+78
-80
lines changed

provisionersdk/proto/xstate_models.ts

Lines changed: 78 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,116 +1,114 @@
1-
import { createMachine } from 'xstate';
1+
import { createMachine } from "xstate"
22

3-
/** If using VSCode, install the XState VSCode extension to get a
4-
* "Open Inspector" link above each machine in your code that will
3+
/** If using VSCode, install the XState VSCode extension to get a
4+
* "Open Inspector" link above each machine in your code that will
55
* visualize the machine. Otherwise, you can paste code into stately.ai/viz.
66
*/
77

88
interface WorkspaceContext {
99
errorMessage?: string
1010
}
1111

12-
type WorkspaceEvent =
13-
| { type: "START" }
14-
| { type: "STOP" }
15-
| { type: "REBUILD" }
12+
type WorkspaceEvent = { type: "START" } | { type: "STOP" } | { type: "REBUILD" }
1613

17-
export const workspaceModel = createMachine<WorkspaceContext, WorkspaceEvent>(
18-
{
19-
id: "workspaceV2Model",
20-
initial: "off",
21-
states: {
22-
off: {
23-
on: {
24-
START: "starting"
25-
}
26-
},
27-
starting: {
28-
invoke: {
29-
src: "buildWorkspace",
30-
onDone: "running",
31-
onError: "error",
32-
},
14+
export const workspaceModel = createMachine<WorkspaceContext, WorkspaceEvent>({
15+
id: "workspaceV2Model",
16+
initial: "off",
17+
states: {
18+
off: {
19+
on: {
20+
START: "starting",
3321
},
34-
running: {
35-
on: {
36-
STOP: "stopping",
37-
REBUILD: "rebuilding"
38-
}
22+
},
23+
starting: {
24+
invoke: {
25+
src: "buildWorkspace",
26+
onDone: "running",
27+
onError: "error",
3928
},
40-
stopping: {
41-
invoke: {
42-
src: "stopWorkspace",
43-
onDone: "off",
44-
onError: "error"
45-
}
29+
},
30+
running: {
31+
on: {
32+
STOP: "stopping",
33+
REBUILD: "rebuilding",
4634
},
47-
rebuilding: {
48-
invoke: {
49-
src: "stopAndStartWorkspace",
50-
onDone: "running",
51-
onError: "error"
52-
}
35+
},
36+
stopping: {
37+
invoke: {
38+
src: "stopWorkspace",
39+
onDone: "off",
40+
onError: "error",
5341
},
54-
error: {
55-
entry: "saveErrorMessage",
42+
},
43+
rebuilding: {
44+
invoke: {
45+
src: "stopAndStartWorkspace",
46+
onDone: "running",
47+
onError: "error",
5648
},
5749
},
50+
error: {
51+
entry: "saveErrorMessage",
52+
},
5853
},
59-
)
54+
})
6055

6156
export const provisionerModel = createMachine({
62-
id: 'provisionerModel',
63-
initial: 'starting',
57+
id: "provisionerModel",
58+
initial: "starting",
6459
context: {
6560
automator: undefined,
66-
supportedProjects: []
61+
supportedProjects: [],
6762
},
6863
states: {
6964
starting: {
7065
on: {
71-
PROVISION: 'provisioning',
72-
PARSE: 'parsing'
73-
}
66+
PROVISION: "provisioning",
67+
PARSE: "parsing",
68+
},
7469
},
7570
provisioning: {
7671
invoke: {
7772
src: "provision",
78-
onDone: 'off',
79-
onError: 'off'
80-
}
73+
onDone: "off",
74+
onError: "off",
75+
},
8176
},
8277
parsing: {
8378
invoke: {
84-
src: 'parse',
85-
onDone: 'off',
86-
onError: 'off'
87-
}
79+
src: "parse",
80+
onDone: "off",
81+
onError: "off",
82+
},
8883
},
8984
off: {
90-
type: 'final'
91-
}
92-
}
85+
type: "final",
86+
},
87+
},
9388
})
9489

95-
export const provisionerDaemonModel = createMachine({
96-
id: 'provisionerd',
97-
initial: 'polling',
98-
states: {
99-
polling: {
100-
on: {
101-
JOB_HAS_PROVISIONER_REGISTERED: 'executing',
102-
NO_JOB_READY: 'polling'
103-
}
90+
export const provisionerDaemonModel = createMachine(
91+
{
92+
id: "provisionerd",
93+
initial: "polling",
94+
states: {
95+
polling: {
96+
on: {
97+
JOB_HAS_PROVISIONER_REGISTERED: "executing",
98+
NO_JOB_READY: "polling",
99+
},
100+
},
101+
executing: {
102+
invoke: {
103+
id: "callProvisionerWithParameters",
104+
src: "provisionerModel",
105+
onDone: { target: "polling", actions: ["returnState", "parseProjectCode"] },
106+
onError: { target: "polling", actions: ["returnState", "markJobFailed"] },
107+
},
108+
},
104109
},
105-
executing: {
106-
invoke: {
107-
id: 'callProvisionerWithParameters',
108-
src: 'provisionerModel',
109-
onDone: {target: 'polling', actions: ['returnState', 'parseProjectCode']},
110-
onError: {target: 'polling', actions: ['returnState', 'markJobFailed']}
111-
}
112-
}
113-
}
114-
}, {
115-
services: { provisionerModel }
116-
})
110+
},
111+
{
112+
services: { provisionerModel },
113+
},
114+
)

0 commit comments

Comments
 (0)