@lcap/nasl 0.3.9 → 0.3.10-beta
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/out/service/create/errHandles.js +7 -2
- package/out/service/create/errHandles.js.map +1 -1
- package/out/service/debugger/debugger.d.ts +3 -0
- package/out/service/debugger/debugger.js +95 -0
- package/out/service/debugger/debugger.js.map +1 -0
- package/out/service/logic/logic.d.ts +27 -0
- package/out/service/logic/logic.js +20 -0
- package/out/service/logic/logic.js.map +1 -1
- package/out/service/page/element.d.ts +9 -0
- package/out/service/page/element.js +6 -0
- package/out/service/page/element.js.map +1 -1
- package/out/service/permission/api.d.ts +57 -0
- package/out/service/permission/api.js +41 -0
- package/out/service/permission/api.js.map +1 -0
- package/out/service/permission/index.d.ts +2 -0
- package/out/service/permission/index.js +17 -0
- package/out/service/permission/index.js.map +1 -0
- package/out/service/webFile/index.js +5 -0
- package/out/service/webFile/index.js.map +1 -1
- package/out/types/app/App.d.ts +4 -1
- package/out/types/app/App.js +24 -0
- package/out/types/app/App.js.map +1 -1
- package/out/types/app/Service.d.ts +2 -2
- package/out/types/app/Service.js +28 -3
- package/out/types/app/Service.js.map +1 -1
- package/out/types/cache.d.ts +6 -0
- package/out/types/cache.js +54 -0
- package/out/types/cache.js.map +1 -0
- package/out/types/common/Vertex.d.ts +25 -0
- package/out/types/common/Vertex.js +40 -0
- package/out/types/common/Vertex.js.map +1 -1
- package/out/types/data/Entity.js +1 -0
- package/out/types/data/Entity.js.map +1 -1
- package/out/types/data/Enum.d.ts +5 -0
- package/out/types/data/Enum.js +5 -0
- package/out/types/data/Enum.js.map +1 -1
- package/out/types/data/Interface.js +5 -3
- package/out/types/data/Interface.js.map +1 -1
- package/out/types/data/genBlock/genCreateBlock.js +5 -5
- package/out/types/data/genBlock/genCreateBlock.js.map +1 -1
- package/out/types/data/genBlock/genCurdBlock.js +3 -3
- package/out/types/data/genBlock/genCurdBlock.js.map +1 -1
- package/out/types/data/genBlock/genEnumSelectBlock.d.ts +1 -1
- package/out/types/data/genBlock/genEnumSelectBlock.js +2 -2
- package/out/types/data/genBlock/genEnumSelectBlock.js.map +1 -1
- package/out/types/data/genBlock/genGridViewBlock.js +12 -1
- package/out/types/data/genBlock/genGridViewBlock.js.map +1 -1
- package/out/types/data/genBlock/genListViewBlock.js +2 -2
- package/out/types/data/genBlock/genSelectBlock.js +2 -2
- package/out/types/data/genBlock/genTableBlock.js +14 -3
- package/out/types/data/genBlock/genTableBlock.js.map +1 -1
- package/out/types/data/genBlock/genUpdateBlock.js +5 -5
- package/out/types/data/genBlock/genUpdateBlock.js.map +1 -1
- package/out/types/data/systemTypes.js +47 -0
- package/out/types/data/systemTypes.js.map +1 -1
- package/out/types/enum.d.ts +6 -0
- package/out/types/enum.js +11 -0
- package/out/types/enum.js.map +1 -0
- package/out/types/generator/hotReload.d.ts +2 -0
- package/out/types/generator/hotReload.js +12 -1
- package/out/types/generator/hotReload.js.map +1 -1
- package/out/types/index.d.ts +7 -1
- package/out/types/index.js +11 -2
- package/out/types/index.js.map +1 -1
- package/out/types/logic/BreakPoint.d.ts +42 -0
- package/out/types/logic/BreakPoint.js +155 -0
- package/out/types/logic/BreakPoint.js.map +1 -0
- package/out/types/logic/Debugger.d.ts +156 -0
- package/out/types/logic/Debugger.js +912 -0
- package/out/types/logic/Debugger.js.map +1 -0
- package/out/types/logic/Logic.d.ts +40 -0
- package/out/types/logic/Logic.js +130 -31
- package/out/types/logic/Logic.js.map +1 -1
- package/out/types/logic/LogicItem.d.ts +21 -1
- package/out/types/logic/LogicItem.js +227 -24
- package/out/types/logic/LogicItem.js.map +1 -1
- package/out/types/logic/Param.d.ts +1 -0
- package/out/types/logic/Param.js +38 -20
- package/out/types/logic/Param.js.map +1 -1
- package/out/types/logic/Return.js +14 -19
- package/out/types/logic/Return.js.map +1 -1
- package/out/types/logic/Variable.js +14 -19
- package/out/types/logic/Variable.js.map +1 -1
- package/out/types/logic/translator.js +0 -2
- package/out/types/logic/translator.js.map +1 -1
- package/out/types/nuims/Nuims.d.ts +1 -1
- package/out/types/nuims/Nuims.js +11 -4
- package/out/types/nuims/Nuims.js.map +1 -1
- package/out/types/page/Element.d.ts +5 -0
- package/out/types/page/Element.js +114 -130
- package/out/types/page/Element.js.map +1 -1
- package/out/types/page/Event.js.map +1 -1
- package/out/types/page/Page.d.ts +1 -0
- package/out/types/page/Page.js +59 -27
- package/out/types/page/Page.js.map +1 -1
- package/out/types/page/View.d.ts +17 -3
- package/out/types/page/View.js +53 -37
- package/out/types/page/View.js.map +1 -1
- package/out/types/page/ViewParam.d.ts +1 -0
- package/out/types/page/ViewParam.js +23 -4
- package/out/types/page/ViewParam.js.map +1 -1
- package/out/types/page/ViewVariable.js +13 -18
- package/out/types/page/ViewVariable.js.map +1 -1
- package/out/types/permission/Permission.d.ts +41 -0
- package/out/types/permission/Permission.js +122 -0
- package/out/types/permission/Permission.js.map +1 -0
- package/package.json +2 -2
- package/src/service/create/errHandles.js +6 -2
- package/src/service/debugger/debugger.js +90 -0
- package/src/service/developPermission/api.js +37 -0
- package/src/service/developPermission/index.js +13 -0
- package/src/service/logic/logic.js +20 -0
- package/src/service/page/element.js +6 -0
- package/src/service/permission/api.js +38 -0
- package/src/service/permission/index.js +13 -0
- package/src/service/webFile/index.js +6 -1
- package/src/types/app/App.ts +27 -1
- package/src/types/app/Service.ts +32 -3
- package/src/types/cache.ts +50 -0
- package/src/types/common/Vertex.ts +30 -0
- package/src/types/data/Entity.ts +1 -0
- package/src/types/data/Enum.ts +5 -0
- package/src/types/data/Interface.ts +4 -3
- package/src/types/data/genBlock/genCreateBlock.ts +5 -5
- package/src/types/data/genBlock/genCurdBlock.ts +3 -3
- package/src/types/data/genBlock/genEnumSelectBlock.ts +2 -2
- package/src/types/data/genBlock/genGridViewBlock.ts +12 -1
- package/src/types/data/genBlock/genListViewBlock.ts +2 -2
- package/src/types/data/genBlock/genSelectBlock.ts +2 -2
- package/src/types/data/genBlock/genTableBlock.ts +14 -3
- package/src/types/data/genBlock/genUpdateBlock.ts +5 -5
- package/src/types/data/systemTypes.ts +47 -0
- package/src/types/enum.ts +6 -0
- package/src/types/generator/hotReload.ts +10 -0
- package/src/types/index.ts +7 -1
- package/src/types/logic/BreakPoint.ts +200 -0
- package/src/types/logic/Debugger.ts +1140 -0
- package/src/types/logic/Logic.ts +133 -28
- package/src/types/logic/LogicItem.ts +250 -28
- package/src/types/logic/Param.ts +26 -8
- package/src/types/logic/Return.ts +4 -9
- package/src/types/logic/Variable.ts +4 -8
- package/src/types/logic/translator.d.ts +16 -0
- package/src/types/logic/translator.js +144 -88
- package/src/types/logic/translator_backup.js +5 -16
- package/src/types/nuims/Nuims.ts +11 -5
- package/src/types/page/Element.ts +63 -75
- package/src/types/page/Event.ts +0 -3
- package/src/types/page/Page.ts +73 -40
- package/src/types/page/View.ts +45 -18
- package/src/types/page/ViewParam.ts +22 -3
- package/src/types/page/ViewVariable.ts +4 -8
- package/src/types/permission/Permission.ts +112 -0
- package/tsconfig.json +1 -1
|
@@ -4,7 +4,7 @@ import { paramService } from '../../service/logic';
|
|
|
4
4
|
import { convert2RefType, convert2SchemaType } from '../data/dataTypeUtils';
|
|
5
5
|
import { getBasicTypeDefaultValue } from '../data/basicTypes';
|
|
6
6
|
import { schemaService } from '../../service/common';
|
|
7
|
-
|
|
7
|
+
import { catchFn } from './Param';
|
|
8
8
|
/**
|
|
9
9
|
* 逻辑输出参数
|
|
10
10
|
*/
|
|
@@ -50,7 +50,7 @@ export class Return extends BaseVariable {
|
|
|
50
50
|
operationDesc: actionOptions?.actionDesc || `添加逻辑"${this.logic.name}"输出参数"${this.name}"`,
|
|
51
51
|
},
|
|
52
52
|
body,
|
|
53
|
-
});
|
|
53
|
+
}).catch(catchFn(this.logic));
|
|
54
54
|
// convert2RefType(result.schema);
|
|
55
55
|
this.deepPick(result, ['id']);
|
|
56
56
|
this.assign({ code: this.genCode() });
|
|
@@ -75,7 +75,6 @@ export class Return extends BaseVariable {
|
|
|
75
75
|
config.defaultApp?.emit('saving');
|
|
76
76
|
|
|
77
77
|
if (this.id) {
|
|
78
|
-
try {
|
|
79
78
|
await paramService.delete({
|
|
80
79
|
headers: {
|
|
81
80
|
appId: config.defaultApp?.id,
|
|
@@ -86,11 +85,7 @@ export class Return extends BaseVariable {
|
|
|
86
85
|
loValId: this.id,
|
|
87
86
|
logicId: this.logic.id,
|
|
88
87
|
},
|
|
89
|
-
});
|
|
90
|
-
} catch(err) {
|
|
91
|
-
await config.defaultApp?.history.load();
|
|
92
|
-
throw err;
|
|
93
|
-
}
|
|
88
|
+
}).catch(catchFn(this.logic));
|
|
94
89
|
}
|
|
95
90
|
|
|
96
91
|
const index = this.logic.returns.indexOf(this);
|
|
@@ -123,7 +118,7 @@ export class Return extends BaseVariable {
|
|
|
123
118
|
operationDesc: actionOptions?.actionDesc || `修改逻辑输出参数"${this.name}"`,
|
|
124
119
|
},
|
|
125
120
|
body,
|
|
126
|
-
});
|
|
121
|
+
}).catch(catchFn(this.logic));
|
|
127
122
|
this.schema.id = result.schema.id;
|
|
128
123
|
// convert2RefType(result.schema);
|
|
129
124
|
// this.plainAssign(result);
|
|
@@ -4,6 +4,7 @@ import { paramService } from '../../service/logic';
|
|
|
4
4
|
import { convert2RefType, convert2SchemaType } from '../data/dataTypeUtils';
|
|
5
5
|
import { getBasicTypeDefaultValue } from '../data/basicTypes';
|
|
6
6
|
import { schemaService } from '../../service/common';
|
|
7
|
+
import { catchFn } from './Param';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* 逻辑局部变量
|
|
@@ -49,7 +50,7 @@ export class Variable extends BaseVariable {
|
|
|
49
50
|
operationDesc: actionOptions?.actionDesc || `添加逻辑"${this.logic.name}"局部变量"${this.name}"`,
|
|
50
51
|
},
|
|
51
52
|
body,
|
|
52
|
-
});
|
|
53
|
+
}).catch(catchFn(this.logic));
|
|
53
54
|
// convert2RefType(result.schema);
|
|
54
55
|
this.deepPick(result, ['id']);
|
|
55
56
|
this.assign({ code: this.genCode() });
|
|
@@ -73,7 +74,6 @@ export class Variable extends BaseVariable {
|
|
|
73
74
|
config.defaultApp?.emit('saving');
|
|
74
75
|
|
|
75
76
|
if (this.id) {
|
|
76
|
-
try {
|
|
77
77
|
await paramService.delete({
|
|
78
78
|
headers: {
|
|
79
79
|
appId: config.defaultApp?.id,
|
|
@@ -84,11 +84,7 @@ export class Variable extends BaseVariable {
|
|
|
84
84
|
loValId: this.id,
|
|
85
85
|
logicId: this.logic.id,
|
|
86
86
|
},
|
|
87
|
-
});
|
|
88
|
-
} catch(err) {
|
|
89
|
-
await config.defaultApp?.history.load();
|
|
90
|
-
throw err;
|
|
91
|
-
}
|
|
87
|
+
}).catch(catchFn(this.logic));
|
|
92
88
|
}
|
|
93
89
|
|
|
94
90
|
const index = this.logic.variables.indexOf(this);
|
|
@@ -120,7 +116,7 @@ export class Variable extends BaseVariable {
|
|
|
120
116
|
operationDesc: actionOptions?.actionDesc || `修改逻辑局部变量"${this.name}"`,
|
|
121
117
|
},
|
|
122
118
|
body,
|
|
123
|
-
});
|
|
119
|
+
}).catch(catchFn(this.logic));
|
|
124
120
|
this.schema.id = result.schema.id;
|
|
125
121
|
// convert2RefType(result.schema);
|
|
126
122
|
// this.plainAssign(result);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
declare namespace Translator {
|
|
3
|
+
export interface FrontEndsourceMap {
|
|
4
|
+
[id: string]: {
|
|
5
|
+
isLogic: boolean,
|
|
6
|
+
node: LogicItem,
|
|
7
|
+
from: number,
|
|
8
|
+
to: number,
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
declare function Translator(source: string, preScript: string): {
|
|
13
|
+
output: string,
|
|
14
|
+
sourceMap: Translator.FrontEndsourceMap,
|
|
15
|
+
};
|
|
16
|
+
export = Translator;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import generate from '@babel/generator';
|
|
2
1
|
import { Vertex } from '..';
|
|
3
2
|
|
|
4
|
-
function switchCase2If(cases) {
|
|
3
|
+
function switchCase2If(node, cases, idx = 0) {
|
|
5
4
|
const cas = cases.shift();
|
|
6
5
|
|
|
7
6
|
const result = {
|
|
8
7
|
type: 'IfStatement',
|
|
9
8
|
test: cas.test,
|
|
9
|
+
level: 'logicNode',
|
|
10
|
+
id: cas.id,
|
|
10
11
|
consequent: {
|
|
11
12
|
type: 'BlockStatement',
|
|
12
13
|
body: cas.consequent || [],
|
|
@@ -15,18 +16,19 @@ function switchCase2If(cases) {
|
|
|
15
16
|
};
|
|
16
17
|
|
|
17
18
|
if (cases.length) {
|
|
18
|
-
result.alternate = switchCase2If(cases);
|
|
19
|
+
result.alternate = switchCase2If(node, cases, idx + 1);
|
|
19
20
|
} else {
|
|
20
21
|
return {
|
|
21
22
|
type: 'BlockStatement',
|
|
22
23
|
body: cas.consequent || [],
|
|
24
|
+
id: cas.id,
|
|
23
25
|
};
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
return result;
|
|
27
29
|
}
|
|
28
30
|
|
|
29
|
-
export default function (source) {
|
|
31
|
+
export default function (source, preScript) {
|
|
30
32
|
const definition = typeof source === 'string' ? JSON.parse(source) : source;
|
|
31
33
|
|
|
32
34
|
function traverse(node, func, parent, index) {
|
|
@@ -122,6 +124,35 @@ export default function (source) {
|
|
|
122
124
|
}
|
|
123
125
|
}`);
|
|
124
126
|
|
|
127
|
+
let output = `
|
|
128
|
+
const methods = componentOptions.methods = componentOptions.methods || {};
|
|
129
|
+
const computed = componentOptions.computed = componentOptions.computed || {};
|
|
130
|
+
const oldDataFunc = componentOptions.data;
|
|
131
|
+
const data = function () {
|
|
132
|
+
const oldData = oldDataFunc ? oldDataFunc.call(this) : {};
|
|
133
|
+
return Object.assign(oldData, {
|
|
134
|
+
${paramsData ? paramsData + ',' : ''}
|
|
135
|
+
${variablesData}
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
componentOptions.data = data;
|
|
139
|
+
const meta = componentOptions.meta = componentOptions.meta || {};
|
|
140
|
+
Object.assign(meta, {
|
|
141
|
+
title: ${JSON.stringify(definition.title)},
|
|
142
|
+
crumb: ${JSON.stringify(definition.crumb)},
|
|
143
|
+
first: ${JSON.stringify(definition.first)},
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
${lifecycles.join('\n\n')}
|
|
147
|
+
|
|
148
|
+
`;
|
|
149
|
+
|
|
150
|
+
let startLineNumber = output.split('\n').length;
|
|
151
|
+
if (preScript && typeof preScript === 'string') {
|
|
152
|
+
startLineNumber += (preScript.split('\n').length - 2);
|
|
153
|
+
}
|
|
154
|
+
// console.log(preScript.split('\n').length, output.split('\n').length, startLineNumber);
|
|
155
|
+
const sourceMap = {};
|
|
125
156
|
const methods = (definition.logics || []).map((logic) => {
|
|
126
157
|
let returnObj = {
|
|
127
158
|
type: 'Identifier',
|
|
@@ -131,10 +162,18 @@ export default function (source) {
|
|
|
131
162
|
if (logic.returns[0])
|
|
132
163
|
returnObj = logic.returns[0];
|
|
133
164
|
|
|
134
|
-
|
|
165
|
+
// let lineRecorder = 0;
|
|
166
|
+
const recorder = {
|
|
167
|
+
line: startLineNumber,
|
|
168
|
+
};
|
|
169
|
+
const _newLine = () => '\n';
|
|
170
|
+
const newLine = () => {
|
|
171
|
+
recorder.line += 1;
|
|
172
|
+
return _newLine();
|
|
173
|
+
};
|
|
135
174
|
const colon = () => ';';
|
|
136
175
|
|
|
137
|
-
const
|
|
176
|
+
const _generateNode = (node, logicItemIndex) => {
|
|
138
177
|
if (!node)
|
|
139
178
|
return '';
|
|
140
179
|
if (node.type === 'End') {
|
|
@@ -179,7 +218,7 @@ export default function (source) {
|
|
|
179
218
|
return `${object}[${property.value}]`;
|
|
180
219
|
}
|
|
181
220
|
if (node.type === 'AssignmentExpression') {
|
|
182
|
-
return `${
|
|
221
|
+
return `${generateNode(node.left)} = ${generateNode(node.right)}${colon()}${newLine()}`;
|
|
183
222
|
}
|
|
184
223
|
if (node.type === 'CallExpression') {
|
|
185
224
|
const args = [];
|
|
@@ -228,23 +267,29 @@ export default function (source) {
|
|
|
228
267
|
const interfaceKeyTarget = Vertex.getVertexByRef(key);
|
|
229
268
|
const arr = key.split('/');
|
|
230
269
|
const download = interfaceKeyTarget && interfaceKeyTarget.name && interfaceKeyTarget.name.includes('export');
|
|
231
|
-
return `await this.$services['_custom']['ID_${arr[arr.length - 1]}']({
|
|
270
|
+
return `await (async () => { console.debug('logic-trace');let result = await this.$services['_custom']['ID_${arr[arr.length - 1]}']({
|
|
232
271
|
config: {
|
|
233
272
|
download: ${download},
|
|
234
273
|
},
|
|
235
274
|
path: {
|
|
236
|
-
${getParams('path').join('
|
|
275
|
+
${getParams('path').join(',')}
|
|
237
276
|
},
|
|
238
277
|
query: {
|
|
239
|
-
${getParams('query').join('
|
|
278
|
+
${getParams('query').join(',')}
|
|
240
279
|
},
|
|
241
280
|
headers: {
|
|
242
|
-
${getParams('header').join('
|
|
281
|
+
${getParams('header').join(',')}
|
|
243
282
|
},
|
|
244
283
|
body: ${getParams('body') || '{}'},
|
|
245
|
-
})
|
|
284
|
+
});
|
|
285
|
+
console.debug('logic-trace-end');
|
|
286
|
+
return result;
|
|
287
|
+
})();
|
|
288
|
+
`;
|
|
246
289
|
} else {
|
|
247
|
-
return `await this.${node.calleeCode}(${node.params.map((param) => generateNode(param.callInterParamValue) || 'undefined').join(',')})
|
|
290
|
+
return `await (async () => {console.debug('logic-trace');let result = await this.${node.calleeCode}(${node.params.map((param) => generateNode(param.callInterParamValue) || 'undefined').join(',')});
|
|
291
|
+
console.debug('logic-trace-end');return result; })()
|
|
292
|
+
`;
|
|
248
293
|
}
|
|
249
294
|
}
|
|
250
295
|
|
|
@@ -283,21 +328,24 @@ export default function (source) {
|
|
|
283
328
|
const interfaceKeyTarget = Vertex.getVertexByRef(node.interfaceKey);
|
|
284
329
|
const download = interfaceKeyTarget && interfaceKeyTarget.name && interfaceKeyTarget.name.includes('export');
|
|
285
330
|
|
|
286
|
-
return `await this.$services['_custom']['ID_${arr[arr.length - 1]}']({
|
|
331
|
+
return `await (async () => {console.debug('logic-trace');let result = await this.$services['_custom']['ID_${arr[arr.length - 1]}']({
|
|
287
332
|
config: {
|
|
288
333
|
download: ${download},
|
|
289
334
|
},
|
|
290
335
|
path: {
|
|
291
|
-
${getParams('path').join('
|
|
336
|
+
${getParams('path').join(',')}
|
|
292
337
|
},
|
|
293
338
|
query: {
|
|
294
|
-
${getParams('query').join('
|
|
339
|
+
${getParams('query').join(',')}
|
|
295
340
|
},
|
|
296
341
|
headers: {
|
|
297
|
-
${getParams('header').join('
|
|
342
|
+
${getParams('header').join(',')}
|
|
298
343
|
},
|
|
299
344
|
body: ${getParams('body') || '{}'},
|
|
300
|
-
})
|
|
345
|
+
});
|
|
346
|
+
console.debug('logic-trace-end');
|
|
347
|
+
return result; })()
|
|
348
|
+
`;
|
|
301
349
|
}
|
|
302
350
|
|
|
303
351
|
if (node.type === 'CallGraphQL') {
|
|
@@ -352,13 +400,13 @@ export default function (source) {
|
|
|
352
400
|
download: ${key.includes('export')},
|
|
353
401
|
},
|
|
354
402
|
path: {
|
|
355
|
-
${getParams('path').join('
|
|
403
|
+
${getParams('path').join(',')}
|
|
356
404
|
},
|
|
357
405
|
query: {
|
|
358
|
-
${getParams('query').join('
|
|
406
|
+
${getParams('query').join(',')}
|
|
359
407
|
},
|
|
360
408
|
headers: {
|
|
361
|
-
${getParams('header').join('
|
|
409
|
+
${getParams('header').join(',')}
|
|
362
410
|
},
|
|
363
411
|
body: ${getParams('body') || '{}'},
|
|
364
412
|
})).Data`;
|
|
@@ -369,7 +417,7 @@ export default function (source) {
|
|
|
369
417
|
.filter((param) => param.in === undefined) // 放在body内部的参数
|
|
370
418
|
.filter((param) => generateNode(param.value) !== '')
|
|
371
419
|
.map((param) => `${safeKey(param.name)}: ${generateNode(param.value)}`)
|
|
372
|
-
.join('
|
|
420
|
+
.join(',');
|
|
373
421
|
const getObj = (type) =>
|
|
374
422
|
(node.params || [])
|
|
375
423
|
.filter((param) => param.in === type)
|
|
@@ -452,11 +500,11 @@ export default function (source) {
|
|
|
452
500
|
}
|
|
453
501
|
|
|
454
502
|
if (node.type === 'CallMessageShow') {
|
|
455
|
-
return
|
|
503
|
+
return `this.$toast.show(${generateNode(node.arguments[0])})${colon()}${newLine()}`;
|
|
456
504
|
}
|
|
457
505
|
|
|
458
506
|
if (node.type === 'CallConsoleLog') {
|
|
459
|
-
return
|
|
507
|
+
return `console.log(${generateNode(node.arguments[0])})${colon()}${newLine()}`;
|
|
460
508
|
}
|
|
461
509
|
|
|
462
510
|
if (node.type === 'Destination') {
|
|
@@ -489,12 +537,11 @@ export default function (source) {
|
|
|
489
537
|
};
|
|
490
538
|
}
|
|
491
539
|
|
|
540
|
+
let resultScript = `if(${generateNode(node.test)}) ${generateNode(node.consequent)}`;
|
|
492
541
|
let alternateScript = '';
|
|
493
542
|
if (node.alternate) {
|
|
494
543
|
alternateScript = generateNode(node.alternate);
|
|
495
544
|
}
|
|
496
|
-
|
|
497
|
-
let resultScript = `if(${generateNode(node.test)}) ${generateNode(node.consequent)}`;
|
|
498
545
|
resultScript = alternateScript ? `${resultScript} else ${alternateScript}` : resultScript;
|
|
499
546
|
return resultScript;
|
|
500
547
|
}
|
|
@@ -503,51 +550,41 @@ export default function (source) {
|
|
|
503
550
|
if (!node.body) {
|
|
504
551
|
return '';
|
|
505
552
|
}
|
|
553
|
+
const str = `{${newLine()}`;
|
|
506
554
|
const body = (node.body || []).map((body) => `${generateNode(body)}${colon()}${newLine()}`);
|
|
507
|
-
return
|
|
508
|
-
${body.join(' ')}
|
|
509
|
-
}`;
|
|
555
|
+
return `${str}${body.join(' ')}${newLine()}}`;
|
|
510
556
|
}
|
|
511
557
|
|
|
512
558
|
if (node.type === 'WhileStatement') {
|
|
513
|
-
let bodyScript = ''
|
|
559
|
+
let bodyScript = `(['WhileStatement']);${newLine()}while(${generateNode(node.test)}) {${newLine()}`;
|
|
514
560
|
if (Array.isArray(node.body)) {
|
|
515
561
|
node.body.forEach((body) => {
|
|
516
562
|
bodyScript += `${generateNode(body)}${newLine()}`;
|
|
517
563
|
});
|
|
518
564
|
}
|
|
519
|
-
return `${newLine()}
|
|
520
|
-
${bodyScript}
|
|
521
|
-
}${newLine()}`;
|
|
565
|
+
return `${bodyScript}${newLine()}}${newLine()}`;
|
|
522
566
|
}
|
|
523
567
|
|
|
524
568
|
if (node.type === 'SwitchStatement') {
|
|
525
|
-
Object.assign(node, switchCase2If(node.cases));
|
|
526
|
-
return generateNode(
|
|
569
|
+
const nextNode = Object.assign({}, node, switchCase2If(node, node.cases));
|
|
570
|
+
return `(['SwitchStatement']);${newLine()}${generateNode(nextNode)}`;
|
|
527
571
|
}
|
|
528
572
|
|
|
529
573
|
if (node.type === 'ForEachStatement') {
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
node.body
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
const endScript = generateNode(node.end);
|
|
540
|
-
const eachScript = generateNode(node.each);
|
|
574
|
+
const generateBodyScript = () => {
|
|
575
|
+
let bodyScript = '';
|
|
576
|
+
if (Array.isArray(node.body)) {
|
|
577
|
+
node.body.forEach((body) => {
|
|
578
|
+
bodyScript += `${generateNode(body)}${newLine()}`;
|
|
579
|
+
});
|
|
580
|
+
}
|
|
581
|
+
return bodyScript;
|
|
582
|
+
};
|
|
541
583
|
|
|
542
584
|
if (node.label === 'async') { // 临时测试 async 的方式
|
|
543
|
-
return
|
|
544
|
-
${bodyScript}
|
|
545
|
-
})${newLine()}`;
|
|
585
|
+
return `(['ForEachStatement']);${newLine()}await Promise.all(${generateNode(node.each)}.slice(${generateNode(node.start)}, ${generateNode(node.end)}).map(async (${generateNode(node.item)}, ${generateNode(node.index)}) => {${newLine()}${generateBodyScript()}})${newLine()}`;
|
|
546
586
|
} else {
|
|
547
|
-
return
|
|
548
|
-
const ${itemScript} = ${eachScript}[${indexScript}];
|
|
549
|
-
${bodyScript}
|
|
550
|
-
}${newLine()}`;
|
|
587
|
+
return `(['ForEachStatement']);${newLine()}for (let ${generateNode(node.index)}=${generateNode(node.start)}; ${generateNode(node.index)} < ${generateNode(node.end)}; ${generateNode(node.index)}++){${newLine()}const ${generateNode(node.item)} = ${generateNode(node.each)}[${generateNode(node.index)}];${newLine()}${generateBodyScript()}}${newLine()}`;
|
|
551
588
|
}
|
|
552
589
|
}
|
|
553
590
|
|
|
@@ -564,12 +601,16 @@ export default function (source) {
|
|
|
564
601
|
}
|
|
565
602
|
|
|
566
603
|
if (node.type === 'JSBlock') {
|
|
567
|
-
return `${newLine()}{
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
604
|
+
// return `${newLine()}{
|
|
605
|
+
// const jsBlock_${logicItemIndex} = async () => {
|
|
606
|
+
// ${node.code}
|
|
607
|
+
// }
|
|
571
608
|
|
|
572
|
-
|
|
609
|
+
// await jsBlock_${logicItemIndex}();
|
|
610
|
+
// }${newLine()}`;
|
|
611
|
+
|
|
612
|
+
return `(['JSBlock_${logicItemIndex}']);${newLine()}{
|
|
613
|
+
${node.code}
|
|
573
614
|
}${newLine()}`;
|
|
574
615
|
}
|
|
575
616
|
|
|
@@ -592,45 +633,60 @@ export default function (source) {
|
|
|
592
633
|
return '';
|
|
593
634
|
};
|
|
594
635
|
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
636
|
+
// source map for debugger!!!
|
|
637
|
+
const generateNode = (node, logicItemIndex) => {
|
|
638
|
+
const startLine = recorder.line;
|
|
639
|
+
|
|
640
|
+
const str = _generateNode(node, logicItemIndex);
|
|
641
|
+
const length = String(str).split('\n').length - 1;
|
|
642
|
+
recorder.line = startLine + length;
|
|
643
|
+
// console.log(node.type, startLine);
|
|
644
|
+
// if (node.type === 'JSBlock') {
|
|
645
|
+
// startLine = recorder.line - 2;
|
|
646
|
+
// }
|
|
647
|
+
sourceMap[node.id] = {
|
|
648
|
+
node,
|
|
649
|
+
// jsBlockFrom: recorder.line - 2,
|
|
650
|
+
from: startLine,
|
|
651
|
+
to: recorder.line,
|
|
652
|
+
};
|
|
653
|
+
return str;
|
|
654
|
+
};
|
|
599
655
|
|
|
600
656
|
// console.info("JSON generate:", JSON.stringify(logic.body));
|
|
601
657
|
// console.log(generate({ type: 'Program', body: logic.body }).code);
|
|
602
|
-
|
|
603
|
-
|
|
658
|
+
sourceMap[logic.id] = {
|
|
659
|
+
node: logic,
|
|
660
|
+
isLogic: true,
|
|
661
|
+
from: startLineNumber,
|
|
662
|
+
};
|
|
663
|
+
// console.log(logic.name, startLineNumber);
|
|
664
|
+
let mstr = `methods['${logic.name}'] = async function (${logic.params.map((param) => param.name).join(', ')}) {
|
|
604
665
|
${logic.params.length ? logic.params.map((param) => `${param.name} = ${param.name} !== undefined ? ${param.name} : this.$genInitFromSchema(${JSON.stringify(param.schema)}, ${JSON.stringify(param.defaultValue)});`).join('\n') + '' : ''}
|
|
605
666
|
${logic.variables.length ? logic.variables.map((variable) => `let ${variable.name} = this.$genInitFromSchema(${JSON.stringify(variable.schema)}, ${JSON.stringify(variable.defaultValue)});`).join('\n') + '' : ''}
|
|
606
667
|
let ${returnObj.name} = this.$genInitFromSchema(${JSON.stringify(returnObj.schema)}, ${JSON.stringify(returnObj.defaultValue)});
|
|
607
|
-
|
|
608
|
-
}`;
|
|
609
|
-
});
|
|
668
|
+
`;
|
|
610
669
|
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
const oldData = oldDataFunc ? oldDataFunc.call(this) : {};
|
|
617
|
-
return Object.assign(oldData, {
|
|
618
|
-
${paramsData ? paramsData + ',' : ''}
|
|
619
|
-
${variablesData}
|
|
620
|
-
});
|
|
621
|
-
};
|
|
622
|
-
componentOptions.data = data;
|
|
623
|
-
const meta = componentOptions.meta = componentOptions.meta || {};
|
|
624
|
-
Object.assign(meta, {
|
|
625
|
-
title: ${JSON.stringify(definition.title)},
|
|
626
|
-
crumb: ${JSON.stringify(definition.crumb)},
|
|
627
|
-
first: ${JSON.stringify(definition.first)},
|
|
670
|
+
let script = '';
|
|
671
|
+
// vital
|
|
672
|
+
recorder.line += mstr.split('\n').length - 1;
|
|
673
|
+
logic.body.forEach((node, index) => {
|
|
674
|
+
script += `${generateNode(node, index)}${newLine()}`;
|
|
628
675
|
});
|
|
629
676
|
|
|
630
|
-
|
|
677
|
+
mstr += script;
|
|
678
|
+
mstr += `
|
|
679
|
+
}\n\n`;
|
|
680
|
+
// vital
|
|
681
|
+
startLineNumber += mstr.split('\n').length - 1;
|
|
682
|
+
sourceMap[logic.id].to = startLineNumber - 1;
|
|
683
|
+
return mstr;
|
|
684
|
+
});
|
|
631
685
|
|
|
632
|
-
|
|
633
|
-
`;
|
|
686
|
+
output += methods.join('');
|
|
634
687
|
|
|
635
|
-
return
|
|
688
|
+
return {
|
|
689
|
+
output,
|
|
690
|
+
sourceMap,
|
|
691
|
+
};
|
|
636
692
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import generate from '@babel/generator';
|
|
2
2
|
import * as babel from '@babel/core';
|
|
3
|
-
import {
|
|
4
|
-
import { Vertex, vertexesMap, utils } from '..';
|
|
5
|
-
import { getQuerySchemaMap } from './tools';
|
|
3
|
+
import { Vertex, utils } from '..';
|
|
6
4
|
|
|
7
5
|
function switchCase2If(cases) {
|
|
8
6
|
const cas = cases.shift();
|
|
@@ -81,9 +79,7 @@ export default function (source) {
|
|
|
81
79
|
} else if (node.type === 'MemberExpression') {
|
|
82
80
|
return checkThis(node.object);
|
|
83
81
|
} else if (node.type === 'CallExpression') {
|
|
84
|
-
(node.arguments || []).forEach((arg) =>
|
|
85
|
-
return checkThis(arg);
|
|
86
|
-
});
|
|
82
|
+
(node.arguments || []).forEach((arg) => checkThis(arg));
|
|
87
83
|
}
|
|
88
84
|
}
|
|
89
85
|
function safeGenerate(node) {
|
|
@@ -586,7 +582,7 @@ export default function (source) {
|
|
|
586
582
|
const jsBlock_${index} = async () => {
|
|
587
583
|
${node.code}
|
|
588
584
|
}
|
|
589
|
-
|
|
585
|
+
|
|
590
586
|
await jsBlock_${index}();
|
|
591
587
|
}`,
|
|
592
588
|
{
|
|
@@ -600,16 +596,9 @@ export default function (source) {
|
|
|
600
596
|
}
|
|
601
597
|
});
|
|
602
598
|
|
|
603
|
-
// console.info("JSON generate:", JSON.stringify(logic.body));
|
|
604
|
-
// console.log(generate({ type: 'Program', body: logic.body }).code);
|
|
605
|
-
|
|
606
599
|
return `methods['${logic.name}'] = async function (${logic.params.map((param) => param.name).join(', ')}) {
|
|
607
|
-
${logic.params.length ? logic.params.map((param) => {
|
|
608
|
-
|
|
609
|
-
}).join('\n') + '' : ''}
|
|
610
|
-
${logic.variables.length ? logic.variables.map((variable) => {
|
|
611
|
-
return `let ${variable.name} = this.$genInitFromSchema(${JSON.stringify(variable.schema)}, ${JSON.stringify(variable.defaultValue)});`;
|
|
612
|
-
}).join('\n') + '' : ''}
|
|
600
|
+
${logic.params.length ? logic.params.map((param) => `${param.name} = ${param.name} !== undefined ? ${param.name} : this.$genInitFromSchema(${JSON.stringify(param.schema)}, ${JSON.stringify(param.defaultValue)});`).join('\n') + '' : ''}
|
|
601
|
+
${logic.variables.length ? logic.variables.map((variable) => `let ${variable.name} = this.$genInitFromSchema(${JSON.stringify(variable.schema)}, ${JSON.stringify(variable.defaultValue)});`).join('\n') + '' : ''}
|
|
613
602
|
let ${returnObj.name} = this.$genInitFromSchema(${JSON.stringify(returnObj.schema)}, ${JSON.stringify(returnObj.defaultValue)});
|
|
614
603
|
${generate({ type: 'Program', body: logic.body }).code}
|
|
615
604
|
}`;
|
package/src/types/nuims/Nuims.ts
CHANGED
|
@@ -17,7 +17,7 @@ interface RoleItem extends Role {
|
|
|
17
17
|
toggling?: Boolean,
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
interface Permission{
|
|
20
|
+
interface Permission {
|
|
21
21
|
DomainName: string,
|
|
22
22
|
PermissionId: string,
|
|
23
23
|
PermissionValue: string,
|
|
@@ -79,7 +79,7 @@ export class Nuims {
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
async getInitRoles() {
|
|
82
|
+
async getInitRoles(auto: unknown) {
|
|
83
83
|
let isCreated = false;
|
|
84
84
|
let resource = await this.getResource();
|
|
85
85
|
if (!resource) {
|
|
@@ -99,9 +99,15 @@ export class Nuims {
|
|
|
99
99
|
await this.bindRolesAndPermissions(role, permission);
|
|
100
100
|
}
|
|
101
101
|
roleName2Permission.set(role.RoleName, permission);
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
if (auto) {
|
|
103
|
+
if ((ResourceValue === '/dashboard' || ((ResourceValue === '/index' || ResourceValue === '/user') && config.scope === 'h5')) && role.RoleName === 'DEV-AdminRole') {
|
|
104
|
+
await this.attachPermissionResourceAction();
|
|
105
|
+
}
|
|
106
|
+
} else {
|
|
107
|
+
// 创建 /dashboard 资源时自动关联 DEV-AdminRole 权限
|
|
108
|
+
if (isCreated && (ResourceValue === '/dashboard' || ((ResourceValue === '/index' || ResourceValue === '/user') && config.scope === 'h5')) && role.RoleName === 'DEV-AdminRole') {
|
|
109
|
+
await this.attachPermissionResourceAction();
|
|
110
|
+
}
|
|
105
111
|
}
|
|
106
112
|
roleItem.permission = permission;
|
|
107
113
|
const resources = await this.getResourcesFromPermission(permission);
|