SB-6.1-PRE
This commit is contained in:
1 parent
690169a409
commit
358a25f522
3760 files changed
+300059
-36
No files matched your search
+58
@@ -0,0 +1,58 @@
|
||||
define(["require", "exports", "../constants/error_msgs", "../constants/metadata_keys"], function (require, exports, ERROR_MSGS, METADATA_KEY) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
function tagParameter(annotationTarget, propertyName, parameterIndex, metadata) {
|
||||
var metadataKey = METADATA_KEY.TAGGED;
|
||||
_tagParameterOrProperty(metadataKey, annotationTarget, propertyName, metadata, parameterIndex);
|
||||
}
|
||||
exports.tagParameter = tagParameter;
|
||||
function tagProperty(annotationTarget, propertyName, metadata) {
|
||||
var metadataKey = METADATA_KEY.TAGGED_PROP;
|
||||
_tagParameterOrProperty(metadataKey, annotationTarget.constructor, propertyName, metadata);
|
||||
}
|
||||
exports.tagProperty = tagProperty;
|
||||
function _tagParameterOrProperty(metadataKey, annotationTarget, propertyName, metadata, parameterIndex) {
|
||||
var paramsOrPropertiesMetadata = {};
|
||||
var isParameterDecorator = (typeof parameterIndex === "number");
|
||||
var key = (parameterIndex !== undefined && isParameterDecorator) ? parameterIndex.toString() : propertyName;
|
||||
if (isParameterDecorator && propertyName !== undefined) {
|
||||
throw new Error(ERROR_MSGS.INVALID_DECORATOR_OPERATION);
|
||||
}
|
||||
if (Reflect.hasOwnMetadata(metadataKey, annotationTarget)) {
|
||||
paramsOrPropertiesMetadata = Reflect.getMetadata(metadataKey, annotationTarget);
|
||||
}
|
||||
var paramOrPropertyMetadata = paramsOrPropertiesMetadata[key];
|
||||
if (!Array.isArray(paramOrPropertyMetadata)) {
|
||||
paramOrPropertyMetadata = [];
|
||||
}
|
||||
else {
|
||||
for (var _i = 0, paramOrPropertyMetadata_1 = paramOrPropertyMetadata; _i < paramOrPropertyMetadata_1.length; _i++) {
|
||||
var m = paramOrPropertyMetadata_1[_i];
|
||||
if (m.key === metadata.key) {
|
||||
throw new Error(ERROR_MSGS.DUPLICATED_METADATA + " " + m.key.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
paramOrPropertyMetadata.push(metadata);
|
||||
paramsOrPropertiesMetadata[key] = paramOrPropertyMetadata;
|
||||
Reflect.defineMetadata(metadataKey, paramsOrPropertiesMetadata, annotationTarget);
|
||||
}
|
||||
function _decorate(decorators, target) {
|
||||
Reflect.decorate(decorators, target);
|
||||
}
|
||||
function _param(paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); };
|
||||
}
|
||||
function decorate(decorator, target, parameterIndex) {
|
||||
if (typeof parameterIndex === "number") {
|
||||
_decorate([_param(parameterIndex, decorator)], target);
|
||||
}
|
||||
else if (typeof parameterIndex === "string") {
|
||||
Reflect.decorate([decorator], target, parameterIndex);
|
||||
}
|
||||
else {
|
||||
_decorate([decorator], target);
|
||||
}
|
||||
}
|
||||
exports.decorate = decorate;
|
||||
});
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
define(["require", "exports", "../constants/error_msgs", "../constants/metadata_keys", "../planning/metadata", "./decorator_utils"], function (require, exports, error_msgs_1, METADATA_KEY, metadata_1, decorator_utils_1) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var LazyServiceIdentifer = (function () {
|
||||
function LazyServiceIdentifer(cb) {
|
||||
this._cb = cb;
|
||||
}
|
||||
LazyServiceIdentifer.prototype.unwrap = function () {
|
||||
return this._cb();
|
||||
};
|
||||
return LazyServiceIdentifer;
|
||||
}());
|
||||
exports.LazyServiceIdentifer = LazyServiceIdentifer;
|
||||
function inject(serviceIdentifier) {
|
||||
return function (target, targetKey, index) {
|
||||
if (serviceIdentifier === undefined) {
|
||||
throw new Error(error_msgs_1.UNDEFINED_INJECT_ANNOTATION(target.name));
|
||||
}
|
||||
var metadata = new metadata_1.Metadata(METADATA_KEY.INJECT_TAG, serviceIdentifier);
|
||||
if (typeof index === "number") {
|
||||
decorator_utils_1.tagParameter(target, targetKey, index, metadata);
|
||||
}
|
||||
else {
|
||||
decorator_utils_1.tagProperty(target, targetKey, metadata);
|
||||
}
|
||||
};
|
||||
}
|
||||
exports.inject = inject;
|
||||
});
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
define(["require", "exports", "../constants/error_msgs", "../constants/metadata_keys"], function (require, exports, ERRORS_MSGS, METADATA_KEY) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
function injectable() {
|
||||
return function (target) {
|
||||
if (Reflect.hasOwnMetadata(METADATA_KEY.PARAM_TYPES, target)) {
|
||||
throw new Error(ERRORS_MSGS.DUPLICATED_INJECTABLE_DECORATOR);
|
||||
}
|
||||
var types = Reflect.getMetadata(METADATA_KEY.DESIGN_PARAM_TYPES, target) || [];
|
||||
Reflect.defineMetadata(METADATA_KEY.PARAM_TYPES, types, target);
|
||||
return target;
|
||||
};
|
||||
}
|
||||
exports.injectable = injectable;
|
||||
});
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
define(["require", "exports", "../constants/metadata_keys", "../planning/metadata", "./decorator_utils"], function (require, exports, METADATA_KEY, metadata_1, decorator_utils_1) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
function multiInject(serviceIdentifier) {
|
||||
return function (target, targetKey, index) {
|
||||
var metadata = new metadata_1.Metadata(METADATA_KEY.MULTI_INJECT_TAG, serviceIdentifier);
|
||||
if (typeof index === "number") {
|
||||
decorator_utils_1.tagParameter(target, targetKey, index, metadata);
|
||||
}
|
||||
else {
|
||||
decorator_utils_1.tagProperty(target, targetKey, metadata);
|
||||
}
|
||||
};
|
||||
}
|
||||
exports.multiInject = multiInject;
|
||||
});
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
define(["require", "exports", "../constants/metadata_keys", "../planning/metadata", "./decorator_utils"], function (require, exports, METADATA_KEY, metadata_1, decorator_utils_1) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
function named(name) {
|
||||
return function (target, targetKey, index) {
|
||||
var metadata = new metadata_1.Metadata(METADATA_KEY.NAMED_TAG, name);
|
||||
if (typeof index === "number") {
|
||||
decorator_utils_1.tagParameter(target, targetKey, index, metadata);
|
||||
}
|
||||
else {
|
||||
decorator_utils_1.tagProperty(target, targetKey, metadata);
|
||||
}
|
||||
};
|
||||
}
|
||||
exports.named = named;
|
||||
});
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
define(["require", "exports", "../constants/metadata_keys", "../planning/metadata", "./decorator_utils"], function (require, exports, METADATA_KEY, metadata_1, decorator_utils_1) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
function optional() {
|
||||
return function (target, targetKey, index) {
|
||||
var metadata = new metadata_1.Metadata(METADATA_KEY.OPTIONAL_TAG, true);
|
||||
if (typeof index === "number") {
|
||||
decorator_utils_1.tagParameter(target, targetKey, index, metadata);
|
||||
}
|
||||
else {
|
||||
decorator_utils_1.tagProperty(target, targetKey, metadata);
|
||||
}
|
||||
};
|
||||
}
|
||||
exports.optional = optional;
|
||||
});
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
define(["require", "exports", "../constants/error_msgs", "../constants/metadata_keys", "../planning/metadata"], function (require, exports, ERRORS_MSGS, METADATA_KEY, metadata_1) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
function postConstruct() {
|
||||
return function (target, propertyKey, descriptor) {
|
||||
var metadata = new metadata_1.Metadata(METADATA_KEY.POST_CONSTRUCT, propertyKey);
|
||||
if (Reflect.hasOwnMetadata(METADATA_KEY.POST_CONSTRUCT, target.constructor)) {
|
||||
throw new Error(ERRORS_MSGS.MULTIPLE_POST_CONSTRUCT_METHODS);
|
||||
}
|
||||
Reflect.defineMetadata(METADATA_KEY.POST_CONSTRUCT, metadata, target.constructor);
|
||||
};
|
||||
}
|
||||
exports.postConstruct = postConstruct;
|
||||
});
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
define(["require", "exports", "../planning/metadata", "./decorator_utils"], function (require, exports, metadata_1, decorator_utils_1) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
function tagged(metadataKey, metadataValue) {
|
||||
return function (target, targetKey, index) {
|
||||
var metadata = new metadata_1.Metadata(metadataKey, metadataValue);
|
||||
if (typeof index === "number") {
|
||||
decorator_utils_1.tagParameter(target, targetKey, index, metadata);
|
||||
}
|
||||
else {
|
||||
decorator_utils_1.tagProperty(target, targetKey, metadata);
|
||||
}
|
||||
};
|
||||
}
|
||||
exports.tagged = tagged;
|
||||
});
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
define(["require", "exports", "../constants/metadata_keys", "../planning/metadata", "./decorator_utils"], function (require, exports, METADATA_KEY, metadata_1, decorator_utils_1) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
function targetName(name) {
|
||||
return function (target, targetKey, index) {
|
||||
var metadata = new metadata_1.Metadata(METADATA_KEY.NAME_TAG, name);
|
||||
decorator_utils_1.tagParameter(target, targetKey, index, metadata);
|
||||
};
|
||||
}
|
||||
exports.targetName = targetName;
|
||||
});
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
define(["require", "exports", "../constants/metadata_keys", "../planning/metadata", "./decorator_utils"], function (require, exports, METADATA_KEY, metadata_1, decorator_utils_1) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
function unmanaged() {
|
||||
return function (target, targetKey, index) {
|
||||
var metadata = new metadata_1.Metadata(METADATA_KEY.UNMANAGED_TAG, true);
|
||||
decorator_utils_1.tagParameter(target, targetKey, index, metadata);
|
||||
};
|
||||
}
|
||||
exports.unmanaged = unmanaged;
|
||||
});
|
||||
Reference in new issue
Block a user