@botpress/cli 0.8.34 → 0.8.36
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 +9 -9
- package/dist/api/client.js +6 -0
- package/dist/api/client.js.map +2 -2
- package/dist/api/integration-body.js +1 -0
- package/dist/api/integration-body.js.map +2 -2
- package/dist/api/interface-body.js +76 -0
- package/dist/api/interface-body.js.map +7 -0
- package/dist/api/types.js.map +1 -1
- package/dist/code-generation/integration-implementation.js +16 -3
- package/dist/code-generation/integration-implementation.js.map +2 -2
- package/dist/code-generation/integration-instance.js +13 -3
- package/dist/code-generation/integration-instance.js.map +2 -2
- package/dist/code-generation/integration-schemas/actions-module.js +2 -1
- package/dist/code-generation/integration-schemas/actions-module.js.map +2 -2
- package/dist/code-generation/integration-schemas/entities-module.js +66 -0
- package/dist/code-generation/integration-schemas/entities-module.js.map +7 -0
- package/dist/code-generation/map-integration.js +4 -3
- package/dist/code-generation/map-integration.js.map +2 -2
- package/dist/code-generation/typings.js.map +1 -1
- package/dist/command-definitions.js +10 -2
- package/dist/command-definitions.js.map +2 -2
- package/dist/command-implementations/add-command.js +20 -13
- package/dist/command-implementations/add-command.js.map +2 -2
- package/dist/command-implementations/build-command.js +5 -1
- package/dist/command-implementations/build-command.js.map +2 -2
- package/dist/command-implementations/bundle-command.js +5 -1
- package/dist/command-implementations/bundle-command.js.map +2 -2
- package/dist/command-implementations/deploy-command.js +70 -4
- package/dist/command-implementations/deploy-command.js.map +2 -2
- package/dist/command-implementations/dev-command.js +12 -5
- package/dist/command-implementations/dev-command.js.map +2 -2
- package/dist/command-implementations/gen-command.js +4 -3
- package/dist/command-implementations/gen-command.js.map +2 -2
- package/dist/command-implementations/index.js +8 -0
- package/dist/command-implementations/index.js.map +2 -2
- package/dist/command-implementations/interface-commands.js +106 -0
- package/dist/command-implementations/interface-commands.js.map +7 -0
- package/dist/command-implementations/project-command.js +33 -4
- package/dist/command-implementations/project-command.js.map +2 -2
- package/dist/command-implementations/read-command.js +17 -5
- package/dist/command-implementations/read-command.js.map +2 -2
- package/dist/command-implementations/serve-command.js +7 -4
- package/dist/command-implementations/serve-command.js.map +2 -2
- package/dist/config.js +22 -1
- package/dist/config.js.map +2 -2
- package/dist/consts.js +2 -1
- package/dist/consts.js.map +2 -2
- package/dist/errors.js +10 -2
- package/dist/errors.js.map +2 -2
- package/package.json +2 -2
- package/templates/echo-bot/package.json +1 -1
- package/templates/empty-integration/.botpress/implementation/entities/index.ts +6 -0
- package/templates/empty-integration/.botpress/implementation/index.ts +7 -1
- package/templates/empty-integration/package.json +1 -1
- package/templates/hello-world/.botpress/implementation/entities/index.ts +6 -0
- package/templates/hello-world/.botpress/implementation/index.ts +7 -1
- package/templates/hello-world/package.json +1 -1
- package/templates/webhook-message/.botpress/implementation/entities/index.ts +6 -0
- package/templates/webhook-message/.botpress/implementation/index.ts +7 -1
- package/templates/webhook-message/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/command-implementations/project-command.ts"],
|
|
4
|
-
"sourcesContent": ["import type * as client from '@botpress/client'\nimport type * as sdk from '@botpress/sdk'\nimport type { YargsConfig } from '@bpinternal/yargs-extra'\nimport bluebird from 'bluebird'\nimport chalk from 'chalk'\nimport fs from 'fs'\nimport _ from 'lodash'\nimport pathlib from 'path'\nimport semver from 'semver'\nimport { ApiClient } from '../api/client'\nimport * as codegen from '../code-generation'\nimport type * as config from '../config'\nimport * as consts from '../consts'\nimport * as errors from '../errors'\nimport { formatIntegrationRef, IntegrationRef } from '../integration-ref'\nimport { validateIntegrationDefinition } from '../sdk/validate-integration'\nimport type { CommandArgv, CommandDefinition } from '../typings'\nimport * as utils from '../utils'\nimport { GlobalCommand } from './global-command'\n\nexport type ProjectCommandDefinition = CommandDefinition<typeof config.schemas.project>\nexport type ProjectCache = { botId: string; devId: string }\n\ntype ConfigurableProjectPaths = { entryPoint: string; outDir: string; workDir: string }\ntype ConstantProjectPaths = typeof consts.fromOutDir & typeof consts.fromWorkDir\ntype AllProjectPaths = ConfigurableProjectPaths & ConstantProjectPaths\n\ntype RemoteIntegrationInstance = utils.types.Merge<sdk.IntegrationInstance<string>, { id: string }>\ntype LocalIntegrationInstance = utils.types.Merge<sdk.IntegrationInstance<string>, { id: null }>\n\nclass ProjectPaths extends utils.path.PathStore<keyof AllProjectPaths> {\n public constructor(argv: CommandArgv<ProjectCommandDefinition>) {\n const absWorkDir = utils.path.absoluteFrom(utils.path.cwd(), argv.workDir)\n const absEntrypoint = utils.path.absoluteFrom(absWorkDir, argv.entryPoint)\n const absOutDir = utils.path.absoluteFrom(absWorkDir, argv.outDir)\n super({\n workDir: absWorkDir,\n entryPoint: absEntrypoint,\n outDir: absOutDir,\n ..._.mapValues(consts.fromOutDir, (p) => utils.path.absoluteFrom(absOutDir, p)),\n ..._.mapValues(consts.fromWorkDir, (p) => utils.path.absoluteFrom(absWorkDir, p)),\n })\n }\n}\n\nexport abstract class ProjectCommand<C extends ProjectCommandDefinition> extends GlobalCommand<C> {\n protected override async bootstrap() {\n await super.bootstrap()\n await this._notifyUpdateSdk()\n }\n\n protected get projectPaths() {\n return new ProjectPaths(this.argv)\n }\n\n protected get projectCache() {\n return new utils.cache.FSKeyValueCache<ProjectCache>(this.projectPaths.abs.projectCacheFile)\n }\n\n protected async fetchBotIntegrationInstances(bot: sdk.Bot, api: ApiClient) {\n const integrationList = _(bot.props.integrations).values().filter(utils.guards.is.defined).value()\n\n const { remoteInstances, localInstances } = this._splitApiAndLocalIntegrationInstances(integrationList)\n\n const fetchedInstances: RemoteIntegrationInstance[] = await bluebird.map(localInstances, async (instance) => {\n const ref: IntegrationRef = { type: 'name', name: instance.name, version: instance.version }\n const integration = await api.findIntegration(ref)\n if (!integration) {\n const formattedRef = formatIntegrationRef(ref)\n throw new errors.BotpressCLIError(`Integration \"${formattedRef}\" not found`)\n }\n return { ...instance, id: integration.id }\n })\n\n return _([...fetchedInstances, ...remoteInstances])\n .keyBy((i) => i.id)\n .mapValues(({ enabled, configuration }) => ({ enabled, configuration }))\n .value()\n }\n\n private _splitApiAndLocalIntegrationInstances(instances: sdk.IntegrationInstance<string>[]): {\n remoteInstances: RemoteIntegrationInstance[]\n localInstances: LocalIntegrationInstance[]\n } {\n const remoteInstances: RemoteIntegrationInstance[] = []\n const localInstances: LocalIntegrationInstance[] = []\n for (const { id, ...instance } of instances) {\n if (id) {\n remoteInstances.push({ ...instance, id })\n } else {\n localInstances.push({ ...instance, id: null })\n }\n }\n\n return { remoteInstances, localInstances }\n }\n\n protected async readIntegrationDefinitionFromFS(\n projectPaths: utils.path.PathStore<'workDir' | 'definition'> = this.projectPaths\n ): Promise<sdk.IntegrationDefinition | undefined> {\n const abs = projectPaths.abs\n const rel = projectPaths.rel('workDir')\n\n if (!fs.existsSync(abs.definition)) {\n this.logger.debug(`Integration definition not found at ${rel.definition}`)\n return\n }\n\n const { outputFiles } = await utils.esbuild.buildEntrypoint({\n cwd: abs.workDir,\n outfile: '',\n entrypoint: rel.definition,\n write: false,\n })\n\n const artifact = outputFiles[0]\n if (!artifact) {\n throw new errors.BotpressCLIError('Could not read integration definition')\n }\n\n const { default: definition } = utils.require.requireJsCode<{ default: sdk.IntegrationDefinition }>(artifact.text)\n\n validateIntegrationDefinition(definition)\n\n return definition\n }\n\n protected async writeGeneratedFilesToOutFolder(files: codegen.File[]) {\n for (const file of files) {\n const filePath = utils.path.absoluteFrom(this.projectPaths.abs.outDir, file.path)\n const dirPath = pathlib.dirname(filePath)\n await fs.promises.mkdir(dirPath, { recursive: true })\n await fs.promises.writeFile(filePath, file.content)\n }\n }\n\n protected displayWebhookUrls(bot: client.Bot) {\n if (!_.keys(bot.integrations).length) {\n this.logger.debug('No integrations in bot')\n return\n }\n\n this.logger.log('Integrations:')\n for (const integration of Object.values(bot.integrations).filter(utils.guards.is.defined)) {\n if (!integration.enabled) {\n this.logger.log(`${chalk.grey(integration.name)} ${chalk.italic('(disabled)')}: ${integration.webhookUrl}`, {\n prefix: { symbol: '\u25CB', indent: 2 },\n })\n } else {\n this.logger.log(`${chalk.bold(integration.name)} : ${integration.webhookUrl}`, {\n prefix: { symbol: '\u25CF', indent: 2 },\n })\n }\n }\n }\n\n protected async promptSecrets(\n integrationDef: sdk.IntegrationDefinition,\n argv: YargsConfig<typeof config.schemas.secrets>,\n opts: { formatEnv?: boolean; knownSecrets?: string[] } = {}\n ): Promise<Record<string, string | null>> {\n const formatEnv = opts.formatEnv ?? false\n const knownSecrets = opts.knownSecrets ?? []\n\n const { secrets: secretDefinitions } = integrationDef\n if (!secretDefinitions) {\n return {}\n }\n\n const secretArgv = this._parseArgvSecrets(argv.secrets)\n const invalidSecret = Object.keys(secretArgv).find((s) => !secretDefinitions[s])\n if (invalidSecret) {\n throw new errors.BotpressCLIError(`Secret ${invalidSecret} is not defined in integration definition`)\n }\n\n const values: Record<string, string | null> = {}\n for (const [secretName, { optional }] of Object.entries(secretDefinitions)) {\n const argvSecret = secretArgv[secretName]\n if (argvSecret) {\n this.logger.debug(`Using secret \"${secretName}\" from argv`)\n values[secretName] = argvSecret\n continue\n }\n\n const alreadyKnown = knownSecrets.includes(secretName)\n let mode: string\n if (alreadyKnown) {\n mode = 'already set'\n } else if (optional) {\n mode = 'optional'\n } else {\n mode = 'required'\n }\n\n const prompted = await this.prompt.text(`Enter value for secret \"${secretName}\" (${mode})`)\n if (prompted) {\n values[secretName] = prompted\n continue\n }\n\n if (alreadyKnown) {\n this.logger.log(`Secret \"${secretName}\" is unchanged`)\n } else if (optional) {\n this.logger.warn(`Secret \"${secretName}\" is unassigned`)\n } else {\n throw new errors.BotpressCLIError(`Secret \"${secretName}\" is required`)\n }\n }\n\n for (const secretName of knownSecrets) {\n const isDefined = secretName in secretDefinitions\n if (isDefined) {\n continue\n }\n const prompted = await this.prompt.confirm(`Secret \"${secretName}\" was removed. Do you wish to delete it?`)\n if (prompted) {\n this.logger.log(`Deleting secret \"${secretName}\"`, { prefix: { symbol: '\u00D7', fg: 'red' } })\n values[secretName] = null\n }\n }\n\n if (!formatEnv) {\n return values\n }\n\n const envVariables = _.mapKeys(values, (_v, k) => codegen.secretEnvVariableName(k))\n return envVariables\n }\n\n private _parseArgvSecrets(argvSecrets: string[]): Record<string, string> {\n const parsed: Record<string, string> = {}\n for (const secret of argvSecrets) {\n const [key, value] = utils.string.splitOnce(secret, '=')\n if (!value) {\n throw new errors.BotpressCLIError(\n `Secret \"${key}\" is missing a value. Expected format: \"SECRET_NAME=secretValue\"`\n )\n }\n parsed[key!] = value\n }\n\n return parsed\n }\n\n private _notifyUpdateSdk = async (): Promise<void> => {\n try {\n this.logger.debug('Checking if sdk is up to date')\n\n const { workDir } = this.projectPaths.abs\n const projectPkgJson = await utils.pkgJson.readPackageJson(workDir)\n if (!projectPkgJson) {\n this.logger.debug(`Could not find package.json at \"${workDir}\"`)\n return\n }\n\n const sdkPackageName = '@botpress/sdk'\n const actualSdkVersion = utils.pkgJson.findDependency(projectPkgJson, sdkPackageName)\n if (!actualSdkVersion) {\n this.logger.debug(`Could not find dependency \"${sdkPackageName}\" in project package.json`)\n return\n }\n\n if (actualSdkVersion.startsWith('workspace:')) {\n return\n }\n\n const actualCleanedSdkVersion = semver.valid(semver.coerce(actualSdkVersion))\n if (!actualCleanedSdkVersion) {\n this.logger.debug(`Invalid sdk version \"${actualSdkVersion}\" in project package.json`)\n return\n }\n\n const cliPkgJson = await this.readPkgJson()\n const expectedSdkVersion = utils.pkgJson.findDependency(cliPkgJson, sdkPackageName)\n if (!expectedSdkVersion) {\n this.logger.debug(`Could not find dependency \"${sdkPackageName}\" in cli package.json`)\n return\n }\n\n const expectedCleanedSdkVersion = semver.valid(semver.coerce(expectedSdkVersion))\n if (!expectedCleanedSdkVersion) {\n this.logger.debug(`Invalid sdk version \"${expectedSdkVersion}\" in cli package.json`)\n return\n }\n\n if (semver.eq(actualCleanedSdkVersion, expectedCleanedSdkVersion)) {\n return\n }\n\n const diff = semver.diff(actualCleanedSdkVersion, expectedCleanedSdkVersion)\n if (!diff) {\n this.logger.debug(`Could not compare versions \"${actualCleanedSdkVersion}\" and \"${expectedCleanedSdkVersion}\"`)\n return\n }\n\n const errorMsg = `Project SDK version is \"${actualCleanedSdkVersion}\", but expected \"${expectedCleanedSdkVersion}\"`\n if (utils.semver.releases.lt(diff, 'minor')) {\n this.logger.debug(`${errorMsg}. This may cause compatibility issues.`)\n return\n }\n\n this.logger.warn(chalk.bold(`${errorMsg}. This will cause compatibility issues.`))\n } catch (thrown) {\n const err = errors.BotpressCLIError.map(thrown)\n this.logger.debug(`Failed to check if sdk is up to date: ${err.message}`)\n }\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,sBAAqB;AACrB,mBAAkB;AAClB,gBAAe;AACf,oBAAc;AACd,kBAAoB;AACpB,oBAAmB;AAEnB,cAAyB;AAEzB,aAAwB;AACxB,aAAwB;AACxB,6BAAqD;AACrD,kCAA8C;AAE9C,YAAuB;AACvB,4BAA8B;
|
|
4
|
+
"sourcesContent": ["import type * as client from '@botpress/client'\nimport type * as sdk from '@botpress/sdk'\nimport type { YargsConfig } from '@bpinternal/yargs-extra'\nimport bluebird from 'bluebird'\nimport chalk from 'chalk'\nimport fs from 'fs'\nimport _ from 'lodash'\nimport pathlib from 'path'\nimport semver from 'semver'\nimport { ApiClient } from '../api/client'\nimport * as codegen from '../code-generation'\nimport type * as config from '../config'\nimport * as consts from '../consts'\nimport * as errors from '../errors'\nimport { formatIntegrationRef, IntegrationRef } from '../integration-ref'\nimport { validateIntegrationDefinition } from '../sdk/validate-integration'\nimport type { CommandArgv, CommandDefinition } from '../typings'\nimport * as utils from '../utils'\nimport { GlobalCommand } from './global-command'\n\nexport type ProjectCommandDefinition = CommandDefinition<typeof config.schemas.project>\nexport type ProjectCache = { botId: string; devId: string }\n\ntype ConfigurableProjectPaths = { entryPoint: string; outDir: string; workDir: string }\ntype ConstantProjectPaths = typeof consts.fromOutDir & typeof consts.fromWorkDir\ntype AllProjectPaths = ConfigurableProjectPaths & ConstantProjectPaths\n\ntype RemoteIntegrationInstance = utils.types.Merge<sdk.IntegrationInstance<any>, { id: string }>\ntype LocalIntegrationInstance = utils.types.Merge<sdk.IntegrationInstance<any>, { id: null }>\n\nexport type ProjectType = ProjectDefinition['type']\nexport type ProjectDefinition =\n | { type: 'integration'; definition: sdk.IntegrationDefinition }\n | { type: 'interface'; definition: sdk.InterfaceDeclaration }\n | { type: 'bot'; definition: null }\n\nclass ProjectPaths extends utils.path.PathStore<keyof AllProjectPaths> {\n public constructor(argv: CommandArgv<ProjectCommandDefinition>) {\n const absWorkDir = utils.path.absoluteFrom(utils.path.cwd(), argv.workDir)\n const absEntrypoint = utils.path.absoluteFrom(absWorkDir, argv.entryPoint)\n const absOutDir = utils.path.absoluteFrom(absWorkDir, argv.outDir)\n super({\n workDir: absWorkDir,\n entryPoint: absEntrypoint,\n outDir: absOutDir,\n ..._.mapValues(consts.fromOutDir, (p) => utils.path.absoluteFrom(absOutDir, p)),\n ..._.mapValues(consts.fromWorkDir, (p) => utils.path.absoluteFrom(absWorkDir, p)),\n })\n }\n}\n\nexport abstract class ProjectCommand<C extends ProjectCommandDefinition> extends GlobalCommand<C> {\n protected override async bootstrap() {\n await super.bootstrap()\n await this._notifyUpdateSdk()\n }\n\n protected get projectPaths() {\n return new ProjectPaths(this.argv)\n }\n\n protected get projectCache() {\n return new utils.cache.FSKeyValueCache<ProjectCache>(this.projectPaths.abs.projectCacheFile)\n }\n\n protected async fetchBotIntegrationInstances(bot: sdk.Bot, api: ApiClient) {\n const integrationList = _(bot.props.integrations).values().filter(utils.guards.is.defined).value()\n\n const { remoteInstances, localInstances } = this._splitApiAndLocalIntegrationInstances(integrationList)\n\n const fetchedInstances: RemoteIntegrationInstance[] = await bluebird.map(localInstances, async (instance) => {\n const ref: IntegrationRef = { type: 'name', name: instance.name, version: instance.version }\n const integration = await api.findIntegration(ref)\n if (!integration) {\n const formattedRef = formatIntegrationRef(ref)\n throw new errors.BotpressCLIError(`Integration \"${formattedRef}\" not found`)\n }\n return { ...instance, id: integration.id }\n })\n\n return _([...fetchedInstances, ...remoteInstances])\n .keyBy((i) => i.id)\n .mapValues(({ enabled, configuration }) => ({ enabled, configuration }))\n .value()\n }\n\n private _splitApiAndLocalIntegrationInstances(instances: sdk.IntegrationInstance<any>[]): {\n remoteInstances: RemoteIntegrationInstance[]\n localInstances: LocalIntegrationInstance[]\n } {\n const remoteInstances: RemoteIntegrationInstance[] = []\n const localInstances: LocalIntegrationInstance[] = []\n for (const { id, ...instance } of instances) {\n if (id) {\n remoteInstances.push({ ...instance, id })\n } else {\n localInstances.push({ ...instance, id: null })\n }\n }\n\n return { remoteInstances, localInstances }\n }\n\n protected async readProjectDefinitionFromFS(\n projectPaths: utils.path.PathStore<'workDir' | 'integrationDefinition' | 'interfaceDefinition'> = this.projectPaths\n ): Promise<ProjectDefinition> {\n const integrationDefinition = await this._readIntegrationDefinitionFromFS(projectPaths)\n if (integrationDefinition) {\n return { type: 'integration', definition: integrationDefinition }\n }\n const interfaceDefinition = await this._readInterfaceDefinitionFromFS(projectPaths)\n if (interfaceDefinition) {\n return { type: 'interface', definition: interfaceDefinition }\n }\n return { type: 'bot', definition: null }\n }\n\n private async _readIntegrationDefinitionFromFS(\n projectPaths: utils.path.PathStore<'workDir' | 'integrationDefinition'> = this.projectPaths\n ): Promise<sdk.IntegrationDefinition | undefined> {\n const abs = projectPaths.abs\n const rel = projectPaths.rel('workDir')\n\n if (!fs.existsSync(abs.integrationDefinition)) {\n return\n }\n\n const { outputFiles } = await utils.esbuild.buildEntrypoint({\n cwd: abs.workDir,\n outfile: '',\n entrypoint: rel.integrationDefinition,\n write: false,\n })\n\n const artifact = outputFiles[0]\n if (!artifact) {\n throw new errors.BotpressCLIError('Could not read integration definition')\n }\n\n const { default: definition } = utils.require.requireJsCode<{ default: sdk.IntegrationDefinition }>(artifact.text)\n\n validateIntegrationDefinition(definition)\n\n return definition\n }\n\n private async _readInterfaceDefinitionFromFS(\n projectPaths: utils.path.PathStore<'workDir' | 'interfaceDefinition'> = this.projectPaths\n ): Promise<sdk.InterfaceDeclaration | undefined> {\n const abs = projectPaths.abs\n const rel = projectPaths.rel('workDir')\n\n if (!fs.existsSync(abs.interfaceDefinition)) {\n return\n }\n\n const { outputFiles } = await utils.esbuild.buildEntrypoint({\n cwd: abs.workDir,\n outfile: '',\n entrypoint: rel.interfaceDefinition,\n write: false,\n })\n\n const artifact = outputFiles[0]\n if (!artifact) {\n throw new errors.BotpressCLIError('Could not read interface definition')\n }\n\n const { default: definition } = utils.require.requireJsCode<{ default: sdk.InterfaceDeclaration }>(artifact.text)\n\n return definition\n }\n\n protected async writeGeneratedFilesToOutFolder(files: codegen.File[]) {\n for (const file of files) {\n const filePath = utils.path.absoluteFrom(this.projectPaths.abs.outDir, file.path)\n const dirPath = pathlib.dirname(filePath)\n await fs.promises.mkdir(dirPath, { recursive: true })\n await fs.promises.writeFile(filePath, file.content)\n }\n }\n\n protected displayWebhookUrls(bot: client.Bot) {\n if (!_.keys(bot.integrations).length) {\n this.logger.debug('No integrations in bot')\n return\n }\n\n this.logger.log('Integrations:')\n for (const integration of Object.values(bot.integrations).filter(utils.guards.is.defined)) {\n if (!integration.enabled) {\n this.logger.log(`${chalk.grey(integration.name)} ${chalk.italic('(disabled)')}: ${integration.webhookUrl}`, {\n prefix: { symbol: '\u25CB', indent: 2 },\n })\n } else {\n this.logger.log(`${chalk.bold(integration.name)} : ${integration.webhookUrl}`, {\n prefix: { symbol: '\u25CF', indent: 2 },\n })\n }\n }\n }\n\n protected async promptSecrets(\n integrationDef: sdk.IntegrationDefinition,\n argv: YargsConfig<typeof config.schemas.secrets>,\n opts: { formatEnv?: boolean; knownSecrets?: string[] } = {}\n ): Promise<Record<string, string | null>> {\n const formatEnv = opts.formatEnv ?? false\n const knownSecrets = opts.knownSecrets ?? []\n\n const { secrets: secretDefinitions } = integrationDef\n if (!secretDefinitions) {\n return {}\n }\n\n const secretArgv = this._parseArgvSecrets(argv.secrets)\n const invalidSecret = Object.keys(secretArgv).find((s) => !secretDefinitions[s])\n if (invalidSecret) {\n throw new errors.BotpressCLIError(`Secret ${invalidSecret} is not defined in integration definition`)\n }\n\n const values: Record<string, string | null> = {}\n for (const [secretName, { optional }] of Object.entries(secretDefinitions)) {\n const argvSecret = secretArgv[secretName]\n if (argvSecret) {\n this.logger.debug(`Using secret \"${secretName}\" from argv`)\n values[secretName] = argvSecret\n continue\n }\n\n const alreadyKnown = knownSecrets.includes(secretName)\n let mode: string\n if (alreadyKnown) {\n mode = 'already set'\n } else if (optional) {\n mode = 'optional'\n } else {\n mode = 'required'\n }\n\n const prompted = await this.prompt.text(`Enter value for secret \"${secretName}\" (${mode})`)\n if (prompted) {\n values[secretName] = prompted\n continue\n }\n\n if (alreadyKnown) {\n this.logger.log(`Secret \"${secretName}\" is unchanged`)\n } else if (optional) {\n this.logger.warn(`Secret \"${secretName}\" is unassigned`)\n } else {\n throw new errors.BotpressCLIError(`Secret \"${secretName}\" is required`)\n }\n }\n\n for (const secretName of knownSecrets) {\n const isDefined = secretName in secretDefinitions\n if (isDefined) {\n continue\n }\n const prompted = await this.prompt.confirm(`Secret \"${secretName}\" was removed. Do you wish to delete it?`)\n if (prompted) {\n this.logger.log(`Deleting secret \"${secretName}\"`, { prefix: { symbol: '\u00D7', fg: 'red' } })\n values[secretName] = null\n }\n }\n\n if (!formatEnv) {\n return values\n }\n\n const envVariables = _.mapKeys(values, (_v, k) => codegen.secretEnvVariableName(k))\n return envVariables\n }\n\n private _parseArgvSecrets(argvSecrets: string[]): Record<string, string> {\n const parsed: Record<string, string> = {}\n for (const secret of argvSecrets) {\n const [key, value] = utils.string.splitOnce(secret, '=')\n if (!value) {\n throw new errors.BotpressCLIError(\n `Secret \"${key}\" is missing a value. Expected format: \"SECRET_NAME=secretValue\"`\n )\n }\n parsed[key!] = value\n }\n\n return parsed\n }\n\n private _notifyUpdateSdk = async (): Promise<void> => {\n try {\n this.logger.debug('Checking if sdk is up to date')\n\n const { workDir } = this.projectPaths.abs\n const projectPkgJson = await utils.pkgJson.readPackageJson(workDir)\n if (!projectPkgJson) {\n this.logger.debug(`Could not find package.json at \"${workDir}\"`)\n return\n }\n\n const sdkPackageName = '@botpress/sdk'\n const actualSdkVersion = utils.pkgJson.findDependency(projectPkgJson, sdkPackageName)\n if (!actualSdkVersion) {\n this.logger.debug(`Could not find dependency \"${sdkPackageName}\" in project package.json`)\n return\n }\n\n if (actualSdkVersion.startsWith('workspace:')) {\n return\n }\n\n const actualCleanedSdkVersion = semver.valid(semver.coerce(actualSdkVersion))\n if (!actualCleanedSdkVersion) {\n this.logger.debug(`Invalid sdk version \"${actualSdkVersion}\" in project package.json`)\n return\n }\n\n const cliPkgJson = await this.readPkgJson()\n const expectedSdkVersion = utils.pkgJson.findDependency(cliPkgJson, sdkPackageName)\n if (!expectedSdkVersion) {\n this.logger.debug(`Could not find dependency \"${sdkPackageName}\" in cli package.json`)\n return\n }\n\n const expectedCleanedSdkVersion = semver.valid(semver.coerce(expectedSdkVersion))\n if (!expectedCleanedSdkVersion) {\n this.logger.debug(`Invalid sdk version \"${expectedSdkVersion}\" in cli package.json`)\n return\n }\n\n if (semver.eq(actualCleanedSdkVersion, expectedCleanedSdkVersion)) {\n return\n }\n\n const diff = semver.diff(actualCleanedSdkVersion, expectedCleanedSdkVersion)\n if (!diff) {\n this.logger.debug(`Could not compare versions \"${actualCleanedSdkVersion}\" and \"${expectedCleanedSdkVersion}\"`)\n return\n }\n\n const errorMsg = `Project SDK version is \"${actualCleanedSdkVersion}\", but expected \"${expectedCleanedSdkVersion}\"`\n if (utils.semver.releases.lt(diff, 'minor')) {\n this.logger.debug(`${errorMsg}. This may cause compatibility issues.`)\n return\n }\n\n this.logger.warn(chalk.bold(`${errorMsg}. This will cause compatibility issues.`))\n } catch (thrown) {\n const err = errors.BotpressCLIError.map(th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cAAAA,QAAO,MAAM,cAAAA,QAAO,OAAO,kBAAkB,CAAC;AAChF,UAAI,CAAC,2BAA2B;AAC9B,aAAK,OAAO,MAAM,wBAAwB,yCAAyC;AACnF;AAAA,MACF;AAEA,UAAI,cAAAA,QAAO,GAAG,yBAAyB,yBAAyB,GAAG;AACjE;AAAA,MACF;AAEA,YAAM,OAAO,cAAAA,QAAO,KAAK,yBAAyB,yBAAyB;AAC3E,UAAI,CAAC,MAAM;AACT,aAAK,OAAO,MAAM,+BAA+B,iCAAiC,4BAA4B;AAC9G;AAAA,MACF;AAEA,YAAM,WAAW,2BAA2B,2CAA2C;AACvF,UAAI,MAAM,OAAO,SAAS,GAAG,MAAM,OAAO,GAAG;AAC3C,aAAK,OAAO,MAAM,GAAG,gDAAgD;AACrE;AAAA,MACF;AAEA,WAAK,OAAO,KAAK,aAAAD,QAAM,KAAK,GAAG,iDAAiD,CAAC;AAAA,IACnF,SAAS,QAAP;AACA,YAAM,MAAM,OAAO,iBAAiB,IAAI,MAAM;AAC9C,WAAK,OAAO,MAAM,yCAAyC,IAAI,SAAS;AAAA,IAC1E;AAAA,EACF;AACF;",
|
|
6
6
|
"names": ["_", "bluebird", "fs", "pathlib", "chalk", "semver"]
|
|
7
7
|
}
|
|
@@ -28,16 +28,28 @@ __export(read_command_exports, {
|
|
|
28
28
|
});
|
|
29
29
|
module.exports = __toCommonJS(read_command_exports);
|
|
30
30
|
var import_integration_body = require("../api/integration-body");
|
|
31
|
+
var import_interface_body = require("../api/interface-body");
|
|
31
32
|
var errors = __toESM(require("../errors"));
|
|
33
|
+
var utils = __toESM(require("../utils"));
|
|
32
34
|
var import_project_command = require("./project-command");
|
|
33
35
|
class ReadCommand extends import_project_command.ProjectCommand {
|
|
34
36
|
async run() {
|
|
35
|
-
const
|
|
36
|
-
if (
|
|
37
|
-
|
|
37
|
+
const projectDef = await this.readProjectDefinitionFromFS();
|
|
38
|
+
if (projectDef.type === "integration") {
|
|
39
|
+
const parsed = (0, import_integration_body.prepareCreateIntegrationBody)(projectDef.definition);
|
|
40
|
+
parsed.interfaces = utils.records.mapValues(projectDef.definition.interfaces, (iface) => ({
|
|
41
|
+
id: "...",
|
|
42
|
+
...iface
|
|
43
|
+
}));
|
|
44
|
+
this.logger.json(parsed);
|
|
45
|
+
return;
|
|
38
46
|
}
|
|
39
|
-
|
|
40
|
-
|
|
47
|
+
if (projectDef.type === "interface") {
|
|
48
|
+
const parsed = (0, import_interface_body.prepareCreateInterfaceBody)(projectDef.definition);
|
|
49
|
+
this.logger.json(parsed);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
throw new errors.BotpressCLIError("A bot project has no definition to read");
|
|
41
53
|
}
|
|
42
54
|
}
|
|
43
55
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/command-implementations/read-command.ts"],
|
|
4
|
-
"sourcesContent": ["import { prepareCreateIntegrationBody } from '../api/integration-body'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport { ProjectCommand } from './project-command'\n\nexport type ReadCommandDefinition = typeof commandDefinitions.read\nexport class ReadCommand extends ProjectCommand<ReadCommandDefinition> {\n public async run(): Promise<void> {\n const
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAA6C;
|
|
4
|
+
"sourcesContent": ["import { prepareCreateIntegrationBody } from '../api/integration-body'\nimport { prepareCreateInterfaceBody } from '../api/interface-body'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport * as utils from '../utils'\nimport { ProjectCommand } from './project-command'\n\nexport type ReadCommandDefinition = typeof commandDefinitions.read\nexport class ReadCommand extends ProjectCommand<ReadCommandDefinition> {\n public async run(): Promise<void> {\n const projectDef = await this.readProjectDefinitionFromFS()\n if (projectDef.type === 'integration') {\n const parsed = prepareCreateIntegrationBody(projectDef.definition)\n parsed.interfaces = utils.records.mapValues(projectDef.definition.interfaces, (iface) => ({\n id: '...', // need to be logged in to get this id\n ...iface,\n }))\n this.logger.json(parsed)\n return\n }\n if (projectDef.type === 'interface') {\n const parsed = prepareCreateInterfaceBody(projectDef.definition)\n this.logger.json(parsed)\n return\n }\n\n throw new errors.BotpressCLIError('A bot project has no definition to read')\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAA6C;AAC7C,4BAA2C;AAE3C,aAAwB;AACxB,YAAuB;AACvB,6BAA+B;AAGxB,MAAM,oBAAoB,sCAAsC;AAAA,EACrE,MAAa,MAAqB;AAChC,UAAM,aAAa,MAAM,KAAK,4BAA4B;AAC1D,QAAI,WAAW,SAAS,eAAe;AACrC,YAAM,aAAS,sDAA6B,WAAW,UAAU;AACjE,aAAO,aAAa,MAAM,QAAQ,UAAU,WAAW,WAAW,YAAY,CAAC,WAAW;AAAA,QACxF,IAAI;AAAA,QACJ,GAAG;AAAA,MACL,EAAE;AACF,WAAK,OAAO,KAAK,MAAM;AACvB;AAAA,IACF;AACA,QAAI,WAAW,SAAS,aAAa;AACnC,YAAM,aAAS,kDAA2B,WAAW,UAAU;AAC/D,WAAK,OAAO,KAAK,MAAM;AACvB;AAAA,IACF;AAEA,UAAM,IAAI,OAAO,iBAAiB,yCAAyC;AAAA,EAC7E;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -37,15 +37,18 @@ class ServeCommand extends import_project_command.ProjectCommand {
|
|
|
37
37
|
if (!fs.existsSync(outfile)) {
|
|
38
38
|
throw new errors.NoBundleFoundError();
|
|
39
39
|
}
|
|
40
|
-
const
|
|
41
|
-
if (
|
|
42
|
-
|
|
40
|
+
const projectDef = await this.readProjectDefinitionFromFS();
|
|
41
|
+
if (projectDef.type === "interface") {
|
|
42
|
+
throw new errors.BotpressCLIError("An interface project has no implementation to serve.");
|
|
43
|
+
}
|
|
44
|
+
if (projectDef.type === "integration") {
|
|
45
|
+
const secretEnvVariables = await this.promptSecrets(projectDef.definition, this.argv, { formatEnv: true });
|
|
43
46
|
const nonNullSecretEnvVariables = utils.records.filterValues(secretEnvVariables, utils.guards.is.notNull);
|
|
44
47
|
for (const [key, value] of Object.entries(nonNullSecretEnvVariables)) {
|
|
45
48
|
process.env[key] = value;
|
|
46
49
|
}
|
|
47
50
|
}
|
|
48
|
-
this.logger.log(`Serving ${
|
|
51
|
+
this.logger.log(`Serving ${projectDef.type}...`);
|
|
49
52
|
const { default: serveable } = utils.require.requireJsFile(outfile);
|
|
50
53
|
const server = await serveable.start(this.argv.port);
|
|
51
54
|
await new Promise((resolve, reject) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/command-implementations/serve-command.ts"],
|
|
4
|
-
"sourcesContent": ["import type { Bot as BotImpl, Integration as IntegrationImpl } from '@botpress/sdk'\nimport * as fs from 'fs'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport * as utils from '../utils'\nimport { ProjectCommand } from './project-command'\n\ntype Serveable = BotImpl | IntegrationImpl\n\nexport type ServeCommandDefinition = typeof commandDefinitions.serve\nexport class ServeCommand extends ProjectCommand<ServeCommandDefinition> {\n public async run(): Promise<void> {\n const outfile = this.projectPaths.abs.outFile\n if (!fs.existsSync(outfile)) {\n throw new errors.NoBundleFoundError()\n }\n\n const
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,SAAoB;AAEpB,aAAwB;AACxB,YAAuB;AACvB,6BAA+B;AAKxB,MAAM,qBAAqB,sCAAuC;AAAA,EACvE,MAAa,MAAqB;AAChC,UAAM,UAAU,KAAK,aAAa,IAAI;AACtC,QAAI,CAAC,GAAG,WAAW,OAAO,GAAG;AAC3B,YAAM,IAAI,OAAO,mBAAmB;AAAA,IACtC;AAEA,UAAM,
|
|
4
|
+
"sourcesContent": ["import type { Bot as BotImpl, Integration as IntegrationImpl } from '@botpress/sdk'\nimport * as fs from 'fs'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport * as utils from '../utils'\nimport { ProjectCommand } from './project-command'\n\ntype Serveable = BotImpl | IntegrationImpl\n\nexport type ServeCommandDefinition = typeof commandDefinitions.serve\nexport class ServeCommand extends ProjectCommand<ServeCommandDefinition> {\n public async run(): Promise<void> {\n const outfile = this.projectPaths.abs.outFile\n if (!fs.existsSync(outfile)) {\n throw new errors.NoBundleFoundError()\n }\n\n const projectDef = await this.readProjectDefinitionFromFS()\n if (projectDef.type === 'interface') {\n throw new errors.BotpressCLIError('An interface project has no implementation to serve.')\n }\n\n if (projectDef.type === 'integration') {\n // TODO: store secrets in local cache to avoid prompting every time\n const secretEnvVariables = await this.promptSecrets(projectDef.definition, this.argv, { formatEnv: true })\n const nonNullSecretEnvVariables = utils.records.filterValues(secretEnvVariables, utils.guards.is.notNull)\n for (const [key, value] of Object.entries(nonNullSecretEnvVariables)) {\n process.env[key] = value\n }\n }\n\n this.logger.log(`Serving ${projectDef.type}...`)\n\n const { default: serveable } = utils.require.requireJsFile<{ default: Serveable }>(outfile)\n const server = await serveable.start(this.argv.port)\n\n await new Promise<void>((resolve, reject) => {\n server.on('error', reject)\n server.on('close', resolve)\n })\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,SAAoB;AAEpB,aAAwB;AACxB,YAAuB;AACvB,6BAA+B;AAKxB,MAAM,qBAAqB,sCAAuC;AAAA,EACvE,MAAa,MAAqB;AAChC,UAAM,UAAU,KAAK,aAAa,IAAI;AACtC,QAAI,CAAC,GAAG,WAAW,OAAO,GAAG;AAC3B,YAAM,IAAI,OAAO,mBAAmB;AAAA,IACtC;AAEA,UAAM,aAAa,MAAM,KAAK,4BAA4B;AAC1D,QAAI,WAAW,SAAS,aAAa;AACnC,YAAM,IAAI,OAAO,iBAAiB,sDAAsD;AAAA,IAC1F;AAEA,QAAI,WAAW,SAAS,eAAe;AAErC,YAAM,qBAAqB,MAAM,KAAK,cAAc,WAAW,YAAY,KAAK,MAAM,EAAE,WAAW,KAAK,CAAC;AACzG,YAAM,4BAA4B,MAAM,QAAQ,aAAa,oBAAoB,MAAM,OAAO,GAAG,OAAO;AACxG,iBAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,yBAAyB,GAAG;AACpE,gBAAQ,IAAI,OAAO;AAAA,MACrB;AAAA,IACF;AAEA,SAAK,OAAO,IAAI,WAAW,WAAW,SAAS;AAE/C,UAAM,EAAE,SAAS,UAAU,IAAI,MAAM,QAAQ,cAAsC,OAAO;AAC1F,UAAM,SAAS,MAAM,UAAU,MAAM,KAAK,KAAK,IAAI;AAEnD,UAAM,IAAI,QAAc,CAAC,SAAS,WAAW;AAC3C,aAAO,GAAG,SAAS,MAAM;AACzB,aAAO,GAAG,SAAS,OAAO;AAAA,IAC5B,CAAC;AAAA,EACH;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/config.js
CHANGED
|
@@ -69,11 +69,15 @@ const botRef = {
|
|
|
69
69
|
};
|
|
70
70
|
const integrationRef = {
|
|
71
71
|
type: "string",
|
|
72
|
-
description: "The integration ID or name with
|
|
72
|
+
description: "The integration ID or name with optional version. Ex: teams or teams@0.2.0",
|
|
73
73
|
demandOption: true,
|
|
74
74
|
positional: true,
|
|
75
75
|
idx: 0
|
|
76
76
|
};
|
|
77
|
+
const interfaceRef = {
|
|
78
|
+
...integrationRef,
|
|
79
|
+
description: "The interface ID or name with optional version. Ex: teams or teams@0.2.0"
|
|
80
|
+
};
|
|
77
81
|
const sourceMap = { type: "boolean", description: "Generate sourcemaps", default: false };
|
|
78
82
|
const dev = {
|
|
79
83
|
type: "boolean",
|
|
@@ -220,6 +224,20 @@ const deleteIntegrationSchema = {
|
|
|
220
224
|
...credentialsSchema,
|
|
221
225
|
integrationRef
|
|
222
226
|
};
|
|
227
|
+
const getInterfaceSchema = {
|
|
228
|
+
...globalSchema,
|
|
229
|
+
...credentialsSchema,
|
|
230
|
+
interfaceRef
|
|
231
|
+
};
|
|
232
|
+
const listInterfacesSchema = {
|
|
233
|
+
...globalSchema,
|
|
234
|
+
...credentialsSchema
|
|
235
|
+
};
|
|
236
|
+
const deleteInterfaceSchema = {
|
|
237
|
+
...globalSchema,
|
|
238
|
+
...credentialsSchema,
|
|
239
|
+
interfaceRef
|
|
240
|
+
};
|
|
223
241
|
const initSchema = {
|
|
224
242
|
...globalSchema,
|
|
225
243
|
workDir,
|
|
@@ -240,6 +258,9 @@ const schemas = {
|
|
|
240
258
|
getIntegration: getIntegrationSchema,
|
|
241
259
|
listIntegrations: listIntegrationsSchema,
|
|
242
260
|
deleteIntegration: deleteIntegrationSchema,
|
|
261
|
+
getInterface: getInterfaceSchema,
|
|
262
|
+
listInterfaces: listInterfacesSchema,
|
|
263
|
+
deleteInterface: deleteInterfaceSchema,
|
|
243
264
|
init: initSchema,
|
|
244
265
|
generate: generateSchema,
|
|
245
266
|
bundle: bundleSchema,
|
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 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: process.cwd(),\n} satisfies CommandOption\n\nconst noBuild = {\n type: 'boolean',\n description: 'Skip the build step',\n default: false,\n} 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 integrationRef = {\n type: 'string',\n description: 'The integration ID or name with
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAAwB;AAKxB,MAAM,OAAO;AAAA,EACX,MAAM;AAAA,EACN,aAAa;AACf;AAEA,MAAM,UAAU;AAAA,EACd,MAAM;AAAA,EACN,aAAa;AAAA,EACb,SAAS,QAAQ,IAAI;AACvB;AAEA,MAAM,UAAU;AAAA,EACd,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,iBAAiB;AAAA,EACrB,MAAM;AAAA,EACN,aAAa;AAAA,EACb,cAAc;AAAA,EACd,YAAY;AAAA,EACZ,KAAK;AACP;AAEA,MAAM,YAAY,EAAE,MAAM,WAAW,aAAa,uBAAuB,SAAS,MAAM;AAExF,MAAM,MAAM;AAAA,EACV,MAAM;AAAA,EACN,aAAa;AAAA,EACb,SAAS;AACX;AAEA,MAAM,WAAW;AAAA,EACf,MAAM;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AAU,aAAa,0BAA0B;AACjE;AAIO,MAAM,UAAU;AAAA,EACrB,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,aAAa;AAAA,EACb,SAAS;AAAA,EAET,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,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;AACP;",
|
|
4
|
+
"sourcesContent": ["import * as consts from './consts'\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: process.cwd(),\n} satisfies CommandOption\n\nconst noBuild = {\n type: 'boolean',\n description: 'Skip the build step',\n default: false,\n} 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 integrationRef = {\n type: 'string',\n description: 'The integration ID or name with optional version. Ex: teams or teams@0.2.0',\n demandOption: true,\n positional: true,\n idx: 0,\n} satisfies CommandOption\n\nconst interfaceRef = {\n ...integrationRef,\n description: 'The interface ID or name with optional version. Ex: teams or teams@0.2.0',\n} satisfies CommandOption\n\nconst sourceMap = { type: 'boolean', description: 'Generate sourcemaps', default: false } satisfies CommandOption\n\nconst dev = {\n type: 'boolean',\n description: 'List only dev bots / dev integrations',\n default: false,\n} satisfies CommandOption\n\nconst isPublic = {\n type: 'boolean',\n description: 'Weither or not to deploy the integration publicly',\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} satisfies CommandSchema\n\nconst projectSchema = {\n ...globalSchema,\n entryPoint: { type: 'string', description: 'The entry point of the project', default: consts.defaultEntrypoint },\n outDir: { type: 'string', description: 'The output directory', default: consts.defaultOutputFolder },\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} satisfies CommandSchema\n\nconst buildSchema = {\n ...projectSchema,\n sourceMap,\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 createNewBot: { type: 'boolean', description: 'Create a new bot when deploying. Only used when deploying a bot' },\n sourceMap,\n public: isPublic,\n allowDeprecated: {\n type: 'boolean',\n description: 'Allow deprecated features in the project',\n default: false,\n },\n} satisfies CommandSchema\n\nconst devSchema = {\n ...projectSchema,\n ...credentialsSchema,\n ...secretsSchema,\n sourceMap,\n port,\n tunnelUrl: {\n type: 'string',\n description: 'The tunnel HTTP URL to use',\n default: consts.defaultTunnelUrl,\n },\n} satisfies CommandSchema\n\nconst addSchema = {\n ...projectSchema,\n ...credentialsSchema,\n integrationRef,\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} 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 initSchema = {\n ...globalSchema,\n workDir,\n type: { type: 'string', choices: ['bot', 'integration'] as const },\n name: { type: 'string', description: 'The name of the project' },\n} satisfies CommandSchema\n\n// exports\n\nexport const schemas = {\n global: globalSchema,\n project: projectSchema,\n credentials: credentialsSchema,\n secrets: secretsSchema,\n\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 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} as const\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAAwB;AAKxB,MAAM,OAAO;AAAA,EACX,MAAM;AAAA,EACN,aAAa;AACf;AAEA,MAAM,UAAU;AAAA,EACd,MAAM;AAAA,EACN,aAAa;AAAA,EACb,SAAS,QAAQ,IAAI;AACvB;AAEA,MAAM,UAAU;AAAA,EACd,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,iBAAiB;AAAA,EACrB,MAAM;AA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,aAAa,4CAA4C;AAAA,EACjF,eAAe,EAAE,MAAM,UAAU,aAAa,+CAA+C;AAAA,EAC7F;AACF;AAEA,MAAM,0BAA0B;AAAA,EAC9B,GAAG;AAAA,EACH,GAAG;AAAA,EACH;AACF;AAEA,MAAM,qBAAqB;AAAA,EACzB,GAAG;AAAA,EACH,GAAG;AAAA,EACH;AACF;AAEA,MAAM,uBAAuB;AAAA,EAC3B,GAAG;AAAA,EACH,GAAG;AACL;AAEA,MAAM,wBAAwB;AAAA,EAC5B,GAAG;AAAA,EACH,GAAG;AAAA,EACH;AACF;AAEA,MAAM,aAAa;AAAA,EACjB,GAAG;AAAA,EACH;AAAA,EACA,MAAM,EAAE,MAAM,UAAU,SAAS,CAAC,OAAO,aAAa,EAAW;AAAA,EACjE,MAAM,EAAE,MAAM,UAAU,aAAa,0BAA0B;AACjE;AAIO,MAAM,UAAU;AAAA,EACrB,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,aAAa;AAAA,EACb,SAAS;AAAA,EAET,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,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;AACP;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/consts.js
CHANGED
|
@@ -65,7 +65,8 @@ const fromHomeDir = {
|
|
|
65
65
|
globalCacheFile: "global.cache.json"
|
|
66
66
|
};
|
|
67
67
|
const fromWorkDir = {
|
|
68
|
-
|
|
68
|
+
integrationDefinition: "integration.definition.ts",
|
|
69
|
+
interfaceDefinition: "interface.definition.ts"
|
|
69
70
|
};
|
|
70
71
|
const fromOutDir = {
|
|
71
72
|
distDir: "dist",
|
package/dist/consts.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/consts.ts"],
|
|
4
|
-
"sourcesContent": ["import os from 'os'\nimport pathlib from 'path'\nimport { CLI_ROOT_DIR } from './root'\n\n// configurable\n\nexport const defaultBotpressHome = pathlib.join(os.homedir(), '.botpress')\n\nexport const defaultOutputFolder = '.botpress'\nexport const defaultEntrypoint = pathlib.join('src', 'index.ts')\nexport const defaultBotpressApiUrl = 'https://api.botpress.cloud'\nexport const defaultBotpressAppUrl = 'https://app.botpress.cloud'\nexport const defaultTunnelUrl = 'https://tunnel.botpress.cloud'\n\n// not configurable\n\nexport const cliRootDir = CLI_ROOT_DIR\n\nexport const echoBotDirName = 'echo-bot'\nexport const emptyIntegrationDirName = 'empty-integration'\nexport const helloWorldIntegrationDirName = 'hello-world'\nexport const webhookMessageIntegrationDirName = 'webhook-message'\n\nexport const fromCliRootDir = {\n echoBotTemplate: pathlib.join('templates', echoBotDirName),\n emptyIntegrationTemplate: pathlib.join('templates', emptyIntegrationDirName),\n helloWorldIntegrationTemplate: pathlib.join('templates', helloWorldIntegrationDirName),\n webhookMessageIntegrationTemplate: pathlib.join('templates', webhookMessageIntegrationDirName),\n}\n\nexport const fromHomeDir = {\n globalCacheFile: 'global.cache.json',\n}\n\nexport const fromWorkDir = {\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAe;AACf,kBAAoB;AACpB,kBAA6B;AAItB,MAAM,sBAAsB,YAAAA,QAAQ,KAAK,UAAAC,QAAG,QAAQ,GAAG,WAAW;AAElE,MAAM,sBAAsB;AAC5B,MAAM,oBAAoB,YAAAD,QAAQ,KAAK,OAAO,UAAU;AACxD,MAAM,wBAAwB;AAC9B,MAAM,wBAAwB;AAC9B,MAAM,mBAAmB;AAIzB,MAAM,aAAa;AAEnB,MAAM,iBAAiB;AACvB,MAAM,0BAA0B;AAChC,MAAM,+BAA+B;AACrC,MAAM,mCAAmC;AAEzC,MAAM,iBAAiB;AAAA,EAC5B,iBAAiB,YAAAA,QAAQ,KAAK,aAAa,cAAc;AAAA,EACzD,0BAA0B,YAAAA,QAAQ,KAAK,aAAa,uBAAuB;AAAA,EAC3E,+BAA+B,YAAAA,QAAQ,KAAK,aAAa,4BAA4B;AAAA,EACrF,mCAAmC,YAAAA,QAAQ,KAAK,aAAa,gCAAgC;AAC/F;AAEO,MAAM,cAAc;AAAA,EACzB,iBAAiB;AACnB;AAEO,MAAM,cAAc;AAAA,EACzB,
|
|
4
|
+
"sourcesContent": ["import os from 'os'\nimport pathlib from 'path'\nimport { CLI_ROOT_DIR } from './root'\n\n// configurable\n\nexport const defaultBotpressHome = pathlib.join(os.homedir(), '.botpress')\n\nexport const defaultOutputFolder = '.botpress'\nexport const defaultEntrypoint = pathlib.join('src', 'index.ts')\nexport const defaultBotpressApiUrl = 'https://api.botpress.cloud'\nexport const defaultBotpressAppUrl = 'https://app.botpress.cloud'\nexport const defaultTunnelUrl = 'https://tunnel.botpress.cloud'\n\n// not configurable\n\nexport const cliRootDir = CLI_ROOT_DIR\n\nexport const echoBotDirName = 'echo-bot'\nexport const emptyIntegrationDirName = 'empty-integration'\nexport const helloWorldIntegrationDirName = 'hello-world'\nexport const webhookMessageIntegrationDirName = 'webhook-message'\n\nexport const fromCliRootDir = {\n echoBotTemplate: pathlib.join('templates', echoBotDirName),\n emptyIntegrationTemplate: pathlib.join('templates', emptyIntegrationDirName),\n helloWorldIntegrationTemplate: pathlib.join('templates', helloWorldIntegrationDirName),\n webhookMessageIntegrationTemplate: pathlib.join('templates', webhookMessageIntegrationDirName),\n}\n\nexport const fromHomeDir = {\n globalCacheFile: 'global.cache.json',\n}\n\nexport const fromWorkDir = {\n integrationDefinition: 'integration.definition.ts',\n interfaceDefinition: 'interface.definition.ts',\n}\n\nexport const fromOutDir = {\n distDir: 'dist',\n outFile: pathlib.join('dist', 'index.js'),\n installDir: 'installations',\n implementationDir: 'implementation',\n secretsDir: 'secrets',\n projectCacheFile: 'project.cache.json',\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAe;AACf,kBAAoB;AACpB,kBAA6B;AAItB,MAAM,sBAAsB,YAAAA,QAAQ,KAAK,UAAAC,QAAG,QAAQ,GAAG,WAAW;AAElE,MAAM,sBAAsB;AAC5B,MAAM,oBAAoB,YAAAD,QAAQ,KAAK,OAAO,UAAU;AACxD,MAAM,wBAAwB;AAC9B,MAAM,wBAAwB;AAC9B,MAAM,mBAAmB;AAIzB,MAAM,aAAa;AAEnB,MAAM,iBAAiB;AACvB,MAAM,0BAA0B;AAChC,MAAM,+BAA+B;AACrC,MAAM,mCAAmC;AAEzC,MAAM,iBAAiB;AAAA,EAC5B,iBAAiB,YAAAA,QAAQ,KAAK,aAAa,cAAc;AAAA,EACzD,0BAA0B,YAAAA,QAAQ,KAAK,aAAa,uBAAuB;AAAA,EAC3E,+BAA+B,YAAAA,QAAQ,KAAK,aAAa,4BAA4B;AAAA,EACrF,mCAAmC,YAAAA,QAAQ,KAAK,aAAa,gCAAgC;AAC/F;AAEO,MAAM,cAAc;AAAA,EACzB,iBAAiB;AACnB;AAEO,MAAM,cAAc;AAAA,EACzB,uBAAuB;AAAA,EACvB,qBAAqB;AACvB;AAEO,MAAM,aAAa;AAAA,EACxB,SAAS;AAAA,EACT,SAAS,YAAAA,QAAQ,KAAK,QAAQ,UAAU;AAAA,EACxC,YAAY;AAAA,EACZ,mBAAmB;AAAA,EACnB,YAAY;AAAA,EACZ,kBAAkB;AACpB;",
|
|
6
6
|
"names": ["pathlib", "os"]
|
|
7
7
|
}
|
package/dist/errors.js
CHANGED
|
@@ -29,6 +29,7 @@ __export(errors_exports, {
|
|
|
29
29
|
ExclusiveIntegrationFeatureError: () => ExclusiveIntegrationFeatureError,
|
|
30
30
|
HTTPError: () => HTTPError,
|
|
31
31
|
InvalidIntegrationReferenceError: () => InvalidIntegrationReferenceError,
|
|
32
|
+
InvalidInterfaceReferenceError: () => InvalidInterfaceReferenceError,
|
|
32
33
|
NoBotsFoundError: () => NoBotsFoundError,
|
|
33
34
|
NoBundleFoundError: () => NoBundleFoundError,
|
|
34
35
|
NoWorkspacesFoundError: () => NoWorkspacesFoundError,
|
|
@@ -90,13 +91,13 @@ class BotpressCLIError extends import_verror.VError {
|
|
|
90
91
|
}
|
|
91
92
|
class ExclusiveBotFeatureError extends BotpressCLIError {
|
|
92
93
|
constructor() {
|
|
93
|
-
const message = "This feature is only available for bots. This project is an integration";
|
|
94
|
+
const message = "This feature is only available for bots. This project is an integration or interface.";
|
|
94
95
|
super(message);
|
|
95
96
|
}
|
|
96
97
|
}
|
|
97
98
|
class ExclusiveIntegrationFeatureError extends BotpressCLIError {
|
|
98
99
|
constructor() {
|
|
99
|
-
const message = "This feature is only available for integration. This project is a bot";
|
|
100
|
+
const message = "This feature is only available for integration. This project is a bot or interface.";
|
|
100
101
|
super(message);
|
|
101
102
|
}
|
|
102
103
|
}
|
|
@@ -166,6 +167,12 @@ class InvalidIntegrationReferenceError extends BotpressCLIError {
|
|
|
166
167
|
super(message);
|
|
167
168
|
}
|
|
168
169
|
}
|
|
170
|
+
class InvalidInterfaceReferenceError extends BotpressCLIError {
|
|
171
|
+
constructor(ref) {
|
|
172
|
+
const message = `Invalid interface reference "${ref}".`;
|
|
173
|
+
super(message);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
169
176
|
// Annotate the CommonJS export names for ESM import in node:
|
|
170
177
|
0 && (module.exports = {
|
|
171
178
|
BotpressCLIError,
|
|
@@ -173,6 +180,7 @@ class InvalidIntegrationReferenceError extends BotpressCLIError {
|
|
|
173
180
|
ExclusiveIntegrationFeatureError,
|
|
174
181
|
HTTPError,
|
|
175
182
|
InvalidIntegrationReferenceError,
|
|
183
|
+
InvalidInterfaceReferenceError,
|
|
176
184
|
NoBotsFoundError,
|
|
177
185
|
NoBundleFoundError,
|
|
178
186
|
NoWorkspacesFoundError,
|
package/dist/errors.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/errors.ts"],
|
|
4
|
-
"sourcesContent": ["import { isApiError, ApiError, UnknownError } from '@botpress/client'\nimport axios, { AxiosError } from 'axios'\nimport { VError } from 'verror'\nimport * as consts from './consts'\n\ntype KnownApiError = Exclude<ApiError, UnknownError>\nconst isKnownApiError = (e: unknown): e is KnownApiError => isApiError(e) && !(e instanceof UnknownError)\n\nexport class BotpressCLIError extends VError {\n public static wrap(thrown: unknown, message: string): BotpressCLIError {\n const err = BotpressCLIError.map(thrown)\n return new BotpressCLIError(err, message ?? '')\n }\n\n public static map(thrown: unknown): BotpressCLIError {\n if (thrown instanceof BotpressCLIError) {\n return thrown\n }\n if (thrown instanceof UnknownError) {\n const inst = new HTTPError(500, 'An unknown error has occurred.')\n inst.debug = thrown.message\n return inst\n }\n if (isKnownApiError(thrown)) {\n return HTTPError.fromApi(thrown)\n }\n if (axios.isAxiosError(thrown)) {\n return HTTPError.fromAxios(thrown)\n }\n if (thrown instanceof Error) {\n const { message } = thrown\n return new BotpressCLIError(message)\n }\n return new BotpressCLIError(`${thrown}`)\n }\n\n private readonly _debug: string[]\n\n constructor(error: BotpressCLIError, message: string)\n constructor(message: string)\n public constructor(first: BotpressCLIError | string, second?: string) {\n if (typeof first === 'string') {\n super(first)\n this._debug = []\n return\n }\n super(first, second!)\n this._debug = [...first._debug]\n }\n\n public set debug(msg: string) {\n this._debug.push(msg)\n }\n\n public get debug(): string {\n const dbgMsgs = this._debug.filter((s) => s.length)\n if (!dbgMsgs.length) {\n return ''\n }\n return 'Error: \\n' + dbgMsgs.map((s) => ` ${s}`).join('\\n')\n }\n}\n\nexport class ExclusiveBotFeatureError extends BotpressCLIError {\n constructor() {\n const message = 'This feature is only available for bots. This project is an integration'\n super(message)\n }\n}\n\nexport class ExclusiveIntegrationFeatureError extends BotpressCLIError {\n constructor() {\n const message = 'This feature is only available for integration. This project is a bot'\n super(message)\n }\n}\n\nexport class HTTPError extends BotpressCLIError {\n constructor(public readonly status: number | undefined, message: string) {\n super(message)\n }\n\n public static fromAxios(e: AxiosError<{ message?: string }>): HTTPError {\n const message = this._axiosMsg(e)\n return new HTTPError(e.response?.status, message)\n }\n\n public static fromApi(e: KnownApiError): HTTPError {\n const { message, code } = e\n return new HTTPError(code, message)\n }\n\n private static _axiosMsg(e: AxiosError<{ message?: string }>): string {\n let message = e.message\n if (e.response?.statusText) {\n message += `\\n ${e.response?.statusText}`\n }\n if (e.response?.status && e.request?.method && e.request?.path) {\n message += `\\n (${e.response?.status}) ${e.request.method} ${e.request.path}`\n }\n if (e.response?.data?.message) {\n message += `\\n ${e.response?.data?.message}`\n }\n return message\n }\n}\n\nexport class NoBundleFoundError extends BotpressCLIError {\n constructor() {\n const message = 'No bundle found. Please run `bp bundle` first.'\n super(message)\n }\n}\n\nexport class NoBotsFoundError extends BotpressCLIError {\n constructor() {\n const message = `No Bot found in your Workspace. Please create one first at ${consts.defaultBotpressAppUrl}.`\n super(message)\n }\n}\n\nexport class NoWorkspacesFoundError extends BotpressCLIError {\n constructor() {\n const message = 'No Workspace found. Please create one first.'\n super(message)\n }\n}\n\nexport class NotLoggedInError extends BotpressCLIError {\n constructor() {\n const message = 'Not logged in. Please run `bp login` first.'\n super(message)\n }\n}\n\nexport class ParamRequiredError extends BotpressCLIError {\n constructor(param: string) {\n const message = `${param} is required.`\n super(message)\n }\n}\n\nexport class InvalidIntegrationReferenceError extends BotpressCLIError {\n constructor(ref: string) {\n const message = `Invalid integration reference \"${ref}\".`\n super(message)\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAmD;AACnD,mBAAkC;AAClC,oBAAuB;AACvB,aAAwB;AAGxB,MAAM,kBAAkB,CAAC,UAAmC,0BAAW,CAAC,KAAK,EAAE,aAAa;AAErF,MAAM,yBAAyB,qBAAO;AAAA,EAC3C,OAAc,KAAK,QAAiB,SAAmC;AACrE,UAAM,MAAM,iBAAiB,IAAI,MAAM;AACvC,WAAO,IAAI,iBAAiB,KAAK,WAAW,EAAE;AAAA,EAChD;AAAA,EAEA,OAAc,IAAI,QAAmC;AACnD,QAAI,kBAAkB,kBAAkB;AACtC,aAAO;AAAA,IACT;AACA,QAAI,kBAAkB,4BAAc;AAClC,YAAM,OAAO,IAAI,UAAU,KAAK,gCAAgC;AAChE,WAAK,QAAQ,OAAO;AACpB,aAAO;AAAA,IACT;AACA,QAAI,gBAAgB,MAAM,GAAG;AAC3B,aAAO,UAAU,QAAQ,MAAM;AAAA,IACjC;AACA,QAAI,aAAAA,QAAM,aAAa,MAAM,GAAG;AAC9B,aAAO,UAAU,UAAU,MAAM;AAAA,IACnC;AACA,QAAI,kBAAkB,OAAO;AAC3B,YAAM,EAAE,QAAQ,IAAI;AACpB,aAAO,IAAI,iBAAiB,OAAO;AAAA,IACrC;AACA,WAAO,IAAI,iBAAiB,GAAG,QAAQ;AAAA,EACzC;AAAA,EAEiB;AAAA,EAIV,YAAY,OAAkC,QAAiB;AACpE,QAAI,OAAO,UAAU,UAAU;AAC7B,YAAM,KAAK;AACX,WAAK,SAAS,CAAC;AACf;AAAA,IACF;AACA,UAAM,OAAO,MAAO;AACpB,SAAK,SAAS,CAAC,GAAG,MAAM,M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MAAM;AAAA,IACtC;AACA,WAAO;AAAA,EACT;AACF;AAEO,MAAM,2BAA2B,iBAAiB;AAAA,EACvD,cAAc;AACZ,UAAM,UAAU;AAChB,UAAM,OAAO;AAAA,EACf;AACF;AAEO,MAAM,yBAAyB,iBAAiB;AAAA,EACrD,cAAc;AACZ,UAAM,UAAU,8DAA8D,OAAO;AACrF,UAAM,OAAO;AAAA,EACf;AACF;AAEO,MAAM,+BAA+B,iBAAiB;AAAA,EAC3D,cAAc;AACZ,UAAM,UAAU;AAChB,UAAM,OAAO;AAAA,EACf;AACF;AAEO,MAAM,yBAAyB,iBAAiB;AAAA,EACrD,cAAc;AACZ,UAAM,UAAU;AAChB,UAAM,OAAO;AAAA,EACf;AACF;AAEO,MAAM,2BAA2B,iBAAiB;AAAA,EACvD,YAAY,OAAe;AACzB,UAAM,UAAU,GAAG;AACnB,UAAM,OAAO;AAAA,EACf;AACF;AAEO,MAAM,yCAAyC,iBAAiB;AAAA,EACrE,YAAY,KAAa;AACvB,UAAM,UAAU,kCAAkC;AAClD,UAAM,OAAO;AAAA,EACf;AACF;",
|
|
4
|
+
"sourcesContent": ["import { isApiError, ApiError, UnknownError } from '@botpress/client'\nimport axios, { AxiosError } from 'axios'\nimport { VError } from 'verror'\nimport * as consts from './consts'\n\ntype KnownApiError = Exclude<ApiError, UnknownError>\nconst isKnownApiError = (e: unknown): e is KnownApiError => isApiError(e) && !(e instanceof UnknownError)\n\nexport class BotpressCLIError extends VError {\n public static wrap(thrown: unknown, message: string): BotpressCLIError {\n const err = BotpressCLIError.map(thrown)\n return new BotpressCLIError(err, message ?? '')\n }\n\n public static map(thrown: unknown): BotpressCLIError {\n if (thrown instanceof BotpressCLIError) {\n return thrown\n }\n if (thrown instanceof UnknownError) {\n const inst = new HTTPError(500, 'An unknown error has occurred.')\n inst.debug = thrown.message\n return inst\n }\n if (isKnownApiError(thrown)) {\n return HTTPError.fromApi(thrown)\n }\n if (axios.isAxiosError(thrown)) {\n return HTTPError.fromAxios(thrown)\n }\n if (thrown instanceof Error) {\n const { message } = thrown\n return new BotpressCLIError(message)\n }\n return new BotpressCLIError(`${thrown}`)\n }\n\n private readonly _debug: string[]\n\n constructor(error: BotpressCLIError, message: string)\n constructor(message: string)\n public constructor(first: BotpressCLIError | string, second?: string) {\n if (typeof first === 'string') {\n super(first)\n this._debug = []\n return\n }\n super(first, second!)\n this._debug = [...first._debug]\n }\n\n public set debug(msg: string) {\n this._debug.push(msg)\n }\n\n public get debug(): string {\n const dbgMsgs = this._debug.filter((s) => s.length)\n if (!dbgMsgs.length) {\n return ''\n }\n return 'Error: \\n' + dbgMsgs.map((s) => ` ${s}`).join('\\n')\n }\n}\n\nexport class ExclusiveBotFeatureError extends BotpressCLIError {\n constructor() {\n const message = 'This feature is only available for bots. This project is an integration or interface.'\n super(message)\n }\n}\n\nexport class ExclusiveIntegrationFeatureError extends BotpressCLIError {\n constructor() {\n const message = 'This feature is only available for integration. This project is a bot or interface.'\n super(message)\n }\n}\n\nexport class HTTPError extends BotpressCLIError {\n constructor(public readonly status: number | undefined, message: string) {\n super(message)\n }\n\n public static fromAxios(e: AxiosError<{ message?: string }>): HTTPError {\n const message = this._axiosMsg(e)\n return new HTTPError(e.response?.status, message)\n }\n\n public static fromApi(e: KnownApiError): HTTPError {\n const { message, code } = e\n return new HTTPError(code, message)\n }\n\n private static _axiosMsg(e: AxiosError<{ message?: string }>): string {\n let message = e.message\n if (e.response?.statusText) {\n message += `\\n ${e.response?.statusText}`\n }\n if (e.response?.status && e.request?.method && e.request?.path) {\n message += `\\n (${e.response?.status}) ${e.request.method} ${e.request.path}`\n }\n if (e.response?.data?.message) {\n message += `\\n ${e.response?.data?.message}`\n }\n return message\n }\n}\n\nexport class NoBundleFoundError extends BotpressCLIError {\n constructor() {\n const message = 'No bundle found. Please run `bp bundle` first.'\n super(message)\n }\n}\n\nexport class NoBotsFoundError extends BotpressCLIError {\n constructor() {\n const message = `No Bot found in your Workspace. Please create one first at ${consts.defaultBotpressAppUrl}.`\n super(message)\n }\n}\n\nexport class NoWorkspacesFoundError extends BotpressCLIError {\n constructor() {\n const message = 'No Workspace found. Please create one first.'\n super(message)\n }\n}\n\nexport class NotLoggedInError extends BotpressCLIError {\n constructor() {\n const message = 'Not logged in. Please run `bp login` first.'\n super(message)\n }\n}\n\nexport class ParamRequiredError extends BotpressCLIError {\n constructor(param: string) {\n const message = `${param} is required.`\n super(message)\n }\n}\n\nexport class InvalidIntegrationReferenceError extends BotpressCLIError {\n constructor(ref: string) {\n const message = `Invalid integration reference \"${ref}\".`\n super(message)\n }\n}\n\nexport class InvalidInterfaceReferenceError extends BotpressCLIError {\n constructor(ref: string) {\n const message = `Invalid interface reference \"${ref}\".`\n super(message)\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAmD;AACnD,mBAAkC;AAClC,oBAAuB;AACvB,aAAwB;AAGxB,MAAM,kBAAkB,CAAC,UAAmC,0BAAW,CAAC,KAAK,EAAE,aAAa;AAErF,MAAM,yBAAyB,qBAAO;AAAA,EAC3C,OAAc,KAAK,QAAiB,SAAmC;AACrE,UAAM,MAAM,iBAAiB,IAAI,MAAM;AACvC,WAAO,IAAI,iBAAiB,KAAK,WAAW,EAAE;AAAA,EAChD;AAAA,EAEA,OAAc,IAAI,QAAmC;AACnD,QAAI,kBAAkB,kBAAkB;AACtC,aAAO;AAAA,IACT;AACA,QAAI,kBAAkB,4BAAc;AAClC,YAAM,OAAO,IAAI,UAAU,KAAK,gCAAgC;AAChE,WAAK,QAAQ,OAAO;AACpB,aAAO;AAAA,IACT;AACA,QAAI,gBAAgB,MAAM,GAAG;AAC3B,aAAO,UAAU,QAAQ,MAAM;AAAA,IACjC;AACA,QAAI,aAAAA,QAAM,aAAa,MAAM,GAAG;AAC9B,aAAO,UAAU,UAAU,MAA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|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botpress/cli",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.36",
|
|
4
4
|
"description": "Botpress CLI",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "pnpm run bundle && pnpm run template:gen",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"main": "dist/index.js",
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@botpress/client": "0.23.1",
|
|
24
|
-
"@botpress/sdk": "0.8.
|
|
24
|
+
"@botpress/sdk": "0.8.31",
|
|
25
25
|
"@bpinternal/const": "^0.0.20",
|
|
26
26
|
"@bpinternal/tunnel": "^0.1.1",
|
|
27
27
|
"@bpinternal/yargs-extra": "^0.0.3",
|
|
@@ -12,15 +12,18 @@ import type * as actions from "./actions/index"
|
|
|
12
12
|
import type * as channels from "./channels/index"
|
|
13
13
|
import type * as events from "./events/index"
|
|
14
14
|
import type * as states from "./states/index"
|
|
15
|
+
import type * as entities from "./entities/index"
|
|
15
16
|
export * as configuration from "./configuration/index"
|
|
16
17
|
export * as actions from "./actions/index"
|
|
17
18
|
export * as channels from "./channels/index"
|
|
18
19
|
export * as events from "./events/index"
|
|
19
20
|
export * as states from "./states/index"
|
|
21
|
+
export * as entities from "./entities/index"
|
|
20
22
|
|
|
21
23
|
// type utils
|
|
22
24
|
type Cast<X, Y> = X extends Y ? X : Y
|
|
23
25
|
type ValueOf<T> = T[keyof T]
|
|
26
|
+
type AsyncFunction = (...args: any[]) => Promise<any>
|
|
24
27
|
type SimplifyObject<T extends object> = T extends infer O ? { [K in keyof O]: Simplify<O[K]> } : never
|
|
25
28
|
type Simplify<T> = T extends (...args: infer A) => infer R
|
|
26
29
|
? (...args: Simplify<A>) => Simplify<R>
|
|
@@ -41,6 +44,7 @@ type TIntegration = {
|
|
|
41
44
|
events: events.Events
|
|
42
45
|
states: states.States
|
|
43
46
|
user: { "tags": {}, "creation": { "enabled": false, "requiredTags": [] } }
|
|
47
|
+
entities: entities.Entities
|
|
44
48
|
}
|
|
45
49
|
|
|
46
50
|
export type IntegrationProps = sdk.IntegrationProps<TIntegration>
|
|
@@ -77,7 +81,9 @@ export type AckFunctions = {
|
|
|
77
81
|
}
|
|
78
82
|
export type AnyAckFunction = ValueOf<ValueOf<AckFunctions>>
|
|
79
83
|
|
|
80
|
-
export type ClientOperation = Simplify<
|
|
84
|
+
export type ClientOperation = Simplify<ValueOf<{
|
|
85
|
+
[K in keyof Client as Client[K] extends AsyncFunction ? K : never]: K
|
|
86
|
+
}>>
|
|
81
87
|
export type ClientRequests = Simplify<{
|
|
82
88
|
[K in ClientOperation]: Parameters<Client[K]>[0]
|
|
83
89
|
}>
|
|
@@ -12,15 +12,18 @@ import type * as actions from "./actions/index"
|
|
|
12
12
|
import type * as channels from "./channels/index"
|
|
13
13
|
import type * as events from "./events/index"
|
|
14
14
|
import type * as states from "./states/index"
|
|
15
|
+
import type * as entities from "./entities/index"
|
|
15
16
|
export * as configuration from "./configuration/index"
|
|
16
17
|
export * as actions from "./actions/index"
|
|
17
18
|
export * as channels from "./channels/index"
|
|
18
19
|
export * as events from "./events/index"
|
|
19
20
|
export * as states from "./states/index"
|
|
21
|
+
export * as entities from "./entities/index"
|
|
20
22
|
|
|
21
23
|
// type utils
|
|
22
24
|
type Cast<X, Y> = X extends Y ? X : Y
|
|
23
25
|
type ValueOf<T> = T[keyof T]
|
|
26
|
+
type AsyncFunction = (...args: any[]) => Promise<any>
|
|
24
27
|
type SimplifyObject<T extends object> = T extends infer O ? { [K in keyof O]: Simplify<O[K]> } : never
|
|
25
28
|
type Simplify<T> = T extends (...args: infer A) => infer R
|
|
26
29
|
? (...args: Simplify<A>) => Simplify<R>
|
|
@@ -41,6 +44,7 @@ type TIntegration = {
|
|
|
41
44
|
events: events.Events
|
|
42
45
|
states: states.States
|
|
43
46
|
user: { "tags": {}, "creation": { "enabled": false, "requiredTags": [] } }
|
|
47
|
+
entities: entities.Entities
|
|
44
48
|
}
|
|
45
49
|
|
|
46
50
|
export type IntegrationProps = sdk.IntegrationProps<TIntegration>
|
|
@@ -77,7 +81,9 @@ export type AckFunctions = {
|
|
|
77
81
|
}
|
|
78
82
|
export type AnyAckFunction = ValueOf<ValueOf<AckFunctions>>
|
|
79
83
|
|
|
80
|
-
export type ClientOperation = Simplify<
|
|
84
|
+
export type ClientOperation = Simplify<ValueOf<{
|
|
85
|
+
[K in keyof Client as Client[K] extends AsyncFunction ? K : never]: K
|
|
86
|
+
}>>
|
|
81
87
|
export type ClientRequests = Simplify<{
|
|
82
88
|
[K in ClientOperation]: Parameters<Client[K]>[0]
|
|
83
89
|
}>
|
|
@@ -12,15 +12,18 @@ import type * as actions from "./actions/index"
|
|
|
12
12
|
import type * as channels from "./channels/index"
|
|
13
13
|
import type * as events from "./events/index"
|
|
14
14
|
import type * as states from "./states/index"
|
|
15
|
+
import type * as entities from "./entities/index"
|
|
15
16
|
export * as configuration from "./configuration/index"
|
|
16
17
|
export * as actions from "./actions/index"
|
|
17
18
|
export * as channels from "./channels/index"
|
|
18
19
|
export * as events from "./events/index"
|
|
19
20
|
export * as states from "./states/index"
|
|
21
|
+
export * as entities from "./entities/index"
|
|
20
22
|
|
|
21
23
|
// type utils
|
|
22
24
|
type Cast<X, Y> = X extends Y ? X : Y
|
|
23
25
|
type ValueOf<T> = T[keyof T]
|
|
26
|
+
type AsyncFunction = (...args: any[]) => Promise<any>
|
|
24
27
|
type SimplifyObject<T extends object> = T extends infer O ? { [K in keyof O]: Simplify<O[K]> } : never
|
|
25
28
|
type Simplify<T> = T extends (...args: infer A) => infer R
|
|
26
29
|
? (...args: Simplify<A>) => Simplify<R>
|
|
@@ -41,6 +44,7 @@ type TIntegration = {
|
|
|
41
44
|
events: events.Events
|
|
42
45
|
states: states.States
|
|
43
46
|
user: { "tags": { "id": { "title": "User ID", "description": "The ID of the user" } }, "creation": { "enabled": false, "requiredTags": [] } }
|
|
47
|
+
entities: entities.Entities
|
|
44
48
|
}
|
|
45
49
|
|
|
46
50
|
export type IntegrationProps = sdk.IntegrationProps<TIntegration>
|
|
@@ -77,7 +81,9 @@ export type AckFunctions = {
|
|
|
77
81
|
}
|
|
78
82
|
export type AnyAckFunction = ValueOf<ValueOf<AckFunctions>>
|
|
79
83
|
|
|
80
|
-
export type ClientOperation = Simplify<
|
|
84
|
+
export type ClientOperation = Simplify<ValueOf<{
|
|
85
|
+
[K in keyof Client as Client[K] extends AsyncFunction ? K : never]: K
|
|
86
|
+
}>>
|
|
81
87
|
export type ClientRequests = Simplify<{
|
|
82
88
|
[K in ClientOperation]: Parameters<Client[K]>[0]
|
|
83
89
|
}>
|