@wabot-dev/framework 0.0.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.
Files changed (127) hide show
  1. package/LICENSE +21 -0
  2. package/dist/src/_virtual/_commonjsHelpers.js +5 -0
  3. package/dist/src/_virtual/main.js +7 -0
  4. package/dist/src/_virtual/main2.js +3 -0
  5. package/dist/src/ai/index.d.ts +1 -0
  6. package/dist/src/ai/openia/OpenaiChatBotAdapter.d.ts +9 -0
  7. package/dist/src/ai/openia/OpenaiChatBotAdapter.js +85 -0
  8. package/dist/src/ai/openia/index.d.ts +1 -0
  9. package/dist/src/channels/cmd/CmdChannel.d.ts +9 -0
  10. package/dist/src/channels/cmd/CmdChannel.js +58 -0
  11. package/dist/src/channels/cmd/index.d.ts +1 -0
  12. package/dist/src/channels/index.d.ts +2 -0
  13. package/dist/src/channels/telegram/@telegram.d.ts +2 -0
  14. package/dist/src/channels/telegram/@telegram.js +19 -0
  15. package/dist/src/channels/telegram/TelegramChannel.d.ts +12 -0
  16. package/dist/src/channels/telegram/TelegramChannel.js +54 -0
  17. package/dist/src/channels/telegram/TelegramChannelConfig.d.ts +7 -0
  18. package/dist/src/channels/telegram/TelegramChannelConfig.js +8 -0
  19. package/dist/src/channels/telegram/index.d.ts +3 -0
  20. package/dist/src/chatbot/ChatBot.d.ts +11 -0
  21. package/dist/src/chatbot/ChatBot.js +51 -0
  22. package/dist/src/chatbot/ChatBotAdapter.d.ts +26 -0
  23. package/dist/src/chatbot/ChatBotAdapter.js +74 -0
  24. package/dist/src/chatbot/IChatBot.d.ts +4 -0
  25. package/dist/src/chatbot/chat/Chat.d.ts +23 -0
  26. package/dist/src/chatbot/chat/Chat.js +55 -0
  27. package/dist/src/chatbot/chat/IChatFunctionCall.d.ts +6 -0
  28. package/dist/src/chatbot/chat/IChatItem.d.ts +19 -0
  29. package/dist/src/chatbot/chat/index.d.ts +4 -0
  30. package/dist/src/chatbot/chat/repository/IChatMemory.d.ts +9 -0
  31. package/dist/src/chatbot/chat/repository/IChatMemory.js +10 -0
  32. package/dist/src/chatbot/chat/repository/IChatRepository.d.ts +12 -0
  33. package/dist/src/chatbot/chat/repository/IChatRepository.js +19 -0
  34. package/dist/src/chatbot/chat/repository/index.d.ts +3 -0
  35. package/dist/src/chatbot/chat/repository/ram/RamChatMemory.d.ts +8 -0
  36. package/dist/src/chatbot/chat/repository/ram/RamChatMemory.js +14 -0
  37. package/dist/src/chatbot/chat/repository/ram/RamChatRepository.d.ts +11 -0
  38. package/dist/src/chatbot/chat/repository/ram/RamChatRepository.js +41 -0
  39. package/dist/src/chatbot/chat/repository/ram/index.d.ts +2 -0
  40. package/dist/src/chatbot/index.d.ts +5 -0
  41. package/dist/src/chatbot/metadata/@chatBot.d.ts +3 -0
  42. package/dist/src/chatbot/metadata/@chatBot.js +18 -0
  43. package/dist/src/chatbot/metadata/ChatBotMetadataStore.d.ts +6 -0
  44. package/dist/src/chatbot/metadata/ChatBotMetadataStore.js +17 -0
  45. package/dist/src/chatbot/metadata/IChatBotMetadata.d.ts +7 -0
  46. package/dist/src/chatbot/metadata/index.d.ts +3 -0
  47. package/dist/src/context/IContext.d.ts +18 -0
  48. package/dist/src/context/IContext.js +10 -0
  49. package/dist/src/context/index.d.ts +1 -0
  50. package/dist/src/controller/channel/ChatResolver.d.ts +9 -0
  51. package/dist/src/controller/channel/ChatResolver.js +43 -0
  52. package/dist/src/controller/channel/IChatChannel.d.ts +5 -0
  53. package/dist/src/controller/channel/IMessageContext.d.ts +10 -0
  54. package/dist/src/controller/channel/index.d.ts +3 -0
  55. package/dist/src/controller/index.d.ts +2 -0
  56. package/dist/src/controller/metadata/ControllerMetadataStore.d.ts +12 -0
  57. package/dist/src/controller/metadata/ControllerMetadataStore.js +42 -0
  58. package/dist/src/controller/metadata/channel/IChannelMetadata.d.ts +8 -0
  59. package/dist/src/controller/metadata/channel/index.d.ts +1 -0
  60. package/dist/src/controller/metadata/controller/@chatController.d.ts +3 -0
  61. package/dist/src/controller/metadata/controller/@chatController.js +14 -0
  62. package/dist/src/controller/metadata/controller/IChatControllerConfig.d.ts +2 -0
  63. package/dist/src/controller/metadata/controller/IChatControllerMetadata.d.ts +3 -0
  64. package/dist/src/controller/metadata/controller/index.d.ts +3 -0
  65. package/dist/src/controller/metadata/index.d.ts +3 -0
  66. package/dist/src/index.d.ts +10 -0
  67. package/dist/src/index.js +34 -0
  68. package/dist/src/injection/Container.d.ts +18 -0
  69. package/dist/src/injection/Container.js +43 -0
  70. package/dist/src/injection/index.d.ts +3 -0
  71. package/dist/src/injection/index.js +4 -0
  72. package/dist/src/message/IChatDocument.d.ts +2 -0
  73. package/dist/src/message/IChatImage.d.ts +2 -0
  74. package/dist/src/message/IChatMessage.d.ts +9 -0
  75. package/dist/src/message/IChatSender.d.ts +4 -0
  76. package/dist/src/message/index.d.ts +4 -0
  77. package/dist/src/mindset/IMindset.d.ts +17 -0
  78. package/dist/src/mindset/IMindset.js +13 -0
  79. package/dist/src/mindset/MindsetOperator.d.ts +25 -0
  80. package/dist/src/mindset/MindsetOperator.js +101 -0
  81. package/dist/src/mindset/index.d.ts +3 -0
  82. package/dist/src/mindset/metadata/IMindsetMetadata.d.ts +28 -0
  83. package/dist/src/mindset/metadata/MindsetMetadataStore.d.ts +19 -0
  84. package/dist/src/mindset/metadata/MindsetMetadataStore.js +134 -0
  85. package/dist/src/mindset/metadata/functions/@mindsetFunction.d.ts +3 -0
  86. package/dist/src/mindset/metadata/functions/@mindsetFunction.js +21 -0
  87. package/dist/src/mindset/metadata/functions/IMindsetFunctionConfig.d.ts +3 -0
  88. package/dist/src/mindset/metadata/functions/IMindsetFunctionDecoration.d.ts +7 -0
  89. package/dist/src/mindset/metadata/functions/decoratorNames.d.ts +1 -0
  90. package/dist/src/mindset/metadata/functions/decoratorNames.js +3 -0
  91. package/dist/src/mindset/metadata/functions/index.d.ts +4 -0
  92. package/dist/src/mindset/metadata/index.d.ts +6 -0
  93. package/dist/src/mindset/metadata/mindsets/@mindset.d.ts +5 -0
  94. package/dist/src/mindset/metadata/mindsets/@mindset.js +18 -0
  95. package/dist/src/mindset/metadata/mindsets/IMindsetConfig.d.ts +4 -0
  96. package/dist/src/mindset/metadata/mindsets/IMindsetDecoration.d.ts +6 -0
  97. package/dist/src/mindset/metadata/mindsets/decoratorNames.d.ts +1 -0
  98. package/dist/src/mindset/metadata/mindsets/decoratorNames.js +3 -0
  99. package/dist/src/mindset/metadata/mindsets/index.d.ts +3 -0
  100. package/dist/src/mindset/metadata/modules/@mindsetModule.d.ts +4 -0
  101. package/dist/src/mindset/metadata/modules/@mindsetModule.js +18 -0
  102. package/dist/src/mindset/metadata/modules/IMindsetModuleConfig.d.ts +3 -0
  103. package/dist/src/mindset/metadata/modules/IMindsetModuleDecoration.d.ts +5 -0
  104. package/dist/src/mindset/metadata/modules/decoratorNames.d.ts +1 -0
  105. package/dist/src/mindset/metadata/modules/decoratorNames.js +3 -0
  106. package/dist/src/mindset/metadata/modules/index.d.ts +4 -0
  107. package/dist/src/mindset/metadata/params/@isOptional.d.ts +2 -0
  108. package/dist/src/mindset/metadata/params/@isOptional.js +21 -0
  109. package/dist/src/mindset/metadata/params/@param.d.ts +3 -0
  110. package/dist/src/mindset/metadata/params/@param.js +21 -0
  111. package/dist/src/mindset/metadata/params/IParamConfig.d.ts +4 -0
  112. package/dist/src/mindset/metadata/params/IParamDecoration.d.ts +7 -0
  113. package/dist/src/mindset/metadata/params/decoratorNames.d.ts +2 -0
  114. package/dist/src/mindset/metadata/params/decoratorNames.js +4 -0
  115. package/dist/src/mindset/metadata/params/index.d.ts +3 -0
  116. package/dist/src/node_modules/dotenv/lib/main.js +376 -0
  117. package/dist/src/node_modules/dotenv/package.json.js +5 -0
  118. package/dist/src/server/index.d.ts +3 -0
  119. package/dist/src/server/prepareChatContainer.d.ts +5 -0
  120. package/dist/src/server/prepareChatContainer.js +41 -0
  121. package/dist/src/server/runChannel.d.ts +12 -0
  122. package/dist/src/server/runChannel.js +29 -0
  123. package/dist/src/server/runServer.d.ts +8 -0
  124. package/dist/src/server/runServer.js +42 -0
  125. package/dist/src/shared/IConstructor.d.ts +1 -0
  126. package/dist/src/shared/index.d.ts +1 -0
  127. package/package.json +47 -0
@@ -0,0 +1,101 @@
1
+ import { __decorate, __metadata } from 'tslib';
2
+ import { injectable } from '../injection/index.js';
3
+ import { Mindset } from './IMindset.js';
4
+ import { MindsetMetadataStore } from './metadata/MindsetMetadataStore.js';
5
+ import { Container } from '../injection/Container.js';
6
+
7
+ let MindsetOperator = class MindsetOperator {
8
+ mindset;
9
+ container;
10
+ metadata;
11
+ constructor(mindset, container, metadataStore) {
12
+ this.mindset = mindset;
13
+ this.container = container;
14
+ this.metadata = metadataStore.getMindsetMetadata(this.mindset.constructor);
15
+ }
16
+ identity() {
17
+ return this.mindset.identity();
18
+ }
19
+ skills() {
20
+ return this.mindset.skills();
21
+ }
22
+ limits() {
23
+ return this.mindset.limits();
24
+ }
25
+ async callFunction(name, params) {
26
+ const fnMetadata = this.metadata.modules
27
+ .map((module) => module.functions)
28
+ .flat()
29
+ .find((fn) => fn.name === name);
30
+ if (!fnMetadata) {
31
+ throw new Error(`Function ${name} not found`);
32
+ }
33
+ const paramsObj = JSON.parse(params);
34
+ const module = this.container.resolve(fnMetadata.moduleConstructor);
35
+ try {
36
+ const response = await module[name](paramsObj);
37
+ if (!response) {
38
+ return 'success';
39
+ }
40
+ return response.toString();
41
+ }
42
+ catch (error) {
43
+ return `Error: ${error}`;
44
+ }
45
+ }
46
+ async allFunctionsDescriptors() {
47
+ return this.metadata.modules
48
+ .map((module) => module.functions.map((fn) => this.functionDescriptor(fn)))
49
+ .flat();
50
+ }
51
+ functionDescriptor(fn) {
52
+ const description = fn.config.description.replaceAll('#', ' ');
53
+ return {
54
+ type: 'function',
55
+ name: fn.name,
56
+ description,
57
+ parameters: {
58
+ type: 'object',
59
+ properties: fn.params.reduce((prev, param) => ({
60
+ ...prev,
61
+ [param.name]: this.toolParam(param),
62
+ }), {}),
63
+ required: fn.params.map((param) => param.name),
64
+ },
65
+ };
66
+ }
67
+ toolParam(param) {
68
+ const addons = {
69
+ description: `
70
+ ### description (in your main language)
71
+ ${param.config.description.replaceAll('#', ' ')}
72
+ `,
73
+ };
74
+ const type = (() => {
75
+ if (param.type === Number)
76
+ return 'number';
77
+ if (param.type === String)
78
+ return 'string';
79
+ if (param.type === Date) {
80
+ addons.description = `${addons.description}
81
+ ### format: ISO 8681 - YYYY-MM-DDTHH:mm:ssZ
82
+ ${addons.description}
83
+ `;
84
+ return 'string';
85
+ }
86
+ throw new Error(`Unsupported type`);
87
+ })();
88
+ return {
89
+ type,
90
+ ...addons,
91
+ };
92
+ }
93
+ };
94
+ MindsetOperator = __decorate([
95
+ injectable(),
96
+ __metadata("design:paramtypes", [Mindset,
97
+ Container,
98
+ MindsetMetadataStore])
99
+ ], MindsetOperator);
100
+
101
+ export { MindsetOperator };
@@ -0,0 +1,3 @@
1
+ export * from './metadata';
2
+ export * from './IMindset';
3
+ export * from './MindsetOperator';
@@ -0,0 +1,28 @@
1
+ import { IConstructor } from '@/shared';
2
+ import { IMindset } from '../IMindset';
3
+ import { IParamConfig } from './params/IParamConfig';
4
+ import { IMindsetFunctionConfig } from './functions/IMindsetFunctionConfig';
5
+ import { IMindsetModuleConfig } from './modules/IMindsetModuleConfig';
6
+ import { IMindsetConfig } from './mindsets/IMindsetConfig';
7
+ export interface IMindsetFunctionParamMetadata {
8
+ config: IParamConfig;
9
+ name: string;
10
+ type: Function;
11
+ }
12
+ export interface IMindsetFunctionMetadata {
13
+ moduleConstructor: Function;
14
+ requestConstructor?: Function;
15
+ name: string;
16
+ config: IMindsetFunctionConfig;
17
+ params: IMindsetFunctionParamMetadata[];
18
+ }
19
+ export interface IMindsetModuleMetadata {
20
+ constructor: Function;
21
+ config: IMindsetModuleConfig;
22
+ functions: IMindsetFunctionMetadata[];
23
+ }
24
+ export interface IMindsetMetadata {
25
+ constructor: IConstructor<IMindset>;
26
+ config: IMindsetConfig;
27
+ modules: IMindsetModuleMetadata[];
28
+ }
@@ -0,0 +1,19 @@
1
+ import { IMindsetFunctionDecoration } from './functions/IMindsetFunctionDecoration';
2
+ import { IMindsetFunctionMetadata, IMindsetFunctionParamMetadata, IMindsetMetadata, IMindsetModuleMetadata } from './IMindsetMetadata';
3
+ import { IMindsetModuleDecoration } from './modules/IMindsetModuleDecoration';
4
+ import { IParamDecoration } from './params/IParamDecoration';
5
+ import { IMindsetDecoration } from './mindsets/IMindsetDecoration';
6
+ export declare class MindsetMetadataStore {
7
+ private readonly paramsDecorations;
8
+ private readonly functionsDecorations;
9
+ private readonly modulesDecorations;
10
+ private readonly mindsetsDecorations;
11
+ saveParamDecoration(paramDecoration: IParamDecoration): void;
12
+ saveFunctionDecoration(functionDecoration: IMindsetFunctionDecoration): void;
13
+ saveModuleDecoration(moduleDecoration: IMindsetModuleDecoration): void;
14
+ saveMindsetDecoration(mindsetDecoration: IMindsetDecoration): void;
15
+ getRequestParamsMetadata(requestConstructor: Function): IMindsetFunctionParamMetadata[];
16
+ getFunctionsMetadata(moduleConstructor: Function): IMindsetFunctionMetadata[];
17
+ getModuleMetadata(moduleConstructor: Function): IMindsetModuleMetadata;
18
+ getMindsetMetadata(ctor: Function): IMindsetMetadata;
19
+ }
@@ -0,0 +1,134 @@
1
+ import { __decorate } from 'tslib';
2
+ import { singleton } from '../../injection/index.js';
3
+ import { MINDSET_FUNCTION_DECORATION_FUNCTION } from './functions/decoratorNames.js';
4
+ import { MINDSET_DECORATION_MINDSET } from './mindsets/decoratorNames.js';
5
+ import { MINDSET_MODULE_DECORATION_MODULE } from './modules/decoratorNames.js';
6
+
7
+ let MindsetMetadataStore = class MindsetMetadataStore {
8
+ paramsDecorations = new Map();
9
+ functionsDecorations = new Map();
10
+ modulesDecorations = new Map();
11
+ mindsetsDecorations = new Map();
12
+ saveParamDecoration(paramDecoration) {
13
+ let paramsMap = this.paramsDecorations.get(paramDecoration.constructor);
14
+ if (!paramsMap) {
15
+ paramsMap = new Map();
16
+ this.paramsDecorations.set(paramDecoration.constructor, paramsMap);
17
+ }
18
+ let decorations = paramsMap.get(paramDecoration.paramName);
19
+ if (!decorations) {
20
+ decorations = [];
21
+ paramsMap.set(paramDecoration.paramName, decorations);
22
+ }
23
+ decorations.push(paramDecoration);
24
+ }
25
+ saveFunctionDecoration(functionDecoration) {
26
+ let functionsMap = this.functionsDecorations.get(functionDecoration.constructor);
27
+ if (!functionsMap) {
28
+ functionsMap = new Map();
29
+ this.functionsDecorations.set(functionDecoration.constructor, functionsMap);
30
+ }
31
+ let decorations = functionsMap.get(functionDecoration.functionName);
32
+ if (!decorations) {
33
+ decorations = [];
34
+ functionsMap.set(functionDecoration.functionName, decorations);
35
+ }
36
+ decorations.push(functionDecoration);
37
+ }
38
+ saveModuleDecoration(moduleDecoration) {
39
+ let modulesDecorations = this.modulesDecorations.get(moduleDecoration.constructor);
40
+ if (!modulesDecorations) {
41
+ modulesDecorations = [];
42
+ this.modulesDecorations.set(moduleDecoration.constructor, modulesDecorations);
43
+ }
44
+ modulesDecorations.push(moduleDecoration);
45
+ }
46
+ saveMindsetDecoration(mindsetDecoration) {
47
+ let mindsetsDecorations = this.mindsetsDecorations.get(mindsetDecoration.constructor);
48
+ if (!mindsetsDecorations) {
49
+ mindsetsDecorations = [];
50
+ this.mindsetsDecorations.set(mindsetDecoration.constructor, mindsetsDecorations);
51
+ }
52
+ mindsetsDecorations.push(mindsetDecoration);
53
+ }
54
+ getRequestParamsMetadata(requestConstructor) {
55
+ const paramsMap = this.paramsDecorations.get(requestConstructor);
56
+ if (!paramsMap) {
57
+ return [];
58
+ }
59
+ const paramsMetadata = [];
60
+ paramsMap.forEach((decorations, paramName) => {
61
+ const paramMainDecoration = decorations.find((decoration) => decoration.decorationConfig);
62
+ if (!paramMainDecoration) {
63
+ return;
64
+ }
65
+ paramsMetadata.push({
66
+ config: paramMainDecoration.decorationConfig,
67
+ name: paramName,
68
+ type: paramMainDecoration.paramType,
69
+ });
70
+ // TODO: add support for validation decorators
71
+ });
72
+ return paramsMetadata;
73
+ }
74
+ getFunctionsMetadata(moduleConstructor) {
75
+ const functionsMap = this.functionsDecorations.get(moduleConstructor);
76
+ if (!functionsMap) {
77
+ return [];
78
+ }
79
+ const functionsMetadata = [];
80
+ functionsMap.forEach((decorations) => {
81
+ const mainDecoration = decorations.find((decoration) => decoration.decorationName === MINDSET_FUNCTION_DECORATION_FUNCTION);
82
+ if (!mainDecoration) {
83
+ return;
84
+ }
85
+ functionsMetadata.push({
86
+ moduleConstructor: mainDecoration.constructor,
87
+ config: mainDecoration.decorationConfig,
88
+ name: mainDecoration.functionName,
89
+ requestConstructor: mainDecoration.paramsTypes[0],
90
+ params: mainDecoration.paramsTypes[0]
91
+ ? this.getRequestParamsMetadata(mainDecoration.paramsTypes[0])
92
+ : [],
93
+ });
94
+ });
95
+ return functionsMetadata;
96
+ }
97
+ getModuleMetadata(moduleConstructor) {
98
+ const decorations = this.modulesDecorations.get(moduleConstructor);
99
+ if (!decorations) {
100
+ throw new Error(`Module ${moduleConstructor.name} not found`);
101
+ }
102
+ const mainDecoration = decorations.find((decoration) => decoration.decorationName === MINDSET_MODULE_DECORATION_MODULE);
103
+ if (!mainDecoration) {
104
+ throw new Error(`Module ${moduleConstructor.name} not found`);
105
+ }
106
+ return {
107
+ constructor: moduleConstructor,
108
+ config: mainDecoration.decorationConfig,
109
+ functions: this.getFunctionsMetadata(moduleConstructor),
110
+ };
111
+ }
112
+ getMindsetMetadata(ctor) {
113
+ const decorations = this.mindsetsDecorations.get(ctor);
114
+ if (!decorations) {
115
+ throw new Error(`Mindset ${ctor.name} not found`);
116
+ }
117
+ const mainDecoration = decorations.find((decoration) => decoration.decorationName === MINDSET_DECORATION_MINDSET);
118
+ if (!mainDecoration) {
119
+ throw new Error(`Mindset ${ctor.name} not found`);
120
+ }
121
+ return {
122
+ constructor: ctor,
123
+ config: mainDecoration.decorationConfig,
124
+ modules: mainDecoration.decorationConfig.modules
125
+ ? mainDecoration.decorationConfig.modules.map((module) => this.getModuleMetadata(module))
126
+ : [],
127
+ };
128
+ }
129
+ };
130
+ MindsetMetadataStore = __decorate([
131
+ singleton()
132
+ ], MindsetMetadataStore);
133
+
134
+ export { MindsetMetadataStore };
@@ -0,0 +1,3 @@
1
+ import 'reflect-metadata';
2
+ import { IMindsetFunctionConfig } from './IMindsetFunctionConfig';
3
+ export declare function mindsetFunction(config: IMindsetFunctionConfig): (target: object, propertyKey: string | symbol) => void;
@@ -0,0 +1,21 @@
1
+ import 'reflect-metadata';
2
+ import { container } from '../../../injection/index.js';
3
+ import { MindsetMetadataStore } from '../MindsetMetadataStore.js';
4
+ import { MINDSET_FUNCTION_DECORATION_FUNCTION } from './decoratorNames.js';
5
+
6
+ function mindsetFunction(config) {
7
+ return function (target, propertyKey) {
8
+ const functionName = propertyKey.toString();
9
+ const paramsTypes = Reflect.getMetadata('design:paramtypes', target, functionName);
10
+ const store = container.resolve(MindsetMetadataStore);
11
+ store.saveFunctionDecoration({
12
+ decorationName: MINDSET_FUNCTION_DECORATION_FUNCTION,
13
+ paramsTypes: paramsTypes,
14
+ functionName,
15
+ constructor: target.constructor,
16
+ decorationConfig: config,
17
+ });
18
+ };
19
+ }
20
+
21
+ export { mindsetFunction };
@@ -0,0 +1,3 @@
1
+ export interface IMindsetFunctionConfig {
2
+ description: string;
3
+ }
@@ -0,0 +1,7 @@
1
+ export interface IMindsetFunctionDecoration {
2
+ decorationName: string;
3
+ functionName: string;
4
+ constructor: Function;
5
+ paramsTypes: Function[];
6
+ decorationConfig: any;
7
+ }
@@ -0,0 +1 @@
1
+ export declare const MINDSET_FUNCTION_DECORATION_FUNCTION = "mindsetFunction";
@@ -0,0 +1,3 @@
1
+ const MINDSET_FUNCTION_DECORATION_FUNCTION = 'mindsetFunction';
2
+
3
+ export { MINDSET_FUNCTION_DECORATION_FUNCTION };
@@ -0,0 +1,4 @@
1
+ export * from './@mindsetFunction';
2
+ export * from './decoratorNames';
3
+ export * from './IMindsetFunctionConfig';
4
+ export * from './IMindsetFunctionDecoration';
@@ -0,0 +1,6 @@
1
+ export * from './functions';
2
+ export * from './mindsets';
3
+ export * from './modules';
4
+ export * from './params';
5
+ export * from './IMindsetMetadata';
6
+ export * from './MindsetMetadataStore';
@@ -0,0 +1,5 @@
1
+ import 'reflect-metadata';
2
+ import { IConstructor } from '@/shared';
3
+ import { IMindset } from '../../IMindset';
4
+ import { IMindsetConfig } from './IMindsetConfig';
5
+ export declare function mindset(config: IMindsetConfig): (target: IConstructor<IMindset>) => void;
@@ -0,0 +1,18 @@
1
+ import 'reflect-metadata';
2
+ import { container, injectable } from '../../../injection/index.js';
3
+ import { MindsetMetadataStore } from '../MindsetMetadataStore.js';
4
+ import { MINDSET_DECORATION_MINDSET } from './decoratorNames.js';
5
+
6
+ function mindset(config) {
7
+ return function (target) {
8
+ const store = container.resolve(MindsetMetadataStore);
9
+ store.saveMindsetDecoration({
10
+ decorationName: MINDSET_DECORATION_MINDSET,
11
+ constructor: target,
12
+ decorationConfig: config,
13
+ });
14
+ injectable()(target);
15
+ };
16
+ }
17
+
18
+ export { mindset };
@@ -0,0 +1,4 @@
1
+ import { IConstructor } from "@/shared";
2
+ export interface IMindsetConfig {
3
+ modules?: IConstructor<any>[];
4
+ }
@@ -0,0 +1,6 @@
1
+ import { IMindsetConfig } from "./IMindsetConfig";
2
+ export interface IMindsetDecoration {
3
+ decorationName: string;
4
+ constructor: Function;
5
+ decorationConfig: IMindsetConfig;
6
+ }
@@ -0,0 +1 @@
1
+ export declare const MINDSET_DECORATION_MINDSET = "mindset";
@@ -0,0 +1,3 @@
1
+ const MINDSET_DECORATION_MINDSET = 'mindset';
2
+
3
+ export { MINDSET_DECORATION_MINDSET };
@@ -0,0 +1,3 @@
1
+ export * from './@mindset';
2
+ export * from './decoratorNames';
3
+ export * from './IMindsetDecoration';
@@ -0,0 +1,4 @@
1
+ import 'reflect-metadata';
2
+ import { IConstructor } from '@/shared';
3
+ import { IMindsetModuleConfig } from './IMindsetModuleConfig';
4
+ export declare function mindsetModule<A>(config: IMindsetModuleConfig): (target: IConstructor<A>) => void;
@@ -0,0 +1,18 @@
1
+ import 'reflect-metadata';
2
+ import { container, injectable } from '../../../injection/index.js';
3
+ import { MindsetMetadataStore } from '../MindsetMetadataStore.js';
4
+ import { MINDSET_MODULE_DECORATION_MODULE } from './decoratorNames.js';
5
+
6
+ function mindsetModule(config) {
7
+ return function (target) {
8
+ const store = container.resolve(MindsetMetadataStore);
9
+ store.saveModuleDecoration({
10
+ decorationName: MINDSET_MODULE_DECORATION_MODULE,
11
+ constructor: target,
12
+ decorationConfig: config,
13
+ });
14
+ injectable()(target);
15
+ };
16
+ }
17
+
18
+ export { mindsetModule };
@@ -0,0 +1,3 @@
1
+ export interface IMindsetModuleConfig {
2
+ description: string;
3
+ }
@@ -0,0 +1,5 @@
1
+ export interface IMindsetModuleDecoration {
2
+ decorationName: string;
3
+ constructor: Function;
4
+ decorationConfig: any;
5
+ }
@@ -0,0 +1 @@
1
+ export declare const MINDSET_MODULE_DECORATION_MODULE = "mindsetModule";
@@ -0,0 +1,3 @@
1
+ const MINDSET_MODULE_DECORATION_MODULE = 'mindsetModule';
2
+
3
+ export { MINDSET_MODULE_DECORATION_MODULE };
@@ -0,0 +1,4 @@
1
+ export * from './@mindsetModule';
2
+ export * from './decoratorNames';
3
+ export * from './IMindsetModuleConfig';
4
+ export * from './IMindsetModuleDecoration';
@@ -0,0 +1,2 @@
1
+ import 'reflect-metadata';
2
+ export declare function isOptional(): PropertyDecorator;
@@ -0,0 +1,21 @@
1
+ import 'reflect-metadata';
2
+ import { MindsetMetadataStore } from '../MindsetMetadataStore.js';
3
+ import { container } from '../../../injection/index.js';
4
+ import { PARAM_DECORATION_IS_OPTIONAL } from './decoratorNames.js';
5
+
6
+ function isOptional() {
7
+ return (target, propertyKey) => {
8
+ const paramName = propertyKey.toString();
9
+ const paramType = Reflect.getMetadata('design:type', target, paramName);
10
+ const store = container.resolve(MindsetMetadataStore);
11
+ store.saveParamDecoration({
12
+ decorationName: PARAM_DECORATION_IS_OPTIONAL,
13
+ paramType: paramType,
14
+ paramName: paramName,
15
+ constructor: target.constructor,
16
+ decorationConfig: {}
17
+ });
18
+ };
19
+ }
20
+
21
+ export { isOptional };
@@ -0,0 +1,3 @@
1
+ import 'reflect-metadata';
2
+ import { IParamConfig } from './IParamConfig';
3
+ export declare function param(config: IParamConfig): PropertyDecorator;
@@ -0,0 +1,21 @@
1
+ import 'reflect-metadata';
2
+ import { MindsetMetadataStore } from '../MindsetMetadataStore.js';
3
+ import { container } from '../../../injection/index.js';
4
+ import { PARAM_DECORATION_PARAM } from './decoratorNames.js';
5
+
6
+ function param(config) {
7
+ return (target, propertyKey) => {
8
+ const paramName = propertyKey.toString();
9
+ const paramType = Reflect.getMetadata('design:type', target, paramName);
10
+ const store = container.resolve(MindsetMetadataStore);
11
+ store.saveParamDecoration({
12
+ decorationName: PARAM_DECORATION_PARAM,
13
+ paramType: paramType,
14
+ paramName: paramName,
15
+ constructor: target.constructor,
16
+ decorationConfig: config,
17
+ });
18
+ };
19
+ }
20
+
21
+ export { param };
@@ -0,0 +1,4 @@
1
+ export interface IParamConfig {
2
+ name?: string;
3
+ description: string;
4
+ }
@@ -0,0 +1,7 @@
1
+ export interface IParamDecoration {
2
+ decorationName: string;
3
+ paramType: any;
4
+ paramName: string;
5
+ constructor: Function;
6
+ decorationConfig: any;
7
+ }
@@ -0,0 +1,2 @@
1
+ export declare const PARAM_DECORATION_IS_OPTIONAL = "isOptional";
2
+ export declare const PARAM_DECORATION_PARAM = "param";
@@ -0,0 +1,4 @@
1
+ const PARAM_DECORATION_IS_OPTIONAL = 'isOptional';
2
+ const PARAM_DECORATION_PARAM = 'param';
3
+
4
+ export { PARAM_DECORATION_IS_OPTIONAL, PARAM_DECORATION_PARAM };
@@ -0,0 +1,3 @@
1
+ export * from './@isOptional';
2
+ export * from './@param';
3
+ export * from './IParamDecoration';