mirror of
https://github.com/HeyPuter/puter
synced 2024-11-14 22:06:00 +00:00
refactor(backend): rename traits to features
This commit is contained in:
parent
7aadae58ce
commit
f7d15bae41
@ -17,7 +17,7 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
const { AdvancedBase } = require("@heyputer/puter-js-common");
|
const { AdvancedBase } = require("@heyputer/puter-js-common");
|
||||||
const { AsyncProviderTrait } = require("../../traits/AsyncProviderTrait");
|
const { AsyncProviderFeature } = require("../../traits/AsyncProviderFeature");
|
||||||
const { HLMkdir, QuickMkdir } = require("../hl_operations/hl_mkdir");
|
const { HLMkdir, QuickMkdir } = require("../hl_operations/hl_mkdir");
|
||||||
const { Context } = require("../../util/context");
|
const { Context } = require("../../util/context");
|
||||||
const { HLWrite } = require("../hl_operations/hl_write");
|
const { HLWrite } = require("../hl_operations/hl_write");
|
||||||
@ -32,8 +32,8 @@ const { HLRemove } = require("../hl_operations/hl_remove");
|
|||||||
|
|
||||||
|
|
||||||
class BatchCommand extends AdvancedBase {
|
class BatchCommand extends AdvancedBase {
|
||||||
static TRAITS = [
|
static FEATURES = [
|
||||||
new AsyncProviderTrait(),
|
new AsyncProviderFeature(),
|
||||||
]
|
]
|
||||||
static async run (executor, parameters) {
|
static async run (executor, parameters) {
|
||||||
const instance = new this();
|
const instance = new this();
|
||||||
|
@ -26,8 +26,8 @@ const StringParam = require('../../api/filesystem/StringParam');
|
|||||||
const FlagParam = require("../../api/filesystem/FlagParam");
|
const FlagParam = require("../../api/filesystem/FlagParam");
|
||||||
const UserParam = require('../../api/filesystem/UserParam');
|
const UserParam = require('../../api/filesystem/UserParam');
|
||||||
const FSNodeContext = require('../FSNodeContext');
|
const FSNodeContext = require('../FSNodeContext');
|
||||||
const { ContextAwareTrait } = require('../../traits/ContextAwareTrait');
|
const { ContextAwareFeature } = require('../../traits/ContextAwareFeature');
|
||||||
const { OtelTrait } = require('../../traits/OtelTrait');
|
const { OtelFeature } = require('../../traits/OtelFeature');
|
||||||
const { HLFilesystemOperation } = require('./definitions');
|
const { HLFilesystemOperation } = require('./definitions');
|
||||||
const { is_valid_path } = require('../validation');
|
const { is_valid_path } = require('../validation');
|
||||||
const { HLRemove } = require('./hl_remove');
|
const { HLRemove } = require('./hl_remove');
|
||||||
@ -249,8 +249,8 @@ class HLMkdir extends HLFilesystemOperation {
|
|||||||
parent_directories_created: () => [],
|
parent_directories_created: () => [],
|
||||||
}
|
}
|
||||||
|
|
||||||
static TRAITS = [
|
static FEATURES = [
|
||||||
new OtelTrait([
|
new OtelFeature([
|
||||||
'_get_existing_parent',
|
'_get_existing_parent',
|
||||||
'_create_parents',
|
'_create_parents',
|
||||||
]),
|
]),
|
||||||
|
@ -33,7 +33,7 @@ const { HLFilesystemOperation } = require("./definitions");
|
|||||||
const { MkTree } = require("./hl_mkdir");
|
const { MkTree } = require("./hl_mkdir");
|
||||||
const { Actor } = require("../../services/auth/Actor");
|
const { Actor } = require("../../services/auth/Actor");
|
||||||
|
|
||||||
class WriteCommonTrait {
|
class WriteCommonFeature {
|
||||||
install_in_instance (instance) {
|
install_in_instance (instance) {
|
||||||
instance._verify_size = async function () {
|
instance._verify_size = async function () {
|
||||||
if (
|
if (
|
||||||
@ -84,8 +84,8 @@ class HLWrite extends HLFilesystemOperation {
|
|||||||
- create shortcuts
|
- create shortcuts
|
||||||
`
|
`
|
||||||
|
|
||||||
static TRAITS = [
|
static FEATURES = [
|
||||||
new WriteCommonTrait(),
|
new WriteCommonFeature(),
|
||||||
]
|
]
|
||||||
|
|
||||||
static PARAMETERS = {
|
static PARAMETERS = {
|
||||||
|
@ -21,7 +21,7 @@ const { id2path } = require("../../helpers");
|
|||||||
|
|
||||||
const { PuterPath } = require("../lib/PuterPath");
|
const { PuterPath } = require("../lib/PuterPath");
|
||||||
const { NodeUIDSelector } = require("../node/selectors");
|
const { NodeUIDSelector } = require("../node/selectors");
|
||||||
const { OtelTrait } = require("../../traits/OtelTrait");
|
const { OtelFeature } = require("../../traits/OtelFeature");
|
||||||
const { Context } = require("../../util/context");
|
const { Context } = require("../../util/context");
|
||||||
const { DB_WRITE } = require("../../services/database/consts");
|
const { DB_WRITE } = require("../../services/database/consts");
|
||||||
|
|
||||||
@ -195,8 +195,8 @@ class DatabaseFSEntryService extends AdvancedBase {
|
|||||||
static STATUS_READY = {};
|
static STATUS_READY = {};
|
||||||
static STATUS_RUNNING_JOB = {};
|
static STATUS_RUNNING_JOB = {};
|
||||||
|
|
||||||
static TRAITS = [
|
static FEATURES = [
|
||||||
new OtelTrait([
|
new OtelFeature([
|
||||||
'insert',
|
'insert',
|
||||||
'update',
|
'update',
|
||||||
'delete',
|
'delete',
|
||||||
|
@ -17,13 +17,13 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
const { AdvancedBase } = require("@heyputer/puter-js-common");
|
const { AdvancedBase } = require("@heyputer/puter-js-common");
|
||||||
const { WeakConstructorTrait } = require("../traits/WeakConstructorTrait");
|
const { WeakConstructorFeature } = require("../traits/WeakConstructorFeature");
|
||||||
const { Eq, And } = require("./query/query");
|
const { Eq, And } = require("./query/query");
|
||||||
const { Entity } = require("./entitystorage/Entity");
|
const { Entity } = require("./entitystorage/Entity");
|
||||||
|
|
||||||
class IdentifierUtil extends AdvancedBase {
|
class IdentifierUtil extends AdvancedBase {
|
||||||
static TRAITS = [
|
static FEATURES = [
|
||||||
new WeakConstructorTrait(),
|
new WeakConstructorFeature(),
|
||||||
]
|
]
|
||||||
|
|
||||||
async detect_identifier (object) {
|
async detect_identifier (object) {
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
const { AdvancedBase } = require("@heyputer/puter-js-common");
|
const { AdvancedBase } = require("@heyputer/puter-js-common");
|
||||||
const { instance_ } = require("../../monitor/PerformanceMonitor");
|
const { instance_ } = require("../../monitor/PerformanceMonitor");
|
||||||
const { WeakConstructorTrait } = require("../../traits/WeakConstructorTrait");
|
const { WeakConstructorFeature } = require("../../traits/WeakConstructorFeature");
|
||||||
const { Property } = require("./Property");
|
const { Property } = require("./Property");
|
||||||
const { Entity } = require("../entitystorage/Entity");
|
const { Entity } = require("../entitystorage/Entity");
|
||||||
const FSNodeContext = require("../../filesystem/FSNodeContext");
|
const FSNodeContext = require("../../filesystem/FSNodeContext");
|
||||||
@ -29,13 +29,13 @@ const FSNodeContext = require("../../filesystem/FSNodeContext");
|
|||||||
* Both wrapping and registering are done by RegistrantService.
|
* Both wrapping and registering are done by RegistrantService.
|
||||||
*/
|
*/
|
||||||
class Mapping extends AdvancedBase {
|
class Mapping extends AdvancedBase {
|
||||||
static TRAITS = [
|
static FEATURES = [
|
||||||
// Whenever you can override something, it's reasonable to want
|
// Whenever you can override something, it's reasonable to want
|
||||||
// to pull the desired implementation from somewhere else to
|
// to pull the desired implementation from somewhere else to
|
||||||
// avoid repeating yourself. Class constructors are one of a few
|
// avoid repeating yourself. Class constructors are one of a few
|
||||||
// examples where this is typically not possible.
|
// examples where this is typically not possible.
|
||||||
// However, javascript is magic, and we do what we want.
|
// However, javascript is magic, and we do what we want.
|
||||||
new WeakConstructorTrait(),
|
new WeakConstructorFeature(),
|
||||||
]
|
]
|
||||||
|
|
||||||
static create (context, data) {
|
static create (context, data) {
|
||||||
|
@ -17,11 +17,11 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
const { AdvancedBase } = require("@heyputer/puter-js-common");
|
const { AdvancedBase } = require("@heyputer/puter-js-common");
|
||||||
const { WeakConstructorTrait } = require("../../traits/WeakConstructorTrait");
|
const { WeakConstructorFeature } = require("../../traits/WeakConstructorFeature");
|
||||||
|
|
||||||
class PropType extends AdvancedBase {
|
class PropType extends AdvancedBase {
|
||||||
static TRAITS = [
|
static FEATURES = [
|
||||||
new WeakConstructorTrait(),
|
new WeakConstructorFeature(),
|
||||||
]
|
]
|
||||||
|
|
||||||
static create (context, data, k) {
|
static create (context, data, k) {
|
||||||
|
@ -17,11 +17,11 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
const { AdvancedBase } = require("@heyputer/puter-js-common");
|
const { AdvancedBase } = require("@heyputer/puter-js-common");
|
||||||
const { WeakConstructorTrait } = require("../../traits/WeakConstructorTrait");
|
const { WeakConstructorFeature } = require("../../traits/WeakConstructorFeature");
|
||||||
|
|
||||||
class Property extends AdvancedBase {
|
class Property extends AdvancedBase {
|
||||||
static TRAITS = [
|
static FEATURES = [
|
||||||
new WeakConstructorTrait(),
|
new WeakConstructorFeature(),
|
||||||
]
|
]
|
||||||
|
|
||||||
static create (context, name, descriptor) {
|
static create (context, name, descriptor) {
|
||||||
|
@ -17,15 +17,15 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
const { AdvancedBase } = require("@heyputer/puter-js-common");
|
const { AdvancedBase } = require("@heyputer/puter-js-common");
|
||||||
const { WeakConstructorTrait } = require("../../traits/WeakConstructorTrait");
|
const { WeakConstructorFeature } = require("../../traits/WeakConstructorFeature");
|
||||||
const { Context } = require("../../util/context");
|
const { Context } = require("../../util/context");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BaseES is a base class for Entity Store classes.
|
* BaseES is a base class for Entity Store classes.
|
||||||
*/
|
*/
|
||||||
class BaseES extends AdvancedBase {
|
class BaseES extends AdvancedBase {
|
||||||
static TRAITS = [
|
static FEATURES = [
|
||||||
new WeakConstructorTrait(),
|
new WeakConstructorFeature(),
|
||||||
]
|
]
|
||||||
|
|
||||||
// Default implementations
|
// Default implementations
|
||||||
|
@ -17,11 +17,11 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
const { AdvancedBase } = require("@heyputer/puter-js-common");
|
const { AdvancedBase } = require("@heyputer/puter-js-common");
|
||||||
const { WeakConstructorTrait } = require("../../traits/WeakConstructorTrait");
|
const { WeakConstructorFeature } = require("../../traits/WeakConstructorFeature");
|
||||||
|
|
||||||
class Entity extends AdvancedBase {
|
class Entity extends AdvancedBase {
|
||||||
static TRAITS = [
|
static FEATURES = [
|
||||||
new WeakConstructorTrait(),
|
new WeakConstructorFeature(),
|
||||||
]
|
]
|
||||||
|
|
||||||
constructor (args) {
|
constructor (args) {
|
||||||
|
@ -21,14 +21,14 @@ const { BaseES } = require("./BaseES");
|
|||||||
|
|
||||||
const APIError = require("../../api/APIError");
|
const APIError = require("../../api/APIError");
|
||||||
const { Entity } = require("./Entity");
|
const { Entity } = require("./Entity");
|
||||||
const { WeakConstructorTrait } = require("../../traits/WeakConstructorTrait");
|
const { WeakConstructorFeature } = require("../../traits/WeakConstructorFeature");
|
||||||
const { And, Or, Eq, Like, Null, Predicate, PredicateUtil, IsNotNull } = require("../query/query");
|
const { And, Or, Eq, Like, Null, Predicate, PredicateUtil, IsNotNull } = require("../query/query");
|
||||||
const { DB_WRITE } = require("../../services/database/consts");
|
const { DB_WRITE } = require("../../services/database/consts");
|
||||||
|
|
||||||
class RawCondition extends AdvancedBase {
|
class RawCondition extends AdvancedBase {
|
||||||
// properties: sql:string, values:any[]
|
// properties: sql:string, values:any[]
|
||||||
static TRAITS = [
|
static FEATURES = [
|
||||||
new WeakConstructorTrait(),
|
new WeakConstructorFeature(),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,11 +17,11 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
const { AdvancedBase } = require("@heyputer/puter-js-common");
|
const { AdvancedBase } = require("@heyputer/puter-js-common");
|
||||||
const { WeakConstructorTrait } = require("../../traits/WeakConstructorTrait");
|
const { WeakConstructorFeature } = require("../../traits/WeakConstructorFeature");
|
||||||
|
|
||||||
class Predicate extends AdvancedBase {
|
class Predicate extends AdvancedBase {
|
||||||
static TRAITS = [
|
static FEATURES = [
|
||||||
new WeakConstructorTrait(),
|
new WeakConstructorFeature(),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ class EntityStoreService extends BaseService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: can replace these with MethodProxyTrait
|
// TODO: can replace these with MethodProxyFeature
|
||||||
async create (entity) {
|
async create (entity) {
|
||||||
return await this.upstream.upsert(entity, { old_entity: null });
|
return await this.upstream.upsert(entity, { old_entity: null });
|
||||||
}
|
}
|
||||||
|
@ -18,10 +18,10 @@
|
|||||||
*/
|
*/
|
||||||
const { AdvancedBase } = require("@heyputer/puter-js-common");
|
const { AdvancedBase } = require("@heyputer/puter-js-common");
|
||||||
const { Context } = require("../util/context");
|
const { Context } = require("../util/context");
|
||||||
const { ContextAwareTrait } = require("../traits/ContextAwareTrait");
|
const { ContextAwareFeature } = require("../traits/ContextAwareFeature");
|
||||||
const { OtelTrait } = require("../traits/OtelTrait");
|
const { OtelFeature } = require("../traits/OtelFeature");
|
||||||
const APIError = require("../api/APIError");
|
const APIError = require("../api/APIError");
|
||||||
const { AssignableMethodsTrait } = require("../traits/AssignableMethodsTrait");
|
const { AssignableMethodsFeature } = require("../traits/AssignableMethodsFeature");
|
||||||
|
|
||||||
const CONTEXT_KEY = Context.make_context_key('operation-trace');
|
const CONTEXT_KEY = Context.make_context_key('operation-trace');
|
||||||
|
|
||||||
@ -220,10 +220,10 @@ class OperationTraceService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class BaseOperation extends AdvancedBase {
|
class BaseOperation extends AdvancedBase {
|
||||||
static TRAITS = [
|
static FEATURES = [
|
||||||
new ContextAwareTrait(),
|
new ContextAwareFeature(),
|
||||||
new OtelTrait(['run']),
|
new OtelFeature(['run']),
|
||||||
new AssignableMethodsTrait(),
|
new AssignableMethodsFeature(),
|
||||||
]
|
]
|
||||||
|
|
||||||
async run (values) {
|
async run (values) {
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
const { get_user, get_app } = require("../../helpers");
|
const { get_user, get_app } = require("../../helpers");
|
||||||
const { AssignableMethodsTrait } = require("../../traits/AssignableMethodsTrait");
|
const { AssignableMethodsFeature } = require("../../traits/AssignableMethodsFeature");
|
||||||
const { Context } = require("../../util/context");
|
const { Context } = require("../../util/context");
|
||||||
const BaseService = require("../BaseService");
|
const BaseService = require("../BaseService");
|
||||||
const { DB_WRITE } = require("../database/consts");
|
const { DB_WRITE } = require("../database/consts");
|
||||||
|
@ -20,7 +20,7 @@ const { AdvancedBase } = require("@heyputer/puter-js-common");
|
|||||||
const APIError = require("../../api/APIError");
|
const APIError = require("../../api/APIError");
|
||||||
const { Context } = require("../../util/context");
|
const { Context } = require("../../util/context");
|
||||||
const BaseService = require("../BaseService");
|
const BaseService = require("../BaseService");
|
||||||
const { SyncTrait } = require("../../traits/SyncTrait");
|
const { SyncFeature } = require("../../traits/SyncFeature");
|
||||||
const { DB_WRITE } = require("../database/consts");
|
const { DB_WRITE } = require("../database/consts");
|
||||||
|
|
||||||
const ts_to_sql = (ts) => Math.floor(ts / 1000);
|
const ts_to_sql = (ts) => Math.floor(ts / 1000);
|
||||||
@ -31,8 +31,8 @@ class RateLimitService extends BaseService {
|
|||||||
kv: globalThis.kv,
|
kv: globalThis.kv,
|
||||||
}
|
}
|
||||||
|
|
||||||
static TRAITS = [
|
static FEATURES = [
|
||||||
new SyncTrait([
|
new SyncFeature([
|
||||||
'check_and_increment',
|
'check_and_increment',
|
||||||
]),
|
]),
|
||||||
]
|
]
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
class AssignableMethodsTrait {
|
class AssignableMethodsFeature {
|
||||||
install_in_instance (instance) {
|
install_in_instance (instance) {
|
||||||
const methods = instance._get_merged_static_object('METHODS');
|
const methods = instance._get_merged_static_object('METHODS');
|
||||||
|
|
||||||
@ -27,5 +27,5 @@ class AssignableMethodsTrait {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
AssignableMethodsTrait
|
AssignableMethodsFeature
|
||||||
};
|
};
|
@ -16,18 +16,18 @@
|
|||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
class AsyncProviderTrait {
|
class AsyncProviderFeature {
|
||||||
install_in_instance (instance) {
|
install_in_instance (instance) {
|
||||||
instance.valueListeners_ = {};
|
instance.valueListeners_ = {};
|
||||||
instance.valueFactories_ = {};
|
instance.valueFactories_ = {};
|
||||||
instance.values_ = {};
|
instance.values_ = {};
|
||||||
instance.rejections_ = {};
|
instance.rejections_ = {};
|
||||||
|
|
||||||
instance.provideValue = AsyncProviderTrait.prototype.provideValue;
|
instance.provideValue = AsyncProviderFeature.prototype.provideValue;
|
||||||
instance.rejectValue = AsyncProviderTrait.prototype.rejectValue;
|
instance.rejectValue = AsyncProviderFeature.prototype.rejectValue;
|
||||||
instance.awaitValue = AsyncProviderTrait.prototype.awaitValue;
|
instance.awaitValue = AsyncProviderFeature.prototype.awaitValue;
|
||||||
instance.onValue = AsyncProviderTrait.prototype.onValue;
|
instance.onValue = AsyncProviderFeature.prototype.onValue;
|
||||||
instance.setFactory = AsyncProviderTrait.prototype.setFactory;
|
instance.setFactory = AsyncProviderFeature.prototype.setFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
provideValue (key, value) {
|
provideValue (key, value) {
|
||||||
@ -116,5 +116,5 @@ class AsyncProviderTrait {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
AsyncProviderTrait
|
AsyncProviderFeature
|
||||||
};
|
};
|
@ -18,7 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
const { Context } = require("../util/context");
|
const { Context } = require("../util/context");
|
||||||
|
|
||||||
class ContextAwareTrait {
|
class ContextAwareFeature {
|
||||||
install_in_instance (instance) {
|
install_in_instance (instance) {
|
||||||
instance.context = Context.get();
|
instance.context = Context.get();
|
||||||
instance.x = instance.context;
|
instance.x = instance.context;
|
||||||
@ -26,5 +26,5 @@ class ContextAwareTrait {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
ContextAwareTrait,
|
ContextAwareFeature,
|
||||||
};
|
};
|
@ -18,7 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
const { Context } = require("../util/context");
|
const { Context } = require("../util/context");
|
||||||
|
|
||||||
class OtelTrait {
|
class OtelFeature {
|
||||||
constructor (method_include_list) {
|
constructor (method_include_list) {
|
||||||
this.method_include_list = method_include_list;
|
this.method_include_list = method_include_list;
|
||||||
}
|
}
|
||||||
@ -44,7 +44,7 @@ class OtelTrait {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class SyncOtelTrait {
|
class SyncOtelFeature {
|
||||||
constructor (method_include_list) {
|
constructor (method_include_list) {
|
||||||
this.method_include_list = method_include_list;
|
this.method_include_list = method_include_list;
|
||||||
}
|
}
|
||||||
@ -72,5 +72,5 @@ class SyncOtelTrait {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
OtelTrait
|
OtelFeature
|
||||||
};
|
};
|
@ -18,7 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
const { Lock } = require("../util/promise");
|
const { Lock } = require("../util/promise");
|
||||||
|
|
||||||
class SyncTrait {
|
class SyncFeature {
|
||||||
constructor (method_include_list) {
|
constructor (method_include_list) {
|
||||||
this.method_include_list = method_include_list;
|
this.method_include_list = method_include_list;
|
||||||
}
|
}
|
||||||
@ -37,5 +37,5 @@ class SyncTrait {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
SyncTrait,
|
SyncFeature,
|
||||||
};
|
};
|
@ -16,7 +16,7 @@
|
|||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
class WeakConstructorTrait {
|
class WeakConstructorFeature {
|
||||||
install_in_instance(instance, { parameters }) {
|
install_in_instance(instance, { parameters }) {
|
||||||
for ( const key in parameters ) {
|
for ( const key in parameters ) {
|
||||||
instance[key] = parameters[key];
|
instance[key] = parameters[key];
|
||||||
@ -25,5 +25,5 @@ class WeakConstructorTrait {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
WeakConstructorTrait,
|
WeakConstructorFeature,
|
||||||
};
|
};
|
@ -19,12 +19,12 @@
|
|||||||
// This doesn't go in ./bases because it logically depends on
|
// This doesn't go in ./bases because it logically depends on
|
||||||
// both ./bases and ./traits, and ./traits depends on ./bases.
|
// both ./bases and ./traits, and ./traits depends on ./bases.
|
||||||
|
|
||||||
const { TraitBase } = require("./bases/TraitBase");
|
const { FeatureBase } = require("./bases/FeatureBase");
|
||||||
|
|
||||||
class AdvancedBase extends TraitBase {
|
class AdvancedBase extends FeatureBase {
|
||||||
static TRAITS = [
|
static FEATURES = [
|
||||||
require('./traits/NodeModuleDITrait'),
|
require('./features/NodeModuleDIFeature'),
|
||||||
require('./traits/PropertiesTrait'),
|
require('./features/PropertiesFeature'),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,11 +18,11 @@
|
|||||||
*/
|
*/
|
||||||
const { BasicBase } = require("./BasicBase");
|
const { BasicBase } = require("./BasicBase");
|
||||||
|
|
||||||
class TraitBase extends BasicBase {
|
class FeatureBase extends BasicBase {
|
||||||
constructor (parameters, ...a) {
|
constructor (parameters, ...a) {
|
||||||
super(parameters, ...a);
|
super(parameters, ...a);
|
||||||
for ( const trait of this.traits ) {
|
for ( const feature of this.features ) {
|
||||||
trait.install_in_instance(
|
feature.install_in_instance(
|
||||||
this,
|
this,
|
||||||
{
|
{
|
||||||
parameters: parameters || {},
|
parameters: parameters || {},
|
||||||
@ -31,11 +31,11 @@ class TraitBase extends BasicBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get traits () {
|
get features () {
|
||||||
return this._get_merged_static_array('TRAITS');
|
return this._get_merged_static_array('FEATURES');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
TraitBase,
|
FeatureBase,
|
||||||
};
|
};
|
Loading…
Reference in New Issue
Block a user