@botpress/cli 0.0.2
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/build.ts +12 -0
- package/dist/app/api-utils.js +105 -0
- package/dist/app/base.js +35 -0
- package/dist/app/cache.js +95 -0
- package/dist/app/errors.js +145 -0
- package/dist/app/esbuild.js +89 -0
- package/dist/app/generator/action.js +76 -0
- package/dist/app/generator/channel.js +51 -0
- package/dist/app/generator/configuration.js +40 -0
- package/dist/app/generator/const.js +31 -0
- package/dist/app/generator/event.js +47 -0
- package/dist/app/generator/index.js +83 -0
- package/dist/app/generator/integration-impl.js +147 -0
- package/dist/app/generator/integration-instance.js +85 -0
- package/dist/app/generator/message.js +47 -0
- package/dist/app/generator/module.js +115 -0
- package/dist/app/generator/strings.js +38 -0
- package/dist/app/generator/typings.js +16 -0
- package/dist/app/index.js +68 -0
- package/dist/app/integration-ref.js +61 -0
- package/dist/app/project.js +502 -0
- package/dist/app/typings.js +16 -0
- package/dist/app/user.js +198 -0
- package/dist/config.js +245 -0
- package/dist/const.js +87 -0
- package/dist/index.js +276 -0
- package/dist/index.js.map +7 -0
- package/dist/init.js +45 -0
- package/dist/init.js.map +7 -0
- package/dist/logger/base-logger.js +159 -0
- package/dist/logger/index.js +79 -0
- package/dist/paths.js +69 -0
- package/dist/requires.js +49 -0
- package/dist/type-utils.js +16 -0
- package/dist/worker/child-entrypoint.js +61 -0
- package/dist/worker/config.js +58 -0
- package/dist/worker/index.js +55 -0
- package/dist/worker/is-child.js +52 -0
- package/dist/worker/listen-child.js +89 -0
- package/init.js +1 -0
- package/package.json +54 -0
- package/readme.md +24 -0
package/build.ts
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
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 api_utils_exports = {};
|
|
26
|
+
__export(api_utils_exports, {
|
|
27
|
+
ApiUtils: () => ApiUtils
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(api_utils_exports);
|
|
30
|
+
var import_lodash = __toESM(require("lodash"));
|
|
31
|
+
var errors = __toESM(require("./errors"));
|
|
32
|
+
var import_integration_ref = require("./integration-ref");
|
|
33
|
+
class ApiUtils {
|
|
34
|
+
constructor(client, host, token, workspaceId, _logger) {
|
|
35
|
+
this.client = client;
|
|
36
|
+
this.host = host;
|
|
37
|
+
this.token = token;
|
|
38
|
+
this.workspaceId = workspaceId;
|
|
39
|
+
this._logger = _logger;
|
|
40
|
+
}
|
|
41
|
+
async findIntegration(ref) {
|
|
42
|
+
const formatted = (0, import_integration_ref.formatIntegrationRef)(ref);
|
|
43
|
+
const privateIntegration = await this.findPrivateIntegration(ref);
|
|
44
|
+
if (privateIntegration) {
|
|
45
|
+
this._logger.debug(`Found integration "${formatted}" in workspace`);
|
|
46
|
+
return privateIntegration;
|
|
47
|
+
}
|
|
48
|
+
const publicIntegration = await this.findPublicIntegration(ref);
|
|
49
|
+
if (publicIntegration) {
|
|
50
|
+
this._logger.debug(`Found integration "${formatted}" in hub`);
|
|
51
|
+
return publicIntegration;
|
|
52
|
+
}
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
async findPrivateIntegration(ref) {
|
|
56
|
+
if (ref.type === "id") {
|
|
57
|
+
return this.validateStatus(() => this.client.getIntegration(ref).then((r) => r.integration), [404, 500]);
|
|
58
|
+
}
|
|
59
|
+
return this.validateStatus(() => this.client.getIntegrationByName(ref).then((r) => r.integration), [404, 500]);
|
|
60
|
+
}
|
|
61
|
+
async findPublicIntegration(ref) {
|
|
62
|
+
if (ref.type === "id") {
|
|
63
|
+
return this.validateStatus(() => this.client.getPublicIntegrationById(ref).then((r) => r.integration), [404, 500]);
|
|
64
|
+
}
|
|
65
|
+
return this.validateStatus(() => this.client.getPublicIntegration(ref).then((r) => r.integration), [404, 500]);
|
|
66
|
+
}
|
|
67
|
+
async testLogin() {
|
|
68
|
+
try {
|
|
69
|
+
await this.client.listBots({});
|
|
70
|
+
} catch (thrown) {
|
|
71
|
+
throw errors.BotpressCLIError.wrap(thrown, "Authentication failed. Please check your credentials");
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
async listAllPages(lister, key) {
|
|
75
|
+
let nextToken;
|
|
76
|
+
const all = [];
|
|
77
|
+
do {
|
|
78
|
+
const { meta, ...r } = await lister({ nextToken });
|
|
79
|
+
all.push(r);
|
|
80
|
+
nextToken = meta.nextToken;
|
|
81
|
+
} while (nextToken);
|
|
82
|
+
if (!key) {
|
|
83
|
+
return all;
|
|
84
|
+
}
|
|
85
|
+
return all.flatMap((r) => r[key]);
|
|
86
|
+
}
|
|
87
|
+
async validateStatus(fn, allowedStatuses) {
|
|
88
|
+
try {
|
|
89
|
+
const v = await fn();
|
|
90
|
+
return v;
|
|
91
|
+
} catch (thrown) {
|
|
92
|
+
const err = errors.mapThrown(thrown);
|
|
93
|
+
const allowedStatusesArray = import_lodash.default.isArray(allowedStatuses) ? allowedStatuses : [allowedStatuses];
|
|
94
|
+
const isAllowed = err instanceof errors.HTTPError && err.status && allowedStatusesArray.includes(err.status);
|
|
95
|
+
if (isAllowed) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
throw err;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
103
|
+
0 && (module.exports = {
|
|
104
|
+
ApiUtils
|
|
105
|
+
});
|
package/dist/app/base.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
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 base_exports = {};
|
|
20
|
+
__export(base_exports, {
|
|
21
|
+
BaseCommands: () => BaseCommands
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(base_exports);
|
|
24
|
+
class BaseCommands {
|
|
25
|
+
constructor(_logger) {
|
|
26
|
+
this._logger = _logger;
|
|
27
|
+
}
|
|
28
|
+
teardown() {
|
|
29
|
+
this._logger.cleanup();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
33
|
+
0 && (module.exports = {
|
|
34
|
+
BaseCommands
|
|
35
|
+
});
|
|
@@ -0,0 +1,95 @@
|
|
|
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 cache_exports = {};
|
|
26
|
+
__export(cache_exports, {
|
|
27
|
+
FSConfigCache: () => FSConfigCache
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(cache_exports);
|
|
30
|
+
var import_fs = __toESM(require("fs"));
|
|
31
|
+
var import_path = __toESM(require("path"));
|
|
32
|
+
class FSConfigCache {
|
|
33
|
+
constructor(_filepath) {
|
|
34
|
+
this._filepath = _filepath;
|
|
35
|
+
}
|
|
36
|
+
static async loadFrom(filepath) {
|
|
37
|
+
const dirname = import_path.default.dirname(filepath);
|
|
38
|
+
if (!import_fs.default.existsSync(dirname)) {
|
|
39
|
+
await import_fs.default.promises.mkdir(dirname, { recursive: true });
|
|
40
|
+
}
|
|
41
|
+
if (!import_fs.default.existsSync(filepath)) {
|
|
42
|
+
await this._writeJSON(filepath, {});
|
|
43
|
+
}
|
|
44
|
+
return new FSConfigCache(filepath);
|
|
45
|
+
}
|
|
46
|
+
static _writeJSON = (filepath, data) => {
|
|
47
|
+
const fileContent = JSON.stringify(data, null, 2);
|
|
48
|
+
return import_fs.default.promises.writeFile(filepath, fileContent);
|
|
49
|
+
};
|
|
50
|
+
static _readJSON = async (filepath) => {
|
|
51
|
+
const fileContent = await import_fs.default.promises.readFile(filepath, "utf8");
|
|
52
|
+
return JSON.parse(fileContent);
|
|
53
|
+
};
|
|
54
|
+
async sync(key, value, prompt) {
|
|
55
|
+
if (value) {
|
|
56
|
+
await this.set(key, value);
|
|
57
|
+
return value;
|
|
58
|
+
}
|
|
59
|
+
const data = await this.get(key);
|
|
60
|
+
const newValue = await prompt(data);
|
|
61
|
+
await this.set(key, newValue);
|
|
62
|
+
return newValue;
|
|
63
|
+
}
|
|
64
|
+
async has(key) {
|
|
65
|
+
const data = await FSConfigCache._readJSON(this._filepath);
|
|
66
|
+
return data[key] !== void 0;
|
|
67
|
+
}
|
|
68
|
+
async get(key) {
|
|
69
|
+
const data = await FSConfigCache._readJSON(this._filepath);
|
|
70
|
+
return data[key];
|
|
71
|
+
}
|
|
72
|
+
async set(key, value) {
|
|
73
|
+
const data = await FSConfigCache._readJSON(this._filepath);
|
|
74
|
+
data[key] = value;
|
|
75
|
+
return FSConfigCache._writeJSON(this._filepath, data);
|
|
76
|
+
}
|
|
77
|
+
async rm(key) {
|
|
78
|
+
const data = await FSConfigCache._readJSON(this._filepath);
|
|
79
|
+
delete data[key];
|
|
80
|
+
return FSConfigCache._writeJSON(this._filepath, data);
|
|
81
|
+
}
|
|
82
|
+
async clear() {
|
|
83
|
+
return FSConfigCache._writeJSON(this._filepath, {});
|
|
84
|
+
}
|
|
85
|
+
async nuke() {
|
|
86
|
+
if (!import_fs.default.existsSync(this._filepath)) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
import_fs.default.unlinkSync(this._filepath);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
93
|
+
0 && (module.exports = {
|
|
94
|
+
FSConfigCache
|
|
95
|
+
});
|
|
@@ -0,0 +1,145 @@
|
|
|
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
|
+
NotLoggedInError: () => NotLoggedInError,
|
|
35
|
+
ParamRequiredError: () => ParamRequiredError,
|
|
36
|
+
mapThrown: () => mapThrown
|
|
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("../const"));
|
|
43
|
+
const mapThrown = (thrown) => {
|
|
44
|
+
if ((0, import_client.isApiError)(thrown)) {
|
|
45
|
+
return HTTPError.fromApi(thrown);
|
|
46
|
+
}
|
|
47
|
+
if (import_axios.default.isAxiosError(thrown)) {
|
|
48
|
+
return HTTPError.fromAxios(thrown);
|
|
49
|
+
}
|
|
50
|
+
if (thrown instanceof Error) {
|
|
51
|
+
return thrown;
|
|
52
|
+
}
|
|
53
|
+
return new BotpressCLIError(`${thrown}`);
|
|
54
|
+
};
|
|
55
|
+
class BotpressCLIError extends import_verror.VError {
|
|
56
|
+
static wrap(thrown, message) {
|
|
57
|
+
const err = mapThrown(thrown);
|
|
58
|
+
return new BotpressCLIError(err, message);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
class ExclusiveBotFeatureError extends BotpressCLIError {
|
|
62
|
+
constructor() {
|
|
63
|
+
const message = "This feature is only available for bots. This project is an integration";
|
|
64
|
+
super(message);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
class ExclusiveIntegrationFeatureError extends BotpressCLIError {
|
|
68
|
+
constructor() {
|
|
69
|
+
const message = "This feature is only available for integration. This project is a bot";
|
|
70
|
+
super(message);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
class HTTPError extends BotpressCLIError {
|
|
74
|
+
constructor(status, message) {
|
|
75
|
+
super(message);
|
|
76
|
+
this.status = status;
|
|
77
|
+
}
|
|
78
|
+
static fromAxios(e) {
|
|
79
|
+
const message = this._axiosMsg(e);
|
|
80
|
+
return new HTTPError(e.response?.status, message);
|
|
81
|
+
}
|
|
82
|
+
static fromApi(e) {
|
|
83
|
+
const { message, code } = e;
|
|
84
|
+
return new HTTPError(code, message);
|
|
85
|
+
}
|
|
86
|
+
static _axiosMsg(e) {
|
|
87
|
+
let message = e.message;
|
|
88
|
+
if (e.response?.statusText) {
|
|
89
|
+
message += `
|
|
90
|
+
${e.response?.statusText}`;
|
|
91
|
+
}
|
|
92
|
+
if (e.response?.status && e.request?.method && e.request?.path) {
|
|
93
|
+
message += `
|
|
94
|
+
(${e.response?.status}) ${e.request.method} ${e.request.path}`;
|
|
95
|
+
}
|
|
96
|
+
if (e.response?.data?.message) {
|
|
97
|
+
message += `
|
|
98
|
+
${e.response?.data?.message}`;
|
|
99
|
+
}
|
|
100
|
+
return message;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
class NoBundleFoundError extends BotpressCLIError {
|
|
104
|
+
constructor() {
|
|
105
|
+
const message = "No bundle found. Please run `bp bundle` first.";
|
|
106
|
+
super(message);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
class NoBotsFoundError extends BotpressCLIError {
|
|
110
|
+
constructor() {
|
|
111
|
+
const message = `No Bot found in your Workspace. Please create one first at ${consts.defaultBotpressApp}.`;
|
|
112
|
+
super(message);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
class NotLoggedInError extends BotpressCLIError {
|
|
116
|
+
constructor() {
|
|
117
|
+
const message = "Not logged in. Please run `bp login` first.";
|
|
118
|
+
super(message);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
class ParamRequiredError extends BotpressCLIError {
|
|
122
|
+
constructor(param) {
|
|
123
|
+
const message = `${param} is required.`;
|
|
124
|
+
super(message);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
class InvalidIntegrationReferenceError extends BotpressCLIError {
|
|
128
|
+
constructor(ref) {
|
|
129
|
+
const message = `Invalid integration reference "${ref}".`;
|
|
130
|
+
super(message);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
134
|
+
0 && (module.exports = {
|
|
135
|
+
BotpressCLIError,
|
|
136
|
+
ExclusiveBotFeatureError,
|
|
137
|
+
ExclusiveIntegrationFeatureError,
|
|
138
|
+
HTTPError,
|
|
139
|
+
InvalidIntegrationReferenceError,
|
|
140
|
+
NoBotsFoundError,
|
|
141
|
+
NoBundleFoundError,
|
|
142
|
+
NotLoggedInError,
|
|
143
|
+
ParamRequiredError,
|
|
144
|
+
mapThrown
|
|
145
|
+
});
|
|
@@ -0,0 +1,89 @@
|
|
|
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 esbuild_exports = {};
|
|
20
|
+
__export(esbuild_exports, {
|
|
21
|
+
buildCode: () => buildCode,
|
|
22
|
+
buildEntrypoint: () => buildEntrypoint
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(esbuild_exports);
|
|
25
|
+
var import_esbuild = require("esbuild");
|
|
26
|
+
const keepNames = true;
|
|
27
|
+
function buildCode({
|
|
28
|
+
cwd,
|
|
29
|
+
minify = true,
|
|
30
|
+
bundle = true,
|
|
31
|
+
sourcemap = false,
|
|
32
|
+
logLevel = "silent",
|
|
33
|
+
outfile,
|
|
34
|
+
code,
|
|
35
|
+
write
|
|
36
|
+
}) {
|
|
37
|
+
return (0, import_esbuild.build)({
|
|
38
|
+
stdin: {
|
|
39
|
+
contents: code,
|
|
40
|
+
resolveDir: cwd,
|
|
41
|
+
loader: "ts"
|
|
42
|
+
},
|
|
43
|
+
logOverride: {
|
|
44
|
+
"equals-negative-zero": "silent"
|
|
45
|
+
},
|
|
46
|
+
platform: "node",
|
|
47
|
+
target: "es2020",
|
|
48
|
+
sourcemap,
|
|
49
|
+
minify,
|
|
50
|
+
bundle,
|
|
51
|
+
outfile,
|
|
52
|
+
absWorkingDir: cwd,
|
|
53
|
+
logLevel,
|
|
54
|
+
keepNames,
|
|
55
|
+
write
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
function buildEntrypoint({
|
|
59
|
+
cwd,
|
|
60
|
+
minify = true,
|
|
61
|
+
bundle = true,
|
|
62
|
+
sourcemap = false,
|
|
63
|
+
logLevel = "silent",
|
|
64
|
+
outfile,
|
|
65
|
+
entrypoint,
|
|
66
|
+
write
|
|
67
|
+
}) {
|
|
68
|
+
return (0, import_esbuild.build)({
|
|
69
|
+
entryPoints: [entrypoint],
|
|
70
|
+
logOverride: {
|
|
71
|
+
"equals-negative-zero": "silent"
|
|
72
|
+
},
|
|
73
|
+
platform: "node",
|
|
74
|
+
target: "es2020",
|
|
75
|
+
sourcemap,
|
|
76
|
+
minify,
|
|
77
|
+
bundle,
|
|
78
|
+
outfile,
|
|
79
|
+
absWorkingDir: cwd,
|
|
80
|
+
logLevel,
|
|
81
|
+
keepNames,
|
|
82
|
+
write
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
86
|
+
0 && (module.exports = {
|
|
87
|
+
buildCode,
|
|
88
|
+
buildEntrypoint
|
|
89
|
+
});
|
|
@@ -0,0 +1,76 @@
|
|
|
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 action_exports = {};
|
|
26
|
+
__export(action_exports, {
|
|
27
|
+
ActionInputModule: () => ActionInputModule,
|
|
28
|
+
ActionModule: () => ActionModule,
|
|
29
|
+
ActionOutputModule: () => ActionOutputModule
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(action_exports);
|
|
32
|
+
var import_json_schema_to_typescript = require("json-schema-to-typescript");
|
|
33
|
+
var import_module = require("./module");
|
|
34
|
+
var strings = __toESM(require("./strings"));
|
|
35
|
+
class ActionInputModule extends import_module.Module {
|
|
36
|
+
static async create(input) {
|
|
37
|
+
const schema = input.schema ?? {};
|
|
38
|
+
const filename = "input.ts";
|
|
39
|
+
const def = {
|
|
40
|
+
path: filename,
|
|
41
|
+
exportName: "Input",
|
|
42
|
+
content: await (0, import_json_schema_to_typescript.compile)(schema, filename)
|
|
43
|
+
};
|
|
44
|
+
return new ActionInputModule(def);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
class ActionOutputModule extends import_module.Module {
|
|
48
|
+
static async create(output) {
|
|
49
|
+
const schema = output.schema ?? {};
|
|
50
|
+
const filename = "output.ts";
|
|
51
|
+
const def = {
|
|
52
|
+
path: filename,
|
|
53
|
+
exportName: "Output",
|
|
54
|
+
content: await (0, import_json_schema_to_typescript.compile)(schema, filename)
|
|
55
|
+
};
|
|
56
|
+
return new ActionOutputModule(def);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
class ActionModule extends import_module.ReExportModule {
|
|
60
|
+
static async create(actionName, action) {
|
|
61
|
+
const inputModule = await ActionInputModule.create(action.input ?? {});
|
|
62
|
+
const outputModule = await ActionOutputModule.create(action.output ?? {});
|
|
63
|
+
const inst = new ActionModule({
|
|
64
|
+
exportName: `Action${strings.pascalCase(actionName)}`
|
|
65
|
+
});
|
|
66
|
+
inst.pushDep(inputModule);
|
|
67
|
+
inst.pushDep(outputModule);
|
|
68
|
+
return inst;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
72
|
+
0 && (module.exports = {
|
|
73
|
+
ActionInputModule,
|
|
74
|
+
ActionModule,
|
|
75
|
+
ActionOutputModule
|
|
76
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
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 channel_exports = {};
|
|
26
|
+
__export(channel_exports, {
|
|
27
|
+
ChannelModule: () => ChannelModule
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(channel_exports);
|
|
30
|
+
var import_bluebird = __toESM(require("bluebird"));
|
|
31
|
+
var import_message = require("./message");
|
|
32
|
+
var import_module = require("./module");
|
|
33
|
+
var strings = __toESM(require("./strings"));
|
|
34
|
+
class ChannelModule extends import_module.ReExportModule {
|
|
35
|
+
static async create(channelName, channel) {
|
|
36
|
+
const messages = channel.messages ?? {};
|
|
37
|
+
const messageModules = await import_bluebird.default.map(
|
|
38
|
+
Object.entries(messages),
|
|
39
|
+
([messageName, message]) => import_message.MessageModule.create(messageName, message)
|
|
40
|
+
);
|
|
41
|
+
const inst = new ChannelModule({
|
|
42
|
+
exportName: `Channel${strings.pascalCase(channelName)}`
|
|
43
|
+
});
|
|
44
|
+
inst.pushDep(...messageModules);
|
|
45
|
+
return inst;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
49
|
+
0 && (module.exports = {
|
|
50
|
+
ChannelModule
|
|
51
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
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 configuration_exports = {};
|
|
20
|
+
__export(configuration_exports, {
|
|
21
|
+
ConfigurationModule: () => ConfigurationModule
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(configuration_exports);
|
|
24
|
+
var import_json_schema_to_typescript = require("json-schema-to-typescript");
|
|
25
|
+
var import_module = require("./module");
|
|
26
|
+
class ConfigurationModule extends import_module.Module {
|
|
27
|
+
static async create(configuration) {
|
|
28
|
+
const schema = configuration.schema ?? {};
|
|
29
|
+
const filename = "configuration";
|
|
30
|
+
return new ConfigurationModule({
|
|
31
|
+
path: `${filename}.ts`,
|
|
32
|
+
exportName: "Configuration",
|
|
33
|
+
content: await (0, import_json_schema_to_typescript.compile)(schema, filename)
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
+
0 && (module.exports = {
|
|
39
|
+
ConfigurationModule
|
|
40
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
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 const_exports = {};
|
|
20
|
+
__export(const_exports, {
|
|
21
|
+
GENERATED_HEADER: () => GENERATED_HEADER,
|
|
22
|
+
INDEX_FILE: () => INDEX_FILE
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(const_exports);
|
|
25
|
+
const GENERATED_HEADER = "/* tslint:disable */\n// This file is generated\n// Do not edit this file\n\n";
|
|
26
|
+
const INDEX_FILE = "index.ts";
|
|
27
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
+
0 && (module.exports = {
|
|
29
|
+
GENERATED_HEADER,
|
|
30
|
+
INDEX_FILE
|
|
31
|
+
});
|