@domain.js/main 1.0.0-alpha.1 → 1.0.0-alpha.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/dist/index.d.ts +19 -74
- package/dist/index.js +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Defaults } from "./defaults";
|
|
2
2
|
import Deps = require("./deps/defines");
|
|
3
|
+
import type { CnfDef as CacheCnfDef } from "./deps/cache";
|
|
3
4
|
export { Main as Cfg } from "./cfg";
|
|
4
5
|
export * as DM from "./dm";
|
|
5
6
|
export { Errors } from "./Errors";
|
|
@@ -7,80 +8,24 @@ export { Main as Http } from "./http";
|
|
|
7
8
|
export * as utils from "./utils";
|
|
8
9
|
export declare const basicErrors: Readonly<Record<"notFound" | "notAllowed" | "noAuth", import("./Errors").ErrorFn>>;
|
|
9
10
|
type TDeps = typeof Deps;
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* 获取模块配置类型
|
|
13
|
+
*/
|
|
14
|
+
type ModuleConfig<T extends keyof TDeps> = T extends "cache" ? CacheCnfDef : TDeps[T]["Main"] extends (arg: infer R, ...args: any[]) => any ? R : {};
|
|
15
|
+
/**
|
|
16
|
+
* 获取模块返回类型
|
|
17
|
+
*/
|
|
18
|
+
type ModuleReturn<T extends keyof TDeps> = ReturnType<TDeps[T]["Main"]>;
|
|
19
|
+
/**
|
|
20
|
+
* 合并多个模块的配置类型(可选)
|
|
21
|
+
*/
|
|
22
|
+
type MergeConfigs<T extends readonly (keyof TDeps)[]> = {
|
|
23
|
+
[K in T[number]]?: ModuleConfig<K>;
|
|
12
24
|
};
|
|
13
25
|
/**
|
|
14
|
-
*
|
|
26
|
+
* 合并多个模块的返回类型
|
|
15
27
|
*/
|
|
16
|
-
type
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
cache: typeof import("./deps/cache");
|
|
21
|
-
checker: typeof import("./deps/checker");
|
|
22
|
-
counter: typeof import("./deps/counter");
|
|
23
|
-
cron: typeof import("./deps/cron");
|
|
24
|
-
frequency: typeof import("./deps/frequency");
|
|
25
|
-
graceful: typeof import("./deps/graceful");
|
|
26
|
-
hash: typeof import("./deps/hash");
|
|
27
|
-
logger: typeof import("./deps/logger");
|
|
28
|
-
myCia: typeof import("./deps/myCia");
|
|
29
|
-
parallel: typeof import("./deps/parallel");
|
|
30
|
-
redis: typeof import("./deps/redis");
|
|
31
|
-
rest: typeof import("./deps/rest");
|
|
32
|
-
schema: typeof import("./deps/schema");
|
|
33
|
-
sequelize: typeof import("./deps/sequelize");
|
|
34
|
-
signer: typeof import("./deps/signer");
|
|
35
|
-
}[Include<"frequency", RemoveReadonlyArray<T>> | Include<"schema", RemoveReadonlyArray<T>> | Include<"logger", RemoveReadonlyArray<T>> | Include<"hash", RemoveReadonlyArray<T>> | Include<"aes", RemoveReadonlyArray<T>> | Include<"redis", RemoveReadonlyArray<T>> | Include<"sequelize", RemoveReadonlyArray<T>> | Include<"counter", RemoveReadonlyArray<T>> | Include<"cron", RemoveReadonlyArray<T>> | Include<"myCia", RemoveReadonlyArray<T>> | Include<"graceful", RemoveReadonlyArray<T>> | Include<"parallel", RemoveReadonlyArray<T>> | Include<"cache", RemoveReadonlyArray<T>> | Include<"rest", RemoveReadonlyArray<T>> | Include<"checker", RemoveReadonlyArray<T>> | Include<"signer", RemoveReadonlyArray<T>>]["Main"] extends (arg: infer R, ...args: any[]) => any ? R : {}>) => (Pick<{
|
|
36
|
-
aes: typeof import("./deps/aes");
|
|
37
|
-
cache: typeof import("./deps/cache");
|
|
38
|
-
checker: typeof import("./deps/checker");
|
|
39
|
-
counter: typeof import("./deps/counter");
|
|
40
|
-
cron: typeof import("./deps/cron");
|
|
41
|
-
frequency: typeof import("./deps/frequency");
|
|
42
|
-
graceful: typeof import("./deps/graceful");
|
|
43
|
-
hash: typeof import("./deps/hash");
|
|
44
|
-
logger: typeof import("./deps/logger");
|
|
45
|
-
myCia: typeof import("./deps/myCia");
|
|
46
|
-
parallel: typeof import("./deps/parallel");
|
|
47
|
-
redis: typeof import("./deps/redis");
|
|
48
|
-
rest: typeof import("./deps/rest");
|
|
49
|
-
schema: typeof import("./deps/schema");
|
|
50
|
-
sequelize: typeof import("./deps/sequelize");
|
|
51
|
-
signer: typeof import("./deps/signer");
|
|
52
|
-
}, RemoveReadonlyArray<T>> extends infer T_1 extends Pick<{
|
|
53
|
-
aes: typeof import("./deps/aes");
|
|
54
|
-
cache: typeof import("./deps/cache");
|
|
55
|
-
checker: typeof import("./deps/checker");
|
|
56
|
-
counter: typeof import("./deps/counter");
|
|
57
|
-
cron: typeof import("./deps/cron");
|
|
58
|
-
frequency: typeof import("./deps/frequency");
|
|
59
|
-
graceful: typeof import("./deps/graceful");
|
|
60
|
-
hash: typeof import("./deps/hash");
|
|
61
|
-
logger: typeof import("./deps/logger");
|
|
62
|
-
myCia: typeof import("./deps/myCia");
|
|
63
|
-
parallel: typeof import("./deps/parallel");
|
|
64
|
-
redis: typeof import("./deps/redis");
|
|
65
|
-
rest: typeof import("./deps/rest");
|
|
66
|
-
schema: typeof import("./deps/schema");
|
|
67
|
-
sequelize: typeof import("./deps/sequelize");
|
|
68
|
-
signer: typeof import("./deps/signer");
|
|
69
|
-
}, RemoveReadonlyArray<T>> ? { [k in keyof T_1]: ReturnType<Pick<{
|
|
70
|
-
aes: typeof import("./deps/aes");
|
|
71
|
-
cache: typeof import("./deps/cache");
|
|
72
|
-
checker: typeof import("./deps/checker");
|
|
73
|
-
counter: typeof import("./deps/counter");
|
|
74
|
-
cron: typeof import("./deps/cron");
|
|
75
|
-
frequency: typeof import("./deps/frequency");
|
|
76
|
-
graceful: typeof import("./deps/graceful");
|
|
77
|
-
hash: typeof import("./deps/hash");
|
|
78
|
-
logger: typeof import("./deps/logger");
|
|
79
|
-
myCia: typeof import("./deps/myCia");
|
|
80
|
-
parallel: typeof import("./deps/parallel");
|
|
81
|
-
redis: typeof import("./deps/redis");
|
|
82
|
-
rest: typeof import("./deps/rest");
|
|
83
|
-
schema: typeof import("./deps/schema");
|
|
84
|
-
sequelize: typeof import("./deps/sequelize");
|
|
85
|
-
signer: typeof import("./deps/signer");
|
|
86
|
-
}, RemoveReadonlyArray<T>>[k]["Main"]>; } : never) & Defaults;
|
|
28
|
+
type MergeReturns<T extends readonly (keyof TDeps)[]> = {
|
|
29
|
+
[K in T[number]]: ModuleReturn<K>;
|
|
30
|
+
};
|
|
31
|
+
export declare function Main<T extends readonly (keyof TDeps)[]>(features: T): (cnf?: MergeConfigs<T>) => MergeReturns<T> & Defaults;
|
package/dist/index.js
CHANGED
|
@@ -52,7 +52,7 @@ Object.defineProperty(exports, "Http", { enumerable: true, get: function () { re
|
|
|
52
52
|
exports.utils = __importStar(require("./utils"));
|
|
53
53
|
exports.basicErrors = defaults_1.defaults.errors;
|
|
54
54
|
function Main(features) {
|
|
55
|
-
return (cnf) => {
|
|
55
|
+
return (cnf = {}) => {
|
|
56
56
|
/** 这里之所以要浅拷贝,是为了避免多次初始化之间互相干扰 */
|
|
57
57
|
const _deps = { ...defaults_1.defaults };
|
|
58
58
|
const modules = DM.auto(lodash_1.default.pick(Deps, features) /** 要启用的内部模块 */, _deps /** 初始的模块依赖对象 */, [cnf, _deps] /** 内部模块初始化参数 */);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domain.js/main",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.2",
|
|
4
4
|
"description": "DDD framework",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -57,8 +57,8 @@
|
|
|
57
57
|
"@types/async": "^3.2.25",
|
|
58
58
|
"@types/lodash": "^4.17.20",
|
|
59
59
|
"@types/validator": "^13.7.0",
|
|
60
|
-
"ajv": "^8.
|
|
61
|
-
"ajv-formats": "^
|
|
60
|
+
"ajv": "^8.17.1",
|
|
61
|
+
"ajv-formats": "^3.0.1",
|
|
62
62
|
"ajv-keywords": "^5.1.0",
|
|
63
63
|
"async": "^3.2.6",
|
|
64
64
|
"cron-parser": "^4.1.0",
|