@botpress/cli 1.2.2 → 1.3.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/.turbo/turbo-build.log +10 -10
- package/dist/command-implementations/lint-command.js +33 -2
- package/dist/command-implementations/lint-command.js.map +2 -2
- package/dist/linter/base-linter.js +75 -0
- package/dist/linter/base-linter.js.map +7 -0
- package/dist/linter/{integration-linter.test.js → base-linter.test.js} +1 -1
- package/dist/linter/base-linter.test.js.map +7 -0
- package/dist/linter/bot-linter.js +35 -0
- package/dist/linter/bot-linter.js.map +7 -0
- package/dist/linter/integration-linter.js +3 -44
- package/dist/linter/integration-linter.js.map +3 -3
- package/dist/linter/interface-linter.js +35 -0
- package/dist/linter/interface-linter.js.map +7 -0
- package/dist/linter/ruleset-tests/bot.ruleset.test.js +356 -0
- package/dist/linter/ruleset-tests/bot.ruleset.test.js.map +7 -0
- package/dist/linter/ruleset-tests/common.js +37 -0
- package/dist/linter/ruleset-tests/common.js.map +7 -0
- package/dist/linter/{rulesets → ruleset-tests}/integration.ruleset.test.js +75 -24
- package/dist/linter/ruleset-tests/integration.ruleset.test.js.map +7 -0
- package/dist/linter/ruleset-tests/interface.ruleset.test.js +391 -0
- package/dist/linter/ruleset-tests/interface.ruleset.test.js.map +7 -0
- package/dist/linter/rulesets/bot.ruleset.js +191 -0
- package/dist/linter/rulesets/bot.ruleset.js.map +7 -0
- package/dist/linter/rulesets/integration.ruleset.js +12 -0
- package/dist/linter/rulesets/integration.ruleset.js.map +2 -2
- package/dist/linter/rulesets/interface.ruleset.js +157 -0
- package/dist/linter/rulesets/interface.ruleset.js.map +7 -0
- package/dist/utils/path-utils.test.js +2 -3
- package/dist/utils/path-utils.test.js.map +2 -2
- package/dist/utils/schema-utils.test.js +1 -2
- package/dist/utils/schema-utils.test.js.map +2 -2
- package/package.json +3 -3
- package/templates/empty-bot/package.json +2 -2
- package/templates/empty-integration/package.json +2 -2
- package/templates/hello-world/package.json +2 -2
- package/templates/webhook-message/package.json +2 -2
- package/dist/linter/integration-linter.test.js.map +0 -7
- package/dist/linter/rulesets/integration.ruleset.test.js.map +0 -7
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
|
|
2
|
-
> @botpress/cli@1.
|
|
2
|
+
> @botpress/cli@1.3.0 build /home/runner/work/botpress/botpress/packages/cli
|
|
3
3
|
> pnpm run bundle && pnpm run template:gen
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
> @botpress/cli@1.
|
|
6
|
+
> @botpress/cli@1.3.0 bundle /home/runner/work/botpress/botpress/packages/cli
|
|
7
7
|
> ts-node -T build.ts
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
> @botpress/cli@1.
|
|
10
|
+
> @botpress/cli@1.3.0 template:gen /home/runner/work/botpress/botpress/packages/cli
|
|
11
11
|
> pnpm -r --stream -F @bp-templates/* exec bp gen
|
|
12
12
|
|
|
13
|
-
🤖 Botpress CLI v1.
|
|
14
|
-
🤖 Botpress CLI v1.
|
|
15
|
-
🤖 Botpress CLI v1.
|
|
16
|
-
🤖 Botpress CLI v1.
|
|
17
|
-
[2K[1G○ Generating typings for bot...[2K[1G
|
|
18
|
-
[2K[1G○ Generating typings for integration empty-integration...[2K[1G✓ Typings available at .botpress
|
|
19
|
-
[2K[1G○ Generating typings for integration
|
|
13
|
+
🤖 Botpress CLI v1.3.0
|
|
14
|
+
🤖 Botpress CLI v1.3.0
|
|
15
|
+
🤖 Botpress CLI v1.3.0
|
|
16
|
+
🤖 Botpress CLI v1.3.0
|
|
17
|
+
[2K[1G○ Generating typings for bot...[2K[1G✓ Typings available at .botpress
|
|
18
|
+
[2K[1G○ Generating typings for integration webhook-message...[2K[1G○ Generating typings for integration empty-integration...[2K[1G✓ Typings available at .botpress
|
|
19
|
+
[2K[1G○ Generating typings for integration hello-world...[2K[1G✓ Typings available at .botpress
|
|
20
20
|
[2K[1G✓ Typings available at .botpress
|
|
@@ -27,9 +27,13 @@ __export(lint_command_exports, {
|
|
|
27
27
|
LintCommand: () => LintCommand
|
|
28
28
|
});
|
|
29
29
|
module.exports = __toCommonJS(lint_command_exports);
|
|
30
|
+
var import_bot_body = require("../api/bot-body");
|
|
30
31
|
var import_integration_body = require("../api/integration-body");
|
|
32
|
+
var import_interface_body = require("../api/interface-body");
|
|
31
33
|
var errors = __toESM(require("../errors"));
|
|
34
|
+
var import_bot_linter = require("../linter/bot-linter");
|
|
32
35
|
var import_integration_linter = require("../linter/integration-linter");
|
|
36
|
+
var import_interface_linter = require("../linter/interface-linter");
|
|
33
37
|
var import_sdk2 = require("../sdk");
|
|
34
38
|
var import_project_command = require("./project-command");
|
|
35
39
|
class LintCommand extends import_project_command.ProjectCommand {
|
|
@@ -39,13 +43,40 @@ class LintCommand extends import_project_command.ProjectCommand {
|
|
|
39
43
|
case "integration":
|
|
40
44
|
return this._runLintForIntegration(projectDef.definition);
|
|
41
45
|
case "bot":
|
|
42
|
-
|
|
46
|
+
return this._runLintForBot(projectDef.definition);
|
|
43
47
|
case "interface":
|
|
44
|
-
|
|
48
|
+
return this._runLintForInterface(projectDef.definition);
|
|
45
49
|
default:
|
|
46
50
|
throw new errors.BotpressCLIError("Unsupported project type");
|
|
47
51
|
}
|
|
48
52
|
}
|
|
53
|
+
async _runLintForInterface(definition) {
|
|
54
|
+
const parsedInterfaceDefinition = await (0, import_interface_body.prepareCreateInterfaceBody)(definition);
|
|
55
|
+
const linter = new import_interface_linter.InterfaceLinter(parsedInterfaceDefinition);
|
|
56
|
+
await linter.lint();
|
|
57
|
+
linter.logResults(this.logger);
|
|
58
|
+
if (linter.hasErrors()) {
|
|
59
|
+
throw new errors.BotpressCLIError("Interface definition contains linting errors");
|
|
60
|
+
}
|
|
61
|
+
this.logger.success("Interface definition is valid");
|
|
62
|
+
}
|
|
63
|
+
async _runLintForBot(definition) {
|
|
64
|
+
const strippedDefinition = this._stripAutoGeneratedContentFromBot(definition);
|
|
65
|
+
const parsedBotDefinition = await (0, import_bot_body.prepareCreateBotBody)(strippedDefinition);
|
|
66
|
+
const linter = new import_bot_linter.BotLinter(parsedBotDefinition);
|
|
67
|
+
await linter.lint();
|
|
68
|
+
linter.logResults(this.logger);
|
|
69
|
+
if (linter.hasErrors()) {
|
|
70
|
+
throw new errors.BotpressCLIError("Bot definition contains linting errors");
|
|
71
|
+
}
|
|
72
|
+
this.logger.success("Bot definition is valid");
|
|
73
|
+
}
|
|
74
|
+
_stripAutoGeneratedContentFromBot(definition) {
|
|
75
|
+
return {
|
|
76
|
+
...definition,
|
|
77
|
+
integrations: {}
|
|
78
|
+
};
|
|
79
|
+
}
|
|
49
80
|
async _runLintForIntegration(definition) {
|
|
50
81
|
const strippedDefinition = this._stripAutoGeneratedContentFromIntegration(definition);
|
|
51
82
|
const parsedIntegrationDefinition = await (0, import_integration_body.prepareCreateIntegrationBody)(strippedDefinition);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/command-implementations/lint-command.ts"],
|
|
4
|
-
"sourcesContent": ["import { IntegrationDefinition } from '@botpress/sdk'\nimport { prepareCreateIntegrationBody } from '../api/integration-body'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport { IntegrationLinter } from '../linter/integration-linter'\nimport { getImplementationStatements } from '../sdk'\nimport { ProjectCommand } from './project-command'\n\nexport type LintCommandDefinition = typeof commandDefinitions.lint\nexport class LintCommand extends ProjectCommand<LintCommandDefinition> {\n public async run(): Promise<void> {\n const projectDef = await this.readProjectDefinitionFromFS()\n\n switch (projectDef.type) {\n case 'integration':\n return this._runLintForIntegration(projectDef.definition)\n case 'bot':\n throw new errors.BotpressCLIError('
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,8BAA6C;
|
|
4
|
+
"sourcesContent": ["import { type IntegrationDefinition, type BotDefinition, type InterfaceDeclaration } from '@botpress/sdk'\nimport { prepareCreateBotBody } from '../api/bot-body'\nimport { prepareCreateIntegrationBody } from '../api/integration-body'\nimport { prepareCreateInterfaceBody } from '../api/interface-body'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport { BotLinter } from '../linter/bot-linter'\nimport { IntegrationLinter } from '../linter/integration-linter'\nimport { InterfaceLinter } from '../linter/interface-linter'\nimport { getImplementationStatements } from '../sdk'\nimport { ProjectCommand } from './project-command'\n\nexport type LintCommandDefinition = typeof commandDefinitions.lint\nexport class LintCommand extends ProjectCommand<LintCommandDefinition> {\n public async run(): Promise<void> {\n const projectDef = await this.readProjectDefinitionFromFS()\n\n switch (projectDef.type) {\n case 'integration':\n return this._runLintForIntegration(projectDef.definition)\n case 'bot':\n return this._runLintForBot(projectDef.definition)\n case 'interface':\n return this._runLintForInterface(projectDef.definition)\n default:\n throw new errors.BotpressCLIError('Unsupported project type')\n }\n }\n\n private async _runLintForInterface(definition: InterfaceDeclaration): Promise<void> {\n const parsedInterfaceDefinition = await prepareCreateInterfaceBody(definition)\n const linter = new InterfaceLinter(parsedInterfaceDefinition)\n\n await linter.lint()\n linter.logResults(this.logger)\n\n if (linter.hasErrors()) {\n throw new errors.BotpressCLIError('Interface definition contains linting errors')\n }\n\n this.logger.success('Interface definition is valid')\n }\n\n private async _runLintForBot(definition: BotDefinition): Promise<void> {\n const strippedDefinition = this._stripAutoGeneratedContentFromBot(definition)\n const parsedBotDefinition = await prepareCreateBotBody(strippedDefinition)\n const linter = new BotLinter(parsedBotDefinition)\n\n await linter.lint()\n linter.logResults(this.logger)\n\n if (linter.hasErrors()) {\n throw new errors.BotpressCLIError('Bot definition contains linting errors')\n }\n\n this.logger.success('Bot definition is valid')\n }\n\n private _stripAutoGeneratedContentFromBot(definition: BotDefinition) {\n return {\n ...definition,\n integrations: {},\n } as BotDefinition\n }\n\n private async _runLintForIntegration(definition: IntegrationDefinition): Promise<void> {\n const strippedDefinition = this._stripAutoGeneratedContentFromIntegration(definition)\n const parsedIntegrationDefinition = await prepareCreateIntegrationBody(strippedDefinition)\n const linter = new IntegrationLinter({ ...parsedIntegrationDefinition, secrets: strippedDefinition.secrets })\n\n await linter.lint()\n linter.logResults(this.logger)\n\n if (linter.hasErrors()) {\n throw new errors.BotpressCLIError('Integration definition contains linting errors')\n }\n\n this.logger.success('Integration definition is valid')\n }\n\n private _stripAutoGeneratedContentFromIntegration(definition: IntegrationDefinition) {\n const { actionNames, eventNames } = this._getAutoGeneratedContentOfIntegration(definition)\n\n return {\n ...definition,\n actions: Object.fromEntries(Object.entries(definition.actions ?? {}).filter(([key]) => !actionNames.has(key))),\n events: Object.fromEntries(Object.entries(definition.events ?? {}).filter(([key]) => !eventNames.has(key))),\n } as IntegrationDefinition\n }\n\n private _getAutoGeneratedContentOfIntegration(definition: IntegrationDefinition) {\n const actionNames = new Set<string>()\n const eventNames = new Set<string>()\n\n const interfacesStatements = getImplementationStatements(definition)\n for (const iface of Object.values(interfacesStatements)) {\n for (const actionDefinition of Object.values(iface.actions)) {\n actionNames.add(actionDefinition.name)\n }\n for (const eventDefinition of Object.values(iface.events)) {\n eventNames.add(eventDefinition.name)\n }\n }\n\n return { actionNames, eventNames } as const\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAqC;AACrC,8BAA6C;AAC7C,4BAA2C;AAE3C,aAAwB;AACxB,wBAA0B;AAC1B,gCAAkC;AAClC,8BAAgC;AAChC,IAAAA,cAA4C;AAC5C,6BAA+B;AAGxB,MAAM,oBAAoB,sCAAsC;AAAA,EACrE,MAAa,MAAqB;AAChC,UAAM,aAAa,MAAM,KAAK,4BAA4B;AAE1D,YAAQ,WAAW,MAAM;AAAA,MACvB,KAAK;AACH,eAAO,KAAK,uBAAuB,WAAW,UAAU;AAAA,MAC1D,KAAK;AACH,eAAO,KAAK,eAAe,WAAW,UAAU;AAAA,MAClD,KAAK;AACH,eAAO,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D;AAAA,EAEQ,0CAA0C,YAAmC;AACnF,UAAM,EAAE,aAAa,WAAW,IAAI,KAAK,sCAAsC,UAAU;AAEzF,WAAO;AAAA,MACL,GAAG;AAAA,MACH,SAAS,OAAO,YAAY,OAAO,QAAQ,WAAW,WAAW,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,GAAG,MAAM,CAAC,YAAY,IAAI,GAAG,CAAC,CAAC;AAAA,MAC7G,QAAQ,OAAO,YAAY,OAAO,QAAQ,WAAW,UAAU,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,GAAG,MAAM,CAAC,WAAW,IAAI,GAAG,CAAC,CAAC;AAAA,IAC5G;AAAA,EACF;AAAA,EAEQ,sCAAsC,YAAmC;AAC/E,UAAM,cAAc,oBAAI,IAAY;AACpC,UAAM,aAAa,oBAAI,IAAY;AAEnC,UAAM,2BAAuB,yCAA4B,UAAU;AACnE,eAAW,SAAS,OAAO,OAAO,oBAAoB,GAAG;AACvD,iBAAW,oBAAoB,OAAO,OAAO,MAAM,OAAO,GAAG;AAC3D,oBAAY,IAAI,iBAAiB,IAAI;AAAA,MACvC;AACA,iBAAW,mBAAmB,OAAO,OAAO,MAAM,MAAM,GAAG;AACzD,mBAAW,IAAI,gBAAgB,IAAI;AAAA,MACrC;AAAA,IACF;AAEA,WAAO,EAAE,aAAa,WAAW;AAAA,EACnC;AACF;",
|
|
6
6
|
"names": ["import_sdk"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,75 @@
|
|
|
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_linter_exports = {};
|
|
20
|
+
__export(base_linter_exports, {
|
|
21
|
+
BaseLinter: () => BaseLinter
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(base_linter_exports);
|
|
24
|
+
var import_spectral_core = require("@stoplight/spectral-core");
|
|
25
|
+
var import_spectral_parsers = require("@stoplight/spectral-parsers");
|
|
26
|
+
class BaseLinter {
|
|
27
|
+
_spectral;
|
|
28
|
+
_spectralDocument;
|
|
29
|
+
_results = [];
|
|
30
|
+
constructor(definition, ruleset) {
|
|
31
|
+
const json = JSON.stringify(definition);
|
|
32
|
+
this._spectralDocument = new import_spectral_core.Document(json, import_spectral_parsers.Json);
|
|
33
|
+
this._spectral = new import_spectral_core.Spectral();
|
|
34
|
+
this._spectral.setRuleset(ruleset);
|
|
35
|
+
}
|
|
36
|
+
async lint() {
|
|
37
|
+
this._results = await this._spectral.run(this._spectralDocument);
|
|
38
|
+
}
|
|
39
|
+
logResults(logger) {
|
|
40
|
+
for (const result of this.getSortedResults()) {
|
|
41
|
+
const message = `${result.path}: ${result.message}`;
|
|
42
|
+
this._logResultMessage(logger, message, result.severity);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
getSortedResults() {
|
|
46
|
+
return this._getResults().sort((a, b) => a.path > b.path ? 1 : a.path < b.path ? -1 : 0);
|
|
47
|
+
}
|
|
48
|
+
hasErrors() {
|
|
49
|
+
return this._results.some((result) => result.severity === 0);
|
|
50
|
+
}
|
|
51
|
+
_getResults() {
|
|
52
|
+
return this._results.map((result) => ({
|
|
53
|
+
message: result.message,
|
|
54
|
+
path: this._simplifyPath(result.path),
|
|
55
|
+
severity: result.severity
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
_simplifyPath(path) {
|
|
59
|
+
return path.join(".").replaceAll(".properties.", ".").replaceAll(".x-zui", "");
|
|
60
|
+
}
|
|
61
|
+
_logResultMessage(logger, message, severity) {
|
|
62
|
+
const logLevelMapping = {
|
|
63
|
+
0: logger.error,
|
|
64
|
+
1: logger.warn,
|
|
65
|
+
2: logger.log,
|
|
66
|
+
3: logger.debug
|
|
67
|
+
};
|
|
68
|
+
logLevelMapping[severity].call(logger, message);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
72
|
+
0 && (module.exports = {
|
|
73
|
+
BaseLinter
|
|
74
|
+
});
|
|
75
|
+
//# sourceMappingURL=base-linter.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/linter/base-linter.ts"],
|
|
4
|
+
"sourcesContent": ["import { Spectral, Document, type ISpectralDiagnostic, type RulesetDefinition } from '@stoplight/spectral-core'\nimport { Json as JsonParser, type JsonParserResult } from '@stoplight/spectral-parsers'\nimport { type Logger } from '../logger'\n\ntype ProblemSeverity = 0 | 1 | 2 | 3\n\nexport abstract class BaseLinter<TDefinition> {\n private readonly _spectral: Spectral\n private readonly _spectralDocument: Document<unknown, JsonParserResult<unknown>>\n private _results: ISpectralDiagnostic[] = []\n\n protected constructor(definition: TDefinition, ruleset: RulesetDefinition) {\n const json = JSON.stringify(definition)\n this._spectralDocument = new Document(json, JsonParser)\n this._spectral = new Spectral()\n this._spectral.setRuleset(ruleset)\n }\n\n public async lint(): Promise<void> {\n this._results = await this._spectral.run(this._spectralDocument)\n }\n\n public logResults(logger: Logger) {\n for (const result of this.getSortedResults()) {\n const message = `${result.path}: ${result.message}`\n\n this._logResultMessage(logger, message, result.severity)\n }\n }\n\n public getSortedResults() {\n return this._getResults().sort((a, b) => (a.path > b.path ? 1 : a.path < b.path ? -1 : 0))\n }\n\n public hasErrors() {\n return this._results.some((result) => result.severity === 0)\n }\n\n private _getResults() {\n return this._results.map((result) => ({\n message: result.message,\n path: this._simplifyPath(result.path),\n severity: result.severity as ProblemSeverity,\n }))\n }\n\n private _simplifyPath(path: (string | number)[]) {\n return path.join('.').replaceAll('.properties.', '.').replaceAll('.x-zui', '')\n }\n\n private _logResultMessage(logger: Logger, message: string, severity: ProblemSeverity) {\n const logLevelMapping = {\n 0: logger.error,\n 1: logger.warn,\n 2: logger.log,\n 3: logger.debug,\n } as const\n\n logLevelMapping[severity].call(logger, message)\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAAqF;AACrF,8BAA0D;AAKnD,MAAe,WAAwB;AAAA,EAC3B;AAAA,EACA;AAAA,EACT,WAAkC,CAAC;AAAA,EAEjC,YAAY,YAAyB,SAA4B;AACzE,UAAM,OAAO,KAAK,UAAU,UAAU;AACtC,SAAK,oBAAoB,IAAI,8BAAS,MAAM,wBAAAA,IAAU;AACtD,SAAK,YAAY,IAAI,8BAAS;AAC9B,SAAK,UAAU,WAAW,OAAO;AAAA,EACnC;AAAA,EAEA,MAAa,OAAsB;AACjC,SAAK,WAAW,MAAM,KAAK,UAAU,IAAI,KAAK,iBAAiB;AAAA,EACjE;AAAA,EAEO,WAAW,QAAgB;AAChC,eAAW,UAAU,KAAK,iBAAiB,GAAG;AAC5C,YAAM,UAAU,GAAG,OAAO,SAAS,OAAO;AAE1C,WAAK,kBAAkB,QAAQ,SAAS,OAAO,QAAQ;AAAA,IACzD;AAAA,EACF;AAAA,EAEO,mBAAmB;AACxB,WAAO,KAAK,YAAY,EAAE,KAAK,CAAC,GAAG,MAAO,EAAE,OAAO,EAAE,OAAO,IAAI,EAAE,OAAO,EAAE,OAAO,KAAK,CAAE;AAAA,EAC3F;AAAA,EAEO,YAAY;AACjB,WAAO,KAAK,SAAS,KAAK,CAAC,WAAW,OAAO,aAAa,CAAC;AAAA,EAC7D;AAAA,EAEQ,cAAc;AACpB,WAAO,KAAK,SAAS,IAAI,CAAC,YAAY;AAAA,MACpC,SAAS,OAAO;AAAA,MAChB,MAAM,KAAK,cAAc,OAAO,IAAI;AAAA,MACpC,UAAU,OAAO;AAAA,IACnB,EAAE;AAAA,EACJ;AAAA,EAEQ,cAAc,MAA2B;AAC/C,WAAO,KAAK,KAAK,GAAG,EAAE,WAAW,gBAAgB,GAAG,EAAE,WAAW,UAAU,EAAE;AAAA,EAC/E;AAAA,EAEQ,kBAAkB,QAAgB,SAAiB,UAA2B;AACpF,UAAM,kBAAkB;AAAA,MACtB,GAAG,OAAO;AAAA,MACV,GAAG,OAAO;AAAA,MACV,GAAG,OAAO;AAAA,MACV,GAAG,OAAO;AAAA,IACZ;AAEA,oBAAgB,UAAU,KAAK,QAAQ,OAAO;AAAA,EAChD;AACF;",
|
|
6
|
+
"names": ["JsonParser"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/linter/base-linter.test.ts"],
|
|
4
|
+
"sourcesContent": ["import { test, expect, describe, vi } from 'vitest'\nimport { prepareCreateIntegrationBody } from '../api/integration-body'\nimport { IntegrationLinter } from './integration-linter'\nimport { IntegrationDefinition, type IntegrationDefinitionProps, z } from '@botpress/sdk'\n\nconst EMPTY_STRING = ''\nconst TRUTHY_STRING = 'truthy'\nconst ACTION_NAME = 'actionName'\nconst EVENT_NAME = 'eventName'\nconst CONFIG_NAME = 'configName'\nconst PARAM_NAME = 'paramName'\nconst TAG_NAME = 'tagName'\nconst CHANNEL_NAME = 'channelName'\nconst STATE_NAME = 'stateName'\nconst MESSAGE_TYPE = 'text'\nconst SECRET_NAME = 'SECRET_NAME'\n\nconst VALID_INTEGRATION = {\n name: TRUTHY_STRING,\n title: TRUTHY_STRING,\n description: TRUTHY_STRING,\n version: TRUTHY_STRING,\n readme: TRUTHY_STRING,\n icon: TRUTHY_STRING,\n actions: {\n [ACTION_NAME]: {\n title: TRUTHY_STRING,\n description: TRUTHY_STRING,\n input: {\n schema: z\n .object({\n [PARAM_NAME]: z.string().title(TRUTHY_STRING).describe(TRUTHY_STRING),\n })\n .title(TRUTHY_STRING)\n .describe(TRUTHY_STRING),\n },\n output: {\n schema: z\n .object({\n [PARAM_NAME]: z.string().title(TRUTHY_STRING).describe(TRUTHY_STRING),\n })\n .title(TRUTHY_STRING)\n .describe(TRUTHY_STRING),\n },\n },\n },\n events: {\n [EVENT_NAME]: {\n title: TRUTHY_STRING,\n description: TRUTHY_STRING,\n schema: z\n .object({\n [PARAM_NAME]: z.string().title(TRUTHY_STRING).describe(TRUTHY_STRING),\n })\n .title(TRUTHY_STRING)\n .describe(TRUTHY_STRING),\n },\n },\n configuration: {\n schema: z\n .object({\n [PARAM_NAME]: z.string().title(TRUTHY_STRING).describe(TRUTHY_STRING),\n })\n .title(TRUTHY_STRING)\n .describe(TRUTHY_STRING),\n },\n configurations: {\n [CONFIG_NAME]: {\n title: TRUTHY_STRING,\n description: TRUTHY_STRING,\n schema: z\n .object({\n [PARAM_NAME]: z.string().title(TRUTHY_STRING).describe(TRUTHY_STRING),\n })\n .title(TRUTHY_STRING)\n .describe(TRUTHY_STRING),\n },\n },\n user: {\n tags: {\n [TAG_NAME]: {\n title: TRUTHY_STRING,\n description: TRUTHY_STRING,\n },\n },\n },\n channels: {\n [CHANNEL_NAME]: {\n title: TRUTHY_STRING,\n description: TRUTHY_STRING,\n messages: {\n [MESSAGE_TYPE]: {\n schema: z\n .object({\n [PARAM_NAME]: z.string().title(TRUTHY_STRING).describe(TRUTHY_STRING),\n })\n .title(TRUTHY_STRING)\n .describe(TRUTHY_STRING),\n },\n },\n message: {\n tags: {\n [TAG_NAME]: {\n title: TRUTHY_STRING,\n description: TRUTHY_STRING,\n },\n },\n },\n conversation: {\n tags: {\n [TAG_NAME]: {\n title: TRUTHY_STRING,\n description: TRUTHY_STRING,\n },\n },\n },\n },\n },\n states: {\n [STATE_NAME]: {\n type: 'integration',\n schema: z\n .object({\n [PARAM_NAME]: z.string().title(TRUTHY_STRING).describe(TRUTHY_STRING),\n })\n .title(TRUTHY_STRING)\n .describe(TRUTHY_STRING),\n },\n },\n secrets: {\n [SECRET_NAME]: {\n description: TRUTHY_STRING,\n },\n },\n} as const satisfies IntegrationDefinitionProps\n\nconst mockLogger = {\n log: vi.fn((message) => void message),\n warn: vi.fn((message) => void message),\n error: vi.fn((message) => void message),\n debug: vi.fn((message) => void message),\n}\n\nconst lintDefinition = async (definition: IntegrationDefinitionProps) => {\n const integrationDefinition = new IntegrationDefinition(definition)\n const integrationBody = await prepareCreateIntegrationBody(integrationDefinition)\n const linter = new IntegrationLinter({ ...integrationBody, secrets: integrationDefinition.secrets })\n await linter.lint()\n return linter\n}\n\nconst lintDefinitionAndReturnResults = async (definition: IntegrationDefinitionProps) => {\n const linter = await lintDefinition(definition)\n return linter.getSortedResults()\n}\n\nconst lintDefinitionAndLogResults = async (definition: IntegrationDefinitionProps) => {\n const linter = await lintDefinition(definition)\n linter.logResults(mockLogger as any)\n}\n\ndescribe.concurrent('Integration Linter', () => {\n test('should lint a valid definition without giving errors', async () => {\n // arrange\n const definition = VALID_INTEGRATION\n\n // act\n const results = await lintDefinitionAndReturnResults(definition)\n\n expect(results).toEqual([])\n })\n\n test('should report an error when missing required fields', async () => {\n // arrange\n const definition = {\n ...VALID_INTEGRATION,\n title: EMPTY_STRING,\n } as const\n\n // act\n const results = await lintDefinitionAndReturnResults(definition)\n\n // assert\n expect(results[0]?.message).toContain('title')\n })\n\n test('should report an error when missing a title in an action input schema', async () => {\n // arrange\n const definition = {\n ...VALID_INTEGRATION,\n actions: {\n [ACTION_NAME]: {\n ...VALID_INTEGRATION.actions[ACTION_NAME],\n input: {\n schema: z.object({\n [PARAM_NAME]: z.string().describe(TRUTHY_STRING),\n }),\n },\n },\n },\n } as const\n\n // act\n const results = await lintDefinitionAndReturnResults(definition)\n\n // assert\n expect(results[0]?.message).toContain('title')\n })\n\n test('should log as an error when severity is 0', async () => {\n // arrange\n const definition = {\n ...VALID_INTEGRATION,\n title: EMPTY_STRING,\n } as const\n\n // act\n await lintDefinitionAndLogResults(definition)\n\n // assert\n expect(mockLogger.error).toHaveBeenCalled()\n })\n\n test('should log as a warning when severity is 1', async () => {\n // arrange\n const definition = {\n ...VALID_INTEGRATION,\n user: {\n tags: {\n [TAG_NAME]: {},\n },\n },\n } as const\n\n // act\n await lintDefinitionAndLogResults(definition)\n\n // assert\n expect(mockLogger.warn).toHaveBeenCalled()\n })\n})\n"],
|
|
5
|
+
"mappings": ";AAAA,oBAA2C;AAC3C,8BAA6C;AAC7C,gCAAkC;AAClC,iBAA0E;AAE1E,MAAM,eAAe;AACrB,MAAM,gBAAgB;AACtB,MAAM,cAAc;AACpB,MAAM,aAAa;AACnB,MAAM,cAAc;AACpB,MAAM,aAAa;AACnB,MAAM,WAAW;AACjB,MAAM,eAAe;AACrB,MAAM,aAAa;AACnB,MAAM,eAAe;AACrB,MAAM,cAAc;AAEpB,MAAM,oBAAoB;AAAA,EACxB,MAAM;AAAA,EACN,OAAO;AAAA,EACP,aAAa;AAAA,EACb,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,SAAS;AAAA,IACP,CAAC,cAAc;AAAA,MACb,OAAO;AAAA,MACP,aAAa;AAAA,MACb,OAAO;AAAA,QACL,QAAQ,aACL,OAAO;AAAA,UACN,CAAC,aAAa,aAAE,OAAO,EAAE,MAAM,aAAa,EAAE,SAAS,aAAa;AAAA,QACtE,CAAC,EACA,MAAM,aAAa,EACnB,SAAS,aAAa;AAAA,MAC3B;AAAA,MACA,QAAQ;AAAA,QACN,QAAQ,aACL,OAAO;AAAA,UACN,CAAC,aAAa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B;AAAA,EAC3C,CAAC;AACH,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -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 bot_linter_exports = {};
|
|
20
|
+
__export(bot_linter_exports, {
|
|
21
|
+
BotLinter: () => BotLinter
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(bot_linter_exports);
|
|
24
|
+
var import_base_linter = require("./base-linter");
|
|
25
|
+
var import_bot = require("./rulesets/bot.ruleset");
|
|
26
|
+
class BotLinter extends import_base_linter.BaseLinter {
|
|
27
|
+
constructor(definition) {
|
|
28
|
+
super(definition, import_bot.BOT_RULESET);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
32
|
+
0 && (module.exports = {
|
|
33
|
+
BotLinter
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=bot-linter.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/linter/bot-linter.ts"],
|
|
4
|
+
"sourcesContent": ["import { type CreateBotBody } from '../api/bot-body'\nimport { BaseLinter } from './base-linter'\nimport { BOT_RULESET } from './rulesets/bot.ruleset'\n\nexport class BotLinter extends BaseLinter<CreateBotBody> {\n public constructor(definition: CreateBotBody) {\n super(definition, BOT_RULESET)\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,yBAA2B;AAC3B,iBAA4B;AAErB,MAAM,kBAAkB,8BAA0B;AAAA,EAChD,YAAY,YAA2B;AAC5C,UAAM,YAAY,sBAAW;AAAA,EAC/B;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -21,52 +21,11 @@ __export(integration_linter_exports, {
|
|
|
21
21
|
IntegrationLinter: () => IntegrationLinter
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(integration_linter_exports);
|
|
24
|
-
var
|
|
25
|
-
var import_spectral_parsers = require("@stoplight/spectral-parsers");
|
|
24
|
+
var import_base_linter = require("./base-linter");
|
|
26
25
|
var import_integration = require("./rulesets/integration.ruleset");
|
|
27
|
-
class IntegrationLinter {
|
|
28
|
-
_spectral;
|
|
29
|
-
_spectralDocument;
|
|
30
|
-
_results = [];
|
|
26
|
+
class IntegrationLinter extends import_base_linter.BaseLinter {
|
|
31
27
|
constructor(definition) {
|
|
32
|
-
|
|
33
|
-
this._spectralDocument = new import_spectral_core.Document(json, import_spectral_parsers.Json);
|
|
34
|
-
this._spectral = new import_spectral_core.Spectral();
|
|
35
|
-
this._spectral.setRuleset(import_integration.INTEGRATION_RULESET);
|
|
36
|
-
}
|
|
37
|
-
async lint() {
|
|
38
|
-
this._results = await this._spectral.run(this._spectralDocument);
|
|
39
|
-
}
|
|
40
|
-
logResults(logger) {
|
|
41
|
-
for (const result of this.getSortedResults()) {
|
|
42
|
-
const message = `${result.path}: ${result.message}`;
|
|
43
|
-
this._logResultMessage(logger, message, result.severity);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
getSortedResults() {
|
|
47
|
-
return this._getResults().sort((a, b) => a.path > b.path ? 1 : a.path < b.path ? -1 : 0);
|
|
48
|
-
}
|
|
49
|
-
hasErrors() {
|
|
50
|
-
return this._results.some((result) => result.severity === 0);
|
|
51
|
-
}
|
|
52
|
-
_getResults() {
|
|
53
|
-
return this._results.map((result) => ({
|
|
54
|
-
message: result.message,
|
|
55
|
-
path: this._simplifyPath(result.path),
|
|
56
|
-
severity: result.severity
|
|
57
|
-
}));
|
|
58
|
-
}
|
|
59
|
-
_simplifyPath(path) {
|
|
60
|
-
return path.join(".").replaceAll(".properties.", ".").replaceAll(".x-zui", "");
|
|
61
|
-
}
|
|
62
|
-
_logResultMessage(logger, message, severity) {
|
|
63
|
-
const logLevelMapping = {
|
|
64
|
-
0: logger.error,
|
|
65
|
-
1: logger.warn,
|
|
66
|
-
2: logger.log,
|
|
67
|
-
3: logger.debug
|
|
68
|
-
};
|
|
69
|
-
logLevelMapping[severity].call(logger, message);
|
|
28
|
+
super(definition, import_integration.INTEGRATION_RULESET);
|
|
70
29
|
}
|
|
71
30
|
}
|
|
72
31
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/linter/integration-linter.ts"],
|
|
4
|
-
"sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
6
|
-
"names": [
|
|
4
|
+
"sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport { type CreateIntegrationBody } from '../api/integration-body'\nimport { BaseLinter } from './base-linter'\nimport { INTEGRATION_RULESET } from './rulesets/integration.ruleset'\n\n// The CreateIntegrationBody type does not contain the descriptions for the secrets\nexport type AggregateIntegrationBody = Omit<CreateIntegrationBody, 'secrets'> &\n Pick<sdk.IntegrationDefinitionProps, 'secrets'>\n\nexport class IntegrationLinter extends BaseLinter<AggregateIntegrationBody> {\n public constructor(definition: AggregateIntegrationBody) {\n super(definition, INTEGRATION_RULESET)\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,yBAA2B;AAC3B,yBAAoC;AAM7B,MAAM,0BAA0B,8BAAqC;AAAA,EACnE,YAAY,YAAsC;AACvD,UAAM,YAAY,sCAAmB;AAAA,EACvC;AACF;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -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 interface_linter_exports = {};
|
|
20
|
+
__export(interface_linter_exports, {
|
|
21
|
+
InterfaceLinter: () => InterfaceLinter
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(interface_linter_exports);
|
|
24
|
+
var import_base_linter = require("./base-linter");
|
|
25
|
+
var import_interface = require("./rulesets/interface.ruleset");
|
|
26
|
+
class InterfaceLinter extends import_base_linter.BaseLinter {
|
|
27
|
+
constructor(definition) {
|
|
28
|
+
super(definition, import_interface.INTERFACE_RULESET);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
32
|
+
0 && (module.exports = {
|
|
33
|
+
InterfaceLinter
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=interface-linter.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/linter/interface-linter.ts"],
|
|
4
|
+
"sourcesContent": ["import { type CreateInterfaceBody } from '../api/interface-body'\nimport { BaseLinter } from './base-linter'\nimport { INTERFACE_RULESET } from './rulesets/interface.ruleset'\n\nexport class InterfaceLinter extends BaseLinter<CreateInterfaceBody> {\n public constructor(definition: CreateInterfaceBody) {\n super(definition, INTERFACE_RULESET)\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,yBAA2B;AAC3B,uBAAkC;AAE3B,MAAM,wBAAwB,8BAAgC;AAAA,EAC5D,YAAY,YAAiC;AAClD,UAAM,YAAY,kCAAiB;AAAA,EACrC;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|