UNPKG

@decaf-ts/db-decorators

Version:

Agnostic database decorators and repository

38 lines (37 loc) 1.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Operations = void 0; const decorator_validation_1 = require("@decaf-ts/decorator-validation"); const OperationsRegistry_1 = require("./OperationsRegistry.cjs"); const constants_1 = require("./constants.cjs"); /** * @summary Static class holding common Operation Functionality * * @class Operations * * @category Operations */ class Operations { constructor() { } static getHandlerName(handler) { if (handler.name) return handler.name; console.warn("Handler name not defined. A name will be generated, but this is not desirable. please avoid using anonymous functions"); return decorator_validation_1.Hashing.hash(handler.toString()); } static key(str) { return constants_1.OperationKeys.REFLECT + str; } static get(targetName, propKey, operation) { return Operations.registry.get(targetName, propKey, operation); } static getOpRegistry() { if (!Operations.registry) Operations.registry = new OperationsRegistry_1.OperationsRegistry(); return Operations.registry; } static register(handler, operation, target, propKey) { Operations.getOpRegistry().register(handler, operation, target, propKey); } } exports.Operations = Operations;