@mondaydotcomorg/z2h-cli 0.25.3 → 0.25.7

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.
Files changed (118) hide show
  1. package/dist/auth.d.ts +2 -1
  2. package/dist/auth.d.ts.map +1 -1
  3. package/dist/auth.js +2 -1
  4. package/dist/commands/__tests__/build.test.d.ts +2 -0
  5. package/dist/commands/__tests__/build.test.d.ts.map +1 -0
  6. package/dist/commands/backend.d.ts.map +1 -1
  7. package/dist/commands/backend.js +7 -1
  8. package/dist/commands/build.d.ts.map +1 -1
  9. package/dist/commands/build.js +10 -0
  10. package/dist/commands/deploy.d.ts.map +1 -1
  11. package/dist/commands/deploy.js +42 -19
  12. package/dist/commands/grant.d.ts.map +1 -1
  13. package/dist/commands/grant.js +8 -7
  14. package/dist/esm/auth.d.ts +2 -1
  15. package/dist/esm/auth.d.ts.map +1 -1
  16. package/dist/esm/auth.mjs +2 -1
  17. package/dist/esm/commands/__tests__/build.test.d.ts +2 -0
  18. package/dist/esm/commands/__tests__/build.test.d.ts.map +1 -0
  19. package/dist/esm/commands/backend.d.ts.map +1 -1
  20. package/dist/esm/commands/backend.mjs +7 -1
  21. package/dist/esm/commands/build.d.ts.map +1 -1
  22. package/dist/esm/commands/build.mjs +10 -0
  23. package/dist/esm/commands/deploy.d.ts.map +1 -1
  24. package/dist/esm/commands/deploy.mjs +43 -20
  25. package/dist/esm/commands/grant.d.ts.map +1 -1
  26. package/dist/esm/commands/grant.mjs +8 -7
  27. package/dist/esm/index.mjs +41 -140
  28. package/dist/esm/types.d.ts +23 -0
  29. package/dist/esm/types.d.ts.map +1 -1
  30. package/dist/esm/util/__tests__/errors.test.d.ts +2 -0
  31. package/dist/esm/util/__tests__/errors.test.d.ts.map +1 -0
  32. package/dist/esm/util/__tests__/run-command.test.d.ts +2 -0
  33. package/dist/esm/util/__tests__/run-command.test.d.ts.map +1 -0
  34. package/dist/esm/util/auth/auth-store.d.ts +0 -4
  35. package/dist/esm/util/auth/auth-store.d.ts.map +1 -1
  36. package/dist/esm/util/auth/auth-store.mjs +2 -9
  37. package/dist/esm/util/auth/broker-credential-provider.d.ts.map +1 -1
  38. package/dist/esm/util/auth/broker-credential-provider.mjs +16 -16
  39. package/dist/esm/util/broker/app.d.ts.map +1 -1
  40. package/dist/esm/util/broker/app.mjs +17 -9
  41. package/dist/esm/util/errors.d.ts +48 -0
  42. package/dist/esm/util/errors.d.ts.map +1 -0
  43. package/dist/esm/util/errors.mjs +91 -0
  44. package/dist/esm/util/git/repo.d.ts +0 -3
  45. package/dist/esm/util/git/repo.d.ts.map +1 -1
  46. package/dist/esm/util/git/repo.mjs +4 -9
  47. package/dist/esm/util/logger.d.ts +4 -1
  48. package/dist/esm/util/logger.d.ts.map +1 -1
  49. package/dist/esm/util/logger.mjs +11 -3
  50. package/dist/esm/util/run-command.d.ts +16 -0
  51. package/dist/esm/util/run-command.d.ts.map +1 -0
  52. package/dist/esm/util/run-command.mjs +47 -0
  53. package/dist/esm/util/s3/upload.d.ts.map +1 -1
  54. package/dist/esm/util/s3/upload.mjs +22 -16
  55. package/dist/esm/util/tracker.d.ts +9 -2
  56. package/dist/esm/util/tracker.d.ts.map +1 -1
  57. package/dist/esm/util/tracker.mjs +18 -15
  58. package/dist/index.js +40 -139
  59. package/dist/types.d.ts +23 -0
  60. package/dist/types.d.ts.map +1 -1
  61. package/dist/util/__tests__/errors.test.d.ts +2 -0
  62. package/dist/util/__tests__/errors.test.d.ts.map +1 -0
  63. package/dist/util/__tests__/run-command.test.d.ts +2 -0
  64. package/dist/util/__tests__/run-command.test.d.ts.map +1 -0
  65. package/dist/util/auth/auth-store.d.ts +0 -4
  66. package/dist/util/auth/auth-store.d.ts.map +1 -1
  67. package/dist/util/auth/auth-store.js +2 -10
  68. package/dist/util/auth/broker-credential-provider.d.ts.map +1 -1
  69. package/dist/util/auth/broker-credential-provider.js +16 -16
  70. package/dist/util/broker/app.d.ts.map +1 -1
  71. package/dist/util/broker/app.js +17 -9
  72. package/dist/util/errors.d.ts +48 -0
  73. package/dist/util/errors.d.ts.map +1 -0
  74. package/dist/util/errors.js +102 -0
  75. package/dist/util/git/repo.d.ts +0 -3
  76. package/dist/util/git/repo.d.ts.map +1 -1
  77. package/dist/util/git/repo.js +4 -10
  78. package/dist/util/logger.d.ts +4 -1
  79. package/dist/util/logger.d.ts.map +1 -1
  80. package/dist/util/logger.js +11 -3
  81. package/dist/util/run-command.d.ts +16 -0
  82. package/dist/util/run-command.d.ts.map +1 -0
  83. package/dist/util/run-command.js +49 -0
  84. package/dist/util/s3/upload.d.ts.map +1 -1
  85. package/dist/util/s3/upload.js +22 -16
  86. package/dist/util/tracker.d.ts +9 -2
  87. package/dist/util/tracker.d.ts.map +1 -1
  88. package/dist/util/tracker.js +19 -14
  89. package/handler-api/backend-runner/channels/llm-channel/llm.channel.ts +3 -2
  90. package/handler-api/backend-runner/channels/snowflake-channel/run-query.ts +7 -6
  91. package/handler-api/backend-runner/channels/snowflake-channel/snowflake.channel.ts +1 -1
  92. package/handler-api/backend-runner/channels/snowflake-channel/stateless-part-b.ts +1 -4
  93. package/package.json +2 -2
  94. package/src/auth.ts +2 -1
  95. package/src/commands/__tests__/backend-deploy.test.ts +18 -0
  96. package/src/commands/__tests__/build.test.ts +83 -0
  97. package/src/commands/__tests__/deploy.test.ts +107 -0
  98. package/src/commands/backend.ts +6 -1
  99. package/src/commands/build.ts +10 -0
  100. package/src/commands/deploy.ts +42 -20
  101. package/src/commands/grant.ts +8 -7
  102. package/src/index.ts +84 -133
  103. package/src/types.ts +47 -0
  104. package/src/util/__tests__/errors.test.ts +90 -0
  105. package/src/util/__tests__/run-command.test.ts +98 -0
  106. package/src/util/auth/__tests__/auth-store.test.ts +2 -1
  107. package/src/util/auth/__tests__/broker-credential-provider.test.ts +44 -8
  108. package/src/util/auth/auth-store.ts +1 -7
  109. package/src/util/auth/broker-credential-provider.ts +18 -16
  110. package/src/util/broker/__tests__/app.test.ts +23 -20
  111. package/src/util/broker/app.ts +16 -9
  112. package/src/util/errors.ts +98 -0
  113. package/src/util/git/__tests__/repo.test.ts +5 -3
  114. package/src/util/git/repo.ts +3 -9
  115. package/src/util/logger.ts +16 -3
  116. package/src/util/run-command.ts +59 -0
  117. package/src/util/s3/upload.ts +27 -22
  118. package/src/util/tracker.ts +19 -19
@@ -18,10 +18,11 @@ import { editCommand } from './commands/edit.mjs';
18
18
  import { backendInvokeCommand } from './commands/backend.mjs';
19
19
  import { doctorCommand } from './commands/doctor.mjs';
20
20
  import { fail, errorLog, setOutputMode, getOutputMode } from './util/logger.mjs';
21
- import { trackDuration } from './util/tracker.mjs';
21
+ import { runCommand } from './util/run-command.mjs';
22
+ import { successEvent } from './util/tracker.mjs';
22
23
  import { getCwdAppName } from './util/app-name.mjs';
23
24
 
24
- const { version } = createRequire(import.meta.url)('../package.json');
25
+ const { version } = createRequire(import.meta.url)('@mondaydotcomorg/z2h-cli/package.json');
25
26
  const UPDATE_SCRIPT = path.join(os.homedir(), 'Development', 'bigbrain-z2h', 'z2h', 'setup', 'update.sh');
26
27
  function selfUpdate() {
27
28
  try {
@@ -44,6 +45,7 @@ function stripConflictingEnvVars() {
44
45
  function collectTag(value, previous) {
45
46
  return previous.concat(value);
46
47
  }
48
+ const cwdApp = () => ({ app_name: getCwdAppName() });
47
49
  async function main() {
48
50
  stripConflictingEnvVars();
49
51
  const program = new Command();
@@ -71,165 +73,86 @@ async function main() {
71
73
  program
72
74
  .command('build')
73
75
  .description('Build the consumer into its .zth/ shadow and copy artifacts to ./build/')
74
- .action(async () => {
75
- try {
76
- await trackDuration('z2h_app_build_success', () => buildCommand(), { app_name: getCwdAppName() });
77
- }
78
- catch (err) {
79
- await fail(`build failed: ${err.message}`, { command: 'build' }, 2);
80
- }
81
- });
76
+ // A standalone build failure is the consumer's own code, not a CLI/infra problem — don't
77
+ // track it. buildCommand still tags the reason on its thrown error, since deploy's own
78
+ // (tracked) failure event benefits from knowing when a build broke it.
79
+ .action(runCommand({ track: false, data: cwdApp, exitCode: 2 }, () => buildCommand()));
82
80
  program
83
81
  .command('clean')
84
82
  .description('Delete <consumer>/.zth/ and <consumer>/build/')
85
- .action(async () => {
86
- try {
87
- await cleanCommand();
88
- }
89
- catch (err) {
90
- await fail(`clean failed: ${err.message}`, { command: 'clean' }, 2);
91
- }
92
- });
83
+ .action(runCommand({ track: false, exitCode: 2 }, () => cleanCommand()));
93
84
  program
94
85
  .command('deploy')
95
86
  .description('Build, upload to S3, and register the app with the Z2H backend')
96
87
  .option('--dry-run', 'print what would happen without uploading anything')
97
88
  .option('--preview', 'build an ephemeral, shareable preview instead of deploying — no git required, no deploy lock, never touches the live version; reuses the same preview URL across runs (stable link)')
98
89
  .option('--open', 'open the resulting app/preview URL in the browser on success')
99
- .option('--remote <type>', 'First deploy only: source control remote to initialise — s3 (shared storage) or github (your repo). Error if the app already has a git remote.')
90
+ .option('--remote <type>', 'First deploy only: source control remote to initialise — s3 (shared storage, recommended, auto-backed-up) or github (manage it yourself in your own repo). Error if the app already has a git remote.')
100
91
  .option('--repo-url <url>', 'First deploy only: GitHub repo URL — required when --remote=github. Error if the app already has a git remote.')
101
92
  .option('--description <text>', 'short (<=200 char) description of the app')
102
- .action(async (opts) => {
103
- try {
104
- await trackDuration(opts.preview ? 'z2h_app_preview_success' : 'z2h_app_deploy_success', () => deployCommand(opts), {
105
- app_name: getCwdAppName(),
106
- });
107
- }
108
- catch (err) {
109
- const label = opts.preview ? 'preview' : 'deploy';
110
- await fail(`${label} failed: ${err.message}`, { command: label }, 2);
111
- }
112
- });
93
+ .action(runCommand({
94
+ // A preview is a real deploy for observability, tracked as its own event since
95
+ // the command name alone (`deploy`) can't distinguish it from a live deploy.
96
+ event: ([opts]) => successEvent(opts.preview ? 'preview' : 'deploy'),
97
+ label: ([opts]) => (opts.preview ? 'preview' : 'deploy'),
98
+ data: cwdApp,
99
+ exitCode: 2,
100
+ }, (opts) => deployCommand(opts)));
113
101
  program
114
102
  .command('tag [app-name]')
115
103
  .description("Set an app's category tags — app type & team (interactive unless --tag or --json is given)")
116
104
  .option('--tag <tag>', 'set a tag (repeatable); full-replaces the tag set non-interactively', collectTag, [])
117
- .action(async (appName, opts) => {
118
- try {
119
- await trackDuration('z2h_app_tag_success', () => tagCommand(appName, opts), {
120
- app_name: appName ?? getCwdAppName(),
121
- });
122
- }
123
- catch (err) {
124
- await fail(`tag failed: ${err.message}`, { command: 'tag' }, 1);
125
- }
126
- });
105
+ .action(runCommand({
106
+ data: ([appName]) => ({ app_name: appName ?? getCwdAppName() }),
107
+ }, (appName, opts) => tagCommand(appName, opts)));
127
108
  program
128
109
  .command('create-workspace')
129
110
  .description(`Bootstrap the ${getWorkspaceHome()}/ yarn workspace (one-time setup)`)
130
- .action(async () => {
131
- try {
132
- await createWorkspaceCommand();
133
- }
134
- catch (err) {
135
- await fail(`create-workspace failed: ${err.message}`, { command: 'create-workspace' }, 1);
136
- }
137
- });
111
+ .action(runCommand({ track: false }, () => createWorkspaceCommand()));
138
112
  program
139
113
  .command('generate-z2h-token')
140
114
  .description('Open the bigbrain.me token page, capture the token via a loopback callback, and persist it to ~/.zth/auth.json')
141
115
  .option('--no-browser', "don't auto-open the browser; print the URL and prompt for manual paste")
142
116
  .option('--url <url>', 'Override the token page URL (e.g. for staging)')
143
- .action(async (opts) => {
144
- try {
145
- await generateZ2HTokenCommand(opts);
146
- }
147
- catch (err) {
148
- await fail(`generate-z2h-token failed: ${err.message}`, { command: 'generate-z2h-token' }, 1);
149
- }
150
- });
117
+ .action(runCommand({}, (opts) => generateZ2HTokenCommand(opts)));
151
118
  program
152
119
  .command('create <app-name>')
153
120
  .description(`Scaffold a new Z2H consumer app inside ${getWorkspaceHome()}/`)
154
121
  .option('--template <name>', 'Template name (default | html-embed)')
155
122
  .option('--html-file <path>', 'Path to an HTML file to embed (implies --template html-embed)')
156
- .option('--remote <type>', 'Source control remote: s3 (shared storage) or github (your repo)')
123
+ .option('--remote <type>', 'Source control remote: s3 (shared storage, recommended, auto-backed-up) or github (manage it yourself in your own repo)')
157
124
  .option('--repo-url <url>', 'GitHub repo URL — required when --remote=github')
158
- .action(async (appName, opts) => {
159
- try {
160
- await trackDuration('z2h_app_created', () => createCommand(appName, opts), {
161
- app_name: appName,
162
- template: opts.template ?? 'default',
163
- remote: opts.remote ?? 'unknown',
164
- });
165
- }
166
- catch (err) {
167
- await fail(`create failed: ${err.message}`, { command: 'create' }, 1);
168
- }
169
- });
125
+ .action(runCommand({
126
+ data: ([appName, opts]) => ({
127
+ app_name: appName,
128
+ template: opts.template ?? 'default',
129
+ remote: opts.remote ?? 'unknown',
130
+ }),
131
+ }, (appName, opts) => createCommand(appName, opts)));
170
132
  program
171
133
  .command('edit <app-name>')
172
134
  .description(`Pull the latest version of an app into ${getWorkspaceHome()}/<app-name>, cloning it first if needed`)
173
- .action(async (appName) => {
174
- try {
175
- await trackDuration('z2h_app_edit_pulled', () => editCommand(appName), {
176
- app_name: appName,
177
- });
178
- }
179
- catch (err) {
180
- await fail(`edit failed: ${err.message}`, { command: 'edit' }, 1);
181
- }
182
- });
135
+ .action(runCommand({ data: ([appName]) => ({ app_name: appName }) }, (appName) => editCommand(appName)));
183
136
  program
184
137
  .command('grant [email]')
185
138
  .description('Grant access to the current app (email, --public, or both)')
186
139
  .option('--public', 'make the app visible to all monday.com employees')
187
140
  .option('--level <level>', 'access level for user grants: owner, editor, or viewer (default: viewer)')
188
- .action(async (email, opts) => {
189
- try {
190
- await grantCommand(email, opts);
191
- }
192
- catch (err) {
193
- await fail(`grant failed: ${err.message}`, { command: 'grant' }, 1);
194
- }
195
- });
141
+ .action(runCommand({}, (email, opts) => grantCommand(email, opts)));
196
142
  program
197
143
  .command('revoke [email]')
198
144
  .description('Revoke access to the current app (email or --public; owners/admins only)')
199
145
  .option('--public', 'remove the public grant, making the app visible to owners/admins only')
200
- .action(async (email, opts) => {
201
- try {
202
- await revokeCommand(email, opts);
203
- }
204
- catch (err) {
205
- await fail(`revoke failed: ${err.message}`, { command: 'revoke' }, 1);
206
- }
207
- });
146
+ .action(runCommand({}, (email, opts) => revokeCommand(email, opts)));
208
147
  program
209
148
  .command('transfer-owner [email]')
210
149
  .description('Transfer ownership of the current app to another monday.com user')
211
- .action(async (email) => {
212
- try {
213
- await transferOwnerCommand(email);
214
- }
215
- catch (err) {
216
- await fail(`transfer-owner failed: ${err.message}`, { command: 'transfer-owner' }, 1);
217
- }
218
- });
150
+ .action(runCommand({}, (email) => transferOwnerCommand(email)));
219
151
  program
220
152
  .command('delete')
221
153
  .description('Permanently delete the current app and take it offline (owners/admins only)')
222
154
  .option('--yes', 'skip the confirmation prompt (required for --json / non-interactive)')
223
- .action(async (opts) => {
224
- try {
225
- await trackDuration('z2h_app_delete_success', () => deleteCommand(opts), {
226
- app_name: getCwdAppName(),
227
- });
228
- }
229
- catch (err) {
230
- await fail(`delete failed: ${err.message}`, { command: 'delete' }, 1);
231
- }
232
- });
155
+ .action(runCommand({ data: cwdApp }, (opts) => deleteCommand(opts)));
233
156
  const backend = program
234
157
  .command('backend')
235
158
  .description("Inspect the app's backend: invoke a deployed handler by name");
@@ -237,40 +160,18 @@ async function main() {
237
160
  .command('invoke <handlerName>')
238
161
  .description('Invoke a deployed backend handler by name (the filename without .ts) — mainly for testing a handler without going through the frontend')
239
162
  .option('--input <json>', 'JSON payload passed as ctx.input')
240
- .action(async (handlerName, opts) => {
241
- try {
242
- await trackDuration('z2h_backend_invoke_success', () => backendInvokeCommand(handlerName, opts), {
243
- app_name: getCwdAppName(),
244
- handler: handlerName,
245
- });
246
- }
247
- catch (err) {
248
- await fail(`backend invoke failed: ${err.message}`, { command: 'backend invoke' }, 1);
249
- }
250
- });
163
+ .action(runCommand({
164
+ data: ([handlerName]) => ({ app_name: getCwdAppName(), handler: handlerName }),
165
+ }, (handlerName, opts) => backendInvokeCommand(handlerName, opts)));
251
166
  program
252
167
  .command('migrate')
253
168
  .description('Run pending workspace migrations')
254
169
  .option('--dry-run', 'show pending migrations without applying any changes')
255
- .action(async (opts) => {
256
- try {
257
- await migrateCommand(version, opts);
258
- }
259
- catch (err) {
260
- await fail(`migrate failed: ${err.message}`, { command: 'migrate' }, 1);
261
- }
262
- });
170
+ .action(runCommand({}, (opts) => migrateCommand(version, opts)));
263
171
  program
264
172
  .command('doctor')
265
173
  .description('Check that all Z2H tools, auth, workspace, and plugins are correctly set up')
266
- .action(async () => {
267
- try {
268
- await doctorCommand();
269
- }
270
- catch (err) {
271
- await fail(`doctor failed: ${err.message}`, { command: 'doctor' }, 1);
272
- }
273
- });
174
+ .action(runCommand({ track: false }, () => doctorCommand()));
274
175
  await program.parseAsync(process.argv);
275
176
  }
276
177
  void main()
@@ -50,4 +50,27 @@ export interface PreparedShadow {
50
50
  port: number;
51
51
  paths: ConsumerPaths;
52
52
  }
53
+ export type DeployFailureReason = 'read_auth_token' | 'broker_auth' | 'broker_error' | 'lock_timeout' | 'build_error' | 'git_error' | 's3_error' | 'deploy_backend_error' | 'register_error' | 'push_error' | 'interrupted' | 'unknown';
54
+ export type GrantFailureReason = 'validation' | 'auth' | 'forbidden' | 'not_found' | 'server_error' | 'unknown';
55
+ /**
56
+ * A spec value that is either a constant or a function of the command's own arguments.
57
+ * Callbacks take the args as one tuple rather than a spread, so a callback that reads only
58
+ * the first arg still typechecks. Destructure what you need.
59
+ */
60
+ export type PerArgs<A extends unknown[], T> = T | ((args: A) => T);
61
+ export interface CommandSpec<A extends unknown[]> {
62
+ /**
63
+ * Opt out of telemetry entirely — both the success event and the error event. Default `true`.
64
+ * Set `false` for a purely local command with no product-usage signal worth a round-trip.
65
+ */
66
+ track?: PerArgs<A, boolean>;
67
+ /** Success-event name when it depends on args (e.g. `deploy --preview`); defaults to `successEvent(<command>)`. */
68
+ event?: PerArgs<A, string>;
69
+ /** Prefix in the error message and the `action` dimension. Defaults to the command's own name. */
70
+ label?: PerArgs<A, string>;
71
+ /** Extra dimensions sent with both the success and the error event. */
72
+ data?: (args: A) => Record<string, unknown>;
73
+ /** Overrides the failing error's own exitCode. */
74
+ exitCode?: number;
75
+ }
53
76
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,EAAE,GAAG;QAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IAChD,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1C,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACtB;AAOD,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,IAAI,CAAC;IACd,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACzC;AAGD,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB;AAGD,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,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G,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;AAEnE,MAAM,WAAW,WAAW,CAAC,CAAC,SAAS,OAAO,EAAE;IAC9C;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;IAC5B,mHAAmH;IACnH,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IAC3B,kGAAkG;IAClG,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IAC3B,uEAAuE;IACvE,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5C,kDAAkD;IAClD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=errors.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.test.d.ts","sourceRoot":"","sources":["../../../../src/util/__tests__/errors.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=run-command.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-command.test.d.ts","sourceRoot":"","sources":["../../../../src/util/__tests__/run-command.test.ts"],"names":[],"mappings":""}
@@ -3,10 +3,6 @@ export declare const Z2H_AUTH_FILE: string;
3
3
  export interface ZthAuth {
4
4
  token: string;
5
5
  }
6
- export declare class Z2hAuthMissingError extends Error {
7
- readonly authFilePath: string;
8
- constructor(authFilePath: string);
9
- }
10
6
  export declare function readZthAuth(): Promise<ZthAuth>;
11
7
  /**
12
8
  * Synchronous, never-throws read of the z2h JWT from `~/.zth/auth.json`.
@@ -1 +1 @@
1
- {"version":3,"file":"auth-store.d.ts","sourceRoot":"","sources":["../../../../src/util/auth/auth-store.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,YAAY,QAAkC,CAAC;AAC5D,eAAO,MAAM,aAAa,QAAuC,CAAC;AAElE,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,qBAAa,mBAAoB,SAAQ,KAAK;aAChB,YAAY,EAAE,MAAM;gBAApB,YAAY,EAAE,MAAM;CAIjD;AAED,wBAAsB,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC,CAkBpD;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,GAAG,IAAI,CAUpD"}
1
+ {"version":3,"file":"auth-store.d.ts","sourceRoot":"","sources":["../../../../src/util/auth/auth-store.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,YAAY,QAAkC,CAAC;AAC5D,eAAO,MAAM,aAAa,QAAuC,CAAC;AAElE,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wBAAsB,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC,CAkBpD;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,GAAG,IAAI,CAUpD"}
@@ -1,20 +1,13 @@
1
1
  import path from 'node:path';
2
2
  import os from 'node:os';
3
3
  import { pathExists, readJson, readJsonSync } from 'fs-extra';
4
+ import { Z2hAuthMissingError } from '../errors.mjs';
4
5
 
5
6
  // npm-style convention: per-user config under ~/.zth (mirrors ~/.npmrc, ~/.aws/).
6
7
  // Kept out of the workspace dir so accidental `git init` in ~/zth-projects can't
7
8
  // stage it.
8
9
  const Z2H_AUTH_DIR = path.join(os.homedir(), '.zth');
9
10
  const Z2H_AUTH_FILE = path.join(Z2H_AUTH_DIR, 'auth.json');
10
- class Z2hAuthMissingError extends Error {
11
- authFilePath;
12
- constructor(authFilePath) {
13
- super(`No Z2H deploy token found at ${authFilePath}. Please run 'z2h-cli generate-z2h-token' command.`);
14
- this.authFilePath = authFilePath;
15
- this.name = 'Z2hAuthMissingError';
16
- }
17
- }
18
11
  async function readZthAuth() {
19
12
  if (process.env.Z2H_AUTH_TOKEN) {
20
13
  const token = process.env.Z2H_AUTH_TOKEN;
@@ -54,4 +47,4 @@ function tryReadAuthTokenSync() {
54
47
  }
55
48
  }
56
49
 
57
- export { Z2H_AUTH_DIR, Z2H_AUTH_FILE, Z2hAuthMissingError, readZthAuth, tryReadAuthTokenSync };
50
+ export { Z2H_AUTH_DIR, Z2H_AUTH_FILE, readZthAuth, tryReadAuthTokenSync };
@@ -1 +1 @@
1
- {"version":3,"file":"broker-credential-provider.d.ts","sourceRoot":"","sources":["../../../../src/util/auth/broker-credential-provider.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAyB,6BAA6B,EAAE,MAAM,gBAAgB,CAAC;AAE3F,eAAO,MAAM,eAAe,6BAA6B,CAAC;AAC1D,eAAO,MAAM,mBAAmB,0BAA0B,CAAC;AAiD3D;;;;GAIG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAUzE;AA4DD;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,EACvC,OAAO,EACP,SAAS,GACV,EAAE;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,6BAA6B,CAIhC"}
1
+ {"version":3,"file":"broker-credential-provider.d.ts","sourceRoot":"","sources":["../../../../src/util/auth/broker-credential-provider.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAyB,6BAA6B,EAAE,MAAM,gBAAgB,CAAC;AAE3F,eAAO,MAAM,eAAe,6BAA6B,CAAC;AAC1D,eAAO,MAAM,mBAAmB,0BAA0B,CAAC;AA0D3D;;;;GAIG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAMzE;AAwDD;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,EACvC,OAAO,EACP,SAAS,GACV,EAAE;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,6BAA6B,CAIhC"}
@@ -1,4 +1,5 @@
1
1
  import { brokerBaseUrl, routingHeaders } from '../../constants.mjs';
2
+ import { DeployError, messageOf } from '../errors.mjs';
2
3
  import { readZthAuth } from './auth-store.mjs';
3
4
 
4
5
  const STS_BROKER_PATH = '/z2h-cli/sts/credentials';
@@ -21,16 +22,23 @@ async function postToBroker(path, body) {
21
22
  });
22
23
  }
23
24
  catch (err) {
24
- const message = err instanceof Error ? err.message : String(err);
25
- throw new Error(`Z2H deploy broker request failed: ${message}`);
25
+ throw new DeployError('broker_error', `Z2H deploy broker request failed: ${messageOf(err)}`);
26
26
  }
27
27
  }
28
- function assertBrokerOk(res) {
28
+ /**
29
+ * Classifies a broker response: 401/403 are `broker_auth` (the user can fix them), any
30
+ * other non-ok status is `broker_error` (the broker or the network, not the user).
31
+ */
32
+ async function assertBrokerOk(res, errorLabel) {
29
33
  if (res.status === 401) {
30
- throw new Error(`Z2H deploy token rejected by the broker (401). Refresh user token by running 'z2h-cli generate-z2h-token'.`);
34
+ throw new DeployError('broker_auth', `Z2H deploy token rejected by the broker (401). Refresh user token by running 'z2h-cli generate-z2h-token'.`);
31
35
  }
32
36
  if (res.status === 403) {
33
- throw new Error(`Access denied (403). You do not have editor access to this app. Ask the app owner to grant you access via 'z2h-cli grant'.`);
37
+ throw new DeployError('broker_auth', `Access denied (403). You do not have editor access to this app. Ask the app owner to grant you access via 'z2h-cli grant'.`);
38
+ }
39
+ if (!res.ok) {
40
+ const text = await res.text();
41
+ throw new DeployError('broker_error', `Z2H ${errorLabel} broker returned ${res.status}: ${text.slice(0, 1024)}`);
34
42
  }
35
43
  }
36
44
  /**
@@ -40,27 +48,19 @@ function assertBrokerOk(res) {
40
48
  */
41
49
  async function fetchDeployVersion(appName) {
42
50
  const res = await postToBroker(DEPLOY_VERSION_PATH, { appName });
43
- assertBrokerOk(res);
44
- if (!res.ok) {
45
- const text = await res.text();
46
- throw new Error(`Z2H deploy broker returned ${res.status}: ${text.slice(0, 1024)}`);
47
- }
51
+ await assertBrokerOk(res, 'deploy');
48
52
  const body = (await res.json());
49
53
  return body.version ?? 0;
50
54
  }
51
55
  async function requestSts(path, body, errorLabel) {
52
56
  const res = await postToBroker(path, body);
53
- assertBrokerOk(res);
54
- if (!res.ok) {
55
- const text = await res.text();
56
- throw new Error(`Z2H ${errorLabel} broker returned ${res.status}: ${text.slice(0, 1024)}`);
57
- }
57
+ await assertBrokerOk(res, errorLabel);
58
58
  const responseBody = (await res.json());
59
59
  if (!responseBody.accessKeyId ||
60
60
  !responseBody.secretAccessKey ||
61
61
  !responseBody.sessionToken ||
62
62
  !responseBody.expiration) {
63
- throw new Error(`Z2H ${errorLabel} broker response missing required credential fields`);
63
+ throw new DeployError('broker_error', `Z2H ${errorLabel} broker response missing required credential fields`);
64
64
  }
65
65
  return {
66
66
  accessKeyId: responseBody.accessKeyId,
@@ -1 +1 @@
1
- {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../../../src/util/broker/app.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,WAAW,OAAO;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,wBAAsB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAsBvE;AA4CD,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,aAAa,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;GAKG;AACH,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC,CAWtF"}
1
+ {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../../../src/util/broker/app.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,WAAW,OAAO;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,wBAAsB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAsBvE;AA4CD,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,aAAa,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;GAKG;AACH,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC,CAiBtF"}
@@ -2,6 +2,7 @@ import { brokerBaseUrl, routingHeaders } from '../../constants.mjs';
2
2
  import { readZthAuth } from '../auth/auth-store.mjs';
3
3
  import { info } from '../logger.mjs';
4
4
  import { resolveAppVisibility } from '../prompt-visibility.mjs';
5
+ import { tagDeployError, DeployError } from '../errors.mjs';
5
6
 
6
7
  /**
7
8
  * Fetches a single app's current state from the broker.
@@ -36,7 +37,7 @@ async function registerApp(appName, token, version, entry, visibility, gitRemote
36
37
  });
37
38
  if (!res.ok) {
38
39
  const text = await res.text();
39
- throw new Error(`App registration failed (${res.status}): ${text.slice(0, 1024)}`);
40
+ throw new DeployError('register_error', `App registration failed (${res.status}): ${text.slice(0, 1024)}`);
40
41
  }
41
42
  }
42
43
  /** Releases a new version onto an app that already exists. */
@@ -48,7 +49,7 @@ async function updateApp(appName, token, version, entry, gitRemote, integrations
48
49
  });
49
50
  if (!res.ok) {
50
51
  const text = await res.text();
51
- throw new Error(`App update failed (${res.status}): ${text.slice(0, 1024)}`);
52
+ throw new DeployError('register_error', `App update failed (${res.status}): ${text.slice(0, 1024)}`);
52
53
  }
53
54
  }
54
55
  /**
@@ -59,14 +60,21 @@ async function updateApp(appName, token, version, entry, gitRemote, integrations
59
60
  */
60
61
  async function registerOrUpdateApp(opts) {
61
62
  const { appName, token, nextVersion, entry, gitRemote, integrations, description } = opts;
62
- if (nextVersion === 1) {
63
- const visibility = await resolveAppVisibility(appName);
64
- info(`registering "${appName}" → v${nextVersion} (${visibility})`);
65
- await registerApp(appName, token, nextVersion, entry, visibility, gitRemote, integrations, description);
63
+ try {
64
+ if (nextVersion === 1) {
65
+ const visibility = await resolveAppVisibility(appName);
66
+ info(`registering "${appName}" → v${nextVersion} (${visibility})`);
67
+ await registerApp(appName, token, nextVersion, entry, visibility, gitRemote, integrations, description);
68
+ }
69
+ else {
70
+ info(`updating "${appName}" → v${nextVersion}`);
71
+ await updateApp(appName, token, nextVersion, entry, gitRemote, integrations, description);
72
+ }
66
73
  }
67
- else {
68
- info(`updating "${appName}" → v${nextVersion}`);
69
- await updateApp(appName, token, nextVersion, entry, gitRemote, integrations, description);
74
+ catch (err) {
75
+ // registerApp/updateApp already tag the non-ok-response case; this catches anything
76
+ // else (a network throw, a resolveAppVisibility failure) under the same reason.
77
+ throw tagDeployError('register_error', err);
70
78
  }
71
79
  }
72
80
 
@@ -0,0 +1,48 @@
1
+ import type { DeployFailureReason, GrantFailureReason } from '../types';
2
+ /**
3
+ * Base for every error the CLI classifies. runCommand in ./run-command.ts reads `reason`
4
+ * and `data` straight off the error, so the throw site is the only place that needs to know
5
+ * why it failed. Nothing re-derives it from the error type at the top level.
6
+ *
7
+ * `exitCode` lets a throw site override the CLI's --help contract, 1 for user-resolvable
8
+ * and 2 for system failures, per error instead of per command. Nothing sets it yet. The
9
+ * command table still pins exit codes, which keeps today's behavior.
10
+ */
11
+ export declare class Z2hError extends Error {
12
+ readonly reason: string;
13
+ readonly data?: Record<string, unknown> | undefined;
14
+ readonly exitCode: number;
15
+ constructor(message: string, reason: string, data?: Record<string, unknown> | undefined, exitCode?: number);
16
+ }
17
+ /** Tags a deploy/preview stage failure with a bounded reason code instead of a freeform message. */
18
+ export declare class DeployError extends Z2hError {
19
+ readonly reason: DeployFailureReason;
20
+ constructor(reason: DeployFailureReason, message: string, data?: Record<string, unknown>);
21
+ }
22
+ /**
23
+ * Tags a grant/revoke/transfer-owner failure with a bounded reason code instead of a freeform message.
24
+ * `reason` also accepts a raw HTTP status, which gets mapped to a bounded reason internally.
25
+ */
26
+ export declare class GrantError extends Z2hError {
27
+ constructor(reason: GrantFailureReason | number, message: string, data?: Record<string, unknown>);
28
+ }
29
+ /** No z2h JWT found — see auth-store.ts for the discovery order (env var, then ~/.zth/auth.json). */
30
+ export declare class Z2hAuthMissingError extends Z2hError {
31
+ readonly authFilePath: string;
32
+ constructor(authFilePath: string);
33
+ }
34
+ /** A git pull diverged or a push was rejected; `reason` distinguishes which stage hit it. */
35
+ export declare class GitConflictError extends Z2hError {
36
+ constructor(message: string, reason?: DeployFailureReason);
37
+ }
38
+ /** Maps an HTTP status to a bounded grant/revoke/transfer-owner failure reason. */
39
+ export declare function grantReasonForStatus(status: number): GrantFailureReason;
40
+ /** Tags a failure with `reason`, unless `err` is already classified; `signal` overrides `reason` for a killed child process. */
41
+ export declare function tagDeployError(reason: DeployFailureReason, err: unknown): Z2hError;
42
+ /** Reads the bounded reason off a classified error; anything unclassified is `unknown`. */
43
+ export declare function reasonOf(err: unknown): string;
44
+ /** Extra telemetry dimensions the throw site attached, if any. */
45
+ export declare function dataOf(err: unknown): Record<string, unknown>;
46
+ /** Safe message for any thrown value. A non-Error throw must not break the error path. */
47
+ export declare function messageOf(err: unknown): string;
48
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/util/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAExE;;;;;;;;GAQG;AACH,qBAAa,QAAS,SAAQ,KAAK;IAG/B,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACvC,QAAQ,CAAC,QAAQ,EAAE,MAAM;gBAHzB,OAAO,EAAE,MAAM,EACN,MAAM,EAAE,MAAM,EACd,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YAAA,EAC9B,QAAQ,GAAE,MAAU;CAKhC;AAED,oGAAoG;AACpG,qBAAa,WAAY,SAAQ,QAAQ;aACT,MAAM,EAAE,mBAAmB;gBAA3B,MAAM,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAG3G;AAED;;;GAGG;AACH,qBAAa,UAAW,SAAQ,QAAQ;gBAC1B,MAAM,EAAE,kBAAkB,GAAG,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAGjG;AAED,qGAAqG;AACrG,qBAAa,mBAAoB,SAAQ,QAAQ;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