@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.
- package/CHANGELOG.md +27 -0
- package/executors.json +0 -5
- package/index.js +44 -0
- package/{src/executors/build-node-app/executor.js → libs/botonic/nx-plugin/src/executors/build-node-app/executor-impl.js} +3 -3
- package/libs/botonic/nx-plugin/src/executors/build-node-app/executor.js +27 -0
- package/{src/executors/delete-bot/executor.js → libs/botonic/nx-plugin/src/executors/delete-bot/executor-impl.js} +3 -5
- package/libs/botonic/nx-plugin/src/executors/delete-bot/executor.js +27 -0
- package/{src/executors/deploy-netlify-snapshot/executor.js → libs/botonic/nx-plugin/src/executors/deploy-netlify-snapshot/executor-impl.js} +3 -3
- package/libs/botonic/nx-plugin/src/executors/deploy-netlify-snapshot/executor.js +27 -0
- package/libs/botonic/nx-plugin/src/executors/deploy-to-hubtype/executor-impl.js +172 -0
- package/libs/botonic/nx-plugin/src/executors/deploy-to-hubtype/executor.js +27 -0
- package/{src/executors/e2e-webchat/executor.js → libs/botonic/nx-plugin/src/executors/e2e-webchat/executor-impl.js} +5 -5
- package/libs/botonic/nx-plugin/src/executors/e2e-webchat/executor.js +27 -0
- package/{src/executors/integrate-provider/executor.js → libs/botonic/nx-plugin/src/executors/integrate-provider/executor-impl.js} +3 -5
- package/libs/botonic/nx-plugin/src/executors/integrate-provider/executor.js +27 -0
- package/{src/executors/login-to-hubtype/executor.js → libs/botonic/nx-plugin/src/executors/login-to-hubtype/executor-impl.js} +3 -5
- package/libs/botonic/nx-plugin/src/executors/login-to-hubtype/executor.js +27 -0
- package/{src/executors/logout-from-hubtype/executor.js → libs/botonic/nx-plugin/src/executors/logout-from-hubtype/executor-impl.js} +5 -5
- package/libs/botonic/nx-plugin/src/executors/logout-from-hubtype/executor.js +27 -0
- package/{src/executors/run-lambda/executor.js → libs/botonic/nx-plugin/src/executors/run-lambda/executor-impl.js} +3 -3
- package/libs/botonic/nx-plugin/src/executors/run-lambda/executor.js +27 -0
- package/{src/executors/serve-bot/executor.js → libs/botonic/nx-plugin/src/executors/serve-bot/executor-impl.js} +145 -27
- package/libs/botonic/nx-plugin/src/executors/serve-bot/executor.js +27 -0
- package/{src/generators/action/generator.js → libs/botonic/nx-plugin/src/generators/action/generator-impl.js} +5 -5
- package/libs/botonic/nx-plugin/src/generators/action/generator.js +27 -0
- package/{src/generators/bot-app/generator.js → libs/botonic/nx-plugin/src/generators/bot-app/generator-impl.js} +6 -5
- package/libs/botonic/nx-plugin/src/generators/bot-app/generator.js +34 -0
- package/{src/generators/custom-message/generator.js → libs/botonic/nx-plugin/src/generators/custom-message/generator-impl.js} +5 -5
- package/libs/botonic/nx-plugin/src/generators/custom-message/generator.js +27 -0
- package/{src/generators/preset/generator.js → libs/botonic/nx-plugin/src/generators/preset/generator-impl.js} +5 -5
- package/libs/botonic/nx-plugin/src/generators/preset/generator.js +34 -0
- package/{src/generators/remove-custom-message/generator.js → libs/botonic/nx-plugin/src/generators/remove-custom-message/generator-impl.js} +5 -5
- package/libs/botonic/nx-plugin/src/generators/remove-custom-message/generator.js +27 -0
- package/{src/generators/webview/generator.js → libs/botonic/nx-plugin/src/generators/webview/generator-impl.js} +5 -5
- package/libs/botonic/nx-plugin/src/generators/webview/generator.js +27 -0
- package/{src → libs/botonic/nx-plugin/src}/index.js +3 -1
- package/{src → libs/botonic/nx-plugin/src}/lib/api-service.js +150 -82
- package/{src → libs/botonic/nx-plugin/src}/lib/constants.js +6 -9
- package/{src → libs/botonic/nx-plugin/src}/lib/credentials-handler.js +42 -24
- package/libs/botonic/nx-plugin/src/lib/delegate/delegate-executor.js +119 -0
- package/libs/botonic/nx-plugin/src/lib/delegate/delegate-generator.js +128 -0
- package/libs/botonic/nx-plugin/src/lib/serve-mode/index.js +183 -0
- package/{src → libs/botonic/nx-plugin/src}/lib/util/executor-helpers.js +494 -106
- package/{src → libs/botonic/nx-plugin/src}/plugin.js +5 -14
- package/migrations.json +1 -8
- package/package.json +7 -4
- package/src/executors/build-node-app/executor-impl.d.ts +5 -0
- package/src/executors/build-node-app/executor.d.ts +4 -2
- package/src/executors/delete-bot/executor-impl.d.ts +5 -0
- package/src/executors/delete-bot/executor.d.ts +4 -2
- package/src/executors/deploy-netlify-snapshot/executor-impl.d.ts +8 -0
- package/src/executors/deploy-netlify-snapshot/executor.d.ts +4 -5
- package/src/executors/deploy-to-hubtype/executor-impl.d.ts +5 -0
- package/src/executors/deploy-to-hubtype/executor.d.ts +4 -2
- package/src/executors/e2e-webchat/botonic-package-publish.spec.ts +7 -11
- package/src/executors/e2e-webchat/executor-impl.d.ts +5 -0
- package/src/executors/e2e-webchat/executor.d.ts +4 -2
- package/src/executors/integrate-provider/executor-impl.d.ts +5 -0
- package/src/executors/integrate-provider/executor.d.ts +4 -2
- package/src/executors/login-to-hubtype/executor-impl.d.ts +5 -0
- package/src/executors/login-to-hubtype/executor.d.ts +4 -2
- package/src/executors/logout-from-hubtype/executor-impl.d.ts +3 -0
- package/src/executors/logout-from-hubtype/executor.d.ts +5 -1
- package/src/executors/run-lambda/executor-impl.d.ts +5 -0
- package/src/executors/run-lambda/executor.d.ts +4 -2
- package/src/executors/serve-bot/executor-impl.d.ts +5 -0
- package/src/executors/serve-bot/executor.d.ts +4 -2
- package/src/executors/serve-bot/schema.json +13 -5
- package/src/generators/action/generator-impl.d.ts +4 -0
- package/src/generators/action/generator.d.ts +2 -3
- package/src/generators/bot-app/files/vite/node.config.ts.template +2 -7
- package/src/generators/bot-app/files/vite/webchat.config.ts.template +10 -2
- package/src/generators/bot-app/generator-impl.d.ts +4 -0
- package/src/generators/bot-app/generator.d.ts +2 -4
- package/src/generators/custom-message/generator-impl.d.ts +4 -0
- package/src/generators/custom-message/generator.d.ts +2 -3
- package/src/generators/preset/generator-impl.d.ts +4 -0
- package/src/generators/preset/generator.d.ts +2 -4
- package/src/generators/remove-custom-message/generator-impl.d.ts +4 -0
- package/src/generators/remove-custom-message/generator.d.ts +2 -3
- package/src/generators/webview/generator-impl.d.ts +4 -0
- package/src/generators/webview/generator.d.ts +2 -3
- package/src/index.d.ts +1 -0
- package/src/lib/api-service.d.ts +19 -20
- package/src/lib/constants.d.ts +2 -3
- package/src/lib/credentials-handler.d.ts +9 -18
- package/src/lib/delegate/delegate-executor.d.ts +6 -0
- package/src/lib/delegate/delegate-generator.d.ts +2 -0
- package/src/lib/interfaces.d.ts +10 -13
- package/src/lib/serve-mode/index.d.ts +25 -0
- package/src/lib/util/executor-helpers.d.ts +52 -23
- package/src/executors/deploy-local-runtime/executor.d.ts +0 -5
- package/src/executors/deploy-local-runtime/executor.js +0 -148
- package/src/executors/deploy-local-runtime/schema.json +0 -34
- package/src/executors/deploy-to-hubtype/executor.js +0 -308
- package/src/executors/serve-bot/schema.d.js +0 -16
- package/src/generators/bot-app/files/vite/botonic-ssr-deps.ts.template +0 -56
- package/src/generators/bot-app/files/vite/plugins/dev-log-viewer-html.plugin.ts.template +0 -65
- package/src/generators/preset/files/package.json +0 -26
- package/src/migrations/install-claude-update-skills/install-claude-update-skills.migration.d.ts +0 -2
- package/src/migrations/install-claude-update-skills/install-claude-update-skills.migration.js +0 -290
- /package/{src → libs/botonic/nx-plugin/src}/executors/build-node-app/schema.d.js +0 -0
- /package/{src → libs/botonic/nx-plugin/src}/executors/delete-bot/schema.d.js +0 -0
- /package/{src/executors/deploy-local-runtime → libs/botonic/nx-plugin/src/executors/deploy-netlify-snapshot}/schema.d.js +0 -0
- /package/{src/executors/deploy-netlify-snapshot → libs/botonic/nx-plugin/src/executors/deploy-to-hubtype}/schema.d.js +0 -0
- /package/{src/executors/deploy-to-hubtype → libs/botonic/nx-plugin/src/executors/e2e-webchat}/schema.d.js +0 -0
- /package/{src/executors/e2e-webchat → libs/botonic/nx-plugin/src/executors/integrate-provider}/schema.d.js +0 -0
- /package/{src/executors/integrate-provider → libs/botonic/nx-plugin/src/executors/login-to-hubtype}/schema.d.js +0 -0
- /package/{src/executors/login-to-hubtype → libs/botonic/nx-plugin/src/executors/logout-from-hubtype}/schema.d.js +0 -0
- /package/{src/executors/logout-from-hubtype → libs/botonic/nx-plugin/src/executors/run-lambda}/schema.d.js +0 -0
- /package/{src/executors/run-lambda → libs/botonic/nx-plugin/src/executors/serve-bot}/schema.d.js +0 -0
- /package/{src → libs/botonic/nx-plugin/src}/generators/action/schema.js +0 -0
- /package/{src → libs/botonic/nx-plugin/src}/generators/bot-app/schema.js +0 -0
- /package/{src → libs/botonic/nx-plugin/src}/generators/custom-message/schema.js +0 -0
- /package/{src → libs/botonic/nx-plugin/src}/generators/preset/schema.js +0 -0
- /package/{src → libs/botonic/nx-plugin/src}/generators/remove-custom-message/schema.js +0 -0
- /package/{src → libs/botonic/nx-plugin/src}/generators/shared/bot-app-utils.js +0 -0
- /package/{src → libs/botonic/nx-plugin/src}/generators/webview/schema.js +0 -0
- /package/{src → libs/botonic/nx-plugin/src}/lib/bot-config.js +0 -0
- /package/{src → libs/botonic/nx-plugin/src}/lib/cloudflared-tunnel.js +0 -0
- /package/{src → libs/botonic/nx-plugin/src}/lib/index.js +0 -0
- /package/{src → libs/botonic/nx-plugin/src}/lib/interfaces.js +0 -0
- /package/{src → libs/botonic/nx-plugin/src}/lib/util/file-system.js +0 -0
- /package/{src → libs/botonic/nx-plugin/src}/lib/util/sam-container-cleanup.js +0 -0
- /package/{src → libs/botonic/nx-plugin/src}/lib/util/sam-template.js +0 -0
- /package/{src → libs/botonic/nx-plugin/src}/lib/util/system.js +0 -0
- /package/{src → libs/botonic/nx-plugin/src}/migrations/utils/migration-utils.js +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BotRegistryEntry, BotsRegistry, GlobalCredentialsStore, JSONObject } from './interfaces';
|
|
2
2
|
export declare class CredentialsHandler {
|
|
3
3
|
homeDir: string;
|
|
4
4
|
pathToCredentials: string;
|
|
@@ -9,12 +9,12 @@ export declare class CredentialsHandler {
|
|
|
9
9
|
initialize(): void;
|
|
10
10
|
createDirIfNotExists(): void;
|
|
11
11
|
loadJSON(): JSONObject | undefined;
|
|
12
|
-
dumpJSON(obj: JSONObject): void;
|
|
12
|
+
dumpJSON(obj: JSONObject | JSONObject[]): void;
|
|
13
13
|
}
|
|
14
14
|
export declare class GlobalCredentialsHandler extends CredentialsHandler {
|
|
15
15
|
/**
|
|
16
16
|
* @param baseDir - Optional directory for credentials (e.g. monorepo_root/.botonic).
|
|
17
|
-
* When provided, credentials are stored at baseDir/credentials.json
|
|
17
|
+
* When provided, credentials are stored at baseDir/env-credentials.json.
|
|
18
18
|
* When omitted, uses ~/.botonic (user home).
|
|
19
19
|
*/
|
|
20
20
|
constructor(baseDir?: string);
|
|
@@ -22,19 +22,10 @@ export declare class GlobalCredentialsHandler extends CredentialsHandler {
|
|
|
22
22
|
load(): GlobalCredentialsStore | undefined;
|
|
23
23
|
dump(obj: GlobalCredentialsStore): void;
|
|
24
24
|
}
|
|
25
|
-
declare class
|
|
26
|
-
constructor(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
dump(obj: T): void;
|
|
32
|
-
}
|
|
33
|
-
export declare class BotCredentialsHandler extends BaseBotCredentialsHandler<BotCredentials> {
|
|
34
|
-
/**
|
|
35
|
-
* @param projectRoot - Directory for app/project .botonic.json (e.g. apps/my-bot).
|
|
36
|
-
* When omitted, uses process.cwd() (may write to repo root when Nx cwd is workspace root).
|
|
37
|
-
*/
|
|
38
|
-
constructor(projectRoot?: string);
|
|
25
|
+
export declare class BotsRegistryHandler extends CredentialsHandler {
|
|
26
|
+
constructor();
|
|
27
|
+
load(): BotsRegistry;
|
|
28
|
+
dump(registry: BotsRegistry): void;
|
|
29
|
+
upsert(env: string, entry: BotRegistryEntry): void;
|
|
30
|
+
findLatestForEnv(env: string): BotRegistryEntry | undefined;
|
|
39
31
|
}
|
|
40
|
-
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ExecutorContext } from '@nx/devkit';
|
|
2
|
+
export declare function runLocalExecutor<T = unknown>(wrapperFilename: string, executorName: string, options: T, ctx: ExecutorContext): Promise<{
|
|
3
|
+
success: boolean;
|
|
4
|
+
} | AsyncIterableIterator<{
|
|
5
|
+
success: boolean;
|
|
6
|
+
}>>;
|
package/src/lib/interfaces.d.ts
CHANGED
|
@@ -24,23 +24,20 @@ export interface EnvironmentCredentials {
|
|
|
24
24
|
}
|
|
25
25
|
/** Store: one entry per environment so multiple envs can be logged in. */
|
|
26
26
|
export type GlobalCredentialsStore = Record<string, EnvironmentCredentials>;
|
|
27
|
+
export interface ProviderAccountEntry {
|
|
28
|
+
id: string;
|
|
29
|
+
provider: string;
|
|
30
|
+
is_test: boolean;
|
|
31
|
+
is_active: boolean;
|
|
32
|
+
}
|
|
27
33
|
export interface BotDetail {
|
|
28
34
|
id: string;
|
|
29
35
|
name: string;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
created_at: string;
|
|
33
|
-
provider_accounts: any[];
|
|
34
|
-
is_debug: boolean;
|
|
35
|
-
is_published: boolean;
|
|
36
|
-
active_users: number;
|
|
37
|
-
}
|
|
38
|
-
export interface BotCredentials {
|
|
39
|
-
bot: BotDetail | null;
|
|
40
|
-
}
|
|
41
|
-
export interface LocalRuntimeBotCredentials {
|
|
42
|
-
localRuntimeBot: BotDetail | null;
|
|
36
|
+
providers?: ProviderAccountEntry[];
|
|
37
|
+
[key: string]: unknown;
|
|
43
38
|
}
|
|
39
|
+
export type BotRegistryEntry = BotDetail;
|
|
40
|
+
export type BotsRegistry = Record<string, BotRegistryEntry[]>;
|
|
44
41
|
export type JSONPrimitive = string | number | boolean | null;
|
|
45
42
|
export type JSONValue = JSONPrimitive | JSONObject | JSONArray;
|
|
46
43
|
export type JSONObject = {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
export interface ChannelCredentials {
|
|
3
|
+
botId?: string;
|
|
4
|
+
apiUrl?: string;
|
|
5
|
+
tunnelUrl?: string;
|
|
6
|
+
lambdaFn?: string;
|
|
7
|
+
accessToken?: string;
|
|
8
|
+
refreshToken?: string;
|
|
9
|
+
clientId?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface WhatsappPanelOptions extends ChannelCredentials {
|
|
12
|
+
registeredPhone?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface DevPanelsOptions {
|
|
15
|
+
panels: Array<'whatsapp' | 'webchat'>;
|
|
16
|
+
registeredPhone?: string;
|
|
17
|
+
}
|
|
18
|
+
/** Injects the WhatsApp channel routing panel. Serve-only. */
|
|
19
|
+
export declare function createWhatsappPanelPlugin(opts?: WhatsappPanelOptions): Plugin;
|
|
20
|
+
/** Injects the Webchat channel routing panel. Serve-only. */
|
|
21
|
+
export declare function createWebchatPanelPlugin(opts?: ChannelCredentials): Plugin;
|
|
22
|
+
/** Injects the log-viewer split layout. Serve-only. No per-panel configuration needed. */
|
|
23
|
+
export declare function createLogViewerPlugin(): Plugin;
|
|
24
|
+
/** Convenience wrapper — creates all requested panel plugins in one call. */
|
|
25
|
+
export declare function createDevPanelsPlugin(opts: DevPanelsOptions): Plugin[];
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { ExecutorContext } from '@nx/devkit';
|
|
2
2
|
import { BotonicAPIService } from '../api-service';
|
|
3
|
-
import type { BotDetail } from '../interfaces';
|
|
4
3
|
export declare function resolveProjectPath(context: ExecutorContext): string;
|
|
5
4
|
export declare function askEmailPassword(): Promise<{
|
|
6
5
|
email: string;
|
|
@@ -15,7 +14,7 @@ export declare function handleAuthentication(botonicApiService: BotonicAPIServic
|
|
|
15
14
|
*/
|
|
16
15
|
export declare function logWorkingAsAndEnvironment(botonicApiService: BotonicAPIService): Promise<void>;
|
|
17
16
|
export declare function getAvailableBots(botonicApiService: BotonicAPIService): Promise<any[]>;
|
|
18
|
-
export declare function createNewBotWithName(botonicApiService: BotonicAPIService, botName: string): Promise<void>;
|
|
17
|
+
export declare function createNewBotWithName(botonicApiService: BotonicAPIService, botName: string, isTest?: boolean): Promise<void>;
|
|
19
18
|
export declare function getAppIdFromEnvFile(projectRoot: string, appIdKey: string): string | null;
|
|
20
19
|
/**
|
|
21
20
|
* Reads VITE_HUBTYPE_APP_ID from .env.[configuration] (e.g. .env.dev) or .env.local when configuration is 'local'.
|
|
@@ -53,24 +52,14 @@ export declare function resolveHubtypeEnvironment(context: ExecutorContext, opti
|
|
|
53
52
|
};
|
|
54
53
|
/**
|
|
55
54
|
* Ensures the user is logged in to Hubtype before starting the tunnel flow.
|
|
56
|
-
* Run this before Lambda + cloudflared + deploy_local_runtime so the login prompt happens first.
|
|
57
55
|
*/
|
|
58
|
-
export declare function ensureHubtypeLoginBeforeTunnel(context: ExecutorContext, projectRoot: string, options?:
|
|
56
|
+
export declare function ensureHubtypeLoginBeforeTunnel(context: ExecutorContext, projectRoot: string, options?: DeployDevSessionOptions): Promise<void>;
|
|
59
57
|
/**
|
|
60
|
-
* Ensures a
|
|
61
|
-
*
|
|
62
|
-
*
|
|
58
|
+
* Ensures a bot is set: reuses one from bots.json registry, or prompts to select an existing
|
|
59
|
+
* deployed bot or create a new one. The selected bot must be deployed with botonic_v2 strategy before
|
|
60
|
+
* dev session registration will succeed — the user is informed of this requirement.
|
|
63
61
|
*/
|
|
64
|
-
export declare function
|
|
65
|
-
/**
|
|
66
|
-
* Writes the local runtime bot to .botonic.json in the app folder so the created bot is persisted per project.
|
|
67
|
-
*/
|
|
68
|
-
export declare function writeLocalRuntimeBotToAppFolder(projectRoot: string, bot: BotDetail): void;
|
|
69
|
-
/**
|
|
70
|
-
* Removes the app folder .botonic.json so the next run will prompt to create/select a new bot (e.g. after 404 when bot was deleted).
|
|
71
|
-
*/
|
|
72
|
-
export declare function removeAppBotonicJson(projectRoot: string): void;
|
|
73
|
-
export declare function ensureLocalRuntimeBot(botonicApiService: BotonicAPIService): Promise<void>;
|
|
62
|
+
export declare function ensureBot(botonicApiService: BotonicAPIService): Promise<void>;
|
|
74
63
|
export type ProviderAccountListItem = {
|
|
75
64
|
id: string;
|
|
76
65
|
provider?: string;
|
|
@@ -78,26 +67,66 @@ export type ProviderAccountListItem = {
|
|
|
78
67
|
is_active?: boolean;
|
|
79
68
|
};
|
|
80
69
|
/**
|
|
81
|
-
*
|
|
70
|
+
* Returns the imp_id of the first active real (non-test) webchat PA on the bot.
|
|
71
|
+
* Used by serve to auto-write VITE_HUBTYPE_APP_ID so the local widget connects.
|
|
72
|
+
*/
|
|
73
|
+
export declare function getActiveWebchatProviderAppId(results: ProviderAccountListItem[] | undefined): string | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* APP_ID for the dev session must be the webchat test provider — not WhatsApp
|
|
82
76
|
* or other channels, which may also be test+active on the same bot.
|
|
83
77
|
*/
|
|
84
78
|
export declare function getActiveTestWebchatProviderAppId(results: ProviderAccountListItem[] | undefined): string | undefined;
|
|
85
|
-
export interface
|
|
79
|
+
export interface DeployDevSessionOptions {
|
|
86
80
|
email?: string;
|
|
87
81
|
password?: string;
|
|
88
82
|
env?: Record<string, unknown>;
|
|
89
83
|
/** Explicit configuration name (e.g. 'dev') so deploy uses the right environment when Nx does not merge config. */
|
|
90
84
|
configuration?: string;
|
|
85
|
+
/** E.164 phone number to register for WhatsApp local routing (e.g. +34612345678). */
|
|
86
|
+
whatsappPhone?: string;
|
|
87
|
+
/** Bot id pre-selected by selectBotForServe — skips ensureBot lookup so the correct bot is used. */
|
|
88
|
+
selectedBotId?: string;
|
|
91
89
|
}
|
|
92
|
-
export interface
|
|
90
|
+
export interface DeployDevSessionResult {
|
|
93
91
|
botId: string;
|
|
92
|
+
apiUrl: string;
|
|
93
|
+
accessToken: string;
|
|
94
|
+
refreshToken: string;
|
|
95
|
+
clientId: string;
|
|
94
96
|
targetEnvironment: string;
|
|
95
97
|
environmentVariables: Record<string, unknown>;
|
|
98
|
+
lambdaFunctionName: string | undefined;
|
|
99
|
+
teardownWebchat: () => Promise<void>;
|
|
96
100
|
}
|
|
97
101
|
/**
|
|
98
|
-
*
|
|
99
|
-
* Handles auth, bot creation/selection, and
|
|
102
|
+
* Registers a dev session with the given tunnel endpoint.
|
|
103
|
+
* Handles auth, bot creation/selection, and registration. Returns the bot id and env.
|
|
100
104
|
* Used by serve-bot (tunnel is always on).
|
|
101
105
|
*/
|
|
102
|
-
export declare function performDeployLocalRuntimeWithEndpoint(context: ExecutorContext, projectRoot: string, endpoint: string, options?:
|
|
106
|
+
export declare function performDeployLocalRuntimeWithEndpoint(context: ExecutorContext, projectRoot: string, endpoint: string, options?: DeployDevSessionOptions): Promise<DeployDevSessionResult>;
|
|
107
|
+
/**
|
|
108
|
+
* Always prompts the user to select or create a bot for local development.
|
|
109
|
+
* Pre-selects the previously used bot (from registry). When botName is provided,
|
|
110
|
+
* skips the prompt entirely. For newly created bots, auto-deploys before returning
|
|
111
|
+
* so the serve flow can proceed without manual intervention.
|
|
112
|
+
*
|
|
113
|
+
* Must be called before tunnel startup so that auto-deploys don't waste tunnel
|
|
114
|
+
* resources and the selected bot is saved to the registry for
|
|
115
|
+
* performDeployLocalRuntimeWithEndpoint to load.
|
|
116
|
+
*/
|
|
117
|
+
export declare function selectBotForServe(context: ExecutorContext, projectRoot: string, options?: DeployDevSessionOptions & {
|
|
118
|
+
botName?: string;
|
|
119
|
+
}): Promise<string | undefined>;
|
|
120
|
+
export declare function isBotDeployedRestartRequired(error: unknown): boolean;
|
|
121
|
+
/**
|
|
122
|
+
* Returns true if the currently selected bot (last entry in bots.json for the
|
|
123
|
+
* given env) has an active WhatsApp provider. Used by the serve executor to
|
|
124
|
+
* decide whether to enable the WhatsApp dev panel.
|
|
125
|
+
*/
|
|
126
|
+
export declare function selectedBotHasActiveWhatsapp(botId: string): boolean;
|
|
127
|
+
/**
|
|
128
|
+
* Builds the bot and deploys it to Hubtype Cloud. Shared by the deploy executor
|
|
129
|
+
* and the serve executor's auto-deploy path for newly created bots.
|
|
130
|
+
*/
|
|
131
|
+
export declare function deployBotToHubtype(botonicApiService: BotonicAPIService, projectRoot: string, projectName: string): Promise<void>;
|
|
103
132
|
export {};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { ExecutorContext } from '@nx/devkit';
|
|
2
|
-
import type { DeployLocalRuntimeExecutorSchema } from './schema';
|
|
3
|
-
export default function deployLocalRuntimeExecutor(options: DeployLocalRuntimeExecutorSchema, context: ExecutorContext): Promise<{
|
|
4
|
-
success: boolean;
|
|
5
|
-
}>;
|
|
@@ -1,148 +0,0 @@
|
|
|
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 executor_exports = {};
|
|
30
|
-
__export(executor_exports, {
|
|
31
|
-
default: () => deployLocalRuntimeExecutor
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(executor_exports);
|
|
34
|
-
var import_enquirer = require("enquirer");
|
|
35
|
-
var fs = __toESM(require("fs"));
|
|
36
|
-
var path = __toESM(require("path"));
|
|
37
|
-
var import_lib = require("../../lib");
|
|
38
|
-
var import_api_service = require("../../lib/api-service");
|
|
39
|
-
var import_executor_helpers = require("../../lib/util/executor-helpers");
|
|
40
|
-
async function deployLocalRuntimeExecutor(options, context) {
|
|
41
|
-
const projectRoot = (0, import_executor_helpers.resolveProjectPath)(context);
|
|
42
|
-
try {
|
|
43
|
-
const { targetEnvironment, environmentVariables } = (0, import_executor_helpers.resolveHubtypeEnvironment)(context, options);
|
|
44
|
-
const botonicApiService = new import_api_service.BotonicAPIService({
|
|
45
|
-
isLocalRuntimeDeployment: true,
|
|
46
|
-
projectRoot,
|
|
47
|
-
workspaceRoot: path.resolve(context.root),
|
|
48
|
-
environmentVariables,
|
|
49
|
-
targetEnvironment
|
|
50
|
-
});
|
|
51
|
-
if (!botonicApiService.oauth) {
|
|
52
|
-
if (options.email && options.password) {
|
|
53
|
-
await botonicApiService.login(options.email, options.password);
|
|
54
|
-
botonicApiService.saveAllCredentials();
|
|
55
|
-
} else {
|
|
56
|
-
await (0, import_executor_helpers.handleAuthentication)(botonicApiService);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
await (0, import_executor_helpers.logWorkingAsAndEnvironment)(botonicApiService);
|
|
60
|
-
console.log(
|
|
61
|
-
`\u{1F680} Deploying to Hubtype Local Runtime...[${environmentVariables["VITE_HUBTYPE_API_URL"]}]
|
|
62
|
-
`
|
|
63
|
-
);
|
|
64
|
-
await (0, import_executor_helpers.ensureLocalRuntimeBot)(botonicApiService);
|
|
65
|
-
const lambdaFunctionName = options.lambdaFunctionName || environmentVariables["VITE_HUBTYPE_LAMBDA_FUNCTION_NAME"];
|
|
66
|
-
const lambdaEndpoint = options.lambdaEndpoint || environmentVariables["VITE_HUBTYPE_LOCAL_LAMBDA_ENDPOINT"];
|
|
67
|
-
await deployLocalRuntime(botonicApiService, projectRoot, {
|
|
68
|
-
lambdaFunctionName,
|
|
69
|
-
lambdaEndpoint
|
|
70
|
-
});
|
|
71
|
-
return { success: true };
|
|
72
|
-
} catch (error) {
|
|
73
|
-
return (0, import_executor_helpers.handleExecutorError)(error, "Local runtime deployment");
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
function updateEnvLocal(projectRoot, appId) {
|
|
77
|
-
const envLocalPath = path.join(projectRoot, ".env.local");
|
|
78
|
-
const envKey = "VITE_HUBTYPE_APP_ID";
|
|
79
|
-
try {
|
|
80
|
-
if (fs.existsSync(envLocalPath)) {
|
|
81
|
-
let content = fs.readFileSync(envLocalPath, "utf-8");
|
|
82
|
-
const regex = new RegExp(`^${envKey}=.*$`, "m");
|
|
83
|
-
if (regex.test(content)) {
|
|
84
|
-
content = content.replace(regex, `${envKey}=${appId}`);
|
|
85
|
-
console.log(`\u{1F4DD} Updated ${envKey} in .env.local`);
|
|
86
|
-
} else {
|
|
87
|
-
content = content.trimEnd() + `
|
|
88
|
-
${envKey}=${appId}
|
|
89
|
-
`;
|
|
90
|
-
console.log(`\u{1F4DD} Added ${envKey} to .env.local`);
|
|
91
|
-
}
|
|
92
|
-
fs.writeFileSync(envLocalPath, content);
|
|
93
|
-
} else {
|
|
94
|
-
const content = `# HUBTYPE
|
|
95
|
-
${envKey}=${appId}
|
|
96
|
-
`;
|
|
97
|
-
fs.writeFileSync(envLocalPath, content);
|
|
98
|
-
console.log(`\u{1F4DD} Created .env.local with ${envKey}`);
|
|
99
|
-
}
|
|
100
|
-
} catch (error) {
|
|
101
|
-
console.warn(`\u26A0\uFE0F Could not update .env.local: ${error}`);
|
|
102
|
-
console.log(`\u{1F194} Manually add to .env.local: ${envKey}=${appId}`);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
async function deployLocalRuntime(botonicApiService, projectRoot, params) {
|
|
106
|
-
console.log("\u{1F528} Generating bot config for local runtime deployment...\n");
|
|
107
|
-
const botConfigJson = await import_lib.BotConfig.get(projectRoot);
|
|
108
|
-
let { lambdaEndpoint } = params;
|
|
109
|
-
if (!lambdaEndpoint) {
|
|
110
|
-
const response = await (0, import_enquirer.prompt)({
|
|
111
|
-
type: "input",
|
|
112
|
-
name: "lambda_endpoint",
|
|
113
|
-
message: "\u{1F310} Local runtime URL (e.g. http://localhost:3001):",
|
|
114
|
-
validate: (input) => {
|
|
115
|
-
try {
|
|
116
|
-
new URL(input);
|
|
117
|
-
return true;
|
|
118
|
-
} catch {
|
|
119
|
-
return "Please enter a valid URL";
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
lambdaEndpoint = response.lambda_endpoint;
|
|
124
|
-
}
|
|
125
|
-
console.log("\u{1F680} Deploying to Hubtype Local Runtime...");
|
|
126
|
-
try {
|
|
127
|
-
await botonicApiService.deployLocalRuntime({
|
|
128
|
-
botConfigJson,
|
|
129
|
-
lambdaFunctionName: params.lambdaFunctionName,
|
|
130
|
-
lambdaEndpoint
|
|
131
|
-
});
|
|
132
|
-
const allProviders = await botonicApiService.getProviders();
|
|
133
|
-
const appId = (0, import_executor_helpers.getActiveTestWebchatProviderAppId)(allProviders.data?.results);
|
|
134
|
-
if (!appId) {
|
|
135
|
-
console.error(
|
|
136
|
-
"\u274C No active test webchat provider found. Local runtime needs a webchat test provider on this bot."
|
|
137
|
-
);
|
|
138
|
-
} else {
|
|
139
|
-
console.log("\u2705 Local runtime deployment completed!");
|
|
140
|
-
updateEnvLocal(projectRoot, appId);
|
|
141
|
-
console.log(`\u{1F194} APP_ID: ${appId}`);
|
|
142
|
-
}
|
|
143
|
-
} catch (error) {
|
|
144
|
-
console.error("\u274C Local runtime deployment failed");
|
|
145
|
-
console.error(`${String(error)}`);
|
|
146
|
-
}
|
|
147
|
-
botonicApiService.saveAllCredentials();
|
|
148
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/schema",
|
|
3
|
-
"$id": "DeployLocalRuntimeExecutor",
|
|
4
|
-
"title": "Deploy to Hubtype Local Runtime executor",
|
|
5
|
-
"type": "object",
|
|
6
|
-
"properties": {
|
|
7
|
-
"configuration": {
|
|
8
|
-
"type": "string",
|
|
9
|
-
"enum": ["local"],
|
|
10
|
-
"description": "Environment to deploy to"
|
|
11
|
-
},
|
|
12
|
-
"command": {
|
|
13
|
-
"type": "string",
|
|
14
|
-
"description": "Command to execute from the package scripts object"
|
|
15
|
-
},
|
|
16
|
-
"email": {
|
|
17
|
-
"type": "string",
|
|
18
|
-
"description": "Email from Hubtype Organization"
|
|
19
|
-
},
|
|
20
|
-
"password": {
|
|
21
|
-
"type": "string",
|
|
22
|
-
"description": "Password from Hubtype Organization"
|
|
23
|
-
},
|
|
24
|
-
"lambdaFunctionName": {
|
|
25
|
-
"type": "string",
|
|
26
|
-
"description": "Name of the Lambda function for the local runtime. Falls back to VITE_HUBTYPE_LAMBDA_FUNCTION_NAME or prompts if missing."
|
|
27
|
-
},
|
|
28
|
-
"lambdaEndpoint": {
|
|
29
|
-
"type": "string",
|
|
30
|
-
"description": "URL where the local runtime is reachable (e.g. http://localhost:3001). Falls back to VITE_HUBTYPE_LOCAL_LAMBDA_ENDPOINT env or prompts if missing."
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
"additionalProperties": false
|
|
34
|
-
}
|