lakutata
Version:
An IoC-based universal application framework.
142 lines (112 loc) • 3.61 kB
JavaScript
import { ObjectConstructor as e } from "../../helpers/ObjectConstructor.mjs";
import { As as t } from "../../helpers/As.mjs";
import { ObjectParentConstructors as o } from "../../helpers/ObjectParentConstructors.mjs";
import { ObjectHash as r } from "../../helpers/ObjectHash.mjs";
import { GetObjectNestingDepth as n } from "../../helpers/GetObjectNestingDepth.mjs";
import { InvalidActionPatternDepthException as a } from "../../../exceptions/InvalidActionPatternDepthException.mjs";
import "../../helpers/ObjectParentConstructor.mjs";
import "../../../../vendor/Package.5.mjs";
import "../../../../vendor/Package.15.mjs";
import "crypto";
import "../abstracts/Exception.mjs";
import "./BasicInfo.mjs";
import "../../../../vendor/Package.6.mjs";
import "../../../../vendor/Package.7.mjs";
import "./ThrowWarning.mjs";
import "../../helpers/Templating.mjs";
import "./CamelCase.mjs";
import "../../helpers/NoCase.mjs";
var c;
(function(e) {
e["HTTP"] = "_$APMT_HTTP";
e["CLI"] = "_$APMT_CLI";
e["Service"] = "_$APMT_Service";
})(c || (c = {}));
const s = Symbol("COMPONENT.CTRL.MAP");
function m(e) {
const t = n(e);
if (t > 2) throw new a("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, r) {
const n = new Map;
o(r).forEach((t => {
const o = Reflect.getOwnMetadata(`${e}_MAP`, t) || new Map;
o.forEach(((e, t) => n.set(t, e)));
}));
t(Reflect.getOwnMetadata(`${e}_MAP`, r) || new Map).forEach(((e, t) => n.set(t, e)));
return n;
}
function p(e, t, o, n) {
o = m(o);
const a = i(e, t);
a.set(r(o), {
pattern: o,
details: n
});
Reflect.defineMetadata(`${e}_MAP`, a, t);
}
function h(e, t) {
const o = Reflect.getOwnMetadata(s, e) || {
CLI: new Map,
HTTP: new Map,
Service: new Map
};
i(c.CLI, t).forEach(((e, t) => o.CLI.set(t, e)));
i(c.HTTP, t).forEach(((e, t) => o.HTTP.set(t, e)));
i(c.Service, t).forEach(((e, t) => o.Service.set(t, e)));
Reflect.defineMetadata(s, o, e);
}
function f(e) {
const t = Reflect.getOwnMetadata(s, e) || {
CLI: new Map,
HTTP: new Map,
Service: new Map
};
const o = {
CLI: new Map,
HTTP: new Map,
Service: new Map
};
t.CLI.forEach((e => o.CLI.set(e.pattern, e.details)));
t.HTTP.forEach((e => o.HTTP.set(e.pattern, e.details)));
t.Service.forEach((e => o.Service.set(e.pattern, e.details)));
return o;
}
function T(o, r, n, a, s) {
r.forEach((r => {
const m = {
route: o,
method: r
};
p(c.HTTP, t(e(n)), m, {
pattern: m,
constructor: t(e(n)),
method: a,
dtoConstructor: s,
jsonSchema: s.toJsonSchema()
});
}));
}
function d(o, r, n, a) {
const s = {
command: o
};
p(c.CLI, t(e(r)), s, {
pattern: s,
constructor: t(e(r)),
method: n,
dtoConstructor: a,
jsonSchema: a.toJsonSchema()
});
}
function j(o, r, n, a) {
p(c.Service, t(e(r)), o, {
pattern: o,
constructor: t(e(r)),
method: n,
dtoConstructor: a,
jsonSchema: a.toJsonSchema()
});
}
export { c as ActionPatternManagerType, h as BindControllerToComponent, f as GetComponentControllerActionMap, d as RegisterCLIAction, p as RegisterControllerActionPattern, T as RegisterHTTPAction, j as RegisterServiceAction };