@prostojs/mate 0.1.12 → 0.1.14

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.
@@ -55,30 +55,21 @@ else {
55
55
  }
56
56
  const Reflect$1 = _reflect;
57
57
 
58
- const banner = () => `[prostojs/mate][${new Date().toISOString().replace('T', ' ').replace(/\.\d{3}z$/i, '')}] `;
59
-
60
- function logError(error) {
61
- console.error('' + '' + banner() + error + '');
62
- }
63
-
64
- function panic(error) {
65
- logError(error);
66
- return new Error(error);
67
- }
68
-
69
58
  const Reflect = (global === null || global === void 0 ? void 0 : global.Reflect) || (self === null || self === void 0 ? void 0 : self.Reflect) || Reflect$1;
70
59
  class Mate {
71
60
  constructor(workspace, options = {}) {
72
61
  this.workspace = workspace;
73
62
  this.options = options;
63
+ this.logger = options.logger || console;
74
64
  }
75
65
  set(args, key, value, isArray) {
76
66
  var _a;
67
+ let level = 'CLASS';
77
68
  const newArgs = args.level === 'CLASS' ? { target: args.target }
78
- : args.level === 'PROPERTY' ? { target: args.target, propKey: args.propKey }
69
+ : args.level === 'PROP' ? { target: args.target, propKey: args.propKey }
79
70
  : args;
80
71
  let meta = Reflect.getOwnMetadata(this.workspace, newArgs.target, newArgs.propKey) || {};
81
- if (newArgs.propKey && this.options.readReturnType && !meta.returnType) {
72
+ if (newArgs.propKey && this.options.readReturnType && !meta.returnType && args.descriptor) {
82
73
  meta.returnType = Reflect.getOwnMetadata('design:returntype', newArgs.target, newArgs.propKey);
83
74
  }
84
75
  if (newArgs.propKey && this.options.readType && !meta.type) {
@@ -91,12 +82,13 @@ class Mate {
91
82
  data.params = (_a = Reflect.getOwnMetadata('design:paramtypes', newArgs.target, newArgs.propKey)) === null || _a === void 0 ? void 0 : _a.map((f) => ({ type: f }));
92
83
  }
93
84
  if (typeof index === 'number') {
85
+ level = 'PARAM';
94
86
  data.params = data.params || [];
95
87
  data.params[index] = data.params[index] || {
96
88
  type: undefined,
97
89
  };
98
90
  if (cb) {
99
- data.params[index] = cb(data.params[index], args.propKey, typeof args.index === 'number' ? args.index : undefined);
91
+ data.params[index] = cb(data.params[index], level, args.propKey, typeof args.index === 'number' ? args.index : undefined);
100
92
  }
101
93
  else {
102
94
  data = data.params[index];
@@ -113,11 +105,12 @@ class Mate {
113
105
  return meta;
114
106
  });
115
107
  }
108
+ level = typeof index === 'number' ? 'PARAM' : newArgs.propKey && newArgs.descriptor ? 'METHOD' : newArgs.propKey ? 'PROP' : 'CLASS';
116
109
  if (typeof key !== 'function') {
117
110
  if (isArray) {
118
111
  const newArray = (data[key] || []);
119
112
  if (!Array.isArray(newArray)) {
120
- panic('Mate.add (isArray=true) called for non-array metadata');
113
+ this.logger.error('Mate.add (isArray=true) called for non-array metadata');
121
114
  }
122
115
  newArray.unshift(value);
123
116
  data[key] = newArray;
@@ -127,11 +120,11 @@ class Mate {
127
120
  }
128
121
  }
129
122
  else if (cb && typeof index !== 'number') {
130
- meta = cb(data, args.propKey, typeof args.index === 'number' ? args.index : undefined);
123
+ meta = cb(data, level, args.propKey, typeof args.index === 'number' ? args.index : undefined);
131
124
  }
132
125
  Reflect.defineMetadata(this.workspace, meta, newArgs.target, newArgs.propKey);
133
126
  }
134
- read(target, propKey, index) {
127
+ read(target, propKey) {
135
128
  const isConstr = isConstructor(target);
136
129
  const constructor = isConstr ? target : getConstructor(target);
137
130
  const proto = constructor.prototype;
@@ -142,17 +135,31 @@ class Mate {
142
135
  if (inheritFn) {
143
136
  if (typeof propKey === 'string') {
144
137
  const classMeta = Reflect.getOwnMetadata(this.workspace, constructor);
145
- shouldInherit = inheritFn(classMeta, propKey, ownMeta);
138
+ shouldInherit = inheritFn(classMeta, ownMeta, 'PROP', propKey);
146
139
  }
147
140
  else {
148
- shouldInherit = inheritFn(ownMeta);
141
+ shouldInherit = inheritFn(ownMeta, ownMeta, 'CLASS');
149
142
  }
150
143
  }
151
144
  if (shouldInherit) {
152
145
  const parent = Object.getPrototypeOf(constructor);
153
146
  if (typeof parent === 'function' && parent !== fnProto && parent !== constructor) {
154
- const inheritedMeta = this.read(parent, propKey);
155
- ownMeta = { ...inheritedMeta, ...ownMeta, params: ownMeta === null || ownMeta === void 0 ? void 0 : ownMeta.params };
147
+ const inheritedMeta = this.read(parent, propKey) || {};
148
+ const ownParams = ownMeta === null || ownMeta === void 0 ? void 0 : ownMeta.params;
149
+ ownMeta = { ...inheritedMeta, ...ownMeta };
150
+ if (typeof propKey === 'string' && ownParams && (inheritedMeta === null || inheritedMeta === void 0 ? void 0 : inheritedMeta.params)) {
151
+ for (let i = 0; i < ownParams.length; i++) {
152
+ if (typeof (inheritedMeta === null || inheritedMeta === void 0 ? void 0 : inheritedMeta.params[i]) !== 'undefined') {
153
+ const ownParam = ownParams[i];
154
+ if (ownMeta.params && inheritFn && inheritFn(ownMeta, ownParam, 'PARAM', typeof propKey === 'string' ? propKey : undefined)) {
155
+ ownMeta.params[i] = {
156
+ ...inheritedMeta === null || inheritedMeta === void 0 ? void 0 : inheritedMeta.params[i],
157
+ ...ownParams[i],
158
+ };
159
+ }
160
+ }
161
+ }
162
+ }
156
163
  }
157
164
  }
158
165
  }
@@ -177,6 +184,16 @@ class Mate {
177
184
  this.set(args, key, value, isArray);
178
185
  });
179
186
  }
187
+ decorateConditional(ccb) {
188
+ return ((target, propKey, descriptor) => {
189
+ const hasIndex = typeof descriptor === 'number';
190
+ const decoratorLevel = hasIndex ? 'PARAM' : propKey && descriptor ? 'METHOD' : propKey ? 'PROP' : 'CLASS';
191
+ const d = ccb(decoratorLevel);
192
+ if (d) {
193
+ d(target, propKey, descriptor);
194
+ }
195
+ });
196
+ }
180
197
  decorateClass(key, value, isArray) {
181
198
  return this.decorate(key, value, isArray, 'CLASS');
182
199
  }
package/dist/mate.d.ts CHANGED
@@ -1,36 +1,64 @@
1
+ declare type ArrayElementType<T> = T extends (infer E)[] ? E : never;
2
+
1
3
  export declare function getConstructor<T = TAny>(instance: T): TFunction;
2
4
 
3
5
  export declare function isConstructor<T = TAny>(v: T): v is (T & TClassConstructor);
4
6
 
5
- export declare class Mate<T extends TProstoMetadata = TProstoMetadata> {
7
+ export declare class Mate<TClass extends TObject = TEmpty, TProp extends TObject = TEmpty, TParam extends TObject = TEmpty> {
6
8
  protected workspace: string;
7
- protected options: TMateOptions<T>;
8
- constructor(workspace: string, options?: TMateOptions<T>);
9
- set<R extends T = T, RP = R['params'][0]>(args: TMergedDecoratorArgs, cb: ((meta: R & RP, propKey?: string | symbol, index?: number) => R & RP)): void;
10
- set<R extends T = T, RP = R['params'][0]>(args: TMergedDecoratorArgs, key: keyof R | keyof RP, value: ((R & RP)[keyof R] & (R & RP)[keyof RP]) | undefined): void;
11
- set<R extends T = T, RP = R['params'][0]>(args: TMergedDecoratorArgs, key: keyof R | keyof RP, value: ((R & RP)[keyof R] & (R & RP)[keyof RP]) | undefined, isArray: boolean | undefined): void;
12
- read<R extends T = T>(target: TFunction | TObject, propKey?: string | symbol, index?: number): R | undefined;
9
+ protected options: TMateOptions<TClass, TProp, TParam>;
10
+ protected logger: TConsoleBase;
11
+ constructor(workspace: string, options?: TMateOptions<TClass, TProp, TParam>);
12
+ set<TMeta extends TObject = Partial<TClass & TProp & TParam>>(args: TMergedDecoratorArgs, cb: ((meta: TMeta, level: TLevels, propKey?: string | symbol, index?: number) => TMeta)): void;
13
+ set<TMeta extends TObject = Partial<TClass & TProp & TParam>, TKey extends keyof TMeta = keyof TMeta>(args: TMergedDecoratorArgs, key: keyof TMeta, value: TMeta[TKey]): void;
14
+ set<TMeta extends TObject = Partial<TClass & TProp & TParam>, TKey extends keyof TMeta = keyof TMeta>(args: TMergedDecoratorArgs, key: keyof TMeta, value: TMeta[TKey], isArray: boolean | undefined): void;
15
+ read<TMeta extends Partial<TClass & TMateClassMeta & TProp & TMatePropMeta<TParam> & TParam & TMateParamMeta>>(target: TFunction | TObject, propKey?: string | symbol): TMeta | undefined;
13
16
  apply(...decorators: (MethodDecorator | ClassDecorator | ParameterDecorator | PropertyDecorator)[]): MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
14
- decorate<R extends T = T, RP = R['params'][0]>(cb: ((meta: R & RP, propKey?: string | symbol, index?: number) => R & RP)): MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
15
- decorate<R extends T = T, RP = R['params'][0]>(key: keyof R | keyof RP | ((meta: R & RP) => R & RP), value: ((R & RP)[keyof R] & (R & RP)[keyof RP]) | undefined): MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
16
- decorate<R extends T = T, RP = R['params'][0]>(key: keyof R | keyof RP | ((meta: R & RP) => R & RP), value: ((R & RP)[keyof R] & (R & RP)[keyof RP]) | undefined, isArray: boolean | undefined): MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
17
- decorate<R extends T = T, RP = R['params'][0]>(key: keyof R | keyof RP | ((meta: R & RP) => R & RP), value: ((R & RP)[keyof R] & (R & RP)[keyof RP]) | undefined, isArray: boolean | undefined, level: TMergedDecoratorArgs['level']): MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
18
- decorateClass<R extends T = T, RP = R['params'][0]>(cb: ((meta: R & RP, propKey?: string | symbol, index?: number) => R & RP)): MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
19
- decorateClass<R extends T = T, RP = R['params'][0]>(key: keyof R | keyof RP | ((meta: R & RP) => R & RP), value: ((R & RP)[keyof R] & (R & RP)[keyof RP]) | undefined): MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
20
- decorateClass<R extends T = T, RP = R['params'][0]>(key: keyof R | keyof RP | ((meta: R & RP) => R & RP), value: ((R & RP)[keyof R] & (R & RP)[keyof RP]) | undefined, isArray: boolean | undefined): MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
17
+ decorate<TMeta extends TObject = Partial<TClass & TProp & TParam>>(cb: ((meta: TMeta, level: TLevels, propKey?: string | symbol, index?: number) => TMeta)): MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
18
+ decorate<TMeta extends Partial<TClass & TProp & TParam>, TKey extends keyof TMeta>(key: TKey, value: TMeta[TKey]): MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
19
+ decorate<TMeta extends Partial<TClass & TProp & TParam>, TKey extends keyof TMeta, TIsArray extends boolean = false>(key: TKey, value: TIsArray extends true ? ArrayElementType<TMeta[TKey]> : TMeta[TKey], isArray: TIsArray): MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
20
+ decorate<TMeta extends Partial<TClass & TProp & TParam>, TKey extends keyof TMeta, TIsArray extends boolean = false>(key: TKey | ((meta: TMeta, level: TLevels, propKey?: string | symbol, index?: number) => TMeta), value: TIsArray extends true ? ArrayElementType<TMeta[TKey]> : TMeta[TKey], isArray: TIsArray, level: TMergedDecoratorArgs['level']): MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
21
+ decorateConditional(ccb: (level: TLevels) => (MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator) | void | undefined): MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
22
+ decorateClass<TMeta extends TObject = Partial<TClass & TProp & TParam>>(cb: ((meta: TMeta, level: TLevels, propKey?: string | symbol, index?: number) => TMeta)): MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
23
+ decorateClass<TMeta extends TObject = Partial<TClass & TProp & TParam>, TKey extends keyof TMeta = keyof TMeta, TIsArray extends boolean = false>(key: TKey, value: TIsArray extends true ? ArrayElementType<TMeta[TKey]> : TMeta[TKey]): MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
24
+ decorateClass<TMeta extends TObject = Partial<TClass & TProp & TParam>, TKey extends keyof TMeta = keyof TMeta, TIsArray extends boolean = false>(key: TKey, value: TIsArray extends true ? ArrayElementType<TMeta[TKey]> : TMeta[TKey], isArray: boolean | undefined): MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
21
25
  }
22
26
 
23
27
  declare type TAny = any;
24
28
 
25
29
  declare type TClassConstructor<T = unknown> = new (...args: TAny[]) => T;
26
30
 
31
+ declare interface TConsoleBase {
32
+ error: ((...args: any) => void);
33
+ }
34
+
35
+ declare interface TEmpty {
36
+ }
37
+
27
38
  declare type TFunction = Function;
28
39
 
29
- export declare interface TMateOptions<T extends TProstoMetadata = TProstoMetadata> {
40
+ declare type TLevels = 'CLASS' | 'METHOD' | 'PROP' | 'PARAM';
41
+
42
+ export declare interface TMateClassMeta {
43
+ properties?: (string | symbol)[];
44
+ type?: TFunction;
45
+ returnType?: TFunction;
46
+ }
47
+
48
+ export declare interface TMateOptions<TClass extends TObject = TEmpty, TProp extends TObject = TEmpty, TParam extends TObject = TEmpty> {
49
+ logger?: TConsoleBase;
30
50
  readReturnType?: boolean;
31
51
  readType?: boolean;
32
52
  collectPropKeys?: boolean;
33
- inherit?: boolean | ((classMeta: T, propKey?: string, methodMeta?: T) => boolean);
53
+ inherit?: boolean | ((classMeta: TClass & TMateClassMeta, targetMeta: (TMatePropMeta<TParam> & TProp) | (TMateParamMeta & TParam), level: 'CLASS' | 'PROP' | 'PARAM', key?: string) => boolean);
54
+ }
55
+
56
+ export declare interface TMateParamMeta {
57
+ type?: TFunction;
58
+ }
59
+
60
+ export declare interface TMatePropMeta<TParam extends TObject = TEmpty> {
61
+ params?: (TParam & TMateParamMeta)[];
34
62
  }
35
63
 
36
64
  export declare interface TMergedDecoratorArgs {
@@ -38,20 +66,9 @@ export declare interface TMergedDecoratorArgs {
38
66
  propKey?: string | symbol;
39
67
  descriptor?: TypedPropertyDescriptor<TAny>;
40
68
  index?: number;
41
- level?: 'CLASS' | 'PROPERTY';
69
+ level?: TLevels;
42
70
  }
43
71
 
44
72
  declare type TObject = object;
45
73
 
46
- export declare interface TProstoMetadata<TParams extends TProstoParamsMetadata = TProstoParamsMetadata> {
47
- params: TParams[];
48
- properties?: (string | symbol)[];
49
- type?: TFunction;
50
- returnType?: TFunction;
51
- }
52
-
53
- export declare interface TProstoParamsMetadata {
54
- type?: TFunction;
55
- }
56
-
57
74
  export { }
@@ -51,30 +51,21 @@ else {
51
51
  }
52
52
  const Reflect$1 = _reflect;
53
53
 
54
- const banner = () => `[prostojs/mate][${new Date().toISOString().replace('T', ' ').replace(/\.\d{3}z$/i, '')}] `;
55
-
56
- function logError(error) {
57
- console.error('' + '' + banner() + error + '');
58
- }
59
-
60
- function panic(error) {
61
- logError(error);
62
- return new Error(error);
63
- }
64
-
65
54
  const Reflect = (global === null || global === void 0 ? void 0 : global.Reflect) || (self === null || self === void 0 ? void 0 : self.Reflect) || Reflect$1;
66
55
  class Mate {
67
56
  constructor(workspace, options = {}) {
68
57
  this.workspace = workspace;
69
58
  this.options = options;
59
+ this.logger = options.logger || console;
70
60
  }
71
61
  set(args, key, value, isArray) {
72
62
  var _a;
63
+ let level = 'CLASS';
73
64
  const newArgs = args.level === 'CLASS' ? { target: args.target }
74
- : args.level === 'PROPERTY' ? { target: args.target, propKey: args.propKey }
65
+ : args.level === 'PROP' ? { target: args.target, propKey: args.propKey }
75
66
  : args;
76
67
  let meta = Reflect.getOwnMetadata(this.workspace, newArgs.target, newArgs.propKey) || {};
77
- if (newArgs.propKey && this.options.readReturnType && !meta.returnType) {
68
+ if (newArgs.propKey && this.options.readReturnType && !meta.returnType && args.descriptor) {
78
69
  meta.returnType = Reflect.getOwnMetadata('design:returntype', newArgs.target, newArgs.propKey);
79
70
  }
80
71
  if (newArgs.propKey && this.options.readType && !meta.type) {
@@ -87,12 +78,13 @@ class Mate {
87
78
  data.params = (_a = Reflect.getOwnMetadata('design:paramtypes', newArgs.target, newArgs.propKey)) === null || _a === void 0 ? void 0 : _a.map((f) => ({ type: f }));
88
79
  }
89
80
  if (typeof index === 'number') {
81
+ level = 'PARAM';
90
82
  data.params = data.params || [];
91
83
  data.params[index] = data.params[index] || {
92
84
  type: undefined,
93
85
  };
94
86
  if (cb) {
95
- data.params[index] = cb(data.params[index], args.propKey, typeof args.index === 'number' ? args.index : undefined);
87
+ data.params[index] = cb(data.params[index], level, args.propKey, typeof args.index === 'number' ? args.index : undefined);
96
88
  }
97
89
  else {
98
90
  data = data.params[index];
@@ -109,11 +101,12 @@ class Mate {
109
101
  return meta;
110
102
  });
111
103
  }
104
+ level = typeof index === 'number' ? 'PARAM' : newArgs.propKey && newArgs.descriptor ? 'METHOD' : newArgs.propKey ? 'PROP' : 'CLASS';
112
105
  if (typeof key !== 'function') {
113
106
  if (isArray) {
114
107
  const newArray = (data[key] || []);
115
108
  if (!Array.isArray(newArray)) {
116
- panic('Mate.add (isArray=true) called for non-array metadata');
109
+ this.logger.error('Mate.add (isArray=true) called for non-array metadata');
117
110
  }
118
111
  newArray.unshift(value);
119
112
  data[key] = newArray;
@@ -123,11 +116,11 @@ class Mate {
123
116
  }
124
117
  }
125
118
  else if (cb && typeof index !== 'number') {
126
- meta = cb(data, args.propKey, typeof args.index === 'number' ? args.index : undefined);
119
+ meta = cb(data, level, args.propKey, typeof args.index === 'number' ? args.index : undefined);
127
120
  }
128
121
  Reflect.defineMetadata(this.workspace, meta, newArgs.target, newArgs.propKey);
129
122
  }
130
- read(target, propKey, index) {
123
+ read(target, propKey) {
131
124
  const isConstr = isConstructor(target);
132
125
  const constructor = isConstr ? target : getConstructor(target);
133
126
  const proto = constructor.prototype;
@@ -138,17 +131,31 @@ class Mate {
138
131
  if (inheritFn) {
139
132
  if (typeof propKey === 'string') {
140
133
  const classMeta = Reflect.getOwnMetadata(this.workspace, constructor);
141
- shouldInherit = inheritFn(classMeta, propKey, ownMeta);
134
+ shouldInherit = inheritFn(classMeta, ownMeta, 'PROP', propKey);
142
135
  }
143
136
  else {
144
- shouldInherit = inheritFn(ownMeta);
137
+ shouldInherit = inheritFn(ownMeta, ownMeta, 'CLASS');
145
138
  }
146
139
  }
147
140
  if (shouldInherit) {
148
141
  const parent = Object.getPrototypeOf(constructor);
149
142
  if (typeof parent === 'function' && parent !== fnProto && parent !== constructor) {
150
- const inheritedMeta = this.read(parent, propKey);
151
- ownMeta = { ...inheritedMeta, ...ownMeta, params: ownMeta === null || ownMeta === void 0 ? void 0 : ownMeta.params };
143
+ const inheritedMeta = this.read(parent, propKey) || {};
144
+ const ownParams = ownMeta === null || ownMeta === void 0 ? void 0 : ownMeta.params;
145
+ ownMeta = { ...inheritedMeta, ...ownMeta };
146
+ if (typeof propKey === 'string' && ownParams && (inheritedMeta === null || inheritedMeta === void 0 ? void 0 : inheritedMeta.params)) {
147
+ for (let i = 0; i < ownParams.length; i++) {
148
+ if (typeof (inheritedMeta === null || inheritedMeta === void 0 ? void 0 : inheritedMeta.params[i]) !== 'undefined') {
149
+ const ownParam = ownParams[i];
150
+ if (ownMeta.params && inheritFn && inheritFn(ownMeta, ownParam, 'PARAM', typeof propKey === 'string' ? propKey : undefined)) {
151
+ ownMeta.params[i] = {
152
+ ...inheritedMeta === null || inheritedMeta === void 0 ? void 0 : inheritedMeta.params[i],
153
+ ...ownParams[i],
154
+ };
155
+ }
156
+ }
157
+ }
158
+ }
152
159
  }
153
160
  }
154
161
  }
@@ -173,6 +180,16 @@ class Mate {
173
180
  this.set(args, key, value, isArray);
174
181
  });
175
182
  }
183
+ decorateConditional(ccb) {
184
+ return ((target, propKey, descriptor) => {
185
+ const hasIndex = typeof descriptor === 'number';
186
+ const decoratorLevel = hasIndex ? 'PARAM' : propKey && descriptor ? 'METHOD' : propKey ? 'PROP' : 'CLASS';
187
+ const d = ccb(decoratorLevel);
188
+ if (d) {
189
+ d(target, propKey, descriptor);
190
+ }
191
+ });
192
+ }
176
193
  decorateClass(key, value, isArray) {
177
194
  return this.decorate(key, value, isArray, 'CLASS');
178
195
  }
@@ -1,41 +1,54 @@
1
1
  import { TAny, TFunction, TObject } from './types';
2
+ type TLevels = 'CLASS' | 'METHOD' | 'PROP' | 'PARAM';
2
3
  export interface TMergedDecoratorArgs {
3
4
  target: TFunction | TObject;
4
5
  propKey?: string | symbol;
5
6
  descriptor?: TypedPropertyDescriptor<TAny>;
6
7
  index?: number;
7
- level?: 'CLASS' | 'PROPERTY';
8
+ level?: TLevels;
8
9
  }
9
- export interface TProstoMetadata<TParams extends TProstoParamsMetadata = TProstoParamsMetadata> {
10
- params: TParams[];
10
+ export interface TMateParamMeta {
11
+ type?: TFunction;
12
+ }
13
+ export interface TMatePropMeta<TParam extends TObject = TEmpty> {
14
+ params?: (TParam & TMateParamMeta)[];
15
+ }
16
+ export interface TMateClassMeta {
11
17
  properties?: (string | symbol)[];
12
18
  type?: TFunction;
13
19
  returnType?: TFunction;
14
20
  }
15
- export interface TProstoParamsMetadata {
16
- type?: TFunction;
21
+ interface TConsoleBase {
22
+ error: ((...args: any) => void);
17
23
  }
18
- export interface TMateOptions<T extends TProstoMetadata = TProstoMetadata> {
24
+ export interface TMateOptions<TClass extends TObject = TEmpty, TProp extends TObject = TEmpty, TParam extends TObject = TEmpty> {
25
+ logger?: TConsoleBase;
19
26
  readReturnType?: boolean;
20
27
  readType?: boolean;
21
28
  collectPropKeys?: boolean;
22
- inherit?: boolean | ((classMeta: T, propKey?: string, methodMeta?: T) => boolean);
29
+ inherit?: boolean | ((classMeta: TClass & TMateClassMeta, targetMeta: (TMatePropMeta<TParam> & TProp) | (TMateParamMeta & TParam), level: 'CLASS' | 'PROP' | 'PARAM', key?: string) => boolean);
30
+ }
31
+ interface TEmpty {
23
32
  }
24
- export declare class Mate<T extends TProstoMetadata = TProstoMetadata> {
33
+ export declare class Mate<TClass extends TObject = TEmpty, TProp extends TObject = TEmpty, TParam extends TObject = TEmpty> {
25
34
  protected workspace: string;
26
- protected options: TMateOptions<T>;
27
- constructor(workspace: string, options?: TMateOptions<T>);
28
- set<R extends T = T, RP = R['params'][0]>(args: TMergedDecoratorArgs, cb: ((meta: R & RP, propKey?: string | symbol, index?: number) => R & RP)): void;
29
- set<R extends T = T, RP = R['params'][0]>(args: TMergedDecoratorArgs, key: keyof R | keyof RP, value: ((R & RP)[keyof R] & (R & RP)[keyof RP]) | undefined): void;
30
- set<R extends T = T, RP = R['params'][0]>(args: TMergedDecoratorArgs, key: keyof R | keyof RP, value: ((R & RP)[keyof R] & (R & RP)[keyof RP]) | undefined, isArray: boolean | undefined): void;
31
- read<R extends T = T>(target: TFunction | TObject, propKey?: string | symbol, index?: number): R | undefined;
35
+ protected options: TMateOptions<TClass, TProp, TParam>;
36
+ protected logger: TConsoleBase;
37
+ constructor(workspace: string, options?: TMateOptions<TClass, TProp, TParam>);
38
+ set<TMeta extends TObject = Partial<TClass & TProp & TParam>>(args: TMergedDecoratorArgs, cb: ((meta: TMeta, level: TLevels, propKey?: string | symbol, index?: number) => TMeta)): void;
39
+ set<TMeta extends TObject = Partial<TClass & TProp & TParam>, TKey extends keyof TMeta = keyof TMeta>(args: TMergedDecoratorArgs, key: keyof TMeta, value: TMeta[TKey]): void;
40
+ set<TMeta extends TObject = Partial<TClass & TProp & TParam>, TKey extends keyof TMeta = keyof TMeta>(args: TMergedDecoratorArgs, key: keyof TMeta, value: TMeta[TKey], isArray: boolean | undefined): void;
41
+ read<TMeta extends Partial<TClass & TMateClassMeta & TProp & TMatePropMeta<TParam> & TParam & TMateParamMeta>>(target: TFunction | TObject, propKey?: string | symbol): TMeta | undefined;
32
42
  apply(...decorators: (MethodDecorator | ClassDecorator | ParameterDecorator | PropertyDecorator)[]): MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
33
- decorate<R extends T = T, RP = R['params'][0]>(cb: ((meta: R & RP, propKey?: string | symbol, index?: number) => R & RP)): MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
34
- decorate<R extends T = T, RP = R['params'][0]>(key: keyof R | keyof RP | ((meta: R & RP) => R & RP), value: ((R & RP)[keyof R] & (R & RP)[keyof RP]) | undefined): MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
35
- decorate<R extends T = T, RP = R['params'][0]>(key: keyof R | keyof RP | ((meta: R & RP) => R & RP), value: ((R & RP)[keyof R] & (R & RP)[keyof RP]) | undefined, isArray: boolean | undefined): MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
36
- decorate<R extends T = T, RP = R['params'][0]>(key: keyof R | keyof RP | ((meta: R & RP) => R & RP), value: ((R & RP)[keyof R] & (R & RP)[keyof RP]) | undefined, isArray: boolean | undefined, level: TMergedDecoratorArgs['level']): MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
37
- decorateClass<R extends T = T, RP = R['params'][0]>(cb: ((meta: R & RP, propKey?: string | symbol, index?: number) => R & RP)): MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
38
- decorateClass<R extends T = T, RP = R['params'][0]>(key: keyof R | keyof RP | ((meta: R & RP) => R & RP), value: ((R & RP)[keyof R] & (R & RP)[keyof RP]) | undefined): MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
39
- decorateClass<R extends T = T, RP = R['params'][0]>(key: keyof R | keyof RP | ((meta: R & RP) => R & RP), value: ((R & RP)[keyof R] & (R & RP)[keyof RP]) | undefined, isArray: boolean | undefined): MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
43
+ decorate<TMeta extends TObject = Partial<TClass & TProp & TParam>>(cb: ((meta: TMeta, level: TLevels, propKey?: string | symbol, index?: number) => TMeta)): MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
44
+ decorate<TMeta extends Partial<TClass & TProp & TParam>, TKey extends keyof TMeta>(key: TKey, value: TMeta[TKey]): MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
45
+ decorate<TMeta extends Partial<TClass & TProp & TParam>, TKey extends keyof TMeta, TIsArray extends boolean = false>(key: TKey, value: TIsArray extends true ? ArrayElementType<TMeta[TKey]> : TMeta[TKey], isArray: TIsArray): MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
46
+ decorate<TMeta extends Partial<TClass & TProp & TParam>, TKey extends keyof TMeta, TIsArray extends boolean = false>(key: TKey | ((meta: TMeta, level: TLevels, propKey?: string | symbol, index?: number) => TMeta), value: TIsArray extends true ? ArrayElementType<TMeta[TKey]> : TMeta[TKey], isArray: TIsArray, level: TMergedDecoratorArgs['level']): MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
47
+ decorateConditional(ccb: (level: TLevels) => (MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator) | void | undefined): MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
48
+ decorateClass<TMeta extends TObject = Partial<TClass & TProp & TParam>>(cb: ((meta: TMeta, level: TLevels, propKey?: string | symbol, index?: number) => TMeta)): MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
49
+ decorateClass<TMeta extends TObject = Partial<TClass & TProp & TParam>, TKey extends keyof TMeta = keyof TMeta, TIsArray extends boolean = false>(key: TKey, value: TIsArray extends true ? ArrayElementType<TMeta[TKey]> : TMeta[TKey]): MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
50
+ decorateClass<TMeta extends TObject = Partial<TClass & TProp & TParam>, TKey extends keyof TMeta = keyof TMeta, TIsArray extends boolean = false>(key: TKey, value: TIsArray extends true ? ArrayElementType<TMeta[TKey]> : TMeta[TKey], isArray: boolean | undefined): MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
40
51
  }
52
+ type ArrayElementType<T> = T extends (infer E)[] ? E : never;
53
+ export {};
41
54
  //# sourceMappingURL=mate.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mate.d.ts","sourceRoot":"","sources":["../../src/mate.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,MAAK,SAAS,CAAA;AAMjD,MAAM,WAAW,oBAAoB;IACjC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAA;IAC3B,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACzB,UAAU,CAAC,EAAE,uBAAuB,CAAC,IAAI,CAAC,CAAA;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,OAAO,GAAG,UAAU,CAAA;CA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BAAkB,GAAG,iBAAiB;CAS/E;AAID,KAAK,gBAAgB,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC"}
@@ -1,8 +1,35 @@
1
- import { Mate, TProstoMetadata } from '..';
2
- export declare const mate: Mate<{
3
- inherit?: boolean | undefined;
4
- fromPropertyCb?: string[] | undefined;
5
- } & TProstoMetadata<import("..").TProstoParamsMetadata>>;
1
+ import { Mate } from '..';
2
+ interface TClass {
3
+ inherit?: boolean;
4
+ fromPropertyCb?: string[];
5
+ d1?: string;
6
+ d2?: string;
7
+ d3?: string;
8
+ multi?: string;
9
+ class?: string;
10
+ classArray?: string[];
11
+ fromProperty?: string;
12
+ }
13
+ interface TProp {
14
+ inherit?: boolean;
15
+ fromPropertyCb?: string[];
16
+ prop1D?: string;
17
+ prop2D?: string;
18
+ method?: string;
19
+ methodArray?: string[];
20
+ method2?: string;
21
+ property?: string;
22
+ empty?: string;
23
+ }
24
+ interface TParam {
25
+ inherit?: boolean;
26
+ propS?: string;
27
+ param?: string;
28
+ param1?: string;
29
+ param2?: string;
30
+ paramArray?: string[];
31
+ }
32
+ export declare const mate: Mate<TClass, TProp, TParam>;
6
33
  export declare class MateTestClass {
7
34
  constructor(_a: string);
8
35
  prop1?: string;
@@ -10,11 +37,12 @@ export declare class MateTestClass {
10
37
  test(_b: string): string;
11
38
  viaCB(_c: string): void;
12
39
  param: string;
40
+ empty(): void;
13
41
  }
14
42
  export declare class MateTestClass2 {
15
43
  constructor(a: string);
16
44
  test(arg1: number, arg2: boolean): void;
17
- toOverwriteMeta(): void;
45
+ toOverwriteMeta(arg: string): void;
18
46
  }
19
47
  export declare class MateTestClass3 extends MateTestClass2 {
20
48
  constructor();
@@ -26,4 +54,5 @@ export declare class MateTestClass4 extends MateTestClass2 {
26
54
  test2(): void;
27
55
  toOverwriteMeta(): void;
28
56
  }
57
+ export {};
29
58
  //# sourceMappingURL=mate.artifacts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mate.artifacts.d.ts","sourceRoot":"","sources":["../../../src/tests/mate.artifacts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,IAAI,CAAA;AAE1C,eAAO,MAAM,IAAI;;;wDAUf,CAAA;AAMF,qBAGa,aAAa;gBAKd,EAAE,EAAE,MAAM;IAMlB,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd,KAAK,CAAC,EAAE,MAAM,CAAA;IAKd,IAAI,CAII,EAAE,EAAE,MAAM,GAAG,MAAM;IAgB3B,KAAK,CAMG,EAAE,EAAE,MAAM;IAWlB,KAAK,EAAE,MAAM,CAAK;CACrB;AAED,qBACa,cAAc;gBACX,CAAC,EAAE,MAAM;IAOrB,IAAI,CAGD,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO;IAM9B,eAAe;CAGlB;AAED,qBACa,cAAe,SAAQ,cAAc;;IAM9C,KAAK;IAML,eAAe;CAGlB;AAED,qBACa,cAAe,SAAQ,cAAc;;IAM9C,KAAK;IAKL,eAAe;CAGlB"}
1
+ {"version":3,"file":"mate.artifacts.d.ts","sourceRoot":"","sources":["../../../src/tests/mate.artifacts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAA;AAEzB,UAAU,MAAM;IACZ,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;IACzB,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;IACrB,YAAY,CAAC,EAAE,MAAM,CAAA;CACxB;AAED,UAAU,KAAK;IACX,OAAO,CAAC,EAAE,OAAO,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TS Metadata Organizer",
5
5
  "main": "index.js",
6
6
  "module": "dist/mate.esm-bundler.js",
@@ -46,7 +46,6 @@
46
46
  },
47
47
  "homepage": "https://github.com/prostojs/mate#readme",
48
48
  "devDependencies": {
49
- "reflect-metadata": "^0.1.13",
50
49
  "@microsoft/api-extractor": "^7.30.0",
51
50
  "@prostojs/dye": "^0.3.0",
52
51
  "@rollup/plugin-commonjs": "^21.0.0",
@@ -67,6 +66,7 @@
67
66
  "fs-extra": "^10.0.0",
68
67
  "jest": "^27.2.5",
69
68
  "minimist": "^1.2.6",
69
+ "reflect-metadata": "^0.1.13",
70
70
  "rollup": "^2.58.0",
71
71
  "rollup-plugin-terser": "^7.0.2",
72
72
  "rollup-plugin-typescript2": "^0.30.0",
@@ -1,2 +0,0 @@
1
- export declare const banner: () => string;
2
- //# sourceMappingURL=banner.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"banner.d.ts","sourceRoot":"","sources":["../../../src/utils/banner.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,MAAM,cAAsG,CAAA"}
@@ -1,4 +0,0 @@
1
- export declare function log(text: string): void;
2
- export declare function warn(text: string): void;
3
- export declare function logError(error: string): void;
4
- //# sourceMappingURL=log.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../../src/utils/log.ts"],"names":[],"mappings":"AAGA,wBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,QAE/B;AAED,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,QAEhC;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,QAErC"}
@@ -1,2 +0,0 @@
1
- export declare function panic(error: string): Error;
2
- //# sourceMappingURL=panic.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"panic.d.ts","sourceRoot":"","sources":["../../../src/utils/panic.ts"],"names":[],"mappings":"AAGA,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,SAGlC"}