phecda-server 7.0.0-alpha.1 → 7.0.0-alpha.10
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 +1 -1
- package/assets/schema.json +55 -55
- package/bin/cli.mjs +31 -23
- package/dist/chunk-4LLLQOMF.js +152 -0
- package/dist/{chunk-7YQ57BQS.js → chunk-6OQ2SB5W.js} +137 -69
- package/dist/{chunk-GSPBHZBH.js → chunk-G7JFKM2M.js} +96 -80
- package/dist/{chunk-MBCHNDAY.js → chunk-KCPBITYZ.js} +24 -24
- package/dist/{chunk-HMVLXNV3.mjs → chunk-MUI6MTUO.mjs} +1 -1
- package/dist/chunk-NQ55PA2X.mjs +152 -0
- package/dist/{chunk-XYVMNY2X.mjs → chunk-YCES6ABN.mjs} +124 -56
- package/dist/{chunk-V7EI76QQ.mjs → chunk-Z7NAAE4M.mjs} +48 -32
- package/dist/{core-BIcUwV18.d.mts → core-CUTbX_IS.d.ts} +5 -3
- package/dist/{core-CYwEPfN4.d.ts → core-DIfgUKIU.d.mts} +5 -3
- package/dist/helper.d.mts +8 -6
- package/dist/helper.d.ts +8 -6
- package/dist/helper.js +8 -3
- package/dist/helper.mjs +10 -5
- package/dist/http/elysia/index.d.mts +4 -4
- package/dist/http/elysia/index.d.ts +4 -4
- package/dist/http/elysia/index.js +43 -44
- package/dist/http/elysia/index.mjs +9 -10
- package/dist/http/express/index.d.mts +4 -4
- package/dist/http/express/index.d.ts +4 -4
- package/dist/http/express/index.js +40 -41
- package/dist/http/express/index.mjs +9 -10
- package/dist/http/fastify/index.d.mts +4 -4
- package/dist/http/fastify/index.d.ts +4 -4
- package/dist/http/fastify/index.js +41 -42
- package/dist/http/fastify/index.mjs +9 -10
- package/dist/http/h3/index.d.mts +4 -4
- package/dist/http/h3/index.d.ts +4 -4
- package/dist/http/h3/index.js +41 -42
- package/dist/http/h3/index.mjs +9 -10
- package/dist/http/hono/index.d.mts +4 -4
- package/dist/http/hono/index.d.ts +4 -4
- package/dist/http/hono/index.js +37 -39
- package/dist/http/hono/index.mjs +5 -7
- 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 +38 -39
- package/dist/http/hyper-express/index.mjs +8 -9
- package/dist/http/koa/index.d.mts +4 -4
- package/dist/http/koa/index.d.ts +4 -4
- package/dist/http/koa/index.js +40 -41
- package/dist/http/koa/index.mjs +9 -10
- package/dist/index.d.mts +44 -38
- package/dist/index.d.ts +44 -38
- package/dist/index.js +48 -42
- package/dist/index.mjs +21 -15
- package/dist/{meta-BXKLFTgG.d.mts → meta-CR-D39hQ.d.mts} +7 -5
- package/dist/{meta-BXKLFTgG.d.ts → meta-CR-D39hQ.d.ts} +7 -5
- package/dist/rpc/bullmq/index.d.mts +5 -5
- package/dist/rpc/bullmq/index.d.ts +5 -5
- package/dist/rpc/bullmq/index.js +15 -14
- package/dist/rpc/bullmq/index.mjs +4 -3
- package/dist/rpc/kafka/index.d.mts +4 -4
- package/dist/rpc/kafka/index.d.ts +4 -4
- package/dist/rpc/kafka/index.js +15 -14
- package/dist/rpc/kafka/index.mjs +3 -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 +14 -13
- package/dist/rpc/nats/index.mjs +4 -3
- package/dist/rpc/rabbitmq/index.d.mts +4 -4
- package/dist/rpc/rabbitmq/index.d.ts +4 -4
- package/dist/rpc/rabbitmq/index.js +16 -15
- package/dist/rpc/rabbitmq/index.mjs +4 -3
- package/dist/rpc/redis/index.d.mts +4 -4
- package/dist/rpc/redis/index.d.ts +4 -4
- package/dist/rpc/redis/index.js +14 -13
- package/dist/rpc/redis/index.mjs +4 -3
- 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-h40T3cRG.d.mts → types-BF1TDbFV.d.ts} +4 -3
- package/dist/{types-BtbL49Zs.d.mts → types-DYRu0vic.d.ts} +4 -3
- package/dist/{types-VFzEM7LL.d.ts → types-DYviSl5B.d.mts} +4 -3
- package/dist/{types-m3IEDKjP.d.ts → types-DqH1qA-q.d.mts} +4 -3
- package/package.json +8 -5
- package/register/export.mjs +30 -0
- package/register/index.mjs +50 -40
- package/register/loader.mjs +84 -66
- package/register/utils.mjs +60 -56
- package/dist/chunk-J5CFUN4V.js +0 -73
- package/dist/chunk-WHJ5FALK.mjs +0 -73
package/register/utils.mjs
CHANGED
|
@@ -1,56 +1,60 @@
|
|
|
1
|
-
import { basename } from 'path'
|
|
2
|
-
import { transform } from '@swc-node/core'
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const { createUnimport } = await import('unimport')
|
|
31
|
-
return createUnimport({
|
|
32
|
-
...opts,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
1
|
+
import { basename } from 'path'
|
|
2
|
+
import { transform } from '@swc-node/core'
|
|
3
|
+
import psExports from './export.mjs'
|
|
4
|
+
const injectInlineSourceMap = ({ code, map }) => {
|
|
5
|
+
if (map) {
|
|
6
|
+
const base64Map = Buffer.from(map, 'utf8').toString('base64')
|
|
7
|
+
const sourceMapContent = `//# sourceMappingURL=data:application/json;charset=utf-8;base64,${base64Map}`
|
|
8
|
+
return `${code}\n${sourceMapContent}`
|
|
9
|
+
}
|
|
10
|
+
return code
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export async function compile(sourcecode, filename) {
|
|
14
|
+
if (filename.endsWith('.d.ts'))
|
|
15
|
+
return ''
|
|
16
|
+
|
|
17
|
+
const { code, map } = await transform(sourcecode, filename, {
|
|
18
|
+
sourcemap: true,
|
|
19
|
+
module: 'es6',
|
|
20
|
+
emitDecoratorMetadata: true,
|
|
21
|
+
experimentalDecorators: true,
|
|
22
|
+
esModuleInterop: false,
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
return injectInlineSourceMap({ code, map })
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export async function genUnImportRet(opts) {
|
|
29
|
+
try {
|
|
30
|
+
const { createUnimport } = await import('unimport')
|
|
31
|
+
return createUnimport({
|
|
32
|
+
...opts,
|
|
33
|
+
|
|
34
|
+
presets: [
|
|
35
|
+
{
|
|
36
|
+
from: 'phecda-server',
|
|
37
|
+
imports: psExports,
|
|
38
|
+
},
|
|
39
|
+
]
|
|
40
|
+
.concat(opts.presets || []),
|
|
41
|
+
})
|
|
42
|
+
}
|
|
43
|
+
catch (e) {
|
|
44
|
+
console.error(e)
|
|
45
|
+
return false
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function handleClassTypes(input) {
|
|
50
|
+
return input.replace(/const\s+(\w+)\s*:\s*typeof\s+import\(['"](.+)['"]\)\['(\w+)'\]/g, (_, n, p, e) => {
|
|
51
|
+
// TestController in test.controller
|
|
52
|
+
if (p.startsWith('./') && (basename(p).replace('.', '').toLowerCase() === e.toLowerCase()))
|
|
53
|
+
return `${_}\n type ${n} = InstanceType<typeof import('${p}')['${e}']>`
|
|
54
|
+
|
|
55
|
+
return _
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
export function slash(str) {
|
|
59
|
+
return str.replace(/\\/g, '/')
|
|
60
|
+
}
|
package/dist/chunk-J5CFUN4V.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
|
-
// src/common.ts
|
|
5
|
-
var ERROR_SYMBOL = "__PS_ERROR__";
|
|
6
|
-
var IS_HMR = process.env.NODE_ENV === "development";
|
|
7
|
-
var IS_ONLY_GENERATE = !!process.env.PS_GENERATE;
|
|
8
|
-
var IS_STRICT = !!process.env.PS_STRICT;
|
|
9
|
-
var LOG_LEVEL = Number(process.env.PS_LOG_LEVEL || 0);
|
|
10
|
-
var PS_EXIT_CODE;
|
|
11
|
-
(function(PS_EXIT_CODE2) {
|
|
12
|
-
PS_EXIT_CODE2[PS_EXIT_CODE2["RELAUNCH"] = 2] = "RELAUNCH";
|
|
13
|
-
PS_EXIT_CODE2[PS_EXIT_CODE2["CODE"] = 4] = "CODE";
|
|
14
|
-
})(PS_EXIT_CODE || (PS_EXIT_CODE = exports.PS_EXIT_CODE = {}));
|
|
15
|
-
|
|
16
|
-
// src/utils.ts
|
|
17
|
-
var _picocolors = require('picocolors'); var _picocolors2 = _interopRequireDefault(_picocolors);
|
|
18
|
-
var _tsmixer = require('ts-mixer');
|
|
19
|
-
var time;
|
|
20
|
-
var internalLogger;
|
|
21
|
-
function setLogger(logger) {
|
|
22
|
-
internalLogger = logger;
|
|
23
|
-
}
|
|
24
|
-
__name(setLogger, "setLogger");
|
|
25
|
-
function getLogger() {
|
|
26
|
-
return internalLogger;
|
|
27
|
-
}
|
|
28
|
-
__name(getLogger, "getLogger");
|
|
29
|
-
function log(msg, level = "log") {
|
|
30
|
-
if (internalLogger) internalLogger[level](msg);
|
|
31
|
-
const logLevel = {
|
|
32
|
-
debug: -1,
|
|
33
|
-
info: 0,
|
|
34
|
-
log: 1,
|
|
35
|
-
warn: 2,
|
|
36
|
-
error: 3
|
|
37
|
-
}[level];
|
|
38
|
-
if (logLevel < LOG_LEVEL) return;
|
|
39
|
-
const color = {
|
|
40
|
-
debug: "bgMagenta",
|
|
41
|
-
error: "red",
|
|
42
|
-
info: "gray",
|
|
43
|
-
warn: "yellow",
|
|
44
|
-
log: "green"
|
|
45
|
-
}[level];
|
|
46
|
-
const date = /* @__PURE__ */ new Date();
|
|
47
|
-
const current = Date.now();
|
|
48
|
-
const interval = time && current - time ? `+${current - time}` : "";
|
|
49
|
-
time = current;
|
|
50
|
-
console[level](`${_picocolors2.default.magenta("[phecda-server]")} ${_picocolors2.default.gray(`${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}`)} ${_picocolors2.default[color](msg)} ${_picocolors2.default.gray(interval)}`);
|
|
51
|
-
}
|
|
52
|
-
__name(log, "log");
|
|
53
|
-
function runMiddleware(ctx, middleware) {
|
|
54
|
-
return new Promise((resolve) => {
|
|
55
|
-
middleware(ctx.getRequest(), ctx.getResponse(), resolve);
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
__name(runMiddleware, "runMiddleware");
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
exports.__name = __name; exports.ERROR_SYMBOL = ERROR_SYMBOL; exports.IS_HMR = IS_HMR; exports.IS_ONLY_GENERATE = IS_ONLY_GENERATE; exports.IS_STRICT = IS_STRICT; exports.LOG_LEVEL = LOG_LEVEL; exports.PS_EXIT_CODE = PS_EXIT_CODE; exports.setLogger = setLogger; exports.getLogger = getLogger; exports.log = log; exports.runMiddleware = runMiddleware; exports.Mixin = _tsmixer.Mixin;
|
package/dist/chunk-WHJ5FALK.mjs
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
|
-
// src/common.ts
|
|
5
|
-
var ERROR_SYMBOL = "__PS_ERROR__";
|
|
6
|
-
var IS_HMR = process.env.NODE_ENV === "development";
|
|
7
|
-
var IS_ONLY_GENERATE = !!process.env.PS_GENERATE;
|
|
8
|
-
var IS_STRICT = !!process.env.PS_STRICT;
|
|
9
|
-
var LOG_LEVEL = Number(process.env.PS_LOG_LEVEL || 0);
|
|
10
|
-
var PS_EXIT_CODE;
|
|
11
|
-
(function(PS_EXIT_CODE2) {
|
|
12
|
-
PS_EXIT_CODE2[PS_EXIT_CODE2["RELAUNCH"] = 2] = "RELAUNCH";
|
|
13
|
-
PS_EXIT_CODE2[PS_EXIT_CODE2["CODE"] = 4] = "CODE";
|
|
14
|
-
})(PS_EXIT_CODE || (PS_EXIT_CODE = {}));
|
|
15
|
-
|
|
16
|
-
// src/utils.ts
|
|
17
|
-
import pc from "picocolors";
|
|
18
|
-
import { Mixin } from "ts-mixer";
|
|
19
|
-
var time;
|
|
20
|
-
var internalLogger;
|
|
21
|
-
function setLogger(logger) {
|
|
22
|
-
internalLogger = logger;
|
|
23
|
-
}
|
|
24
|
-
__name(setLogger, "setLogger");
|
|
25
|
-
function getLogger() {
|
|
26
|
-
return internalLogger;
|
|
27
|
-
}
|
|
28
|
-
__name(getLogger, "getLogger");
|
|
29
|
-
function log(msg, level = "log") {
|
|
30
|
-
if (internalLogger) internalLogger[level](msg);
|
|
31
|
-
const logLevel = {
|
|
32
|
-
debug: -1,
|
|
33
|
-
info: 0,
|
|
34
|
-
log: 1,
|
|
35
|
-
warn: 2,
|
|
36
|
-
error: 3
|
|
37
|
-
}[level];
|
|
38
|
-
if (logLevel < LOG_LEVEL) return;
|
|
39
|
-
const color = {
|
|
40
|
-
debug: "bgMagenta",
|
|
41
|
-
error: "red",
|
|
42
|
-
info: "gray",
|
|
43
|
-
warn: "yellow",
|
|
44
|
-
log: "green"
|
|
45
|
-
}[level];
|
|
46
|
-
const date = /* @__PURE__ */ new Date();
|
|
47
|
-
const current = Date.now();
|
|
48
|
-
const interval = time && current - time ? `+${current - time}` : "";
|
|
49
|
-
time = current;
|
|
50
|
-
console[level](`${pc.magenta("[phecda-server]")} ${pc.gray(`${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}`)} ${pc[color](msg)} ${pc.gray(interval)}`);
|
|
51
|
-
}
|
|
52
|
-
__name(log, "log");
|
|
53
|
-
function runMiddleware(ctx, middleware) {
|
|
54
|
-
return new Promise((resolve) => {
|
|
55
|
-
middleware(ctx.getRequest(), ctx.getResponse(), resolve);
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
__name(runMiddleware, "runMiddleware");
|
|
59
|
-
|
|
60
|
-
export {
|
|
61
|
-
__name,
|
|
62
|
-
ERROR_SYMBOL,
|
|
63
|
-
IS_HMR,
|
|
64
|
-
IS_ONLY_GENERATE,
|
|
65
|
-
IS_STRICT,
|
|
66
|
-
LOG_LEVEL,
|
|
67
|
-
PS_EXIT_CODE,
|
|
68
|
-
setLogger,
|
|
69
|
-
getLogger,
|
|
70
|
-
log,
|
|
71
|
-
runMiddleware,
|
|
72
|
-
Mixin
|
|
73
|
-
};
|