@lcap/nasl 4.3.0-beta.1 → 4.3.0-beta.4
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/server/OQL/oql-cache.d.ts.map +1 -1
- package/out/server/OQL/oql-cache.js +9 -2
- package/out/server/OQL/oql-cache.js.map +1 -1
- package/out/server/extendBaseNode.d.ts.map +1 -1
- package/out/server/extendBaseNode.js +33 -9
- 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 +553 -106
- package/out/server/naslServer.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 +24 -2
- package/out/service/storage/init.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/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 -4
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,102 @@ 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
|
-
sender: 'ide',
|
|
317
|
-
context: this,
|
|
318
|
-
timeout: 420000,
|
|
319
|
-
getReceiver: () => this.worker,
|
|
320
|
-
getSender: () => this.worker,
|
|
321
|
-
handleMessage: async ({ data }) => {
|
|
668
|
+
this.handlePublishDiagnostics =
|
|
669
|
+
async ({ data }) => {
|
|
322
670
|
if (!data || data.event !== 'publishDiagnostics') {
|
|
323
671
|
return;
|
|
324
672
|
}
|
|
673
|
+
console.debug(`[NaslServer] flags: ${JSON.stringify(this.flags ?? {})}`);
|
|
325
674
|
// getDiagnosticRecordsAndPushAll 最终通过 ts 回调走到这里
|
|
326
|
-
const tsDiagnostics = await this._resolveDiagnosticRecords(data.records, data.versions) ?? [];
|
|
675
|
+
const tsDiagnostics = this.flags.tssEnabled ? [] : await this._resolveDiagnosticRecords(data.records, data.versions) ?? [];
|
|
327
676
|
if (!this.isAnnotationMode) {
|
|
328
|
-
|
|
329
|
-
|
|
677
|
+
if (this.flags.tssEnabled) {
|
|
678
|
+
await utils.timeSlicingWithGenerator(this._incrementalAnnotationJSONWithGenerator(data.records));
|
|
679
|
+
}
|
|
330
680
|
if (this.isFirstScreen) {
|
|
331
681
|
// 首屏时,语言服务初始化
|
|
332
682
|
await this.languageServerInitiate();
|
|
333
683
|
}
|
|
684
|
+
console.log("等待uiTsInited");
|
|
685
|
+
(await this.uiTsInited)?.();
|
|
334
686
|
// 已经和 NASL 节点配对的诊断信息
|
|
335
687
|
const isProfileMode = this.flags.profileMode;
|
|
336
688
|
if (this.isFirstScreen) {
|
|
@@ -348,7 +700,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
348
700
|
console.profile('check');
|
|
349
701
|
}
|
|
350
702
|
let fixAllUseBeforeAssignTasks = [];
|
|
351
|
-
const rawApp =
|
|
703
|
+
const rawApp = NaslServer.toRaw(this.getProxyApp());
|
|
352
704
|
// 让事件逻辑显示出来
|
|
353
705
|
this._getAllElementLogicRoots();
|
|
354
706
|
try {
|
|
@@ -414,8 +766,20 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
414
766
|
this.firstScreenEndWork();
|
|
415
767
|
this.firstScreenEndWork = undefined;
|
|
416
768
|
}
|
|
417
|
-
}
|
|
418
|
-
|
|
769
|
+
};
|
|
770
|
+
// 只有在tssEnabled时才创建messager
|
|
771
|
+
if (this.flags.tssEnabled) {
|
|
772
|
+
this.messager = new Messager_1.default({
|
|
773
|
+
protocol: 'ts-worker',
|
|
774
|
+
sender: 'ide',
|
|
775
|
+
context: this,
|
|
776
|
+
timeout: 420000,
|
|
777
|
+
getReceiver: () => this.worker,
|
|
778
|
+
getSender: () => this.worker,
|
|
779
|
+
// @ts-expect-error FIXME 看不懂,等高人修复
|
|
780
|
+
handleMessage: this.handlePublishDiagnostics
|
|
781
|
+
});
|
|
782
|
+
}
|
|
419
783
|
// 监听所有改变操作
|
|
420
784
|
this.embeddedTSEmitter = new concepts_1.EventEmitter();
|
|
421
785
|
if (!this.isAnnotationMode) {
|
|
@@ -451,16 +815,16 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
451
815
|
return;
|
|
452
816
|
const changeNode = changeEvent.target;
|
|
453
817
|
// FIXME: 验证完成后需要移除
|
|
454
|
-
const { fileNode: fileNode2 } =
|
|
818
|
+
const { fileNode: fileNode2 } = NaslServer.getCurrentSource(changeNode);
|
|
455
819
|
const fileNode = (0, service_1.getFileNode)(changeNode);
|
|
456
|
-
if (
|
|
820
|
+
if (NaslServer.toRaw(fileNode) !== NaslServer.toRaw(fileNode2)) {
|
|
457
821
|
this.logger.error('\x1b[41m\x1b[97m ☁️ embeddedTSEmitter change 事件中计算不一致 \x1b[0m');
|
|
458
822
|
}
|
|
459
823
|
// 这个方法是 5.0 加入标准库的,但是这里 ts 版本是 4.x,ci 会挂,所以需要忽略
|
|
460
824
|
// @ts-ignore
|
|
461
825
|
const findLastIndex = this.changeStackList.findLastIndex((changeStackItem) => {
|
|
462
826
|
const { target } = changeStackItem;
|
|
463
|
-
const { fileNode: targetFileNode } =
|
|
827
|
+
const { fileNode: targetFileNode } = NaslServer.getCurrentSource(target);
|
|
464
828
|
return targetFileNode === fileNode;
|
|
465
829
|
});
|
|
466
830
|
// 如果当前找到了节点,而且节点在数组的最后一项,说明此次可以合并
|
|
@@ -513,10 +877,6 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
513
877
|
this.createUiTsArg0Copy = components;
|
|
514
878
|
this.createUiTsArg1Copy = options;
|
|
515
879
|
}
|
|
516
|
-
let resolve = undefined;
|
|
517
|
-
this.inited = new Promise((finish) => {
|
|
518
|
-
resolve = finish;
|
|
519
|
-
});
|
|
520
880
|
const { standardUIComponents, // 标准组件(带有ts类型定义文件的组件)
|
|
521
881
|
} = options;
|
|
522
882
|
Object.assign(allComponent, components);
|
|
@@ -542,16 +902,20 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
542
902
|
fileContent: convertTsCode(options.basicUITsCode),
|
|
543
903
|
};
|
|
544
904
|
// 基础组件
|
|
545
|
-
|
|
905
|
+
if (this.flags.tssEnabled) {
|
|
906
|
+
await this.addFile(naslUiComponentTsFile, { cache: true });
|
|
907
|
+
}
|
|
546
908
|
this._debugPutFilesInAnonymousApp([naslUiComponentTsFile]);
|
|
547
909
|
const extensionComponentFile = {
|
|
548
910
|
file: 'extension.component.ts',
|
|
549
911
|
fileContent: convertTsCode(options.withTypeLibraryTsCode),
|
|
550
912
|
};
|
|
551
913
|
// 带有类型的依赖库组件
|
|
552
|
-
|
|
914
|
+
if (this.flags.tssEnabled) {
|
|
915
|
+
await this.addFile(extensionComponentFile, { cache: true });
|
|
916
|
+
}
|
|
553
917
|
this._debugPutFilesInAnonymousApp([extensionComponentFile]);
|
|
554
|
-
|
|
918
|
+
this.uiTsInitedResolve(() => {
|
|
555
919
|
(0, nasl_language_server_core_1.parseTsFnToNaslQNameRefMaps)(this.semEnv.refMgr, naslUiComponentTsFile.fileContent);
|
|
556
920
|
if (extensionComponentFile.fileContent) {
|
|
557
921
|
(0, nasl_language_server_core_1.parseTsFnToNaslQNameRefMaps)(this.semEnv.refMgr, extensionComponentFile.fileContent);
|
|
@@ -568,12 +932,14 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
568
932
|
});
|
|
569
933
|
});
|
|
570
934
|
// 内置标准库类型
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
935
|
+
if (this.flags.tssEnabled) {
|
|
936
|
+
Object.keys(naslStdlibMap_1.default).forEach(async (libFileName) => {
|
|
937
|
+
await this.addFile({
|
|
938
|
+
file: `/${libFileName}`,
|
|
939
|
+
fileContent: naslStdlibMap_1.default[libFileName],
|
|
940
|
+
}, { cache: true });
|
|
941
|
+
});
|
|
942
|
+
}
|
|
577
943
|
this.elementsLogic = elementsLogic;
|
|
578
944
|
}
|
|
579
945
|
*contentToFile(module1) {
|
|
@@ -800,7 +1166,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
800
1166
|
value: () => app,
|
|
801
1167
|
configurable: true,
|
|
802
1168
|
});
|
|
803
|
-
const rawApp =
|
|
1169
|
+
const rawApp = NaslServer.toRaw(app);
|
|
804
1170
|
this.lsRunEnd = new Promise((resolve) => {
|
|
805
1171
|
this._lsRunEndSwitch = resolve;
|
|
806
1172
|
});
|
|
@@ -811,7 +1177,6 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
811
1177
|
await (0, initial_1.initialize)({ app, axios: this.http });
|
|
812
1178
|
this.logger.time('全量生成并写入 TS 文件——总计');
|
|
813
1179
|
const toEmbeddedTSStartTime = new Date().getTime();
|
|
814
|
-
this.logger.time('全量生成 TS——翻译');
|
|
815
1180
|
this.logger.time('全量生成 TS——翻译——简单语义分析');
|
|
816
1181
|
this.semData = new nasl_concepts_1.SemanticData();
|
|
817
1182
|
// 除此之外,好像没什么简单的方法可以让 __xxx.ts 文件快速拿到 app.naslServer 的引用了……
|
|
@@ -826,35 +1191,45 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
826
1191
|
notifyEndWork();
|
|
827
1192
|
};
|
|
828
1193
|
const self = this;
|
|
1194
|
+
this.logger.time('请求数据库配置列表');
|
|
829
1195
|
try {
|
|
830
1196
|
await this.requestDatabaseConfigs(this.http, app);
|
|
831
1197
|
}
|
|
832
1198
|
catch (err) {
|
|
833
1199
|
this.logger.error('请求数据库配置列表失败', err);
|
|
834
1200
|
}
|
|
1201
|
+
this.logger.timeEnd('请求数据库配置列表');
|
|
1202
|
+
this.logger.time('请求sql函数列表');
|
|
835
1203
|
try {
|
|
836
1204
|
this.sqlSignatureFiles = await this.requestSqlFunctions(this.http, app.name);
|
|
837
1205
|
}
|
|
838
1206
|
catch (err) {
|
|
839
1207
|
this.logger.error('请求sql函数列表失败', err);
|
|
840
1208
|
}
|
|
841
|
-
|
|
1209
|
+
this.logger.timeEnd('请求sql函数列表');
|
|
1210
|
+
// 等待 OQL2TS 请求
|
|
1211
|
+
this.logger.info("开始收集 OQL 并请求 OQL2TS 接口");
|
|
1212
|
+
this.logger.time('OQL2TS 查询');
|
|
842
1213
|
await this.waitOqlQueryComponentChildrenFinish(app);
|
|
1214
|
+
this.logger.timeEnd('OQL2TS 查询');
|
|
843
1215
|
// 翻译 ts 文件
|
|
844
|
-
|
|
1216
|
+
this.logger.time('全量生成 TS——翻译');
|
|
1217
|
+
const results = self.flags.tssEnabled ? await utils.runGeneratorAsync(getAllTsFiles()) : [];
|
|
845
1218
|
const files = results.map((result) => ({
|
|
846
1219
|
file: result.filePath,
|
|
847
1220
|
fileContent: result.code,
|
|
848
1221
|
}));
|
|
849
1222
|
this.logger.timeEnd('全量生成 TS——翻译');
|
|
850
1223
|
this.logger.time('全量生成 TS——写入文件');
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
1224
|
+
if (self.flags.tssEnabled) {
|
|
1225
|
+
// 全量生成TS文件,因此清空版本记录
|
|
1226
|
+
files.forEach((f) => {
|
|
1227
|
+
this.diagnosticManager.deleteVersionByFilePath(f.file);
|
|
1228
|
+
});
|
|
1229
|
+
}
|
|
855
1230
|
// 添加 sql 函数签名文件
|
|
856
1231
|
this.sqlSignatureFiles.forEach((sqlFunction) => {
|
|
857
|
-
files.push(
|
|
1232
|
+
files.push(NaslServer.toRaw(sqlFunction));
|
|
858
1233
|
});
|
|
859
1234
|
await this.writeFiles(files);
|
|
860
1235
|
this._debugInFileStorage(app, files);
|
|
@@ -878,6 +1253,9 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
878
1253
|
app.naslServer.appPerfermenceData = app.naslServer.appPerfermenceData || {};
|
|
879
1254
|
app.naslServer.appPerfermenceData.toEmbeddedTSUsedTime = toEmbeddedTSUsedTime;
|
|
880
1255
|
function* getAllTsFiles() {
|
|
1256
|
+
if (!self.flags.tssEnabled) {
|
|
1257
|
+
return [];
|
|
1258
|
+
}
|
|
881
1259
|
const files = yield* self.contentToFile(app);
|
|
882
1260
|
const otherModules = [
|
|
883
1261
|
...app.integration?.connectors ?? [],
|
|
@@ -906,8 +1284,10 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
906
1284
|
// 刷新 ts 代码
|
|
907
1285
|
this.tsFiles.clear();
|
|
908
1286
|
await this.deleteDirectoryFiles({ directoryName: '/embedded' });
|
|
909
|
-
//
|
|
910
|
-
|
|
1287
|
+
// 清除check count的数量
|
|
1288
|
+
if (this.flags.tssEnabled) {
|
|
1289
|
+
await this.messager.requestCommand('_clearTimeout');
|
|
1290
|
+
}
|
|
911
1291
|
// 如果没传就用当前this的
|
|
912
1292
|
if (performance === undefined) {
|
|
913
1293
|
performance = this.performance;
|
|
@@ -922,6 +1302,9 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
922
1302
|
* 初始化之前添加文件
|
|
923
1303
|
*/
|
|
924
1304
|
addFile(file, { cache = false } = {}) {
|
|
1305
|
+
if (!this.flags.tssEnabled) {
|
|
1306
|
+
return Promise.resolve();
|
|
1307
|
+
}
|
|
925
1308
|
cache && this.cacheFile(file);
|
|
926
1309
|
this.tsFiles.set(file.file, file.fileContent);
|
|
927
1310
|
return this.messager.requestCommand('addFile', file);
|
|
@@ -935,6 +1318,9 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
935
1318
|
* @param {*} files
|
|
936
1319
|
*/
|
|
937
1320
|
writeFiles(files) {
|
|
1321
|
+
if (!this.flags.tssEnabled) {
|
|
1322
|
+
return Promise.resolve();
|
|
1323
|
+
}
|
|
938
1324
|
files.forEach(({ file, fileContent }) => this.tsFiles.set(file, fileContent));
|
|
939
1325
|
return this.messager.requestCommand('writeFiles', files);
|
|
940
1326
|
}
|
|
@@ -944,6 +1330,9 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
944
1330
|
* @param {*} args
|
|
945
1331
|
*/
|
|
946
1332
|
updateFiles(args) {
|
|
1333
|
+
if (!this.flags.tssEnabled) {
|
|
1334
|
+
return Promise.resolve();
|
|
1335
|
+
}
|
|
947
1336
|
args.outputFiles.forEach(({ file, fileContent }) => this.tsFiles.set(file, fileContent));
|
|
948
1337
|
return this.messager.requestCommand('updateFiles', args);
|
|
949
1338
|
}
|
|
@@ -951,6 +1340,9 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
951
1340
|
* 清除一个目录下的所有文件
|
|
952
1341
|
*/
|
|
953
1342
|
deleteDirectoryFiles(args) {
|
|
1343
|
+
if (!this.flags.tssEnabled) {
|
|
1344
|
+
return Promise.resolve();
|
|
1345
|
+
}
|
|
954
1346
|
Array.from(this.tsFiles.keys())
|
|
955
1347
|
.filter((key) => key.startsWith(args.directoryName))
|
|
956
1348
|
.forEach((key) => this.tsFiles.delete(key));
|
|
@@ -960,6 +1352,9 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
960
1352
|
return this._debugPutFilesByAppId('anonymous', files);
|
|
961
1353
|
}
|
|
962
1354
|
async _debugPutFilesByAppId(appId, openFiles) {
|
|
1355
|
+
if (!this.flags.tssEnabled) {
|
|
1356
|
+
return;
|
|
1357
|
+
}
|
|
963
1358
|
// 测试模式下跳过调试步骤
|
|
964
1359
|
if (process.env.NODE_ENV === 'testing' || !this.openDebugEmbedded) {
|
|
965
1360
|
this.openDebugEmbedded = false;
|
|
@@ -1013,16 +1408,25 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
1013
1408
|
return this.messager.requestCommand('open');
|
|
1014
1409
|
}
|
|
1015
1410
|
updateOpen(args) {
|
|
1411
|
+
if (!this.flags.tssEnabled) {
|
|
1412
|
+
return;
|
|
1413
|
+
}
|
|
1016
1414
|
return this.messager.requestCommand('updateOpen', args);
|
|
1017
1415
|
}
|
|
1018
1416
|
fileReferences(filePath) {
|
|
1417
|
+
if (!this.flags.tssEnabled) {
|
|
1418
|
+
return Promise.resolve([]);
|
|
1419
|
+
}
|
|
1019
1420
|
return this.messager.requestCommand('fileReferences', filePath);
|
|
1020
1421
|
}
|
|
1021
1422
|
async references(args) {
|
|
1423
|
+
if (!this.flags.tssEnabled) {
|
|
1424
|
+
return undefined;
|
|
1425
|
+
}
|
|
1022
1426
|
return (await this.messager.requestCommand('references', args))?.response;
|
|
1023
1427
|
}
|
|
1024
1428
|
getValueSelectCompletion(node, value, noFilterList) {
|
|
1025
|
-
const { currentSource, fileNode } =
|
|
1429
|
+
const { currentSource, fileNode } = NaslServer.getCurrentSource(node);
|
|
1026
1430
|
// this.logger.info(currentSource, fileNode);
|
|
1027
1431
|
if (currentSource && fileNode) {
|
|
1028
1432
|
return this._getValueSelectCompletion({
|
|
@@ -1038,6 +1442,9 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
1038
1442
|
this.logger.info('没找到节点', node, currentSource, fileNode);
|
|
1039
1443
|
}
|
|
1040
1444
|
_getValueSelectCompletion(args) {
|
|
1445
|
+
if (!this.flags.tssEnabled) {
|
|
1446
|
+
return Promise.resolve([]);
|
|
1447
|
+
}
|
|
1041
1448
|
return this.messager.requestCommand('getValueSelectCompletion', args);
|
|
1042
1449
|
}
|
|
1043
1450
|
async getDataSchemaStructureOrTypeAnnotation(node) {
|
|
@@ -1104,9 +1511,15 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
1104
1511
|
* @returns 查询到的
|
|
1105
1512
|
*/
|
|
1106
1513
|
_getTypeQuickinfo(args) {
|
|
1514
|
+
if (!this.flags.tssEnabled) {
|
|
1515
|
+
return Promise.resolve({ responseRequired: false, response: null });
|
|
1516
|
+
}
|
|
1107
1517
|
return this.messager.requestCommand('quickInfo', args);
|
|
1108
1518
|
}
|
|
1109
1519
|
_getQuickInfoFull(args) {
|
|
1520
|
+
if (!this.flags.tssEnabled) {
|
|
1521
|
+
return Promise.resolve({ responseRequired: false, response: [] });
|
|
1522
|
+
}
|
|
1110
1523
|
return this.messager.requestCommand('quickInfoFull', args);
|
|
1111
1524
|
}
|
|
1112
1525
|
/**
|
|
@@ -1120,9 +1533,15 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
1120
1533
|
return result;
|
|
1121
1534
|
}
|
|
1122
1535
|
_getTypeFull(args) {
|
|
1536
|
+
if (!this.flags.tssEnabled) {
|
|
1537
|
+
return Promise.resolve({ responseRequired: false, response: null });
|
|
1538
|
+
}
|
|
1123
1539
|
return this.messager.requestCommand('typeFull', args);
|
|
1124
1540
|
}
|
|
1125
1541
|
_getTypeBatch(args) {
|
|
1542
|
+
if (!this.flags.tssEnabled) {
|
|
1543
|
+
return Promise.resolve({ responseRequired: false, response: null });
|
|
1544
|
+
}
|
|
1126
1545
|
return this.messager.requestCommand('typeBatch', args);
|
|
1127
1546
|
}
|
|
1128
1547
|
async getNaslNodeTypeFull(args) {
|
|
@@ -1140,7 +1559,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
1140
1559
|
* @returns 可以选择的数据数组
|
|
1141
1560
|
*/
|
|
1142
1561
|
getSelectNextCompletion(node, noFilterList) {
|
|
1143
|
-
const { currentSource, fileNode } =
|
|
1562
|
+
const { currentSource, fileNode } = NaslServer.getCurrentSource(node);
|
|
1144
1563
|
// this.logger.info(currentSource, fileNode);
|
|
1145
1564
|
if (currentSource && fileNode) {
|
|
1146
1565
|
return this._getSelectNextCompletion({
|
|
@@ -1155,9 +1574,16 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
1155
1574
|
this.logger.info('没找到节点', currentSource, fileNode);
|
|
1156
1575
|
}
|
|
1157
1576
|
_getSelectNextCompletion(args) {
|
|
1577
|
+
if (!this.flags.tssEnabled) {
|
|
1578
|
+
return Promise.resolve([]);
|
|
1579
|
+
}
|
|
1158
1580
|
return this.messager.requestCommand('getSelectNextCompletion', args);
|
|
1159
1581
|
}
|
|
1160
1582
|
async getDiagnosticRecordsAndPushAllAndWaitPublishDiagnosticsEnd(fileNames) {
|
|
1583
|
+
if (!this.flags.tssEnabled) {
|
|
1584
|
+
await this.handlePublishDiagnostics({ data: { event: 'publishDiagnostics', records: [], versions: [] } });
|
|
1585
|
+
return [];
|
|
1586
|
+
}
|
|
1161
1587
|
await this.getDiagnosticRecordsAndPushAll(fileNames);
|
|
1162
1588
|
// 订阅 publishDiagnosticsEnd 主题,通知订阅者诊断流程已结束
|
|
1163
1589
|
return new Promise((resolve, reject) => {
|
|
@@ -1176,6 +1602,9 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
1176
1602
|
this.embeddedTSEmitter.emit('publishDiagnosticsEnd', tsDiagnostics);
|
|
1177
1603
|
}
|
|
1178
1604
|
getDiagnosticRecordsAndPushAll(fileNames) {
|
|
1605
|
+
if (!this.flags.tssEnabled) {
|
|
1606
|
+
return this.handlePublishDiagnostics({ data: { event: 'publishDiagnostics', records: [], versions: [] } });
|
|
1607
|
+
}
|
|
1179
1608
|
const versions = fileNames?.map((x) => {
|
|
1180
1609
|
return this.diagnosticManager.incrementVersionByFilePath(x);
|
|
1181
1610
|
});
|
|
@@ -1627,12 +2056,12 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
1627
2056
|
}
|
|
1628
2057
|
return result;
|
|
1629
2058
|
};
|
|
1630
|
-
const nd =
|
|
2059
|
+
const nd = NaslServer.toRaw(__node);
|
|
1631
2060
|
if (concepts_1.asserts.isDirectory(__node)) {
|
|
1632
2061
|
return [];
|
|
1633
2062
|
}
|
|
1634
2063
|
const { parentNode } = nd;
|
|
1635
|
-
const semEnv =
|
|
2064
|
+
const semEnv = NaslServer.toRaw(this.semEnv);
|
|
1636
2065
|
let result = wrapRefs(semEnv.refMgr.getReferences(semEnv, nd));
|
|
1637
2066
|
if (nd.concept === 'ProcessElementV2') {
|
|
1638
2067
|
const refMemAddrs = semEnv.refMgr.getProcessElementRefs(semEnv, nd);
|
|
@@ -1657,7 +2086,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
1657
2086
|
}
|
|
1658
2087
|
else if (nd.concept === 'Param' || nd.concept === 'ParamWithGroup') {
|
|
1659
2088
|
// 调用处的 keyword = XXX 等也要修改,所以查 Logic、View 等的引用
|
|
1660
|
-
const pNode =
|
|
2089
|
+
const pNode = NaslServer.toRaw(parentNode);
|
|
1661
2090
|
if ((0, service_1.isCallableNaslLogic)(pNode) || concepts_1.asserts.isStrictView(pNode)) {
|
|
1662
2091
|
const refs = semEnv.refMgr.getReferences(semEnv, pNode);
|
|
1663
2092
|
result.push(...wrapRefs(refs));
|
|
@@ -1695,7 +2124,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
1695
2124
|
* @returns 找到的引用
|
|
1696
2125
|
*/
|
|
1697
2126
|
_renamePrepare(__nd, refsList, newValue) {
|
|
1698
|
-
const nd =
|
|
2127
|
+
const nd = NaslServer.toRaw(__nd);
|
|
1699
2128
|
const oldName = nd?.name;
|
|
1700
2129
|
const result = refsList
|
|
1701
2130
|
.map((record) => {
|
|
@@ -2225,7 +2654,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
2225
2654
|
// 获取element方法的可选值
|
|
2226
2655
|
getFieldKeySelectCompletion(nd, fieldKey) {
|
|
2227
2656
|
console.warn('obsolete API');
|
|
2228
|
-
const { currentSource, fileNode } =
|
|
2657
|
+
const { currentSource, fileNode } = NaslServer.getCurrentSource(nd);
|
|
2229
2658
|
if (currentSource && fileNode) {
|
|
2230
2659
|
const range = {
|
|
2231
2660
|
line: (0, translator_1.lsp2tspNumber)(currentSource.start.line),
|
|
@@ -2249,8 +2678,11 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
2249
2678
|
}
|
|
2250
2679
|
}
|
|
2251
2680
|
getSlotCurrentCompletion(nd) {
|
|
2681
|
+
if (!this.flags.tssEnabled) {
|
|
2682
|
+
return Promise.resolve([]);
|
|
2683
|
+
}
|
|
2252
2684
|
console.warn('obsolete API');
|
|
2253
|
-
const { currentSource, fileNode } =
|
|
2685
|
+
const { currentSource, fileNode } = NaslServer.getCurrentSource(nd);
|
|
2254
2686
|
if (currentSource && fileNode) {
|
|
2255
2687
|
const range = {
|
|
2256
2688
|
line: (0, translator_1.lsp2tspNumber)(currentSource.start.line),
|
|
@@ -2267,6 +2699,9 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
2267
2699
|
}
|
|
2268
2700
|
}
|
|
2269
2701
|
_getFieldKeySelectCompletion(args) {
|
|
2702
|
+
if (!this.flags.tssEnabled) {
|
|
2703
|
+
return Promise.resolve([]);
|
|
2704
|
+
}
|
|
2270
2705
|
console.warn('obsolete API');
|
|
2271
2706
|
return this.messager.requestCommand('getFieldKeySelectCompletion', args);
|
|
2272
2707
|
}
|
|
@@ -2284,7 +2719,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
2284
2719
|
const item = oldInterfaces[i];
|
|
2285
2720
|
const refsList = await this._isHaveRef(item);
|
|
2286
2721
|
refsList.forEach(({ fileNode }) => {
|
|
2287
|
-
fileNodes.add(
|
|
2722
|
+
fileNodes.add(NaslServer.toRaw(fileNode));
|
|
2288
2723
|
});
|
|
2289
2724
|
}
|
|
2290
2725
|
return [...fileNodes];
|
|
@@ -2340,13 +2775,13 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
2340
2775
|
}
|
|
2341
2776
|
// Convert和new都是自身携带类型的,就不进行修改
|
|
2342
2777
|
if (node instanceof concepts_1.CallFunction && node.calleeNamespace === 'nasl.util' && ['Convert', 'New', 'FromString'].includes(node.calleeName)) {
|
|
2343
|
-
if (node.typeArguments
|
|
2778
|
+
if (node.typeArguments?.length) {
|
|
2344
2779
|
return node.typeArguments[0];
|
|
2345
2780
|
}
|
|
2346
2781
|
}
|
|
2347
2782
|
// Convert和new都是自身携带类型的,就不进行修改
|
|
2348
2783
|
if (node instanceof concepts_1.CallLogic && node.calleeNamespace === 'nasl.util' && node.calleeName === 'jsonDeserialize') {
|
|
2349
|
-
if (node.typeArguments
|
|
2784
|
+
if (node.typeArguments?.length) {
|
|
2350
2785
|
return node.typeArguments[0];
|
|
2351
2786
|
}
|
|
2352
2787
|
}
|
|
@@ -2841,7 +3276,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
2841
3276
|
}
|
|
2842
3277
|
return newJson;
|
|
2843
3278
|
};
|
|
2844
|
-
const json =
|
|
3279
|
+
const json = NaslServer.toRaw(naslNode)._toJSON(doWork, preWork, postWork);
|
|
2845
3280
|
this.logger.timeEnd('app to AnnotatedJSON');
|
|
2846
3281
|
// 输出内存优化统计信息
|
|
2847
3282
|
const stats = (0, memory_optimization_1.getOptimizationStats)();
|
|
@@ -3192,6 +3627,9 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
3192
3627
|
return type;
|
|
3193
3628
|
}
|
|
3194
3629
|
_getTypeStrFull(args) {
|
|
3630
|
+
if (!this.flags.tssEnabled) {
|
|
3631
|
+
return undefined;
|
|
3632
|
+
}
|
|
3195
3633
|
return this.messager.requestCommand('typeStrFull', args);
|
|
3196
3634
|
}
|
|
3197
3635
|
async getNaslNodeTypeStrFull(args) {
|
|
@@ -3252,13 +3690,13 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
3252
3690
|
if (targetNode instanceof concepts_1.I18nInfo) {
|
|
3253
3691
|
return;
|
|
3254
3692
|
}
|
|
3255
|
-
|
|
3693
|
+
NaslServer.toRaw(this.originProxyTargetNodes).add(targetNode);
|
|
3256
3694
|
// FIXME: 验证完成后需要移除
|
|
3257
|
-
const { fileNode: fileNode2 } =
|
|
3695
|
+
const { fileNode: fileNode2 } = NaslServer.getCurrentSource(targetNode);
|
|
3258
3696
|
const fileNode = (0, service_1.getFileNode)(targetNode);
|
|
3259
|
-
const fileNodeRaw =
|
|
3260
|
-
fileNodeRaw !==
|
|
3261
|
-
const targetNodeRaw =
|
|
3697
|
+
const fileNodeRaw = NaslServer.toRaw(fileNode);
|
|
3698
|
+
fileNodeRaw !== NaslServer.toRaw(fileNode2) && console.log('\x1b[41m\x1b[97m☁️ handleAllChange 事件 fileNode 校验失败\x1b[0m');
|
|
3699
|
+
const targetNodeRaw = NaslServer.toRaw(targetNode);
|
|
3262
3700
|
// 处理定义节点或引用节点,更新 typerCheckFiles 和 typerRemoveNodes
|
|
3263
3701
|
let result = false;
|
|
3264
3702
|
if (nasl_language_server_core_1.ReferenceManager.defConcept.includes(targetNodeRaw.concept)) {
|
|
@@ -3398,7 +3836,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
3398
3836
|
return (this.tsFiles.get(fileNode.getEmbeddedFilePath()) ?? '').slice(range.start.offset, range.end.offset);
|
|
3399
3837
|
}
|
|
3400
3838
|
waitOqlQueryComponentChildrenFinish(node) {
|
|
3401
|
-
return (0, oql_cache_1.internalWaitOqlQueryComponentChildrenFinish)(
|
|
3839
|
+
return (0, oql_cache_1.internalWaitOqlQueryComponentChildrenFinish)(NaslServer.toRaw(node));
|
|
3402
3840
|
}
|
|
3403
3841
|
/** 关闭 metadataTypes 校验 */
|
|
3404
3842
|
async disableMetadataTypesCheck(app) {
|
|
@@ -3488,7 +3926,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
3488
3926
|
*/
|
|
3489
3927
|
getDirectRefFileNodes(node) {
|
|
3490
3928
|
const refList = this.semEnv.refMgr.getReferences(this.semEnv, node)
|
|
3491
|
-
.map((item) => (
|
|
3929
|
+
.map((item) => (NaslServer.toRaw((0, service_1.getFileNode)(item))))
|
|
3492
3930
|
.filter(Boolean);
|
|
3493
3931
|
return refList;
|
|
3494
3932
|
}
|
|
@@ -3497,7 +3935,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
3497
3935
|
if (!this.isFirstScreen) {
|
|
3498
3936
|
return;
|
|
3499
3937
|
}
|
|
3500
|
-
const rawApp =
|
|
3938
|
+
const rawApp = NaslServer.toRaw(this.getProxyApp());
|
|
3501
3939
|
// 使用增量标注的模块图建立初始引用关系图
|
|
3502
3940
|
// console.time('\x1b[44m\x1b[97m Build SymbolGraph \x1b[0m');
|
|
3503
3941
|
// @ts-ignore
|
|
@@ -3528,10 +3966,23 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
3528
3966
|
'nasl.processV2',
|
|
3529
3967
|
'nasl.http',
|
|
3530
3968
|
'nasl.logging',
|
|
3531
|
-
'nasl.configuration'
|
|
3969
|
+
'nasl.configuration',
|
|
3970
|
+
'nasl.core'].forEach(name => {
|
|
3532
3971
|
// @ts-expect-error
|
|
3533
3972
|
this.semEnv.refMgr.buildTsQNameDefs(this.semEnv, name, naslStdlibMap_1.default[`${name}.ts`]);
|
|
3534
3973
|
});
|
|
3974
|
+
if (!this.flags.tssEnabled) {
|
|
3975
|
+
console.info("[NaslServer] 全局启用 NASL-OQL 类型检查");
|
|
3976
|
+
this.semEnv.enableCheckOQL();
|
|
3977
|
+
this.semEnv.refMgr.buildTsQNameDefs(this.semEnv, 'nasl.oql', oqlDefsStr);
|
|
3978
|
+
this.semEnv.refMgr.buildTsQNameDefs(this.semEnv, 'nasl.core', `
|
|
3979
|
+
declare namespace nasl.core {
|
|
3980
|
+
export function $InternalMerge<A, B>(a: A, b: B): nasl.core.InternalMergeType<A, B>;
|
|
3981
|
+
export function $InternalMergeUnary<A>(a: A): nasl.core.InternalMergeType<A>;
|
|
3982
|
+
${(0, nasl_language_server_core_1.createInternalArrayCode)(20)}
|
|
3983
|
+
}
|
|
3984
|
+
`);
|
|
3985
|
+
}
|
|
3535
3986
|
this.sqlSignatureFiles?.forEach(file => {
|
|
3536
3987
|
this.semEnv.refMgr.buildTsQNameDefs(this.semEnv, 'nasl.sqlFunction', file.fileContent);
|
|
3537
3988
|
});
|
|
@@ -3541,7 +3992,6 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
3541
3992
|
this.semEnv.refMgr.buildTsQNameDefs(this.semEnv, 'nasl.error', naslStdlibMap_1.default['nasl.error.ts']);
|
|
3542
3993
|
utils.isDebugMode && console.timeEnd('\x1b[44m\x1b[97m Collect All Global Definitions \x1b[0m');
|
|
3543
3994
|
// HACK wudengke 临时处理,要求组件库下完之后再进行类型检查
|
|
3544
|
-
(await this.inited)?.();
|
|
3545
3995
|
//@ts-ignore
|
|
3546
3996
|
globalThis.getTokenQualifiedName = nasl_language_server_core_1.getTokenQualifiedName;
|
|
3547
3997
|
// @ts-ignore
|
|
@@ -3573,7 +4023,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
3573
4023
|
// @ts-ignore
|
|
3574
4024
|
globalThis.checkNode = (node) => {
|
|
3575
4025
|
const { clearDiagnostics, checkNode, getDiagnostics } = this.semEnv.errorDiagnoser;
|
|
3576
|
-
const rawNode =
|
|
4026
|
+
const rawNode = NaslServer.toRaw(node);
|
|
3577
4027
|
clearDiagnostics(rawNode);
|
|
3578
4028
|
utils.runGeneratorAsync(checkNode(rawNode)).then(() => {
|
|
3579
4029
|
console.log(getDiagnostics(rawNode));
|
|
@@ -3581,7 +4031,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
3581
4031
|
};
|
|
3582
4032
|
// @ts-ignore
|
|
3583
4033
|
globalThis.getDiagnostics = (node) => {
|
|
3584
|
-
const rowNode =
|
|
4034
|
+
const rowNode = NaslServer.toRaw(node);
|
|
3585
4035
|
return this.semEnv.errorDiagnoser.getDiagnostics(rowNode);
|
|
3586
4036
|
};
|
|
3587
4037
|
}
|
|
@@ -3648,12 +4098,9 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
3648
4098
|
async getClient() {
|
|
3649
4099
|
return (0, nasl_server_client_1.getNaslServerClient)(this);
|
|
3650
4100
|
}
|
|
3651
|
-
}
|
|
4101
|
+
}
|
|
3652
4102
|
exports.NaslServer = NaslServer;
|
|
3653
4103
|
__decorate([
|
|
3654
4104
|
(0, decorators_1.withQueueExecute)('diagnostic')
|
|
3655
4105
|
], NaslServer.prototype, "_resolveDiagnosticRecords", null);
|
|
3656
|
-
exports.NaslServer = NaslServer = NaslServer_1 = __decorate([
|
|
3657
|
-
nasl_sentry_1.sentryMonitorNaslServer
|
|
3658
|
-
], NaslServer);
|
|
3659
4106
|
//# sourceMappingURL=naslServer.js.map
|