phecda-server 7.0.0-alpha.1 → 7.0.0-alpha.3

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 (80) hide show
  1. package/assets/ps.json +1 -1
  2. package/bin/cli.mjs +8 -7
  3. package/dist/{chunk-GSPBHZBH.js → chunk-6EBEME3I.js} +52 -52
  4. package/dist/{chunk-XYVMNY2X.mjs → chunk-A53KNKY4.mjs} +1 -1
  5. package/dist/{chunk-HMVLXNV3.mjs → chunk-KUGFI6SC.mjs} +1 -1
  6. package/dist/{chunk-V7EI76QQ.mjs → chunk-MMG73S64.mjs} +2 -2
  7. package/dist/{chunk-7YQ57BQS.js → chunk-PKSWGQLW.js} +18 -18
  8. package/dist/{chunk-MBCHNDAY.js → chunk-QCOBXM7F.js} +24 -24
  9. package/dist/{chunk-WHJ5FALK.mjs → chunk-QD3QR3NW.mjs} +3 -3
  10. package/dist/{chunk-J5CFUN4V.js → chunk-RQSQRZL4.js} +3 -3
  11. package/dist/{core-CYwEPfN4.d.ts → core-C1kHRqU9.d.ts} +1 -1
  12. package/dist/{core-BIcUwV18.d.mts → core-CSiaRU7r.d.mts} +1 -1
  13. package/dist/helper.d.mts +1 -1
  14. package/dist/helper.d.ts +1 -1
  15. package/dist/helper.js +3 -3
  16. package/dist/helper.mjs +2 -2
  17. package/dist/http/elysia/index.d.mts +3 -3
  18. package/dist/http/elysia/index.d.ts +3 -3
  19. package/dist/http/elysia/index.js +42 -40
  20. package/dist/http/elysia/index.mjs +5 -3
  21. package/dist/http/express/index.d.mts +3 -3
  22. package/dist/http/express/index.d.ts +3 -3
  23. package/dist/http/express/index.js +39 -37
  24. package/dist/http/express/index.mjs +4 -2
  25. package/dist/http/fastify/index.d.mts +3 -3
  26. package/dist/http/fastify/index.d.ts +3 -3
  27. package/dist/http/fastify/index.js +40 -38
  28. package/dist/http/fastify/index.mjs +5 -3
  29. package/dist/http/h3/index.d.mts +3 -3
  30. package/dist/http/h3/index.d.ts +3 -3
  31. package/dist/http/h3/index.js +39 -37
  32. package/dist/http/h3/index.mjs +4 -2
  33. package/dist/http/hono/index.d.mts +3 -3
  34. package/dist/http/hono/index.d.ts +3 -3
  35. package/dist/http/hono/index.js +37 -35
  36. package/dist/http/hono/index.mjs +4 -2
  37. package/dist/http/hyper-express/index.d.mts +3 -3
  38. package/dist/http/hyper-express/index.d.ts +3 -3
  39. package/dist/http/hyper-express/index.js +37 -35
  40. package/dist/http/hyper-express/index.mjs +4 -2
  41. package/dist/http/koa/index.d.mts +3 -3
  42. package/dist/http/koa/index.d.ts +3 -3
  43. package/dist/http/koa/index.js +39 -37
  44. package/dist/http/koa/index.mjs +4 -2
  45. package/dist/index.d.mts +8 -8
  46. package/dist/index.d.ts +8 -8
  47. package/dist/index.js +39 -39
  48. package/dist/index.mjs +5 -5
  49. package/dist/{meta-BXKLFTgG.d.mts → meta-D1M85Hef.d.mts} +1 -0
  50. package/dist/{meta-BXKLFTgG.d.ts → meta-D1M85Hef.d.ts} +1 -0
  51. package/dist/rpc/bullmq/index.d.mts +3 -3
  52. package/dist/rpc/bullmq/index.d.ts +3 -3
  53. package/dist/rpc/bullmq/index.js +15 -14
  54. package/dist/rpc/bullmq/index.mjs +3 -2
  55. package/dist/rpc/kafka/index.d.mts +3 -3
  56. package/dist/rpc/kafka/index.d.ts +3 -3
  57. package/dist/rpc/kafka/index.js +15 -14
  58. package/dist/rpc/kafka/index.mjs +3 -2
  59. package/dist/rpc/nats/index.d.mts +3 -3
  60. package/dist/rpc/nats/index.d.ts +3 -3
  61. package/dist/rpc/nats/index.js +14 -13
  62. package/dist/rpc/nats/index.mjs +3 -2
  63. package/dist/rpc/rabbitmq/index.d.mts +3 -3
  64. package/dist/rpc/rabbitmq/index.d.ts +3 -3
  65. package/dist/rpc/rabbitmq/index.js +16 -15
  66. package/dist/rpc/rabbitmq/index.mjs +3 -2
  67. package/dist/rpc/redis/index.d.mts +3 -3
  68. package/dist/rpc/redis/index.d.ts +3 -3
  69. package/dist/rpc/redis/index.js +14 -13
  70. package/dist/rpc/redis/index.mjs +3 -2
  71. package/dist/test.d.mts +2 -2
  72. package/dist/test.d.ts +2 -2
  73. package/dist/test.js +6 -6
  74. package/dist/test.mjs +2 -2
  75. package/dist/{types-BtbL49Zs.d.mts → types-C9Remkup.d.ts} +2 -1
  76. package/dist/{types-m3IEDKjP.d.ts → types-JMhFVp-Z.d.mts} +2 -1
  77. package/dist/{types-h40T3cRG.d.mts → types-ee1FBodH.d.ts} +2 -1
  78. package/dist/{types-VFzEM7LL.d.ts → types-wbHHC93P.d.mts} +2 -1
  79. package/package.json +1 -1
  80. package/register/loader.mjs +2 -2
@@ -4,29 +4,29 @@
4
4
 
5
5
 
6
6
 
7
- var _chunkGSPBHZBHjs = require('../../chunk-GSPBHZBH.js');
7
+ var _chunk6EBEME3Ijs = require('../../chunk-6EBEME3I.js');
8
8
 
9
9
 
10
- var _chunkJ5CFUN4Vjs = require('../../chunk-J5CFUN4V.js');
10
+ var _chunkRQSQRZL4js = require('../../chunk-RQSQRZL4.js');
11
11
 
12
12
  // src/rpc/redis/bind.ts
13
13
  var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
14
14
  var debug = _debug2.default.call(void 0, "phecda-server/redis");
15
15
  function bind({ sub, pub }, { moduleMap, meta }, opts = {}) {
16
16
  const { globalGuards, globalFilter, globalPipe, globalAddons = [], defaultQueue } = opts;
17
- const metaMap = _chunkGSPBHZBHjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
17
+ const metaMap = _chunk6EBEME3Ijs.createControllerMetaMap.call(void 0, meta, (meta2) => {
18
18
  const { controller, rpc, func, tag } = meta2.data;
19
19
  if (controller === "rpc" && _optionalChain([rpc, 'optionalAccess', _ => _.queue]) !== void 0) {
20
20
  debug(`register method "${func}" in module "${tag}"`);
21
21
  return true;
22
22
  }
23
23
  });
24
- _chunkGSPBHZBHjs.detectAopDep.call(void 0, meta, {
24
+ _chunk6EBEME3Ijs.detectAopDep.call(void 0, meta, {
25
25
  guards: globalGuards,
26
26
  addons: globalAddons
27
27
  }, "rpc");
28
28
  const existQueue = /* @__PURE__ */ new Set();
29
- _chunkGSPBHZBHjs.Context.applyAddons(globalAddons, {
29
+ _chunk6EBEME3Ijs.Context.applyAddons(globalAddons, {
30
30
  pub,
31
31
  sub
32
32
  }, "redis");
@@ -45,7 +45,7 @@ function bind({ sub, pub }, { moduleMap, meta }, opts = {}) {
45
45
  }
46
46
  }
47
47
  }
48
- _chunkJ5CFUN4Vjs.__name.call(void 0, subscribeQueues, "subscribeQueues");
48
+ _chunkRQSQRZL4js.__name.call(void 0, subscribeQueues, "subscribeQueues");
49
49
  sub.on("message", async (channel, msg) => {
50
50
  if (!existQueue.has(channel)) return;
51
51
  if (msg) {
@@ -55,13 +55,14 @@ function bind({ sub, pub }, { moduleMap, meta }, opts = {}) {
55
55
  if (_ps !== 1) return;
56
56
  const meta2 = metaMap.get(tag)[func];
57
57
  const { data: { rpc: { isEvent } = {} } } = meta2;
58
- const aop = _chunkGSPBHZBHjs.Context.getAop(meta2, {
58
+ const aop = _chunk6EBEME3Ijs.Context.getAop(meta2, {
59
59
  globalFilter,
60
60
  globalGuards,
61
61
  globalPipe
62
62
  });
63
- const context = new (0, _chunkGSPBHZBHjs.Context)({
63
+ const context = new (0, _chunk6EBEME3Ijs.Context)({
64
64
  type: "redis",
65
+ category: "rpc",
65
66
  moduleMap,
66
67
  redis: sub,
67
68
  meta: meta2,
@@ -91,12 +92,12 @@ function bind({ sub, pub }, { moduleMap, meta }, opts = {}) {
91
92
  }
92
93
  });
93
94
  subscribeQueues();
94
- _chunkGSPBHZBHjs.HMR.call(void 0, async () => {
95
+ _chunk6EBEME3Ijs.HMR.call(void 0, async () => {
95
96
  for (const queue of existQueue) await sub.unsubscribe(queue);
96
97
  subscribeQueues();
97
98
  });
98
99
  }
99
- _chunkJ5CFUN4Vjs.__name.call(void 0, bind, "bind");
100
+ _chunkRQSQRZL4js.__name.call(void 0, bind, "bind");
100
101
 
101
102
  // src/rpc/redis/client.ts
102
103
  var _events = require('events'); var _events2 = _interopRequireDefault(_events);
@@ -105,7 +106,7 @@ async function createClient({ pub, sub }, controllers, opts) {
105
106
  let eventId = 1;
106
107
  let eventCount = 0;
107
108
  const emitter = new (0, _events2.default)();
108
- const clientQueue = _chunkGSPBHZBHjs.genClientQueue.call(void 0, _optionalChain([opts, 'optionalAccess', _2 => _2.key]));
109
+ const clientQueue = _chunk6EBEME3Ijs.genClientQueue.call(void 0, _optionalChain([opts, 'optionalAccess', _2 => _2.key]));
109
110
  await sub.subscribe(clientQueue);
110
111
  for (const i in controllers) {
111
112
  ret[i] = new Proxy(new controllers[i](), {
@@ -145,7 +146,7 @@ async function createClient({ pub, sub }, controllers, opts) {
145
146
  if (error) reject(data);
146
147
  else resolve(data);
147
148
  }
148
- _chunkJ5CFUN4Vjs.__name.call(void 0, listener, "listener");
149
+ _chunkRQSQRZL4js.__name.call(void 0, listener, "listener");
149
150
  eventCount++;
150
151
  emitter.once(id, listener);
151
152
  });
@@ -161,7 +162,7 @@ async function createClient({ pub, sub }, controllers, opts) {
161
162
  });
162
163
  return ret;
163
164
  }
164
- _chunkJ5CFUN4Vjs.__name.call(void 0, createClient, "createClient");
165
+ _chunkRQSQRZL4js.__name.call(void 0, createClient, "createClient");
165
166
 
166
167
 
167
168
 
@@ -4,10 +4,10 @@ import {
4
4
  createControllerMetaMap,
5
5
  detectAopDep,
6
6
  genClientQueue
7
- } from "../../chunk-V7EI76QQ.mjs";
7
+ } from "../../chunk-MMG73S64.mjs";
8
8
  import {
9
9
  __name
10
- } from "../../chunk-WHJ5FALK.mjs";
10
+ } from "../../chunk-QD3QR3NW.mjs";
11
11
 
12
12
  // src/rpc/redis/bind.ts
13
13
  import Debug from "debug";
@@ -62,6 +62,7 @@ function bind({ sub, pub }, { moduleMap, meta }, opts = {}) {
62
62
  });
63
63
  const context = new Context({
64
64
  type: "redis",
65
+ category: "rpc",
65
66
  moduleMap,
66
67
  redis: sub,
67
68
  meta: meta2,
package/dist/test.d.mts CHANGED
@@ -2,8 +2,8 @@ import * as supertest from 'supertest';
2
2
  import { Test } from 'supertest';
3
3
  import { Server } from 'node:http';
4
4
  import { Construct } from 'phecda-core';
5
- import { F as Factory } from './core-BIcUwV18.mjs';
6
- import { P as PickFunc } from './meta-BXKLFTgG.mjs';
5
+ import { F as Factory } from './core-CSiaRU7r.mjs';
6
+ import { P as PickFunc } from './meta-D1M85Hef.mjs';
7
7
 
8
8
  declare function TestFactory<T extends Construct[]>(...Modules: T): Promise<{
9
9
  get<C extends T[number]>(Model: C): InstanceType<C>;
package/dist/test.d.ts CHANGED
@@ -2,8 +2,8 @@ import * as supertest from 'supertest';
2
2
  import { Test } from 'supertest';
3
3
  import { Server } from 'node:http';
4
4
  import { Construct } from 'phecda-core';
5
- import { F as Factory } from './core-CYwEPfN4.js';
6
- import { P as PickFunc } from './meta-BXKLFTgG.js';
5
+ import { F as Factory } from './core-C1kHRqU9.js';
6
+ import { P as PickFunc } from './meta-D1M85Hef.js';
7
7
 
8
8
  declare function TestFactory<T extends Construct[]>(...Modules: T): Promise<{
9
9
  get<C extends T[number]>(Model: C): InstanceType<C>;
package/dist/test.js CHANGED
@@ -1,14 +1,14 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } }
2
2
 
3
- var _chunk7YQ57BQSjs = require('./chunk-7YQ57BQS.js');
3
+ var _chunkPKSWGQLWjs = require('./chunk-PKSWGQLW.js');
4
4
 
5
5
 
6
- var _chunkJ5CFUN4Vjs = require('./chunk-J5CFUN4V.js');
6
+ var _chunkRQSQRZL4js = require('./chunk-RQSQRZL4.js');
7
7
 
8
8
  // src/test.ts
9
9
  var _phecdacore = require('phecda-core');
10
10
  async function TestFactory(...Modules) {
11
- const { moduleMap, modelMap } = await _chunk7YQ57BQSjs.Factory.call(void 0, Modules);
11
+ const { moduleMap, modelMap } = await _chunkPKSWGQLWjs.Factory.call(void 0, Modules);
12
12
  return {
13
13
  get(Model) {
14
14
  const tag = _phecdacore.getTag.call(void 0, Model);
@@ -19,7 +19,7 @@ async function TestFactory(...Modules) {
19
19
  }
20
20
  };
21
21
  }
22
- _chunkJ5CFUN4Vjs.__name.call(void 0, TestFactory, "TestFactory");
22
+ _chunkRQSQRZL4js.__name.call(void 0, TestFactory, "TestFactory");
23
23
  async function TestHttp(app, { moduleMap, meta }, isAgent = true) {
24
24
  const { default: request, agent } = await Promise.resolve().then(() => _interopRequireWildcard(require("supertest")));
25
25
  const Agent = agent(app);
@@ -59,11 +59,11 @@ async function TestHttp(app, { moduleMap, meta }, isAgent = true) {
59
59
  }
60
60
  });
61
61
  }
62
- _chunkJ5CFUN4Vjs.__name.call(void 0, module, "module");
62
+ _chunkRQSQRZL4js.__name.call(void 0, module, "module");
63
63
  Agent.module = module;
64
64
  return Agent;
65
65
  }
66
- _chunkJ5CFUN4Vjs.__name.call(void 0, TestHttp, "TestHttp");
66
+ _chunkRQSQRZL4js.__name.call(void 0, TestHttp, "TestHttp");
67
67
 
68
68
 
69
69
 
package/dist/test.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  Factory
3
- } from "./chunk-XYVMNY2X.mjs";
3
+ } from "./chunk-A53KNKY4.mjs";
4
4
  import {
5
5
  __name
6
- } from "./chunk-WHJ5FALK.mjs";
6
+ } from "./chunk-QD3QR3NW.mjs";
7
7
 
8
8
  // src/test.ts
9
9
  import { getTag } from "phecda-core";
@@ -1,4 +1,4 @@
1
- import { D as DefaultOptions, B as BaseContext } from './meta-BXKLFTgG.mjs';
1
+ import { D as DefaultOptions, B as BaseContext } from './meta-D1M85Hef.js';
2
2
 
3
3
  interface RpcServerOptions extends DefaultOptions {
4
4
  defaultQueue?: string;
@@ -13,6 +13,7 @@ interface RpcContext extends BaseContext {
13
13
  id: string;
14
14
  queue: string;
15
15
  isEvent?: boolean;
16
+ category: 'rpc';
16
17
  }
17
18
 
18
19
  export type { RpcContext as R, RpcServerOptions as a, RpcClientOptions as b };
@@ -1,4 +1,4 @@
1
- import { D as DefaultOptions, B as BaseContext } from './meta-BXKLFTgG.js';
1
+ import { D as DefaultOptions, B as BaseContext } from './meta-D1M85Hef.mjs';
2
2
 
3
3
  interface RpcServerOptions extends DefaultOptions {
4
4
  defaultQueue?: string;
@@ -13,6 +13,7 @@ interface RpcContext extends BaseContext {
13
13
  id: string;
14
14
  queue: string;
15
15
  isEvent?: boolean;
16
+ category: 'rpc';
16
17
  }
17
18
 
18
19
  export type { RpcContext as R, RpcServerOptions as a, RpcClientOptions as b };
@@ -1,5 +1,5 @@
1
1
  import { IncomingHttpHeaders, IncomingMessage, ServerResponse } from 'node:http';
2
- import { D as DefaultOptions, B as BaseContext } from './meta-BXKLFTgG.mjs';
2
+ import { D as DefaultOptions, B as BaseContext } from './meta-D1M85Hef.js';
3
3
 
4
4
  interface HttpOptions extends DefaultOptions {
5
5
  /**
@@ -22,6 +22,7 @@ interface HttpContext extends BaseContext {
22
22
  params: Record<string, string>;
23
23
  body: Record<string, any>;
24
24
  headers: IncomingHttpHeaders;
25
+ category: 'http';
25
26
  redirect: (url: string, status?: number) => void;
26
27
  getCookie(key: string): string | undefined;
27
28
  setCookie(key: string, value: string, opts?: CookieSerializeOptions): void;
@@ -1,5 +1,5 @@
1
1
  import { IncomingHttpHeaders, IncomingMessage, ServerResponse } from 'node:http';
2
- import { D as DefaultOptions, B as BaseContext } from './meta-BXKLFTgG.js';
2
+ import { D as DefaultOptions, B as BaseContext } from './meta-D1M85Hef.mjs';
3
3
 
4
4
  interface HttpOptions extends DefaultOptions {
5
5
  /**
@@ -22,6 +22,7 @@ interface HttpContext extends BaseContext {
22
22
  params: Record<string, string>;
23
23
  body: Record<string, any>;
24
24
  headers: IncomingHttpHeaders;
25
+ category: 'http';
25
26
  redirect: (url: string, status?: number) => void;
26
27
  getCookie(key: string): string | undefined;
27
28
  setCookie(key: string, value: string, opts?: CookieSerializeOptions): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "phecda-server",
3
- "version": "7.0.0-alpha.1",
3
+ "version": "7.0.0-alpha.3",
4
4
  "description": "server framework that provide IOC/type-reuse/http&rpc-adaptor",
5
5
  "author": "fgsreally",
6
6
  "license": "MIT",
@@ -40,7 +40,7 @@ if (isLowVersion)
40
40
 
41
41
  let config
42
42
 
43
- const workdir = process.env.PS_WORKDIR || process.cwd()
43
+ const workdir = process.cwd()
44
44
 
45
45
  const configPath = resolvePath(
46
46
  workdir,
@@ -357,7 +357,7 @@ export function isModuleFileUrl(url) {
357
357
  'addon',
358
358
  'filter',
359
359
  'pipe',
360
- 'edge',
360
+ 'solo',
361
361
  ].includes(midName)
362
362
  )
363
363
  return true