@botpress/cli 6.3.5 → 6.5.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 +12 -12
- package/dist/api/retry.js +31 -1
- package/dist/api/retry.js.map +2 -2
- package/dist/chat/index.d.ts +1 -0
- package/dist/chat/index.js +4 -1
- package/dist/chat/index.js.map +2 -2
- package/dist/command-definitions.d.ts +5 -0
- package/dist/command-implementations/bot-commands.js.map +1 -1
- package/dist/command-implementations/chat-command.js +1 -1
- package/dist/command-implementations/chat-command.js.map +2 -2
- package/dist/command-implementations/index.d.ts +5 -0
- package/dist/command-implementations/init-command.js.map +1 -1
- package/dist/command-implementations/integration-commands.js.map +1 -1
- package/dist/config.d.ts +5 -0
- package/dist/config.js +44 -8
- package/dist/config.js.map +2 -2
- package/dist/index.d.ts +5 -0
- package/package.json +3 -3
- package/templates/empty-bot/package.json +2 -2
- package/templates/empty-bot/tsconfig.json +1 -1
- package/templates/empty-integration/package.json +2 -2
- package/templates/empty-integration/tsconfig.json +1 -1
- package/templates/empty-plugin/package.json +1 -1
- package/templates/empty-plugin/tsconfig.json +1 -1
- package/templates/hello-world/package.json +2 -2
- package/templates/hello-world/tsconfig.json +1 -1
- package/templates/webhook-message/package.json +2 -2
- package/templates/webhook-message/tsconfig.json +1 -1
- package/tsconfig.build.json +0 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
1
|
|
|
2
|
-
> @botpress/cli@6.
|
|
2
|
+
> @botpress/cli@6.5.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@6.
|
|
6
|
+
> @botpress/cli@6.5.0 build:types /home/runner/work/botpress/botpress/packages/cli
|
|
7
7
|
> tsc -p ./tsconfig.build.json
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
> @botpress/cli@6.
|
|
10
|
+
> @botpress/cli@6.5.0 bundle /home/runner/work/botpress/botpress/packages/cli
|
|
11
11
|
> ts-node -T build.ts
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
> @botpress/cli@6.
|
|
14
|
+
> @botpress/cli@6.5.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 v6.
|
|
18
|
-
🤖 Botpress CLI v6.3.5
|
|
19
|
-
🤖 Botpress CLI v6.3.5
|
|
17
|
+
🤖 Botpress CLI v6.5.0
|
|
20
18
|
● Checking if cli is up to date
|
|
19
|
+
🤖 Botpress CLI v6.5.0
|
|
20
|
+
🤖 Botpress CLI v6.5.0
|
|
21
21
|
● Checking if cli is up to date
|
|
22
22
|
● Checking if cli is up to date
|
|
23
|
-
🤖 Botpress CLI v6.
|
|
23
|
+
🤖 Botpress CLI v6.5.0
|
|
24
24
|
● Checking if cli is up to date
|
|
25
25
|
● Checking if sdk is up to date
|
|
26
26
|
● Checking if sdk is up to date
|
|
27
27
|
● Checking if sdk is up to date
|
|
28
28
|
● Checking if sdk is up to date
|
|
29
29
|
○ Generating typings for bot...
|
|
30
|
+
○ Generating typings for plugin empty-plugin...
|
|
31
|
+
○ Generating typings for integration hello-world...
|
|
32
|
+
○ Generating typings for integration empty-integration...
|
|
30
33
|
✓ Typings available at .botpress
|
|
31
34
|
|
|
32
|
-
○ Generating typings for plugin empty-plugin...
|
|
33
35
|
✓ Typings available at .botpress
|
|
34
36
|
|
|
35
|
-
○ Generating typings for integration hello-world...
|
|
36
|
-
○ Generating typings for integration empty-integration...
|
|
37
37
|
✓ Typings available at .botpress
|
|
38
38
|
|
|
39
39
|
✓ Typings available at .botpress
|
|
40
40
|
|
|
41
|
-
🤖 Botpress CLI v6.
|
|
41
|
+
🤖 Botpress CLI v6.5.0
|
|
42
42
|
● Checking if cli is up to date
|
|
43
43
|
● Checking if sdk is up to date
|
|
44
44
|
○ Generating typings for integration webhook-message...
|
package/dist/api/retry.js
CHANGED
|
@@ -33,10 +33,40 @@ __export(retry_exports, {
|
|
|
33
33
|
module.exports = __toCommonJS(retry_exports);
|
|
34
34
|
var client = __toESM(require("@botpress/client"));
|
|
35
35
|
const HTTP_STATUS_TO_RETRY_ON = [429, 500, 502, 503, 504];
|
|
36
|
+
function getRetryAfterMs(error) {
|
|
37
|
+
const headers = error?.response?.headers;
|
|
38
|
+
if (!headers) return void 0;
|
|
39
|
+
const headerNames = ["retry-after", "ratelimit-reset", "x-ratelimit-reset"];
|
|
40
|
+
for (const name of headerNames) {
|
|
41
|
+
const raw = headers[name];
|
|
42
|
+
if (!raw) continue;
|
|
43
|
+
const value = String(raw);
|
|
44
|
+
if (value.includes(" ")) {
|
|
45
|
+
const futureDate = new Date(value);
|
|
46
|
+
if (!isNaN(futureDate.getTime())) {
|
|
47
|
+
return Math.max(0, futureDate.getTime() - Date.now());
|
|
48
|
+
}
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
const seconds = parseInt(value, 10);
|
|
52
|
+
if (!isNaN(seconds) && seconds >= 0) {
|
|
53
|
+
return seconds * 1e3;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return void 0;
|
|
57
|
+
}
|
|
36
58
|
const config = {
|
|
37
59
|
retries: 3,
|
|
38
60
|
retryCondition: (err) => client.axiosRetry.isNetworkOrIdempotentRequestError(err) || HTTP_STATUS_TO_RETRY_ON.includes(err.response?.status ?? 0),
|
|
39
|
-
retryDelay: (retryCount) =>
|
|
61
|
+
retryDelay: (retryCount, error) => {
|
|
62
|
+
if (error?.response?.status === 429) {
|
|
63
|
+
const retryAfterMs = getRetryAfterMs(error);
|
|
64
|
+
if (retryAfterMs !== void 0) {
|
|
65
|
+
return retryAfterMs;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return Math.max(retryCount, 1) * 1e3;
|
|
69
|
+
}
|
|
40
70
|
};
|
|
41
71
|
// Annotate the CommonJS export names for ESM import in node:
|
|
42
72
|
0 && (module.exports = {
|
package/dist/api/retry.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/api/retry.ts"],
|
|
4
|
-
"sourcesContent": ["import * as client from '@botpress/client'\n\n// TODO: we probably shouldnt retry on 500 errors, but this is a temporary fix for the botpress repo CI\nconst HTTP_STATUS_TO_RETRY_ON = [429, 500, 502, 503, 504]\nexport const config: client.RetryConfig = {\n retries: 3,\n retryCondition: (err) =>\n client.axiosRetry.isNetworkOrIdempotentRequestError(err) ||\n HTTP_STATUS_TO_RETRY_ON.includes(err.response?.status ?? 0),\n retryDelay: (retryCount) => retryCount * 1000,\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAAwB;AAGxB,MAAM,0BAA0B,CAAC,KAAK,KAAK,KAAK,KAAK,GAAG;
|
|
4
|
+
"sourcesContent": ["import * as client from '@botpress/client'\n\n// TODO: we probably shouldnt retry on 500 errors, but this is a temporary fix for the botpress repo CI\nconst HTTP_STATUS_TO_RETRY_ON = [429, 500, 502, 503, 504]\n\nfunction getRetryAfterMs(error: Parameters<NonNullable<client.RetryConfig['retryDelay']>>[1]): number | undefined {\n const headers = error?.response?.headers\n if (!headers) return undefined\n\n const headerNames = ['retry-after', 'ratelimit-reset', 'x-ratelimit-reset']\n for (const name of headerNames) {\n const raw = headers[name]\n if (!raw) continue\n const value = String(raw)\n\n // HTTP-date format (e.g. \"Mon, 28 Apr 2026 12:00:00 GMT\")\n if (value.includes(' ')) {\n const futureDate = new Date(value)\n if (!isNaN(futureDate.getTime())) {\n return Math.max(0, futureDate.getTime() - Date.now())\n }\n continue\n }\n\n // Seconds format (e.g. \"120\")\n const seconds = parseInt(value, 10)\n if (!isNaN(seconds) && seconds >= 0) {\n return seconds * 1000\n }\n }\n return undefined\n}\n\nexport const config: client.RetryConfig = {\n retries: 3,\n retryCondition: (err) =>\n client.axiosRetry.isNetworkOrIdempotentRequestError(err) ||\n HTTP_STATUS_TO_RETRY_ON.includes(err.response?.status ?? 0),\n retryDelay: (retryCount, error) => {\n if (error?.response?.status === 429) {\n const retryAfterMs = getRetryAfterMs(error)\n if (retryAfterMs !== undefined) {\n return retryAfterMs\n }\n }\n return Math.max(retryCount, 1) * 1000\n },\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAAwB;AAGxB,MAAM,0BAA0B,CAAC,KAAK,KAAK,KAAK,KAAK,GAAG;AAExD,SAAS,gBAAgB,OAAyF;AAChH,QAAM,UAAU,OAAO,UAAU;AACjC,MAAI,CAAC,QAAS,QAAO;AAErB,QAAM,cAAc,CAAC,eAAe,mBAAmB,mBAAmB;AAC1E,aAAW,QAAQ,aAAa;AAC9B,UAAM,MAAM,QAAQ,IAAI;AACxB,QAAI,CAAC,IAAK;AACV,UAAM,QAAQ,OAAO,GAAG;AAGxB,QAAI,MAAM,SAAS,GAAG,GAAG;AACvB,YAAM,aAAa,IAAI,KAAK,KAAK;AACjC,UAAI,CAAC,MAAM,WAAW,QAAQ,CAAC,GAAG;AAChC,eAAO,KAAK,IAAI,GAAG,WAAW,QAAQ,IAAI,KAAK,IAAI,CAAC;AAAA,MACtD;AACA;AAAA,IACF;AAGA,UAAM,UAAU,SAAS,OAAO,EAAE;AAClC,QAAI,CAAC,MAAM,OAAO,KAAK,WAAW,GAAG;AACnC,aAAO,UAAU;AAAA,IACnB;AAAA,EACF;AACA,SAAO;AACT;AAEO,MAAM,SAA6B;AAAA,EACxC,SAAS;AAAA,EACT,gBAAgB,CAAC,QACf,OAAO,WAAW,kCAAkC,GAAG,KACvD,wBAAwB,SAAS,IAAI,UAAU,UAAU,CAAC;AAAA,EAC5D,YAAY,CAAC,YAAY,UAAU;AACjC,QAAI,OAAO,UAAU,WAAW,KAAK;AACnC,YAAM,eAAe,gBAAgB,KAAK;AAC1C,UAAI,iBAAiB,QAAW;AAC9B,eAAO;AAAA,MACT;AAAA,IACF;AACA,WAAO,KAAK,IAAI,YAAY,CAAC,IAAI;AAAA,EACnC;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/chat/index.d.ts
CHANGED
package/dist/chat/index.js
CHANGED
|
@@ -69,7 +69,10 @@ class Chat {
|
|
|
69
69
|
async _run() {
|
|
70
70
|
this._switchAlternateScreenBuffer();
|
|
71
71
|
this._events.on("state", this._renderMessages);
|
|
72
|
-
const connection = await this._props.client.listenConversation({
|
|
72
|
+
const connection = await this._props.client.listenConversation({
|
|
73
|
+
id: this._props.conversationId,
|
|
74
|
+
protocol: this._props.protocol
|
|
75
|
+
});
|
|
73
76
|
const keyboard = readline.createInterface({
|
|
74
77
|
input: process.stdin,
|
|
75
78
|
output: process.stdout
|
package/dist/chat/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/chat/index.ts"],
|
|
4
|
-
"sourcesContent": ["import * as chat from '@botpress/chat'\nimport chalk from 'chalk'\nimport * as readline from 'readline'\nimport * as uuid from 'uuid'\nimport * as utils from '../utils'\n\ntype MessageSource = 'myself' | 'bot' | 'other'\ntype ChatMessage = chat.Message & { source: MessageSource }\ntype ChatState =\n | {\n status: 'stopped'\n }\n | {\n status: 'running'\n messages: ChatMessage[]\n connection: chat.SignalListener\n keyboard: readline.Interface\n }\n\nconst USER_ICONS: Record<MessageSource, string> = {\n myself: '\uD83D\uDC64',\n bot: '\uD83E\uDD16',\n other: '\uD83D\uDC65',\n}\n\nconst MESSAGE_ICONS: Record<chat.Message['payload']['type'], string> = {\n audio: '\uD83C\uDFB5',\n card: '\uD83C\uDCCF',\n carousel: '\uD83C\uDFA0',\n choice: '\uD83D\uDD3D',\n dropdown: '\uD83D\uDD3D',\n file: '\uD83D\uDCC1',\n image: '\uD83C\uDF05',\n location: '\uD83D\uDCCD',\n text: '',\n video: '\uD83C\uDFA5',\n markdown: '',\n bloc: '\uD83E\uDDF1',\n}\n\nconst EXIT_KEYWORDS = ['exit', '.exit']\n\nexport type ChatProps = {\n client: chat.AuthenticatedClient\n conversationId: string\n}\n\nexport class Chat {\n private _events = new utils.emitter.EventEmitter<{ state: ChatState }>()\n private _state: ChatState = { status: 'stopped' }\n\n public static launch(props: ChatProps): Chat {\n const instance = new Chat(props)\n void instance._run()\n return instance\n }\n\n private constructor(private _props: ChatProps) {}\n\n private async _run() {\n this._switchAlternateScreenBuffer()\n this._events.on('state', this._renderMessages)\n\n const connection = await this._props.client.listenConversation({
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAClB,eAA0B;AAC1B,WAAsB;AACtB,YAAuB;AAevB,MAAM,aAA4C;AAAA,EAChD,QAAQ;AAAA,EACR,KAAK;AAAA,EACL,OAAO;AACT;AAEA,MAAM,gBAAiE;AAAA,EACrE,OAAO;AAAA,EACP,MAAM;AAAA,EACN,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,MAAM;AAAA,EACN,OAAO;AAAA,EACP,UAAU;AAAA,EACV,MAAM;AAAA,EACN,OAAO;AAAA,EACP,UAAU;AAAA,EACV,MAAM;AACR;AAEA,MAAM,gBAAgB,CAAC,QAAQ,OAAO;
|
|
4
|
+
"sourcesContent": ["import * as chat from '@botpress/chat'\nimport chalk from 'chalk'\nimport * as readline from 'readline'\nimport * as uuid from 'uuid'\nimport * as utils from '../utils'\n\ntype MessageSource = 'myself' | 'bot' | 'other'\ntype ChatMessage = chat.Message & { source: MessageSource }\ntype ChatState =\n | {\n status: 'stopped'\n }\n | {\n status: 'running'\n messages: ChatMessage[]\n connection: chat.SignalListener\n keyboard: readline.Interface\n }\n\nconst USER_ICONS: Record<MessageSource, string> = {\n myself: '\uD83D\uDC64',\n bot: '\uD83E\uDD16',\n other: '\uD83D\uDC65',\n}\n\nconst MESSAGE_ICONS: Record<chat.Message['payload']['type'], string> = {\n audio: '\uD83C\uDFB5',\n card: '\uD83C\uDCCF',\n carousel: '\uD83C\uDFA0',\n choice: '\uD83D\uDD3D',\n dropdown: '\uD83D\uDD3D',\n file: '\uD83D\uDCC1',\n image: '\uD83C\uDF05',\n location: '\uD83D\uDCCD',\n text: '',\n video: '\uD83C\uDFA5',\n markdown: '',\n bloc: '\uD83E\uDDF1',\n}\n\nconst EXIT_KEYWORDS = ['exit', '.exit']\n\nexport type ChatProps = {\n client: chat.AuthenticatedClient\n conversationId: string\n protocol: chat.ServerEventsProtocol\n}\n\nexport class Chat {\n private _events = new utils.emitter.EventEmitter<{ state: ChatState }>()\n private _state: ChatState = { status: 'stopped' }\n\n public static launch(props: ChatProps): Chat {\n const instance = new Chat(props)\n void instance._run()\n return instance\n }\n\n private constructor(private _props: ChatProps) {}\n\n private async _run() {\n this._switchAlternateScreenBuffer()\n this._events.on('state', this._renderMessages)\n\n const connection = await this._props.client.listenConversation({\n id: this._props.conversationId,\n protocol: this._props.protocol,\n })\n const keyboard = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n })\n\n connection.on('message_created', (m) => void this._onMessageReceived(m))\n keyboard.on('line', (l) => void this._onKeyboardInput(l))\n process.stdin.on('keypress', (_, key) => {\n if (key.name === 'escape') {\n void this._onExit()\n }\n })\n\n this._setState({ status: 'running', messages: [], connection, keyboard })\n }\n\n private _setState = (newState: ChatState) => {\n this._state = newState\n this._events.emit('state', this._state)\n }\n\n private _onMessageReceived = async (message: chat.Signals['message_created']) => {\n if (this._state.status === 'stopped') {\n return\n }\n if (message.userId === this._props.client.user.id) {\n return\n }\n const source: MessageSource = message.isBot ? 'bot' : 'other'\n this._setState({ ...this._state, messages: [...this._state.messages, { ...message, source }] })\n }\n\n private _onKeyboardInput = async (line: string) => {\n if (this._state.status === 'stopped') {\n return\n }\n\n if (EXIT_KEYWORDS.includes(line)) {\n await this._onExit()\n return\n }\n\n if (!line) {\n this._setState({ ...this._state })\n return\n }\n\n const message = this._textToMessage(line)\n this._setState({ ...this._state, messages: [...this._state.messages, message] })\n await this._props.client.createMessage(message)\n }\n\n private _onExit = async () => {\n if (this._state.status === 'stopped') {\n return\n }\n const { connection, keyboard } = this._state\n await connection.disconnect()\n connection.cleanup()\n keyboard.close()\n this._setState({ status: 'stopped' })\n this._clearStdOut()\n this._restoreOriginalScreenBuffer()\n }\n\n public wait(): Promise<void> {\n return new Promise<void>((resolve) => {\n const cb = (state: ChatState) => {\n if (state.status === 'stopped') {\n this._events.off('state', cb)\n resolve()\n }\n }\n this._events.on('state', cb)\n })\n }\n\n private _renderMessages = () => {\n if (this._state.status === 'stopped') {\n return\n }\n\n this._clearStdOut()\n this._printHeader()\n\n for (const message of this._state.messages) {\n const prefix = USER_ICONS[message.source]\n const text = this._messageToText(message)\n const coloredText = message.source === 'bot' ? text : chalk.gray(text)\n process.stdout.write(`${prefix} ${coloredText}\\n`)\n }\n\n this._state.keyboard.setPrompt('>> ')\n this._state.keyboard.prompt(true) // Redisplay the prompt and maintain current input\n }\n\n private _printHeader = () => {\n process.stdout.write(chalk.bold('Botpress Chat\\n'))\n process.stdout.write(chalk.gray('Type \"exit\" or press ESC key to quit\\n'))\n }\n\n private _switchAlternateScreenBuffer = () => {\n process.stdout.write('\\x1B[?1049h')\n }\n\n private _restoreOriginalScreenBuffer = () => {\n process.stdout.write('\\x1B[?1049l')\n }\n\n private _clearStdOut = () => {\n process.stdout.write('\\x1B[2J\\x1B[0;0H')\n }\n\n private _messageToText = (message: Pick<chat.Message, 'payload'>): string => {\n const prefix = MESSAGE_ICONS[message.payload.type]\n switch (message.payload.type) {\n case 'audio':\n return prefix + message.payload.audioUrl\n case 'card':\n return prefix + JSON.stringify(message.payload)\n case 'carousel':\n return prefix + JSON.stringify(message.payload)\n case 'choice':\n return (\n prefix +\n [message.payload.text, ...message.payload.options.map((o) => ` - ${o.label} (${o.value})`)].join('\\n')\n )\n case 'dropdown':\n return (\n prefix +\n [message.payload.text, ...message.payload.options.map((o) => ` - ${o.label} (${o.value})`)].join('\\n')\n )\n case 'file':\n return prefix + message.payload.fileUrl\n case 'image':\n return prefix + message.payload.imageUrl\n case 'location':\n return prefix + `${message.payload.latitude},${message.payload.longitude} (${message.payload.address})`\n case 'text':\n return prefix + message.payload.text\n case 'video':\n return prefix + message.payload.videoUrl\n case 'markdown':\n return prefix + message.payload.markdown\n case 'bloc':\n return [\n prefix,\n ...message.payload.items.map((item) => this._messageToText({ payload: item })).map((l) => `\\t${l}`),\n ].join('\\n')\n default:\n type _assertion = utils.types.AssertNever<typeof message.payload>\n return '<unknown>'\n }\n }\n\n private _textToMessage = (text: string): ChatMessage => {\n return {\n id: uuid.v4(),\n userId: this._props.client.user.id,\n source: 'myself',\n conversationId: this._props.conversationId,\n createdAt: new Date().toISOString(),\n payload: { type: 'text', text },\n }\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAClB,eAA0B;AAC1B,WAAsB;AACtB,YAAuB;AAevB,MAAM,aAA4C;AAAA,EAChD,QAAQ;AAAA,EACR,KAAK;AAAA,EACL,OAAO;AACT;AAEA,MAAM,gBAAiE;AAAA,EACrE,OAAO;AAAA,EACP,MAAM;AAAA,EACN,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,MAAM;AAAA,EACN,OAAO;AAAA,EACP,UAAU;AAAA,EACV,MAAM;AAAA,EACN,OAAO;AAAA,EACP,UAAU;AAAA,EACV,MAAM;AACR;AAEA,MAAM,gBAAgB,CAAC,QAAQ,OAAO;AAQ/B,MAAM,KAAK;AAAA,EAUR,YAAoB,QAAmB;AAAnB;AAAA,EAAoB;AAAA,EATxC,UAAU,IAAI,MAAM,Q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GAAG,CAAC,EAAE,KAAK,IAAI;AAAA,MAE1G,KAAK;AACH,eAAO,SAAS,QAAQ,QAAQ;AAAA,MAClC,KAAK;AACH,eAAO,SAAS,QAAQ,QAAQ;AAAA,MAClC,KAAK;AACH,eAAO,SAAS,GAAG,QAAQ,QAAQ,QAAQ,IAAI,QAAQ,QAAQ,SAAS,KAAK,QAAQ,QAAQ,OAAO;AAAA,MACtG,KAAK;AACH,eAAO,SAAS,QAAQ,QAAQ;AAAA,MAClC,KAAK;AACH,eAAO,SAAS,QAAQ,QAAQ;AAAA,MAClC,KAAK;AACH,eAAO,SAAS,QAAQ,QAAQ;AAAA,MAClC,KAAK;AACH,eAAO;AAAA,UACL;AAAA,UACA,GAAG,QAAQ,QAAQ,MAAM,IAAI,CAAC,SAAS,KAAK,eAAe,EAAE,SAAS,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,IAAK,CAAC,EAAE;AAAA,QACpG,EAAE,KAAK,IAAI;AAAA,MACb;AAEE,eAAO;AAAA,IACX;AAAA,EACF;AAAA,EAEQ,iBAAiB,CAAC,SAA8B;AACtD,WAAO;AAAA,MACL,IAAI,KAAK,GAAG;AAAA,MACZ,QAAQ,KAAK,OAAO,OAAO,KAAK;AAAA,MAChC,QAAQ;AAAA,MACR,gBAAgB,KAAK,OAAO;AAAA,MAC5B,YAAW,oBAAI,KAAK,GAAE,YAAY;AAAA,MAClC,SAAS,EAAE,MAAM,QAAQ,KAAK;AAAA,IAChC;AAAA,EACF;AACF;",
|
|
6
6
|
"names": ["chalk"]
|
|
7
7
|
}
|
|
@@ -1405,6 +1405,11 @@ declare const _default: {
|
|
|
1405
1405
|
idx: number;
|
|
1406
1406
|
description: string;
|
|
1407
1407
|
};
|
|
1408
|
+
protocol: {
|
|
1409
|
+
choices: ("websocket" | "sse")[];
|
|
1410
|
+
default: "sse";
|
|
1411
|
+
description: string;
|
|
1412
|
+
};
|
|
1408
1413
|
apiUrl: {
|
|
1409
1414
|
type: "string";
|
|
1410
1415
|
description: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/command-implementations/bot-commands.ts"],
|
|
4
|
-
"sourcesContent": ["import chalk from 'chalk'\nimport { ApiClient } from '
|
|
4
|
+
"sourcesContent": ["import chalk from 'chalk'\nimport { ApiClient } from '../api/client'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport { GlobalCommand } from './global-command'\n\nexport type GetBotCommandDefinition = typeof commandDefinitions.bots.subcommands.get\nexport class GetBotCommand extends GlobalCommand<GetBotCommandDefinition> {\n public async run(): Promise<void> {\n const { client } = await this.ensureLoginAndCreateClient(this.argv)\n\n try {\n const { bot } = await client.getBot({ id: this.argv.botRef })\n this.logger.success(`Bot ${chalk.bold(this.argv.botRef)}:`)\n this.logger.json(bot)\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, `Could not get bot ${this.argv.botRef}`)\n }\n }\n}\n\nexport type ListBotsCommandDefinition = typeof commandDefinitions.bots.subcommands.list\nexport class ListBotsCommand extends GlobalCommand<ListBotsCommandDefinition> {\n public async run(): Promise<void> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n\n try {\n const { dev } = this.argv\n const bots = await api.listAllPages(\n (x) => api.client.listBots({ ...x, dev }),\n (r) => r.bots\n )\n this.logger.success('Bots:')\n this.logger.json(bots)\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not list bots')\n }\n }\n}\n\nexport type DeleteBotCommandDefinition = typeof commandDefinitions.bots.subcommands.delete\nexport class DeleteBotCommand extends GlobalCommand<DeleteBotCommandDefinition> {\n public async run(): Promise<void> {\n const { client } = await this.ensureLoginAndCreateClient(this.argv)\n\n try {\n await client.deleteBot({ id: this.argv.botRef })\n this.logger.success(`Bot ${chalk.bold(this.argv.botRef)} deleted`)\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, `Could not delete bot ${this.argv.botRef}`)\n }\n }\n}\n\nexport type CreateBotCommandDefinition = typeof commandDefinitions.bots.subcommands.create\nexport class CreateBotCommand extends GlobalCommand<CreateBotCommandDefinition> {\n public async run(): Promise<void> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n\n try {\n if (this.argv.ifNotExists) {\n await this._getOrCreate(api, this.argv.name)\n return\n }\n await this._create(api, this.argv.name)\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not create bot')\n }\n }\n\n private _getOrCreate = async (api: ApiClient, name: string | undefined) => {\n if (!name) {\n throw new errors.BotpressCLIError('option --if-not-exists requires that a name be provided')\n }\n const existingBot = await api.findBotByName(name)\n if (existingBot) {\n this.logger.success(`Bot ${chalk.bold(name)} already exists`)\n this.logger.json(existingBot)\n return\n }\n return this._create(api, name)\n }\n\n private _create = async (api: ApiClient, name: string | undefined) => {\n const { bot } = await api.client.createBot({ name })\n this.logger.success(`Bot ${chalk.bold(bot.id)}:`)\n this.logger.json(bot)\n }\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAGlB,aAAwB;AACxB,4BAA8B;AAGvB,MAAM,sBAAsB,oCAAuC;AAAA,EACxE,MAAa,MAAqB;AAChC,UAAM,EAAE,OAAO,IAAI,MAAM,KAAK,2BAA2B,KAAK,IAAI;AAElE,QAAI;AACF,YAAM,EAAE,IAAI,IAAI,MAAM,OAAO,OAAO,EAAE,IAAI,KAAK,KAAK,OAAO,CAAC;AAC5D,WAAK,OAAO,QAAQ,OAAO,aAAAA,QAAM,KAAK,KAAK,KAAK,MAAM,CAAC,GAAG;AAC1D,WAAK,OAAO,KAAK,GAAG;AAAA,IACtB,SAAS,QAAQ;AACf,YAAM,OAAO,iBAAiB,KAAK,QAAQ,qBAAqB,KAAK,KAAK,MAAM,EAAE;AAAA,IACpF;AAAA,EACF;AACF;AAGO,MAAM,wBAAw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AACzE,QAAI,CAAC,MAAM;AACT,YAAM,IAAI,OAAO,iBAAiB,yDAAyD;AAAA,IAC7F;AACA,UAAM,cAAc,MAAM,IAAI,cAAc,IAAI;AAChD,QAAI,aAAa;AACf,WAAK,OAAO,QAAQ,OAAO,aAAAA,QAAM,KAAK,IAAI,CAAC,iBAAiB;AAC5D,WAAK,OAAO,KAAK,WAAW;AAC5B;AAAA,IACF;AACA,WAAO,KAAK,QAAQ,KAAK,IAAI;AAAA,EAC/B;AAAA,EAEQ,UAAU,OAAO,KAAgB,SAA6B;AACpE,UAAM,EAAE,IAAI,IAAI,MAAM,IAAI,OAAO,UAAU,EAAE,KAAK,CAAC;AACnD,SAAK,OAAO,QAAQ,OAAO,aAAAA,QAAM,KAAK,IAAI,EAAE,CAAC,GAAG;AAChD,SAAK,OAAO,KAAK,GAAG;AAAA,EACtB;AACF;",
|
|
6
6
|
"names": ["chalk"]
|
|
7
7
|
}
|
|
@@ -71,7 +71,7 @@ class ChatCommand extends import_global_command.GlobalCommand {
|
|
|
71
71
|
const { conversation } = await client2.createConversation({});
|
|
72
72
|
convLine.success(`Conversation created with id "${conversation.id}"`);
|
|
73
73
|
convLine.commit();
|
|
74
|
-
const chat2 = import_chat.Chat.launch({ client: client2, conversationId: conversation.id });
|
|
74
|
+
const chat2 = import_chat.Chat.launch({ client: client2, conversationId: conversation.id, protocol: this.argv.protocol });
|
|
75
75
|
await chat2.wait();
|
|
76
76
|
};
|
|
77
77
|
_getChatApiUrl = (api) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/command-implementations/chat-command.ts"],
|
|
4
|
-
"sourcesContent": ["import * as chat from '@botpress/chat'\nimport * as client from '@botpress/client'\nimport semver from 'semver'\nimport { ApiClient } from '../api'\nimport { Chat } from '../chat'\nimport type commandDefinitions from '../command-definitions'\nimport * as consts from '../consts'\nimport * as errors from '../errors'\nimport * as utils from '../utils'\nimport { GlobalCommand } from './global-command'\n\ntype IntegrationInstance = {\n alias: string\n instance: client.Bot['integrations'][string]\n}\n\nexport type ChatCommandDefinition = typeof commandDefinitions.chat\nexport class ChatCommand extends GlobalCommand<ChatCommandDefinition> {\n public async run(): Promise<void> {\n if (process.platform === 'win32') {\n this.logger.warn('The chat command was not tested on Windows and may not work as expected')\n }\n\n const api = await this.ensureLoginAndCreateClient(this.argv)\n const botId = this.argv.botId ?? (await this._selectBot(api))\n const { bot } = await api.client.getBot({ id: botId }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not fetch bot \"${botId}\"`)\n })\n\n const targetChatVersion = this._getChatApiTargetVersionRange()\n let chatIntegrationInstance = this._findChatInstance(bot)\n\n if (!chatIntegrationInstance) {\n this.logger.log(`Chat integration with version ${targetChatVersion} is not installed in the selected bot`)\n const confirmInstall = await this.prompt.confirm('Do you wish to install it now?')\n if (!confirmInstall) {\n throw new errors.BotpressCLIError('Chat integration is required to proceed')\n }\n chatIntegrationInstance = await this._installChatIntegration(api, botId)\n }\n\n const { webhookId } = chatIntegrationInstance.instance\n const chatApiBaseUrl = this._getChatApiUrl(api)\n this.logger.debug(`using chat api url: \"${chatApiBaseUrl}\"`)\n\n const chatApiUrl = `${chatApiBaseUrl}/${webhookId}`\n const chatClient = await chat.Client.connect({ apiUrl: chatApiUrl })\n await this._chat(chatClient)\n }\n\n private _chat = async (client: chat.AuthenticatedClient): Promise<void> => {\n const convLine = this.logger.line()\n convLine.started('Creating a conversation...')\n const { conversation } = await client.createConversation({})\n convLine.success(`Conversation created with id \"${conversation.id}\"`)\n convLine.commit()\n\n const chat = Chat.launch({ client, conversationId: conversation.id })\n await chat.wait()\n }\n\n private _getChatApiUrl = (api: ApiClient): string => {\n if (this.argv.chatApiUrl) {\n return this.argv.chatApiUrl\n }\n\n const parseResult = utils.url.parse(api.url)\n if (parseResult.status === 'error') {\n return consts.defaultChatApiUrl\n }\n\n const { host, ...url } = parseResult.url\n if (!host.startsWith('api.')) {\n return consts.defaultChatApiUrl\n }\n\n const newHost = host.replace('api.', 'chat.')\n return utils.url.format({ ...url, host: newHost })\n }\n\n private _selectBot = async (api: ApiClient): Promise<string> => {\n const availableBots = 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 (!availableBots.length) {\n throw new errors.NoBotsFoundError()\n }\n\n const prompted = await this.prompt.select('Which bot do you want to deploy?', {\n choices: availableBots.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 private _installChatIntegration = async (api: ApiClient, botId: string): Promise<IntegrationInstance> => {\n const line = this.logger.line()\n line.started('Installing chat integration...')\n\n const { integration } = await api.client.getPublicIntegration({\n name: 'chat',\n version: this._getChatApiTargetVersion(),\n })\n\n const { bot } = await api.client.updateBot({\n id: botId,\n integrations: {\n [integration.name]: {\n integrationId: integration.id,\n enabled: true,\n configuration: {}, // empty object will always be a valid chat integration configuration\n },\n },\n })\n\n line.success('Chat integration installed')\n line.commit()\n\n const inst = this._findChatInstance(bot)\n if (!inst) {\n throw new errors.BotpressCLIError('Chat integration was installed but could not be found')\n }\n\n return inst\n }\n\n private _findChatInstance = (bot: client.Bot): IntegrationInstance | undefined => {\n const integrationInstances = Object.entries(bot.integrations).map(([alias, integrationInstance]) => ({\n alias,\n instance: integrationInstance,\n }))\n\n const targetChatVersion = this._getChatApiTargetVersionRange()\n return integrationInstances.find(\n (i) =>\n i.instance.name === 'chat' &&\n (semver.satisfies(i.instance.version, targetChatVersion) || i.instance.version === 'dev')\n )\n }\n\n private _getChatApiTargetVersionRange = (): string => {\n const targetApiVersion = this._getChatApiTargetVersion()\n const nextMajor = semver.inc(targetApiVersion, 'major')\n return `>=${targetApiVersion} <${nextMajor}`\n }\n\n private _getChatApiTargetVersion = (): string => {\n const dummyClient = new chat.Client({ apiUrl: '' })\n return dumm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,MAAM,UAAU;AAAA,EAC7B;AAAA,EAEQ,QAAQ,OAAOA,YAAoD;AACzE,UAAM,WAAW,KAAK,OAAO,KAAK;AAClC,aAAS,QAAQ,4BAA4B;AAC7C,UAAM,EAAE,aAAa,IAAI,MAAMA,QAAO,mBAAmB,CAAC,CAAC;AAC3D,aAAS,QAAQ,iCAAiC,aAAa,EAAE,GAAG;AACpE,aAAS,OAAO;AAEhB,UAAMC,QAAO,iBAAK,OAAO,EAAE,QAAAD,SAAQ,gBAAgB,aAAa,
|
|
4
|
+
"sourcesContent": ["import * as chat from '@botpress/chat'\nimport * as client from '@botpress/client'\nimport semver from 'semver'\nimport { ApiClient } from '../api'\nimport { Chat } from '../chat'\nimport type commandDefinitions from '../command-definitions'\nimport * as consts from '../consts'\nimport * as errors from '../errors'\nimport * as utils from '../utils'\nimport { GlobalCommand } from './global-command'\n\ntype IntegrationInstance = {\n alias: string\n instance: client.Bot['integrations'][string]\n}\n\nexport type ChatCommandDefinition = typeof commandDefinitions.chat\nexport class ChatCommand extends GlobalCommand<ChatCommandDefinition> {\n public async run(): Promise<void> {\n if (process.platform === 'win32') {\n this.logger.warn('The chat command was not tested on Windows and may not work as expected')\n }\n\n const api = await this.ensureLoginAndCreateClient(this.argv)\n const botId = this.argv.botId ?? (await this._selectBot(api))\n const { bot } = await api.client.getBot({ id: botId }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not fetch bot \"${botId}\"`)\n })\n\n const targetChatVersion = this._getChatApiTargetVersionRange()\n let chatIntegrationInstance = this._findChatInstance(bot)\n\n if (!chatIntegrationInstance) {\n this.logger.log(`Chat integration with version ${targetChatVersion} is not installed in the selected bot`)\n const confirmInstall = await this.prompt.confirm('Do you wish to install it now?')\n if (!confirmInstall) {\n throw new errors.BotpressCLIError('Chat integration is required to proceed')\n }\n chatIntegrationInstance = await this._installChatIntegration(api, botId)\n }\n\n const { webhookId } = chatIntegrationInstance.instance\n const chatApiBaseUrl = this._getChatApiUrl(api)\n this.logger.debug(`using chat api url: \"${chatApiBaseUrl}\"`)\n\n const chatApiUrl = `${chatApiBaseUrl}/${webhookId}`\n const chatClient = await chat.Client.connect({ apiUrl: chatApiUrl })\n await this._chat(chatClient)\n }\n\n private _chat = async (client: chat.AuthenticatedClient): Promise<void> => {\n const convLine = this.logger.line()\n convLine.started('Creating a conversation...')\n const { conversation } = await client.createConversation({})\n convLine.success(`Conversation created with id \"${conversation.id}\"`)\n convLine.commit()\n\n const chat = Chat.launch({ client, conversationId: conversation.id, protocol: this.argv.protocol })\n await chat.wait()\n }\n\n private _getChatApiUrl = (api: ApiClient): string => {\n if (this.argv.chatApiUrl) {\n return this.argv.chatApiUrl\n }\n\n const parseResult = utils.url.parse(api.url)\n if (parseResult.status === 'error') {\n return consts.defaultChatApiUrl\n }\n\n const { host, ...url } = parseResult.url\n if (!host.startsWith('api.')) {\n return consts.defaultChatApiUrl\n }\n\n const newHost = host.replace('api.', 'chat.')\n return utils.url.format({ ...url, host: newHost })\n }\n\n private _selectBot = async (api: ApiClient): Promise<string> => {\n const availableBots = 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 (!availableBots.length) {\n throw new errors.NoBotsFoundError()\n }\n\n const prompted = await this.prompt.select('Which bot do you want to deploy?', {\n choices: availableBots.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 private _installChatIntegration = async (api: ApiClient, botId: string): Promise<IntegrationInstance> => {\n const line = this.logger.line()\n line.started('Installing chat integration...')\n\n const { integration } = await api.client.getPublicIntegration({\n name: 'chat',\n version: this._getChatApiTargetVersion(),\n })\n\n const { bot } = await api.client.updateBot({\n id: botId,\n integrations: {\n [integration.name]: {\n integrationId: integration.id,\n enabled: true,\n configuration: {}, // empty object will always be a valid chat integration configuration\n },\n },\n })\n\n line.success('Chat integration installed')\n line.commit()\n\n const inst = this._findChatInstance(bot)\n if (!inst) {\n throw new errors.BotpressCLIError('Chat integration was installed but could not be found')\n }\n\n return inst\n }\n\n private _findChatInstance = (bot: client.Bot): IntegrationInstance | undefined => {\n const integrationInstances = Object.entries(bot.integrations).map(([alias, integrationInstance]) => ({\n alias,\n instance: integrationInstance,\n }))\n\n const targetChatVersion = this._getChatApiTargetVersionRange()\n return integrationInstances.find(\n (i) =>\n i.instance.name === 'chat' &&\n (semver.satisfies(i.instance.version, targetChatVersion) || i.instance.version === 'dev')\n )\n }\n\n private _getChatApiTargetVersionRange = (): string => {\n const targetApiVersion = this._getChatApiTargetVersion()\n const nextMajor = semver.inc(targetApiVersion, 'major')\n return `>=${targetApiVersion} <${nextMajor}`\n }\n\n private _getChatApiTargetVersion = (): string => {\n const dummyClient = new chat.Client({ apiUrl: '' })\n return dummyClient.apiVersion\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,WAAsB;AAEtB,oBAAmB;AAEnB,kBAAqB;AAErB,aAAwB;AACxB,aAAwB;AACxB,YAAuB;AACvB,4BAA8B;AAQvB,MAAM,oBAAoB,oCAAqC;AAAA,EACpE,MAAa,MAAqB;AAChC,QAAI,QAAQ,aAAa,SAAS;AAChC,WAAK,OAAO,KAAK,yEAAyE;AAAA,IAC5F;AAEA,UAAM,MAAM,MAAM,KAAK,2BAA2B,KAAK,IAAI;AAC3D,UAAM,QAAQ,KAAK,KAAK,SAAU,MAAM,KAAK,WAAW,GAAG;AAC3D,UAAM,EAAE,IAAI,IAAI,MAAM,IAAI,OAAO,OAAO,EAAE,IAAI,MAAM,CAAC,EAAE,MAAM,CAAC,WAAW;AACvE,YAAM,OAAO,iBAAiB,KAAK,QAAQ,wBAAwB,KAAK,GAAG;AAAA,IAC7E,CAAC;AAED,UAAM,oBAAoB,KAAK,8BAA8B;AAC7D,QAAI,0BAA0B,KAA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AAO,KAAK,kBAAkB,GAAG;AACvC,QAAI,CAAC,MAAM;AACT,YAAM,IAAI,OAAO,iBAAiB,uDAAuD;AAAA,IAC3F;AAEA,WAAO;AAAA,EACT;AAAA,EAEQ,oBAAoB,CAAC,QAAqD;AAChF,UAAM,uBAAuB,OAAO,QAAQ,IAAI,YAAY,EAAE,IAAI,CAAC,CAAC,OAAO,mBAAmB,OAAO;AAAA,MACnG;AAAA,MACA,UAAU;AAAA,IACZ,EAAE;AAEF,UAAM,oBAAoB,KAAK,8BAA8B;AAC7D,WAAO,qBAAqB;AAAA,MAC1B,CAAC,MACC,EAAE,SAAS,SAAS,WACnB,cAAAC,QAAO,UAAU,EAAE,SAAS,SAAS,iBAAiB,KAAK,EAAE,SAAS,YAAY;AAAA,IACvF;AAAA,EACF;AAAA,EAEQ,gCAAgC,MAAc;AACpD,UAAM,mBAAmB,KAAK,yBAAyB;AACvD,UAAM,YAAY,cAAAA,QAAO,IAAI,kBAAkB,OAAO;AACtD,WAAO,KAAK,gBAAgB,KAAK,SAAS;AAAA,EAC5C;AAAA,EAEQ,2BAA2B,MAAc;AAC/C,UAAM,cAAc,IAAI,KAAK,OAAO,EAAE,QAAQ,GAAG,CAAC;AAClD,WAAO,YAAY;AAAA,EACrB;AACF;",
|
|
6
6
|
"names": ["client", "chat", "semver"]
|
|
7
7
|
}
|
|
@@ -1454,6 +1454,11 @@ declare const _default: {
|
|
|
1454
1454
|
idx: number;
|
|
1455
1455
|
description: string;
|
|
1456
1456
|
};
|
|
1457
|
+
protocol: {
|
|
1458
|
+
choices: ("websocket" | "sse")[];
|
|
1459
|
+
default: "sse";
|
|
1460
|
+
description: string;
|
|
1461
|
+
};
|
|
1457
1462
|
apiUrl: {
|
|
1458
1463
|
type: "string";
|
|
1459
1464
|
description: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/command-implementations/init-command.ts"],
|
|
4
|
-
"sourcesContent": ["import type * as client from '@botpress/client'\nimport chalk from 'chalk'\nimport * as fs from 'fs'\nimport * as pathlib from 'path'\nimport { ApiClient } from 'src/api'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport { Logger } from '../logger'\nimport { ProjectTemplates } from '../project-templates'\nimport * as utils from '../utils'\nimport { GlobalCommand } from './global-command'\n\nconst projectTypes = ['bot', 'integration', 'plugin'] as const\ntype ProjectType = (typeof projectTypes)[number]\n\ntype CopyProps = { srcDir: string; destDir: string; name: string; pkgJson: Record<string, unknown> }\n\nexport type InitCommandDefinition = typeof commandDefinitions.init\nexport class InitCommand extends GlobalCommand<InitCommandDefinition> {\n public async run(): Promise<void> {\n const projectType = await this._promptProjectType()\n const workDir = utils.path.absoluteFrom(utils.path.cwd(), this.argv.workDir)\n\n try {\n if (projectType === 'bot') {\n await this._initBot({ workDir })\n return\n }\n\n if (projectType === 'integration') {\n const workspaceHandle = await this._promptWorkspaceHandle()\n await this._initIntegration({ workDir, workspaceHandle })\n return\n }\n\n if (projectType === 'plugin') {\n const workspaceHandle = await this._promptWorkspaceHandle()\n await this._initPlugin({ workDir, workspaceHandle })\n return\n }\n } catch (error) {\n if (error instanceof errors.AbortedOperationError) {\n this.logger.log(error.message)\n return\n }\n throw error\n }\n\n type _assertion = utils.types.AssertNever<typeof projectType>\n throw new errors.BotpressCLIError(`Unknown project type: ${projectType}`)\n }\n\n private async _promptWorkspaceHandle() {\n const client = (await this.getAuthenticatedClient({})) ?? undefined\n\n const nameParts = this.argv.name?.split('/', 2) ?? []\n const workspaceHandle = nameParts.length > 1 ? nameParts[0] : undefined\n\n const resolver = await WorkspaceResolver.from({\n client,\n workspaceHandle,\n prompt: this.prompt,\n logger: this.logger,\n })\n\n return await resolver.getWorkspaceHandle()\n }\n\n private async _promptProjectType() {\n if (this.argv.type) {\n return this.argv.type\n }\n\n const promptedType = await this.prompt.select('What type of project do you wish to initialize?', {\n choices: projectTypes.map((t) => ({ title: t, value: t })),\n })\n\n if (!promptedType) {\n throw new errors.ParamRequiredError('Project Type')\n }\n\n return promptedType\n }\n\n private _initPlugin = async (args: { workDir: string; workspaceHandle: string }) => {\n const { workDir, workspaceHandle } = args\n const template = await this._getOrPromptForTemplate('plugin')\n const name = await this._getName('plugin', template.defaultProjectName)\n const { fullName, shortName } = this._getFullNameAndShortName({ workspaceHandle, name })\n\n await this._copy({\n srcDir: template.absolutePath,\n destDir: workDir,\n name: shortName,\n pkgJson: {\n pluginName: fullName,\n },\n })\n this.logger.success(`Plugin project initialized in ${chalk.bold(pathlib.join(workDir, shortName))}`)\n }\n\n private async _getOrPromptForTemplate(type: ProjectType): Promise<ProjectTemplates.Template> {\n const availableTemplates = ProjectTemplates.templates[type]\n\n if (this.argv.template) {\n const template = availableTemplates.find((t) => t.identifier === this.argv.template)\n if (!template) {\n throw new errors.BotpressCLIError(`No ${type} template found for identifier \"${this.argv.template}\"`)\n }\n return template\n }\n\n if (availableTemplates.length === 1) {\n this.logger.log(`Using default template: ${chalk.bold(availableTemplates[0].fullName)}`)\n return availableTemplates[0]\n }\n\n return await this._promptForTemplate(availableTemplates)\n }\n\n private async _promptForTemplate(\n availableTemplates: ProjectTemplates.TemplateArray\n ): Promise<ProjectTemplates.Template> {\n const templateIndex = await this.prompt.select<number>('Which template do you want to use?', {\n choices: availableTemplates.map((template, index) => ({\n title: template.fullName,\n value: index,\n })),\n default: 0,\n })\n\n if (templateIndex === undefined || templateIndex < 0 || templateIndex >= availableTemplates.length) {\n this.logger.log(`Using default template: ${chalk.bold(availableTemplates[0].fullName)}`)\n return availableTemplates[0]\n }\n\n return availableTemplates[templateIndex]!\n }\n\n private _getFullNameAndShortName(args: { workspaceHandle: string; name: string }) {\n const [workspaceOrName, projectName] = args.name.split('/', 2)\n const shortName = projectName ?? workspaceOrName!\n const fullName = `${args.workspaceHandle}/${shortName}`\n\n return { shortName, fullName }\n }\n\n private _initBot = async (args: { workDir: string }) => {\n const { workDir } = args\n const template = await this._getOrPromptForTemplate('bot')\n const name = await this._getName('bot', template.defaultProjectName)\n\n await this._copy({ srcDir: template.absolutePath, destDir: workDir, name, pkgJson: {} })\n this.logger.success(`Bot project initialized in ${chalk.bold(pathlib.join(workDir, name))}`)\n }\n\n private _initIntegration = async (args: { workDir: string; workspaceHandle: string }) => {\n const { workDir, workspaceHandle } = args\n const template = await this._getOrPromptForTemplate('integration')\n const name = await this._getName('integration', template.defaultProjectName)\n const { fullName, shortName } = this._getFullNameAndShortName({ workspaceHandle, name })\n\n await this._copy({\n srcDir: template.absolutePath,\n destDir: workDir,\n name: shortName,\n pkgJson: {\n integrationName: fullName,\n },\n })\n this.logger.success(`Integration project initialized in ${chalk.bold(pathlib.join(workDir, shortName))}`)\n return\n }\n\n private _getName = async (projectType: ProjectType, defaultName: string): Promise<string> => {\n if (this.argv.name) {\n return this.argv.name\n }\n const promptMessage = `What is the name of your ${projectType}?`\n const promptedName = await this.prompt.text(promptMessage, { initial: defaultName })\n if (!promptedName) {\n throw new errors.ParamRequiredError('Project Name')\n }\n return promptedName\n }\n\n private _copy = async (props: CopyProps) => {\n const { srcDir, destDir, name, pkgJson } = props\n\n const dirName = utils.casing.to.kebabCase(name)\n const destination = pathlib.join(destDir, dirName)\n\n const destinationCanBeUsed = await this._checkIfDestinationCanBeUsed(destination)\n if (!destinationCanBeUsed) {\n throw new errors.AbortedOperationError()\n }\n await fs.promises.rm(destination, { recursive: true, force: true })\n\n await fs.promises.cp(srcDir, destination, { recursive: true })\n\n const json = await utils.pkgJson.readPackageJson(destination).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Failed to read package.json file')\n })\n\n const pkgJsonName = utils.casing.to.snakeCase(name)\n const updatedJson = { name: pkgJsonName, ...json, ...pkgJson }\n await utils.pkgJson.writePackageJson(destination, updatedJson).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Failed to write package.json file')\n })\n }\n\n private _checkIfDestinationCanBeUsed = async (destination: string) => {\n if (fs.existsSync(destination)) {\n const override = await this.prompt.confirm(\n `Directory ${chalk.bold(destination)} already exists. Do you want to overwrite it?`\n )\n if (!override) {\n return false\n }\n }\n return true\n }\n}\n\nclass WorkspaceResolver {\n private _workspaces: client.Workspace[] = []\n private _currentWorkspace?: client.Workspace\n\n private constructor(\n private readonly _client: ApiClient | undefined,\n private readonly _workspaceHandle: string | undefined,\n private readonly _prompt: utils.prompt.CLIPrompt,\n private readonly _logger: Logger\n ) {}\n\n public static async from({\n client,\n workspaceHandle,\n prompt,\n logger,\n }: {\n client?: ApiClient\n workspaceHandle?: string\n prompt: utils.prompt.CLIPrompt\n logger: Logger\n }): Promise<WorkspaceResolver> {\n const resolver = new WorkspaceResolver(client, workspaceHandle, prompt, logger)\n await resolver._fetchWorkspaces()\n return resolver\n }\n\n public async getWorkspaceHandle(): Promise<string> {\n if (this._hasNoWorkspaces()) {\n return this._promptForArbitraryWorkspaceHandle()\n }\n\n const workspace = await this._promptUserToSelectWorkspace()\n return workspace.handle || (await this._assignHandleToWorkspace(workspace))\n }\n\n private async _fetchWorkspaces(): Promise<void> {\n if (!this._isAuthenticated()) {\n return\n }\n\n const workspaces = await this._getClient()\n .client.list.workspaces({})\n .collect({})\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Unable to list your workspaces')\n })\n const currentWorkspace = workspaces.find((ws) => ws.id === this._getClient().workspaceId)\n\n this._workspaces = workspaces\n this._currentWorkspace = currentWorkspace\n }\n\n private _isAuthenticated(): boolean {\n return !!this._client\n }\n\n private _hasNoWorkspaces(): boolean {\n return !this._isAuthenticated() || this._workspaces.length === 0 || !this._currentWorkspace\n }\n\n private async _promptForArbitraryWorkspaceHandle(): Promise<string> {\n if (this._workspaceHandle) {\n return this._workspaceHandle\n }\n\n const handle = await this._prompt.text('Enter your workspace handle')\n\n if (!handle) {\n throw new errors.ParamRequiredError('Workspace handle')\n }\n\n return handle\n }\n\n private async _promptUserToSelectWorkspace(): Promise<client.Workspace> {\n const workspaceChoices = this._workspaces.map((ws) => ({\n title: ws.name,\n value: ws.id,\n }))\n\n const initialChoice = {\n title: this._currentWorkspace!.name,\n value: this._currentWorkspace!.id,\n }\n\n const workspaceId = await this._prompt.select('Which workspace do you want to use?', {\n initial: initialChoice,\n choices: workspaceChoices,\n })\n\n if (!workspaceId) {\n throw new errors.ParamRequiredError('Workspace')\n }\n\n return this._workspaces.find((ws) => ws.id === workspaceId)!\n }\n\n private async _assignHandleToWorkspace(workspace: client.Workspace): Promise<string> {\n this._logger.warn(\"It seems you don't have a workspace handle yet.\")\n\n let claimedHandle: string | undefined\n\n do {\n const desiredHandle = await this._promptForDesiredHandle()\n const isAvailable = await this._checkHandleAvailability(desiredHandle)\n\n if (isAvailable) {\n claimedHandle = desiredHandle\n await this._updateWorkspaceWithHandle(workspace.id, claimedHandle)\n }\n } while (!claimedHandle)\n\n this._logger.success(`Handle \"${claimedHandle}\" is yours!`)\n return claimedHandle\n }\n\n private async _promptForDesiredHandle(): Promise<string> {\n const desiredHandle = await this._prompt.text('Please enter a workspace handle')\n\n if (!desiredHandle) {\n throw new errors.BotpressCLIError('Workspace handle is required')\n }\n\n return desiredHandle\n }\n\n private async _checkHandleAvailability(handle: string): Promise<boolean> {\n const { available, suggestions } = await this._getClient().client.checkHandleAvailability({ handle })\n\n if (!available) {\n this._logger.warn(`Handle \"${handle}\" is not available. Suggestions: ${suggestions.join(', ')}`)\n return false\n }\n\n return true\n }\n\n private async _updateWorkspaceWithHandle(workspaceId: string, handle: string): Promise<void> {\n try {\n await this._getClient().switchWorkspace(workspaceId).updateWorkspace({ handle })\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, `Could not claim handle \"${handle}\"`)\n }\n }\n\n private _getClient(): ApiClient {\n if (!this._client) {\n throw new errors.BotpressCLIError('Could not authenticate')\n }\n return this._client\n }\n}\n"],
|
|
4
|
+
"sourcesContent": ["import type * as client from '@botpress/client'\nimport chalk from 'chalk'\nimport * as fs from 'fs'\nimport * as pathlib from 'path'\nimport { ApiClient } from '../api'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport { Logger } from '../logger'\nimport { ProjectTemplates } from '../project-templates'\nimport * as utils from '../utils'\nimport { GlobalCommand } from './global-command'\n\nconst projectTypes = ['bot', 'integration', 'plugin'] as const\ntype ProjectType = (typeof projectTypes)[number]\n\ntype CopyProps = { srcDir: string; destDir: string; name: string; pkgJson: Record<string, unknown> }\n\nexport type InitCommandDefinition = typeof commandDefinitions.init\nexport class InitCommand extends GlobalCommand<InitCommandDefinition> {\n public async run(): Promise<void> {\n const projectType = await this._promptProjectType()\n const workDir = utils.path.absoluteFrom(utils.path.cwd(), this.argv.workDir)\n\n try {\n if (projectType === 'bot') {\n await this._initBot({ workDir })\n return\n }\n\n if (projectType === 'integration') {\n const workspaceHandle = await this._promptWorkspaceHandle()\n await this._initIntegration({ workDir, workspaceHandle })\n return\n }\n\n if (projectType === 'plugin') {\n const workspaceHandle = await this._promptWorkspaceHandle()\n await this._initPlugin({ workDir, workspaceHandle })\n return\n }\n } catch (error) {\n if (error instanceof errors.AbortedOperationError) {\n this.logger.log(error.message)\n return\n }\n throw error\n }\n\n type _assertion = utils.types.AssertNever<typeof projectType>\n throw new errors.BotpressCLIError(`Unknown project type: ${projectType}`)\n }\n\n private async _promptWorkspaceHandle() {\n const client = (await this.getAuthenticatedClient({})) ?? undefined\n\n const nameParts = this.argv.name?.split('/', 2) ?? []\n const workspaceHandle = nameParts.length > 1 ? nameParts[0] : undefined\n\n const resolver = await WorkspaceResolver.from({\n client,\n workspaceHandle,\n prompt: this.prompt,\n logger: this.logger,\n })\n\n return await resolver.getWorkspaceHandle()\n }\n\n private async _promptProjectType() {\n if (this.argv.type) {\n return this.argv.type\n }\n\n const promptedType = await this.prompt.select('What type of project do you wish to initialize?', {\n choices: projectTypes.map((t) => ({ title: t, value: t })),\n })\n\n if (!promptedType) {\n throw new errors.ParamRequiredError('Project Type')\n }\n\n return promptedType\n }\n\n private _initPlugin = async (args: { workDir: string; workspaceHandle: string }) => {\n const { workDir, workspaceHandle } = args\n const template = await this._getOrPromptForTemplate('plugin')\n const name = await this._getName('plugin', template.defaultProjectName)\n const { fullName, shortName } = this._getFullNameAndShortName({ workspaceHandle, name })\n\n await this._copy({\n srcDir: template.absolutePath,\n destDir: workDir,\n name: shortName,\n pkgJson: {\n pluginName: fullName,\n },\n })\n this.logger.success(`Plugin project initialized in ${chalk.bold(pathlib.join(workDir, shortName))}`)\n }\n\n private async _getOrPromptForTemplate(type: ProjectType): Promise<ProjectTemplates.Template> {\n const availableTemplates = ProjectTemplates.templates[type]\n\n if (this.argv.template) {\n const template = availableTemplates.find((t) => t.identifier === this.argv.template)\n if (!template) {\n throw new errors.BotpressCLIError(`No ${type} template found for identifier \"${this.argv.template}\"`)\n }\n return template\n }\n\n if (availableTemplates.length === 1) {\n this.logger.log(`Using default template: ${chalk.bold(availableTemplates[0].fullName)}`)\n return availableTemplates[0]\n }\n\n return await this._promptForTemplate(availableTemplates)\n }\n\n private async _promptForTemplate(\n availableTemplates: ProjectTemplates.TemplateArray\n ): Promise<ProjectTemplates.Template> {\n const templateIndex = await this.prompt.select<number>('Which template do you want to use?', {\n choices: availableTemplates.map((template, index) => ({\n title: template.fullName,\n value: index,\n })),\n default: 0,\n })\n\n if (templateIndex === undefined || templateIndex < 0 || templateIndex >= availableTemplates.length) {\n this.logger.log(`Using default template: ${chalk.bold(availableTemplates[0].fullName)}`)\n return availableTemplates[0]\n }\n\n return availableTemplates[templateIndex]!\n }\n\n private _getFullNameAndShortName(args: { workspaceHandle: string; name: string }) {\n const [workspaceOrName, projectName] = args.name.split('/', 2)\n const shortName = projectName ?? workspaceOrName!\n const fullName = `${args.workspaceHandle}/${shortName}`\n\n return { shortName, fullName }\n }\n\n private _initBot = async (args: { workDir: string }) => {\n const { workDir } = args\n const template = await this._getOrPromptForTemplate('bot')\n const name = await this._getName('bot', template.defaultProjectName)\n\n await this._copy({ srcDir: template.absolutePath, destDir: workDir, name, pkgJson: {} })\n this.logger.success(`Bot project initialized in ${chalk.bold(pathlib.join(workDir, name))}`)\n }\n\n private _initIntegration = async (args: { workDir: string; workspaceHandle: string }) => {\n const { workDir, workspaceHandle } = args\n const template = await this._getOrPromptForTemplate('integration')\n const name = await this._getName('integration', template.defaultProjectName)\n const { fullName, shortName } = this._getFullNameAndShortName({ workspaceHandle, name })\n\n await this._copy({\n srcDir: template.absolutePath,\n destDir: workDir,\n name: shortName,\n pkgJson: {\n integrationName: fullName,\n },\n })\n this.logger.success(`Integration project initialized in ${chalk.bold(pathlib.join(workDir, shortName))}`)\n return\n }\n\n private _getName = async (projectType: ProjectType, defaultName: string): Promise<string> => {\n if (this.argv.name) {\n return this.argv.name\n }\n const promptMessage = `What is the name of your ${projectType}?`\n const promptedName = await this.prompt.text(promptMessage, { initial: defaultName })\n if (!promptedName) {\n throw new errors.ParamRequiredError('Project Name')\n }\n return promptedName\n }\n\n private _copy = async (props: CopyProps) => {\n const { srcDir, destDir, name, pkgJson } = props\n\n const dirName = utils.casing.to.kebabCase(name)\n const destination = pathlib.join(destDir, dirName)\n\n const destinationCanBeUsed = await this._checkIfDestinationCanBeUsed(destination)\n if (!destinationCanBeUsed) {\n throw new errors.AbortedOperationError()\n }\n await fs.promises.rm(destination, { recursive: true, force: true })\n\n await fs.promises.cp(srcDir, destination, { recursive: true })\n\n const json = await utils.pkgJson.readPackageJson(destination).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Failed to read package.json file')\n })\n\n const pkgJsonName = utils.casing.to.snakeCase(name)\n const updatedJson = { name: pkgJsonName, ...json, ...pkgJson }\n await utils.pkgJson.writePackageJson(destination, updatedJson).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Failed to write package.json file')\n })\n }\n\n private _checkIfDestinationCanBeUsed = async (destination: string) => {\n if (fs.existsSync(destination)) {\n const override = await this.prompt.confirm(\n `Directory ${chalk.bold(destination)} already exists. Do you want to overwrite it?`\n )\n if (!override) {\n return false\n }\n }\n return true\n }\n}\n\nclass WorkspaceResolver {\n private _workspaces: client.Workspace[] = []\n private _currentWorkspace?: client.Workspace\n\n private constructor(\n private readonly _client: ApiClient | undefined,\n private readonly _workspaceHandle: string | undefined,\n private readonly _prompt: utils.prompt.CLIPrompt,\n private readonly _logger: Logger\n ) {}\n\n public static async from({\n client,\n workspaceHandle,\n prompt,\n logger,\n }: {\n client?: ApiClient\n workspaceHandle?: string\n prompt: utils.prompt.CLIPrompt\n logger: Logger\n }): Promise<WorkspaceResolver> {\n const resolver = new WorkspaceResolver(client, workspaceHandle, prompt, logger)\n await resolver._fetchWorkspaces()\n return resolver\n }\n\n public async getWorkspaceHandle(): Promise<string> {\n if (this._hasNoWorkspaces()) {\n return this._promptForArbitraryWorkspaceHandle()\n }\n\n const workspace = await this._promptUserToSelectWorkspace()\n return workspace.handle || (await this._assignHandleToWorkspace(workspace))\n }\n\n private async _fetchWorkspaces(): Promise<void> {\n if (!this._isAuthenticated()) {\n return\n }\n\n const workspaces = await this._getClient()\n .client.list.workspaces({})\n .collect({})\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Unable to list your workspaces')\n })\n const currentWorkspace = workspaces.find((ws) => ws.id === this._getClient().workspaceId)\n\n this._workspaces = workspaces\n this._currentWorkspace = currentWorkspace\n }\n\n private _isAuthenticated(): boolean {\n return !!this._client\n }\n\n private _hasNoWorkspaces(): boolean {\n return !this._isAuthenticated() || this._workspaces.length === 0 || !this._currentWorkspace\n }\n\n private async _promptForArbitraryWorkspaceHandle(): Promise<string> {\n if (this._workspaceHandle) {\n return this._workspaceHandle\n }\n\n const handle = await this._prompt.text('Enter your workspace handle')\n\n if (!handle) {\n throw new errors.ParamRequiredError('Workspace handle')\n }\n\n return handle\n }\n\n private async _promptUserToSelectWorkspace(): Promise<client.Workspace> {\n const workspaceChoices = this._workspaces.map((ws) => ({\n title: ws.name,\n value: ws.id,\n }))\n\n const initialChoice = {\n title: this._currentWorkspace!.name,\n value: this._currentWorkspace!.id,\n }\n\n const workspaceId = await this._prompt.select('Which workspace do you want to use?', {\n initial: initialChoice,\n choices: workspaceChoices,\n })\n\n if (!workspaceId) {\n throw new errors.ParamRequiredError('Workspace')\n }\n\n return this._workspaces.find((ws) => ws.id === workspaceId)!\n }\n\n private async _assignHandleToWorkspace(workspace: client.Workspace): Promise<string> {\n this._logger.warn(\"It seems you don't have a workspace handle yet.\")\n\n let claimedHandle: string | undefined\n\n do {\n const desiredHandle = await this._promptForDesiredHandle()\n const isAvailable = await this._checkHandleAvailability(desiredHandle)\n\n if (isAvailable) {\n claimedHandle = desiredHandle\n await this._updateWorkspaceWithHandle(workspace.id, claimedHandle)\n }\n } while (!claimedHandle)\n\n this._logger.success(`Handle \"${claimedHandle}\" is yours!`)\n return claimedHandle\n }\n\n private async _promptForDesiredHandle(): Promise<string> {\n const desiredHandle = await this._prompt.text('Please enter a workspace handle')\n\n if (!desiredHandle) {\n throw new errors.BotpressCLIError('Workspace handle is required')\n }\n\n return desiredHandle\n }\n\n private async _checkHandleAvailability(handle: string): Promise<boolean> {\n const { available, suggestions } = await this._getClient().client.checkHandleAvailability({ handle })\n\n if (!available) {\n this._logger.warn(`Handle \"${handle}\" is not available. Suggestions: ${suggestions.join(', ')}`)\n return false\n }\n\n return true\n }\n\n private async _updateWorkspaceWithHandle(workspaceId: string, handle: string): Promise<void> {\n try {\n await this._getClient().switchWorkspace(workspaceId).updateWorkspace({ handle })\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, `Could not claim handle \"${handle}\"`)\n }\n }\n\n private _getClient(): ApiClient {\n if (!this._client) {\n throw new errors.BotpressCLIError('Could not authenticate')\n }\n return this._client\n }\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAClB,SAAoB;AACpB,cAAyB;AAGzB,aAAwB;AAExB,+BAAiC;AACjC,YAAuB;AACvB,4BAA8B;AAE9B,MAAM,eAAe,CAA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ources": ["../../src/command-implementations/integration-commands.ts"],
|
|
4
|
-
"sourcesContent": ["import chalk from 'chalk'\nimport _ from 'lodash'\nimport { ApiClient, PublicOrPrivateIntegration, IntegrationSummary } from '
|
|
4
|
+
"sourcesContent": ["import chalk from 'chalk'\nimport _ from 'lodash'\nimport { ApiClient, PublicOrPrivateIntegration, IntegrationSummary } from '../api/client'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport { NamePackageRef, parsePackageRef } from '../package-ref'\nimport { GlobalCommand } from './global-command'\n\nexport type GetIntegrationCommandDefinition = typeof commandDefinitions.integrations.subcommands.get\nexport class GetIntegrationCommand extends GlobalCommand<GetIntegrationCommandDefinition> {\n public async run(): Promise<void> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n const parsedRef = parsePackageRef(this.argv.integrationRef)\n if (!parsedRef) {\n throw new errors.InvalidPackageReferenceError(this.argv.integrationRef)\n }\n if (parsedRef.type === 'path') {\n throw new errors.BotpressCLIError('Cannot get local integration')\n }\n\n try {\n const integration = await api.findPublicOrPrivateIntegration(parsedRef)\n if (integration) {\n this.logger.success(`Integration ${chalk.bold(this.argv.integrationRef)}:`)\n this.logger.json(integration)\n return\n }\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, `Could not get integration ${this.argv.integrationRef}`)\n }\n\n throw new errors.BotpressCLIError(`Integration ${this.argv.integrationRef} not found`)\n }\n}\n\nexport type ListIntegrationsCommandDefinition = typeof commandDefinitions.integrations.subcommands.list\nexport class ListIntegrationsCommand extends GlobalCommand<ListIntegrationsCommandDefinition> {\n public async run(): Promise<void> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n\n const { dev, public: isPublic, owned } = this.argv\n\n if (dev && isPublic) {\n throw new errors.BotpressCLIError(\n 'Cannot use --dev and --public flags together as dev integrations are always private'\n )\n }\n if (dev && owned) {\n throw new errors.BotpressCLIError(\n 'Cannot use --dev and --owned flags together as dev integrations are always owned by the current workspace'\n )\n }\n\n try {\n const integrations = await this._listAllIntegrations(api)\n this.logger.success('Integrations:')\n this.logger.json(integrations)\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not list integrations')\n }\n }\n\n private _listAllIntegrations = async (api: ApiClient): Promise<IntegrationSummary[]> => {\n if (this.argv.dev) {\n return this._listDevIntegrations(api)\n }\n\n if (this.argv.public && this.argv.owned) {\n const [owned, publicIntegrations] = await Promise.all([\n this._listOwnedIntegrations(api),\n this._listPublicIntegrations(api),\n ])\n return _.intersectionBy(owned, publicIntegrations, (i) => i.id).slice(0, this.argv.limit)\n }\n\n if (this.argv.owned) {\n return this._listOwnedIntegrations(api)\n }\n\n if (this.argv.public) {\n return this._listPublicIntegrations(api)\n }\n\n const [owned, publicIntegrations] = await Promise.all([\n this._listOwnedIntegrations(api),\n this._listPublicIntegrations(api),\n ])\n return _.uniqBy([...owned, ...publicIntegrations], (i) => i.id).slice(0, this.argv.limit)\n }\n\n private _listDevIntegrations = async (api: ApiClient): Promise<IntegrationSummary[]> => {\n const { name, versionNumber: version } = this.argv\n return api.client.list.integrations({ dev: true, name, version }).collect({ limit: this.argv.limit })\n }\n\n private _listOwnedIntegrations = async (api: ApiClient): Promise<IntegrationSummary[]> => {\n const { name, versionNumber: version } = this.argv\n return api.client.list.integrations({ name, version }).collect({ limit: this.argv.limit })\n }\n\n private _listPublicIntegrations = async (api: ApiClient): Promise<IntegrationSummary[]> => {\n const { name, versionNumber: version } = this.argv\n return api.client.list.publicIntegrations({ name, version }).collect({ limit: this.argv.limit })\n }\n}\n\nexport type DeleteIntegrationCommandDefinition = typeof commandDefinitions.integrations.subcommands.delete\nexport class DeleteIntegrationCommand extends GlobalCommand<DeleteIntegrationCommandDefinition> {\n public async run(): Promise<void> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n const parsedRef = parsePackageRef(this.argv.integrationRef)\n if (!parsedRef) {\n throw new errors.InvalidPackageReferenceError(this.argv.integrationRef)\n }\n if (parsedRef.type === 'path') {\n throw new errors.BotpressCLIError('Cannot delete local integration')\n }\n\n let integrationId: string | undefined\n if (parsedRef.type === 'id') {\n integrationId = parsedRef.id\n } else {\n const integration = await this._findIntegration(api, parsedRef)\n integrationId = integration.id\n }\n\n try {\n await api.client.deleteIntegration({ id: integrationId })\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, `Could not delete integration ${this.argv.integrationRef}`)\n }\n\n this.logger.success(`Integration ${chalk.bold(this.argv.integrationRef)} deleted`)\n return\n }\n\n private _findIntegration = async (api: ApiClient, parsedRef: NamePackageRef) => {\n let integration: PublicOrPrivateIntegration | undefined\n\n try {\n integration = await api.findPrivateIntegration(parsedRef)\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, `Could not get integration ${this.argv.integrationRef}`)\n }\n\n if (!integration) {\n const publicIntegration = await api.findPublicIntegration(parsedRef)\n if (publicIntegration) {\n throw new errors.BotpressCLIError(`Integration ${this.argv.integrationRef} does not belong to your workspace`)\n }\n\n throw new errors.BotpressCLIError(`Integration ${this.argv.integrationRef} not found`)\n }\n\n return integration\n }\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAClB,oBAAc;AAGd,aAAwB;AACxB,yBAAgD;AAChD,4BAA8B;AAGvB,MAAM,8BAA8B,oCAA+C;AAAA,EACxF,MAAa,MAAqB;AAChC,UAAM,MAAM,MAAM,KAAK,2BAA2B,KAAK,IAAI;AAC3D,UAAM,gBAAY,oCAAgB,KAAK,KAAK,cAAc;AAC1D,QAAI,CAAC,WAAW;AACd,YAAM,IAAI,OAAO,6BAA6B,KAAK,KAAK,cAAc;AAAA,IACxE;AACA,QAAI,UAAU,SAAS,QAAQ;AAC7B,YAAM,IAAI,OAAO,iBAAiB,8BAA8B;AAAA,IAClE;AAEA,QAAI;AACF,YAAM,cAAc,MAAM,IAAI,+BAA+B,SAAS;AACtE,UAAI,aAAa;AACf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1378,6 +1378,11 @@ export declare const schemas: {
|
|
|
1378
1378
|
idx: number;
|
|
1379
1379
|
description: string;
|
|
1380
1380
|
};
|
|
1381
|
+
protocol: {
|
|
1382
|
+
choices: ("websocket" | "sse")[];
|
|
1383
|
+
default: "sse";
|
|
1384
|
+
description: string;
|
|
1385
|
+
};
|
|
1381
1386
|
apiUrl: {
|
|
1382
1387
|
type: "string";
|
|
1383
1388
|
description: string;
|
package/dist/config.js
CHANGED
|
@@ -98,8 +98,16 @@ const pluginRef = {
|
|
|
98
98
|
demandOption: true,
|
|
99
99
|
description: "The plugin ID or name and version. Ex: knowledge@0.0.1"
|
|
100
100
|
};
|
|
101
|
-
const sourceMap = {
|
|
102
|
-
|
|
101
|
+
const sourceMap = {
|
|
102
|
+
type: "boolean",
|
|
103
|
+
description: "Generate sourcemaps",
|
|
104
|
+
default: false
|
|
105
|
+
};
|
|
106
|
+
const minify = {
|
|
107
|
+
type: "boolean",
|
|
108
|
+
description: "Minify the bundled code",
|
|
109
|
+
default: true
|
|
110
|
+
};
|
|
103
111
|
const dev = {
|
|
104
112
|
type: "boolean",
|
|
105
113
|
description: "List only dev bots / dev integrations",
|
|
@@ -174,7 +182,10 @@ const deploySchema = {
|
|
|
174
182
|
botId: { type: "string", description: "The bot ID to deploy. Only used when deploying a bot" },
|
|
175
183
|
noBuild,
|
|
176
184
|
dryRun,
|
|
177
|
-
createNewBot: {
|
|
185
|
+
createNewBot: {
|
|
186
|
+
type: "boolean",
|
|
187
|
+
description: "Create a new bot when deploying. Only used when deploying a bot"
|
|
188
|
+
},
|
|
178
189
|
sourceMap,
|
|
179
190
|
minify,
|
|
180
191
|
visibility: {
|
|
@@ -194,7 +205,10 @@ const deploySchema = {
|
|
|
194
205
|
description: "Allow deprecated features in the project",
|
|
195
206
|
default: false
|
|
196
207
|
},
|
|
197
|
-
url: {
|
|
208
|
+
url: {
|
|
209
|
+
type: "string",
|
|
210
|
+
description: "Custom URL for the integration. Only used when deploying an integration"
|
|
211
|
+
}
|
|
198
212
|
};
|
|
199
213
|
const devSchema = {
|
|
200
214
|
...projectSchema,
|
|
@@ -242,7 +256,12 @@ const removeSchema = {
|
|
|
242
256
|
...globalSchema,
|
|
243
257
|
...credentialsSchema,
|
|
244
258
|
workDir,
|
|
245
|
-
alias: {
|
|
259
|
+
alias: {
|
|
260
|
+
idx: 0,
|
|
261
|
+
positional: true,
|
|
262
|
+
type: "string",
|
|
263
|
+
description: "The alias of the package to uninstall"
|
|
264
|
+
}
|
|
246
265
|
};
|
|
247
266
|
const loginSchema = {
|
|
248
267
|
...globalSchema,
|
|
@@ -354,15 +373,28 @@ const chatSchema = {
|
|
|
354
373
|
positional: true,
|
|
355
374
|
idx: 0,
|
|
356
375
|
description: "The bot ID to chat with"
|
|
376
|
+
},
|
|
377
|
+
protocol: {
|
|
378
|
+
choices: ["sse", "websocket"],
|
|
379
|
+
default: "sse",
|
|
380
|
+
description: "The protocol to use for long lived connections"
|
|
357
381
|
}
|
|
358
382
|
};
|
|
359
383
|
const listProfilesSchema = {
|
|
360
384
|
...globalSchema,
|
|
361
|
-
displayToken: {
|
|
385
|
+
displayToken: {
|
|
386
|
+
type: "boolean",
|
|
387
|
+
description: "Display the token in each of the bp profiles",
|
|
388
|
+
default: false
|
|
389
|
+
}
|
|
362
390
|
};
|
|
363
391
|
const activeProfileSchema = {
|
|
364
392
|
...globalSchema,
|
|
365
|
-
displayToken: {
|
|
393
|
+
displayToken: {
|
|
394
|
+
type: "boolean",
|
|
395
|
+
description: "Display the token in the bp profile",
|
|
396
|
+
default: false
|
|
397
|
+
}
|
|
366
398
|
};
|
|
367
399
|
const useProfileSchema = {
|
|
368
400
|
...globalSchema,
|
|
@@ -381,7 +413,11 @@ const getProfileSchema = {
|
|
|
381
413
|
positional: true,
|
|
382
414
|
idx: 0
|
|
383
415
|
},
|
|
384
|
-
displayToken: {
|
|
416
|
+
displayToken: {
|
|
417
|
+
type: "boolean",
|
|
418
|
+
description: "Display the token in the bp profile",
|
|
419
|
+
default: false
|
|
420
|
+
}
|
|
385
421
|
};
|
|
386
422
|
const schemas = {
|
|
387
423
|
global: globalSchema,
|
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 bot or 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 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 url: { type: 'string', description: 'Custom URL for the integration. Only used when deploying an integration' },\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 noSecretCaching: {\n type: 'boolean',\n description: 'Do not save the secrets locally',\n default: false,\n alias: 'nsc',\n },\n} satisfies CommandSchema\n\nconst addSchema = {\n ...globalSchema,\n ...credentialsSchema,\n packageRef,\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 to install the package with',\n },\n} satisfies CommandSchema\n\nconst removeSchema = {\n ...globalSchema,\n ...credentialsSchema,\n workDir,\n alias: { idx: 0, positional: true, type: 'string', description: 'The alias of the package to uninstall' },\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 owned: { type: 'boolean', description: 'List only owned integrations' },\n public: { type: 'boolean', description: 'List only public integrations' },\n limit: { type: 'number', description: 'Limit the number of integrations returned' },\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 displayToken: { type: 'boolean', description: 'Display the token in each of the bp profiles', default: false },\n} satisfies CommandSchema\n\nconst activeProfileSchema = {\n ...globalSchema,\n displayToken: { type: 'boolean', description: 'Display the token in the bp profile', default: false },\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\nconst getProfileSchema = {\n ...globalSchema,\n profileToGet: {\n type: 'string',\n description: 'The CLI profile defined in the $BP_BOTPRESS_HOME/profiles.json',\n positional: true,\n idx: 0,\n },\n displayToken: { type: 'boolean', description: 'Display the token in the bp profile', default: false },\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 remove: removeSchema,\n dev: devSchema,\n lint: lintSchema,\n chat: chatSchema,\n listProfiles: listProfilesSchema,\n activeProfile: activeProfileSchema,\n useProfile: useProfileSchema,\n getProfile: getProfileSchema,\n} as const\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["import type { ServerEventsProtocol } from '@botpress/chat'\nimport * 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 bot or 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 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 = {\n type: 'boolean',\n description: 'Generate sourcemaps',\n default: false,\n} satisfies CommandOption\n\nconst minify = {\n type: 'boolean',\n description: 'Minify the bundled code',\n default: true,\n} 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: {\n type: 'boolean',\n description: 'Create a new bot when deploying. Only used when deploying a bot',\n },\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 url: {\n type: 'string',\n description: 'Custom URL for the integration. Only used when deploying an integration',\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 noSecretCaching: {\n type: 'boolean',\n description: 'Do not save the secrets locally',\n default: false,\n alias: 'nsc',\n },\n} satisfies CommandSchema\n\nconst addSchema = {\n ...globalSchema,\n ...credentialsSchema,\n packageRef,\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 to install the package with',\n },\n} satisfies CommandSchema\n\nconst removeSchema = {\n ...globalSchema,\n ...credentialsSchema,\n workDir,\n alias: {\n idx: 0,\n positional: true,\n type: 'string',\n description: 'The alias of the package to uninstall',\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 owned: { type: 'boolean', description: 'List only owned integrations' },\n public: { type: 'boolean', description: 'List only public integrations' },\n limit: { type: 'number', description: 'Limit the number of integrations returned' },\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 protocol: {\n choices: ['sse', 'websocket'] satisfies ReadonlyArray<ServerEventsProtocol>,\n default: 'sse' as const,\n description: 'The protocol to use for long lived connections',\n },\n} satisfies CommandSchema\n\nconst listProfilesSchema = {\n ...globalSchema,\n displayToken: {\n type: 'boolean',\n description: 'Display the token in each of the bp profiles',\n default: false,\n },\n} satisfies CommandSchema\n\nconst activeProfileSchema = {\n ...globalSchema,\n displayToken: {\n type: 'boolean',\n description: 'Display the token in the bp profile',\n default: false,\n },\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\nconst getProfileSchema = {\n ...globalSchema,\n profileToGet: {\n type: 'string',\n description: 'The CLI profile defined in the $BP_BOTPRESS_HOME/profiles.json',\n positional: true,\n idx: 0,\n },\n displayToken: {\n type: 'boolean',\n description: 'Display the token in the bp profile',\n default: false,\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 remove: removeSchema,\n dev: devSchema,\n lint: lintSchema,\n chat: chatSchema,\n listProfiles: listProfilesSchema,\n activeProfile: activeProfileSchema,\n useProfile: useProfileSchema,\n getProfile: getProfileSchema,\n} as const\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,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,aAAa;AAAA,EACjB,MAAM;AAAA,EACN,aACE;AAAA,EACF,YAAY;AAAA,EACZ,KAAK;AACP;AAEA,MAAM,iBAAiB;AAAA,EACrB,GAAG;AAAA,EACH,cAAc;AAAA,EACd,aAA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11 @@ declare const _default: {
|
|
|
1446
1446
|
idx: number;
|
|
1447
1447
|
description: string;
|
|
1448
1448
|
};
|
|
1449
|
+
protocol: {
|
|
1450
|
+
choices: ("websocket" | "sse")[];
|
|
1451
|
+
default: "sse";
|
|
1452
|
+
description: string;
|
|
1453
|
+
};
|
|
1449
1454
|
apiUrl: {
|
|
1450
1455
|
type: "string";
|
|
1451
1456
|
description: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botpress/cli",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.5.0",
|
|
4
4
|
"description": "Botpress CLI",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "pnpm run build:types && pnpm run bundle && pnpm run template:gen",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@apidevtools/json-schema-ref-parser": "^11.7.0",
|
|
29
29
|
"@botpress/chat": "0.5.5",
|
|
30
|
-
"@botpress/client": "1.
|
|
31
|
-
"@botpress/sdk": "6.
|
|
30
|
+
"@botpress/client": "1.42.0",
|
|
31
|
+
"@botpress/sdk": "6.7.0",
|
|
32
32
|
"@bpinternal/const": "^0.1.0",
|
|
33
33
|
"@bpinternal/tunnel": "^0.1.1",
|
|
34
34
|
"@bpinternal/verel": "^0.2.0",
|