@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
package/src/plugin.js
CHANGED
|
@@ -102,7 +102,7 @@ const configurations = {
|
|
|
102
102
|
dev: {
|
|
103
103
|
configuration: "dev",
|
|
104
104
|
env: {
|
|
105
|
-
VITE_HUBTYPE_CLIENT_ID: "
|
|
105
|
+
VITE_HUBTYPE_CLIENT_ID: "WlvymZ703Y5zGnmaCZ9Da5vf0lNX08jFvgC4pRMT",
|
|
106
106
|
VITE_HUBTYPE_API_URL: "https://api.dev.dev.dev.hubtype.com",
|
|
107
107
|
VITE_PUSHER_API_PREFIX: "dev-dev-dev"
|
|
108
108
|
}
|
|
@@ -140,34 +140,29 @@ async function createBotonicTargets(projectRoot, options, context) {
|
|
|
140
140
|
targets[options.serveTargetName] = {
|
|
141
141
|
executor: "@botonic/nx-plugin:serve-bot",
|
|
142
142
|
options: {},
|
|
143
|
-
configurations
|
|
144
|
-
continuous: true
|
|
143
|
+
configurations
|
|
145
144
|
};
|
|
146
145
|
targets["serve:webchat"] = {
|
|
147
146
|
executor: "@botonic/nx-plugin:serve-bot",
|
|
148
147
|
options: {
|
|
149
148
|
skipWebviews: true
|
|
150
149
|
},
|
|
151
|
-
configurations
|
|
152
|
-
continuous: true
|
|
150
|
+
configurations
|
|
153
151
|
};
|
|
154
152
|
targets["serve:webview"] = {
|
|
155
153
|
executor: "@botonic/nx-plugin:serve-bot",
|
|
156
154
|
options: {},
|
|
157
|
-
configurations
|
|
158
|
-
continuous: true
|
|
155
|
+
configurations
|
|
159
156
|
};
|
|
160
157
|
targets["serve-dev"] = {
|
|
161
158
|
executor: "@botonic/nx-plugin:serve-bot",
|
|
162
159
|
options: {},
|
|
163
|
-
configurations
|
|
164
|
-
continuous: true
|
|
160
|
+
configurations
|
|
165
161
|
};
|
|
166
162
|
targets["serve-dev-tunnel"] = {
|
|
167
163
|
executor: "@botonic/nx-plugin:serve-bot",
|
|
168
164
|
options: {},
|
|
169
|
-
configurations
|
|
170
|
-
continuous: true
|
|
165
|
+
configurations
|
|
171
166
|
};
|
|
172
167
|
targets["build-node-app"] = {
|
|
173
168
|
executor: "nx:run-commands",
|
|
@@ -213,10 +208,6 @@ async function createBotonicTargets(projectRoot, options, context) {
|
|
|
213
208
|
executor: "@botonic/nx-plugin:deploy-to-hubtype",
|
|
214
209
|
configurations
|
|
215
210
|
};
|
|
216
|
-
targets["deploy-local-runtime"] = {
|
|
217
|
-
executor: "@botonic/nx-plugin:deploy-local-runtime",
|
|
218
|
-
configurations
|
|
219
|
-
};
|
|
220
211
|
targets["integrate-provider"] = {
|
|
221
212
|
executor: "@botonic/nx-plugin:integrate-provider",
|
|
222
213
|
configurations
|
|
@@ -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,144 +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 = allProviders.data.results.filter(
|
|
134
|
-
(provider) => provider.is_test && provider.is_active
|
|
135
|
-
)[0].id;
|
|
136
|
-
console.log("\u2705 Local runtime deployment completed!");
|
|
137
|
-
updateEnvLocal(projectRoot, appId);
|
|
138
|
-
console.log(`\u{1F194} APP_ID: ${appId}`);
|
|
139
|
-
} catch (error) {
|
|
140
|
-
console.error("\u274C Local runtime deployment failed");
|
|
141
|
-
console.error(`${String(error)}`);
|
|
142
|
-
}
|
|
143
|
-
botonicApiService.saveAllCredentials();
|
|
144
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
-
var schema_d_exports = {};
|
|
16
|
-
module.exports = __toCommonJS(schema_d_exports);
|
|
@@ -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
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BotonicPluginHubtypeAnalytics,
|
|
3
|
-
EventAction,
|
|
4
|
-
HtEventProps,
|
|
5
|
-
} from '@botonic/plugin-hubtype-analytics'
|
|
6
|
-
import { BotonicContext } from '@botonic/core'
|
|
7
|
-
|
|
8
|
-
import { BotPlugins } from './types'
|
|
9
|
-
|
|
10
|
-
export async function trackEventToHubtypeAnalytics(
|
|
11
|
-
botonicContext: BotonicContext<BotPlugins>,
|
|
12
|
-
eventName: EventAction,
|
|
13
|
-
args: Omit<HtEventProps, 'action'>
|
|
14
|
-
): Promise<void> {
|
|
15
|
-
const hubtypeAnalyticsPlugin = botonicContext.plugins.hubtypeAnalytics
|
|
16
|
-
const htEventProps = {
|
|
17
|
-
action: eventName,
|
|
18
|
-
...args,
|
|
19
|
-
} as HtEventProps
|
|
20
|
-
|
|
21
|
-
if (
|
|
22
|
-
!hubtypeAnalyticsPlugin ||
|
|
23
|
-
!(hubtypeAnalyticsPlugin instanceof BotonicPluginHubtypeAnalytics)
|
|
24
|
-
) {
|
|
25
|
-
console.log('Hubtype Analytics Plugin not found')
|
|
26
|
-
return
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const response = await hubtypeAnalyticsPlugin.trackEvent(
|
|
30
|
-
botonicContext,
|
|
31
|
-
htEventProps
|
|
32
|
-
)
|
|
33
|
-
console.log('TrackEvent Response', response, args)
|
|
34
|
-
return
|
|
35
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "<%= name %>",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"description": "A Botonic workspace using NPM workspaces and TypeScript project references",
|
|
5
|
-
"private": true,
|
|
6
|
-
"workspaces": [
|
|
7
|
-
"packages/*",
|
|
8
|
-
"apps/*"
|
|
9
|
-
],
|
|
10
|
-
"scripts": {
|
|
11
|
-
"build": "nx run-many --target=build",
|
|
12
|
-
"test": "nx run-many --target=test",
|
|
13
|
-
"lint": "nx run-many --target=lint",
|
|
14
|
-
"typecheck": "nx run-many --target=typecheck"
|
|
15
|
-
},
|
|
16
|
-
"devDependencies": {
|
|
17
|
-
"@nx/js": "21.0.3",
|
|
18
|
-
"@swc-node/register": "~1.9.1",
|
|
19
|
-
"@swc/core": "~1.5.7",
|
|
20
|
-
"@swc/helpers": "~0.5.11",
|
|
21
|
-
"nx": "21.0.3",
|
|
22
|
-
"prettier": "^2.6.2",
|
|
23
|
-
"tslib": "^2.3.0",
|
|
24
|
-
"typescript": "~5.8.2"
|
|
25
|
-
}
|
|
26
|
-
}
|