UNPKG

lakutata

Version:

An IoC-based universal application framework.

173 lines (140 loc) 4.49 kB
/* Build Date: Mon Jan 05 2026 23:52:23 GMT+0800 (China Standard Time) */ import { ObjectConstructor as t } from "../../helpers/ObjectConstructor.mjs"; import { As as e } from "../../helpers/As.mjs"; import { ObjectParentConstructors as n } from "../../helpers/ObjectParentConstructors.mjs"; import { ObjectHash as o } from "../../helpers/ObjectHash.mjs"; import { GetObjectNestingDepth as r } from "../../helpers/GetObjectNestingDepth.mjs"; import { InvalidActionPatternDepthException as c } from "../../../exceptions/InvalidActionPatternDepthException.mjs"; import { StringifyPattern as a } from "./StringifyPattern.mjs"; import { v as s, N as i } from "../../../../vendor/Package.internal.55.mjs"; import "../../helpers/ObjectParentConstructor.mjs"; import "../../../../vendor/Package.internal.2.mjs"; import "crypto"; import "../abstracts/Exception.mjs"; import "../../../../vendor/Package.internal.5.mjs"; import "../../../../vendor/Package.internal.6.mjs"; import "./ThrowWarning.mjs"; import "../../helpers/Templating.mjs"; import "./CamelCase.mjs"; import "../../helpers/NoCase.mjs"; import "../../helpers/DevNull.mjs"; import "../../../../vendor/Package.internal.522.mjs"; var m; (function(t) { t["HTTP"] = "_$APMT_HTTP"; t["CLI"] = "_$APMT_CLI"; t["Service"] = "_$APMT_Service"; })(m || (m = {})); const p = Symbol("COMPONENT.CTRL.MAP"); function f(n, o, r, c) { const a = `${e(t(n)).className}:${o}`; const m = s(`${a}:${c}`, i); const p = r.name ? r.name : a; const f = r.description ? r.description : ""; return { id: m, acl: !!r.acl, action: a, name: p, description: f, groups: r.groups ? r.groups : [], rule: r.rule }; } function h(t) { const e = r(t); if (e > 2) throw new c("The maximum nesting depth of ActionPattern objects cannot be greater than 2 levels. The current nesting depth of the object is {0} levels", [ e ]); return t; } function l(t, o) { const r = new Map; n(o).forEach(e => { const n = Reflect.getOwnMetadata(`${t}_MAP`, e) || new Map; n.forEach((t, e) => r.set(e, t)); }); e(Reflect.getOwnMetadata(`${t}_MAP`, o) || new Map).forEach((t, e) => r.set(e, t)); return r; } function d(t, e, n, r) { n = h(n); const c = l(t, e); c.set(o(n), { pattern: n, details: r }); Reflect.defineMetadata(`${t}_MAP`, c, e); } function u(t, e) { const n = Reflect.getOwnMetadata(p, t) || { CLI: new Map, HTTP: new Map, Service: new Map }; l(m.CLI, e).forEach((t, e) => n.CLI.set(e, t)); l(m.HTTP, e).forEach((t, e) => n.HTTP.set(e, t)); l(m.Service, e).forEach((t, e) => n.Service.set(e, t)); Reflect.defineMetadata(p, n, t); } function j(t) { const e = Reflect.getOwnMetadata(p, t) || { CLI: new Map, HTTP: new Map, Service: new Map }; const n = { CLI: new Map, HTTP: new Map, Service: new Map }; e.CLI.forEach(t => n.CLI.set(t.pattern, t.details)); e.HTTP.forEach(t => n.HTTP.set(t.pattern, t.details)); e.Service.forEach(t => n.Service.set(t.pattern, t.details)); return n; } function T(n, o, r, c, a, s) { o.forEach(o => { const i = { route: n, method: o }; const p = f(r, c, s, n); d(m.HTTP, e(t(r)), i, { ...p, pattern: i, constructor: e(t(r)), method: c, dtoConstructor: a, jsonSchema: a.toJsonSchema(), getActionInfo: () => p }); }); } function P(n, o, r, c, a) { const s = { command: n }; const i = f(o, r, a, n); d(m.CLI, e(t(o)), s, { ...i, pattern: s, constructor: e(t(o)), method: r, dtoConstructor: c, jsonSchema: c.toJsonSchema(), getActionInfo: () => i }); } function M(n, o, r, c, s) { const i = a(n); const p = f(o, r, s, i); d(m.Service, e(t(o)), n, { ...p, pattern: n, constructor: e(t(o)), method: r, dtoConstructor: c, jsonSchema: c.toJsonSchema(), getActionInfo: () => p }); } export { m as ActionPatternManagerType, u as BindControllerToComponent, j as GetComponentControllerActionMap, P as RegisterCLIAction, d as RegisterControllerActionPattern, T as RegisterHTTPAction, M as RegisterServiceAction };