@lcap/nasl 3.0.0-beta.5 → 3.0.0-beta.7
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/automate/engine/utils.js +1 -1
- package/out/automate/engine/utils.js.map +1 -1
- package/out/breakpoint/generator/BreakpointNode.js +30 -1
- package/out/breakpoint/generator/BreakpointNode.js.map +1 -1
- package/out/breakpoint/shared/utils.js +1 -1
- package/out/breakpoint/shared/utils.js.map +1 -1
- package/out/common/BaseNode.js +1 -1
- package/out/common/BaseNode.js.map +1 -1
- package/out/common/Command.js +1 -1
- package/out/common/Command.js.map +1 -1
- package/out/concepts/BatchAssignment__.js +3 -3
- package/out/concepts/BatchAssignment__.js.map +1 -1
- package/out/concepts/BindEvent__.js +3 -3
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/CallConnector__.d.ts +42 -0
- package/out/concepts/CallConnector__.js +198 -0
- package/out/concepts/CallConnector__.js.map +1 -0
- package/out/concepts/CallInterface__.js +2 -4
- package/out/concepts/CallInterface__.js.map +1 -1
- package/out/concepts/CallLogic__.js +1 -1
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.js +2 -2
- package/out/concepts/CallQueryComponent__.js.map +1 -1
- package/out/concepts/ConnectorTrigger__.d.ts +78 -0
- package/out/concepts/ConnectorTrigger__.js +155 -0
- package/out/concepts/ConnectorTrigger__.js.map +1 -0
- package/out/concepts/Connector__.d.ts +464 -0
- package/out/concepts/Connector__.js +698 -0
- package/out/concepts/Connector__.js.map +1 -0
- package/out/concepts/DataSource__.js +1 -1
- package/out/concepts/DataSource__.js.map +1 -1
- package/out/concepts/EntityProperty__.js +1 -1
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/MemberExpression__.js +1 -1
- package/out/concepts/MemberExpression__.js.map +1 -1
- package/out/concepts/MsgTriggerEvent__.d.ts +137 -0
- package/out/concepts/MsgTriggerEvent__.js +228 -0
- package/out/concepts/MsgTriggerEvent__.js.map +1 -0
- package/out/concepts/MsgTriggerLauncher__.d.ts +118 -0
- package/out/concepts/MsgTriggerLauncher__.js +204 -0
- package/out/concepts/MsgTriggerLauncher__.js.map +1 -0
- package/out/concepts/SelectMembers__.js +1 -1
- package/out/concepts/SelectMembers__.js.map +1 -1
- package/out/concepts/StringLiteral__.js +5 -1
- package/out/concepts/StringLiteral__.js.map +1 -1
- package/out/concepts/TriggerEvent__.d.ts +120 -0
- package/out/concepts/TriggerEvent__.js +222 -0
- package/out/concepts/TriggerEvent__.js.map +1 -0
- package/out/concepts/TriggerLauncher__.d.ts +88 -0
- package/out/concepts/TriggerLauncher__.js +235 -0
- package/out/concepts/TriggerLauncher__.js.map +1 -0
- package/out/concepts/TypeAnnotation__.js +1 -1
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/ViewElement__.js +1 -1
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/types__.d.ts +124 -0
- package/out/concepts/types__.js +3 -0
- package/out/concepts/types__.js.map +1 -0
- package/out/sentry/index.d.ts +8 -4
- package/out/sentry/index.js +84 -54
- package/out/sentry/index.js.map +1 -1
- package/out/server/entity2LogicNamespace.js +1 -1
- package/out/server/entity2LogicNamespace.js.map +1 -1
- package/out/server/extendBaseNode.js +9 -1
- package/out/server/extendBaseNode.js.map +1 -1
- package/out/server/formatTsUtils.js +2 -2
- package/out/server/formatTsUtils.js.map +1 -1
- package/out/server/getConnector.d.ts +11 -0
- package/out/server/getConnector.js +42 -0
- package/out/server/getConnector.js.map +1 -0
- package/out/server/getInterfaces.js +1 -1
- package/out/server/getInterfaces.js.map +1 -1
- package/out/server/getLogics.js +2 -2
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getMemberIdentifier.js +2 -2
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/getScope.js +3 -3
- package/out/server/getScope.js.map +1 -1
- package/out/server/naslServer.d.ts +2 -2
- package/out/server/naslServer.js +19 -7
- package/out/server/naslServer.js.map +1 -1
- package/out/server/translator.js +3 -3
- package/out/server/translator.js.map +1 -1
- package/out/service/storage/init.js +1 -1
- package/out/service/storage/init.js.map +1 -1
- package/out/utils/string.js +1 -1
- package/out/utils/string.js.map +1 -1
- package/package.json +1 -1
- package/src/automate/engine/utils.js +1 -1
- package/src/breakpoint/generator/BreakpointNode.ts +40 -1
- package/src/breakpoint/shared/utils.ts +1 -1
- package/src/common/BaseNode.ts +1 -1
- package/src/common/Command.ts +1 -1
- package/src/common/dist/Command.js +39 -0
- package/src/concepts/BatchAssignment__.ts +3 -3
- package/src/concepts/BindEvent__.ts +3 -3
- package/src/concepts/CallInterface__.ts +2 -3
- package/src/concepts/CallLogic__.ts +1 -1
- package/src/concepts/CallQueryComponent__.ts +2 -2
- package/src/concepts/DataSource__.ts +2 -2
- package/src/concepts/EntityProperty__.ts +1 -7
- package/src/concepts/MemberExpression__.ts +1 -1
- package/src/concepts/SelectMembers__.ts +1 -1
- package/src/concepts/StringLiteral__.ts +5 -1
- package/src/concepts/TypeAnnotation__.ts +17 -17
- package/src/concepts/ViewElement__.ts +1 -1
- package/src/concepts/dist/Entity__.js +729 -0
- package/src/concepts/dist/StringLiteral__.js +158 -0
- package/src/sentry/index.ts +99 -57
- package/src/server/dist/naslServer.js +52 -1
- package/src/server/entity2LogicNamespace.ts +1 -1
- package/src/server/extendBaseNode.ts +10 -1
- package/src/server/formatTsUtils.ts +2 -2
- package/src/server/getInterfaces.ts +1 -1
- package/src/server/getLogics.ts +2 -2
- package/src/server/getMemberIdentifier.ts +2 -2
- package/src/server/getScope.ts +3 -3
- package/src/server/naslServer.ts +12 -7
- package/src/server/translator.ts +3 -3
- package/src/service/storage/init.ts +1 -1
- package/src/utils/string.ts +1 -1
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
extendStatics(d, b);
|
|
11
|
+
function __() { this.constructor = d; }
|
|
12
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
var __assign = (this && this.__assign) || function () {
|
|
16
|
+
__assign = Object.assign || function(t) {
|
|
17
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
18
|
+
s = arguments[i];
|
|
19
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
20
|
+
t[p] = s[p];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
24
|
+
return __assign.apply(this, arguments);
|
|
25
|
+
};
|
|
26
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
27
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
28
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
29
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
30
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
31
|
+
};
|
|
32
|
+
exports.__esModule = true;
|
|
33
|
+
exports.StringLiteral = void 0;
|
|
34
|
+
var translator_1 = require("../translator");
|
|
35
|
+
var decorators_1 = require("../decorators");
|
|
36
|
+
var classMap_1 = require("../common/classMap");
|
|
37
|
+
var LogicItem__1 = require("./LogicItem__");
|
|
38
|
+
/**
|
|
39
|
+
* 字符串字面量
|
|
40
|
+
*/
|
|
41
|
+
var StringLiteral = /** @class */ (function (_super) {
|
|
42
|
+
__extends(StringLiteral, _super);
|
|
43
|
+
/**
|
|
44
|
+
* @param source 需要合并的部分参数
|
|
45
|
+
*/
|
|
46
|
+
function StringLiteral(source) {
|
|
47
|
+
var _this = this;
|
|
48
|
+
source = Object.assign({}, StringLiteral_1.getDefaultOptions(), source);
|
|
49
|
+
_this = _super.call(this, source) || this;
|
|
50
|
+
/**
|
|
51
|
+
* 产品概念
|
|
52
|
+
*/
|
|
53
|
+
_this.concept = 'StringLiteral';
|
|
54
|
+
/**
|
|
55
|
+
* 字面量的值
|
|
56
|
+
*/
|
|
57
|
+
_this.value = '';
|
|
58
|
+
_super.prototype.subConstructor.call(_this, source);
|
|
59
|
+
return _this;
|
|
60
|
+
}
|
|
61
|
+
StringLiteral_1 = StringLiteral;
|
|
62
|
+
StringLiteral.prototype.getClassName = function () {
|
|
63
|
+
return 'StringLiteral';
|
|
64
|
+
};
|
|
65
|
+
StringLiteral.from = function (source, parentNode, parentKey) {
|
|
66
|
+
return _super.from.call(this, source, parentNode, parentKey);
|
|
67
|
+
};
|
|
68
|
+
//================================================================================
|
|
69
|
+
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
70
|
+
// 自动生成的代码已结束。下面可以手动编写。
|
|
71
|
+
//================================================================================
|
|
72
|
+
StringLiteral.prototype.toVue = function (options) {
|
|
73
|
+
var code = '';
|
|
74
|
+
if (typeof this.value === 'string') {
|
|
75
|
+
code = "`" + this.value + "`";
|
|
76
|
+
if ((options === null || options === void 0 ? void 0 : options.finalCode) !== false) {
|
|
77
|
+
code = "`" + this.value.replace(/['"`\\]/g, function (m) {
|
|
78
|
+
var escape = '\\\\';
|
|
79
|
+
escape = '\\\\';
|
|
80
|
+
/// #if process.env.BUILD_TARGET === 'node'
|
|
81
|
+
escape = '\\';
|
|
82
|
+
/// #endif
|
|
83
|
+
if (m === '\\') {
|
|
84
|
+
return "" + escape + escape;
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
return "" + escape + m;
|
|
88
|
+
}
|
|
89
|
+
}) + "`";
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return code;
|
|
93
|
+
};
|
|
94
|
+
StringLiteral.prototype.toUI = function () {
|
|
95
|
+
var code = '';
|
|
96
|
+
if (typeof this.value === 'string') {
|
|
97
|
+
code = "`" + this.value + "`";
|
|
98
|
+
}
|
|
99
|
+
return code;
|
|
100
|
+
};
|
|
101
|
+
StringLiteral.prototype.toJS = function () {
|
|
102
|
+
var code = "";
|
|
103
|
+
if (typeof this.value === 'string') {
|
|
104
|
+
code += "`" + this.value.replace(/['"`\\]/g, function (m) { return "\\" + m; }) + "`";
|
|
105
|
+
}
|
|
106
|
+
return code;
|
|
107
|
+
};
|
|
108
|
+
StringLiteral.prototype.toBrief = function () {
|
|
109
|
+
return "`" + this.value + "`";
|
|
110
|
+
};
|
|
111
|
+
StringLiteral.prototype.toEmbeddedTS = function (state, isRequired) {
|
|
112
|
+
var code = '';
|
|
113
|
+
if (typeof this.value === 'string') {
|
|
114
|
+
code += "new nasl.core.String('StringLiteral')";
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
code += isRequired ? '__IDENTIFIER__' : "''";
|
|
118
|
+
}
|
|
119
|
+
return code;
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* 设置字符串内容
|
|
123
|
+
*/
|
|
124
|
+
StringLiteral.prototype.setValue = function (value) {
|
|
125
|
+
var object = {
|
|
126
|
+
value: value
|
|
127
|
+
};
|
|
128
|
+
this.update(__assign({}, object));
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* 获取添加时的默认选项
|
|
132
|
+
* @returns
|
|
133
|
+
*/
|
|
134
|
+
StringLiteral.getDefaultOptions = function () {
|
|
135
|
+
return { value: '' };
|
|
136
|
+
};
|
|
137
|
+
var StringLiteral_1;
|
|
138
|
+
__decorate([
|
|
139
|
+
decorators_1.property()
|
|
140
|
+
], StringLiteral.prototype, "concept");
|
|
141
|
+
__decorate([
|
|
142
|
+
decorators_1.property()
|
|
143
|
+
], StringLiteral.prototype, "value");
|
|
144
|
+
__decorate([
|
|
145
|
+
translator_1.withSourceMap()
|
|
146
|
+
], StringLiteral.prototype, "toEmbeddedTS");
|
|
147
|
+
StringLiteral = StringLiteral_1 = __decorate([
|
|
148
|
+
decorators_1.concept('字符串字面量')
|
|
149
|
+
], StringLiteral);
|
|
150
|
+
return StringLiteral;
|
|
151
|
+
}(LogicItem__1["default"]));
|
|
152
|
+
exports.StringLiteral = StringLiteral;
|
|
153
|
+
classMap_1["default"].StringLiteral = StringLiteral;
|
|
154
|
+
exports["default"] = StringLiteral;
|
|
155
|
+
//================================================================================
|
|
156
|
+
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
157
|
+
// 自动生成的代码已结束。下面可以手动编写。
|
|
158
|
+
//================================================================================
|
package/src/sentry/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ export const BEFORE_HOOK = 'before';
|
|
|
5
5
|
export const AFTER_HOOK = 'after';
|
|
6
6
|
|
|
7
7
|
export const NASL_NODE = 'nasl-node';
|
|
8
|
+
export const NASL_SERVER = 'nasl-server';
|
|
8
9
|
export const TS_WORKER_MESSAGER = 'ts-worker-messager';
|
|
9
10
|
|
|
10
11
|
export const getAxios = () => axios;
|
|
@@ -19,18 +20,32 @@ type Source = {
|
|
|
19
20
|
result?: any;
|
|
20
21
|
};
|
|
21
22
|
|
|
22
|
-
type Listener = (source: Source) => void;
|
|
23
|
+
type Listener = (source: Source) => Function | void;
|
|
23
24
|
|
|
24
25
|
type Monitor = (key: string) => <T extends ClassType>(SourceClass: T) => T;
|
|
25
26
|
|
|
26
|
-
const
|
|
27
|
+
const flag = '__monitor__';
|
|
28
|
+
const passthroughProperties = ['constructor', 'getClassName', 'getAncestor'];
|
|
27
29
|
|
|
28
|
-
const
|
|
30
|
+
const classStore: { [key:string]: ClassType } = {};
|
|
29
31
|
const listenersStore: { [key:string]: Listener[] } = {};
|
|
30
32
|
|
|
31
33
|
const isPromise = (obj: any) => obj && typeof obj.then === 'function';
|
|
34
|
+
const isUsefulProperty = (SourceClass: ClassType) => (property: string) => {
|
|
35
|
+
if (!SourceClass || !property) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (passthroughProperties.includes(property)) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (typeof SourceClass.prototype[property] !== 'function') {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
32
46
|
|
|
33
|
-
|
|
47
|
+
return !SourceClass.prototype[property][flag];
|
|
48
|
+
};
|
|
34
49
|
|
|
35
50
|
export const removeListener = (key: string) => (listener: Listener) => {
|
|
36
51
|
listenersStore[key] = listenersStore[key] || [];
|
|
@@ -49,15 +64,66 @@ export const addListener = (key: string) => (listener: Listener, capture = false
|
|
|
49
64
|
return () => removeListener(key)(listener);
|
|
50
65
|
};
|
|
51
66
|
|
|
52
|
-
const fireListeners = (key: string) => (source: Source) => {
|
|
53
|
-
|
|
54
|
-
|
|
67
|
+
const fireListeners = (key: string) => (source: Source): Function => {
|
|
68
|
+
const { [key]: listeners = [] } = listenersStore;
|
|
69
|
+
const effects = listeners.map((listener) => listener(source));
|
|
70
|
+
|
|
71
|
+
return () => effects.forEach((effect) => effect && effect());
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const monitor = (key: string, SourceClass: ClassType, TargetClass: ClassType) => (name: string) => {
|
|
75
|
+
if (!TargetClass || !SourceClass) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (!key || !name) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const { [name]: callback } = SourceClass.prototype;
|
|
84
|
+
|
|
85
|
+
TargetClass.prototype[name] = function (...params: any[]) {
|
|
86
|
+
const effect = fireListeners(key)({
|
|
87
|
+
hook: BEFORE_HOOK,
|
|
88
|
+
instance: this,
|
|
89
|
+
name,
|
|
90
|
+
params,
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
const result = callback.apply(this, params);
|
|
94
|
+
|
|
95
|
+
if (isPromise(result)) {
|
|
96
|
+
return result.then((data: any) => {
|
|
97
|
+
fireListeners(key)({
|
|
98
|
+
hook: AFTER_HOOK,
|
|
99
|
+
instance: this,
|
|
100
|
+
result: data,
|
|
101
|
+
params,
|
|
102
|
+
name,
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
effect && effect();
|
|
106
|
+
return data;
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
fireListeners(key)({
|
|
111
|
+
hook: AFTER_HOOK,
|
|
112
|
+
instance: this,
|
|
113
|
+
name,
|
|
114
|
+
params,
|
|
115
|
+
result,
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
effect && effect();
|
|
119
|
+
return result;
|
|
120
|
+
};
|
|
55
121
|
|
|
56
|
-
|
|
122
|
+
TargetClass.prototype[name][flag] = true;
|
|
57
123
|
};
|
|
58
124
|
|
|
59
125
|
export const sentryMonitor: Monitor = (key) => (SourceClass) => {
|
|
60
|
-
if (!key) {
|
|
126
|
+
if (!key || !SourceClass) {
|
|
61
127
|
return SourceClass;
|
|
62
128
|
}
|
|
63
129
|
|
|
@@ -76,65 +142,41 @@ export const sentryMonitor: Monitor = (key) => (SourceClass) => {
|
|
|
76
142
|
}
|
|
77
143
|
|
|
78
144
|
const properties = Object.getOwnPropertyNames(SourceClass.prototype);
|
|
79
|
-
const names = properties.filter((
|
|
80
|
-
if (passthroughProperties.includes(property)) {
|
|
81
|
-
return false;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return typeof SourceClass.prototype[property] === 'function';
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
names.forEach((name) => {
|
|
88
|
-
const { [name]: callback } = SourceClass.prototype;
|
|
145
|
+
const names = properties.filter(isUsefulProperty(SourceClass));
|
|
89
146
|
|
|
90
|
-
|
|
91
|
-
|
|
147
|
+
classStore[key] = SourceClass;
|
|
148
|
+
names.forEach(monitor(key, SourceClass, TargetClass));
|
|
92
149
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
instance: this,
|
|
96
|
-
name,
|
|
97
|
-
params,
|
|
98
|
-
});
|
|
150
|
+
return TargetClass;
|
|
151
|
+
};
|
|
99
152
|
|
|
100
|
-
|
|
153
|
+
export const extendSentryMonitor: Monitor = (key) => (SourceClass) => {
|
|
154
|
+
if (!key || !SourceClass) {
|
|
155
|
+
return SourceClass;
|
|
156
|
+
}
|
|
101
157
|
|
|
102
|
-
|
|
103
|
-
return result.then((data: any) => {
|
|
104
|
-
fireListeners(key)({
|
|
105
|
-
hook: AFTER_HOOK,
|
|
106
|
-
instance: this,
|
|
107
|
-
result: data,
|
|
108
|
-
params,
|
|
109
|
-
name,
|
|
110
|
-
});
|
|
158
|
+
const { [key]: TargetClass } = classStore;
|
|
111
159
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
160
|
+
if (!TargetClass) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
116
163
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
instance: this,
|
|
120
|
-
name,
|
|
121
|
-
params,
|
|
122
|
-
result,
|
|
123
|
-
});
|
|
164
|
+
const properties = Object.getOwnPropertyNames(SourceClass.prototype);
|
|
165
|
+
const names = properties.filter(isUsefulProperty(SourceClass));
|
|
124
166
|
|
|
125
|
-
|
|
126
|
-
return result;
|
|
127
|
-
};
|
|
128
|
-
});
|
|
167
|
+
names.forEach(monitor(key, SourceClass, TargetClass));
|
|
129
168
|
|
|
130
|
-
return TargetClass;
|
|
169
|
+
return TargetClass as typeof SourceClass;
|
|
131
170
|
};
|
|
132
171
|
|
|
133
|
-
export const getPreviousFromNaslNode = () => getPrevious(NASL_NODE);
|
|
134
|
-
export const getPreviousFromTSWorkerMessager = () => getPrevious(TS_WORKER_MESSAGER);
|
|
135
|
-
|
|
136
172
|
export const addListenerToNaslNode = addListener(NASL_NODE);
|
|
173
|
+
export const addListenerToNaslServer = addListener(NASL_SERVER);
|
|
137
174
|
export const addListenerToTSWorkerMessager = addListener(TS_WORKER_MESSAGER);
|
|
138
175
|
|
|
139
176
|
export const sentryMonitorNaslNode = sentryMonitor(NASL_NODE);
|
|
140
|
-
export const
|
|
177
|
+
export const sentryMonitorNaslServer = sentryMonitor(NASL_SERVER);
|
|
178
|
+
export const sentryMonitorTSWorkerMessager = sentryMonitor(TS_WORKER_MESSAGER);
|
|
179
|
+
|
|
180
|
+
export const extendSentryMonitorNaslNode = extendSentryMonitor(NASL_NODE);
|
|
181
|
+
export const extendSentryMonitorNaslServer = extendSentryMonitor(NASL_SERVER);
|
|
182
|
+
export const extendSentryMonitorTSWorkerMessager = extendSentryMonitor(TS_WORKER_MESSAGER);
|
|
@@ -985,7 +985,10 @@ var NaslServer = /** @class */ (function () {
|
|
|
985
985
|
switch (_a.label) {
|
|
986
986
|
case 0:
|
|
987
987
|
// 开始诊断和标注
|
|
988
|
-
|
|
988
|
+
try {
|
|
989
|
+
common_1.invokeCommand('naslServer:startWork');
|
|
990
|
+
}
|
|
991
|
+
catch (err) { }
|
|
989
992
|
return [4 /*yield*/, this.getDiagnosticRecords(fileNames)];
|
|
990
993
|
case 1:
|
|
991
994
|
records = _a.sent();
|
|
@@ -2561,6 +2564,52 @@ var NaslServer = /** @class */ (function () {
|
|
|
2561
2564
|
if (node instanceof concepts_1.Entity) {
|
|
2562
2565
|
// 过滤一把不需要改的信息
|
|
2563
2566
|
refsList = refsList.filter(function (item) { return fileNode.getEmbeddedFilePath() !== item.file || item.isDefinition === true; });
|
|
2567
|
+
// 防止死循环
|
|
2568
|
+
// const forRefsList = [...refsList];
|
|
2569
|
+
// for (let i = 0; i < forRefsList.length; i++) {
|
|
2570
|
+
// const refItem = forRefsList[i];
|
|
2571
|
+
// if (refItem.lineText?.includes('new nasl.langUtil.Collection')) {
|
|
2572
|
+
// try {
|
|
2573
|
+
// const fileNode = this.file2NodeMap.get(refItem.file);
|
|
2574
|
+
// if (!fileNode)
|
|
2575
|
+
// return;
|
|
2576
|
+
// const minRange = this._findMinRange(refItem, fileNode as FileNode);
|
|
2577
|
+
// if (minRange.node && (minRange.node instanceof QueryFromExpression || minRange.node instanceof QueryJoinExpression)) {
|
|
2578
|
+
// const callQueryComponent = minRange.node.getAncestor('CallQueryComponent') as CallQueryComponent;
|
|
2579
|
+
// const callQueryComponentTypeAnnotation = callQueryComponent.typeAnnotation;
|
|
2580
|
+
// const { currentSource: qcTypeAnnotationCurrentSource, fileNode } = callQueryComponentTypeAnnotation.getCurrentSource();
|
|
2581
|
+
// const { currentSource: logicCurrentSource } = fileNode.getCurrentSource();
|
|
2582
|
+
// const aggregateLength = callQueryComponent.select.selectAggregateElements.filter((item: any) => item.aggregateName && item.asName).length;
|
|
2583
|
+
// const groupByLength = callQueryComponent.groupBy.filter((item) => (item.groupElement as QueryFieldExpression)?.propertyName && (item.groupElement as QueryFieldExpression).asName).length;
|
|
2584
|
+
// if (!groupByLength && !aggregateLength && callQueryComponentTypeAnnotation.typeKind === 'anonymousStructure') {
|
|
2585
|
+
// // 拿到 List 的泛型(匿名数据结构)的所有属性
|
|
2586
|
+
// const properties = callQueryComponentTypeAnnotation.properties[0].typeAnnotation.typeArguments[0].properties;
|
|
2587
|
+
// const targetProperty = properties.find((p) => p.name === utils.firstLowerCase(node.name));
|
|
2588
|
+
// if (!targetProperty) {
|
|
2589
|
+
// continue;
|
|
2590
|
+
// }
|
|
2591
|
+
// const { currentSource: propertyTypeCurrentSource } = targetProperty.typeAnnotation.getCurrentSource();
|
|
2592
|
+
// // 减去 ": " 2个字符、减去属性名长度
|
|
2593
|
+
// const propertyCharacter = propertyTypeCurrentSource.range.start.character - 2 - targetProperty.name.length;
|
|
2594
|
+
// const propertyOffset = propertyCharacter - qcTypeAnnotationCurrentSource.range.start.character;
|
|
2595
|
+
// const qcTypeAnnotationOffset = logicCurrentSource.code.indexOf(qcTypeAnnotationCurrentSource.code);
|
|
2596
|
+
// const declarationCodeArr = logicCurrentSource.code.slice(0, qcTypeAnnotationOffset).split('\n');
|
|
2597
|
+
// const line = declarationCodeArr.length - 1;
|
|
2598
|
+
// const character = declarationCodeArr[declarationCodeArr.length - 1].length;
|
|
2599
|
+
// // eslint-disable-next-line no-await-in-loop
|
|
2600
|
+
// const newRefs = await this.references({
|
|
2601
|
+
// file: (fileNode as any).getEmbeddedFilePath(),
|
|
2602
|
+
// line: line + 2,
|
|
2603
|
+
// offset: character + 1 + propertyOffset,
|
|
2604
|
+
// });
|
|
2605
|
+
// refsList.push(...newRefs.refs);
|
|
2606
|
+
// }
|
|
2607
|
+
// }
|
|
2608
|
+
// } catch (e) {
|
|
2609
|
+
// console.error('naslServer实体引用', e);
|
|
2610
|
+
// }
|
|
2611
|
+
// }
|
|
2612
|
+
// }
|
|
2564
2613
|
// 不再当前文件里
|
|
2565
2614
|
// 或者在当前列表但是位置小于entity的结束位置
|
|
2566
2615
|
}
|
|
@@ -2920,6 +2969,8 @@ var NaslServer = /** @class */ (function () {
|
|
|
2920
2969
|
var newTextValue = node.parentNode.name === 'defaultDS' ? "/api/" + newName + "/import" : "/api/" + node.parentNode.name + "/" + newName + "/import";
|
|
2921
2970
|
minRange.setTypeMethods = 'setUrlValue';
|
|
2922
2971
|
minRange.newValue = newTextValue;
|
|
2972
|
+
// } else if (minRange.node instanceof Identifier) {
|
|
2973
|
+
// minRange.newValue = utils.firstLowerCase(newValue);
|
|
2923
2974
|
}
|
|
2924
2975
|
}
|
|
2925
2976
|
// 如果是修改实体属性,要同步实体属性
|
|
@@ -23,7 +23,7 @@ export function entity2LogicNamespace(entity: Entity) {
|
|
|
23
23
|
new Param({
|
|
24
24
|
name: 'body',
|
|
25
25
|
typeAnnotation: TypeAnnotation.createGeneric('List', {
|
|
26
|
-
typeArguments: [TypeAnnotation.createPrimitive(keys[0]
|
|
26
|
+
typeArguments: [TypeAnnotation.createPrimitive(keys?.[0]?.typeAnnotation.typeName)],
|
|
27
27
|
}),
|
|
28
28
|
required: true,
|
|
29
29
|
}),
|
|
@@ -5,6 +5,8 @@ import { BaseNode, CallLogic, Destination, EnumItem, Interface, Logic, Param, Pr
|
|
|
5
5
|
import { EventPayload, invokeCommand, registerCommand } from '../common';
|
|
6
6
|
import { getNodeByNodeCallee, getNaslNodeByNodeCallee } from '../automate/engine/utils';
|
|
7
7
|
|
|
8
|
+
import { extendSentryMonitorNaslNode } from '../sentry';
|
|
9
|
+
|
|
8
10
|
interface SetNameNode extends BaseNode {
|
|
9
11
|
setName(name: string): any;
|
|
10
12
|
[propname: string]: any;
|
|
@@ -119,7 +121,12 @@ BaseNode.prototype.changeName = async function changeName(newValue: string, upda
|
|
|
119
121
|
const itemNode = item.node as SetNameNode;
|
|
120
122
|
if (item.newValue) {
|
|
121
123
|
// 如果有指定的修改方法,就用那个,没有就修改名字
|
|
122
|
-
|
|
124
|
+
if (item.setTypeMethods) {
|
|
125
|
+
const func = itemNode && itemNode[item.setTypeMethods];
|
|
126
|
+
typeof func === 'function' && itemNode[item.setTypeMethods](item.newValue);
|
|
127
|
+
} else {
|
|
128
|
+
itemNode.setName?.(item.newValue);
|
|
129
|
+
}
|
|
123
130
|
} else {
|
|
124
131
|
if (_this.concept === 'AuthLogicForCallInterface' && itemNode.concept === 'CallAuthInterface') {
|
|
125
132
|
const { calleewholeKey } = itemNode;
|
|
@@ -471,3 +478,5 @@ BaseNode.prototype.getSelectRef = function getSelectRef(newTypeAnnotation: TypeA
|
|
|
471
478
|
console.log(err);
|
|
472
479
|
}
|
|
473
480
|
};
|
|
481
|
+
|
|
482
|
+
extendSentryMonitorNaslNode(BaseNode);
|
|
@@ -753,7 +753,7 @@ export function formatBackendVariables(variables: Array<BackendVariable>) {
|
|
|
753
753
|
namespace,
|
|
754
754
|
}),
|
|
755
755
|
};
|
|
756
|
-
const noChildType = isNoChildType(itemNode.typeAnnotation
|
|
756
|
+
const noChildType = isNoChildType(itemNode.typeAnnotation?.typeKey);
|
|
757
757
|
|
|
758
758
|
if (!noChildType) {
|
|
759
759
|
nextFindTypeChild(itemNode.typeAnnotation.typeKey, newItem, itemNode);
|
|
@@ -775,7 +775,7 @@ export function formatFrontEndVariables(frontEndVariables: Array<Variable>) {
|
|
|
775
775
|
namespace,
|
|
776
776
|
}),
|
|
777
777
|
};
|
|
778
|
-
const noChildType = isNoChildType(itemNode.typeAnnotation
|
|
778
|
+
const noChildType = isNoChildType(itemNode.typeAnnotation?.typeKey);
|
|
779
779
|
|
|
780
780
|
if (!noChildType) {
|
|
781
781
|
nextFindTypeChild(itemNode.typeAnnotation.typeKey, newItem, itemNode);
|
|
@@ -33,7 +33,7 @@ function iterator(tree: Namespace, searchContent: string, fakeNode: FakeNode) {
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
export function getInterfaces(node: CallInterface | BindEvent, filterText?: string) {
|
|
36
|
-
const app = node
|
|
36
|
+
const app = node?.rootNode as App;
|
|
37
37
|
const _moduleList = app.interfaceDependencies.filter((item) => item.type === 'interface');
|
|
38
38
|
const fakeNode = {};
|
|
39
39
|
const interfaces = _moduleList.map((item) => new Namespace({ name: item.name, interfaces: item.interfaces }));
|
package/src/server/getLogics.ts
CHANGED
|
@@ -79,7 +79,7 @@ function javaLogicDataSourceLogics(logics: Logic[]) {
|
|
|
79
79
|
|
|
80
80
|
export async function getLogics(node: CallLogic | BindEvent | Identifier | Logic, needAllLogic: boolean = true) {
|
|
81
81
|
const app = node?.rootNode as App;
|
|
82
|
-
if (node
|
|
82
|
+
if (node?.concept === 'CallLogic' || node?.concept === 'BindEvent' || node?.concept === 'Logic') {
|
|
83
83
|
const result = [];
|
|
84
84
|
|
|
85
85
|
if (needAllLogic) {
|
|
@@ -314,7 +314,7 @@ export async function getLogics(node: CallLogic | BindEvent | Identifier | Logic
|
|
|
314
314
|
result.push(systemTree);
|
|
315
315
|
}
|
|
316
316
|
return result;
|
|
317
|
-
} else if (node
|
|
317
|
+
} else if (node?.concept === 'Identifier') {
|
|
318
318
|
const extensions = app.dependencies.map((dep) => moduleToLogicNamesapce(dep, app.overriddenLogics)).filter((item) => item.logics && item.logics.length);
|
|
319
319
|
const tree = new Namespace({
|
|
320
320
|
name: 'category`',
|
|
@@ -249,7 +249,7 @@ export function getEnumsIdentifier(node: BaseNode): CompletionProperty[] {
|
|
|
249
249
|
// 获取后端全局变量
|
|
250
250
|
export function getBackendVariablesIdentifier(node: BaseNode): CompletionProperty[] {
|
|
251
251
|
const app = node.rootNode as App;
|
|
252
|
-
const variables = app?.backend
|
|
252
|
+
const variables = app?.backend?.variables;
|
|
253
253
|
const newvariables = variables ? formatBackendVariables(variables) : [];
|
|
254
254
|
|
|
255
255
|
return newvariables;
|
|
@@ -298,7 +298,7 @@ export async function getSelectNextCompletionData(node: Identifier, completionPr
|
|
|
298
298
|
|
|
299
299
|
const app = node.getAncestor('App');
|
|
300
300
|
const naslServer = (app as any).naslServer;
|
|
301
|
-
const nextCompletion = await naslServer.getFieldKeySelectCompletion(node, fieldKey);
|
|
301
|
+
const nextCompletion = naslServer && await naslServer.getFieldKeySelectCompletion(node, fieldKey);
|
|
302
302
|
const completionData = formatVariableData(nextCompletion, node, completionProperty);
|
|
303
303
|
return completionData;
|
|
304
304
|
}
|
package/src/server/getScope.ts
CHANGED
|
@@ -10,9 +10,9 @@ type wordScope = {
|
|
|
10
10
|
|
|
11
11
|
export function getLogicScopeWords(logic: Logic): wordScope {
|
|
12
12
|
const scope: wordScope = {
|
|
13
|
-
Param: logic.params.map((p) => p.name),
|
|
14
|
-
Return: logic.returns.map((p) => p.name),
|
|
15
|
-
Variable: logic.variables.map((p) => p.name),
|
|
13
|
+
Param: logic ? logic.params.map((p) => p.name) : [],
|
|
14
|
+
Return: logic ? logic.returns.map((p) => p.name) : [],
|
|
15
|
+
Variable: logic ? logic.variables.map((p) => p.name) : [],
|
|
16
16
|
Constant: [],
|
|
17
17
|
Logic: []
|
|
18
18
|
};
|
package/src/server/naslServer.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { Worker } from 'worker_threads';
|
|
|
5
5
|
/// #endif
|
|
6
6
|
|
|
7
7
|
import { config } from '../config';
|
|
8
|
-
import { sentryMonitorTSWorkerMessager } from '../sentry';
|
|
8
|
+
import { sentryMonitorNaslServer, sentryMonitorTSWorkerMessager } from '../sentry';
|
|
9
9
|
import Messager from '../common/Messager';
|
|
10
10
|
import * as tsProtocol from 'typescript/lib/protocol';
|
|
11
11
|
import { formatEnums } from '../server/getMemberIdentifier';
|
|
@@ -179,7 +179,8 @@ export function getDisplayString2Type(displayString: string) {
|
|
|
179
179
|
return typeList;
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
-
|
|
182
|
+
@sentryMonitorNaslServer
|
|
183
|
+
class NaslServer {
|
|
183
184
|
messager: Messager = undefined;
|
|
184
185
|
|
|
185
186
|
worker: Worker = undefined;
|
|
@@ -944,7 +945,9 @@ export class NaslServer {
|
|
|
944
945
|
|
|
945
946
|
async getDiagnosticRecordsAndPushAll(fileNames?: Array<string>) {
|
|
946
947
|
// 开始诊断和标注
|
|
947
|
-
|
|
948
|
+
try {
|
|
949
|
+
invokeCommand('naslServer:startWork');
|
|
950
|
+
} catch (err) { }
|
|
948
951
|
const records = await this.getDiagnosticRecords(fileNames);
|
|
949
952
|
// diagnosticManager.pushAll(records);
|
|
950
953
|
}
|
|
@@ -974,7 +977,7 @@ export class NaslServer {
|
|
|
974
977
|
return;
|
|
975
978
|
|
|
976
979
|
// 先获取原来的节点先清除一下之前有异常的节点,下面重新赋值
|
|
977
|
-
const oldRecord = this.diagnosticManager.getRecord(record.id);
|
|
980
|
+
const oldRecord = this.diagnosticManager.getRecord?.(record.id);
|
|
978
981
|
oldRecord?.semanticDiagnostics.forEach((item) => {
|
|
979
982
|
if (item.node) {
|
|
980
983
|
item.node.tsErrorDetail = undefined;
|
|
@@ -2239,7 +2242,7 @@ export class NaslServer {
|
|
|
2239
2242
|
}
|
|
2240
2243
|
const typeAnnotation = minRange.node instanceof TypeAnnotation ? (minRange.node.upperNode as Variable).typeAnnotation : (minRange.node as Variable).typeAnnotation;
|
|
2241
2244
|
const regNamespace = /<(\S*)>/;
|
|
2242
|
-
const typeKey = (typeAnnotation
|
|
2245
|
+
const typeKey = (typeAnnotation?.typeKey.match(regNamespace) && typeAnnotation?.typeKey.match(regNamespace)[1]) || typeAnnotation?.typeKey;
|
|
2243
2246
|
const typeKeyArr = typeKey.split('.');
|
|
2244
2247
|
if (typeKeyArr[0] === 'apis') {
|
|
2245
2248
|
const structureName = typeKeyArr[3];
|
|
@@ -3652,7 +3655,7 @@ export class NaslServer {
|
|
|
3652
3655
|
args.push(fileDetail);
|
|
3653
3656
|
});
|
|
3654
3657
|
// console.time('请求');
|
|
3655
|
-
const resultMap: any = (await this.getNaslNodeTypeFull(args))
|
|
3658
|
+
const resultMap: any = (await this.getNaslNodeTypeFull(args))?.response;
|
|
3656
3659
|
// console.timeEnd('请求');
|
|
3657
3660
|
|
|
3658
3661
|
// console.log(resultMap);
|
|
@@ -3824,7 +3827,7 @@ export class NaslServer {
|
|
|
3824
3827
|
record.id = fileNode.id;
|
|
3825
3828
|
record.node = fileNode;
|
|
3826
3829
|
if (!['Structure', 'DataSource', 'Entity', 'Enum', 'Role'].includes(fileNode.concept)) {
|
|
3827
|
-
fileNode.sourceMap.forEach((item, nodeItem) => {
|
|
3830
|
+
fileNode.sourceMap && fileNode.sourceMap.forEach((item, nodeItem) => {
|
|
3828
3831
|
nodes.push({
|
|
3829
3832
|
filePath: record.filePath,
|
|
3830
3833
|
node: nodeItem,
|
|
@@ -4405,3 +4408,5 @@ export class NaslServer {
|
|
|
4405
4408
|
}
|
|
4406
4409
|
}
|
|
4407
4410
|
}
|
|
4411
|
+
|
|
4412
|
+
export { NaslServer };
|
package/src/server/translator.ts
CHANGED
|
@@ -699,9 +699,9 @@ export function naslNodeTranslateMessage(minRange: MinRange, tsErrorDetail: Diag
|
|
|
699
699
|
|
|
700
700
|
if (/'__UpdateNoProperty__' is declared but its value is never read./.exec(text)) {
|
|
701
701
|
tsErrorDetail.message = '局部更新:未选择任何属性';
|
|
702
|
-
const callLogic = node
|
|
703
|
-
const bodyArgument = callLogic
|
|
704
|
-
node = bodyArgument
|
|
702
|
+
const callLogic = node?.parentNode?.parentNode?.parentNode as CallLogic;
|
|
703
|
+
const bodyArgument = callLogic?.arguments?.find((item) => item.keyword === 'body');
|
|
704
|
+
node = bodyArgument?.expression;
|
|
705
705
|
}
|
|
706
706
|
|
|
707
707
|
// 左右类型不一致的,把上级信息带上
|
package/src/utils/string.ts
CHANGED
|
@@ -31,7 +31,7 @@ export const Camel2Snake = (name: string) => name.replace(/([A-Z])/g, (m, $1, of
|
|
|
31
31
|
* 首字母大写
|
|
32
32
|
* @param value 字符串
|
|
33
33
|
*/
|
|
34
|
-
export const firstUpperCase = (value: string) => value.replace(/^\S/, (letter) => letter.toUpperCase());
|
|
34
|
+
export const firstUpperCase = (value: string) => value.replace?.(/^\S/, (letter) => letter.toUpperCase());
|
|
35
35
|
/**
|
|
36
36
|
* 首字母小写
|
|
37
37
|
* @param value 字符串
|