@botpress/cli 0.0.8 → 0.0.10
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 +28 -31
- package/dist/app/index.js +18 -11
- package/dist/app/project.js +4 -4
- 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 +18 -8
- package/dist/consts.js +24 -9
- package/dist/errors.js +156 -0
- package/dist/index.js +33 -20
- package/dist/integration-ref.js +61 -0
- package/dist/path-utils.js +7 -4
- 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/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
|
@@ -0,0 +1,68 @@
|
|
|
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 file_watcher_exports = {};
|
|
26
|
+
__export(file_watcher_exports, {
|
|
27
|
+
FileWatcher: () => FileWatcher
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(file_watcher_exports);
|
|
30
|
+
var import_watcher = __toESM(require("@parcel/watcher"));
|
|
31
|
+
var import_event_emitter = require("./event-emitter");
|
|
32
|
+
class FileWatcher {
|
|
33
|
+
constructor(subscription, errorEmitter) {
|
|
34
|
+
this.subscription = subscription;
|
|
35
|
+
this.errorEmitter = errorEmitter;
|
|
36
|
+
}
|
|
37
|
+
static async watch(dir, fn, opt) {
|
|
38
|
+
const eventEmitter = new import_event_emitter.EventEmitter();
|
|
39
|
+
const subscription = await import_watcher.default.subscribe(
|
|
40
|
+
dir,
|
|
41
|
+
async (err, events) => {
|
|
42
|
+
if (err) {
|
|
43
|
+
eventEmitter.emit("error", err);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
await fn(events);
|
|
48
|
+
} catch (thrown) {
|
|
49
|
+
eventEmitter.emit("error", thrown);
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
opt
|
|
53
|
+
);
|
|
54
|
+
return new FileWatcher(subscription, eventEmitter);
|
|
55
|
+
}
|
|
56
|
+
async close() {
|
|
57
|
+
await this.subscription.unsubscribe();
|
|
58
|
+
this.errorEmitter.emit("close", {});
|
|
59
|
+
}
|
|
60
|
+
wait = () => new Promise((resolve, reject) => {
|
|
61
|
+
this.errorEmitter.once("error", reject);
|
|
62
|
+
this.errorEmitter.once("close", resolve);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
66
|
+
0 && (module.exports = {
|
|
67
|
+
FileWatcher
|
|
68
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
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 utils_exports = {};
|
|
26
|
+
__export(utils_exports, {
|
|
27
|
+
cache: () => cache,
|
|
28
|
+
emitter: () => emitter,
|
|
29
|
+
esbuild: () => esbuild,
|
|
30
|
+
filewatcher: () => filewatcher,
|
|
31
|
+
path: () => path,
|
|
32
|
+
prompt: () => prompt,
|
|
33
|
+
require: () => require2,
|
|
34
|
+
strings: () => strings
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(utils_exports);
|
|
37
|
+
var esbuild = __toESM(require("./esbuild-utils"));
|
|
38
|
+
var path = __toESM(require("./path-utils"));
|
|
39
|
+
var require2 = __toESM(require("./require-utils"));
|
|
40
|
+
var filewatcher = __toESM(require("./file-watcher"));
|
|
41
|
+
var emitter = __toESM(require("./event-emitter"));
|
|
42
|
+
var cache = __toESM(require("./cache-utils"));
|
|
43
|
+
var strings = __toESM(require("./string-utils"));
|
|
44
|
+
var prompt = __toESM(require("./prompt-utils"));
|
|
45
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
46
|
+
0 && (module.exports = {
|
|
47
|
+
cache,
|
|
48
|
+
emitter,
|
|
49
|
+
esbuild,
|
|
50
|
+
filewatcher,
|
|
51
|
+
path,
|
|
52
|
+
prompt,
|
|
53
|
+
require,
|
|
54
|
+
strings
|
|
55
|
+
});
|
|
@@ -0,0 +1,83 @@
|
|
|
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 path_utils_exports = {};
|
|
26
|
+
__export(path_utils_exports, {
|
|
27
|
+
PathStore: () => PathStore,
|
|
28
|
+
absoluteFrom: () => absoluteFrom,
|
|
29
|
+
cwd: () => cwd,
|
|
30
|
+
isAbsolute: () => isAbsolute,
|
|
31
|
+
isPath: () => isPath,
|
|
32
|
+
join: () => join,
|
|
33
|
+
relativeFrom: () => relativeFrom,
|
|
34
|
+
rmExtension: () => rmExtension,
|
|
35
|
+
toUnix: () => toUnix
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(path_utils_exports);
|
|
38
|
+
var import_lodash = __toESM(require("lodash"));
|
|
39
|
+
var import_path = __toESM(require("path"));
|
|
40
|
+
const cwd = () => process.cwd();
|
|
41
|
+
const isAbsolute = (path) => import_path.default.isAbsolute(path);
|
|
42
|
+
const isPath = (path) => isAbsolute(path) || path.startsWith(".");
|
|
43
|
+
const join = (abs, ...paths) => {
|
|
44
|
+
const joined = import_path.default.join(abs, ...paths);
|
|
45
|
+
return import_path.default.normalize(joined);
|
|
46
|
+
};
|
|
47
|
+
const rmExtension = (filename) => filename.replace(/\.[^/.]+$/, "");
|
|
48
|
+
const toUnix = (path) => path.split(import_path.default.sep).join(import_path.default.posix.sep);
|
|
49
|
+
const absoluteFrom = (rootdir, target) => {
|
|
50
|
+
if (isAbsolute(target)) {
|
|
51
|
+
return target;
|
|
52
|
+
}
|
|
53
|
+
return import_path.default.join(rootdir, target);
|
|
54
|
+
};
|
|
55
|
+
const relativeFrom = (rootdir, target) => {
|
|
56
|
+
let absPath;
|
|
57
|
+
if (isAbsolute(target)) {
|
|
58
|
+
absPath = target;
|
|
59
|
+
} else {
|
|
60
|
+
absPath = import_path.default.resolve(import_path.default.join(rootdir, target));
|
|
61
|
+
}
|
|
62
|
+
return import_path.default.relative(rootdir, absPath);
|
|
63
|
+
};
|
|
64
|
+
class PathStore {
|
|
65
|
+
constructor(abs) {
|
|
66
|
+
this.abs = abs;
|
|
67
|
+
}
|
|
68
|
+
rel(from) {
|
|
69
|
+
return import_lodash.default.mapValues(this.abs, (to) => relativeFrom(this.abs[from], to));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
73
|
+
0 && (module.exports = {
|
|
74
|
+
PathStore,
|
|
75
|
+
absoluteFrom,
|
|
76
|
+
cwd,
|
|
77
|
+
isAbsolute,
|
|
78
|
+
isPath,
|
|
79
|
+
join,
|
|
80
|
+
relativeFrom,
|
|
81
|
+
rmExtension,
|
|
82
|
+
toUnix
|
|
83
|
+
});
|
|
@@ -0,0 +1,75 @@
|
|
|
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 prompt_utils_exports = {};
|
|
26
|
+
__export(prompt_utils_exports, {
|
|
27
|
+
CLIPrompt: () => CLIPrompt
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(prompt_utils_exports);
|
|
30
|
+
var import_prompts = __toESM(require("prompts"));
|
|
31
|
+
class CLIPrompt {
|
|
32
|
+
constructor(_props, _logger) {
|
|
33
|
+
this._props = _props;
|
|
34
|
+
this._logger = _logger;
|
|
35
|
+
}
|
|
36
|
+
async confirm(message) {
|
|
37
|
+
if (this._props.confirm) {
|
|
38
|
+
this._logger.debug(`Confirming automatically: ${message}`);
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
const { confirm } = await (0, import_prompts.default)({
|
|
42
|
+
type: "confirm",
|
|
43
|
+
name: "confirm",
|
|
44
|
+
message,
|
|
45
|
+
initial: false
|
|
46
|
+
});
|
|
47
|
+
if (!confirm) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
async password(message, opts) {
|
|
53
|
+
const { prompted } = await (0, import_prompts.default)({
|
|
54
|
+
type: "password",
|
|
55
|
+
name: "prompted",
|
|
56
|
+
message,
|
|
57
|
+
initial: opts?.initial
|
|
58
|
+
});
|
|
59
|
+
return prompted ? prompted : void 0;
|
|
60
|
+
}
|
|
61
|
+
async select(message, opts) {
|
|
62
|
+
const { prompted } = await (0, import_prompts.default)({
|
|
63
|
+
type: "autocomplete",
|
|
64
|
+
name: "prompted",
|
|
65
|
+
message,
|
|
66
|
+
initial: opts?.initial?.value,
|
|
67
|
+
choices: opts?.choices
|
|
68
|
+
});
|
|
69
|
+
return prompted ? prompted : void 0;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
73
|
+
0 && (module.exports = {
|
|
74
|
+
CLIPrompt
|
|
75
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
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 require_utils_exports = {};
|
|
26
|
+
__export(require_utils_exports, {
|
|
27
|
+
requireJsCode: () => requireJsCode,
|
|
28
|
+
requireJsFile: () => requireJsFile
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(require_utils_exports);
|
|
31
|
+
var import_module = __toESM(require("module"));
|
|
32
|
+
var import_path = __toESM(require("path"));
|
|
33
|
+
const requireJsFile = (path) => {
|
|
34
|
+
return require(path);
|
|
35
|
+
};
|
|
36
|
+
const requireJsCode = (code) => {
|
|
37
|
+
const filedir = "tmp";
|
|
38
|
+
const filename = `${Date.now()}.js`;
|
|
39
|
+
const fileid = import_path.default.join(filedir, filename);
|
|
40
|
+
const m = new import_module.default(fileid);
|
|
41
|
+
m.filename = filename;
|
|
42
|
+
m._compile(code, filename);
|
|
43
|
+
return m.exports;
|
|
44
|
+
};
|
|
45
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
46
|
+
0 && (module.exports = {
|
|
47
|
+
requireJsCode,
|
|
48
|
+
requireJsFile
|
|
49
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
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 string_utils_exports = {};
|
|
20
|
+
__export(string_utils_exports, {
|
|
21
|
+
kebabCase: () => kebabCase,
|
|
22
|
+
pascalCase: () => pascalCase
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(string_utils_exports);
|
|
25
|
+
const capitalizeFirstLetter = (string) => string.charAt(0).toUpperCase() + string.slice(1);
|
|
26
|
+
const pascalCase = (string) => {
|
|
27
|
+
const words = string.split(/[-_]/);
|
|
28
|
+
return words.map(capitalizeFirstLetter).join("");
|
|
29
|
+
};
|
|
30
|
+
const kebabCase = (string) => {
|
|
31
|
+
const words = string.split(/(?<=[a-z])(?=[A-Z])/);
|
|
32
|
+
return words.map((word) => word.toLowerCase()).join("-");
|
|
33
|
+
};
|
|
34
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
+
0 && (module.exports = {
|
|
36
|
+
kebabCase,
|
|
37
|
+
pascalCase
|
|
38
|
+
});
|
package/package.json
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botpress/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"description": "Botpress CLI",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"build": "pnpm run type-check && pnpm run bundle",
|
|
6
|
+
"build": "pnpm run type-check && pnpm run bundle && pnpm run template:gen && pnpm run template:type-check",
|
|
7
7
|
"dev": "ts-node -T src/index.ts",
|
|
8
8
|
"start": "node dist/index.js",
|
|
9
9
|
"type-check": "tsc --noEmit",
|
|
10
|
-
"bundle": "ts-node -T build.ts"
|
|
10
|
+
"bundle": "ts-node -T build.ts",
|
|
11
|
+
"template:type-check": "pnpm -r --stream -F './**/templates/*' run type-check",
|
|
12
|
+
"template:gen": "pnpm -r --stream -F './**/templates/*' exec bp gen"
|
|
11
13
|
},
|
|
12
14
|
"keywords": [],
|
|
13
15
|
"author": "",
|
|
@@ -17,7 +19,7 @@
|
|
|
17
19
|
},
|
|
18
20
|
"main": "dist/index.js",
|
|
19
21
|
"dependencies": {
|
|
20
|
-
"@botpress/client": "0.0.
|
|
22
|
+
"@botpress/client": "0.0.10",
|
|
21
23
|
"@bpinternal/yargs-extra": "^0.0.2",
|
|
22
24
|
"@parcel/watcher": "^2.1.0",
|
|
23
25
|
"@types/lodash": "^4.14.191",
|
|
@@ -43,7 +45,7 @@
|
|
|
43
45
|
"zod-to-json-schema": "^3.20.1"
|
|
44
46
|
},
|
|
45
47
|
"devDependencies": {
|
|
46
|
-
"@botpress/sdk": "0.0.
|
|
48
|
+
"@botpress/sdk": "0.0.8",
|
|
47
49
|
"@types/bluebird": "^3.5.38",
|
|
48
50
|
"@types/prompts": "^2.0.14",
|
|
49
51
|
"@types/semver": "^7.3.11",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@botpresshub/echo-bot",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Bot that answers with the received message",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"type-check": "tsc --noEmit"
|
|
7
|
+
},
|
|
8
|
+
"keywords": [],
|
|
9
|
+
"private": true,
|
|
10
|
+
"author": "",
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@botpress/client": "0.0.10",
|
|
14
|
+
"@botpress/sdk": "0.0.8",
|
|
15
|
+
"zod": "^3.20.6"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@types/node": "^18.11.17",
|
|
19
|
+
"ts-node": "^10.9.1",
|
|
20
|
+
"typescript": "^4.9.4"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { Client } from '@botpress/client'
|
|
2
|
+
import { Bot, messages } from '@botpress/sdk'
|
|
3
|
+
import type { z } from 'zod'
|
|
4
|
+
// import * as botpress from '.botpress' /** uncomment to get generated code */
|
|
5
|
+
|
|
6
|
+
type DefaultMessages = typeof messages.defaults
|
|
7
|
+
type DefaultMessageType = keyof DefaultMessages
|
|
8
|
+
type DefaultMessagePayload<T extends DefaultMessageType> = z.infer<DefaultMessages[T]['schema']>
|
|
9
|
+
|
|
10
|
+
type CreateMessageProps = Parameters<Client['createMessage']>[0]
|
|
11
|
+
type CreateMessageBody<T extends DefaultMessageType> = Omit<CreateMessageProps, 'type' | 'payload'> & {
|
|
12
|
+
type: T
|
|
13
|
+
payload: DefaultMessagePayload<T>
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const logger = console
|
|
17
|
+
|
|
18
|
+
const bot = new Bot({
|
|
19
|
+
integrations: [],
|
|
20
|
+
configuration: {
|
|
21
|
+
schema: {},
|
|
22
|
+
},
|
|
23
|
+
states: {},
|
|
24
|
+
events: {},
|
|
25
|
+
recurringEvents: {},
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
bot.message('', async ({ message, client, ctx }) => {
|
|
29
|
+
logger.info('Received message', message)
|
|
30
|
+
|
|
31
|
+
await client.createMessage({
|
|
32
|
+
conversationId: message.conversationId,
|
|
33
|
+
userId: ctx.botId,
|
|
34
|
+
tags: {},
|
|
35
|
+
type: 'text',
|
|
36
|
+
payload: {
|
|
37
|
+
text: `You said: ${message.payload.text}`,
|
|
38
|
+
},
|
|
39
|
+
} satisfies CreateMessageBody<'text'>)
|
|
40
|
+
|
|
41
|
+
logger.info('text message sent')
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
export default bot
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "@tsconfig/node18-strictest/tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"target": "es2017",
|
|
5
|
+
"baseUrl": ".",
|
|
6
|
+
"outDir": "dist",
|
|
7
|
+
"checkJs": false,
|
|
8
|
+
"incremental": true,
|
|
9
|
+
"exactOptionalPropertyTypes": false,
|
|
10
|
+
"resolveJsonModule": true,
|
|
11
|
+
"noPropertyAccessFromIndexSignature": false,
|
|
12
|
+
"noUnusedLocals": false
|
|
13
|
+
},
|
|
14
|
+
"include": [".botpress/**/*", "src/**/*", "./*.ts", "./*.json"]
|
|
15
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/**
|
|
3
|
+
* This file was automatically generated by json-schema-to-typescript.
|
|
4
|
+
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
5
|
+
* and run json-schema-to-typescript to regenerate this file.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export interface Audio {
|
|
9
|
+
audioUrl: string;
|
|
10
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/**
|
|
3
|
+
* This file was automatically generated by json-schema-to-typescript.
|
|
4
|
+
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
5
|
+
* and run json-schema-to-typescript to regenerate this file.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export interface Card {
|
|
9
|
+
title: string;
|
|
10
|
+
subtitle?: string;
|
|
11
|
+
imageUrl?: string;
|
|
12
|
+
actions: {
|
|
13
|
+
action: "postback" | "url" | "say";
|
|
14
|
+
label: string;
|
|
15
|
+
value: string;
|
|
16
|
+
}[];
|
|
17
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/**
|
|
3
|
+
* This file was automatically generated by json-schema-to-typescript.
|
|
4
|
+
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
5
|
+
* and run json-schema-to-typescript to regenerate this file.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export interface Carousel {
|
|
9
|
+
items: {
|
|
10
|
+
title: string;
|
|
11
|
+
subtitle?: string;
|
|
12
|
+
imageUrl?: string;
|
|
13
|
+
actions: {
|
|
14
|
+
action: "postback" | "url" | "say";
|
|
15
|
+
label: string;
|
|
16
|
+
value: string;
|
|
17
|
+
}[];
|
|
18
|
+
}[];
|
|
19
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/**
|
|
3
|
+
* This file was automatically generated by json-schema-to-typescript.
|
|
4
|
+
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
5
|
+
* and run json-schema-to-typescript to regenerate this file.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export interface Choice {
|
|
9
|
+
text: string;
|
|
10
|
+
options: {
|
|
11
|
+
label: string;
|
|
12
|
+
value: string;
|
|
13
|
+
}[];
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/**
|
|
3
|
+
* This file was automatically generated by json-schema-to-typescript.
|
|
4
|
+
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
5
|
+
* and run json-schema-to-typescript to regenerate this file.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export interface Dropdown {
|
|
9
|
+
text: string;
|
|
10
|
+
options: {
|
|
11
|
+
label: string;
|
|
12
|
+
value: string;
|
|
13
|
+
}[];
|
|
14
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/**
|
|
3
|
+
* This file was automatically generated by json-schema-to-typescript.
|
|
4
|
+
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
5
|
+
* and run json-schema-to-typescript to regenerate this file.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export interface File {
|
|
9
|
+
fileUrl: string;
|
|
10
|
+
title?: string;
|
|
11
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/**
|
|
3
|
+
* This file was automatically generated by json-schema-to-typescript.
|
|
4
|
+
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
5
|
+
* and run json-schema-to-typescript to regenerate this file.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export interface Image {
|
|
9
|
+
imageUrl: string;
|
|
10
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
// This file is generated
|
|
3
|
+
// Do not edit this file
|
|
4
|
+
|
|
5
|
+
import type * as text from "./text";
|
|
6
|
+
export * as text from "./text";
|
|
7
|
+
import type * as markdown from "./markdown";
|
|
8
|
+
export * as markdown from "./markdown";
|
|
9
|
+
import type * as image from "./image";
|
|
10
|
+
export * as image from "./image";
|
|
11
|
+
import type * as audio from "./audio";
|
|
12
|
+
export * as audio from "./audio";
|
|
13
|
+
import type * as video from "./video";
|
|
14
|
+
export * as video from "./video";
|
|
15
|
+
import type * as file from "./file";
|
|
16
|
+
export * as file from "./file";
|
|
17
|
+
import type * as location from "./location";
|
|
18
|
+
export * as location from "./location";
|
|
19
|
+
import type * as carousel from "./carousel";
|
|
20
|
+
export * as carousel from "./carousel";
|
|
21
|
+
import type * as card from "./card";
|
|
22
|
+
export * as card from "./card";
|
|
23
|
+
import type * as dropdown from "./dropdown";
|
|
24
|
+
export * as dropdown from "./dropdown";
|
|
25
|
+
import type * as choice from "./choice";
|
|
26
|
+
export * as choice from "./choice";
|
|
27
|
+
|
|
28
|
+
export type ChannelChannel = {
|
|
29
|
+
text: text.Text;
|
|
30
|
+
markdown: markdown.Markdown;
|
|
31
|
+
image: image.Image;
|
|
32
|
+
audio: audio.Audio;
|
|
33
|
+
video: video.Video;
|
|
34
|
+
file: file.File;
|
|
35
|
+
location: location.Location;
|
|
36
|
+
carousel: carousel.Carousel;
|
|
37
|
+
card: card.Card;
|
|
38
|
+
dropdown: dropdown.Dropdown;
|
|
39
|
+
choice: choice.Choice;
|
|
40
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/**
|
|
3
|
+
* This file was automatically generated by json-schema-to-typescript.
|
|
4
|
+
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
5
|
+
* and run json-schema-to-typescript to regenerate this file.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export interface Location {
|
|
9
|
+
latitude: number;
|
|
10
|
+
longitude: number;
|
|
11
|
+
}
|