@botonic/nx-plugin 2.29.0 → 2.31.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 +32 -0
- package/executors.json +0 -5
- package/package.json +3 -2
- package/src/executors/delete-bot/executor.js +0 -2
- package/src/executors/deploy-to-hubtype/executor.js +24 -160
- package/src/executors/e2e-webchat/botonic-package-publish.spec.ts +7 -11
- package/src/executors/integrate-provider/executor.js +0 -2
- package/src/executors/login-to-hubtype/executor.js +0 -2
- package/src/executors/logout-from-hubtype/executor.js +2 -2
- package/src/executors/serve-bot/executor.js +142 -24
- package/src/executors/serve-bot/schema.json +13 -5
- package/src/generators/bot-app/files/src/client/webchat/index.tsx.template +2 -0
- package/src/generators/bot-app/files/src/client/webchat/webchat.tsx.template +111 -0
- package/src/generators/bot-app/files/src/server/bot/plugins/flow-builder/index.ts.template +13 -4
- package/src/generators/bot-app/files/src/server/bot/plugins/index.ts.template +0 -3
- package/src/generators/bot-app/files/src/server/lambda/handler.js.template +1 -1
- package/src/generators/bot-app/files/src/server/lambda/package.json +3 -3
- package/src/generators/bot-app/files/vite/node.config.ts.template +2 -4
- package/src/generators/bot-app/files/vite/webchat.config.ts.template +20 -1
- package/src/generators/bot-app/generator.js +6 -5
- package/src/generators/bot-app/lilara-version.json +1 -1
- package/src/lib/api-service.d.ts +19 -20
- package/src/lib/api-service.js +150 -82
- package/src/lib/bot-config.d.ts +10 -7
- package/src/lib/bot-config.js +5 -1
- package/src/lib/constants.d.ts +2 -3
- package/src/lib/constants.js +6 -9
- package/src/lib/credentials-handler.d.ts +9 -18
- package/src/lib/credentials-handler.js +42 -24
- package/src/lib/interfaces.d.ts +10 -13
- package/src/lib/util/executor-helpers.d.ts +58 -18
- package/src/lib/util/executor-helpers.js +501 -102
- package/src/plugin.js +6 -15
- package/src/executors/deploy-local-runtime/executor.d.ts +0 -5
- package/src/executors/deploy-local-runtime/executor.js +0 -144
- package/src/executors/deploy-local-runtime/schema.d.js +0 -16
- package/src/executors/deploy-local-runtime/schema.json +0 -34
- package/src/generators/bot-app/files/src/server/bot/tracking.ts.template +0 -35
- package/src/generators/preset/files/package.json +0 -26
|
@@ -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,40 +52,81 @@ 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
|
|
62
|
+
export declare function ensureBot(botonicApiService: BotonicAPIService): Promise<void>;
|
|
63
|
+
export type ProviderAccountListItem = {
|
|
64
|
+
id: string;
|
|
65
|
+
provider?: string;
|
|
66
|
+
is_test?: boolean;
|
|
67
|
+
is_active?: boolean;
|
|
68
|
+
};
|
|
65
69
|
/**
|
|
66
|
-
*
|
|
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.
|
|
67
72
|
*/
|
|
68
|
-
export declare function
|
|
73
|
+
export declare function getActiveWebchatProviderAppId(results: ProviderAccountListItem[] | undefined): string | undefined;
|
|
69
74
|
/**
|
|
70
|
-
*
|
|
75
|
+
* APP_ID for the dev session must be the webchat test provider — not WhatsApp
|
|
76
|
+
* or other channels, which may also be test+active on the same bot.
|
|
71
77
|
*/
|
|
72
|
-
export declare function
|
|
73
|
-
export
|
|
74
|
-
export interface PerformDeployLocalRuntimeOptions {
|
|
78
|
+
export declare function getActiveTestWebchatProviderAppId(results: ProviderAccountListItem[] | undefined): string | undefined;
|
|
79
|
+
export interface DeployDevSessionOptions {
|
|
75
80
|
email?: string;
|
|
76
81
|
password?: string;
|
|
77
82
|
env?: Record<string, unknown>;
|
|
78
83
|
/** Explicit configuration name (e.g. 'dev') so deploy uses the right environment when Nx does not merge config. */
|
|
79
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;
|
|
80
89
|
}
|
|
81
|
-
export interface
|
|
90
|
+
export interface DeployDevSessionResult {
|
|
82
91
|
botId: string;
|
|
92
|
+
apiUrl: string;
|
|
93
|
+
accessToken: string;
|
|
94
|
+
refreshToken: string;
|
|
95
|
+
clientId: string;
|
|
83
96
|
targetEnvironment: string;
|
|
84
97
|
environmentVariables: Record<string, unknown>;
|
|
98
|
+
lambdaFunctionName: string | undefined;
|
|
99
|
+
teardownWebchat: () => Promise<void>;
|
|
85
100
|
}
|
|
86
101
|
/**
|
|
87
|
-
*
|
|
88
|
-
* 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.
|
|
89
104
|
* Used by serve-bot (tunnel is always on).
|
|
90
105
|
*/
|
|
91
|
-
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>;
|
|
92
132
|
export {};
|