phecda-server 5.2.0 → 5.2.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/assets/ps.json +21 -22
- package/bin/cli.mjs +24 -17
- package/dist/helper.d.ts +7 -5
- package/dist/index.d.ts +3 -0
- package/dist/rpc/bullmq/index.d.ts +1 -1
- package/dist/rpc/kafka/index.d.ts +1 -1
- package/dist/rpc/nats/index.d.ts +1 -1
- package/dist/rpc/rabbitmq/index.d.ts +1 -1
- package/dist/rpc/redis/index.d.ts +1 -1
- package/dist/server/elysia/index.d.ts +1 -1
- package/dist/server/express/index.d.ts +1 -1
- package/dist/server/fastify/index.d.ts +1 -1
- package/dist/server/h3/index.d.ts +1 -1
- package/dist/server/hono/index.d.ts +1 -1
- package/dist/server/hyper-express/index.d.ts +1 -1
- package/dist/server/koa/index.d.ts +1 -1
- package/dist/test.d.ts +1 -1
- package/dist/{helper-49c7213c.d.ts → types-68f2ec2a.d.ts} +2 -4
- package/dist/{helper-5d755442.d.ts → types-f3b79218.d.ts} +1 -2
- package/package.json +1 -1
package/assets/ps.json
CHANGED
|
@@ -1,25 +1,24 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
"$schema": "https://unpkg.com/phecda-server/assets/schema.json",
|
|
3
|
+
"resolve": [
|
|
4
|
+
{
|
|
5
|
+
"source": "controller",
|
|
6
|
+
"importer": "http",
|
|
7
|
+
"path": ".ps/http.js"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"source": "rpc",
|
|
11
|
+
"importer": "client",
|
|
12
|
+
"path": ".ps/rpc.js"
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
15
|
"unimport": {
|
|
16
16
|
"dirs": ["."],
|
|
17
|
-
"dirsScanOptions":{
|
|
18
|
-
"filePatterns":["*.{service,controller,module,rpc,edge,guard,interceptor,extension,pipe,filter,plugin}.ts"]
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
"dirsScanOptions": {
|
|
18
|
+
"filePatterns": ["*.{service,controller,module,rpc,edge,guard,interceptor,extension,pipe,filter,plugin}.ts"]
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"virtualFile": {},
|
|
22
|
+
"moduleFile": []
|
|
23
|
+
|
|
24
|
+
}
|
package/bin/cli.mjs
CHANGED
|
@@ -9,10 +9,9 @@ import cac from 'cac'
|
|
|
9
9
|
import fse from 'fs-extra'
|
|
10
10
|
import { log } from '../dist/index.mjs'
|
|
11
11
|
|
|
12
|
-
const cli = cac('phecda')
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
})
|
|
12
|
+
const cli = cac('phecda').option('-c,--config <config>', 'config file', {
|
|
13
|
+
default: 'ps.json',
|
|
14
|
+
})
|
|
16
15
|
|
|
17
16
|
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
18
17
|
|
|
@@ -75,19 +74,25 @@ process.on('SIGINT', () => {
|
|
|
75
74
|
})
|
|
76
75
|
|
|
77
76
|
cli
|
|
78
|
-
.command('init [
|
|
77
|
+
.command('init [root]', 'init config file')
|
|
79
78
|
.allowUnknownOptions()
|
|
80
79
|
.option('-t,--tsconfig <tsconfig>', 'init tsconfig file', {
|
|
81
80
|
default: 'tsconfig.json',
|
|
82
81
|
})
|
|
83
|
-
.action(async (
|
|
84
|
-
|
|
85
|
-
|
|
82
|
+
.action(async (root, options) => {
|
|
83
|
+
if (!root)
|
|
84
|
+
root = ''
|
|
85
|
+
|
|
86
|
+
const tsconfigPath = join(root, options.tsconfig)
|
|
87
|
+
const psconfigPath = join(root, options.config)
|
|
86
88
|
|
|
87
89
|
if (!fse.existsSync(tsconfigPath)) {
|
|
88
90
|
log(`create ${tsconfigPath}`)
|
|
89
91
|
|
|
90
|
-
await fse.copyFile(
|
|
92
|
+
await fse.copyFile(
|
|
93
|
+
resolve(__dirname, '../assets/tsconfig.json'),
|
|
94
|
+
tsconfigPath,
|
|
95
|
+
)
|
|
91
96
|
}
|
|
92
97
|
|
|
93
98
|
if (!fse.existsSync(psconfigPath)) {
|
|
@@ -95,15 +100,17 @@ cli
|
|
|
95
100
|
|
|
96
101
|
await fse.copyFile(resolve(__dirname, '../assets/ps.json'), psconfigPath)
|
|
97
102
|
}
|
|
103
|
+
|
|
104
|
+
log('init finish')
|
|
98
105
|
})
|
|
99
106
|
|
|
100
107
|
cli
|
|
101
|
-
.command('<file> [
|
|
108
|
+
.command('<file> [root]', 'run file')
|
|
102
109
|
.allowUnknownOptions()
|
|
103
110
|
.alias('run')
|
|
104
|
-
.action((file,
|
|
105
|
-
if (
|
|
106
|
-
process.env.PS_WORKDIR =
|
|
111
|
+
.action((file, root, options) => {
|
|
112
|
+
if (root)
|
|
113
|
+
process.env.PS_WORKDIR = root
|
|
107
114
|
process.env.PS_CONFIG_FILE = options.config
|
|
108
115
|
|
|
109
116
|
log('process start!')
|
|
@@ -134,11 +141,11 @@ cli
|
|
|
134
141
|
})
|
|
135
142
|
|
|
136
143
|
cli
|
|
137
|
-
.command('generate <file> [
|
|
144
|
+
.command('generate <file> [root]', 'generate code(mainly for ci)')
|
|
138
145
|
.allowUnknownOptions()
|
|
139
|
-
.action((file,
|
|
140
|
-
if (
|
|
141
|
-
process.env.PS_WORKDIR =
|
|
146
|
+
.action((file, root, options) => {
|
|
147
|
+
if (root)
|
|
148
|
+
process.env.PS_WORKDIR = root
|
|
142
149
|
process.env.PS_GENERATE = 'true'
|
|
143
150
|
process.env.PS_CONFIG_FILE = options.config
|
|
144
151
|
startChild(file, options['--'])
|
package/dist/helper.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { h as Meta, i as ControllerMeta } from './types-81be0ba3.js';
|
|
2
|
-
export { a as HttpContext, H as HttpOptions, b as argToReq, r as resolveDep } from './helper-49c7213c.js';
|
|
3
|
-
export { a as RpcClientOptions, b as RpcContext, R as RpcServerOptions, g as genClientQueue } from './helper-5d755442.js';
|
|
1
|
+
import { C as ControllerMetaData, h as Meta, i as ControllerMeta } from './types-81be0ba3.js';
|
|
4
2
|
import 'phecda-core';
|
|
5
|
-
import 'node:http';
|
|
6
3
|
|
|
7
4
|
declare function HMR(cb: (...args: any) => any): void;
|
|
8
5
|
|
|
6
|
+
declare function resolveDep(ret: any, key: string): any;
|
|
7
|
+
declare function argToReq(params: ControllerMetaData['params'], args: any[], headers: Record<string, any>): any;
|
|
8
|
+
|
|
9
|
+
declare function genClientQueue(key?: string): string;
|
|
10
|
+
|
|
9
11
|
declare function shallowClone(obj: any): any;
|
|
10
12
|
declare function mergeObject(...args: any[]): any;
|
|
11
13
|
|
|
@@ -22,4 +24,4 @@ declare function detectAopDep(meta: Meta[], { guards, interceptors, plugins }?:
|
|
|
22
24
|
filterSet: Set<string>;
|
|
23
25
|
};
|
|
24
26
|
|
|
25
|
-
export { HMR, createControllerMetaMap, detectAopDep, mergeObject, shallowClone };
|
|
27
|
+
export { HMR, argToReq, createControllerMetaMap, detectAopDep, genClientQueue, mergeObject, resolveDep, shallowClone };
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,9 @@ import { G as Generator } from './core-7f6d2be6.js';
|
|
|
4
4
|
export { F as Factory, e as emitter } from './core-7f6d2be6.js';
|
|
5
5
|
import { Construct, AbConstruct } from 'phecda-core';
|
|
6
6
|
export * from 'phecda-core';
|
|
7
|
+
export { a as HttpContext, H as HttpOptions } from './types-68f2ec2a.js';
|
|
8
|
+
export { a as RpcClientOptions, b as RpcContext, R as RpcServerOptions } from './types-f3b79218.js';
|
|
9
|
+
import 'node:http';
|
|
7
10
|
|
|
8
11
|
declare class Exception extends Error {
|
|
9
12
|
message: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { WorkerOptions, QueueOptions, Worker, Queue } from 'bullmq';
|
|
2
2
|
import { F as Factory } from '../../core-7f6d2be6.js';
|
|
3
|
-
import { b as RpcContext, R as RpcServerOptions, a as RpcClientOptions } from '../../
|
|
3
|
+
import { b as RpcContext, R as RpcServerOptions, a as RpcClientOptions } from '../../types-f3b79218.js';
|
|
4
4
|
import { T as ToClientMap } from '../../types-81be0ba3.js';
|
|
5
5
|
import 'phecda-core';
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Consumer, Producer } from 'kafkajs';
|
|
2
2
|
import { F as Factory } from '../../core-7f6d2be6.js';
|
|
3
|
-
import { b as RpcContext, R as RpcServerOptions, a as RpcClientOptions } from '../../
|
|
3
|
+
import { b as RpcContext, R as RpcServerOptions, a as RpcClientOptions } from '../../types-f3b79218.js';
|
|
4
4
|
import { T as ToClientMap } from '../../types-81be0ba3.js';
|
|
5
5
|
import 'phecda-core';
|
|
6
6
|
|
package/dist/rpc/nats/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NatsConnection } from 'nats';
|
|
2
2
|
import { F as Factory } from '../../core-7f6d2be6.js';
|
|
3
|
-
import { b as RpcContext, R as RpcServerOptions, a as RpcClientOptions } from '../../
|
|
3
|
+
import { b as RpcContext, R as RpcServerOptions, a as RpcClientOptions } from '../../types-f3b79218.js';
|
|
4
4
|
import { T as ToClientMap } from '../../types-81be0ba3.js';
|
|
5
5
|
import 'phecda-core';
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import amqplib from 'amqplib';
|
|
2
2
|
import { F as Factory } from '../../core-7f6d2be6.js';
|
|
3
|
-
import { b as RpcContext, R as RpcServerOptions, a as RpcClientOptions } from '../../
|
|
3
|
+
import { b as RpcContext, R as RpcServerOptions, a as RpcClientOptions } from '../../types-f3b79218.js';
|
|
4
4
|
import { T as ToClientMap } from '../../types-81be0ba3.js';
|
|
5
5
|
import 'phecda-core';
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Redis from 'ioredis';
|
|
2
2
|
import { F as Factory } from '../../core-7f6d2be6.js';
|
|
3
|
-
import { b as RpcContext, R as RpcServerOptions, a as RpcClientOptions } from '../../
|
|
3
|
+
import { b as RpcContext, R as RpcServerOptions, a as RpcClientOptions } from '../../types-f3b79218.js';
|
|
4
4
|
import { T as ToClientMap } from '../../types-81be0ba3.js';
|
|
5
5
|
import 'phecda-core';
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Elysia as Elysia$1, Context, LocalHook, InputSchema, RouteSchema, SingletonBase } from 'elysia';
|
|
2
2
|
import { BaseMacro } from 'elysia/dist/types';
|
|
3
|
-
import { a as HttpContext, H as HttpOptions } from '../../
|
|
3
|
+
import { a as HttpContext, H as HttpOptions } from '../../types-68f2ec2a.js';
|
|
4
4
|
import { F as Factory } from '../../core-7f6d2be6.js';
|
|
5
5
|
import 'node:http';
|
|
6
6
|
import '../../types-81be0ba3.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Request, Response, Router, RequestHandler } from 'express';
|
|
2
|
-
import { a as HttpContext, H as HttpOptions } from '../../
|
|
2
|
+
import { a as HttpContext, H as HttpOptions } from '../../types-68f2ec2a.js';
|
|
3
3
|
import { F as Factory } from '../../core-7f6d2be6.js';
|
|
4
4
|
import 'node:http';
|
|
5
5
|
import '../../types-81be0ba3.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FastifyRequest, FastifyReply, FastifyInstance, FastifyPluginCallback, FastifyRegisterOptions, FastifyPluginOptions, RouteShorthandOptions } from 'fastify';
|
|
2
|
-
import { a as HttpContext, H as HttpOptions } from '../../
|
|
2
|
+
import { a as HttpContext, H as HttpOptions } from '../../types-68f2ec2a.js';
|
|
3
3
|
import { F as Factory } from '../../core-7f6d2be6.js';
|
|
4
4
|
import 'node:http';
|
|
5
5
|
import '../../types-81be0ba3.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { H3Event, Router, _RequestMiddleware } from 'h3';
|
|
2
2
|
import { F as Factory } from '../../core-7f6d2be6.js';
|
|
3
|
-
import { a as HttpContext, H as HttpOptions } from '../../
|
|
3
|
+
import { a as HttpContext, H as HttpOptions } from '../../types-68f2ec2a.js';
|
|
4
4
|
import 'phecda-core';
|
|
5
5
|
import '../../types-81be0ba3.js';
|
|
6
6
|
import 'node:http';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Context, Hono, MiddlewareHandler } from 'hono';
|
|
2
|
-
import { a as HttpContext, H as HttpOptions } from '../../
|
|
2
|
+
import { a as HttpContext, H as HttpOptions } from '../../types-68f2ec2a.js';
|
|
3
3
|
import { F as Factory } from '../../core-7f6d2be6.js';
|
|
4
4
|
import 'node:http';
|
|
5
5
|
import '../../types-81be0ba3.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Request, Response, Router, MiddlewareHandler } from 'hyper-express';
|
|
2
|
-
import { a as HttpContext, H as HttpOptions } from '../../
|
|
2
|
+
import { a as HttpContext, H as HttpOptions } from '../../types-68f2ec2a.js';
|
|
3
3
|
import { F as Factory } from '../../core-7f6d2be6.js';
|
|
4
4
|
import 'node:http';
|
|
5
5
|
import '../../types-81be0ba3.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Router, { RouterParamContext } from '@koa/router';
|
|
2
2
|
import { DefaultContext, DefaultState } from 'koa';
|
|
3
|
-
import { a as HttpContext, H as HttpOptions } from '../../
|
|
3
|
+
import { a as HttpContext, H as HttpOptions } from '../../types-68f2ec2a.js';
|
|
4
4
|
import { F as Factory } from '../../core-7f6d2be6.js';
|
|
5
5
|
import 'node:http';
|
|
6
6
|
import '../../types-81be0ba3.js';
|
package/dist/test.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ declare function TestFactory<T extends Construct[]>(...Modules: T): Promise<{
|
|
|
11
11
|
type SuperTestRequest<T> = {
|
|
12
12
|
[K in keyof T]: T[K] extends (...args: infer R) => any ? (...args: R) => Test : never;
|
|
13
13
|
};
|
|
14
|
-
declare function TestHttp(app: Server | any, { moduleMap, meta }: Awaited<ReturnType<typeof Factory>>, isAgent?: boolean): Promise<supertest.SuperTestWithHost<Test> & Pick<supertest.Request, "type" | "
|
|
14
|
+
declare function TestHttp(app: Server | any, { moduleMap, meta }: Awaited<ReturnType<typeof Factory>>, isAgent?: boolean): Promise<supertest.SuperTestWithHost<Test> & Pick<supertest.Request, "type" | "key" | "query" | "use" | "on" | "set" | "accept" | "auth" | "withCredentials" | "retry" | "ok" | "redirects" | "timeout" | "buffer" | "serialize" | "parse" | "ca" | "pfx" | "cert"> & {
|
|
15
15
|
module: <T extends Construct>(Module: T) => SuperTestRequest<PickFunc<InstanceType<T>>>;
|
|
16
16
|
}>;
|
|
17
17
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { IncomingHttpHeaders } from 'node:http';
|
|
2
|
-
import { D as DefaultOptions, B as BaseContext
|
|
2
|
+
import { D as DefaultOptions, B as BaseContext } from './types-81be0ba3.js';
|
|
3
3
|
|
|
4
|
-
declare function resolveDep(ret: any, key: string): any;
|
|
5
4
|
interface HttpOptions extends DefaultOptions {
|
|
6
5
|
parallelRoute?: string | false;
|
|
7
6
|
parallelPlugins?: string[];
|
|
@@ -15,6 +14,5 @@ interface HttpContext extends BaseContext {
|
|
|
15
14
|
body: Record<string, any>;
|
|
16
15
|
headers: IncomingHttpHeaders;
|
|
17
16
|
}
|
|
18
|
-
declare function argToReq(params: ControllerMetaData['params'], args: any[], headers: Record<string, any>): any;
|
|
19
17
|
|
|
20
|
-
export { HttpOptions as H, HttpContext as a
|
|
18
|
+
export { HttpOptions as H, HttpContext as a };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { D as DefaultOptions, B as BaseContext } from './types-81be0ba3.js';
|
|
2
2
|
|
|
3
|
-
declare function genClientQueue(key?: string): string;
|
|
4
3
|
interface RpcServerOptions extends DefaultOptions {
|
|
5
4
|
}
|
|
6
5
|
interface RpcClientOptions {
|
|
@@ -15,4 +14,4 @@ interface RpcContext extends BaseContext {
|
|
|
15
14
|
isEvent?: boolean;
|
|
16
15
|
}
|
|
17
16
|
|
|
18
|
-
export { RpcServerOptions as R, RpcClientOptions as a, RpcContext as b
|
|
17
|
+
export { RpcServerOptions as R, RpcClientOptions as a, RpcContext as b };
|