@lcap/nasl 4.3.0-beta.1 → 4.3.0-beta.11
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/index.d.ts +1 -2
- package/out/index.d.ts.map +1 -1
- package/out/index.js +2 -2
- package/out/index.js.map +1 -1
- package/out/natural/transformTS2UI.d.ts.map +1 -1
- package/out/natural/transformTS2UI.js +38 -1
- package/out/natural/transformTS2UI.js.map +1 -1
- package/out/natural/transforms/transform2LogicItem.d.ts +1 -0
- package/out/natural/transforms/transform2LogicItem.d.ts.map +1 -1
- package/out/natural/transforms/transform2LogicItem.js +27 -2
- package/out/natural/transforms/transform2LogicItem.js.map +1 -1
- package/out/natural/transforms/transform2TypeAnnotation.d.ts.map +1 -1
- package/out/natural/transforms/transform2TypeAnnotation.js +5 -0
- package/out/natural/transforms/transform2TypeAnnotation.js.map +1 -1
- package/out/server/OQL/oql-cache.d.ts.map +1 -1
- package/out/server/OQL/oql-cache.js +10 -3
- package/out/server/OQL/oql-cache.js.map +1 -1
- package/out/server/extendBaseNode.d.ts.map +1 -1
- package/out/server/extendBaseNode.js +34 -10
- package/out/server/extendBaseNode.js.map +1 -1
- package/out/server/findReference.d.ts.map +1 -1
- package/out/server/findReference.js +15 -2
- package/out/server/findReference.js.map +1 -1
- package/out/server/naslServer.d.ts +45 -16
- package/out/server/naslServer.d.ts.map +1 -1
- package/out/server/naslServer.js +567 -107
- package/out/server/naslServer.js.map +1 -1
- package/out/service/autofix/index.d.ts.map +1 -1
- package/out/service/autofix/index.js +2 -0
- package/out/service/autofix/index.js.map +1 -1
- package/out/service/autofix/rules/rule-change-valuefield-in-viewelement.d.ts +3 -0
- package/out/service/autofix/rules/rule-change-valuefield-in-viewelement.d.ts.map +1 -0
- package/out/service/autofix/rules/rule-change-valuefield-in-viewelement.js +52 -0
- package/out/service/autofix/rules/rule-change-valuefield-in-viewelement.js.map +1 -0
- package/out/service/creator/errHandles.js +0 -5
- package/out/service/creator/errHandles.js.map +1 -1
- package/out/service/storage/init.d.ts +1 -0
- package/out/service/storage/init.d.ts.map +1 -1
- package/out/service/storage/init.js +31 -4
- package/out/service/storage/init.js.map +1 -1
- package/out/service/storage/service.d.ts.map +1 -1
- package/out/service/storage/service.js +1 -0
- package/out/service/storage/service.js.map +1 -1
- package/out/service/storage/utils.d.ts +0 -6
- package/out/service/storage/utils.d.ts.map +1 -1
- package/out/service/storage/utils.js +1 -36
- package/out/service/storage/utils.js.map +1 -1
- package/out/templator/block2nasl/viewMergeBlock.d.ts.map +1 -1
- package/out/templator/block2nasl/viewMergeBlock.js +7 -0
- package/out/templator/block2nasl/viewMergeBlock.js.map +1 -1
- package/out/templator/utils.d.ts +16 -7
- package/out/templator/utils.d.ts.map +1 -1
- package/out/templator/utils.js +14 -2
- package/out/templator/utils.js.map +1 -1
- package/out/utils/index.d.ts +1 -0
- package/out/utils/index.d.ts.map +1 -1
- package/out/utils/index.js +1 -0
- package/out/utils/index.js.map +1 -1
- package/out/utils/sentry.d.ts +3 -0
- package/out/utils/sentry.d.ts.map +1 -0
- package/out/utils/sentry.js +10 -0
- package/out/utils/sentry.js.map +1 -0
- package/package.json +9 -10
- package/sandbox/stdlib/nasl.core.ts +4 -8
- package/sandbox/stdlib/nasl.io.ts +10 -0
- package/sandbox/stdlib/nasl.ui.ts +1 -9
- package/sandbox/stdlib/nasl.util.ts +16 -6
package/out/server/naslServer.js
CHANGED
|
@@ -31,11 +31,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
31
31
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
32
32
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
33
33
|
};
|
|
34
|
-
var NaslServer_1;
|
|
35
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
35
|
exports.NaslServer = exports.getDisplayString2Type = void 0;
|
|
37
36
|
const config_1 = require("../config");
|
|
38
|
-
const nasl_sentry_1 = require("@lcap/nasl-sentry");
|
|
39
37
|
const Messager_1 = __importDefault(require("../common/Messager"));
|
|
40
38
|
const oql_cache_1 = require("./OQL/oql-cache");
|
|
41
39
|
const initial_1 = require("../service/initial");
|
|
@@ -62,7 +60,6 @@ const nasl_concepts_1 = require("@lcap/nasl-concepts");
|
|
|
62
60
|
const nasl_language_server_core_1 = require("@lcap/nasl-language-server-core");
|
|
63
61
|
const findReference_1 = require("./findReference");
|
|
64
62
|
const nasl_server_client_1 = require("./client/nasl-server-client");
|
|
65
|
-
const SentryMessager = (0, nasl_sentry_1.sentryMonitorTSWorkerMessager)(Messager_1.default);
|
|
66
63
|
// naslStdlib文件缓存;作为全局变量给多实例用复用
|
|
67
64
|
const __naslStdlibFileCacheMap = new Map();
|
|
68
65
|
function transformDiagnosticMapToRecords(diagnosticMap) {
|
|
@@ -127,8 +124,320 @@ const createWorker = async (link, options) => {
|
|
|
127
124
|
URL.revokeObjectURL(url);
|
|
128
125
|
return worker;
|
|
129
126
|
};
|
|
127
|
+
// FIXME wudengke 移动位置,放到nasl-language-server-core中
|
|
128
|
+
const oqlDefsStr = `
|
|
129
|
+
declare namespace nasl.oql {
|
|
130
|
+
// 一次平铺的查询视为一次Query,FROM查询的依据为实体Entity
|
|
131
|
+
// RecordList需要形如 any[]。而目前extends约束会参与求解;因此加上这个约束,会将 RecordList 解成 any[],导致单测挂掉
|
|
132
|
+
function checkUniqueKeys<RecordList>(...args: RecordList): CheckUniqueKeys<RecordList>;
|
|
133
|
+
export class Query<Record extends Array<any>> {
|
|
134
|
+
FROM_0<R>(): Query<[R]>;
|
|
135
|
+
FROM_1<JoinRecord extends Array<any>>(query: Query<JoinRecord>): Query<[...Record, ...JoinRecord]>;
|
|
136
|
+
FROM_SUBQUERY<JoinRecord extends Array<any>>(query: Query<JoinRecord>): Query<[...JoinRecord]>;
|
|
137
|
+
PARTITION(expr: (...record: Record) => any): Query<Record>;
|
|
138
|
+
INDEXHIT(expr: (...record: Record) => any): Query<Record>;
|
|
139
|
+
|
|
140
|
+
JOIN_0<Record>(): Query<[Record]>;
|
|
141
|
+
JOIN_1<JoinRecord extends Array<any>>(query: Query<JoinRecord>): Query<[...Record, ...JoinRecord]>;
|
|
142
|
+
USING(...expr: Array<(...record: Record) => any>): Query<Record>;
|
|
143
|
+
ON(expr: (...record: Record) => nasl.core.Boolean): Query<Record>;
|
|
144
|
+
// UNION<T2 extends Array<any>>(union: Query<T2> & IfEquals<Record, T2>): Query<Record>;
|
|
145
|
+
UNION<UnionRecord extends Array<any>>(union: Query<UnionRecord>): Query<Record>;
|
|
146
|
+
WHERE(...expr: Array<(...record: Record) => nasl.core.Boolean>): Query<Record>;
|
|
147
|
+
GROUP_BY(...expr: Array<(...record: Record) => any>): Query<Record>;
|
|
148
|
+
HAVING(...expr: Array<(...record: Record) => nasl.core.Boolean>): Query<Record>;
|
|
149
|
+
SELECT<SelectRecord>(expr: (...record: Record) => SelectRecord, check?: (...record: Record) => true, check2?: void): Query<[SelectRecord]>;
|
|
150
|
+
// 内存临时表
|
|
151
|
+
SELECT_WITH_TEMP_TABLE<SelectRecord>(expr: (...record: Record) => SelectRecord): Query<[SelectRecord, ...Record]>;
|
|
152
|
+
SELECT_SUBQUERY_EXPR<SelectRecord>(expr: (...record: Record) => SelectRecord): SelectRecord;
|
|
153
|
+
ORDER_BY(...expr: Array<(...record: Record) => any>): Query<Record>;
|
|
154
|
+
LIMIT_OFFSET(limit: nasl.core.Long, offset?: nasl.core.Long): Query<Record>;
|
|
155
|
+
PAGINATE(page: nasl.core.Long, size: nasl.core.Long): Query<Record>;
|
|
156
|
+
DynamicIfJoinExpr<JoinRecord extends Array<any>>(testExpr: nasl.core.Boolean, sqlExpr: Query<JoinRecord>): Query<[...Record, ...JoinRecord]>;
|
|
157
|
+
|
|
158
|
+
GET_NO_LIST(_: nasl.core.Boolean): nasl.oql.InternalGetQueryNoListResult<Record>;
|
|
159
|
+
GET_LIST(_: nasl.core.Boolean): nasl.oql.InternalGetQueryListResult<Record>;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// String functions
|
|
163
|
+
export function ASCII(str: nasl.core.String ): nasl.core.String;
|
|
164
|
+
export function BIN(expr: nasl.core.Long ): nasl.core.String;
|
|
165
|
+
export function BIT_LENGTH(str: nasl.core.String ): nasl.core.Long;
|
|
166
|
+
export function CHAR(charset?: nasl.core.String , ...exprs: Array<any>): nasl.core.String;
|
|
167
|
+
export function CHAR_LENGTH(str: nasl.core.String ): nasl.core.Long;
|
|
168
|
+
export function CONCAT(...strs: Array<any>): nasl.core.String;
|
|
169
|
+
export function CONCAT_WS(seperator: nasl.core.String , ...strs: Array<nasl.core.String >): nasl.core.String;
|
|
170
|
+
export function ELT(expr: nasl.core.Long, ...strs: Array<nasl.core.String >): nasl.core.String;
|
|
171
|
+
export function EXPORT_SET(bits: nasl.core.Long, on: nasl.core.String , off: nasl.core.String , separator?: nasl.core.String , number_of_bits?: nasl.core.Long): nasl.core.String;
|
|
172
|
+
export function FIELD(str: nasl.core.String , ...strs: Array<nasl.core.String >): nasl.core.Long;
|
|
173
|
+
export function FIND_IN_SET(str: nasl.core.String , strs: nasl.core.String ): nasl.core.Long;
|
|
174
|
+
export function FORMAT(expr1: nasl.core.Long | nasl.core.Decimal, expr2: nasl.core.Long, locale?: nasl.core.String ): nasl.core.String;
|
|
175
|
+
export function FROM_BASE64(str: nasl.core.String ): nasl.core.String;
|
|
176
|
+
export function HEX(expr: nasl.core.String ): nasl.core.String;
|
|
177
|
+
export function INSERT(str: nasl.core.String , pos: nasl.core.Long, len: nasl.core.Long, newStr: nasl.core.String ): nasl.core.String;
|
|
178
|
+
export function INSTR(str: nasl.core.String , newStr: nasl.core.String ): nasl.core.Long;
|
|
179
|
+
export function LCASE(str: nasl.core.String ): nasl.core.String;
|
|
180
|
+
export function LEFT(str: nasl.core.String | nasl.core.Date, len: nasl.core.Long): nasl.core.String;
|
|
181
|
+
export function LENGTH(str: nasl.core.String ): nasl.core.Long;
|
|
182
|
+
export function LOAD_FILE(fileName: nasl.core.String ): nasl.core.String;
|
|
183
|
+
export function LOCATE(subStr: nasl.core.String , str: nasl.core.String, pos?: nasl.core.Long): nasl.core.Long;
|
|
184
|
+
export function LOWER(str: nasl.core.String ): nasl.core.String;
|
|
185
|
+
export function LPAD(str: nasl.core.String , len: nasl.core.Long, padStr: nasl.core.String ): nasl.core.String;
|
|
186
|
+
export function LTRIM(str: nasl.core.String ): nasl.core.String;
|
|
187
|
+
export function MAKE_SET(bits: nasl.core.Long, ...strs: Array<nasl.core.String >): nasl.core.String;
|
|
188
|
+
export function MID(str: nasl.core.String , pos: nasl.core.Long, len: nasl.core.Long): nasl.core.String;
|
|
189
|
+
export function OCT(expr: nasl.core.Long ): nasl.core.String;
|
|
190
|
+
export function OCTET_LENGTH(str: nasl.core.String ): nasl.core.Long;
|
|
191
|
+
export function ORD(str: nasl.core.String ): nasl.core.Long;
|
|
192
|
+
export function POSITION(subStr: nasl.core.String , str: nasl.core.String ): nasl.core.Long;
|
|
193
|
+
export function QUOTE(str: nasl.core.String ): nasl.core.String;
|
|
194
|
+
export function REPEAT(str: nasl.core.String , count: nasl.core.Long): nasl.core.String;
|
|
195
|
+
export function REPLACE(str: nasl.core.String , fromStr: nasl.core.String , toStr: nasl.core.String ): nasl.core.String;
|
|
196
|
+
export function REVERSE(str: nasl.core.String ): nasl.core.String;
|
|
197
|
+
export function RIGHT(str: nasl.core.String , len: nasl.core.Long): nasl.core.String;
|
|
198
|
+
export function RPAD(str: nasl.core.String , len: nasl.core.Long, padStr: nasl.core.String ): nasl.core.String;
|
|
199
|
+
export function RTRIM(str: nasl.core.String ): nasl.core.String;
|
|
200
|
+
export function SOUNDEX(str: nasl.core.String ): nasl.core.String;
|
|
201
|
+
export function SOUNDES_LIKE(str1: nasl.core.String , str2: nasl.core.String ): nasl.core.Boolean;
|
|
202
|
+
export function SPACE(expr: nasl.core.Long): nasl.core.Long;
|
|
203
|
+
export function SUBSTR(str: nasl.core.String , pos: nasl.core.Long, len?: nasl.core.Long): nasl.core.String;
|
|
204
|
+
export function SUBSTRING(str: nasl.core.String , pos: nasl.core.Long, len?: nasl.core.Long): nasl.core.String;
|
|
205
|
+
export function SUBSTRING_INDEX(str: nasl.core.String , delim: nasl.core.String, count: nasl.core.Long): nasl.core.String;
|
|
206
|
+
export function TO_BASE64(str: nasl.core.String ): nasl.core.String;
|
|
207
|
+
export function TRIM(remStr: nasl.core.String , str: nasl.core.String ): nasl.core.String;
|
|
208
|
+
export function UCASE(str: nasl.core.String ): nasl.core.String;
|
|
209
|
+
export function UNHEX(str: nasl.core.String ): nasl.core.String;
|
|
210
|
+
export function UPPER(str: nasl.core.String ): nasl.core.String;
|
|
211
|
+
export function WEIGHT_STRING(str: nasl.core.String , as: 'CHAR' | 'BINARY', ...level: Array<nasl.core.Long>): nasl.core.String;
|
|
212
|
+
// String comparison functions
|
|
213
|
+
export function LIKE(str1: nasl.core.String , str2: nasl.core.String , escape?: nasl.core.String ): nasl.core.Boolean;
|
|
214
|
+
export function NOT_LIKE(str1: nasl.core.String , str2: nasl.core.String , escape?: nasl.core.String ): nasl.core.Boolean;
|
|
215
|
+
export function STRCMP(str1: nasl.core.String , str2: nasl.core.String ): nasl.core.Boolean;
|
|
216
|
+
// Regular Expressions
|
|
217
|
+
export function REGEXP(str1: nasl.core.String , str2: nasl.core.String ): nasl.core.Boolean;
|
|
218
|
+
export function NOT_REGEXP(str1: nasl.core.String , str2: nasl.core.String ): nasl.core.Boolean;
|
|
219
|
+
export function RLIKE(str1: nasl.core.String , str2: nasl.core.String ): nasl.core.Boolean;
|
|
220
|
+
|
|
221
|
+
// Character Set and Collation of Function Results
|
|
222
|
+
|
|
223
|
+
// Mathematical Functions
|
|
224
|
+
export function ABS(expr: nasl.core.Long): nasl.core.Long;
|
|
225
|
+
export function ABS(expr: nasl.core.Long): nasl.core.Long;
|
|
226
|
+
export function ABS(expr: nasl.core.Decimal): nasl.core.Decimal;
|
|
227
|
+
export function ABS(expr: nasl.core.Decimal): nasl.core.Decimal;
|
|
228
|
+
export function ACOS(expr: nasl.core.Long ): nasl.core.Decimal;
|
|
229
|
+
export function ACOS(expr: nasl.core.Decimal): nasl.core.Decimal;
|
|
230
|
+
export function ASIN(expr: nasl.core.Long ): nasl.core.Decimal;
|
|
231
|
+
export function ASIN(expr: nasl.core.Decimal): nasl.core.Decimal;
|
|
232
|
+
export function ATAN(expr: nasl.core.Long ): nasl.core.Decimal;
|
|
233
|
+
export function ATAN(expr: nasl.core.Decimal): nasl.core.Decimal;
|
|
234
|
+
export function ATAN(expr1: nasl.core.Long | nasl.core.Decimal, expr2: nasl.core.Long | nasl.core.Decimal): nasl.core.Decimal;
|
|
235
|
+
export function ATAN(expr1: nasl.core.Long | nasl.core.Decimal, expr2: nasl.core.Decimal): nasl.core.Decimal;
|
|
236
|
+
export function ATAN(expr1: nasl.core.Decimal, expr2: nasl.core.Long | nasl.core.Decimal): nasl.core.Decimal;
|
|
237
|
+
export function ATAN2(expr1: nasl.core.Long | nasl.core.Decimal, expr2: nasl.core.Long | nasl.core.Decimal): nasl.core.Decimal;
|
|
238
|
+
export function ATAN2(expr1: nasl.core.Long | nasl.core.Decimal, expr2: nasl.core.Decimal): nasl.core.Decimal;
|
|
239
|
+
export function ATAN2(expr1: nasl.core.Decimal, expr2: nasl.core.Long | nasl.core.Decimal): nasl.core.Decimal;
|
|
240
|
+
export function CEIL(expr1: nasl.core.Long | nasl.core.Decimal): nasl.core.Long;
|
|
241
|
+
export function CEILING(expr1: nasl.core.Long | nasl.core.Decimal): nasl.core.Long;
|
|
242
|
+
export function CONV(expr1: nasl.core.Long | nasl.core.String, expr2: nasl.core.Long, expr3: nasl.core.Long): nasl.core.String;
|
|
243
|
+
export function COS(expr1: nasl.core.Long | nasl.core.Decimal): nasl.core.Decimal;
|
|
244
|
+
export function COS(expr1: nasl.core.Decimal): nasl.core.Decimal;
|
|
245
|
+
export function COT(expr1: nasl.core.Long | nasl.core.Decimal): nasl.core.Decimal;
|
|
246
|
+
export function COT(expr1: nasl.core.Decimal): nasl.core.Decimal;
|
|
247
|
+
export function CRC32(expr1: nasl.core.String): nasl.core.Long;
|
|
248
|
+
export function DEGREES(expr1: nasl.core.Long | nasl.core.Decimal): nasl.core.Decimal;
|
|
249
|
+
export function DEGREES(expr1: nasl.core.Decimal): nasl.core.Decimal;
|
|
250
|
+
export function EXP(expr1: nasl.core.Long | nasl.core.Decimal): nasl.core.Decimal;
|
|
251
|
+
export function EXP(expr1: nasl.core.Decimal): nasl.core.Decimal;
|
|
252
|
+
export function FLOOR(expr1: nasl.core.Long | nasl.core.Decimal): nasl.core.Long;
|
|
253
|
+
export function LN(expr1: nasl.core.Long | nasl.core.Decimal): nasl.core.Decimal;
|
|
254
|
+
export function LN(expr1: nasl.core.Decimal): nasl.core.Decimal;
|
|
255
|
+
export function LOG(expr1: nasl.core.Decimal): nasl.core.Decimal;
|
|
256
|
+
export function LOG(expr1: nasl.core.Long | nasl.core.Decimal): nasl.core.Decimal;
|
|
257
|
+
export function LOG(expr1: nasl.core.Long | nasl.core.Decimal, expr2: nasl.core.Long | nasl.core.Decimal): nasl.core.Decimal;
|
|
258
|
+
export function LOG(expr1: nasl.core.Decimal, expr2: nasl.core.Long | nasl.core.Decimal): nasl.core.Decimal;
|
|
259
|
+
export function LOG(expr1: nasl.core.Long | nasl.core.Decimal, expr2: nasl.core.Decimal): nasl.core.Decimal;
|
|
260
|
+
export function LOG2(expr1: nasl.core.Decimal): nasl.core.Decimal;
|
|
261
|
+
export function LOG2(expr1: nasl.core.Long | nasl.core.Decimal): nasl.core.Decimal;
|
|
262
|
+
export function LOG10(expr1: nasl.core.Decimal): nasl.core.Decimal;
|
|
263
|
+
export function LOG10(expr1: nasl.core.Long | nasl.core.Decimal): nasl.core.Decimal;
|
|
264
|
+
export function MOD(expr1: nasl.core.Long | nasl.core.Decimal, expr2: nasl.core.Long | nasl.core.Decimal): nasl.core.Decimal;
|
|
265
|
+
export function MOD(expr1: nasl.core.Decimal, expr2: nasl.core.Long | nasl.core.Decimal): nasl.core.Decimal;
|
|
266
|
+
export function MOD(expr1: nasl.core.Long | nasl.core.Decimal, expr2: nasl.core.Decimal): nasl.core.Decimal;
|
|
267
|
+
export function PI(): nasl.core.Decimal;
|
|
268
|
+
export function POW(expr1: nasl.core.Long , expr2: nasl.core.Long ): nasl.core.Long;
|
|
269
|
+
export function POW(expr1: nasl.core.Long , expr2: nasl.core.Decimal): nasl.core.Decimal;
|
|
270
|
+
export function POW(expr1: nasl.core.Decimal, expr2: nasl.core.Long | nasl.core.Decimal): nasl.core.Decimal;
|
|
271
|
+
export function POWER(expr1: nasl.core.Long , expr2: nasl.core.Long ): nasl.core.Long;
|
|
272
|
+
export function POWER(expr1: nasl.core.Long , expr2: nasl.core.Decimal): nasl.core.Decimal;
|
|
273
|
+
export function POWER(expr1: nasl.core.Decimal, expr2: nasl.core.Long | nasl.core.Decimal): nasl.core.Decimal;
|
|
274
|
+
export function RADIANS(expr1: nasl.core.Long | nasl.core.Decimal): nasl.core.Decimal;
|
|
275
|
+
export function RAND(expr1?: nasl.core.Long | nasl.core.Decimal): nasl.core.Decimal;
|
|
276
|
+
export function RAND(expr1: nasl.core.Decimal): nasl.core.Decimal;
|
|
277
|
+
export function ROUND(expr1: nasl.core.Long | nasl.core.Decimal): nasl.core.Long;
|
|
278
|
+
export function ROUND(expr1: nasl.core.Long | nasl.core.Decimal, expr2: nasl.core.Long | nasl.core.Decimal): nasl.core.Decimal;
|
|
279
|
+
export function SIGN(expr1: nasl.core.Long | nasl.core.Decimal): nasl.core.Long;
|
|
280
|
+
export function SIN(expr1: nasl.core.Long | nasl.core.Decimal): nasl.core.Decimal;
|
|
281
|
+
export function SQRT(expr1: nasl.core.Long | nasl.core.Decimal): nasl.core.Decimal;
|
|
282
|
+
export function TAN(expr1: nasl.core.Long | nasl.core.Decimal): nasl.core.Decimal;
|
|
283
|
+
export function TRUNCATE(expr1: nasl.core.Long | nasl.core.Decimal, expr2: nasl.core.Long | nasl.core.Decimal): nasl.core.Decimal;
|
|
284
|
+
|
|
285
|
+
// Date and Time Functions
|
|
286
|
+
type TIME_UNIT = 'MICROSECOND' | 'SECOND' | 'MINUTE' | 'HOUR' | 'DAY' | 'WEEK' | 'MONTH' | 'QUARTER' | 'YEAR' | 'SECOND_MICROSECOND' | 'MINUTE_MICROSECOND' | 'MINUTE_SECOND' | 'HOUR_MICROSECOND' | 'HOUR_SECOND' | 'HOUR_MINUTE' | 'DAY_MICROSECOND' | 'DAY_SECOND' | 'DAY_MINUTE' | 'DAY_HOUR' | 'YEAR_MONTH';
|
|
287
|
+
type fsp = 0 | 1 | 2 | 3 | 4 | 5 | 6; // fractional seconds precision
|
|
288
|
+
export function DATE_ADD(date: nasl.core.Date, interval: "INTERVAL", expr: nasl.core.Long, unit: 'YEAR' | 'MONTH' | 'DAY'): nasl.core.Date;
|
|
289
|
+
export function DATE_ADD(date: nasl.core.DateTime, interval: "INTERVAL", expr: nasl.core.Long, unit: TIME_UNIT): nasl.core.DateTime;
|
|
290
|
+
export function DATE_ADD(date: nasl.core.Date, interval: "INTERVAL", expr: nasl.core.String, unit: 'YEAR' | 'MONTH' | 'DAY'): nasl.core.Date;
|
|
291
|
+
export function DATE_ADD(date: nasl.core.DateTime, interval: "INTERVAL", expr: nasl.core.String, unit: TIME_UNIT): nasl.core.DateTime;
|
|
292
|
+
export function DATE_SUB(date: nasl.core.Date, interval: "INTERVAL", expr: nasl.core.Long, unit: 'YEAR' | 'MONTH' | 'DAY'): nasl.core.Date;
|
|
293
|
+
export function DATE_SUB(date: nasl.core.DateTime, interval: "INTERVAL", expr: nasl.core.Long, unit: TIME_UNIT): nasl.core.DateTime;
|
|
294
|
+
export function DATE_SUB(date: nasl.core.Date, interval: "INTERVAL", expr: nasl.core.String, unit: 'YEAR' | 'MONTH' | 'DAY'): nasl.core.Date;
|
|
295
|
+
export function DATE_SUB(date: nasl.core.DateTime, interval: "INTERVAL", expr: nasl.core.String, unit: TIME_UNIT): nasl.core.DateTime;
|
|
296
|
+
export function ADDDATE(date: nasl.core.Date, interval: "INTERVAL", expr: nasl.core.Long, unit: 'YEAR' | 'MONTH' | 'DAY'): nasl.core.Date;
|
|
297
|
+
export function ADDDATE(date: nasl.core.DateTime, interval: "INTERVAL", expr: nasl.core.Long, unit: TIME_UNIT): nasl.core.DateTime;
|
|
298
|
+
export function ADDDATE(date: nasl.core.Date, interval: "INTERVAL", expr: nasl.core.String, unit: 'YEAR' | 'MONTH' | 'DAY'): nasl.core.Date;
|
|
299
|
+
export function ADDDATE(date: nasl.core.DateTime, interval: "INTERVAL", expr: nasl.core.String, unit: TIME_UNIT): nasl.core.DateTime;
|
|
300
|
+
export function ADDDATE(date: nasl.core.Date, expr: nasl.core.Long): nasl.core.Date;
|
|
301
|
+
export function ADDDATE(date: nasl.core.DateTime, expr: nasl.core.Long): nasl.core.DateTime;
|
|
302
|
+
export function ADDTIME(expr1: nasl.core.DateTime, expr: nasl.core.Time): nasl.core.DateTime;
|
|
303
|
+
export function ADDTIME(expr1: nasl.core.Time, expr: nasl.core.Time): nasl.core.Time;
|
|
304
|
+
export function CONVERT_TZ(expr1: nasl.core.DateTime, fromTz: nasl.core.String, toTz: nasl.core.String): nasl.core.DateTime;
|
|
305
|
+
export function CURDATE(): nasl.core.Date;
|
|
306
|
+
export function CURRENT_DATE(): nasl.core.Date;
|
|
307
|
+
export function CURTIME(): nasl.core.Time;
|
|
308
|
+
export function CURTIME(fsp: fsp): nasl.core.Decimal;
|
|
309
|
+
export function CURRENT_TIME(): nasl.core.Time;
|
|
310
|
+
export function CURRENT_TIME(fsp: fsp): nasl.core.Decimal;
|
|
311
|
+
export function DATE(expr: nasl.core.Date | nasl.core.DateTime): nasl.core.Date;
|
|
312
|
+
export function DATEDIFF(expr1: nasl.core.Date | nasl.core.DateTime, expr2: nasl.core.Date | nasl.core.DateTime): nasl.core.Long;
|
|
313
|
+
export function DATE_FORMAT(expr1: nasl.core.Date | nasl.core.DateTime | nasl.core.Time, format: nasl.core.String): nasl.core.String;
|
|
314
|
+
export function DAY(expr1: nasl.core.Date | nasl.core.DateTime): nasl.core.Long;
|
|
315
|
+
export function DAYNAME(expr1: nasl.core.Date | nasl.core.DateTime): nasl.core.String;
|
|
316
|
+
export function DAYOFMONTH(expr1: nasl.core.Date | nasl.core.DateTime): nasl.core.Long;
|
|
317
|
+
export function DAYOFWEEK(expr1: nasl.core.Date | nasl.core.DateTime): nasl.core.Long;
|
|
318
|
+
export function EXTRACT(unit: TIME_UNIT, expr1: nasl.core.Date | nasl.core.DateTime): nasl.core.Long;
|
|
319
|
+
export function FROM_DAYS(days: nasl.core.Long): nasl.core.Date;
|
|
320
|
+
export function FROM_UNIXTIME(timestamp: nasl.core.Long, format?: nasl.core.String): nasl.core.DateTime;
|
|
321
|
+
export function GET_FORMAT(str1: 'DATE' | 'TIME' | 'DATETIME', str2: 'EUR' | 'USA' | 'JIS' | 'ISO' | 'INTERNAL'): nasl.core.String;
|
|
322
|
+
export function LAST_DAY(date: nasl.core.Date | nasl.core.DateTime): nasl.core.Date;
|
|
323
|
+
export function LOCALTIME(): nasl.core.DateTime;
|
|
324
|
+
export function LOCALTIMESTAMP(): nasl.core.DateTime;
|
|
325
|
+
export function MAKEDATE(year: nasl.core.Long, dayOfYear: nasl.core.Long): nasl.core.Date;
|
|
326
|
+
export function MAKETIME(hour: nasl.core.Long, minute: nasl.core.Long, second: nasl.core.Long): nasl.core.Time;
|
|
327
|
+
export function MICROSECOND(expr: nasl.core.Time | nasl.core.DateTime): nasl.core.Long;
|
|
328
|
+
export function MINUTE(expr: nasl.core.Time | nasl.core.DateTime): nasl.core.Long;
|
|
329
|
+
export function MONTH(expr: nasl.core.Date | nasl.core.DateTime): nasl.core.Long;
|
|
330
|
+
export function MONTHNAME(expr: nasl.core.Date | nasl.core.DateTime): nasl.core.String;
|
|
331
|
+
export function PERIOD_ADD(expr1: nasl.core.Long, expr2: nasl.core.Long): nasl.core.Long;
|
|
332
|
+
export function PERIOD_DIFF(expr1: nasl.core.Long, expr2: nasl.core.Long): nasl.core.Long;
|
|
333
|
+
export function QUARTER(expr1: nasl.core.Date | nasl.core.DateTime): nasl.core.Long;
|
|
334
|
+
export function SECOND(expr1: nasl.core.Time | nasl.core.DateTime): nasl.core.Long;
|
|
335
|
+
export function SEC_TO_TIME(expr1: nasl.core.Long): nasl.core.Time;
|
|
336
|
+
export function STR_TO_DATE(str: nasl.core.String, format: nasl.core.String): nasl.core.DateTime;
|
|
337
|
+
export function SUBDATE(date: nasl.core.Date, interval: "INTERVAL", expr: nasl.core.Long, unit: 'YEAR' | 'MONTH' | 'DAY'): nasl.core.Date;
|
|
338
|
+
export function SUBDATE(date: nasl.core.DateTime, interval: "INTERVAL", expr: nasl.core.Long, unit: TIME_UNIT): nasl.core.DateTime;
|
|
339
|
+
export function SUBDATE(date: nasl.core.Date, interval: "INTERVAL", expr: nasl.core.String, unit: 'YEAR' | 'MONTH' | 'DAY'): nasl.core.Date;
|
|
340
|
+
export function SUBDATE(date: nasl.core.DateTime, interval: "INTERVAL", expr: nasl.core.String, unit: TIME_UNIT): nasl.core.DateTime;
|
|
341
|
+
export function SUBDATE(date: nasl.core.Date, expr: nasl.core.Long): nasl.core.Date;
|
|
342
|
+
export function SUBDATE(date: nasl.core.DateTime, expr: nasl.core.Long): nasl.core.DateTime;
|
|
343
|
+
export function SUBTIME(expr1: nasl.core.DateTime, expr2: nasl.core.Time): nasl.core.DateTime;
|
|
344
|
+
export function SUBTIME(expr1: nasl.core.Time, expr2: nasl.core.Time): nasl.core.Time;
|
|
345
|
+
export function TIME(expr: nasl.core.Time | nasl.core.DateTime): nasl.core.Time;
|
|
346
|
+
export function TIMEDIFF(expr1: nasl.core.Time | nasl.core.DateTime, expr2: nasl.core.Time | nasl.core.DateTime): nasl.core.Time;
|
|
347
|
+
export function TO_DAYS(expr: nasl.core.Date | nasl.core.DateTime): nasl.core.Long;
|
|
348
|
+
export function TO_SECONDS(expr: nasl.core.Date | nasl.core.DateTime): nasl.core.Long;
|
|
349
|
+
export function UNIX_TIMESTAMP(date?: nasl.core.DateTime): nasl.core.Long;
|
|
350
|
+
export function UTC_DATE(): nasl.core.Date;
|
|
351
|
+
export function UTC_TIME(): nasl.core.Time;
|
|
352
|
+
export function UTC_TIMESTAMP(): nasl.core.DateTime;
|
|
353
|
+
export function WEEK(date: nasl.core.Date | nasl.core.DateTime, mode?: nasl.core.Long): nasl.core.Long;
|
|
354
|
+
export function WEEKDAY(date: nasl.core.Date | nasl.core.DateTime): nasl.core.Long;
|
|
355
|
+
export function DAYOFYEAR(date: nasl.core.Date | nasl.core.DateTime): nasl.core.Long
|
|
356
|
+
export function WEEKOFYEAR(date: nasl.core.Date | nasl.core.DateTime): nasl.core.Long;
|
|
357
|
+
export function YEAR(date: nasl.core.Date | nasl.core.DateTime): nasl.core.Long;
|
|
358
|
+
export function YEARWEEK(date: nasl.core.Date, mode?: nasl.core.Long): nasl.core.Long;
|
|
359
|
+
export function HOUR(date: nasl.core.Date | nasl.core.DateTime): nasl.core.Long;
|
|
360
|
+
export function NOW(): nasl.core.DateTime;
|
|
361
|
+
|
|
362
|
+
// Comparison Functions
|
|
363
|
+
export function INTERVAL(...value: Array<nasl.core.Long>): nasl.core.Long;
|
|
364
|
+
export function GREATEST(...value: Array<nasl.core.Long>): nasl.core.Long;
|
|
365
|
+
export function GREATEST(...value: Array<nasl.core.Long>): nasl.core.Long;
|
|
366
|
+
export function GREATEST(...value: Array<nasl.core.Decimal>): nasl.core.Decimal;
|
|
367
|
+
export function GREATEST(...value: Array<nasl.core.Decimal>): nasl.core.Decimal;
|
|
368
|
+
export function GREATEST(...value: Array<nasl.core.String>): nasl.core.String;
|
|
369
|
+
export function LEAST(...value: Array<nasl.core.Long>): nasl.core.Long;
|
|
370
|
+
export function LEAST(...value: Array<nasl.core.Long>): nasl.core.Long;
|
|
371
|
+
export function LEAST(...value: Array<nasl.core.Decimal>): nasl.core.Decimal;
|
|
372
|
+
export function LEAST(...value: Array<nasl.core.Decimal>): nasl.core.Decimal;
|
|
373
|
+
export function LEAST(...value: Array<nasl.core.String>): nasl.core.String;
|
|
374
|
+
|
|
375
|
+
// Miscellaneous Functions
|
|
376
|
+
export function ANY_VALUE<T>(arg: T): T;
|
|
377
|
+
|
|
378
|
+
// nonAggregateWindowedFunction
|
|
379
|
+
export function CUME_DIST(): nasl.core.Decimal;
|
|
380
|
+
export function DENSE_RANK(): nasl.core.Long;
|
|
381
|
+
export function PERCENT_RANK(): nasl.core.Decimal;
|
|
382
|
+
export function RANK(): nasl.core.Long;
|
|
383
|
+
export function ROW_NUMBER(): nasl.core.Long;
|
|
384
|
+
|
|
385
|
+
// aggregateWindowedFunction
|
|
386
|
+
export function COUNT(...value: Array<any>): nasl.core.Long;
|
|
387
|
+
export function SUM(value: nasl.core.Long): nasl.core.Long;
|
|
388
|
+
export function SUM(value: nasl.core.Decimal): nasl.core.Decimal;
|
|
389
|
+
export function AVG(value: nasl.core.Long | nasl.core.Decimal): nasl.core.Decimal;
|
|
390
|
+
// FIXME wudengke 删掉。它没有啥用的,其实可以去掉
|
|
391
|
+
// export function AVG(value: nasl.core.Decimal): nasl.core.Decimal;
|
|
392
|
+
export function MAX(value: nasl.core.Long): nasl.core.Long;
|
|
393
|
+
export function MAX(value: nasl.core.Decimal): nasl.core.Decimal;
|
|
394
|
+
export function MAX(value: nasl.core.Date): nasl.core.Date;
|
|
395
|
+
export function MAX(value: nasl.core.DateTime): nasl.core.DateTime;
|
|
396
|
+
export function MAX(value: nasl.core.Time): nasl.core.Time;
|
|
397
|
+
export function MAX(value: nasl.core.Boolean): nasl.core.Boolean;
|
|
398
|
+
export function MIN(value: nasl.core.Long): nasl.core.Long;
|
|
399
|
+
export function MIN(value: nasl.core.Decimal): nasl.core.Decimal;
|
|
400
|
+
export function MIN(value: nasl.core.Date): nasl.core.Date;
|
|
401
|
+
export function MIN(value: nasl.core.DateTime): nasl.core.DateTime;
|
|
402
|
+
export function MIN(value: nasl.core.Time): nasl.core.Time;
|
|
403
|
+
export function MIN(value: nasl.core.Boolean): nasl.core.Boolean;
|
|
404
|
+
|
|
405
|
+
// self
|
|
406
|
+
export function STARTWITH(str1: nasl.core.String, str2: nasl.core.String): nasl.core.Boolean;
|
|
407
|
+
export function ENDWITH(str1: nasl.core.String, str2: nasl.core.String): nasl.core.Boolean;
|
|
408
|
+
export function IN<T>(value: T, list: nasl.collection.List<T>): nasl.core.Boolean;
|
|
409
|
+
export function IN<T>(value: T, ...array: Array<T>): nasl.core.Boolean;
|
|
410
|
+
export function IN_SUBQUERY<SelectRecord, T>(value: T, expr: Query<[SelectRecord]>): nasl.core.Boolean;
|
|
411
|
+
export function COMPARE_SUBQUERY<SelectRecord, T extends SelectRecord>(value: T, expr: Query<[SelectRecord]>): nasl.core.Boolean;
|
|
412
|
+
export function ISNULL(value: any): nasl.core.Boolean;
|
|
413
|
+
export function IFNULL<T extends nasl.core.Long | nasl.core.Decimal>(expr1: T, expr2: nasl.core.Decimal): nasl.core.Decimal;
|
|
414
|
+
export function IFNULL<T extends nasl.core.Decimal | nasl.core.Long>(expr1: nasl.core.Decimal, expr2: T): nasl.core.Decimal;
|
|
415
|
+
export function IFNULL<T1, T2>(expr1: T1, expr2: T2): T1 | T2;
|
|
416
|
+
export function CASE_WHEN<THEN>(caseCase: any, ...caseWhen: Array<[() => any, () => THEN]>): THEN;
|
|
417
|
+
export function CASE_WHEN<THEN>(caseCase: any, caseElse: THEN, ...caseWhen: Array<[() => any, () => THEN]>): THEN;
|
|
418
|
+
export function BETWEEN_AND<T>(value: T, between: T, and: T): nasl.core.Boolean;
|
|
419
|
+
export function GROUP_CONCAT(...value: Array<any>): nasl.core.String;
|
|
420
|
+
export function IF<THEN, ELSE>(expr1: nasl.core.Boolean, expr2: THEN, expr3: ELSE): THEN | ELSE;
|
|
421
|
+
export function ISBOOLEAN(value: nasl.core.Boolean): nasl.core.Boolean;
|
|
422
|
+
export function COMPARE<T>(left: T, right: T): nasl.core.Boolean;
|
|
423
|
+
export function CAST<T>(value: any, dataType: T): T;
|
|
424
|
+
export function CONVERT<T>(value: any, dataType: T): T;
|
|
425
|
+
export function CONVERT<T>(value: T): T;
|
|
426
|
+
|
|
427
|
+
export function EXISTS_EXPR<Record extends Array<any>>(value: Query<Record>): nasl.core.Boolean;
|
|
428
|
+
export function COALESCE<T>(...args: Array<T>): T
|
|
429
|
+
|
|
430
|
+
// others
|
|
431
|
+
export let NULL: never
|
|
432
|
+
export function DynamicIfExpr<Record>(testExpr: nasl.core.Boolean, sqlExpr: Record): Record;
|
|
433
|
+
export function checkDynamicReference(...expr1: Array<any>): void;
|
|
434
|
+
|
|
435
|
+
// 单项查询
|
|
436
|
+
export function SINGLE_SELECT_ELEMENT<Record>(query: Record): Record;
|
|
437
|
+
}
|
|
438
|
+
`;
|
|
130
439
|
const allComponent = {};
|
|
131
|
-
|
|
440
|
+
class NaslServer {
|
|
132
441
|
constructor(opt) {
|
|
133
442
|
/** naslStdlib文件缓存 */
|
|
134
443
|
this.naslStdlibFileCacheMap = __naslStdlibFileCacheMap;
|
|
@@ -181,8 +490,17 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
181
490
|
*/
|
|
182
491
|
this._lsRunEndSwitch = () => void 0;
|
|
183
492
|
this.flags = {
|
|
184
|
-
|
|
493
|
+
/**
|
|
494
|
+
* 是否启用性能分析模式
|
|
495
|
+
*/
|
|
496
|
+
profileMode: false,
|
|
497
|
+
/**
|
|
498
|
+
* 是否启用 TypeScript 语言服务
|
|
499
|
+
* 默认启用,可以通过在 url 中添加 oql-check=true 来关闭 tss,使用 NASL 的OQL类型检查器
|
|
500
|
+
*/
|
|
501
|
+
tssEnabled: true,
|
|
185
502
|
};
|
|
503
|
+
this.uiTsInitedResolve = null;
|
|
186
504
|
// 检查共享数据是否有更新
|
|
187
505
|
this._latestVersionsOfSharedApp = [];
|
|
188
506
|
this.firstScreenEndWork = undefined;
|
|
@@ -196,6 +514,9 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
196
514
|
* @returns 需要校验的文件名
|
|
197
515
|
*/
|
|
198
516
|
this.prepareAndWriteTsFilesToCheck = async (oqlFiles, removedNodes, oqlRemoveNodesTsPath) => {
|
|
517
|
+
if (!this.flags.tssEnabled) {
|
|
518
|
+
return { tsFilePathsToCheck: new Set() };
|
|
519
|
+
}
|
|
199
520
|
function getETSFilePath(fileNode) {
|
|
200
521
|
try {
|
|
201
522
|
return fileNode.getEmbeddedFilePath();
|
|
@@ -266,71 +587,105 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
266
587
|
this.getProxyNode = (nd) => {
|
|
267
588
|
return this.getProxyApp()?.findNodeByPath(nd.nodePath);
|
|
268
589
|
};
|
|
590
|
+
// 初始化 uiTsInited Promise 并保存 resolve 函数
|
|
591
|
+
this.uiTsInited = new Promise((resolve) => {
|
|
592
|
+
this.uiTsInitedResolve = resolve;
|
|
593
|
+
});
|
|
269
594
|
this.promise = this.launch(opt);
|
|
270
595
|
}
|
|
271
596
|
async start() {
|
|
272
597
|
await this.promise;
|
|
273
|
-
|
|
598
|
+
if (this.flags.tssEnabled) {
|
|
599
|
+
return this.messager.requestCommand('start');
|
|
600
|
+
}
|
|
274
601
|
}
|
|
275
602
|
terminate() {
|
|
276
|
-
this.worker
|
|
277
|
-
|
|
603
|
+
if (this.worker) {
|
|
604
|
+
this.worker.terminate();
|
|
605
|
+
this.worker = null;
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
loadFlags(flags) {
|
|
609
|
+
if (flags) {
|
|
610
|
+
Object.keys(flags).forEach((k) => {
|
|
611
|
+
const v = flags[k];
|
|
612
|
+
if (v !== undefined) {
|
|
613
|
+
this.flags[k] = v;
|
|
614
|
+
}
|
|
615
|
+
});
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
synthesisFlagsFromUrl() {
|
|
619
|
+
if (utils.isBrowser) {
|
|
620
|
+
return {
|
|
621
|
+
tssEnabled: !/[?&]oql-check=true/.test(location.search),
|
|
622
|
+
};
|
|
623
|
+
}
|
|
624
|
+
return undefined;
|
|
278
625
|
}
|
|
279
626
|
async launch(opt) {
|
|
280
|
-
|
|
281
|
-
if (
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
627
|
+
const flags = opt.flags ?? this.synthesisFlagsFromUrl();
|
|
628
|
+
if (flags) {
|
|
629
|
+
this.loadFlags(flags);
|
|
630
|
+
}
|
|
631
|
+
// 根据特性开关控制是否创建TypeScript Worker
|
|
632
|
+
if (this.flags.tssEnabled) {
|
|
633
|
+
/// #if process.env.BUILD_TARGET === 'node'
|
|
634
|
+
if (globalThis.process)
|
|
635
|
+
// For TS build
|
|
636
|
+
// this.worker = new Worker(require.resolve('@lcap/nasl-typescript-worker/src/index.js'));
|
|
637
|
+
this.worker = new worker_threads_1.Worker(require.resolve('../../ts-worker/src/index.js'));
|
|
638
|
+
/// #endif
|
|
639
|
+
/// #if process.env.BUILD_TARGET !== 'node'
|
|
640
|
+
if (globalThis.window) {
|
|
641
|
+
// const source = require('!!raw-loader!@lcap/nasl-typescript-worker/dist/index.js').default;
|
|
642
|
+
this.worker = await (async () => {
|
|
643
|
+
if (process.env.NODE_ENV === 'development') {
|
|
644
|
+
const source = require('!!raw-loader!../../ts-worker/bundle.js').default;
|
|
645
|
+
const url = URL.createObjectURL(new Blob([source]));
|
|
646
|
+
const worker = new window.Worker(url);
|
|
647
|
+
URL.revokeObjectURL(url);
|
|
648
|
+
return worker;
|
|
649
|
+
}
|
|
650
|
+
const instance = globalThis.window;
|
|
651
|
+
const baseIdePath = instance?.baseIdePath;
|
|
652
|
+
const hash = process.env.COMMIT_HASH || '';
|
|
653
|
+
const filename = instance?.electron?.createWorker
|
|
654
|
+
? 'tsserver.electron.js'
|
|
655
|
+
: 'tsserver.js';
|
|
656
|
+
// @ts-ignore
|
|
657
|
+
const link = `${baseIdePath}/js/${filename}?${hash}`;
|
|
658
|
+
const options = { name: 'typescript-server' };
|
|
659
|
+
return createWorker(link, options);
|
|
660
|
+
})();
|
|
661
|
+
}
|
|
662
|
+
/// #endif
|
|
308
663
|
}
|
|
309
|
-
/// #endif
|
|
310
664
|
this.http = opt.http;
|
|
311
665
|
this.isAnnotationMode = opt?.isAnnotationMode ?? false;
|
|
312
666
|
this.logger = opt.logger ?? utils.internalLogger;
|
|
313
667
|
this.diagnosticManager = new diagnostic_1.DiagnosticManager();
|
|
314
|
-
this.
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
timeout: 420000,
|
|
319
|
-
getReceiver: () => this.worker,
|
|
320
|
-
getSender: () => this.worker,
|
|
321
|
-
handleMessage: async ({ data }) => {
|
|
668
|
+
this.handlePublishDiagnostics =
|
|
669
|
+
async ({ data }) => {
|
|
670
|
+
console.timeEnd('wait-tss');
|
|
671
|
+
console.time('ls-typecheck');
|
|
322
672
|
if (!data || data.event !== 'publishDiagnostics') {
|
|
323
673
|
return;
|
|
324
674
|
}
|
|
675
|
+
console.debug(`[NaslServer] flags: ${JSON.stringify(this.flags ?? {})}`);
|
|
325
676
|
// getDiagnosticRecordsAndPushAll 最终通过 ts 回调走到这里
|
|
326
|
-
const tsDiagnostics = await this._resolveDiagnosticRecords(data.records, data.versions) ?? [];
|
|
677
|
+
const tsDiagnostics = this.flags.tssEnabled ? [] : await this._resolveDiagnosticRecords(data.records, data.versions) ?? [];
|
|
327
678
|
if (!this.isAnnotationMode) {
|
|
328
|
-
|
|
329
|
-
|
|
679
|
+
if (this.flags.tssEnabled) {
|
|
680
|
+
await utils.timeSlicingWithGenerator(this._incrementalAnnotationJSONWithGenerator(data.records));
|
|
681
|
+
}
|
|
330
682
|
if (this.isFirstScreen) {
|
|
331
683
|
// 首屏时,语言服务初始化
|
|
332
684
|
await this.languageServerInitiate();
|
|
333
685
|
}
|
|
686
|
+
console.time("等待uiTsInited");
|
|
687
|
+
(await this.uiTsInited)?.();
|
|
688
|
+
console.timeEnd("等待uiTsInited");
|
|
334
689
|
// 已经和 NASL 节点配对的诊断信息
|
|
335
690
|
const isProfileMode = this.flags.profileMode;
|
|
336
691
|
if (this.isFirstScreen) {
|
|
@@ -348,7 +703,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
348
703
|
console.profile('check');
|
|
349
704
|
}
|
|
350
705
|
let fixAllUseBeforeAssignTasks = [];
|
|
351
|
-
const rawApp =
|
|
706
|
+
const rawApp = NaslServer.toRaw(this.getProxyApp());
|
|
352
707
|
// 让事件逻辑显示出来
|
|
353
708
|
this._getAllElementLogicRoots();
|
|
354
709
|
try {
|
|
@@ -410,12 +765,25 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
410
765
|
(0, nasl_language_server_core_1.clearFileNodeCache)();
|
|
411
766
|
}
|
|
412
767
|
this.notifyPublishDiagnosticsEnd(tsDiagnostics);
|
|
768
|
+
console.timeEnd("ls-typecheck");
|
|
413
769
|
if (this.firstScreenEndWork) {
|
|
414
770
|
this.firstScreenEndWork();
|
|
415
771
|
this.firstScreenEndWork = undefined;
|
|
416
772
|
}
|
|
417
|
-
}
|
|
418
|
-
|
|
773
|
+
};
|
|
774
|
+
// 只有在tssEnabled时才创建messager
|
|
775
|
+
if (this.flags.tssEnabled) {
|
|
776
|
+
this.messager = new Messager_1.default({
|
|
777
|
+
protocol: 'ts-worker',
|
|
778
|
+
sender: 'ide',
|
|
779
|
+
context: this,
|
|
780
|
+
timeout: 420000,
|
|
781
|
+
getReceiver: () => this.worker,
|
|
782
|
+
getSender: () => this.worker,
|
|
783
|
+
// @ts-expect-error FIXME 看不懂,等高人修复
|
|
784
|
+
handleMessage: this.handlePublishDiagnostics
|
|
785
|
+
});
|
|
786
|
+
}
|
|
419
787
|
// 监听所有改变操作
|
|
420
788
|
this.embeddedTSEmitter = new concepts_1.EventEmitter();
|
|
421
789
|
if (!this.isAnnotationMode) {
|
|
@@ -451,16 +819,16 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
451
819
|
return;
|
|
452
820
|
const changeNode = changeEvent.target;
|
|
453
821
|
// FIXME: 验证完成后需要移除
|
|
454
|
-
const { fileNode: fileNode2 } =
|
|
822
|
+
const { fileNode: fileNode2 } = NaslServer.getCurrentSource(changeNode);
|
|
455
823
|
const fileNode = (0, service_1.getFileNode)(changeNode);
|
|
456
|
-
if (
|
|
824
|
+
if (NaslServer.toRaw(fileNode) !== NaslServer.toRaw(fileNode2)) {
|
|
457
825
|
this.logger.error('\x1b[41m\x1b[97m ☁️ embeddedTSEmitter change 事件中计算不一致 \x1b[0m');
|
|
458
826
|
}
|
|
459
827
|
// 这个方法是 5.0 加入标准库的,但是这里 ts 版本是 4.x,ci 会挂,所以需要忽略
|
|
460
828
|
// @ts-ignore
|
|
461
829
|
const findLastIndex = this.changeStackList.findLastIndex((changeStackItem) => {
|
|
462
830
|
const { target } = changeStackItem;
|
|
463
|
-
const { fileNode: targetFileNode } =
|
|
831
|
+
const { fileNode: targetFileNode } = NaslServer.getCurrentSource(target);
|
|
464
832
|
return targetFileNode === fileNode;
|
|
465
833
|
});
|
|
466
834
|
// 如果当前找到了节点,而且节点在数组的最后一项,说明此次可以合并
|
|
@@ -513,10 +881,6 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
513
881
|
this.createUiTsArg0Copy = components;
|
|
514
882
|
this.createUiTsArg1Copy = options;
|
|
515
883
|
}
|
|
516
|
-
let resolve = undefined;
|
|
517
|
-
this.inited = new Promise((finish) => {
|
|
518
|
-
resolve = finish;
|
|
519
|
-
});
|
|
520
884
|
const { standardUIComponents, // 标准组件(带有ts类型定义文件的组件)
|
|
521
885
|
} = options;
|
|
522
886
|
Object.assign(allComponent, components);
|
|
@@ -542,16 +906,20 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
542
906
|
fileContent: convertTsCode(options.basicUITsCode),
|
|
543
907
|
};
|
|
544
908
|
// 基础组件
|
|
545
|
-
|
|
909
|
+
if (this.flags.tssEnabled) {
|
|
910
|
+
await this.addFile(naslUiComponentTsFile, { cache: true });
|
|
911
|
+
}
|
|
546
912
|
this._debugPutFilesInAnonymousApp([naslUiComponentTsFile]);
|
|
547
913
|
const extensionComponentFile = {
|
|
548
914
|
file: 'extension.component.ts',
|
|
549
915
|
fileContent: convertTsCode(options.withTypeLibraryTsCode),
|
|
550
916
|
};
|
|
551
917
|
// 带有类型的依赖库组件
|
|
552
|
-
|
|
918
|
+
if (this.flags.tssEnabled) {
|
|
919
|
+
await this.addFile(extensionComponentFile, { cache: true });
|
|
920
|
+
}
|
|
553
921
|
this._debugPutFilesInAnonymousApp([extensionComponentFile]);
|
|
554
|
-
|
|
922
|
+
this.uiTsInitedResolve(() => {
|
|
555
923
|
(0, nasl_language_server_core_1.parseTsFnToNaslQNameRefMaps)(this.semEnv.refMgr, naslUiComponentTsFile.fileContent);
|
|
556
924
|
if (extensionComponentFile.fileContent) {
|
|
557
925
|
(0, nasl_language_server_core_1.parseTsFnToNaslQNameRefMaps)(this.semEnv.refMgr, extensionComponentFile.fileContent);
|
|
@@ -568,12 +936,14 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
568
936
|
});
|
|
569
937
|
});
|
|
570
938
|
// 内置标准库类型
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
939
|
+
if (this.flags.tssEnabled) {
|
|
940
|
+
Object.keys(naslStdlibMap_1.default).forEach(async (libFileName) => {
|
|
941
|
+
await this.addFile({
|
|
942
|
+
file: `/${libFileName}`,
|
|
943
|
+
fileContent: naslStdlibMap_1.default[libFileName],
|
|
944
|
+
}, { cache: true });
|
|
945
|
+
});
|
|
946
|
+
}
|
|
577
947
|
this.elementsLogic = elementsLogic;
|
|
578
948
|
}
|
|
579
949
|
*contentToFile(module1) {
|
|
@@ -800,7 +1170,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
800
1170
|
value: () => app,
|
|
801
1171
|
configurable: true,
|
|
802
1172
|
});
|
|
803
|
-
const rawApp =
|
|
1173
|
+
const rawApp = NaslServer.toRaw(app);
|
|
804
1174
|
this.lsRunEnd = new Promise((resolve) => {
|
|
805
1175
|
this._lsRunEndSwitch = resolve;
|
|
806
1176
|
});
|
|
@@ -811,7 +1181,9 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
811
1181
|
await (0, initial_1.initialize)({ app, axios: this.http });
|
|
812
1182
|
this.logger.time('全量生成并写入 TS 文件——总计');
|
|
813
1183
|
const toEmbeddedTSStartTime = new Date().getTime();
|
|
814
|
-
this.logger.time('
|
|
1184
|
+
this.logger.time('创建 OQL 请求');
|
|
1185
|
+
const oqlQueryHandle = this.waitOqlQueryComponentChildrenFinish(rawApp);
|
|
1186
|
+
this.logger.timeEnd('创建 OQL 请求');
|
|
815
1187
|
this.logger.time('全量生成 TS——翻译——简单语义分析');
|
|
816
1188
|
this.semData = new nasl_concepts_1.SemanticData();
|
|
817
1189
|
// 除此之外,好像没什么简单的方法可以让 __xxx.ts 文件快速拿到 app.naslServer 的引用了……
|
|
@@ -826,35 +1198,45 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
826
1198
|
notifyEndWork();
|
|
827
1199
|
};
|
|
828
1200
|
const self = this;
|
|
1201
|
+
this.logger.time('请求数据库配置列表');
|
|
829
1202
|
try {
|
|
830
1203
|
await this.requestDatabaseConfigs(this.http, app);
|
|
831
1204
|
}
|
|
832
1205
|
catch (err) {
|
|
833
1206
|
this.logger.error('请求数据库配置列表失败', err);
|
|
834
1207
|
}
|
|
1208
|
+
this.logger.timeEnd('请求数据库配置列表');
|
|
1209
|
+
this.logger.time('请求sql函数列表');
|
|
835
1210
|
try {
|
|
836
1211
|
this.sqlSignatureFiles = await this.requestSqlFunctions(this.http, app.name);
|
|
837
1212
|
}
|
|
838
1213
|
catch (err) {
|
|
839
1214
|
this.logger.error('请求sql函数列表失败', err);
|
|
840
1215
|
}
|
|
841
|
-
|
|
842
|
-
|
|
1216
|
+
this.logger.timeEnd('请求sql函数列表');
|
|
1217
|
+
// 等待 OQL2TS 请求
|
|
1218
|
+
this.logger.info("开始收集 OQL 并请求 OQL2TS 接口");
|
|
1219
|
+
this.logger.time('等待 OqlQuery 查询');
|
|
1220
|
+
await oqlQueryHandle;
|
|
1221
|
+
this.logger.timeEnd('等待 OqlQuery 查询');
|
|
843
1222
|
// 翻译 ts 文件
|
|
844
|
-
|
|
1223
|
+
this.logger.time('全量生成 TS——翻译');
|
|
1224
|
+
const results = self.flags.tssEnabled ? await utils.runGeneratorAsync(getAllTsFiles()) : [];
|
|
845
1225
|
const files = results.map((result) => ({
|
|
846
1226
|
file: result.filePath,
|
|
847
1227
|
fileContent: result.code,
|
|
848
1228
|
}));
|
|
849
1229
|
this.logger.timeEnd('全量生成 TS——翻译');
|
|
850
1230
|
this.logger.time('全量生成 TS——写入文件');
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
1231
|
+
if (self.flags.tssEnabled) {
|
|
1232
|
+
// 全量生成TS文件,因此清空版本记录
|
|
1233
|
+
files.forEach((f) => {
|
|
1234
|
+
this.diagnosticManager.deleteVersionByFilePath(f.file);
|
|
1235
|
+
});
|
|
1236
|
+
}
|
|
855
1237
|
// 添加 sql 函数签名文件
|
|
856
1238
|
this.sqlSignatureFiles.forEach((sqlFunction) => {
|
|
857
|
-
files.push(
|
|
1239
|
+
files.push(NaslServer.toRaw(sqlFunction));
|
|
858
1240
|
});
|
|
859
1241
|
await this.writeFiles(files);
|
|
860
1242
|
this._debugInFileStorage(app, files);
|
|
@@ -877,7 +1259,11 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
877
1259
|
const toEmbeddedTSUsedTime = toEmbeddedTSEndTime - toEmbeddedTSStartTime;
|
|
878
1260
|
app.naslServer.appPerfermenceData = app.naslServer.appPerfermenceData || {};
|
|
879
1261
|
app.naslServer.appPerfermenceData.toEmbeddedTSUsedTime = toEmbeddedTSUsedTime;
|
|
1262
|
+
console.time('wait-tss');
|
|
880
1263
|
function* getAllTsFiles() {
|
|
1264
|
+
if (!self.flags.tssEnabled) {
|
|
1265
|
+
return [];
|
|
1266
|
+
}
|
|
881
1267
|
const files = yield* self.contentToFile(app);
|
|
882
1268
|
const otherModules = [
|
|
883
1269
|
...app.integration?.connectors ?? [],
|
|
@@ -906,8 +1292,10 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
906
1292
|
// 刷新 ts 代码
|
|
907
1293
|
this.tsFiles.clear();
|
|
908
1294
|
await this.deleteDirectoryFiles({ directoryName: '/embedded' });
|
|
909
|
-
//
|
|
910
|
-
|
|
1295
|
+
// 清除check count的数量
|
|
1296
|
+
if (this.flags.tssEnabled) {
|
|
1297
|
+
await this.messager.requestCommand('_clearTimeout');
|
|
1298
|
+
}
|
|
911
1299
|
// 如果没传就用当前this的
|
|
912
1300
|
if (performance === undefined) {
|
|
913
1301
|
performance = this.performance;
|
|
@@ -922,6 +1310,9 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
922
1310
|
* 初始化之前添加文件
|
|
923
1311
|
*/
|
|
924
1312
|
addFile(file, { cache = false } = {}) {
|
|
1313
|
+
if (!this.flags.tssEnabled) {
|
|
1314
|
+
return Promise.resolve();
|
|
1315
|
+
}
|
|
925
1316
|
cache && this.cacheFile(file);
|
|
926
1317
|
this.tsFiles.set(file.file, file.fileContent);
|
|
927
1318
|
return this.messager.requestCommand('addFile', file);
|
|
@@ -935,6 +1326,9 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
935
1326
|
* @param {*} files
|
|
936
1327
|
*/
|
|
937
1328
|
writeFiles(files) {
|
|
1329
|
+
if (!this.flags.tssEnabled) {
|
|
1330
|
+
return Promise.resolve();
|
|
1331
|
+
}
|
|
938
1332
|
files.forEach(({ file, fileContent }) => this.tsFiles.set(file, fileContent));
|
|
939
1333
|
return this.messager.requestCommand('writeFiles', files);
|
|
940
1334
|
}
|
|
@@ -944,6 +1338,9 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
944
1338
|
* @param {*} args
|
|
945
1339
|
*/
|
|
946
1340
|
updateFiles(args) {
|
|
1341
|
+
if (!this.flags.tssEnabled) {
|
|
1342
|
+
return Promise.resolve();
|
|
1343
|
+
}
|
|
947
1344
|
args.outputFiles.forEach(({ file, fileContent }) => this.tsFiles.set(file, fileContent));
|
|
948
1345
|
return this.messager.requestCommand('updateFiles', args);
|
|
949
1346
|
}
|
|
@@ -951,6 +1348,9 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
951
1348
|
* 清除一个目录下的所有文件
|
|
952
1349
|
*/
|
|
953
1350
|
deleteDirectoryFiles(args) {
|
|
1351
|
+
if (!this.flags.tssEnabled) {
|
|
1352
|
+
return Promise.resolve();
|
|
1353
|
+
}
|
|
954
1354
|
Array.from(this.tsFiles.keys())
|
|
955
1355
|
.filter((key) => key.startsWith(args.directoryName))
|
|
956
1356
|
.forEach((key) => this.tsFiles.delete(key));
|
|
@@ -960,6 +1360,9 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
960
1360
|
return this._debugPutFilesByAppId('anonymous', files);
|
|
961
1361
|
}
|
|
962
1362
|
async _debugPutFilesByAppId(appId, openFiles) {
|
|
1363
|
+
if (!this.flags.tssEnabled) {
|
|
1364
|
+
return;
|
|
1365
|
+
}
|
|
963
1366
|
// 测试模式下跳过调试步骤
|
|
964
1367
|
if (process.env.NODE_ENV === 'testing' || !this.openDebugEmbedded) {
|
|
965
1368
|
this.openDebugEmbedded = false;
|
|
@@ -1013,16 +1416,25 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
1013
1416
|
return this.messager.requestCommand('open');
|
|
1014
1417
|
}
|
|
1015
1418
|
updateOpen(args) {
|
|
1419
|
+
if (!this.flags.tssEnabled) {
|
|
1420
|
+
return;
|
|
1421
|
+
}
|
|
1016
1422
|
return this.messager.requestCommand('updateOpen', args);
|
|
1017
1423
|
}
|
|
1018
1424
|
fileReferences(filePath) {
|
|
1425
|
+
if (!this.flags.tssEnabled) {
|
|
1426
|
+
return Promise.resolve([]);
|
|
1427
|
+
}
|
|
1019
1428
|
return this.messager.requestCommand('fileReferences', filePath);
|
|
1020
1429
|
}
|
|
1021
1430
|
async references(args) {
|
|
1431
|
+
if (!this.flags.tssEnabled) {
|
|
1432
|
+
return undefined;
|
|
1433
|
+
}
|
|
1022
1434
|
return (await this.messager.requestCommand('references', args))?.response;
|
|
1023
1435
|
}
|
|
1024
1436
|
getValueSelectCompletion(node, value, noFilterList) {
|
|
1025
|
-
const { currentSource, fileNode } =
|
|
1437
|
+
const { currentSource, fileNode } = NaslServer.getCurrentSource(node);
|
|
1026
1438
|
// this.logger.info(currentSource, fileNode);
|
|
1027
1439
|
if (currentSource && fileNode) {
|
|
1028
1440
|
return this._getValueSelectCompletion({
|
|
@@ -1038,6 +1450,9 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
1038
1450
|
this.logger.info('没找到节点', node, currentSource, fileNode);
|
|
1039
1451
|
}
|
|
1040
1452
|
_getValueSelectCompletion(args) {
|
|
1453
|
+
if (!this.flags.tssEnabled) {
|
|
1454
|
+
return Promise.resolve([]);
|
|
1455
|
+
}
|
|
1041
1456
|
return this.messager.requestCommand('getValueSelectCompletion', args);
|
|
1042
1457
|
}
|
|
1043
1458
|
async getDataSchemaStructureOrTypeAnnotation(node) {
|
|
@@ -1104,9 +1519,15 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
1104
1519
|
* @returns 查询到的
|
|
1105
1520
|
*/
|
|
1106
1521
|
_getTypeQuickinfo(args) {
|
|
1522
|
+
if (!this.flags.tssEnabled) {
|
|
1523
|
+
return Promise.resolve({ responseRequired: false, response: null });
|
|
1524
|
+
}
|
|
1107
1525
|
return this.messager.requestCommand('quickInfo', args);
|
|
1108
1526
|
}
|
|
1109
1527
|
_getQuickInfoFull(args) {
|
|
1528
|
+
if (!this.flags.tssEnabled) {
|
|
1529
|
+
return Promise.resolve({ responseRequired: false, response: [] });
|
|
1530
|
+
}
|
|
1110
1531
|
return this.messager.requestCommand('quickInfoFull', args);
|
|
1111
1532
|
}
|
|
1112
1533
|
/**
|
|
@@ -1120,9 +1541,15 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
1120
1541
|
return result;
|
|
1121
1542
|
}
|
|
1122
1543
|
_getTypeFull(args) {
|
|
1544
|
+
if (!this.flags.tssEnabled) {
|
|
1545
|
+
return Promise.resolve({ responseRequired: false, response: null });
|
|
1546
|
+
}
|
|
1123
1547
|
return this.messager.requestCommand('typeFull', args);
|
|
1124
1548
|
}
|
|
1125
1549
|
_getTypeBatch(args) {
|
|
1550
|
+
if (!this.flags.tssEnabled) {
|
|
1551
|
+
return Promise.resolve({ responseRequired: false, response: null });
|
|
1552
|
+
}
|
|
1126
1553
|
return this.messager.requestCommand('typeBatch', args);
|
|
1127
1554
|
}
|
|
1128
1555
|
async getNaslNodeTypeFull(args) {
|
|
@@ -1140,7 +1567,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
1140
1567
|
* @returns 可以选择的数据数组
|
|
1141
1568
|
*/
|
|
1142
1569
|
getSelectNextCompletion(node, noFilterList) {
|
|
1143
|
-
const { currentSource, fileNode } =
|
|
1570
|
+
const { currentSource, fileNode } = NaslServer.getCurrentSource(node);
|
|
1144
1571
|
// this.logger.info(currentSource, fileNode);
|
|
1145
1572
|
if (currentSource && fileNode) {
|
|
1146
1573
|
return this._getSelectNextCompletion({
|
|
@@ -1155,9 +1582,16 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
1155
1582
|
this.logger.info('没找到节点', currentSource, fileNode);
|
|
1156
1583
|
}
|
|
1157
1584
|
_getSelectNextCompletion(args) {
|
|
1585
|
+
if (!this.flags.tssEnabled) {
|
|
1586
|
+
return Promise.resolve([]);
|
|
1587
|
+
}
|
|
1158
1588
|
return this.messager.requestCommand('getSelectNextCompletion', args);
|
|
1159
1589
|
}
|
|
1160
1590
|
async getDiagnosticRecordsAndPushAllAndWaitPublishDiagnosticsEnd(fileNames) {
|
|
1591
|
+
if (!this.flags.tssEnabled) {
|
|
1592
|
+
await this.handlePublishDiagnostics({ data: { event: 'publishDiagnostics', records: [], versions: [] } });
|
|
1593
|
+
return [];
|
|
1594
|
+
}
|
|
1161
1595
|
await this.getDiagnosticRecordsAndPushAll(fileNames);
|
|
1162
1596
|
// 订阅 publishDiagnosticsEnd 主题,通知订阅者诊断流程已结束
|
|
1163
1597
|
return new Promise((resolve, reject) => {
|
|
@@ -1176,6 +1610,9 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
1176
1610
|
this.embeddedTSEmitter.emit('publishDiagnosticsEnd', tsDiagnostics);
|
|
1177
1611
|
}
|
|
1178
1612
|
getDiagnosticRecordsAndPushAll(fileNames) {
|
|
1613
|
+
if (!this.flags.tssEnabled) {
|
|
1614
|
+
return this.handlePublishDiagnostics({ data: { event: 'publishDiagnostics', records: [], versions: [] } });
|
|
1615
|
+
}
|
|
1179
1616
|
const versions = fileNames?.map((x) => {
|
|
1180
1617
|
return this.diagnosticManager.incrementVersionByFilePath(x);
|
|
1181
1618
|
});
|
|
@@ -1627,12 +2064,12 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
1627
2064
|
}
|
|
1628
2065
|
return result;
|
|
1629
2066
|
};
|
|
1630
|
-
const nd =
|
|
2067
|
+
const nd = NaslServer.toRaw(__node);
|
|
1631
2068
|
if (concepts_1.asserts.isDirectory(__node)) {
|
|
1632
2069
|
return [];
|
|
1633
2070
|
}
|
|
1634
2071
|
const { parentNode } = nd;
|
|
1635
|
-
const semEnv =
|
|
2072
|
+
const semEnv = NaslServer.toRaw(this.semEnv);
|
|
1636
2073
|
let result = wrapRefs(semEnv.refMgr.getReferences(semEnv, nd));
|
|
1637
2074
|
if (nd.concept === 'ProcessElementV2') {
|
|
1638
2075
|
const refMemAddrs = semEnv.refMgr.getProcessElementRefs(semEnv, nd);
|
|
@@ -1657,7 +2094,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
1657
2094
|
}
|
|
1658
2095
|
else if (nd.concept === 'Param' || nd.concept === 'ParamWithGroup') {
|
|
1659
2096
|
// 调用处的 keyword = XXX 等也要修改,所以查 Logic、View 等的引用
|
|
1660
|
-
const pNode =
|
|
2097
|
+
const pNode = NaslServer.toRaw(parentNode);
|
|
1661
2098
|
if ((0, service_1.isCallableNaslLogic)(pNode) || concepts_1.asserts.isStrictView(pNode)) {
|
|
1662
2099
|
const refs = semEnv.refMgr.getReferences(semEnv, pNode);
|
|
1663
2100
|
result.push(...wrapRefs(refs));
|
|
@@ -1695,7 +2132,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
1695
2132
|
* @returns 找到的引用
|
|
1696
2133
|
*/
|
|
1697
2134
|
_renamePrepare(__nd, refsList, newValue) {
|
|
1698
|
-
const nd =
|
|
2135
|
+
const nd = NaslServer.toRaw(__nd);
|
|
1699
2136
|
const oldName = nd?.name;
|
|
1700
2137
|
const result = refsList
|
|
1701
2138
|
.map((record) => {
|
|
@@ -2225,7 +2662,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
2225
2662
|
// 获取element方法的可选值
|
|
2226
2663
|
getFieldKeySelectCompletion(nd, fieldKey) {
|
|
2227
2664
|
console.warn('obsolete API');
|
|
2228
|
-
const { currentSource, fileNode } =
|
|
2665
|
+
const { currentSource, fileNode } = NaslServer.getCurrentSource(nd);
|
|
2229
2666
|
if (currentSource && fileNode) {
|
|
2230
2667
|
const range = {
|
|
2231
2668
|
line: (0, translator_1.lsp2tspNumber)(currentSource.start.line),
|
|
@@ -2249,8 +2686,11 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
2249
2686
|
}
|
|
2250
2687
|
}
|
|
2251
2688
|
getSlotCurrentCompletion(nd) {
|
|
2689
|
+
if (!this.flags.tssEnabled) {
|
|
2690
|
+
return Promise.resolve([]);
|
|
2691
|
+
}
|
|
2252
2692
|
console.warn('obsolete API');
|
|
2253
|
-
const { currentSource, fileNode } =
|
|
2693
|
+
const { currentSource, fileNode } = NaslServer.getCurrentSource(nd);
|
|
2254
2694
|
if (currentSource && fileNode) {
|
|
2255
2695
|
const range = {
|
|
2256
2696
|
line: (0, translator_1.lsp2tspNumber)(currentSource.start.line),
|
|
@@ -2267,6 +2707,9 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
2267
2707
|
}
|
|
2268
2708
|
}
|
|
2269
2709
|
_getFieldKeySelectCompletion(args) {
|
|
2710
|
+
if (!this.flags.tssEnabled) {
|
|
2711
|
+
return Promise.resolve([]);
|
|
2712
|
+
}
|
|
2270
2713
|
console.warn('obsolete API');
|
|
2271
2714
|
return this.messager.requestCommand('getFieldKeySelectCompletion', args);
|
|
2272
2715
|
}
|
|
@@ -2284,7 +2727,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
2284
2727
|
const item = oldInterfaces[i];
|
|
2285
2728
|
const refsList = await this._isHaveRef(item);
|
|
2286
2729
|
refsList.forEach(({ fileNode }) => {
|
|
2287
|
-
fileNodes.add(
|
|
2730
|
+
fileNodes.add(NaslServer.toRaw(fileNode));
|
|
2288
2731
|
});
|
|
2289
2732
|
}
|
|
2290
2733
|
return [...fileNodes];
|
|
@@ -2340,13 +2783,13 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
2340
2783
|
}
|
|
2341
2784
|
// Convert和new都是自身携带类型的,就不进行修改
|
|
2342
2785
|
if (node instanceof concepts_1.CallFunction && node.calleeNamespace === 'nasl.util' && ['Convert', 'New', 'FromString'].includes(node.calleeName)) {
|
|
2343
|
-
if (node.typeArguments
|
|
2786
|
+
if (node.typeArguments?.length) {
|
|
2344
2787
|
return node.typeArguments[0];
|
|
2345
2788
|
}
|
|
2346
2789
|
}
|
|
2347
2790
|
// Convert和new都是自身携带类型的,就不进行修改
|
|
2348
2791
|
if (node instanceof concepts_1.CallLogic && node.calleeNamespace === 'nasl.util' && node.calleeName === 'jsonDeserialize') {
|
|
2349
|
-
if (node.typeArguments
|
|
2792
|
+
if (node.typeArguments?.length) {
|
|
2350
2793
|
return node.typeArguments[0];
|
|
2351
2794
|
}
|
|
2352
2795
|
}
|
|
@@ -2839,9 +3282,14 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
2839
3282
|
else if ((!oldNd.typeAnnotation) && !nasl_language_server_core_1.ReferenceManager.defConcept.includes(oldNd.concept)) {
|
|
2840
3283
|
newJson.typeAnnotation = tyAnn;
|
|
2841
3284
|
}
|
|
3285
|
+
// Logic 需要 virtualParams 的类型标注
|
|
3286
|
+
else if (oldNd.concept === 'Logic' && oldNd.virtualParams?.length > 0) {
|
|
3287
|
+
// @ts-expect-error
|
|
3288
|
+
newJson.virtualParams = oldNd.virtualParams.map((param) => param?.toJSON());
|
|
3289
|
+
}
|
|
2842
3290
|
return newJson;
|
|
2843
3291
|
};
|
|
2844
|
-
const json =
|
|
3292
|
+
const json = NaslServer.toRaw(naslNode)._toJSON(doWork, preWork, postWork);
|
|
2845
3293
|
this.logger.timeEnd('app to AnnotatedJSON');
|
|
2846
3294
|
// 输出内存优化统计信息
|
|
2847
3295
|
const stats = (0, memory_optimization_1.getOptimizationStats)();
|
|
@@ -3192,6 +3640,9 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
3192
3640
|
return type;
|
|
3193
3641
|
}
|
|
3194
3642
|
_getTypeStrFull(args) {
|
|
3643
|
+
if (!this.flags.tssEnabled) {
|
|
3644
|
+
return undefined;
|
|
3645
|
+
}
|
|
3195
3646
|
return this.messager.requestCommand('typeStrFull', args);
|
|
3196
3647
|
}
|
|
3197
3648
|
async getNaslNodeTypeStrFull(args) {
|
|
@@ -3252,13 +3703,13 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
3252
3703
|
if (targetNode instanceof concepts_1.I18nInfo) {
|
|
3253
3704
|
return;
|
|
3254
3705
|
}
|
|
3255
|
-
|
|
3706
|
+
NaslServer.toRaw(this.originProxyTargetNodes).add(targetNode);
|
|
3256
3707
|
// FIXME: 验证完成后需要移除
|
|
3257
|
-
const { fileNode: fileNode2 } =
|
|
3708
|
+
const { fileNode: fileNode2 } = NaslServer.getCurrentSource(targetNode);
|
|
3258
3709
|
const fileNode = (0, service_1.getFileNode)(targetNode);
|
|
3259
|
-
const fileNodeRaw =
|
|
3260
|
-
fileNodeRaw !==
|
|
3261
|
-
const targetNodeRaw =
|
|
3710
|
+
const fileNodeRaw = NaslServer.toRaw(fileNode);
|
|
3711
|
+
fileNodeRaw !== NaslServer.toRaw(fileNode2) && console.log('\x1b[41m\x1b[97m☁️ handleAllChange 事件 fileNode 校验失败\x1b[0m');
|
|
3712
|
+
const targetNodeRaw = NaslServer.toRaw(targetNode);
|
|
3262
3713
|
// 处理定义节点或引用节点,更新 typerCheckFiles 和 typerRemoveNodes
|
|
3263
3714
|
let result = false;
|
|
3264
3715
|
if (nasl_language_server_core_1.ReferenceManager.defConcept.includes(targetNodeRaw.concept)) {
|
|
@@ -3398,7 +3849,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
3398
3849
|
return (this.tsFiles.get(fileNode.getEmbeddedFilePath()) ?? '').slice(range.start.offset, range.end.offset);
|
|
3399
3850
|
}
|
|
3400
3851
|
waitOqlQueryComponentChildrenFinish(node) {
|
|
3401
|
-
return (0, oql_cache_1.internalWaitOqlQueryComponentChildrenFinish)(
|
|
3852
|
+
return (0, oql_cache_1.internalWaitOqlQueryComponentChildrenFinish)(NaslServer.toRaw(node));
|
|
3402
3853
|
}
|
|
3403
3854
|
/** 关闭 metadataTypes 校验 */
|
|
3404
3855
|
async disableMetadataTypesCheck(app) {
|
|
@@ -3488,7 +3939,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
3488
3939
|
*/
|
|
3489
3940
|
getDirectRefFileNodes(node) {
|
|
3490
3941
|
const refList = this.semEnv.refMgr.getReferences(this.semEnv, node)
|
|
3491
|
-
.map((item) => (
|
|
3942
|
+
.map((item) => (NaslServer.toRaw((0, service_1.getFileNode)(item))))
|
|
3492
3943
|
.filter(Boolean);
|
|
3493
3944
|
return refList;
|
|
3494
3945
|
}
|
|
@@ -3497,7 +3948,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
3497
3948
|
if (!this.isFirstScreen) {
|
|
3498
3949
|
return;
|
|
3499
3950
|
}
|
|
3500
|
-
const rawApp =
|
|
3951
|
+
const rawApp = NaslServer.toRaw(this.getProxyApp());
|
|
3501
3952
|
// 使用增量标注的模块图建立初始引用关系图
|
|
3502
3953
|
// console.time('\x1b[44m\x1b[97m Build SymbolGraph \x1b[0m');
|
|
3503
3954
|
// @ts-ignore
|
|
@@ -3528,10 +3979,23 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
3528
3979
|
'nasl.processV2',
|
|
3529
3980
|
'nasl.http',
|
|
3530
3981
|
'nasl.logging',
|
|
3531
|
-
'nasl.configuration'
|
|
3982
|
+
'nasl.configuration',
|
|
3983
|
+
'nasl.core'].forEach(name => {
|
|
3532
3984
|
// @ts-expect-error
|
|
3533
3985
|
this.semEnv.refMgr.buildTsQNameDefs(this.semEnv, name, naslStdlibMap_1.default[`${name}.ts`]);
|
|
3534
3986
|
});
|
|
3987
|
+
if (!this.flags.tssEnabled) {
|
|
3988
|
+
console.debug("[NaslServer] 全局启用 NASL-OQL 类型检查");
|
|
3989
|
+
this.semEnv.enableCheckOQL();
|
|
3990
|
+
this.semEnv.refMgr.buildTsQNameDefs(this.semEnv, 'nasl.oql', oqlDefsStr);
|
|
3991
|
+
this.semEnv.refMgr.buildTsQNameDefs(this.semEnv, 'nasl.core', `
|
|
3992
|
+
declare namespace nasl.core {
|
|
3993
|
+
export function $InternalMerge<A, B>(a: A, b: B): nasl.core.InternalMergeType<A, B>;
|
|
3994
|
+
export function $InternalMergeUnary<A>(a: A): nasl.core.InternalMergeType<A>;
|
|
3995
|
+
${(0, nasl_language_server_core_1.createInternalArrayCode)(20)}
|
|
3996
|
+
}
|
|
3997
|
+
`);
|
|
3998
|
+
}
|
|
3535
3999
|
this.sqlSignatureFiles?.forEach(file => {
|
|
3536
4000
|
this.semEnv.refMgr.buildTsQNameDefs(this.semEnv, 'nasl.sqlFunction', file.fileContent);
|
|
3537
4001
|
});
|
|
@@ -3541,7 +4005,6 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
3541
4005
|
this.semEnv.refMgr.buildTsQNameDefs(this.semEnv, 'nasl.error', naslStdlibMap_1.default['nasl.error.ts']);
|
|
3542
4006
|
utils.isDebugMode && console.timeEnd('\x1b[44m\x1b[97m Collect All Global Definitions \x1b[0m');
|
|
3543
4007
|
// HACK wudengke 临时处理,要求组件库下完之后再进行类型检查
|
|
3544
|
-
(await this.inited)?.();
|
|
3545
4008
|
//@ts-ignore
|
|
3546
4009
|
globalThis.getTokenQualifiedName = nasl_language_server_core_1.getTokenQualifiedName;
|
|
3547
4010
|
// @ts-ignore
|
|
@@ -3573,7 +4036,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
3573
4036
|
// @ts-ignore
|
|
3574
4037
|
globalThis.checkNode = (node) => {
|
|
3575
4038
|
const { clearDiagnostics, checkNode, getDiagnostics } = this.semEnv.errorDiagnoser;
|
|
3576
|
-
const rawNode =
|
|
4039
|
+
const rawNode = NaslServer.toRaw(node);
|
|
3577
4040
|
clearDiagnostics(rawNode);
|
|
3578
4041
|
utils.runGeneratorAsync(checkNode(rawNode)).then(() => {
|
|
3579
4042
|
console.log(getDiagnostics(rawNode));
|
|
@@ -3581,7 +4044,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
3581
4044
|
};
|
|
3582
4045
|
// @ts-ignore
|
|
3583
4046
|
globalThis.getDiagnostics = (node) => {
|
|
3584
|
-
const rowNode =
|
|
4047
|
+
const rowNode = NaslServer.toRaw(node);
|
|
3585
4048
|
return this.semEnv.errorDiagnoser.getDiagnostics(rowNode);
|
|
3586
4049
|
};
|
|
3587
4050
|
}
|
|
@@ -3648,12 +4111,9 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
3648
4111
|
async getClient() {
|
|
3649
4112
|
return (0, nasl_server_client_1.getNaslServerClient)(this);
|
|
3650
4113
|
}
|
|
3651
|
-
}
|
|
4114
|
+
}
|
|
3652
4115
|
exports.NaslServer = NaslServer;
|
|
3653
4116
|
__decorate([
|
|
3654
4117
|
(0, decorators_1.withQueueExecute)('diagnostic')
|
|
3655
4118
|
], NaslServer.prototype, "_resolveDiagnosticRecords", null);
|
|
3656
|
-
exports.NaslServer = NaslServer = NaslServer_1 = __decorate([
|
|
3657
|
-
nasl_sentry_1.sentryMonitorNaslServer
|
|
3658
|
-
], NaslServer);
|
|
3659
4119
|
//# sourceMappingURL=naslServer.js.map
|