@botonic/nx-plugin 2.30.0 → 2.31.1-alpha.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 (127) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/executors.json +0 -5
  3. package/index.js +44 -0
  4. package/{src/executors/build-node-app/executor.js → libs/botonic/nx-plugin/src/executors/build-node-app/executor-impl.js} +3 -3
  5. package/libs/botonic/nx-plugin/src/executors/build-node-app/executor.js +27 -0
  6. package/{src/executors/delete-bot/executor.js → libs/botonic/nx-plugin/src/executors/delete-bot/executor-impl.js} +3 -5
  7. package/libs/botonic/nx-plugin/src/executors/delete-bot/executor.js +27 -0
  8. package/{src/executors/deploy-netlify-snapshot/executor.js → libs/botonic/nx-plugin/src/executors/deploy-netlify-snapshot/executor-impl.js} +3 -3
  9. package/libs/botonic/nx-plugin/src/executors/deploy-netlify-snapshot/executor.js +27 -0
  10. package/libs/botonic/nx-plugin/src/executors/deploy-to-hubtype/executor-impl.js +172 -0
  11. package/libs/botonic/nx-plugin/src/executors/deploy-to-hubtype/executor.js +27 -0
  12. package/{src/executors/e2e-webchat/executor.js → libs/botonic/nx-plugin/src/executors/e2e-webchat/executor-impl.js} +5 -5
  13. package/libs/botonic/nx-plugin/src/executors/e2e-webchat/executor.js +27 -0
  14. package/{src/executors/integrate-provider/executor.js → libs/botonic/nx-plugin/src/executors/integrate-provider/executor-impl.js} +3 -5
  15. package/libs/botonic/nx-plugin/src/executors/integrate-provider/executor.js +27 -0
  16. package/{src/executors/login-to-hubtype/executor.js → libs/botonic/nx-plugin/src/executors/login-to-hubtype/executor-impl.js} +3 -5
  17. package/libs/botonic/nx-plugin/src/executors/login-to-hubtype/executor.js +27 -0
  18. package/{src/executors/logout-from-hubtype/executor.js → libs/botonic/nx-plugin/src/executors/logout-from-hubtype/executor-impl.js} +5 -5
  19. package/libs/botonic/nx-plugin/src/executors/logout-from-hubtype/executor.js +27 -0
  20. package/{src/executors/run-lambda/executor.js → libs/botonic/nx-plugin/src/executors/run-lambda/executor-impl.js} +3 -3
  21. package/libs/botonic/nx-plugin/src/executors/run-lambda/executor.js +27 -0
  22. package/{src/executors/serve-bot/executor.js → libs/botonic/nx-plugin/src/executors/serve-bot/executor-impl.js} +145 -27
  23. package/libs/botonic/nx-plugin/src/executors/serve-bot/executor.js +27 -0
  24. package/{src/generators/action/generator.js → libs/botonic/nx-plugin/src/generators/action/generator-impl.js} +5 -5
  25. package/libs/botonic/nx-plugin/src/generators/action/generator.js +27 -0
  26. package/{src/generators/bot-app/generator.js → libs/botonic/nx-plugin/src/generators/bot-app/generator-impl.js} +6 -5
  27. package/libs/botonic/nx-plugin/src/generators/bot-app/generator.js +34 -0
  28. package/{src/generators/custom-message/generator.js → libs/botonic/nx-plugin/src/generators/custom-message/generator-impl.js} +5 -5
  29. package/libs/botonic/nx-plugin/src/generators/custom-message/generator.js +27 -0
  30. package/{src/generators/preset/generator.js → libs/botonic/nx-plugin/src/generators/preset/generator-impl.js} +5 -5
  31. package/libs/botonic/nx-plugin/src/generators/preset/generator.js +34 -0
  32. package/{src/generators/remove-custom-message/generator.js → libs/botonic/nx-plugin/src/generators/remove-custom-message/generator-impl.js} +5 -5
  33. package/libs/botonic/nx-plugin/src/generators/remove-custom-message/generator.js +27 -0
  34. package/{src/generators/webview/generator.js → libs/botonic/nx-plugin/src/generators/webview/generator-impl.js} +5 -5
  35. package/libs/botonic/nx-plugin/src/generators/webview/generator.js +27 -0
  36. package/{src → libs/botonic/nx-plugin/src}/index.js +3 -1
  37. package/{src → libs/botonic/nx-plugin/src}/lib/api-service.js +150 -82
  38. package/{src → libs/botonic/nx-plugin/src}/lib/constants.js +6 -9
  39. package/{src → libs/botonic/nx-plugin/src}/lib/credentials-handler.js +42 -24
  40. package/libs/botonic/nx-plugin/src/lib/delegate/delegate-executor.js +119 -0
  41. package/libs/botonic/nx-plugin/src/lib/delegate/delegate-generator.js +128 -0
  42. package/libs/botonic/nx-plugin/src/lib/serve-mode/index.js +183 -0
  43. package/{src → libs/botonic/nx-plugin/src}/lib/util/executor-helpers.js +494 -106
  44. package/{src → libs/botonic/nx-plugin/src}/plugin.js +5 -14
  45. package/migrations.json +1 -8
  46. package/package.json +7 -4
  47. package/src/executors/build-node-app/executor-impl.d.ts +5 -0
  48. package/src/executors/build-node-app/executor.d.ts +4 -2
  49. package/src/executors/delete-bot/executor-impl.d.ts +5 -0
  50. package/src/executors/delete-bot/executor.d.ts +4 -2
  51. package/src/executors/deploy-netlify-snapshot/executor-impl.d.ts +8 -0
  52. package/src/executors/deploy-netlify-snapshot/executor.d.ts +4 -5
  53. package/src/executors/deploy-to-hubtype/executor-impl.d.ts +5 -0
  54. package/src/executors/deploy-to-hubtype/executor.d.ts +4 -2
  55. package/src/executors/e2e-webchat/botonic-package-publish.spec.ts +7 -11
  56. package/src/executors/e2e-webchat/executor-impl.d.ts +5 -0
  57. package/src/executors/e2e-webchat/executor.d.ts +4 -2
  58. package/src/executors/integrate-provider/executor-impl.d.ts +5 -0
  59. package/src/executors/integrate-provider/executor.d.ts +4 -2
  60. package/src/executors/login-to-hubtype/executor-impl.d.ts +5 -0
  61. package/src/executors/login-to-hubtype/executor.d.ts +4 -2
  62. package/src/executors/logout-from-hubtype/executor-impl.d.ts +3 -0
  63. package/src/executors/logout-from-hubtype/executor.d.ts +5 -1
  64. package/src/executors/run-lambda/executor-impl.d.ts +5 -0
  65. package/src/executors/run-lambda/executor.d.ts +4 -2
  66. package/src/executors/serve-bot/executor-impl.d.ts +5 -0
  67. package/src/executors/serve-bot/executor.d.ts +4 -2
  68. package/src/executors/serve-bot/schema.json +13 -5
  69. package/src/generators/action/generator-impl.d.ts +4 -0
  70. package/src/generators/action/generator.d.ts +2 -3
  71. package/src/generators/bot-app/files/vite/node.config.ts.template +2 -7
  72. package/src/generators/bot-app/files/vite/webchat.config.ts.template +10 -2
  73. package/src/generators/bot-app/generator-impl.d.ts +4 -0
  74. package/src/generators/bot-app/generator.d.ts +2 -4
  75. package/src/generators/custom-message/generator-impl.d.ts +4 -0
  76. package/src/generators/custom-message/generator.d.ts +2 -3
  77. package/src/generators/preset/generator-impl.d.ts +4 -0
  78. package/src/generators/preset/generator.d.ts +2 -4
  79. package/src/generators/remove-custom-message/generator-impl.d.ts +4 -0
  80. package/src/generators/remove-custom-message/generator.d.ts +2 -3
  81. package/src/generators/webview/generator-impl.d.ts +4 -0
  82. package/src/generators/webview/generator.d.ts +2 -3
  83. package/src/index.d.ts +1 -0
  84. package/src/lib/api-service.d.ts +19 -20
  85. package/src/lib/constants.d.ts +2 -3
  86. package/src/lib/credentials-handler.d.ts +9 -18
  87. package/src/lib/delegate/delegate-executor.d.ts +6 -0
  88. package/src/lib/delegate/delegate-generator.d.ts +2 -0
  89. package/src/lib/interfaces.d.ts +10 -13
  90. package/src/lib/serve-mode/index.d.ts +25 -0
  91. package/src/lib/util/executor-helpers.d.ts +52 -23
  92. package/src/executors/deploy-local-runtime/executor.d.ts +0 -5
  93. package/src/executors/deploy-local-runtime/executor.js +0 -148
  94. package/src/executors/deploy-local-runtime/schema.json +0 -34
  95. package/src/executors/deploy-to-hubtype/executor.js +0 -308
  96. package/src/executors/serve-bot/schema.d.js +0 -16
  97. package/src/generators/bot-app/files/vite/botonic-ssr-deps.ts.template +0 -56
  98. package/src/generators/bot-app/files/vite/plugins/dev-log-viewer-html.plugin.ts.template +0 -65
  99. package/src/generators/preset/files/package.json +0 -26
  100. package/src/migrations/install-claude-update-skills/install-claude-update-skills.migration.d.ts +0 -2
  101. package/src/migrations/install-claude-update-skills/install-claude-update-skills.migration.js +0 -290
  102. /package/{src → libs/botonic/nx-plugin/src}/executors/build-node-app/schema.d.js +0 -0
  103. /package/{src → libs/botonic/nx-plugin/src}/executors/delete-bot/schema.d.js +0 -0
  104. /package/{src/executors/deploy-local-runtime → libs/botonic/nx-plugin/src/executors/deploy-netlify-snapshot}/schema.d.js +0 -0
  105. /package/{src/executors/deploy-netlify-snapshot → libs/botonic/nx-plugin/src/executors/deploy-to-hubtype}/schema.d.js +0 -0
  106. /package/{src/executors/deploy-to-hubtype → libs/botonic/nx-plugin/src/executors/e2e-webchat}/schema.d.js +0 -0
  107. /package/{src/executors/e2e-webchat → libs/botonic/nx-plugin/src/executors/integrate-provider}/schema.d.js +0 -0
  108. /package/{src/executors/integrate-provider → libs/botonic/nx-plugin/src/executors/login-to-hubtype}/schema.d.js +0 -0
  109. /package/{src/executors/login-to-hubtype → libs/botonic/nx-plugin/src/executors/logout-from-hubtype}/schema.d.js +0 -0
  110. /package/{src/executors/logout-from-hubtype → libs/botonic/nx-plugin/src/executors/run-lambda}/schema.d.js +0 -0
  111. /package/{src/executors/run-lambda → libs/botonic/nx-plugin/src/executors/serve-bot}/schema.d.js +0 -0
  112. /package/{src → libs/botonic/nx-plugin/src}/generators/action/schema.js +0 -0
  113. /package/{src → libs/botonic/nx-plugin/src}/generators/bot-app/schema.js +0 -0
  114. /package/{src → libs/botonic/nx-plugin/src}/generators/custom-message/schema.js +0 -0
  115. /package/{src → libs/botonic/nx-plugin/src}/generators/preset/schema.js +0 -0
  116. /package/{src → libs/botonic/nx-plugin/src}/generators/remove-custom-message/schema.js +0 -0
  117. /package/{src → libs/botonic/nx-plugin/src}/generators/shared/bot-app-utils.js +0 -0
  118. /package/{src → libs/botonic/nx-plugin/src}/generators/webview/schema.js +0 -0
  119. /package/{src → libs/botonic/nx-plugin/src}/lib/bot-config.js +0 -0
  120. /package/{src → libs/botonic/nx-plugin/src}/lib/cloudflared-tunnel.js +0 -0
  121. /package/{src → libs/botonic/nx-plugin/src}/lib/index.js +0 -0
  122. /package/{src → libs/botonic/nx-plugin/src}/lib/interfaces.js +0 -0
  123. /package/{src → libs/botonic/nx-plugin/src}/lib/util/file-system.js +0 -0
  124. /package/{src → libs/botonic/nx-plugin/src}/lib/util/sam-container-cleanup.js +0 -0
  125. /package/{src → libs/botonic/nx-plugin/src}/lib/util/sam-template.js +0 -0
  126. /package/{src → libs/botonic/nx-plugin/src}/lib/util/system.js +0 -0
  127. /package/{src → libs/botonic/nx-plugin/src}/migrations/utils/migration-utils.js +0 -0
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var executor_exports = {};
20
+ __export(executor_exports, {
21
+ default: () => logoutFromHubtypeExecutor
22
+ });
23
+ module.exports = __toCommonJS(executor_exports);
24
+ var import_delegate_executor = require("../../lib/delegate/delegate-executor");
25
+ async function logoutFromHubtypeExecutor(options, ctx) {
26
+ return (0, import_delegate_executor.runLocalExecutor)(__filename, "logout-from-hubtype", options, ctx);
27
+ }
@@ -16,11 +16,11 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var executor_exports = {};
20
- __export(executor_exports, {
19
+ var executor_impl_exports = {};
20
+ __export(executor_impl_exports, {
21
21
  default: () => runLambdaExecutor
22
22
  });
23
- module.exports = __toCommonJS(executor_exports);
23
+ module.exports = __toCommonJS(executor_impl_exports);
24
24
  var import_child_process = require("child_process");
25
25
  var import_path = require("path");
26
26
  var import_executor_helpers = require("../../lib/util/executor-helpers");
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var executor_exports = {};
20
+ __export(executor_exports, {
21
+ default: () => runLambdaExecutor
22
+ });
23
+ module.exports = __toCommonJS(executor_exports);
24
+ var import_delegate_executor = require("../../lib/delegate/delegate-executor");
25
+ async function runLambdaExecutor(options, ctx) {
26
+ return (0, import_delegate_executor.runLocalExecutor)(__filename, "run-lambda", options, ctx);
27
+ }
@@ -26,11 +26,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var executor_exports = {};
30
- __export(executor_exports, {
29
+ var executor_impl_exports = {};
30
+ __export(executor_impl_exports, {
31
31
  default: () => serveBotExecutor
32
32
  });
33
- module.exports = __toCommonJS(executor_exports);
33
+ module.exports = __toCommonJS(executor_impl_exports);
34
34
  var import_child_process = require("child_process");
35
35
  var import_fs = require("fs");
36
36
  var import_path = require("path");
@@ -70,7 +70,10 @@ function writeToLogFile(line) {
70
70
  }
71
71
  function checkFrontailInstalled(cwd) {
72
72
  try {
73
- (0, import_child_process.execSync)("npx --no frontail --help", { stdio: "pipe", cwd });
73
+ (0, import_child_process.execSync)(`${cwd}/node_modules/.bin/frontail --help`, {
74
+ stdio: "pipe",
75
+ cwd
76
+ });
74
77
  return true;
75
78
  } catch {
76
79
  return false;
@@ -86,10 +89,8 @@ function startFrontail(logPath, port, cwd) {
86
89
  return null;
87
90
  }
88
91
  const frontailProcess = (0, import_child_process.spawn)(
89
- "npx",
92
+ `${cwd}/node_modules/.bin/frontail`,
90
93
  [
91
- "--no",
92
- "frontail",
93
94
  "--port",
94
95
  port.toString(),
95
96
  "--theme",
@@ -205,33 +206,60 @@ async function serveBotExecutor(options, context) {
205
206
  `${colors.dim}[lambda] No previous Lambda container to clean up.${colors.reset}`
206
207
  );
207
208
  }
208
- const logViewerEnabled = options.logViewer === true;
209
209
  logFilePath = null;
210
210
  const logViewerPort = options.logViewerPort ?? 9001;
211
211
  const webchatDevPort = tryReadWebchatDevPort(fullProjectRoot);
212
- let frontailProcess = null;
213
- if (logViewerEnabled) {
214
- logFilePath = initLogFile(fullProjectRoot);
215
- frontailProcess = startFrontail(logFilePath, logViewerPort, context.root);
216
- }
217
- const logViewerInfo = logViewerEnabled ? `${colors.dim}Webchat:${colors.reset} ${colors.bold}http://localhost:${webchatDevPort}/?logs=${logViewerPort}${colors.reset} (with logs panel)
218
- ${colors.dim}Log viewer:${colors.reset} http://localhost:${logViewerPort}` : "";
212
+ logFilePath = initLogFile(fullProjectRoot);
213
+ const frontailProcess = startFrontail(
214
+ logFilePath,
215
+ logViewerPort,
216
+ context.root
217
+ );
218
+ const logViewerInfo = `${colors.dim}Webchat:${colors.reset} ${colors.bold}http://localhost:${webchatDevPort}/?logs=${logViewerPort}${colors.reset} (with logs panel)
219
+ ${colors.dim}Log viewer:${colors.reset} http://localhost:${logViewerPort}`;
219
220
  const useTunnel = true;
220
221
  const tunnelPort = options.tunnelPort ?? 3001;
221
222
  let effectiveLambdaEndpoint = options.lambdaEndpoint;
222
223
  let startLambda = !options.skipLambda && !effectiveLambdaEndpoint;
223
224
  let tunnelDeployResult;
225
+ let devSessionLambdaFunctionName;
226
+ let registeredTunnelUrl;
227
+ let deployedBotId;
228
+ let selectedBotId;
229
+ let deployedApiUrl;
230
+ let deployedAccessToken;
231
+ let deployedRefreshToken;
232
+ let deployedClientId;
224
233
  if (useTunnel) {
225
234
  await (0, import_executor_helpers.ensureHubtypeLoginBeforeTunnel)(context, fullProjectRoot, {
226
235
  env: options.env,
227
236
  configuration
228
237
  });
229
- await (0, import_executor_helpers.ensureLocalRuntimeBotBeforeTunnel)(context, fullProjectRoot, {
230
- env: options.env,
231
- configuration
232
- });
238
+ try {
239
+ selectedBotId = await (0, import_executor_helpers.selectBotForServe)(context, fullProjectRoot, {
240
+ env: options.env,
241
+ configuration,
242
+ botName: options.botName
243
+ });
244
+ } catch (botDeployErr) {
245
+ if ((0, import_executor_helpers.isBotDeployedRestartRequired)(botDeployErr)) {
246
+ if (frontailProcess) {
247
+ frontailProcess.kill("SIGTERM");
248
+ }
249
+ if (process.stdin.isTTY) {
250
+ try {
251
+ process.stdin.setRawMode(false);
252
+ } catch {
253
+ }
254
+ }
255
+ process.stdin.pause();
256
+ process.stdin.unref();
257
+ return { success: true };
258
+ }
259
+ throw botDeployErr;
260
+ }
233
261
  console.log(
234
- `${colors.dim}Starting tunnel flow (Lambda + cloudflared + deploy_local_runtime)...${colors.reset}
262
+ `${colors.dim}Starting tunnel flow (Lambda + cloudflared + dev session registration)...${colors.reset}
235
263
  `
236
264
  );
237
265
  }
@@ -256,18 +284,79 @@ ${colors.dim}Log viewer:${colors.reset} http://localhost:${logViewerPort}` :
256
284
  console.log(`${colors.dim}Tunnel URL: ${tunnelUrl}${colors.reset}
257
285
  `);
258
286
  console.log(
259
- `${colors.dim}Registering tunnel with backend (deploy_local_runtime)...${colors.reset}`
287
+ `${colors.dim}Setting up dev bot and writing dev session env vars...${colors.reset}`
260
288
  );
261
289
  const deployResult = await (0, import_executor_helpers.performDeployLocalRuntimeWithEndpoint)(
262
290
  context,
263
291
  fullProjectRoot,
264
292
  tunnelUrl,
265
- { env: options.env, configuration }
293
+ {
294
+ env: options.env,
295
+ configuration,
296
+ whatsappPhone: options.phone,
297
+ selectedBotId
298
+ }
266
299
  );
267
300
  tunnelDeployResult = {
268
301
  targetEnvironment: deployResult.targetEnvironment,
269
- environmentVariables: deployResult.environmentVariables
302
+ environmentVariables: deployResult.environmentVariables,
303
+ teardownWebchat: deployResult.teardownWebchat
270
304
  };
305
+ devSessionLambdaFunctionName = deployResult.lambdaFunctionName;
306
+ registeredTunnelUrl = tunnelUrl;
307
+ deployedBotId = deployResult.botId ?? "";
308
+ deployedApiUrl = deployResult.apiUrl ?? "https://api.hubtype.com";
309
+ deployedAccessToken = deployResult.accessToken ?? "";
310
+ deployedRefreshToken = deployResult.refreshToken ?? "";
311
+ deployedClientId = deployResult.clientId ?? "";
312
+ const resolvedEnv = ["local", "dev", "dev2", "qa", "prod"].includes(deployResult.targetEnvironment) ? deployResult.targetEnvironment : "local";
313
+ (0, import_executor_helpers.writeEnvVarToEnvFile)(
314
+ fullProjectRoot,
315
+ "VITE_DEV_SESSION_URL",
316
+ tunnelUrl,
317
+ resolvedEnv
318
+ );
319
+ if (devSessionLambdaFunctionName) {
320
+ (0, import_executor_helpers.writeEnvVarToEnvFile)(
321
+ fullProjectRoot,
322
+ "VITE_DEV_LAMBDA_FUNCTION_NAME",
323
+ devSessionLambdaFunctionName,
324
+ resolvedEnv
325
+ );
326
+ }
327
+ (0, import_executor_helpers.writeEnvVarToEnvFile)(
328
+ fullProjectRoot,
329
+ "VITE_DEV_BOT_ID",
330
+ deployResult.botId ?? "",
331
+ resolvedEnv
332
+ );
333
+ (0, import_executor_helpers.writeEnvVarToEnvFile)(
334
+ fullProjectRoot,
335
+ "VITE_DEV_API_URL",
336
+ deployResult.apiUrl ?? "https://api.hubtype.com",
337
+ resolvedEnv
338
+ );
339
+ (0, import_executor_helpers.writeEnvVarToEnvFile)(
340
+ fullProjectRoot,
341
+ "VITE_DEV_ACCESS_TOKEN",
342
+ deployResult.accessToken ?? "",
343
+ resolvedEnv
344
+ );
345
+ (0, import_executor_helpers.writeEnvVarToEnvFile)(
346
+ fullProjectRoot,
347
+ "VITE_DEV_REFRESH_TOKEN",
348
+ deployResult.refreshToken ?? "",
349
+ resolvedEnv
350
+ );
351
+ (0, import_executor_helpers.writeEnvVarToEnvFile)(
352
+ fullProjectRoot,
353
+ "VITE_DEV_CLIENT_ID",
354
+ deployResult.clientId ?? "",
355
+ resolvedEnv
356
+ );
357
+ console.log(
358
+ `${colors.dim}VITE_DEV_SESSION_URL written to .env.${resolvedEnv}${colors.reset}`
359
+ );
271
360
  effectiveLambdaEndpoint = tunnelUrl;
272
361
  startLambda = false;
273
362
  }
@@ -312,7 +401,7 @@ ${colors.webviews}[webviews]${colors.reset} - Webviews Vite dev server
312
401
  `);
313
402
  if (useExternalLambda && !useTunnel) {
314
403
  console.log(
315
- `${colors.dim}\u{1F4A1} Ensure you have run deploy_local_runtime with this URL so the backend can invoke your Lambda.${colors.reset}
404
+ `${colors.dim}\u{1F4A1} Ensure you have run the serve target first to register your dev session.${colors.reset}
316
405
  `
317
406
  );
318
407
  }
@@ -340,13 +429,23 @@ ${colors.webviews}[webviews]${colors.reset} - Webviews Vite dev server
340
429
  }
341
430
  const noOpenEnv = options.open === false ? "VITE_SERVE_OPEN=false " : "";
342
431
  const viteEnvAppId = `VITE_HUBTYPE_APP_ID=${effectiveAppId}`;
343
- const logViewerEnv = logViewerEnabled ? `LOG_VIEWER_PORT=${logViewerPort} ` : "";
344
- const webchatCommand = `${noOpenEnv}${logViewerEnv}${viteEnvAppId} TARGET_APP=webchat MODE=${configuration} vite --config ${configPath}`;
432
+ const viteDevSessionEnv = registeredTunnelUrl && devSessionLambdaFunctionName ? `VITE_DEV_SESSION_URL=${registeredTunnelUrl} VITE_DEV_LAMBDA_FUNCTION_NAME=${devSessionLambdaFunctionName} ` : "";
433
+ const viteDevCredentialsEnv = deployedBotId ? [
434
+ `VITE_DEV_BOT_ID=${deployedBotId}`,
435
+ `VITE_DEV_API_URL=${deployedApiUrl ?? "https://api.hubtype.com"}`,
436
+ `VITE_DEV_ACCESS_TOKEN=${deployedAccessToken ?? ""}`,
437
+ `VITE_DEV_REFRESH_TOKEN=${deployedRefreshToken ?? ""}`,
438
+ `VITE_DEV_CLIENT_ID=${deployedClientId ?? ""}`
439
+ ].join(" ") + " " : "";
440
+ const logViewerEnv = `LOG_VIEWER_PORT=${logViewerPort} `;
441
+ const botHasWhatsapp = deployedBotId ? (0, import_executor_helpers.selectedBotHasActiveWhatsapp)(deployedBotId) : false;
442
+ const whatsappPanelEnv = botHasWhatsapp ? `BOT_HAS_WHATSAPP=1 ${options.phone ? `WHATSAPP_PANEL_PHONE=${options.phone} ` : ""}` : "";
443
+ const webchatCommand = `${noOpenEnv}${logViewerEnv}${viteDevSessionEnv}${viteDevCredentialsEnv}${whatsappPanelEnv}${viteEnvAppId} TARGET_APP=webchat MODE=${configuration} vite --config ${configPath}`;
345
444
  processes.push(
346
445
  spawnProcess(webchatCommand, "webchat", colors.webchat, fullProjectRoot)
347
446
  );
348
447
  if (!options.skipWebviews) {
349
- const webviewsCommand = `${noOpenEnv}${viteEnvAppId} TARGET_APP=webviews MODE=${configuration} vite --config ${configPath}`;
448
+ const webviewsCommand = `${noOpenEnv}${viteDevSessionEnv}${viteEnvAppId} TARGET_APP=webviews MODE=${configuration} vite --config ${configPath}`;
350
449
  processes.push(
351
450
  spawnProcess(
352
451
  webviewsCommand,
@@ -364,6 +463,22 @@ ${colors.webviews}[webviews]${colors.reset} - Webviews Vite dev server
364
463
  `
365
464
  ${colors.bold}\u{1F6D1} Shutting down all processes...${colors.reset}`
366
465
  );
466
+ try {
467
+ const envConfig = ["local", "dev", "dev2", "qa", "prod"].includes(tunnelDeployResult?.targetEnvironment ?? "") ? tunnelDeployResult.targetEnvironment : "local";
468
+ (0, import_executor_helpers.writeEnvVarToEnvFile)(
469
+ fullProjectRoot,
470
+ "VITE_DEV_SESSION_URL",
471
+ "",
472
+ envConfig
473
+ );
474
+ (0, import_executor_helpers.writeEnvVarToEnvFile)(
475
+ fullProjectRoot,
476
+ "VITE_DEV_LAMBDA_FUNCTION_NAME",
477
+ "",
478
+ envConfig
479
+ );
480
+ } catch {
481
+ }
367
482
  processes.forEach(({ name, color, process: proc }) => {
368
483
  console.log(`${color}[${name}]${colors.reset} Stopping...`);
369
484
  proc.kill("SIGTERM");
@@ -405,6 +520,9 @@ ${colors.bold}\u{1F6D1} Shutting down all processes...${colors.reset}`
405
520
  });
406
521
  });
407
522
  } catch (error) {
523
+ if ((0, import_executor_helpers.isBotDeployedRestartRequired)(error)) {
524
+ return { success: true };
525
+ }
408
526
  const errorMessage = error instanceof Error ? error.message : String(error);
409
527
  console.error(`\u274C Error starting dev server:`, errorMessage);
410
528
  return { success: false };
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var executor_exports = {};
20
+ __export(executor_exports, {
21
+ default: () => serveBotExecutor
22
+ });
23
+ module.exports = __toCommonJS(executor_exports);
24
+ var import_delegate_executor = require("../../lib/delegate/delegate-executor");
25
+ async function serveBotExecutor(options, ctx) {
26
+ return (0, import_delegate_executor.runLocalExecutor)(__filename, "serve-bot", options, ctx);
27
+ }
@@ -16,11 +16,11 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var generator_exports = {};
20
- __export(generator_exports, {
21
- default: () => generator_default
19
+ var generator_impl_exports = {};
20
+ __export(generator_impl_exports, {
21
+ default: () => generator_impl_default
22
22
  });
23
- module.exports = __toCommonJS(generator_exports);
23
+ module.exports = __toCommonJS(generator_impl_exports);
24
24
  var import_devkit = require("@nx/devkit");
25
25
  var import_bot_app_utils = require("../shared/bot-app-utils");
26
26
  const MODULE_DIR = __dirname;
@@ -84,7 +84,7 @@ function updateRoutes(tree, options) {
84
84
  ` },`
85
85
  ]);
86
86
  }
87
- async function generator_default(tree, options) {
87
+ async function generator_impl_default(tree, options) {
88
88
  console.log(`Creating action: ${options.name}`);
89
89
  const normalizedOptions = normalizeOptions(tree, options);
90
90
  console.log(`Project: ${normalizedOptions.projectName}`);
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var generator_exports = {};
20
+ __export(generator_exports, {
21
+ default: () => generator_default
22
+ });
23
+ module.exports = __toCommonJS(generator_exports);
24
+ var import_delegate_generator = require("../../lib/delegate/delegate-generator");
25
+ async function generator_default(tree, options) {
26
+ return (0, import_delegate_generator.runLocalGenerator)(__filename, "action", tree, options);
27
+ }
@@ -26,11 +26,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var generator_exports = {};
30
- __export(generator_exports, {
31
- default: () => generator_default
29
+ var generator_impl_exports = {};
30
+ __export(generator_impl_exports, {
31
+ default: () => generator_impl_default
32
32
  });
33
- module.exports = __toCommonJS(generator_exports);
33
+ module.exports = __toCommonJS(generator_impl_exports);
34
34
  var import_devkit = require("@nx/devkit");
35
35
  var import_child_process = require("child_process");
36
36
  var fs = __toESM(require("fs"));
@@ -162,6 +162,7 @@ function createPackageJson(tree, options, botonicVersion, lilaraVersion) {
162
162
  zod: "^4.4.3"
163
163
  },
164
164
  devDependencies: {
165
+ "@botonic/nx-plugin": botonicVersion,
165
166
  "@nx/vite": "21.6.11",
166
167
  "@types/node": "22.13.0",
167
168
  "@types/react": "18.3.1",
@@ -283,7 +284,7 @@ function addBotonicFiles(tree, options, botonicVersion) {
283
284
  templateOptions
284
285
  );
285
286
  }
286
- async function generator_default(tree, options) {
287
+ async function generator_impl_default(tree, options) {
287
288
  const botonicVersion = getBotonicVersion(options);
288
289
  const lilaraVersion = getLilaraVersion(options);
289
290
  const tasks = [];
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var generator_exports = {};
30
+ __export(generator_exports, {
31
+ default: () => import_generator_impl.default
32
+ });
33
+ module.exports = __toCommonJS(generator_exports);
34
+ var import_generator_impl = __toESM(require("./generator-impl"));
@@ -16,11 +16,11 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var generator_exports = {};
20
- __export(generator_exports, {
21
- default: () => generator_default
19
+ var generator_impl_exports = {};
20
+ __export(generator_impl_exports, {
21
+ default: () => generator_impl_default
22
22
  });
23
- module.exports = __toCommonJS(generator_exports);
23
+ module.exports = __toCommonJS(generator_impl_exports);
24
24
  var import_devkit = require("@nx/devkit");
25
25
  var import_bot_app_utils = require("../shared/bot-app-utils");
26
26
  const MODULE_DIR = __dirname;
@@ -200,7 +200,7 @@ function updateRoutes(tree, options) {
200
200
  ` },`
201
201
  ]);
202
202
  }
203
- async function generator_default(tree, options) {
203
+ async function generator_impl_default(tree, options) {
204
204
  console.log(`Creating custom message: ${options.name}`);
205
205
  const normalizedOptions = normalizeOptions(tree, options);
206
206
  console.log(`Project: ${normalizedOptions.projectName}`);
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var generator_exports = {};
20
+ __export(generator_exports, {
21
+ default: () => generator_default
22
+ });
23
+ module.exports = __toCommonJS(generator_exports);
24
+ var import_delegate_generator = require("../../lib/delegate/delegate-generator");
25
+ async function generator_default(tree, options) {
26
+ return (0, import_delegate_generator.runLocalGenerator)(__filename, "custom-message", tree, options);
27
+ }
@@ -26,11 +26,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var generator_exports = {};
30
- __export(generator_exports, {
31
- default: () => generator_default
29
+ var generator_impl_exports = {};
30
+ __export(generator_impl_exports, {
31
+ default: () => generator_impl_default
32
32
  });
33
- module.exports = __toCommonJS(generator_exports);
33
+ module.exports = __toCommonJS(generator_impl_exports);
34
34
  var import_devkit = require("@nx/devkit");
35
35
  var fs = __toESM(require("fs"));
36
36
  var path = __toESM(require("path"));
@@ -63,7 +63,7 @@ function normalizeOptions(options) {
63
63
  botonicVersion: resolveBotonicVersion(options.botonicVersion)
64
64
  };
65
65
  }
66
- async function generator_default(tree, options) {
66
+ async function generator_impl_default(tree, options) {
67
67
  const normalizedOptions = normalizeOptions(options);
68
68
  const tasks = [];
69
69
  console.log("Configuring existing TypeScript workspace with Botonic...");
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var generator_exports = {};
30
+ __export(generator_exports, {
31
+ default: () => import_generator_impl.default
32
+ });
33
+ module.exports = __toCommonJS(generator_exports);
34
+ var import_generator_impl = __toESM(require("./generator-impl"));
@@ -16,11 +16,11 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var generator_exports = {};
20
- __export(generator_exports, {
21
- default: () => generator_default
19
+ var generator_impl_exports = {};
20
+ __export(generator_impl_exports, {
21
+ default: () => generator_impl_default
22
22
  });
23
- module.exports = __toCommonJS(generator_exports);
23
+ module.exports = __toCommonJS(generator_impl_exports);
24
24
  var import_devkit = require("@nx/devkit");
25
25
  function normalizeOptions(tree, options) {
26
26
  const projects = (0, import_devkit.getProjects)(tree);
@@ -212,7 +212,7 @@ function removeFromRoutes(tree, options) {
212
212
  }
213
213
  return found;
214
214
  }
215
- async function generator_default(tree, options) {
215
+ async function generator_impl_default(tree, options) {
216
216
  console.log(`\u{1F5D1}\uFE0F Removing custom message: ${options.name}`);
217
217
  const normalizedOptions = normalizeOptions(tree, options);
218
218
  console.log(`\u{1F4C1} Project: ${normalizedOptions.projectName}`);
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var generator_exports = {};
20
+ __export(generator_exports, {
21
+ default: () => generator_default
22
+ });
23
+ module.exports = __toCommonJS(generator_exports);
24
+ var import_delegate_generator = require("../../lib/delegate/delegate-generator");
25
+ async function generator_default(tree, options) {
26
+ return (0, import_delegate_generator.runLocalGenerator)(__filename, "remove-custom-message", tree, options);
27
+ }