@botpress/sdk 6.8.0 → 6.9.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.
@@ -1,20 +1,20 @@
1
1
 
2
- > @botpress/sdk@6.8.0 build /home/runner/work/botpress/botpress/packages/sdk
2
+ > @botpress/sdk@6.9.1 build /home/runner/work/botpress/botpress/packages/sdk
3
3
  > pnpm build:type && pnpm build:node && pnpm build:browser
4
4
 
5
5
 
6
- > @botpress/sdk@6.8.0 build:type /home/runner/work/botpress/botpress/packages/sdk
6
+ > @botpress/sdk@6.9.1 build:type /home/runner/work/botpress/botpress/packages/sdk
7
7
  > tsc -p ./tsconfig.package.json --emitDeclarationOnly --declaration
8
8
 
9
9
 
10
- > @botpress/sdk@6.8.0 build:node /home/runner/work/botpress/botpress/packages/sdk
10
+ > @botpress/sdk@6.9.1 build:node /home/runner/work/botpress/botpress/packages/sdk
11
11
  > ts-node -T ./build.ts --node
12
12
 
13
13
  Done
14
14
 
15
- > @botpress/sdk@6.8.0 build:browser /home/runner/work/botpress/botpress/packages/sdk
15
+ > @botpress/sdk@6.9.1 build:browser /home/runner/work/botpress/botpress/packages/sdk
16
16
  > ts-node -T ./build.ts --browser
17
17
 
18
- (node:3369) [DEP0180] DeprecationWarning: fs.Stats constructor is deprecated.
18
+ (node:3331) [DEP0180] DeprecationWarning: fs.Stats constructor is deprecated.
19
19
  (Use `node --trace-deprecation ...` to show where the warning was created)
20
20
  Done
@@ -190,6 +190,12 @@ export type WorkflowHandlers<TBot extends common.BaseBot> = {
190
190
  type BaseHookDefinition = {
191
191
  stoppable?: boolean;
192
192
  data: any;
193
+ /**
194
+ * Per-hook-type extra props injected into the hook handler input. Only set
195
+ * for hooks where the bot runtime already has the relevant context (e.g.
196
+ * incoming message hooks).
197
+ */
198
+ extraInputs?: object;
193
199
  };
194
200
  type HookDefinition<THookDef extends BaseHookDefinition = BaseHookDefinition> = THookDef;
195
201
  /**
@@ -211,6 +217,10 @@ export type HookDefinitions<TBot extends common.BaseBot> = {
211
217
  data: _IncomingMessages<TBot> & {
212
218
  '*': AnyIncomingMessage<TBot>;
213
219
  };
220
+ extraInputs: {
221
+ user?: client.User;
222
+ conversation?: client.Conversation;
223
+ };
214
224
  }>;
215
225
  before_outgoing_message: HookDefinition<{
216
226
  stoppable: false;
@@ -241,6 +251,10 @@ export type HookDefinitions<TBot extends common.BaseBot> = {
241
251
  data: _IncomingMessages<TBot> & {
242
252
  '*': AnyIncomingMessage<TBot>;
243
253
  };
254
+ extraInputs: {
255
+ user?: client.User;
256
+ conversation?: client.Conversation;
257
+ };
244
258
  }>;
245
259
  after_outgoing_message: HookDefinition<{
246
260
  stoppable: false;
@@ -266,9 +280,14 @@ export type HookData<TBot extends common.BaseBot> = {
266
280
  [THookDataName in utils.StringKeys<HookDefinitions<TBot>[THookType]['data']>]: HookDefinitions<TBot>[THookType]['data'][THookDataName];
267
281
  };
268
282
  };
283
+ type _HookExtraInputs<TBot extends common.BaseBot> = {
284
+ [THookType in utils.StringKeys<HookDefinitions<TBot>>]: HookDefinitions<TBot>[THookType] extends {
285
+ extraInputs: infer T;
286
+ } ? T : {};
287
+ };
269
288
  export type HookInputs<TBot extends common.BaseBot> = {
270
289
  [THookType in utils.StringKeys<HookData<TBot>>]: {
271
- [THookDataName in utils.StringKeys<HookData<TBot>[THookType]>]: ExtendedHandlerProps<TBot> & {
290
+ [THookDataName in utils.StringKeys<HookData<TBot>[THookType]>]: ExtendedHandlerProps<TBot> & _HookExtraInputs<TBot>[THookType] & {
272
291
  data: HookData<TBot>[THookType][THookDataName];
273
292
  };
274
293
  };
@@ -1,6 +1,7 @@
1
1
  import * as typeUtils from '../utils/type-utils';
2
2
  import { z } from '../zui';
3
3
  export type ToTags<TTags extends string | number | symbol> = typeUtils.Cast<Partial<Record<TTags, string>>, Record<string, string>>;
4
+ export type ToNullableTags<TTags extends string | number | symbol> = typeUtils.Cast<Partial<Record<TTags, string | null>>, Record<string, string | null>>;
4
5
  export type SchemaTransformOptions = {
5
6
  useLegacyZuiTransformer?: boolean;
6
7
  toJSONSchemaOptions?: Partial<z.transforms.JSONSchemaGenerationOptions>;