phecda-server 5.3.3 → 6.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/dist/chunk-F3W3NN7F.mjs +238 -0
  2. package/dist/{chunk-ECSI4QBK.mjs → chunk-HDQAT2IM.mjs} +55 -65
  3. package/dist/{chunk-3D7AROG2.js → chunk-LYEZ6RGX.js} +54 -64
  4. package/dist/{chunk-RZ7IXJYQ.js → chunk-TZYATAJX.js} +12 -30
  5. package/dist/chunk-XCND2QW3.js +238 -0
  6. package/dist/{chunk-3IPYLGY2.mjs → chunk-YUXERDQ6.mjs} +13 -31
  7. package/dist/{core-dx9E5x2N.d.ts → core-Blq8frmr.d.ts} +4 -3
  8. package/dist/{core-Bc2ENEHX.d.mts → core-D2oL8Ge0.d.mts} +4 -3
  9. package/dist/helper.js +2 -2
  10. package/dist/helper.mjs +1 -1
  11. package/dist/index.d.mts +10 -10
  12. package/dist/index.d.ts +10 -10
  13. package/dist/index.js +29 -27
  14. package/dist/index.mjs +9 -7
  15. package/dist/rpc/bullmq/index.d.mts +1 -1
  16. package/dist/rpc/bullmq/index.d.ts +1 -1
  17. package/dist/rpc/bullmq/index.js +6 -6
  18. package/dist/rpc/bullmq/index.mjs +1 -1
  19. package/dist/rpc/kafka/index.d.mts +1 -1
  20. package/dist/rpc/kafka/index.d.ts +1 -1
  21. package/dist/rpc/kafka/index.js +5 -5
  22. package/dist/rpc/kafka/index.mjs +1 -1
  23. package/dist/rpc/nats/index.d.mts +1 -1
  24. package/dist/rpc/nats/index.d.ts +1 -1
  25. package/dist/rpc/nats/index.js +5 -5
  26. package/dist/rpc/nats/index.mjs +1 -1
  27. package/dist/rpc/rabbitmq/index.d.mts +1 -1
  28. package/dist/rpc/rabbitmq/index.d.ts +1 -1
  29. package/dist/rpc/rabbitmq/index.js +6 -6
  30. package/dist/rpc/rabbitmq/index.mjs +1 -1
  31. package/dist/rpc/redis/index.d.mts +1 -1
  32. package/dist/rpc/redis/index.d.ts +1 -1
  33. package/dist/rpc/redis/index.js +6 -6
  34. package/dist/rpc/redis/index.mjs +1 -1
  35. package/dist/server/elysia/index.d.mts +1 -1
  36. package/dist/server/elysia/index.d.ts +1 -1
  37. package/dist/server/elysia/index.js +15 -15
  38. package/dist/server/elysia/index.mjs +2 -2
  39. package/dist/server/express/index.d.mts +1 -1
  40. package/dist/server/express/index.d.ts +1 -1
  41. package/dist/server/express/index.js +14 -14
  42. package/dist/server/express/index.mjs +1 -1
  43. package/dist/server/fastify/index.d.mts +1 -1
  44. package/dist/server/fastify/index.d.ts +1 -1
  45. package/dist/server/fastify/index.js +15 -15
  46. package/dist/server/fastify/index.mjs +2 -2
  47. package/dist/server/h3/index.d.mts +1 -1
  48. package/dist/server/h3/index.d.ts +1 -1
  49. package/dist/server/h3/index.js +12 -12
  50. package/dist/server/h3/index.mjs +1 -1
  51. package/dist/server/hono/index.d.mts +1 -1
  52. package/dist/server/hono/index.d.ts +1 -1
  53. package/dist/server/hono/index.js +13 -13
  54. package/dist/server/hono/index.mjs +1 -1
  55. package/dist/server/hyper-express/index.d.mts +1 -1
  56. package/dist/server/hyper-express/index.d.ts +1 -1
  57. package/dist/server/hyper-express/index.js +13 -13
  58. package/dist/server/hyper-express/index.mjs +1 -1
  59. package/dist/server/koa/index.d.mts +1 -1
  60. package/dist/server/koa/index.d.ts +1 -1
  61. package/dist/server/koa/index.js +14 -14
  62. package/dist/server/koa/index.mjs +1 -1
  63. package/dist/test.d.mts +1 -1
  64. package/dist/test.d.ts +1 -1
  65. package/dist/test.js +2 -2
  66. package/dist/test.mjs +1 -1
  67. package/package.json +2 -2
  68. package/dist/chunk-2HVTWYS2.js +0 -279
  69. package/dist/chunk-SXOZVIKW.mjs +0 -279
@@ -0,0 +1,238 @@
1
+ import {
2
+ __name
3
+ } from "./chunk-UXD62LGG.mjs";
4
+
5
+ // src/decorators/param.ts
6
+ import { setMeta } from "phecda-core";
7
+ function BaseParam(data) {
8
+ return (target, property, index) => {
9
+ if (!property) return;
10
+ setMeta(target, property, index, data);
11
+ };
12
+ }
13
+ __name(BaseParam, "BaseParam");
14
+ function Body(key = "") {
15
+ return BaseParam({
16
+ type: "body",
17
+ key
18
+ });
19
+ }
20
+ __name(Body, "Body");
21
+ function Head(key) {
22
+ return BaseParam({
23
+ type: "headers",
24
+ key: key.toLowerCase()
25
+ });
26
+ }
27
+ __name(Head, "Head");
28
+ function Query(key = "") {
29
+ return BaseParam({
30
+ type: "query",
31
+ key
32
+ });
33
+ }
34
+ __name(Query, "Query");
35
+ function Param(key) {
36
+ return BaseParam({
37
+ type: "params",
38
+ key
39
+ });
40
+ }
41
+ __name(Param, "Param");
42
+ function Arg(target, k, index) {
43
+ BaseParam({
44
+ type: "args",
45
+ key: `${index}`
46
+ })(target, k, index);
47
+ }
48
+ __name(Arg, "Arg");
49
+
50
+ // src/decorators/aop.ts
51
+ import { setMeta as setMeta2 } from "phecda-core";
52
+ function Guard(...guards) {
53
+ return (target, property) => {
54
+ setMeta2(target, property, void 0, {
55
+ guards
56
+ });
57
+ };
58
+ }
59
+ __name(Guard, "Guard");
60
+ function Plugin(...plugins) {
61
+ return (target, property) => {
62
+ setMeta2(target, property, void 0, {
63
+ plugins
64
+ });
65
+ };
66
+ }
67
+ __name(Plugin, "Plugin");
68
+ function Interceptor(...interceptors) {
69
+ return (target, property) => {
70
+ setMeta2(target, property, void 0, {
71
+ interceptors
72
+ });
73
+ };
74
+ }
75
+ __name(Interceptor, "Interceptor");
76
+ function Filter(filter) {
77
+ return (target, property) => {
78
+ setMeta2(target, property, void 0, {
79
+ filter
80
+ });
81
+ };
82
+ }
83
+ __name(Filter, "Filter");
84
+ function Pipe(pipe) {
85
+ return (target, property, index) => {
86
+ if (typeof index === "number") {
87
+ BaseParam({
88
+ pipe
89
+ })(target, property, index);
90
+ return;
91
+ }
92
+ setMeta2(target, property, void 0, {
93
+ pipe
94
+ });
95
+ };
96
+ }
97
+ __name(Pipe, "Pipe");
98
+
99
+ // src/decorators/http.ts
100
+ import { setMeta as setMeta3 } from "phecda-core";
101
+ function Route(route, type) {
102
+ return (target, property) => {
103
+ setMeta3(target, property, void 0, {
104
+ http: {
105
+ route,
106
+ type
107
+ }
108
+ });
109
+ };
110
+ }
111
+ __name(Route, "Route");
112
+ function Header(headers) {
113
+ return (target, property) => {
114
+ setMeta3(target, property, void 0, {
115
+ http: {
116
+ headers
117
+ }
118
+ });
119
+ };
120
+ }
121
+ __name(Header, "Header");
122
+ function Get(route = "") {
123
+ return Route(route, "get");
124
+ }
125
+ __name(Get, "Get");
126
+ function Post(route = "") {
127
+ return Route(route, "post");
128
+ }
129
+ __name(Post, "Post");
130
+ function Put(route = "") {
131
+ return Route(route, "put");
132
+ }
133
+ __name(Put, "Put");
134
+ function Search(route = "") {
135
+ return Route(route, "search");
136
+ }
137
+ __name(Search, "Search");
138
+ function Patch(route = "") {
139
+ return Route(route, "patch");
140
+ }
141
+ __name(Patch, "Patch");
142
+ function Delete(route = "") {
143
+ return Route(route, "delete");
144
+ }
145
+ __name(Delete, "Delete");
146
+ function Controller(prefix = "") {
147
+ return (target) => {
148
+ setMeta3(target, void 0, void 0, {
149
+ controller: "http",
150
+ http: {
151
+ prefix
152
+ }
153
+ });
154
+ };
155
+ }
156
+ __name(Controller, "Controller");
157
+
158
+ // src/decorators/rpc.ts
159
+ import { setMeta as setMeta4 } from "phecda-core";
160
+ function Queue(queue = "", isEvent) {
161
+ return (target, property) => {
162
+ setMeta4(target, property, void 0, {
163
+ rpc: {
164
+ queue,
165
+ isEvent
166
+ }
167
+ });
168
+ };
169
+ }
170
+ __name(Queue, "Queue");
171
+ function Rpc() {
172
+ return (target) => {
173
+ setMeta4(target, void 0, void 0, {
174
+ controller: "rpc"
175
+ });
176
+ };
177
+ }
178
+ __name(Rpc, "Rpc");
179
+
180
+ // src/decorators/ctx.ts
181
+ import { SHARE_KEY, setMeta as setMeta5 } from "phecda-core";
182
+ var Ctx = /* @__PURE__ */ __name((target, property) => {
183
+ setMeta5(target, SHARE_KEY, void 0, {
184
+ ctxs: [
185
+ property
186
+ ]
187
+ });
188
+ }, "Ctx");
189
+ function Define(key, value) {
190
+ return (target, property, index) => {
191
+ if (typeof index === "number") {
192
+ setMeta5(target, property, void 0, {
193
+ params: [
194
+ {
195
+ define: {
196
+ [key]: value
197
+ },
198
+ index
199
+ }
200
+ ]
201
+ });
202
+ } else {
203
+ setMeta5(target, property, void 0, {
204
+ define: {
205
+ [key]: value
206
+ }
207
+ });
208
+ }
209
+ };
210
+ }
211
+ __name(Define, "Define");
212
+
213
+ export {
214
+ BaseParam,
215
+ Body,
216
+ Head,
217
+ Query,
218
+ Param,
219
+ Arg,
220
+ Guard,
221
+ Plugin,
222
+ Interceptor,
223
+ Filter,
224
+ Pipe,
225
+ Route,
226
+ Header,
227
+ Get,
228
+ Post,
229
+ Put,
230
+ Search,
231
+ Patch,
232
+ Delete,
233
+ Controller,
234
+ Queue,
235
+ Rpc,
236
+ Ctx,
237
+ Define
238
+ };
@@ -21,11 +21,11 @@ var Meta = class {
21
21
  // src/core.ts
22
22
  import "reflect-metadata";
23
23
  import EventEmitter from "node:events";
24
- import { getExposeKey, getInject, getState, getTag, invokeHandler, isPhecda, setInject } from "phecda-core";
24
+ import { getInject, getMergedMeta, getMetaKey, getMetaParams, getTag, invokeInit, invokeUnmount, isPhecda, setInject } from "phecda-core";
25
25
  import Debug from "debug";
26
- var debug = Debug("phecda-server(Factory)");
26
+ var debug = Debug("phecda-server(createPhecda)");
27
27
  var emitter = new EventEmitter();
28
- async function Factory(models, opts = {}) {
28
+ async function createPhecda(models, opts = {}) {
29
29
  const moduleMap = /* @__PURE__ */ new Map();
30
30
  const meta = [];
31
31
  const modelMap = /* @__PURE__ */ new WeakMap();
@@ -33,8 +33,8 @@ async function Factory(models, opts = {}) {
33
33
  const dependenceGraph = /* @__PURE__ */ new Map();
34
34
  const { parseModule = /* @__PURE__ */ __name((module) => module, "parseModule"), parseMeta = /* @__PURE__ */ __name((meta2) => meta2, "parseMeta"), generators } = opts;
35
35
  if (!getInject("watcher")) {
36
- setInject("watcher", ({ eventName, instance, key, options }) => {
37
- const fn = typeof instance[key] === "function" ? instance[key].bind(instance) : (v) => instance[key] = v;
36
+ setInject("watcher", ({ eventName, instance, property, options }) => {
37
+ const fn = typeof instance[property] === "function" ? instance[property].bind(instance) : (v) => instance[property] = v;
38
38
  if (options?.once) emitter.once(eventName, fn);
39
39
  else emitter.on(eventName, fn);
40
40
  return () => {
@@ -46,7 +46,7 @@ async function Factory(models, opts = {}) {
46
46
  if (!moduleMap.has(tag)) return;
47
47
  const module = moduleMap.get(tag);
48
48
  debug(`unmount module "${String(tag)}"`);
49
- await invokeHandler("unmount", module);
49
+ await invokeUnmount(module);
50
50
  debug(`del module "${String(tag)}"`);
51
51
  moduleMap.delete(tag);
52
52
  modelMap.delete(module);
@@ -111,7 +111,7 @@ async function Factory(models, opts = {}) {
111
111
  }
112
112
  meta.push(...getMetaFromInstance(module, tag, Model.name).map(parseMeta).filter((item) => !!item));
113
113
  debug(`init module "${String(tag)}"`);
114
- if (!IS_ONLY_GENERATE) await invokeHandler("init", module);
114
+ if (!IS_ONLY_GENERATE) await invokeInit(module);
115
115
  debug(`add module "${String(tag)}"`);
116
116
  moduleMap.set(tag, module);
117
117
  modelMap.set(module, Model);
@@ -156,65 +156,58 @@ async function Factory(models, opts = {}) {
156
156
  destroy
157
157
  };
158
158
  }
159
- __name(Factory, "Factory");
159
+ __name(createPhecda, "createPhecda");
160
+ var Factory = createPhecda;
160
161
  function getMetaFromInstance(instance, tag, name) {
161
- const vars = getExposeKey(instance).filter((item) => typeof item === "string");
162
- const baseState = getState(instance);
163
- initState(baseState);
164
- const ctxs = getState(instance).ctxs;
165
- return vars.filter((i) => typeof instance[i] === "function").map((i) => {
166
- const state = getState(instance, i);
167
- const meta = {
168
- ...state,
162
+ const propertyKeys = getMetaKey(instance).filter((item) => typeof item === "string");
163
+ const baseMeta = getMergedMeta(instance, void 0);
164
+ const ctxs = baseMeta.ctxs;
165
+ return propertyKeys.filter((i) => typeof instance[i] === "function").map((i) => {
166
+ const meta = getMergedMeta(instance, i);
167
+ const metaData = {
168
+ ...meta,
169
169
  name,
170
170
  tag,
171
171
  func: i
172
172
  };
173
- if (baseState.controller) {
173
+ if (baseMeta.controller) {
174
174
  if (typeof tag !== "string") log(`can't use Tag with ${typeof tag} on controller "${instance.constructor.name}",instead with "${tag = String(tag)}"`, "error");
175
- initState(state);
176
- meta.controller = baseState.controller;
177
- meta[baseState.controller] = {
178
- ...baseState[baseState.controller],
179
- ...state[baseState.controller]
175
+ metaData.controller = baseMeta.controller;
176
+ metaData[baseMeta.controller] = {
177
+ ...baseMeta[baseMeta.controller],
178
+ ...meta[baseMeta.controller]
180
179
  };
181
- const params = [];
182
- for (const item of state.params || []) {
183
- const newItem = {
184
- ...item
185
- };
186
- if (!newItem.pipe) newItem.pipe = state.pipe || baseState.pipe;
187
- if (!newItem.define) newItem.define = {};
188
- params.unshift(newItem);
189
- if (item.index === 0) break;
190
- }
191
- meta.ctxs = ctxs;
192
- meta.params = params;
193
- meta.filter = state.filter || baseState.filter;
194
- meta.define = {
195
- ...baseState.define,
196
- ...state.define
180
+ const params = getMetaParams(instance, i).map((item) => getMergedMeta(instance, i, item));
181
+ params.forEach((item, index) => {
182
+ if (!item.pipe) item.pipe = meta.pipe || baseMeta.pipe;
183
+ if (!item.define) item.define = {};
184
+ item.index = index;
185
+ });
186
+ metaData.ctxs = ctxs;
187
+ metaData.params = params;
188
+ metaData.filter = meta.filter || baseMeta.filter;
189
+ metaData.define = {
190
+ ...baseMeta.define,
191
+ ...meta.define
197
192
  };
198
- meta.plugins = [
199
- .../* @__PURE__ */ new Set([
200
- ...baseState.plugins,
201
- ...state.plugins
202
- ])
203
- ];
204
- meta.guards = [
205
- .../* @__PURE__ */ new Set([
206
- ...baseState.guards,
207
- ...state.guards
208
- ])
209
- ];
210
- meta.interceptors = [
211
- .../* @__PURE__ */ new Set([
212
- ...baseState.interceptors,
213
- ...state.interceptors
214
- ])
215
- ];
193
+ for (const item of [
194
+ "plugins",
195
+ "guards",
196
+ "interceptors"
197
+ ]) {
198
+ const set = new Set(baseMeta[item]);
199
+ if (meta[item]) {
200
+ meta[item].forEach((part) => {
201
+ set.delete(part);
202
+ set.add(part);
203
+ });
204
+ }
205
+ metaData[item] = [
206
+ ...set
207
+ ];
208
+ }
216
209
  }
217
- return new Meta(deepFreeze(meta), getParamTypes(instance, i) || []);
210
+ return new Meta(deepFreeze(metaData), getParamTypes(instance, i) || []);
218
211
  });
219
212
  }
220
213
  __name(getMetaFromInstance, "getMetaFromInstance");
@@ -230,18 +223,15 @@ function getParamTypes(Model, key) {
230
223
  return Reflect.getMetadata("design:paramtypes", Model, key);
231
224
  }
232
225
  __name(getParamTypes, "getParamTypes");
233
- function initState(state) {
234
- if (!state.define) state.define = {};
235
- if (!state.plugins) state.plugins = /* @__PURE__ */ new Set();
236
- if (!state.guards) state.guards = /* @__PURE__ */ new Set();
237
- if (!state.interceptors) state.interceptors = /* @__PURE__ */ new Set();
226
+ function isObject(o) {
227
+ return Object.prototype.toString.call(o) === "[object Object]";
238
228
  }
239
- __name(initState, "initState");
240
- var createPhecda = Factory;
229
+ __name(isObject, "isObject");
241
230
 
242
231
  export {
243
232
  Meta,
244
233
  emitter,
234
+ createPhecda,
245
235
  Factory,
246
- createPhecda
236
+ isObject
247
237
  };
@@ -23,9 +23,9 @@ require('reflect-metadata');
23
23
  var _events = require('events'); var _events2 = _interopRequireDefault(_events);
24
24
  var _phecdacore = require('phecda-core');
25
25
  var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
26
- var debug = _debug2.default.call(void 0, "phecda-server(Factory)");
26
+ var debug = _debug2.default.call(void 0, "phecda-server(createPhecda)");
27
27
  var emitter = new (0, _events2.default)();
28
- async function Factory(models, opts = {}) {
28
+ async function createPhecda(models, opts = {}) {
29
29
  const moduleMap = /* @__PURE__ */ new Map();
30
30
  const meta = [];
31
31
  const modelMap = /* @__PURE__ */ new WeakMap();
@@ -33,8 +33,8 @@ async function Factory(models, opts = {}) {
33
33
  const dependenceGraph = /* @__PURE__ */ new Map();
34
34
  const { parseModule = /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (module) => module, "parseModule"), parseMeta = /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (meta2) => meta2, "parseMeta"), generators } = opts;
35
35
  if (!_phecdacore.getInject.call(void 0, "watcher")) {
36
- _phecdacore.setInject.call(void 0, "watcher", ({ eventName, instance, key, options }) => {
37
- const fn = typeof instance[key] === "function" ? instance[key].bind(instance) : (v) => instance[key] = v;
36
+ _phecdacore.setInject.call(void 0, "watcher", ({ eventName, instance, property, options }) => {
37
+ const fn = typeof instance[property] === "function" ? instance[property].bind(instance) : (v) => instance[property] = v;
38
38
  if (_optionalChain([options, 'optionalAccess', _ => _.once])) emitter.once(eventName, fn);
39
39
  else emitter.on(eventName, fn);
40
40
  return () => {
@@ -46,7 +46,7 @@ async function Factory(models, opts = {}) {
46
46
  if (!moduleMap.has(tag)) return;
47
47
  const module = moduleMap.get(tag);
48
48
  debug(`unmount module "${String(tag)}"`);
49
- await _phecdacore.invokeHandler.call(void 0, "unmount", module);
49
+ await _phecdacore.invokeUnmount.call(void 0, module);
50
50
  debug(`del module "${String(tag)}"`);
51
51
  moduleMap.delete(tag);
52
52
  modelMap.delete(module);
@@ -111,7 +111,7 @@ async function Factory(models, opts = {}) {
111
111
  }
112
112
  meta.push(...getMetaFromInstance(module, tag, Model.name).map(parseMeta).filter((item) => !!item));
113
113
  debug(`init module "${String(tag)}"`);
114
- if (!_chunkGHFSIZUOjs.IS_ONLY_GENERATE) await _phecdacore.invokeHandler.call(void 0, "init", module);
114
+ if (!_chunkGHFSIZUOjs.IS_ONLY_GENERATE) await _phecdacore.invokeInit.call(void 0, module);
115
115
  debug(`add module "${String(tag)}"`);
116
116
  moduleMap.set(tag, module);
117
117
  modelMap.set(module, Model);
@@ -156,65 +156,58 @@ async function Factory(models, opts = {}) {
156
156
  destroy
157
157
  };
158
158
  }
159
- _chunkGHFSIZUOjs.__name.call(void 0, Factory, "Factory");
159
+ _chunkGHFSIZUOjs.__name.call(void 0, createPhecda, "createPhecda");
160
+ var Factory = createPhecda;
160
161
  function getMetaFromInstance(instance, tag, name) {
161
- const vars = _phecdacore.getExposeKey.call(void 0, instance).filter((item) => typeof item === "string");
162
- const baseState = _phecdacore.getState.call(void 0, instance);
163
- initState(baseState);
164
- const ctxs = _phecdacore.getState.call(void 0, instance).ctxs;
165
- return vars.filter((i) => typeof instance[i] === "function").map((i) => {
166
- const state = _phecdacore.getState.call(void 0, instance, i);
167
- const meta = {
168
- ...state,
162
+ const propertyKeys = _phecdacore.getMetaKey.call(void 0, instance).filter((item) => typeof item === "string");
163
+ const baseMeta = _phecdacore.getMergedMeta.call(void 0, instance, void 0);
164
+ const ctxs = baseMeta.ctxs;
165
+ return propertyKeys.filter((i) => typeof instance[i] === "function").map((i) => {
166
+ const meta = _phecdacore.getMergedMeta.call(void 0, instance, i);
167
+ const metaData = {
168
+ ...meta,
169
169
  name,
170
170
  tag,
171
171
  func: i
172
172
  };
173
- if (baseState.controller) {
173
+ if (baseMeta.controller) {
174
174
  if (typeof tag !== "string") _chunkGHFSIZUOjs.log.call(void 0, `can't use Tag with ${typeof tag} on controller "${instance.constructor.name}",instead with "${tag = String(tag)}"`, "error");
175
- initState(state);
176
- meta.controller = baseState.controller;
177
- meta[baseState.controller] = {
178
- ...baseState[baseState.controller],
179
- ...state[baseState.controller]
175
+ metaData.controller = baseMeta.controller;
176
+ metaData[baseMeta.controller] = {
177
+ ...baseMeta[baseMeta.controller],
178
+ ...meta[baseMeta.controller]
180
179
  };
181
- const params = [];
182
- for (const item of state.params || []) {
183
- const newItem = {
184
- ...item
185
- };
186
- if (!newItem.pipe) newItem.pipe = state.pipe || baseState.pipe;
187
- if (!newItem.define) newItem.define = {};
188
- params.unshift(newItem);
189
- if (item.index === 0) break;
190
- }
191
- meta.ctxs = ctxs;
192
- meta.params = params;
193
- meta.filter = state.filter || baseState.filter;
194
- meta.define = {
195
- ...baseState.define,
196
- ...state.define
180
+ const params = _phecdacore.getMetaParams.call(void 0, instance, i).map((item) => _phecdacore.getMergedMeta.call(void 0, instance, i, item));
181
+ params.forEach((item, index) => {
182
+ if (!item.pipe) item.pipe = meta.pipe || baseMeta.pipe;
183
+ if (!item.define) item.define = {};
184
+ item.index = index;
185
+ });
186
+ metaData.ctxs = ctxs;
187
+ metaData.params = params;
188
+ metaData.filter = meta.filter || baseMeta.filter;
189
+ metaData.define = {
190
+ ...baseMeta.define,
191
+ ...meta.define
197
192
  };
198
- meta.plugins = [
199
- .../* @__PURE__ */ new Set([
200
- ...baseState.plugins,
201
- ...state.plugins
202
- ])
203
- ];
204
- meta.guards = [
205
- .../* @__PURE__ */ new Set([
206
- ...baseState.guards,
207
- ...state.guards
208
- ])
209
- ];
210
- meta.interceptors = [
211
- .../* @__PURE__ */ new Set([
212
- ...baseState.interceptors,
213
- ...state.interceptors
214
- ])
215
- ];
193
+ for (const item of [
194
+ "plugins",
195
+ "guards",
196
+ "interceptors"
197
+ ]) {
198
+ const set = new Set(baseMeta[item]);
199
+ if (meta[item]) {
200
+ meta[item].forEach((part) => {
201
+ set.delete(part);
202
+ set.add(part);
203
+ });
204
+ }
205
+ metaData[item] = [
206
+ ...set
207
+ ];
208
+ }
216
209
  }
217
- return new Meta(deepFreeze(meta), getParamTypes(instance, i) || []);
210
+ return new Meta(deepFreeze(metaData), getParamTypes(instance, i) || []);
218
211
  });
219
212
  }
220
213
  _chunkGHFSIZUOjs.__name.call(void 0, getMetaFromInstance, "getMetaFromInstance");
@@ -230,18 +223,15 @@ function getParamTypes(Model, key) {
230
223
  return Reflect.getMetadata("design:paramtypes", Model, key);
231
224
  }
232
225
  _chunkGHFSIZUOjs.__name.call(void 0, getParamTypes, "getParamTypes");
233
- function initState(state) {
234
- if (!state.define) state.define = {};
235
- if (!state.plugins) state.plugins = /* @__PURE__ */ new Set();
236
- if (!state.guards) state.guards = /* @__PURE__ */ new Set();
237
- if (!state.interceptors) state.interceptors = /* @__PURE__ */ new Set();
226
+ function isObject(o) {
227
+ return Object.prototype.toString.call(o) === "[object Object]";
238
228
  }
239
- _chunkGHFSIZUOjs.__name.call(void 0, initState, "initState");
240
- var createPhecda = Factory;
229
+ _chunkGHFSIZUOjs.__name.call(void 0, isObject, "isObject");
230
+
241
231
 
242
232
 
243
233
 
244
234
 
245
235
 
246
236
 
247
- exports.Meta = Meta; exports.emitter = emitter; exports.Factory = Factory; exports.createPhecda = createPhecda;
237
+ exports.Meta = Meta; exports.emitter = emitter; exports.createPhecda = createPhecda; exports.Factory = Factory; exports.isObject = isObject;
@@ -14,7 +14,9 @@ var _picocolors = require('picocolors'); var _picocolors2 = _interopRequireDefau
14
14
  var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
15
15
 
16
16
  // src/pipe.ts
17
- var _phecdacore = require('phecda-core');
17
+ var defaultPipe = /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, ({ arg }) => {
18
+ return arg;
19
+ }, "defaultPipe");
18
20
 
19
21
  // src/exception/base.ts
20
22
  var Exception = class extends Error {
@@ -40,43 +42,23 @@ var Exception = class extends Error {
40
42
  }
41
43
  };
42
44
 
43
- // src/exception/validate.ts
44
- var ValidateException = class extends Exception {
45
+ // src/exception/undefine.ts
46
+ var UndefinedException = class extends Exception {
45
47
  static {
46
- _chunkGHFSIZUOjs.__name.call(void 0, this, "ValidateException");
48
+ _chunkGHFSIZUOjs.__name.call(void 0, this, "UndefinedException");
47
49
  }
48
50
  constructor(message) {
49
- super(message, 400, "Validate exception");
51
+ super(message, 500, "Undefined error");
50
52
  }
51
53
  };
52
54
 
53
- // src/pipe.ts
54
- var defaultPipe = /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, ({ arg, reflect, index }) => {
55
- if (_phecdacore.isPhecda.call(void 0, reflect)) {
56
- const instance = _phecdacore.plainToClass.call(void 0, reflect, arg);
57
- const err = _phecdacore.transformInstance.call(void 0, instance);
58
- if (err.length > 0) throw new ValidateException(err[0]);
59
- arg = instance;
60
- } else {
61
- if (arg === void 0 && !reflect) return void 0;
62
- if ([
63
- Number,
64
- Boolean
65
- ].includes(reflect)) {
66
- arg = reflect(arg);
67
- if (reflect === Number && Object.is(arg, NaN)) throw new ValidateException(`parameter ${Number(index) + 1} should be a number`);
68
- }
69
- }
70
- return arg;
71
- }, "defaultPipe");
72
-
73
- // src/exception/undefine.ts
74
- var UndefinedException = class extends Exception {
55
+ // src/exception/validate.ts
56
+ var ValidateException = class extends Exception {
75
57
  static {
76
- _chunkGHFSIZUOjs.__name.call(void 0, this, "UndefinedException");
58
+ _chunkGHFSIZUOjs.__name.call(void 0, this, "ValidateException");
77
59
  }
78
60
  constructor(message) {
79
- super(message, 500, "Undefined error");
61
+ super(message, 400, "Validate exception");
80
62
  }
81
63
  };
82
64
 
@@ -557,4 +539,4 @@ _chunkGHFSIZUOjs.__name.call(void 0, detectAopDep, "detectAopDep");
557
539
 
558
540
 
559
541
 
560
- exports.Exception = Exception; exports.ValidateException = ValidateException; exports.defaultPipe = defaultPipe; exports.UndefinedException = UndefinedException; exports.ForbiddenException = ForbiddenException; exports.BadRequestException = BadRequestException; exports.NotFoundException = NotFoundException; exports.ConflictException = ConflictException; exports.BadGatewayException = BadGatewayException; exports.InvalidInputException = InvalidInputException; exports.UnsupportedMediaTypeException = UnsupportedMediaTypeException; exports.PayloadLargeException = PayloadLargeException; exports.TimeoutException = TimeoutException; exports.UnauthorizedException = UnauthorizedException; exports.ServiceUnavailableException = ServiceUnavailableException; exports.FrameworkException = FrameworkException; exports.TimerException = TimerException; exports.WorkerException = WorkerException; exports.HMR = HMR; exports.resolveDep = resolveDep; exports.argToReq = argToReq; exports.genClientQueue = genClientQueue; exports.shallowClone = shallowClone; exports.mergeObject = mergeObject; exports.createControllerMetaMap = createControllerMetaMap; exports.detectAopDep = detectAopDep; exports.Context = Context; exports.addPlugin = addPlugin; exports.addPipe = addPipe; exports.addFilter = addFilter; exports.addGuard = addGuard; exports.addInterceptor = addInterceptor;
542
+ exports.defaultPipe = defaultPipe; exports.Exception = Exception; exports.UndefinedException = UndefinedException; exports.ValidateException = ValidateException; exports.ForbiddenException = ForbiddenException; exports.BadRequestException = BadRequestException; exports.NotFoundException = NotFoundException; exports.ConflictException = ConflictException; exports.BadGatewayException = BadGatewayException; exports.InvalidInputException = InvalidInputException; exports.UnsupportedMediaTypeException = UnsupportedMediaTypeException; exports.PayloadLargeException = PayloadLargeException; exports.TimeoutException = TimeoutException; exports.UnauthorizedException = UnauthorizedException; exports.ServiceUnavailableException = ServiceUnavailableException; exports.FrameworkException = FrameworkException; exports.TimerException = TimerException; exports.WorkerException = WorkerException; exports.HMR = HMR; exports.resolveDep = resolveDep; exports.argToReq = argToReq; exports.genClientQueue = genClientQueue; exports.shallowClone = shallowClone; exports.mergeObject = mergeObject; exports.createControllerMetaMap = createControllerMetaMap; exports.detectAopDep = detectAopDep; exports.Context = Context; exports.addPlugin = addPlugin; exports.addPipe = addPipe; exports.addFilter = addFilter; exports.addGuard = addGuard; exports.addInterceptor = addInterceptor;