@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.
- package/LICENSE +21 -0
- package/dist/src/_virtual/_commonjsHelpers.js +5 -0
- package/dist/src/_virtual/main.js +7 -0
- package/dist/src/_virtual/main2.js +3 -0
- package/dist/src/ai/index.d.ts +1 -0
- package/dist/src/ai/openia/OpenaiChatBotAdapter.d.ts +9 -0
- package/dist/src/ai/openia/OpenaiChatBotAdapter.js +85 -0
- package/dist/src/ai/openia/index.d.ts +1 -0
- package/dist/src/channels/cmd/CmdChannel.d.ts +9 -0
- package/dist/src/channels/cmd/CmdChannel.js +58 -0
- package/dist/src/channels/cmd/index.d.ts +1 -0
- package/dist/src/channels/index.d.ts +2 -0
- package/dist/src/channels/telegram/@telegram.d.ts +2 -0
- package/dist/src/channels/telegram/@telegram.js +19 -0
- package/dist/src/channels/telegram/TelegramChannel.d.ts +12 -0
- package/dist/src/channels/telegram/TelegramChannel.js +54 -0
- package/dist/src/channels/telegram/TelegramChannelConfig.d.ts +7 -0
- package/dist/src/channels/telegram/TelegramChannelConfig.js +8 -0
- package/dist/src/channels/telegram/index.d.ts +3 -0
- package/dist/src/chatbot/ChatBot.d.ts +11 -0
- package/dist/src/chatbot/ChatBot.js +51 -0
- package/dist/src/chatbot/ChatBotAdapter.d.ts +26 -0
- package/dist/src/chatbot/ChatBotAdapter.js +74 -0
- package/dist/src/chatbot/IChatBot.d.ts +4 -0
- package/dist/src/chatbot/chat/Chat.d.ts +23 -0
- package/dist/src/chatbot/chat/Chat.js +55 -0
- package/dist/src/chatbot/chat/IChatFunctionCall.d.ts +6 -0
- package/dist/src/chatbot/chat/IChatItem.d.ts +19 -0
- package/dist/src/chatbot/chat/index.d.ts +4 -0
- package/dist/src/chatbot/chat/repository/IChatMemory.d.ts +9 -0
- package/dist/src/chatbot/chat/repository/IChatMemory.js +10 -0
- package/dist/src/chatbot/chat/repository/IChatRepository.d.ts +12 -0
- package/dist/src/chatbot/chat/repository/IChatRepository.js +19 -0
- package/dist/src/chatbot/chat/repository/index.d.ts +3 -0
- package/dist/src/chatbot/chat/repository/ram/RamChatMemory.d.ts +8 -0
- package/dist/src/chatbot/chat/repository/ram/RamChatMemory.js +14 -0
- package/dist/src/chatbot/chat/repository/ram/RamChatRepository.d.ts +11 -0
- package/dist/src/chatbot/chat/repository/ram/RamChatRepository.js +41 -0
- package/dist/src/chatbot/chat/repository/ram/index.d.ts +2 -0
- package/dist/src/chatbot/index.d.ts +5 -0
- package/dist/src/chatbot/metadata/@chatBot.d.ts +3 -0
- package/dist/src/chatbot/metadata/@chatBot.js +18 -0
- package/dist/src/chatbot/metadata/ChatBotMetadataStore.d.ts +6 -0
- package/dist/src/chatbot/metadata/ChatBotMetadataStore.js +17 -0
- package/dist/src/chatbot/metadata/IChatBotMetadata.d.ts +7 -0
- package/dist/src/chatbot/metadata/index.d.ts +3 -0
- package/dist/src/context/IContext.d.ts +18 -0
- package/dist/src/context/IContext.js +10 -0
- package/dist/src/context/index.d.ts +1 -0
- package/dist/src/controller/channel/ChatResolver.d.ts +9 -0
- package/dist/src/controller/channel/ChatResolver.js +43 -0
- package/dist/src/controller/channel/IChatChannel.d.ts +5 -0
- package/dist/src/controller/channel/IMessageContext.d.ts +10 -0
- package/dist/src/controller/channel/index.d.ts +3 -0
- package/dist/src/controller/index.d.ts +2 -0
- package/dist/src/controller/metadata/ControllerMetadataStore.d.ts +12 -0
- package/dist/src/controller/metadata/ControllerMetadataStore.js +42 -0
- package/dist/src/controller/metadata/channel/IChannelMetadata.d.ts +8 -0
- package/dist/src/controller/metadata/channel/index.d.ts +1 -0
- package/dist/src/controller/metadata/controller/@chatController.d.ts +3 -0
- package/dist/src/controller/metadata/controller/@chatController.js +14 -0
- package/dist/src/controller/metadata/controller/IChatControllerConfig.d.ts +2 -0
- package/dist/src/controller/metadata/controller/IChatControllerMetadata.d.ts +3 -0
- package/dist/src/controller/metadata/controller/index.d.ts +3 -0
- package/dist/src/controller/metadata/index.d.ts +3 -0
- package/dist/src/index.d.ts +10 -0
- package/dist/src/index.js +34 -0
- package/dist/src/injection/Container.d.ts +18 -0
- package/dist/src/injection/Container.js +43 -0
- package/dist/src/injection/index.d.ts +3 -0
- package/dist/src/injection/index.js +4 -0
- package/dist/src/message/IChatDocument.d.ts +2 -0
- package/dist/src/message/IChatImage.d.ts +2 -0
- package/dist/src/message/IChatMessage.d.ts +9 -0
- package/dist/src/message/IChatSender.d.ts +4 -0
- package/dist/src/message/index.d.ts +4 -0
- package/dist/src/mindset/IMindset.d.ts +17 -0
- package/dist/src/mindset/IMindset.js +13 -0
- package/dist/src/mindset/MindsetOperator.d.ts +25 -0
- package/dist/src/mindset/MindsetOperator.js +101 -0
- package/dist/src/mindset/index.d.ts +3 -0
- package/dist/src/mindset/metadata/IMindsetMetadata.d.ts +28 -0
- package/dist/src/mindset/metadata/MindsetMetadataStore.d.ts +19 -0
- package/dist/src/mindset/metadata/MindsetMetadataStore.js +134 -0
- package/dist/src/mindset/metadata/functions/@mindsetFunction.d.ts +3 -0
- package/dist/src/mindset/metadata/functions/@mindsetFunction.js +21 -0
- package/dist/src/mindset/metadata/functions/IMindsetFunctionConfig.d.ts +3 -0
- package/dist/src/mindset/metadata/functions/IMindsetFunctionDecoration.d.ts +7 -0
- package/dist/src/mindset/metadata/functions/decoratorNames.d.ts +1 -0
- package/dist/src/mindset/metadata/functions/decoratorNames.js +3 -0
- package/dist/src/mindset/metadata/functions/index.d.ts +4 -0
- package/dist/src/mindset/metadata/index.d.ts +6 -0
- package/dist/src/mindset/metadata/mindsets/@mindset.d.ts +5 -0
- package/dist/src/mindset/metadata/mindsets/@mindset.js +18 -0
- package/dist/src/mindset/metadata/mindsets/IMindsetConfig.d.ts +4 -0
- package/dist/src/mindset/metadata/mindsets/IMindsetDecoration.d.ts +6 -0
- package/dist/src/mindset/metadata/mindsets/decoratorNames.d.ts +1 -0
- package/dist/src/mindset/metadata/mindsets/decoratorNames.js +3 -0
- package/dist/src/mindset/metadata/mindsets/index.d.ts +3 -0
- package/dist/src/mindset/metadata/modules/@mindsetModule.d.ts +4 -0
- package/dist/src/mindset/metadata/modules/@mindsetModule.js +18 -0
- package/dist/src/mindset/metadata/modules/IMindsetModuleConfig.d.ts +3 -0
- package/dist/src/mindset/metadata/modules/IMindsetModuleDecoration.d.ts +5 -0
- package/dist/src/mindset/metadata/modules/decoratorNames.d.ts +1 -0
- package/dist/src/mindset/metadata/modules/decoratorNames.js +3 -0
- package/dist/src/mindset/metadata/modules/index.d.ts +4 -0
- package/dist/src/mindset/metadata/params/@isOptional.d.ts +2 -0
- package/dist/src/mindset/metadata/params/@isOptional.js +21 -0
- package/dist/src/mindset/metadata/params/@param.d.ts +3 -0
- package/dist/src/mindset/metadata/params/@param.js +21 -0
- package/dist/src/mindset/metadata/params/IParamConfig.d.ts +4 -0
- package/dist/src/mindset/metadata/params/IParamDecoration.d.ts +7 -0
- package/dist/src/mindset/metadata/params/decoratorNames.d.ts +2 -0
- package/dist/src/mindset/metadata/params/decoratorNames.js +4 -0
- package/dist/src/mindset/metadata/params/index.d.ts +3 -0
- package/dist/src/node_modules/dotenv/lib/main.js +376 -0
- package/dist/src/node_modules/dotenv/package.json.js +5 -0
- package/dist/src/server/index.d.ts +3 -0
- package/dist/src/server/prepareChatContainer.d.ts +5 -0
- package/dist/src/server/prepareChatContainer.js +41 -0
- package/dist/src/server/runChannel.d.ts +12 -0
- package/dist/src/server/runChannel.js +29 -0
- package/dist/src/server/runServer.d.ts +8 -0
- package/dist/src/server/runServer.js +42 -0
- package/dist/src/shared/IConstructor.d.ts +1 -0
- package/dist/src/shared/index.d.ts +1 -0
- 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,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,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 @@
|
|
|
1
|
+
export declare const MINDSET_FUNCTION_DECORATION_FUNCTION = "mindsetFunction";
|
|
@@ -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 @@
|
|
|
1
|
+
export declare const MINDSET_DECORATION_MINDSET = "mindset";
|
|
@@ -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 @@
|
|
|
1
|
+
export declare const MINDSET_MODULE_DECORATION_MODULE = "mindsetModule";
|
|
@@ -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,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 };
|