New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

koatty_container

Package Overview
Dependencies
Maintainers
1
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koatty_container - npm Package Compare versions

Comparing version 1.6.2 to 1.6.6

4

CHANGELOG.md

@@ -5,2 +5,6 @@ # Changelog

### [1.6.6](https://github.com/koatty/koatty_container/compare/v1.6.2...v1.6.6) (2021-11-23)
### [1.6.4](https://github.com/koatty/koatty_container/compare/v1.6.2...v1.6.4) (2021-11-23)
### [1.6.2](https://github.com/koatty/koatty_container/compare/v1.6.0...v1.6.2) (2021-11-20)

@@ -7,0 +11,0 @@

4

dist/AOP.d.ts

@@ -10,3 +10,5 @@ import { Container } from "./Container";

"Before" = "Before",
"After" = "After"
"BeforeEach" = "BeforeEach",
"After" = "After",
"AfterEach" = "AfterEach"
}

@@ -13,0 +15,0 @@ /**

@@ -12,3 +12,3 @@ "use strict";

const helper = (0, tslib_1.__importStar)(require("koatty_lib"));
const koatty_logger_1 = require("koatty_logger");
// import { DefaultLogger as logger } from "koatty_logger";
const Container_1 = require("./Container");

@@ -26,3 +26,5 @@ const IContainer_1 = require("./IContainer");

AOPType["Before"] = "Before";
AOPType["BeforeEach"] = "BeforeEach";
AOPType["After"] = "After";
AOPType["AfterEach"] = "AfterEach";
})(AOPType = exports.AOPType || (exports.AOPType = {}));

@@ -84,3 +86,3 @@ /**

Container_1.IOCContainer.saveClassMetadata(IContainer_1.TAGGED_CLS, IContainer_1.TAGGED_AOP, {
type: AOPType.Before,
type: AOPType.BeforeEach,
name: aopName

@@ -129,3 +131,3 @@ }, target);

Container_1.IOCContainer.saveClassMetadata(IContainer_1.TAGGED_CLS, IContainer_1.TAGGED_AOP, {
type: AOPType.After,
type: AOPType.AfterEach,
name: aopName

@@ -145,7 +147,7 @@ }, target);

// tslint:disable-next-line: one-variable-per-declaration
let aspect, name = "";
let aspect; //, name = "";
if (helper.isClass(aopName)) {
// tslint:disable-next-line: no-invalid-this
aspect = Container_1.IOCContainer.getInsByClass(aopName);
name = Container_1.IOCContainer.getIdentifier(aopName) || aopName.name || "";
// name = IOCContainer.getIdentifier(<Function>aopName) || (<Function>aopName).name || "";
}

@@ -155,6 +157,6 @@ else {

aspect = Container_1.IOCContainer.get(aopName, "COMPONENT");
name = aopName;
// name = <string>aopName;
}
if (aspect && helper.isFunction(aspect.run)) {
koatty_logger_1.DefaultLogger.Info(`Execute the aspect ${name}`);
// logger.Info(`Execute the aspect ${name}`);
// tslint:disable-next-line: no-invalid-this

@@ -175,6 +177,7 @@ await aspect.run(props);

// If the class has defined the default AOP method, @BeforeEach and @AfterEach will not take effect
const flag = hasDefaultAOP(target);
if (flag) {
const allMethods = (0, Util_1.getMethodNames)(target);
const methods = allMethods.filter((m) => !["constructor", "init", "__before", "__after"].includes(m));
if (allMethods.includes("__before") || allMethods.includes("__after")) {
// inject default AOP method
injectDefaultAOP(target, instance, container);
injectDefaultAOP(target, instance, methods);
}

@@ -185,6 +188,5 @@ else {

const { type, name } = classMetaData;
if (type && name) {
const methods = (0, Util_1.getMethodNames)(target, true).filter((m) => !["constructor", "init", "__before", "__after"].includes(m));
if (name && [AOPType.BeforeEach, AOPType.AfterEach].includes(type)) {
methods.forEach((element) => {
koatty_logger_1.DefaultLogger.Debug(`Register inject AOP ${target.name} method: ${element} => ${type}`);
// logger.Debug(`Register inject AOP ${target.name} method: ${element} => ${type}`);
defineAOPProperty(target, element, name, type);

@@ -197,17 +199,19 @@ });

exports.injectAOP = injectAOP;
// /**
// * Determine whether the class contains the default AOP method
// *
// * @param {*} target
// * @returns {*} {boolean}
// */
// function hasDefaultAOP(target: any): boolean {
// const allMethods = getMethodNames(target).filter((m: string) =>
// !["constructor", "init"].includes(m)
// );
// // class contains the default AOP method
// if (allMethods.includes("__before") || allMethods.includes("__after")) {
// return true;
// }
// return false;
// }
/**
* Determine whether the class contains the default AOP method
*
* @param {*} target
* @returns {*} {boolean}
*/
function hasDefaultAOP(target) {
const allMethods = (0, Util_1.getMethodNames)(target).filter((m) => !["constructor", "init"].includes(m));
// class contains the default AOP method
if (allMethods.includes("__before") || allMethods.includes("__after")) {
return true;
}
return false;
}
/**
* inject default AOP

@@ -218,17 +222,19 @@ *

* @param {*} instance
* @param {Container} container
* @param {string[]} methods
* @returns {*}
*/
function injectDefaultAOP(target, instance, container) {
function injectDefaultAOP(target, instance, methods) {
// class methods
const methods = (0, Util_1.getMethodNames)(target, true).filter((m) => !["constructor", "init", "__before", "__after"].includes(m));
koatty_logger_1.DefaultLogger.Warn(`The ${target.name} class has a default AOP method, @BeforeEach and @AfterEach maybe not take effect`);
// const methods = getMethodNames(target, true).filter((m: string) =>
// !["constructor", "init", "__before", "__after"].includes(m)
// );
// logger.Warn(`The ${target.name} class has a default AOP method, @BeforeEach and @AfterEach maybe not take effect`);
methods.forEach((element) => {
if (helper.isFunction(instance.__before)) {
koatty_logger_1.DefaultLogger.Debug(`Register inject default AOP ${target.name} method: ${element} => __before`);
defineAOPProperty(target, element, "__before", AOPType.Before);
// logger.Debug(`Register inject default AOP ${target.name} method: ${element} => __before`);
defineAOPProperty(target, element, "__before", AOPType.BeforeEach);
}
if (helper.isFunction(instance.__after)) {
koatty_logger_1.DefaultLogger.Debug(`Register inject default AOP ${target.name} method: ${element} => __after`);
defineAOPProperty(target, element, "__after", AOPType.After);
// logger.Debug(`Register inject default AOP ${target.name} method: ${element} => __after`);
defineAOPProperty(target, element, "__after", AOPType.AfterEach);
}

@@ -252,6 +258,6 @@ });

async value(...props) {
if (type === AOPType.Before) {
if (type === AOPType.BeforeEach) {
if (aopName) {
if (aopName === "__before") {
koatty_logger_1.DefaultLogger.Info(`Execute the aspect ${classes.name}.__before`);
// logger.Info(`Execute the aspect ${classes.name}.__before`);
// tslint:disable-next-line: no-invalid-this

@@ -267,3 +273,3 @@ await Reflect.apply(this.__before, this, props);

}
else {
else if (type === AOPType.AfterEach) {
// tslint:disable-next-line: no-invalid-this

@@ -273,3 +279,3 @@ const res = await Reflect.apply(oldMethod, this, props);

if (aopName === "__after") {
koatty_logger_1.DefaultLogger.Info(`Execute the aspect ${classes.name}.__after`);
// logger.Info(`Execute the aspect ${classes.name}.__after`);
// tslint:disable-next-line: no-invalid-this

@@ -276,0 +282,0 @@ await Reflect.apply(this.__after, this, props);

@@ -15,3 +15,3 @@ "use strict";

const Container_1 = require("./Container");
const koatty_logger_1 = require("koatty_logger");
// import { DefaultLogger as logger } from "koatty_logger";
const IContainer_1 = require("./IContainer");

@@ -109,3 +109,3 @@ const Util_1 = require("./Util");

if (dep) {
koatty_logger_1.DefaultLogger.Debug(`Register inject ${target.name} properties key: ${metaKey} => value: ${JSON.stringify(metaData[metaKey])}`);
// logger.Debug(`Register inject ${target.name} properties key: ${metaKey} => value: ${JSON.stringify(metaData[metaKey])}`);
Reflect.defineProperty(instance, metaKey, {

@@ -126,6 +126,8 @@ enumerable: true,

// tslint:disable-next-line: no-unused-expression
app && app.once("appStart", () => {
// lazy inject autowired
injectAutowired(target, instance, container, true);
});
if (app && app.once) {
app.once("appStart", () => {
// lazy inject autowired
injectAutowired(target, instance, container, true);
});
}
}

@@ -132,0 +134,0 @@ }

@@ -10,3 +10,3 @@ import { Container } from "./Container";

*/
export declare function Value(key: string, type?: string): PropertyDecorator;
export declare function Value(key?: string, type?: string): PropertyDecorator;
/**

@@ -13,0 +13,0 @@ * Indicates that an decorated configuration as a property.

@@ -8,7 +8,7 @@ "use strict";

* @LastEditors: Please set LastEditors
* @LastEditTime: 2021-07-07 18:04:11
* @LastEditTime: 2021-11-23 10:53:10
* @License: BSD (3-Clause)
* @Copyright (c) - <richenlin(at)gmail.com>
*/
const koatty_logger_1 = require("koatty_logger");
// import { DefaultLogger as logger } from "koatty_logger";
const Container_1 = require("./Container");

@@ -69,3 +69,3 @@ const IContainer_1 = require("./IContainer");

for (const metaKey in metaData) {
koatty_logger_1.DefaultLogger.Debug(`Register inject ${Container_1.IOCContainer.getIdentifier(target)} config key: ${metaKey} => value: ${metaData[metaKey]}`);
// logger.Debug(`Register inject ${IOCContainer.getIdentifier(target)} config key: ${metaKey} => value: ${metaData[metaKey]}`);
const propKeys = metaData[metaKey].split("|");

@@ -72,0 +72,0 @@ const [propKey, type] = propKeys;

{
"name": "koatty_container",
"version": "1.6.2",
"version": "1.6.6",
"description": "IOC Container for Koatty.",

@@ -69,3 +69,2 @@ "scripts": {

"koatty_lib": "^1.x.x",
"koatty_logger": "^1.x.x",
"reflect-metadata": "^0.1.13",

@@ -72,0 +71,0 @@ "tslib": "^2.3.1"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc