1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | require("reflect-metadata");
|
4 | exports.INCEPTUM_METADATA_KEY = 'inceptum';
|
5 | class InceptumMetadata {
|
6 | constructor() {
|
7 | this.autowire = new Map();
|
8 | this.defaultValue = new Map();
|
9 | this.lazy = true;
|
10 | this.startMethod = null;
|
11 | this.stopMethod = null;
|
12 | this.groups = [];
|
13 | }
|
14 | }
|
15 | exports.InceptumMetadata = InceptumMetadata;
|
16 | function hasDecoratorMetadata(target) {
|
17 | return Reflect.hasMetadata(exports.INCEPTUM_METADATA_KEY, target);
|
18 | }
|
19 | exports.hasDecoratorMetadata = hasDecoratorMetadata;
|
20 | function getDecoratorMetadata(target) {
|
21 | return Reflect.getMetadata(exports.INCEPTUM_METADATA_KEY, target);
|
22 | }
|
23 | exports.getDecoratorMetadata = getDecoratorMetadata;
|
24 | function getOrCreateMetadata(target) {
|
25 | if (hasDecoratorMetadata(target)) {
|
26 | return getDecoratorMetadata(target);
|
27 | }
|
28 | const metadata = new InceptumMetadata();
|
29 | Reflect.defineMetadata(exports.INCEPTUM_METADATA_KEY, metadata, target);
|
30 | return metadata;
|
31 | }
|
32 | function Autowire(what) {
|
33 | return (target, key) => {
|
34 |
|
35 | const metadata = getOrCreateMetadata(target);
|
36 | metadata.autowire.set(key, what);
|
37 | };
|
38 | }
|
39 | exports.Autowire = Autowire;
|
40 | function AutowireContext(target, key) {
|
41 |
|
42 | const metadata = getOrCreateMetadata(target);
|
43 | metadata.autowire.set(key, '__CONTEXT__');
|
44 | }
|
45 | exports.AutowireContext = AutowireContext;
|
46 | function AutowireConfig(configKey, defaultValue) {
|
47 | return (target, key) => {
|
48 |
|
49 | const metadata = getOrCreateMetadata(target);
|
50 | metadata.autowire.set(key, `#${configKey}`);
|
51 | if (defaultValue !== undefined) {
|
52 | metadata.defaultValue.set(configKey, defaultValue);
|
53 | }
|
54 | };
|
55 | }
|
56 | exports.AutowireConfig = AutowireConfig;
|
57 | function AutowireGroup(groupName) {
|
58 | return (target, key) => {
|
59 |
|
60 | const metadata = getOrCreateMetadata(target);
|
61 | metadata.autowire.set(key, `%${groupName}`);
|
62 | };
|
63 | }
|
64 | exports.AutowireGroup = AutowireGroup;
|
65 | function AutowireGroupDefinitions(groupName) {
|
66 | return (target, key) => {
|
67 |
|
68 | const metadata = getOrCreateMetadata(target);
|
69 | metadata.autowire.set(key, `&${groupName}`);
|
70 | };
|
71 | }
|
72 | exports.AutowireGroupDefinitions = AutowireGroupDefinitions;
|
73 | function Lazy(lazy) {
|
74 | return (target) => {
|
75 | const metadata = getOrCreateMetadata(target.prototype);
|
76 | metadata.lazy = lazy;
|
77 | };
|
78 | }
|
79 | exports.Lazy = Lazy;
|
80 | function StartMethod(target, key) {
|
81 | const metadata = getOrCreateMetadata(target);
|
82 | metadata.startMethod = key;
|
83 | }
|
84 | exports.StartMethod = StartMethod;
|
85 | function StopMethod(target, key) {
|
86 | const metadata = getOrCreateMetadata(target);
|
87 | metadata.stopMethod = key;
|
88 | }
|
89 | exports.StopMethod = StopMethod;
|
90 | function RegisterInGroup(groupName) {
|
91 | return (target) => {
|
92 | const metadata = getOrCreateMetadata(target.prototype);
|
93 | metadata.groups.push(groupName);
|
94 | };
|
95 | }
|
96 | exports.RegisterInGroup = RegisterInGroup;
|
97 |
|
\ | No newline at end of file |