@domain.js/main 0.1.0 → 0.1.5
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/.husky/pre-commit +1 -1
- package/dist/Errors/index.d.ts +16 -0
- package/dist/Errors/index.js +27 -0
- package/dist/basic-errors.d.ts +1 -0
- package/dist/basic-errors.js +10 -0
- package/dist/cfg/index.d.ts +6 -0
- package/dist/cfg/index.js +26 -0
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +5 -5
- package/dist/cli/schema2ts.d.ts +1 -0
- package/dist/cli/schema2ts.js +37 -0
- package/dist/defaults.d.ts +102 -0
- package/dist/defaults.js +36 -0
- package/dist/deps/cache/After.d.ts +1 -2
- package/dist/deps/cache/Before.js +3 -3
- package/dist/deps/cache/Define.d.ts +2 -0
- package/dist/deps/cache/index.js +2 -2
- package/dist/deps/checker/index.d.ts +4 -0
- package/dist/deps/checker/index.js +2 -3
- package/dist/deps/cia/index.d.ts +8 -0
- package/dist/deps/cia/index.js +3 -6
- package/dist/deps/cron/index.d.ts +4 -0
- package/dist/deps/cron/index.js +2 -4
- package/dist/deps/defines.d.ts +2 -2
- package/dist/deps/defines.js +2 -2
- package/dist/deps/logger/index.d.ts +12 -1
- package/dist/deps/logger/index.js +6 -6
- package/dist/deps/parallel/index.d.ts +22 -4
- package/dist/deps/parallel/index.js +20 -11
- package/dist/deps/redis/index.d.ts +12 -1
- package/dist/deps/redis/index.js +12 -4
- package/dist/deps/request/index.d.ts +43 -0
- package/dist/deps/{axios → request}/index.js +17 -6
- package/dist/deps/rest/index.d.ts +16 -3
- package/dist/deps/rest/index.js +41 -2
- package/dist/deps/rest/stats.d.ts +8 -1
- package/dist/deps/rest/stats.js +9 -2
- package/dist/deps/rest/utils.d.ts +8 -0
- package/dist/deps/rest/utils.js +1 -3
- package/dist/deps/schema/index.d.ts +20 -5
- package/dist/deps/schema/index.js +35 -11
- package/dist/deps/sequelize/index.d.ts +7 -2
- package/dist/deps/sequelize/index.js +3 -4
- package/dist/deps/signer/index.d.ts +33 -8
- package/dist/deps/signer/index.js +50 -27
- package/dist/dm/index.d.ts +17 -2
- package/dist/dm/index.js +15 -0
- package/dist/http/defines.d.ts +45 -0
- package/dist/http/defines.js +2 -0
- package/dist/http/index.d.ts +2 -1
- package/dist/http/index.js +2 -1
- package/dist/http/router.d.ts +2 -1
- package/dist/http/router.js +3 -3
- package/dist/index.d.ts +12 -8
- package/dist/index.js +11 -4
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +2 -0
- package/dist/utils/index.d.ts +55 -13
- package/dist/utils/index.js +61 -15
- package/jest.config.js +8 -1
- package/package.json +18 -13
- package/dist/deps/axios/index.d.ts +0 -22
- package/dist/dm/dm.d.ts +0 -21
- package/dist/dm/dm.js +0 -57
package/package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domain.js/main",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "DDD framework",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"domain-cli": "dist/cli/index.js"
|
|
8
|
+
},
|
|
6
9
|
"scripts": {
|
|
7
10
|
"build": "tsc",
|
|
8
11
|
"test": "export NODE_ENV=test && jest ./src --coverage",
|
|
@@ -15,16 +18,6 @@
|
|
|
15
18
|
"author": "Redstone Zhao",
|
|
16
19
|
"license": "MIT",
|
|
17
20
|
"devDependencies": {
|
|
18
|
-
"@types/async": "^3.2.10",
|
|
19
|
-
"@types/crypto-js": "^4.0.2",
|
|
20
|
-
"@types/ioredis": "^4.28.1",
|
|
21
|
-
"@types/jest": "^27.0.3",
|
|
22
|
-
"@types/lodash": "^4.14.177",
|
|
23
|
-
"@types/lru-cache": "^5.1.1",
|
|
24
|
-
"@types/restify": "^8.5.4",
|
|
25
|
-
"@types/restify-errors": "^4.3.4",
|
|
26
|
-
"@types/uuid": "^8.3.3",
|
|
27
|
-
"@types/validator": "^13.7.0",
|
|
28
21
|
"@typescript-eslint/eslint-plugin": "^4.22.0",
|
|
29
22
|
"@typescript-eslint/parser": "^4.22.0",
|
|
30
23
|
"babel-eslint": "^10.1.0",
|
|
@@ -42,6 +35,7 @@
|
|
|
42
35
|
"prettier": "^2.3.0",
|
|
43
36
|
"sequelize-json-schema": "^2.1.1",
|
|
44
37
|
"ts-jest": "^27.0.7",
|
|
38
|
+
"ts-node": "^10.4.0",
|
|
45
39
|
"typescript": "^4.5.2"
|
|
46
40
|
},
|
|
47
41
|
"prettier": {
|
|
@@ -55,6 +49,16 @@
|
|
|
55
49
|
]
|
|
56
50
|
},
|
|
57
51
|
"dependencies": {
|
|
52
|
+
"@types/async": "^3.2.10",
|
|
53
|
+
"@types/crypto-js": "^4.0.2",
|
|
54
|
+
"@types/ioredis": "^4.28.1",
|
|
55
|
+
"@types/jest": "^27.0.3",
|
|
56
|
+
"@types/lodash": "^4.14.177",
|
|
57
|
+
"@types/lru-cache": "^5.1.1",
|
|
58
|
+
"@types/restify": "^8.5.4",
|
|
59
|
+
"@types/restify-errors": "^4.3.4",
|
|
60
|
+
"@types/uuid": "^8.3.3",
|
|
61
|
+
"@types/validator": "^13.7.0",
|
|
58
62
|
"ajv": "^8.8.1",
|
|
59
63
|
"ajv-formats": "^2.1.1",
|
|
60
64
|
"async": "^3.2.2",
|
|
@@ -64,15 +68,16 @@
|
|
|
64
68
|
"csv-stringify": "^6.0.2",
|
|
65
69
|
"human-interval": "^2.0.1",
|
|
66
70
|
"ioredis": "^4.28.0",
|
|
71
|
+
"json-schema-to-typescript": "^10.1.5",
|
|
67
72
|
"lodash": "^4.17.21",
|
|
68
73
|
"lru-cache": "^6.0.0",
|
|
69
74
|
"moment": "^2.29.1",
|
|
70
75
|
"mysql2": "^2.3.3",
|
|
71
76
|
"restify": "^8.6.0",
|
|
72
77
|
"restify-errors": "^8.0.2",
|
|
73
|
-
"sequelize": "
|
|
78
|
+
"sequelize": "6.12.1",
|
|
74
79
|
"swagger-ui-restify": "^3.0.8",
|
|
75
|
-
"
|
|
80
|
+
"type-fest": "^2.8.0",
|
|
76
81
|
"uuid": "^8.3.2",
|
|
77
82
|
"xlsx": "^0.17.4"
|
|
78
83
|
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { AxiosInstance } from "axios";
|
|
2
|
-
import { Main as Logger } from "../logger";
|
|
3
|
-
import * as utils from "../../utils";
|
|
4
|
-
declare type VERBS = "post" | "get" | "put" | "delete";
|
|
5
|
-
interface Cnf {
|
|
6
|
-
axios: {
|
|
7
|
-
loggers?: VERBS[];
|
|
8
|
-
retrys?: VERBS[];
|
|
9
|
-
retryTimes?: number;
|
|
10
|
-
retryIntervalMS?: number;
|
|
11
|
-
conf?: {};
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
interface Deps {
|
|
15
|
-
logger: ReturnType<typeof Logger>;
|
|
16
|
-
utils: typeof utils;
|
|
17
|
-
}
|
|
18
|
-
export declare function Main(cnf: Cnf, deps: Deps): AxiosInstance & {
|
|
19
|
-
origin?: import("axios").AxiosStatic | undefined;
|
|
20
|
-
};
|
|
21
|
-
export declare const Deps: string[];
|
|
22
|
-
export {};
|
package/dist/dm/dm.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import * as lodash from "lodash";
|
|
2
|
-
interface ModuleInterface {
|
|
3
|
-
Main?: (...args: any[]) => any;
|
|
4
|
-
main?: (...args: any[]) => any;
|
|
5
|
-
Deps?: string[];
|
|
6
|
-
Before?: (...args: any[]) => any;
|
|
7
|
-
After?: (...args: any[]) => void;
|
|
8
|
-
}
|
|
9
|
-
declare type ModuleFn = (((...args: any[]) => any) | {}) & ModuleInterface;
|
|
10
|
-
export declare type Merge<T extends {}, D extends {
|
|
11
|
-
[k in string]: ModuleFn;
|
|
12
|
-
}> = T & {
|
|
13
|
-
[K in keyof D]: ReturnType<D[K]["Main"] extends (...args: any) => any ? D[K]["Main"] : D[K]["main"] extends (...args: any) => any ? D[K]["main"] : D[K] extends (...args: any) => any ? D[K] : (...args: any) => any>;
|
|
14
|
-
};
|
|
15
|
-
export declare function DM(_: typeof lodash): {
|
|
16
|
-
exec: <Args extends any[], BeforeFn extends (...args: Args) => any[], MainFn extends (...args: ReturnType<BeforeFn>) => any, AfterFn extends (main: ReturnType<MainFn>, ...args: ReturnType<BeforeFn>) => void>(Main: MainFn, Before: BeforeFn | undefined, After: AfterFn | undefined, _args?: Args) => ReturnType<MainFn>;
|
|
17
|
-
auto: <Modules extends {
|
|
18
|
-
[x: string]: ModuleFn;
|
|
19
|
-
}, Deps extends object, Args_1 extends any[]>(modules: Modules, deps: Deps, args: Args_1) => Merge<Deps, Modules>;
|
|
20
|
-
};
|
|
21
|
-
export {};
|
package/dist/dm/dm.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DM = void 0;
|
|
4
|
-
function DM(_) {
|
|
5
|
-
function exec(Main, Before = ((...args) => args), After, _args = []) {
|
|
6
|
-
const args = Before(..._args);
|
|
7
|
-
const main = Main(...args);
|
|
8
|
-
if (typeof After === "function")
|
|
9
|
-
After(main, ...args);
|
|
10
|
-
return main;
|
|
11
|
-
}
|
|
12
|
-
function auto(modules, deps, args) {
|
|
13
|
-
// 获取全部即将初始化的模块名称,此时的 modules 是扁平的一级结构
|
|
14
|
-
const names = new Set(Object.keys(modules));
|
|
15
|
-
while (names.size) {
|
|
16
|
-
// 记录此次迭代有多少个模块被排序了,如果某次迭代被排序的模块数量为0,
|
|
17
|
-
// 那就要抛出异常了,说明依赖指定有问题,永远都不可能排序完毕
|
|
18
|
-
let count = 0;
|
|
19
|
-
/** 默认挂载函数 */
|
|
20
|
-
const plugin = (name) => {
|
|
21
|
-
const Module = modules[name];
|
|
22
|
-
const Main = Module.Main || Module.main || Module;
|
|
23
|
-
if (typeof Main !== "function")
|
|
24
|
-
throw Error("Main is not a function");
|
|
25
|
-
const Before = Module.Before || ((...args) => args);
|
|
26
|
-
const After = Module.After;
|
|
27
|
-
if (After && typeof After !== "function")
|
|
28
|
-
throw Error("After is not a function");
|
|
29
|
-
const main = exec(Main, Before, After, args);
|
|
30
|
-
if (_.has(deps, name))
|
|
31
|
-
throw Error(`Name ${name} duplicate`);
|
|
32
|
-
_.set(deps, name, main);
|
|
33
|
-
names.delete(name);
|
|
34
|
-
count += 1;
|
|
35
|
-
};
|
|
36
|
-
for (const x of names) {
|
|
37
|
-
const { Deps } = modules[x];
|
|
38
|
-
if (!Array.isArray(Deps) || !Deps.length) {
|
|
39
|
-
plugin(x);
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
if (Deps.every((d) => _.has(deps, d)))
|
|
43
|
-
plugin(x);
|
|
44
|
-
}
|
|
45
|
-
if (count === 0) {
|
|
46
|
-
const lacks = [];
|
|
47
|
-
for (const x of names) {
|
|
48
|
-
lacks.push(`${x}: ${_.filter(modules[x].Deps, (d) => !_.has(deps, d)).join(",")}`);
|
|
49
|
-
}
|
|
50
|
-
throw Error(`Deps defined conflict, ${lacks.join(";")}`);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return deps;
|
|
54
|
-
}
|
|
55
|
-
return { exec, auto };
|
|
56
|
-
}
|
|
57
|
-
exports.DM = DM;
|