phecda-server 6.1.0 → 7.0.0-alpha.1
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 +24 -24
- package/bin/cli.mjs +165 -157
- package/dist/{chunk-NL6QBQAR.js → chunk-7YQ57BQS.js} +21 -22
- package/dist/chunk-GSPBHZBH.js +534 -0
- package/dist/{chunk-J7B24YSE.mjs → chunk-HMVLXNV3.mjs} +5 -14
- package/dist/{chunk-TVT62GIX.js → chunk-J5CFUN4V.js} +8 -1
- package/dist/{chunk-JDV2XJYE.js → chunk-MBCHNDAY.js} +27 -36
- package/dist/{chunk-2CFYUXPM.mjs → chunk-V7EI76QQ.mjs} +136 -141
- package/dist/{chunk-G7TD2VB7.mjs → chunk-WHJ5FALK.mjs} +7 -0
- package/dist/{chunk-3H3T54IC.mjs → chunk-XYVMNY2X.mjs} +4 -5
- package/dist/{core-P1CsH6jz.d.mts → core-BIcUwV18.d.mts} +1 -1
- package/dist/{core-BlN0Spy9.d.ts → core-CYwEPfN4.d.ts} +1 -1
- package/dist/helper.d.mts +4 -6
- package/dist/helper.d.ts +4 -6
- package/dist/helper.js +3 -3
- package/dist/helper.mjs +2 -2
- package/dist/{server → http}/elysia/index.d.mts +5 -5
- package/dist/{server → http}/elysia/index.d.ts +5 -5
- package/dist/{server → http}/elysia/index.js +80 -62
- package/dist/{server → http}/elysia/index.mjs +50 -32
- package/dist/{server → http}/express/index.d.mts +5 -5
- package/dist/{server → http}/express/index.d.ts +5 -5
- package/dist/{server → http}/express/index.js +71 -55
- package/dist/{server → http}/express/index.mjs +42 -26
- package/dist/{server → http}/fastify/index.d.mts +5 -5
- package/dist/{server → http}/fastify/index.d.ts +5 -5
- package/dist/{server → http}/fastify/index.js +72 -72
- package/dist/{server → http}/fastify/index.mjs +47 -47
- package/dist/{server → http}/h3/index.d.mts +5 -5
- package/dist/{server → http}/h3/index.d.ts +5 -5
- package/dist/http/h3/index.js +160 -0
- package/dist/{server → http}/h3/index.mjs +68 -62
- package/dist/{server → http}/hono/index.d.mts +5 -5
- package/dist/{server → http}/hono/index.d.ts +5 -5
- package/dist/{server → http}/hono/index.js +69 -54
- package/dist/{server → http}/hono/index.mjs +41 -26
- package/dist/{server → http}/hyper-express/index.d.mts +5 -5
- package/dist/{server → http}/hyper-express/index.d.ts +5 -5
- package/dist/{server → http}/hyper-express/index.js +69 -56
- package/dist/{server → http}/hyper-express/index.mjs +41 -28
- package/dist/{server → http}/koa/index.d.mts +5 -5
- package/dist/{server → http}/koa/index.d.ts +5 -5
- package/dist/{server → http}/koa/index.js +71 -55
- package/dist/{server → http}/koa/index.mjs +42 -26
- package/dist/index.d.mts +52 -41
- package/dist/index.d.ts +52 -41
- package/dist/index.js +59 -81
- package/dist/index.mjs +39 -61
- package/dist/{meta-KtfiBIde.d.ts → meta-BXKLFTgG.d.mts} +2 -3
- package/dist/{meta-KtfiBIde.d.mts → meta-BXKLFTgG.d.ts} +2 -3
- package/dist/rpc/bullmq/index.d.mts +6 -6
- package/dist/rpc/bullmq/index.d.ts +6 -6
- package/dist/rpc/bullmq/index.js +24 -24
- package/dist/rpc/bullmq/index.mjs +14 -14
- package/dist/rpc/kafka/index.d.mts +3 -3
- package/dist/rpc/kafka/index.d.ts +3 -3
- package/dist/rpc/kafka/index.js +25 -21
- package/dist/rpc/kafka/index.mjs +15 -11
- package/dist/rpc/nats/index.d.mts +3 -3
- package/dist/rpc/nats/index.d.ts +3 -3
- package/dist/rpc/nats/index.js +22 -21
- package/dist/rpc/nats/index.mjs +13 -12
- package/dist/rpc/rabbitmq/index.d.mts +3 -3
- package/dist/rpc/rabbitmq/index.d.ts +3 -3
- package/dist/rpc/rabbitmq/index.js +23 -22
- package/dist/rpc/rabbitmq/index.mjs +12 -11
- package/dist/rpc/redis/index.d.mts +3 -3
- package/dist/rpc/redis/index.d.ts +3 -3
- package/dist/rpc/redis/index.js +24 -20
- package/dist/rpc/redis/index.mjs +15 -11
- 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-JVT0mgLD.d.ts → types-BtbL49Zs.d.mts} +2 -1
- package/dist/{types-DIw7B6Up.d.ts → types-VFzEM7LL.d.ts} +5 -5
- package/dist/{types-BvD3B5Ny.d.mts → types-h40T3cRG.d.mts} +5 -5
- package/dist/{types-t9D1fU6G.d.mts → types-m3IEDKjP.d.ts} +2 -1
- package/package.json +23 -23
- package/register/loader.mjs +366 -367
- package/dist/chunk-DVTBLV6I.js +0 -539
- package/dist/server/h3/index.js +0 -154
package/assets/ps.json
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
{
|
|
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
|
-
"unimport": {
|
|
16
|
-
"dirs": ["."],
|
|
17
|
-
"dirsScanOptions": {
|
|
18
|
-
"filePatterns": ["*.{service,controller,module,rpc,edge,guard,
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
"virtualFile": {},
|
|
22
|
-
"moduleFile": []
|
|
23
|
-
|
|
24
|
-
}
|
|
1
|
+
{
|
|
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
|
+
"unimport": {
|
|
16
|
+
"dirs": ["."],
|
|
17
|
+
"dirsScanOptions": {
|
|
18
|
+
"filePatterns": ["*.{service,controller,module,rpc,edge,guard,extension,pipe,filter,addon}.ts"]
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"virtualFile": {},
|
|
22
|
+
"moduleFile": []
|
|
23
|
+
|
|
24
|
+
}
|
package/bin/cli.mjs
CHANGED
|
@@ -1,158 +1,166 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
|
-
import { fork } from 'child_process'
|
|
3
|
-
import { createRequire } from 'module'
|
|
4
|
-
import { fileURLToPath } from 'url'
|
|
5
|
-
|
|
6
|
-
import { dirname, join, resolve } from 'path'
|
|
7
|
-
import pc from 'picocolors'
|
|
8
|
-
import cac from 'cac'
|
|
9
|
-
import fse from 'fs-extra'
|
|
10
|
-
import { log } from '../dist/index.mjs'
|
|
11
|
-
|
|
12
|
-
const cli = cac('phecda').option('-c,--config <config>', 'config file', {
|
|
13
|
-
default: 'ps.json',
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
17
|
-
|
|
18
|
-
const require = createRequire(import.meta.url)
|
|
19
|
-
let child
|
|
20
|
-
|
|
21
|
-
let closePromise
|
|
22
|
-
const nodeVersion = parseFloat(process.version.slice(1))
|
|
23
|
-
|
|
24
|
-
if (nodeVersion < 18.19) {
|
|
25
|
-
log(
|
|
26
|
-
`Nodejs version less than 18.19(current is ${nodeVersion}) can't support hmr`,
|
|
27
|
-
'yellow',
|
|
28
|
-
)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function startChild(file, args) {
|
|
32
|
-
child = fork(file, {
|
|
33
|
-
env: { NODE_ENV: 'development', ...process.env },
|
|
34
|
-
stdio: 'inherit',
|
|
35
|
-
execArgv: [
|
|
36
|
-
nodeVersion < 18.19
|
|
37
|
-
? '--loader=phecda-server/register/loader.mjs'
|
|
38
|
-
: '--import=phecda-server/register',
|
|
39
|
-
...args,
|
|
40
|
-
],
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
closePromise = new Promise((resolve) => {
|
|
44
|
-
child.once('exit', (code) => {
|
|
45
|
-
if (code === 4) {
|
|
46
|
-
log('only generate code')
|
|
47
|
-
process.exit(0)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
log('
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
.
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
.
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
)
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
startChild(file, options['--'])
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
2
|
+
import { fork } from 'child_process'
|
|
3
|
+
import { createRequire } from 'module'
|
|
4
|
+
import { fileURLToPath } from 'url'
|
|
5
|
+
|
|
6
|
+
import { dirname, join, resolve } from 'path'
|
|
7
|
+
import pc from 'picocolors'
|
|
8
|
+
import cac from 'cac'
|
|
9
|
+
import fse from 'fs-extra'
|
|
10
|
+
import { log } from '../dist/index.mjs'
|
|
11
|
+
|
|
12
|
+
const cli = cac('phecda').option('-c,--config <config>', 'config file', {
|
|
13
|
+
default: 'ps.json',
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
17
|
+
|
|
18
|
+
const require = createRequire(import.meta.url)
|
|
19
|
+
let child
|
|
20
|
+
|
|
21
|
+
let closePromise
|
|
22
|
+
const nodeVersion = parseFloat(process.version.slice(1))
|
|
23
|
+
|
|
24
|
+
if (nodeVersion < 18.19) {
|
|
25
|
+
log(
|
|
26
|
+
`Nodejs version less than 18.19(current is ${nodeVersion}) can't support hmr`,
|
|
27
|
+
'yellow',
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function startChild(file, args) {
|
|
32
|
+
child = fork(file, {
|
|
33
|
+
env: { NODE_ENV: 'development', ...process.env },
|
|
34
|
+
stdio: 'inherit',
|
|
35
|
+
execArgv: [
|
|
36
|
+
nodeVersion < 18.19
|
|
37
|
+
? '--loader=phecda-server/register/loader.mjs'
|
|
38
|
+
: '--import=phecda-server/register',
|
|
39
|
+
...args,
|
|
40
|
+
],
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
closePromise = new Promise((resolve) => {
|
|
44
|
+
child.once('exit', (code) => {
|
|
45
|
+
if (code === 4) {
|
|
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...')
|
|
57
|
+
startChild(file, args)
|
|
58
|
+
}
|
|
59
|
+
child = undefined
|
|
60
|
+
|
|
61
|
+
resolve()
|
|
62
|
+
})
|
|
63
|
+
})
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function exit() {
|
|
67
|
+
log('process exit')
|
|
68
|
+
|
|
69
|
+
if (child) {
|
|
70
|
+
child.kill()
|
|
71
|
+
process.exit(0)
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
process.exit(0)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
process.on('SIGINT', () => {
|
|
78
|
+
process.exit()
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
cli
|
|
82
|
+
.command('init [root]', 'init config file')
|
|
83
|
+
.allowUnknownOptions()
|
|
84
|
+
.option('-t,--tsconfig <tsconfig>', 'init tsconfig file', {
|
|
85
|
+
default: 'tsconfig.json',
|
|
86
|
+
})
|
|
87
|
+
.action(async (root, options) => {
|
|
88
|
+
if (!root)
|
|
89
|
+
root = ''
|
|
90
|
+
|
|
91
|
+
const tsconfigPath = join(root, options.tsconfig)
|
|
92
|
+
const psconfigPath = join(root, options.config)
|
|
93
|
+
|
|
94
|
+
if (!fse.existsSync(tsconfigPath)) {
|
|
95
|
+
log(`create ${tsconfigPath}`)
|
|
96
|
+
|
|
97
|
+
await fse.copyFile(
|
|
98
|
+
resolve(__dirname, '../assets/tsconfig.json'),
|
|
99
|
+
tsconfigPath,
|
|
100
|
+
)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (!fse.existsSync(psconfigPath)) {
|
|
104
|
+
log(`create ${psconfigPath}`)
|
|
105
|
+
|
|
106
|
+
await fse.copyFile(resolve(__dirname, '../assets/ps.json'), psconfigPath)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
log('init finish')
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
cli
|
|
113
|
+
.command('<file> [root]', 'run file')
|
|
114
|
+
.alias('run')
|
|
115
|
+
.allowUnknownOptions()
|
|
116
|
+
.alias('run')
|
|
117
|
+
.action((file, root, options) => {
|
|
118
|
+
if (root)
|
|
119
|
+
process.env.PS_WORKDIR = root
|
|
120
|
+
process.env.PS_CONFIG_FILE = options.config
|
|
121
|
+
|
|
122
|
+
log('process start!')
|
|
123
|
+
|
|
124
|
+
startChild(file, options['--'])
|
|
125
|
+
console.log(`${pc.green('->')} press ${pc.green('e')} to exit`)
|
|
126
|
+
console.log(`${pc.green('->')} press ${pc.green('r')} to relaunch`)
|
|
127
|
+
|
|
128
|
+
process.stdin.on('data', async (data) => {
|
|
129
|
+
const input = data.toString().trim().toLocaleLowerCase()
|
|
130
|
+
if (input === 'r') {
|
|
131
|
+
if (child) {
|
|
132
|
+
await child.kill()
|
|
133
|
+
if (closePromise)
|
|
134
|
+
await closePromise
|
|
135
|
+
log('relaunch...')
|
|
136
|
+
startChild(file, options['--'])
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
log('relaunch...')
|
|
140
|
+
|
|
141
|
+
startChild(file, options['--'])
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (input === 'e')
|
|
145
|
+
exit()
|
|
146
|
+
|
|
147
|
+
if (input === 'c')
|
|
148
|
+
console.clear()
|
|
149
|
+
})
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
cli
|
|
153
|
+
.command('generate <file> [root]', 'generate code(mainly for ci)')
|
|
154
|
+
.allowUnknownOptions()
|
|
155
|
+
.action((file, root, options) => {
|
|
156
|
+
if (root)
|
|
157
|
+
process.env.PS_WORKDIR = root
|
|
158
|
+
process.env.PS_GENERATE = 'true'
|
|
159
|
+
process.env.PS_CONFIG_FILE = options.config
|
|
160
|
+
startChild(file, options['--'])
|
|
161
|
+
})
|
|
162
|
+
|
|
163
|
+
cli.help()
|
|
164
|
+
cli.version(require('../package.json').version)
|
|
165
|
+
|
|
166
|
+
cli.parse()
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkJ5CFUN4Vjs = require('./chunk-J5CFUN4V.js');
|
|
7
7
|
|
|
8
8
|
// src/meta.ts
|
|
9
9
|
var Meta = class {
|
|
10
10
|
static {
|
|
11
|
-
|
|
11
|
+
_chunkJ5CFUN4Vjs.__name.call(void 0, this, "Meta");
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
|
|
@@ -23,7 +23,7 @@ require('reflect-metadata');
|
|
|
23
23
|
var _events = require('events'); var _events2 = _interopRequireDefault(_events);
|
|
24
24
|
var _phecdacore = require('phecda-core');
|
|
25
25
|
var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
|
26
|
-
var debug = _debug2.default.call(void 0, "phecda-server(
|
|
26
|
+
var debug = _debug2.default.call(void 0, "phecda-server(Factory)");
|
|
27
27
|
var emitter = new (0, _events2.default)();
|
|
28
28
|
function defaultServerInject() {
|
|
29
29
|
if (!_phecdacore.getInject.call(void 0, "watcher")) {
|
|
@@ -37,11 +37,11 @@ function defaultServerInject() {
|
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
|
|
40
|
+
_chunkJ5CFUN4Vjs.__name.call(void 0, defaultServerInject, "defaultServerInject");
|
|
41
41
|
var phecdaNamespace = /* @__PURE__ */ new Map();
|
|
42
42
|
var ServerPhecda = (_class = class {
|
|
43
43
|
static {
|
|
44
|
-
|
|
44
|
+
_chunkJ5CFUN4Vjs.__name.call(void 0, this, "ServerPhecda");
|
|
45
45
|
}
|
|
46
46
|
__init() {this.moduleMap = /* @__PURE__ */ new Map()}
|
|
47
47
|
__init2() {this.meta = []}
|
|
@@ -53,7 +53,7 @@ var ServerPhecda = (_class = class {
|
|
|
53
53
|
|
|
54
54
|
constructor(options) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);_class.prototype.__init5.call(this);
|
|
55
55
|
defaultServerInject();
|
|
56
|
-
const { namespace = "default", parseModule = /* @__PURE__ */
|
|
56
|
+
const { namespace = "default", parseModule = /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, (module) => module, "parseModule"), parseMeta = /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, (meta) => meta, "parseMeta"), generators = [] } = options;
|
|
57
57
|
phecdaNamespace.set(namespace, this);
|
|
58
58
|
this.parseMeta = parseMeta;
|
|
59
59
|
this.parseModule = parseModule;
|
|
@@ -61,8 +61,8 @@ var ServerPhecda = (_class = class {
|
|
|
61
61
|
}
|
|
62
62
|
async start(models) {
|
|
63
63
|
for (const model of models) await this.buildDepModule(model);
|
|
64
|
-
const generateCode = /* @__PURE__ */
|
|
65
|
-
if (
|
|
64
|
+
const generateCode = /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, async () => {
|
|
65
|
+
if (_chunkJ5CFUN4Vjs.IS_HMR) {
|
|
66
66
|
return Promise.all(this.generators.map((generator) => {
|
|
67
67
|
debug(`generate "${generator.name}" code to ${generator.path}`);
|
|
68
68
|
return generator.output(this.meta);
|
|
@@ -70,9 +70,9 @@ var ServerPhecda = (_class = class {
|
|
|
70
70
|
}
|
|
71
71
|
}, "generateCode");
|
|
72
72
|
generateCode().then(() => {
|
|
73
|
-
if (
|
|
73
|
+
if (_chunkJ5CFUN4Vjs.IS_ONLY_GENERATE) process.exit(4);
|
|
74
74
|
});
|
|
75
|
-
if (
|
|
75
|
+
if (_chunkJ5CFUN4Vjs.IS_HMR) {
|
|
76
76
|
if (!globalThis.__PS_HMR__) globalThis.__PS_HMR__ = [];
|
|
77
77
|
_optionalChain([globalThis, 'access', _2 => _2.__PS_HMR__, 'optionalAccess', _3 => _3.push, 'call', _4 => _4(async (files) => {
|
|
78
78
|
debug("reload files ");
|
|
@@ -128,8 +128,8 @@ var ServerPhecda = (_class = class {
|
|
|
128
128
|
if (!module) throw new Error(`exist Circular-Dependency or Multiple modules with the same name/tag [tag] ${String(tag)}--[module] ${Model}`);
|
|
129
129
|
if (this.modelMap.get(module) !== Model && !this.modelSet.has(Model)) {
|
|
130
130
|
this.modelSet.add(Model);
|
|
131
|
-
if (module instanceof Model)
|
|
132
|
-
else
|
|
131
|
+
if (module instanceof Model) _chunkJ5CFUN4Vjs.log.call(void 0, `Module taged ${String(tag)} has been overridden`);
|
|
132
|
+
else _chunkJ5CFUN4Vjs.log.call(void 0, `Synonym module: Module taged "${String(tag)}" has been loaded before, so phecda-server won't load Module "${Model.name}"`, "warn");
|
|
133
133
|
}
|
|
134
134
|
return {
|
|
135
135
|
module,
|
|
@@ -152,7 +152,7 @@ var ServerPhecda = (_class = class {
|
|
|
152
152
|
}
|
|
153
153
|
this.meta.push(...getMetaFromInstance(module, tag, Model.name).map(this.parseMeta).filter((item) => !!item));
|
|
154
154
|
debug(`init module "${String(tag)}"`);
|
|
155
|
-
if (!
|
|
155
|
+
if (!_chunkJ5CFUN4Vjs.IS_ONLY_GENERATE) await _phecdacore.invokeInit.call(void 0, module);
|
|
156
156
|
debug(`add module "${String(tag)}"`);
|
|
157
157
|
this.moduleMap.set(tag, module);
|
|
158
158
|
this.modelMap.set(module, Model);
|
|
@@ -175,7 +175,7 @@ async function Factory(models, opts = {}) {
|
|
|
175
175
|
await phecda.start(models);
|
|
176
176
|
return phecda;
|
|
177
177
|
}
|
|
178
|
-
|
|
178
|
+
_chunkJ5CFUN4Vjs.__name.call(void 0, Factory, "Factory");
|
|
179
179
|
function useS(nsOrModel, namespace) {
|
|
180
180
|
if (!nsOrModel) {
|
|
181
181
|
namespace = "default";
|
|
@@ -188,7 +188,7 @@ function useS(nsOrModel, namespace) {
|
|
|
188
188
|
if (nsOrModel && typeof nsOrModel !== "string") return serverPhecda.get(nsOrModel);
|
|
189
189
|
else return serverPhecda;
|
|
190
190
|
}
|
|
191
|
-
|
|
191
|
+
_chunkJ5CFUN4Vjs.__name.call(void 0, useS, "useS");
|
|
192
192
|
function getMetaFromInstance(instance, tag, name) {
|
|
193
193
|
const propertyKeys = _phecdacore.getMetaKey.call(void 0, instance).filter((item) => typeof item === "string");
|
|
194
194
|
const baseMeta = _phecdacore.getMergedMeta.call(void 0, instance, void 0);
|
|
@@ -202,7 +202,7 @@ function getMetaFromInstance(instance, tag, name) {
|
|
|
202
202
|
func: i
|
|
203
203
|
};
|
|
204
204
|
if (baseMeta.controller) {
|
|
205
|
-
if (typeof tag !== "string")
|
|
205
|
+
if (typeof tag !== "string") _chunkJ5CFUN4Vjs.log.call(void 0, `can't use Tag with ${typeof tag} on controller "${instance.constructor.name}",instead with "${tag = String(tag)}"`, "error");
|
|
206
206
|
metaData.controller = baseMeta.controller;
|
|
207
207
|
metaData[baseMeta.controller] = {
|
|
208
208
|
...baseMeta[baseMeta.controller],
|
|
@@ -222,9 +222,8 @@ function getMetaFromInstance(instance, tag, name) {
|
|
|
222
222
|
...meta.define
|
|
223
223
|
};
|
|
224
224
|
for (const item of [
|
|
225
|
-
"
|
|
226
|
-
"guards"
|
|
227
|
-
"interceptors"
|
|
225
|
+
"addons",
|
|
226
|
+
"guards"
|
|
228
227
|
]) {
|
|
229
228
|
const set = new Set(baseMeta[item]);
|
|
230
229
|
if (meta[item]) {
|
|
@@ -241,7 +240,7 @@ function getMetaFromInstance(instance, tag, name) {
|
|
|
241
240
|
return new Meta(deepFreeze(metaData), getParamTypes(instance, i) || []);
|
|
242
241
|
});
|
|
243
242
|
}
|
|
244
|
-
|
|
243
|
+
_chunkJ5CFUN4Vjs.__name.call(void 0, getMetaFromInstance, "getMetaFromInstance");
|
|
245
244
|
function deepFreeze(object) {
|
|
246
245
|
Object.freeze(object);
|
|
247
246
|
Object.getOwnPropertyNames(object).forEach((prop) => {
|
|
@@ -249,11 +248,11 @@ function deepFreeze(object) {
|
|
|
249
248
|
});
|
|
250
249
|
return object;
|
|
251
250
|
}
|
|
252
|
-
|
|
251
|
+
_chunkJ5CFUN4Vjs.__name.call(void 0, deepFreeze, "deepFreeze");
|
|
253
252
|
function getParamTypes(Model, key) {
|
|
254
253
|
return Reflect.getMetadata("design:paramtypes", Model, key);
|
|
255
254
|
}
|
|
256
|
-
|
|
255
|
+
_chunkJ5CFUN4Vjs.__name.call(void 0, getParamTypes, "getParamTypes");
|
|
257
256
|
|
|
258
257
|
|
|
259
258
|
|