phecda-server 7.0.0-alpha.9 → 7.0.0
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/README.md +10 -10
- package/assets/schema.json +12 -9
- package/bin/cli.mjs +96 -37
- package/dist/chunk-5SUY5UVC.js +258 -0
- package/dist/chunk-5SUY5UVC.js.map +1 -0
- package/dist/{chunk-7ZGYJ5OW.mjs → chunk-6JAHCTOT.mjs} +7 -2
- package/dist/chunk-6JAHCTOT.mjs.map +1 -0
- package/dist/{chunk-V5EYXVJT.js → chunk-EDAWJVJ4.js} +42 -25
- package/dist/chunk-EDAWJVJ4.js.map +1 -0
- package/dist/{chunk-FX3LDQII.js → chunk-H7OCHDZT.js} +61 -70
- package/dist/chunk-H7OCHDZT.js.map +1 -0
- package/dist/chunk-KRUOHWFR.js +306 -0
- package/dist/chunk-KRUOHWFR.js.map +1 -0
- package/dist/{chunk-KJUD2BKE.js → chunk-KUGU3UGO.js} +23 -18
- package/dist/chunk-KUGU3UGO.js.map +1 -0
- package/dist/{chunk-CVPZWDXU.mjs → chunk-LBH4RXQQ.mjs} +11 -20
- package/dist/chunk-LBH4RXQQ.mjs.map +1 -0
- package/dist/{chunk-FXTJ3BJ6.mjs → chunk-MDPW6WGF.mjs} +10 -4
- package/dist/chunk-MDPW6WGF.mjs.map +1 -0
- package/dist/{chunk-5RBTN33A.js → chunk-RLFCI3RG.js} +11 -5
- package/dist/chunk-RLFCI3RG.js.map +1 -0
- package/dist/{chunk-ODVWOXVB.mjs → chunk-TTHYUNOT.mjs} +18 -1
- package/dist/chunk-TTHYUNOT.mjs.map +1 -0
- package/dist/chunk-VDOICQ2U.mjs +258 -0
- package/dist/chunk-VDOICQ2U.mjs.map +1 -0
- package/dist/chunk-WTJKTICN.mjs +306 -0
- package/dist/chunk-WTJKTICN.mjs.map +1 -0
- package/dist/{core-D_cz0tKa.d.ts → core-BOo3uGFX.d.ts} +2 -2
- package/dist/{core-BDkhrEyf.d.mts → core-CF45G79J.d.mts} +2 -2
- package/dist/core-DbqWh47p.d.mts +50 -0
- package/dist/core-Rq7BhPHE.d.ts +50 -0
- package/dist/helper.d.mts +3 -5
- package/dist/helper.d.ts +3 -5
- package/dist/helper.js +4 -5
- package/dist/helper.js.map +1 -0
- package/dist/helper.mjs +3 -4
- package/dist/helper.mjs.map +1 -0
- 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 -40
- package/dist/http/elysia/index.js.map +1 -0
- package/dist/http/elysia/index.mjs +5 -3
- package/dist/http/elysia/index.mjs.map +1 -0
- package/dist/http/express/index.d.mts +3 -3
- package/dist/http/express/index.d.ts +3 -3
- package/dist/http/express/index.js +39 -37
- package/dist/http/express/index.js.map +1 -0
- package/dist/http/express/index.mjs +4 -2
- package/dist/http/express/index.mjs.map +1 -0
- package/dist/http/fastify/index.d.mts +3 -3
- package/dist/http/fastify/index.d.ts +3 -3
- package/dist/http/fastify/index.js +40 -38
- package/dist/http/fastify/index.js.map +1 -0
- package/dist/http/fastify/index.mjs +5 -3
- package/dist/http/fastify/index.mjs.map +1 -0
- package/dist/http/h3/index.d.mts +3 -3
- package/dist/http/h3/index.d.ts +3 -3
- package/dist/http/h3/index.js +40 -38
- package/dist/http/h3/index.js.map +1 -0
- package/dist/http/h3/index.mjs +4 -2
- package/dist/http/h3/index.mjs.map +1 -0
- package/dist/http/hono/index.d.mts +3 -3
- package/dist/http/hono/index.d.ts +3 -3
- package/dist/http/hono/index.js +36 -34
- package/dist/http/hono/index.js.map +1 -0
- package/dist/http/hono/index.mjs +4 -2
- package/dist/http/hono/index.mjs.map +1 -0
- package/dist/http/hyper-express/index.d.mts +3 -3
- package/dist/http/hyper-express/index.d.ts +3 -3
- package/dist/http/hyper-express/index.js +37 -35
- package/dist/http/hyper-express/index.js.map +1 -0
- package/dist/http/hyper-express/index.mjs +4 -2
- package/dist/http/hyper-express/index.mjs.map +1 -0
- package/dist/http/koa/index.d.mts +3 -3
- package/dist/http/koa/index.d.ts +3 -3
- package/dist/http/koa/index.js +39 -37
- package/dist/http/koa/index.js.map +1 -0
- package/dist/http/koa/index.mjs +4 -2
- package/dist/http/koa/index.mjs.map +1 -0
- package/dist/index.d.mts +76 -12
- package/dist/index.d.ts +76 -12
- package/dist/index.js +105 -49
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +68 -12
- package/dist/index.mjs.map +1 -0
- package/dist/{meta-BX5jhe4Z.d.mts → meta-BoS1E-Nz.d.mts} +6 -23
- package/dist/{meta-BX5jhe4Z.d.ts → meta-BoS1E-Nz.d.ts} +6 -23
- package/dist/rpc/bullmq/index.d.mts +4 -6
- package/dist/rpc/bullmq/index.d.ts +4 -6
- package/dist/rpc/bullmq/index.js +13 -80
- package/dist/rpc/bullmq/index.js.map +1 -0
- package/dist/rpc/bullmq/index.mjs +5 -72
- package/dist/rpc/bullmq/index.mjs.map +1 -0
- package/dist/rpc/electron/index.d.mts +13 -0
- package/dist/rpc/electron/index.d.ts +13 -0
- package/dist/rpc/electron/index.js +73 -0
- package/dist/rpc/electron/index.js.map +1 -0
- package/dist/rpc/electron/index.mjs +73 -0
- package/dist/rpc/electron/index.mjs.map +1 -0
- package/dist/rpc/kafka/index.d.mts +4 -9
- package/dist/rpc/kafka/index.d.ts +4 -9
- package/dist/rpc/kafka/index.js +12 -90
- package/dist/rpc/kafka/index.js.map +1 -0
- package/dist/rpc/kafka/index.mjs +5 -83
- package/dist/rpc/kafka/index.mjs.map +1 -0
- package/dist/rpc/nats/index.d.mts +4 -6
- package/dist/rpc/nats/index.d.ts +4 -6
- package/dist/rpc/nats/index.js +13 -72
- package/dist/rpc/nats/index.js.map +1 -0
- package/dist/rpc/nats/index.mjs +4 -63
- package/dist/rpc/nats/index.mjs.map +1 -0
- package/dist/rpc/rabbitmq/index.d.mts +4 -6
- package/dist/rpc/rabbitmq/index.d.ts +4 -6
- package/dist/rpc/rabbitmq/index.js +14 -79
- package/dist/rpc/rabbitmq/index.js.map +1 -0
- package/dist/rpc/rabbitmq/index.mjs +5 -70
- package/dist/rpc/rabbitmq/index.mjs.map +1 -0
- package/dist/rpc/redis/index.d.mts +4 -9
- package/dist/rpc/redis/index.d.ts +4 -9
- package/dist/rpc/redis/index.js +12 -78
- package/dist/rpc/redis/index.js.map +1 -0
- package/dist/rpc/redis/index.mjs +5 -71
- package/dist/rpc/redis/index.mjs.map +1 -0
- package/dist/rpc/web-ext/index.d.mts +2 -0
- package/dist/rpc/web-ext/index.d.ts +2 -0
- package/dist/rpc/web-ext/index.js +1 -0
- package/dist/rpc/web-ext/index.js.map +1 -0
- package/dist/rpc/web-ext/index.mjs +1 -0
- package/dist/rpc/web-ext/index.mjs.map +1 -0
- package/dist/rpc/ws/index.d.mts +14 -0
- package/dist/rpc/ws/index.d.ts +14 -0
- package/dist/rpc/ws/index.js +74 -0
- package/dist/rpc/ws/index.js.map +1 -0
- package/dist/rpc/ws/index.mjs +74 -0
- package/dist/rpc/ws/index.mjs.map +1 -0
- package/dist/test.d.mts +7 -3
- package/dist/test.d.ts +7 -3
- package/dist/test.js +7 -6
- package/dist/test.js.map +1 -0
- package/dist/test.mjs +3 -2
- package/dist/test.mjs.map +1 -0
- package/dist/types-CInz3bD0.d.ts +14 -0
- package/dist/types-E-rqlg3-.d.mts +14 -0
- package/dist/{types-DKVhyZk_.d.mts → types-SCJZFCYt.d.mts} +1 -1
- package/dist/{types-CMeuFoyd.d.ts → types-xruyYmyu.d.ts} +1 -1
- package/package.json +24 -8
- package/register/export.mjs +30 -0
- package/register/index.mjs +2 -3
- package/register/loader.mjs +83 -90
- package/register/utils.mjs +36 -6
- package/assets/ps.json +0 -24
- package/assets/tsconfig.json +0 -21
- package/dist/types-B-rUM9Fm.d.mts +0 -19
- package/dist/types-MxxtkZXw.d.ts +0 -19
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
# phecda-server
|
|
2
|
-
|
|
3
|
-
[DOCUMENT](https://fgsreally.github.io/phecda/)
|
|
4
|
-
|
|
5
|
-
nodejs server framework that provide IOC/type-reuse/http&rpc-adaptor
|
|
6
|
-
|
|
7
|
-
like `nestjs`+ `trpc`, work with `elysia/express/hono/h3/koa/fastify/hyper-express` and `redis/rabbimq/kafka/bullmq/nats`
|
|
8
|
-
|
|
9
|
-
Pragmatism , Progressive, Less code and Easy to maintain
|
|
10
|
-
|
|
1
|
+
# phecda-server
|
|
2
|
+
|
|
3
|
+
[DOCUMENT](https://fgsreally.github.io/phecda/)
|
|
4
|
+
|
|
5
|
+
nodejs server framework that provide IOC/type-reuse/http&rpc-adaptor
|
|
6
|
+
|
|
7
|
+
like `nestjs`+ `trpc`, work with `elysia/express/hono/h3/koa/fastify/hyper-express` and `redis/rabbimq/kafka/bullmq/nats`
|
|
8
|
+
|
|
9
|
+
Pragmatism , Progressive, Less code and Easy to maintain
|
|
10
|
+
|
package/assets/schema.json
CHANGED
|
@@ -38,16 +38,19 @@
|
|
|
38
38
|
},
|
|
39
39
|
"description": "Including the module's file middle name, such as controller mapping to xx.controller.ts"
|
|
40
40
|
},
|
|
41
|
-
|
|
42
|
-
"type": "object",
|
|
43
|
-
"additionalProperties": {
|
|
44
|
-
"type": "string"
|
|
45
|
-
},
|
|
46
|
-
"description": "Virtual module, just like in Vite."
|
|
47
|
-
},
|
|
41
|
+
|
|
48
42
|
"unimport": {
|
|
49
|
-
"
|
|
50
|
-
|
|
43
|
+
"oneOf": [
|
|
44
|
+
{
|
|
45
|
+
"type": "object",
|
|
46
|
+
"description": "Includes the arguments passed to unimport"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"type": "boolean",
|
|
50
|
+
"enum": [false],
|
|
51
|
+
"description": "Disable unimport"
|
|
52
|
+
}
|
|
53
|
+
]
|
|
51
54
|
}
|
|
52
55
|
},
|
|
53
56
|
|
package/bin/cli.mjs
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
1
|
-
#! /usr/bin/env node
|
|
1
|
+
#! /usr/bin/env node
|
|
2
2
|
import { fork } from 'child_process'
|
|
3
3
|
import { createRequire } from 'module'
|
|
4
|
-
import { fileURLToPath } from 'url'
|
|
5
|
-
|
|
6
|
-
import { dirname, resolve } from 'path'
|
|
7
4
|
import pc from 'picocolors'
|
|
8
5
|
import cac from 'cac'
|
|
9
6
|
import fse from 'fs-extra'
|
|
10
|
-
import { log } from '../dist/index.mjs'
|
|
7
|
+
import { log as psLog } from '../dist/index.mjs'
|
|
8
|
+
|
|
9
|
+
const log = (...args) => {
|
|
10
|
+
if (process.env.PS_BAN_CLI_LOG)
|
|
11
|
+
return
|
|
12
|
+
|
|
13
|
+
psLog(...args)
|
|
14
|
+
}
|
|
11
15
|
|
|
12
16
|
const cli = cac('phecda').option('-c,--config <config>', 'config file', {
|
|
13
17
|
default: 'ps.json',
|
|
18
|
+
}).option('-n,--node-args <node-args>', 'args that will be passed to nodejs', {
|
|
19
|
+
default: '',
|
|
14
20
|
})
|
|
15
21
|
|
|
16
|
-
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
17
|
-
|
|
18
22
|
const require = createRequire(import.meta.url)
|
|
19
23
|
let child
|
|
20
24
|
|
|
@@ -29,33 +33,25 @@ if (nodeVersion < 18.19) {
|
|
|
29
33
|
}
|
|
30
34
|
|
|
31
35
|
function startChild(file, args) {
|
|
32
|
-
child = fork(file, {
|
|
36
|
+
child = globalThis.PS_CREATE_CHILD?.() || fork(file, {
|
|
33
37
|
env: { ...process.env },
|
|
34
38
|
stdio: 'inherit',
|
|
35
39
|
execArgv: [
|
|
40
|
+
...args,
|
|
36
41
|
nodeVersion < 18.19
|
|
37
42
|
? '--loader=phecda-server/register/loader.mjs'
|
|
38
43
|
: '--import=phecda-server/register',
|
|
39
|
-
...args,
|
|
40
44
|
],
|
|
41
45
|
})
|
|
42
46
|
|
|
43
47
|
closePromise = new Promise((resolve) => {
|
|
44
48
|
child.once('exit', (code) => {
|
|
45
|
-
if (code ===
|
|
46
|
-
log('only generate code')
|
|
47
|
-
process.exit(0)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (code === 5) {
|
|
51
|
-
log('Does not comply with strict mode', 'error')
|
|
52
|
-
process.exit(0)
|
|
53
|
-
}
|
|
54
|
-
if (code >= 2) {
|
|
55
|
-
// for relaunch
|
|
56
|
-
log('relaunch...')
|
|
49
|
+
if (code === 4171)
|
|
57
50
|
startChild(file, args)
|
|
58
|
-
|
|
51
|
+
|
|
52
|
+
if (code === 4172)
|
|
53
|
+
return process.exit()
|
|
54
|
+
|
|
59
55
|
child = undefined
|
|
60
56
|
|
|
61
57
|
resolve()
|
|
@@ -80,7 +76,7 @@ process.on('SIGINT', () => {
|
|
|
80
76
|
|
|
81
77
|
cli
|
|
82
78
|
.command('init [root]', 'init config file')
|
|
83
|
-
.allowUnknownOptions()
|
|
79
|
+
// .allowUnknownOptions()
|
|
84
80
|
.option('-t,--tsconfig <tsconfig>', 'init tsconfig file', {
|
|
85
81
|
default: 'tsconfig.json',
|
|
86
82
|
})
|
|
@@ -88,22 +84,82 @@ cli
|
|
|
88
84
|
if (root)
|
|
89
85
|
process.chdir(root)
|
|
90
86
|
|
|
87
|
+
let hasUnimport
|
|
88
|
+
|
|
89
|
+
try {
|
|
90
|
+
await import('unimport')
|
|
91
|
+
hasUnimport = true
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
catch (e) {
|
|
95
|
+
hasUnimport = false
|
|
96
|
+
}
|
|
97
|
+
|
|
91
98
|
const tsconfigPath = options.tsconfig
|
|
92
|
-
const psconfigPath = options.config
|
|
99
|
+
const psconfigPath = process.env.PS_CONFIG_FILE || options.config
|
|
93
100
|
|
|
94
101
|
if (!fse.existsSync(tsconfigPath)) {
|
|
95
102
|
log(`create ${tsconfigPath}`)
|
|
96
103
|
|
|
97
|
-
await fse.
|
|
98
|
-
resolve(__dirname, '../assets/tsconfig.json'),
|
|
104
|
+
await fse.outputJSON(
|
|
99
105
|
tsconfigPath,
|
|
106
|
+
{
|
|
107
|
+
compilerOptions: {
|
|
108
|
+
target: 'esnext',
|
|
109
|
+
useDefineForClassFields: false,
|
|
110
|
+
experimentalDecorators: true,
|
|
111
|
+
emitDecoratorMetadata: true,
|
|
112
|
+
module: 'esnext',
|
|
113
|
+
lib: ['esnext', 'DOM'],
|
|
114
|
+
paths: {
|
|
115
|
+
|
|
116
|
+
},
|
|
117
|
+
strictPropertyInitialization: false,
|
|
118
|
+
moduleResolution: 'bundler',
|
|
119
|
+
strict: true,
|
|
120
|
+
resolveJsonModule: true,
|
|
121
|
+
esModuleInterop: true,
|
|
122
|
+
noEmit: true,
|
|
123
|
+
noUnusedLocals: true,
|
|
124
|
+
noUnusedParameters: true,
|
|
125
|
+
noImplicitReturns: true,
|
|
126
|
+
skipLibCheck: true,
|
|
127
|
+
},
|
|
128
|
+
include: ['.', hasUnimport ? (process.env.PS_DTS_PATH || 'ps.d.ts') : undefined],
|
|
129
|
+
},
|
|
130
|
+
|
|
100
131
|
)
|
|
101
132
|
}
|
|
102
133
|
|
|
103
134
|
if (!fse.existsSync(psconfigPath)) {
|
|
104
135
|
log(`create ${psconfigPath}`)
|
|
105
136
|
|
|
106
|
-
await fse.
|
|
137
|
+
await fse.outputJSON(psconfigPath, {
|
|
138
|
+
$schema: './node_modules/phecda-server/assets/schema.json',
|
|
139
|
+
resolve: [
|
|
140
|
+
{
|
|
141
|
+
source: 'controller',
|
|
142
|
+
importer: 'http',
|
|
143
|
+
path: '.ps/http.js',
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
source: 'rpc',
|
|
147
|
+
importer: 'client',
|
|
148
|
+
path: '.ps/rpc.js',
|
|
149
|
+
},
|
|
150
|
+
],
|
|
151
|
+
unimport: hasUnimport && {
|
|
152
|
+
dirs: [
|
|
153
|
+
'.',
|
|
154
|
+
],
|
|
155
|
+
dirsScanOptions: {
|
|
156
|
+
filePatterns: [
|
|
157
|
+
'*.{service,controller,module,rpc,solo,guard,extension,pipe,filter,addon}.ts',
|
|
158
|
+
],
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
moduleFile: [],
|
|
162
|
+
})
|
|
107
163
|
}
|
|
108
164
|
|
|
109
165
|
log('init finish')
|
|
@@ -112,12 +168,13 @@ cli
|
|
|
112
168
|
cli
|
|
113
169
|
.command('<file> [root]', 'run file')
|
|
114
170
|
.alias('run')
|
|
115
|
-
.allowUnknownOptions()
|
|
116
|
-
.
|
|
117
|
-
.option('-p,--prod [prod]', 'prod mode', {
|
|
171
|
+
// .allowUnknownOptions()
|
|
172
|
+
.option('-p,--prod', 'prod mode', {
|
|
118
173
|
default: false,
|
|
119
174
|
})
|
|
120
175
|
.action((file, root, options) => {
|
|
176
|
+
const nodeArgs = options.nodeArgs.split(' ').filter(Boolean)
|
|
177
|
+
|
|
121
178
|
if (root)
|
|
122
179
|
process.chdir(root)
|
|
123
180
|
|
|
@@ -126,11 +183,11 @@ cli
|
|
|
126
183
|
else
|
|
127
184
|
process.env.NODE_ENV = 'development'
|
|
128
185
|
|
|
129
|
-
process.env.PS_CONFIG_FILE = options.config
|
|
186
|
+
process.env.PS_CONFIG_FILE = process.env.PS_CONFIG_FILE || options.config
|
|
130
187
|
|
|
131
188
|
log('process start!')
|
|
132
189
|
|
|
133
|
-
startChild(file,
|
|
190
|
+
startChild(file, nodeArgs)
|
|
134
191
|
console.log(`${pc.green('->')} press ${pc.green('e')} to exit`)
|
|
135
192
|
console.log(`${pc.green('->')} press ${pc.green('r')} to relaunch`)
|
|
136
193
|
console.log(`${pc.green('->')} press ${pc.green('c')} to clear terminal`)
|
|
@@ -143,12 +200,12 @@ cli
|
|
|
143
200
|
if (closePromise)
|
|
144
201
|
await closePromise
|
|
145
202
|
log('relaunch...')
|
|
146
|
-
startChild(file,
|
|
203
|
+
startChild(file, nodeArgs)
|
|
147
204
|
}
|
|
148
205
|
else {
|
|
149
206
|
log('relaunch...')
|
|
150
207
|
|
|
151
|
-
startChild(file,
|
|
208
|
+
startChild(file, nodeArgs)
|
|
152
209
|
}
|
|
153
210
|
}
|
|
154
211
|
if (input === 'e')
|
|
@@ -161,13 +218,15 @@ cli
|
|
|
161
218
|
|
|
162
219
|
cli
|
|
163
220
|
.command('generate <file> [root]', 'generate code(mainly for ci)')
|
|
164
|
-
.allowUnknownOptions()
|
|
221
|
+
// .allowUnknownOptions()
|
|
165
222
|
.action((file, root, options) => {
|
|
223
|
+
const nodeArgs = options.nodeArgs.split(' ').filter(Boolean)
|
|
224
|
+
|
|
166
225
|
if (root)
|
|
167
226
|
process.chdir(root)
|
|
168
227
|
process.env.PS_GENERATE = 'true'
|
|
169
|
-
process.env.PS_CONFIG_FILE = options.config
|
|
170
|
-
startChild(file,
|
|
228
|
+
process.env.PS_CONFIG_FILE = process.env.PS_CONFIG_FILE || options.config
|
|
229
|
+
startChild(file, nodeArgs)
|
|
171
230
|
})
|
|
172
231
|
|
|
173
232
|
cli.help()
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkRLFCI3RGjs = require('./chunk-RLFCI3RG.js');
|
|
4
|
+
|
|
5
|
+
// src/decorators/param.ts
|
|
6
|
+
var _phecdacore = require('phecda-core');
|
|
7
|
+
function BaseParam(data) {
|
|
8
|
+
return (target, property, index) => {
|
|
9
|
+
if (!property) return;
|
|
10
|
+
_phecdacore.setMeta.call(void 0, target, property, index, data);
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
_chunkRLFCI3RGjs.__name.call(void 0, BaseParam, "BaseParam");
|
|
14
|
+
function Body(key = "") {
|
|
15
|
+
return BaseParam({
|
|
16
|
+
type: "body",
|
|
17
|
+
key
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
_chunkRLFCI3RGjs.__name.call(void 0, Body, "Body");
|
|
21
|
+
function Head(key) {
|
|
22
|
+
return BaseParam({
|
|
23
|
+
type: "headers",
|
|
24
|
+
key: key.toLowerCase()
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
_chunkRLFCI3RGjs.__name.call(void 0, Head, "Head");
|
|
28
|
+
function Query(key = "") {
|
|
29
|
+
return BaseParam({
|
|
30
|
+
type: "query",
|
|
31
|
+
key
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
_chunkRLFCI3RGjs.__name.call(void 0, Query, "Query");
|
|
35
|
+
function Param(key) {
|
|
36
|
+
return BaseParam({
|
|
37
|
+
type: "params",
|
|
38
|
+
key
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
_chunkRLFCI3RGjs.__name.call(void 0, Param, "Param");
|
|
42
|
+
function Arg(target, k, index) {
|
|
43
|
+
BaseParam({
|
|
44
|
+
type: "args",
|
|
45
|
+
key: `${index}`
|
|
46
|
+
})(target, k, index);
|
|
47
|
+
}
|
|
48
|
+
_chunkRLFCI3RGjs.__name.call(void 0, Arg, "Arg");
|
|
49
|
+
function OneFile(key = "") {
|
|
50
|
+
return BaseParam({
|
|
51
|
+
type: "file",
|
|
52
|
+
key
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
_chunkRLFCI3RGjs.__name.call(void 0, OneFile, "OneFile");
|
|
56
|
+
function ManyFiles(key = "") {
|
|
57
|
+
return BaseParam({
|
|
58
|
+
type: "files",
|
|
59
|
+
key
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
_chunkRLFCI3RGjs.__name.call(void 0, ManyFiles, "ManyFiles");
|
|
63
|
+
|
|
64
|
+
// src/decorators/aop.ts
|
|
65
|
+
|
|
66
|
+
function Guard(...guards) {
|
|
67
|
+
return (target, property) => {
|
|
68
|
+
_phecdacore.setMeta.call(void 0, target, property, void 0, {
|
|
69
|
+
guards
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
_chunkRLFCI3RGjs.__name.call(void 0, Guard, "Guard");
|
|
74
|
+
function Addon(...addons) {
|
|
75
|
+
return (target, property) => {
|
|
76
|
+
_phecdacore.setMeta.call(void 0, target, property, void 0, {
|
|
77
|
+
addons
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
_chunkRLFCI3RGjs.__name.call(void 0, Addon, "Addon");
|
|
82
|
+
function Filter(filter) {
|
|
83
|
+
return (target, property) => {
|
|
84
|
+
_phecdacore.setMeta.call(void 0, target, property, void 0, {
|
|
85
|
+
filter
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
_chunkRLFCI3RGjs.__name.call(void 0, Filter, "Filter");
|
|
90
|
+
function Pipe(pipe) {
|
|
91
|
+
return (target, property, index) => {
|
|
92
|
+
if (typeof index === "number") {
|
|
93
|
+
BaseParam({
|
|
94
|
+
pipe
|
|
95
|
+
})(target, property, index);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
_phecdacore.setMeta.call(void 0, target, property, void 0, {
|
|
99
|
+
pipe
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
_chunkRLFCI3RGjs.__name.call(void 0, Pipe, "Pipe");
|
|
104
|
+
|
|
105
|
+
// src/decorators/http.ts
|
|
106
|
+
|
|
107
|
+
function Route(route, type) {
|
|
108
|
+
return (target, property) => {
|
|
109
|
+
_phecdacore.setMeta.call(void 0, target, property, void 0, {
|
|
110
|
+
http: {
|
|
111
|
+
route,
|
|
112
|
+
type
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
_chunkRLFCI3RGjs.__name.call(void 0, Route, "Route");
|
|
118
|
+
function Header(headers) {
|
|
119
|
+
return (target, property) => {
|
|
120
|
+
_phecdacore.setMeta.call(void 0, target, property, void 0, {
|
|
121
|
+
http: {
|
|
122
|
+
headers
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
_chunkRLFCI3RGjs.__name.call(void 0, Header, "Header");
|
|
128
|
+
function Get(route = "") {
|
|
129
|
+
return Route(route, "get");
|
|
130
|
+
}
|
|
131
|
+
_chunkRLFCI3RGjs.__name.call(void 0, Get, "Get");
|
|
132
|
+
function Post(route = "") {
|
|
133
|
+
return Route(route, "post");
|
|
134
|
+
}
|
|
135
|
+
_chunkRLFCI3RGjs.__name.call(void 0, Post, "Post");
|
|
136
|
+
function Put(route = "") {
|
|
137
|
+
return Route(route, "put");
|
|
138
|
+
}
|
|
139
|
+
_chunkRLFCI3RGjs.__name.call(void 0, Put, "Put");
|
|
140
|
+
function Search(route = "") {
|
|
141
|
+
return Route(route, "search");
|
|
142
|
+
}
|
|
143
|
+
_chunkRLFCI3RGjs.__name.call(void 0, Search, "Search");
|
|
144
|
+
function Patch(route = "") {
|
|
145
|
+
return Route(route, "patch");
|
|
146
|
+
}
|
|
147
|
+
_chunkRLFCI3RGjs.__name.call(void 0, Patch, "Patch");
|
|
148
|
+
function Delete(route = "") {
|
|
149
|
+
return Route(route, "delete");
|
|
150
|
+
}
|
|
151
|
+
_chunkRLFCI3RGjs.__name.call(void 0, Delete, "Delete");
|
|
152
|
+
function Controller(prefix = "") {
|
|
153
|
+
return (target) => {
|
|
154
|
+
_phecdacore.setMeta.call(void 0, target, void 0, void 0, {
|
|
155
|
+
controller: "http",
|
|
156
|
+
http: {
|
|
157
|
+
prefix
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
_chunkRLFCI3RGjs.__name.call(void 0, Controller, "Controller");
|
|
163
|
+
|
|
164
|
+
// src/decorators/rpc.ts
|
|
165
|
+
|
|
166
|
+
function Queue(queue = "", isEvent) {
|
|
167
|
+
return (target, property) => {
|
|
168
|
+
_phecdacore.setMeta.call(void 0, target, property, void 0, {
|
|
169
|
+
rpc: {
|
|
170
|
+
queue,
|
|
171
|
+
isEvent
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
_chunkRLFCI3RGjs.__name.call(void 0, Queue, "Queue");
|
|
177
|
+
function Rpc() {
|
|
178
|
+
return (target) => {
|
|
179
|
+
_phecdacore.setMeta.call(void 0, target, void 0, void 0, {
|
|
180
|
+
controller: "rpc"
|
|
181
|
+
});
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
_chunkRLFCI3RGjs.__name.call(void 0, Rpc, "Rpc");
|
|
185
|
+
|
|
186
|
+
// src/decorators/ctx.ts
|
|
187
|
+
|
|
188
|
+
var Ctx = /* @__PURE__ */ _chunkRLFCI3RGjs.__name.call(void 0, (target, property) => {
|
|
189
|
+
_phecdacore.setMeta.call(void 0, target, _phecdacore.SHARE_KEY, void 0, {
|
|
190
|
+
ctxs: [
|
|
191
|
+
property
|
|
192
|
+
]
|
|
193
|
+
});
|
|
194
|
+
}, "Ctx");
|
|
195
|
+
function Define(key, value) {
|
|
196
|
+
return (target, property, index) => {
|
|
197
|
+
if (typeof index === "number") {
|
|
198
|
+
_phecdacore.setMeta.call(void 0, target, property, void 0, {
|
|
199
|
+
params: [
|
|
200
|
+
{
|
|
201
|
+
define: {
|
|
202
|
+
[key]: value
|
|
203
|
+
},
|
|
204
|
+
index
|
|
205
|
+
}
|
|
206
|
+
]
|
|
207
|
+
});
|
|
208
|
+
} else {
|
|
209
|
+
_phecdacore.setMeta.call(void 0, target, property, void 0, {
|
|
210
|
+
define: {
|
|
211
|
+
[key]: value
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
_chunkRLFCI3RGjs.__name.call(void 0, Define, "Define");
|
|
218
|
+
|
|
219
|
+
// src/decorators/openapi.ts
|
|
220
|
+
|
|
221
|
+
function ApiDoc(config) {
|
|
222
|
+
return function(target, propertyKey, descriptor) {
|
|
223
|
+
_phecdacore.setMeta.call(void 0, target, propertyKey, void 0, {
|
|
224
|
+
openapi: config
|
|
225
|
+
});
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
_chunkRLFCI3RGjs.__name.call(void 0, ApiDoc, "ApiDoc");
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
exports.BaseParam = BaseParam; exports.Body = Body; exports.Head = Head; exports.Query = Query; exports.Param = Param; exports.Arg = Arg; exports.OneFile = OneFile; exports.ManyFiles = ManyFiles; exports.Guard = Guard; exports.Addon = Addon; exports.Filter = Filter; exports.Pipe = Pipe; exports.Route = Route; exports.Header = Header; exports.Get = Get; exports.Post = Post; exports.Put = Put; exports.Search = Search; exports.Patch = Patch; exports.Delete = Delete; exports.Controller = Controller; exports.Queue = Queue; exports.Rpc = Rpc; exports.Ctx = Ctx; exports.Define = Define; exports.ApiDoc = ApiDoc;
|
|
258
|
+
//# sourceMappingURL=chunk-5SUY5UVC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["d:\\myproject\\phecda\\packages\\server\\dist\\chunk-5SUY5UVC.js"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACA;AACA,yCAAqC;AACrC,SAAS,SAAS,CAAC,IAAI,EAAE;AACzB,EAAE,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG;AACtC,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,MAAM;AACzB,IAAI,iCAAO,MAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,CAAC;AAC1C,EAAE,CAAC;AACH;AACA,qCAAM,SAAU,EAAE,WAAW,CAAC;AAC9B,SAAS,IAAI,CAAC,IAAI,EAAE,E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A;AACA,EAAA;AACA,IAAA;AACA,MAAA;AACA,QAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,IAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAA;AACA,IAAA;AACA,MAAA;AACA,QAAA;AACA,QAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA,EAAA;AACA,IAAA;AACA,MAAA;AACA,QAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA,EAAA;AACA;AACA;AACA;AACA,EAAA;AACA;AACA;AACA;AACA,EAAA;AACA;AACA;AACA;AACA,EAAA;AACA;AACA;AACA;AACA,EAAA;AACA;AACA;AACA;AACA,EAAA;AACA;AACA;AACA;AACA,EAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,QAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAA;AACA,IAAA;AACA,MAAA;AACA,QAAA;AACA,QAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA,EAAA;AACA,IAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAA;AACA,IAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA,EAAA;AACA,IAAA;AACA,MAAA;AACA,QAAA;AACA,UAAA;AACA,YAAA;AACA,cAAA;AACA,YAAA;AACA,YAAA;AACA,UAAA;AACA,QAAA;AACA,MAAA;AACA,IAAA;AACA,MAAA;AACA,QAAA;AACA,UAAA;AACA,QAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAA;AACA,IAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"D:\\myproject\\phecda\\packages\\server\\dist\\chunk-5SUY5UVC.js","sourcesContent":[null]}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
HMR,
|
|
3
3
|
IS_ONLY_GENERATE,
|
|
4
|
+
PS_EXIT_CODE,
|
|
4
5
|
__name,
|
|
5
6
|
log
|
|
6
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-MDPW6WGF.mjs";
|
|
7
8
|
|
|
8
9
|
// src/meta.ts
|
|
9
10
|
var Meta = class {
|
|
@@ -63,7 +64,10 @@ var ServerPhecda = class {
|
|
|
63
64
|
for (const model of models) await this.buildDepModule(model);
|
|
64
65
|
this.hmr();
|
|
65
66
|
this.generateCode().then(() => {
|
|
66
|
-
if (IS_ONLY_GENERATE)
|
|
67
|
+
if (IS_ONLY_GENERATE) {
|
|
68
|
+
log("Only generate code");
|
|
69
|
+
process.exit(PS_EXIT_CODE.EXIT);
|
|
70
|
+
}
|
|
67
71
|
});
|
|
68
72
|
}
|
|
69
73
|
generateCode = /* @__PURE__ */ __name(async () => {
|
|
@@ -327,3 +331,4 @@ export {
|
|
|
327
331
|
Factory,
|
|
328
332
|
useS
|
|
329
333
|
};
|
|
334
|
+
//# sourceMappingURL=chunk-6JAHCTOT.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/meta.ts","../src/core.ts"],"sourcesContent":["import type { BaseRequestType } from './types'\r\n\r\nexport interface ServiceMetaData {\r\n func: string\r\n name: string\r\n tag: string\r\n define?: any\r\n [key: string]: any\r\n}\r\n\r\nexport interface ControllerMetaData extends ServiceMetaData {\r\n controller: string\r\n http?: {\r\n type: BaseRequestType\r\n prefix: string\r\n route: string\r\n headers?: Record<string, string>\r\n\r\n }\r\n rpc?: {\r\n queue?: string\r\n isEvent?: boolean\r\n }\r\n ctxs?: string[]\r\n params: { type: string; index: number; key: string; pipe?: string; define: Record<string, any> }[]\r\n guards: string[]\r\n pipe?: string\r\n filter?: string\r\n addons: string[]\r\n\r\n}\r\n\r\nexport type MetaData = ControllerMetaData | ServiceMetaData\r\n\r\nexport class Meta {\r\n constructor(public data: MetaData, public paramsType: any[]) {\r\n\r\n }\r\n}\r\n\r\nexport interface ControllerMeta extends Meta {\r\n data: ControllerMetaData\r\n}\r\n","import 'reflect-metadata'\r\nimport EventEmitter from 'node:events'\r\nimport type { Construct, Phecda, WatcherParam } from 'phecda-core'\r\nimport { getInject, getMergedMeta, getMetaKey, getMetaParams, getTag, invokeInit, invokeUnmount, setInject } from 'phecda-core'\r\nimport Debug from 'debug'\r\nimport type { Emitter } from './types'\r\nimport type { MetaData } from './meta'\r\nimport { Meta } from './meta'\r\nimport { log } from './utils'\r\nimport { IS_ONLY_GENERATE, PS_EXIT_CODE } from './common'\r\nimport type { Generator } from './generator'\r\nimport { HMR } from './hmr'\r\n\r\nconst debug = Debug('phecda-server(Factory)')\r\n// TODO: support both emitter types and origin emitter type in future\r\nexport const emitter: Emitter = new EventEmitter() as any\r\nexport interface Options {\r\n parseModule?: (module: any) => any\r\n parseMeta?: (meta: Meta) => Meta | null | undefined\r\n generators?: Generator[]\r\n namespace?: string\r\n\r\n}\r\n\r\nexport function defaultServerInject() {\r\n if (!getInject('watcher')) {\r\n setInject('watcher', ({ eventName, instance, property, options }: WatcherParam) => {\r\n const fn = typeof instance[property] === 'function' ? instance[property].bind(instance) : (v: any) => instance[property] = v\r\n\r\n if (options?.once)\r\n (emitter as any).once(eventName, fn)\r\n\r\n else\r\n (emitter as any).on(eventName, fn)\r\n\r\n return () => {\r\n (emitter as any).off(eventName, fn)\r\n }\r\n })\r\n }\r\n}\r\n\r\nexport const phecdaNamespace = new Map<string, ServerPhecda>()\r\n\r\nexport class ServerPhecda {\r\n moduleMap = new Map<PropertyKey, InstanceType<Construct>>()\r\n meta: Meta[] = []\r\n modelMap = new WeakMap<InstanceType<Construct>, Construct>()\r\n modelSet = new WeakSet<Construct>()\r\n dependenceGraph = new Map<PropertyKey, Set<PropertyKey>>()\r\n parseModule: (module: any) => any\r\n parseMeta: (meta: Meta) => Meta | null | undefined\r\n generators: Generator[]\r\n constructor(options: Options) {\r\n defaultServerInject()\r\n const { namespace = 'default', parseModule = (module: any) => module, parseMeta = (meta: any) => meta, generators = [] } = options\r\n phecdaNamespace.set(namespace, this)\r\n this.parseMeta = parseMeta\r\n this.parseModule = parseModule\r\n this.generators = generators\r\n }\r\n\r\n async start(models: Construct[]) {\r\n for (const model of models)\r\n await this.buildDepModule(model)\r\n\r\n this.hmr()\r\n this.generateCode().then(() => {\r\n if (IS_ONLY_GENERATE) {\r\n log('Only generate code')\r\n process.exit(PS_EXIT_CODE.EXIT)// only output code/work for ci\r\n }\r\n })\r\n }\r\n\r\n generateCode = async () => {\r\n return Promise.all(this.generators.map((generator) => {\r\n debug(`generate \"${generator.name}\" code to ${generator.path}`)\r\n\r\n return generator.output(this.meta)\r\n }))\r\n }\r\n\r\n hmr() {\r\n HMR(async (oldModels, newModels) => {\r\n debug('reload models ')\r\n\r\n await this.replace(oldModels, newModels)\r\n\r\n this.generateCode()\r\n })\r\n }\r\n // async add(Model: Construct) {\r\n // const tag = getTag(Model)\r\n\r\n // const oldInstance = await this.del(tag)\r\n // const { module: newModule } = await this.buildDepModule(Model)\r\n\r\n // if (oldInstance && this.dependenceGraph.has(tag)) {\r\n // debug(`replace module \"${String(tag)}\"`);\r\n\r\n // [...this.dependenceGraph.get(tag)!].forEach((tag) => {\r\n // const module = this.moduleMap.get(tag)\r\n // for (const key in module) {\r\n // if (module[key] === oldInstance)\r\n // module[key] = newModule\r\n // }\r\n // })\r\n // }\r\n // }\r\n\r\n // async del(modelOrTag: Construct | PropertyKey) {\r\n // const tag = typeof modelOrTag === 'function' ? getTag(modelOrTag) : modelOrTag\r\n\r\n // if (!this.moduleMap.has(tag))\r\n // return\r\n\r\n // const module = this.moduleMap.get(tag)\r\n\r\n // debug(`unmount module \"${String(tag)}\"`)\r\n // await invokeUnmount(module)\r\n // debug(`del module \"${String(tag)}\"`)\r\n\r\n // this.moduleMap.delete(tag)\r\n // this.modelMap.delete(module)\r\n // for (let i = this.meta.length - 1; i >= 0; i--) {\r\n // if (this.meta[i].data.tag === tag)\r\n // this.meta.splice(i, 1)\r\n // }\r\n // return module\r\n // }\r\n\r\n async destroy() {\r\n debug('destroy all')\r\n\r\n this.replace(Object.values(this.modelMap), [])\r\n }\r\n\r\n createProxyModule(tag: PropertyKey) {\r\n // eslint-disable-next-line @typescript-eslint/no-this-alias\r\n const that = this\r\n return new Proxy({}, {\r\n get(_target, prop) {\r\n const module = that.moduleMap.get(tag)\r\n return Reflect.get(module, prop, module)\r\n },\r\n set(_target, prop, newValue) {\r\n const module = that.moduleMap.get(tag)\r\n\r\n return Reflect.set(module, prop, newValue, module)\r\n },\r\n has(_target, prop) {\r\n return Reflect.has(that.moduleMap.get(tag), prop)\r\n },\r\n ownKeys() {\r\n return Reflect.ownKeys(that.moduleMap.get(tag))\r\n },\r\n getPrototypeOf() {\r\n return Reflect.getPrototypeOf(that.moduleMap.get(tag))\r\n },\r\n getOwnPropertyDescriptor(_target, prop) {\r\n return Reflect.getOwnPropertyDescriptor(that.moduleMap.get(tag), prop)\r\n },\r\n })\r\n }\r\n\r\n protected async buildDepModule(Model: Construct) {\r\n const paramtypes = getParamTypes(Model) as Construct[]\r\n let module: InstanceType<Construct>\r\n const tag = getTag(Model)\r\n\r\n if (this.moduleMap.has(tag)) {\r\n module = this.moduleMap.get(tag)\r\n if (!module) {\r\n log(`Exist Circular-Dependency or Multiple modules with the same tag [${String(tag)}]`, 'warn')\r\n return { module: this.createProxyModule(tag), tag }\r\n }\r\n if (this.modelMap.get(module) !== Model && !this.modelSet.has(Model)) {\r\n this.modelSet.add(Model)// a module will only warn once\r\n\r\n if (module instanceof Model)\r\n log(`Module taged ${String(tag)} has been overridden`)// legal override\r\n else\r\n log(`Synonym module: Module taged \"${String(tag)}\" has been loaded before, so phecda-server won't load Module \"${Model.name}\"`, 'warn')\r\n }\r\n return { module, tag }\r\n }\r\n this.moduleMap.set(tag, undefined)\r\n debug(`instantiate module \"${String(tag)}\"`)\r\n\r\n if (paramtypes) {\r\n const paramtypesInstances = [] as any[]\r\n for (const i in paramtypes) {\r\n const { module: sub, tag: subTag } = await this.buildDepModule(paramtypes[i])\r\n paramtypesInstances[i] = sub\r\n if (!this.dependenceGraph.has(subTag))\r\n this.dependenceGraph.set(subTag, new Set())\r\n this.dependenceGraph.get(subTag)!.add(tag)\r\n }\r\n\r\n module = this.parseModule(new Model(...paramtypesInstances))\r\n }\r\n else {\r\n module = this.parseModule(new Model())\r\n }\r\n this.meta.push(...getMetaFromInstance(module, tag, Model.name).map(this.parseMeta).filter(item => !!item))\r\n\r\n debug(`init module \"${String(tag)}\"`)\r\n\r\n if (!IS_ONLY_GENERATE)// ??\r\n\r\n await invokeInit(module)\r\n\r\n debug(`add module \"${String(tag)}\"`)\r\n\r\n this.moduleMap.set(tag, module)\r\n this.modelMap.set(module, Model)\r\n return { module, tag }\r\n }\r\n\r\n async replace(oldModels: Construct[], newModels: Construct[]) {\r\n const oldModules = (await Promise.all(oldModels.map(async (model) => {\r\n const tag = getTag(model)\r\n if (!this.has(tag))\r\n return\r\n const module = this.moduleMap.get(tag)\r\n\r\n debug(`unmount module \"${String(tag)}\"`)\r\n await invokeUnmount(module)\r\n debug(`del module \"${String(tag)}\"`)\r\n\r\n this.moduleMap.delete(tag)\r\n this.modelMap.delete(module)\r\n for (let i = this.meta.length - 1; i >= 0; i--) {\r\n if (this.meta[i].data.tag === tag)\r\n this.meta.splice(i, 1)\r\n }\r\n return module\r\n }))).filter(item => item)\r\n\r\n for (const model of newModels) {\r\n debug(`mount module: ${model.name}`)\r\n await this.buildDepModule(model)\r\n }\r\n\r\n debug('replace old modules')\r\n\r\n for (const module of oldModules) {\r\n const tag = getTag(module)\r\n if (this.dependenceGraph.has(tag)) {\r\n [...this.dependenceGraph.get(tag)!].forEach((depTag) => {\r\n const depModule = this.moduleMap.get(depTag)\r\n\r\n if (depModule) {\r\n for (const key in depModule) {\r\n if (depModule[key] === module)\r\n depModule[key] = this.moduleMap.get(tag)\r\n }\r\n }\r\n })\r\n }\r\n }\r\n }\r\n\r\n has(modelOrTag: Construct | PropertyKey) {\r\n return this.moduleMap.has(typeof modelOrTag === 'function' ? getTag(modelOrTag) : modelOrTag)\r\n }\r\n\r\n get<Model extends Construct>(modelOrTag: Model | PropertyKey): InstanceType<Model> {\r\n const tag = typeof modelOrTag === 'function' ? getTag(modelOrTag) : modelOrTag\r\n if (!this.has(tag))\r\n throw new Error(`module \"${tag.toString()}\" doesn't exist`)\r\n return this.moduleMap.get(tag)\r\n }\r\n}\r\n\r\nexport async function Factory(models: Construct[], opts: Options = {}) {\r\n const phecda = new ServerPhecda(opts)\r\n await phecda.start(models)\r\n return phecda\r\n}\r\n\r\nexport function useS<Model extends Construct>(model: Model, namespace?: string): InstanceType<Model>\r\nexport function useS(namespace?: string): ServerPhecda\r\nexport function useS(nsOrModel?: Construct | string, namespace?: string) {\r\n if (!nsOrModel) {\r\n namespace = 'default'\r\n }\r\n else {\r\n if (typeof nsOrModel === 'string')\r\n namespace = nsOrModel\r\n else if (!namespace)\r\n namespace = 'default'\r\n }\r\n if (!phecdaNamespace.has(namespace))\r\n throw new Error(`namespace \"${namespace}\" doesn't exist`)\r\n const serverPhecda = phecdaNamespace.get(namespace)!\r\n if (nsOrModel && typeof nsOrModel !== 'string')\r\n return serverPhecda.get(nsOrModel)\r\n else\r\n\r\n return serverPhecda\r\n}\r\n\r\nfunction getMetaFromInstance(instance: Phecda, tag: PropertyKey, name: string) {\r\n const propertyKeys = getMetaKey(instance).filter(item => typeof item === 'string') as string[]\r\n const baseMeta = getMergedMeta(instance, undefined) as MetaData\r\n\r\n const ctxs = baseMeta.ctxs\r\n return propertyKeys.filter(i => typeof (instance as any)[i] === 'function').map((i) => {\r\n const meta = getMergedMeta(instance, i)\r\n const metaData = {\r\n ...meta,\r\n name,\r\n tag,\r\n func:\r\n i,\r\n } as MetaData\r\n if (baseMeta.controller) {\r\n if (typeof tag !== 'string')\r\n log(`can't use Tag with ${typeof tag} on controller \"${(instance as any).constructor.name}\",instead with \"${tag = String(tag)}\"`, 'error')\r\n metaData.controller = baseMeta.controller\r\n metaData[baseMeta.controller] = {\r\n ...baseMeta[baseMeta.controller],\r\n ...meta[baseMeta.controller],\r\n }\r\n\r\n const params = getMetaParams(instance, i).map(item => getMergedMeta(instance, i, item))\r\n params.forEach((item, index) => {\r\n if (!item.pipe)\r\n item.pipe = meta.pipe || baseMeta.pipe\r\n if (!item.define)\r\n item.define = {}\r\n item.index = index\r\n })\r\n\r\n metaData.ctxs = ctxs\r\n metaData.params = params\r\n metaData.filter = meta.filter || baseMeta.filter\r\n metaData.define = { ...baseMeta.define, ...meta.define }\r\n\r\n for (const item of ['addons', 'guards']) {\r\n const set = new Set<string>(baseMeta[item])\r\n if (meta[item]) {\r\n meta[item].forEach((part: string) => {\r\n set.delete(part)\r\n set.add(part)\r\n })\r\n }\r\n\r\n metaData[item] = [...set]\r\n }\r\n\r\n // metaData.addons = [...new Set([...baseMeta.addons, ...meta.addons])]\r\n // metaData.guards = [...new Set([...baseMeta.guards, ...meta.guards])]\r\n // metaData.interceptors = [...new Set([...baseMeta.interceptors, ...meta.interceptors])]\r\n }\r\n return new Meta(deepFreeze(metaData as MetaData), getParamTypes(instance, i as string) || [])\r\n })\r\n}\r\n\r\nfunction deepFreeze<T extends Record<string, any>>(object: T): T {\r\n // 先冻结对象本身\r\n Object.freeze(object)\r\n\r\n // 获取对象的所有属性名\r\n Object.getOwnPropertyNames(object).forEach((prop) => {\r\n // 如果属性是对象,并且没有被冻结,则递归冻结\r\n if (object[prop] !== null\r\n && (typeof object[prop] === 'object' || typeof object[prop] === 'function')\r\n && !Object.isFrozen(object[prop]))\r\n deepFreeze(object[prop])\r\n })\r\n\r\n return object\r\n}\r\nfunction getParamTypes(Model: any, key?: string | symbol) {\r\n const paramTypes = Reflect.getMetadata('design:paramtypes', Model, key!)\r\n if (typeof paramTypes === 'function')// work with loader to handle Circular-Dependency\r\n return paramTypes()\r\n\r\n else return paramTypes\r\n}\r\n"],"mappings":";;;;;;;;;AAkCO,IAAMA,OAAN,MAAMA;EAAb,OAAaA;;;;;EACXC,YAAmBC,MAAuBC,YAAmB;SAA1CD,OAAAA;SAAuBC,aAAAA;EAE1C;AACF;;;ACtCA,OAAO;AACP,OAAOC,kBAAkB;AAEzB,SAASC,WAAWC,eAAeC,YAAYC,eAAeC,QAAQC,YAAYC,eAAeC,iBAAiB;AAClH,OAAOC,WAAW;AASlB,IAAMC,QAAQC,MAAM,wBAAA;AAEb,IAAMC,UAAmB,IAAIC,aAAAA;AAS7B,SAASC,sBAAAA;AACd,MAAI,CAACC,UAAU,SAAA,GAAY;AACzBC,cAAU,WAAW,CAAC,EAAEC,WAAWC,UAAUC,UAAUC,QAAO,MAAgB;AAC5E,YAAMC,KAAK,OAAOH,SAASC,QAAAA,MAAc,aAAaD,SAASC,QAAAA,EAAUG,KAAKJ,QAAAA,IAAY,CAACK,MAAWL,SAASC,QAAAA,IAAYI;AAE3H,UAAIH,SAASI,KACVZ,SAAgBY,KAAKP,WAAWI,EAAAA;UAGhCT,SAAgBa,GAAGR,WAAWI,EAAAA;AAEjC,aAAO,MAAA;AACJT,gBAAgBc,IAAIT,WAAWI,EAAAA;MAClC;IACF,CAAA;EACF;AACF;AAhBgBP;AAkBT,IAAMa,kBAAkB,oBAAIC,IAAAA;AAE5B,IAAMC,eAAN,MAAMA;EA5Cb,OA4CaA;;;EACXC,YAAY,oBAAIF,IAAAA;EAChBG,OAAe,CAAA;EACfC,WAAW,oBAAIC,QAAAA;EACfC,WAAW,oBAAIC,QAAAA;EACfC,kBAAkB,oBAAIR,IAAAA;EACtBS;EACAC;EACAC;EACAC,YAAYpB,SAAkB;AAC5BN,wBAAAA;AACA,UAAM,EAAE2B,YA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CAAE;EAC9F,CAAA;AACF;AAvDSK;AAyDT,SAASsC,WAA0CC,QAAS;AAE1DnE,SAAOoE,OAAOD,MAAAA;AAGdnE,SAAOqE,oBAAoBF,MAAAA,EAAQ7B,QAAQ,CAAC9B,SAAAA;AAE1C,QAAI2D,OAAO3D,IAAAA,MAAU,SACf,OAAO2D,OAAO3D,IAAAA,MAAU,YAAY,OAAO2D,OAAO3D,IAAAA,MAAU,eAC7D,CAACR,OAAOsE,SAASH,OAAO3D,IAAAA,CAAK,EAChC0D,YAAWC,OAAO3D,IAAAA,CAAK;EAC3B,CAAA;AAEA,SAAO2D;AACT;AAdSD;AAeT,SAASjD,cAAcF,OAAY0B,KAAqB;AACtD,QAAM8B,aAAa9D,QAAQ+D,YAAY,qBAAqBzD,OAAO0B,GAAAA;AACnE,MAAI,OAAO8B,eAAe,WACxB,QAAOA,WAAAA;MAEJ,QAAOA;AACd;AANStD;","names":["Meta","constructor","data","paramsType","EventEmitter","getInject","getMergedMeta","getMetaKey","getMetaParams","getTag","invokeInit","invokeUnmount","setInject","Debug","debug","Debug","emitter","EventEmitter","defaultServerInject","getInject","setInject","eventName","instance","property","options","fn","bind","v","once","on","off","phecdaNamespace","Map","ServerPhecda","moduleMap","meta","modelMap","WeakMap","modelSet","WeakSet","dependenceGraph","parseModule","parseMeta","generators","constructor","namespace","module","set","start","models","model","buildDepModule","hmr","generateCode","then","IS_ONLY_GENERATE","log","process","exit","PS_EXIT_CODE","EXIT","Promise","all","map","generator","name","path","output","HMR","oldModels","newModels","replace","destroy","Object","values","createProxyModule","tag","that","Proxy","get","_target","prop","Reflect","newValue","has","ownKeys","getPrototypeOf","getOwnPropertyDescriptor","Model","paramtypes","getParamTypes","getTag","String","add","undefined","paramtypesInstances","i","sub","subTag","Set","push","getMetaFromInstance","filter","item","invokeInit","oldModules","invokeUnmount","delete","length","data","splice","forEach","depTag","depModule","key","modelOrTag","Error","toString","Factory","opts","phecda","useS","nsOrModel","serverPhecda","propertyKeys","getMetaKey","baseMeta","getMergedMeta","ctxs","metaData","func","controller","params","getMetaParams","index","pipe","define","part","Meta","deepFreeze","object","freeze","getOwnPropertyNames","isFrozen","paramTypes","getMetadata"]}
|