@botpress/cli 0.0.9 → 0.0.11
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/dist/api-client.js +107 -0
- package/dist/app/api-utils.js +9 -3
- package/dist/app/base.js +1 -3
- package/dist/app/errors.js +8 -0
- package/dist/app/file-paths.js +4 -2
- package/dist/app/index.js +17 -12
- package/dist/app/user.js +73 -23
- package/dist/code-generation/action.js +70 -0
- package/dist/code-generation/channel.js +51 -0
- package/dist/code-generation/configuration.js +40 -0
- package/dist/code-generation/const.js +31 -0
- package/dist/code-generation/event.js +41 -0
- package/dist/code-generation/index.js +80 -0
- package/dist/code-generation/integration-impl.js +147 -0
- package/dist/code-generation/integration-instance.js +79 -0
- package/dist/code-generation/message.js +41 -0
- package/dist/code-generation/module.js +115 -0
- package/dist/code-generation/typings.js +16 -0
- package/dist/command-definitions.js +61 -0
- package/dist/command-implementations/add-command.js +124 -0
- package/dist/command-implementations/base-command.js +53 -0
- package/dist/command-implementations/bot-commands.js +89 -0
- package/dist/command-implementations/build-command.js +48 -0
- package/dist/command-implementations/bundle-command.js +58 -0
- package/dist/command-implementations/deploy-command.js +162 -0
- package/dist/command-implementations/dev-command.js +168 -0
- package/dist/command-implementations/gen-command.js +58 -0
- package/dist/command-implementations/global-command.js +111 -0
- package/dist/command-implementations/index.js +78 -0
- package/dist/command-implementations/init-command.js +85 -0
- package/dist/command-implementations/integration-commands.js +107 -0
- package/dist/command-implementations/login-command.js +75 -0
- package/dist/command-implementations/logout-command.js +34 -0
- package/dist/command-implementations/project-command.js +115 -0
- package/dist/command-implementations/serve-command.js +53 -0
- package/dist/command-tree.js +59 -0
- package/dist/config.js +85 -112
- package/dist/consts.js +14 -1
- package/dist/errors.js +156 -0
- package/dist/index.js +13 -243
- package/dist/integration-ref.js +61 -0
- package/dist/logger/base-logger.js +5 -20
- package/dist/logger/index.js +3 -2
- package/dist/path-utils.js +6 -0
- package/dist/register-yargs.js +85 -0
- package/dist/typings.js +16 -0
- package/dist/utils/cache-utils.js +99 -0
- package/dist/utils/esbuild-utils.js +89 -0
- package/dist/utils/event-emitter.js +62 -0
- package/dist/utils/file-watcher.js +68 -0
- package/dist/utils/index.js +55 -0
- package/dist/utils/path-utils.js +83 -0
- package/dist/utils/prompt-utils.js +75 -0
- package/dist/utils/require-utils.js +49 -0
- package/dist/utils/string-utils.js +38 -0
- package/dist/worker/child-entrypoint.js +3 -3
- package/package.json +7 -5
- package/templates/echo-bot/.botpress/project.cache.json +1 -0
- package/templates/echo-bot/package.json +22 -0
- package/templates/echo-bot/readme.md +5 -0
- package/templates/echo-bot/src/index.ts +44 -0
- package/templates/echo-bot/tsconfig.json +15 -0
- package/templates/empty-integration/.botpress/implementation/actions/index.ts +7 -0
- package/templates/empty-integration/.botpress/implementation/channels/channel/audio.ts +10 -0
- package/templates/empty-integration/.botpress/implementation/channels/channel/card.ts +17 -0
- package/templates/empty-integration/.botpress/implementation/channels/channel/carousel.ts +19 -0
- package/templates/empty-integration/.botpress/implementation/channels/channel/choice.ts +14 -0
- package/templates/empty-integration/.botpress/implementation/channels/channel/dropdown.ts +14 -0
- package/templates/empty-integration/.botpress/implementation/channels/channel/file.ts +11 -0
- package/templates/empty-integration/.botpress/implementation/channels/channel/image.ts +10 -0
- package/templates/empty-integration/.botpress/implementation/channels/channel/index.ts +40 -0
- package/templates/empty-integration/.botpress/implementation/channels/channel/location.ts +11 -0
- package/templates/empty-integration/.botpress/implementation/channels/channel/markdown.ts +10 -0
- package/templates/empty-integration/.botpress/implementation/channels/channel/text.ts +10 -0
- package/templates/empty-integration/.botpress/implementation/channels/channel/video.ts +10 -0
- package/templates/empty-integration/.botpress/implementation/channels/index.ts +10 -0
- package/templates/empty-integration/.botpress/implementation/configuration.ts +10 -0
- package/templates/empty-integration/.botpress/implementation/events/index.ts +7 -0
- package/templates/empty-integration/.botpress/implementation/index.ts +17 -0
- package/templates/empty-integration/.botpress/index.ts +1 -0
- package/templates/empty-integration/.botpress/project.cache.json +1 -0
- package/templates/empty-integration/integration.definition.ts +13 -0
- package/templates/empty-integration/package.json +22 -0
- package/templates/empty-integration/readme.md +5 -0
- package/templates/empty-integration/src/index.ts +58 -0
- package/templates/empty-integration/tsconfig.json +15 -0
- package/.ignore.me.github/index.ts +0 -38
- package/dist/github-download.js +0 -159
- package/dist/github-fetch.js +0 -173
|
@@ -0,0 +1,59 @@
|
|
|
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 command_tree_exports = {};
|
|
20
|
+
__export(command_tree_exports, {
|
|
21
|
+
guards: () => guards,
|
|
22
|
+
zipTree: () => zipTree
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(command_tree_exports);
|
|
25
|
+
const guards = {
|
|
26
|
+
definition: {
|
|
27
|
+
isDef: (x) => "schema" in x,
|
|
28
|
+
isSubTree: (x) => "subcommands" in x
|
|
29
|
+
},
|
|
30
|
+
implementation: {
|
|
31
|
+
isImpl: (x) => typeof x === "function",
|
|
32
|
+
isSubTree: (x) => typeof x === "object"
|
|
33
|
+
},
|
|
34
|
+
command: {
|
|
35
|
+
isLeaf: (x) => "handler" in x,
|
|
36
|
+
isSubTree: (x) => "subcommands" in x
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const zipTree = (defTree, implTree) => {
|
|
40
|
+
const tree = {};
|
|
41
|
+
for (const key in defTree) {
|
|
42
|
+
const def = defTree[key];
|
|
43
|
+
const impl = implTree[key];
|
|
44
|
+
if (guards.definition.isDef(def) && guards.implementation.isImpl(impl)) {
|
|
45
|
+
tree[key] = { ...def, handler: impl };
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (guards.definition.isSubTree(def) && guards.implementation.isSubTree(impl)) {
|
|
49
|
+
tree[key] = { ...def, subcommands: zipTree(def.subcommands, impl.subcommands) };
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return tree;
|
|
54
|
+
};
|
|
55
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
+
0 && (module.exports = {
|
|
57
|
+
guards,
|
|
58
|
+
zipTree
|
|
59
|
+
});
|
package/dist/config.js
CHANGED
|
@@ -24,85 +24,19 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
25
|
var config_exports = {};
|
|
26
26
|
__export(config_exports, {
|
|
27
|
-
|
|
28
|
-
botRef: () => botRef,
|
|
29
|
-
buildSchema: () => buildSchema,
|
|
30
|
-
bundleSchema: () => bundleSchema,
|
|
31
|
-
createBotSchema: () => createBotSchema,
|
|
32
|
-
deleteBotSchema: () => deleteBotSchema,
|
|
33
|
-
deleteIntegrationSchema: () => deleteIntegrationSchema,
|
|
34
|
-
deploySchema: () => deploySchema,
|
|
35
|
-
devSchema: () => devSchema,
|
|
36
|
-
generateSchema: () => generateSchema,
|
|
37
|
-
globalSchema: () => globalSchema,
|
|
38
|
-
integrationRef: () => integrationRef,
|
|
39
|
-
listBotsSchema: () => listBotsSchema,
|
|
40
|
-
listIntegrationsSchema: () => listIntegrationsSchema,
|
|
41
|
-
loggedInSchema: () => loggedInSchema,
|
|
42
|
-
loginSchema: () => loginSchema,
|
|
43
|
-
logoutSchema: () => logoutSchema,
|
|
44
|
-
projectSchema: () => projectSchema,
|
|
45
|
-
readBotSchema: () => readBotSchema,
|
|
46
|
-
readIntegrationSchema: () => readIntegrationSchema,
|
|
47
|
-
serveSchema: () => serveSchema
|
|
27
|
+
schemas: () => schemas
|
|
48
28
|
});
|
|
49
29
|
module.exports = __toCommonJS(config_exports);
|
|
50
30
|
var consts = __toESM(require("./consts"));
|
|
51
|
-
const botpressHome = {
|
|
52
|
-
type: "string",
|
|
53
|
-
description: "The path to the Botpress home directory",
|
|
54
|
-
default: consts.defaultBotpressHome
|
|
55
|
-
};
|
|
56
|
-
const verbose = {
|
|
57
|
-
type: "boolean",
|
|
58
|
-
description: "Enable verbose logging",
|
|
59
|
-
alias: "v",
|
|
60
|
-
default: false
|
|
61
|
-
};
|
|
62
|
-
const json = {
|
|
63
|
-
type: "boolean",
|
|
64
|
-
description: "Prevent logging anything else than raw json. Useful for piping output to other tools",
|
|
65
|
-
alias: "j",
|
|
66
|
-
default: false
|
|
67
|
-
};
|
|
68
|
-
const confirm = {
|
|
69
|
-
type: "boolean",
|
|
70
|
-
description: "Confirm all prompts",
|
|
71
|
-
alias: "y",
|
|
72
|
-
default: false
|
|
73
|
-
};
|
|
74
31
|
const port = {
|
|
75
32
|
type: "number",
|
|
76
33
|
description: "The port to use"
|
|
77
34
|
};
|
|
78
|
-
const entryPoint = {
|
|
79
|
-
type: "string",
|
|
80
|
-
description: "The entry point of the project",
|
|
81
|
-
default: consts.defaultEntrypoint
|
|
82
|
-
};
|
|
83
|
-
const outDir = {
|
|
84
|
-
type: "string",
|
|
85
|
-
description: "The output directory",
|
|
86
|
-
default: consts.defaultOutputFolder
|
|
87
|
-
};
|
|
88
35
|
const workDir = {
|
|
89
36
|
type: "string",
|
|
90
37
|
description: "The path to the project",
|
|
91
38
|
default: process.cwd()
|
|
92
39
|
};
|
|
93
|
-
const botId = {
|
|
94
|
-
type: "string",
|
|
95
|
-
description: "The bot ID to deploy. Only used when deploying a bot"
|
|
96
|
-
};
|
|
97
|
-
const createNewBot = {
|
|
98
|
-
type: "boolean",
|
|
99
|
-
description: "Create a new bot when deploying. Only used when deploying a bot"
|
|
100
|
-
};
|
|
101
|
-
const url = {
|
|
102
|
-
type: "string",
|
|
103
|
-
description: "The publicly available URL of the bot or integration (often using ngrok)",
|
|
104
|
-
demandOption: true
|
|
105
|
-
};
|
|
106
40
|
const noBuild = {
|
|
107
41
|
type: "boolean",
|
|
108
42
|
description: "Skip the build step",
|
|
@@ -123,26 +57,48 @@ const workspaceId = {
|
|
|
123
57
|
const botRef = {
|
|
124
58
|
type: "string",
|
|
125
59
|
description: "The bot ID. Bot Name is not supported.",
|
|
126
|
-
demandOption: true
|
|
60
|
+
demandOption: true,
|
|
61
|
+
positional: true,
|
|
62
|
+
idx: 0
|
|
127
63
|
};
|
|
128
64
|
const integrationRef = {
|
|
129
65
|
type: "string",
|
|
130
66
|
description: "The integration ID or name with optionnal version. Ex: teams or teams@0.2.0",
|
|
131
|
-
demandOption: true
|
|
67
|
+
demandOption: true,
|
|
68
|
+
positional: true,
|
|
69
|
+
idx: 0
|
|
132
70
|
};
|
|
133
71
|
const globalSchema = {
|
|
134
|
-
verbose
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
72
|
+
verbose: {
|
|
73
|
+
type: "boolean",
|
|
74
|
+
description: "Enable verbose logging",
|
|
75
|
+
alias: "v",
|
|
76
|
+
default: false
|
|
77
|
+
},
|
|
78
|
+
confirm: {
|
|
79
|
+
type: "boolean",
|
|
80
|
+
description: "Confirm all prompts",
|
|
81
|
+
alias: "y",
|
|
82
|
+
default: false
|
|
83
|
+
},
|
|
84
|
+
json: {
|
|
85
|
+
type: "boolean",
|
|
86
|
+
description: "Prevent logging anything else than raw json in stdout. Useful for piping output to other tools",
|
|
87
|
+
default: false
|
|
88
|
+
},
|
|
89
|
+
botpressHome: {
|
|
90
|
+
type: "string",
|
|
91
|
+
description: "The path to the Botpress home directory",
|
|
92
|
+
default: consts.defaultBotpressHome
|
|
93
|
+
}
|
|
138
94
|
};
|
|
139
95
|
const projectSchema = {
|
|
140
96
|
...globalSchema,
|
|
141
|
-
entryPoint,
|
|
142
|
-
outDir,
|
|
97
|
+
entryPoint: { type: "string", description: "The entry point of the project", default: consts.defaultEntrypoint },
|
|
98
|
+
outDir: { type: "string", description: "The output directory", default: consts.defaultOutputFolder },
|
|
143
99
|
workDir
|
|
144
100
|
};
|
|
145
|
-
const
|
|
101
|
+
const credentialsSchema = {
|
|
146
102
|
host,
|
|
147
103
|
workspaceId,
|
|
148
104
|
token
|
|
@@ -162,21 +118,26 @@ const serveSchema = {
|
|
|
162
118
|
};
|
|
163
119
|
const deploySchema = {
|
|
164
120
|
...projectSchema,
|
|
165
|
-
...
|
|
166
|
-
botId,
|
|
121
|
+
...credentialsSchema,
|
|
122
|
+
botId: { type: "string", description: "The bot ID to deploy. Only used when deploying a bot" },
|
|
167
123
|
noBuild,
|
|
168
|
-
createNewBot
|
|
124
|
+
createNewBot: { type: "boolean", description: "Create a new bot when deploying. Only used when deploying a bot" }
|
|
169
125
|
};
|
|
170
126
|
const devSchema = {
|
|
171
127
|
...projectSchema,
|
|
172
|
-
...
|
|
173
|
-
url
|
|
128
|
+
...credentialsSchema,
|
|
129
|
+
url: {
|
|
130
|
+
type: "string",
|
|
131
|
+
description: "The publicly available URL of the bot or integration (often using ngrok)",
|
|
132
|
+
demandOption: true
|
|
133
|
+
},
|
|
174
134
|
port,
|
|
175
135
|
noBuild
|
|
176
136
|
};
|
|
177
137
|
const addSchema = {
|
|
178
138
|
...projectSchema,
|
|
179
|
-
...
|
|
139
|
+
...credentialsSchema,
|
|
140
|
+
integrationRef
|
|
180
141
|
};
|
|
181
142
|
const loginSchema = {
|
|
182
143
|
...globalSchema,
|
|
@@ -189,56 +150,68 @@ const logoutSchema = {
|
|
|
189
150
|
};
|
|
190
151
|
const createBotSchema = {
|
|
191
152
|
...globalSchema,
|
|
192
|
-
...
|
|
153
|
+
...credentialsSchema,
|
|
193
154
|
name: { type: "string", description: "The name of the bot to create" }
|
|
194
155
|
};
|
|
195
|
-
const
|
|
156
|
+
const getBotSchema = {
|
|
196
157
|
...globalSchema,
|
|
197
|
-
...
|
|
158
|
+
...credentialsSchema,
|
|
159
|
+
botRef
|
|
198
160
|
};
|
|
199
161
|
const deleteBotSchema = {
|
|
200
162
|
...globalSchema,
|
|
201
|
-
...
|
|
163
|
+
...credentialsSchema,
|
|
164
|
+
botRef
|
|
202
165
|
};
|
|
203
166
|
const listBotsSchema = {
|
|
204
167
|
...globalSchema,
|
|
205
|
-
...
|
|
168
|
+
...credentialsSchema
|
|
206
169
|
};
|
|
207
|
-
const
|
|
170
|
+
const getIntegrationSchema = {
|
|
208
171
|
...globalSchema,
|
|
209
|
-
...
|
|
172
|
+
...credentialsSchema,
|
|
173
|
+
integrationRef
|
|
210
174
|
};
|
|
211
175
|
const listIntegrationsSchema = {
|
|
212
176
|
...globalSchema,
|
|
213
|
-
...
|
|
177
|
+
...credentialsSchema,
|
|
214
178
|
name: { type: "string", description: "The name filter when listing integrations" },
|
|
215
179
|
version: { type: "string", description: "The version filter when listing integrations" }
|
|
216
180
|
};
|
|
217
181
|
const deleteIntegrationSchema = {
|
|
218
182
|
...globalSchema,
|
|
219
|
-
...
|
|
183
|
+
...credentialsSchema,
|
|
184
|
+
integrationRef
|
|
185
|
+
};
|
|
186
|
+
const initSchema = {
|
|
187
|
+
...globalSchema,
|
|
188
|
+
workDir,
|
|
189
|
+
type: { type: "string", choices: ["bot", "integration"] },
|
|
190
|
+
name: { type: "string", description: "The name of the project" }
|
|
191
|
+
};
|
|
192
|
+
const schemas = {
|
|
193
|
+
global: globalSchema,
|
|
194
|
+
project: projectSchema,
|
|
195
|
+
credentials: credentialsSchema,
|
|
196
|
+
login: loginSchema,
|
|
197
|
+
logout: logoutSchema,
|
|
198
|
+
createBot: createBotSchema,
|
|
199
|
+
getBot: getBotSchema,
|
|
200
|
+
deleteBot: deleteBotSchema,
|
|
201
|
+
listBots: listBotsSchema,
|
|
202
|
+
getIntegration: getIntegrationSchema,
|
|
203
|
+
listIntegrations: listIntegrationsSchema,
|
|
204
|
+
deleteIntegration: deleteIntegrationSchema,
|
|
205
|
+
init: initSchema,
|
|
206
|
+
generate: generateSchema,
|
|
207
|
+
bundle: bundleSchema,
|
|
208
|
+
build: buildSchema,
|
|
209
|
+
serve: serveSchema,
|
|
210
|
+
deploy: deploySchema,
|
|
211
|
+
add: addSchema,
|
|
212
|
+
dev: devSchema
|
|
220
213
|
};
|
|
221
214
|
// Annotate the CommonJS export names for ESM import in node:
|
|
222
215
|
0 && (module.exports = {
|
|
223
|
-
|
|
224
|
-
botRef,
|
|
225
|
-
buildSchema,
|
|
226
|
-
bundleSchema,
|
|
227
|
-
createBotSchema,
|
|
228
|
-
deleteBotSchema,
|
|
229
|
-
deleteIntegrationSchema,
|
|
230
|
-
deploySchema,
|
|
231
|
-
devSchema,
|
|
232
|
-
generateSchema,
|
|
233
|
-
globalSchema,
|
|
234
|
-
integrationRef,
|
|
235
|
-
listBotsSchema,
|
|
236
|
-
listIntegrationsSchema,
|
|
237
|
-
loggedInSchema,
|
|
238
|
-
loginSchema,
|
|
239
|
-
logoutSchema,
|
|
240
|
-
projectSchema,
|
|
241
|
-
readBotSchema,
|
|
242
|
-
readIntegrationSchema,
|
|
243
|
-
serveSchema
|
|
216
|
+
schemas
|
|
244
217
|
});
|
package/dist/consts.js
CHANGED
|
@@ -29,6 +29,9 @@ __export(consts_exports, {
|
|
|
29
29
|
defaultBotpressHome: () => defaultBotpressHome,
|
|
30
30
|
defaultEntrypoint: () => defaultEntrypoint,
|
|
31
31
|
defaultOutputFolder: () => defaultOutputFolder,
|
|
32
|
+
echoBotName: () => echoBotName,
|
|
33
|
+
emptyIntegrationName: () => emptyIntegrationName,
|
|
34
|
+
fromCliRootDir: () => fromCliRootDir,
|
|
32
35
|
fromHomeDir: () => fromHomeDir,
|
|
33
36
|
fromOutDir: () => fromOutDir,
|
|
34
37
|
fromWorkDir: () => fromWorkDir
|
|
@@ -41,8 +44,15 @@ const defaultOutputFolder = ".botpress";
|
|
|
41
44
|
const defaultEntrypoint = import_path.default.join("src", "index.ts");
|
|
42
45
|
const defaultBotpressApi = "https://api.botpress.cloud";
|
|
43
46
|
const defaultBotpressApp = "https://app.botpress.cloud";
|
|
47
|
+
const echoBotName = "echo-bot";
|
|
48
|
+
const emptyIntegrationName = "empty-integration";
|
|
49
|
+
const fromCliRootDir = {
|
|
50
|
+
packageJson: "package.json",
|
|
51
|
+
echoBotTemplate: import_path.default.join("templates", echoBotName),
|
|
52
|
+
emptyIntegrationTemplate: import_path.default.join("templates", emptyIntegrationName)
|
|
53
|
+
};
|
|
44
54
|
const fromHomeDir = {
|
|
45
|
-
|
|
55
|
+
globalCacheFile: "global.cache.json"
|
|
46
56
|
};
|
|
47
57
|
const fromWorkDir = {
|
|
48
58
|
definition: "integration.definition.ts"
|
|
@@ -61,6 +71,9 @@ const fromOutDir = {
|
|
|
61
71
|
defaultBotpressHome,
|
|
62
72
|
defaultEntrypoint,
|
|
63
73
|
defaultOutputFolder,
|
|
74
|
+
echoBotName,
|
|
75
|
+
emptyIntegrationName,
|
|
76
|
+
fromCliRootDir,
|
|
64
77
|
fromHomeDir,
|
|
65
78
|
fromOutDir,
|
|
66
79
|
fromWorkDir
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
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
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var errors_exports = {};
|
|
26
|
+
__export(errors_exports, {
|
|
27
|
+
BotpressCLIError: () => BotpressCLIError,
|
|
28
|
+
ExclusiveBotFeatureError: () => ExclusiveBotFeatureError,
|
|
29
|
+
ExclusiveIntegrationFeatureError: () => ExclusiveIntegrationFeatureError,
|
|
30
|
+
HTTPError: () => HTTPError,
|
|
31
|
+
InvalidIntegrationReferenceError: () => InvalidIntegrationReferenceError,
|
|
32
|
+
NoBotsFoundError: () => NoBotsFoundError,
|
|
33
|
+
NoBundleFoundError: () => NoBundleFoundError,
|
|
34
|
+
NoWorkspacesFoundError: () => NoWorkspacesFoundError,
|
|
35
|
+
NotLoggedInError: () => NotLoggedInError,
|
|
36
|
+
ParamRequiredError: () => ParamRequiredError
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(errors_exports);
|
|
39
|
+
var import_client = require("@botpress/client");
|
|
40
|
+
var import_axios = __toESM(require("axios"));
|
|
41
|
+
var import_verror = require("verror");
|
|
42
|
+
var consts = __toESM(require("./consts"));
|
|
43
|
+
const isKnownApiError = (e) => (0, import_client.isApiError)(e) && !(e instanceof import_client.UnknownError);
|
|
44
|
+
class BotpressCLIError extends import_verror.VError {
|
|
45
|
+
static wrap(thrown, message) {
|
|
46
|
+
const err = BotpressCLIError.map(thrown);
|
|
47
|
+
return new BotpressCLIError(err, message ?? "");
|
|
48
|
+
}
|
|
49
|
+
static map(thrown) {
|
|
50
|
+
if (thrown instanceof import_client.UnknownError) {
|
|
51
|
+
return new HTTPError(500, "An unknown error has occurred.");
|
|
52
|
+
}
|
|
53
|
+
if (isKnownApiError(thrown)) {
|
|
54
|
+
return HTTPError.fromApi(thrown);
|
|
55
|
+
}
|
|
56
|
+
if (import_axios.default.isAxiosError(thrown)) {
|
|
57
|
+
return HTTPError.fromAxios(thrown);
|
|
58
|
+
}
|
|
59
|
+
if (thrown instanceof Error) {
|
|
60
|
+
const { message } = thrown;
|
|
61
|
+
return new BotpressCLIError(message);
|
|
62
|
+
}
|
|
63
|
+
return new BotpressCLIError(`${thrown}`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
class ExclusiveBotFeatureError extends BotpressCLIError {
|
|
67
|
+
constructor() {
|
|
68
|
+
const message = "This feature is only available for bots. This project is an integration";
|
|
69
|
+
super(message);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
class ExclusiveIntegrationFeatureError extends BotpressCLIError {
|
|
73
|
+
constructor() {
|
|
74
|
+
const message = "This feature is only available for integration. This project is a bot";
|
|
75
|
+
super(message);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
class HTTPError extends BotpressCLIError {
|
|
79
|
+
constructor(status, message) {
|
|
80
|
+
super(message);
|
|
81
|
+
this.status = status;
|
|
82
|
+
}
|
|
83
|
+
static fromAxios(e) {
|
|
84
|
+
const message = this._axiosMsg(e);
|
|
85
|
+
return new HTTPError(e.response?.status, message);
|
|
86
|
+
}
|
|
87
|
+
static fromApi(e) {
|
|
88
|
+
const { message, code } = e;
|
|
89
|
+
return new HTTPError(code, message);
|
|
90
|
+
}
|
|
91
|
+
static _axiosMsg(e) {
|
|
92
|
+
let message = e.message;
|
|
93
|
+
if (e.response?.statusText) {
|
|
94
|
+
message += `
|
|
95
|
+
${e.response?.statusText}`;
|
|
96
|
+
}
|
|
97
|
+
if (e.response?.status && e.request?.method && e.request?.path) {
|
|
98
|
+
message += `
|
|
99
|
+
(${e.response?.status}) ${e.request.method} ${e.request.path}`;
|
|
100
|
+
}
|
|
101
|
+
if (e.response?.data?.message) {
|
|
102
|
+
message += `
|
|
103
|
+
${e.response?.data?.message}`;
|
|
104
|
+
}
|
|
105
|
+
return message;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
class NoBundleFoundError extends BotpressCLIError {
|
|
109
|
+
constructor() {
|
|
110
|
+
const message = "No bundle found. Please run `bp bundle` first.";
|
|
111
|
+
super(message);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
class NoBotsFoundError extends BotpressCLIError {
|
|
115
|
+
constructor() {
|
|
116
|
+
const message = `No Bot found in your Workspace. Please create one first at ${consts.defaultBotpressApp}.`;
|
|
117
|
+
super(message);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
class NoWorkspacesFoundError extends BotpressCLIError {
|
|
121
|
+
constructor() {
|
|
122
|
+
const message = "No Workspace found. Please create one first.";
|
|
123
|
+
super(message);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
class NotLoggedInError extends BotpressCLIError {
|
|
127
|
+
constructor() {
|
|
128
|
+
const message = "Not logged in. Please run `bp login` first.";
|
|
129
|
+
super(message);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
class ParamRequiredError extends BotpressCLIError {
|
|
133
|
+
constructor(param) {
|
|
134
|
+
const message = `${param} is required.`;
|
|
135
|
+
super(message);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
class InvalidIntegrationReferenceError extends BotpressCLIError {
|
|
139
|
+
constructor(ref) {
|
|
140
|
+
const message = `Invalid integration reference "${ref}".`;
|
|
141
|
+
super(message);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
145
|
+
0 && (module.exports = {
|
|
146
|
+
BotpressCLIError,
|
|
147
|
+
ExclusiveBotFeatureError,
|
|
148
|
+
ExclusiveIntegrationFeatureError,
|
|
149
|
+
HTTPError,
|
|
150
|
+
InvalidIntegrationReferenceError,
|
|
151
|
+
NoBotsFoundError,
|
|
152
|
+
NoBundleFoundError,
|
|
153
|
+
NoWorkspacesFoundError,
|
|
154
|
+
NotLoggedInError,
|
|
155
|
+
ParamRequiredError
|
|
156
|
+
});
|