@typeix/metadata 8.6.1-rc.1 → 8.8.0-rc.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 (2) hide show
  1. package/dist/metadata.js +30 -30
  2. package/package.json +4 -4
package/dist/metadata.js CHANGED
@@ -1,6 +1,35 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createMethodDecorator = exports.createParameterAndPropertyDecorator = exports.createParameterDecorator = exports.createPropertyDecorator = exports.createClassDecorator = exports.getAllMetadataForTarget = exports.getAllMetadataKeysForTarget = exports.getAllKeysForTarget = exports.getMetadataForTarget = exports.getMetadataKeysForTarget = exports.getParameterMetadata = exports.getMethodMetadata = exports.getPropertyMetadata = exports.getClassMetadata = exports.hasDecorator = exports.validateDecorator = exports.getDecoratorName = exports.getDecoratorType = exports.getDecoratorUUID = exports.getDecoratorId = exports.isDecorator = exports.deleteMetadata = exports.getOwnMetadataKeys = exports.getMetadataKeys = exports.getOwnMetadata = exports.getMetadata = exports.hasOwnMetadata = exports.hasMetadata = exports.defineMetadata = exports.TS_RETURN = exports.TS_TYPE = exports.TS_PARAMS = void 0;
3
+ exports.TS_RETURN = exports.TS_TYPE = exports.TS_PARAMS = void 0;
4
+ exports.defineMetadata = defineMetadata;
5
+ exports.hasMetadata = hasMetadata;
6
+ exports.hasOwnMetadata = hasOwnMetadata;
7
+ exports.getMetadata = getMetadata;
8
+ exports.getOwnMetadata = getOwnMetadata;
9
+ exports.getMetadataKeys = getMetadataKeys;
10
+ exports.getOwnMetadataKeys = getOwnMetadataKeys;
11
+ exports.deleteMetadata = deleteMetadata;
12
+ exports.isDecorator = isDecorator;
13
+ exports.getDecoratorId = getDecoratorId;
14
+ exports.getDecoratorUUID = getDecoratorUUID;
15
+ exports.getDecoratorType = getDecoratorType;
16
+ exports.getDecoratorName = getDecoratorName;
17
+ exports.validateDecorator = validateDecorator;
18
+ exports.hasDecorator = hasDecorator;
19
+ exports.getClassMetadata = getClassMetadata;
20
+ exports.getPropertyMetadata = getPropertyMetadata;
21
+ exports.getMethodMetadata = getMethodMetadata;
22
+ exports.getParameterMetadata = getParameterMetadata;
23
+ exports.getMetadataKeysForTarget = getMetadataKeysForTarget;
24
+ exports.getMetadataForTarget = getMetadataForTarget;
25
+ exports.getAllKeysForTarget = getAllKeysForTarget;
26
+ exports.getAllMetadataKeysForTarget = getAllMetadataKeysForTarget;
27
+ exports.getAllMetadataForTarget = getAllMetadataForTarget;
28
+ exports.createClassDecorator = createClassDecorator;
29
+ exports.createPropertyDecorator = createPropertyDecorator;
30
+ exports.createParameterDecorator = createParameterDecorator;
31
+ exports.createParameterAndPropertyDecorator = createParameterAndPropertyDecorator;
32
+ exports.createMethodDecorator = createMethodDecorator;
4
33
  const utils_1 = require("@typeix/utils");
5
34
  require("reflect-metadata");
6
35
  const TX_PREFIX = "@typeix";
@@ -17,7 +46,6 @@ function defineMetadata(metadataKey, metadataValue, target, targetKey) {
17
46
  }
18
47
  Reflect.defineMetadata(metadataKey, metadataValue, target, targetKey);
19
48
  }
20
- exports.defineMetadata = defineMetadata;
21
49
  function hasMetadata(metadataKey, target, targetKey) {
22
50
  try {
23
51
  return Reflect.hasMetadata(metadataKey, target, targetKey);
@@ -26,7 +54,6 @@ function hasMetadata(metadataKey, target, targetKey) {
26
54
  return false;
27
55
  }
28
56
  }
29
- exports.hasMetadata = hasMetadata;
30
57
  function hasOwnMetadata(metadataKey, target, targetKey) {
31
58
  try {
32
59
  return Reflect.hasOwnMetadata(metadataKey, target, targetKey);
@@ -35,23 +62,18 @@ function hasOwnMetadata(metadataKey, target, targetKey) {
35
62
  return false;
36
63
  }
37
64
  }
38
- exports.hasOwnMetadata = hasOwnMetadata;
39
65
  function getMetadata(metadataKey, target, targetKey) {
40
66
  return Reflect.getMetadata(metadataKey, target, targetKey);
41
67
  }
42
- exports.getMetadata = getMetadata;
43
68
  function getOwnMetadata(metadataKey, target, targetKey) {
44
69
  return Reflect.getOwnMetadata(metadataKey, target, targetKey);
45
70
  }
46
- exports.getOwnMetadata = getOwnMetadata;
47
71
  function getMetadataKeys(target, targetKey) {
48
72
  return Reflect.getMetadataKeys(target, targetKey);
49
73
  }
50
- exports.getMetadataKeys = getMetadataKeys;
51
74
  function getOwnMetadataKeys(target, targetKey) {
52
75
  return Reflect.getOwnMetadataKeys(target, targetKey);
53
76
  }
54
- exports.getOwnMetadataKeys = getOwnMetadataKeys;
55
77
  function deleteMetadata(metadataKey, target, targetKey) {
56
78
  if ((0, utils_1.inArray)([exports.TS_TYPE, exports.TS_PARAMS, exports.TS_RETURN], metadataKey)) {
57
79
  throw new Error(`You can't delete typescript metadata: ${exports.TS_TYPE}, ${exports.TS_PARAMS}, ${exports.TS_RETURN}`);
@@ -63,39 +85,33 @@ function deleteMetadata(metadataKey, target, targetKey) {
63
85
  return false;
64
86
  }
65
87
  }
66
- exports.deleteMetadata = deleteMetadata;
67
88
  function isDecorator(decorator) {
68
89
  return (0, utils_1.isTruthy)(decorator[TX_ID]);
69
90
  }
70
- exports.isDecorator = isDecorator;
71
91
  function getDecoratorId(decorator, index) {
72
92
  if ((0, utils_1.isFalsy)(decorator[TX_ID])) {
73
93
  throw new TypeError(`Decorator must be created via @typeix decorator functions: ${decorator.toString()}`);
74
94
  }
75
95
  return decorator[TX_ID] + ((0, utils_1.isNumber)(index) ? `:${index}` : "");
76
96
  }
77
- exports.getDecoratorId = getDecoratorId;
78
97
  function getDecoratorUUID(decorator) {
79
98
  if ((0, utils_1.isFalsy)(decorator[TX_UUID])) {
80
99
  throw new TypeError(`Decorator must be created via @typeix decorator functions: ${decorator.toString()}`);
81
100
  }
82
101
  return decorator[TX_UUID];
83
102
  }
84
- exports.getDecoratorUUID = getDecoratorUUID;
85
103
  function getDecoratorType(decorator) {
86
104
  if ((0, utils_1.isFalsy)(decorator[TX_TYPE])) {
87
105
  throw new TypeError(`Decorator must be created via @typeix decorator functions: ${decorator.toString()}`);
88
106
  }
89
107
  return decorator[TX_TYPE];
90
108
  }
91
- exports.getDecoratorType = getDecoratorType;
92
109
  function getDecoratorName(decorator) {
93
110
  if ((0, utils_1.isFalsy)(decorator[TX_NAME])) {
94
111
  throw new TypeError(`Decorator must be created via @typeix decorator functions: ${decorator.toString()}`);
95
112
  }
96
113
  return decorator[TX_NAME];
97
114
  }
98
- exports.getDecoratorName = getDecoratorName;
99
115
  function validateDecorator(decorator, name) {
100
116
  let type = getDecoratorType(decorator);
101
117
  if (type !== name) {
@@ -111,31 +127,25 @@ function validateDecorator(decorator, name) {
111
127
  }
112
128
  }
113
129
  }
114
- exports.validateDecorator = validateDecorator;
115
130
  function hasDecorator(decorator, target, targetKey, index) {
116
131
  return isDecorator(decorator) ? hasMetadata(getDecoratorId(decorator, index), target, targetKey) : false;
117
132
  }
118
- exports.hasDecorator = hasDecorator;
119
133
  function getClassMetadata(decorator, target) {
120
134
  validateDecorator(decorator, "constructor");
121
135
  return getMetadata(getDecoratorId(decorator), target);
122
136
  }
123
- exports.getClassMetadata = getClassMetadata;
124
137
  function getPropertyMetadata(decorator, target, targetKey) {
125
138
  validateDecorator(decorator, "property");
126
139
  return getMetadata(getDecoratorId(decorator), target.prototype, targetKey);
127
140
  }
128
- exports.getPropertyMetadata = getPropertyMetadata;
129
141
  function getMethodMetadata(decorator, target, targetKey, isStatic = false) {
130
142
  validateDecorator(decorator, "method");
131
143
  return getMetadata(getDecoratorId(decorator), !!isStatic ? target : target.prototype, targetKey);
132
144
  }
133
- exports.getMethodMetadata = getMethodMetadata;
134
145
  function getParameterMetadata(decorator, target, index, targetKey) {
135
146
  validateDecorator(decorator, "parameter");
136
147
  return getMetadata(getDecoratorId(decorator, index), target.prototype, targetKey);
137
148
  }
138
- exports.getParameterMetadata = getParameterMetadata;
139
149
  function mapKeyToMetadata(key) {
140
150
  let metadata = getMetadata(key.metadataKey, key.target, key.propertyKey);
141
151
  if (key.metadataKey.includes(TX_PREFIX)) {
@@ -161,7 +171,6 @@ function getMetadataKeysForTarget(target, targetKey) {
161
171
  };
162
172
  });
163
173
  }
164
- exports.getMetadataKeysForTarget = getMetadataKeysForTarget;
165
174
  function getMetadataForTarget(target, targetKey) {
166
175
  let keys = getMetadataKeysForTarget(target, targetKey), proto = Object.getPrototypeOf(target);
167
176
  if (!(0, utils_1.isNull)(proto)) {
@@ -169,7 +178,6 @@ function getMetadataForTarget(target, targetKey) {
169
178
  }
170
179
  return (0, utils_1.flatten)(keys.map(item => mapKeyToMetadata(item)));
171
180
  }
172
- exports.getMetadataForTarget = getMetadataForTarget;
173
181
  function getAllKeysForTarget(target) {
174
182
  let keys = (0, utils_1.isObject)(target.prototype) ? [{ target: target, key: undefined }] : [], _target = (0, utils_1.isObject)(target.prototype) ? target.prototype : target;
175
183
  return keys.concat(Reflect
@@ -182,7 +190,6 @@ function getAllKeysForTarget(target) {
182
190
  };
183
191
  }));
184
192
  }
185
- exports.getAllKeysForTarget = getAllKeysForTarget;
186
193
  function getAllMetadataKeysForTarget(target) {
187
194
  let keys = getAllKeysForTarget(target), metadata = [], proto = Object.getPrototypeOf(target);
188
195
  keys.forEach(item => metadata = metadata.concat(getMetadataKeysForTarget(item.target, item.key)));
@@ -191,11 +198,9 @@ function getAllMetadataKeysForTarget(target) {
191
198
  }
192
199
  return metadata;
193
200
  }
194
- exports.getAllMetadataKeysForTarget = getAllMetadataKeysForTarget;
195
201
  function getAllMetadataForTarget(target) {
196
202
  return (0, utils_1.flatten)(getAllMetadataKeysForTarget(target).map(item => mapKeyToMetadata(item)));
197
203
  }
198
- exports.getAllMetadataForTarget = getAllMetadataForTarget;
199
204
  function getType(target, parameterOrDescriptor, propertyKey, type) {
200
205
  type = type === "mixed" ? (0, utils_1.isNumber)(parameterOrDescriptor) ? "parameter" : "property" : type;
201
206
  if ((0, utils_1.inArray)(["property", "parameter"], type) && (0, utils_1.isFunction)(target) && (0, utils_1.isDefined)(propertyKey)) {
@@ -257,21 +262,16 @@ function decorate(decorator, type, args) {
257
262
  function createClassDecorator(decorator, args) {
258
263
  return decorate(decorator, "constructor", args);
259
264
  }
260
- exports.createClassDecorator = createClassDecorator;
261
265
  function createPropertyDecorator(decorator, args) {
262
266
  return decorate(decorator, "property", args);
263
267
  }
264
- exports.createPropertyDecorator = createPropertyDecorator;
265
268
  function createParameterDecorator(decorator, args) {
266
269
  return decorate(decorator, "parameter", args);
267
270
  }
268
- exports.createParameterDecorator = createParameterDecorator;
269
271
  function createParameterAndPropertyDecorator(decorator, args) {
270
272
  return decorate(decorator, "mixed", args);
271
273
  }
272
- exports.createParameterAndPropertyDecorator = createParameterAndPropertyDecorator;
273
274
  function createMethodDecorator(decorator, args) {
274
275
  return decorate(decorator, "method", args);
275
276
  }
276
- exports.createMethodDecorator = createMethodDecorator;
277
277
  //# sourceMappingURL=metadata.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typeix/metadata",
3
- "version": "8.6.1-rc.1",
3
+ "version": "8.8.0-rc.1",
4
4
  "description": "@typeix metadata apis::::",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -29,8 +29,8 @@
29
29
  },
30
30
  "homepage": "https://typeix.com",
31
31
  "dependencies": {
32
- "@typeix/utils": "^8.6.1-rc.1",
33
- "reflect-metadata": "^0.2.2"
32
+ "@typeix/utils": "^8.8.0-rc.1",
33
+ "reflect-metadata": "~0.2.2"
34
34
  },
35
35
  "publishConfig": {
36
36
  "access": "public"
@@ -38,5 +38,5 @@
38
38
  "engines": {
39
39
  "node": ">=18.0.0"
40
40
  },
41
- "gitHead": "897a0c636017be6843502feae7a3a8ad1951ce21"
41
+ "gitHead": "8d95e8382394eeb45075731f936f44cd1766047c"
42
42
  }