@gct-paas/cli 0.0.1-dev.9 → 0.0.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/dist/actions/gen-api/api-manage.cjs +46 -0
- package/dist/actions/gen-api/api-manage.d.ts +36 -0
- package/dist/actions/gen-api/gen-api.cjs +157 -0
- package/dist/actions/gen-api/gen-api.d.ts +58 -0
- package/dist/actions/gen-api/model-manage.cjs +127 -0
- package/dist/actions/gen-api/model-manage.d.ts +124 -0
- package/dist/actions/index.cjs +12 -0
- package/dist/actions/index.d.ts +1 -0
- package/dist/commands/gen-api/gen-api.cjs +16 -0
- package/dist/commands/gen-api/gen-api.d.ts +44 -0
- package/dist/commands/index.cjs +2 -0
- package/dist/core/handlebars/constant/index.cjs +8 -0
- package/dist/core/handlebars/constant/index.d.ts +2 -0
- package/dist/core/handlebars/handlebars-engine.cjs +134 -0
- package/dist/core/handlebars/handlebars-engine.d.ts +74 -0
- package/dist/core/handlebars/helpers/and/and.cjs +21 -0
- package/dist/core/handlebars/helpers/and/and.d.ts +13 -0
- package/dist/core/handlebars/helpers/camel-case/camel-case.cjs +20 -0
- package/dist/core/handlebars/helpers/camel-case/camel-case.d.ts +13 -0
- package/dist/core/handlebars/helpers/concat/concat.cjs +17 -0
- package/dist/core/handlebars/helpers/concat/concat.d.ts +13 -0
- package/dist/core/handlebars/helpers/eq/eq.cjs +19 -0
- package/dist/core/handlebars/helpers/eq/eq.d.ts +14 -0
- package/dist/core/handlebars/helpers/format-import/format-import.cjs +41 -0
- package/dist/core/handlebars/helpers/format-import/format-import.d.ts +13 -0
- package/dist/core/handlebars/helpers/format-import-item/format-import-item.cjs +40 -0
- package/dist/core/handlebars/helpers/format-import-item/format-import-item.d.ts +13 -0
- package/dist/core/handlebars/helpers/format-js-type/format-js-type.cjs +41 -0
- package/dist/core/handlebars/helpers/format-js-type/format-js-type.d.ts +14 -0
- package/dist/core/handlebars/helpers/gt/gt.cjs +19 -0
- package/dist/core/handlebars/helpers/gt/gt.d.ts +14 -0
- package/dist/core/handlebars/helpers/gte/gte.cjs +19 -0
- package/dist/core/handlebars/helpers/gte/gte.d.ts +14 -0
- package/dist/core/handlebars/helpers/helper-base.cjs +19 -0
- package/dist/core/handlebars/helpers/helper-base.d.ts +22 -0
- package/dist/core/handlebars/helpers/includes/includes.cjs +18 -0
- package/dist/core/handlebars/helpers/includes/includes.d.ts +13 -0
- package/dist/core/handlebars/helpers/index.cjs +52 -0
- package/dist/core/handlebars/helpers/index.d.ts +6 -0
- package/dist/core/handlebars/helpers/json/json.cjs +16 -0
- package/dist/core/handlebars/helpers/json/json.d.ts +13 -0
- package/dist/core/handlebars/helpers/lower-case/lower-case.cjs +19 -0
- package/dist/core/handlebars/helpers/lower-case/lower-case.d.ts +13 -0
- package/dist/core/handlebars/helpers/lt/lt.cjs +19 -0
- package/dist/core/handlebars/helpers/lt/lt.d.ts +14 -0
- package/dist/core/handlebars/helpers/lte/lte.cjs +19 -0
- package/dist/core/handlebars/helpers/lte/lte.d.ts +14 -0
- package/dist/core/handlebars/helpers/neq/neq.cjs +19 -0
- package/dist/core/handlebars/helpers/neq/neq.d.ts +14 -0
- package/dist/core/handlebars/helpers/not/not.cjs +21 -0
- package/dist/core/handlebars/helpers/not/not.d.ts +14 -0
- package/dist/core/handlebars/helpers/not-includes/not-includes.cjs +18 -0
- package/dist/core/handlebars/helpers/not-includes/not-includes.d.ts +13 -0
- package/dist/core/handlebars/helpers/or/or.cjs +23 -0
- package/dist/core/handlebars/helpers/or/or.d.ts +13 -0
- package/dist/core/handlebars/helpers/pascal-case/pascal-case.cjs +20 -0
- package/dist/core/handlebars/helpers/pascal-case/pascal-case.d.ts +13 -0
- package/dist/core/handlebars/helpers/snake-case/snake-case.cjs +20 -0
- package/dist/core/handlebars/helpers/snake-case/snake-case.d.ts +13 -0
- package/dist/core/handlebars/helpers/spinal-case/spinal-case.cjs +20 -0
- package/dist/core/handlebars/helpers/spinal-case/spinal-case.d.ts +13 -0
- package/dist/core/handlebars/helpers/upper-case/upper-case.cjs +19 -0
- package/dist/core/handlebars/helpers/upper-case/upper-case.d.ts +13 -0
- package/dist/core/handlebars/index.cjs +27 -0
- package/dist/core/handlebars/index.d.ts +2 -0
- package/dist/core/handlebars/utils/helper/helper.cjs +41 -0
- package/dist/core/handlebars/utils/helper/helper.d.ts +33 -0
- package/dist/core/handlebars/utils/index.cjs +20 -0
- package/dist/core/handlebars/utils/index.d.ts +17 -0
- package/dist/core/index.cjs +27 -0
- package/dist/core/index.d.ts +2 -0
- package/dist/core/interface/index.cjs +1 -0
- package/dist/core/interface/index.d.ts +1 -0
- package/dist/index.cjs +1 -1
- package/es/actions/gen-api/api-manage.d.ts +36 -0
- package/es/actions/gen-api/api-manage.mjs +38 -0
- package/es/actions/gen-api/gen-api.d.ts +58 -0
- package/es/actions/gen-api/gen-api.mjs +164 -0
- package/es/actions/gen-api/model-manage.d.ts +124 -0
- package/es/actions/gen-api/model-manage.mjs +126 -0
- package/es/actions/index.d.ts +1 -0
- package/es/actions/index.mjs +1 -0
- package/es/commands/gen-api/gen-api.d.ts +44 -0
- package/es/commands/gen-api/gen-api.mjs +15 -0
- package/es/commands/index.mjs +2 -0
- package/es/core/handlebars/constant/index.d.ts +2 -0
- package/es/core/handlebars/constant/index.mjs +2 -0
- package/es/core/handlebars/handlebars-engine.d.ts +74 -0
- package/es/core/handlebars/handlebars-engine.mjs +122 -0
- package/es/core/handlebars/helpers/and/and.d.ts +13 -0
- package/es/core/handlebars/helpers/and/and.mjs +14 -0
- package/es/core/handlebars/helpers/camel-case/camel-case.d.ts +13 -0
- package/es/core/handlebars/helpers/camel-case/camel-case.mjs +13 -0
- package/es/core/handlebars/helpers/concat/concat.d.ts +13 -0
- package/es/core/handlebars/helpers/concat/concat.mjs +10 -0
- package/es/core/handlebars/helpers/eq/eq.d.ts +14 -0
- package/es/core/handlebars/helpers/eq/eq.mjs +12 -0
- package/es/core/handlebars/helpers/format-import/format-import.d.ts +13 -0
- package/es/core/handlebars/helpers/format-import/format-import.mjs +34 -0
- package/es/core/handlebars/helpers/format-import-item/format-import-item.d.ts +13 -0
- package/es/core/handlebars/helpers/format-import-item/format-import-item.mjs +33 -0
- package/es/core/handlebars/helpers/format-js-type/format-js-type.d.ts +14 -0
- package/es/core/handlebars/helpers/format-js-type/format-js-type.mjs +34 -0
- package/es/core/handlebars/helpers/gt/gt.d.ts +14 -0
- package/es/core/handlebars/helpers/gt/gt.mjs +12 -0
- package/es/core/handlebars/helpers/gte/gte.d.ts +14 -0
- package/es/core/handlebars/helpers/gte/gte.mjs +12 -0
- package/es/core/handlebars/helpers/helper-base.d.ts +22 -0
- package/es/core/handlebars/helpers/helper-base.mjs +11 -0
- package/es/core/handlebars/helpers/includes/includes.d.ts +13 -0
- package/es/core/handlebars/helpers/includes/includes.mjs +11 -0
- package/es/core/handlebars/helpers/index.d.ts +6 -0
- package/es/core/handlebars/helpers/index.mjs +46 -0
- package/es/core/handlebars/helpers/json/json.d.ts +13 -0
- package/es/core/handlebars/helpers/json/json.mjs +13 -0
- package/es/core/handlebars/helpers/lower-case/lower-case.d.ts +13 -0
- package/es/core/handlebars/helpers/lower-case/lower-case.mjs +12 -0
- package/es/core/handlebars/helpers/lt/lt.d.ts +14 -0
- package/es/core/handlebars/helpers/lt/lt.mjs +12 -0
- package/es/core/handlebars/helpers/lte/lte.d.ts +14 -0
- package/es/core/handlebars/helpers/lte/lte.mjs +12 -0
- package/es/core/handlebars/helpers/neq/neq.d.ts +14 -0
- package/es/core/handlebars/helpers/neq/neq.mjs +12 -0
- package/es/core/handlebars/helpers/not/not.d.ts +14 -0
- package/es/core/handlebars/helpers/not/not.mjs +12 -0
- package/es/core/handlebars/helpers/not-includes/not-includes.d.ts +13 -0
- package/es/core/handlebars/helpers/not-includes/not-includes.mjs +11 -0
- package/es/core/handlebars/helpers/or/or.d.ts +13 -0
- package/es/core/handlebars/helpers/or/or.mjs +16 -0
- package/es/core/handlebars/helpers/pascal-case/pascal-case.d.ts +13 -0
- package/es/core/handlebars/helpers/pascal-case/pascal-case.mjs +13 -0
- package/es/core/handlebars/helpers/snake-case/snake-case.d.ts +13 -0
- package/es/core/handlebars/helpers/snake-case/snake-case.mjs +13 -0
- package/es/core/handlebars/helpers/spinal-case/spinal-case.d.ts +13 -0
- package/es/core/handlebars/helpers/spinal-case/spinal-case.mjs +13 -0
- package/es/core/handlebars/helpers/upper-case/upper-case.d.ts +13 -0
- package/es/core/handlebars/helpers/upper-case/upper-case.mjs +12 -0
- package/es/core/handlebars/index.d.ts +2 -0
- package/es/core/handlebars/index.mjs +2 -0
- package/es/core/handlebars/utils/helper/helper.d.ts +33 -0
- package/es/core/handlebars/utils/helper/helper.mjs +54 -0
- package/es/core/handlebars/utils/index.d.ts +17 -0
- package/es/core/handlebars/utils/index.mjs +7 -0
- package/es/core/index.d.ts +2 -0
- package/es/core/index.mjs +2 -0
- package/es/core/interface/index.d.ts +1 -0
- package/es/core/interface/index.mjs +0 -0
- package/es/index.mjs +1 -1
- package/package.json +10 -7
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import Handlebars from 'handlebars';
|
|
2
|
+
import { IObject } from '../interface';
|
|
3
|
+
/**
|
|
4
|
+
* 生成器
|
|
5
|
+
*
|
|
6
|
+
* @export
|
|
7
|
+
* @class HandlebarsEngine
|
|
8
|
+
*/
|
|
9
|
+
export declare class HandlebarsEngine {
|
|
10
|
+
/**
|
|
11
|
+
* 编译参数
|
|
12
|
+
*
|
|
13
|
+
* @protected
|
|
14
|
+
* @type {CompileOptions}
|
|
15
|
+
*/
|
|
16
|
+
protected compileOpt: CompileOptions;
|
|
17
|
+
/**
|
|
18
|
+
* Handlebars 运行时参数
|
|
19
|
+
*
|
|
20
|
+
* @protected
|
|
21
|
+
* @type {Handlebars.RuntimeOptions}
|
|
22
|
+
*/
|
|
23
|
+
protected runtimeOpt: Handlebars.RuntimeOptions;
|
|
24
|
+
/**
|
|
25
|
+
* 忽略编译的上下文标签规则
|
|
26
|
+
*
|
|
27
|
+
* @protected
|
|
28
|
+
*/
|
|
29
|
+
protected tagReg: RegExp;
|
|
30
|
+
/**
|
|
31
|
+
* 模板映射内容
|
|
32
|
+
*
|
|
33
|
+
* @type {Map<string, string>} Map<模板路径, 模板内容>
|
|
34
|
+
*/
|
|
35
|
+
readonly temps: Map<string, string>;
|
|
36
|
+
constructor();
|
|
37
|
+
/**
|
|
38
|
+
* 注册宏
|
|
39
|
+
*
|
|
40
|
+
* @param {string} key 宏标识
|
|
41
|
+
* @param {string} template 宏模板内容
|
|
42
|
+
*/
|
|
43
|
+
registerMacro(key: string, template: string): void;
|
|
44
|
+
/**
|
|
45
|
+
* 注册模板
|
|
46
|
+
*
|
|
47
|
+
* @param {string} key
|
|
48
|
+
* @param {string} template
|
|
49
|
+
*/
|
|
50
|
+
registerTemp(key: string, template: string): void;
|
|
51
|
+
/**
|
|
52
|
+
* 编译模板获取所有使用到的上下文级参数标识
|
|
53
|
+
*
|
|
54
|
+
* @param {string} template
|
|
55
|
+
* @return {*} {string[]}
|
|
56
|
+
*/
|
|
57
|
+
parseContextTags(template: string): string[];
|
|
58
|
+
/**
|
|
59
|
+
* 计算编译模板中的参数标签
|
|
60
|
+
*
|
|
61
|
+
* @protected
|
|
62
|
+
* @param {Set<string>} set
|
|
63
|
+
* @param {Record<string, any>[]} tags
|
|
64
|
+
*/
|
|
65
|
+
protected calcTemplateTags(set: Set<string>, tags: Record<string, any>[]): void;
|
|
66
|
+
/**
|
|
67
|
+
* 直接工具模板和数据编译
|
|
68
|
+
*
|
|
69
|
+
* @param {string} template
|
|
70
|
+
* @param {IObject} data
|
|
71
|
+
* @return {*} {string}
|
|
72
|
+
*/
|
|
73
|
+
render(template: string, data: IObject): string;
|
|
74
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import Handlebars from "handlebars";
|
|
2
|
+
import { installHelpers } from "./helpers/index.mjs";
|
|
3
|
+
import { HelperUtil, winToUnixPath } from "./utils/index.mjs";
|
|
4
|
+
import { TEMP_EXTENSION } from "./constant/index.mjs";
|
|
5
|
+
export class HandlebarsEngine {
|
|
6
|
+
/**
|
|
7
|
+
* 编译参数
|
|
8
|
+
*
|
|
9
|
+
* @protected
|
|
10
|
+
* @type {CompileOptions}
|
|
11
|
+
*/
|
|
12
|
+
compileOpt = { compat: true, noEscape: true };
|
|
13
|
+
/**
|
|
14
|
+
* Handlebars 运行时参数
|
|
15
|
+
*
|
|
16
|
+
* @protected
|
|
17
|
+
* @type {Handlebars.RuntimeOptions}
|
|
18
|
+
*/
|
|
19
|
+
runtimeOpt = {
|
|
20
|
+
allowProtoPropertiesByDefault: true
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* 忽略编译的上下文标签规则
|
|
24
|
+
*
|
|
25
|
+
* @protected
|
|
26
|
+
*/
|
|
27
|
+
tagReg = /^[a-zA-Z0-9:_-]+$/;
|
|
28
|
+
/**
|
|
29
|
+
* 模板映射内容
|
|
30
|
+
*
|
|
31
|
+
* @type {Map<string, string>} Map<模板路径, 模板内容>
|
|
32
|
+
*/
|
|
33
|
+
temps = /* @__PURE__ */ new Map();
|
|
34
|
+
constructor() {
|
|
35
|
+
installHelpers();
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* 注册宏
|
|
39
|
+
*
|
|
40
|
+
* @param {string} key 宏标识
|
|
41
|
+
* @param {string} template 宏模板内容
|
|
42
|
+
*/
|
|
43
|
+
registerMacro(key, template) {
|
|
44
|
+
key = winToUnixPath(key);
|
|
45
|
+
if (key.endsWith(TEMP_EXTENSION)) {
|
|
46
|
+
key = key.replace(TEMP_EXTENSION, "");
|
|
47
|
+
Handlebars.registerPartial(key, template);
|
|
48
|
+
} else {
|
|
49
|
+
Handlebars.registerPartial(key, template);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* 注册模板
|
|
54
|
+
*
|
|
55
|
+
* @param {string} key
|
|
56
|
+
* @param {string} template
|
|
57
|
+
*/
|
|
58
|
+
registerTemp(key, template) {
|
|
59
|
+
key = winToUnixPath(key);
|
|
60
|
+
if (key.endsWith(TEMP_EXTENSION)) {
|
|
61
|
+
key = key.replace(TEMP_EXTENSION, "");
|
|
62
|
+
this.temps.set(key, template);
|
|
63
|
+
} else {
|
|
64
|
+
this.temps.set(key, template);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* 编译模板获取所有使用到的上下文级参数标识
|
|
69
|
+
*
|
|
70
|
+
* @param {string} template
|
|
71
|
+
* @return {*} {string[]}
|
|
72
|
+
*/
|
|
73
|
+
parseContextTags(template) {
|
|
74
|
+
const program = Handlebars.parse(template);
|
|
75
|
+
const set = /* @__PURE__ */ new Set();
|
|
76
|
+
this.calcTemplateTags(set, program.body);
|
|
77
|
+
return Array.from(set);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* 计算编译模板中的参数标签
|
|
81
|
+
*
|
|
82
|
+
* @protected
|
|
83
|
+
* @param {Set<string>} set
|
|
84
|
+
* @param {Record<string, any>[]} tags
|
|
85
|
+
*/
|
|
86
|
+
calcTemplateTags(set, tags) {
|
|
87
|
+
tags.forEach((item) => {
|
|
88
|
+
switch (item.type) {
|
|
89
|
+
case "SubExpression":
|
|
90
|
+
if (item.params?.length > 0) {
|
|
91
|
+
this.calcTemplateTags(set, item.params);
|
|
92
|
+
}
|
|
93
|
+
return;
|
|
94
|
+
case "MustacheStatement":
|
|
95
|
+
case "PathExpression": {
|
|
96
|
+
const tag = item.path ? item.path.original : item.original;
|
|
97
|
+
if (HelperUtil.isHelperName(tag)) {
|
|
98
|
+
if (item.params?.length > 0) {
|
|
99
|
+
this.calcTemplateTags(set, item.params);
|
|
100
|
+
}
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if (this.tagReg.test(tag)) {
|
|
104
|
+
set.add(tag);
|
|
105
|
+
}
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
default:
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* 直接工具模板和数据编译
|
|
114
|
+
*
|
|
115
|
+
* @param {string} template
|
|
116
|
+
* @param {IObject} data
|
|
117
|
+
* @return {*} {string}
|
|
118
|
+
*/
|
|
119
|
+
render(template, data) {
|
|
120
|
+
return Handlebars.compile(template, this.compileOpt)(data, this.runtimeOpt);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { HelperBase } from '../helper-base';
|
|
2
|
+
/**
|
|
3
|
+
* 并且条件模式
|
|
4
|
+
*
|
|
5
|
+
* @description 判断: word wor2 word3 必须在判断中必须全部为 true, 用法: {{#and word word2 word3}}xxx{{else}}yyy{{/and}}、{{and word word2 word3}} 返回值为 boolean 类型
|
|
6
|
+
* @export
|
|
7
|
+
* @class HelperAnd
|
|
8
|
+
* @extends {HelperBase}
|
|
9
|
+
*/
|
|
10
|
+
export declare class HelperAnd extends HelperBase {
|
|
11
|
+
constructor();
|
|
12
|
+
onExecute(...args: unknown[] | Handlebars.HelperOptions[]): string | boolean;
|
|
13
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { HelperUtil } from "../../utils/index.mjs";
|
|
2
|
+
import { HelperBase } from "../helper-base.mjs";
|
|
3
|
+
export class HelperAnd extends HelperBase {
|
|
4
|
+
constructor() {
|
|
5
|
+
super("and");
|
|
6
|
+
}
|
|
7
|
+
onExecute(...args) {
|
|
8
|
+
const options = args[args.length - 1];
|
|
9
|
+
args.pop();
|
|
10
|
+
const arr = args.filter((item) => !!item);
|
|
11
|
+
const bol = arr.length === args.length;
|
|
12
|
+
return HelperUtil.handleJudgmentExecute(this, bol, options);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { HelperBase } from '../helper-base';
|
|
2
|
+
/**
|
|
3
|
+
* 转驼峰
|
|
4
|
+
*
|
|
5
|
+
* @description 用法 {{camelCase xxx}},效果: this-is-my-name => thisIsMyName
|
|
6
|
+
* @export
|
|
7
|
+
* @class HelperCamelCase
|
|
8
|
+
* @extends {HelperBase}
|
|
9
|
+
*/
|
|
10
|
+
export declare class HelperCamelCase extends HelperBase {
|
|
11
|
+
constructor();
|
|
12
|
+
onExecute(param: string): string;
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { camelCase } from "lodash-es";
|
|
2
|
+
import { HelperBase } from "../helper-base.mjs";
|
|
3
|
+
export class HelperCamelCase extends HelperBase {
|
|
4
|
+
constructor() {
|
|
5
|
+
super("camelCase");
|
|
6
|
+
}
|
|
7
|
+
onExecute(param) {
|
|
8
|
+
if (!param) {
|
|
9
|
+
return "";
|
|
10
|
+
}
|
|
11
|
+
return camelCase(param);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { HelperBase } from '../helper-base';
|
|
2
|
+
/**
|
|
3
|
+
* 字符串拼接
|
|
4
|
+
*
|
|
5
|
+
* @description 用法:{{concat string1 string2 string3}} 返回值为 string 类型
|
|
6
|
+
* @export
|
|
7
|
+
* @class HelperConcat
|
|
8
|
+
* @extends {HelperBase}
|
|
9
|
+
*/
|
|
10
|
+
export declare class HelperConcat extends HelperBase {
|
|
11
|
+
constructor();
|
|
12
|
+
onExecute(...args: string[]): string;
|
|
13
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as Handlebars from 'handlebars';
|
|
2
|
+
import { HelperBase } from '../helper-base';
|
|
3
|
+
/**
|
|
4
|
+
* 等于
|
|
5
|
+
*
|
|
6
|
+
* @description 判断: word === word2, 用法: {{#eq word word2}}xxx{{else}}yyy{{/eq}}、{{eq word 'xxx'}} 返回值为 boolean 类型
|
|
7
|
+
* @export
|
|
8
|
+
* @class HelperEq
|
|
9
|
+
* @extends {HelperBase}
|
|
10
|
+
*/
|
|
11
|
+
export declare class HelperEq extends HelperBase {
|
|
12
|
+
constructor();
|
|
13
|
+
onExecute(param: unknown, param2: unknown, options: Handlebars.HelperOptions): string | boolean;
|
|
14
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { eq } from "lodash-es";
|
|
2
|
+
import { HelperUtil } from "../../utils/index.mjs";
|
|
3
|
+
import { HelperBase } from "../helper-base.mjs";
|
|
4
|
+
export class HelperEq extends HelperBase {
|
|
5
|
+
constructor() {
|
|
6
|
+
super("eq");
|
|
7
|
+
}
|
|
8
|
+
onExecute(param, param2, options) {
|
|
9
|
+
const bol = eq(param, param2);
|
|
10
|
+
return HelperUtil.handleJudgmentExecute(this, bol, options);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { HelperBase } from '../helper-base';
|
|
2
|
+
/**
|
|
3
|
+
* 格式化导入
|
|
4
|
+
*
|
|
5
|
+
* @description 专门格式化导入的 response 对象,效果: ResponseEntity«List«TraceSettingResponse»» => TraceSettingResponse
|
|
6
|
+
* @export
|
|
7
|
+
* @class HelperFormatImport
|
|
8
|
+
* @extends {HelperBase}
|
|
9
|
+
*/
|
|
10
|
+
export declare class HelperFormatImport extends HelperBase {
|
|
11
|
+
constructor();
|
|
12
|
+
onExecute(param: string[]): string;
|
|
13
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { HelperBase } from "../helper-base.mjs";
|
|
2
|
+
export class HelperFormatImport extends HelperBase {
|
|
3
|
+
constructor() {
|
|
4
|
+
super("formatImport");
|
|
5
|
+
}
|
|
6
|
+
onExecute(param) {
|
|
7
|
+
if (!param || param.length === 0) {
|
|
8
|
+
return "";
|
|
9
|
+
}
|
|
10
|
+
const items = param.map((item) => {
|
|
11
|
+
if (item.indexOf("\xAB") > -1) {
|
|
12
|
+
const arr = item.split("\xAB");
|
|
13
|
+
return arr[arr.length - 1].split("\xBB")[0];
|
|
14
|
+
}
|
|
15
|
+
return item;
|
|
16
|
+
}).filter((item) => {
|
|
17
|
+
const keys = item.split(",");
|
|
18
|
+
const tag = keys[0];
|
|
19
|
+
switch (tag) {
|
|
20
|
+
case "string":
|
|
21
|
+
case "object":
|
|
22
|
+
case "void":
|
|
23
|
+
case "integer":
|
|
24
|
+
case "int":
|
|
25
|
+
case "long":
|
|
26
|
+
case "Map":
|
|
27
|
+
return false;
|
|
28
|
+
default:
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
return Array.from(new Set(items)).join(",");
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { HelperBase } from '../helper-base';
|
|
2
|
+
/**
|
|
3
|
+
* 格式化导入
|
|
4
|
+
*
|
|
5
|
+
* @description 专门格式化导入的 response 对象,效果: ResponseEntity«List«TraceSettingResponse»» => TraceSettingResponse
|
|
6
|
+
* @export
|
|
7
|
+
* @class HelperFormatImportItem
|
|
8
|
+
* @extends {HelperBase}
|
|
9
|
+
*/
|
|
10
|
+
export declare class HelperFormatImportItem extends HelperBase {
|
|
11
|
+
constructor();
|
|
12
|
+
onExecute(param: string): string;
|
|
13
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { HelperBase } from "../helper-base.mjs";
|
|
2
|
+
export class HelperFormatImportItem extends HelperBase {
|
|
3
|
+
constructor() {
|
|
4
|
+
super("formatImportItem");
|
|
5
|
+
}
|
|
6
|
+
onExecute(param) {
|
|
7
|
+
if (!param) {
|
|
8
|
+
return "";
|
|
9
|
+
}
|
|
10
|
+
if (param.indexOf("\xAB") > -1) {
|
|
11
|
+
const arr = param.split("\xAB");
|
|
12
|
+
const text = arr[arr.length - 1].split("\xBB")[0];
|
|
13
|
+
let keys = text.split(",");
|
|
14
|
+
if (keys.length > 1) {
|
|
15
|
+
return "IObject";
|
|
16
|
+
}
|
|
17
|
+
keys = keys.map((key) => {
|
|
18
|
+
if (key === "Void") {
|
|
19
|
+
return "void";
|
|
20
|
+
}
|
|
21
|
+
if (key === "int" || key === "long") {
|
|
22
|
+
return "number";
|
|
23
|
+
}
|
|
24
|
+
if (key === "Map") {
|
|
25
|
+
return "IObject";
|
|
26
|
+
}
|
|
27
|
+
return key;
|
|
28
|
+
});
|
|
29
|
+
return keys.join(",");
|
|
30
|
+
}
|
|
31
|
+
return param;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { IObject } from '../../../interface';
|
|
2
|
+
import { HelperBase } from '../helper-base';
|
|
3
|
+
/**
|
|
4
|
+
* 格式化导入
|
|
5
|
+
*
|
|
6
|
+
* @description 针对后台的 swagger 生成的 js 类型,进行对 js 的类型转换
|
|
7
|
+
* @export
|
|
8
|
+
* @class HelperFormatJsType
|
|
9
|
+
* @extends {HelperBase}
|
|
10
|
+
*/
|
|
11
|
+
export declare class HelperFormatJsType extends HelperBase {
|
|
12
|
+
constructor();
|
|
13
|
+
onExecute(param: string, cfg?: IObject): string;
|
|
14
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { HelperBase } from "../helper-base.mjs";
|
|
2
|
+
export class HelperFormatJsType extends HelperBase {
|
|
3
|
+
constructor() {
|
|
4
|
+
super("formatJsType");
|
|
5
|
+
}
|
|
6
|
+
onExecute(param, cfg) {
|
|
7
|
+
if (!param) {
|
|
8
|
+
return "unknown";
|
|
9
|
+
}
|
|
10
|
+
if (param === "array") {
|
|
11
|
+
if (cfg) {
|
|
12
|
+
let type = cfg.type || cfg.originalRef;
|
|
13
|
+
if (type) {
|
|
14
|
+
if (type === "integer") {
|
|
15
|
+
type = "number";
|
|
16
|
+
} else if (type.startsWith("Triple\xAB")) {
|
|
17
|
+
type = "unknown";
|
|
18
|
+
}
|
|
19
|
+
} else {
|
|
20
|
+
type = "unknown";
|
|
21
|
+
}
|
|
22
|
+
return type + "[]";
|
|
23
|
+
}
|
|
24
|
+
return "unknown[]";
|
|
25
|
+
}
|
|
26
|
+
if (param === "integer") {
|
|
27
|
+
return "number";
|
|
28
|
+
}
|
|
29
|
+
if (param === "object") {
|
|
30
|
+
return "Record<string, unknown>";
|
|
31
|
+
}
|
|
32
|
+
return param;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as Handlebars from 'handlebars';
|
|
2
|
+
import { HelperBase } from '../helper-base';
|
|
3
|
+
/**
|
|
4
|
+
* 大于
|
|
5
|
+
*
|
|
6
|
+
* @description 判断: word > word2, 用法: {{#gt word word2}}xxx{{else}}yyy{{/gt}}、{{gt word word2}} 返回值为 boolean 类型
|
|
7
|
+
* @export
|
|
8
|
+
* @class HelperGt
|
|
9
|
+
* @extends {HelperBase}
|
|
10
|
+
*/
|
|
11
|
+
export declare class HelperGt extends HelperBase {
|
|
12
|
+
constructor();
|
|
13
|
+
onExecute(param: unknown, param2: unknown, options: Handlebars.HelperOptions): string | boolean;
|
|
14
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { gt } from "lodash-es";
|
|
2
|
+
import { HelperUtil } from "../../utils/index.mjs";
|
|
3
|
+
import { HelperBase } from "../helper-base.mjs";
|
|
4
|
+
export class HelperGt extends HelperBase {
|
|
5
|
+
constructor() {
|
|
6
|
+
super("gt");
|
|
7
|
+
}
|
|
8
|
+
onExecute(param, param2, options) {
|
|
9
|
+
const bol = gt(param, param2);
|
|
10
|
+
return HelperUtil.handleJudgmentExecute(this, bol, options);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as Handlebars from 'handlebars';
|
|
2
|
+
import { HelperBase } from '../helper-base';
|
|
3
|
+
/**
|
|
4
|
+
* 大于等于
|
|
5
|
+
*
|
|
6
|
+
* @description 判断: word >= word2, 用法 {{#gte word word2}}xxx{{else}}yyy{{/gte}}、{{gte word word2}} 返回值为 boolean 类型
|
|
7
|
+
* @export
|
|
8
|
+
* @class HelperGte
|
|
9
|
+
* @extends {HelperBase}
|
|
10
|
+
*/
|
|
11
|
+
export declare class HelperGte extends HelperBase {
|
|
12
|
+
constructor();
|
|
13
|
+
onExecute(param: unknown, param2: unknown, options: Handlebars.HelperOptions): string | boolean;
|
|
14
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { gte } from "lodash-es";
|
|
2
|
+
import { HelperUtil } from "../../utils/index.mjs";
|
|
3
|
+
import { HelperBase } from "../helper-base.mjs";
|
|
4
|
+
export class HelperGte extends HelperBase {
|
|
5
|
+
constructor() {
|
|
6
|
+
super("gte");
|
|
7
|
+
}
|
|
8
|
+
onExecute(param, param2, options) {
|
|
9
|
+
const bol = gte(param, param2);
|
|
10
|
+
return HelperUtil.handleJudgmentExecute(this, bol, options);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* helper 基类
|
|
3
|
+
*
|
|
4
|
+
* @export
|
|
5
|
+
* @class HelperBase
|
|
6
|
+
*/
|
|
7
|
+
export declare abstract class HelperBase {
|
|
8
|
+
/**
|
|
9
|
+
* Creates an instance of HelperBase.
|
|
10
|
+
*
|
|
11
|
+
* @param {string} tag 助手标识
|
|
12
|
+
*/
|
|
13
|
+
constructor(tag: string);
|
|
14
|
+
/**
|
|
15
|
+
* 助手执行
|
|
16
|
+
*
|
|
17
|
+
* @abstract
|
|
18
|
+
* @param {...unknown[]} args
|
|
19
|
+
* @return {*} {(string | boolean)}
|
|
20
|
+
*/
|
|
21
|
+
abstract onExecute(...args: unknown[]): string | boolean;
|
|
22
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { HelperBase } from '../helper-base';
|
|
2
|
+
/**
|
|
3
|
+
* 字符串包含内容
|
|
4
|
+
*
|
|
5
|
+
* @description 判断: 'test'.includes('t'), 用法: {{#includes word word2}}xxx{{else}}yyy{{/includes}}、{{includes word word2}} 返回值为 boolean 类型
|
|
6
|
+
* @export
|
|
7
|
+
* @class HelperIncludes
|
|
8
|
+
* @extends {HelperBase}
|
|
9
|
+
*/
|
|
10
|
+
export declare class HelperIncludes extends HelperBase {
|
|
11
|
+
constructor();
|
|
12
|
+
onExecute(param: string, param2: string, options: Handlebars.HelperOptions): string | boolean;
|
|
13
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { HelperUtil } from "../../utils/index.mjs";
|
|
2
|
+
import { HelperBase } from "../helper-base.mjs";
|
|
3
|
+
export class HelperIncludes extends HelperBase {
|
|
4
|
+
constructor() {
|
|
5
|
+
super("includes");
|
|
6
|
+
}
|
|
7
|
+
onExecute(param, param2, options) {
|
|
8
|
+
const bol = param.includes(param2);
|
|
9
|
+
return HelperUtil.handleJudgmentExecute(this, bol, options);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { HelperAnd } from "./and/and.mjs";
|
|
2
|
+
import { HelperCamelCase } from "./camel-case/camel-case.mjs";
|
|
3
|
+
import { HelperConcat } from "./concat/concat.mjs";
|
|
4
|
+
import { HelperEq } from "./eq/eq.mjs";
|
|
5
|
+
import { HelperFormatImport } from "./format-import/format-import.mjs";
|
|
6
|
+
import { HelperFormatImportItem } from "./format-import-item/format-import-item.mjs";
|
|
7
|
+
import { HelperFormatJsType } from "./format-js-type/format-js-type.mjs";
|
|
8
|
+
import { HelperGt } from "./gt/gt.mjs";
|
|
9
|
+
import { HelperGte } from "./gte/gte.mjs";
|
|
10
|
+
import { HelperIncludes } from "./includes/includes.mjs";
|
|
11
|
+
import { HelperJson } from "./json/json.mjs";
|
|
12
|
+
import { HelperLowerCase } from "./lower-case/lower-case.mjs";
|
|
13
|
+
import { HelperLt } from "./lt/lt.mjs";
|
|
14
|
+
import { HelperLte } from "./lte/lte.mjs";
|
|
15
|
+
import { HelperNeq } from "./neq/neq.mjs";
|
|
16
|
+
import { HelperNotIncludes } from "./not-includes/not-includes.mjs";
|
|
17
|
+
import { HelperNot } from "./not/not.mjs";
|
|
18
|
+
import { HelperOr } from "./or/or.mjs";
|
|
19
|
+
import { HelperPascalCase } from "./pascal-case/pascal-case.mjs";
|
|
20
|
+
import { HelperSnakeCase } from "./snake-case/snake-case.mjs";
|
|
21
|
+
import { HelperSpinalCase } from "./spinal-case/spinal-case.mjs";
|
|
22
|
+
import { HelperUpperCase } from "./upper-case/upper-case.mjs";
|
|
23
|
+
export function installHelpers() {
|
|
24
|
+
new HelperAnd();
|
|
25
|
+
new HelperCamelCase();
|
|
26
|
+
new HelperConcat();
|
|
27
|
+
new HelperEq();
|
|
28
|
+
new HelperFormatImport();
|
|
29
|
+
new HelperFormatImportItem();
|
|
30
|
+
new HelperFormatJsType();
|
|
31
|
+
new HelperGt();
|
|
32
|
+
new HelperGte();
|
|
33
|
+
new HelperIncludes();
|
|
34
|
+
new HelperJson();
|
|
35
|
+
new HelperLowerCase();
|
|
36
|
+
new HelperLt();
|
|
37
|
+
new HelperLte();
|
|
38
|
+
new HelperNeq();
|
|
39
|
+
new HelperNot();
|
|
40
|
+
new HelperNotIncludes();
|
|
41
|
+
new HelperOr();
|
|
42
|
+
new HelperPascalCase();
|
|
43
|
+
new HelperSnakeCase();
|
|
44
|
+
new HelperSpinalCase();
|
|
45
|
+
new HelperUpperCase();
|
|
46
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { HelperBase } from '../helper-base';
|
|
2
|
+
/**
|
|
3
|
+
* json 转 string
|
|
4
|
+
*
|
|
5
|
+
* @description 用法 {{json xxx 2}},支持第二个参数传递格式化。效果: 将 json 对象转为 json 字符串
|
|
6
|
+
* @export
|
|
7
|
+
* @class HelperJson
|
|
8
|
+
* @extends {HelperBase}
|
|
9
|
+
*/
|
|
10
|
+
export declare class HelperJson extends HelperBase {
|
|
11
|
+
constructor();
|
|
12
|
+
onExecute(obj: Record<string, unknown> | unknown[], space: number): string;
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { HelperBase } from "../helper-base.mjs";
|
|
2
|
+
export class HelperJson extends HelperBase {
|
|
3
|
+
constructor() {
|
|
4
|
+
super("jsonStringify");
|
|
5
|
+
}
|
|
6
|
+
onExecute(obj, space) {
|
|
7
|
+
return JSON.stringify(
|
|
8
|
+
obj,
|
|
9
|
+
null,
|
|
10
|
+
typeof space === "number" ? space : void 0
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { HelperBase } from '../helper-base';
|
|
2
|
+
/**
|
|
3
|
+
* 字符串转换小写
|
|
4
|
+
*
|
|
5
|
+
* @description 用法 {{lowerCase word}}, 效果: MyName => myname
|
|
6
|
+
* @export
|
|
7
|
+
* @class HelperLowerCase
|
|
8
|
+
* @extends {HelperBase}
|
|
9
|
+
*/
|
|
10
|
+
export declare class HelperLowerCase extends HelperBase {
|
|
11
|
+
constructor();
|
|
12
|
+
onExecute(param: string): string;
|
|
13
|
+
}
|