@botpress/cli 4.23.3 → 4.25.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 +13 -13
- package/dist/command-definitions.d.ts +4 -0
- package/dist/command-implementations/add-command.d.ts +2 -0
- package/dist/command-implementations/add-command.js +17 -10
- package/dist/command-implementations/add-command.js.map +2 -2
- package/dist/command-implementations/deploy-command.js +6 -3
- package/dist/command-implementations/deploy-command.js.map +2 -2
- package/dist/command-implementations/index.d.ts +4 -0
- package/dist/config.d.ts +4 -0
- package/dist/config.js +4 -0
- package/dist/config.js.map +2 -2
- package/dist/index.d.ts +4 -0
- package/package.json +2 -2
- package/templates/empty-bot/package.json +1 -1
- package/templates/empty-integration/package.json +1 -1
- package/templates/empty-plugin/package.json +1 -1
- package/templates/hello-world/package.json +1 -1
- package/templates/webhook-message/package.json +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
|
|
2
|
-
> @botpress/cli@4.
|
|
2
|
+
> @botpress/cli@4.25.0 build /home/runner/work/botpress/botpress/packages/cli
|
|
3
3
|
> pnpm run build:types && pnpm run bundle && pnpm run template:gen
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
> @botpress/cli@4.
|
|
6
|
+
> @botpress/cli@4.25.0 build:types /home/runner/work/botpress/botpress/packages/cli
|
|
7
7
|
> tsc -p ./tsconfig.build.json
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
> @botpress/cli@4.
|
|
10
|
+
> @botpress/cli@4.25.0 bundle /home/runner/work/botpress/botpress/packages/cli
|
|
11
11
|
> ts-node -T build.ts
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
> @botpress/cli@4.
|
|
14
|
+
> @botpress/cli@4.25.0 template:gen /home/runner/work/botpress/botpress/packages/cli
|
|
15
15
|
> pnpm -r --stream -F @bp-templates/* exec bp gen
|
|
16
16
|
|
|
17
|
-
🤖 Botpress CLI v4.
|
|
18
|
-
🤖 Botpress CLI v4.
|
|
19
|
-
🤖 Botpress CLI v4.
|
|
20
|
-
🤖 Botpress CLI v4.
|
|
21
|
-
○ Generating typings for
|
|
22
|
-
○ Generating typings for integration empty-integration...
|
|
17
|
+
🤖 Botpress CLI v4.25.0
|
|
18
|
+
🤖 Botpress CLI v4.25.0
|
|
19
|
+
🤖 Botpress CLI v4.25.0
|
|
20
|
+
🤖 Botpress CLI v4.25.0
|
|
21
|
+
○ Generating typings for integration hello-world...
|
|
23
22
|
✓ Typings available at .botpress
|
|
24
23
|
|
|
24
|
+
○ Generating typings for plugin empty-plugin...
|
|
25
|
+
○ Generating typings for bot...
|
|
25
26
|
✓ Typings available at .botpress
|
|
26
27
|
|
|
27
|
-
○ Generating typings for integration
|
|
28
|
+
○ Generating typings for integration empty-integration...
|
|
28
29
|
✓ Typings available at .botpress
|
|
29
30
|
|
|
30
|
-
○ Generating typings for bot...
|
|
31
31
|
✓ Typings available at .botpress
|
|
32
32
|
|
|
33
|
-
🤖 Botpress CLI v4.
|
|
33
|
+
🤖 Botpress CLI v4.25.0
|
|
34
34
|
○ Generating typings for integration webhook-message...
|
|
35
35
|
✓ Typings available at .botpress
|
|
36
36
|
|
|
@@ -5,6 +5,8 @@ export declare class AddCommand extends GlobalCommand<AddCommandDefinition> {
|
|
|
5
5
|
run(): Promise<void>;
|
|
6
6
|
private _parseArgvRef;
|
|
7
7
|
private _addSinglePackage;
|
|
8
|
+
private _addNewSinglePackage;
|
|
9
|
+
private _findPackage;
|
|
8
10
|
private _findRemotePackage;
|
|
9
11
|
private _findLocalPackage;
|
|
10
12
|
private _install;
|
|
@@ -47,7 +47,7 @@ class AddCommand extends import_global_command.GlobalCommand {
|
|
|
47
47
|
async run() {
|
|
48
48
|
const ref = this._parseArgvRef();
|
|
49
49
|
if (ref) {
|
|
50
|
-
return await this.
|
|
50
|
+
return await this._addNewSinglePackage({ ...ref, alias: this.argv.alias });
|
|
51
51
|
}
|
|
52
52
|
const pkgJson = await utils.pkgJson.readPackageJson(this.argv.installPath);
|
|
53
53
|
if (!pkgJson) {
|
|
@@ -93,12 +93,7 @@ class AddCommand extends import_global_command.GlobalCommand {
|
|
|
93
93
|
return ref;
|
|
94
94
|
};
|
|
95
95
|
async _addSinglePackage(ref) {
|
|
96
|
-
const
|
|
97
|
-
if (!targetPackage) {
|
|
98
|
-
const strRef = pkgRef.formatPackageRef(ref);
|
|
99
|
-
throw new errors.BotpressCLIError(`Could not find package "${strRef}"`);
|
|
100
|
-
}
|
|
101
|
-
const packageName = ref.alias ?? targetPackage.pkg.name;
|
|
96
|
+
const { packageName, targetPackage } = await this._findPackage(ref);
|
|
102
97
|
const baseInstallPath = utils.path.absoluteFrom(utils.path.cwd(), this.argv.installPath);
|
|
103
98
|
const packageDirName = utils.casing.to.kebabCase(packageName);
|
|
104
99
|
const installPath = utils.path.join(baseInstallPath, consts.installDirName, packageDirName);
|
|
@@ -107,8 +102,7 @@ class AddCommand extends import_global_command.GlobalCommand {
|
|
|
107
102
|
this.logger.warn(`Package with name "${packageName}" already installed.`);
|
|
108
103
|
const res = await this.prompt.confirm("Do you want to overwrite the existing package?");
|
|
109
104
|
if (!res) {
|
|
110
|
-
|
|
111
|
-
return;
|
|
105
|
+
throw new errors.AbortedOperationError();
|
|
112
106
|
}
|
|
113
107
|
await this._uninstall(installPath);
|
|
114
108
|
}
|
|
@@ -132,8 +126,21 @@ class AddCommand extends import_global_command.GlobalCommand {
|
|
|
132
126
|
throw new errors.BotpressCLIError("Invalid package type");
|
|
133
127
|
}
|
|
134
128
|
await this._install(installPath, files);
|
|
129
|
+
}
|
|
130
|
+
async _addNewSinglePackage(ref) {
|
|
131
|
+
await this._addSinglePackage(ref);
|
|
132
|
+
const { packageName, targetPackage } = await this._findPackage(ref);
|
|
135
133
|
await this._addDependencyToPackage(packageName, targetPackage);
|
|
136
134
|
}
|
|
135
|
+
async _findPackage(ref) {
|
|
136
|
+
const targetPackage = ref.type === "path" ? await this._findLocalPackage(ref) : await this._findRemotePackage(ref);
|
|
137
|
+
if (!targetPackage) {
|
|
138
|
+
const strRef = pkgRef.formatPackageRef(ref);
|
|
139
|
+
throw new errors.BotpressCLIError(`Could not find package "${strRef}"`);
|
|
140
|
+
}
|
|
141
|
+
const packageName = ref.alias ?? targetPackage.pkg.name;
|
|
142
|
+
return { packageName, targetPackage };
|
|
143
|
+
}
|
|
137
144
|
async _findRemotePackage(ref) {
|
|
138
145
|
const api = await this.ensureLoginAndCreateClient(this.argv);
|
|
139
146
|
if (this._pkgCouldBe(ref, "integration")) {
|
|
@@ -291,7 +298,7 @@ class AddCommand extends import_global_command.GlobalCommand {
|
|
|
291
298
|
}
|
|
292
299
|
async _addDependencyToPackage(packageName, targetPackage) {
|
|
293
300
|
const pkgJson = await utils.pkgJson.readPackageJson(this.argv.installPath);
|
|
294
|
-
const version = targetPackage.pkg.path ?? targetPackage.pkg.version
|
|
301
|
+
const version = targetPackage.pkg.path ?? `${targetPackage.type}:${targetPackage.pkg.name}@${targetPackage.pkg.version}`;
|
|
295
302
|
if (!pkgJson) {
|
|
296
303
|
this.logger.warn("No package.json found in the install path");
|
|
297
304
|
return;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/command-implementations/add-command.ts"],
|
|
4
|
-
"sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport * as fslib from 'fs'\nimport * as pathlib from 'path'\nimport semver from 'semver'\nimport * as apiUtils from '../api'\nimport * as codegen from '../code-generation'\nimport type commandDefinitions from '../command-definitions'\nimport * as consts from '../consts'\nimport * as errors from '../errors'\nimport * as pkgRef from '../package-ref'\nimport * as utils from '../utils'\nimport { GlobalCommand } from './global-command'\nimport {\n ProjectCache,\n ProjectCommand,\n ProjectCommandDefinition,\n ProjectDefinitionLazy,\n ProjectDefinition,\n} from './project-command'\n\ntype InstallablePackage =\n | {\n type: 'integration'\n pkg: codegen.IntegrationInstallablePackage\n }\n | {\n type: 'interface'\n pkg: codegen.InterfaceInstallablePackage\n }\n | {\n type: 'plugin'\n pkg: codegen.PluginInstallablePackage\n }\n\nexport type AddCommandDefinition = typeof commandDefinitions.add\nexport class AddCommand extends GlobalCommand<AddCommandDefinition> {\n public async run(): Promise<void> {\n const ref = this._parseArgvRef()\n if (ref) {\n return await this._addSinglePackage(ref)\n }\n\n const pkgJson = await utils.pkgJson.readPackageJson(this.argv.installPath)\n if (!pkgJson) {\n this.logger.warn('No package.json found in the install path')\n return\n }\n\n const { bpDependencies } = pkgJson\n if (!bpDependencies) {\n this.logger.log('No bp dependencies found in package.json')\n return\n }\n\n const bpDependenciesSchema = sdk.z.record(sdk.z.string())\n const parseResults = bpDependenciesSchema.safeParse(bpDependencies)\n if (!parseResults.success) {\n throw new errors.BotpressCLIError('Invalid bpDependencies found in package.json')\n }\n\n for (const [pkgAlias, pkgRefStr] of Object.entries(parseResults.data)) {\n const parsed = pkgRef.parsePackageRef(pkgRefStr)\n if (!parsed) {\n throw new errors.InvalidPackageReferenceError(pkgRefStr)\n }\n\n await this._addSinglePackage({ ...parsed, alias: pkgAlias })\n }\n }\n\n private _parseArgvRef = (): pkgRef.PackageRef | undefined => {\n if (!this.argv.packageRef) {\n return\n }\n\n const parsed = pkgRef.parsePackageRef(this.argv.packageRef)\n if (!parsed) {\n throw new errors.InvalidPackageReferenceError(this.argv.packageRef)\n }\n\n if (parsed.type !== 'name') {\n return parsed\n }\n\n const argvPkgType = this.argv.packageType\n if (!argvPkgType) {\n return parsed\n }\n\n const ref = { ...parsed, pkg: argvPkgType }\n\n const strRef = pkgRef.formatPackageRef(ref)\n this.logger.warn(`argument --packageType is deprecated; please use the package reference format \"${strRef}\"`)\n\n return ref\n }\n\n private async _addSinglePackage(ref: pkgRef.PackageRef & { alias?: string }): Promise<void> {\n const targetPackage = ref.type === 'path' ? await this._findLocalPackage(ref) : await this._findRemotePackage(ref)\n\n if (!targetPackage) {\n const strRef = pkgRef.formatPackageRef(ref)\n throw new errors.BotpressCLIError(`Could not find package \"${strRef}\"`)\n }\n\n const packageName = ref.alias ?? targetPackage.pkg.name\n const baseInstallPath = utils.path.absoluteFrom(utils.path.cwd(), this.argv.installPath)\n const packageDirName = utils.casing.to.kebabCase(packageName)\n const installPath = utils.path.join(baseInstallPath, consts.installDirName, packageDirName)\n\n const alreadyInstalled = fslib.existsSync(installPath)\n if (alreadyInstalled) {\n this.logger.warn(`Package with name \"${packageName}\" already installed.`)\n const res = await this.prompt.confirm('Do you want to overwrite the existing package?')\n if (!res) {\n this.logger.log('Aborted')\n return\n }\n\n await this._uninstall(installPath)\n }\n\n if (ref.type === 'name' && ref.version === pkgRef.LATEST_TAG) {\n // If the semver version expression is 'latest', we assume the project\n // is compatible with all versions of the latest major:\n const major = semver.major(targetPackage.pkg.version)\n targetPackage.pkg.version = `>=${major}.0.0 <${major + 1}.0.0`\n\n this.logger.log(\n `Dependency \"${packageName}\" will be installed with version \"${targetPackage.pkg.version}\". ` +\n `To pin a specific version or version range, please change \"${targetPackage.type}:${packageName}@latest\" ` +\n 'to a specific version number or range instead of \"latest\".'\n )\n } else if (ref.type === 'name') {\n // Preserve the semver version expression in the generated code:\n targetPackage.pkg.version = ref.version\n }\n\n let files: codegen.File[]\n if (targetPackage.type === 'integration') {\n files = await codegen.generateIntegrationPackage(targetPackage.pkg)\n } else if (targetPackage.type === 'interface') {\n files = await codegen.generateInterfacePackage(targetPackage.pkg)\n } else if (targetPackage.type === 'plugin') {\n files = await codegen.generatePluginPackage(targetPackage.pkg)\n } else {\n type _assertion = utils.types.AssertNever<typeof targetPackage>\n throw new errors.BotpressCLIError('Invalid package type')\n }\n\n await this._install(installPath, files)\n await this._addDependencyToPackage(packageName, targetPackage)\n }\n\n private async _findRemotePackage(ref: pkgRef.ApiPackageRef): Promise<InstallablePackage | undefined> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n if (this._pkgCouldBe(ref, 'integration')) {\n const integration = await api.findPublicOrPrivateIntegration(ref)\n if (integration) {\n const { name, version } = integration\n return { type: 'integration', pkg: { integration, name, version } }\n }\n }\n if (this._pkgCouldBe(ref, 'interface')) {\n const intrface = await api.findPublicOrPrivateInterface(ref)\n if (intrface) {\n const { name, version } = intrface\n return { type: 'interface', pkg: { interface: intrface, name, version } }\n }\n }\n if (this._pkgCouldBe(ref, 'plugin')) {\n const plugin = await api.findPublicOrPrivatePlugin(ref)\n if (plugin) {\n const { code } = plugin.public\n ? await api.client.getPublicPluginCode({ id: plugin.id, platform: 'node' })\n : await api.client.getPluginCode({ id: plugin.id, platform: 'node' })\n const { name, version } = plugin\n return {\n type: 'plugin',\n pkg: {\n name,\n version,\n plugin,\n code,\n },\n }\n }\n }\n return\n }\n\n private async _findLocalPackage(ref: pkgRef.LocalPackageRef): Promise<InstallablePackage | undefined> {\n const absPath = utils.path.absoluteFrom(utils.path.cwd(), ref.path)\n const {\n definition: projectDefinition,\n implementation: projectImplementation,\n devId: projectDevId,\n } = await this._readProject(absPath)\n\n if (projectDefinition?.type === 'integration') {\n const { name, version } = projectDefinition.definition\n let devId: string | undefined\n if (this.argv.useDev && projectDevId) {\n this.logger.warn(`Installing integration \"${name}\" with dev version \"${projectDevId}\"`)\n devId = projectDevId\n }\n\n let createIntegrationReqBody = await this._getProjectCmd(ref.path).prepareCreateIntegrationBody(\n projectDefinition.definition\n )\n createIntegrationReqBody = {\n ...createIntegrationReqBody,\n interfaces: utils.records.mapValues(projectDefinition.definition.interfaces ?? {}, (i) => ({\n id: '', // TODO: do this better\n ...i,\n })),\n }\n return {\n type: 'integration',\n pkg: { path: absPath, devId, name, version, integration: createIntegrationReqBody },\n }\n }\n\n if (projectDefinition?.type === 'interface') {\n const { name, version } = projectDefinition.definition\n const createInterfaceReqBody = await apiUtils.prepareCreateInterfaceBody(projectDefinition.definition)\n return {\n type: 'interface',\n pkg: { path: absPath, name, version, interface: createInterfaceReqBody },\n }\n }\n\n if (projectDefinition?.type === 'plugin') {\n if (!projectImplementation) {\n throw new errors.BotpressCLIError(\n 'Plugin implementation not found; Please build the plugin project before installing'\n )\n }\n\n const pluginDefinition = projectDefinition.definition\n const { name, version } = pluginDefinition\n const code = projectImplementation\n\n const createPluginReqBody = await apiUtils.prepareCreatePluginBody(pluginDefinition)\n return {\n type: 'plugin',\n pkg: {\n path: absPath,\n name,\n version,\n code,\n plugin: {\n ...createPluginReqBody,\n dependencies: {\n interfaces: pluginDefinition.interfaces,\n integrations: pluginDefinition.integrations,\n },\n recurringEvents: pluginDefinition.recurringEvents,\n },\n },\n }\n }\n\n if (projectDefinition?.type === 'bot') {\n throw new errors.BotpressCLIError('Cannot install a bot as a package')\n }\n return\n }\n\n private async _install(installPath: utils.path.AbsolutePath, files: codegen.File[]): Promise<void> {\n const line = this.logger.line()\n line.started(`Installing ${files.length} files to \"${installPath}\"`)\n try {\n for (const file of files) {\n const filePath = utils.path.absoluteFrom(installPath, file.path)\n const dirPath = pathlib.dirname(filePath)\n await fslib.promises.mkdir(dirPath, { recursive: true })\n await fslib.promises.writeFile(filePath, file.content)\n }\n line.success(`Installed ${files.length} files to \"${installPath}\"`)\n } finally {\n line.commit()\n }\n }\n\n private async _uninstall(installPath: utils.path.AbsolutePath): Promise<void> {\n await fslib.promises.rm(installPath, { recursive: true })\n }\n\n private async _readProject(workDir: utils.path.AbsolutePath): Promise<{\n definition?: ProjectDefinition\n implementation?: string\n devId?: string\n }> {\n const cmd = this._getProjectCmd(workDir)\n\n const { resolveProjectDefinition } = cmd.readProjectDefinitionFromFS()\n const definition = await resolveProjectDefinition().catch((thrown) => {\n if (thrown instanceof errors.ProjectDefinitionNotFoundError) {\n return undefined\n }\n throw thrown\n })\n\n const devId = await cmd.projectCache.get('devId')\n\n const implementationAbsPath = utils.path.join(workDir, consts.fromWorkDir.outFileCJS)\n if (!fslib.existsSync(implementationAbsPath)) {\n return { definition, devId }\n }\n\n const implementation = await fslib.promises.readFile(implementationAbsPath, 'utf8')\n return { definition, implementation, devId }\n }\n\n private _pkgCouldBe = (ref: pkgRef.ApiPackageRef, pkgType: InstallablePackage['type']) => {\n if (ref.type === 'id') {\n // TODO: use ULID prefixes to determine the type of the package\n return true\n }\n if (!ref.pkg) {\n return true // ref does not specify the package type\n }\n return ref.pkg === pkgType\n }\n\n private _getProjectCmd(workDir: string): _AnyProjectCommand {\n return new _AnyProjectCommand(apiUtils.ApiClient, this.prompt, this.logger, {\n ...this.argv,\n workDir,\n })\n }\n\n private async _addDependencyToPackage(packageName: string, targetPackage: InstallablePackage) {\n const pkgJson = await utils.pkgJson.readPackageJson(this.argv.installPath)\n const version = targetPackage.pkg.path ?? targetPackage.pkg.version\n if (!pkgJson) {\n this.logger.warn('No package.json found in the install path')\n return\n }\n\n const { bpDependencies } = pkgJson\n if (!bpDependencies) {\n pkgJson.bpDependencies = { [packageName]: version }\n await utils.pkgJson.writePackageJson(this.argv.installPath, pkgJson)\n return\n }\n\n const bpDependenciesSchema = sdk.z.record(sdk.z.string())\n const parseResult = bpDependenciesSchema.safeParse(bpDependencies)\n if (!parseResult.success) {\n throw new errors.BotpressCLIError('Invalid bpDependencies found in package.json')\n }\n\n const { data: validatedBpDeps } = parseResult\n\n const alreadyPresentDep = Object.entries(validatedBpDeps).find(([key]) => key === packageName)\n if (alreadyPresentDep) {\n if (alreadyPresentDep[1] !== version) {\n this.logger.warn(\n `The dependency ${packageName} is already present in the bpDependencies of package.json. It will not be replaced.`\n )\n }\n return\n }\n\n pkgJson.bpDependencies = {\n ...validatedBpDeps,\n [packageName]: version,\n }\n\n await utils.pkgJson.writePackageJson(this.argv.installPath, pkgJson)\n }\n}\n\n// this is a hack to avoid refactoring the project command class\nclass _AnyProjectCommand extends ProjectCommand<ProjectCommandDefinition> {\n public async run(): Promise<void> {\n throw new errors.BotpressCLIError('Not implemented')\n }\n\n public readProjectDefinitionFromFS(): ProjectDefinitionLazy {\n return super.readProjectDefinitionFromFS()\n }\n\n public async prepareCreateIntegrationBody(\n integrationDef: sdk.IntegrationDefinition\n ): Promise<apiUtils.CreateIntegrationRequestBody> {\n return super.prepareCreateIntegrationBody(integrationDef)\n }\n\n public get projectCache(): utils.cache.FSKeyValueCache<ProjectCache> {\n return super.projectCache\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UAAqB;AACrB,YAAuB;AACvB,cAAyB;AACzB,oBAAmB;AACnB,eAA0B;AAC1B,cAAyB;AAEzB,aAAwB;AACxB,aAAwB;AACxB,aAAwB;AACxB,YAAuB;AACvB,4BAA8B;AAC9B,6BAMO;
|
|
4
|
+
"sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport * as fslib from 'fs'\nimport * as pathlib from 'path'\nimport semver from 'semver'\nimport * as apiUtils from '../api'\nimport * as codegen from '../code-generation'\nimport type commandDefinitions from '../command-definitions'\nimport * as consts from '../consts'\nimport * as errors from '../errors'\nimport * as pkgRef from '../package-ref'\nimport * as utils from '../utils'\nimport { GlobalCommand } from './global-command'\nimport {\n ProjectCache,\n ProjectCommand,\n ProjectCommandDefinition,\n ProjectDefinitionLazy,\n ProjectDefinition,\n} from './project-command'\n\ntype InstallablePackage =\n | {\n type: 'integration'\n pkg: codegen.IntegrationInstallablePackage\n }\n | {\n type: 'interface'\n pkg: codegen.InterfaceInstallablePackage\n }\n | {\n type: 'plugin'\n pkg: codegen.PluginInstallablePackage\n }\n\ntype RefWithAlias = pkgRef.PackageRef & { alias?: string }\n\nexport type AddCommandDefinition = typeof commandDefinitions.add\nexport class AddCommand extends GlobalCommand<AddCommandDefinition> {\n public async run(): Promise<void> {\n const ref = this._parseArgvRef()\n if (ref) {\n return await this._addNewSinglePackage({ ...ref, alias: this.argv.alias })\n }\n const pkgJson = await utils.pkgJson.readPackageJson(this.argv.installPath)\n if (!pkgJson) {\n this.logger.warn('No package.json found in the install path')\n return\n }\n\n const { bpDependencies } = pkgJson\n if (!bpDependencies) {\n this.logger.log('No bp dependencies found in package.json')\n return\n }\n\n const bpDependenciesSchema = sdk.z.record(sdk.z.string())\n const parseResults = bpDependenciesSchema.safeParse(bpDependencies)\n if (!parseResults.success) {\n throw new errors.BotpressCLIError('Invalid bpDependencies found in package.json')\n }\n\n for (const [pkgAlias, pkgRefStr] of Object.entries(parseResults.data)) {\n const parsed = pkgRef.parsePackageRef(pkgRefStr)\n if (!parsed) {\n throw new errors.InvalidPackageReferenceError(pkgRefStr)\n }\n\n await this._addSinglePackage({ ...parsed, alias: pkgAlias })\n }\n }\n\n private _parseArgvRef = (): pkgRef.PackageRef | undefined => {\n if (!this.argv.packageRef) {\n return\n }\n\n const parsed = pkgRef.parsePackageRef(this.argv.packageRef)\n if (!parsed) {\n throw new errors.InvalidPackageReferenceError(this.argv.packageRef)\n }\n\n if (parsed.type !== 'name') {\n return parsed\n }\n\n const argvPkgType = this.argv.packageType\n if (!argvPkgType) {\n return parsed\n }\n\n const ref = { ...parsed, pkg: argvPkgType }\n\n const strRef = pkgRef.formatPackageRef(ref)\n this.logger.warn(`argument --packageType is deprecated; please use the package reference format \"${strRef}\"`)\n\n return ref\n }\n\n private async _addSinglePackage(ref: RefWithAlias) {\n const { packageName, targetPackage } = await this._findPackage(ref)\n\n const baseInstallPath = utils.path.absoluteFrom(utils.path.cwd(), this.argv.installPath)\n const packageDirName = utils.casing.to.kebabCase(packageName)\n const installPath = utils.path.join(baseInstallPath, consts.installDirName, packageDirName)\n\n const alreadyInstalled = fslib.existsSync(installPath)\n if (alreadyInstalled) {\n this.logger.warn(`Package with name \"${packageName}\" already installed.`)\n const res = await this.prompt.confirm('Do you want to overwrite the existing package?')\n if (!res) {\n throw new errors.AbortedOperationError()\n }\n\n await this._uninstall(installPath)\n }\n\n if (ref.type === 'name' && ref.version === pkgRef.LATEST_TAG) {\n // If the semver version expression is 'latest', we assume the project\n // is compatible with all versions of the latest major:\n const major = semver.major(targetPackage.pkg.version)\n targetPackage.pkg.version = `>=${major}.0.0 <${major + 1}.0.0`\n\n this.logger.log(\n `Dependency \"${packageName}\" will be installed with version \"${targetPackage.pkg.version}\". ` +\n `To pin a specific version or version range, please change \"${targetPackage.type}:${packageName}@latest\" ` +\n 'to a specific version number or range instead of \"latest\".'\n )\n } else if (ref.type === 'name') {\n // Preserve the semver version expression in the generated code:\n targetPackage.pkg.version = ref.version\n }\n\n let files: codegen.File[]\n if (targetPackage.type === 'integration') {\n files = await codegen.generateIntegrationPackage(targetPackage.pkg)\n } else if (targetPackage.type === 'interface') {\n files = await codegen.generateInterfacePackage(targetPackage.pkg)\n } else if (targetPackage.type === 'plugin') {\n files = await codegen.generatePluginPackage(targetPackage.pkg)\n } else {\n type _assertion = utils.types.AssertNever<typeof targetPackage>\n throw new errors.BotpressCLIError('Invalid package type')\n }\n\n await this._install(installPath, files)\n }\n\n private async _addNewSinglePackage(ref: RefWithAlias) {\n await this._addSinglePackage(ref)\n const { packageName, targetPackage } = await this._findPackage(ref)\n await this._addDependencyToPackage(packageName, targetPackage)\n }\n\n private async _findPackage(ref: RefWithAlias): Promise<{ packageName: string; targetPackage: InstallablePackage }> {\n const targetPackage = ref.type === 'path' ? await this._findLocalPackage(ref) : await this._findRemotePackage(ref)\n if (!targetPackage) {\n const strRef = pkgRef.formatPackageRef(ref)\n throw new errors.BotpressCLIError(`Could not find package \"${strRef}\"`)\n }\n const packageName = ref.alias ?? targetPackage.pkg.name\n\n return { packageName, targetPackage }\n }\n\n private async _findRemotePackage(ref: pkgRef.ApiPackageRef): Promise<InstallablePackage | undefined> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n if (this._pkgCouldBe(ref, 'integration')) {\n const integration = await api.findPublicOrPrivateIntegration(ref)\n if (integration) {\n const { name, version } = integration\n return { type: 'integration', pkg: { integration, name, version } }\n }\n }\n if (this._pkgCouldBe(ref, 'interface')) {\n const intrface = await api.findPublicOrPrivateInterface(ref)\n if (intrface) {\n const { name, version } = intrface\n return { type: 'interface', pkg: { interface: intrface, name, version } }\n }\n }\n if (this._pkgCouldBe(ref, 'plugin')) {\n const plugin = await api.findPublicOrPrivatePlugin(ref)\n if (plugin) {\n const { code } = plugin.public\n ? await api.client.getPublicPluginCode({ id: plugin.id, platform: 'node' })\n : await api.client.getPluginCode({ id: plugin.id, platform: 'node' })\n const { name, version } = plugin\n return {\n type: 'plugin',\n pkg: {\n name,\n version,\n plugin,\n code,\n },\n }\n }\n }\n return\n }\n\n private async _findLocalPackage(ref: pkgRef.LocalPackageRef): Promise<InstallablePackage | undefined> {\n const absPath = utils.path.absoluteFrom(utils.path.cwd(), ref.path)\n const {\n definition: projectDefinition,\n implementation: projectImplementation,\n devId: projectDevId,\n } = await this._readProject(absPath)\n\n if (projectDefinition?.type === 'integration') {\n const { name, version } = projectDefinition.definition\n let devId: string | undefined\n if (this.argv.useDev && projectDevId) {\n this.logger.warn(`Installing integration \"${name}\" with dev version \"${projectDevId}\"`)\n devId = projectDevId\n }\n\n let createIntegrationReqBody = await this._getProjectCmd(ref.path).prepareCreateIntegrationBody(\n projectDefinition.definition\n )\n createIntegrationReqBody = {\n ...createIntegrationReqBody,\n interfaces: utils.records.mapValues(projectDefinition.definition.interfaces ?? {}, (i) => ({\n id: '', // TODO: do this better\n ...i,\n })),\n }\n return {\n type: 'integration',\n pkg: { path: absPath, devId, name, version, integration: createIntegrationReqBody },\n }\n }\n\n if (projectDefinition?.type === 'interface') {\n const { name, version } = projectDefinition.definition\n const createInterfaceReqBody = await apiUtils.prepareCreateInterfaceBody(projectDefinition.definition)\n return {\n type: 'interface',\n pkg: { path: absPath, name, version, interface: createInterfaceReqBody },\n }\n }\n\n if (projectDefinition?.type === 'plugin') {\n if (!projectImplementation) {\n throw new errors.BotpressCLIError(\n 'Plugin implementation not found; Please build the plugin project before installing'\n )\n }\n\n const pluginDefinition = projectDefinition.definition\n const { name, version } = pluginDefinition\n const code = projectImplementation\n\n const createPluginReqBody = await apiUtils.prepareCreatePluginBody(pluginDefinition)\n return {\n type: 'plugin',\n pkg: {\n path: absPath,\n name,\n version,\n code,\n plugin: {\n ...createPluginReqBody,\n dependencies: {\n interfaces: pluginDefinition.interfaces,\n integrations: pluginDefinition.integrations,\n },\n recurringEvents: pluginDefinition.recurringEvents,\n },\n },\n }\n }\n\n if (projectDefinition?.type === 'bot') {\n throw new errors.BotpressCLIError('Cannot install a bot as a package')\n }\n return\n }\n\n private async _install(installPath: utils.path.AbsolutePath, files: codegen.File[]): Promise<void> {\n const line = this.logger.line()\n line.started(`Installing ${files.length} files to \"${installPath}\"`)\n try {\n for (const file of files) {\n const filePath = utils.path.absoluteFrom(installPath, file.path)\n const dirPath = pathlib.dirname(filePath)\n await fslib.promises.mkdir(dirPath, { recursive: true })\n await fslib.promises.writeFile(filePath, file.content)\n }\n line.success(`Installed ${files.length} files to \"${installPath}\"`)\n } finally {\n line.commit()\n }\n }\n\n private async _uninstall(installPath: utils.path.AbsolutePath): Promise<void> {\n await fslib.promises.rm(installPath, { recursive: true })\n }\n\n private async _readProject(workDir: utils.path.AbsolutePath): Promise<{\n definition?: ProjectDefinition\n implementation?: string\n devId?: string\n }> {\n const cmd = this._getProjectCmd(workDir)\n\n const { resolveProjectDefinition } = cmd.readProjectDefinitionFromFS()\n const definition = await resolveProjectDefinition().catch((thrown) => {\n if (thrown instanceof errors.ProjectDefinitionNotFoundError) {\n return undefined\n }\n throw thrown\n })\n\n const devId = await cmd.projectCache.get('devId')\n\n const implementationAbsPath = utils.path.join(workDir, consts.fromWorkDir.outFileCJS)\n if (!fslib.existsSync(implementationAbsPath)) {\n return { definition, devId }\n }\n\n const implementation = await fslib.promises.readFile(implementationAbsPath, 'utf8')\n return { definition, implementation, devId }\n }\n\n private _pkgCouldBe = (ref: pkgRef.ApiPackageRef, pkgType: InstallablePackage['type']) => {\n if (ref.type === 'id') {\n // TODO: use ULID prefixes to determine the type of the package\n return true\n }\n if (!ref.pkg) {\n return true // ref does not specify the package type\n }\n return ref.pkg === pkgType\n }\n\n private _getProjectCmd(workDir: string): _AnyProjectCommand {\n return new _AnyProjectCommand(apiUtils.ApiClient, this.prompt, this.logger, {\n ...this.argv,\n workDir,\n })\n }\n\n private async _addDependencyToPackage(packageName: string, targetPackage: InstallablePackage) {\n const pkgJson = await utils.pkgJson.readPackageJson(this.argv.installPath)\n const version =\n targetPackage.pkg.path ?? `${targetPackage.type}:${targetPackage.pkg.name}@${targetPackage.pkg.version}`\n if (!pkgJson) {\n this.logger.warn('No package.json found in the install path')\n return\n }\n\n const { bpDependencies } = pkgJson\n if (!bpDependencies) {\n pkgJson.bpDependencies = { [packageName]: version }\n await utils.pkgJson.writePackageJson(this.argv.installPath, pkgJson)\n return\n }\n\n const bpDependenciesSchema = sdk.z.record(sdk.z.string())\n const parseResult = bpDependenciesSchema.safeParse(bpDependencies)\n if (!parseResult.success) {\n throw new errors.BotpressCLIError('Invalid bpDependencies found in package.json')\n }\n\n const { data: validatedBpDeps } = parseResult\n\n const alreadyPresentDep = Object.entries(validatedBpDeps).find(([key]) => key === packageName)\n if (alreadyPresentDep) {\n if (alreadyPresentDep[1] !== version) {\n this.logger.warn(\n `The dependency ${packageName} is already present in the bpDependencies of package.json. It will not be replaced.`\n )\n }\n return\n }\n\n pkgJson.bpDependencies = {\n ...validatedBpDeps,\n [packageName]: version,\n }\n\n await utils.pkgJson.writePackageJson(this.argv.installPath, pkgJson)\n }\n}\n\n// this is a hack to avoid refactoring the project command class\nclass _AnyProjectCommand extends ProjectCommand<ProjectCommandDefinition> {\n public async run(): Promise<void> {\n throw new errors.BotpressCLIError('Not implemented')\n }\n\n public readProjectDefinitionFromFS(): ProjectDefinitionLazy {\n return super.readProjectDefinitionFromFS()\n }\n\n public async prepareCreateIntegrationBody(\n integrationDef: sdk.IntegrationDefinition\n ): Promise<apiUtils.CreateIntegrationRequestBody> {\n return super.prepareCreateIntegrationBody(integrationDef)\n }\n\n public get projectCache(): utils.cache.FSKeyValueCache<ProjectCache> {\n return super.projectCache\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;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W,GAAG;AAAA,IACjB;AAEA,UAAM,MAAM,QAAQ,iBAAiB,KAAK,KAAK,aAAa,OAAO;AAAA,EACrE;AACF;AAGA,MAAM,2BAA2B,sCAAyC;AAAA,EACxE,MAAa,MAAqB;AAChC,UAAM,IAAI,OAAO,iBAAiB,iBAAiB;AAAA,EACrD;AAAA,EAEO,8BAAqD;AAC1D,WAAO,MAAM,4BAA4B;AAAA,EAC3C;AAAA,EAEA,MAAa,6BACX,gBACgD;AAChD,WAAO,MAAM,6BAA6B,cAAc;AAAA,EAC1D;AAAA,EAEA,IAAW,eAA0D;AACnE,WAAO,MAAM;AAAA,EACf;AACF;",
|
|
6
6
|
"names": ["semver"]
|
|
7
7
|
}
|
|
@@ -121,7 +121,8 @@ class DeployCommand extends import_project_command.ProjectCommand {
|
|
|
121
121
|
const createBody = {
|
|
122
122
|
...await this.prepareCreateIntegrationBody(integrationDef),
|
|
123
123
|
...await this.prepareIntegrationDependencies(integrationDef, api),
|
|
124
|
-
visibility: this._visibility
|
|
124
|
+
visibility: this._visibility,
|
|
125
|
+
sdkVersion: integrationDef.metadata?.sdkVersion
|
|
125
126
|
};
|
|
126
127
|
const startedMessage = `Deploying integration ${import_chalk.default.bold(name)} v${version}...`;
|
|
127
128
|
const successMessage = "Integration deployed";
|
|
@@ -214,7 +215,8 @@ class DeployCommand extends import_project_command.ProjectCommand {
|
|
|
214
215
|
...await apiUtils.prepareCreateInterfaceBody(interfaceDeclaration),
|
|
215
216
|
public: this._visibility === "public",
|
|
216
217
|
icon,
|
|
217
|
-
readme
|
|
218
|
+
readme,
|
|
219
|
+
sdkVersion: interfaceDeclaration.metadata?.sdkVersion
|
|
218
220
|
};
|
|
219
221
|
const startedMessage = `Deploying interface ${import_chalk.default.bold(name)} v${version}...`;
|
|
220
222
|
const successMessage = "Interface deployed";
|
|
@@ -284,7 +286,8 @@ class DeployCommand extends import_project_command.ProjectCommand {
|
|
|
284
286
|
code: {
|
|
285
287
|
node: codeCJS,
|
|
286
288
|
browser: codeESM
|
|
287
|
-
}
|
|
289
|
+
},
|
|
290
|
+
sdkVersion: pluginDef.metadata?.sdkVersion
|
|
288
291
|
};
|
|
289
292
|
const startedMessage = `Deploying plugin ${import_chalk.default.bold(name)} v${version}...`;
|
|
290
293
|
const successMessage = "Plugin deployed";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/command-implementations/deploy-command.ts"],
|
|
4
|
-
"sourcesContent": ["import type * as client from '@botpress/client'\nimport * as sdk from '@botpress/sdk'\nimport chalk from 'chalk'\nimport * as fs from 'fs'\nimport semver from 'semver'\nimport * as apiUtils from '../api'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport * as tables from '../tables'\nimport * as utils from '../utils'\nimport { BuildCommand } from './build-command'\nimport { ProjectCommand } from './project-command'\n\nexport type DeployCommandDefinition = typeof commandDefinitions.deploy\nexport class DeployCommand extends ProjectCommand<DeployCommandDefinition> {\n public async run(): Promise<void> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n\n if (!this.argv.noBuild) {\n await this._runBuild() // This ensures the bundle is always synced with source code\n }\n\n const { projectType, resolveProjectDefinition } = this.readProjectDefinitionFromFS()\n\n if (projectType === 'integration') {\n const projectDef = await resolveProjectDefinition()\n return this._deployIntegration(api, projectDef.definition)\n }\n if (projectType === 'interface') {\n const projectDef = await resolveProjectDefinition()\n return this._deployInterface(api, projectDef.definition)\n }\n if (projectType === 'plugin') {\n const projectDef = await resolveProjectDefinition()\n return this._deployPlugin(api, projectDef.definition)\n }\n if (projectType === 'bot') {\n const projectDef = await resolveProjectDefinition()\n return this._deployBot(api, projectDef.definition, this.argv.botId, this.argv.createNewBot)\n }\n throw new errors.UnsupportedProjectType()\n }\n\n private async _runBuild() {\n return new BuildCommand(this.api, this.prompt, this.logger, this.argv).setProjectContext(this.projectContext).run()\n }\n\n private get _visibility(): 'public' | 'private' | 'unlisted' {\n if (this.argv.public && this.argv.visibility === 'private') {\n this.logger.warn('The --public flag is deprecated. Please use \"--visibility public\" instead.')\n return 'public'\n }\n\n if (this.argv.public && this.argv.visibility !== 'private') {\n this.logger.warn('The --public flag and --visibility option are both present. Ignoring the --public flag...')\n }\n\n return this.argv.visibility\n }\n\n private async _deployIntegration(api: apiUtils.ApiClient, integrationDef: sdk.IntegrationDefinition) {\n const res = await this._manageWorkspaceHandle(api, integrationDef)\n if (!res) return\n const { integration: updatedIntegrationDef, workspaceId } = res\n integrationDef = updatedIntegrationDef\n if (workspaceId) {\n api = api.switchWorkspace(workspaceId)\n }\n\n const { name, version } = integrationDef\n\n if (integrationDef.icon && !integrationDef.icon.toLowerCase().endsWith('.svg')) {\n throw new errors.BotpressCLIError('Icon must be an SVG file')\n }\n\n if (integrationDef.readme && !integrationDef.readme.toLowerCase().endsWith('.md')) {\n throw new errors.BotpressCLIError('Readme must be a Markdown file')\n }\n\n const integration = await api.findPublicOrPrivateIntegration({ type: 'name', name, version })\n if (integration && integration.workspaceId !== api.workspaceId) {\n throw new errors.BotpressCLIError(\n `Public integration ${name} v${version} is already deployed in another workspace.`\n )\n }\n\n if (integration && integration.visibility !== 'private' && !api.isBotpressWorkspace) {\n throw new errors.BotpressCLIError(\n `Integration ${name} v${version} is already deployed publicly and cannot be updated. Please bump the version.`\n )\n }\n\n let message: string\n if (integration) {\n this.logger.warn('Integration already exists. If you decide to deploy, it will override the existing one.')\n message = `Are you sure you want to override integration ${name} v${version}?`\n } else {\n message = `Are you sure you want to deploy integration ${name} v${version}?`\n }\n\n const confirm = await this.prompt.confirm(message)\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n\n this.logger.debug('Preparing integration request body...')\n\n const createBody = {\n ...(await this.prepareCreateIntegrationBody(integrationDef)),\n ...(await this.prepareIntegrationDependencies(integrationDef, api)),\n visibility: this._visibility,\n }\n\n const startedMessage = `Deploying integration ${chalk.bold(name)} v${version}...`\n const successMessage = 'Integration deployed'\n if (integration) {\n const updateBody = apiUtils.prepareUpdateIntegrationBody(\n {\n id: integration.id,\n ...createBody,\n },\n integration\n )\n\n const { secrets: knownSecrets } = integration\n updateBody.secrets = await this.promptSecrets(integrationDef, this.argv, { knownSecrets })\n this._detectDeprecatedFeatures(integrationDef, { allowDeprecated: true })\n\n const line = this.logger.line()\n line.started(startedMessage)\n\n if (this.argv.dryRun) {\n this.logger.log('Dry-run mode is active. Simulating integration update...')\n\n await api.client.validateIntegrationUpdate(updateBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update integration \"${name}\"`)\n })\n } else {\n await api.client.updateIntegration(updateBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update integration \"${name}\"`)\n })\n }\n\n line.success(successMessage)\n } else {\n this.logger.debug(`looking for previous version of integration \"${name}\"`)\n const previousVersion = await api.findPreviousIntegrationVersion({ type: 'name', name, version })\n\n if (previousVersion) {\n this.logger.debug(`previous version found: ${previousVersion.version}`)\n } else {\n this.logger.debug('no previous version found')\n }\n\n const knownSecrets = previousVersion?.secrets\n\n createBody.secrets = await this.promptSecrets(integrationDef, this.argv, { knownSecrets })\n this._detectDeprecatedFeatures(integrationDef, {\n allowDeprecated: this._allowDeprecatedFeatures(integrationDef, previousVersion),\n })\n\n const line = this.logger.line()\n line.started(startedMessage)\n\n if (this.argv.dryRun) {\n this.logger.log('Dry-run mode is active. Simulating integration creation...')\n\n await api.client.validateIntegrationCreation(createBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not create integration \"${name}\"`)\n })\n } else {\n await api.client.createIntegration(createBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not create integration \"${name}\"`)\n })\n }\n\n line.success(successMessage)\n }\n }\n\n private async _deployInterface(api: apiUtils.ApiClient, interfaceDeclaration: sdk.InterfaceDefinition) {\n if (this._visibility === 'unlisted') {\n throw new errors.BotpressCLIError(\n 'Unlisted visibility is not supported for interfaces. Please use \"public\" or \"private\".'\n )\n }\n\n if (interfaceDeclaration.icon && !interfaceDeclaration.icon.toLowerCase().endsWith('.svg')) {\n throw new errors.BotpressCLIError('Icon must be an SVG file')\n }\n\n if (interfaceDeclaration.readme && !interfaceDeclaration.readme.toLowerCase().endsWith('.md')) {\n throw new errors.BotpressCLIError('Readme must be a Markdown file')\n }\n\n const { name, version } = interfaceDeclaration\n const intrface = await api.findPublicOrPrivateInterface({ type: 'name', name, version })\n\n let message: string\n if (intrface) {\n this.logger.warn('Interface already exists. If you decide to deploy, it will override the existing one.')\n message = `Are you sure you want to override interface ${name} v${version}?`\n } else {\n message = `Are you sure you want to deploy interface ${name} v${version}?`\n }\n\n const confirm = await this.prompt.confirm(message)\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n\n const icon = await this.readProjectFile(interfaceDeclaration.icon, 'base64')\n const readme = await this.readProjectFile(interfaceDeclaration.readme, 'base64')\n\n if (this._visibility !== 'public') {\n this.logger.warn(\n 'You are currently publishing a private interface, which cannot be used by integrations and plugins. To fix this, change the visibility to \"public\"'\n )\n }\n\n const createBody = {\n ...(await apiUtils.prepareCreateInterfaceBody(interfaceDeclaration)),\n public: this._visibility === 'public',\n icon,\n readme,\n }\n\n const startedMessage = `Deploying interface ${chalk.bold(name)} v${version}...`\n const successMessage = 'Interface deployed'\n if (intrface) {\n const updateBody = apiUtils.prepareUpdateInterfaceBody(\n {\n id: intrface.id,\n ...createBody,\n },\n intrface\n )\n\n const line = this.logger.line()\n line.started(startedMessage)\n\n if (this.argv.dryRun) {\n this.logger.warn('Dry-run mode is not supported for interface updates. Skipping deployment...')\n } else {\n await api.client.updateInterface(updateBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update interface \"${name}\"`)\n })\n }\n\n line.success(successMessage)\n } else {\n const line = this.logger.line()\n line.started(startedMessage)\n\n if (this.argv.dryRun) {\n this.logger.warn('Dry-run mode is not supported for interface creation. Skipping deployment...')\n } else {\n await api.client.createInterface(createBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not create interface \"${name}\"`)\n })\n }\n\n line.success(successMessage)\n }\n }\n\n private async _deployPlugin(api: apiUtils.ApiClient, pluginDef: sdk.PluginDefinition) {\n const codeCJS = await fs.promises.readFile(this.projectPaths.abs.outFileCJS, 'utf-8')\n const codeESM = await fs.promises.readFile(this.projectPaths.abs.outFileESM, 'utf-8')\n\n const { name, version } = pluginDef\n\n if (pluginDef.icon && !pluginDef.icon.toLowerCase().endsWith('.svg')) {\n throw new errors.BotpressCLIError('Icon must be an SVG file')\n }\n\n if (pluginDef.readme && !pluginDef.readme.toLowerCase().endsWith('.md')) {\n throw new errors.BotpressCLIError('Readme must be a Markdown file')\n }\n\n const plugin = await api.findPublicOrPrivatePlugin({ type: 'name', name, version })\n\n let message: string\n if (plugin) {\n this.logger.warn('Plugin already exists. If you decide to deploy, it will override the existing one.')\n message = `Are you sure you want to override plugin ${name} v${version}?`\n } else {\n message = `Are you sure you want to deploy plugin ${name} v${version}?`\n }\n\n const confirm = await this.prompt.confirm(message)\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n\n this.logger.debug('Preparing plugin request body...')\n\n const icon = await this.readProjectFile(pluginDef.icon, 'base64')\n const readme = await this.readProjectFile(pluginDef.readme, 'base64')\n\n const createBody = {\n ...(await apiUtils.prepareCreatePluginBody(pluginDef)),\n ...(await this.preparePluginDependencies(pluginDef, api)),\n visibility: this._visibility,\n icon,\n readme,\n code: {\n node: codeCJS,\n browser: codeESM,\n },\n }\n\n const startedMessage = `Deploying plugin ${chalk.bold(name)} v${version}...`\n const successMessage = 'Plugin deployed'\n if (plugin) {\n const updateBody = apiUtils.prepareUpdatePluginBody(\n {\n id: plugin.id,\n ...createBody,\n },\n plugin\n )\n\n const line = this.logger.line()\n line.started(startedMessage)\n\n if (this.argv.dryRun) {\n this.logger.warn('Dry-run mode is not supported for plugin updates. Skipping deployment...')\n } else {\n await api.client.updatePlugin(updateBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update plugin \"${name}\"`)\n })\n }\n\n line.success(successMessage)\n } else {\n const line = this.logger.line()\n line.started(startedMessage)\n\n if (this.argv.dryRun) {\n this.logger.warn('Dry-run mode is not supported for plugin creation. Skipping deployment...')\n } else {\n await api.client.createPlugin(createBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not create plugin \"${name}\"`)\n })\n }\n\n line.success(successMessage)\n }\n }\n\n private _allowDeprecatedFeatures(\n integrationDef: sdk.IntegrationDefinition,\n previousVersion: client.Integration | undefined\n ): boolean {\n if (this.argv.allowDeprecated) {\n return true\n }\n\n if (!previousVersion) {\n return false\n }\n\n const versionDiff = semver.diff(integrationDef.version, previousVersion.version)\n if (!versionDiff) {\n return false\n }\n\n return utils.semver.releases.lt(versionDiff, 'major')\n }\n\n private _detectDeprecatedFeatures(\n integrationDef: sdk.IntegrationDefinition,\n opts: { allowDeprecated?: boolean } = {}\n ) {\n const deprecatedFields: string[] = []\n const { user, channels } = integrationDef\n if (user?.creation?.enabled) {\n deprecatedFields.push('user.creation')\n }\n\n for (const [channelName, channel] of Object.entries(channels ?? {})) {\n if (channel?.conversation?.creation?.enabled) {\n deprecatedFields.push(`channels.${channelName}.creation`)\n }\n }\n\n if (!deprecatedFields.length) {\n return\n }\n\n const errorMessage = `The following fields of the integration's definition are deprecated: ${deprecatedFields.join(\n ', '\n )}`\n\n if (opts.allowDeprecated) {\n this.logger.warn(errorMessage)\n } else {\n throw new errors.BotpressCLIError(errorMessage)\n }\n }\n\n private async _deployBot(\n api: apiUtils.ApiClient,\n botDefinition: sdk.BotDefinition,\n argvBotId: string | undefined,\n argvCreateNew: boolean | undefined\n ) {\n if (this.argv.dryRun) {\n this.logger.warn('Dry-run mode is not supported for bot deployments. Skipping deployment...')\n return\n }\n\n const outfile = this.projectPaths.abs.outFileCJS\n const code = await fs.promises.readFile(outfile, 'utf-8')\n\n let bot: client.Bot\n if (argvBotId && argvCreateNew) {\n throw new errors.BotpressCLIError('Cannot specify both --botId and --createNew')\n } else if (argvCreateNew) {\n const confirm = await this.prompt.confirm('Are you sure you want to create a new bot ?')\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n\n bot = await this._createNewBot(api)\n } else {\n bot = await this._getExistingBot(api, argvBotId)\n\n const confirm = await this.prompt.confirm(`Are you sure you want to deploy the bot \"${bot.name}\"?`)\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n }\n\n const line = this.logger.line()\n line.started(`Deploying bot ${chalk.bold(bot.name)}...`)\n\n const updateBotBody = apiUtils.prepareUpdateBotBody(\n {\n ...(await apiUtils.prepareCreateBotBody(botDefinition)),\n ...(await this.prepareBotDependencies(botDefinition, api)),\n id: bot.id,\n code,\n },\n bot\n )\n\n const { bot: updatedBot } = await api.client.updateBot(updateBotBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update bot \"${bot.name}\"`)\n })\n\n this.validateIntegrationRegistration(updatedBot, (failedIntegrations) =>\n this.logger.warn(\n `Some integrations failed to register:\\n${Object.entries(failedIntegrations)\n .map(([key, int]) => `\u2022 ${key}: ${int.statusReason}`)\n .join('\\n')}`\n )\n )\n\n const tablesPublisher = new tables.TablesPublisher({ api, logger: this.logger, prompt: this.prompt })\n await tablesPublisher.deployTables({ botId: updatedBot.id, botDefinition })\n\n line.success('Bot deployed')\n await this.displayIntegrationUrls({ api, bot: updatedBot })\n }\n\n private async _createNewBot(api: apiUtils.ApiClient): Promise<client.Bot> {\n const line = this.logger.line()\n const { bot: createdBot } = await api.client.createBot({}).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not create bot')\n })\n line.success(`Bot created with ID \"${createdBot.id}\" and name \"${createdBot.name}\"`)\n await this.projectCache.set('botId', createdBot.id)\n return createdBot\n }\n\n private async _getExistingBot(api: apiUtils.ApiClient, botId: string | undefined): Promise<client.Bot> {\n const promptedBotId = await this.projectCache.sync('botId', botId, async (defaultId) => {\n const userBots = await api\n .listAllPages(api.client.listBots, (r) => r.bots)\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not fetch existing bots')\n })\n\n if (!userBots.length) {\n throw new errors.NoBotsFoundError()\n }\n\n const initial = userBots.find((bot) => bot.id === defaultId)\n\n const prompted = await this.prompt.select('Which bot do you want to deploy?', {\n initial: initial && { title: initial.name, value: initial.id },\n choices: userBots.map((bot) => ({ title: bot.name, value: bot.id })),\n })\n\n if (!prompted) {\n throw new errors.ParamRequiredError('Bot Id')\n }\n\n return prompted\n })\n\n const { bot: fetchedBot } = await api.client.getBot({ id: promptedBotId }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not get bot info')\n })\n\n return fetchedBot\n }\n\n private async _manageWorkspaceHandle(\n api: apiUtils.ApiClient,\n integration: sdk.IntegrationDefinition\n ): Promise<\n | {\n integration: sdk.IntegrationDefinition\n workspaceId?: string // Set if user opted to deploy on another available workspace\n }\n | undefined\n > {\n const { name: localName, workspaceHandle: localHandle } = this._parseIntegrationName(integration.name)\n if (!localHandle && api.isBotpressWorkspace) {\n this.logger.debug('Botpress workspace detected; workspace handle omitted')\n return { integration } // botpress has the right to omit workspace handle\n }\n\n const { handle: remoteHandle, name: workspaceName } = await api.getWorkspace().catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not fetch workspace')\n })\n\n if (localHandle && remoteHandle) {\n let workspaceId: string | undefined = undefined\n if (localHandle !== remoteHandle) {\n const remoteWorkspace = await api.findWorkspaceByHandle(localHandle).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not list workspaces')\n })\n if (!remoteWorkspace) {\n throw new errors.BotpressCLIError(\n `The integration handle \"${localHandle}\" is not associated with any of your workspaces.`\n )\n }\n this.logger.warn(\n `Your are logged in to workspace \"${workspaceName}\" but integration handle \"${localHandle}\" belongs to \"${remoteWorkspace.name}\".`\n )\n const confirmUseAlternateWorkspace = await this.prompt.confirm(\n 'Do you want to deploy integration on this workspace instead?'\n )\n if (!confirmUseAlternateWorkspace) {\n throw new errors.BotpressCLIError(\n `Cannot deploy integration with handle \"${localHandle}\" on workspace \"${workspaceName}\"`\n )\n }\n\n workspaceId = remoteWorkspace.id\n }\n return { integration, workspaceId }\n }\n\n const workspaceHandleIsMandatoryMsg = 'Cannot deploy integration without workspace handle'\n\n if (!localHandle && remoteHandle) {\n const confirmAddHandle = await this.prompt.confirm(\n `Your current workspace handle is \"${remoteHandle}\". Do you want to use the name \"${remoteHandle}/${localName}\"?`\n )\n if (!confirmAddHandle) {\n this.logger.log('Aborted')\n return\n }\n const newName = `${remoteHandle}/${localName}`\n return { integration: new sdk.IntegrationDefinition({ ...integration, name: newName }) }\n }\n\n if (localHandle && !remoteHandle) {\n const { available } = await api.client.checkHandleAvailability({ handle: localHandle }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not check handle availability')\n })\n\n if (!available) {\n throw new errors.BotpressCLIError(`Handle \"${localHandle}\" is not yours and is not available`)\n }\n\n const confirmClaimHandle = await this.prompt.confirm(\n `Handle \"${localHandle}\" is available. Do you want to claim it for your workspace ${workspaceName}?`\n )\n if (!confirmClaimHandle) {\n throw new errors.BotpressCLIError(workspaceHandleIsMandatoryMsg)\n }\n\n await api.updateWorkspace({ handle: localHandle }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not claim handle \"${localHandle}\"`)\n })\n\n this.logger.success(`Handle \"${localHandle}\" is now yours!`)\n return { integration }\n }\n\n this.logger.warn(\"It seems you don't have a workspace handle yet.\")\n let claimedHandle: string | undefined = undefined\n do {\n const prompted = await this.prompt.text('Please enter a workspace handle')\n if (!prompted) {\n throw new errors.BotpressCLIError(workspaceHandleIsMandatoryMsg)\n }\n\n const { available, suggestions } = await api.client.checkHandleAvailability({ handle: prompted })\n if (!available) {\n this.logger.warn(`Handle \"${prompted}\" is not available. Suggestions: ${suggestions.join(', ')}`)\n continue\n }\n\n claimedHandle = prompted\n await api.updateWorkspace({ handle: claimedHandle }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not claim handle \"${claimedHandle}\"`)\n })\n } while (!claimedHandle)\n\n this.logger.success(`Handle \"${claimedHandle}\" is yours!`)\n const newName = `${claimedHandle}/${localName}`\n return { integration: new sdk.IntegrationDefinition({ ...integration, name: newName }) }\n }\n\n private _parseIntegrationName = (integrationName: string): { name: string; workspaceHandle?: string } => {\n const parts = integrationName.split('/')\n if (parts.length > 2) {\n throw new errors.BotpressCLIError(\n `Invalid integration name \"${integrationName}\": a single forward slash is allowed`\n )\n }\n if (parts.length === 2) {\n const [workspaceHandle, name] = parts as [string, string]\n return { name, workspaceHandle }\n }\n const [name] = parts as [string]\n return { name }\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,UAAqB;AACrB,mBAAkB;AAClB,SAAoB;AACpB,oBAAmB;AACnB,eAA0B;AAE1B,aAAwB;AACxB,aAAwB;AACxB,YAAuB;AACvB,2BAA6B;AAC7B,6BAA+B;AAGxB,MAAM,sBAAsB,sCAAwC;AAAA,EACzE,MAAa,MAAqB;AAChC,UAAM,MAAM,MAAM,KAAK,2BAA2B,KAAK,IAAI;AAE3D,QAAI,CAAC,KAAK,KAAK,SAAS;AACtB,YAAM,KAAK,UAAU;AAAA,IACvB;AAEA,UAAM,EAAE,aAAa,yBAAyB,IAAI,KAAK,4BAA4B;AAEnF,QAAI,gBAAgB,eAAe;AACjC,YAAM,aAAa,MAAM,yBAAyB;AAClD,aAAO,KAAK,mBAAmB,KAAK,WAAW,UAAU;AAAA,IAC3D;AACA,QAAI,gBAAgB,aAAa;AAC/B,YAAM,aAAa,MAAM,yBAAyB;AAClD,aAAO,KAAK,iBAAiB,KAAK,WAAW,UAAU;AAAA,IACzD;AACA,QAAI,gBAAgB,UAAU;AAC5B,YAAM,aAAa,MAAM,yBAAyB;AAClD,aAAO,KAAK,cAAc,KAAK,WAAW,UAAU;AAAA,IACtD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AAM,QAAQ,gBAAgB,MAAM,GAAG;AACvC,QAAI,MAAM,SAAS,GAAG;AACpB,YAAM,IAAI,OAAO;AAAA,QACf,6BAA6B,eAAe;AAAA,MAC9C;AAAA,IACF;AACA,QAAI,MAAM,WAAW,GAAG;AACtB,YAAM,CAAC,iBAAiBC,KAAI,IAAI;AAChC,aAAO,EAAE,MAAAA,OAAM,gBAAgB;AAAA,IACjC;AACA,UAAM,CAAC,IAAI,IAAI;AACf,WAAO,EAAE,KAAK;AAAA,EAChB;AACF;",
|
|
4
|
+
"sourcesContent": ["import type * as client from '@botpress/client'\nimport * as sdk from '@botpress/sdk'\nimport chalk from 'chalk'\nimport * as fs from 'fs'\nimport semver from 'semver'\nimport * as apiUtils from '../api'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport * as tables from '../tables'\nimport * as utils from '../utils'\nimport { BuildCommand } from './build-command'\nimport { ProjectCommand } from './project-command'\n\nexport type DeployCommandDefinition = typeof commandDefinitions.deploy\nexport class DeployCommand extends ProjectCommand<DeployCommandDefinition> {\n public async run(): Promise<void> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n\n if (!this.argv.noBuild) {\n await this._runBuild() // This ensures the bundle is always synced with source code\n }\n\n const { projectType, resolveProjectDefinition } = this.readProjectDefinitionFromFS()\n\n if (projectType === 'integration') {\n const projectDef = await resolveProjectDefinition()\n return this._deployIntegration(api, projectDef.definition)\n }\n if (projectType === 'interface') {\n const projectDef = await resolveProjectDefinition()\n return this._deployInterface(api, projectDef.definition)\n }\n if (projectType === 'plugin') {\n const projectDef = await resolveProjectDefinition()\n return this._deployPlugin(api, projectDef.definition)\n }\n if (projectType === 'bot') {\n const projectDef = await resolveProjectDefinition()\n return this._deployBot(api, projectDef.definition, this.argv.botId, this.argv.createNewBot)\n }\n throw new errors.UnsupportedProjectType()\n }\n\n private async _runBuild() {\n return new BuildCommand(this.api, this.prompt, this.logger, this.argv).setProjectContext(this.projectContext).run()\n }\n\n private get _visibility(): 'public' | 'private' | 'unlisted' {\n if (this.argv.public && this.argv.visibility === 'private') {\n this.logger.warn('The --public flag is deprecated. Please use \"--visibility public\" instead.')\n return 'public'\n }\n\n if (this.argv.public && this.argv.visibility !== 'private') {\n this.logger.warn('The --public flag and --visibility option are both present. Ignoring the --public flag...')\n }\n\n return this.argv.visibility\n }\n\n private async _deployIntegration(api: apiUtils.ApiClient, integrationDef: sdk.IntegrationDefinition) {\n const res = await this._manageWorkspaceHandle(api, integrationDef)\n if (!res) return\n const { integration: updatedIntegrationDef, workspaceId } = res\n integrationDef = updatedIntegrationDef\n if (workspaceId) {\n api = api.switchWorkspace(workspaceId)\n }\n\n const { name, version } = integrationDef\n\n if (integrationDef.icon && !integrationDef.icon.toLowerCase().endsWith('.svg')) {\n throw new errors.BotpressCLIError('Icon must be an SVG file')\n }\n\n if (integrationDef.readme && !integrationDef.readme.toLowerCase().endsWith('.md')) {\n throw new errors.BotpressCLIError('Readme must be a Markdown file')\n }\n\n const integration = await api.findPublicOrPrivateIntegration({ type: 'name', name, version })\n if (integration && integration.workspaceId !== api.workspaceId) {\n throw new errors.BotpressCLIError(\n `Public integration ${name} v${version} is already deployed in another workspace.`\n )\n }\n\n if (integration && integration.visibility !== 'private' && !api.isBotpressWorkspace) {\n throw new errors.BotpressCLIError(\n `Integration ${name} v${version} is already deployed publicly and cannot be updated. Please bump the version.`\n )\n }\n\n let message: string\n if (integration) {\n this.logger.warn('Integration already exists. If you decide to deploy, it will override the existing one.')\n message = `Are you sure you want to override integration ${name} v${version}?`\n } else {\n message = `Are you sure you want to deploy integration ${name} v${version}?`\n }\n\n const confirm = await this.prompt.confirm(message)\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n\n this.logger.debug('Preparing integration request body...')\n\n const createBody = {\n ...(await this.prepareCreateIntegrationBody(integrationDef)),\n ...(await this.prepareIntegrationDependencies(integrationDef, api)),\n visibility: this._visibility,\n sdkVersion: integrationDef.metadata?.sdkVersion,\n }\n\n const startedMessage = `Deploying integration ${chalk.bold(name)} v${version}...`\n const successMessage = 'Integration deployed'\n if (integration) {\n const updateBody = apiUtils.prepareUpdateIntegrationBody(\n {\n id: integration.id,\n ...createBody,\n },\n integration\n )\n\n const { secrets: knownSecrets } = integration\n updateBody.secrets = await this.promptSecrets(integrationDef, this.argv, { knownSecrets })\n this._detectDeprecatedFeatures(integrationDef, { allowDeprecated: true })\n\n const line = this.logger.line()\n line.started(startedMessage)\n\n if (this.argv.dryRun) {\n this.logger.log('Dry-run mode is active. Simulating integration update...')\n\n await api.client.validateIntegrationUpdate(updateBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update integration \"${name}\"`)\n })\n } else {\n await api.client.updateIntegration(updateBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update integration \"${name}\"`)\n })\n }\n\n line.success(successMessage)\n } else {\n this.logger.debug(`looking for previous version of integration \"${name}\"`)\n const previousVersion = await api.findPreviousIntegrationVersion({ type: 'name', name, version })\n\n if (previousVersion) {\n this.logger.debug(`previous version found: ${previousVersion.version}`)\n } else {\n this.logger.debug('no previous version found')\n }\n\n const knownSecrets = previousVersion?.secrets\n\n createBody.secrets = await this.promptSecrets(integrationDef, this.argv, { knownSecrets })\n this._detectDeprecatedFeatures(integrationDef, {\n allowDeprecated: this._allowDeprecatedFeatures(integrationDef, previousVersion),\n })\n\n const line = this.logger.line()\n line.started(startedMessage)\n\n if (this.argv.dryRun) {\n this.logger.log('Dry-run mode is active. Simulating integration creation...')\n\n await api.client.validateIntegrationCreation(createBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not create integration \"${name}\"`)\n })\n } else {\n await api.client.createIntegration(createBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not create integration \"${name}\"`)\n })\n }\n\n line.success(successMessage)\n }\n }\n\n private async _deployInterface(api: apiUtils.ApiClient, interfaceDeclaration: sdk.InterfaceDefinition) {\n if (this._visibility === 'unlisted') {\n throw new errors.BotpressCLIError(\n 'Unlisted visibility is not supported for interfaces. Please use \"public\" or \"private\".'\n )\n }\n\n if (interfaceDeclaration.icon && !interfaceDeclaration.icon.toLowerCase().endsWith('.svg')) {\n throw new errors.BotpressCLIError('Icon must be an SVG file')\n }\n\n if (interfaceDeclaration.readme && !interfaceDeclaration.readme.toLowerCase().endsWith('.md')) {\n throw new errors.BotpressCLIError('Readme must be a Markdown file')\n }\n\n const { name, version } = interfaceDeclaration\n const intrface = await api.findPublicOrPrivateInterface({ type: 'name', name, version })\n\n let message: string\n if (intrface) {\n this.logger.warn('Interface already exists. If you decide to deploy, it will override the existing one.')\n message = `Are you sure you want to override interface ${name} v${version}?`\n } else {\n message = `Are you sure you want to deploy interface ${name} v${version}?`\n }\n\n const confirm = await this.prompt.confirm(message)\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n\n const icon = await this.readProjectFile(interfaceDeclaration.icon, 'base64')\n const readme = await this.readProjectFile(interfaceDeclaration.readme, 'base64')\n\n if (this._visibility !== 'public') {\n this.logger.warn(\n 'You are currently publishing a private interface, which cannot be used by integrations and plugins. To fix this, change the visibility to \"public\"'\n )\n }\n\n const createBody = {\n ...(await apiUtils.prepareCreateInterfaceBody(interfaceDeclaration)),\n public: this._visibility === 'public',\n icon,\n readme,\n sdkVersion: interfaceDeclaration.metadata?.sdkVersion,\n }\n\n const startedMessage = `Deploying interface ${chalk.bold(name)} v${version}...`\n const successMessage = 'Interface deployed'\n if (intrface) {\n const updateBody = apiUtils.prepareUpdateInterfaceBody(\n {\n id: intrface.id,\n ...createBody,\n },\n intrface\n )\n\n const line = this.logger.line()\n line.started(startedMessage)\n\n if (this.argv.dryRun) {\n this.logger.warn('Dry-run mode is not supported for interface updates. Skipping deployment...')\n } else {\n await api.client.updateInterface(updateBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update interface \"${name}\"`)\n })\n }\n\n line.success(successMessage)\n } else {\n const line = this.logger.line()\n line.started(startedMessage)\n\n if (this.argv.dryRun) {\n this.logger.warn('Dry-run mode is not supported for interface creation. Skipping deployment...')\n } else {\n await api.client.createInterface(createBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not create interface \"${name}\"`)\n })\n }\n\n line.success(successMessage)\n }\n }\n\n private async _deployPlugin(api: apiUtils.ApiClient, pluginDef: sdk.PluginDefinition) {\n const codeCJS = await fs.promises.readFile(this.projectPaths.abs.outFileCJS, 'utf-8')\n const codeESM = await fs.promises.readFile(this.projectPaths.abs.outFileESM, 'utf-8')\n\n const { name, version } = pluginDef\n\n if (pluginDef.icon && !pluginDef.icon.toLowerCase().endsWith('.svg')) {\n throw new errors.BotpressCLIError('Icon must be an SVG file')\n }\n\n if (pluginDef.readme && !pluginDef.readme.toLowerCase().endsWith('.md')) {\n throw new errors.BotpressCLIError('Readme must be a Markdown file')\n }\n\n const plugin = await api.findPublicOrPrivatePlugin({ type: 'name', name, version })\n\n let message: string\n if (plugin) {\n this.logger.warn('Plugin already exists. If you decide to deploy, it will override the existing one.')\n message = `Are you sure you want to override plugin ${name} v${version}?`\n } else {\n message = `Are you sure you want to deploy plugin ${name} v${version}?`\n }\n\n const confirm = await this.prompt.confirm(message)\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n\n this.logger.debug('Preparing plugin request body...')\n\n const icon = await this.readProjectFile(pluginDef.icon, 'base64')\n const readme = await this.readProjectFile(pluginDef.readme, 'base64')\n\n const createBody = {\n ...(await apiUtils.prepareCreatePluginBody(pluginDef)),\n ...(await this.preparePluginDependencies(pluginDef, api)),\n visibility: this._visibility,\n icon,\n readme,\n code: {\n node: codeCJS,\n browser: codeESM,\n },\n sdkVersion: pluginDef.metadata?.sdkVersion,\n }\n\n const startedMessage = `Deploying plugin ${chalk.bold(name)} v${version}...`\n const successMessage = 'Plugin deployed'\n if (plugin) {\n const updateBody = apiUtils.prepareUpdatePluginBody(\n {\n id: plugin.id,\n ...createBody,\n },\n plugin\n )\n\n const line = this.logger.line()\n line.started(startedMessage)\n\n if (this.argv.dryRun) {\n this.logger.warn('Dry-run mode is not supported for plugin updates. Skipping deployment...')\n } else {\n await api.client.updatePlugin(updateBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update plugin \"${name}\"`)\n })\n }\n\n line.success(successMessage)\n } else {\n const line = this.logger.line()\n line.started(startedMessage)\n\n if (this.argv.dryRun) {\n this.logger.warn('Dry-run mode is not supported for plugin creation. Skipping deployment...')\n } else {\n await api.client.createPlugin(createBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not create plugin \"${name}\"`)\n })\n }\n\n line.success(successMessage)\n }\n }\n\n private _allowDeprecatedFeatures(\n integrationDef: sdk.IntegrationDefinition,\n previousVersion: client.Integration | undefined\n ): boolean {\n if (this.argv.allowDeprecated) {\n return true\n }\n\n if (!previousVersion) {\n return false\n }\n\n const versionDiff = semver.diff(integrationDef.version, previousVersion.version)\n if (!versionDiff) {\n return false\n }\n\n return utils.semver.releases.lt(versionDiff, 'major')\n }\n\n private _detectDeprecatedFeatures(\n integrationDef: sdk.IntegrationDefinition,\n opts: { allowDeprecated?: boolean } = {}\n ) {\n const deprecatedFields: string[] = []\n const { user, channels } = integrationDef\n if (user?.creation?.enabled) {\n deprecatedFields.push('user.creation')\n }\n\n for (const [channelName, channel] of Object.entries(channels ?? {})) {\n if (channel?.conversation?.creation?.enabled) {\n deprecatedFields.push(`channels.${channelName}.creation`)\n }\n }\n\n if (!deprecatedFields.length) {\n return\n }\n\n const errorMessage = `The following fields of the integration's definition are deprecated: ${deprecatedFields.join(\n ', '\n )}`\n\n if (opts.allowDeprecated) {\n this.logger.warn(errorMessage)\n } else {\n throw new errors.BotpressCLIError(errorMessage)\n }\n }\n\n private async _deployBot(\n api: apiUtils.ApiClient,\n botDefinition: sdk.BotDefinition,\n argvBotId: string | undefined,\n argvCreateNew: boolean | undefined\n ) {\n if (this.argv.dryRun) {\n this.logger.warn('Dry-run mode is not supported for bot deployments. Skipping deployment...')\n return\n }\n\n const outfile = this.projectPaths.abs.outFileCJS\n const code = await fs.promises.readFile(outfile, 'utf-8')\n\n let bot: client.Bot\n if (argvBotId && argvCreateNew) {\n throw new errors.BotpressCLIError('Cannot specify both --botId and --createNew')\n } else if (argvCreateNew) {\n const confirm = await this.prompt.confirm('Are you sure you want to create a new bot ?')\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n\n bot = await this._createNewBot(api)\n } else {\n bot = await this._getExistingBot(api, argvBotId)\n\n const confirm = await this.prompt.confirm(`Are you sure you want to deploy the bot \"${bot.name}\"?`)\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n }\n\n const line = this.logger.line()\n line.started(`Deploying bot ${chalk.bold(bot.name)}...`)\n\n const updateBotBody = apiUtils.prepareUpdateBotBody(\n {\n ...(await apiUtils.prepareCreateBotBody(botDefinition)),\n ...(await this.prepareBotDependencies(botDefinition, api)),\n id: bot.id,\n code,\n },\n bot\n )\n\n const { bot: updatedBot } = await api.client.updateBot(updateBotBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update bot \"${bot.name}\"`)\n })\n\n this.validateIntegrationRegistration(updatedBot, (failedIntegrations) =>\n this.logger.warn(\n `Some integrations failed to register:\\n${Object.entries(failedIntegrations)\n .map(([key, int]) => `\u2022 ${key}: ${int.statusReason}`)\n .join('\\n')}`\n )\n )\n\n const tablesPublisher = new tables.TablesPublisher({ api, logger: this.logger, prompt: this.prompt })\n await tablesPublisher.deployTables({ botId: updatedBot.id, botDefinition })\n\n line.success('Bot deployed')\n await this.displayIntegrationUrls({ api, bot: updatedBot })\n }\n\n private async _createNewBot(api: apiUtils.ApiClient): Promise<client.Bot> {\n const line = this.logger.line()\n const { bot: createdBot } = await api.client.createBot({}).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not create bot')\n })\n line.success(`Bot created with ID \"${createdBot.id}\" and name \"${createdBot.name}\"`)\n await this.projectCache.set('botId', createdBot.id)\n return createdBot\n }\n\n private async _getExistingBot(api: apiUtils.ApiClient, botId: string | undefined): Promise<client.Bot> {\n const promptedBotId = await this.projectCache.sync('botId', botId, async (defaultId) => {\n const userBots = await api\n .listAllPages(api.client.listBots, (r) => r.bots)\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not fetch existing bots')\n })\n\n if (!userBots.length) {\n throw new errors.NoBotsFoundError()\n }\n\n const initial = userBots.find((bot) => bot.id === defaultId)\n\n const prompted = await this.prompt.select('Which bot do you want to deploy?', {\n initial: initial && { title: initial.name, value: initial.id },\n choices: userBots.map((bot) => ({ title: bot.name, value: bot.id })),\n })\n\n if (!prompted) {\n throw new errors.ParamRequiredError('Bot Id')\n }\n\n return prompted\n })\n\n const { bot: fetchedBot } = await api.client.getBot({ id: promptedBotId }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not get bot info')\n })\n\n return fetchedBot\n }\n\n private async _manageWorkspaceHandle(\n api: apiUtils.ApiClient,\n integration: sdk.IntegrationDefinition\n ): Promise<\n | {\n integration: sdk.IntegrationDefinition\n workspaceId?: string // Set if user opted to deploy on another available workspace\n }\n | undefined\n > {\n const { name: localName, workspaceHandle: localHandle } = this._parseIntegrationName(integration.name)\n if (!localHandle && api.isBotpressWorkspace) {\n this.logger.debug('Botpress workspace detected; workspace handle omitted')\n return { integration } // botpress has the right to omit workspace handle\n }\n\n const { handle: remoteHandle, name: workspaceName } = await api.getWorkspace().catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not fetch workspace')\n })\n\n if (localHandle && remoteHandle) {\n let workspaceId: string | undefined = undefined\n if (localHandle !== remoteHandle) {\n const remoteWorkspace = await api.findWorkspaceByHandle(localHandle).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not list workspaces')\n })\n if (!remoteWorkspace) {\n throw new errors.BotpressCLIError(\n `The integration handle \"${localHandle}\" is not associated with any of your workspaces.`\n )\n }\n this.logger.warn(\n `Your are logged in to workspace \"${workspaceName}\" but integration handle \"${localHandle}\" belongs to \"${remoteWorkspace.name}\".`\n )\n const confirmUseAlternateWorkspace = await this.prompt.confirm(\n 'Do you want to deploy integration on this workspace instead?'\n )\n if (!confirmUseAlternateWorkspace) {\n throw new errors.BotpressCLIError(\n `Cannot deploy integration with handle \"${localHandle}\" on workspace \"${workspaceName}\"`\n )\n }\n\n workspaceId = remoteWorkspace.id\n }\n return { integration, workspaceId }\n }\n\n const workspaceHandleIsMandatoryMsg = 'Cannot deploy integration without workspace handle'\n\n if (!localHandle && remoteHandle) {\n const confirmAddHandle = await this.prompt.confirm(\n `Your current workspace handle is \"${remoteHandle}\". Do you want to use the name \"${remoteHandle}/${localName}\"?`\n )\n if (!confirmAddHandle) {\n this.logger.log('Aborted')\n return\n }\n const newName = `${remoteHandle}/${localName}`\n return { integration: new sdk.IntegrationDefinition({ ...integration, name: newName }) }\n }\n\n if (localHandle && !remoteHandle) {\n const { available } = await api.client.checkHandleAvailability({ handle: localHandle }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not check handle availability')\n })\n\n if (!available) {\n throw new errors.BotpressCLIError(`Handle \"${localHandle}\" is not yours and is not available`)\n }\n\n const confirmClaimHandle = await this.prompt.confirm(\n `Handle \"${localHandle}\" is available. Do you want to claim it for your workspace ${workspaceName}?`\n )\n if (!confirmClaimHandle) {\n throw new errors.BotpressCLIError(workspaceHandleIsMandatoryMsg)\n }\n\n await api.updateWorkspace({ handle: localHandle }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not claim handle \"${localHandle}\"`)\n })\n\n this.logger.success(`Handle \"${localHandle}\" is now yours!`)\n return { integration }\n }\n\n this.logger.warn(\"It seems you don't have a workspace handle yet.\")\n let claimedHandle: string | undefined = undefined\n do {\n const prompted = await this.prompt.text('Please enter a workspace handle')\n if (!prompted) {\n throw new errors.BotpressCLIError(workspaceHandleIsMandatoryMsg)\n }\n\n const { available, suggestions } = await api.client.checkHandleAvailability({ handle: prompted })\n if (!available) {\n this.logger.warn(`Handle \"${prompted}\" is not available. Suggestions: ${suggestions.join(', ')}`)\n continue\n }\n\n claimedHandle = prompted\n await api.updateWorkspace({ handle: claimedHandle }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not claim handle \"${claimedHandle}\"`)\n })\n } while (!claimedHandle)\n\n this.logger.success(`Handle \"${claimedHandle}\" is yours!`)\n const newName = `${claimedHandle}/${localName}`\n return { integration: new sdk.IntegrationDefinition({ ...integration, name: newName }) }\n }\n\n private _parseIntegrationName = (integrationName: string): { name: string; workspaceHandle?: string } => {\n const parts = integrationName.split('/')\n if (parts.length > 2) {\n throw new errors.BotpressCLIError(\n `Invalid integration name \"${integrationName}\": a single forward slash is allowed`\n )\n }\n if (parts.length === 2) {\n const [workspaceHandle, name] = parts as [string, string]\n return { name, workspaceHandle }\n }\n const [name] = parts as [string]\n return { name }\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,UAAqB;AACrB,mBAAkB;AAClB,SAAoB;AACpB,oBAAmB;AACnB,eAA0B;AAE1B,aAAwB;AACxB,aAAwB;AACxB,YAAuB;AACvB,2BAA6B;AAC7B,6BAA+B;AAGxB,MAAM,sBAAsB,sCAAwC;AAAA,EACzE,MAAa,MAAqB;AAChC,UAAM,MAAM,MAAM,KAAK,2BAA2B,KAAK,IAAI;AAE3D,QAAI,CAAC,KAAK,KAAK,SAAS;AACtB,YAAM,KAAK,UAAU;AAAA,IACvB;AAEA,UAAM,EAAE,aAAa,yBAAyB,IAAI,KAAK,4BAA4B;AAEnF,QAAI,gBAAgB,eAAe;AACjC,YAAM,aAAa,MAAM,yBAAyB;AAClD,aAAO,KAAK,mBAAmB,KAAK,WAAW,UAAU;AAAA,IAC3D;AACA,QAAI,gBAAgB,aAAa;AAC/B,YAAM,aAAa,MAAM,yBAAyB;AAClD,aAAO,KAAK,iBAAiB,KAAK,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AAEV,SAAK,OAAO,QAAQ,WAAW,aAAa,aAAa;AACzD,UAAM,UAAU,GAAG,aAAa,IAAI,SAAS;AAC7C,WAAO,EAAE,aAAa,IAAI,IAAI,sBAAsB,EAAE,GAAG,aAAa,MAAM,QAAQ,CAAC,EAAE;AAAA,EACzF;AAAA,EAEQ,wBAAwB,CAAC,oBAAwE;AACvG,UAAM,QAAQ,gBAAgB,MAAM,GAAG;AACvC,QAAI,MAAM,SAAS,GAAG;AACpB,YAAM,IAAI,OAAO;AAAA,QACf,6BAA6B,eAAe;AAAA,MAC9C;AAAA,IACF;AACA,QAAI,MAAM,WAAW,GAAG;AACtB,YAAM,CAAC,iBAAiBC,KAAI,IAAI;AAChC,aAAO,EAAE,MAAAA,OAAM,gBAAgB;AAAA,IACjC;AACA,UAAM,CAAC,IAAI,IAAI;AACf,WAAO,EAAE,KAAK;AAAA,EAChB;AACF;",
|
|
6
6
|
"names": ["chalk", "semver", "newName", "name"]
|
|
7
7
|
}
|
package/dist/config.d.ts
CHANGED
package/dist/config.js
CHANGED
|
@@ -231,6 +231,10 @@ const addSchema = {
|
|
|
231
231
|
type: "boolean",
|
|
232
232
|
description: "If a dev version of the package is found, use it",
|
|
233
233
|
default: false
|
|
234
|
+
},
|
|
235
|
+
alias: {
|
|
236
|
+
type: "string",
|
|
237
|
+
description: "The alias of the dependency you want to install"
|
|
234
238
|
}
|
|
235
239
|
};
|
|
236
240
|
const loginSchema = {
|
package/dist/config.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/config.ts"],
|
|
4
|
-
"sourcesContent": ["import * as consts from './consts'\nimport { ProjectTemplates } from './project-templates'\nimport type { CommandOption, CommandSchema } from './typings'\n\n// command options\n\nconst port = {\n type: 'number',\n description: 'The port to use',\n} satisfies CommandOption\n\nconst workDir = {\n type: 'string',\n description: 'The path to the project',\n default: consts.defaultWorkDir,\n} satisfies CommandOption\n\nconst noBuild = {\n type: 'boolean',\n description: 'Skip the build step',\n default: false,\n} satisfies CommandOption\n\nconst dryRun = {\n type: 'boolean',\n description: 'Ask the API not to perform the actual operation',\n default: false,\n} as const satisfies CommandOption\n\nconst apiUrl = {\n type: 'string',\n description: 'The URL of the Botpress server',\n} satisfies CommandOption\n\nconst token = {\n type: 'string',\n description: 'You Personal Access Token ',\n} satisfies CommandOption\n\nconst workspaceId = {\n type: 'string',\n description: 'The Workspace Id to deploy to',\n} satisfies CommandOption\n\nconst secrets = {\n type: 'string',\n description: 'Values for the integration secrets',\n array: true,\n default: [],\n} satisfies CommandOption\n\nconst botRef = {\n type: 'string',\n description: 'The bot ID. Bot Name is not supported.',\n demandOption: true,\n positional: true,\n idx: 0,\n} satisfies CommandOption\n\nconst packageType = {\n type: 'string',\n description:\n 'Either an integration or an interface; helps disambiguate the package type in case both an integration and an interface have the same reference.',\n choices: ['integration', 'interface', 'plugin'] as const,\n} satisfies CommandOption\n\nconst packageRef = {\n type: 'string',\n description:\n 'The package ID or name with optional version. The package can be either an integration or an interface. Ex: teams, teams@0.2.0, llm@5.1.0',\n positional: true,\n idx: 0,\n} satisfies CommandOption\n\nconst integrationRef = {\n ...packageRef,\n demandOption: true,\n description: 'The integration ID or name with optional version. Ex: teams or teams@0.2.0',\n} satisfies CommandOption\n\nconst interfaceRef = {\n ...packageRef,\n demandOption: true,\n description: 'The interface ID or name and version. Ex: llm@5.1.0',\n} satisfies CommandOption\n\nconst pluginRef = {\n ...packageRef,\n demandOption: true,\n description: 'The plugin ID or name and version. Ex: knowledge@0.0.1',\n} satisfies CommandOption\n\nconst sourceMap = { type: 'boolean', description: 'Generate sourcemaps', default: false } satisfies CommandOption\n\nconst minify = { type: 'boolean', description: 'Minify the bundled code', default: true } satisfies CommandOption\n\nconst dev = {\n type: 'boolean',\n description: 'List only dev bots / dev integrations',\n default: false,\n} satisfies CommandOption\n\n// base schemas\n\nconst globalSchema = {\n verbose: {\n type: 'boolean',\n description: 'Enable verbose logging',\n alias: 'v',\n default: false,\n },\n confirm: {\n type: 'boolean',\n description: 'Confirm all prompts',\n alias: 'y',\n default: false,\n },\n json: {\n type: 'boolean',\n description: 'Prevent logging anything else than raw json in stdout. Useful for piping output to other tools',\n default: false,\n },\n botpressHome: {\n type: 'string',\n description: 'The path to the Botpress home directory',\n default: consts.defaultBotpressHome,\n },\n profile: {\n type: 'string',\n description: 'The CLI profile defined in the $BP_BOTPRESS_HOME/profiles.json',\n alias: 'p',\n },\n} satisfies CommandSchema\n\nconst projectSchema = {\n ...globalSchema,\n workDir,\n} satisfies CommandSchema\n\nconst credentialsSchema = {\n apiUrl,\n workspaceId,\n token,\n} satisfies CommandSchema\n\nconst secretsSchema = {\n secrets,\n} satisfies CommandSchema\n\n// command schemas\n\nconst generateSchema = {\n ...projectSchema,\n} satisfies CommandSchema\n\nconst bundleSchema = {\n ...projectSchema,\n sourceMap,\n minify,\n} satisfies CommandSchema\n\nconst buildSchema = {\n ...projectSchema,\n sourceMap,\n minify,\n} satisfies CommandSchema\n\nconst readSchema = {\n ...projectSchema,\n} satisfies CommandSchema\n\nconst serveSchema = {\n ...projectSchema,\n ...secretsSchema,\n port,\n} satisfies CommandSchema\n\nconst deploySchema = {\n ...projectSchema,\n ...credentialsSchema,\n ...secretsSchema,\n botId: { type: 'string', description: 'The bot ID to deploy. Only used when deploying a bot' },\n noBuild,\n dryRun,\n createNewBot: { type: 'boolean', description: 'Create a new bot when deploying. Only used when deploying a bot' },\n sourceMap,\n minify,\n visibility: {\n type: 'string',\n choices: ['public', 'private', 'unlisted'] as const,\n description:\n 'The visibility of the project. By default, projects are always private. Unlisted visibility is only supported for integrations and plugins.',\n default: 'private',\n },\n public: {\n type: 'boolean',\n description: 'DEPRECATED: Please use \"--visibility public\" instead.',\n default: false,\n deprecated: true,\n } satisfies CommandOption,\n allowDeprecated: {\n type: 'boolean',\n description: 'Allow deprecated features in the project',\n default: false,\n },\n} as const satisfies CommandSchema\n\nconst devSchema = {\n ...projectSchema,\n ...credentialsSchema,\n ...secretsSchema,\n sourceMap,\n minify,\n port,\n tunnelUrl: {\n type: 'string',\n description: 'The tunnel HTTP URL to use',\n default: consts.defaultTunnelUrl,\n },\n tunnelId: {\n type: 'string',\n description: 'The tunnel ID to use. The ID will be generated if not specified',\n },\n} satisfies CommandSchema\n\nconst addSchema = {\n ...globalSchema,\n ...credentialsSchema,\n packageRef,\n packageType,\n installPath: {\n type: 'string',\n description: 'The path where to install the package',\n default: consts.defaultInstallPath,\n },\n useDev: {\n type: 'boolean',\n description: 'If a dev version of the package is found, use it',\n default: false,\n },\n} satisfies CommandSchema\n\nconst loginSchema = {\n ...globalSchema,\n token,\n workspaceId,\n apiUrl: { ...apiUrl, default: consts.defaultBotpressApiUrl },\n} satisfies CommandSchema\n\nconst logoutSchema = {\n ...globalSchema,\n} satisfies CommandSchema\n\nconst createBotSchema = {\n ...globalSchema,\n ...credentialsSchema,\n name: { type: 'string', description: 'The name of the bot to create' },\n ifNotExists: {\n type: 'boolean',\n description: 'Do not create if a bot with the same name already exists',\n default: false,\n },\n} satisfies CommandSchema\n\nconst getBotSchema = {\n ...globalSchema,\n ...credentialsSchema,\n botRef,\n} satisfies CommandSchema\n\nconst deleteBotSchema = {\n ...globalSchema,\n ...credentialsSchema,\n botRef,\n} satisfies CommandSchema\n\nconst listBotsSchema = {\n ...globalSchema,\n ...credentialsSchema,\n dev,\n} satisfies CommandSchema\n\nconst getIntegrationSchema = {\n ...globalSchema,\n ...credentialsSchema,\n integrationRef,\n} satisfies CommandSchema\n\nconst listIntegrationsSchema = {\n ...globalSchema,\n ...credentialsSchema,\n name: { type: 'string', description: 'The name filter when listing integrations' },\n versionNumber: { type: 'string', description: 'The version filter when listing integrations' },\n dev,\n} satisfies CommandSchema\n\nconst deleteIntegrationSchema = {\n ...globalSchema,\n ...credentialsSchema,\n integrationRef,\n} satisfies CommandSchema\n\nconst getInterfaceSchema = {\n ...globalSchema,\n ...credentialsSchema,\n interfaceRef,\n} satisfies CommandSchema\n\nconst listInterfacesSchema = {\n ...globalSchema,\n ...credentialsSchema,\n} satisfies CommandSchema\n\nconst deleteInterfaceSchema = {\n ...globalSchema,\n ...credentialsSchema,\n interfaceRef,\n} satisfies CommandSchema\n\nconst getPluginSchema = {\n ...globalSchema,\n ...credentialsSchema,\n pluginRef,\n} satisfies CommandSchema\n\nconst listPluginsSchema = {\n ...globalSchema,\n ...credentialsSchema,\n name: { type: 'string', description: 'The name filter when listing plugins' },\n versionNumber: { type: 'string', description: 'The version filter when listing plugins' },\n} satisfies CommandSchema\n\nconst deletePluginSchema = {\n ...globalSchema,\n ...credentialsSchema,\n pluginRef,\n} satisfies CommandSchema\n\nconst initSchema = {\n ...globalSchema,\n workDir,\n type: { type: 'string', choices: ['bot', 'integration', 'plugin'] as const },\n template: {\n type: 'string',\n choices: ProjectTemplates.getAllChoices(),\n description: 'The template to use',\n },\n name: { type: 'string', description: 'The name of the project' },\n} satisfies CommandSchema\n\nconst lintSchema = {\n ...projectSchema,\n} satisfies CommandSchema\n\nconst chatSchema = {\n ...globalSchema,\n ...credentialsSchema,\n chatApiUrl: {\n type: 'string',\n description: 'The URL of the chat server',\n },\n botId: {\n type: 'string',\n positional: true,\n idx: 0,\n description: 'The bot ID to chat with',\n },\n} satisfies CommandSchema\n\nconst listProfilesSchema = {\n ...globalSchema,\n} satisfies CommandSchema\n\nconst activeProfileSchema = {\n ...globalSchema,\n} satisfies CommandSchema\n\nconst useProfileSchema = {\n ...globalSchema,\n profileToUse: {\n type: 'string',\n description: 'The CLI profile defined in the $BP_BOTPRESS_HOME/profiles.json',\n positional: true,\n idx: 0,\n },\n} satisfies CommandSchema\n\n// exports\n\nexport const schemas = {\n global: globalSchema,\n project: projectSchema,\n credentials: credentialsSchema,\n secrets: secretsSchema,\n login: loginSchema,\n logout: logoutSchema,\n createBot: createBotSchema,\n getBot: getBotSchema,\n deleteBot: deleteBotSchema,\n listBots: listBotsSchema,\n getIntegration: getIntegrationSchema,\n listIntegrations: listIntegrationsSchema,\n deleteIntegration: deleteIntegrationSchema,\n getInterface: getInterfaceSchema,\n listInterfaces: listInterfacesSchema,\n deleteInterface: deleteInterfaceSchema,\n getPlugin: getPluginSchema,\n listPlugins: listPluginsSchema,\n deletePlugin: deletePluginSchema,\n init: initSchema,\n generate: generateSchema,\n bundle: bundleSchema,\n build: buildSchema,\n read: readSchema,\n serve: serveSchema,\n deploy: deploySchema,\n add: addSchema,\n dev: devSchema,\n lint: lintSchema,\n chat: chatSchema,\n listProfiles: listProfilesSchema,\n activeProfile: activeProfileSchema,\n useProfile: useProfileSchema,\n} as const\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAAwB;AACxB,+BAAiC;AAKjC,MAAM,OAAO;AAAA,EACX,MAAM;AAAA,EACN,aAAa;AACf;AAEA,MAAM,UAAU;AAAA,EACd,MAAM;AAAA,EACN,aAAa;AAAA,EACb,SAAS,OAAO;AAClB;AAEA,MAAM,UAAU;AAAA,EACd,MAAM;AAAA,EACN,aAAa;AAAA,EACb,SAAS;AACX;AAEA,MAAM,SAAS;AAAA,EACb,MAAM;AAAA,EACN,aAAa;AAAA,EACb,SAAS;AACX;AAEA,MAAM,SAAS;AAAA,EACb,MAAM;AAAA,EACN,aAAa;AACf;AAEA,MAAM,QAAQ;AAAA,EACZ,MAAM;AAAA,EACN,aAAa;AACf;AAEA,MAAM,cAAc;AAAA,EAClB,MAAM;AAAA,EACN,aAAa;AACf;AAEA,MAAM,UAAU;AAAA,EACd,MAAM;AAAA,EACN,aAAa;AAAA,EACb,OAAO;AAAA,EACP,SAAS,CAAC;AACZ;AAEA,MAAM,SAAS;AAAA,EACb,MAAM;AAAA,EACN,aAAa;AAAA,EACb,cAAc;AAAA,EACd,YAAY;AAAA,EACZ,KAAK;AACP;AAEA,MAAM,cAAc;AAAA,EAClB,MAAM;AAAA,EACN,aACE;AAAA,EACF,SAAS,CAAC,eAAe,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AAAA,EACb,cAAc;AAAA,EACd,MAAM;AAAA,EACN,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,MAAM;AAAA,EACN,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,KAAK;AAAA,EACL,KAAK;AAAA,EACL,MAAM;AAAA,EACN,MAAM;AAAA,EACN,cAAc;AAAA,EACd,eAAe;AAAA,EACf,YAAY;AACd;",
|
|
4
|
+
"sourcesContent": ["import * as consts from './consts'\nimport { ProjectTemplates } from './project-templates'\nimport type { CommandOption, CommandSchema } from './typings'\n\n// command options\n\nconst port = {\n type: 'number',\n description: 'The port to use',\n} satisfies CommandOption\n\nconst workDir = {\n type: 'string',\n description: 'The path to the project',\n default: consts.defaultWorkDir,\n} satisfies CommandOption\n\nconst noBuild = {\n type: 'boolean',\n description: 'Skip the build step',\n default: false,\n} satisfies CommandOption\n\nconst dryRun = {\n type: 'boolean',\n description: 'Ask the API not to perform the actual operation',\n default: false,\n} as const satisfies CommandOption\n\nconst apiUrl = {\n type: 'string',\n description: 'The URL of the Botpress server',\n} satisfies CommandOption\n\nconst token = {\n type: 'string',\n description: 'You Personal Access Token ',\n} satisfies CommandOption\n\nconst workspaceId = {\n type: 'string',\n description: 'The Workspace Id to deploy to',\n} satisfies CommandOption\n\nconst secrets = {\n type: 'string',\n description: 'Values for the integration secrets',\n array: true,\n default: [],\n} satisfies CommandOption\n\nconst botRef = {\n type: 'string',\n description: 'The bot ID. Bot Name is not supported.',\n demandOption: true,\n positional: true,\n idx: 0,\n} satisfies CommandOption\n\nconst packageType = {\n type: 'string',\n description:\n 'Either an integration or an interface; helps disambiguate the package type in case both an integration and an interface have the same reference.',\n choices: ['integration', 'interface', 'plugin'] as const,\n} satisfies CommandOption\n\nconst packageRef = {\n type: 'string',\n description:\n 'The package ID or name with optional version. The package can be either an integration or an interface. Ex: teams, teams@0.2.0, llm@5.1.0',\n positional: true,\n idx: 0,\n} satisfies CommandOption\n\nconst integrationRef = {\n ...packageRef,\n demandOption: true,\n description: 'The integration ID or name with optional version. Ex: teams or teams@0.2.0',\n} satisfies CommandOption\n\nconst interfaceRef = {\n ...packageRef,\n demandOption: true,\n description: 'The interface ID or name and version. Ex: llm@5.1.0',\n} satisfies CommandOption\n\nconst pluginRef = {\n ...packageRef,\n demandOption: true,\n description: 'The plugin ID or name and version. Ex: knowledge@0.0.1',\n} satisfies CommandOption\n\nconst sourceMap = { type: 'boolean', description: 'Generate sourcemaps', default: false } satisfies CommandOption\n\nconst minify = { type: 'boolean', description: 'Minify the bundled code', default: true } satisfies CommandOption\n\nconst dev = {\n type: 'boolean',\n description: 'List only dev bots / dev integrations',\n default: false,\n} satisfies CommandOption\n\n// base schemas\n\nconst globalSchema = {\n verbose: {\n type: 'boolean',\n description: 'Enable verbose logging',\n alias: 'v',\n default: false,\n },\n confirm: {\n type: 'boolean',\n description: 'Confirm all prompts',\n alias: 'y',\n default: false,\n },\n json: {\n type: 'boolean',\n description: 'Prevent logging anything else than raw json in stdout. Useful for piping output to other tools',\n default: false,\n },\n botpressHome: {\n type: 'string',\n description: 'The path to the Botpress home directory',\n default: consts.defaultBotpressHome,\n },\n profile: {\n type: 'string',\n description: 'The CLI profile defined in the $BP_BOTPRESS_HOME/profiles.json',\n alias: 'p',\n },\n} satisfies CommandSchema\n\nconst projectSchema = {\n ...globalSchema,\n workDir,\n} satisfies CommandSchema\n\nconst credentialsSchema = {\n apiUrl,\n workspaceId,\n token,\n} satisfies CommandSchema\n\nconst secretsSchema = {\n secrets,\n} satisfies CommandSchema\n\n// command schemas\n\nconst generateSchema = {\n ...projectSchema,\n} satisfies CommandSchema\n\nconst bundleSchema = {\n ...projectSchema,\n sourceMap,\n minify,\n} satisfies CommandSchema\n\nconst buildSchema = {\n ...projectSchema,\n sourceMap,\n minify,\n} satisfies CommandSchema\n\nconst readSchema = {\n ...projectSchema,\n} satisfies CommandSchema\n\nconst serveSchema = {\n ...projectSchema,\n ...secretsSchema,\n port,\n} satisfies CommandSchema\n\nconst deploySchema = {\n ...projectSchema,\n ...credentialsSchema,\n ...secretsSchema,\n botId: { type: 'string', description: 'The bot ID to deploy. Only used when deploying a bot' },\n noBuild,\n dryRun,\n createNewBot: { type: 'boolean', description: 'Create a new bot when deploying. Only used when deploying a bot' },\n sourceMap,\n minify,\n visibility: {\n type: 'string',\n choices: ['public', 'private', 'unlisted'] as const,\n description:\n 'The visibility of the project. By default, projects are always private. Unlisted visibility is only supported for integrations and plugins.',\n default: 'private',\n },\n public: {\n type: 'boolean',\n description: 'DEPRECATED: Please use \"--visibility public\" instead.',\n default: false,\n deprecated: true,\n } satisfies CommandOption,\n allowDeprecated: {\n type: 'boolean',\n description: 'Allow deprecated features in the project',\n default: false,\n },\n} as const satisfies CommandSchema\n\nconst devSchema = {\n ...projectSchema,\n ...credentialsSchema,\n ...secretsSchema,\n sourceMap,\n minify,\n port,\n tunnelUrl: {\n type: 'string',\n description: 'The tunnel HTTP URL to use',\n default: consts.defaultTunnelUrl,\n },\n tunnelId: {\n type: 'string',\n description: 'The tunnel ID to use. The ID will be generated if not specified',\n },\n} satisfies CommandSchema\n\nconst addSchema = {\n ...globalSchema,\n ...credentialsSchema,\n packageRef,\n packageType,\n installPath: {\n type: 'string',\n description: 'The path where to install the package',\n default: consts.defaultInstallPath,\n },\n useDev: {\n type: 'boolean',\n description: 'If a dev version of the package is found, use it',\n default: false,\n },\n alias: {\n type: 'string',\n description: 'The alias of the dependency you want to install',\n },\n} satisfies CommandSchema\n\nconst loginSchema = {\n ...globalSchema,\n token,\n workspaceId,\n apiUrl: { ...apiUrl, default: consts.defaultBotpressApiUrl },\n} satisfies CommandSchema\n\nconst logoutSchema = {\n ...globalSchema,\n} satisfies CommandSchema\n\nconst createBotSchema = {\n ...globalSchema,\n ...credentialsSchema,\n name: { type: 'string', description: 'The name of the bot to create' },\n ifNotExists: {\n type: 'boolean',\n description: 'Do not create if a bot with the same name already exists',\n default: false,\n },\n} satisfies CommandSchema\n\nconst getBotSchema = {\n ...globalSchema,\n ...credentialsSchema,\n botRef,\n} satisfies CommandSchema\n\nconst deleteBotSchema = {\n ...globalSchema,\n ...credentialsSchema,\n botRef,\n} satisfies CommandSchema\n\nconst listBotsSchema = {\n ...globalSchema,\n ...credentialsSchema,\n dev,\n} satisfies CommandSchema\n\nconst getIntegrationSchema = {\n ...globalSchema,\n ...credentialsSchema,\n integrationRef,\n} satisfies CommandSchema\n\nconst listIntegrationsSchema = {\n ...globalSchema,\n ...credentialsSchema,\n name: { type: 'string', description: 'The name filter when listing integrations' },\n versionNumber: { type: 'string', description: 'The version filter when listing integrations' },\n dev,\n} satisfies CommandSchema\n\nconst deleteIntegrationSchema = {\n ...globalSchema,\n ...credentialsSchema,\n integrationRef,\n} satisfies CommandSchema\n\nconst getInterfaceSchema = {\n ...globalSchema,\n ...credentialsSchema,\n interfaceRef,\n} satisfies CommandSchema\n\nconst listInterfacesSchema = {\n ...globalSchema,\n ...credentialsSchema,\n} satisfies CommandSchema\n\nconst deleteInterfaceSchema = {\n ...globalSchema,\n ...credentialsSchema,\n interfaceRef,\n} satisfies CommandSchema\n\nconst getPluginSchema = {\n ...globalSchema,\n ...credentialsSchema,\n pluginRef,\n} satisfies CommandSchema\n\nconst listPluginsSchema = {\n ...globalSchema,\n ...credentialsSchema,\n name: { type: 'string', description: 'The name filter when listing plugins' },\n versionNumber: { type: 'string', description: 'The version filter when listing plugins' },\n} satisfies CommandSchema\n\nconst deletePluginSchema = {\n ...globalSchema,\n ...credentialsSchema,\n pluginRef,\n} satisfies CommandSchema\n\nconst initSchema = {\n ...globalSchema,\n workDir,\n type: { type: 'string', choices: ['bot', 'integration', 'plugin'] as const },\n template: {\n type: 'string',\n choices: ProjectTemplates.getAllChoices(),\n description: 'The template to use',\n },\n name: { type: 'string', description: 'The name of the project' },\n} satisfies CommandSchema\n\nconst lintSchema = {\n ...projectSchema,\n} satisfies CommandSchema\n\nconst chatSchema = {\n ...globalSchema,\n ...credentialsSchema,\n chatApiUrl: {\n type: 'string',\n description: 'The URL of the chat server',\n },\n botId: {\n type: 'string',\n positional: true,\n idx: 0,\n description: 'The bot ID to chat with',\n },\n} satisfies CommandSchema\n\nconst listProfilesSchema = {\n ...globalSchema,\n} satisfies CommandSchema\n\nconst activeProfileSchema = {\n ...globalSchema,\n} satisfies CommandSchema\n\nconst useProfileSchema = {\n ...globalSchema,\n profileToUse: {\n type: 'string',\n description: 'The CLI profile defined in the $BP_BOTPRESS_HOME/profiles.json',\n positional: true,\n idx: 0,\n },\n} satisfies CommandSchema\n\n// exports\n\nexport const schemas = {\n global: globalSchema,\n project: projectSchema,\n credentials: credentialsSchema,\n secrets: secretsSchema,\n login: loginSchema,\n logout: logoutSchema,\n createBot: createBotSchema,\n getBot: getBotSchema,\n deleteBot: deleteBotSchema,\n listBots: listBotsSchema,\n getIntegration: getIntegrationSchema,\n listIntegrations: listIntegrationsSchema,\n deleteIntegration: deleteIntegrationSchema,\n getInterface: getInterfaceSchema,\n listInterfaces: listInterfacesSchema,\n deleteInterface: deleteInterfaceSchema,\n getPlugin: getPluginSchema,\n listPlugins: listPluginsSchema,\n deletePlugin: deletePluginSchema,\n init: initSchema,\n generate: generateSchema,\n bundle: bundleSchema,\n build: buildSchema,\n read: readSchema,\n serve: serveSchema,\n deploy: deploySchema,\n add: addSchema,\n dev: devSchema,\n lint: lintSchema,\n chat: chatSchema,\n listProfiles: listProfilesSchema,\n activeProfile: activeProfileSchema,\n useProfile: useProfileSchema,\n} as const\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAAwB;AACxB,+BAAiC;AAKjC,MAAM,OAAO;AAAA,EACX,MAAM;AAAA,EACN,aAAa;AACf;AAEA,MAAM,UAAU;AAAA,EACd,MAAM;AAAA,EACN,aAAa;AAAA,EACb,SAAS,OAAO;AAClB;AAEA,MAAM,UAAU;AAAA,EACd,MAAM;AAAA,EACN,aAAa;AAAA,EACb,SAAS;AACX;AA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Aa;AAAA,EACf;AACF;AAEA,MAAM,qBAAqB;AAAA,EACzB,GAAG;AACL;AAEA,MAAM,sBAAsB;AAAA,EAC1B,GAAG;AACL;AAEA,MAAM,mBAAmB;AAAA,EACvB,GAAG;AAAA,EACH,cAAc;AAAA,IACZ,MAAM;AAAA,IACN,aAAa;AAAA,IACb,YAAY;AAAA,IACZ,KAAK;AAAA,EACP;AACF;AAIO,MAAM,UAAU;AAAA,EACrB,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,aAAa;AAAA,EACb,SAAS;AAAA,EACT,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,UAAU;AAAA,EACV,gBAAgB;AAAA,EAChB,kBAAkB;AAAA,EAClB,mBAAmB;AAAA,EACnB,cAAc;AAAA,EACd,gBAAgB;AAAA,EAChB,iBAAiB;AAAA,EACjB,WAAW;AAAA,EACX,aAAa;AAAA,EACb,cAAc;AAAA,EACd,MAAM;AAAA,EACN,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,MAAM;AAAA,EACN,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,KAAK;AAAA,EACL,KAAK;AAAA,EACL,MAAM;AAAA,EACN,MAAM;AAAA,EACN,cAAc;AAAA,EACd,eAAe;AAAA,EACf,YAAY;AACd;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botpress/cli",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.25.0",
|
|
4
4
|
"description": "Botpress CLI",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "pnpm run build:types && pnpm run bundle && pnpm run template:gen",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"@apidevtools/json-schema-ref-parser": "^11.7.0",
|
|
28
28
|
"@botpress/chat": "0.5.4",
|
|
29
29
|
"@botpress/client": "1.27.1",
|
|
30
|
-
"@botpress/sdk": "4.
|
|
30
|
+
"@botpress/sdk": "4.19.0",
|
|
31
31
|
"@bpinternal/const": "^0.1.0",
|
|
32
32
|
"@bpinternal/tunnel": "^0.1.1",
|
|
33
33
|
"@bpinternal/verel": "^0.2.0",
|