@botpress/cli 0.8.14 → 0.8.18

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.
@@ -0,0 +1,20 @@
1
+
2
+ > @botpress/cli@0.8.18 build /home/runner/work/botpress/botpress/packages/cli
3
+ > pnpm run bundle && pnpm run template:gen
4
+
5
+
6
+ > @botpress/cli@0.8.18 bundle /home/runner/work/botpress/botpress/packages/cli
7
+ > ts-node -T build.ts
8
+
9
+
10
+ > @botpress/cli@0.8.18 template:gen /home/runner/work/botpress/botpress/packages/cli
11
+ > pnpm -r --stream -F @bp-templates/* exec bp gen
12
+
13
+ šŸ¤– Botpress CLI v0.8.18
14
+ šŸ¤– Botpress CLI v0.8.18
15
+ šŸ¤– Botpress CLI v0.8.18
16
+ šŸ¤– Botpress CLI v0.8.18
17
+ ⚠ No typings to generate for bot
18
+ ā—‹ Generating typings for integration empty-integration...ā—‹ Generating typings for integration hello-world...ā—‹ Generating typings for integration webhook-message...āœ“ Typings available at .botpress
19
+ āœ“ Typings available at .botpress
20
+ āœ“ Typings available at .botpress
@@ -93,6 +93,18 @@ class IntegrationImplementationIndexModule extends import_module.Module {
93
93
  `export * as ${eventsModule.name} from "./${eventsImport}"`,
94
94
  `export * as ${statesModule.name} from "./${statesImport}"`,
95
95
  "",
96
+ "// type utils",
97
+ "type Cast<X, Y> = X extends Y ? X : Y",
98
+ "type ValueOf<T> = T[keyof T]",
99
+ "type SimplifyObject<T extends object> = T extends infer O ? { [K in keyof O]: Simplify<O[K]> } : never",
100
+ "type Simplify<T> = T extends (...args: infer A) => infer R",
101
+ " ? (...args: Simplify<A>) => Simplify<R>",
102
+ " : T extends Promise<infer R>",
103
+ " ? Promise<Simplify<R>>",
104
+ " : T extends object",
105
+ " ? SimplifyObject<T>",
106
+ " : T",
107
+ "",
96
108
  "type TIntegration = {",
97
109
  ` name: "${integration.name}"`,
98
110
  ` version: "${integration.version}"`,
@@ -108,7 +120,43 @@ class IntegrationImplementationIndexModule extends import_module.Module {
108
120
  "",
109
121
  "export class Integration extends sdk.Integration<TIntegration> {}",
110
122
  "",
111
- "export type Client = sdk.IntegrationSpecificClient<TIntegration>"
123
+ "export type Client = sdk.IntegrationSpecificClient<TIntegration>",
124
+ "",
125
+ "// extra types",
126
+ "",
127
+ "export type HandlerProps = Simplify<Parameters<IntegrationProps['handler']>[0]>",
128
+ "",
129
+ "export type ActionProps = Simplify<{",
130
+ " [K in keyof IntegrationProps['actions']]: Parameters<IntegrationProps['actions'][K]>[0]",
131
+ "}>",
132
+ "export type AnyActionProps = ValueOf<ActionProps>",
133
+ "",
134
+ "export type MessageProps = Simplify<{",
135
+ " [TChannel in keyof IntegrationProps['channels']]: {",
136
+ " [TMessage in keyof IntegrationProps['channels'][TChannel]['messages']]: Parameters<",
137
+ " IntegrationProps['channels'][TChannel]['messages'][TMessage]",
138
+ " >[0]",
139
+ " }",
140
+ "}>",
141
+ "export type AnyMessageProps = ValueOf<ValueOf<MessageProps>>",
142
+ "",
143
+ "export type Context = HandlerProps['ctx']",
144
+ "export type Logger = HandlerProps['logger']",
145
+ "",
146
+ "export type AckFunctions = {",
147
+ " [TChannel in keyof MessageProps]: {",
148
+ " [TMessage in keyof MessageProps[TChannel]]: Cast<MessageProps[TChannel][TMessage], AnyMessageProps>['ack']",
149
+ " }",
150
+ "}",
151
+ "export type AnyAckFunction = ValueOf<ValueOf<AckFunctions>>",
152
+ "",
153
+ "export type ClientOperation = Simplify<keyof Client>",
154
+ "export type ClientRequests = Simplify<{",
155
+ " [K in ClientOperation]: Parameters<Client[K]>[0]",
156
+ "}>",
157
+ "export type ClientResponses = Simplify<{",
158
+ " [K in ClientOperation]: Awaited<ReturnType<Client[K]>>",
159
+ "}>"
112
160
  ].join("\n");
113
161
  return content;
114
162
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/code-generation/integration-implementation.ts"],
4
- "sourcesContent": ["import { GENERATED_HEADER, INDEX_FILE } from './const'\nimport { stringifySingleLine } from './generators'\nimport { ActionsModule } from './integration-schemas/actions-module'\nimport { ChannelsModule } from './integration-schemas/channels-module'\nimport { ConfigurationModule } from './integration-schemas/configuration-module'\nimport { EventsModule } from './integration-schemas/events-module'\nimport { StatesModule } from './integration-schemas/states-module'\nimport { Module, ModuleDef } from './module'\nimport * as types from './typings'\n\nexport class IntegrationImplementationIndexModule extends Module {\n public static async create(integration: types.IntegrationDefinition): Promise<IntegrationImplementationIndexModule> {\n const configModule = await ConfigurationModule.create(integration.configuration ?? { schema: {} })\n configModule.unshift('configuration')\n\n const actionsModule = await ActionsModule.create(integration.actions ?? {})\n actionsModule.unshift('actions')\n\n const channelsModule = await ChannelsModule.create(integration.channels ?? {})\n channelsModule.unshift('channels')\n\n const eventsModule = await EventsModule.create(integration.events ?? {})\n eventsModule.unshift('events')\n\n const statesModule = await StatesModule.create(integration.states ?? {})\n statesModule.unshift('states')\n\n const inst = new IntegrationImplementationIndexModule(\n integration,\n configModule,\n actionsModule,\n channelsModule,\n eventsModule,\n statesModule,\n {\n path: INDEX_FILE,\n exportName: 'Integration',\n content: '',\n }\n )\n\n inst.pushDep(configModule)\n inst.pushDep(actionsModule)\n inst.pushDep(channelsModule)\n inst.pushDep(eventsModule)\n inst.pushDep(statesModule)\n return inst\n }\n\n private constructor(\n private integration: types.IntegrationDefinition,\n private configModule: ConfigurationModule,\n private actionsModule: ActionsModule,\n private channelsModule: ChannelsModule,\n private eventsModule: EventsModule,\n private statesModule: StatesModule,\n def: ModuleDef\n ) {\n super(def)\n }\n\n public override get content(): string {\n let content = GENERATED_HEADER\n\n const { configModule, actionsModule, channelsModule, eventsModule, statesModule, integration } = this\n\n const configImport = configModule.import(this)\n const actionsImport = actionsModule.import(this)\n const channelsImport = channelsModule.import(this)\n const eventsImport = eventsModule.import(this)\n const statesImport = statesModule.import(this)\n\n content += [\n GENERATED_HEADER,\n 'import * as sdk from \"@botpress/sdk\"',\n '',\n `import type * as ${configModule.name} from \"./${configImport}\"`,\n `import type * as ${actionsModule.name} from \"./${actionsImport}\"`,\n `import type * as ${channelsModule.name} from \"./${channelsImport}\"`,\n `import type * as ${eventsModule.name} from \"./${eventsImport}\"`,\n `import type * as ${statesModule.name} from \"./${statesImport}\"`,\n `export * as ${configModule.name} from \"./${configImport}\"`,\n `export * as ${actionsModule.name} from \"./${actionsImport}\"`,\n `export * as ${channelsModule.name} from \"./${channelsImport}\"`,\n `export * as ${eventsModule.name} from \"./${eventsImport}\"`,\n `export * as ${statesModule.name} from \"./${statesImport}\"`,\n '',\n 'type TIntegration = {',\n ` name: \"${integration.name}\"`,\n ` version: \"${integration.version}\"`,\n ` configuration: ${configModule.name}.${configModule.exports}`,\n ` actions: ${actionsModule.name}.${actionsModule.exports}`,\n ` channels: ${channelsModule.name}.${channelsModule.exports}`,\n ` events: ${eventsModule.name}.${eventsModule.exports}`,\n ` states: ${statesModule.name}.${statesModule.exports}`,\n ` user: ${stringifySingleLine(integration.user)}`,\n '}',\n '',\n 'export type IntegrationProps = sdk.IntegrationProps<TIntegration>',\n '',\n 'export class Integration extends sdk.Integration<TIntegration> {}',\n '',\n 'export type Client = sdk.IntegrationSpecificClient<TIntegration>',\n ].join('\\n')\n\n return content\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA6C;AAC7C,wBAAoC;AACpC,4BAA8B;AAC9B,6BAA+B;AAC/B,kCAAoC;AACpC,2BAA6B;AAC7B,2BAA6B;AAC7B,oBAAkC;AAG3B,MAAM,6CAA6C,qBAAO;AAAA,EAuCvD,YACE,aACA,cACA,eACA,gBACA,cACA,cACR,KACA;AACA,UAAM,GAAG;AARD;AACA;AACA;AACA;AACA;AACA;AAAA,EAIV;AAAA,EAhDA,aAAoB,OAAO,aAAyF;AAClH,UAAM,eAAe,MAAM,gDAAoB,OAAO,YAAY,iBAAiB,EAAE,QAAQ,CAAC,EAAE,CAAC;AACjG,iBAAa,Q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eAAe,aAAa,gBAAgB;AAAA,MAC5C,eAAe,cAAc,gBAAgB;AAAA,MAC7C,eAAe,eAAe,gBAAgB;AAAA,MAC9C,eAAe,aAAa,gBAAgB;AAAA,MAC5C,eAAe,aAAa,gBAAgB;AAAA,MAC5C;AAAA,MACA;AAAA,MACA,YAAY,YAAY;AAAA,MACxB,eAAe,YAAY;AAAA,MAC3B,oBAAoB,aAAa,QAAQ,aAAa;AAAA,MACtD,cAAc,cAAc,QAAQ,cAAc;AAAA,MAClD,eAAe,eAAe,QAAQ,eAAe;AAAA,MACrD,aAAa,aAAa,QAAQ,aAAa;AAAA,MAC/C,aAAa,aAAa,QAAQ,aAAa;AAAA,MAC/C,eAAW,uCAAoB,YAAY,IAAI;AAAA,MAC/C;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,EAAE,KAAK,IAAI;AAEX,WAAO;AAAA,EACT;AACF;",
4
+ "sourcesContent": ["import { GENERATED_HEADER, INDEX_FILE } from './const'\nimport { stringifySingleLine } from './generators'\nimport { ActionsModule } from './integration-schemas/actions-module'\nimport { ChannelsModule } from './integration-schemas/channels-module'\nimport { ConfigurationModule } from './integration-schemas/configuration-module'\nimport { EventsModule } from './integration-schemas/events-module'\nimport { StatesModule } from './integration-schemas/states-module'\nimport { Module, ModuleDef } from './module'\nimport * as types from './typings'\n\nexport class IntegrationImplementationIndexModule extends Module {\n public static async create(integration: types.IntegrationDefinition): Promise<IntegrationImplementationIndexModule> {\n const configModule = await ConfigurationModule.create(integration.configuration ?? { schema: {} })\n configModule.unshift('configuration')\n\n const actionsModule = await ActionsModule.create(integration.actions ?? {})\n actionsModule.unshift('actions')\n\n const channelsModule = await ChannelsModule.create(integration.channels ?? {})\n channelsModule.unshift('channels')\n\n const eventsModule = await EventsModule.create(integration.events ?? {})\n eventsModule.unshift('events')\n\n const statesModule = await StatesModule.create(integration.states ?? {})\n statesModule.unshift('states')\n\n const inst = new IntegrationImplementationIndexModule(\n integration,\n configModule,\n actionsModule,\n channelsModule,\n eventsModule,\n statesModule,\n {\n path: INDEX_FILE,\n exportName: 'Integration',\n content: '',\n }\n )\n\n inst.pushDep(configModule)\n inst.pushDep(actionsModule)\n inst.pushDep(channelsModule)\n inst.pushDep(eventsModule)\n inst.pushDep(statesModule)\n return inst\n }\n\n private constructor(\n private integration: types.IntegrationDefinition,\n private configModule: ConfigurationModule,\n private actionsModule: ActionsModule,\n private channelsModule: ChannelsModule,\n private eventsModule: EventsModule,\n private statesModule: StatesModule,\n def: ModuleDef\n ) {\n super(def)\n }\n\n public override get content(): string {\n let content = GENERATED_HEADER\n\n const { configModule, actionsModule, channelsModule, eventsModule, statesModule, integration } = this\n\n const configImport = configModule.import(this)\n const actionsImport = actionsModule.import(this)\n const channelsImport = channelsModule.import(this)\n const eventsImport = eventsModule.import(this)\n const statesImport = statesModule.import(this)\n\n content += [\n GENERATED_HEADER,\n 'import * as sdk from \"@botpress/sdk\"',\n '',\n `import type * as ${configModule.name} from \"./${configImport}\"`,\n `import type * as ${actionsModule.name} from \"./${actionsImport}\"`,\n `import type * as ${channelsModule.name} from \"./${channelsImport}\"`,\n `import type * as ${eventsModule.name} from \"./${eventsImport}\"`,\n `import type * as ${statesModule.name} from \"./${statesImport}\"`,\n `export * as ${configModule.name} from \"./${configImport}\"`,\n `export * as ${actionsModule.name} from \"./${actionsImport}\"`,\n `export * as ${channelsModule.name} from \"./${channelsImport}\"`,\n `export * as ${eventsModule.name} from \"./${eventsImport}\"`,\n `export * as ${statesModule.name} from \"./${statesImport}\"`,\n '',\n '// type utils',\n 'type Cast<X, Y> = X extends Y ? X : Y',\n 'type ValueOf<T> = T[keyof T]',\n 'type SimplifyObject<T extends object> = T extends infer O ? { [K in keyof O]: Simplify<O[K]> } : never',\n 'type Simplify<T> = T extends (...args: infer A) => infer R',\n ' ? (...args: Simplify<A>) => Simplify<R>',\n ' : T extends Promise<infer R>',\n ' ? Promise<Simplify<R>>',\n ' : T extends object',\n ' ? SimplifyObject<T>',\n ' : T',\n '',\n 'type TIntegration = {',\n ` name: \"${integration.name}\"`,\n ` version: \"${integration.version}\"`,\n ` configuration: ${configModule.name}.${configModule.exports}`,\n ` actions: ${actionsModule.name}.${actionsModule.exports}`,\n ` channels: ${channelsModule.name}.${channelsModule.exports}`,\n ` events: ${eventsModule.name}.${eventsModule.exports}`,\n ` states: ${statesModule.name}.${statesModule.exports}`,\n ` user: ${stringifySingleLine(integration.user)}`,\n '}',\n '',\n 'export type IntegrationProps = sdk.IntegrationProps<TIntegration>',\n '',\n 'export class Integration extends sdk.Integration<TIntegration> {}',\n '',\n 'export type Client = sdk.IntegrationSpecificClient<TIntegration>',\n '',\n '// extra types',\n '',\n \"export type HandlerProps = Simplify<Parameters<IntegrationProps['handler']>[0]>\",\n '',\n 'export type ActionProps = Simplify<{',\n \" [K in keyof IntegrationProps['actions']]: Parameters<IntegrationProps['actions'][K]>[0]\",\n '}>',\n 'export type AnyActionProps = ValueOf<ActionProps>',\n '',\n 'export type MessageProps = Simplify<{',\n \" [TChannel in keyof IntegrationProps['channels']]: {\",\n \" [TMessage in keyof IntegrationProps['channels'][TChannel]['messages']]: Parameters<\",\n \" IntegrationProps['channels'][TChannel]['messages'][TMessage]\",\n ' >[0]',\n ' }',\n '}>',\n 'export type AnyMessageProps = ValueOf<ValueOf<MessageProps>>',\n '',\n \"export type Context = HandlerProps['ctx']\",\n \"export type Logger = HandlerProps['logger']\",\n '',\n 'export type AckFunctions = {',\n ' [TChannel in keyof MessageProps]: {',\n \" [TMessage in keyof MessageProps[TChannel]]: Cast<MessageProps[TChannel][TMessage], AnyMessageProps>['ack']\",\n ' }',\n '}',\n 'export type AnyAckFunction = ValueOf<ValueOf<AckFunctions>>',\n '',\n 'export type ClientOperation = Simplify<keyof Client>',\n 'export type ClientRequests = Simplify<{',\n ' [K in ClientOperation]: Parameters<Client[K]>[0]',\n '}>',\n 'export type ClientResponses = Simplify<{',\n ' [K in ClientOperation]: Awaited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ACA;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;AAEX,WAAO;AAAA,EACT;AACF;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botpress/cli",
3
- "version": "0.8.14",
3
+ "version": "0.8.18",
4
4
  "description": "Botpress CLI",
5
5
  "scripts": {
6
6
  "build": "pnpm run bundle && pnpm run template:gen",
@@ -20,8 +20,8 @@
20
20
  },
21
21
  "main": "dist/index.js",
22
22
  "dependencies": {
23
- "@botpress/client": "0.17.0",
24
- "@botpress/sdk": "0.8.10",
23
+ "@botpress/client": "0.18.2",
24
+ "@botpress/sdk": "0.8.14",
25
25
  "@bpinternal/const": "^0.0.20",
26
26
  "@bpinternal/tunnel": "^0.1.1",
27
27
  "@bpinternal/yargs-extra": "^0.0.3",
package/readme.md CHANGED
@@ -2,10 +2,6 @@
2
2
 
3
3
  Official Botpress CLI. Made to query to BotpressAPI and simplify the development of bots and integrations as code.
4
4
 
5
- ## Disclaimer āš ļø
6
-
7
- This package is still in development and is not ready for production use. Use it at your own risk.
8
-
9
5
  ## Installation
10
6
 
11
7
  ```bash
@@ -5,8 +5,8 @@
5
5
  },
6
6
  "private": true,
7
7
  "dependencies": {
8
- "@botpress/client": "0.17.0",
9
- "@botpress/sdk": "0.8.10"
8
+ "@botpress/client": "0.18.2",
9
+ "@botpress/sdk": "0.8.14"
10
10
  },
11
11
  "devDependencies": {
12
12
  "@types/node": "^18.11.17",
@@ -18,6 +18,18 @@ export * as channels from "./channels/index"
18
18
  export * as events from "./events/index"
19
19
  export * as states from "./states/index"
20
20
 
21
+ // type utils
22
+ type Cast<X, Y> = X extends Y ? X : Y
23
+ type ValueOf<T> = T[keyof T]
24
+ type SimplifyObject<T extends object> = T extends infer O ? { [K in keyof O]: Simplify<O[K]> } : never
25
+ type Simplify<T> = T extends (...args: infer A) => infer R
26
+ ? (...args: Simplify<A>) => Simplify<R>
27
+ : T extends Promise<infer R>
28
+ ? Promise<Simplify<R>>
29
+ : T extends object
30
+ ? SimplifyObject<T>
31
+ : T
32
+
21
33
  type TIntegration = {
22
34
  name: "empty-integration"
23
35
  version: "0.0.1"
@@ -33,4 +45,40 @@ export type IntegrationProps = sdk.IntegrationProps<TIntegration>
33
45
 
34
46
  export class Integration extends sdk.Integration<TIntegration> {}
35
47
 
36
- export type Client = sdk.IntegrationSpecificClient<TIntegration>
48
+ export type Client = sdk.IntegrationSpecificClient<TIntegration>
49
+
50
+ // extra types
51
+
52
+ export type HandlerProps = Simplify<Parameters<IntegrationProps['handler']>[0]>
53
+
54
+ export type ActionProps = Simplify<{
55
+ [K in keyof IntegrationProps['actions']]: Parameters<IntegrationProps['actions'][K]>[0]
56
+ }>
57
+ export type AnyActionProps = ValueOf<ActionProps>
58
+
59
+ export type MessageProps = Simplify<{
60
+ [TChannel in keyof IntegrationProps['channels']]: {
61
+ [TMessage in keyof IntegrationProps['channels'][TChannel]['messages']]: Parameters<
62
+ IntegrationProps['channels'][TChannel]['messages'][TMessage]
63
+ >[0]
64
+ }
65
+ }>
66
+ export type AnyMessageProps = ValueOf<ValueOf<MessageProps>>
67
+
68
+ export type Context = HandlerProps['ctx']
69
+ export type Logger = HandlerProps['logger']
70
+
71
+ export type AckFunctions = {
72
+ [TChannel in keyof MessageProps]: {
73
+ [TMessage in keyof MessageProps[TChannel]]: Cast<MessageProps[TChannel][TMessage], AnyMessageProps>['ack']
74
+ }
75
+ }
76
+ export type AnyAckFunction = ValueOf<ValueOf<AckFunctions>>
77
+
78
+ export type ClientOperation = Simplify<keyof Client>
79
+ export type ClientRequests = Simplify<{
80
+ [K in ClientOperation]: Parameters<Client[K]>[0]
81
+ }>
82
+ export type ClientResponses = Simplify<{
83
+ [K in ClientOperation]: Awaited<ReturnType<Client[K]>>
84
+ }>
@@ -6,8 +6,8 @@
6
6
  },
7
7
  "private": true,
8
8
  "dependencies": {
9
- "@botpress/client": "0.17.0",
10
- "@botpress/sdk": "0.8.10"
9
+ "@botpress/client": "0.18.2",
10
+ "@botpress/sdk": "0.8.14"
11
11
  },
12
12
  "devDependencies": {
13
13
  "@types/node": "^18.11.17",
@@ -18,6 +18,18 @@ export * as channels from "./channels/index"
18
18
  export * as events from "./events/index"
19
19
  export * as states from "./states/index"
20
20
 
21
+ // type utils
22
+ type Cast<X, Y> = X extends Y ? X : Y
23
+ type ValueOf<T> = T[keyof T]
24
+ type SimplifyObject<T extends object> = T extends infer O ? { [K in keyof O]: Simplify<O[K]> } : never
25
+ type Simplify<T> = T extends (...args: infer A) => infer R
26
+ ? (...args: Simplify<A>) => Simplify<R>
27
+ : T extends Promise<infer R>
28
+ ? Promise<Simplify<R>>
29
+ : T extends object
30
+ ? SimplifyObject<T>
31
+ : T
32
+
21
33
  type TIntegration = {
22
34
  name: "hello-world"
23
35
  version: "0.0.1"
@@ -33,4 +45,40 @@ export type IntegrationProps = sdk.IntegrationProps<TIntegration>
33
45
 
34
46
  export class Integration extends sdk.Integration<TIntegration> {}
35
47
 
36
- export type Client = sdk.IntegrationSpecificClient<TIntegration>
48
+ export type Client = sdk.IntegrationSpecificClient<TIntegration>
49
+
50
+ // extra types
51
+
52
+ export type HandlerProps = Simplify<Parameters<IntegrationProps['handler']>[0]>
53
+
54
+ export type ActionProps = Simplify<{
55
+ [K in keyof IntegrationProps['actions']]: Parameters<IntegrationProps['actions'][K]>[0]
56
+ }>
57
+ export type AnyActionProps = ValueOf<ActionProps>
58
+
59
+ export type MessageProps = Simplify<{
60
+ [TChannel in keyof IntegrationProps['channels']]: {
61
+ [TMessage in keyof IntegrationProps['channels'][TChannel]['messages']]: Parameters<
62
+ IntegrationProps['channels'][TChannel]['messages'][TMessage]
63
+ >[0]
64
+ }
65
+ }>
66
+ export type AnyMessageProps = ValueOf<ValueOf<MessageProps>>
67
+
68
+ export type Context = HandlerProps['ctx']
69
+ export type Logger = HandlerProps['logger']
70
+
71
+ export type AckFunctions = {
72
+ [TChannel in keyof MessageProps]: {
73
+ [TMessage in keyof MessageProps[TChannel]]: Cast<MessageProps[TChannel][TMessage], AnyMessageProps>['ack']
74
+ }
75
+ }
76
+ export type AnyAckFunction = ValueOf<ValueOf<AckFunctions>>
77
+
78
+ export type ClientOperation = Simplify<keyof Client>
79
+ export type ClientRequests = Simplify<{
80
+ [K in ClientOperation]: Parameters<Client[K]>[0]
81
+ }>
82
+ export type ClientResponses = Simplify<{
83
+ [K in ClientOperation]: Awaited<ReturnType<Client[K]>>
84
+ }>
@@ -6,8 +6,8 @@
6
6
  },
7
7
  "private": true,
8
8
  "dependencies": {
9
- "@botpress/client": "0.17.0",
10
- "@botpress/sdk": "0.8.10"
9
+ "@botpress/client": "0.18.2",
10
+ "@botpress/sdk": "0.8.14"
11
11
  },
12
12
  "devDependencies": {
13
13
  "@types/node": "^18.11.17",
@@ -18,6 +18,18 @@ export * as channels from "./channels/index"
18
18
  export * as events from "./events/index"
19
19
  export * as states from "./states/index"
20
20
 
21
+ // type utils
22
+ type Cast<X, Y> = X extends Y ? X : Y
23
+ type ValueOf<T> = T[keyof T]
24
+ type SimplifyObject<T extends object> = T extends infer O ? { [K in keyof O]: Simplify<O[K]> } : never
25
+ type Simplify<T> = T extends (...args: infer A) => infer R
26
+ ? (...args: Simplify<A>) => Simplify<R>
27
+ : T extends Promise<infer R>
28
+ ? Promise<Simplify<R>>
29
+ : T extends object
30
+ ? SimplifyObject<T>
31
+ : T
32
+
21
33
  type TIntegration = {
22
34
  name: "webhook-message"
23
35
  version: "0.0.1"
@@ -33,4 +45,40 @@ export type IntegrationProps = sdk.IntegrationProps<TIntegration>
33
45
 
34
46
  export class Integration extends sdk.Integration<TIntegration> {}
35
47
 
36
- export type Client = sdk.IntegrationSpecificClient<TIntegration>
48
+ export type Client = sdk.IntegrationSpecificClient<TIntegration>
49
+
50
+ // extra types
51
+
52
+ export type HandlerProps = Simplify<Parameters<IntegrationProps['handler']>[0]>
53
+
54
+ export type ActionProps = Simplify<{
55
+ [K in keyof IntegrationProps['actions']]: Parameters<IntegrationProps['actions'][K]>[0]
56
+ }>
57
+ export type AnyActionProps = ValueOf<ActionProps>
58
+
59
+ export type MessageProps = Simplify<{
60
+ [TChannel in keyof IntegrationProps['channels']]: {
61
+ [TMessage in keyof IntegrationProps['channels'][TChannel]['messages']]: Parameters<
62
+ IntegrationProps['channels'][TChannel]['messages'][TMessage]
63
+ >[0]
64
+ }
65
+ }>
66
+ export type AnyMessageProps = ValueOf<ValueOf<MessageProps>>
67
+
68
+ export type Context = HandlerProps['ctx']
69
+ export type Logger = HandlerProps['logger']
70
+
71
+ export type AckFunctions = {
72
+ [TChannel in keyof MessageProps]: {
73
+ [TMessage in keyof MessageProps[TChannel]]: Cast<MessageProps[TChannel][TMessage], AnyMessageProps>['ack']
74
+ }
75
+ }
76
+ export type AnyAckFunction = ValueOf<ValueOf<AckFunctions>>
77
+
78
+ export type ClientOperation = Simplify<keyof Client>
79
+ export type ClientRequests = Simplify<{
80
+ [K in ClientOperation]: Parameters<Client[K]>[0]
81
+ }>
82
+ export type ClientResponses = Simplify<{
83
+ [K in ClientOperation]: Awaited<ReturnType<Client[K]>>
84
+ }>
@@ -6,8 +6,8 @@
6
6
  },
7
7
  "private": true,
8
8
  "dependencies": {
9
- "@botpress/client": "0.17.0",
10
- "@botpress/sdk": "0.8.10",
9
+ "@botpress/client": "0.18.2",
10
+ "@botpress/sdk": "0.8.14",
11
11
  "axios": "^1.6.8"
12
12
  },
13
13
  "devDependencies": {