phecda-server 5.0.0-alpha.8 → 5.0.0-beta.19

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 (39) hide show
  1. package/bin/cli.js +90 -57
  2. package/dist/{chunk-GY5KXMJJ.js → chunk-EVF2CXTP.js} +21 -4
  3. package/dist/{chunk-65S2TIDV.mjs → chunk-LSMNOIFA.mjs} +31 -30
  4. package/dist/chunk-N7GEBDPZ.mjs +32 -0
  5. package/dist/{chunk-DBYLTVRY.mjs → chunk-PXI5J4LR.mjs} +21 -14
  6. package/dist/{chunk-WB437JJ2.mjs → chunk-UFSW7A6B.mjs} +17 -3
  7. package/dist/{chunk-WVL2B47I.js → chunk-VBYDVWRK.js} +47 -46
  8. package/dist/{chunk-ZV4O77YM.js → chunk-WNTTAFLC.js} +61 -54
  9. package/dist/{chunk-ALJSRZ4Z.js → chunk-XHKBG2VA.js} +17 -3
  10. package/dist/{core-fe0991cd.d.ts → core-eb2a0799.d.ts} +18 -10
  11. package/dist/index.d.ts +32 -29
  12. package/dist/index.js +108 -96
  13. package/dist/index.mjs +71 -59
  14. package/dist/rpc/kafka/index.d.ts +2 -1
  15. package/dist/rpc/kafka/index.js +9 -9
  16. package/dist/rpc/kafka/index.mjs +3 -3
  17. package/dist/rpc/rabbitmq/index.d.ts +2 -1
  18. package/dist/rpc/rabbitmq/index.js +9 -9
  19. package/dist/rpc/rabbitmq/index.mjs +3 -3
  20. package/dist/rpc/redis/index.d.ts +2 -1
  21. package/dist/rpc/redis/index.js +9 -9
  22. package/dist/rpc/redis/index.mjs +3 -3
  23. package/dist/server/express/index.d.ts +4 -3
  24. package/dist/server/express/index.js +42 -36
  25. package/dist/server/express/index.mjs +23 -17
  26. package/dist/server/fastify/index.d.ts +3 -3
  27. package/dist/server/fastify/index.js +38 -35
  28. package/dist/server/fastify/index.mjs +19 -16
  29. package/dist/server/h3/index.d.ts +3 -3
  30. package/dist/server/h3/index.js +40 -51
  31. package/dist/server/h3/index.mjs +22 -33
  32. package/dist/server/koa/index.d.ts +4 -3
  33. package/dist/server/koa/index.js +41 -34
  34. package/dist/server/koa/index.mjs +22 -15
  35. package/dist/test.d.ts +5 -4
  36. package/dist/test.js +50 -47
  37. package/dist/test.mjs +46 -43
  38. package/package.json +2 -2
  39. package/dist/chunk-EP4EN3MM.mjs +0 -15
package/bin/cli.js CHANGED
@@ -10,15 +10,21 @@ let child
10
10
  let closePromise
11
11
  const nodeVersion = parseFloat(process.version.slice(1))
12
12
 
13
- if (nodeVersion < 18.18)
14
- log(`Nodejs version less than 18.18(current is ${nodeVersion}) can't support hmr`, 'yellow')
13
+ if (nodeVersion < 18.18) {
14
+ log(
15
+ `Nodejs version less than 18.18(current is ${nodeVersion}) can't support hmr`,
16
+ 'yellow',
17
+ )
18
+ }
15
19
 
16
20
  function startChild() {
17
21
  child = fork(cmd[0], {
18
22
  env: { NODE_ENV: 'development', ...process.env },
19
23
  stdio: 'inherit',
20
24
  execArgv: [
21
- nodeVersion < 18.18 ? '--loader=phecda-server/register/loader.mjs' : '--import=phecda-server/register',
25
+ nodeVersion < 18.18
26
+ ? '--loader=phecda-server/register/loader.mjs'
27
+ : '--import=phecda-server/register',
22
28
  ...cmd.slice(1),
23
29
  ],
24
30
  })
@@ -61,51 +67,77 @@ function log(msg, color = 'green') {
61
67
  )} ${pc[color](msg)}`,
62
68
  )
63
69
  }
70
+ if (cmd[0] === 'init') {
71
+ fs.writeFileSync('tsconfig.json', `{
72
+ "compilerOptions": {
73
+ "target": "esnext",
74
+ "useDefineForClassFields": false,
75
+ "experimentalDecorators": true,
76
+ "emitDecoratorMetadata": true,
77
+ "module": "esnext",
78
+ "lib": ["esnext", "DOM"],
79
+ "strictPropertyInitialization": false,
80
+ "moduleResolution": "Node",
81
+ "strict": true,
82
+ "resolveJsonModule": true,
83
+ "isolatedModules": true,
84
+ "esModuleInterop": true,
85
+ "noEmit": true,
86
+ "noUnusedLocals": true,
87
+ "noUnusedParameters": true,
88
+ "noImplicitReturns": true,
89
+ "skipLibCheck": true
90
+ },
91
+ "include": ["src","./ps.d.ts"]
92
+ }
93
+ `)
64
94
 
65
- startChild()
66
-
67
- log('process start!')
68
- console.log(`${pc.green('->')} press ${pc.green('e')} to exit`)
69
- console.log(`${pc.green('->')} press ${pc.green('r')} to relaunch`)
70
- console.log(
95
+ log('init tsconfig.json!')
96
+ }
97
+ else {
98
+ startChild()
99
+ log('process start!')
100
+ console.log(`${pc.green('->')} press ${pc.green('e')} to exit`)
101
+ console.log(`${pc.green('->')} press ${pc.green('r')} to relaunch`)
102
+ console.log(
71
103
  `${pc.green('->')} press ${pc.green(
72
104
  'c {moduleName} {dir}',
73
105
  )} to create controller`,
74
- )
75
- console.log(
106
+ )
107
+ console.log(
76
108
  `${pc.green('->')} press ${pc.green(
77
109
  's {moduleName} {dir}',
78
110
  )} to create service`,
79
- )
80
- console.log(
111
+ )
112
+ console.log(
81
113
  `${pc.green('->')} press ${pc.green('m {moduleName} {dir}')} to create module`,
82
- )
83
-
84
- process.stdin.on('data', async (data) => {
85
- const input = data.toString().trim().toLocaleLowerCase()
86
- if (input === 'r') {
87
- if (child) {
88
- await child.kill()
89
- if (closePromise)
90
- await closePromise
91
- log('relaunch...')
92
- startChild()
93
- }
94
- else {
95
- log('relaunch...')
114
+ )
96
115
 
97
- startChild()
116
+ process.stdin.on('data', async (data) => {
117
+ const input = data.toString().trim().toLocaleLowerCase()
118
+ if (input === 'r') {
119
+ if (child) {
120
+ await child.kill()
121
+ if (closePromise)
122
+ await closePromise
123
+ log('relaunch...')
124
+ startChild()
125
+ }
126
+ else {
127
+ log('relaunch...')
128
+
129
+ startChild()
130
+ }
98
131
  }
99
- }
100
- if (input === 'e')
101
- exit()
102
-
103
- if (input.startsWith('c ')) {
104
- let [, module, dir] = input.split(' ')
105
- module = toCamelCase(module)
106
- const path = posix.join(dir, `${module}.controller.ts`)
107
- fs.writeFile(
108
- path,
132
+ if (input === 'e')
133
+ exit()
134
+
135
+ if (input.startsWith('c ')) {
136
+ let [, module, dir] = input.split(' ')
137
+ module = toCamelCase(module)
138
+ const path = posix.join(dir, `${module}.controller.ts`)
139
+ fs.writeFile(
140
+ path,
109
141
  `
110
142
  export class ${module[0].toUpperCase()}${module.slice(1)}Controller{
111
143
 
@@ -116,14 +148,14 @@ process.stdin.on('data', async (data) => {
116
148
  log('writeFile filled', 'red')
117
149
  else log(`create controller at ${path}`)
118
150
  },
119
- )
120
- }
121
- if (input.startsWith('s ')) {
122
- let [, module, dir] = input.split(' ')
123
- module = toCamelCase(module)
124
- const path = posix.join(dir, `${module}.service.ts`)
125
- fs.writeFile(
126
- path,
151
+ )
152
+ }
153
+ if (input.startsWith('s ')) {
154
+ let [, module, dir] = input.split(' ')
155
+ module = toCamelCase(module)
156
+ const path = posix.join(dir, `${module}.service.ts`)
157
+ fs.writeFile(
158
+ path,
127
159
  `
128
160
  import {Tag} from 'phecda-server'
129
161
  @Tag('${module}')
@@ -136,15 +168,15 @@ process.stdin.on('data', async (data) => {
136
168
  log('writeFile filled', 'red')
137
169
  else log(`create service at ${path}`)
138
170
  },
139
- )
140
- }
171
+ )
172
+ }
141
173
 
142
- if (input.startsWith('m ')) {
143
- let [, module, dir] = input.split(' ')
144
- module = toCamelCase(module)
145
- const path = posix.join(dir, `${module}.module.ts`)
146
- fs.writeFile(
147
- path,
174
+ if (input.startsWith('m ')) {
175
+ let [, module, dir] = input.split(' ')
176
+ module = toCamelCase(module)
177
+ const path = posix.join(dir, `${module}.module.ts`)
178
+ fs.writeFile(
179
+ path,
148
180
  `
149
181
  import {Tag} from 'phecda-server'
150
182
  @Tag('${module}')
@@ -157,9 +189,10 @@ process.stdin.on('data', async (data) => {
157
189
  log('writeFile filled', 'red')
158
190
  else log(`create module at ${path}`)
159
191
  },
160
- )
161
- }
162
- })
192
+ )
193
+ }
194
+ })
195
+ }
163
196
 
164
197
  function toCamelCase(str) {
165
198
  return str.replace(/[-_]\w/g, match => match.charAt(1).toUpperCase())
@@ -1,15 +1,32 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkALJSRZ4Zjs = require('./chunk-ALJSRZ4Z.js');
3
+ var _chunkXHKBG2VAjs = require('./chunk-XHKBG2VA.js');
4
4
 
5
- // src/helper.ts
5
+ // src/server/helper.ts
6
6
  function resolveDep(ret, key) {
7
7
  if (key)
8
8
  return _optionalChain([ret, 'optionalAccess', _ => _[key]]);
9
9
  return ret;
10
10
  }
11
- _chunkALJSRZ4Zjs.__name.call(void 0, resolveDep, "resolveDep");
11
+ _chunkXHKBG2VAjs.__name.call(void 0, resolveDep, "resolveDep");
12
+ function argToReq(params, args, headers) {
13
+ const req = {
14
+ body: {},
15
+ query: {},
16
+ params: {},
17
+ headers
18
+ };
19
+ params.forEach((param) => {
20
+ if (param.key)
21
+ req[param.type][param.key] = args[param.index];
22
+ else
23
+ req[param.type] = args[param.index];
24
+ });
25
+ return req;
26
+ }
27
+ _chunkXHKBG2VAjs.__name.call(void 0, argToReq, "argToReq");
28
+
12
29
 
13
30
 
14
31
 
15
- exports.resolveDep = resolveDep;
32
+ exports.resolveDep = resolveDep; exports.argToReq = argToReq;
@@ -1,18 +1,15 @@
1
1
  import {
2
2
  IS_DEV,
3
- UNMOUNT_SYMBOL,
4
3
  __name,
5
4
  log
6
- } from "./chunk-WB437JJ2.mjs";
5
+ } from "./chunk-UFSW7A6B.mjs";
7
6
 
8
7
  // src/meta.ts
9
8
  var Meta = class {
10
9
  data;
11
- handlers;
12
10
  paramsType;
13
- constructor(data, handlers, paramsType) {
11
+ constructor(data, paramsType) {
14
12
  this.data = data;
15
- this.handlers = handlers;
16
13
  this.paramsType = paramsType;
17
14
  }
18
15
  };
@@ -103,7 +100,7 @@ __name(generateHTTPCode, "generateHTTPCode");
103
100
  import "reflect-metadata";
104
101
  import fs from "fs";
105
102
  import EventEmitter from "node:events";
106
- import { Empty, SHARE_KEY, getExposeKey, getHandler, getProperty, getState, injectProperty, isPhecda, registerAsync } from "phecda-core";
103
+ import { Empty, SHARE_KEY, getExposeKey, getKey, getState, getTag, injectKey, invokeHandler, isPhecda } from "phecda-core";
107
104
  import Debug from "debug";
108
105
  function Injectable() {
109
106
  return (target) => Empty(target);
@@ -118,30 +115,25 @@ async function Factory(Modules, opts = {}) {
118
115
  const constructorSet = /* @__PURE__ */ new WeakSet();
119
116
  const moduleGraph = /* @__PURE__ */ new Map();
120
117
  const { http, rpc } = opts;
121
- if (!getProperty("watcher")) {
122
- injectProperty("watcher", ({ eventName, instance, key, options }) => {
118
+ if (!getKey("watcher")) {
119
+ injectKey("watcher", ({ eventName, instance, key, options }) => {
123
120
  const fn = typeof instance[key] === "function" ? instance[key].bind(instance) : (v) => instance[key] = v;
124
- if (!instance[UNMOUNT_SYMBOL])
125
- instance[UNMOUNT_SYMBOL] = [];
126
- instance[UNMOUNT_SYMBOL].push(() => {
127
- emitter.off(eventName, fn);
128
- });
129
121
  if (options?.once)
130
122
  emitter.once(eventName, fn);
131
123
  else
132
124
  emitter.on(eventName, fn);
125
+ return () => {
126
+ emitter.off(eventName, fn);
127
+ };
133
128
  });
134
129
  }
135
130
  async function del(tag) {
136
131
  if (!moduleMap.has(tag))
137
132
  return;
138
133
  const instance = moduleMap.get(tag);
139
- debug(`unmount module "${tag}"`);
140
- if (instance?.[UNMOUNT_SYMBOL]) {
141
- for (const cb of instance[UNMOUNT_SYMBOL])
142
- await cb();
143
- }
144
- debug(`del module "${tag}"`);
134
+ debug(`unmount module "${String(tag)}"`);
135
+ invokeHandler("unmount", instance);
136
+ debug(`del module "${String(tag)}"`);
145
137
  moduleMap.delete(tag);
146
138
  constructorMap.delete(tag);
147
139
  for (let i = meta.length - 1; i >= 0; i--) {
@@ -151,12 +143,18 @@ async function Factory(Modules, opts = {}) {
151
143
  return instance;
152
144
  }
153
145
  __name(del, "del");
146
+ async function destroy() {
147
+ debug("destroy all");
148
+ for (const [tag] of moduleMap)
149
+ await del(tag);
150
+ }
151
+ __name(destroy, "destroy");
154
152
  async function add(Module) {
155
- const tag = Module.prototype?.__TAG__ || Module.name;
153
+ const tag = getTag(Module);
156
154
  const oldInstance = await del(tag);
157
155
  const { instance: newModule } = await buildNestModule(Module);
158
156
  if (oldInstance && moduleGraph.has(tag)) {
159
- debug(`replace module "${tag}"`);
157
+ debug(`replace module "${String(tag)}"`);
160
158
  [
161
159
  ...moduleGraph.get(tag)
162
160
  ].forEach((tag2) => {
@@ -172,14 +170,14 @@ async function Factory(Modules, opts = {}) {
172
170
  async function buildNestModule(Module) {
173
171
  const paramtypes = getParamTypes(Module);
174
172
  let instance;
175
- const tag = Module.prototype?.__TAG__ || Module.name;
173
+ const tag = getTag(Module);
176
174
  if (moduleMap.has(tag)) {
177
175
  instance = moduleMap.get(tag);
178
176
  if (!instance)
179
- throw new Error(`exist Circular-Dependency or Multiple modules with the same name/tag [tag] ${tag}--[module] ${Module}`);
177
+ throw new Error(`exist Circular-Dependency or Multiple modules with the same name/tag [tag] ${String(tag)}--[module] ${Module}`);
180
178
  if (constructorMap.get(tag) !== Module && !constructorSet.has(Module)) {
181
179
  constructorSet.add(Module);
182
- log(`Synonym module: Module taged "${tag}" has been loaded before, so phecda-server won't load Module "${Module.name}"`, "warn");
180
+ log(`Synonym module: Module taged "${String(tag)}" has been loaded before, so phecda-server won't load Module "${Module.name}"`, "warn");
183
181
  }
184
182
  return {
185
183
  instance,
@@ -187,7 +185,7 @@ async function Factory(Modules, opts = {}) {
187
185
  };
188
186
  }
189
187
  moduleMap.set(tag, void 0);
190
- debug(`instantiate module "${tag}"`);
188
+ debug(`instantiate module "${String(tag)}"`);
191
189
  if (paramtypes) {
192
190
  const paramtypesInstances = [];
193
191
  for (const i in paramtypes) {
@@ -202,9 +200,9 @@ async function Factory(Modules, opts = {}) {
202
200
  instance = new Module();
203
201
  }
204
202
  meta.push(...getMetaFromInstance(instance, tag, Module.name));
205
- debug(`init module "${tag}"`);
206
- await registerAsync(instance);
207
- debug(`add module "${tag}"`);
203
+ debug(`init module "${String(tag)}"`);
204
+ await invokeHandler("init", instance);
205
+ debug(`add module "${String(tag)}"`);
208
206
  moduleMap.set(tag, instance);
209
207
  constructorMap.set(tag, Module);
210
208
  return {
@@ -247,7 +245,8 @@ async function Factory(Modules, opts = {}) {
247
245
  meta,
248
246
  constructorMap,
249
247
  add,
250
- del
248
+ del,
249
+ destroy
251
250
  };
252
251
  }
253
252
  __name(Factory, "Factory");
@@ -273,6 +272,8 @@ function getMetaFromInstance(instance, tag, name) {
273
272
  ...state.rpc
274
273
  };
275
274
  }
275
+ if (typeof tag !== "string" && (meta.rpc || meta.http))
276
+ log(`can't use Tag with ${typeof tag} on http/rpc controller "${instance.constructor.name}",instead with "${tag = String(tag)}"`, "error");
276
277
  meta.name = name;
277
278
  meta.tag = tag;
278
279
  meta.method = i;
@@ -310,7 +311,7 @@ function getMetaFromInstance(instance, tag, name) {
310
311
  ...state.interceptors
311
312
  ])
312
313
  ];
313
- return new Meta(meta, getHandler(instance, i), getParamTypes(instance, i) || []);
314
+ return new Meta(meta, getParamTypes(instance, i) || []);
314
315
  });
315
316
  }
316
317
  __name(getMetaFromInstance, "getMetaFromInstance");
@@ -0,0 +1,32 @@
1
+ import {
2
+ __name
3
+ } from "./chunk-UFSW7A6B.mjs";
4
+
5
+ // src/server/helper.ts
6
+ function resolveDep(ret, key) {
7
+ if (key)
8
+ return ret?.[key];
9
+ return ret;
10
+ }
11
+ __name(resolveDep, "resolveDep");
12
+ function argToReq(params, args, headers) {
13
+ const req = {
14
+ body: {},
15
+ query: {},
16
+ params: {},
17
+ headers
18
+ };
19
+ params.forEach((param) => {
20
+ if (param.key)
21
+ req[param.type][param.key] = args[param.index];
22
+ else
23
+ req[param.type] = args[param.index];
24
+ });
25
+ return req;
26
+ }
27
+ __name(argToReq, "argToReq");
28
+
29
+ export {
30
+ resolveDep,
31
+ argToReq
32
+ };
@@ -1,11 +1,12 @@
1
1
  import {
2
2
  ERROR_SYMBOL,
3
3
  IS_DEV,
4
+ IS_LOG_BAN,
4
5
  IS_STRICT,
5
6
  __name,
6
7
  __publicField,
7
8
  log
8
- } from "./chunk-WB437JJ2.mjs";
9
+ } from "./chunk-UFSW7A6B.mjs";
9
10
 
10
11
  // src/exception/base.ts
11
12
  var Exception = class extends Error {
@@ -38,11 +39,11 @@ var ValidateException = class extends Exception {
38
39
  __name(ValidateException, "ValidateException");
39
40
 
40
41
  // src/pipe.ts
41
- import { isPhecda, plainToClass, transformClass } from "phecda-core";
42
- var defaultPipe = /* @__PURE__ */ __name(async ({ arg, reflect, index }) => {
42
+ import { isPhecda, plainToClass, transformInstance } from "phecda-core";
43
+ var defaultPipe = /* @__PURE__ */ __name(({ arg, reflect, index }) => {
43
44
  if (isPhecda(reflect)) {
44
45
  const instance = plainToClass(reflect, arg);
45
- const err = await transformClass(instance);
46
+ const err = transformInstance(instance);
46
47
  if (err.length > 0)
47
48
  throw new ValidateException(err[0]);
48
49
  arg = instance;
@@ -169,16 +170,14 @@ import pc from "picocolors";
169
170
  // src/filter.ts
170
171
  var defaultFilter = /* @__PURE__ */ __name((e) => {
171
172
  if (!(e instanceof Exception)) {
172
- if (IS_DEV) {
173
- log(e.message, "error");
173
+ log(e.message, "error");
174
+ if (!IS_LOG_BAN)
174
175
  console.error(e.stack);
175
- }
176
176
  e = new UndefinedException(e.message || e);
177
177
  } else {
178
- if (IS_DEV) {
179
- log(`[${e.constructor.name}] ${e.message}`, "error");
178
+ log(`[${e.constructor.name}] ${e.message}`, "error");
179
+ if (!IS_LOG_BAN)
180
180
  console.error(e.stack);
181
- }
182
181
  }
183
182
  return e.data;
184
183
  }, "defaultFilter");
@@ -294,28 +293,36 @@ __publicField(Context, "guardRecord", {});
294
293
  __publicField(Context, "interceptorRecord", {});
295
294
  __publicField(Context, "pluginRecord", {});
296
295
  function addPlugin(key, handler) {
296
+ if (Context.pluginRecord[key] && Context.pluginRecord[key] !== handler)
297
+ log(`overwrite Plugin "${String(key)}"`, "warn");
297
298
  Context.pluginRecord[key] = handler;
298
299
  }
299
300
  __name(addPlugin, "addPlugin");
300
- function addPipe(key, pipe) {
301
- Context.pipeRecord[key] = pipe;
301
+ function addPipe(key, handler) {
302
+ if (Context.pipeRecord[key] && Context.pipeRecord[key] !== handler)
303
+ log(`overwrite Pipe "${String(key)}"`, "warn");
304
+ Context.pipeRecord[key] = handler;
302
305
  }
303
306
  __name(addPipe, "addPipe");
304
307
  function addFilter(key, handler) {
308
+ if (Context.filterRecord[key] && Context.filterRecord[key] !== handler)
309
+ log(`overwrite Filter "${String(key)}"`, "warn");
305
310
  Context.filterRecord[key] = handler;
306
311
  }
307
312
  __name(addFilter, "addFilter");
308
313
  function addGuard(key, handler) {
314
+ if (Context.guardRecord[key] && Context.guardRecord[key] !== handler)
315
+ log(`overwrite Guard "${String(key)}"`, "warn");
309
316
  Context.guardRecord[key] = handler;
310
317
  }
311
318
  __name(addGuard, "addGuard");
312
319
  function addInterceptor(key, handler) {
320
+ if (Context.interceptorRecord[key] && Context.interceptorRecord[key] !== handler)
321
+ log(`overwrite Interceptor "${String(key)}"`, "warn");
313
322
  Context.interceptorRecord[key] = handler;
314
323
  }
315
324
  __name(addInterceptor, "addInterceptor");
316
325
  function isAopDepInject(meta, { guards, interceptors, plugins } = {}) {
317
- if (!IS_DEV)
318
- return;
319
326
  const pluginSet = new Set(plugins);
320
327
  const guardSet = new Set(guards);
321
328
  const interceptorSet = new Set(interceptors);
@@ -14,15 +14,18 @@ var META_SYMBOL = "__PS_META__";
14
14
  var APP_SYMBOL = "__PS__";
15
15
  var IS_DEV = process.env.NODE_ENV === "development";
16
16
  var IS_STRICT = !!process.env.PS_STRICT;
17
+ var IS_LOG_BAN = !!process.env.PS_LOG_BAN;
17
18
  var ERROR_SYMBOL = "__PS_ERROR__";
18
- var PS_FILE_RE = /\.(controller|service|module|extension|guard|interceptor|plugin|filter|pipe|edge)\.ts$/i;
19
- var PS_IMPORT_RE = /\.(controller|extension|guard|interceptor|plugin|filter|pipe|edge)\.ts$/i;
19
+ var PS_FILE_RE = /\.(controller|service|module|extension|ext|guard|interceptor|plugin|filter|pipe|edge)\.ts$/i;
20
+ var PS_IMPORT_RE = /\.(controller|extension|ext|guard|interceptor|plugin|filter|pipe|edge)\.ts$/i;
20
21
 
21
22
  // src/utils.ts
22
23
  import pc from "picocolors";
23
24
  import { DataMap } from "phecda-core";
24
25
  var time;
25
26
  function log(msg, level = "info") {
27
+ if (IS_LOG_BAN)
28
+ return;
26
29
  const color = {
27
30
  error: "red",
28
31
  info: "green",
@@ -50,6 +53,15 @@ function setConfig(key, conf, force = true) {
50
53
  DataMap[key] = conf;
51
54
  }
52
55
  __name(setConfig, "setConfig");
56
+ function Mix(InternalClass, ExtendClass) {
57
+ return class extends InternalClass {
58
+ constructor(...args) {
59
+ super();
60
+ Object.assign(this, new ExtendClass(...args));
61
+ }
62
+ };
63
+ }
64
+ __name(Mix, "Mix");
53
65
 
54
66
  export {
55
67
  __name,
@@ -61,10 +73,12 @@ export {
61
73
  APP_SYMBOL,
62
74
  IS_DEV,
63
75
  IS_STRICT,
76
+ IS_LOG_BAN,
64
77
  ERROR_SYMBOL,
65
78
  PS_FILE_RE,
66
79
  PS_IMPORT_RE,
67
80
  log,
68
81
  getConfig,
69
- setConfig
82
+ setConfig,
83
+ Mix
70
84
  };