@usestatemachines/cli 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +34 -2
- package/dist/agents/bundled.d.ts +5 -0
- package/dist/agents/bundled.js +6 -0
- package/dist/agents/destinations.d.ts +13 -0
- package/dist/agents/destinations.js +16 -0
- package/dist/api-internal.d.ts +62 -0
- package/dist/api-internal.js +348 -0
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +4 -0
- package/dist/command.d.ts +119 -0
- package/dist/command.js +195 -0
- package/dist/commands/api/command.d.ts +15 -0
- package/dist/commands/api/command.js +38 -0
- package/dist/commands/api/run.d.ts +4 -0
- package/dist/commands/api/run.js +24 -0
- package/dist/commands/apps/command.d.ts +19 -0
- package/dist/commands/apps/command.js +29 -0
- package/dist/commands/apps/list.d.ts +8 -0
- package/dist/commands/apps/list.js +10 -0
- package/dist/commands/connect/command.d.ts +34 -0
- package/dist/commands/connect/command.js +70 -0
- package/dist/commands/connect/run.d.ts +10 -0
- package/dist/commands/connect/run.js +71 -0
- package/dist/commands/doctor/command.d.ts +29 -0
- package/dist/commands/doctor/command.js +36 -0
- package/dist/commands/doctor/run.d.ts +13 -0
- package/dist/commands/doctor/run.js +12 -0
- package/dist/commands/env/command.d.ts +5 -0
- package/dist/commands/env/command.js +19 -0
- package/dist/commands/env/pull.d.ts +6 -0
- package/dist/commands/env/pull.js +6 -0
- package/dist/commands/environments/command.d.ts +121 -0
- package/dist/commands/environments/command.js +170 -0
- package/dist/commands/environments/create.d.ts +9 -0
- package/dist/commands/environments/create.js +42 -0
- package/dist/commands/environments/delete.d.ts +7 -0
- package/dist/commands/environments/delete.js +48 -0
- package/dist/commands/environments/get.d.ts +39 -0
- package/dist/commands/environments/get.js +5 -0
- package/dist/commands/environments/list.d.ts +41 -0
- package/dist/commands/environments/list.js +18 -0
- package/dist/commands/environments/wait.d.ts +39 -0
- package/dist/commands/environments/wait.js +21 -0
- package/dist/commands/init/command.d.ts +68 -0
- package/dist/commands/init/command.js +90 -0
- package/dist/commands/init/run.d.ts +8 -0
- package/dist/commands/init/run.js +422 -0
- package/dist/commands/link/command.d.ts +13 -0
- package/dist/commands/link/command.js +32 -0
- package/dist/commands/link/run.d.ts +12 -0
- package/dist/commands/link/run.js +7 -0
- package/dist/commands/login/command.d.ts +1 -0
- package/dist/commands/login/command.js +43 -0
- package/dist/commands/login/run.d.ts +30 -0
- package/dist/commands/login/run.js +43 -0
- package/dist/commands/login/schema.d.ts +33 -0
- package/dist/commands/login/schema.js +33 -0
- package/dist/commands/logout/command.d.ts +1 -0
- package/dist/commands/logout/command.js +24 -0
- package/dist/commands/logout/run.d.ts +10 -0
- package/dist/commands/logout/run.js +19 -0
- package/dist/commands/logout/schema.d.ts +10 -0
- package/dist/commands/logout/schema.js +10 -0
- package/dist/commands/profiles/command.d.ts +2 -0
- package/dist/commands/profiles/command.js +29 -0
- package/dist/commands/profiles/list.d.ts +20 -0
- package/dist/commands/profiles/list.js +10 -0
- package/dist/commands/profiles/schema.d.ts +24 -0
- package/dist/commands/profiles/schema.js +19 -0
- package/dist/commands/profiles/use.d.ts +7 -0
- package/dist/commands/profiles/use.js +7 -0
- package/dist/commands/requests/command.d.ts +39 -0
- package/dist/commands/requests/command.js +65 -0
- package/dist/commands/requests/get.d.ts +32 -0
- package/dist/commands/requests/get.js +15 -0
- package/dist/commands/requests/list.d.ts +27 -0
- package/dist/commands/requests/list.js +25 -0
- package/dist/commands/snapshots/command.d.ts +48 -0
- package/dist/commands/snapshots/command.js +80 -0
- package/dist/commands/snapshots/create.d.ts +7 -0
- package/dist/commands/snapshots/create.js +26 -0
- package/dist/commands/snapshots/delete.d.ts +34 -0
- package/dist/commands/snapshots/delete.js +8 -0
- package/dist/commands/snapshots/get.d.ts +35 -0
- package/dist/commands/snapshots/get.js +5 -0
- package/dist/commands/snapshots/list.d.ts +37 -0
- package/dist/commands/snapshots/list.js +10 -0
- package/dist/commands/unlink/command.d.ts +1 -0
- package/dist/commands/unlink/command.js +15 -0
- package/dist/commands/unlink/run.d.ts +7 -0
- package/dist/commands/unlink/run.js +8 -0
- package/dist/commands/whoami/command.d.ts +28 -0
- package/dist/commands/whoami/command.js +44 -0
- package/dist/commands/whoami/run.d.ts +5 -0
- package/dist/commands/whoami/run.js +39 -0
- package/dist/commands/workspaces/command.d.ts +33 -0
- package/dist/commands/workspaces/command.js +73 -0
- package/dist/commands/workspaces/list.d.ts +5 -0
- package/dist/commands/workspaces/list.js +42 -0
- package/dist/commands/workspaces/use.d.ts +5 -0
- package/dist/commands/workspaces/use.js +18 -0
- package/dist/config/project.d.ts +21 -0
- package/dist/config/project.js +105 -0
- package/dist/config/schema.d.ts +616 -0
- package/dist/config/schema.js +282 -0
- package/dist/context-types.d.ts +89 -0
- package/dist/context-types.js +56 -0
- package/dist/context.d.ts +13 -0
- package/dist/context.js +290 -0
- package/dist/credentials/sealing.d.ts +10 -0
- package/dist/credentials/sealing.js +72 -0
- package/dist/credentials/store.d.ts +17 -0
- package/dist/credentials/store.js +156 -0
- package/dist/doctor.d.ts +4 -0
- package/dist/doctor.js +239 -0
- package/dist/env-file.d.ts +10 -0
- package/dist/env-file.js +254 -0
- package/dist/errors.d.ts +784 -0
- package/dist/errors.js +459 -0
- package/dist/flags.d.ts +22 -0
- package/dist/flags.js +56 -0
- package/dist/generated/internal.d.ts +138 -0
- package/dist/generated/internal.js +2627 -0
- package/dist/generated/retry.d.ts +1 -0
- package/dist/generated/retry.js +11 -0
- package/dist/help.d.ts +408 -0
- package/dist/help.js +220 -0
- package/dist/io-types.d.ts +127 -0
- package/dist/io-types.js +1 -0
- package/dist/io.d.ts +13 -0
- package/dist/io.js +1017 -0
- package/dist/keys.d.ts +50 -0
- package/dist/keys.js +691 -0
- package/dist/link.d.ts +6 -0
- package/dist/link.js +58 -0
- package/dist/login.d.ts +92 -0
- package/dist/login.js +965 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.js +126 -0
- package/dist/native-helper.d.ts +1 -0
- package/dist/native-helper.js +2 -0
- package/dist/output.d.ts +8 -0
- package/dist/output.js +135 -0
- package/dist/parser.d.ts +28 -0
- package/dist/parser.js +250 -0
- package/dist/program-types.d.ts +67 -0
- package/dist/program-types.js +14 -0
- package/dist/programs.d.ts +2 -0
- package/dist/programs.js +44 -0
- package/dist/project-roots.d.ts +3 -0
- package/dist/project-roots.js +26 -0
- package/dist/prompt.d.ts +3 -0
- package/dist/prompt.js +61 -0
- package/dist/registry.d.ts +2 -0
- package/dist/registry.js +44 -0
- package/dist/resources/create.d.ts +9 -0
- package/dist/resources/create.js +55 -0
- package/dist/resources/read.d.ts +15 -0
- package/dist/resources/read.js +69 -0
- package/dist/resources/schema.d.ts +177 -0
- package/dist/resources/schema.js +158 -0
- package/dist/text.d.ts +3 -0
- package/dist/text.js +19 -0
- package/dist/update.d.ts +22 -0
- package/dist/update.js +126 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +2 -0
- package/package.json +52 -3
package/dist/errors.js
ADDED
|
@@ -0,0 +1,459 @@
|
|
|
1
|
+
const loginNext = [
|
|
2
|
+
{ command: 'statemachines login', reason: 'Sign in to continue.' },
|
|
3
|
+
];
|
|
4
|
+
const doctorNext = [
|
|
5
|
+
{ command: 'statemachines doctor', reason: 'Check the local configuration.' },
|
|
6
|
+
];
|
|
7
|
+
export const errorCatalog = {
|
|
8
|
+
'cli.resource_failed': {
|
|
9
|
+
message: 'The resource failed.',
|
|
10
|
+
exitCode: 1,
|
|
11
|
+
retryable: false,
|
|
12
|
+
userActionRequired: false,
|
|
13
|
+
next: [],
|
|
14
|
+
},
|
|
15
|
+
'cli.unexpected_status': {
|
|
16
|
+
message: 'The resource cannot reach the requested status.',
|
|
17
|
+
exitCode: 1,
|
|
18
|
+
retryable: false,
|
|
19
|
+
userActionRequired: false,
|
|
20
|
+
next: [],
|
|
21
|
+
},
|
|
22
|
+
'cli.env_requires_login': {
|
|
23
|
+
message: 'Env pull needs a signed-in profile. Unset STATEMACHINES_API_KEY and sign in.',
|
|
24
|
+
exitCode: 3,
|
|
25
|
+
retryable: false,
|
|
26
|
+
userActionRequired: true,
|
|
27
|
+
next: loginNext,
|
|
28
|
+
},
|
|
29
|
+
'cli.env_path_refused': {
|
|
30
|
+
message: 'Choose an untracked, regular file inside this repository, outside Git and State metadata.',
|
|
31
|
+
exitCode: 2,
|
|
32
|
+
retryable: false,
|
|
33
|
+
userActionRequired: true,
|
|
34
|
+
next: [],
|
|
35
|
+
},
|
|
36
|
+
'cli.env_invalid': {
|
|
37
|
+
message: 'The managed dotenv assignments are invalid. Fix them and try again.',
|
|
38
|
+
exitCode: 2,
|
|
39
|
+
retryable: false,
|
|
40
|
+
userActionRequired: true,
|
|
41
|
+
next: [],
|
|
42
|
+
},
|
|
43
|
+
'cli.env_changed': {
|
|
44
|
+
message: 'The managed dotenv values changed during this command. Run env pull again.',
|
|
45
|
+
exitCode: 1,
|
|
46
|
+
retryable: true,
|
|
47
|
+
userActionRequired: false,
|
|
48
|
+
next: [],
|
|
49
|
+
},
|
|
50
|
+
'cli.git': {
|
|
51
|
+
message: 'Could not check Git file status or ignore rules. Check repository access and try again.',
|
|
52
|
+
exitCode: 1,
|
|
53
|
+
retryable: false,
|
|
54
|
+
userActionRequired: true,
|
|
55
|
+
next: [],
|
|
56
|
+
},
|
|
57
|
+
'cli.child_start': {
|
|
58
|
+
message: 'Could not start the command. Check its name and PATH.',
|
|
59
|
+
exitCode: 1,
|
|
60
|
+
retryable: false,
|
|
61
|
+
userActionRequired: true,
|
|
62
|
+
next: [],
|
|
63
|
+
},
|
|
64
|
+
'cli.package_install': {
|
|
65
|
+
message: 'The package manager could not install the dependencies. Check its output and run init again.',
|
|
66
|
+
exitCode: 1,
|
|
67
|
+
retryable: false,
|
|
68
|
+
userActionRequired: true,
|
|
69
|
+
next: [],
|
|
70
|
+
},
|
|
71
|
+
'cli.invalid_environment_credential': {
|
|
72
|
+
message: 'STATEMACHINES_API_KEY must contain a workspace API key.',
|
|
73
|
+
exitCode: 3,
|
|
74
|
+
retryable: false,
|
|
75
|
+
userActionRequired: true,
|
|
76
|
+
next: [
|
|
77
|
+
{
|
|
78
|
+
command: 'statemachines whoami',
|
|
79
|
+
reason: 'Replace or unset STATEMACHINES_API_KEY, then check access again.',
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
'cli.no_credential': {
|
|
84
|
+
message: 'Sign in to continue.',
|
|
85
|
+
exitCode: 3,
|
|
86
|
+
retryable: false,
|
|
87
|
+
userActionRequired: true,
|
|
88
|
+
next: loginNext,
|
|
89
|
+
},
|
|
90
|
+
'cli.credential_expired': {
|
|
91
|
+
message: 'Your credential has expired. Sign in again.',
|
|
92
|
+
exitCode: 3,
|
|
93
|
+
retryable: false,
|
|
94
|
+
userActionRequired: true,
|
|
95
|
+
next: loginNext,
|
|
96
|
+
},
|
|
97
|
+
'cli.credential_revoked': {
|
|
98
|
+
message: 'Your credential is no longer valid. Sign in again.',
|
|
99
|
+
exitCode: 3,
|
|
100
|
+
retryable: false,
|
|
101
|
+
userActionRequired: true,
|
|
102
|
+
next: loginNext,
|
|
103
|
+
},
|
|
104
|
+
'cli.profile_not_found': {
|
|
105
|
+
message: 'The selected profile has no saved session. Sign in again.',
|
|
106
|
+
exitCode: 3,
|
|
107
|
+
retryable: false,
|
|
108
|
+
userActionRequired: true,
|
|
109
|
+
next: loginNext,
|
|
110
|
+
},
|
|
111
|
+
'cli.not_linked': {
|
|
112
|
+
message: 'Choose a workspace with --workspace or link this repository.',
|
|
113
|
+
exitCode: 2,
|
|
114
|
+
retryable: false,
|
|
115
|
+
userActionRequired: true,
|
|
116
|
+
next: [
|
|
117
|
+
{
|
|
118
|
+
command: 'statemachines link',
|
|
119
|
+
reason: 'Link this repository to a workspace.',
|
|
120
|
+
},
|
|
121
|
+
],
|
|
122
|
+
},
|
|
123
|
+
'cli.workspace_mismatch': {
|
|
124
|
+
message: 'The selected workspace does not match this credential or resource.',
|
|
125
|
+
exitCode: 2,
|
|
126
|
+
retryable: false,
|
|
127
|
+
userActionRequired: true,
|
|
128
|
+
next: [
|
|
129
|
+
{
|
|
130
|
+
command: 'statemachines whoami',
|
|
131
|
+
reason: 'Check the active credential and workspace.',
|
|
132
|
+
},
|
|
133
|
+
],
|
|
134
|
+
},
|
|
135
|
+
'cli.organization_mismatch': {
|
|
136
|
+
message: 'The repository link belongs to a different organization.',
|
|
137
|
+
exitCode: 2,
|
|
138
|
+
retryable: false,
|
|
139
|
+
userActionRequired: true,
|
|
140
|
+
next: [
|
|
141
|
+
{
|
|
142
|
+
command: 'statemachines link --force',
|
|
143
|
+
reason: 'Replace the repository link.',
|
|
144
|
+
},
|
|
145
|
+
],
|
|
146
|
+
},
|
|
147
|
+
'cli.origin_mismatch': {
|
|
148
|
+
message: 'The selected API origin does not match the saved credential. Sign in again.',
|
|
149
|
+
exitCode: 3,
|
|
150
|
+
retryable: false,
|
|
151
|
+
userActionRequired: true,
|
|
152
|
+
next: loginNext,
|
|
153
|
+
},
|
|
154
|
+
'cli.keychain_denied': {
|
|
155
|
+
message: 'Could not access the keychain. Check access and try again.',
|
|
156
|
+
exitCode: 1,
|
|
157
|
+
retryable: false,
|
|
158
|
+
userActionRequired: true,
|
|
159
|
+
next: [
|
|
160
|
+
{
|
|
161
|
+
command: 'STATEMACHINES_CREDENTIAL_STORE=file statemachines login',
|
|
162
|
+
reason: 'Save credentials in a protected file instead of the keychain.',
|
|
163
|
+
},
|
|
164
|
+
],
|
|
165
|
+
},
|
|
166
|
+
'cli.keychain_timeout': {
|
|
167
|
+
message: 'The keychain did not respond in time. Check access and try again.',
|
|
168
|
+
exitCode: 1,
|
|
169
|
+
retryable: true,
|
|
170
|
+
userActionRequired: true,
|
|
171
|
+
next: doctorNext,
|
|
172
|
+
},
|
|
173
|
+
'cli.keychain_unavailable': {
|
|
174
|
+
message: 'The selected keychain is unavailable. Restore access before continuing.',
|
|
175
|
+
exitCode: 1,
|
|
176
|
+
retryable: false,
|
|
177
|
+
userActionRequired: true,
|
|
178
|
+
next: doctorNext,
|
|
179
|
+
},
|
|
180
|
+
'cli.credential_store_mismatch': {
|
|
181
|
+
message: 'The selected credential store does not match the saved credential.',
|
|
182
|
+
exitCode: 1,
|
|
183
|
+
retryable: false,
|
|
184
|
+
userActionRequired: true,
|
|
185
|
+
next: doctorNext,
|
|
186
|
+
},
|
|
187
|
+
'cli.credentials_invalid': {
|
|
188
|
+
message: 'Could not read the saved credential. Check the credential store.',
|
|
189
|
+
exitCode: 1,
|
|
190
|
+
retryable: false,
|
|
191
|
+
userActionRequired: true,
|
|
192
|
+
next: doctorNext,
|
|
193
|
+
},
|
|
194
|
+
'cli.input_required': {
|
|
195
|
+
message: 'This command needs an answer. Supply the flag shown in the next command.',
|
|
196
|
+
exitCode: 2,
|
|
197
|
+
retryable: false,
|
|
198
|
+
userActionRequired: true,
|
|
199
|
+
next: [],
|
|
200
|
+
},
|
|
201
|
+
'cli.invalid_arguments': {
|
|
202
|
+
message: 'The command arguments are invalid. Check the command help.',
|
|
203
|
+
exitCode: 2,
|
|
204
|
+
retryable: false,
|
|
205
|
+
userActionRequired: false,
|
|
206
|
+
next: [
|
|
207
|
+
{
|
|
208
|
+
command: 'statemachines help',
|
|
209
|
+
reason: 'Check the supported arguments and flags.',
|
|
210
|
+
},
|
|
211
|
+
],
|
|
212
|
+
},
|
|
213
|
+
'cli.path_refused': {
|
|
214
|
+
message: 'This API path is not allowed. Use the dedicated command for credentials.',
|
|
215
|
+
exitCode: 2,
|
|
216
|
+
retryable: false,
|
|
217
|
+
userActionRequired: false,
|
|
218
|
+
next: [
|
|
219
|
+
{
|
|
220
|
+
command: 'statemachines logout',
|
|
221
|
+
reason: 'Revoke the active profile credential.',
|
|
222
|
+
},
|
|
223
|
+
],
|
|
224
|
+
},
|
|
225
|
+
'cli.wait_timeout': {
|
|
226
|
+
message: 'The wait timed out. Check the current status before trying again.',
|
|
227
|
+
exitCode: 1,
|
|
228
|
+
retryable: true,
|
|
229
|
+
userActionRequired: false,
|
|
230
|
+
next: [],
|
|
231
|
+
},
|
|
232
|
+
'cli.config_too_new': {
|
|
233
|
+
message: 'A newer CLI wrote this configuration. Update the CLI to continue.',
|
|
234
|
+
exitCode: 1,
|
|
235
|
+
retryable: false,
|
|
236
|
+
userActionRequired: true,
|
|
237
|
+
next: [
|
|
238
|
+
{
|
|
239
|
+
command: 'npx @usestatemachines/cli@latest doctor',
|
|
240
|
+
reason: 'Check the configuration with the latest CLI.',
|
|
241
|
+
},
|
|
242
|
+
],
|
|
243
|
+
},
|
|
244
|
+
'cli.file_not_utf8': {
|
|
245
|
+
message: 'A file is not valid UTF-8. Save it as UTF-8 and try again.',
|
|
246
|
+
exitCode: 2,
|
|
247
|
+
retryable: false,
|
|
248
|
+
userActionRequired: true,
|
|
249
|
+
next: [],
|
|
250
|
+
},
|
|
251
|
+
'cli.config_invalid': {
|
|
252
|
+
message: 'The saved configuration is invalid. Check the local configuration.',
|
|
253
|
+
exitCode: 1,
|
|
254
|
+
retryable: false,
|
|
255
|
+
userActionRequired: true,
|
|
256
|
+
next: doctorNext,
|
|
257
|
+
},
|
|
258
|
+
'cli.config_locked': {
|
|
259
|
+
message: 'Another command is changing the configuration. Wait for it to finish and try again.',
|
|
260
|
+
exitCode: 1,
|
|
261
|
+
retryable: true,
|
|
262
|
+
userActionRequired: false,
|
|
263
|
+
next: [],
|
|
264
|
+
},
|
|
265
|
+
'cli.config_lock_invalid': {
|
|
266
|
+
message: 'Could not verify the configuration lock. Check that no other command is running.',
|
|
267
|
+
exitCode: 1,
|
|
268
|
+
retryable: false,
|
|
269
|
+
userActionRequired: true,
|
|
270
|
+
next: doctorNext,
|
|
271
|
+
},
|
|
272
|
+
'cli.config_io': {
|
|
273
|
+
message: 'Could not read or save the local configuration. Check directory access.',
|
|
274
|
+
exitCode: 1,
|
|
275
|
+
retryable: false,
|
|
276
|
+
userActionRequired: true,
|
|
277
|
+
next: doctorNext,
|
|
278
|
+
},
|
|
279
|
+
'cli.login_busy': {
|
|
280
|
+
message: 'Another login is using this profile. Wait for it to finish and try again.',
|
|
281
|
+
exitCode: 1,
|
|
282
|
+
retryable: true,
|
|
283
|
+
userActionRequired: false,
|
|
284
|
+
next: [],
|
|
285
|
+
},
|
|
286
|
+
'cli.profile_changed': {
|
|
287
|
+
message: 'This profile changed during the command. Check the active profile and try again.',
|
|
288
|
+
exitCode: 1,
|
|
289
|
+
retryable: false,
|
|
290
|
+
userActionRequired: true,
|
|
291
|
+
next: [
|
|
292
|
+
{
|
|
293
|
+
command: 'statemachines whoami',
|
|
294
|
+
reason: 'Check the active profile before trying again.',
|
|
295
|
+
},
|
|
296
|
+
],
|
|
297
|
+
},
|
|
298
|
+
'cli.logout_pending': {
|
|
299
|
+
message: 'Local access was removed, but revocation is pending. Revoke the CLI session in the dashboard settings.',
|
|
300
|
+
exitCode: 1,
|
|
301
|
+
retryable: true,
|
|
302
|
+
userActionRequired: true,
|
|
303
|
+
next: [
|
|
304
|
+
{
|
|
305
|
+
command: 'statemachines logout',
|
|
306
|
+
reason: 'Retry the pending revocation.',
|
|
307
|
+
},
|
|
308
|
+
],
|
|
309
|
+
},
|
|
310
|
+
'cli.network': {
|
|
311
|
+
message: 'Could not reach the API. Check the connection and try again.',
|
|
312
|
+
exitCode: 1,
|
|
313
|
+
retryable: true,
|
|
314
|
+
userActionRequired: false,
|
|
315
|
+
next: [],
|
|
316
|
+
},
|
|
317
|
+
'cli.invalid_response': {
|
|
318
|
+
message: 'The API returned an unexpected response. Try again.',
|
|
319
|
+
exitCode: 1,
|
|
320
|
+
retryable: true,
|
|
321
|
+
userActionRequired: false,
|
|
322
|
+
next: [],
|
|
323
|
+
},
|
|
324
|
+
'cli.invalid_result': {
|
|
325
|
+
message: 'The command returned an invalid result.',
|
|
326
|
+
exitCode: 1,
|
|
327
|
+
retryable: false,
|
|
328
|
+
userActionRequired: false,
|
|
329
|
+
next: [],
|
|
330
|
+
},
|
|
331
|
+
'cli.cancelled': {
|
|
332
|
+
message: 'Command canceled.',
|
|
333
|
+
exitCode: 130,
|
|
334
|
+
retryable: false,
|
|
335
|
+
userActionRequired: false,
|
|
336
|
+
next: [],
|
|
337
|
+
},
|
|
338
|
+
'cli.internal': {
|
|
339
|
+
message: 'The command could not finish.',
|
|
340
|
+
exitCode: 1,
|
|
341
|
+
retryable: false,
|
|
342
|
+
userActionRequired: false,
|
|
343
|
+
next: [],
|
|
344
|
+
},
|
|
345
|
+
};
|
|
346
|
+
export class CliError extends Error {
|
|
347
|
+
code;
|
|
348
|
+
exitCode;
|
|
349
|
+
document;
|
|
350
|
+
constructor(code, options = {}) {
|
|
351
|
+
const definition = errorCatalog[code];
|
|
352
|
+
const message = options.message ?? definition.message;
|
|
353
|
+
super(message);
|
|
354
|
+
this.name = 'CliError';
|
|
355
|
+
this.code = code;
|
|
356
|
+
this.exitCode = definition.exitCode;
|
|
357
|
+
this.document = {
|
|
358
|
+
error: {
|
|
359
|
+
code,
|
|
360
|
+
message,
|
|
361
|
+
requestId: options.requestId ?? null,
|
|
362
|
+
retryable: definition.retryable,
|
|
363
|
+
next: options.next ?? definition.next,
|
|
364
|
+
userActionRequired: options.userActionRequired ?? definition.userActionRequired,
|
|
365
|
+
details: options.details ?? null,
|
|
366
|
+
},
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
export class ApiError extends Error {
|
|
371
|
+
status;
|
|
372
|
+
exitCode;
|
|
373
|
+
document;
|
|
374
|
+
constructor(input) {
|
|
375
|
+
super(input.message);
|
|
376
|
+
this.name = 'ApiError';
|
|
377
|
+
this.status = input.status;
|
|
378
|
+
this.exitCode = input.status === 401 ? 3 : 1;
|
|
379
|
+
this.document = {
|
|
380
|
+
error: {
|
|
381
|
+
code: input.code ?? 'cli.invalid_response',
|
|
382
|
+
message: input.message,
|
|
383
|
+
requestId: input.requestId,
|
|
384
|
+
retryable: input.status === 408 || input.status === 429 || input.status >= 500,
|
|
385
|
+
next: input.status === 401 ? loginNext : [],
|
|
386
|
+
userActionRequired: input.status === 401,
|
|
387
|
+
details: input.details,
|
|
388
|
+
},
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
export const keychainFailures = [
|
|
393
|
+
'cli.keychain_denied',
|
|
394
|
+
'cli.keychain_timeout',
|
|
395
|
+
'cli.keychain_unavailable',
|
|
396
|
+
];
|
|
397
|
+
export function failedWith(error, codes) {
|
|
398
|
+
return error instanceof CliError && codes.includes(error.document.error.code);
|
|
399
|
+
}
|
|
400
|
+
export function unconfirmedRevocations(count) {
|
|
401
|
+
return count === 1
|
|
402
|
+
? {
|
|
403
|
+
problem: 'Could not confirm that 1 CLI session was revoked.',
|
|
404
|
+
remedy: 'Revoke it in the dashboard under Settings, Signed-in CLIs.',
|
|
405
|
+
}
|
|
406
|
+
: {
|
|
407
|
+
problem: `Could not confirm that ${count} CLI sessions were revoked.`,
|
|
408
|
+
remedy: 'Revoke them in the dashboard under Settings, Signed-in CLIs.',
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
export function withErrorDetails(error, details) {
|
|
412
|
+
const value = error.document.error;
|
|
413
|
+
return error instanceof CliError
|
|
414
|
+
? new CliError(error.code, {
|
|
415
|
+
message: value.message,
|
|
416
|
+
requestId: value.requestId,
|
|
417
|
+
next: value.next,
|
|
418
|
+
userActionRequired: value.userActionRequired,
|
|
419
|
+
details,
|
|
420
|
+
})
|
|
421
|
+
: new ApiError({
|
|
422
|
+
status: error.status,
|
|
423
|
+
code: value.code,
|
|
424
|
+
message: value.message,
|
|
425
|
+
requestId: value.requestId,
|
|
426
|
+
details,
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
export function normalizeError(error) {
|
|
430
|
+
if (error instanceof CliError || error instanceof ApiError) {
|
|
431
|
+
return error;
|
|
432
|
+
}
|
|
433
|
+
if (error instanceof Error && error.name === 'AbortError') {
|
|
434
|
+
return new CliError('cli.cancelled');
|
|
435
|
+
}
|
|
436
|
+
return new CliError('cli.internal');
|
|
437
|
+
}
|
|
438
|
+
export function errorHelp() {
|
|
439
|
+
return Object.entries(errorCatalog).map(([code, definition]) => ({
|
|
440
|
+
code,
|
|
441
|
+
...definition,
|
|
442
|
+
}));
|
|
443
|
+
}
|
|
444
|
+
export const exitCodeHelp = [
|
|
445
|
+
{ code: 0, meaning: 'Success.' },
|
|
446
|
+
{
|
|
447
|
+
code: 1,
|
|
448
|
+
meaning: 'An API, network, resource, local state, or wait failed.',
|
|
449
|
+
},
|
|
450
|
+
{
|
|
451
|
+
code: 2,
|
|
452
|
+
meaning: 'Invalid arguments, a required answer, or a missing workspace link.',
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
code: 3,
|
|
456
|
+
meaning: 'A missing, expired, revoked, or origin-mismatched credential.',
|
|
457
|
+
},
|
|
458
|
+
{ code: 130, meaning: 'Command canceled.' },
|
|
459
|
+
];
|
package/dist/flags.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare const globalFlags: ({
|
|
2
|
+
name: string;
|
|
3
|
+
key: string;
|
|
4
|
+
type: "string";
|
|
5
|
+
description: string;
|
|
6
|
+
short?: undefined;
|
|
7
|
+
negatedName?: undefined;
|
|
8
|
+
} | {
|
|
9
|
+
name: string;
|
|
10
|
+
key: string;
|
|
11
|
+
type: "boolean";
|
|
12
|
+
negatedName: null;
|
|
13
|
+
description: string;
|
|
14
|
+
short?: undefined;
|
|
15
|
+
} | {
|
|
16
|
+
name: string;
|
|
17
|
+
key: string;
|
|
18
|
+
short: string;
|
|
19
|
+
type: "boolean";
|
|
20
|
+
negatedName: null;
|
|
21
|
+
description: string;
|
|
22
|
+
})[];
|
package/dist/flags.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export const globalFlags = [
|
|
2
|
+
{
|
|
3
|
+
name: 'profile',
|
|
4
|
+
key: 'profile',
|
|
5
|
+
type: 'string',
|
|
6
|
+
description: 'Use a saved profile.',
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
name: 'workspace',
|
|
10
|
+
key: 'workspace',
|
|
11
|
+
type: 'string',
|
|
12
|
+
description: 'Choose a workspace for commands that use one.',
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
name: 'format',
|
|
16
|
+
key: 'format',
|
|
17
|
+
type: 'string',
|
|
18
|
+
description: 'Print text or JSON.',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: 'json',
|
|
22
|
+
key: 'json',
|
|
23
|
+
type: 'boolean',
|
|
24
|
+
negatedName: null,
|
|
25
|
+
description: 'Print JSON.',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: 'no-input',
|
|
29
|
+
key: 'noInput',
|
|
30
|
+
type: 'boolean',
|
|
31
|
+
negatedName: null,
|
|
32
|
+
description: 'Run without prompts.',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: 'yes',
|
|
36
|
+
key: 'yes',
|
|
37
|
+
type: 'boolean',
|
|
38
|
+
negatedName: null,
|
|
39
|
+
description: 'Confirm destructive actions.',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: 'stream',
|
|
43
|
+
key: 'stream',
|
|
44
|
+
type: 'boolean',
|
|
45
|
+
negatedName: null,
|
|
46
|
+
description: 'Print progress as JSON lines on supported commands.',
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: 'help',
|
|
50
|
+
key: 'help',
|
|
51
|
+
short: 'h',
|
|
52
|
+
type: 'boolean',
|
|
53
|
+
negatedName: null,
|
|
54
|
+
description: 'Show command help.',
|
|
55
|
+
},
|
|
56
|
+
];
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import type { StateMachinesError } from '@usestatemachines/sdk';
|
|
2
|
+
export declare const parseStartLogin: (input: unknown) => {
|
|
3
|
+
publicKey: string;
|
|
4
|
+
cliVersion: string;
|
|
5
|
+
hostname: string;
|
|
6
|
+
platform: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const parseStartedLogin: (input: unknown) => {
|
|
9
|
+
loginId: string;
|
|
10
|
+
deviceCode: string;
|
|
11
|
+
userCode: string;
|
|
12
|
+
verificationUrl: string;
|
|
13
|
+
expiresIn: number;
|
|
14
|
+
interval: number;
|
|
15
|
+
};
|
|
16
|
+
export declare const parseLoginToken: (input: unknown) => {
|
|
17
|
+
envelope: {
|
|
18
|
+
v: 1;
|
|
19
|
+
serverPublicKey: string;
|
|
20
|
+
nonce: string;
|
|
21
|
+
ciphertext: string;
|
|
22
|
+
tag: string;
|
|
23
|
+
};
|
|
24
|
+
tokenId: string;
|
|
25
|
+
idleExpiresAt: string;
|
|
26
|
+
expiresAt: string;
|
|
27
|
+
organization: {
|
|
28
|
+
id: string;
|
|
29
|
+
name: string;
|
|
30
|
+
};
|
|
31
|
+
user: {
|
|
32
|
+
email: string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export declare const parsePollError: (input: unknown) => {
|
|
36
|
+
error: "access_denied" | "authorization_pending" | "expired_token" | "slow_down";
|
|
37
|
+
interval: number;
|
|
38
|
+
};
|
|
39
|
+
export declare const parseCollected: (input: unknown) => {
|
|
40
|
+
loginId: string;
|
|
41
|
+
status: "collected";
|
|
42
|
+
};
|
|
43
|
+
export declare const parseCreateKey: (input: unknown) => {
|
|
44
|
+
workspaceId: string;
|
|
45
|
+
name: string;
|
|
46
|
+
permissions: ("environments:connect" | "environments:read" | "environments:write" | "snapshots:read" | "snapshots:write")[];
|
|
47
|
+
kind?: "cli_run" | "env_pull" | undefined;
|
|
48
|
+
};
|
|
49
|
+
export declare const keyPolicy: {
|
|
50
|
+
permissions: ("environments:connect" | "environments:read" | "environments:write" | "snapshots:read" | "snapshots:write")[];
|
|
51
|
+
maxNameLength: number | null;
|
|
52
|
+
};
|
|
53
|
+
export declare const parseEnvironmentLabels: (input: unknown) => Record<string, string>;
|
|
54
|
+
export declare const parseCreatedKey: (input: unknown) => {
|
|
55
|
+
apiKey: {
|
|
56
|
+
id: string;
|
|
57
|
+
workspaceId: string;
|
|
58
|
+
name: string;
|
|
59
|
+
displayValue: string;
|
|
60
|
+
permissions: ("environments:connect" | "environments:read" | "environments:write" | "snapshots:read" | "snapshots:write")[];
|
|
61
|
+
createdBy: {
|
|
62
|
+
type: "api_key" | "member" | "system";
|
|
63
|
+
id: string | null;
|
|
64
|
+
name: string | null;
|
|
65
|
+
};
|
|
66
|
+
createdAt: string;
|
|
67
|
+
lastUsedAt: string | null;
|
|
68
|
+
revokedAt: string | null;
|
|
69
|
+
kind: "cli_run" | "dashboard" | "env_pull";
|
|
70
|
+
expiresAt: string | null;
|
|
71
|
+
};
|
|
72
|
+
secret?: string | undefined;
|
|
73
|
+
};
|
|
74
|
+
export declare const parseKey: (input: unknown) => {
|
|
75
|
+
id: string;
|
|
76
|
+
workspaceId: string;
|
|
77
|
+
name: string;
|
|
78
|
+
displayValue: string;
|
|
79
|
+
permissions: ("environments:connect" | "environments:read" | "environments:write" | "snapshots:read" | "snapshots:write")[];
|
|
80
|
+
createdBy: {
|
|
81
|
+
type: "api_key" | "member" | "system";
|
|
82
|
+
id: string | null;
|
|
83
|
+
name: string | null;
|
|
84
|
+
};
|
|
85
|
+
createdAt: string;
|
|
86
|
+
lastUsedAt: string | null;
|
|
87
|
+
revokedAt: string | null;
|
|
88
|
+
kind: "cli_run" | "dashboard" | "env_pull";
|
|
89
|
+
expiresAt: string | null;
|
|
90
|
+
};
|
|
91
|
+
export declare const parseKeyListQuery: (input: unknown) => {
|
|
92
|
+
limit: number;
|
|
93
|
+
cursor?: string | undefined;
|
|
94
|
+
workspaceId: string;
|
|
95
|
+
};
|
|
96
|
+
export declare const parseKeyList: (input: unknown) => {
|
|
97
|
+
data: {
|
|
98
|
+
id: string;
|
|
99
|
+
workspaceId: string;
|
|
100
|
+
name: string;
|
|
101
|
+
displayValue: string;
|
|
102
|
+
permissions: ("environments:connect" | "environments:read" | "environments:write" | "snapshots:read" | "snapshots:write")[];
|
|
103
|
+
createdBy: {
|
|
104
|
+
type: "api_key" | "member" | "system";
|
|
105
|
+
id: string | null;
|
|
106
|
+
name: string | null;
|
|
107
|
+
};
|
|
108
|
+
createdAt: string;
|
|
109
|
+
lastUsedAt: string | null;
|
|
110
|
+
revokedAt: string | null;
|
|
111
|
+
kind: "cli_run" | "dashboard" | "env_pull";
|
|
112
|
+
expiresAt: string | null;
|
|
113
|
+
}[];
|
|
114
|
+
nextCursor: string | null;
|
|
115
|
+
};
|
|
116
|
+
export declare const parseTokenList: (input: unknown) => {
|
|
117
|
+
data: {
|
|
118
|
+
id: string;
|
|
119
|
+
name: string;
|
|
120
|
+
createdAt: string;
|
|
121
|
+
lastUsedAt: string | null;
|
|
122
|
+
idleExpiresAt: string;
|
|
123
|
+
expiresAt: string;
|
|
124
|
+
revokedAt: string | null;
|
|
125
|
+
}[];
|
|
126
|
+
nextCursor: string | null;
|
|
127
|
+
};
|
|
128
|
+
export declare const parseAgent: (input: unknown) => "claude_code" | "codex_cli" | "cursor" | "cursor-cli" | "gemini_cli" | "github-copilot" | null;
|
|
129
|
+
export declare function parseApiError(input: unknown): Pick<ConstructorParameters<typeof StateMachinesError>[0], 'code' | 'message' | 'requestId' | 'fields'>;
|
|
130
|
+
export declare const credentialVariables: (appName: string, actorToken: string, services: readonly {
|
|
131
|
+
id: string;
|
|
132
|
+
url: string;
|
|
133
|
+
headers: Readonly<Record<string, string>>;
|
|
134
|
+
servers?: readonly {
|
|
135
|
+
name: string;
|
|
136
|
+
url: string;
|
|
137
|
+
}[] | undefined;
|
|
138
|
+
}[]) => [string, string][];
|