phecda-server 5.0.0 → 5.0.2
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.
- package/bin/schema.json +7 -0
- package/dist/{chunk-5VMFQOJ7.mjs → chunk-AB4OX3WV.mjs} +13 -5
- package/dist/{chunk-VMXI3KFJ.js → chunk-BXLBWRHS.js} +12 -12
- package/dist/{chunk-C7MN5B36.mjs → chunk-W5EOVGQD.mjs} +1 -1
- package/dist/{chunk-5YYZLGGN.js → chunk-YERBWZCS.js} +13 -5
- package/dist/{core-eb646fe5.d.ts → core-fd134ffa.d.ts} +6 -15
- package/dist/helper-73e8d2f0.d.ts +18 -0
- package/dist/helper-f29f082f.d.ts +19 -0
- package/dist/index.d.ts +7 -7
- package/dist/index.js +23 -23
- package/dist/index.mjs +2 -2
- package/dist/rpc/bullmq/index.d.ts +2 -3
- package/dist/rpc/bullmq/index.js +14 -17
- package/dist/rpc/bullmq/index.mjs +9 -12
- package/dist/rpc/kafka/index.d.ts +2 -3
- package/dist/rpc/kafka/index.js +14 -17
- package/dist/rpc/kafka/index.mjs +9 -12
- package/dist/rpc/nats/index.d.ts +2 -3
- package/dist/rpc/nats/index.js +13 -16
- package/dist/rpc/nats/index.mjs +9 -12
- package/dist/rpc/rabbitmq/index.d.ts +2 -3
- package/dist/rpc/rabbitmq/index.js +14 -17
- package/dist/rpc/rabbitmq/index.mjs +9 -12
- package/dist/rpc/redis/index.d.ts +2 -3
- package/dist/rpc/redis/index.js +14 -17
- package/dist/rpc/redis/index.mjs +9 -12
- package/dist/server/elysia/index.d.ts +4 -4
- package/dist/server/elysia/index.js +30 -30
- package/dist/server/elysia/index.mjs +17 -17
- package/dist/server/express/index.d.ts +4 -4
- package/dist/server/express/index.js +28 -28
- package/dist/server/express/index.mjs +16 -16
- package/dist/server/fastify/index.d.ts +4 -4
- package/dist/server/fastify/index.js +30 -30
- package/dist/server/fastify/index.mjs +17 -17
- package/dist/server/h3/index.d.ts +5 -10
- package/dist/server/h3/index.js +28 -28
- package/dist/server/h3/index.mjs +16 -16
- package/dist/server/hono/index.d.ts +4 -4
- package/dist/server/hono/index.js +28 -28
- package/dist/server/hono/index.mjs +16 -16
- package/dist/server/hyper-express/index.d.ts +4 -4
- package/dist/server/hyper-express/index.js +28 -28
- package/dist/server/hyper-express/index.mjs +16 -16
- package/dist/server/koa/index.d.ts +4 -4
- package/dist/server/koa/index.js +28 -28
- package/dist/server/koa/index.mjs +16 -16
- package/dist/test.d.ts +1 -2
- package/dist/test.js +8 -1
- package/dist/test.mjs +8 -1
- package/package.json +2 -2
- package/register/loader.mjs +36 -8
- package/dist/helper-88b19c66.d.ts +0 -12
- package/dist/helper-9e206c66.d.ts +0 -12
package/bin/schema.json
CHANGED
|
@@ -38,6 +38,13 @@
|
|
|
38
38
|
},
|
|
39
39
|
"description": "Including the module's file middle name, such as controller mapping to xx.controller.ts"
|
|
40
40
|
},
|
|
41
|
+
"virtualFile": {
|
|
42
|
+
"type": "object",
|
|
43
|
+
"additionalProperties": {
|
|
44
|
+
"type": "string"
|
|
45
|
+
},
|
|
46
|
+
"description": "Virtual module, just like in Vite."
|
|
47
|
+
},
|
|
41
48
|
"unimport": {
|
|
42
49
|
"type": "object",
|
|
43
50
|
"description": "Includes the arguments passed to unimport and 'dtsPath' that specifies the location for generating type files."
|
|
@@ -283,19 +283,27 @@ var _Context = class {
|
|
|
283
283
|
if (IS_HMR)
|
|
284
284
|
data._context = this;
|
|
285
285
|
}
|
|
286
|
-
async run(successCb, failCb) {
|
|
286
|
+
async run(opts, successCb, failCb) {
|
|
287
287
|
const { meta, moduleMap } = this.data;
|
|
288
|
+
const { globalGuards = [], globalFilter, globalInterceptors = [], globalPipe } = opts;
|
|
288
289
|
const { paramsType, data: { guards, interceptors, params, tag, func, ctx, filter } } = meta;
|
|
289
290
|
try {
|
|
290
|
-
await this.useGuard(
|
|
291
|
-
|
|
291
|
+
await this.useGuard([
|
|
292
|
+
...globalGuards,
|
|
293
|
+
...guards
|
|
294
|
+
]);
|
|
295
|
+
const i1 = await this.useInterceptor([
|
|
296
|
+
...globalInterceptors,
|
|
297
|
+
...interceptors
|
|
298
|
+
]);
|
|
292
299
|
if (i1 !== void 0)
|
|
293
300
|
return successCb(i1);
|
|
294
301
|
const args = await this.usePipe(params.map((param) => {
|
|
295
302
|
return {
|
|
296
303
|
arg: resolveDep(this.data[param.type], param.key),
|
|
297
304
|
reflect: paramsType[param.index],
|
|
298
|
-
...param
|
|
305
|
+
...param,
|
|
306
|
+
pipe: param.pipe || globalPipe
|
|
299
307
|
};
|
|
300
308
|
}));
|
|
301
309
|
const instance = moduleMap.get(tag);
|
|
@@ -307,7 +315,7 @@ var _Context = class {
|
|
|
307
315
|
return successCb(i2);
|
|
308
316
|
return successCb(returnData);
|
|
309
317
|
} catch (e) {
|
|
310
|
-
const err = await this.useFilter(e, filter);
|
|
318
|
+
const err = await this.useFilter(e, filter || globalFilter);
|
|
311
319
|
return failCb(err);
|
|
312
320
|
}
|
|
313
321
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
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
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunkYERBWZCSjs = require('./chunk-YERBWZCS.js');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
var _chunkYR5Q5F2Kjs = require('./chunk-YR5Q5F2K.js');
|
|
@@ -16,7 +16,7 @@ function BaseParam(data) {
|
|
|
16
16
|
if (!state.params)
|
|
17
17
|
state.params = [
|
|
18
18
|
..._optionalChain([_phecdacore.getState.call(void 0, target, k), 'optionalAccess', _ => _.params]) || []
|
|
19
|
-
].map(
|
|
19
|
+
].map(_chunkYERBWZCSjs.shallowClone);
|
|
20
20
|
const existItem = state.params.find((item) => item.index === index);
|
|
21
21
|
if (existItem)
|
|
22
22
|
Object.assign(existItem, data);
|
|
@@ -139,7 +139,7 @@ _chunkYR5Q5F2Kjs.__name.call(void 0, Pipe, "Pipe");
|
|
|
139
139
|
function Route(route, type) {
|
|
140
140
|
return (target, k) => {
|
|
141
141
|
_phecdacore.setPropertyState.call(void 0, target, k, (state) => {
|
|
142
|
-
state.http =
|
|
142
|
+
state.http = _chunkYERBWZCSjs.mergeObject.call(void 0, state.http || _optionalChain([_phecdacore.getState.call(void 0, target, k), 'optionalAccess', _5 => _5.http]), {
|
|
143
143
|
route,
|
|
144
144
|
type
|
|
145
145
|
});
|
|
@@ -151,9 +151,9 @@ function Header(headers) {
|
|
|
151
151
|
return (target, k) => {
|
|
152
152
|
_phecdacore.setPropertyState.call(void 0, target, k, (state) => {
|
|
153
153
|
if (!state.http)
|
|
154
|
-
state.http =
|
|
155
|
-
state.http =
|
|
156
|
-
headers:
|
|
154
|
+
state.http = _chunkYERBWZCSjs.mergeObject.call(void 0, _optionalChain([_phecdacore.getState.call(void 0, target, k), 'optionalAccess', _6 => _6.http]));
|
|
155
|
+
state.http = _chunkYERBWZCSjs.mergeObject.call(void 0, state.http, {
|
|
156
|
+
headers: _chunkYERBWZCSjs.mergeObject.call(void 0, _optionalChain([state, 'access', _7 => _7.http, 'optionalAccess', _8 => _8.headers]), headers)
|
|
157
157
|
});
|
|
158
158
|
});
|
|
159
159
|
};
|
|
@@ -183,7 +183,7 @@ function Controller(prefix = "") {
|
|
|
183
183
|
return (target) => {
|
|
184
184
|
_phecdacore.setPropertyState.call(void 0, target, void 0, (state) => {
|
|
185
185
|
state.controller = "http";
|
|
186
|
-
state.http =
|
|
186
|
+
state.http = _chunkYERBWZCSjs.mergeObject.call(void 0, state.http || _optionalChain([_phecdacore.getState.call(void 0, target), 'optionalAccess', _9 => _9.http]), {
|
|
187
187
|
prefix
|
|
188
188
|
});
|
|
189
189
|
});
|
|
@@ -196,7 +196,7 @@ _chunkYR5Q5F2Kjs.__name.call(void 0, Controller, "Controller");
|
|
|
196
196
|
function Event(isEvent = true) {
|
|
197
197
|
return (target, k) => {
|
|
198
198
|
_phecdacore.setPropertyState.call(void 0, target, k, (state) => {
|
|
199
|
-
state.rpc =
|
|
199
|
+
state.rpc = _chunkYERBWZCSjs.mergeObject.call(void 0, state.rpc || _optionalChain([_phecdacore.getState.call(void 0, target, k), 'optionalAccess', _10 => _10.rpc]), {
|
|
200
200
|
isEvent
|
|
201
201
|
});
|
|
202
202
|
});
|
|
@@ -206,7 +206,7 @@ _chunkYR5Q5F2Kjs.__name.call(void 0, Event, "Event");
|
|
|
206
206
|
function Queue(queue = "") {
|
|
207
207
|
return (target, k) => {
|
|
208
208
|
_phecdacore.setPropertyState.call(void 0, target, k, (state) => {
|
|
209
|
-
state.rpc =
|
|
209
|
+
state.rpc = _chunkYERBWZCSjs.mergeObject.call(void 0, state.rpc || _optionalChain([_phecdacore.getState.call(void 0, target, k), 'optionalAccess', _11 => _11.rpc]), {
|
|
210
210
|
queue
|
|
211
211
|
});
|
|
212
212
|
});
|
|
@@ -239,10 +239,10 @@ function Define(key, value) {
|
|
|
239
239
|
if (!state.params)
|
|
240
240
|
state.params = [
|
|
241
241
|
...parentState
|
|
242
|
-
].map(
|
|
242
|
+
].map(_chunkYERBWZCSjs.shallowClone);
|
|
243
243
|
const existItem = state.params.find((item) => item.index === index);
|
|
244
244
|
if (existItem)
|
|
245
|
-
existItem.define =
|
|
245
|
+
existItem.define = _chunkYERBWZCSjs.mergeObject.call(void 0, existItem.define, {
|
|
246
246
|
[key]: value
|
|
247
247
|
});
|
|
248
248
|
else
|
|
@@ -258,7 +258,7 @@ function Define(key, value) {
|
|
|
258
258
|
_phecdacore.setPropertyState.call(void 0, target, k, (state) => {
|
|
259
259
|
const parentState = _optionalChain([_phecdacore.getState.call(void 0, target, k), 'optionalAccess', _13 => _13.define]);
|
|
260
260
|
if (!state.define)
|
|
261
|
-
state.define =
|
|
261
|
+
state.define = _chunkYERBWZCSjs.mergeObject.call(void 0, parentState);
|
|
262
262
|
state.define[key] = value;
|
|
263
263
|
});
|
|
264
264
|
};
|
|
@@ -283,19 +283,27 @@ var _Context = class {
|
|
|
283
283
|
if (_chunkYR5Q5F2Kjs.IS_HMR)
|
|
284
284
|
data._context = this;
|
|
285
285
|
}
|
|
286
|
-
async run(successCb, failCb) {
|
|
286
|
+
async run(opts, successCb, failCb) {
|
|
287
287
|
const { meta, moduleMap } = this.data;
|
|
288
|
+
const { globalGuards = [], globalFilter, globalInterceptors = [], globalPipe } = opts;
|
|
288
289
|
const { paramsType, data: { guards, interceptors, params, tag, func, ctx, filter } } = meta;
|
|
289
290
|
try {
|
|
290
|
-
await this.useGuard(
|
|
291
|
-
|
|
291
|
+
await this.useGuard([
|
|
292
|
+
...globalGuards,
|
|
293
|
+
...guards
|
|
294
|
+
]);
|
|
295
|
+
const i1 = await this.useInterceptor([
|
|
296
|
+
...globalInterceptors,
|
|
297
|
+
...interceptors
|
|
298
|
+
]);
|
|
292
299
|
if (i1 !== void 0)
|
|
293
300
|
return successCb(i1);
|
|
294
301
|
const args = await this.usePipe(params.map((param) => {
|
|
295
302
|
return {
|
|
296
303
|
arg: resolveDep(this.data[param.type], param.key),
|
|
297
304
|
reflect: paramsType[param.index],
|
|
298
|
-
...param
|
|
305
|
+
...param,
|
|
306
|
+
pipe: param.pipe || globalPipe
|
|
299
307
|
};
|
|
300
308
|
}));
|
|
301
309
|
const instance = moduleMap.get(tag);
|
|
@@ -307,7 +315,7 @@ var _Context = class {
|
|
|
307
315
|
return successCb(i2);
|
|
308
316
|
return successCb(returnData);
|
|
309
317
|
} catch (e) {
|
|
310
|
-
const err = await this.useFilter(e, filter);
|
|
318
|
+
const err = await this.useFilter(e, filter || globalFilter);
|
|
311
319
|
return failCb(err);
|
|
312
320
|
}
|
|
313
321
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Events, Construct } from 'phecda-core';
|
|
2
|
-
import { IncomingHttpHeaders } from 'http';
|
|
3
2
|
|
|
4
3
|
interface ServiceMetaData {
|
|
5
4
|
func: string;
|
|
@@ -84,19 +83,11 @@ interface BaseContext {
|
|
|
84
83
|
func: string;
|
|
85
84
|
[key: string]: any;
|
|
86
85
|
}
|
|
87
|
-
interface
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
body: Record<string, any>;
|
|
93
|
-
headers: IncomingHttpHeaders;
|
|
94
|
-
}
|
|
95
|
-
interface RpcContext extends BaseContext {
|
|
96
|
-
args: any[];
|
|
97
|
-
id: string;
|
|
98
|
-
queue: string;
|
|
99
|
-
isEvent?: boolean;
|
|
86
|
+
interface DefaultOptions {
|
|
87
|
+
globalGuards?: string[];
|
|
88
|
+
globalInterceptors?: string[];
|
|
89
|
+
globalFilter?: string;
|
|
90
|
+
globalPipe?: string;
|
|
100
91
|
}
|
|
101
92
|
interface BaseError {
|
|
102
93
|
[ERROR_SYMBOL]: true;
|
|
@@ -136,4 +127,4 @@ declare function Factory(models: (new (...args: any) => any)[], opts?: {
|
|
|
136
127
|
destroy: () => Promise<void>;
|
|
137
128
|
}>;
|
|
138
129
|
|
|
139
|
-
export { BaseContext as B, ControllerMetaData as C, Emitter as E, Factory as F, Generator as G,
|
|
130
|
+
export { BaseContext as B, ControllerMetaData as C, DefaultOptions as D, Emitter as E, Factory as F, Generator as G, IS_HMR as I, LOG_LEVEL as L, Meta as M, OmitFunction as O, PickFunc as P, ServiceMetaData as S, ToClientMap as T, UNMOUNT_SYMBOL as U, MetaData as a, BaseError as b, ToClientInstance as c, ToClientFn as d, BaseReturn as e, BaseRequestType as f, CustomResponse as g, ExtractResponse as h, emitter as i, ControllerMeta as j, ERROR_SYMBOL as k, IS_ONLY_GENERATE as l, IS_STRICT as m, PS_EXIT_CODE as n };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { D as DefaultOptions, B as BaseContext } from './core-fd134ffa.js';
|
|
2
|
+
|
|
3
|
+
declare function genClientQueue(key?: string): string;
|
|
4
|
+
interface RpcServerOptions extends DefaultOptions {
|
|
5
|
+
}
|
|
6
|
+
interface RpcClientOptions {
|
|
7
|
+
key?: string;
|
|
8
|
+
timeout?: number;
|
|
9
|
+
max?: number;
|
|
10
|
+
}
|
|
11
|
+
interface RpcContext extends BaseContext {
|
|
12
|
+
args: any[];
|
|
13
|
+
id: string;
|
|
14
|
+
queue: string;
|
|
15
|
+
isEvent?: boolean;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { RpcServerOptions as R, RpcClientOptions as a, RpcContext as b, genClientQueue as g };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { IncomingHttpHeaders } from 'node:http';
|
|
2
|
+
import { D as DefaultOptions, B as BaseContext, C as ControllerMetaData } from './core-fd134ffa.js';
|
|
3
|
+
|
|
4
|
+
declare function resolveDep(ret: any, key: string): any;
|
|
5
|
+
interface HttpOptions extends DefaultOptions {
|
|
6
|
+
route?: string;
|
|
7
|
+
plugins?: string[];
|
|
8
|
+
}
|
|
9
|
+
interface HttpContext extends BaseContext {
|
|
10
|
+
parallel?: true;
|
|
11
|
+
index?: number;
|
|
12
|
+
query: Record<string, any>;
|
|
13
|
+
params: Record<string, string>;
|
|
14
|
+
body: Record<string, any>;
|
|
15
|
+
headers: IncomingHttpHeaders;
|
|
16
|
+
}
|
|
17
|
+
declare function argToReq(params: ControllerMetaData['params'], args: any[], headers: Record<string, any>): any;
|
|
18
|
+
|
|
19
|
+
export { HttpOptions as H, HttpContext as a, argToReq as b, resolveDep as r };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { B as BaseContext, M as Meta, G as Generator, C as ControllerMetaData, a as MetaData, U as UNMOUNT_SYMBOL, b as BaseError } from './core-
|
|
2
|
-
export { f as BaseRequestType, e as BaseReturn, j as ControllerMeta, g as CustomResponse, k as ERROR_SYMBOL, E as Emitter, h as ExtractResponse, F as Factory,
|
|
1
|
+
import { B as BaseContext, D as DefaultOptions, M as Meta, G as Generator, C as ControllerMetaData, a as MetaData, U as UNMOUNT_SYMBOL, b as BaseError } from './core-fd134ffa.js';
|
|
2
|
+
export { f as BaseRequestType, e as BaseReturn, j as ControllerMeta, g as CustomResponse, k as ERROR_SYMBOL, E as Emitter, h as ExtractResponse, F as Factory, I as IS_HMR, l as IS_ONLY_GENERATE, m as IS_STRICT, L as LOG_LEVEL, O as OmitFunction, n as PS_EXIT_CODE, P as PickFunc, S as ServiceMetaData, d as ToClientFn, c as ToClientInstance, T as ToClientMap, i as emitter } from './core-fd134ffa.js';
|
|
3
3
|
import { Construct, AbConstruct } from 'phecda-core';
|
|
4
4
|
export * from 'phecda-core';
|
|
5
|
-
export {
|
|
6
|
-
export { a as RpcClientOptions, R as RpcServerOptions, g as genClientQueue } from './helper-
|
|
7
|
-
import 'http';
|
|
5
|
+
export { a as HttpContext, H as HttpOptions, b as argToReq, r as resolveDep } from './helper-f29f082f.js';
|
|
6
|
+
export { a as RpcClientOptions, b as RpcContext, R as RpcServerOptions, g as genClientQueue } from './helper-73e8d2f0.js';
|
|
7
|
+
import 'node:http';
|
|
8
8
|
|
|
9
9
|
declare class Histroy {
|
|
10
10
|
guard: string[];
|
|
@@ -114,7 +114,7 @@ declare class Context<Data extends BaseContext> {
|
|
|
114
114
|
static pluginRecord: Record<PropertyKey, any>;
|
|
115
115
|
private postInterceptors;
|
|
116
116
|
constructor(data: Data);
|
|
117
|
-
run<ReturnData = any, ReturnErr = any>(successCb: (data: any) => ReturnData, failCb: (err: any) => ReturnErr): Promise<ReturnData | ReturnErr>;
|
|
117
|
+
run<ReturnData = any, ReturnErr = any>(opts: DefaultOptions, successCb: (data: any) => ReturnData, failCb: (err: any) => ReturnErr): Promise<ReturnData | ReturnErr>;
|
|
118
118
|
private usePipe;
|
|
119
119
|
private useFilter;
|
|
120
120
|
private useGuard;
|
|
@@ -265,4 +265,4 @@ declare function shallowClone(obj: any): any;
|
|
|
265
265
|
declare function mergeObject(...args: any[]): any;
|
|
266
266
|
declare function mergeArray(...args: any[]): any[];
|
|
267
267
|
|
|
268
|
-
export { Arg, BadGatewayException, BadRequestException, BaseContext, BaseError, BaseParam, Body, ConflictException, Context, Controller, ControllerMetaData, Ctx, Define, Delete, Dev, Event, Exception, Filter, FilterType, ForbiddenException, FrameworkException, Generator, Get, Guard, GuardType, HMR, HTTPGenerator, Head, Header, Injectable, Interceptor, InterceptorType, InvalidInputException, Meta, MetaData, Mix, NotFoundException, PExtension, PFilter, PGuard, PInterceptor, PPipe, PPlugin, Param, Patch, PayloadLargeException, Pipe, PipeArg, PipeType, Plugin, Post, Put, Query, Queue, RPCGenerator, Route, Rpc, ServiceUnavailableException, TimeoutException, TimerException, UNMOUNT_SYMBOL, UnauthorizedException, UndefinedException, UnsupportedMediaTypeException, ValidateException, WorkerException, addFilter, addGuard, addInterceptor, addPipe, addPlugin, defaultPipe, detectAopDep, getConfig, log, mergeArray, mergeObject, setConfig, shallowClone };
|
|
268
|
+
export { Arg, BadGatewayException, BadRequestException, BaseContext, BaseError, BaseParam, Body, ConflictException, Context, Controller, ControllerMetaData, Ctx, DefaultOptions, Define, Delete, Dev, Event, Exception, Filter, FilterType, ForbiddenException, FrameworkException, Generator, Get, Guard, GuardType, HMR, HTTPGenerator, Head, Header, Injectable, Interceptor, InterceptorType, InvalidInputException, Meta, MetaData, Mix, NotFoundException, PExtension, PFilter, PGuard, PInterceptor, PPipe, PPlugin, Param, Patch, PayloadLargeException, Pipe, PipeArg, PipeType, Plugin, Post, Put, Query, Queue, RPCGenerator, Route, Rpc, ServiceUnavailableException, TimeoutException, TimerException, UNMOUNT_SYMBOL, UnauthorizedException, UndefinedException, UnsupportedMediaTypeException, ValidateException, WorkerException, addFilter, addGuard, addInterceptor, addPipe, addPlugin, defaultPipe, detectAopDep, getConfig, log, mergeArray, mergeObject, setConfig, shallowClone };
|
package/dist/index.js
CHANGED
|
@@ -29,7 +29,7 @@ var _chunkF5YWXY5Wjs = require('./chunk-F5YWXY5W.js');
|
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
var
|
|
32
|
+
var _chunkBXLBWRHSjs = require('./chunk-BXLBWRHS.js');
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
|
|
@@ -63,7 +63,7 @@ var _chunkVMXI3KFJjs = require('./chunk-VMXI3KFJ.js');
|
|
|
63
63
|
|
|
64
64
|
|
|
65
65
|
|
|
66
|
-
var
|
|
66
|
+
var _chunkYERBWZCSjs = require('./chunk-YERBWZCS.js');
|
|
67
67
|
|
|
68
68
|
|
|
69
69
|
|
|
@@ -129,9 +129,9 @@ var PFilter = class extends Dev {
|
|
|
129
129
|
constructor(tag) {
|
|
130
130
|
super();
|
|
131
131
|
this.key = tag || _phecdacore.getTag.call(void 0, this);
|
|
132
|
-
|
|
132
|
+
_chunkYERBWZCSjs.addFilter.call(void 0, this.key, this.use.bind(this));
|
|
133
133
|
this.onUnmount(() => {
|
|
134
|
-
delete
|
|
134
|
+
delete _chunkYERBWZCSjs.Context.filterRecord[this.key];
|
|
135
135
|
});
|
|
136
136
|
}
|
|
137
137
|
};
|
|
@@ -144,9 +144,9 @@ var PGuard = class extends Dev {
|
|
|
144
144
|
constructor(tag) {
|
|
145
145
|
super();
|
|
146
146
|
this.key = tag || _phecdacore.getTag.call(void 0, this);
|
|
147
|
-
|
|
147
|
+
_chunkYERBWZCSjs.addGuard.call(void 0, this.key, this.use.bind(this));
|
|
148
148
|
this.onUnmount(() => {
|
|
149
|
-
delete
|
|
149
|
+
delete _chunkYERBWZCSjs.Context.guardRecord[this.key];
|
|
150
150
|
});
|
|
151
151
|
}
|
|
152
152
|
};
|
|
@@ -160,9 +160,9 @@ var PInterceptor = class extends Dev {
|
|
|
160
160
|
super();
|
|
161
161
|
this.key = tag || _phecdacore.getTag.call(void 0, this);
|
|
162
162
|
this.onUnmount(() => {
|
|
163
|
-
delete
|
|
163
|
+
delete _chunkYERBWZCSjs.Context.interceptorRecord[this.key];
|
|
164
164
|
});
|
|
165
|
-
|
|
165
|
+
_chunkYERBWZCSjs.addInterceptor.call(void 0, this.key, this.use.bind(this));
|
|
166
166
|
}
|
|
167
167
|
};
|
|
168
168
|
_chunkYR5Q5F2Kjs.__name.call(void 0, PInterceptor, "PInterceptor");
|
|
@@ -174,9 +174,9 @@ var PPipe = class extends Dev {
|
|
|
174
174
|
constructor(tag) {
|
|
175
175
|
super();
|
|
176
176
|
this.key = tag || _phecdacore.getTag.call(void 0, this);
|
|
177
|
-
|
|
177
|
+
_chunkYERBWZCSjs.addPipe.call(void 0, this.key, this.use.bind(this));
|
|
178
178
|
this.onUnmount(() => {
|
|
179
|
-
delete
|
|
179
|
+
delete _chunkYERBWZCSjs.Context.pipeRecord[this.key];
|
|
180
180
|
});
|
|
181
181
|
}
|
|
182
182
|
};
|
|
@@ -189,9 +189,9 @@ var PPlugin = class extends Dev {
|
|
|
189
189
|
constructor(tag) {
|
|
190
190
|
super();
|
|
191
191
|
this.key = tag || _phecdacore.getTag.call(void 0, this);
|
|
192
|
-
|
|
192
|
+
_chunkYERBWZCSjs.addPlugin.call(void 0, this.key, this.use.bind(this));
|
|
193
193
|
this.onUnmount(() => {
|
|
194
|
-
delete
|
|
194
|
+
delete _chunkYERBWZCSjs.Context.pluginRecord[this.key];
|
|
195
195
|
});
|
|
196
196
|
}
|
|
197
197
|
};
|
|
@@ -205,33 +205,33 @@ var PExtension = class extends Dev {
|
|
|
205
205
|
super();
|
|
206
206
|
const key = this.key = tag || _phecdacore.getTag.call(void 0, this);
|
|
207
207
|
if (this.pipe) {
|
|
208
|
-
|
|
208
|
+
_chunkYERBWZCSjs.addPipe.call(void 0, key, this.pipe.bind(this));
|
|
209
209
|
this.onUnmount(() => {
|
|
210
|
-
delete
|
|
210
|
+
delete _chunkYERBWZCSjs.Context.pipeRecord[key];
|
|
211
211
|
});
|
|
212
212
|
}
|
|
213
213
|
if (this.plugin) {
|
|
214
|
-
|
|
214
|
+
_chunkYERBWZCSjs.addPlugin.call(void 0, key, this.plugin.bind(this));
|
|
215
215
|
this.onUnmount(() => {
|
|
216
|
-
delete
|
|
216
|
+
delete _chunkYERBWZCSjs.Context.pluginRecord[key];
|
|
217
217
|
});
|
|
218
218
|
}
|
|
219
219
|
if (this.intercept) {
|
|
220
|
-
|
|
220
|
+
_chunkYERBWZCSjs.addInterceptor.call(void 0, key, this.intercept.bind(this));
|
|
221
221
|
this.onUnmount(() => {
|
|
222
|
-
delete
|
|
222
|
+
delete _chunkYERBWZCSjs.Context.interceptorRecord[key];
|
|
223
223
|
});
|
|
224
224
|
}
|
|
225
225
|
if (this.guard) {
|
|
226
|
-
|
|
226
|
+
_chunkYERBWZCSjs.addGuard.call(void 0, key, this.guard.bind(this));
|
|
227
227
|
this.onUnmount(() => {
|
|
228
|
-
delete
|
|
228
|
+
delete _chunkYERBWZCSjs.Context.guardRecord[key];
|
|
229
229
|
});
|
|
230
230
|
}
|
|
231
231
|
if (this.filter) {
|
|
232
|
-
|
|
232
|
+
_chunkYERBWZCSjs.addFilter.call(void 0, key, this.filter.bind(this));
|
|
233
233
|
this.onUnmount(() => {
|
|
234
|
-
delete
|
|
234
|
+
delete _chunkYERBWZCSjs.Context.filterRecord[key];
|
|
235
235
|
});
|
|
236
236
|
}
|
|
237
237
|
}
|
|
@@ -415,4 +415,4 @@ _chunkYR5Q5F2Kjs.__name.call(void 0, HTTPGenerator, "HTTPGenerator");
|
|
|
415
415
|
|
|
416
416
|
|
|
417
417
|
|
|
418
|
-
exports.Arg =
|
|
418
|
+
exports.Arg = _chunkBXLBWRHSjs.Arg; exports.BadGatewayException = _chunkYERBWZCSjs.BadGatewayException; exports.BadRequestException = _chunkYERBWZCSjs.BadRequestException; exports.BaseParam = _chunkBXLBWRHSjs.BaseParam; exports.Body = _chunkBXLBWRHSjs.Body; exports.ConflictException = _chunkYERBWZCSjs.ConflictException; exports.Context = _chunkYERBWZCSjs.Context; exports.Controller = _chunkBXLBWRHSjs.Controller; exports.Ctx = _chunkBXLBWRHSjs.Ctx; exports.CustomResponse = CustomResponse; exports.Define = _chunkBXLBWRHSjs.Define; exports.Delete = _chunkBXLBWRHSjs.Delete; exports.Dev = Dev; exports.ERROR_SYMBOL = _chunkYR5Q5F2Kjs.ERROR_SYMBOL; exports.Event = _chunkBXLBWRHSjs.Event; exports.Exception = _chunkYERBWZCSjs.Exception; exports.Factory = _chunkF5YWXY5Wjs.Factory; exports.Filter = _chunkBXLBWRHSjs.Filter; exports.ForbiddenException = _chunkYERBWZCSjs.ForbiddenException; exports.FrameworkException = _chunkYERBWZCSjs.FrameworkException; exports.Generator = Generator; exports.Get = _chunkBXLBWRHSjs.Get; exports.Guard = _chunkBXLBWRHSjs.Guard; exports.HMR = _chunkYERBWZCSjs.HMR; exports.HTTPGenerator = HTTPGenerator; exports.Head = _chunkBXLBWRHSjs.Head; exports.Header = _chunkBXLBWRHSjs.Header; exports.IS_HMR = _chunkYR5Q5F2Kjs.IS_HMR; exports.IS_ONLY_GENERATE = _chunkYR5Q5F2Kjs.IS_ONLY_GENERATE; exports.IS_STRICT = _chunkYR5Q5F2Kjs.IS_STRICT; exports.Injectable = _chunkBXLBWRHSjs.Injectable; exports.Interceptor = _chunkBXLBWRHSjs.Interceptor; exports.InvalidInputException = _chunkYERBWZCSjs.InvalidInputException; exports.LOG_LEVEL = _chunkYR5Q5F2Kjs.LOG_LEVEL; exports.Meta = _chunkF5YWXY5Wjs.Meta; exports.Mix = _chunkYR5Q5F2Kjs.Mix; exports.NotFoundException = _chunkYERBWZCSjs.NotFoundException; exports.PExtension = PExtension; exports.PFilter = PFilter; exports.PGuard = PGuard; exports.PInterceptor = PInterceptor; exports.PPipe = PPipe; exports.PPlugin = PPlugin; exports.PS_EXIT_CODE = _chunkYR5Q5F2Kjs.PS_EXIT_CODE; exports.Param = _chunkBXLBWRHSjs.Param; exports.Patch = _chunkBXLBWRHSjs.Patch; exports.PayloadLargeException = _chunkYERBWZCSjs.PayloadLargeException; exports.Pipe = _chunkBXLBWRHSjs.Pipe; exports.Plugin = _chunkBXLBWRHSjs.Plugin; exports.Post = _chunkBXLBWRHSjs.Post; exports.Put = _chunkBXLBWRHSjs.Put; exports.Query = _chunkBXLBWRHSjs.Query; exports.Queue = _chunkBXLBWRHSjs.Queue; exports.RPCGenerator = RPCGenerator; exports.Route = _chunkBXLBWRHSjs.Route; exports.Rpc = _chunkBXLBWRHSjs.Rpc; exports.ServiceUnavailableException = _chunkYERBWZCSjs.ServiceUnavailableException; exports.TimeoutException = _chunkYERBWZCSjs.TimeoutException; exports.TimerException = _chunkYERBWZCSjs.TimerException; exports.UNMOUNT_SYMBOL = _chunkYR5Q5F2Kjs.UNMOUNT_SYMBOL; exports.UnauthorizedException = _chunkYERBWZCSjs.UnauthorizedException; exports.UndefinedException = _chunkYERBWZCSjs.UndefinedException; exports.UnsupportedMediaTypeException = _chunkYERBWZCSjs.UnsupportedMediaTypeException; exports.ValidateException = _chunkYERBWZCSjs.ValidateException; exports.WorkerException = _chunkYERBWZCSjs.WorkerException; exports.addFilter = _chunkYERBWZCSjs.addFilter; exports.addGuard = _chunkYERBWZCSjs.addGuard; exports.addInterceptor = _chunkYERBWZCSjs.addInterceptor; exports.addPipe = _chunkYERBWZCSjs.addPipe; exports.addPlugin = _chunkYERBWZCSjs.addPlugin; exports.argToReq = _chunkYERBWZCSjs.argToReq; exports.defaultPipe = _chunkYERBWZCSjs.defaultPipe; exports.detectAopDep = _chunkYERBWZCSjs.detectAopDep; exports.emitter = _chunkF5YWXY5Wjs.emitter; exports.genClientQueue = _chunkYERBWZCSjs.genClientQueue; exports.getConfig = _chunkYR5Q5F2Kjs.getConfig; exports.log = _chunkYR5Q5F2Kjs.log; exports.mergeArray = _chunkYERBWZCSjs.mergeArray; exports.mergeObject = _chunkYERBWZCSjs.mergeObject; exports.resolveDep = _chunkYERBWZCSjs.resolveDep; exports.setConfig = _chunkYR5Q5F2Kjs.setConfig; exports.shallowClone = _chunkYERBWZCSjs.shallowClone;
|
package/dist/index.mjs
CHANGED
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
Queue,
|
|
30
30
|
Route,
|
|
31
31
|
Rpc
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-W5EOVGQD.mjs";
|
|
33
33
|
import {
|
|
34
34
|
BadGatewayException,
|
|
35
35
|
BadRequestException,
|
|
@@ -63,7 +63,7 @@ import {
|
|
|
63
63
|
mergeObject,
|
|
64
64
|
resolveDep,
|
|
65
65
|
shallowClone
|
|
66
|
-
} from "./chunk-
|
|
66
|
+
} from "./chunk-AB4OX3WV.mjs";
|
|
67
67
|
import {
|
|
68
68
|
ERROR_SYMBOL,
|
|
69
69
|
IS_HMR,
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { ConnectionOptions, Worker, Queue } from 'bullmq';
|
|
2
|
-
import {
|
|
3
|
-
import { R as RpcServerOptions, a as RpcClientOptions } from '../../helper-
|
|
2
|
+
import { F as Factory, T as ToClientMap } from '../../core-fd134ffa.js';
|
|
3
|
+
import { b as RpcContext, R as RpcServerOptions, a as RpcClientOptions } from '../../helper-73e8d2f0.js';
|
|
4
4
|
import 'phecda-core';
|
|
5
|
-
import 'http';
|
|
6
5
|
|
|
7
6
|
interface BullmqCtx extends RpcContext {
|
|
8
7
|
type: 'bullmq';
|
package/dist/rpc/bullmq/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkYERBWZCSjs = require('../../chunk-YERBWZCS.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
var _chunkYR5Q5F2Kjs = require('../../chunk-YR5Q5F2K.js');
|
|
@@ -12,8 +12,8 @@ var _chunkYR5Q5F2Kjs = require('../../chunk-YR5Q5F2K.js');
|
|
|
12
12
|
var _bullmq = require('bullmq');
|
|
13
13
|
var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
|
14
14
|
var debug = _debug2.default.call(void 0, "phecda-server/bullmq");
|
|
15
|
-
async function bind(connectOpts, { moduleMap, meta }, opts) {
|
|
16
|
-
const { globalGuards
|
|
15
|
+
async function bind(connectOpts, { moduleMap, meta }, opts = {}) {
|
|
16
|
+
const { globalGuards, globalInterceptors, globalFilter, globalPipe } = opts;
|
|
17
17
|
const metaMap = /* @__PURE__ */ new Map();
|
|
18
18
|
const workerMap = {};
|
|
19
19
|
const queueMap = {};
|
|
@@ -24,14 +24,6 @@ async function bind(connectOpts, { moduleMap, meta }, opts) {
|
|
|
24
24
|
const { tag, func, controller, rpc } = item.data;
|
|
25
25
|
if (controller !== "rpc" || _optionalChain([rpc, 'optionalAccess', _ => _.queue]) === void 0)
|
|
26
26
|
continue;
|
|
27
|
-
item.data.guards = [
|
|
28
|
-
...globalGuards,
|
|
29
|
-
...item.data.guards
|
|
30
|
-
];
|
|
31
|
-
item.data.interceptors = [
|
|
32
|
-
...globalInterceptors,
|
|
33
|
-
...item.data.interceptors
|
|
34
|
-
];
|
|
35
27
|
if (metaMap.has(tag))
|
|
36
28
|
metaMap.get(tag)[func] = item;
|
|
37
29
|
else
|
|
@@ -72,7 +64,7 @@ async function bind(connectOpts, { moduleMap, meta }, opts) {
|
|
|
72
64
|
queueMap[clientQueue] = new (0, _bullmq.Queue)(clientQueue, {
|
|
73
65
|
connection: connectOpts
|
|
74
66
|
});
|
|
75
|
-
const context = new (0,
|
|
67
|
+
const context = new (0, _chunkYERBWZCSjs.Context)({
|
|
76
68
|
type: "bullmq",
|
|
77
69
|
moduleMap,
|
|
78
70
|
meta: meta2,
|
|
@@ -84,7 +76,12 @@ async function bind(connectOpts, { moduleMap, meta }, opts) {
|
|
|
84
76
|
queue: job.queueName,
|
|
85
77
|
isEvent
|
|
86
78
|
});
|
|
87
|
-
await context.run(
|
|
79
|
+
await context.run({
|
|
80
|
+
globalGuards,
|
|
81
|
+
globalInterceptors,
|
|
82
|
+
globalFilter,
|
|
83
|
+
globalPipe
|
|
84
|
+
}, (returnData) => {
|
|
88
85
|
if (!isEvent)
|
|
89
86
|
queueMap[clientQueue].add(`${tag}-${func}`, {
|
|
90
87
|
data: returnData,
|
|
@@ -101,14 +98,14 @@ async function bind(connectOpts, { moduleMap, meta }, opts) {
|
|
|
101
98
|
});
|
|
102
99
|
}
|
|
103
100
|
_chunkYR5Q5F2Kjs.__name.call(void 0, handleRequest, "handleRequest");
|
|
104
|
-
|
|
101
|
+
_chunkYERBWZCSjs.detectAopDep.call(void 0, meta, {
|
|
105
102
|
guards: globalGuards,
|
|
106
103
|
interceptors: globalInterceptors
|
|
107
104
|
}, "rpc");
|
|
108
105
|
handleMeta();
|
|
109
106
|
subscribeQueues();
|
|
110
|
-
|
|
111
|
-
|
|
107
|
+
_chunkYERBWZCSjs.HMR.call(void 0, async () => {
|
|
108
|
+
_chunkYERBWZCSjs.detectAopDep.call(void 0, meta, {
|
|
112
109
|
guards: globalGuards,
|
|
113
110
|
interceptors: globalInterceptors
|
|
114
111
|
}, "rpc");
|
|
@@ -134,7 +131,7 @@ async function createClient(connectOpts, controllers, opts) {
|
|
|
134
131
|
let eventCount = 0;
|
|
135
132
|
const ret = {};
|
|
136
133
|
const emitter = new (0, _events.EventEmitter)();
|
|
137
|
-
const clientQueue =
|
|
134
|
+
const clientQueue = _chunkYERBWZCSjs.genClientQueue.call(void 0, _optionalChain([opts, 'optionalAccess', _2 => _2.key]));
|
|
138
135
|
const queueMap = {};
|
|
139
136
|
new (0, _bullmq.Worker)(clientQueue, async (job) => {
|
|
140
137
|
const { data, id, error } = job.data;
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
HMR,
|
|
4
4
|
detectAopDep,
|
|
5
5
|
genClientQueue
|
|
6
|
-
} from "../../chunk-
|
|
6
|
+
} from "../../chunk-AB4OX3WV.mjs";
|
|
7
7
|
import {
|
|
8
8
|
__name
|
|
9
9
|
} from "../../chunk-ITTD2GBR.mjs";
|
|
@@ -12,8 +12,8 @@ import {
|
|
|
12
12
|
import { Queue, Worker } from "bullmq";
|
|
13
13
|
import Debug from "debug";
|
|
14
14
|
var debug = Debug("phecda-server/bullmq");
|
|
15
|
-
async function bind(connectOpts, { moduleMap, meta }, opts) {
|
|
16
|
-
const { globalGuards
|
|
15
|
+
async function bind(connectOpts, { moduleMap, meta }, opts = {}) {
|
|
16
|
+
const { globalGuards, globalInterceptors, globalFilter, globalPipe } = opts;
|
|
17
17
|
const metaMap = /* @__PURE__ */ new Map();
|
|
18
18
|
const workerMap = {};
|
|
19
19
|
const queueMap = {};
|
|
@@ -24,14 +24,6 @@ async function bind(connectOpts, { moduleMap, meta }, opts) {
|
|
|
24
24
|
const { tag, func, controller, rpc } = item.data;
|
|
25
25
|
if (controller !== "rpc" || rpc?.queue === void 0)
|
|
26
26
|
continue;
|
|
27
|
-
item.data.guards = [
|
|
28
|
-
...globalGuards,
|
|
29
|
-
...item.data.guards
|
|
30
|
-
];
|
|
31
|
-
item.data.interceptors = [
|
|
32
|
-
...globalInterceptors,
|
|
33
|
-
...item.data.interceptors
|
|
34
|
-
];
|
|
35
27
|
if (metaMap.has(tag))
|
|
36
28
|
metaMap.get(tag)[func] = item;
|
|
37
29
|
else
|
|
@@ -84,7 +76,12 @@ async function bind(connectOpts, { moduleMap, meta }, opts) {
|
|
|
84
76
|
queue: job.queueName,
|
|
85
77
|
isEvent
|
|
86
78
|
});
|
|
87
|
-
await context.run(
|
|
79
|
+
await context.run({
|
|
80
|
+
globalGuards,
|
|
81
|
+
globalInterceptors,
|
|
82
|
+
globalFilter,
|
|
83
|
+
globalPipe
|
|
84
|
+
}, (returnData) => {
|
|
88
85
|
if (!isEvent)
|
|
89
86
|
queueMap[clientQueue].add(`${tag}-${func}`, {
|
|
90
87
|
data: returnData,
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Consumer, Producer } from 'kafkajs';
|
|
2
|
-
import {
|
|
3
|
-
import { R as RpcServerOptions, a as RpcClientOptions } from '../../helper-
|
|
2
|
+
import { F as Factory, T as ToClientMap } from '../../core-fd134ffa.js';
|
|
3
|
+
import { b as RpcContext, R as RpcServerOptions, a as RpcClientOptions } from '../../helper-73e8d2f0.js';
|
|
4
4
|
import 'phecda-core';
|
|
5
|
-
import 'http';
|
|
6
5
|
|
|
7
6
|
interface KafkaCtx extends RpcContext {
|
|
8
7
|
type: 'kafka';
|