@botpress/cli 0.2.9 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/dist/api/client.js +1 -1
  2. package/dist/api/client.js.map +2 -2
  3. package/dist/code-generation/const.js +1 -1
  4. package/dist/code-generation/const.js.map +1 -1
  5. package/dist/code-generation/{event.js → generators.js} +15 -19
  6. package/dist/code-generation/generators.js.map +7 -0
  7. package/dist/code-generation/index.js +40 -8
  8. package/dist/code-generation/index.js.map +2 -2
  9. package/dist/code-generation/integration-implementation.js +157 -0
  10. package/dist/code-generation/integration-implementation.js.map +7 -0
  11. package/dist/code-generation/integration-instance.js +101 -39
  12. package/dist/code-generation/integration-instance.js.map +2 -2
  13. package/dist/code-generation/{action.js → integration-schemas/actions-module.js} +41 -19
  14. package/dist/code-generation/integration-schemas/actions-module.js.map +7 -0
  15. package/dist/code-generation/integration-schemas/channels-module.js +114 -0
  16. package/dist/code-generation/integration-schemas/channels-module.js.map +7 -0
  17. package/dist/code-generation/{configuration.js → integration-schemas/configuration-module.js} +11 -10
  18. package/dist/code-generation/integration-schemas/configuration-module.js.map +7 -0
  19. package/dist/code-generation/integration-schemas/events-module.js +64 -0
  20. package/dist/code-generation/integration-schemas/events-module.js.map +7 -0
  21. package/dist/code-generation/integration-schemas/states-module.js +64 -0
  22. package/dist/code-generation/integration-schemas/states-module.js.map +7 -0
  23. package/dist/code-generation/module.js +5 -5
  24. package/dist/code-generation/module.js.map +2 -2
  25. package/dist/code-generation/typings.js.map +1 -1
  26. package/dist/command-implementations/deploy-command.js +2 -20
  27. package/dist/command-implementations/deploy-command.js.map +3 -3
  28. package/dist/command-implementations/dev-command.js +26 -13
  29. package/dist/command-implementations/dev-command.js.map +3 -3
  30. package/dist/command-implementations/project-command.js +54 -1
  31. package/dist/command-implementations/project-command.js.map +2 -2
  32. package/dist/{code-generation/message.js → utils/guard-utils.js} +9 -20
  33. package/dist/utils/guard-utils.js.map +7 -0
  34. package/dist/utils/index.js +9 -0
  35. package/dist/utils/index.js.map +2 -2
  36. package/dist/utils/record-utils.js +9 -0
  37. package/dist/utils/record-utils.js.map +2 -2
  38. package/dist/{code-generation/channel.js → utils/schema-utils.js} +25 -22
  39. package/dist/utils/schema-utils.js.map +7 -0
  40. package/dist/utils/type-utils.js +17 -0
  41. package/dist/utils/type-utils.js.map +7 -0
  42. package/e2e/api.ts +4 -4
  43. package/e2e/tests/create-deploy-bot.ts +1 -1
  44. package/e2e/tests/create-deploy-integration.ts +1 -1
  45. package/e2e/tests/dev-bot.ts +5 -4
  46. package/package.json +6 -5
  47. package/templates/echo-bot/package.json +2 -2
  48. package/templates/echo-bot/src/index.ts +7 -20
  49. package/templates/empty-integration/.botpress/implementation/actions/index.ts +0 -1
  50. package/templates/empty-integration/.botpress/implementation/channels/channel/index.ts +6 -34
  51. package/templates/empty-integration/.botpress/implementation/channels/channel/{audio.ts → messages/audio.ts} +1 -1
  52. package/templates/empty-integration/.botpress/implementation/channels/channel/{card.ts → messages/card.ts} +1 -1
  53. package/templates/empty-integration/.botpress/implementation/channels/channel/{carousel.ts → messages/carousel.ts} +1 -1
  54. package/templates/empty-integration/.botpress/implementation/channels/channel/{choice.ts → messages/choice.ts} +1 -1
  55. package/templates/empty-integration/.botpress/implementation/channels/channel/{dropdown.ts → messages/dropdown.ts} +1 -1
  56. package/templates/empty-integration/.botpress/implementation/channels/channel/{file.ts → messages/file.ts} +1 -1
  57. package/templates/empty-integration/.botpress/implementation/channels/channel/{image.ts → messages/image.ts} +1 -1
  58. package/templates/empty-integration/.botpress/implementation/channels/channel/messages/index.ts +39 -0
  59. package/templates/empty-integration/.botpress/implementation/channels/channel/{location.ts → messages/location.ts} +1 -1
  60. package/templates/empty-integration/.botpress/implementation/channels/channel/{markdown.ts → messages/markdown.ts} +1 -1
  61. package/templates/empty-integration/.botpress/implementation/channels/channel/{text.ts → messages/text.ts} +1 -1
  62. package/templates/empty-integration/.botpress/implementation/channels/channel/{video.ts → messages/video.ts} +1 -1
  63. package/templates/empty-integration/.botpress/implementation/channels/index.ts +1 -2
  64. package/templates/empty-integration/.botpress/implementation/{configuration.ts → configuration/index.ts} +2 -2
  65. package/templates/empty-integration/.botpress/implementation/events/index.ts +0 -1
  66. package/templates/empty-integration/.botpress/implementation/index.ts +30 -12
  67. package/templates/empty-integration/.botpress/implementation/states/index.ts +6 -0
  68. package/templates/empty-integration/.botpress/secrets/index.ts +0 -1
  69. package/templates/empty-integration/package.json +2 -2
  70. package/dist/code-generation/action.js.map +0 -7
  71. package/dist/code-generation/channel.js.map +0 -7
  72. package/dist/code-generation/configuration.js.map +0 -7
  73. package/dist/code-generation/event.js.map +0 -7
  74. package/dist/code-generation/integration-impl.js +0 -147
  75. package/dist/code-generation/integration-impl.js.map +0 -7
  76. package/dist/code-generation/message.js.map +0 -7
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var type_utils_exports = {};
16
+ module.exports = __toCommonJS(type_utils_exports);
17
+ //# sourceMappingURL=type-utils.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/utils/type-utils.ts"],
4
+ "sourcesContent": ["export type Merge<A extends object, B extends object> = Omit<A, keyof B> & B\n"],
5
+ "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
6
+ "names": []
7
+ }
package/e2e/api.ts CHANGED
@@ -3,10 +3,10 @@ import { Client } from '@botpress/client'
3
3
  export type ApiBot = Awaited<ReturnType<Client['listBots']>>['bots'][0]
4
4
  export const fetchAllBots = async (client: Client): Promise<ApiBot[]> => {
5
5
  let allBots: ApiBot[] = []
6
- let nextToken: string | undefined = undefined
6
+ let nextToken: string | undefined
7
7
  do {
8
8
  const { bots, meta } = await client.listBots({ nextToken })
9
- allBots = allBots.concat(bots)
9
+ allBots = [...allBots, ...bots]
10
10
  nextToken = meta.nextToken
11
11
  } while (nextToken)
12
12
  return allBots
@@ -15,10 +15,10 @@ export const fetchAllBots = async (client: Client): Promise<ApiBot[]> => {
15
15
  export type ApiIntegration = Awaited<ReturnType<Client['listIntegrations']>>['integrations'][0]
16
16
  export const fetchAllIntegrations = async (client: Client): Promise<ApiIntegration[]> => {
17
17
  let allIntegrations: ApiIntegration[] = []
18
- let nextToken: string | undefined = undefined
18
+ let nextToken: string | undefined
19
19
  do {
20
20
  const { integrations, meta } = await client.listIntegrations({ nextToken })
21
- allIntegrations = allIntegrations.concat(integrations)
21
+ allIntegrations = [...allIntegrations, ...integrations]
22
22
  nextToken = meta.nextToken
23
23
  } while (nextToken)
24
24
  return allIntegrations
@@ -27,7 +27,7 @@ export const createDeployBot: Test = {
27
27
  ...creds,
28
28
  }
29
29
 
30
- const client = new Client({ host: creds.apiUrl, token: creds.token, workspaceId: creds.workspaceId })
30
+ const client = new Client({ apiUrl: creds.apiUrl, token: creds.token, workspaceId: creds.workspaceId })
31
31
 
32
32
  await impl.init({ ...argv, workDir: baseDir, name: botName, type: 'bot' }).then(utils.handleExitCode)
33
33
  await utils.fixBotpressDependencies({ workDir: botDir, target: dependencies })
@@ -28,7 +28,7 @@ export const createDeployIntegration: Test = {
28
28
  ...creds,
29
29
  }
30
30
 
31
- const client = new Client({ host: creds.apiUrl, token: creds.token, workspaceId: creds.workspaceId })
31
+ const client = new Client({ apiUrl: creds.apiUrl, token: creds.token, workspaceId: creds.workspaceId })
32
32
 
33
33
  await impl
34
34
  .init({ ...argv, workDir: baseDir, name: integrationName, type: 'integration' })
@@ -38,13 +38,14 @@ export const devBot: Test = {
38
38
  await utils.sleep(5000)
39
39
 
40
40
  const allProcess = await findProcess('port', PORT)
41
- if (allProcess.length === 0) {
42
- throw new Error(`Expected to find a process listening on port ${PORT}`)
43
- }
41
+
42
+ const [botProcess] = allProcess
44
43
  if (allProcess.length > 1) {
45
44
  throw new Error(`Expected to find only one process listening on port ${PORT}`)
46
45
  }
47
- const botProcess = allProcess[0]
46
+ if (!botProcess) {
47
+ throw new Error(`Expected to find a process listening on port ${PORT}`)
48
+ }
48
49
 
49
50
  /**
50
51
  * TODO:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botpress/cli",
3
- "version": "0.2.9",
3
+ "version": "0.3.2",
4
4
  "description": "Botpress CLI",
5
5
  "scripts": {
6
6
  "build": "pnpm run bundle && pnpm run template:gen",
@@ -20,9 +20,10 @@
20
20
  },
21
21
  "main": "dist/index.js",
22
22
  "dependencies": {
23
- "@botpress/client": "0.3.2",
23
+ "@botpress/client": "0.3.4",
24
24
  "@bpinternal/tunnel": "^0.1.0",
25
25
  "@bpinternal/yargs-extra": "^0.0.3",
26
+ "@bpinternal/zod-to-json-schema": "^3.21.4",
26
27
  "@parcel/watcher": "^2.1.0",
27
28
  "@types/lodash": "^4.14.191",
28
29
  "@types/node": "^18.11.17",
@@ -43,13 +44,13 @@
43
44
  "uuid": "^9.0.0",
44
45
  "verror": "^1.10.1",
45
46
  "winston": "^3.8.2",
46
- "zod": "^3.20.6",
47
- "zod-to-json-schema": "^3.20.1"
47
+ "zod": "^3.20.6"
48
48
  },
49
49
  "devDependencies": {
50
- "@botpress/sdk": "0.2.3",
50
+ "@botpress/sdk": "0.3.2",
51
51
  "@bpinternal/log4bot": "^0.0.4",
52
52
  "@types/bluebird": "^3.5.38",
53
+ "@types/json-schema": "^7.0.11",
53
54
  "@types/prompts": "^2.0.14",
54
55
  "@types/semver": "^7.3.11",
55
56
  "@types/tmp": "^0.2.3",
@@ -8,8 +8,8 @@
8
8
  "author": "",
9
9
  "license": "MIT",
10
10
  "dependencies": {
11
- "@botpress/client": "0.3.2",
12
- "@botpress/sdk": "0.2.3",
11
+ "@botpress/client": "0.3.4",
12
+ "@botpress/sdk": "0.3.2",
13
13
  "zod": "^3.20.6"
14
14
  },
15
15
  "devDependencies": {
@@ -1,24 +1,11 @@
1
- import type { Client } from '@botpress/client'
2
- import { Bot, messages } from '@botpress/sdk'
3
- import type { z } from 'zod'
1
+ import { Bot } from '@botpress/sdk'
2
+ import { z } from 'zod'
4
3
  // import * as botpress from '.botpress' /** uncomment to get generated code */
5
4
 
6
- type DefaultMessages = typeof messages.defaults
7
- type DefaultMessageType = keyof DefaultMessages
8
- type DefaultMessagePayload<T extends DefaultMessageType> = z.infer<DefaultMessages[T]['schema']>
9
-
10
- type CreateMessageProps = Parameters<Client['createMessage']>[0]
11
- type CreateMessageBody<T extends DefaultMessageType> = Omit<CreateMessageProps, 'type' | 'payload'> & {
12
- type: T
13
- payload: DefaultMessagePayload<T>
14
- }
15
-
16
- const logger = console
17
-
18
5
  const bot = new Bot({
19
- integrations: [],
6
+ integrations: {},
20
7
  configuration: {
21
- schema: {},
8
+ schema: z.object({}),
22
9
  },
23
10
  states: {},
24
11
  events: {},
@@ -26,7 +13,7 @@ const bot = new Bot({
26
13
  })
27
14
 
28
15
  bot.message(async ({ message, client, ctx }) => {
29
- logger.info('Received message', message)
16
+ console.info('Received message', message)
30
17
 
31
18
  await client.createMessage({
32
19
  conversationId: message.conversationId,
@@ -36,9 +23,9 @@ bot.message(async ({ message, client, ctx }) => {
36
23
  payload: {
37
24
  text: `You said: ${message.payload.text}`,
38
25
  },
39
- } satisfies CreateMessageBody<'text'>)
26
+ })
40
27
 
41
- logger.info('text message sent')
28
+ console.info('text message sent')
42
29
  })
43
30
 
44
31
  export default bot
@@ -2,6 +2,5 @@
2
2
  // This file is generated
3
3
  // Do not edit this file
4
4
 
5
-
6
5
  export type Actions = {
7
6
  }
@@ -2,39 +2,11 @@
2
2
  // This file is generated
3
3
  // Do not edit this file
4
4
 
5
- import type * as text from "./text";
6
- export * as text from "./text";
7
- import type * as markdown from "./markdown";
8
- export * as markdown from "./markdown";
9
- import type * as image from "./image";
10
- export * as image from "./image";
11
- import type * as audio from "./audio";
12
- export * as audio from "./audio";
13
- import type * as video from "./video";
14
- export * as video from "./video";
15
- import type * as file from "./file";
16
- export * as file from "./file";
17
- import type * as location from "./location";
18
- export * as location from "./location";
19
- import type * as carousel from "./carousel";
20
- export * as carousel from "./carousel";
21
- import type * as card from "./card";
22
- export * as card from "./card";
23
- import type * as dropdown from "./dropdown";
24
- export * as dropdown from "./dropdown";
25
- import type * as choice from "./choice";
26
- export * as choice from "./choice";
5
+ import { Messages } from './messages/index'
6
+ export * from './messages/index'
27
7
 
28
8
  export type ChannelChannel = {
29
- text: text.Text;
30
- markdown: markdown.Markdown;
31
- image: image.Image;
32
- audio: audio.Audio;
33
- video: video.Video;
34
- file: file.File;
35
- location: location.Location;
36
- carousel: carousel.Carousel;
37
- card: card.Card;
38
- dropdown: dropdown.Dropdown;
39
- choice: choice.Choice;
40
- }
9
+ messages: Messages
10
+ message: { "tags": {} }
11
+ conversation: { "tags": {}, "creation": { "enabled": false, "requiredTags": [] } }
12
+ }
@@ -1,4 +1,4 @@
1
- /* eslint-disable */
1
+ /* tslint:disable */
2
2
  /**
3
3
  * This file was automatically generated by json-schema-to-typescript.
4
4
  * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
@@ -1,4 +1,4 @@
1
- /* eslint-disable */
1
+ /* tslint:disable */
2
2
  /**
3
3
  * This file was automatically generated by json-schema-to-typescript.
4
4
  * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
@@ -1,4 +1,4 @@
1
- /* eslint-disable */
1
+ /* tslint:disable */
2
2
  /**
3
3
  * This file was automatically generated by json-schema-to-typescript.
4
4
  * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
@@ -1,4 +1,4 @@
1
- /* eslint-disable */
1
+ /* tslint:disable */
2
2
  /**
3
3
  * This file was automatically generated by json-schema-to-typescript.
4
4
  * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
@@ -1,4 +1,4 @@
1
- /* eslint-disable */
1
+ /* tslint:disable */
2
2
  /**
3
3
  * This file was automatically generated by json-schema-to-typescript.
4
4
  * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
@@ -1,4 +1,4 @@
1
- /* eslint-disable */
1
+ /* tslint:disable */
2
2
  /**
3
3
  * This file was automatically generated by json-schema-to-typescript.
4
4
  * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
@@ -1,4 +1,4 @@
1
- /* eslint-disable */
1
+ /* tslint:disable */
2
2
  /**
3
3
  * This file was automatically generated by json-schema-to-typescript.
4
4
  * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
@@ -0,0 +1,39 @@
1
+ /* tslint:disable */
2
+ // This file is generated
3
+ // Do not edit this file
4
+ import * as text from "./text";
5
+ export * as text from "./text";
6
+ import * as markdown from "./markdown";
7
+ export * as markdown from "./markdown";
8
+ import * as image from "./image";
9
+ export * as image from "./image";
10
+ import * as audio from "./audio";
11
+ export * as audio from "./audio";
12
+ import * as video from "./video";
13
+ export * as video from "./video";
14
+ import * as file from "./file";
15
+ export * as file from "./file";
16
+ import * as location from "./location";
17
+ export * as location from "./location";
18
+ import * as carousel from "./carousel";
19
+ export * as carousel from "./carousel";
20
+ import * as card from "./card";
21
+ export * as card from "./card";
22
+ import * as dropdown from "./dropdown";
23
+ export * as dropdown from "./dropdown";
24
+ import * as choice from "./choice";
25
+ export * as choice from "./choice";
26
+
27
+ export type Messages = {
28
+ text: text.Text;
29
+ markdown: markdown.Markdown;
30
+ image: image.Image;
31
+ audio: audio.Audio;
32
+ video: video.Video;
33
+ file: file.File;
34
+ location: location.Location;
35
+ carousel: carousel.Carousel;
36
+ card: card.Card;
37
+ dropdown: dropdown.Dropdown;
38
+ choice: choice.Choice;
39
+ }
@@ -1,4 +1,4 @@
1
- /* eslint-disable */
1
+ /* tslint:disable */
2
2
  /**
3
3
  * This file was automatically generated by json-schema-to-typescript.
4
4
  * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
@@ -1,4 +1,4 @@
1
- /* eslint-disable */
1
+ /* tslint:disable */
2
2
  /**
3
3
  * This file was automatically generated by json-schema-to-typescript.
4
4
  * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
@@ -1,4 +1,4 @@
1
- /* eslint-disable */
1
+ /* tslint:disable */
2
2
  /**
3
3
  * This file was automatically generated by json-schema-to-typescript.
4
4
  * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
@@ -1,4 +1,4 @@
1
- /* eslint-disable */
1
+ /* tslint:disable */
2
2
  /**
3
3
  * This file was automatically generated by json-schema-to-typescript.
4
4
  * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
@@ -1,8 +1,7 @@
1
1
  /* tslint:disable */
2
2
  // This file is generated
3
3
  // Do not edit this file
4
-
5
- import type * as channel from "./channel/index";
4
+ import * as channel from "./channel/index";
6
5
  export * as channel from "./channel/index";
7
6
 
8
7
  export type Channels = {
@@ -1,4 +1,4 @@
1
- /* eslint-disable */
1
+ /* tslint:disable */
2
2
  /**
3
3
  * This file was automatically generated by json-schema-to-typescript.
4
4
  * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
@@ -6,5 +6,5 @@
6
6
  */
7
7
 
8
8
  export interface Configuration {
9
- [k: string]: unknown;
9
+ [k: string]: any;
10
10
  }
@@ -2,6 +2,5 @@
2
2
  // This file is generated
3
3
  // Do not edit this file
4
4
 
5
-
6
5
  export type Events = {
7
6
  }
@@ -1,18 +1,36 @@
1
1
  /* tslint:disable */
2
2
  // This file is generated
3
3
  // Do not edit this file
4
+ /* tslint:disable */
5
+ // This file is generated
6
+ // Do not edit this file
7
+
8
+ import * as sdk from "@botpress/sdk"
9
+
10
+ import type * as configuration from "./configuration/index"
11
+ import type * as actions from "./actions/index"
12
+ import type * as channels from "./channels/index"
13
+ import type * as events from "./events/index"
14
+ import type * as states from "./states/index"
15
+ export * as configuration from "./configuration/index"
16
+ export * as actions from "./actions/index"
17
+ export * as channels from "./channels/index"
18
+ export * as events from "./events/index"
19
+ export * as states from "./states/index"
20
+
21
+ type TIntegration = {
22
+ name: "empty-integration"
23
+ version: "0.2.0"
24
+ configuration: configuration.Configuration
25
+ actions: actions.Actions
26
+ channels: channels.Channels
27
+ events: events.Events
28
+ states: states.States
29
+ user: { "tags": {}, "creation": { "enabled": false, "requiredTags": [] } }
30
+ }
4
31
 
5
- import * as sdk from "@botpress/sdk";
32
+ export type IntegrationProps = sdk.IntegrationProps<TIntegration>
6
33
 
7
- import type * as configuration from "./configuration";
8
- import type * as actions from "./actions/index";
9
- import type * as channels from "./channels/index";
10
- import type * as events from "./events/index";
11
- export * as configuration from "./configuration";
12
- export * as actions from "./actions/index";
13
- export * as channels from "./channels/index";
14
- export * as events from "./events/index";
34
+ export class Integration extends sdk.Integration<TIntegration> {}
15
35
 
16
- export class Integration
17
- extends sdk.Integration<configuration.Configuration, actions.Actions, channels.Channels, events.Events> {}
18
- export type IntegrationProps = sdk.IntegrationProps<configuration.Configuration, actions.Actions, channels.Channels, events.Events>;
36
+ export type Client = sdk.IntegrationSpecificClient<TIntegration>
@@ -0,0 +1,6 @@
1
+ /* tslint:disable */
2
+ // This file is generated
3
+ // Do not edit this file
4
+
5
+ export type States = {
6
+ }
@@ -1,7 +1,6 @@
1
1
  /* tslint:disable */
2
2
  // This file is generated
3
3
  // Do not edit this file
4
-
5
4
  class Secrets {
6
5
  }
7
6
  export const secrets = new Secrets()
@@ -8,8 +8,8 @@
8
8
  "author": "",
9
9
  "license": "MIT",
10
10
  "dependencies": {
11
- "@botpress/client": "0.3.2",
12
- "@botpress/sdk": "0.2.3",
11
+ "@botpress/client": "0.3.4",
12
+ "@botpress/sdk": "0.3.2",
13
13
  "zod": "^3.20.6"
14
14
  },
15
15
  "devDependencies": {
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/code-generation/action.ts"],
4
- "sourcesContent": ["import { compile } from 'json-schema-to-typescript'\nimport { casing } from '../utils'\nimport { Module, ModuleDef, ReExportTypeModule } from './module'\nimport type * as types from './typings'\n\ntype ActionInput = types.Action['input']\ntype ActionOutput = types.Action['output']\n\nexport class ActionInputModule extends Module {\n public static async create(input: ActionInput): Promise<ActionInputModule> {\n const schema = input.schema ?? {}\n const filename = 'input.ts'\n const def: ModuleDef = {\n path: filename,\n exportName: 'Input',\n content: await compile(schema, filename),\n }\n return new ActionInputModule(def)\n }\n}\n\nexport class ActionOutputModule extends Module {\n public static async create(output: ActionOutput): Promise<ActionOutputModule> {\n const schema = output.schema ?? {}\n const filename = 'output.ts'\n const def: ModuleDef = {\n path: filename,\n exportName: 'Output',\n content: await compile(schema, filename),\n }\n return new ActionOutputModule(def)\n }\n}\n\nexport class ActionModule extends ReExportTypeModule {\n public static async create(actionName: string, action: types.Action): Promise<ActionModule> {\n const inputModule = await ActionInputModule.create(action.input ?? {})\n const outputModule = await ActionOutputModule.create(action.output ?? {})\n\n const inst = new ActionModule({\n exportName: `Action${casing.to.pascalCase(actionName)}`,\n })\n\n inst.pushDep(inputModule)\n inst.pushDep(outputModule)\n\n return inst\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uCAAwB;AACxB,mBAAuB;AACvB,oBAAsD;AAM/C,MAAM,0BAA0B,qBAAO;AAAA,EAC5C,aAAoB,OAAO,OAAgD;AACzE,UAAM,SAAS,MAAM,UAAU,CAAC;AAChC,UAAM,WAAW;AACjB,UAAM,MAAiB;AAAA,MACrB,MAAM;AAAA,MACN,YAAY;AAAA,MACZ,SAAS,UAAM,0CAAQ,QAAQ,QAAQ;AAAA,IACzC;AACA,WAAO,IAAI,kBAAkB,GAAG;AAAA,EAClC;AACF;AAEO,MAAM,2BAA2B,qBAAO;AAAA,EAC7C,aAAoB,OAAO,QAAmD;AAC5E,UAAM,SAAS,OAAO,UAAU,CAAC;AACjC,UAAM,WAAW;AACjB,UAAM,MAAiB;AAAA,MACrB,MAAM;AAAA,MACN,YAAY;AAAA,MACZ,SAAS,UAAM,0CAAQ,QAAQ,QAAQ;AAAA,IACzC;AACA,WAAO,IAAI,mBAAmB,GAAG;AAAA,EACnC;AACF;AAEO,MAAM,qBAAqB,iCAAmB;AAAA,EACnD,aAAoB,OAAO,YAAoB,QAA6C;AAC1F,UAAM,cAAc,MAAM,kBAAkB,OAAO,OAAO,SAAS,CAAC,CAAC;AACrE,UAAM,eAAe,MAAM,mBAAmB,OAAO,OAAO,UAAU,CAAC,CAAC;AAExE,UAAM,OAAO,IAAI,aAAa;AAAA,MAC5B,YAAY,SAAS,oBAAO,GAAG,WAAW,UAAU;AAAA,IACtD,CAAC;AAED,SAAK,QAAQ,WAAW;AACxB,SAAK,QAAQ,YAAY;AAEzB,WAAO;AAAA,EACT;AACF;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/code-generation/channel.ts"],
4
- "sourcesContent": ["import bluebird from 'bluebird'\nimport { casing } from '../utils'\nimport { MessageModule } from './message'\nimport { ReExportTypeModule } from './module'\nimport type { Channel } from './typings'\n\nexport class ChannelModule extends ReExportTypeModule {\n public static async create(channelName: string, channel: Channel): Promise<ChannelModule> {\n const messages = channel.messages ?? {}\n const messageModules = await bluebird.map(Object.entries(messages), ([messageName, message]) =>\n MessageModule.create(messageName, message)\n )\n\n const inst = new ChannelModule({\n exportName: `Channel${casing.to.pascalCase(channelName)}`,\n })\n inst.pushDep(...messageModules)\n return inst\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAqB;AACrB,mBAAuB;AACvB,qBAA8B;AAC9B,oBAAmC;AAG5B,MAAM,sBAAsB,iCAAmB;AAAA,EACpD,aAAoB,OAAO,aAAqB,SAA0C;AACxF,UAAM,WAAW,QAAQ,YAAY,CAAC;AACtC,UAAM,iBAAiB,MAAM,gBAAAA,QAAS;AAAA,MAAI,OAAO,QAAQ,QAAQ;AAAA,MAAG,CAAC,CAAC,aAAa,OAAO,MACxF,6BAAc,OAAO,aAAa,OAAO;AAAA,IAC3C;AAEA,UAAM,OAAO,IAAI,cAAc;AAAA,MAC7B,YAAY,UAAU,oBAAO,GAAG,WAAW,WAAW;AAAA,IACxD,CAAC;AACD,SAAK,QAAQ,GAAG,cAAc;AAC9B,WAAO;AAAA,EACT;AACF;",
6
- "names": ["bluebird"]
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/code-generation/configuration.ts"],
4
- "sourcesContent": ["import { compile } from 'json-schema-to-typescript'\nimport { Module } from './module'\nimport type * as types from './typings'\n\nexport class ConfigurationModule extends Module {\n public static async create(configuration: types.Config): Promise<ConfigurationModule> {\n const schema = configuration.schema ?? {}\n const filename = 'configuration'\n return new ConfigurationModule({\n path: `${filename}.ts`,\n exportName: 'Configuration',\n content: await compile(schema, filename),\n })\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uCAAwB;AACxB,oBAAuB;AAGhB,MAAM,4BAA4B,qBAAO;AAAA,EAC9C,aAAoB,OAAO,eAA2D;AACpF,UAAM,SAAS,cAAc,UAAU,CAAC;AACxC,UAAM,WAAW;AACjB,WAAO,IAAI,oBAAoB;AAAA,MAC7B,MAAM,GAAG;AAAA,MACT,YAAY;AAAA,MACZ,SAAS,UAAM,0CAAQ,QAAQ,QAAQ;AAAA,IACzC,CAAC;AAAA,EACH;AACF;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/code-generation/event.ts"],
4
- "sourcesContent": ["import { compile } from 'json-schema-to-typescript'\nimport { casing } from '../utils'\nimport { Module, ModuleDef } from './module'\nimport type { Event } from './typings'\n\nexport class EventModule extends Module {\n public static async create(name: string, event: Event): Promise<EventModule> {\n const schema = event.schema ?? {}\n const def: ModuleDef = {\n path: `${name}.ts`,\n exportName: casing.to.pascalCase(name),\n content: await compile(schema, name),\n }\n return new EventModule(def)\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uCAAwB;AACxB,mBAAuB;AACvB,oBAAkC;AAG3B,MAAM,oBAAoB,qBAAO;AAAA,EACtC,aAAoB,OAAO,MAAc,OAAoC;AAC3E,UAAM,SAAS,MAAM,UAAU,CAAC;AAChC,UAAM,MAAiB;AAAA,MACrB,MAAM,GAAG;AAAA,MACT,YAAY,oBAAO,GAAG,WAAW,IAAI;AAAA,MACrC,SAAS,UAAM,0CAAQ,QAAQ,IAAI;AAAA,IACrC;AACA,WAAO,IAAI,YAAY,GAAG;AAAA,EAC5B;AACF;",
6
- "names": []
7
- }