UNPKG

lakutata

Version:

An IoC-based universal application framework.

189 lines (149 loc) 5.01 kB
/* Build Date: Mon Jan 05 2026 23:52:23 GMT+0800 (China Standard Time) */ "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"); const s = require("./StringifyPattern.cjs"); const a = require("../../../../vendor/Package.internal.55.cjs"); require("../../helpers/ObjectParentConstructor.cjs"); require("../../../../vendor/Package.internal.2.cjs"); require("crypto"); require("../abstracts/Exception.cjs"); require("../../../../vendor/Package.internal.5.cjs"); require("../../../../vendor/Package.internal.6.cjs"); require("./ThrowWarning.cjs"); require("../../helpers/Templating.cjs"); require("./CamelCase.cjs"); require("../../helpers/NoCase.cjs"); require("../../helpers/DevNull.cjs"); require("../../../../vendor/Package.internal.522.cjs"); exports.ActionPatternManagerType = void 0; (function(e) { e["HTTP"] = "_$APMT_HTTP"; e["CLI"] = "_$APMT_CLI"; e["Service"] = "_$APMT_Service"; })(exports.ActionPatternManagerType || (exports.ActionPatternManagerType = {})); const i = Symbol("COMPONENT.CTRL.MAP"); function p(r, n, o, c) { const s = `${t.As(e.ObjectConstructor(r)).className}:${n}`; const i = a.v5(`${s}:${c}`, a.NIL); const p = o.name ? o.name : s; const u = o.description ? o.description : ""; return { id: i, acl: !!o.acl, action: s, name: p, description: u, groups: o.groups ? o.groups : [], rule: o.rule }; } function u(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 l(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 h(e, t, r, o) { r = u(r); const c = l(e, t); c.set(n.ObjectHash(r), { pattern: r, details: o }); Reflect.defineMetadata(`${e}_MAP`, c, t); } function P(e, t) { const r = Reflect.getOwnMetadata(i, e) || { CLI: new Map, HTTP: new Map, Service: new Map }; l(exports.ActionPatternManagerType.CLI, t).forEach((e, t) => r.CLI.set(t, e)); l(exports.ActionPatternManagerType.HTTP, t).forEach((e, t) => r.HTTP.set(t, e)); l(exports.ActionPatternManagerType.Service, t).forEach((e, t) => r.Service.set(t, e)); Reflect.defineMetadata(i, r, e); } function T(e) { const t = Reflect.getOwnMetadata(i, 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 j(r, n, o, c, s, a) { n.forEach(n => { const i = { route: r, method: n }; const u = p(o, c, a, r); h(exports.ActionPatternManagerType.HTTP, t.As(e.ObjectConstructor(o)), i, { ...u, pattern: i, constructor: t.As(e.ObjectConstructor(o)), method: c, dtoConstructor: s, jsonSchema: s.toJsonSchema(), getActionInfo: () => u }); }); } function g(r, n, o, c, s) { const a = { command: r }; const i = p(n, o, s, r); h(exports.ActionPatternManagerType.CLI, t.As(e.ObjectConstructor(n)), a, { ...i, pattern: a, constructor: t.As(e.ObjectConstructor(n)), method: o, dtoConstructor: c, jsonSchema: c.toJsonSchema(), getActionInfo: () => i }); } function d(r, n, o, c, a) { const i = s.StringifyPattern(r); const u = p(n, o, a, i); h(exports.ActionPatternManagerType.Service, t.As(e.ObjectConstructor(n)), r, { ...u, pattern: r, constructor: t.As(e.ObjectConstructor(n)), method: o, dtoConstructor: c, jsonSchema: c.toJsonSchema(), getActionInfo: () => u }); } exports.BindControllerToComponent = P; exports.GetComponentControllerActionMap = T; exports.RegisterCLIAction = g; exports.RegisterControllerActionPattern = h; exports.RegisterHTTPAction = j; exports.RegisterServiceAction = d;