phecda-server 7.0.0-alpha.6 → 7.0.0-alpha.8
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/cli.mjs +10 -1
- package/dist/{chunk-JF4YU32E.js → chunk-7EMAZGYO.js} +86 -56
- package/dist/{chunk-ICI5KUDX.mjs → chunk-7NWDKK7D.mjs} +1 -1
- package/dist/{chunk-HTY3H33L.mjs → chunk-B45BN7LY.mjs} +4 -4
- package/dist/{chunk-UKRQVTEY.js → chunk-BBNJVYVX.js} +24 -24
- package/dist/{chunk-WYI2F7LD.js → chunk-QJIAXSLZ.js} +19 -19
- package/dist/{chunk-3C7Z3IJN.mjs → chunk-SGMQZRP6.mjs} +39 -9
- package/dist/{chunk-62FBZWGW.js → chunk-VSGYTGHY.js} +24 -3
- package/dist/{chunk-KSDE5G57.mjs → chunk-YKP4ODZA.mjs} +24 -3
- package/dist/{core-CzElxZoF.d.ts → core-BGEsBtTG.d.ts} +1 -1
- package/dist/{core-DU7gQKSk.d.mts → core-BcKywWLd.d.mts} +1 -1
- package/dist/helper.d.mts +3 -2
- package/dist/helper.d.ts +3 -2
- package/dist/helper.js +5 -3
- package/dist/helper.mjs +4 -2
- package/dist/http/elysia/index.d.mts +4 -4
- package/dist/http/elysia/index.d.ts +4 -4
- package/dist/http/elysia/index.js +42 -41
- package/dist/http/elysia/index.mjs +6 -5
- package/dist/http/express/index.d.mts +4 -4
- package/dist/http/express/index.d.ts +4 -4
- package/dist/http/express/index.js +39 -38
- package/dist/http/express/index.mjs +5 -4
- package/dist/http/fastify/index.d.mts +4 -4
- package/dist/http/fastify/index.d.ts +4 -4
- package/dist/http/fastify/index.js +40 -39
- package/dist/http/fastify/index.mjs +6 -5
- package/dist/http/h3/index.d.mts +4 -4
- package/dist/http/h3/index.d.ts +4 -4
- package/dist/http/h3/index.js +40 -39
- package/dist/http/h3/index.mjs +6 -5
- package/dist/http/hono/index.d.mts +4 -4
- package/dist/http/hono/index.d.ts +4 -4
- package/dist/http/hono/index.js +35 -35
- package/dist/http/hono/index.mjs +2 -2
- package/dist/http/hyper-express/index.d.mts +4 -4
- package/dist/http/hyper-express/index.d.ts +4 -4
- package/dist/http/hyper-express/index.js +37 -36
- package/dist/http/hyper-express/index.mjs +5 -4
- package/dist/http/koa/index.d.mts +4 -4
- package/dist/http/koa/index.d.ts +4 -4
- package/dist/http/koa/index.js +39 -38
- package/dist/http/koa/index.mjs +5 -4
- package/dist/index.d.mts +38 -36
- package/dist/index.d.ts +38 -36
- package/dist/index.js +44 -43
- package/dist/index.mjs +16 -15
- package/dist/{meta-BTnLXuCa.d.ts → meta-B_HW7cWh.d.mts} +3 -3
- package/dist/{meta-BTnLXuCa.d.mts → meta-B_HW7cWh.d.ts} +3 -3
- package/dist/rpc/bullmq/index.d.mts +5 -5
- package/dist/rpc/bullmq/index.d.ts +5 -5
- package/dist/rpc/bullmq/index.js +14 -14
- package/dist/rpc/bullmq/index.mjs +2 -2
- package/dist/rpc/kafka/index.d.mts +4 -4
- package/dist/rpc/kafka/index.d.ts +4 -4
- package/dist/rpc/kafka/index.js +14 -14
- package/dist/rpc/kafka/index.mjs +2 -2
- package/dist/rpc/nats/index.d.mts +4 -4
- package/dist/rpc/nats/index.d.ts +4 -4
- package/dist/rpc/nats/index.js +13 -13
- package/dist/rpc/nats/index.mjs +2 -2
- package/dist/rpc/rabbitmq/index.d.mts +4 -4
- package/dist/rpc/rabbitmq/index.d.ts +4 -4
- package/dist/rpc/rabbitmq/index.js +15 -15
- package/dist/rpc/rabbitmq/index.mjs +2 -2
- package/dist/rpc/redis/index.d.mts +4 -4
- package/dist/rpc/redis/index.d.ts +4 -4
- package/dist/rpc/redis/index.js +13 -13
- package/dist/rpc/redis/index.mjs +2 -2
- package/dist/test.d.mts +3 -3
- package/dist/test.d.ts +3 -3
- package/dist/test.js +6 -6
- package/dist/test.mjs +2 -2
- package/dist/{types--E-OCZhC.d.ts → types-C2SQ9U9V.d.mts} +3 -3
- package/dist/{types-CbfaGkPA.d.ts → types-CYF0vha6.d.ts} +3 -3
- package/dist/{types-BYqBeqrs.d.mts → types-DEQb_e59.d.mts} +3 -3
- package/dist/{types-BxlzVoRv.d.mts → types-PFPIQWVF.d.ts} +3 -3
- package/package.json +3 -2
- package/register/loader.mjs +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { B as
|
|
2
|
-
export { g as BaseRequestType, f as BaseReturn, h as CustomResponse, j as ERROR_SYMBOL, i as ExtractResponse, I as
|
|
3
|
-
import { G as Generator } from './core-
|
|
4
|
-
export { F as Factory, O as Options, S as ServerPhecda, d as defaultServerInject, e as emitter, p as phecdaNamespace, u as useS } from './core-
|
|
1
|
+
import { B as BaseCtx, a as ControllerMeta, D as DefaultOptions, C as ControllerMetaData, b as MetaData, E as Emitter, c as BaseError } from './meta-B_HW7cWh.mjs';
|
|
2
|
+
export { g as BaseRequestType, f as BaseReturn, h as CustomResponse, j as ERROR_SYMBOL, i as ExtractResponse, I as IS_DEV, k as IS_ONLY_GENERATE, m as IS_READY, l as IS_STRICT, L as LOG_LEVEL, M as Meta, O as OmitFunction, n as PS_EXIT_CODE, P as PickFunc, S as ServiceMetaData, e as ToClientFn, d as ToClientInstance, T as ToClientMap } from './meta-B_HW7cWh.mjs';
|
|
3
|
+
import { G as Generator } from './core-BcKywWLd.mjs';
|
|
4
|
+
export { F as Factory, O as Options, S as ServerPhecda, d as defaultServerInject, e as emitter, p as phecdaNamespace, u as useS } from './core-BcKywWLd.mjs';
|
|
5
5
|
import { Base } from 'phecda-core';
|
|
6
6
|
export * from 'phecda-core';
|
|
7
|
-
import { H as
|
|
8
|
-
export { C as CookieSerializeOptions, a as HttpOptions } from './types-
|
|
9
|
-
import { R as
|
|
10
|
-
export { b as RpcClientOptions, a as RpcServerOptions } from './types-
|
|
7
|
+
import { H as HttpCtx } from './types-C2SQ9U9V.mjs';
|
|
8
|
+
export { C as CookieSerializeOptions, a as HttpOptions } from './types-C2SQ9U9V.mjs';
|
|
9
|
+
import { R as RpcCtx } from './types-DEQb_e59.mjs';
|
|
10
|
+
export { b as RpcClientOptions, a as RpcServerOptions } from './types-DEQb_e59.mjs';
|
|
11
11
|
export { Mixin } from 'ts-mixer';
|
|
12
12
|
import 'node:http';
|
|
13
13
|
|
|
@@ -102,11 +102,11 @@ interface PipeArg {
|
|
|
102
102
|
reflect: any;
|
|
103
103
|
define: Record<string, any>;
|
|
104
104
|
}
|
|
105
|
-
type GuardType<
|
|
106
|
-
type PipeType<
|
|
107
|
-
type FilterType<
|
|
108
|
-
declare class Context<
|
|
109
|
-
data:
|
|
105
|
+
type GuardType<Ctx extends BaseCtx = any> = (ctx: Ctx, next: () => Promise<any>) => any;
|
|
106
|
+
type PipeType<Ctx extends BaseCtx = any> = (arg: PipeArg, ctx: Ctx) => Promise<any>;
|
|
107
|
+
type FilterType<Ctx extends BaseCtx = any, E extends Exception = any> = (err: E | Error, ctx?: Ctx) => Error | any;
|
|
108
|
+
declare class Context<Ctx extends BaseCtx> {
|
|
109
|
+
data: Ctx;
|
|
110
110
|
method: string;
|
|
111
111
|
params: string[];
|
|
112
112
|
static filterRecord: Record<PropertyKey, FilterType>;
|
|
@@ -119,7 +119,9 @@ declare class Context<Data extends BaseContext> {
|
|
|
119
119
|
value: (router: any, framework: string) => any;
|
|
120
120
|
priority: number;
|
|
121
121
|
}>;
|
|
122
|
-
|
|
122
|
+
ctx: Ctx;
|
|
123
|
+
protected canGetCtx: boolean;
|
|
124
|
+
constructor(data: Ctx);
|
|
123
125
|
static getAop(meta: ControllerMeta, opts: DefaultOptions): {
|
|
124
126
|
guards: GuardType<any>[];
|
|
125
127
|
pipe: PipeType<any>[];
|
|
@@ -135,9 +137,9 @@ declare class Context<Data extends BaseContext> {
|
|
|
135
137
|
static getGuards(guards: string[]): GuardType<any>[];
|
|
136
138
|
static applyAddons(addons: string[], router: any, framework: string): void;
|
|
137
139
|
}
|
|
138
|
-
declare function addPipe<C extends
|
|
139
|
-
declare function addFilter<C extends
|
|
140
|
-
declare function addGuard<C extends
|
|
140
|
+
declare function addPipe<C extends BaseCtx>(key: PropertyKey, pipe: PipeType<C>): void;
|
|
141
|
+
declare function addFilter<C extends BaseCtx>(key: PropertyKey, filter: FilterType<C>): void;
|
|
142
|
+
declare function addGuard<C extends BaseCtx>(key: PropertyKey, guard: GuardType<C>, priority?: number): void;
|
|
141
143
|
declare function addAddon(key: PropertyKey, addon: (router: any, framework: string) => void, priority?: number): void;
|
|
142
144
|
|
|
143
145
|
declare class RPCGenerator extends Generator {
|
|
@@ -192,38 +194,38 @@ declare const defaultPipe: PipeType;
|
|
|
192
194
|
|
|
193
195
|
type LogLevel = 'error' | 'info' | 'warn' | 'log' | 'debug';
|
|
194
196
|
interface Logger {
|
|
195
|
-
log(msg:
|
|
197
|
+
log(msg: unknown, level: LogLevel, ctx?: string): void;
|
|
196
198
|
}
|
|
197
199
|
declare function setLogger(logger: Logger): void;
|
|
198
200
|
declare function getLogger(): Logger;
|
|
199
|
-
declare function log(msg:
|
|
200
|
-
declare function runMiddleware(ctx:
|
|
201
|
+
declare function log(msg: unknown, level?: LogLevel, ctx?: any): void;
|
|
202
|
+
declare function runMiddleware(ctx: HttpCtx, middleware: (req: any, res: any, next?: any) => any): Promise<unknown>;
|
|
201
203
|
|
|
202
204
|
declare class ServerBase extends Base {
|
|
203
205
|
emitter: Emitter;
|
|
204
|
-
log(msg:
|
|
206
|
+
log(msg: unknown, level?: LogLevel): void;
|
|
205
207
|
}
|
|
206
|
-
declare class HttpBase extends ServerBase {
|
|
207
|
-
context:
|
|
208
|
+
declare class HttpBase<Ctx extends HttpCtx = HttpCtx> extends ServerBase {
|
|
209
|
+
context: Ctx;
|
|
208
210
|
}
|
|
209
|
-
declare class RpcBase extends ServerBase {
|
|
210
|
-
context:
|
|
211
|
+
declare class RpcBase<Ctx extends RpcCtx = RpcCtx> extends ServerBase {
|
|
212
|
+
context: Ctx;
|
|
211
213
|
}
|
|
212
214
|
|
|
213
|
-
declare abstract class PFilter<
|
|
215
|
+
declare abstract class PFilter<Ctx extends BaseCtx = any, E extends Exception = Exception> extends ServerBase {
|
|
214
216
|
readonly key: PropertyKey;
|
|
215
217
|
constructor(tag?: string);
|
|
216
|
-
abstract use(error: Error | E, ctx?:
|
|
218
|
+
abstract use(error: Error | E, ctx?: Ctx): BaseError;
|
|
217
219
|
}
|
|
218
220
|
|
|
219
|
-
declare abstract class PGuard<
|
|
220
|
-
abstract use(ctx:
|
|
221
|
+
declare abstract class PGuard<Ctx extends BaseCtx = any> extends ServerBase {
|
|
222
|
+
abstract use(ctx: Ctx, next: () => Promise<any>): any;
|
|
221
223
|
readonly key: PropertyKey;
|
|
222
224
|
priority: number;
|
|
223
225
|
constructor(tag?: string);
|
|
224
226
|
}
|
|
225
227
|
|
|
226
|
-
declare abstract class PPipe<
|
|
228
|
+
declare abstract class PPipe<Ctx extends BaseCtx = any> extends ServerBase {
|
|
227
229
|
readonly key: PropertyKey;
|
|
228
230
|
constructor(tag?: string);
|
|
229
231
|
abstract use(param: {
|
|
@@ -233,7 +235,7 @@ declare abstract class PPipe<C extends BaseContext = any> extends ServerBase {
|
|
|
233
235
|
type: string;
|
|
234
236
|
index: number;
|
|
235
237
|
reflect: any;
|
|
236
|
-
}, ctx:
|
|
238
|
+
}, ctx: Ctx): any;
|
|
237
239
|
}
|
|
238
240
|
|
|
239
241
|
declare abstract class PAddon extends ServerBase {
|
|
@@ -243,8 +245,8 @@ declare abstract class PAddon extends ServerBase {
|
|
|
243
245
|
abstract use(router: any, framework: string): undefined;
|
|
244
246
|
}
|
|
245
247
|
|
|
246
|
-
interface PExtension<
|
|
247
|
-
guard(ctx:
|
|
248
|
+
interface PExtension<Ctx extends BaseCtx = any, E extends Exception = Exception> {
|
|
249
|
+
guard(ctx: Ctx): Promise<boolean> | boolean;
|
|
248
250
|
pipe(param: {
|
|
249
251
|
arg: any;
|
|
250
252
|
option?: any;
|
|
@@ -252,8 +254,8 @@ interface PExtension<C extends BaseContext = any, E extends Exception = Exceptio
|
|
|
252
254
|
type: string;
|
|
253
255
|
index: number;
|
|
254
256
|
reflect: any;
|
|
255
|
-
}, ctx:
|
|
256
|
-
filter(error: Error | E, ctx?:
|
|
257
|
+
}, ctx: Ctx): any;
|
|
258
|
+
filter(error: Error | E, ctx?: Ctx): BaseError;
|
|
257
259
|
addon<Addon = any>(framework: string): Addon;
|
|
258
260
|
}
|
|
259
261
|
declare class PExtension extends ServerBase {
|
|
@@ -263,4 +265,4 @@ declare class PExtension extends ServerBase {
|
|
|
263
265
|
constructor(tag?: string);
|
|
264
266
|
}
|
|
265
267
|
|
|
266
|
-
export { type AOP, Addon, Arg, BadGatewayException, BadRequestException,
|
|
268
|
+
export { type AOP, Addon, Arg, BadGatewayException, BadRequestException, BaseCtx, BaseError, BaseParam, Body, ConflictException, Context, Controller, ControllerMeta, ControllerMetaData, Ctx, DefaultOptions, Define, Delete, Emitter, Exception, Filter, type FilterType, ForbiddenException, FrameworkException, Generator, Get, Guard, type GuardType, HTTPGenerator, Head, Header, HttpBase, HttpCtx, InvalidInputException, type LogLevel, type Logger, MetaData, NotFoundException, PAddon, PExtension, PFilter, PGuard, PPipe, Param, Patch, PayloadLargeException, Pipe, type PipeArg, type PipeType, Post, Put, Query, Queue, RPCGenerator, Route, Rpc, RpcBase, RpcCtx, Search, ServerBase, ServiceUnavailableException, TimeoutException, TimerException, UnauthorizedException, UndefinedException, UnsupportedMediaTypeException, ValidateException, WorkerException, addAddon, addFilter, addGuard, addPipe, defaultPipe, getLogger, log, runMiddleware, setLogger };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { B as
|
|
2
|
-
export { g as BaseRequestType, f as BaseReturn, h as CustomResponse, j as ERROR_SYMBOL, i as ExtractResponse, I as
|
|
3
|
-
import { G as Generator } from './core-
|
|
4
|
-
export { F as Factory, O as Options, S as ServerPhecda, d as defaultServerInject, e as emitter, p as phecdaNamespace, u as useS } from './core-
|
|
1
|
+
import { B as BaseCtx, a as ControllerMeta, D as DefaultOptions, C as ControllerMetaData, b as MetaData, E as Emitter, c as BaseError } from './meta-B_HW7cWh.js';
|
|
2
|
+
export { g as BaseRequestType, f as BaseReturn, h as CustomResponse, j as ERROR_SYMBOL, i as ExtractResponse, I as IS_DEV, k as IS_ONLY_GENERATE, m as IS_READY, l as IS_STRICT, L as LOG_LEVEL, M as Meta, O as OmitFunction, n as PS_EXIT_CODE, P as PickFunc, S as ServiceMetaData, e as ToClientFn, d as ToClientInstance, T as ToClientMap } from './meta-B_HW7cWh.js';
|
|
3
|
+
import { G as Generator } from './core-BGEsBtTG.js';
|
|
4
|
+
export { F as Factory, O as Options, S as ServerPhecda, d as defaultServerInject, e as emitter, p as phecdaNamespace, u as useS } from './core-BGEsBtTG.js';
|
|
5
5
|
import { Base } from 'phecda-core';
|
|
6
6
|
export * from 'phecda-core';
|
|
7
|
-
import { H as
|
|
8
|
-
export { C as CookieSerializeOptions, a as HttpOptions } from './types
|
|
9
|
-
import { R as
|
|
10
|
-
export { b as RpcClientOptions, a as RpcServerOptions } from './types-
|
|
7
|
+
import { H as HttpCtx } from './types-PFPIQWVF.js';
|
|
8
|
+
export { C as CookieSerializeOptions, a as HttpOptions } from './types-PFPIQWVF.js';
|
|
9
|
+
import { R as RpcCtx } from './types-CYF0vha6.js';
|
|
10
|
+
export { b as RpcClientOptions, a as RpcServerOptions } from './types-CYF0vha6.js';
|
|
11
11
|
export { Mixin } from 'ts-mixer';
|
|
12
12
|
import 'node:http';
|
|
13
13
|
|
|
@@ -102,11 +102,11 @@ interface PipeArg {
|
|
|
102
102
|
reflect: any;
|
|
103
103
|
define: Record<string, any>;
|
|
104
104
|
}
|
|
105
|
-
type GuardType<
|
|
106
|
-
type PipeType<
|
|
107
|
-
type FilterType<
|
|
108
|
-
declare class Context<
|
|
109
|
-
data:
|
|
105
|
+
type GuardType<Ctx extends BaseCtx = any> = (ctx: Ctx, next: () => Promise<any>) => any;
|
|
106
|
+
type PipeType<Ctx extends BaseCtx = any> = (arg: PipeArg, ctx: Ctx) => Promise<any>;
|
|
107
|
+
type FilterType<Ctx extends BaseCtx = any, E extends Exception = any> = (err: E | Error, ctx?: Ctx) => Error | any;
|
|
108
|
+
declare class Context<Ctx extends BaseCtx> {
|
|
109
|
+
data: Ctx;
|
|
110
110
|
method: string;
|
|
111
111
|
params: string[];
|
|
112
112
|
static filterRecord: Record<PropertyKey, FilterType>;
|
|
@@ -119,7 +119,9 @@ declare class Context<Data extends BaseContext> {
|
|
|
119
119
|
value: (router: any, framework: string) => any;
|
|
120
120
|
priority: number;
|
|
121
121
|
}>;
|
|
122
|
-
|
|
122
|
+
ctx: Ctx;
|
|
123
|
+
protected canGetCtx: boolean;
|
|
124
|
+
constructor(data: Ctx);
|
|
123
125
|
static getAop(meta: ControllerMeta, opts: DefaultOptions): {
|
|
124
126
|
guards: GuardType<any>[];
|
|
125
127
|
pipe: PipeType<any>[];
|
|
@@ -135,9 +137,9 @@ declare class Context<Data extends BaseContext> {
|
|
|
135
137
|
static getGuards(guards: string[]): GuardType<any>[];
|
|
136
138
|
static applyAddons(addons: string[], router: any, framework: string): void;
|
|
137
139
|
}
|
|
138
|
-
declare function addPipe<C extends
|
|
139
|
-
declare function addFilter<C extends
|
|
140
|
-
declare function addGuard<C extends
|
|
140
|
+
declare function addPipe<C extends BaseCtx>(key: PropertyKey, pipe: PipeType<C>): void;
|
|
141
|
+
declare function addFilter<C extends BaseCtx>(key: PropertyKey, filter: FilterType<C>): void;
|
|
142
|
+
declare function addGuard<C extends BaseCtx>(key: PropertyKey, guard: GuardType<C>, priority?: number): void;
|
|
141
143
|
declare function addAddon(key: PropertyKey, addon: (router: any, framework: string) => void, priority?: number): void;
|
|
142
144
|
|
|
143
145
|
declare class RPCGenerator extends Generator {
|
|
@@ -192,38 +194,38 @@ declare const defaultPipe: PipeType;
|
|
|
192
194
|
|
|
193
195
|
type LogLevel = 'error' | 'info' | 'warn' | 'log' | 'debug';
|
|
194
196
|
interface Logger {
|
|
195
|
-
log(msg:
|
|
197
|
+
log(msg: unknown, level: LogLevel, ctx?: string): void;
|
|
196
198
|
}
|
|
197
199
|
declare function setLogger(logger: Logger): void;
|
|
198
200
|
declare function getLogger(): Logger;
|
|
199
|
-
declare function log(msg:
|
|
200
|
-
declare function runMiddleware(ctx:
|
|
201
|
+
declare function log(msg: unknown, level?: LogLevel, ctx?: any): void;
|
|
202
|
+
declare function runMiddleware(ctx: HttpCtx, middleware: (req: any, res: any, next?: any) => any): Promise<unknown>;
|
|
201
203
|
|
|
202
204
|
declare class ServerBase extends Base {
|
|
203
205
|
emitter: Emitter;
|
|
204
|
-
log(msg:
|
|
206
|
+
log(msg: unknown, level?: LogLevel): void;
|
|
205
207
|
}
|
|
206
|
-
declare class HttpBase extends ServerBase {
|
|
207
|
-
context:
|
|
208
|
+
declare class HttpBase<Ctx extends HttpCtx = HttpCtx> extends ServerBase {
|
|
209
|
+
context: Ctx;
|
|
208
210
|
}
|
|
209
|
-
declare class RpcBase extends ServerBase {
|
|
210
|
-
context:
|
|
211
|
+
declare class RpcBase<Ctx extends RpcCtx = RpcCtx> extends ServerBase {
|
|
212
|
+
context: Ctx;
|
|
211
213
|
}
|
|
212
214
|
|
|
213
|
-
declare abstract class PFilter<
|
|
215
|
+
declare abstract class PFilter<Ctx extends BaseCtx = any, E extends Exception = Exception> extends ServerBase {
|
|
214
216
|
readonly key: PropertyKey;
|
|
215
217
|
constructor(tag?: string);
|
|
216
|
-
abstract use(error: Error | E, ctx?:
|
|
218
|
+
abstract use(error: Error | E, ctx?: Ctx): BaseError;
|
|
217
219
|
}
|
|
218
220
|
|
|
219
|
-
declare abstract class PGuard<
|
|
220
|
-
abstract use(ctx:
|
|
221
|
+
declare abstract class PGuard<Ctx extends BaseCtx = any> extends ServerBase {
|
|
222
|
+
abstract use(ctx: Ctx, next: () => Promise<any>): any;
|
|
221
223
|
readonly key: PropertyKey;
|
|
222
224
|
priority: number;
|
|
223
225
|
constructor(tag?: string);
|
|
224
226
|
}
|
|
225
227
|
|
|
226
|
-
declare abstract class PPipe<
|
|
228
|
+
declare abstract class PPipe<Ctx extends BaseCtx = any> extends ServerBase {
|
|
227
229
|
readonly key: PropertyKey;
|
|
228
230
|
constructor(tag?: string);
|
|
229
231
|
abstract use(param: {
|
|
@@ -233,7 +235,7 @@ declare abstract class PPipe<C extends BaseContext = any> extends ServerBase {
|
|
|
233
235
|
type: string;
|
|
234
236
|
index: number;
|
|
235
237
|
reflect: any;
|
|
236
|
-
}, ctx:
|
|
238
|
+
}, ctx: Ctx): any;
|
|
237
239
|
}
|
|
238
240
|
|
|
239
241
|
declare abstract class PAddon extends ServerBase {
|
|
@@ -243,8 +245,8 @@ declare abstract class PAddon extends ServerBase {
|
|
|
243
245
|
abstract use(router: any, framework: string): undefined;
|
|
244
246
|
}
|
|
245
247
|
|
|
246
|
-
interface PExtension<
|
|
247
|
-
guard(ctx:
|
|
248
|
+
interface PExtension<Ctx extends BaseCtx = any, E extends Exception = Exception> {
|
|
249
|
+
guard(ctx: Ctx): Promise<boolean> | boolean;
|
|
248
250
|
pipe(param: {
|
|
249
251
|
arg: any;
|
|
250
252
|
option?: any;
|
|
@@ -252,8 +254,8 @@ interface PExtension<C extends BaseContext = any, E extends Exception = Exceptio
|
|
|
252
254
|
type: string;
|
|
253
255
|
index: number;
|
|
254
256
|
reflect: any;
|
|
255
|
-
}, ctx:
|
|
256
|
-
filter(error: Error | E, ctx?:
|
|
257
|
+
}, ctx: Ctx): any;
|
|
258
|
+
filter(error: Error | E, ctx?: Ctx): BaseError;
|
|
257
259
|
addon<Addon = any>(framework: string): Addon;
|
|
258
260
|
}
|
|
259
261
|
declare class PExtension extends ServerBase {
|
|
@@ -263,4 +265,4 @@ declare class PExtension extends ServerBase {
|
|
|
263
265
|
constructor(tag?: string);
|
|
264
266
|
}
|
|
265
267
|
|
|
266
|
-
export { type AOP, Addon, Arg, BadGatewayException, BadRequestException,
|
|
268
|
+
export { type AOP, Addon, Arg, BadGatewayException, BadRequestException, BaseCtx, BaseError, BaseParam, Body, ConflictException, Context, Controller, ControllerMeta, ControllerMetaData, Ctx, DefaultOptions, Define, Delete, Emitter, Exception, Filter, type FilterType, ForbiddenException, FrameworkException, Generator, Get, Guard, type GuardType, HTTPGenerator, Head, Header, HttpBase, HttpCtx, InvalidInputException, type LogLevel, type Logger, MetaData, NotFoundException, PAddon, PExtension, PFilter, PGuard, PPipe, Param, Patch, PayloadLargeException, Pipe, type PipeArg, type PipeType, Post, Put, Query, Queue, RPCGenerator, Route, Rpc, RpcBase, RpcCtx, Search, ServerBase, ServiceUnavailableException, TimeoutException, TimerException, UnauthorizedException, UndefinedException, UnsupportedMediaTypeException, ValidateException, WorkerException, addAddon, addFilter, addGuard, addPipe, defaultPipe, getLogger, log, runMiddleware, setLogger };
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkQJIAXSLZjs = require('./chunk-QJIAXSLZ.js');
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
@@ -31,7 +31,7 @@ var _chunkWYI2F7LDjs = require('./chunk-WYI2F7LD.js');
|
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
|
|
34
|
-
var
|
|
34
|
+
var _chunkBBNJVYVXjs = require('./chunk-BBNJVYVX.js');
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
|
|
@@ -56,8 +56,8 @@ var _chunkUKRQVTEYjs = require('./chunk-UKRQVTEY.js');
|
|
|
56
56
|
|
|
57
57
|
|
|
58
58
|
|
|
59
|
-
var _chunkJF4YU32Ejs = require('./chunk-JF4YU32E.js');
|
|
60
59
|
|
|
60
|
+
var _chunk7EMAZGYOjs = require('./chunk-7EMAZGYO.js');
|
|
61
61
|
|
|
62
62
|
|
|
63
63
|
|
|
@@ -71,13 +71,14 @@ var _chunkJF4YU32Ejs = require('./chunk-JF4YU32E.js');
|
|
|
71
71
|
|
|
72
72
|
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
|
|
75
|
+
var _chunkVSGYTGHYjs = require('./chunk-VSGYTGHY.js');
|
|
75
76
|
|
|
76
77
|
// src/types.ts
|
|
77
78
|
var ResponseSymbol = Symbol("response");
|
|
78
79
|
var CustomResponse = class {
|
|
79
80
|
static {
|
|
80
|
-
|
|
81
|
+
_chunkVSGYTGHYjs.__name.call(void 0, this, "CustomResponse");
|
|
81
82
|
}
|
|
82
83
|
|
|
83
84
|
};
|
|
@@ -90,54 +91,54 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
90
91
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
91
92
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
92
93
|
}
|
|
93
|
-
|
|
94
|
+
_chunkVSGYTGHYjs.__name.call(void 0, _ts_decorate, "_ts_decorate");
|
|
94
95
|
function _ts_metadata(k, v) {
|
|
95
96
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
96
97
|
}
|
|
97
|
-
|
|
98
|
+
_chunkVSGYTGHYjs.__name.call(void 0, _ts_metadata, "_ts_metadata");
|
|
98
99
|
var ServerBase = (_class = class extends _phecdacore.Base {constructor(...args2) { super(...args2); _class.prototype.__init.call(this); }
|
|
99
100
|
static {
|
|
100
|
-
|
|
101
|
+
_chunkVSGYTGHYjs.__name.call(void 0, this, "ServerBase");
|
|
101
102
|
}
|
|
102
|
-
__init() {this.emitter = exports.emitter =
|
|
103
|
-
log(msg, level) {
|
|
104
|
-
|
|
103
|
+
__init() {this.emitter = exports.emitter = _chunkQJIAXSLZjs.emitter}
|
|
104
|
+
log(msg, level = "log") {
|
|
105
|
+
_chunkVSGYTGHYjs.log.call(void 0, msg, level, this.tag);
|
|
105
106
|
}
|
|
106
107
|
}, _class);
|
|
107
108
|
var HttpBase = class extends ServerBase {
|
|
108
109
|
static {
|
|
109
|
-
|
|
110
|
+
_chunkVSGYTGHYjs.__name.call(void 0, this, "HttpBase");
|
|
110
111
|
}
|
|
111
112
|
|
|
112
113
|
};
|
|
113
114
|
_ts_decorate([
|
|
114
|
-
|
|
115
|
-
_ts_metadata("design:type", typeof
|
|
115
|
+
_chunkBBNJVYVXjs.Ctx,
|
|
116
|
+
_ts_metadata("design:type", typeof Ctx === "undefined" ? Object : Ctx)
|
|
116
117
|
], HttpBase.prototype, "context", void 0);
|
|
117
118
|
var RpcBase = class extends ServerBase {
|
|
118
119
|
static {
|
|
119
|
-
|
|
120
|
+
_chunkVSGYTGHYjs.__name.call(void 0, this, "RpcBase");
|
|
120
121
|
}
|
|
121
122
|
|
|
122
123
|
};
|
|
123
124
|
_ts_decorate([
|
|
124
|
-
|
|
125
|
-
_ts_metadata("design:type", typeof
|
|
125
|
+
_chunkBBNJVYVXjs.Ctx,
|
|
126
|
+
_ts_metadata("design:type", typeof Ctx === "undefined" ? Object : Ctx)
|
|
126
127
|
], RpcBase.prototype, "context", void 0);
|
|
127
128
|
|
|
128
129
|
// src/modules/filter.ts
|
|
129
130
|
|
|
130
131
|
var PFilter = class extends ServerBase {
|
|
131
132
|
static {
|
|
132
|
-
|
|
133
|
+
_chunkVSGYTGHYjs.__name.call(void 0, this, "PFilter");
|
|
133
134
|
}
|
|
134
135
|
|
|
135
136
|
constructor(tag) {
|
|
136
137
|
super();
|
|
137
138
|
this.key = tag || _phecdacore.getTag.call(void 0, this);
|
|
138
|
-
|
|
139
|
+
_chunk7EMAZGYOjs.addFilter.call(void 0, this.key, this.use.bind(this));
|
|
139
140
|
this.onUnmount(() => {
|
|
140
|
-
delete
|
|
141
|
+
delete _chunk7EMAZGYOjs.Context.filterRecord[this.key];
|
|
141
142
|
});
|
|
142
143
|
}
|
|
143
144
|
};
|
|
@@ -146,16 +147,16 @@ var PFilter = class extends ServerBase {
|
|
|
146
147
|
|
|
147
148
|
var PGuard = (_class2 = class extends ServerBase {
|
|
148
149
|
static {
|
|
149
|
-
|
|
150
|
+
_chunkVSGYTGHYjs.__name.call(void 0, this, "PGuard");
|
|
150
151
|
}
|
|
151
152
|
|
|
152
153
|
__init2() {this.priority = 0}
|
|
153
154
|
constructor(tag) {
|
|
154
155
|
super();_class2.prototype.__init2.call(this);;
|
|
155
156
|
this.key = tag || _phecdacore.getTag.call(void 0, this);
|
|
156
|
-
|
|
157
|
+
_chunk7EMAZGYOjs.addGuard.call(void 0, this.key, this.use.bind(this), this.priority);
|
|
157
158
|
this.onUnmount(() => {
|
|
158
|
-
delete
|
|
159
|
+
delete _chunk7EMAZGYOjs.Context.guardRecord[this.key];
|
|
159
160
|
});
|
|
160
161
|
}
|
|
161
162
|
}, _class2);
|
|
@@ -164,15 +165,15 @@ var PGuard = (_class2 = class extends ServerBase {
|
|
|
164
165
|
|
|
165
166
|
var PPipe = class extends ServerBase {
|
|
166
167
|
static {
|
|
167
|
-
|
|
168
|
+
_chunkVSGYTGHYjs.__name.call(void 0, this, "PPipe");
|
|
168
169
|
}
|
|
169
170
|
|
|
170
171
|
constructor(tag) {
|
|
171
172
|
super();
|
|
172
173
|
this.key = tag || _phecdacore.getTag.call(void 0, this);
|
|
173
|
-
|
|
174
|
+
_chunk7EMAZGYOjs.addPipe.call(void 0, this.key, this.use.bind(this));
|
|
174
175
|
this.onUnmount(() => {
|
|
175
|
-
delete
|
|
176
|
+
delete _chunk7EMAZGYOjs.Context.pipeRecord[this.key];
|
|
176
177
|
});
|
|
177
178
|
}
|
|
178
179
|
};
|
|
@@ -181,16 +182,16 @@ var PPipe = class extends ServerBase {
|
|
|
181
182
|
|
|
182
183
|
var PAddon = (_class3 = class extends ServerBase {
|
|
183
184
|
static {
|
|
184
|
-
|
|
185
|
+
_chunkVSGYTGHYjs.__name.call(void 0, this, "PAddon");
|
|
185
186
|
}
|
|
186
187
|
|
|
187
188
|
__init3() {this.priority = 0}
|
|
188
189
|
constructor(tag) {
|
|
189
190
|
super();_class3.prototype.__init3.call(this);;
|
|
190
191
|
this.key = tag || _phecdacore.getTag.call(void 0, this);
|
|
191
|
-
|
|
192
|
+
_chunk7EMAZGYOjs.addAddon.call(void 0, this.key, this.use.bind(this), this.priority);
|
|
192
193
|
this.onUnmount(() => {
|
|
193
|
-
delete
|
|
194
|
+
delete _chunk7EMAZGYOjs.Context.addonRecord[this.key];
|
|
194
195
|
});
|
|
195
196
|
}
|
|
196
197
|
}, _class3);
|
|
@@ -199,7 +200,7 @@ var PAddon = (_class3 = class extends ServerBase {
|
|
|
199
200
|
|
|
200
201
|
var PExtension = class extends ServerBase {
|
|
201
202
|
static {
|
|
202
|
-
|
|
203
|
+
_chunkVSGYTGHYjs.__name.call(void 0, this, "PExtension");
|
|
203
204
|
}
|
|
204
205
|
|
|
205
206
|
|
|
@@ -208,27 +209,27 @@ var PExtension = class extends ServerBase {
|
|
|
208
209
|
super();
|
|
209
210
|
const key = this.key = tag || _phecdacore.getTag.call(void 0, this);
|
|
210
211
|
if (this.pipe) {
|
|
211
|
-
|
|
212
|
+
_chunk7EMAZGYOjs.addPipe.call(void 0, key, this.pipe.bind(this));
|
|
212
213
|
this.onUnmount(() => {
|
|
213
|
-
delete
|
|
214
|
+
delete _chunk7EMAZGYOjs.Context.pipeRecord[key];
|
|
214
215
|
});
|
|
215
216
|
}
|
|
216
217
|
if (this.addon) {
|
|
217
|
-
|
|
218
|
+
_chunk7EMAZGYOjs.addAddon.call(void 0, key, this.addon.bind(this), this.addonPriority);
|
|
218
219
|
this.onUnmount(() => {
|
|
219
|
-
delete
|
|
220
|
+
delete _chunk7EMAZGYOjs.Context.addonRecord[key];
|
|
220
221
|
});
|
|
221
222
|
}
|
|
222
223
|
if (this.guard) {
|
|
223
|
-
|
|
224
|
+
_chunk7EMAZGYOjs.addGuard.call(void 0, key, this.guard.bind(this), this.guardPriority);
|
|
224
225
|
this.onUnmount(() => {
|
|
225
|
-
delete
|
|
226
|
+
delete _chunk7EMAZGYOjs.Context.guardRecord[key];
|
|
226
227
|
});
|
|
227
228
|
}
|
|
228
229
|
if (this.filter) {
|
|
229
|
-
|
|
230
|
+
_chunk7EMAZGYOjs.addFilter.call(void 0, key, this.filter.bind(this));
|
|
230
231
|
this.onUnmount(() => {
|
|
231
|
-
delete
|
|
232
|
+
delete _chunk7EMAZGYOjs.Context.filterRecord[key];
|
|
232
233
|
});
|
|
233
234
|
}
|
|
234
235
|
}
|
|
@@ -238,7 +239,7 @@ var PExtension = class extends ServerBase {
|
|
|
238
239
|
var _fsextra = require('fs-extra'); var _fsextra2 = _interopRequireDefault(_fsextra);
|
|
239
240
|
var Generator = class {
|
|
240
241
|
static {
|
|
241
|
-
|
|
242
|
+
_chunkVSGYTGHYjs.__name.call(void 0, this, "Generator");
|
|
242
243
|
}
|
|
243
244
|
|
|
244
245
|
constructor(path) {
|
|
@@ -255,7 +256,7 @@ var Generator = class {
|
|
|
255
256
|
// src/generator/rpc.ts
|
|
256
257
|
var RPCGenerator = (_class4 = class extends Generator {constructor(...args3) { super(...args3); _class4.prototype.__init4.call(this);_class4.prototype.__init5.call(this); }
|
|
257
258
|
static {
|
|
258
|
-
|
|
259
|
+
_chunkVSGYTGHYjs.__name.call(void 0, this, "RPCGenerator");
|
|
259
260
|
}
|
|
260
261
|
__init4() {this.name = "RPC"}
|
|
261
262
|
__init5() {this.classMap = {}}
|
|
@@ -291,7 +292,7 @@ var RPCGenerator = (_class4 = class extends Generator {constructor(...args3) { s
|
|
|
291
292
|
// src/generator/http.ts
|
|
292
293
|
var HTTPGenerator = (_class5 = class extends Generator {constructor(...args4) { super(...args4); _class5.prototype.__init6.call(this);_class5.prototype.__init7.call(this); }
|
|
293
294
|
static {
|
|
294
|
-
|
|
295
|
+
_chunkVSGYTGHYjs.__name.call(void 0, this, "HTTPGenerator");
|
|
295
296
|
}
|
|
296
297
|
__init6() {this.name = "HTTP"}
|
|
297
298
|
__init7() {this.classMap = {}}
|
|
@@ -308,7 +309,7 @@ var HTTPGenerator = (_class5 = class extends Generator {constructor(...args4) {
|
|
|
308
309
|
addMethod(args) {
|
|
309
310
|
const { http, name, func, params, tag } = args;
|
|
310
311
|
if (!_optionalChain([http, 'optionalAccess', _2 => _2.type])) return;
|
|
311
|
-
const url = http.prefix
|
|
312
|
+
const url = _chunk7EMAZGYOjs.joinUrl.call(void 0, http.prefix, http.route).replace(/\/\:([^\/]*)/g, (_, js) => `/{{${js}}}`);
|
|
312
313
|
if (!this.classMap[name]) this.classMap[name] = {};
|
|
313
314
|
this.classMap[name][func] = `
|
|
314
315
|
${func}(...args){
|
|
@@ -409,4 +410,4 @@ return ret
|
|
|
409
410
|
|
|
410
411
|
|
|
411
412
|
|
|
412
|
-
exports.Addon =
|
|
413
|
+
exports.Addon = _chunkBBNJVYVXjs.Addon; exports.Arg = _chunkBBNJVYVXjs.Arg; exports.BadGatewayException = _chunk7EMAZGYOjs.BadGatewayException; exports.BadRequestException = _chunk7EMAZGYOjs.BadRequestException; exports.BaseParam = _chunkBBNJVYVXjs.BaseParam; exports.Body = _chunkBBNJVYVXjs.Body; exports.ConflictException = _chunk7EMAZGYOjs.ConflictException; exports.Context = _chunk7EMAZGYOjs.Context; exports.Controller = _chunkBBNJVYVXjs.Controller; exports.Ctx = _chunkBBNJVYVXjs.Ctx; exports.CustomResponse = CustomResponse; exports.Define = _chunkBBNJVYVXjs.Define; exports.Delete = _chunkBBNJVYVXjs.Delete; exports.ERROR_SYMBOL = _chunkVSGYTGHYjs.ERROR_SYMBOL; exports.Exception = _chunk7EMAZGYOjs.Exception; exports.Factory = _chunkQJIAXSLZjs.Factory; exports.Filter = _chunkBBNJVYVXjs.Filter; exports.ForbiddenException = _chunk7EMAZGYOjs.ForbiddenException; exports.FrameworkException = _chunk7EMAZGYOjs.FrameworkException; exports.Generator = Generator; exports.Get = _chunkBBNJVYVXjs.Get; exports.Guard = _chunkBBNJVYVXjs.Guard; exports.HTTPGenerator = HTTPGenerator; exports.Head = _chunkBBNJVYVXjs.Head; exports.Header = _chunkBBNJVYVXjs.Header; exports.HttpBase = HttpBase; exports.IS_DEV = _chunkVSGYTGHYjs.IS_DEV; exports.IS_ONLY_GENERATE = _chunkVSGYTGHYjs.IS_ONLY_GENERATE; exports.IS_READY = _chunkVSGYTGHYjs.IS_READY; exports.IS_STRICT = _chunkVSGYTGHYjs.IS_STRICT; exports.InvalidInputException = _chunk7EMAZGYOjs.InvalidInputException; exports.LOG_LEVEL = _chunkVSGYTGHYjs.LOG_LEVEL; exports.Meta = _chunkQJIAXSLZjs.Meta; exports.Mixin = _chunkVSGYTGHYjs.Mixin; exports.NotFoundException = _chunk7EMAZGYOjs.NotFoundException; exports.PAddon = PAddon; exports.PExtension = PExtension; exports.PFilter = PFilter; exports.PGuard = PGuard; exports.PPipe = PPipe; exports.PS_EXIT_CODE = _chunkVSGYTGHYjs.PS_EXIT_CODE; exports.Param = _chunkBBNJVYVXjs.Param; exports.Patch = _chunkBBNJVYVXjs.Patch; exports.PayloadLargeException = _chunk7EMAZGYOjs.PayloadLargeException; exports.Pipe = _chunkBBNJVYVXjs.Pipe; exports.Post = _chunkBBNJVYVXjs.Post; exports.Put = _chunkBBNJVYVXjs.Put; exports.Query = _chunkBBNJVYVXjs.Query; exports.Queue = _chunkBBNJVYVXjs.Queue; exports.RPCGenerator = RPCGenerator; exports.Route = _chunkBBNJVYVXjs.Route; exports.Rpc = _chunkBBNJVYVXjs.Rpc; exports.RpcBase = RpcBase; exports.Search = _chunkBBNJVYVXjs.Search; exports.ServerBase = ServerBase; exports.ServerPhecda = _chunkQJIAXSLZjs.ServerPhecda; exports.ServiceUnavailableException = _chunk7EMAZGYOjs.ServiceUnavailableException; exports.TimeoutException = _chunk7EMAZGYOjs.TimeoutException; exports.TimerException = _chunk7EMAZGYOjs.TimerException; exports.UnauthorizedException = _chunk7EMAZGYOjs.UnauthorizedException; exports.UndefinedException = _chunk7EMAZGYOjs.UndefinedException; exports.UnsupportedMediaTypeException = _chunk7EMAZGYOjs.UnsupportedMediaTypeException; exports.ValidateException = _chunk7EMAZGYOjs.ValidateException; exports.WorkerException = _chunk7EMAZGYOjs.WorkerException; exports.addAddon = _chunk7EMAZGYOjs.addAddon; exports.addFilter = _chunk7EMAZGYOjs.addFilter; exports.addGuard = _chunk7EMAZGYOjs.addGuard; exports.addPipe = _chunk7EMAZGYOjs.addPipe; exports.defaultPipe = _chunk7EMAZGYOjs.defaultPipe; exports.defaultServerInject = _chunkQJIAXSLZjs.defaultServerInject; exports.emitter = _chunkQJIAXSLZjs.emitter; exports.getLogger = _chunkVSGYTGHYjs.getLogger; exports.log = _chunkVSGYTGHYjs.log; exports.phecdaNamespace = _chunkQJIAXSLZjs.phecdaNamespace; exports.runMiddleware = _chunkVSGYTGHYjs.runMiddleware; exports.setLogger = _chunkVSGYTGHYjs.setLogger; exports.useS = _chunkQJIAXSLZjs.useS;
|