@botpress/cli 3.4.0 ā 3.5.1
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 +11 -11
- package/dist/code-generation/bot-implementation/bot-implementation.js +9 -0
- package/dist/code-generation/bot-implementation/bot-implementation.js.map +2 -2
- package/dist/code-generation/bot-implementation/bot-plugins/index.js +3 -3
- package/dist/code-generation/bot-implementation/bot-plugins/index.js.map +2 -2
- package/dist/code-generation/bot-implementation/bot-plugins/plugin-module.js +4 -4
- package/dist/code-generation/bot-implementation/bot-plugins/plugin-module.js.map +2 -2
- package/dist/code-generation/bot-implementation/bot-typings/index.js +11 -2
- package/dist/code-generation/bot-implementation/bot-typings/index.js.map +2 -2
- package/dist/code-generation/bot-implementation/bot-typings/workflows-module.js +104 -0
- package/dist/code-generation/bot-implementation/bot-typings/workflows-module.js.map +7 -0
- package/dist/code-generation/plugin-implementation/plugin-implementation.js +9 -0
- package/dist/code-generation/plugin-implementation/plugin-implementation.js.map +2 -2
- package/dist/code-generation/plugin-implementation/plugin-typings/index.js +24 -11
- package/dist/code-generation/plugin-implementation/plugin-typings/index.js.map +2 -2
- package/dist/code-generation/plugin-implementation/plugin-typings/workflows-module.js +104 -0
- package/dist/code-generation/plugin-implementation/plugin-typings/workflows-module.js.map +7 -0
- package/dist/code-generation/typings.js.map +1 -1
- package/dist/command-implementations/deploy-command.js +1 -2
- package/dist/command-implementations/deploy-command.js.map +2 -2
- package/dist/sdk/validate-bot.js +5 -1
- package/dist/sdk/validate-bot.js.map +2 -2
- package/dist/sdk/validate-bot.test.js +131 -0
- package/dist/sdk/validate-bot.test.js.map +7 -0
- package/package.json +3 -3
- package/templates/empty-bot/.botpress/implementation/index.ts +9 -0
- package/templates/empty-bot/.botpress/implementation/typings/index.ts +3 -0
- package/templates/empty-bot/.botpress/implementation/typings/workflows/index.ts +6 -0
- package/templates/empty-bot/package.json +2 -2
- package/templates/empty-integration/package.json +2 -2
- package/templates/empty-plugin/.botpress/implementation/index.ts +9 -0
- package/templates/empty-plugin/.botpress/implementation/typings/index.ts +5 -0
- package/templates/empty-plugin/.botpress/implementation/typings/workflows/index.ts +6 -0
- package/templates/empty-plugin/package.json +1 -1
- package/templates/hello-world/package.json +2 -2
- package/templates/webhook-message/package.json +2 -2
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
|
|
2
|
-
> @botpress/cli@3.
|
|
2
|
+
> @botpress/cli@3.5.1 build /home/runner/work/botpress/botpress/packages/cli
|
|
3
3
|
> pnpm run bundle && pnpm run template:gen
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
> @botpress/cli@3.
|
|
6
|
+
> @botpress/cli@3.5.1 bundle /home/runner/work/botpress/botpress/packages/cli
|
|
7
7
|
> ts-node -T build.ts
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
> @botpress/cli@3.
|
|
10
|
+
> @botpress/cli@3.5.1 template:gen /home/runner/work/botpress/botpress/packages/cli
|
|
11
11
|
> pnpm -r --stream -F @bp-templates/* exec bp gen
|
|
12
12
|
|
|
13
|
-
š¤ Botpress CLI v3.
|
|
14
|
-
š¤ Botpress CLI v3.
|
|
15
|
-
š¤ Botpress CLI v3.
|
|
16
|
-
š¤ Botpress CLI v3.
|
|
17
|
-
[2K[1Gā Generating typings for bot...[2K[1Gā Typings available at .botpress
|
|
18
|
-
[2K[1Gā Generating typings for integration hello-world...[2K[1Gā Typings available at .botpress
|
|
19
|
-
[2K[1Gā Generating typings for plugin empty-plugin...[2K[1Gā Typings available at .botpress
|
|
13
|
+
š¤ Botpress CLI v3.5.1
|
|
14
|
+
š¤ Botpress CLI v3.5.1
|
|
15
|
+
š¤ Botpress CLI v3.5.1
|
|
16
|
+
š¤ Botpress CLI v3.5.1
|
|
20
17
|
[2K[1Gā Generating typings for integration empty-integration...[2K[1Gā Typings available at .botpress
|
|
21
|
-
|
|
18
|
+
[2K[1Gā Generating typings for bot...[2K[1Gā Typings available at .botpress
|
|
19
|
+
[2K[1Gā Generating typings for integration hello-world...[2K[1Gā Generating typings for plugin empty-plugin...[2K[1Gā Typings available at .botpress
|
|
20
|
+
[2K[1Gā Typings available at .botpress
|
|
21
|
+
š¤ Botpress CLI v3.5.1
|
|
22
22
|
[2K[1Gā Generating typings for integration webhook-message...[2K[1Gā Typings available at .botpress
|
|
@@ -95,9 +95,18 @@ class BotImplementationModule extends import_module.Module {
|
|
|
95
95
|
"export type MessageHandlers = Required<{",
|
|
96
96
|
" [K in keyof BotHandlers['messageHandlers']]: NonNullable<BotHandlers['messageHandlers'][K]>[number]",
|
|
97
97
|
"}>",
|
|
98
|
+
"export type WorkflowHandlers = {",
|
|
99
|
+
" [TWorkflowName in keyof Required<BotHandlers['workflowHandlers'][keyof BotHandlers['workflowHandlers']]>]:",
|
|
100
|
+
" Required<BotHandlers['workflowHandlers'][keyof BotHandlers['workflowHandlers']]>[TWorkflowName] extends",
|
|
101
|
+
" ({ handler: infer U })[] ? U : never",
|
|
102
|
+
"}",
|
|
98
103
|
"",
|
|
99
104
|
"export type MessageHandlerProps = Parameters<MessageHandlers['*']>[0]",
|
|
100
105
|
"export type EventHandlerProps = Parameters<EventHandlers['*']>[0]",
|
|
106
|
+
"export type WorkflowHandlerProps = {",
|
|
107
|
+
" [TWorkflowName in keyof WorkflowHandlers]: WorkflowHandlers[TWorkflowName] extends",
|
|
108
|
+
" (..._: infer U) => any ? U[0] : never",
|
|
109
|
+
"}",
|
|
101
110
|
"",
|
|
102
111
|
"export type Client = (MessageHandlerProps | EventHandlerProps)['client']",
|
|
103
112
|
"export type ClientOperation = keyof {",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/code-generation/bot-implementation/bot-implementation.ts"],
|
|
4
|
-
"sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport * as consts from '../consts'\nimport { Module } from '../module'\nimport { BotPluginsIndexModule } from './bot-plugins'\nimport { BotTypingsModule } from './bot-typings'\n\nexport class BotImplementationModule extends Module {\n private _typingsModule: BotTypingsModule\n private _pluginsModule: BotPluginsIndexModule\n\n public constructor(bot: sdk.BotDefinition) {\n super({\n exportName: 'Bot',\n path: consts.INDEX_FILE,\n })\n\n this._typingsModule = new BotTypingsModule(bot)\n this._typingsModule.unshift('typings')\n this.pushDep(this._typingsModule)\n\n this._pluginsModule = new BotPluginsIndexModule(bot)\n this._pluginsModule.unshift(consts.fromOutDir.pluginsDir)\n this.pushDep(this._pluginsModule)\n }\n\n public async getContent() {\n const {\n //\n _typingsModule: typingsModule,\n _pluginsModule: pluginsModule,\n } = this\n\n const typingsImport = typingsModule.import(this)\n const pluginsImport = pluginsModule.import(this)\n\n return [\n consts.GENERATED_HEADER,\n 'import * as sdk from \"@botpress/sdk\"',\n `import * as ${typingsModule.name} from \"./${typingsImport}\"`,\n `import * as ${pluginsModule.name} from \"./${pluginsImport}\"`,\n '',\n `export * from \"./${typingsImport}\"`,\n `export * from \"./${pluginsImport}\"`,\n '',\n `type TPlugins = ${pluginsModule.name}.TPlugins`,\n `type TBot = sdk.DefaultBot<${typingsModule.name}.${typingsModule.exportName}>`,\n '',\n 'export type BotProps = {',\n ' actions: sdk.BotProps<TBot, TPlugins>[\"actions\"]',\n '}',\n '',\n 'export class Bot extends sdk.Bot<TBot, TPlugins> {',\n ' public constructor(props: BotProps) {',\n ' super({',\n ' actions: props.actions,',\n ` plugins: ${pluginsModule.name}.${pluginsModule.exportName}`,\n ' })',\n ' }',\n '}',\n '',\n '// extra types',\n '',\n 'type AsyncFunction = (...args: any[]) => Promise<any>',\n '',\n 'export type BotHandlers = sdk.BotHandlers<TBot>',\n '',\n 'export type EventHandlers = Required<{',\n \" [K in keyof BotHandlers['eventHandlers']]: NonNullable<BotHandlers['eventHandlers'][K]>[number]\",\n '}>',\n 'export type MessageHandlers = Required<{',\n \" [K in keyof BotHandlers['messageHandlers']]: NonNullable<BotHandlers['messageHandlers'][K]>[number]\",\n '}>',\n '',\n \"export type MessageHandlerProps = Parameters<MessageHandlers['*']>[0]\",\n \"export type EventHandlerProps = Parameters<EventHandlers['*']>[0]\",\n '',\n \"export type Client = (MessageHandlerProps | EventHandlerProps)['client']\",\n 'export type ClientOperation = keyof {',\n ' [K in keyof Client as Client[K] extends AsyncFunction ? K : never]: null',\n '}',\n 'export type ClientInputs = {',\n ' [K in ClientOperation]: Parameters<Client[K]>[0]',\n '}',\n 'export type ClientOutputs = {',\n ' [K in ClientOperation]: Awaited<ReturnType<Client[K]>>',\n '}',\n ].join('\\n')\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,aAAwB;AACxB,oBAAuB;AACvB,yBAAsC;AACtC,yBAAiC;AAE1B,MAAM,gCAAgC,qBAAO;AAAA,EAC1C;AAAA,EACA;AAAA,EAED,YAAY,KAAwB;AACzC,UAAM;AAAA,MACJ,YAAY;AAAA,MACZ,MAAM,OAAO;AAAA,IACf,CAAC;AAED,SAAK,iBAAiB,IAAI,oCAAiB,GAAG;AAC9C,SAAK,eAAe,QAAQ,SAAS;AACrC,SAAK,QAAQ,KAAK,cAAc;AAEhC,SAAK,iBAAiB,IAAI,yCAAsB,GAAG;AACnD,SAAK,eAAe,QAAQ,OAAO,WAAW,UAAU;AACxD,SAAK,QAAQ,KAAK,cAAc;AAAA,EAClC;AAAA,EAEA,MAAa,aAAa;AACxB,UAAM;AAAA;AAAA,MAEJ,gBAAgB;AAAA,MAChB,gBAAgB;AAAA,IAClB,IAAI;AAEJ,UAAM,gBAAgB,cAAc,OAAO,IAAI;AAC/C,UAAM,gBAAgB,cAAc,OAAO,IAAI;AAE/C,WAAO;AAAA,MACL,OAAO;AAAA,MACP;AAAA,MACA,eAAe,cAAc,gBAAgB;AAAA,MAC7C,eAAe,cAAc,gBAAgB;AAAA,MAC7C;AAAA,MACA,oBAAoB;AAAA,MACpB,oBAAoB;AAAA,MACpB;AAAA,MACA,mBAAmB,cAAc;AAAA,MACjC,8BAA8B,cAAc,QAAQ,cAAc;AAAA,MAClE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,kBAAkB,cAAc,QAAQ,cAAc;AAAA,MACtD;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,EAAE,KAAK,IAAI;AAAA,EACb;AACF;",
|
|
4
|
+
"sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport * as consts from '../consts'\nimport { Module } from '../module'\nimport { BotPluginsIndexModule } from './bot-plugins'\nimport { BotTypingsModule } from './bot-typings'\n\nexport class BotImplementationModule extends Module {\n private _typingsModule: BotTypingsModule\n private _pluginsModule: BotPluginsIndexModule\n\n public constructor(bot: sdk.BotDefinition) {\n super({\n exportName: 'Bot',\n path: consts.INDEX_FILE,\n })\n\n this._typingsModule = new BotTypingsModule(bot)\n this._typingsModule.unshift('typings')\n this.pushDep(this._typingsModule)\n\n this._pluginsModule = new BotPluginsIndexModule(bot)\n this._pluginsModule.unshift(consts.fromOutDir.pluginsDir)\n this.pushDep(this._pluginsModule)\n }\n\n public async getContent() {\n const {\n //\n _typingsModule: typingsModule,\n _pluginsModule: pluginsModule,\n } = this\n\n const typingsImport = typingsModule.import(this)\n const pluginsImport = pluginsModule.import(this)\n\n return [\n consts.GENERATED_HEADER,\n 'import * as sdk from \"@botpress/sdk\"',\n `import * as ${typingsModule.name} from \"./${typingsImport}\"`,\n `import * as ${pluginsModule.name} from \"./${pluginsImport}\"`,\n '',\n `export * from \"./${typingsImport}\"`,\n `export * from \"./${pluginsImport}\"`,\n '',\n `type TPlugins = ${pluginsModule.name}.TPlugins`,\n `type TBot = sdk.DefaultBot<${typingsModule.name}.${typingsModule.exportName}>`,\n '',\n 'export type BotProps = {',\n ' actions: sdk.BotProps<TBot, TPlugins>[\"actions\"]',\n '}',\n '',\n 'export class Bot extends sdk.Bot<TBot, TPlugins> {',\n ' public constructor(props: BotProps) {',\n ' super({',\n ' actions: props.actions,',\n ` plugins: ${pluginsModule.name}.${pluginsModule.exportName}`,\n ' })',\n ' }',\n '}',\n '',\n '// extra types',\n '',\n 'type AsyncFunction = (...args: any[]) => Promise<any>',\n '',\n 'export type BotHandlers = sdk.BotHandlers<TBot>',\n '',\n 'export type EventHandlers = Required<{',\n \" [K in keyof BotHandlers['eventHandlers']]: NonNullable<BotHandlers['eventHandlers'][K]>[number]\",\n '}>',\n 'export type MessageHandlers = Required<{',\n \" [K in keyof BotHandlers['messageHandlers']]: NonNullable<BotHandlers['messageHandlers'][K]>[number]\",\n '}>',\n 'export type WorkflowHandlers = {',\n \" [TWorkflowName in keyof Required<BotHandlers['workflowHandlers'][keyof BotHandlers['workflowHandlers']]>]:\",\n \" Required<BotHandlers['workflowHandlers'][keyof BotHandlers['workflowHandlers']]>[TWorkflowName] extends\",\n ' ({ handler: infer U })[] ? U : never',\n '}',\n '',\n \"export type MessageHandlerProps = Parameters<MessageHandlers['*']>[0]\",\n \"export type EventHandlerProps = Parameters<EventHandlers['*']>[0]\",\n 'export type WorkflowHandlerProps = {',\n ' [TWorkflowName in keyof WorkflowHandlers]: WorkflowHandlers[TWorkflowName] extends',\n ' (..._: infer U) => any ? U[0] : never',\n '}',\n '',\n \"export type Client = (MessageHandlerProps | EventHandlerProps)['client']\",\n 'export type ClientOperation = keyof {',\n ' [K in keyof Client as Client[K] extends AsyncFunction ? K : never]: null',\n '}',\n 'export type ClientInputs = {',\n ' [K in ClientOperation]: Parameters<Client[K]>[0]',\n '}',\n 'export type ClientOutputs = {',\n ' [K in ClientOperation]: Awaited<ReturnType<Client[K]>>',\n '}',\n ].join('\\n')\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,aAAwB;AACxB,oBAAuB;AACvB,yBAAsC;AACtC,yBAAiC;AAE1B,MAAM,gCAAgC,qBAAO;AAAA,EAC1C;AAAA,EACA;AAAA,EAED,YAAY,KAAwB;AACzC,UAAM;AAAA,MACJ,YAAY;AAAA,MACZ,MAAM,OAAO;AAAA,IACf,CAAC;AAED,SAAK,iBAAiB,IAAI,oCAAiB,GAAG;AAC9C,SAAK,eAAe,QAAQ,SAAS;AACrC,SAAK,QAAQ,KAAK,cAAc;AAEhC,SAAK,iBAAiB,IAAI,yCAAsB,GAAG;AACnD,SAAK,eAAe,QAAQ,OAAO,WAAW,UAAU;AACxD,SAAK,QAAQ,KAAK,cAAc;AAAA,EAClC;AAAA,EAEA,MAAa,aAAa;AACxB,UAAM;AAAA;AAAA,MAEJ,gBAAgB;AAAA,MAChB,gBAAgB;AAAA,IAClB,IAAI;AAEJ,UAAM,gBAAgB,cAAc,OAAO,IAAI;AAC/C,UAAM,gBAAgB,cAAc,OAAO,IAAI;AAE/C,WAAO;AAAA,MACL,OAAO;AAAA,MACP;AAAA,MACA,eAAe,cAAc,gBAAgB;AAAA,MAC7C,eAAe,cAAc,gBAAgB;AAAA,MAC7C;AAAA,MACA,oBAAoB;AAAA,MACpB,oBAAoB;AAAA,MACpB;AAAA,MACA,mBAAmB,cAAc;AAAA,MACjC,8BAA8B,cAAc,QAAQ,cAAc;AAAA,MAClE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,kBAAkB,cAAc,QAAQ,cAAc;AAAA,MACtD;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,EAAE,KAAK,IAAI;AAAA,EACb;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -45,7 +45,7 @@ class BotPluginsIndexModule extends mod.Module {
|
|
|
45
45
|
const pluginsModules = [];
|
|
46
46
|
for (const plugin of Object.values(sdkBotDefinition.plugins ?? {})) {
|
|
47
47
|
const pluginModule = new import_plugin_module.BotPluginModule(plugin);
|
|
48
|
-
pluginModule.unshift(
|
|
48
|
+
pluginModule.unshift(pluginModule.pluginKey);
|
|
49
49
|
this.pushDep(pluginModule);
|
|
50
50
|
pluginsModules.push(pluginModule);
|
|
51
51
|
}
|
|
@@ -64,11 +64,11 @@ class BotPluginsIndexModule extends mod.Module {
|
|
|
64
64
|
...modules.map(({ importAlias, importFrom }) => `export * as ${importAlias} from "./${importFrom}";`),
|
|
65
65
|
"",
|
|
66
66
|
`export const ${this.exportName} = {`,
|
|
67
|
-
...modules.map(({ module: module2, importAlias }) => ` "${module2.
|
|
67
|
+
...modules.map(({ module: module2, importAlias }) => ` "${module2.pluginKey}": ${importAlias}.${module2.exportName},`),
|
|
68
68
|
"}",
|
|
69
69
|
"",
|
|
70
70
|
"export type TPlugins = {",
|
|
71
|
-
...modules.map(({ module: module2, importAlias }) => ` "${module2.
|
|
71
|
+
...modules.map(({ module: module2, importAlias }) => ` "${module2.pluginKey}": ${importAlias}.TPlugin;`),
|
|
72
72
|
"}"
|
|
73
73
|
].join("\n");
|
|
74
74
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/code-generation/bot-implementation/bot-plugins/index.ts"],
|
|
4
|
-
"sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport * as consts from '../../consts'\nimport * as mod from '../../module'\nimport * as strings from '../../strings'\nimport { BotPluginModule } from './plugin-module'\n\nexport class BotPluginsIndexModule extends mod.Module {\n private _pluginModules: BotPluginModule[]\n\n public constructor(sdkBotDefinition: sdk.BotDefinition) {\n super({\n path: consts.INDEX_FILE,\n exportName: 'plugins',\n })\n\n const pluginsModules: BotPluginModule[] = []\n for (const plugin of Object.values(sdkBotDefinition.plugins ?? {})) {\n const pluginModule = new BotPluginModule(plugin)\n pluginModule.unshift(
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,aAAwB;AACxB,UAAqB;AACrB,cAAyB;AACzB,2BAAgC;AAEzB,MAAM,8BAA8B,IAAI,OAAO;AAAA,EAC5C;AAAA,EAED,YAAY,kBAAqC;AACtD,UAAM;AAAA,MACJ,MAAM,OAAO;AAAA,MACb,YAAY;AAAA,IACd,CAAC;AAED,UAAM,iBAAoC,CAAC;AAC3C,eAAW,UAAU,OAAO,OAAO,iBAAiB,WAAW,CAAC,CAAC,GAAG;AAClE,YAAM,eAAe,IAAI,qCAAgB,MAAM;AAC/C,mBAAa,QAAQ,
|
|
4
|
+
"sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport * as consts from '../../consts'\nimport * as mod from '../../module'\nimport * as strings from '../../strings'\nimport { BotPluginModule } from './plugin-module'\n\nexport class BotPluginsIndexModule extends mod.Module {\n private _pluginModules: BotPluginModule[]\n\n public constructor(sdkBotDefinition: sdk.BotDefinition) {\n super({\n path: consts.INDEX_FILE,\n exportName: 'plugins',\n })\n\n const pluginsModules: BotPluginModule[] = []\n for (const plugin of Object.values(sdkBotDefinition.plugins ?? {})) {\n const pluginModule = new BotPluginModule(plugin)\n pluginModule.unshift(pluginModule.pluginKey)\n this.pushDep(pluginModule)\n pluginsModules.push(pluginModule)\n }\n\n this._pluginModules = pluginsModules\n }\n\n public async getContent(): Promise<string> {\n const modules = this._pluginModules.map((module) => ({\n importAlias: strings.importAlias(module.name),\n importFrom: module.import(this),\n module,\n }))\n\n return [\n consts.GENERATED_HEADER,\n 'import * as sdk from \"@botpress/sdk\"',\n ...modules.map(({ importAlias, importFrom }) => `import * as ${importAlias} from \"./${importFrom}\";`),\n ...modules.map(({ importAlias, importFrom }) => `export * as ${importAlias} from \"./${importFrom}\";`),\n '',\n `export const ${this.exportName} = {`,\n ...modules.map(({ module, importAlias }) => ` \"${module.pluginKey}\": ${importAlias}.${module.exportName},`),\n '}',\n '',\n 'export type TPlugins = {',\n ...modules.map(({ module, importAlias }) => ` \"${module.pluginKey}\": ${importAlias}.TPlugin;`),\n '}',\n ].join('\\n')\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,aAAwB;AACxB,UAAqB;AACrB,cAAyB;AACzB,2BAAgC;AAEzB,MAAM,8BAA8B,IAAI,OAAO;AAAA,EAC5C;AAAA,EAED,YAAY,kBAAqC;AACtD,UAAM;AAAA,MACJ,MAAM,OAAO;AAAA,MACb,YAAY;AAAA,IACd,CAAC;AAED,UAAM,iBAAoC,CAAC;AAC3C,eAAW,UAAU,OAAO,OAAO,iBAAiB,WAAW,CAAC,CAAC,GAAG;AAClE,YAAM,eAAe,IAAI,qCAAgB,MAAM;AAC/C,mBAAa,QAAQ,aAAa,SAAS;AAC3C,WAAK,QAAQ,YAAY;AACzB,qBAAe,KAAK,YAAY;AAAA,IAClC;AAEA,SAAK,iBAAiB;AAAA,EACxB;AAAA,EAEA,MAAa,aAA8B;AACzC,UAAM,UAAU,KAAK,eAAe,IAAI,CAACA,aAAY;AAAA,MACnD,aAAa,QAAQ,YAAYA,QAAO,IAAI;AAAA,MAC5C,YAAYA,QAAO,OAAO,IAAI;AAAA,MAC9B,QAAAA;AAAA,IACF,EAAE;AAEF,WAAO;AAAA,MACL,OAAO;AAAA,MACP;AAAA,MACA,GAAG,QAAQ,IAAI,CAAC,EAAE,aAAa,WAAW,MAAM,eAAe,uBAAuB,cAAc;AAAA,MACpG,GAAG,QAAQ,IAAI,CAAC,EAAE,aAAa,WAAW,MAAM,eAAe,uBAAuB,cAAc;AAAA,MACpG;AAAA,MACA,gBAAgB,KAAK;AAAA,MACrB,GAAG,QAAQ,IAAI,CAAC,EAAE,QAAAA,SAAQ,YAAY,MAAM,MAAMA,QAAO,eAAe,eAAeA,QAAO,aAAa;AAAA,MAC3G;AAAA,MACA;AAAA,MACA;AAAA,MACA,GAAG,QAAQ,IAAI,CAAC,EAAE,QAAAA,SAAQ,YAAY,MAAM,MAAMA,QAAO,eAAe,sBAAsB;AAAA,MAC9F;AAAA,IACF,EAAE,KAAK,IAAI;AAAA,EACb;AACF;",
|
|
6
6
|
"names": ["module"]
|
|
7
7
|
}
|
|
@@ -74,8 +74,8 @@ class PluginConfigModule extends import_module.Module {
|
|
|
74
74
|
this._plugin = config.plugin;
|
|
75
75
|
}
|
|
76
76
|
async getContent() {
|
|
77
|
-
const { interfaces, configuration } = this._plugin;
|
|
78
|
-
const content = JSON.stringify({ interfaces, configuration }, null, 2);
|
|
77
|
+
const { interfaces, configuration, alias } = this._plugin;
|
|
78
|
+
const content = JSON.stringify({ alias, interfaces, configuration }, null, 2);
|
|
79
79
|
return `export default ${content}`;
|
|
80
80
|
}
|
|
81
81
|
}
|
|
@@ -84,13 +84,13 @@ class BotPluginModule extends import_module.Module {
|
|
|
84
84
|
_bundleJsModule;
|
|
85
85
|
_bundleDtsModule;
|
|
86
86
|
_configModule;
|
|
87
|
-
|
|
87
|
+
pluginKey;
|
|
88
88
|
constructor(plugin) {
|
|
89
89
|
super({
|
|
90
90
|
exportName: "default",
|
|
91
91
|
path: consts.INDEX_FILE
|
|
92
92
|
});
|
|
93
|
-
this.
|
|
93
|
+
this.pluginKey = plugin.alias ?? plugin.name;
|
|
94
94
|
this._typingsModule = new import_plugin_typings.PluginTypingsModule(plugin.definition);
|
|
95
95
|
this._typingsModule.unshift("typings");
|
|
96
96
|
this.pushDep(this._typingsModule);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/code-generation/bot-implementation/bot-plugins/plugin-module.ts"],
|
|
4
|
-
"sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport * as consts from '../../consts'\nimport { Module, ModuleProps } from '../../module'\nimport { PluginTypingsModule } from '../../plugin-implementation/plugin-typings'\n\ntype PluginInstance = NonNullable<sdk.BotDefinition['plugins']>[string]\n\nclass BundleJsModule extends Module {\n private _indexJs: string\n public constructor(plugin: PluginInstance) {\n super({\n path: 'bundle.js',\n exportName: 'default',\n })\n this._indexJs = plugin.implementation.toString()\n }\n\n public async getContent() {\n return this._indexJs\n }\n}\n\nclass BundleDtsModule extends Module {\n public constructor(private _typingsModule: PluginTypingsModule) {\n super({\n path: 'bundle.d.ts',\n exportName: 'default',\n })\n }\n\n public async getContent() {\n const typingsImport = this._typingsModule.import(this)\n\n return [\n consts.GENERATED_HEADER,\n 'import * as sdk from \"@botpress/sdk\"',\n `import * as ${this._typingsModule.name} from \"./${typingsImport}\"`,\n `type TPlugin = sdk.DefaultPlugin<${this._typingsModule.name}.${this._typingsModule.exportName}>`,\n 'export default new sdk.Plugin<TPlugin>({})',\n '',\n ].join('\\n')\n }\n}\n\nclass PluginConfigModule extends Module {\n private _plugin: PluginInstance\n public constructor(config: ModuleProps & { plugin: PluginInstance }) {\n super(config)\n this._plugin = config.plugin\n }\n\n public async getContent() {\n const { interfaces, configuration } = this._plugin\n const content = JSON.stringify({ interfaces, configuration }, null, 2)\n return `export default ${content}`\n }\n}\n\nexport class BotPluginModule extends Module {\n private _typingsModule: PluginTypingsModule\n private _bundleJsModule: BundleJsModule\n private _bundleDtsModule: BundleDtsModule\n private _configModule: PluginConfigModule\n\n public readonly
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,aAAwB;AACxB,oBAAoC;AACpC,4BAAoC;AAIpC,MAAM,uBAAuB,qBAAO;AAAA,EAC1B;AAAA,EACD,YAAY,QAAwB;AACzC,UAAM;AAAA,MACJ,MAAM;AAAA,MACN,YAAY;AAAA,IACd,CAAC;AACD,SAAK,WAAW,OAAO,eAAe,SAAS;AAAA,EACjD;AAAA,EAEA,MAAa,aAAa;AACxB,WAAO,KAAK;AAAA,EACd;AACF;AAEA,MAAM,wBAAwB,qBAAO;AAAA,EAC5B,YAAoB,gBAAqC;AAC9D,UAAM;AAAA,MACJ,MAAM;AAAA,MACN,YAAY;AAAA,IACd,CAAC;AAJwB;AAAA,EAK3B;AAAA,EAEA,MAAa,aAAa;AACxB,UAAM,gBAAgB,KAAK,eAAe,OAAO,IAAI;AAErD,WAAO;AAAA,MACL,OAAO;AAAA,MACP;AAAA,MACA,eAAe,KAAK,eAAe,gBAAgB;AAAA,MACnD,oCAAoC,KAAK,eAAe,QAAQ,KAAK,eAAe;AAAA,MACpF;AAAA,MACA;AAAA,IACF,EAAE,KAAK,IAAI;AAAA,EACb;AACF;AAEA,MAAM,2BAA2B,qBAAO;AAAA,EAC9B;AAAA,EACD,YAAY,QAAkD;AACnE,UAAM,MAAM;AACZ,SAAK,UAAU,OAAO;AAAA,EACxB;AAAA,EAEA,MAAa,aAAa;AACxB,UAAM,EAAE,YAAY,
|
|
4
|
+
"sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport * as consts from '../../consts'\nimport { Module, ModuleProps } from '../../module'\nimport { PluginTypingsModule } from '../../plugin-implementation/plugin-typings'\n\ntype PluginInstance = NonNullable<sdk.BotDefinition['plugins']>[string]\n\nclass BundleJsModule extends Module {\n private _indexJs: string\n public constructor(plugin: PluginInstance) {\n super({\n path: 'bundle.js',\n exportName: 'default',\n })\n this._indexJs = plugin.implementation.toString()\n }\n\n public async getContent() {\n return this._indexJs\n }\n}\n\nclass BundleDtsModule extends Module {\n public constructor(private _typingsModule: PluginTypingsModule) {\n super({\n path: 'bundle.d.ts',\n exportName: 'default',\n })\n }\n\n public async getContent() {\n const typingsImport = this._typingsModule.import(this)\n\n return [\n consts.GENERATED_HEADER,\n 'import * as sdk from \"@botpress/sdk\"',\n `import * as ${this._typingsModule.name} from \"./${typingsImport}\"`,\n `type TPlugin = sdk.DefaultPlugin<${this._typingsModule.name}.${this._typingsModule.exportName}>`,\n 'export default new sdk.Plugin<TPlugin>({})',\n '',\n ].join('\\n')\n }\n}\n\nclass PluginConfigModule extends Module {\n private _plugin: PluginInstance\n public constructor(config: ModuleProps & { plugin: PluginInstance }) {\n super(config)\n this._plugin = config.plugin\n }\n\n public async getContent() {\n const { interfaces, configuration, alias } = this._plugin\n const content = JSON.stringify({ alias, interfaces, configuration }, null, 2)\n return `export default ${content}`\n }\n}\n\nexport class BotPluginModule extends Module {\n private _typingsModule: PluginTypingsModule\n private _bundleJsModule: BundleJsModule\n private _bundleDtsModule: BundleDtsModule\n private _configModule: PluginConfigModule\n\n public readonly pluginKey: string\n\n public constructor(plugin: PluginInstance) {\n super({\n exportName: 'default',\n path: consts.INDEX_FILE,\n })\n\n this.pluginKey = plugin.alias ?? plugin.name\n\n this._typingsModule = new PluginTypingsModule(plugin.definition)\n this._typingsModule.unshift('typings')\n this.pushDep(this._typingsModule)\n\n this._bundleJsModule = new BundleJsModule(plugin)\n this.pushDep(this._bundleJsModule)\n\n this._bundleDtsModule = new BundleDtsModule(this._typingsModule)\n this.pushDep(this._bundleDtsModule)\n\n this._configModule = new PluginConfigModule({\n path: 'config.ts',\n exportName: 'default',\n plugin,\n })\n this.pushDep(this._configModule)\n }\n\n public async getContent() {\n const configImport = this._configModule.import(this)\n const typingsImport = this._typingsModule.import(this)\n return [\n consts.GENERATED_HEADER,\n 'import * as sdk from \"@botpress/sdk\"',\n 'import bundle from \"./bundle\"',\n `import * as ${this._typingsModule.name} from \"./${typingsImport}\"`,\n `import * as ${this._configModule.name} from \"./${configImport}\"`,\n '',\n `export type TPlugin = sdk.DefaultPlugin<${this._typingsModule.name}.${this._typingsModule.exportName}>`,\n '',\n `export const configuration = ${this._configModule.name}.${this._configModule.exportName}.configuration`,\n `export const interfaces = ${this._configModule.name}.${this._configModule.exportName}.interfaces`,\n '',\n `export default bundle.initialize(${this._configModule.name}.${this._configModule.exportName})`,\n '',\n ].join('\\n')\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,aAAwB;AACxB,oBAAoC;AACpC,4BAAoC;AAIpC,MAAM,uBAAuB,qBAAO;AAAA,EAC1B;AAAA,EACD,YAAY,QAAwB;AACzC,UAAM;AAAA,MACJ,MAAM;AAAA,MACN,YAAY;AAAA,IACd,CAAC;AACD,SAAK,WAAW,OAAO,eAAe,SAAS;AAAA,EACjD;AAAA,EAEA,MAAa,aAAa;AACxB,WAAO,KAAK;AAAA,EACd;AACF;AAEA,MAAM,wBAAwB,qBAAO;AAAA,EAC5B,YAAoB,gBAAqC;AAC9D,UAAM;AAAA,MACJ,MAAM;AAAA,MACN,YAAY;AAAA,IACd,CAAC;AAJwB;AAAA,EAK3B;AAAA,EAEA,MAAa,aAAa;AACxB,UAAM,gBAAgB,KAAK,eAAe,OAAO,IAAI;AAErD,WAAO;AAAA,MACL,OAAO;AAAA,MACP;AAAA,MACA,eAAe,KAAK,eAAe,gBAAgB;AAAA,MACnD,oCAAoC,KAAK,eAAe,QAAQ,KAAK,eAAe;AAAA,MACpF;AAAA,MACA;AAAA,IACF,EAAE,KAAK,IAAI;AAAA,EACb;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AA,MAC3F;AAAA,MACA,gCAAgC,KAAK,cAAc,QAAQ,KAAK,cAAc;AAAA,MAC9E,6BAA6B,KAAK,cAAc,QAAQ,KAAK,cAAc;AAAA,MAC3E;AAAA,MACA,oCAAoC,KAAK,cAAc,QAAQ,KAAK,cAAc;AAAA,MAClF;AAAA,IACF,EAAE,KAAK,IAAI;AAAA,EACb;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -38,6 +38,7 @@ var import_actions_module = require("./actions-module");
|
|
|
38
38
|
var import_events_module = require("./events-module");
|
|
39
39
|
var import_states_module = require("./states-module");
|
|
40
40
|
var import_tables_module = require("./tables-module");
|
|
41
|
+
var import_workflows_module = require("./workflows-module");
|
|
41
42
|
class BotIntegrationsModule extends import_module.ReExportTypeModule {
|
|
42
43
|
constructor(bot) {
|
|
43
44
|
super({
|
|
@@ -72,21 +73,26 @@ class BotTypingsModule extends import_module.Module {
|
|
|
72
73
|
const actionsModule = new import_actions_module.ActionsModule(bot.actions ?? {});
|
|
73
74
|
actionsModule.unshift("actions");
|
|
74
75
|
this.pushDep(actionsModule);
|
|
76
|
+
const workflowsModule = new import_workflows_module.WorkflowsModule(bot.workflows ?? {});
|
|
77
|
+
workflowsModule.unshift("workflows");
|
|
78
|
+
this.pushDep(workflowsModule);
|
|
75
79
|
this._dependencies = {
|
|
76
80
|
integrationsModule,
|
|
77
81
|
eventsModule,
|
|
78
82
|
statesModule,
|
|
79
83
|
actionsModule,
|
|
80
|
-
tablesModule
|
|
84
|
+
tablesModule,
|
|
85
|
+
workflowsModule
|
|
81
86
|
};
|
|
82
87
|
}
|
|
83
88
|
async getContent() {
|
|
84
|
-
const { integrationsModule, eventsModule, statesModule, actionsModule, tablesModule } = this._dependencies;
|
|
89
|
+
const { integrationsModule, eventsModule, statesModule, actionsModule, tablesModule, workflowsModule } = this._dependencies;
|
|
85
90
|
const integrationsImport = integrationsModule.import(this);
|
|
86
91
|
const eventsImport = eventsModule.import(this);
|
|
87
92
|
const statesImport = statesModule.import(this);
|
|
88
93
|
const actionsImport = actionsModule;
|
|
89
94
|
const tablesImport = tablesModule.import(this);
|
|
95
|
+
const workflowsImport = workflowsModule;
|
|
90
96
|
return [
|
|
91
97
|
consts.GENERATED_HEADER,
|
|
92
98
|
`import * as ${integrationsModule.name} from './${integrationsImport}'`,
|
|
@@ -94,12 +100,14 @@ class BotTypingsModule extends import_module.Module {
|
|
|
94
100
|
`import * as ${statesModule.name} from './${statesModule.name}'`,
|
|
95
101
|
`import * as ${actionsModule.name} from './${actionsImport.name}'`,
|
|
96
102
|
`import * as ${tablesModule.name} from './${tablesImport}'`,
|
|
103
|
+
`import * as ${workflowsModule.name} from './${workflowsImport.name}'`,
|
|
97
104
|
"",
|
|
98
105
|
`export * as ${integrationsModule.name} from './${integrationsImport}'`,
|
|
99
106
|
`export * as ${eventsModule.name} from './${eventsImport}'`,
|
|
100
107
|
`export * as ${statesModule.name} from './${statesImport}'`,
|
|
101
108
|
`export * as ${actionsModule.name} from './${actionsImport.name}'`,
|
|
102
109
|
`export * as ${tablesModule.name} from './${tablesImport}'`,
|
|
110
|
+
`export * as ${workflowsModule.name} from './${workflowsImport.name}'`,
|
|
103
111
|
"",
|
|
104
112
|
"export type TBot = {",
|
|
105
113
|
` integrations: ${integrationsModule.name}.${integrationsModule.exportName}`,
|
|
@@ -107,6 +115,7 @@ class BotTypingsModule extends import_module.Module {
|
|
|
107
115
|
` states: ${statesModule.name}.${statesModule.exportName}`,
|
|
108
116
|
` actions: ${actionsModule.name}.${actionsModule.exportName}`,
|
|
109
117
|
` tables: ${tablesModule.name}.${tablesModule.exportName}`,
|
|
118
|
+
` workflows: ${workflowsModule.name}.${workflowsModule.exportName}`,
|
|
110
119
|
"}"
|
|
111
120
|
].join("\n");
|
|
112
121
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/code-generation/bot-implementation/bot-typings/index.ts"],
|
|
4
|
-
"sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport * as consts from '../../consts'\nimport { IntegrationTypingsModule } from '../../integration-implementation/integration-typings'\nimport { Module, ReExportTypeModule } from '../../module'\nimport { ActionsModule } from './actions-module'\nimport { EventsModule } from './events-module'\nimport { StatesModule } from './states-module'\nimport { TablesModule } from './tables-module'\n\nclass BotIntegrationsModule extends ReExportTypeModule {\n public constructor(bot: sdk.BotDefinition) {\n super({\n exportName: 'Integrations',\n })\n\n for (const [alias, integration] of Object.entries(bot.integrations ?? {})) {\n const integrationModule = new IntegrationTypingsModule(integration.definition)\n integrationModule.unshift(alias)\n this.pushDep(integrationModule)\n }\n }\n}\n\ntype BotTypingsIndexDependencies = {\n integrationsModule: BotIntegrationsModule\n eventsModule: EventsModule\n statesModule: StatesModule\n actionsModule: ActionsModule\n tablesModule: TablesModule\n}\n\nexport class BotTypingsModule extends Module {\n private _dependencies: BotTypingsIndexDependencies\n\n public constructor(bot: sdk.BotDefinition) {\n super({\n exportName: 'TBot',\n path: consts.INDEX_FILE,\n })\n\n const integrationsModule = new BotIntegrationsModule(bot)\n integrationsModule.unshift('integrations')\n this.pushDep(integrationsModule)\n\n const eventsModule = new EventsModule(bot.events ?? {})\n eventsModule.unshift('events')\n this.pushDep(eventsModule)\n\n const statesModule = new StatesModule(bot.states ?? {})\n statesModule.unshift('states')\n this.pushDep(statesModule)\n\n const tablesModule = new TablesModule(bot.tables ?? {})\n tablesModule.unshift('tables')\n this.pushDep(tablesModule)\n\n const actionsModule = new ActionsModule(bot.actions ?? {})\n actionsModule.unshift('actions')\n this.pushDep(actionsModule)\n\n this._dependencies = {\n integrationsModule,\n eventsModule,\n statesModule,\n actionsModule,\n tablesModule,\n }\n }\n\n public async getContent() {\n const { integrationsModule, eventsModule, statesModule, actionsModule, tablesModule }
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,aAAwB;AACxB,iCAAyC;AACzC,oBAA2C;AAC3C,4BAA8B;AAC9B,2BAA6B;AAC7B,2BAA6B;AAC7B,2BAA6B;
|
|
4
|
+
"sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport * as consts from '../../consts'\nimport { IntegrationTypingsModule } from '../../integration-implementation/integration-typings'\nimport { Module, ReExportTypeModule } from '../../module'\nimport { ActionsModule } from './actions-module'\nimport { EventsModule } from './events-module'\nimport { StatesModule } from './states-module'\nimport { TablesModule } from './tables-module'\nimport { WorkflowsModule } from './workflows-module'\n\nclass BotIntegrationsModule extends ReExportTypeModule {\n public constructor(bot: sdk.BotDefinition) {\n super({\n exportName: 'Integrations',\n })\n\n for (const [alias, integration] of Object.entries(bot.integrations ?? {})) {\n const integrationModule = new IntegrationTypingsModule(integration.definition)\n integrationModule.unshift(alias)\n this.pushDep(integrationModule)\n }\n }\n}\n\ntype BotTypingsIndexDependencies = {\n integrationsModule: BotIntegrationsModule\n eventsModule: EventsModule\n statesModule: StatesModule\n actionsModule: ActionsModule\n tablesModule: TablesModule\n workflowsModule: WorkflowsModule\n}\n\nexport class BotTypingsModule extends Module {\n private _dependencies: BotTypingsIndexDependencies\n\n public constructor(bot: sdk.BotDefinition) {\n super({\n exportName: 'TBot',\n path: consts.INDEX_FILE,\n })\n\n const integrationsModule = new BotIntegrationsModule(bot)\n integrationsModule.unshift('integrations')\n this.pushDep(integrationsModule)\n\n const eventsModule = new EventsModule(bot.events ?? {})\n eventsModule.unshift('events')\n this.pushDep(eventsModule)\n\n const statesModule = new StatesModule(bot.states ?? {})\n statesModule.unshift('states')\n this.pushDep(statesModule)\n\n const tablesModule = new TablesModule(bot.tables ?? {})\n tablesModule.unshift('tables')\n this.pushDep(tablesModule)\n\n const actionsModule = new ActionsModule(bot.actions ?? {})\n actionsModule.unshift('actions')\n this.pushDep(actionsModule)\n\n const workflowsModule = new WorkflowsModule(bot.workflows ?? {})\n workflowsModule.unshift('workflows')\n this.pushDep(workflowsModule)\n\n this._dependencies = {\n integrationsModule,\n eventsModule,\n statesModule,\n actionsModule,\n tablesModule,\n workflowsModule,\n }\n }\n\n public async getContent() {\n const { integrationsModule, eventsModule, statesModule, actionsModule, tablesModule, workflowsModule } =\n this._dependencies\n\n const integrationsImport = integrationsModule.import(this)\n const eventsImport = eventsModule.import(this)\n const statesImport = statesModule.import(this)\n const actionsImport = actionsModule\n const tablesImport = tablesModule.import(this)\n const workflowsImport = workflowsModule\n\n return [\n consts.GENERATED_HEADER,\n `import * as ${integrationsModule.name} from './${integrationsImport}'`,\n `import * as ${eventsModule.name} from './${eventsModule.name}'`,\n `import * as ${statesModule.name} from './${statesModule.name}'`,\n `import * as ${actionsModule.name} from './${actionsImport.name}'`,\n `import * as ${tablesModule.name} from './${tablesImport}'`,\n `import * as ${workflowsModule.name} from './${workflowsImport.name}'`,\n '',\n `export * as ${integrationsModule.name} from './${integrationsImport}'`,\n `export * as ${eventsModule.name} from './${eventsImport}'`,\n `export * as ${statesModule.name} from './${statesImport}'`,\n `export * as ${actionsModule.name} from './${actionsImport.name}'`,\n `export * as ${tablesModule.name} from './${tablesImport}'`,\n `export * as ${workflowsModule.name} from './${workflowsImport.name}'`,\n '',\n 'export type TBot = {',\n ` integrations: ${integrationsModule.name}.${integrationsModule.exportName}`,\n ` events: ${eventsModule.name}.${eventsModule.exportName}`,\n ` states: ${statesModule.name}.${statesModule.exportName}`,\n ` actions: ${actionsModule.name}.${actionsModule.exportName}`,\n ` tables: ${tablesModule.name}.${tablesModule.exportName}`,\n ` workflows: ${workflowsModule.name}.${workflowsModule.exportName}`,\n '}',\n ].join('\\n')\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,aAAwB;AACxB,iCAAyC;AACzC,oBAA2C;AAC3C,4BAA8B;AAC9B,2BAA6B;AAC7B,2BAA6B;AAC7B,2BAA6B;AAC7B,8BAAgC;AAEhC,MAAM,8BAA8B,iCAAmB;AAAA,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5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var workflows_module_exports = {};
|
|
30
|
+
__export(workflows_module_exports, {
|
|
31
|
+
WorkflowInputModule: () => WorkflowInputModule,
|
|
32
|
+
WorkflowModule: () => WorkflowModule,
|
|
33
|
+
WorkflowOutputModule: () => WorkflowOutputModule,
|
|
34
|
+
WorkflowTagsModule: () => WorkflowTagsModule,
|
|
35
|
+
WorkflowsModule: () => WorkflowsModule
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(workflows_module_exports);
|
|
38
|
+
var import_generators = require("../../generators");
|
|
39
|
+
var import_module = require("../../module");
|
|
40
|
+
var strings = __toESM(require("../../strings"));
|
|
41
|
+
class WorkflowInputModule extends import_module.Module {
|
|
42
|
+
constructor(_input) {
|
|
43
|
+
const name = "input";
|
|
44
|
+
const exportName = strings.typeName(name);
|
|
45
|
+
super({ path: `${name}.ts`, exportName });
|
|
46
|
+
this._input = _input;
|
|
47
|
+
}
|
|
48
|
+
async getContent() {
|
|
49
|
+
return (0, import_generators.zuiSchemaToTypeScriptType)(this._input.schema, this.exportName);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
class WorkflowOutputModule extends import_module.Module {
|
|
53
|
+
constructor(_output) {
|
|
54
|
+
const name = "output";
|
|
55
|
+
const exportName = strings.typeName(name);
|
|
56
|
+
super({ path: `${name}.ts`, exportName });
|
|
57
|
+
this._output = _output;
|
|
58
|
+
}
|
|
59
|
+
async getContent() {
|
|
60
|
+
return (0, import_generators.zuiSchemaToTypeScriptType)(this._output.schema, this.exportName);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
class WorkflowTagsModule extends import_module.Module {
|
|
64
|
+
constructor(_tags) {
|
|
65
|
+
const name = "tags";
|
|
66
|
+
const exportName = strings.typeName(name);
|
|
67
|
+
super({ path: `${name}.ts`, exportName });
|
|
68
|
+
this._tags = _tags;
|
|
69
|
+
}
|
|
70
|
+
async getContent() {
|
|
71
|
+
const tags = Object.keys(this._tags ?? {}).map((tagName) => `${(0, import_generators.primitiveToTypescriptValue)(tagName)}: string`).join(", ");
|
|
72
|
+
return `export type ${this.exportName} = { ${tags} }`;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
class WorkflowModule extends import_module.ReExportTypeModule {
|
|
76
|
+
constructor(workflowName, workflow) {
|
|
77
|
+
super({ exportName: strings.typeName(workflowName) });
|
|
78
|
+
const inputModule = new WorkflowInputModule(workflow.input);
|
|
79
|
+
const outputModule = new WorkflowOutputModule(workflow.output);
|
|
80
|
+
const tagsModule = new WorkflowTagsModule(workflow.tags);
|
|
81
|
+
this.pushDep(inputModule);
|
|
82
|
+
this.pushDep(outputModule);
|
|
83
|
+
this.pushDep(tagsModule);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
class WorkflowsModule extends import_module.ReExportTypeModule {
|
|
87
|
+
constructor(workflows) {
|
|
88
|
+
super({ exportName: strings.typeName("workflows") });
|
|
89
|
+
for (const [workflowName, workflow] of Object.entries(workflows)) {
|
|
90
|
+
const module2 = new WorkflowModule(workflowName, workflow);
|
|
91
|
+
module2.unshift(workflowName);
|
|
92
|
+
this.pushDep(module2);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
97
|
+
0 && (module.exports = {
|
|
98
|
+
WorkflowInputModule,
|
|
99
|
+
WorkflowModule,
|
|
100
|
+
WorkflowOutputModule,
|
|
101
|
+
WorkflowTagsModule,
|
|
102
|
+
WorkflowsModule
|
|
103
|
+
});
|
|
104
|
+
//# sourceMappingURL=workflows-module.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/code-generation/bot-implementation/bot-typings/workflows-module.ts"],
|
|
4
|
+
"sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport { primitiveToTypescriptValue, zuiSchemaToTypeScriptType } from '../../generators'\nimport { Module, ReExportTypeModule } from '../../module'\nimport * as strings from '../../strings'\n\ntype WorkflowInput = sdk.BotWorkflowDefinition['input']\ntype WorkflowOutput = sdk.BotWorkflowDefinition['output']\ntype WorkflowTags = sdk.BotWorkflowDefinition['tags']\n\nexport class WorkflowInputModule extends Module {\n public constructor(private _input: WorkflowInput) {\n const name = 'input'\n const exportName = strings.typeName(name)\n super({ path: `${name}.ts`, exportName })\n }\n\n public async getContent() {\n return zuiSchemaToTypeScriptType(this._input.schema, this.exportName)\n }\n}\n\nexport class WorkflowOutputModule extends Module {\n public constructor(private _output: WorkflowOutput) {\n const name = 'output'\n const exportName = strings.typeName(name)\n super({ path: `${name}.ts`, exportName })\n }\n\n public async getContent() {\n return zuiSchemaToTypeScriptType(this._output.schema, this.exportName)\n }\n}\n\nexport class WorkflowTagsModule extends Module {\n public constructor(private _tags: WorkflowTags) {\n const name = 'tags'\n const exportName = strings.typeName(name)\n super({ path: `${name}.ts`, exportName })\n }\n\n public async getContent() {\n const tags = Object.keys(this._tags ?? {})\n .map((tagName) => `${primitiveToTypescriptValue(tagName)}: string`)\n .join(', ')\n\n return `export type ${this.exportName} = { ${tags} }`\n }\n}\n\nexport class WorkflowModule extends ReExportTypeModule {\n public constructor(workflowName: string, workflow: sdk.BotWorkflowDefinition) {\n super({ exportName: strings.typeName(workflowName) })\n\n const inputModule = new WorkflowInputModule(workflow.input)\n const outputModule = new WorkflowOutputModule(workflow.output)\n const tagsModule = new WorkflowTagsModule(workflow.tags)\n\n this.pushDep(inputModule)\n this.pushDep(outputModule)\n this.pushDep(tagsModule)\n }\n}\n\nexport class WorkflowsModule extends ReExportTypeModule {\n public constructor(workflows: Record<string, sdk.BotWorkflowDefinition>) {\n super({ exportName: strings.typeName('workflows') })\n for (const [workflowName, workflow] of Object.entries(workflows)) {\n const module = new WorkflowModule(workflowName, workflow)\n module.unshift(workflowName)\n this.pushDep(module)\n }\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,wBAAsE;AACtE,oBAA2C;AAC3C,cAAyB;AAMlB,MAAM,4BAA4B,qBAAO;AAAA,EACvC,YAAoB,QAAuB;AAChD,UAAM,OAAO;AACb,UAAM,aAAa,QAAQ,SAAS,IAAI;AACxC,UAAM,EAAE,MAAM,GAAG,WAAW,WAAW,CAAC;AAHf;AAAA,EAI3B;AAAA,EAEA,MAAa,aAAa;AACxB,eAAO,6CAA0B,KAAK,OAAO,QAAQ,KAA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AAQ;AACxD,MAAAA,QAAO,QAAQ,YAAY;AAC3B,WAAK,QAAQA,OAAM;AAAA,IACrB;AAAA,EACF;AACF;",
|
|
6
|
+
"names": ["module"]
|
|
7
|
+
}
|
|
@@ -78,6 +78,11 @@ class PluginImplementationModule extends import_module.Module {
|
|
|
78
78
|
" [K in keyof PluginHandlers['hookHandlers'][H]]: NonNullable<PluginHandlers['hookHandlers'][H][K]>[number]",
|
|
79
79
|
" }>",
|
|
80
80
|
"}>",
|
|
81
|
+
"export type WorkflowHandlers = {",
|
|
82
|
+
" [TWorkflowName in keyof Required<PluginHandlers['workflowHandlers'][keyof PluginHandlers['workflowHandlers']]>]:",
|
|
83
|
+
" Required<PluginHandlers['workflowHandlers'][keyof PluginHandlers['workflowHandlers']]>[TWorkflowName] extends",
|
|
84
|
+
" ({ handler: infer U })[] ? U : never",
|
|
85
|
+
"}",
|
|
81
86
|
"",
|
|
82
87
|
"export type AnyMessageHandler = MessageHandlers['*']",
|
|
83
88
|
"export type AnyEventHandler = EventHandlers['*']",
|
|
@@ -92,6 +97,10 @@ class PluginImplementationModule extends import_module.Module {
|
|
|
92
97
|
"export type HookHandlerProps = {",
|
|
93
98
|
" [H in keyof AnyHookHanders]: Parameters<NonNullable<AnyHookHanders[H]>>[0]",
|
|
94
99
|
"}",
|
|
100
|
+
"export type WorkflowHandlerProps = {",
|
|
101
|
+
" [TWorkflowName in keyof WorkflowHandlers]: WorkflowHandlers[TWorkflowName] extends",
|
|
102
|
+
" (..._: infer U) => any ? U[0] : never",
|
|
103
|
+
"}",
|
|
95
104
|
"",
|
|
96
105
|
"export type Client = (MessageHandlerProps | EventHandlerProps)['client']",
|
|
97
106
|
"export type ClientOperation = keyof {",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/code-generation/plugin-implementation/plugin-implementation.ts"],
|
|
4
|
-
"sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport * as consts from '../consts'\nimport { Module } from '../module'\nimport { PluginTypingsModule } from './plugin-typings'\n\nexport class PluginImplementationModule extends Module {\n private _typingsModule: PluginTypingsModule\n\n public constructor(plugin: sdk.PluginDefinition) {\n super({\n exportName: 'Plugin',\n path: consts.INDEX_FILE,\n })\n\n this._typingsModule = new PluginTypingsModule(plugin)\n this._typingsModule.unshift('typings')\n this.pushDep(this._typingsModule)\n }\n\n public async getContent() {\n const typingsImport = this._typingsModule.import(this)\n\n return [\n consts.GENERATED_HEADER,\n 'import * as sdk from \"@botpress/sdk\"',\n `import * as ${this._typingsModule.name} from \"./${typingsImport}\"`,\n `export * from \"./${typingsImport}\"`,\n '',\n `type TPlugin = sdk.DefaultPlugin<${this._typingsModule.name}.${this._typingsModule.exportName}>`,\n '',\n 'export class Plugin extends sdk.Plugin<TPlugin> {}',\n '',\n 'export type PluginProps = sdk.PluginProps<TPlugin>',\n 'export type PluginRuntimeProps = sdk.PluginRuntimeProps<TPlugin>',\n '',\n '// extra types',\n '',\n 'type ValueOf<T> = T[keyof T]',\n 'type AsyncFunction = (...args: any[]) => Promise<any>',\n '',\n 'export type PluginHandlers = sdk.PluginHandlers<TPlugin>',\n '',\n 'export type EventHandlers = Required<{',\n \" [K in keyof PluginHandlers['eventHandlers']]: NonNullable<PluginHandlers['eventHandlers'][K]>[number]\",\n '}>',\n 'export type MessageHandlers = Required<{',\n \" [K in keyof PluginHandlers['messageHandlers']]: NonNullable<PluginHandlers['messageHandlers'][K]>[number]\",\n '}>',\n 'export type HookHandlers = Required<{',\n \" [H in keyof PluginHandlers['hookHandlers']]: Required<{\",\n \" [K in keyof PluginHandlers['hookHandlers'][H]]: NonNullable<PluginHandlers['hookHandlers'][H][K]>[number]\",\n ' }>',\n '}>',\n '',\n \"export type AnyMessageHandler = MessageHandlers['*']\",\n \"export type AnyEventHandler = EventHandlers['*']\",\n \"export type AnyActionHandler = ValueOf<PluginHandlers['actionHandlers']>\",\n 'export type AnyHookHanders = {',\n \" [H in keyof HookHandlers]: NonNullable<HookHandlers[H]['*']>\",\n '}',\n '',\n 'export type MessageHandlerProps = Parameters<AnyMessageHandler>[0]',\n 'export type EventHandlerProps = Parameters<AnyEventHandler>[0]',\n 'export type ActionHandlerProps = Parameters<AnyActionHandler>[0]',\n 'export type HookHandlerProps = {',\n ' [H in keyof AnyHookHanders]: Parameters<NonNullable<AnyHookHanders[H]>>[0]',\n '}',\n '',\n \"export type Client = (MessageHandlerProps | EventHandlerProps)['client']\",\n 'export type ClientOperation = keyof {',\n ' [K in keyof Client as Client[K] extends AsyncFunction ? K : never]: null',\n '}',\n 'export type ClientInputs = {',\n ' [K in ClientOperation]: Parameters<Client[K]>[0]',\n '}',\n 'export type ClientOutputs = {',\n ' [K in ClientOperation]: Awaited<ReturnType<Client[K]>>',\n '}',\n ].join('\\n')\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,aAAwB;AACxB,oBAAuB;AACvB,4BAAoC;AAE7B,MAAM,mCAAmC,qBAAO;AAAA,EAC7C;AAAA,EAED,YAAY,QAA8B;AAC/C,UAAM;AAAA,MACJ,YAAY;AAAA,MACZ,MAAM,OAAO;AAAA,IACf,CAAC;AAED,SAAK,iBAAiB,IAAI,0CAAoB,MAAM;AACpD,SAAK,eAAe,QAAQ,SAAS;AACrC,SAAK,QAAQ,KAAK,cAAc;AAAA,EAClC;AAAA,EAEA,MAAa,aAAa;AACxB,UAAM,gBAAgB,KAAK,eAAe,OAAO,IAAI;AAErD,WAAO;AAAA,MACL,OAAO;AAAA,MACP;AAAA,MACA,eAAe,KAAK,eAAe,gBAAgB;AAAA,MACnD,oBAAoB;AAAA,MACpB;AAAA,MACA,oCAAoC,KAAK,eAAe,QAAQ,KAAK,eAAe;AAAA,MACpF;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,EAAE,KAAK,IAAI;AAAA,EACb;AACF;",
|
|
4
|
+
"sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport * as consts from '../consts'\nimport { Module } from '../module'\nimport { PluginTypingsModule } from './plugin-typings'\n\nexport class PluginImplementationModule extends Module {\n private _typingsModule: PluginTypingsModule\n\n public constructor(plugin: sdk.PluginDefinition) {\n super({\n exportName: 'Plugin',\n path: consts.INDEX_FILE,\n })\n\n this._typingsModule = new PluginTypingsModule(plugin)\n this._typingsModule.unshift('typings')\n this.pushDep(this._typingsModule)\n }\n\n public async getContent() {\n const typingsImport = this._typingsModule.import(this)\n\n return [\n consts.GENERATED_HEADER,\n 'import * as sdk from \"@botpress/sdk\"',\n `import * as ${this._typingsModule.name} from \"./${typingsImport}\"`,\n `export * from \"./${typingsImport}\"`,\n '',\n `type TPlugin = sdk.DefaultPlugin<${this._typingsModule.name}.${this._typingsModule.exportName}>`,\n '',\n 'export class Plugin extends sdk.Plugin<TPlugin> {}',\n '',\n 'export type PluginProps = sdk.PluginProps<TPlugin>',\n 'export type PluginRuntimeProps = sdk.PluginRuntimeProps<TPlugin>',\n '',\n '// extra types',\n '',\n 'type ValueOf<T> = T[keyof T]',\n 'type AsyncFunction = (...args: any[]) => Promise<any>',\n '',\n 'export type PluginHandlers = sdk.PluginHandlers<TPlugin>',\n '',\n 'export type EventHandlers = Required<{',\n \" [K in keyof PluginHandlers['eventHandlers']]: NonNullable<PluginHandlers['eventHandlers'][K]>[number]\",\n '}>',\n 'export type MessageHandlers = Required<{',\n \" [K in keyof PluginHandlers['messageHandlers']]: NonNullable<PluginHandlers['messageHandlers'][K]>[number]\",\n '}>',\n 'export type HookHandlers = Required<{',\n \" [H in keyof PluginHandlers['hookHandlers']]: Required<{\",\n \" [K in keyof PluginHandlers['hookHandlers'][H]]: NonNullable<PluginHandlers['hookHandlers'][H][K]>[number]\",\n ' }>',\n '}>',\n 'export type WorkflowHandlers = {',\n \" [TWorkflowName in keyof Required<PluginHandlers['workflowHandlers'][keyof PluginHandlers['workflowHandlers']]>]:\",\n \" Required<PluginHandlers['workflowHandlers'][keyof PluginHandlers['workflowHandlers']]>[TWorkflowName] extends\",\n ' ({ handler: infer U })[] ? U : never',\n '}',\n '',\n \"export type AnyMessageHandler = MessageHandlers['*']\",\n \"export type AnyEventHandler = EventHandlers['*']\",\n \"export type AnyActionHandler = ValueOf<PluginHandlers['actionHandlers']>\",\n 'export type AnyHookHanders = {',\n \" [H in keyof HookHandlers]: NonNullable<HookHandlers[H]['*']>\",\n '}',\n '',\n 'export type MessageHandlerProps = Parameters<AnyMessageHandler>[0]',\n 'export type EventHandlerProps = Parameters<AnyEventHandler>[0]',\n 'export type ActionHandlerProps = Parameters<AnyActionHandler>[0]',\n 'export type HookHandlerProps = {',\n ' [H in keyof AnyHookHanders]: Parameters<NonNullable<AnyHookHanders[H]>>[0]',\n '}',\n 'export type WorkflowHandlerProps = {',\n ' [TWorkflowName in keyof WorkflowHandlers]: WorkflowHandlers[TWorkflowName] extends',\n ' (..._: infer U) => any ? U[0] : never',\n '}',\n '',\n \"export type Client = (MessageHandlerProps | EventHandlerProps)['client']\",\n 'export type ClientOperation = keyof {',\n ' [K in keyof Client as Client[K] extends AsyncFunction ? K : never]: null',\n '}',\n 'export type ClientInputs = {',\n ' [K in ClientOperation]: Parameters<Client[K]>[0]',\n '}',\n 'export type ClientOutputs = {',\n ' [K in ClientOperation]: Awaited<ReturnType<Client[K]>>',\n '}',\n ].join('\\n')\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,aAAwB;AACxB,oBAAuB;AACvB,4BAAoC;AAE7B,MAAM,mCAAmC,qBAAO;AAAA,EAC7C;AAAA,EAED,YAAY,QAA8B;AAC/C,UAAM;AAAA,MACJ,YAAY;AAAA,MACZ,MAAM,OAAO;AAAA,IACf,CAAC;AAED,SAAK,iBAAiB,IAAI,0CAAoB,MAAM;AACpD,SAAK,eAAe,QAAQ,SAAS;AACrC,SAAK,QAAQ,KAAK,cAAc;AAAA,EAClC;AAAA,EAEA,MAAa,aAAa;AACxB,UAAM,gBAAgB,KAAK,eAAe,OAAO,IAAI;AAErD,WAAO;AAAA,MACL,OAAO;AAAA,MACP;AAAA,MACA,eAAe,KAAK,eAAe,gBAAgB;AAAA,MACnD,oBAAoB;AAAA,MACpB;AAAA,MACA,oCAAoC,KAAK,eAAe,QAAQ,KAAK,eAAe;AAAA,MACpF;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,EAAE,KAAK,IAAI;AAAA,EACb;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -40,6 +40,7 @@ var import_configuration_module = require("./configuration-module");
|
|
|
40
40
|
var import_events_module = require("./events-module");
|
|
41
41
|
var import_states_module = require("./states-module");
|
|
42
42
|
var import_tables_module = require("./tables-module");
|
|
43
|
+
var import_workflows_module = require("./workflows-module");
|
|
43
44
|
class PluginIntegrationsModule extends import_module.ReExportTypeModule {
|
|
44
45
|
constructor(plugin) {
|
|
45
46
|
super({
|
|
@@ -68,41 +69,44 @@ const _isLocalPluginDefinition = (plugin) => {
|
|
|
68
69
|
return "props" in plugin;
|
|
69
70
|
};
|
|
70
71
|
class PluginTypingsModule extends import_module.Module {
|
|
71
|
-
|
|
72
|
-
constructor(plugin) {
|
|
72
|
+
constructor(_plugin) {
|
|
73
73
|
super({
|
|
74
74
|
exportName: "TPlugin",
|
|
75
75
|
path: consts.INDEX_FILE
|
|
76
76
|
});
|
|
77
|
-
|
|
77
|
+
this._plugin = _plugin;
|
|
78
|
+
const integrationsModule = _isLocalPluginDefinition(_plugin) ? new PluginIntegrationsModule(_plugin) : new import_module.SingleFileModule({
|
|
78
79
|
path: consts.INDEX_FILE,
|
|
79
80
|
exportName: "Integrations",
|
|
80
81
|
content: "export type Integrations = {}"
|
|
81
82
|
});
|
|
82
83
|
integrationsModule.unshift("integrations");
|
|
83
84
|
this.pushDep(integrationsModule);
|
|
84
|
-
const interfacesModule = _isLocalPluginDefinition(
|
|
85
|
+
const interfacesModule = _isLocalPluginDefinition(_plugin) ? new PluginInterfacesModule(_plugin) : new import_module.SingleFileModule({
|
|
85
86
|
path: consts.INDEX_FILE,
|
|
86
87
|
exportName: "Interfaces",
|
|
87
88
|
content: "export type Interfaces = {}"
|
|
88
89
|
});
|
|
89
90
|
interfacesModule.unshift("interfaces");
|
|
90
91
|
this.pushDep(interfacesModule);
|
|
91
|
-
const defaultConfigModule = new import_configuration_module.DefaultConfigurationModule(
|
|
92
|
+
const defaultConfigModule = new import_configuration_module.DefaultConfigurationModule(_plugin.configuration);
|
|
92
93
|
defaultConfigModule.unshift("configuration");
|
|
93
94
|
this.pushDep(defaultConfigModule);
|
|
94
|
-
const eventsModule = new import_events_module.EventsModule(
|
|
95
|
+
const eventsModule = new import_events_module.EventsModule(_plugin.events ?? {});
|
|
95
96
|
eventsModule.unshift("events");
|
|
96
97
|
this.pushDep(eventsModule);
|
|
97
|
-
const statesModule = new import_states_module.StatesModule(
|
|
98
|
+
const statesModule = new import_states_module.StatesModule(_plugin.states ?? {});
|
|
98
99
|
statesModule.unshift("states");
|
|
99
100
|
this.pushDep(statesModule);
|
|
100
|
-
const actionsModule = new import_actions_module.ActionsModule(
|
|
101
|
+
const actionsModule = new import_actions_module.ActionsModule(_plugin.actions ?? {});
|
|
101
102
|
actionsModule.unshift("actions");
|
|
102
103
|
this.pushDep(actionsModule);
|
|
103
|
-
const tablesModule = new import_tables_module.TablesModule(
|
|
104
|
+
const tablesModule = new import_tables_module.TablesModule(_plugin.tables ?? {});
|
|
104
105
|
tablesModule.unshift("tables");
|
|
105
106
|
this.pushDep(tablesModule);
|
|
107
|
+
const workflowsModule = new import_workflows_module.WorkflowsModule(_plugin.workflows ?? {});
|
|
108
|
+
workflowsModule.unshift("workflows");
|
|
109
|
+
this.pushDep(workflowsModule);
|
|
106
110
|
this._dependencies = {
|
|
107
111
|
integrationsModule,
|
|
108
112
|
interfacesModule,
|
|
@@ -110,9 +114,11 @@ class PluginTypingsModule extends import_module.Module {
|
|
|
110
114
|
eventsModule,
|
|
111
115
|
statesModule,
|
|
112
116
|
actionsModule,
|
|
113
|
-
tablesModule
|
|
117
|
+
tablesModule,
|
|
118
|
+
workflowsModule
|
|
114
119
|
};
|
|
115
120
|
}
|
|
121
|
+
_dependencies;
|
|
116
122
|
async getContent() {
|
|
117
123
|
const {
|
|
118
124
|
integrationsModule,
|
|
@@ -121,7 +127,8 @@ class PluginTypingsModule extends import_module.Module {
|
|
|
121
127
|
eventsModule,
|
|
122
128
|
statesModule,
|
|
123
129
|
actionsModule,
|
|
124
|
-
tablesModule
|
|
130
|
+
tablesModule,
|
|
131
|
+
workflowsModule
|
|
125
132
|
} = this._dependencies;
|
|
126
133
|
const integrationsImport = integrationsModule.import(this);
|
|
127
134
|
const interfacesImport = interfacesModule.import(this);
|
|
@@ -130,6 +137,7 @@ class PluginTypingsModule extends import_module.Module {
|
|
|
130
137
|
const statesImport = statesModule.import(this);
|
|
131
138
|
const actionsImport = actionsModule;
|
|
132
139
|
const tablesImport = tablesModule.import(this);
|
|
140
|
+
const workflowsImport = workflowsModule;
|
|
133
141
|
return [
|
|
134
142
|
consts.GENERATED_HEADER,
|
|
135
143
|
`import * as ${integrationsModule.name} from './${integrationsImport}'`,
|
|
@@ -139,6 +147,7 @@ class PluginTypingsModule extends import_module.Module {
|
|
|
139
147
|
`import * as ${statesModule.name} from './${statesModule.name}'`,
|
|
140
148
|
`import * as ${actionsModule.name} from './${actionsImport.name}'`,
|
|
141
149
|
`import * as ${tablesModule.name} from './${tablesImport}'`,
|
|
150
|
+
`import * as ${workflowsModule.name} from './${workflowsImport.name}'`,
|
|
142
151
|
"",
|
|
143
152
|
`export * as ${integrationsModule.name} from './${integrationsImport}'`,
|
|
144
153
|
`export * as ${interfacesModule.name} from './${interfacesImport}'`,
|
|
@@ -147,8 +156,11 @@ class PluginTypingsModule extends import_module.Module {
|
|
|
147
156
|
`export * as ${statesModule.name} from './${statesImport}'`,
|
|
148
157
|
`export * as ${actionsModule.name} from './${actionsImport.name}'`,
|
|
149
158
|
`export * as ${tablesModule.name} from './${tablesImport}'`,
|
|
159
|
+
`export * as ${workflowsModule.name} from './${workflowsImport.name}'`,
|
|
150
160
|
"",
|
|
151
161
|
"export type TPlugin = {",
|
|
162
|
+
` name: "${this._plugin.name}"`,
|
|
163
|
+
` version: "${this._plugin.version}"`,
|
|
152
164
|
` integrations: ${integrationsModule.name}.${integrationsModule.exportName}`,
|
|
153
165
|
` interfaces: ${interfacesModule.name}.${interfacesModule.exportName}`,
|
|
154
166
|
` configuration: ${defaultConfigModule.name}.${defaultConfigModule.exportName}`,
|
|
@@ -156,6 +168,7 @@ class PluginTypingsModule extends import_module.Module {
|
|
|
156
168
|
` states: ${statesModule.name}.${statesModule.exportName}`,
|
|
157
169
|
` actions: ${actionsModule.name}.${actionsModule.exportName}`,
|
|
158
170
|
` tables: ${tablesModule.name}.${tablesModule.exportName}`,
|
|
171
|
+
` workflows: ${workflowsModule.name}.${workflowsModule.exportName}`,
|
|
159
172
|
"}"
|
|
160
173
|
].join("\n");
|
|
161
174
|
}
|