@mondaydotcomorg/z2h-cli 0.32.2 → 0.33.1
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/dist/backend/__tests__/format-sandbox-run.test.d.ts +2 -0
- package/dist/backend/__tests__/format-sandbox-run.test.d.ts.map +1 -0
- package/dist/backend/client.d.ts +32 -2
- package/dist/backend/client.d.ts.map +1 -1
- package/dist/backend/client.js +8 -5
- package/dist/backend/format-sandbox-run.d.ts +4 -0
- package/dist/backend/format-sandbox-run.d.ts.map +1 -0
- package/dist/backend/format-sandbox-run.js +49 -0
- package/dist/commands/__tests__/backend-invoke.test.d.ts +2 -0
- package/dist/commands/__tests__/backend-invoke.test.d.ts.map +1 -0
- package/dist/commands/__tests__/custom-integrations.test.d.ts +2 -0
- package/dist/commands/__tests__/custom-integrations.test.d.ts.map +1 -0
- package/dist/commands/backend.d.ts +6 -1
- package/dist/commands/backend.d.ts.map +1 -1
- package/dist/commands/backend.js +35 -3
- package/dist/commands/custom-integrations.d.ts +3 -0
- package/dist/commands/custom-integrations.d.ts.map +1 -0
- package/dist/commands/custom-integrations.js +51 -0
- package/dist/commands/deploy.js +3 -0
- package/dist/esm/backend/__tests__/format-sandbox-run.test.d.ts +2 -0
- package/dist/esm/backend/__tests__/format-sandbox-run.test.d.ts.map +1 -0
- package/dist/esm/backend/client.d.ts +32 -2
- package/dist/esm/backend/client.d.ts.map +1 -1
- package/dist/esm/backend/client.mjs +8 -5
- package/dist/esm/backend/format-sandbox-run.d.ts +4 -0
- package/dist/esm/backend/format-sandbox-run.d.ts.map +1 -0
- package/dist/esm/backend/format-sandbox-run.mjs +47 -0
- package/dist/esm/commands/__tests__/backend-invoke.test.d.ts +2 -0
- package/dist/esm/commands/__tests__/backend-invoke.test.d.ts.map +1 -0
- package/dist/esm/commands/__tests__/custom-integrations.test.d.ts +2 -0
- package/dist/esm/commands/__tests__/custom-integrations.test.d.ts.map +1 -0
- package/dist/esm/commands/backend.d.ts +6 -1
- package/dist/esm/commands/backend.d.ts.map +1 -1
- package/dist/esm/commands/backend.mjs +36 -4
- package/dist/esm/commands/custom-integrations.d.ts +3 -0
- package/dist/esm/commands/custom-integrations.d.ts.map +1 -0
- package/dist/esm/commands/custom-integrations.mjs +48 -0
- package/dist/esm/commands/deploy.mjs +3 -0
- package/dist/esm/index.mjs +18 -4
- package/dist/esm/util/app-name.mjs +1 -1
- package/dist/esm/util/broker/app.d.ts +4 -1
- package/dist/esm/util/broker/app.d.ts.map +1 -1
- package/dist/index.js +18 -4
- package/dist/util/app-name.js +1 -1
- package/dist/util/broker/app.d.ts +4 -1
- package/dist/util/broker/app.d.ts.map +1 -1
- package/handler-api/backend-runner/backend-runner.errors.ts +13 -0
- package/handler-api/backend-runner/backend-runner.types.ts +3 -0
- package/handler-api/backend-runner/channels/channel-map.ts +26 -6
- package/handler-api/backend-runner/channels/channel-telemetry.ts +13 -7
- package/handler-api/backend-runner/channels/channel-trace.ts +52 -0
- package/handler-api/backend-runner/channels/custom-integration-channel/custom-integration.channel.ts +243 -0
- package/handler-api/signatures.json +4 -0
- package/package.json +2 -2
- package/src/backend/__tests__/client.test.ts +17 -13
- package/src/backend/__tests__/format-sandbox-run.test.ts +42 -0
- package/src/backend/client.ts +27 -10
- package/src/backend/format-sandbox-run.ts +51 -0
- package/src/commands/__tests__/backend-invoke.test.ts +125 -0
- package/src/commands/__tests__/custom-integrations.test.ts +62 -0
- package/src/commands/backend.ts +43 -4
- package/src/commands/custom-integrations.ts +68 -0
- package/src/commands/deploy.ts +3 -0
- package/src/index.ts +24 -5
- package/src/util/app-name.ts +1 -1
- package/src/util/broker/__tests__/app.test.ts +32 -0
- package/src/util/broker/app.ts +4 -1
package/src/index.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { cleanCommand } from './commands/clean';
|
|
|
9
9
|
import { deployCommand } from './commands/deploy';
|
|
10
10
|
import { deleteCommand } from './commands/delete';
|
|
11
11
|
import { grantCommand, revokeCommand, transferOwnerCommand } from './commands/grant';
|
|
12
|
+
import { listCustomIntegrationsCommand, removeCustomIntegrationCommand } from './commands/custom-integrations';
|
|
12
13
|
import { createWorkspaceCommand } from './commands/create-workspace';
|
|
13
14
|
import { createCommand, CreateOptions } from './commands/create';
|
|
14
15
|
import { generateCommand, GenerateOptions } from './commands/generate';
|
|
@@ -260,6 +261,16 @@ async function main(): Promise<void> {
|
|
|
260
261
|
.description('Transfer ownership of the current app to another monday.com user')
|
|
261
262
|
.action(runCommand({}, (email: string | undefined) => transferOwnerCommand(email)));
|
|
262
263
|
|
|
264
|
+
program
|
|
265
|
+
.command('custom-integration:list')
|
|
266
|
+
.description("List the current app's registered custom integrations (never shows the PAT)")
|
|
267
|
+
.action(runCommand({}, () => listCustomIntegrationsCommand()));
|
|
268
|
+
|
|
269
|
+
program
|
|
270
|
+
.command('custom-integration:remove <name>')
|
|
271
|
+
.description('Remove a registered custom integration from the current app')
|
|
272
|
+
.action(runCommand({}, (name: string) => removeCustomIntegrationCommand(name)));
|
|
273
|
+
|
|
263
274
|
program
|
|
264
275
|
.command('delete')
|
|
265
276
|
.description('Permanently delete the current app and take it offline (owners/admins only)')
|
|
@@ -268,7 +279,7 @@ async function main(): Promise<void> {
|
|
|
268
279
|
|
|
269
280
|
const backend = program
|
|
270
281
|
.command('backend')
|
|
271
|
-
.description("Inspect the app's backend: validate handler sources or
|
|
282
|
+
.description("Inspect the app's backend: validate handler sources or run a handler from the working tree");
|
|
272
283
|
|
|
273
284
|
backend
|
|
274
285
|
.command('validate')
|
|
@@ -280,15 +291,21 @@ async function main(): Promise<void> {
|
|
|
280
291
|
backend
|
|
281
292
|
.command('invoke <handlerName>')
|
|
282
293
|
.description(
|
|
283
|
-
|
|
294
|
+
"Run backend/handlers/<handlerName>.js from the working tree — not the deployed handler — against the app's real " +
|
|
295
|
+
'channels (real db data, real monday calls), and print a trace of every channel call and the ' +
|
|
296
|
+
'result. Nothing is deployed. Exits 1 when the handler fails.'
|
|
297
|
+
)
|
|
298
|
+
.option('--input <json>', 'JSON passed to the handler as ctx.input (what the frontend would send)')
|
|
299
|
+
.option(
|
|
300
|
+
'--code <source>',
|
|
301
|
+
'run this source instead of backend/handlers/<handlerName>.js — <handlerName> is then just a label'
|
|
284
302
|
)
|
|
285
|
-
.option('--input <json>', 'JSON payload passed as ctx.input')
|
|
286
303
|
.action(
|
|
287
304
|
runCommand(
|
|
288
305
|
{
|
|
289
306
|
data: ([handlerName]: [string, unknown]) => ({ app_name: getCwdAppName(), handler: handlerName }),
|
|
290
307
|
},
|
|
291
|
-
(handlerName: string, opts: { input?: string }) => backendInvokeCommand(handlerName, opts)
|
|
308
|
+
(handlerName: string, opts: { input?: string; code?: string }) => backendInvokeCommand(handlerName, opts)
|
|
292
309
|
)
|
|
293
310
|
);
|
|
294
311
|
|
|
@@ -319,7 +336,9 @@ void main()
|
|
|
319
336
|
if (getOutputMode() === 'human') {
|
|
320
337
|
selfUpdate();
|
|
321
338
|
}
|
|
322
|
-
|
|
339
|
+
// A command can finish normally and still report a non-zero code (e.g.
|
|
340
|
+
// `backend invoke` when the handler failed) via process.exitCode.
|
|
341
|
+
process.exit(process.exitCode ?? 0);
|
|
323
342
|
})
|
|
324
343
|
.catch(async (err: unknown) => {
|
|
325
344
|
const errorMsg = err instanceof Error ? err.message : String(err);
|
package/src/util/app-name.ts
CHANGED
|
@@ -29,7 +29,7 @@ export function mfAppName(name: string): string {
|
|
|
29
29
|
// Names reserved by the host MF (mf-bigbrain-zth) for platform pages under
|
|
30
30
|
// /bigbrain-vibe/<name>. Creating an app with one of these would shadow the
|
|
31
31
|
// platform page in the URL, so we refuse upfront.
|
|
32
|
-
const RESERVED_APP_NAMES = new Set(['generate-z2h-token']);
|
|
32
|
+
const RESERVED_APP_NAMES = new Set(['generate-z2h-token', 'set-custom-integration']);
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* Validates a de-scoped, kebab-case app name against every rule shared by
|
|
@@ -60,6 +60,38 @@ describe('registerOrUpdateApp', () => {
|
|
|
60
60
|
});
|
|
61
61
|
});
|
|
62
62
|
|
|
63
|
+
it('forwards masterAppName on registration only', async () => {
|
|
64
|
+
const fetchMock = mockFetchOnce();
|
|
65
|
+
|
|
66
|
+
await registerOrUpdateApp({
|
|
67
|
+
appName: 'mf-zth-preview-abc-my-app',
|
|
68
|
+
token: 'jwt',
|
|
69
|
+
nextVersion: 1,
|
|
70
|
+
entry: ENTRY,
|
|
71
|
+
gitRemote: '',
|
|
72
|
+
masterAppName: 'mf-my-app',
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const [, init] = fetchMock.mock.calls[0] as [string, RequestInit];
|
|
76
|
+
expect(JSON.parse(init.body as string)).toMatchObject({ masterAppName: 'mf-my-app' });
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('does not send masterAppName on update — the link is immutable after registration', async () => {
|
|
80
|
+
const fetchMock = mockFetchOnce();
|
|
81
|
+
|
|
82
|
+
await registerOrUpdateApp({
|
|
83
|
+
appName: 'mf-zth-preview-abc-my-app',
|
|
84
|
+
token: 'jwt',
|
|
85
|
+
nextVersion: 2,
|
|
86
|
+
entry: ENTRY,
|
|
87
|
+
gitRemote: '',
|
|
88
|
+
masterAppName: 'mf-my-app',
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
const [, init] = fetchMock.mock.calls[0] as [string, RequestInit];
|
|
92
|
+
expect(JSON.parse(init.body as string)).not.toHaveProperty('masterAppName');
|
|
93
|
+
});
|
|
94
|
+
|
|
63
95
|
it('updates (not registers) when nextVersion > 1, without prompting for visibility', async () => {
|
|
64
96
|
const fetchMock = mockFetchOnce();
|
|
65
97
|
|
package/src/util/broker/app.ts
CHANGED
|
@@ -115,7 +115,10 @@ export interface RegisterOrUpdateOptions {
|
|
|
115
115
|
gitRemote: string;
|
|
116
116
|
integrations?: string[];
|
|
117
117
|
description?: string;
|
|
118
|
-
/**
|
|
118
|
+
/**
|
|
119
|
+
* The base app a preview is for, sent only on first registration — the link
|
|
120
|
+
* is set once and is immutable thereafter, so a later update doesn't need it.
|
|
121
|
+
*/
|
|
119
122
|
masterAppName?: string;
|
|
120
123
|
}
|
|
121
124
|
|