{"id":11300,"library":"metal-aop","title":"Metal.js AOP Utility","description":"metal-aop is a utility package that provides Aspect-Oriented Programming (AOP) capabilities specifically for applications built with the Metal.js framework. AOP allows developers to modularize cross-cutting concerns such as logging, security, and transaction management, by defining advice (code to be executed) and applying it at specific join points (execution points) in the application's flow. The package's latest stable version is 3.0.0, released approximately eight years ago. However, the underlying Metal.js framework has been officially deprecated by Liferay, its primary maintainer, with no active staffing for open-source support and no future plans to use the framework. Consequently, metal-aop is effectively an abandoned project, meaning it receives no new features, bug fixes, or security patches. Its differentiators were primarily its tight integration with Metal.js's component model, which is no longer actively developed.","status":"abandoned","version":"3.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/metal/metal-plugins/tree/master/packages/metal-aop","tags":["javascript","metal"],"install":[{"cmd":"npm install metal-aop","lang":"bash","label":"npm"},{"cmd":"yarn add metal-aop","lang":"bash","label":"yarn"},{"cmd":"pnpm add metal-aop","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"This package is a utility for the Metal.js framework and requires the core 'metal' package or its related components to function, as it extends or interacts with Metal.js's architecture for AOP.","package":"metal","optional":false}],"imports":[{"note":"Given the package's age (last published ~8 years ago) and Node.js engine requirement (>=0.12.0), CommonJS `require` is the primary and most compatible import mechanism. ESM `import` syntax is unlikely to be supported without a transpiler or later version.","wrong":"import { Aop } from 'metal-aop';","symbol":"Aop","correct":"const Aop = require('metal-aop');"},{"note":"If specific AOP constructs like an 'Aspect' factory or class were exposed, they would likely be named exports via CommonJS `require` destructuring, consistent with the package's publication era.","wrong":"import Aspect from 'metal-aop';","symbol":"Aspect","correct":"const { Aspect } = require('metal-aop');"},{"note":"Specific advice types (like 'before', 'after', 'around') might have been exposed as individual functions or part of a main 'Aop' object. Direct import from internal paths (`src/aop`) would be a common CJS pattern for older libraries exposing smaller utilities.","wrong":"import { before } from 'metal-aop';","symbol":"before","correct":"const { before } = require('metal-aop/src/aop'); // Example for a specific advice type"}],"quickstart":{"code":"const Aop = require('metal-aop');\n\nclass MyService {\n  doSomething(data) {\n    console.log(`Processing data: ${data}`);\n    return `Result for ${data}`;\n  }\n\n  anotherMethod() {\n    console.log('Another method called.');\n  }\n}\n\nconst myServiceInstance = new MyService();\n\n// Define a 'before' advice\nAop.before(myServiceInstance, 'doSomething', function(originalArgs) {\n  console.log(`[AOP-Before] Preparing to call doSomething with: ${originalArgs[0]}`);\n});\n\n// Define an 'after' advice\nAop.after(myServiceInstance, 'doSomething', function(originalArgs, result) {\n  console.log(`[AOP-After] doSomething finished. Original args: ${originalArgs[0]}, Result: ${result}`);\n});\n\n// Define an 'around' advice\nAop.around(myServiceInstance, 'anotherMethod', function(originalFn) {\n  console.log('[AOP-Around] Before calling anotherMethod');\n  const result = originalFn(); // Call the original method\n  console.log('[AOP-Around] After calling anotherMethod');\n  return result;\n});\n\nconsole.log('--- Calling doSomething ---');\nmyServiceInstance.doSomething('input123');\n\nconsole.log('\\n--- Calling anotherMethod ---');\nmyServiceInstance.anotherMethod();","lang":"javascript","description":"This quickstart demonstrates how to apply 'before', 'after', and 'around' advice to methods of a class using metal-aop, illustrating basic Aspect-Oriented Programming (AOP) concepts like interception."},"warnings":[{"fix":"Migrate to a actively maintained AOP solution or a different framework. If continued use is unavoidable, significant testing and custom patching may be required.","message":"The Metal.js framework, which metal-aop is built upon, has been officially deprecated. This means metal-aop is effectively abandoned and will not receive updates, bug fixes, or security patches. Running this library in modern environments without careful consideration may lead to compatibility issues or unpatched vulnerabilities.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Use a CommonJS environment or a transpilation step that targets older JavaScript versions. Avoid using with module bundlers that heavily rely on ESM unless configured for CJS compatibility.","message":"Compatibility with modern JavaScript (ESM, async/await, newer Node.js versions) is not guaranteed due to the library's age and abandoned status. Its design predates many modern language features and module systems.","severity":"gotcha","affected_versions":">=3.0.0"},{"fix":"For new projects or integrations, choose AOP solutions that are actively maintained and compatible with your current technology stack.","message":"Integrating `metal-aop` with other modern frontend libraries or frameworks (e.g., React, Vue, Angular) is highly discouraged. It was designed for the Metal.js ecosystem and may cause unexpected conflicts or performance issues outside of it.","severity":"gotcha","affected_versions":">=3.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Ensure `const Aop = require('metal-aop');` is at the top of your file and that `metal-aop` is correctly installed. Verify the AOP object provides a `before` method as expected.","cause":"The Aop object was not correctly imported or is not available in the scope, or the `before` method does not exist on the imported object.","error":"TypeError: Aop.before is not a function"},{"fix":"Ensure the object you are trying to apply AOP to (e.g., `myServiceInstance`) is properly instantiated and not `null` or `undefined` before calling any `Aop` methods on it.","cause":"The target object passed to an AOP method (e.g., `Aop.before`) is `undefined` or `null`, meaning the aspect is trying to attach to a non-existent object.","error":"Cannot read properties of undefined (reading 'doSomething')"}],"ecosystem":"npm"}