@mondaydotcomorg/z2h-cli 0.30.0 → 0.32.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.
Files changed (175) hide show
  1. package/dist/backend/handlers.d.ts +3 -0
  2. package/dist/backend/handlers.d.ts.map +1 -1
  3. package/dist/backend/handlers.js +7 -4
  4. package/dist/backend/parser/__tests__/ast.test.d.ts.map +1 -0
  5. package/dist/backend/parser/__tests__/parse.test.d.ts.map +1 -0
  6. package/dist/backend/parser/api-signatures.d.ts +4 -0
  7. package/dist/backend/parser/api-signatures.d.ts.map +1 -0
  8. package/dist/backend/parser/api-signatures.js +31 -0
  9. package/dist/backend/parser/api-usage.d.ts +5 -0
  10. package/dist/backend/parser/api-usage.d.ts.map +1 -0
  11. package/dist/backend/parser/api-usage.js +61 -0
  12. package/dist/backend/parser/bindings.d.ts +5 -0
  13. package/dist/backend/parser/bindings.d.ts.map +1 -0
  14. package/dist/backend/parser/bindings.js +84 -0
  15. package/dist/backend/parser/handler-declaration.d.ts.map +1 -0
  16. package/dist/backend/parser/member-path.d.ts +3 -0
  17. package/dist/backend/parser/member-path.d.ts.map +1 -0
  18. package/dist/backend/parser/member-path.js +31 -0
  19. package/dist/backend/parser/messages.d.ts.map +1 -0
  20. package/dist/backend/parser/parse.d.ts.map +1 -0
  21. package/dist/backend/{parse.js → parser/parse.js} +9 -9
  22. package/dist/backend/parser/static-value.d.ts +6 -0
  23. package/dist/backend/parser/static-value.d.ts.map +1 -0
  24. package/dist/backend/parser/static-value.js +117 -0
  25. package/dist/backend/parser/types.d.ts +53 -0
  26. package/dist/backend/parser/types.d.ts.map +1 -0
  27. package/dist/backend/parser/types.js +1 -0
  28. package/dist/backend/parser/utils.d.ts +19 -0
  29. package/dist/backend/parser/utils.d.ts.map +1 -0
  30. package/dist/backend/parser/utils.js +97 -0
  31. package/dist/backend/validate.d.ts +3 -3
  32. package/dist/backend/validate.d.ts.map +1 -1
  33. package/dist/backend/validate.js +18 -18
  34. package/dist/commands/__tests__/llm-migration.test.d.ts +2 -0
  35. package/dist/commands/__tests__/llm-migration.test.d.ts.map +1 -0
  36. package/dist/commands/backend.d.ts +2 -13
  37. package/dist/commands/backend.d.ts.map +1 -1
  38. package/dist/commands/backend.js +30 -21
  39. package/dist/commands/create.d.ts.map +1 -1
  40. package/dist/commands/create.js +1 -0
  41. package/dist/commands/deploy.d.ts.map +1 -1
  42. package/dist/commands/deploy.js +2 -8
  43. package/dist/commands/llm-migration.d.ts +6 -0
  44. package/dist/commands/llm-migration.d.ts.map +1 -0
  45. package/dist/commands/llm-migration.js +33 -0
  46. package/dist/commands/migrate.d.ts.map +1 -1
  47. package/dist/commands/migrate.js +6 -13
  48. package/dist/esm/backend/handlers.d.ts +3 -0
  49. package/dist/esm/backend/handlers.d.ts.map +1 -1
  50. package/dist/esm/backend/handlers.mjs +7 -4
  51. package/dist/esm/backend/parser/__tests__/ast.test.d.ts.map +1 -0
  52. package/dist/esm/backend/parser/__tests__/parse.test.d.ts.map +1 -0
  53. package/dist/esm/backend/parser/api-signatures.d.ts +4 -0
  54. package/dist/esm/backend/parser/api-signatures.d.ts.map +1 -0
  55. package/dist/esm/backend/parser/api-signatures.mjs +24 -0
  56. package/dist/esm/backend/parser/api-usage.d.ts +5 -0
  57. package/dist/esm/backend/parser/api-usage.d.ts.map +1 -0
  58. package/dist/esm/backend/parser/api-usage.mjs +58 -0
  59. package/dist/esm/backend/parser/bindings.d.ts +5 -0
  60. package/dist/esm/backend/parser/bindings.d.ts.map +1 -0
  61. package/dist/esm/backend/parser/bindings.mjs +81 -0
  62. package/dist/esm/backend/parser/handler-declaration.d.ts.map +1 -0
  63. package/dist/esm/backend/parser/member-path.d.ts +3 -0
  64. package/dist/esm/backend/parser/member-path.d.ts.map +1 -0
  65. package/dist/esm/backend/parser/member-path.mjs +29 -0
  66. package/dist/esm/backend/parser/messages.d.ts.map +1 -0
  67. package/dist/esm/backend/parser/parse.d.ts.map +1 -0
  68. package/dist/esm/backend/{parse.mjs → parser/parse.mjs} +1 -1
  69. package/dist/esm/backend/parser/static-value.d.ts +6 -0
  70. package/dist/esm/backend/parser/static-value.d.ts.map +1 -0
  71. package/dist/esm/backend/parser/static-value.mjs +114 -0
  72. package/dist/esm/backend/parser/types.d.ts +53 -0
  73. package/dist/esm/backend/parser/types.d.ts.map +1 -0
  74. package/dist/esm/backend/parser/types.mjs +1 -0
  75. package/dist/esm/backend/parser/utils.d.ts +19 -0
  76. package/dist/esm/backend/parser/utils.d.ts.map +1 -0
  77. package/dist/esm/backend/parser/utils.mjs +88 -0
  78. package/dist/esm/backend/validate.d.ts +3 -3
  79. package/dist/esm/backend/validate.d.ts.map +1 -1
  80. package/dist/esm/backend/validate.mjs +8 -8
  81. package/dist/esm/commands/__tests__/llm-migration.test.d.ts +2 -0
  82. package/dist/esm/commands/__tests__/llm-migration.test.d.ts.map +1 -0
  83. package/dist/esm/commands/backend.d.ts +2 -13
  84. package/dist/esm/commands/backend.d.ts.map +1 -1
  85. package/dist/esm/commands/backend.mjs +31 -22
  86. package/dist/esm/commands/create.d.ts.map +1 -1
  87. package/dist/esm/commands/create.mjs +1 -0
  88. package/dist/esm/commands/deploy.d.ts.map +1 -1
  89. package/dist/esm/commands/deploy.mjs +3 -8
  90. package/dist/esm/commands/llm-migration.d.ts +6 -0
  91. package/dist/esm/commands/llm-migration.d.ts.map +1 -0
  92. package/dist/esm/commands/llm-migration.mjs +27 -0
  93. package/dist/esm/commands/migrate.d.ts.map +1 -1
  94. package/dist/esm/commands/migrate.mjs +6 -12
  95. package/dist/esm/index.mjs +6 -0
  96. package/dist/esm/templates/app/usage.mjs +5 -0
  97. package/dist/esm/util/machine-identity.d.ts +2 -3
  98. package/dist/esm/util/machine-identity.d.ts.map +1 -1
  99. package/dist/esm/util/machine-identity.mjs +7 -4
  100. package/dist/esm/util/migrations-json.d.ts +28 -0
  101. package/dist/esm/util/migrations-json.d.ts.map +1 -0
  102. package/dist/esm/util/migrations-json.mjs +17 -0
  103. package/dist/index.js +6 -0
  104. package/dist/templates/app/usage.js +7 -0
  105. package/dist/util/machine-identity.d.ts +2 -3
  106. package/dist/util/machine-identity.d.ts.map +1 -1
  107. package/dist/util/machine-identity.js +11 -3
  108. package/dist/util/migrations-json.d.ts +28 -0
  109. package/dist/util/migrations-json.d.ts.map +1 -0
  110. package/dist/util/migrations-json.js +25 -0
  111. package/handler-api/signatures.json +26 -0
  112. package/migrations.json +6 -0
  113. package/package.json +1 -1
  114. package/src/backend/__tests__/handlers.test.ts +13 -2
  115. package/src/backend/__tests__/validate.test.ts +54 -0
  116. package/src/backend/handlers.ts +10 -5
  117. package/src/backend/parser/__tests__/ast.test.ts +252 -0
  118. package/src/backend/{__tests__ → parser/__tests__}/parse.test.ts +2 -2
  119. package/src/backend/parser/api-signatures.ts +23 -0
  120. package/src/backend/parser/api-usage.ts +73 -0
  121. package/src/backend/parser/bindings.ts +87 -0
  122. package/src/backend/parser/member-path.ts +31 -0
  123. package/src/backend/{parse.ts → parser/parse.ts} +1 -1
  124. package/src/backend/parser/static-value.ts +145 -0
  125. package/src/backend/parser/types.ts +66 -0
  126. package/src/backend/parser/utils.ts +106 -0
  127. package/src/backend/validate.ts +12 -8
  128. package/src/commands/__tests__/backend-deploy.test.ts +70 -5
  129. package/src/commands/__tests__/backend-validate.test.ts +11 -1
  130. package/src/commands/__tests__/create.test.ts +1 -0
  131. package/src/commands/__tests__/llm-migration.test.ts +98 -0
  132. package/src/commands/backend.ts +31 -20
  133. package/src/commands/create.ts +1 -0
  134. package/src/commands/deploy.ts +3 -9
  135. package/src/commands/llm-migration.ts +33 -0
  136. package/src/commands/migrate.ts +7 -25
  137. package/src/index.ts +7 -0
  138. package/src/migrations-llm/snowflake-service-to-backend-runner.md +168 -0
  139. package/src/templates/app/usage.json +1 -0
  140. package/src/util/machine-identity.ts +7 -3
  141. package/src/util/migrations-json.ts +45 -0
  142. package/dist/backend/__tests__/ast.test.d.ts.map +0 -1
  143. package/dist/backend/__tests__/parse.test.d.ts.map +0 -1
  144. package/dist/backend/ast.d.ts +0 -39
  145. package/dist/backend/ast.d.ts.map +0 -1
  146. package/dist/backend/ast.js +0 -149
  147. package/dist/backend/handler-declaration.d.ts.map +0 -1
  148. package/dist/backend/messages.d.ts.map +0 -1
  149. package/dist/backend/parse.d.ts.map +0 -1
  150. package/dist/esm/backend/__tests__/ast.test.d.ts.map +0 -1
  151. package/dist/esm/backend/__tests__/parse.test.d.ts.map +0 -1
  152. package/dist/esm/backend/ast.d.ts +0 -39
  153. package/dist/esm/backend/ast.d.ts.map +0 -1
  154. package/dist/esm/backend/ast.mjs +0 -144
  155. package/dist/esm/backend/handler-declaration.d.ts.map +0 -1
  156. package/dist/esm/backend/messages.d.ts.map +0 -1
  157. package/dist/esm/backend/parse.d.ts.map +0 -1
  158. package/src/backend/__tests__/ast.test.ts +0 -53
  159. package/src/backend/ast.ts +0 -201
  160. /package/dist/backend/{__tests__ → parser/__tests__}/ast.test.d.ts +0 -0
  161. /package/dist/backend/{__tests__ → parser/__tests__}/parse.test.d.ts +0 -0
  162. /package/dist/backend/{handler-declaration.d.ts → parser/handler-declaration.d.ts} +0 -0
  163. /package/dist/backend/{handler-declaration.js → parser/handler-declaration.js} +0 -0
  164. /package/dist/backend/{messages.d.ts → parser/messages.d.ts} +0 -0
  165. /package/dist/backend/{messages.js → parser/messages.js} +0 -0
  166. /package/dist/backend/{parse.d.ts → parser/parse.d.ts} +0 -0
  167. /package/dist/esm/backend/{__tests__ → parser/__tests__}/ast.test.d.ts +0 -0
  168. /package/dist/esm/backend/{__tests__ → parser/__tests__}/parse.test.d.ts +0 -0
  169. /package/dist/esm/backend/{handler-declaration.d.ts → parser/handler-declaration.d.ts} +0 -0
  170. /package/dist/esm/backend/{handler-declaration.mjs → parser/handler-declaration.mjs} +0 -0
  171. /package/dist/esm/backend/{messages.d.ts → parser/messages.d.ts} +0 -0
  172. /package/dist/esm/backend/{messages.mjs → parser/messages.mjs} +0 -0
  173. /package/dist/esm/backend/{parse.d.ts → parser/parse.d.ts} +0 -0
  174. /package/src/backend/{handler-declaration.ts → parser/handler-declaration.ts} +0 -0
  175. /package/src/backend/{messages.ts → parser/messages.ts} +0 -0
@@ -1,8 +1,10 @@
1
1
  import path from 'node:path';
2
2
  import { existsSync } from 'node:fs';
3
+ import { readJson, writeJson } from 'fs-extra';
3
4
  import { PutObjectCommand } from '@aws-sdk/client-s3';
4
5
  import { output, info } from '../util/logger.mjs';
5
- import { getCwdAppName, mfAppName } from '../util/app-name.mjs';
6
+ import { mfAppName, getCwdAppName } from '../util/app-name.mjs';
7
+ import { whoAmI } from '../util/machine-identity.mjs';
6
8
  import { readHandlers } from '../backend/handlers.mjs';
7
9
  import { detectIntegrations } from '../backend/detect-integrations.mjs';
8
10
  import { getS3Client } from '../util/s3/client.mjs';
@@ -17,30 +19,41 @@ function currentAppName() {
17
19
  }
18
20
  return mfAppName(raw);
19
21
  }
20
- /**
21
- * True if the app ships an app-level backend — a `backend/handlers/` directory.
22
- * Callers gate on this so the deploy path is explicit about whether a backend is in
23
- * play.
24
- */
25
22
  function hasHandlers(appDir) {
26
23
  return existsSync(path.join(appDir, 'backend', 'handlers'));
27
24
  }
25
+ /** Other features may add top-level fields, so writes below merge into this copy instead of replacing it. */
26
+ async function readExistingUsage(appDir) {
27
+ try {
28
+ return (await readJson(path.join(appDir, 'usage.json')));
29
+ }
30
+ catch (err) {
31
+ if (err.code === 'ENOENT') {
32
+ return {};
33
+ }
34
+ throw err;
35
+ }
36
+ }
37
+ /** Keeps the app's git-tracked `usage.json` current with every handler parse (validate or deploy). */
38
+ async function writeUsageJson(appDir, patch) {
39
+ const existing = await readExistingUsage(appDir);
40
+ await writeJson(path.join(appDir, 'usage.json'), { ...existing, ...patch }, { spaces: 2 });
41
+ }
28
42
  /**
29
- * Read handlers, detect declared integrations, and upload to `prefix` when there
30
- * is anything to upload. Returns `[]` when there is no `backend/handlers/` dir
31
- * (or it is empty of sources) so callers can always pass the result to
32
- * `registerOrUpdateApp` without a separate gate.
43
+ * Returns `[]` when there is no `backend/handlers/` dir (or it is empty of sources)
44
+ * so callers can always pass the result to `registerOrUpdateApp` without a separate gate.
33
45
  */
34
- async function readDetectAndUpload(appDir, prefix, version, deployedBy, logLabel) {
46
+ async function readDetectAndUpload(appDir, prefix, appName, version, deployedBy, logLabel) {
35
47
  if (!hasHandlers(appDir)) {
36
48
  return [];
37
49
  }
38
50
  info(`reading backend handlers ${logLabel}`);
39
- const { handlers, apiDomains } = await readHandlers(appDir);
51
+ const { handlers, apiDomains, apiUsages } = await readHandlers(appDir);
40
52
  const integrations = detectIntegrations(apiDomains);
41
53
  if (Object.keys(handlers).length === 0) {
42
54
  return integrations;
43
55
  }
56
+ await writeUsageJson(appDir, { appName, deployedBy, apiUsages });
44
57
  const s3 = getS3Client();
45
58
  const meta = JSON.stringify({ version, deployedBy, handlers: Object.keys(handlers) });
46
59
  const put = (key, body, contentType) => s3.send(new PutObjectCommand({ Bucket: BUCKET_WRITE_NAME, Key: key, Body: body, ContentType: contentType }));
@@ -55,11 +68,6 @@ async function readDetectAndUpload(appDir, prefix, version, deployedBy, logLabel
55
68
  * from their sources. Each `.js` handler is uploaded as its own flat file — no
56
69
  * compilation, no bundling, no npm deps.
57
70
  *
58
- * Live and preview differ only in where the handlers land, so that is the only
59
- * thing `isPreview` switches:
60
- * - live: `<appName>/backend-<version>` — the app's immutable per-version slot.
61
- * - preview: `<mfKeyPrefix without /MF>/MS` — beside the preview's `/MF` frontend.
62
- *
63
71
  * Integration sync note: the returned set is re-derived from the CURRENT backend
64
72
  * sources on every deploy, and the platform set is reconciled to exactly match
65
73
  * it (there is no stored declaration to fall back on). A deploy therefore always
@@ -71,25 +79,26 @@ async function deployBackend(opts) {
71
79
  const prefix = isPreview ? `${mfKeyPrefix.replace(/\/MF$/, '')}/MS` : `${appName}/backend-${version}`;
72
80
  const logLabel = isPreview ? 'for preview' : `for "${appName}"`;
73
81
  try {
74
- return await readDetectAndUpload(appDir, prefix, version, deployedBy, logLabel);
82
+ return await readDetectAndUpload(appDir, prefix, appName, version, deployedBy, logLabel);
75
83
  }
76
84
  catch (err) {
77
85
  throw tagDeployError('deploy_backend_error', err);
78
86
  }
79
87
  }
80
88
  /**
81
- * Run the same handler validation deploy runs (syntax, isolate constraints,
82
- * handler rules, integration detection) against the working tree — without
83
- * uploading anything. Throws on the first invalid handler.
89
+ * Runs the same checks deploy does against the working tree, refreshing the
90
+ * local `usage.json` — no upload to S3. Throws on the first invalid handler.
84
91
  */
85
92
  async function backendValidateCommand(appDir = process.cwd()) {
86
93
  if (!hasHandlers(appDir)) {
87
94
  output('[z2h-cli] no backend/handlers/ directory — nothing to validate', { handlers: [], integrations: [] });
88
95
  return;
89
96
  }
90
- const { handlers, apiDomains } = await readHandlers(appDir);
97
+ const { handlers, apiDomains, apiUsages } = await readHandlers(appDir);
91
98
  const names = Object.keys(handlers).sort();
92
99
  const integrations = detectIntegrations(apiDomains);
100
+ const { name } = (await readJson(path.join(appDir, 'package.json')));
101
+ await writeUsageJson(appDir, { appName: name ? mfAppName(name) : undefined, deployedBy: whoAmI(), apiUsages });
93
102
  const list = (xs) => (xs.length ? xs.join(', ') : 'none');
94
103
  output(`[z2h-cli] ${names.length} handler(s) valid: ${list(names)}\n[z2h-cli] integrations: ${list(integrations)}`, {
95
104
  handlers: names,
@@ -1 +1 @@
1
- {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/commands/create.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,YAAY,EAAE,KAAK,UAAU,EAA2C,MAAM,4BAA4B,CAAC;AAKpH,OAAO,EAAE,YAAY,EAAE,KAAK,UAAU,EAAE,CAAC;AAEzC,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAwBD,wBAAsB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,aAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CA6F5F"}
1
+ {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/commands/create.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,YAAY,EAAE,KAAK,UAAU,EAA2C,MAAM,4BAA4B,CAAC;AAKpH,OAAO,EAAE,YAAY,EAAE,KAAK,UAAU,EAAE,CAAC;AAEzC,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAwBD,wBAAsB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,aAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CA8F5F"}
@@ -85,6 +85,7 @@ async function createCommand(appName, opts = {}) {
85
85
  await copy(path.join(appTemplatesDir, 'gitignore'), path.join(appDir, '.gitignore'));
86
86
  await copy(path.join(appTemplatesDir, 'claude-settings.json'), path.join(appDir, '.claude', 'settings.json'));
87
87
  await copy(path.join(appTemplatesDir, 'CLAUDE.md'), path.join(appDir, 'CLAUDE.md'));
88
+ await copy(path.join(appTemplatesDir, 'usage.json'), path.join(appDir, 'usage.json'));
88
89
  // html-embed: also copy the source HTML.
89
90
  if (template === 'html-embed' && opts.htmlFile) {
90
91
  await copy(opts.htmlFile, path.join(appDir, 'src', 'page.html'));
@@ -1 +1 @@
1
- {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../../src/commands/deploy.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,KAAK,UAAU,EAA2C,MAAM,4BAA4B,CAAC;AAkBtG,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IAIrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAWD,wBAAsB,aAAa,CAAC,IAAI,GAAE,aAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAyB3E"}
1
+ {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../../src/commands/deploy.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,KAAK,UAAU,EAA2C,MAAM,4BAA4B,CAAC;AAatG,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IAIrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAWD,wBAAsB,aAAa,CAAC,IAAI,GAAE,aAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAyB3E"}
@@ -1,4 +1,3 @@
1
- import os from 'node:os';
2
1
  import path from 'node:path';
3
2
  import { readJson, ensureDir, copy } from 'fs-extra';
4
3
  import { info, output, getOutputMode, warn } from '../util/logger.mjs';
@@ -13,7 +12,7 @@ import { getRemoteUrl, initRepo, guardCleanTree, pullAndResolve, pushToRemote }
13
12
  import { resolveGitEnv } from '../util/git/git-env.mjs';
14
13
  import { validateRemoteOptions, resolveRemoteUrl } from '../util/git/remote-options.mjs';
15
14
  import { setupS3Client } from '../util/s3/client.mjs';
16
- import { getMachineAppName } from '../util/machine-identity.mjs';
15
+ import { whoAmI } from '../util/machine-identity.mjs';
17
16
  import { fetchApp, registerOrUpdateApp } from '../util/broker/app.mjs';
18
17
  import { openInBrowser } from '../util/open-browser.mjs';
19
18
  import { resolvePortAndMetadata } from '../shadow/prepare.mjs';
@@ -22,10 +21,6 @@ import { deployBackend } from './backend.mjs';
22
21
  import { buildCommand } from './build.mjs';
23
22
  import { promptForTags } from './tag.mjs';
24
23
 
25
- /** Who is publishing this version — the machine identity, else the OS user. */
26
- function whoDeployed() {
27
- return getMachineAppName() ?? os.userInfo().username;
28
- }
29
24
  // Should be run from the consumer app directory — uses process.cwd() to locate it.
30
25
  async function deployCommand(opts = {}) {
31
26
  const paths = resolveConsumerPaths(process.cwd());
@@ -68,7 +63,7 @@ async function buildAndStamp(opts) {
68
63
  else {
69
64
  ({ assetManifest } = await buildCommand({ publicUrl: opts.publicUrl }));
70
65
  }
71
- const deployedBy = whoDeployed();
66
+ const deployedBy = whoAmI();
72
67
  return {
73
68
  ...assetManifest,
74
69
  version: opts.nextVersion,
@@ -94,7 +89,7 @@ async function uploadAndRegister(opts) {
94
89
  appName,
95
90
  mfKeyPrefix: keyPrefix,
96
91
  version: nextVersion,
97
- deployedBy: whoDeployed(),
92
+ deployedBy: whoAmI(),
98
93
  isPreview,
99
94
  });
100
95
  await registerOrUpdateApp({
@@ -0,0 +1,6 @@
1
+ export interface LlmMigrationOptions {
2
+ /** Omit to list every LLM migration instead of printing one guide. */
3
+ migration?: string;
4
+ }
5
+ export declare function llmMigrationCommand(opts: LlmMigrationOptions): Promise<void>;
6
+ //# sourceMappingURL=llm-migration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"llm-migration.d.ts","sourceRoot":"","sources":["../../../src/commands/llm-migration.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,mBAAmB;IAClC,sEAAsE;IACtE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAsBlF"}
@@ -0,0 +1,27 @@
1
+ import path from 'node:path';
2
+ import { readFile } from 'fs-extra';
3
+ import { output } from '../util/logger.mjs';
4
+ import { resolveMigrationsJson, LLM_MIGRATION_TYPE } from '../util/migrations-json.mjs';
5
+
6
+ async function llmMigrationCommand(opts) {
7
+ const resolved = await resolveMigrationsJson();
8
+ if (!resolved) {
9
+ throw new Error('migrations.json not found');
10
+ }
11
+ const { migrationsJson, migrationsDir } = resolved;
12
+ if (!opts.migration) {
13
+ const migrations = Object.entries(migrationsJson.migrations)
14
+ .filter(([, entry]) => entry.type === LLM_MIGRATION_TYPE)
15
+ .map(([name, entry]) => ({ name, description: entry.description }));
16
+ output(migrations.map(m => `${m.name}\n ${m.description}`).join('\n'), { ok: true, migrations });
17
+ return;
18
+ }
19
+ const entry = migrationsJson.migrations[opts.migration];
20
+ if (entry?.type !== LLM_MIGRATION_TYPE) {
21
+ throw new Error(`no LLM migration named "${opts.migration}"`);
22
+ }
23
+ const guide = await readFile(path.resolve(migrationsDir, entry.guide), 'utf8');
24
+ output(guide, { ok: true, description: entry.description, guide });
25
+ }
26
+
27
+ export { llmMigrationCommand };
@@ -1 +1 @@
1
- {"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../../src/commands/migrate.ts"],"names":[],"mappings":"AA4BA,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAMnD;AAqBD,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,wBAAsB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,GAAE,cAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAmGjG"}
1
+ {"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../../src/commands/migrate.ts"],"names":[],"mappings":"AAiBA,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAMnD;AAqBD,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,wBAAsB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,GAAE,cAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CA4FjG"}
@@ -1,13 +1,12 @@
1
1
  import { createRequire } from 'node:module';
2
2
  import path from 'node:path';
3
- import { fileURLToPath } from 'node:url';
4
3
  import { pathExists, readJson, writeJson } from 'fs-extra';
5
4
  import semver from 'semver';
6
5
  import { warn, info, errorLog } from '../util/logger.mjs';
7
6
  import { getWorkspaceHome, isZ2hWorkspace, ensureWorkspaceNx, runYarnInstall } from '../util/workspace.mjs';
7
+ import { resolveMigrationsJson, LLM_MIGRATION_TYPE } from '../util/migrations-json.mjs';
8
8
 
9
9
  const STATE_FILE = '.z2h-migrations-state.json';
10
- // ─── Helpers ───
11
10
  // A prerelease sorts BELOW its own release under plain semver ordering, so
12
11
  // comparing raw beta versions here would skip migrations the beta introduced.
13
12
  function baseVersion(version) {
@@ -47,19 +46,14 @@ async function migrateCommand(cliVersion, opts = {}) {
47
46
  return;
48
47
  }
49
48
  info(`migrating workspace from v${lastVersion} → v${targetVersion}...`);
50
- // migrations.json is at the package root — two dirs up from dist/migrations/
51
- const thisDir = path.dirname(fileURLToPath(import.meta.url));
52
- const migrationsJsonPath = path.resolve(thisDir, '..', '..', 'migrations.json');
53
- if (!(await pathExists(migrationsJsonPath))) {
49
+ const resolved = await resolveMigrationsJson();
50
+ if (!resolved) {
54
51
  warn('migrations.json not found — skipping migrations');
55
52
  return;
56
53
  }
57
- const migrationsJson = (await readJson(migrationsJsonPath));
58
- // Filter to pending migrations (version > lastVersion AND <= targetVersion).
59
- // CONVENTION: a migration's `version` field must equal the CLI release it
60
- // ships with (not the feature branch version). This ensures the `gt` check
61
- // always catches a migration on the exact upgrade that introduces it.
54
+ const { migrationsJson, migrationsDir } = resolved;
62
55
  const pending = Object.entries(migrationsJson.migrations)
56
+ .filter((pair) => pair[1].type !== LLM_MIGRATION_TYPE)
63
57
  .filter(([, entry]) => semver.gt(entry.version, lastVersion) && semver.lte(entry.version, targetVersion))
64
58
  .sort(([, a], [, b]) => semver.compare(a.version, b.version));
65
59
  if (opts.dryRun) {
@@ -85,7 +79,7 @@ async function migrateCommand(cliVersion, opts = {}) {
85
79
  for (const [name, entry] of pending) {
86
80
  const tree = new FsTree(workspaceHome, false);
87
81
  try {
88
- const factoryPath = path.resolve(path.dirname(migrationsJsonPath), entry.migrate);
82
+ const factoryPath = path.resolve(migrationsDir, entry.migrate);
89
83
  const mod = require(factoryPath);
90
84
  const fn = mod.default || mod;
91
85
  fn(tree);
@@ -15,6 +15,7 @@ import { generateCommand } from './commands/generate.mjs';
15
15
  import { templatesCommand } from './commands/templates.mjs';
16
16
  import { generateZ2HTokenCommand } from './commands/generate-z2h-token.mjs';
17
17
  import { migrateCommand } from './commands/migrate.mjs';
18
+ import { llmMigrationCommand } from './commands/llm-migration.mjs';
18
19
  import { tagCommand } from './commands/tag.mjs';
19
20
  import { editCommand } from './commands/edit.mjs';
20
21
  import { backendValidateCommand, backendInvokeCommand } from './commands/backend.mjs';
@@ -187,6 +188,11 @@ async function main() {
187
188
  .description('Run pending workspace migrations')
188
189
  .option('--dry-run', 'show pending migrations without applying any changes')
189
190
  .action(runCommand({}, (opts) => migrateCommand(version, opts)));
191
+ program
192
+ .command('llm-migration')
193
+ .description('List agent-guided (LLM) migrations, or print one migration guide with --migration')
194
+ .option('--migration <name>', 'name of the LLM migration to print; omit to list all')
195
+ .action(runCommand({}, (opts) => llmMigrationCommand(opts)));
190
196
  program
191
197
  .command('doctor')
192
198
  .description('Check that all Z2H tools, auth, workspace, and plugins are correctly set up')
@@ -0,0 +1,5 @@
1
+ const usage = {
2
+
3
+ };
4
+
5
+ export { usage as default };
@@ -1,9 +1,8 @@
1
1
  /**
2
2
  * Returns the machine app name when running as a service (e.g. agent-runner).
3
3
  * Available when the process is a monday.com microservice with `APP_NAME` set
4
- * by the platform runtime.
5
- *
6
- * Returns `undefined` for interactive human users (fallback to os.userInfo).
4
+ * by the platform runtime. Returns `undefined` for interactive human users.
7
5
  */
8
6
  export declare function getMachineAppName(): string | undefined;
7
+ export declare function whoAmI(): string;
9
8
  //# sourceMappingURL=machine-identity.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"machine-identity.d.ts","sourceRoot":"","sources":["../../../src/util/machine-identity.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,GAAG,SAAS,CAEtD"}
1
+ {"version":3,"file":"machine-identity.d.ts","sourceRoot":"","sources":["../../../src/util/machine-identity.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,GAAG,SAAS,CAEtD;AAED,wBAAgB,MAAM,IAAI,MAAM,CAE/B"}
@@ -1,12 +1,15 @@
1
+ import os from 'node:os';
2
+
1
3
  /**
2
4
  * Returns the machine app name when running as a service (e.g. agent-runner).
3
5
  * Available when the process is a monday.com microservice with `APP_NAME` set
4
- * by the platform runtime.
5
- *
6
- * Returns `undefined` for interactive human users (fallback to os.userInfo).
6
+ * by the platform runtime. Returns `undefined` for interactive human users.
7
7
  */
8
8
  function getMachineAppName() {
9
9
  return process.env.APP_NAME || undefined;
10
10
  }
11
+ function whoAmI() {
12
+ return getMachineAppName() ?? os.userInfo().username;
13
+ }
11
14
 
12
- export { getMachineAppName };
15
+ export { getMachineAppName, whoAmI };
@@ -0,0 +1,28 @@
1
+ export interface DeterministicMigrationEntry {
2
+ type?: never;
3
+ /** Must equal the CLI release it ships with (not the feature branch version),
4
+ * so the `gt` check in migrate.ts always catches it on the exact upgrade that introduces it. */
5
+ version: string;
6
+ description: string;
7
+ migrate: string;
8
+ }
9
+ export declare const LLM_MIGRATION_TYPE: "llm";
10
+ /** Applied by handing `guide`'s contents to the calling agent. The guide owns detection too:
11
+ * it tells the agent how to find the old pattern and to report "not relevant" if absent. */
12
+ export interface LlmMigrationEntry {
13
+ type: typeof LLM_MIGRATION_TYPE;
14
+ /** Version of the CLI this migration was added at. */
15
+ version: string;
16
+ description: string;
17
+ /** Path (relative to migrations.json) to the markdown guideline for the agent applying this migration. */
18
+ guide: string;
19
+ }
20
+ export type MigrationEntry = DeterministicMigrationEntry | LlmMigrationEntry;
21
+ export interface MigrationsJson {
22
+ migrations: Record<string, MigrationEntry>;
23
+ }
24
+ export declare function resolveMigrationsJson(): Promise<{
25
+ migrationsJson: MigrationsJson;
26
+ migrationsDir: string;
27
+ } | null>;
28
+ //# sourceMappingURL=migrations-json.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrations-json.d.ts","sourceRoot":"","sources":["../../../src/util/migrations-json.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,2BAA2B;IAC1C,IAAI,CAAC,EAAE,KAAK,CAAC;IACb;qGACiG;IACjG,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,kBAAkB,EAAG,KAAc,CAAC;AAEjD;6FAC6F;AAC7F,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,OAAO,kBAAkB,CAAC;IAChC,sDAAsD;IACtD,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,0GAA0G;IAC1G,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,cAAc,GAAG,2BAA2B,GAAG,iBAAiB,CAAC;AAE7E,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;CAC5C;AAED,wBAAsB,qBAAqB,IAAI,OAAO,CAAC;IACrD,cAAc,EAAE,cAAc,CAAC;IAC/B,aAAa,EAAE,MAAM,CAAC;CACvB,GAAG,IAAI,CAAC,CASR"}
@@ -0,0 +1,17 @@
1
+ import { createRequire } from 'node:module';
2
+ import path from 'node:path';
3
+ import { pathExists, readJson } from 'fs-extra';
4
+
5
+ const LLM_MIGRATION_TYPE = 'llm';
6
+ async function resolveMigrationsJson() {
7
+ const pkgJsonPath = createRequire(import.meta.url).resolve('@mondaydotcomorg/z2h-cli/package.json');
8
+ const migrationsDir = path.dirname(pkgJsonPath);
9
+ const migrationsJsonPath = path.join(migrationsDir, 'migrations.json');
10
+ if (!(await pathExists(migrationsJsonPath))) {
11
+ return null;
12
+ }
13
+ const migrationsJson = (await readJson(migrationsJsonPath));
14
+ return { migrationsJson, migrationsDir };
15
+ }
16
+
17
+ export { LLM_MIGRATION_TYPE, resolveMigrationsJson };
package/dist/index.js CHANGED
@@ -15,6 +15,7 @@ const commands_generate = require('./commands/generate.js');
15
15
  const commands_templates = require('./commands/templates.js');
16
16
  const commands_generateZ2hToken = require('./commands/generate-z2h-token.js');
17
17
  const commands_migrate = require('./commands/migrate.js');
18
+ const commands_llmMigration = require('./commands/llm-migration.js');
18
19
  const commands_tag = require('./commands/tag.js');
19
20
  const commands_edit = require('./commands/edit.js');
20
21
  const commands_backend = require('./commands/backend.js');
@@ -193,6 +194,11 @@ async function main() {
193
194
  .description('Run pending workspace migrations')
194
195
  .option('--dry-run', 'show pending migrations without applying any changes')
195
196
  .action(util_runCommand.runCommand({}, (opts) => commands_migrate.migrateCommand(version, opts)));
197
+ program
198
+ .command('llm-migration')
199
+ .description('List agent-guided (LLM) migrations, or print one migration guide with --migration')
200
+ .option('--migration <name>', 'name of the LLM migration to print; omit to list all')
201
+ .action(util_runCommand.runCommand({}, (opts) => commands_llmMigration.llmMigrationCommand(opts)));
196
202
  program
197
203
  .command('doctor')
198
204
  .description('Check that all Z2H tools, auth, workspace, and plugins are correctly set up')
@@ -0,0 +1,7 @@
1
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
+
3
+ const usage = {
4
+
5
+ };
6
+
7
+ exports.default = usage;
@@ -1,9 +1,8 @@
1
1
  /**
2
2
  * Returns the machine app name when running as a service (e.g. agent-runner).
3
3
  * Available when the process is a monday.com microservice with `APP_NAME` set
4
- * by the platform runtime.
5
- *
6
- * Returns `undefined` for interactive human users (fallback to os.userInfo).
4
+ * by the platform runtime. Returns `undefined` for interactive human users.
7
5
  */
8
6
  export declare function getMachineAppName(): string | undefined;
7
+ export declare function whoAmI(): string;
9
8
  //# sourceMappingURL=machine-identity.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"machine-identity.d.ts","sourceRoot":"","sources":["../../src/util/machine-identity.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,GAAG,SAAS,CAEtD"}
1
+ {"version":3,"file":"machine-identity.d.ts","sourceRoot":"","sources":["../../src/util/machine-identity.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,GAAG,SAAS,CAEtD;AAED,wBAAgB,MAAM,IAAI,MAAM,CAE/B"}
@@ -1,14 +1,22 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
+ const os = require('node:os');
4
+
5
+ const _interopDefault = e => e && e.__esModule ? e : { default: e };
6
+
7
+ const os__default = /*#__PURE__*/_interopDefault(os);
8
+
3
9
  /**
4
10
  * Returns the machine app name when running as a service (e.g. agent-runner).
5
11
  * Available when the process is a monday.com microservice with `APP_NAME` set
6
- * by the platform runtime.
7
- *
8
- * Returns `undefined` for interactive human users (fallback to os.userInfo).
12
+ * by the platform runtime. Returns `undefined` for interactive human users.
9
13
  */
10
14
  function getMachineAppName() {
11
15
  return process.env.APP_NAME || undefined;
12
16
  }
17
+ function whoAmI() {
18
+ return getMachineAppName() ?? os__default.default.userInfo().username;
19
+ }
13
20
 
14
21
  exports.getMachineAppName = getMachineAppName;
22
+ exports.whoAmI = whoAmI;
@@ -0,0 +1,28 @@
1
+ export interface DeterministicMigrationEntry {
2
+ type?: never;
3
+ /** Must equal the CLI release it ships with (not the feature branch version),
4
+ * so the `gt` check in migrate.ts always catches it on the exact upgrade that introduces it. */
5
+ version: string;
6
+ description: string;
7
+ migrate: string;
8
+ }
9
+ export declare const LLM_MIGRATION_TYPE: "llm";
10
+ /** Applied by handing `guide`'s contents to the calling agent. The guide owns detection too:
11
+ * it tells the agent how to find the old pattern and to report "not relevant" if absent. */
12
+ export interface LlmMigrationEntry {
13
+ type: typeof LLM_MIGRATION_TYPE;
14
+ /** Version of the CLI this migration was added at. */
15
+ version: string;
16
+ description: string;
17
+ /** Path (relative to migrations.json) to the markdown guideline for the agent applying this migration. */
18
+ guide: string;
19
+ }
20
+ export type MigrationEntry = DeterministicMigrationEntry | LlmMigrationEntry;
21
+ export interface MigrationsJson {
22
+ migrations: Record<string, MigrationEntry>;
23
+ }
24
+ export declare function resolveMigrationsJson(): Promise<{
25
+ migrationsJson: MigrationsJson;
26
+ migrationsDir: string;
27
+ } | null>;
28
+ //# sourceMappingURL=migrations-json.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrations-json.d.ts","sourceRoot":"","sources":["../../src/util/migrations-json.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,2BAA2B;IAC1C,IAAI,CAAC,EAAE,KAAK,CAAC;IACb;qGACiG;IACjG,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,kBAAkB,EAAG,KAAc,CAAC;AAEjD;6FAC6F;AAC7F,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,OAAO,kBAAkB,CAAC;IAChC,sDAAsD;IACtD,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,0GAA0G;IAC1G,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,cAAc,GAAG,2BAA2B,GAAG,iBAAiB,CAAC;AAE7E,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;CAC5C;AAED,wBAAsB,qBAAqB,IAAI,OAAO,CAAC;IACrD,cAAc,EAAE,cAAc,CAAC;IAC/B,aAAa,EAAE,MAAM,CAAC;CACvB,GAAG,IAAI,CAAC,CASR"}
@@ -0,0 +1,25 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const node_module = require('node:module');
4
+ const path = require('node:path');
5
+ const fs = require('fs-extra');
6
+
7
+ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
8
+ const _interopDefault = e => e && e.__esModule ? e : { default: e };
9
+
10
+ const path__default = /*#__PURE__*/_interopDefault(path);
11
+
12
+ const LLM_MIGRATION_TYPE = 'llm';
13
+ async function resolveMigrationsJson() {
14
+ const pkgJsonPath = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('util/migrations-json.js', document.baseURI).href))).resolve('@mondaydotcomorg/z2h-cli/package.json');
15
+ const migrationsDir = path__default.default.dirname(pkgJsonPath);
16
+ const migrationsJsonPath = path__default.default.join(migrationsDir, 'migrations.json');
17
+ if (!(await fs.pathExists(migrationsJsonPath))) {
18
+ return null;
19
+ }
20
+ const migrationsJson = (await fs.readJson(migrationsJsonPath));
21
+ return { migrationsJson, migrationsDir };
22
+ }
23
+
24
+ exports.LLM_MIGRATION_TYPE = LLM_MIGRATION_TYPE;
25
+ exports.resolveMigrationsJson = resolveMigrationsJson;
@@ -0,0 +1,26 @@
1
+ {
2
+ "db.delete": [
3
+ "key"
4
+ ],
5
+ "db.get": [
6
+ "key"
7
+ ],
8
+ "db.list": [],
9
+ "db.put": [
10
+ "key",
11
+ "value"
12
+ ],
13
+ "llm.complete": [
14
+ "modelId",
15
+ "messages"
16
+ ],
17
+ "monday.query": [
18
+ "query",
19
+ "variables"
20
+ ],
21
+ "snowflake.query": [
22
+ "sql",
23
+ "params",
24
+ "options"
25
+ ]
26
+ }
package/migrations.json CHANGED
@@ -34,6 +34,12 @@
34
34
  "version": "0.19.0",
35
35
  "description": "Rewrite html-embed apps' iframe src to go through the host's same-origin /z2h-assets proxy instead of the raw CDN bucket URL",
36
36
  "migrate": "./dist/migrations/007-proxy-iframe-src"
37
+ },
38
+ "snowflake-service-to-backend-runner": {
39
+ "type": "llm",
40
+ "version": "0.29.3",
41
+ "description": "Migrate off the deprecated direct bigbrain-zth /snowflake/query pattern onto a zth-backend-runner handler (ctx.api.v1.snowflake)",
42
+ "guide": "./src/migrations-llm/snowflake-service-to-backend-runner.md"
37
43
  }
38
44
  }
39
45
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mondaydotcomorg/z2h-cli",
3
- "version": "0.30.0",
3
+ "version": "0.32.0",
4
4
  "bin": "./bin/z2h-cli.js",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -5,6 +5,9 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
5
5
 
6
6
  import { readHandlers } from '../handlers';
7
7
 
8
+ vi.mock('../parser/api-signatures', () => ({
9
+ loadApiSignatures: () => ({ 'monday.query': ['query', 'variables'] }),
10
+ }));
8
11
  vi.mock('../../util/tracker', () => ({
9
12
  trackEvent: vi.fn().mockResolvedValue(undefined),
10
13
  trackDuration: vi.fn(),
@@ -28,14 +31,14 @@ describe('readHandlers — discovery', () => {
28
31
  it('returns empty handlers when backend/handlers does not exist', async () => {
29
32
  const dir = await mkdtemp(path.join(os.tmpdir(), 'z2h-empty-'));
30
33
  try {
31
- await expect(readHandlers(dir)).resolves.toEqual({ handlers: {}, apiDomains: [] });
34
+ await expect(readHandlers(dir)).resolves.toEqual({ handlers: {}, apiDomains: [], apiUsages: {} });
32
35
  } finally {
33
36
  await rm(dir, { recursive: true, force: true });
34
37
  }
35
38
  });
36
39
 
37
40
  it('returns empty handlers when the directory is empty', async () => {
38
- await expect(readHandlers(appDir)).resolves.toEqual({ handlers: {}, apiDomains: [] });
41
+ await expect(readHandlers(appDir)).resolves.toEqual({ handlers: {}, apiDomains: [], apiUsages: {} });
39
42
  });
40
43
 
41
44
  it('uses the filename (without .js) as the handler name', async () => {
@@ -69,6 +72,14 @@ describe('readHandlers — output contract', () => {
69
72
  const { apiDomains } = await readHandlers(appDir);
70
73
  expect(apiDomains).toEqual(['db', 'monday']);
71
74
  });
75
+
76
+ it('attaches per-handler apiUsages keyed by handler name', async () => {
77
+ await writeHandler('a.js', 'async function handler(ctx) { return ctx.api.v1.monday.query("x"); }');
78
+ await writeHandler('c.js', 'async function handler(ctx) { return ctx.input; }');
79
+ const { apiUsages } = await readHandlers(appDir);
80
+ expect(apiUsages.a).toEqual({ monday: { query: [{ query: 'x' }] } });
81
+ expect(apiUsages.c).toEqual({});
82
+ });
72
83
  });
73
84
 
74
85
  // Per-shape validation rules are covered in validate.test.ts; here we only prove