@holocronlab/botruntime-sdk 6.13.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/LICENSE +8 -0
  2. package/dist/base-logger.d.ts +34 -0
  3. package/dist/base-logger.test.d.ts +1 -0
  4. package/dist/bot/bot-logger.d.ts +18 -0
  5. package/dist/bot/client/index.d.ts +80 -0
  6. package/dist/bot/client/types.d.ts +254 -0
  7. package/dist/bot/client/types.test.d.ts +1 -0
  8. package/dist/bot/common/generic.d.ts +41 -0
  9. package/dist/bot/common/generic.test.d.ts +1 -0
  10. package/dist/bot/common/index.d.ts +2 -0
  11. package/dist/bot/common/types.d.ts +54 -0
  12. package/dist/bot/common/types.test.d.ts +1 -0
  13. package/dist/bot/definition.d.ts +214 -0
  14. package/dist/bot/definition.test.d.ts +1 -0
  15. package/dist/bot/implementation.d.ts +72 -0
  16. package/dist/bot/implementation.test.d.ts +1 -0
  17. package/dist/bot/index.d.ts +6 -0
  18. package/dist/bot/server/context.d.ts +2 -0
  19. package/dist/bot/server/index.d.ts +5 -0
  20. package/dist/bot/server/responses.d.ts +3 -0
  21. package/dist/bot/server/types.d.ts +423 -0
  22. package/dist/bot/server/types.test.d.ts +1 -0
  23. package/dist/bot/server/workflows/update-handler.d.ts +3 -0
  24. package/dist/bot/server/workflows/update-type-conv.d.ts +2 -0
  25. package/dist/bot/workflow-proxy/index.d.ts +2 -0
  26. package/dist/bot/workflow-proxy/proxy.d.ts +17 -0
  27. package/dist/bot/workflow-proxy/types.d.ts +80 -0
  28. package/dist/bot/workflow-proxy/types.test.d.ts +1 -0
  29. package/dist/common/index.d.ts +1 -0
  30. package/dist/common/recurring-events.d.ts +9 -0
  31. package/dist/common/recurring-events.test.d.ts +1 -0
  32. package/dist/common/types.d.ts +8 -0
  33. package/dist/consts.d.ts +11 -0
  34. package/dist/errors.d.ts +19 -0
  35. package/dist/fixtures.d.ts +357 -0
  36. package/dist/index.cjs +5 -0
  37. package/dist/index.cjs.map +7 -0
  38. package/dist/index.d.ts +17 -0
  39. package/dist/index.mjs +34 -0
  40. package/dist/index.mjs.map +7 -0
  41. package/dist/integration/client/index.d.ts +55 -0
  42. package/dist/integration/client/sub-types.d.ts +27 -0
  43. package/dist/integration/client/sub-types.test.d.ts +1 -0
  44. package/dist/integration/client/types.d.ts +209 -0
  45. package/dist/integration/client/types.test.d.ts +1 -0
  46. package/dist/integration/common/generic.d.ts +57 -0
  47. package/dist/integration/common/generic.test.d.ts +1 -0
  48. package/dist/integration/common/index.d.ts +1 -0
  49. package/dist/integration/definition/branded-schema.d.ts +21 -0
  50. package/dist/integration/definition/definition.test.d.ts +1 -0
  51. package/dist/integration/definition/generic.d.ts +9 -0
  52. package/dist/integration/definition/index.d.ts +130 -0
  53. package/dist/integration/definition/types.d.ts +119 -0
  54. package/dist/integration/implementation.d.ts +37 -0
  55. package/dist/integration/index.d.ts +5 -0
  56. package/dist/integration/server/action-metadata.d.ts +9 -0
  57. package/dist/integration/server/context.d.ts +4 -0
  58. package/dist/integration/server/index.d.ts +6 -0
  59. package/dist/integration/server/integration-logger.d.ts +36 -0
  60. package/dist/integration/server/types.d.ts +108 -0
  61. package/dist/interface/common/generic.d.ts +34 -0
  62. package/dist/interface/common/generic.test.d.ts +1 -0
  63. package/dist/interface/common/index.d.ts +1 -0
  64. package/dist/interface/definition.d.ts +87 -0
  65. package/dist/interface/index.d.ts +2 -0
  66. package/dist/interface/resolve.d.ts +18 -0
  67. package/dist/log.d.ts +7 -0
  68. package/dist/message.d.ts +742 -0
  69. package/dist/package.d.ts +64 -0
  70. package/dist/plugin/action-proxy/index.d.ts +2 -0
  71. package/dist/plugin/action-proxy/proxy.d.ts +5 -0
  72. package/dist/plugin/action-proxy/types.d.ts +14 -0
  73. package/dist/plugin/action-proxy/types.test.d.ts +1 -0
  74. package/dist/plugin/common/generic.d.ts +63 -0
  75. package/dist/plugin/common/generic.test.d.ts +1 -0
  76. package/dist/plugin/common/index.d.ts +2 -0
  77. package/dist/plugin/common/types.d.ts +59 -0
  78. package/dist/plugin/conversation-proxy/index.d.ts +2 -0
  79. package/dist/plugin/conversation-proxy/proxy.d.ts +13 -0
  80. package/dist/plugin/conversation-proxy/types.d.ts +54 -0
  81. package/dist/plugin/conversation-proxy/types.test.d.ts +1 -0
  82. package/dist/plugin/definition.d.ts +152 -0
  83. package/dist/plugin/definition.test.d.ts +1 -0
  84. package/dist/plugin/event-proxy/index.d.ts +2 -0
  85. package/dist/plugin/event-proxy/proxy.d.ts +5 -0
  86. package/dist/plugin/event-proxy/types.d.ts +19 -0
  87. package/dist/plugin/event-proxy/types.test.d.ts +1 -0
  88. package/dist/plugin/implementation.d.ts +71 -0
  89. package/dist/plugin/implementation.test.d.ts +1 -0
  90. package/dist/plugin/index.d.ts +4 -0
  91. package/dist/plugin/message-proxy/index.d.ts +2 -0
  92. package/dist/plugin/message-proxy/proxy.d.ts +13 -0
  93. package/dist/plugin/message-proxy/types.d.ts +22 -0
  94. package/dist/plugin/server/index.d.ts +1 -0
  95. package/dist/plugin/server/types.d.ts +505 -0
  96. package/dist/plugin/server/types.test.d.ts +1 -0
  97. package/dist/plugin/state-proxy/index.d.ts +2 -0
  98. package/dist/plugin/state-proxy/proxy.d.ts +5 -0
  99. package/dist/plugin/state-proxy/types.d.ts +29 -0
  100. package/dist/plugin/state-proxy/types.test.d.ts +1 -0
  101. package/dist/plugin/tag-prefixer.d.ts +10 -0
  102. package/dist/plugin/tag-prefixer.test.d.ts +1 -0
  103. package/dist/plugin/user-proxy/index.d.ts +2 -0
  104. package/dist/plugin/user-proxy/proxy.d.ts +14 -0
  105. package/dist/plugin/user-proxy/types.d.ts +30 -0
  106. package/dist/public-consts.d.ts +9 -0
  107. package/dist/retry.d.ts +2 -0
  108. package/dist/retry.test.d.ts +1 -0
  109. package/dist/schema.d.ts +18 -0
  110. package/dist/serve.d.ts +38 -0
  111. package/dist/utils/api-paging-utils.d.ts +43 -0
  112. package/dist/utils/api-paging-utils.test.d.ts +1 -0
  113. package/dist/utils/array-utils.d.ts +2 -0
  114. package/dist/utils/error-utils.d.ts +4 -0
  115. package/dist/utils/function-utils.d.ts +2 -0
  116. package/dist/utils/function-utils.test.d.ts +1 -0
  117. package/dist/utils/index.d.ts +4 -0
  118. package/dist/utils/record-utils.d.ts +6 -0
  119. package/dist/utils/record-utils.test.d.ts +1 -0
  120. package/dist/utils/type-utils.d.ts +63 -0
  121. package/dist/utils/type-utils.test.d.ts +1 -0
  122. package/dist/version-utils.d.ts +18 -0
  123. package/dist/version.d.ts +1 -0
  124. package/dist/zui.d.ts +9 -0
  125. package/package.json +59 -0
  126. package/readme.md +11 -0
@@ -0,0 +1,64 @@
1
+ import * as integration from './integration';
2
+ import * as plugin from './plugin';
3
+ import * as utils from './utils/type-utils';
4
+ type NameVersion = {
5
+ name: string;
6
+ version: string;
7
+ };
8
+ type PackageReference = NameVersion & {
9
+ id?: string;
10
+ uri?: string;
11
+ };
12
+ type Attributes = {
13
+ attributes?: Record<string, string>;
14
+ };
15
+ type IntegrationPackageDefinitionInterface = utils.Merge<PackageReference, integration.InterfaceExtension>;
16
+ type IntegrationPackageDefinition = NameVersion & Attributes & {
17
+ configuration?: integration.ConfigurationDefinition;
18
+ configurations?: Record<string, integration.AdditionalConfigurationDefinition>;
19
+ events?: Record<string, integration.EventDefinition>;
20
+ actions?: Record<string, integration.ActionDefinition>;
21
+ channels?: Record<string, integration.ChannelDefinition>;
22
+ states?: Record<string, integration.StateDefinition>;
23
+ user?: integration.UserDefinition;
24
+ secrets?: Record<string, integration.SecretDefinition>;
25
+ entities?: Record<string, integration.EntityDefinition>;
26
+ interfaces?: Record<string, IntegrationPackageDefinitionInterface>;
27
+ };
28
+ type InterfacePackageDefinition = NameVersion & Attributes & {
29
+ entities?: Record<string, integration.EntityDefinition>;
30
+ events?: Record<string, integration.EventDefinition>;
31
+ actions?: Record<string, integration.ActionDefinition>;
32
+ channels?: Record<string, integration.ChannelDefinition>;
33
+ };
34
+ type PluginPackageDefinition = NameVersion & Attributes & {
35
+ integrations?: Record<string, PackageReference>;
36
+ interfaces?: Record<string, PackageReference>;
37
+ user?: plugin.UserDefinition;
38
+ conversation?: plugin.ConversationDefinition;
39
+ message?: plugin.MessageDefinition;
40
+ states?: Record<string, plugin.StateDefinition>;
41
+ configuration?: plugin.ConfigurationDefinition;
42
+ events?: Record<string, plugin.EventDefinition>;
43
+ recurringEvents?: Record<string, plugin.RecurringEventDefinition>;
44
+ actions?: Record<string, plugin.ActionDefinition>;
45
+ tables?: Record<string, plugin.TableDefinition>;
46
+ workflows?: Record<string, plugin.WorkflowDefinition>;
47
+ };
48
+ export type IntegrationPackage = PackageReference & {
49
+ type: 'integration';
50
+ definition: IntegrationPackageDefinition;
51
+ implementation?: null;
52
+ };
53
+ export type InterfacePackage = PackageReference & {
54
+ type: 'interface';
55
+ definition: InterfacePackageDefinition;
56
+ implementation?: null;
57
+ };
58
+ export type PluginPackage = PackageReference & {
59
+ type: 'plugin';
60
+ definition: PluginPackageDefinition;
61
+ implementation: Buffer;
62
+ };
63
+ export type Package = IntegrationPackage | InterfacePackage | PluginPackage;
64
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from './proxy';
2
+ export * from './types';
@@ -0,0 +1,5 @@
1
+ import { Client } from '@holocronlab/botruntime-client';
2
+ import { BotSpecificClient } from '../../bot';
3
+ import { BasePlugin, PluginRuntimeProps } from '../common';
4
+ import { ActionProxy } from './types';
5
+ export declare const proxyActions: <TPlugin extends BasePlugin>(client: BotSpecificClient<TPlugin> | Client, props: PluginRuntimeProps<TPlugin>) => ActionProxy<TPlugin>;
@@ -0,0 +1,14 @@
1
+ import * as utils from '../../utils/type-utils';
2
+ import { BasePlugin } from '../common';
3
+ type IntegrationActionProxy<TPlugin extends BasePlugin> = {
4
+ [TIntegrationName in keyof TPlugin['integrations']]: {
5
+ [TActionName in keyof TPlugin['integrations'][TIntegrationName]['actions']]: (input: TPlugin['integrations'][TIntegrationName]['actions'][TActionName]['input']) => Promise<TPlugin['integrations'][TIntegrationName]['actions'][TActionName]['output']>;
6
+ };
7
+ };
8
+ type InterfacesActionProxy<TPlugin extends BasePlugin> = {
9
+ [TInterfaceName in keyof TPlugin['interfaces']]: {
10
+ [TActionName in keyof TPlugin['interfaces'][TInterfaceName]['actions']]: (input: TPlugin['interfaces'][TInterfaceName]['actions'][TActionName]['input']) => Promise<TPlugin['interfaces'][TInterfaceName]['actions'][TActionName]['output']>;
11
+ };
12
+ };
13
+ export type ActionProxy<TPlugin extends BasePlugin> = utils.Normalize<IntegrationActionProxy<TPlugin> & InterfacesActionProxy<TPlugin>>;
14
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,63 @@
1
+ import * as bot from '../../bot';
2
+ import { BaseIntegration, DefaultIntegration, InputBaseIntegration } from '../../integration/common/generic';
3
+ import { BaseInterface, InputBaseInterface, DefaultInterface } from '../../interface/common/generic';
4
+ import * as utils from '../../utils/type-utils';
5
+ export type BaseAction = {
6
+ input: any;
7
+ output: any;
8
+ };
9
+ export type BaseTable = {
10
+ [k: string]: any;
11
+ };
12
+ export type BaseWorkflow = {
13
+ input: any;
14
+ output: any;
15
+ tags?: {
16
+ [k: string]: string;
17
+ };
18
+ };
19
+ export type BaseState = {
20
+ type: bot.StateType;
21
+ payload: any;
22
+ };
23
+ export type BasePlugin = {
24
+ name: string;
25
+ version: string;
26
+ configuration: any;
27
+ integrations: Record<string, BaseIntegration>;
28
+ interfaces: Record<string, BaseInterface>;
29
+ events: Record<string, any>;
30
+ states: Record<string, BaseState>;
31
+ actions: Record<string, BaseAction>;
32
+ tables: Record<string, BaseTable>;
33
+ workflows: Record<string, BaseWorkflow>;
34
+ conversation: {
35
+ tags: Record<string, any>;
36
+ };
37
+ user: {
38
+ tags: Record<string, any>;
39
+ };
40
+ message: {
41
+ tags: Record<string, any>;
42
+ };
43
+ };
44
+ export type InputBasePlugin = utils.DeepPartial<BasePlugin>;
45
+ export type DefaultPlugin<B extends utils.DeepPartial<BasePlugin>> = {
46
+ name: utils.Default<B['name'], BasePlugin['name']>;
47
+ version: utils.Default<B['version'], BasePlugin['version']>;
48
+ configuration: utils.Default<B['configuration'], BasePlugin['configuration']>;
49
+ events: utils.Default<B['events'], BasePlugin['events']>;
50
+ states: utils.Default<B['states'], BasePlugin['states']>;
51
+ actions: utils.Default<B['actions'], BasePlugin['actions']>;
52
+ tables: utils.Default<B['tables'], BasePlugin['tables']>;
53
+ workflows: utils.Default<B['workflows'], BasePlugin['workflows']>;
54
+ integrations: undefined extends B['integrations'] ? BasePlugin['integrations'] : {
55
+ [K in keyof B['integrations']]: DefaultIntegration<utils.Cast<B['integrations'][K], InputBaseIntegration>>;
56
+ };
57
+ interfaces: undefined extends B['interfaces'] ? BasePlugin['interfaces'] : {
58
+ [K in keyof B['interfaces']]: DefaultInterface<utils.Cast<B['interfaces'][K], InputBaseInterface>>;
59
+ };
60
+ conversation: utils.Default<B['conversation'], BasePlugin['conversation']>;
61
+ user: utils.Default<B['user'], BasePlugin['user']>;
62
+ message: utils.Default<B['message'], BasePlugin['message']>;
63
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from './types';
2
+ export * from './generic';
@@ -0,0 +1,59 @@
1
+ import type { BaseInterface } from '../../interface';
2
+ import type { Cast, Join, UnionToIntersection } from '../../utils/type-utils';
3
+ import type { BasePlugin } from './generic';
4
+ type EventKey<TIntegrationName extends string, TEventName extends string> = string extends TIntegrationName ? string : string extends TEventName ? string : Join<[TIntegrationName, ':', TEventName]>;
5
+ export type EnumerateInterfaceEvents<TPlugin extends BasePlugin> = UnionToIntersection<{
6
+ [TInterfaceName in keyof TPlugin['interfaces']]: {
7
+ [TEventName in keyof TPlugin['interfaces'][TInterfaceName]['events'] as EventKey<Cast<TInterfaceName, string>, Cast<TEventName, string>>]: TPlugin['interfaces'][TInterfaceName]['events'][TEventName];
8
+ };
9
+ }[keyof TPlugin['interfaces']]>;
10
+ /**
11
+ * Used by a bot to tell the plugin what integration should be used to implement an interface.
12
+ */
13
+ export type PluginInterfaceExtension<TInterface extends BaseInterface = BaseInterface> = {
14
+ id?: string;
15
+ name: string;
16
+ version: string;
17
+ integrationAlias: string;
18
+ integrationInterfaceAlias: string;
19
+ entities: {
20
+ [K in keyof TInterface['entities']]: {
21
+ name: string;
22
+ };
23
+ };
24
+ actions: {
25
+ [K in keyof TInterface['actions']]: {
26
+ name: string;
27
+ };
28
+ };
29
+ events: {
30
+ [K in keyof TInterface['events']]: {
31
+ name: string;
32
+ };
33
+ };
34
+ channels: {
35
+ [K in keyof TInterface['channels']]: {
36
+ name: string;
37
+ };
38
+ };
39
+ };
40
+ export type PluginIntegrationExtension = {
41
+ id?: string;
42
+ name: string;
43
+ version: string;
44
+ integrationAlias: string;
45
+ };
46
+ export type PluginInterfaceExtensions<TPlugin extends BasePlugin = BasePlugin> = {
47
+ [TPluginInterfaceAlias in keyof TPlugin['interfaces']]: PluginInterfaceExtension<TPlugin['interfaces'][TPluginInterfaceAlias]>;
48
+ };
49
+ export type PluginIntegrationExtensions<TPlugin extends BasePlugin = BasePlugin> = {
50
+ [TPluginIntegrationAlias in keyof TPlugin['integrations']]: PluginIntegrationExtension;
51
+ };
52
+ export type PluginConfiguration<TPlugin extends BasePlugin> = TPlugin['configuration'];
53
+ export type PluginRuntimeProps<TPlugin extends BasePlugin = BasePlugin> = {
54
+ alias: string;
55
+ configuration: PluginConfiguration<TPlugin>;
56
+ interfaces: PluginInterfaceExtensions<TPlugin>;
57
+ integrations: PluginIntegrationExtensions<TPlugin>;
58
+ };
59
+ export {};
@@ -0,0 +1,2 @@
1
+ export { proxyConversation, proxyConversations } from './proxy';
2
+ export { ActionableConversation, ConversationFinder } from './types';
@@ -0,0 +1,13 @@
1
+ import type * as client from '@holocronlab/botruntime-client';
2
+ import type { BotSpecificClient } from '../../bot';
3
+ import type { BasePlugin, PluginRuntimeProps } from '../common';
4
+ import type { ActionableConversation, ConversationFinder } from './types';
5
+ export declare const proxyConversations: <TPlugin extends BasePlugin>(props: {
6
+ client: BotSpecificClient<TPlugin> | client.Client;
7
+ plugin?: PluginRuntimeProps<TPlugin>;
8
+ }) => ConversationFinder<TPlugin>;
9
+ export declare const proxyConversation: <TPlugin extends BasePlugin>(props: {
10
+ client: BotSpecificClient<TPlugin> | client.Client;
11
+ plugin?: PluginRuntimeProps<TPlugin>;
12
+ conversation: client.Conversation;
13
+ }) => ActionableConversation<TPlugin>;
@@ -0,0 +1,54 @@
1
+ import type * as client from '@holocronlab/botruntime-client';
2
+ import type { commonTypes } from '../../common';
3
+ import type { AsyncCollection } from '../../utils/api-paging-utils';
4
+ import type * as typeUtils from '../../utils/type-utils';
5
+ import type { BasePlugin } from '../common';
6
+ import type * as messageProxy from '../message-proxy/types';
7
+ import type * as userProxy from '../user-proxy/types';
8
+ export type ConversationFinder<TPlugin extends BasePlugin> = _ConversationFinderForDepType<TPlugin, 'interfaces'> & _ConversationFinderForDepType<TPlugin, 'integrations'>;
9
+ type _ConversationFinderForDepType<TPlugin extends BasePlugin, TDepType extends 'interfaces' | 'integrations'> = {
10
+ [TAlias in typeUtils.StringKeys<TPlugin[TDepType]> | '*']: {
11
+ [TChannelName in TAlias extends '*' ? '*' : typeUtils.StringKeys<TPlugin[TDepType][TAlias]['channels']> | '*']: _ConversationFinderForChannel<TPlugin, TChannelName, _MessageForChannel<TPlugin, TDepType, TAlias extends '*' ? string : TAlias, TChannelName extends '*' ? string : TChannelName>>;
12
+ };
13
+ };
14
+ type _ConversationFinderForChannel<TPlugin extends BasePlugin, TChannelName extends string, TMessage extends client.Message> = {
15
+ list: (props?: typeUtils.Merge<Omit<client.ClientInputs['listConversations'], 'integrationName' | 'channel' | 'nextToken'>, {
16
+ tags?: commonTypes.ToTags<typeUtils.StringKeys<TPlugin['conversation']['tags']>>;
17
+ }>) => AsyncCollection<ActionableConversation<TPlugin, TChannelName extends '*' ? string : TChannelName, TMessage>>;
18
+ getById: (props: {
19
+ id: string;
20
+ }) => Promise<ActionableConversation<TPlugin, TChannelName extends '*' ? string : TChannelName, TMessage>>;
21
+ };
22
+ type _MessageForChannel<TPlugin extends BasePlugin, TDepType extends 'interfaces' | 'integrations', TAlias extends keyof TPlugin[TDepType], TChannelName extends keyof TPlugin[TDepType][TAlias]['channels']> = _FallbackWhenNever<Omit<client.Message, 'type' | 'payload' | 'tags'> & typeUtils.ValueOf<{
23
+ [TMessageName in typeUtils.StringKeys<TPlugin[TDepType][TAlias]['channels'][TChannelName]['messages']>]: {
24
+ type: TMessageName;
25
+ payload: TPlugin[TDepType][TAlias]['channels'][TChannelName]['messages'][TMessageName];
26
+ tags: commonTypes.ToTags<typeUtils.StringKeys<TPlugin['message']['tags']>>;
27
+ };
28
+ }>, typeUtils.Merge<client.Message, {
29
+ tags: commonTypes.ToTags<typeUtils.StringKeys<TPlugin['message']['tags']>>;
30
+ }>>;
31
+ type _FallbackWhenNever<T, TFallback> = [T] extends [never] ? TFallback : T;
32
+ export type ActionableConversation<TPlugin extends BasePlugin, TChannelName extends string = string, TMessage extends client.Message = client.Message> = typeUtils.Merge<client.Conversation, {
33
+ tags: commonTypes.ToTags<typeUtils.StringKeys<TPlugin['conversation']['tags']>>;
34
+ channel: TChannelName;
35
+ }> & {
36
+ delete: () => Promise<void>;
37
+ update: (props: typeUtils.Merge<Omit<client.ClientInputs['updateConversation'], 'id'>, {
38
+ tags?: commonTypes.ToTags<typeUtils.StringKeys<TPlugin['conversation']['tags']>>;
39
+ }>) => Promise<ActionableConversation<TPlugin, TChannelName, TMessage>>;
40
+ getMessage: (props: {
41
+ id: string;
42
+ }) => Promise<messageProxy.ActionableMessage<TPlugin, TMessage>>;
43
+ getOrCreateMessage: (props: Omit<client.ClientInputs['getOrCreateMessage'], 'conversationId' | 'tags' | 'type' | 'payload'> & typeUtils.DistributivePick<TMessage, 'type' | 'payload'> & {
44
+ tags: commonTypes.ToTags<typeUtils.StringKeys<TPlugin['message']['tags']>>;
45
+ }) => Promise<messageProxy.ActionableMessage<TPlugin, TMessage>>;
46
+ createMessage: (props: Omit<client.ClientInputs['createMessage'], 'conversationId' | 'tags' | 'type' | 'payload'> & typeUtils.DistributivePick<TMessage, 'type' | 'payload'> & {
47
+ tags: commonTypes.ToTags<typeUtils.StringKeys<TPlugin['message']['tags']>>;
48
+ }) => Promise<messageProxy.ActionableMessage<TPlugin, TMessage>>;
49
+ listMessages: (props?: typeUtils.Merge<Omit<client.ClientInputs['listMessages'], 'conversationId' | 'nextToken'>, {
50
+ tags?: commonTypes.ToTags<typeUtils.StringKeys<TPlugin['message']['tags']>>;
51
+ }>) => AsyncCollection<messageProxy.ActionableMessage<TPlugin, TMessage>>;
52
+ listParticipants: () => AsyncCollection<userProxy.ActionableUser<TPlugin, string>>;
53
+ };
54
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,152 @@
1
+ import { StateDefinition as BotStateDefinition, EventDefinition as BotEventDefinition, ConfigurationDefinition as BotConfigurationDefinition, UserDefinition, ConversationDefinition, MessageDefinition, ActionDefinition as BotActionDefinition, TableDefinition as BotTableDefinition, WorkflowDefinition } from '../bot/definition';
2
+ import { SchemaTransformOptions } from '../common/types';
3
+ import { IntegrationPackage, InterfacePackage } from '../package';
4
+ import * as typeUtils from '../utils/type-utils';
5
+ import { z } from '../zui';
6
+ export { UserDefinition, ConversationDefinition, MessageDefinition, WorkflowDefinition } from '../bot/definition';
7
+ type BaseConfig = z.ZuiObjectOrRefSchema;
8
+ type BaseStates = Record<string, z.ZuiObjectOrRefSchema>;
9
+ type BaseEvents = Record<string, z.ZuiObjectOrRefSchema>;
10
+ type BaseActions = Record<string, z.ZuiObjectOrRefSchema>;
11
+ type BaseInterfaces = Record<string, InterfacePackage>;
12
+ type BaseIntegrations = Record<string, IntegrationPackage>;
13
+ type BaseTables = Record<string, z.ZuiObjectOrRefSchema>;
14
+ type BaseWorkflows = Record<string, z.ZuiObjectSchema>;
15
+ export type TableDefinition<TTable extends BaseTables[string] = BaseTables[string]> = typeUtils.Merge<BotTableDefinition, {
16
+ schema: TTable;
17
+ }>;
18
+ export type ConfigurationDefinition<TConfig extends BaseConfig = BaseConfig> = typeUtils.Merge<BotConfigurationDefinition, {
19
+ schema: TConfig;
20
+ }>;
21
+ export type StateDefinition<TState extends BaseStates[string] = BaseStates[string]> = typeUtils.Merge<BotStateDefinition, {
22
+ schema: TState;
23
+ }>;
24
+ export type EventDefinition<TEvent extends BaseEvents[string] = BaseEvents[string]> = typeUtils.Merge<BotEventDefinition, {
25
+ schema: TEvent;
26
+ }>;
27
+ export type ActionDefinition<TAction extends BaseActions[string] = BaseActions[string]> = typeUtils.Merge<BotActionDefinition, {
28
+ input: {
29
+ schema: TAction;
30
+ };
31
+ output: {
32
+ schema: z.ZuiObjectOrRefSchema;
33
+ };
34
+ }>;
35
+ export type RecurringEventDefinition<TEvents extends BaseEvents = BaseEvents> = {
36
+ [K in keyof TEvents]: {
37
+ type: K;
38
+ payload: z.infer<TEvents[K]>;
39
+ schedule: {
40
+ cron: string;
41
+ };
42
+ };
43
+ }[keyof TEvents];
44
+ export type ZuiSchemaWithEntityReferences<TInterfaces extends BaseInterfaces, TReturnType extends z.ZuiObjectOrRefSchema> = ((props: {
45
+ entities: {
46
+ [TInterfaceAlias in keyof TInterfaces]: {
47
+ [TEntityName in keyof TInterfaces[TInterfaceAlias]['definition']['entities']]: z.ZodRef;
48
+ };
49
+ };
50
+ }) => TReturnType) | TReturnType;
51
+ type GenericDefinition<TInterfaces extends BaseInterfaces, TDefinition extends {
52
+ schema: z.ZuiObjectOrRefSchema;
53
+ }> = typeUtils.Merge<TDefinition, {
54
+ schema: ZuiSchemaWithEntityReferences<TInterfaces, TDefinition['schema']>;
55
+ }>;
56
+ type GenericNestedDefinition<TInterfaces extends BaseInterfaces, TDefinition extends {
57
+ [k: string]: any;
58
+ }, TKeys extends string> = Omit<TDefinition, TKeys> & {
59
+ [TKey in TKeys]: Omit<TDefinition[TKey], 'schema'> & {
60
+ schema: ZuiSchemaWithEntityReferences<TInterfaces, TDefinition[TKey]['schema']>;
61
+ };
62
+ };
63
+ export type PluginDefinitionProps<TName extends string = string, TVersion extends string = string, TConfig extends BaseConfig = BaseConfig, TStates extends BaseStates = BaseStates, TEvents extends BaseEvents = BaseEvents, TActions extends BaseActions = BaseActions, TInterfaces extends BaseInterfaces = BaseInterfaces, TIntegrations extends BaseIntegrations = BaseIntegrations, TTables extends BaseTables = BaseTables, TWorkflows extends BaseWorkflows = BaseWorkflows> = {
64
+ name: TName;
65
+ version: TVersion;
66
+ title?: string;
67
+ description?: string;
68
+ icon?: string;
69
+ readme?: string;
70
+ attributes?: Record<string, string>;
71
+ integrations?: TIntegrations;
72
+ interfaces?: TInterfaces;
73
+ user?: UserDefinition;
74
+ conversation?: ConversationDefinition;
75
+ message?: MessageDefinition;
76
+ states?: {
77
+ [K in keyof TStates]: GenericDefinition<TInterfaces, StateDefinition<TStates[K]>>;
78
+ };
79
+ configuration?: GenericDefinition<TInterfaces, ConfigurationDefinition<TConfig>>;
80
+ events?: {
81
+ [K in keyof TEvents]: GenericDefinition<TInterfaces, EventDefinition<TEvents[K]>>;
82
+ };
83
+ /** @deprecated Use the `recurrence` field on each event in `events` instead. */
84
+ recurringEvents?: Record<string, RecurringEventDefinition<TEvents>>;
85
+ actions?: {
86
+ [K in keyof TActions]: GenericNestedDefinition<TInterfaces, ActionDefinition<TActions[K]>, 'input' | 'output'>;
87
+ };
88
+ tables?: {
89
+ [K in keyof TTables]: GenericDefinition<TInterfaces, TableDefinition<TTables[K]>>;
90
+ };
91
+ /**
92
+ * # EXPERIMENTAL
93
+ * This API is experimental and may change in the future.
94
+ */
95
+ workflows?: {
96
+ [K in keyof TWorkflows]: WorkflowDefinition<TWorkflows[K]>;
97
+ };
98
+ __advanced?: SchemaTransformOptions;
99
+ };
100
+ export declare class PluginDefinition<TName extends string = string, TVersion extends string = string, TConfig extends BaseConfig = BaseConfig, TStates extends BaseStates = BaseStates, TEvents extends BaseEvents = BaseEvents, TActions extends BaseActions = BaseActions, TInterfaces extends BaseInterfaces = BaseInterfaces, TIntegrations extends BaseIntegrations = BaseIntegrations, TTables extends BaseTables = BaseTables, TWorkflows extends BaseWorkflows = BaseWorkflows> {
101
+ readonly props: PluginDefinitionProps<TName, TVersion, TConfig, TStates, TEvents, TActions, TInterfaces, TIntegrations, TTables, TWorkflows>;
102
+ readonly name: this['props']['name'];
103
+ readonly version: this['props']['version'];
104
+ readonly title: this['props']['title'];
105
+ readonly description: this['props']['description'];
106
+ readonly icon: this['props']['icon'];
107
+ readonly readme: this['props']['readme'];
108
+ readonly attributes: this['props']['attributes'];
109
+ readonly integrations: this['props']['integrations'];
110
+ readonly interfaces: this['props']['interfaces'];
111
+ readonly user: this['props']['user'];
112
+ readonly conversation: this['props']['conversation'];
113
+ readonly message: this['props']['message'];
114
+ readonly states: {
115
+ [K in keyof TStates]: StateDefinition<TStates[K]>;
116
+ };
117
+ readonly configuration?: ConfigurationDefinition<TConfig>;
118
+ readonly events: {
119
+ [K in keyof TEvents]: EventDefinition<TEvents[K]>;
120
+ };
121
+ readonly recurringEvents: this['props']['recurringEvents'];
122
+ readonly actions: {
123
+ [K in keyof TActions]: ActionDefinition<TActions[K]>;
124
+ };
125
+ readonly tables: {
126
+ [K in keyof TTables]: TableDefinition<TTables[K]>;
127
+ };
128
+ readonly workflows: this['props']['workflows'];
129
+ readonly __advanced: this['props']['__advanced'];
130
+ constructor(props: PluginDefinitionProps<TName, TVersion, TConfig, TStates, TEvents, TActions, TInterfaces, TIntegrations, TTables, TWorkflows>);
131
+ get metadata(): {
132
+ readonly sdkVersion: string;
133
+ };
134
+ readonly clone?: (overrides?: Partial<PluginDefinitionProps>) => PluginDefinition;
135
+ /**
136
+ * Returns a copy of the plugin definition where all entity references are
137
+ * resolved to the base entity schema defined by the interface. This does not
138
+ * include any additional properties that may be added to the entity by the
139
+ * backing integration.
140
+ *
141
+ * If `intersectWithUnknownRecord` is `true` (default), the entity schemas
142
+ * will be intersected with `z.record(z.string(), z.unknown())` to make it
143
+ * explicit that the backing integration may have added additional properties.
144
+ */
145
+ dereferenceEntities({ intersectWithUnknownRecord }?: {
146
+ intersectWithUnknownRecord?: boolean;
147
+ }): this;
148
+ private _buildZuiReferenceMap;
149
+ private _dereferenceZuiSchema;
150
+ private _dereferenceDefinitionSchemas;
151
+ private _dereferenceActionDefinitionSchemas;
152
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from './proxy';
2
+ export * from './types';
@@ -0,0 +1,5 @@
1
+ import type * as client from '@holocronlab/botruntime-client';
2
+ import { BotSpecificClient } from '../../bot';
3
+ import { BasePlugin, PluginRuntimeProps } from '../common';
4
+ import { EventProxy } from './types';
5
+ export declare const proxyEvents: <TPlugin extends BasePlugin>(client: BotSpecificClient<TPlugin> | client.Client, props: PluginRuntimeProps<TPlugin>) => EventProxy<TPlugin>;
@@ -0,0 +1,19 @@
1
+ import type * as client from '@holocronlab/botruntime-client';
2
+ import type { AsyncCollection } from '../../utils/api-paging-utils';
3
+ import type * as utils from '../../utils/type-utils';
4
+ import type { BasePlugin } from '../common';
5
+ export type EventSchedule = NonNullable<client.ClientInputs['createEvent']['schedule']>;
6
+ export type EventSender<TPayload> = {
7
+ emit: (event: TPayload) => Promise<client.Event>;
8
+ schedule: (event: TPayload, schedule: EventSchedule) => Promise<client.Event>;
9
+ withConversationId: (conversationId: string) => EventSender<TPayload>;
10
+ withUserId: (userId: string) => EventSender<TPayload>;
11
+ withMessageId: (messageId: string) => EventSender<TPayload>;
12
+ list: (props?: Omit<client.ClientInputs['listEvents'], 'type' | 'nextToken' | 'conversationId' | 'messageId' | 'userId'>) => AsyncCollection<client.Event>;
13
+ getById: (props: {
14
+ id: string;
15
+ }) => Promise<client.Event>;
16
+ };
17
+ export type EventProxy<TPlugin extends BasePlugin> = utils.Normalize<{
18
+ [TEventName in keyof TPlugin['events']]: EventSender<TPlugin['events'][TEventName]>;
19
+ }>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,71 @@
1
+ import type { MessageHandlersMap as BotMessageHandlersMap, EventHandlersMap as BotEventHandlersMap, StateExpiredHandlersMap as BotStateExpiredHandlersMap, HookHandlersMap as BotHookHandlersMap, WorkflowHandlersMap as BotWorkflowHandlersMap, ActionHandlersMap as BotActionHandlersMap, BotHandlers } from '../bot';
2
+ import * as utils from '../utils';
3
+ import { BasePlugin, PluginRuntimeProps } from './common';
4
+ import { ActionHandlers, MessageHandlers, EventHandlers, StateExpiredHandlers, HookHandlers, WorkflowHandlers, HookHandlersMap, WorkflowHandlersMap } from './server/types';
5
+ export type PluginImplementationProps<TPlugin extends BasePlugin = BasePlugin> = {
6
+ actions: ActionHandlers<TPlugin>;
7
+ };
8
+ export declare class PluginImplementation<TPlugin extends BasePlugin = BasePlugin> implements BotHandlers<TPlugin> {
9
+ readonly props: PluginImplementationProps<TPlugin>;
10
+ private _runtimeProps;
11
+ private _actionHandlers;
12
+ private _messageHandlers;
13
+ private _eventHandlers;
14
+ private _stateExpiredHandlers;
15
+ private _hookHandlers;
16
+ private _workflowHandlers;
17
+ private _registerOrder;
18
+ constructor(props: PluginImplementationProps<TPlugin>);
19
+ initialize(props: PluginRuntimeProps<TPlugin>): this;
20
+ private get _runtime();
21
+ private _getTools;
22
+ get actionHandlers(): BotActionHandlersMap<TPlugin>;
23
+ get messageHandlers(): BotMessageHandlersMap<TPlugin>;
24
+ get eventHandlers(): BotEventHandlersMap<TPlugin>;
25
+ get stateExpiredHandlers(): BotStateExpiredHandlersMap<TPlugin>;
26
+ get hookHandlers(): BotHookHandlersMap<TPlugin>;
27
+ get workflowHandlers(): BotWorkflowHandlersMap<TPlugin>;
28
+ readonly on: {
29
+ message: <T extends utils.types.StringKeys<MessageHandlers<TPlugin>>>(type: T, handler: MessageHandlers<TPlugin>[T]) => void;
30
+ event: <T extends utils.types.StringKeys<EventHandlers<TPlugin>>>(type: T, handler: EventHandlers<TPlugin>[T]) => void;
31
+ stateExpired: <T extends utils.types.StringKeys<StateExpiredHandlers<TPlugin>>>(type: T, handler: StateExpiredHandlers<TPlugin>[T]) => void;
32
+ beforeIncomingEvent: <T extends utils.types.StringKeys<HookHandlersMap<TPlugin>["before_incoming_event"]>>(type: T, handler: HookHandlers<TPlugin>["before_incoming_event"][T]) => void;
33
+ beforeIncomingMessage: <T extends utils.types.StringKeys<HookHandlersMap<TPlugin>["before_incoming_message"]>>(type: T, handler: HookHandlers<TPlugin>["before_incoming_message"][T]) => void;
34
+ beforeOutgoingMessage: <T extends utils.types.StringKeys<HookHandlersMap<TPlugin>["before_outgoing_message"]>>(type: T, handler: HookHandlers<TPlugin>["before_outgoing_message"][T]) => void;
35
+ beforeOutgoingCallAction: <T extends utils.types.StringKeys<HookHandlersMap<TPlugin>["before_outgoing_call_action"]>>(type: T, handler: HookHandlers<TPlugin>["before_outgoing_call_action"][T]) => void;
36
+ /**
37
+ * # EXPERIMENTAL
38
+ * This API is experimental and may change in the future.
39
+ */
40
+ beforeIncomingCallAction: <T extends utils.types.StringKeys<HookHandlersMap<TPlugin>["before_incoming_call_action"]>>(type: T, handler: HookHandlers<TPlugin>["before_incoming_call_action"][T]) => void;
41
+ afterIncomingEvent: <T extends utils.types.StringKeys<HookHandlersMap<TPlugin>["after_incoming_event"]>>(type: T, handler: HookHandlers<TPlugin>["after_incoming_event"][T]) => void;
42
+ afterIncomingMessage: <T extends utils.types.StringKeys<HookHandlersMap<TPlugin>["after_incoming_message"]>>(type: T, handler: HookHandlers<TPlugin>["after_incoming_message"][T]) => void;
43
+ afterOutgoingMessage: <T extends utils.types.StringKeys<HookHandlersMap<TPlugin>["after_outgoing_message"]>>(type: T, handler: HookHandlers<TPlugin>["after_outgoing_message"][T]) => void;
44
+ afterOutgoingCallAction: <T extends utils.types.StringKeys<HookHandlersMap<TPlugin>["after_outgoing_call_action"]>>(type: T, handler: HookHandlers<TPlugin>["after_outgoing_call_action"][T]) => void;
45
+ /**
46
+ * # EXPERIMENTAL
47
+ * This API is experimental and may change in the future.
48
+ */
49
+ afterIncomingCallAction: <T extends utils.types.StringKeys<HookHandlersMap<TPlugin>["after_incoming_call_action"]>>(type: T, handler: HookHandlers<TPlugin>["after_incoming_call_action"][T]) => void;
50
+ /**
51
+ * # EXPERIMENTAL
52
+ * This API is experimental and may change in the future.
53
+ */
54
+ workflowStart: <T extends utils.types.StringKeys<WorkflowHandlersMap<TPlugin>["started"]>>(type: T, handler: WorkflowHandlers<TPlugin>[T]) => void;
55
+ /**
56
+ * # EXPERIMENTAL
57
+ * This API is experimental and may change in the future.
58
+ */
59
+ workflowContinue: <T extends utils.types.StringKeys<WorkflowHandlersMap<TPlugin>["continued"]>>(type: T, handler: WorkflowHandlers<TPlugin>[T]) => void;
60
+ /**
61
+ * # EXPERIMENTAL
62
+ * This API is experimental and may change in the future.
63
+ */
64
+ workflowTimeout: <T extends utils.types.StringKeys<WorkflowHandlersMap<TPlugin>["timed_out"]>>(type: T, handler: WorkflowHandlers<TPlugin>[T]) => void;
65
+ };
66
+ /**
67
+ * checks if the actual event resolves to the target event
68
+ */
69
+ private _eventResolvesTo;
70
+ private _stripAliasPrefix;
71
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ export * from './definition';
2
+ export * from './implementation';
3
+ export * from './server';
4
+ export * from './common';
@@ -0,0 +1,2 @@
1
+ export { proxyMessage, proxyMessages } from './proxy';
2
+ export { ActionableMessage, MessageFinder } from './types';
@@ -0,0 +1,13 @@
1
+ import type * as client from '@holocronlab/botruntime-client';
2
+ import type { BotSpecificClient } from '../../bot';
3
+ import type { BasePlugin, PluginRuntimeProps } from '../common';
4
+ import type { ActionableMessage, AnyPluginMessage, MessageFinder } from './types';
5
+ export declare const proxyMessages: <TPlugin extends BasePlugin>(props: {
6
+ client: BotSpecificClient<TPlugin> | client.Client;
7
+ plugin?: PluginRuntimeProps<TPlugin>;
8
+ }) => MessageFinder<TPlugin>;
9
+ export declare const proxyMessage: <TPlugin extends BasePlugin, TMessage extends client.Message | AnyPluginMessage<TPlugin> = AnyPluginMessage<TPlugin>>(props: {
10
+ client: BotSpecificClient<TPlugin> | client.Client;
11
+ plugin?: PluginRuntimeProps<TPlugin>;
12
+ message: TMessage;
13
+ }) => ActionableMessage<TPlugin, TMessage>;
@@ -0,0 +1,22 @@
1
+ import type * as client from '@holocronlab/botruntime-client';
2
+ import type { GetMessages } from '../../bot';
3
+ import type { commonTypes } from '../../common';
4
+ import type { AsyncCollection } from '../../utils/api-paging-utils';
5
+ import type * as typeUtils from '../../utils/type-utils';
6
+ import type { BasePlugin } from '../common';
7
+ import type { IncomingMessages } from '../server';
8
+ export type MessageFinder<TPlugin extends BasePlugin> = {
9
+ list: (props?: Omit<client.ClientInputs['listMessages'], 'nextToken'>) => AsyncCollection<ActionableMessage<TPlugin>>;
10
+ getById: (props: {
11
+ id: string;
12
+ }) => Promise<ActionableMessage<TPlugin>>;
13
+ };
14
+ export type AnyPluginMessage<TPlugin extends BasePlugin> = IncomingMessages<TPlugin>['*'] | IncomingMessages<TPlugin>[typeUtils.StringKeys<GetMessages<TPlugin>>];
15
+ export type ActionableMessage<TPlugin extends BasePlugin, TMessage extends client.Message | AnyPluginMessage<TPlugin> = client.Message> = typeUtils.Merge<TMessage, {
16
+ tags: commonTypes.ToTags<typeUtils.StringKeys<TPlugin['conversation']['tags']>>;
17
+ }> & {
18
+ delete: () => Promise<void>;
19
+ update: (props: typeUtils.Merge<Omit<client.ClientInputs['updateMessage'], 'id'>, {
20
+ tags: commonTypes.ToTags<typeUtils.StringKeys<TPlugin['message']['tags']>>;
21
+ }>) => Promise<ActionableMessage<TPlugin, TMessage>>;
22
+ };
@@ -0,0 +1 @@
1
+ export * from './types';