UNPKG

lakutata

Version:

An IoC-based universal application framework.

158 lines (121 loc) 4.11 kB
"use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); const e = require("../../helpers/ObjectConstructor.cjs"); const t = require("../../helpers/As.cjs"); const r = require("../../helpers/ObjectParentConstructors.cjs"); const n = require("../../helpers/ObjectHash.cjs"); const o = require("../../helpers/GetObjectNestingDepth.cjs"); const c = require("../../../exceptions/InvalidActionPatternDepthException.cjs"); require("../../helpers/ObjectParentConstructor.cjs"); require("../../../../vendor/Package.5.cjs"); require("../../../../vendor/Package.15.cjs"); require("crypto"); require("../abstracts/Exception.cjs"); require("./BasicInfo.cjs"); require("../../../../vendor/Package.6.cjs"); require("../../../../vendor/Package.7.cjs"); require("./ThrowWarning.cjs"); require("../../helpers/Templating.cjs"); require("./CamelCase.cjs"); require("../../helpers/NoCase.cjs"); exports.ActionPatternManagerType = void 0; (function(e) { e["HTTP"] = "_$APMT_HTTP"; e["CLI"] = "_$APMT_CLI"; e["Service"] = "_$APMT_Service"; })(exports.ActionPatternManagerType || (exports.ActionPatternManagerType = {})); const s = Symbol("COMPONENT.CTRL.MAP"); function a(e) { const t = o.GetObjectNestingDepth(e); if (t > 2) throw new c.InvalidActionPatternDepthException("The maximum nesting depth of ActionPattern objects cannot be greater than 2 levels. The current nesting depth of the object is {0} levels", [ t ]); return e; } function i(e, n) { const o = new Map; r.ObjectParentConstructors(n).forEach((t => { const r = Reflect.getOwnMetadata(`${e}_MAP`, t) || new Map; r.forEach(((e, t) => o.set(t, e))); })); t.As(Reflect.getOwnMetadata(`${e}_MAP`, n) || new Map).forEach(((e, t) => o.set(t, e))); return o; } function p(e, t, r, o) { r = a(r); const c = i(e, t); c.set(n.ObjectHash(r), { pattern: r, details: o }); Reflect.defineMetadata(`${e}_MAP`, c, t); } function u(e, t) { const r = Reflect.getOwnMetadata(s, e) || { CLI: new Map, HTTP: new Map, Service: new Map }; i(exports.ActionPatternManagerType.CLI, t).forEach(((e, t) => r.CLI.set(t, e))); i(exports.ActionPatternManagerType.HTTP, t).forEach(((e, t) => r.HTTP.set(t, e))); i(exports.ActionPatternManagerType.Service, t).forEach(((e, t) => r.Service.set(t, e))); Reflect.defineMetadata(s, r, e); } function h(e) { const t = Reflect.getOwnMetadata(s, e) || { CLI: new Map, HTTP: new Map, Service: new Map }; const r = { CLI: new Map, HTTP: new Map, Service: new Map }; t.CLI.forEach((e => r.CLI.set(e.pattern, e.details))); t.HTTP.forEach((e => r.HTTP.set(e.pattern, e.details))); t.Service.forEach((e => r.Service.set(e.pattern, e.details))); return r; } function T(r, n, o, c, s) { n.forEach((n => { const a = { route: r, method: n }; p(exports.ActionPatternManagerType.HTTP, t.As(e.ObjectConstructor(o)), a, { pattern: a, constructor: t.As(e.ObjectConstructor(o)), method: c, dtoConstructor: s, jsonSchema: s.toJsonSchema() }); })); } function P(r, n, o, c) { const s = { command: r }; p(exports.ActionPatternManagerType.CLI, t.As(e.ObjectConstructor(n)), s, { pattern: s, constructor: t.As(e.ObjectConstructor(n)), method: o, dtoConstructor: c, jsonSchema: c.toJsonSchema() }); } function j(r, n, o, c) { p(exports.ActionPatternManagerType.Service, t.As(e.ObjectConstructor(n)), r, { pattern: r, constructor: t.As(e.ObjectConstructor(n)), method: o, dtoConstructor: c, jsonSchema: c.toJsonSchema() }); } exports.BindControllerToComponent = u; exports.GetComponentControllerActionMap = h; exports.RegisterCLIAction = P; exports.RegisterControllerActionPattern = p; exports.RegisterHTTPAction = T; exports.RegisterServiceAction = j;