@nasl/types 0.1.0 → 0.1.2

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/nasl.ui.ast.d.ts CHANGED
@@ -114,6 +114,7 @@ export interface PropDeclaration {
114
114
  bindOpen: boolean;
115
115
  tabKind: 'property' | 'style';
116
116
  setter: BaseSetter;
117
+ defaultValue?: DefaultValue;
117
118
  tsDesignerValue?: string;
118
119
  tsIf?: string;
119
120
  tsDisabledIf?: string;
@@ -153,29 +154,50 @@ export interface LogicDeclaration {
153
154
  title: string;
154
155
  description: string;
155
156
  typeParams?: Array<TypeParam>;
156
- params: Array<ParamDeclaration>;
157
+ params: Array<Param>;
157
158
  returns: Array<Return>;
158
159
  }
159
160
 
160
161
  /**
161
- * 输入参数声明
162
+ * 空字面量
162
163
  */
163
- export interface ParamDeclaration {
164
- concept: 'ParamDeclaration';
165
- name: string;
166
- title: string;
167
- description: string;
168
- tsType: string;
164
+ export interface NullLiteral {
165
+ concept: 'NullLiteral';
166
+
169
167
  }
170
168
 
171
169
  /**
172
- * 输出参数声明
170
+ * 布尔型字面量
173
171
  */
174
- export interface ReturnDeclaration {
175
- concept: 'ReturnDeclaration';
176
- name: string;
177
- description: string;
178
- tsType: string;
172
+ export interface BooleanLiteral {
173
+ concept: 'BooleanLiteral';
174
+ value: string;
175
+ }
176
+
177
+ /**
178
+ * 字符串字面量
179
+ */
180
+ export interface StringLiteral {
181
+ concept: 'StringLiteral';
182
+ value: string;
183
+ }
184
+
185
+ /**
186
+ * 数字字面量
187
+ */
188
+ export interface NumericLiteral {
189
+ concept: 'NumericLiteral';
190
+ value: string;
191
+ typeAnnotation: TypeAnnotation;
192
+ }
193
+
194
+ /**
195
+ * 列表构造器
196
+ */
197
+ export interface NewList {
198
+ concept: 'NewList';
199
+ typeAnnotation: TypeAnnotation;
200
+ items: Array<LogicItem>;
179
201
  }
180
202
 
181
203
  /**
@@ -221,6 +243,20 @@ export interface ThemeVariable {
221
243
  name: string;
222
244
  }
223
245
 
246
+ /**
247
+ * 默认值
248
+ */
249
+ export interface DefaultValue {
250
+ concept: 'DefaultValue';
251
+ expression: LogicItem;
252
+ playground: Array<LogicItem>;
253
+ }
254
+
255
+ /**
256
+ * 设置器基类
257
+ */
258
+ export type LogicItem = NullLiteral | BooleanLiteral | StringLiteral | NumericLiteral | NewList;
259
+
224
260
  /**
225
261
  * 类型参数
226
262
  */
@@ -230,14 +266,14 @@ export interface TypeParam {
230
266
  }
231
267
 
232
268
  /**
233
- * 输出参数
269
+ * 输入参数
234
270
  */
235
- export interface Return {
236
- concept: 'Return';
271
+ export interface Param {
272
+ concept: 'Param';
237
273
  name: string;
238
274
  description: string;
239
275
  typeAnnotation: TypeAnnotation;
240
- defaultValue: DefaultValue;
276
+ defaultValue?: DefaultValue;
241
277
  }
242
278
 
243
279
  /**
@@ -264,30 +300,19 @@ export interface StructureProperty {
264
300
  label: string;
265
301
  description: string;
266
302
  typeAnnotation: TypeAnnotation;
267
- required: boolean;
268
303
  defaultValue: DefaultValue;
269
304
  jsonName: string;
270
305
  }
271
306
 
272
307
  /**
273
- * 默认值
274
- */
275
- export interface DefaultValue {
276
- concept: 'DefaultValue';
277
- expression: LogicItem;
278
- playground: Array<LogicItem>;
279
- }
280
-
281
- /**
282
- * 逻辑项
308
+ * 输出参数
283
309
  */
284
- export interface LogicItem {
285
- concept: 'LogicItem';
286
- label?: string;
287
- description?: string;
288
- folded?: boolean;
289
- offsetX?: number;
290
- offsetY?: number;
310
+ export interface Return {
311
+ concept: 'Return';
312
+ name: string;
313
+ description: string;
314
+ typeAnnotation: TypeAnnotation;
315
+ defaultValue?: DefaultValue;
291
316
  }
292
317
 
293
318
  export type UILib = Array<ViewComponentDeclaration>;
@@ -163,6 +163,9 @@
163
163
  "setter": {
164
164
  "$ref": "#/definitions/BaseSetter"
165
165
  },
166
+ "defaultValue": {
167
+ "$ref": "#/definitions/DefaultValue"
168
+ },
166
169
  "tsDesignerValue": {
167
170
  "type": "string"
168
171
  },
@@ -401,230 +404,122 @@
401
404
  "additionalProperties": false,
402
405
  "description": "属性选择设置器"
403
406
  },
404
- "EventDeclaration": {
405
- "type": "object",
406
- "properties": {
407
- "concept": {
408
- "type": "string",
409
- "const": "EventDeclaration"
410
- },
411
- "name": {
412
- "type": "string"
413
- },
414
- "title": {
415
- "type": "string"
416
- },
417
- "description": {
418
- "type": "string"
419
- },
420
- "tsType": {
421
- "type": "string"
422
- }
423
- },
424
- "required": [
425
- "concept",
426
- "name",
427
- "title",
428
- "tsType"
429
- ],
430
- "additionalProperties": false,
431
- "description": "组件事件"
432
- },
433
- "SlotDeclaration": {
407
+ "DefaultValue": {
434
408
  "type": "object",
435
409
  "properties": {
436
410
  "concept": {
437
411
  "type": "string",
438
- "const": "SlotDeclaration"
439
- },
440
- "name": {
441
- "type": "string"
442
- },
443
- "title": {
444
- "type": "string"
445
- },
446
- "description": {
447
- "type": "string"
448
- },
449
- "tsType": {
450
- "type": "string"
412
+ "const": "DefaultValue"
451
413
  },
452
- "emptyBackground": {
453
- "type": "string"
414
+ "expression": {
415
+ "$ref": "#/definitions/LogicItem"
454
416
  },
455
- "snippets": {
417
+ "playground": {
456
418
  "type": "array",
457
419
  "items": {
458
- "$ref": "#/definitions/ViewBlockWithImage"
420
+ "$ref": "#/definitions/LogicItem"
459
421
  }
460
422
  }
461
423
  },
462
424
  "required": [
463
425
  "concept",
464
- "name",
465
- "title",
466
- "tsType",
467
- "snippets"
426
+ "expression",
427
+ "playground"
468
428
  ],
469
429
  "additionalProperties": false,
470
- "description": "插槽"
430
+ "description": "默认值"
471
431
  },
472
- "ViewBlockWithImage": {
473
- "type": "object",
474
- "properties": {
475
- "concept": {
476
- "type": "string",
477
- "const": "ViewBlockWithImage"
478
- },
479
- "title": {
480
- "type": "string"
432
+ "LogicItem": {
433
+ "anyOf": [
434
+ {
435
+ "$ref": "#/definitions/NullLiteral"
481
436
  },
482
- "code": {
483
- "type": "string"
437
+ {
438
+ "$ref": "#/definitions/BooleanLiteral"
484
439
  },
485
- "description": {
486
- "type": "string"
440
+ {
441
+ "$ref": "#/definitions/StringLiteral"
487
442
  },
488
- "screenshot": {
489
- "type": "string"
443
+ {
444
+ "$ref": "#/definitions/NumericLiteral"
490
445
  },
491
- "drawing": {
492
- "type": "string"
446
+ {
447
+ "$ref": "#/definitions/NewList"
493
448
  }
494
- },
495
- "required": [
496
- "concept",
497
- "title",
498
- "code",
499
- "screenshot",
500
- "drawing"
501
449
  ],
502
- "additionalProperties": false,
503
- "description": "带截图的代码块"
450
+ "description": "设置器基类"
504
451
  },
505
- "LogicDeclaration": {
452
+ "NullLiteral": {
506
453
  "type": "object",
507
454
  "properties": {
508
455
  "concept": {
509
456
  "type": "string",
510
- "const": "LogicDeclaration"
511
- },
512
- "name": {
513
- "type": "string"
514
- },
515
- "title": {
516
- "type": "string"
517
- },
518
- "description": {
519
- "type": "string"
520
- },
521
- "typeParams": {
522
- "type": "array",
523
- "items": {
524
- "$ref": "#/definitions/TypeParam"
525
- }
526
- },
527
- "params": {
528
- "type": "array",
529
- "items": {
530
- "$ref": "#/definitions/ParamDeclaration"
531
- }
532
- },
533
- "returns": {
534
- "type": "array",
535
- "items": {
536
- "$ref": "#/definitions/Return"
537
- }
457
+ "const": "NullLiteral"
538
458
  }
539
459
  },
540
460
  "required": [
541
- "concept",
542
- "name",
543
- "title",
544
- "description",
545
- "params",
546
- "returns"
461
+ "concept"
547
462
  ],
548
463
  "additionalProperties": false,
549
- "description": "逻辑声明"
464
+ "description": "空字面量"
550
465
  },
551
- "TypeParam": {
466
+ "BooleanLiteral": {
552
467
  "type": "object",
553
468
  "properties": {
554
469
  "concept": {
555
470
  "type": "string",
556
- "const": "TypeParam"
471
+ "const": "BooleanLiteral"
557
472
  },
558
- "name": {
473
+ "value": {
559
474
  "type": "string"
560
475
  }
561
476
  },
562
477
  "required": [
563
478
  "concept",
564
- "name"
479
+ "value"
565
480
  ],
566
481
  "additionalProperties": false,
567
- "description": "类型参数"
482
+ "description": "布尔型字面量"
568
483
  },
569
- "ParamDeclaration": {
484
+ "StringLiteral": {
570
485
  "type": "object",
571
486
  "properties": {
572
487
  "concept": {
573
488
  "type": "string",
574
- "const": "ParamDeclaration"
575
- },
576
- "name": {
577
- "type": "string"
578
- },
579
- "title": {
580
- "type": "string"
489
+ "const": "StringLiteral"
581
490
  },
582
- "description": {
583
- "type": "string"
584
- },
585
- "tsType": {
491
+ "value": {
586
492
  "type": "string"
587
493
  }
588
494
  },
589
495
  "required": [
590
496
  "concept",
591
- "name",
592
- "title",
593
- "description",
594
- "tsType"
497
+ "value"
595
498
  ],
596
499
  "additionalProperties": false,
597
- "description": "输入参数声明"
500
+ "description": "字符串字面量"
598
501
  },
599
- "Return": {
502
+ "NumericLiteral": {
600
503
  "type": "object",
601
504
  "properties": {
602
505
  "concept": {
603
506
  "type": "string",
604
- "const": "Return"
605
- },
606
- "name": {
607
- "type": "string"
507
+ "const": "NumericLiteral"
608
508
  },
609
- "description": {
509
+ "value": {
610
510
  "type": "string"
611
511
  },
612
512
  "typeAnnotation": {
613
513
  "$ref": "#/definitions/TypeAnnotation"
614
- },
615
- "defaultValue": {
616
- "$ref": "#/definitions/DefaultValue"
617
514
  }
618
515
  },
619
516
  "required": [
620
517
  "concept",
621
- "name",
622
- "description",
623
- "typeAnnotation",
624
- "defaultValue"
518
+ "value",
519
+ "typeAnnotation"
625
520
  ],
626
521
  "additionalProperties": false,
627
- "description": "输出参数"
522
+ "description": "数字字面量"
628
523
  },
629
524
  "TypeAnnotation": {
630
525
  "type": "object",
@@ -715,9 +610,6 @@
715
610
  "typeAnnotation": {
716
611
  "$ref": "#/definitions/TypeAnnotation"
717
612
  },
718
- "required": {
719
- "type": "boolean"
720
- },
721
613
  "defaultValue": {
722
614
  "$ref": "#/definitions/DefaultValue"
723
615
  },
@@ -731,24 +623,23 @@
731
623
  "label",
732
624
  "description",
733
625
  "typeAnnotation",
734
- "required",
735
626
  "defaultValue",
736
627
  "jsonName"
737
628
  ],
738
629
  "additionalProperties": false,
739
630
  "description": "数据结构属性"
740
631
  },
741
- "DefaultValue": {
632
+ "NewList": {
742
633
  "type": "object",
743
634
  "properties": {
744
635
  "concept": {
745
636
  "type": "string",
746
- "const": "DefaultValue"
637
+ "const": "NewList"
747
638
  },
748
- "expression": {
749
- "$ref": "#/definitions/LogicItem"
639
+ "typeAnnotation": {
640
+ "$ref": "#/definitions/TypeAnnotation"
750
641
  },
751
- "playground": {
642
+ "items": {
752
643
  "type": "array",
753
644
  "items": {
754
645
  "$ref": "#/definitions/LogicItem"
@@ -757,40 +648,234 @@
757
648
  },
758
649
  "required": [
759
650
  "concept",
760
- "expression",
761
- "playground"
651
+ "typeAnnotation",
652
+ "items"
762
653
  ],
763
654
  "additionalProperties": false,
764
- "description": "默认值"
655
+ "description": "列表构造器"
765
656
  },
766
- "LogicItem": {
657
+ "EventDeclaration": {
767
658
  "type": "object",
768
659
  "properties": {
769
660
  "concept": {
770
661
  "type": "string",
771
- "const": "LogicItem"
662
+ "const": "EventDeclaration"
772
663
  },
773
- "label": {
664
+ "name": {
665
+ "type": "string"
666
+ },
667
+ "title": {
774
668
  "type": "string"
775
669
  },
776
670
  "description": {
777
671
  "type": "string"
778
672
  },
779
- "folded": {
780
- "type": "boolean"
673
+ "tsType": {
674
+ "type": "string"
675
+ }
676
+ },
677
+ "required": [
678
+ "concept",
679
+ "name",
680
+ "title",
681
+ "tsType"
682
+ ],
683
+ "additionalProperties": false,
684
+ "description": "组件事件"
685
+ },
686
+ "SlotDeclaration": {
687
+ "type": "object",
688
+ "properties": {
689
+ "concept": {
690
+ "type": "string",
691
+ "const": "SlotDeclaration"
781
692
  },
782
- "offsetX": {
783
- "type": "number"
693
+ "name": {
694
+ "type": "string"
784
695
  },
785
- "offsetY": {
786
- "type": "number"
696
+ "title": {
697
+ "type": "string"
698
+ },
699
+ "description": {
700
+ "type": "string"
701
+ },
702
+ "tsType": {
703
+ "type": "string"
704
+ },
705
+ "emptyBackground": {
706
+ "type": "string"
707
+ },
708
+ "snippets": {
709
+ "type": "array",
710
+ "items": {
711
+ "$ref": "#/definitions/ViewBlockWithImage"
712
+ }
787
713
  }
788
714
  },
789
715
  "required": [
790
- "concept"
716
+ "concept",
717
+ "name",
718
+ "title",
719
+ "tsType",
720
+ "snippets"
721
+ ],
722
+ "additionalProperties": false,
723
+ "description": "插槽"
724
+ },
725
+ "ViewBlockWithImage": {
726
+ "type": "object",
727
+ "properties": {
728
+ "concept": {
729
+ "type": "string",
730
+ "const": "ViewBlockWithImage"
731
+ },
732
+ "title": {
733
+ "type": "string"
734
+ },
735
+ "code": {
736
+ "type": "string"
737
+ },
738
+ "description": {
739
+ "type": "string"
740
+ },
741
+ "screenshot": {
742
+ "type": "string"
743
+ },
744
+ "drawing": {
745
+ "type": "string"
746
+ }
747
+ },
748
+ "required": [
749
+ "concept",
750
+ "title",
751
+ "code",
752
+ "screenshot",
753
+ "drawing"
754
+ ],
755
+ "additionalProperties": false,
756
+ "description": "带截图的代码块"
757
+ },
758
+ "LogicDeclaration": {
759
+ "type": "object",
760
+ "properties": {
761
+ "concept": {
762
+ "type": "string",
763
+ "const": "LogicDeclaration"
764
+ },
765
+ "name": {
766
+ "type": "string"
767
+ },
768
+ "title": {
769
+ "type": "string"
770
+ },
771
+ "description": {
772
+ "type": "string"
773
+ },
774
+ "typeParams": {
775
+ "type": "array",
776
+ "items": {
777
+ "$ref": "#/definitions/TypeParam"
778
+ }
779
+ },
780
+ "params": {
781
+ "type": "array",
782
+ "items": {
783
+ "$ref": "#/definitions/Param"
784
+ }
785
+ },
786
+ "returns": {
787
+ "type": "array",
788
+ "items": {
789
+ "$ref": "#/definitions/Return"
790
+ }
791
+ }
792
+ },
793
+ "required": [
794
+ "concept",
795
+ "name",
796
+ "title",
797
+ "description",
798
+ "params",
799
+ "returns"
791
800
  ],
792
801
  "additionalProperties": false,
793
- "description": "逻辑项"
802
+ "description": "逻辑声明"
803
+ },
804
+ "TypeParam": {
805
+ "type": "object",
806
+ "properties": {
807
+ "concept": {
808
+ "type": "string",
809
+ "const": "TypeParam"
810
+ },
811
+ "name": {
812
+ "type": "string"
813
+ }
814
+ },
815
+ "required": [
816
+ "concept",
817
+ "name"
818
+ ],
819
+ "additionalProperties": false,
820
+ "description": "类型参数"
821
+ },
822
+ "Param": {
823
+ "type": "object",
824
+ "properties": {
825
+ "concept": {
826
+ "type": "string",
827
+ "const": "Param"
828
+ },
829
+ "name": {
830
+ "type": "string"
831
+ },
832
+ "description": {
833
+ "type": "string"
834
+ },
835
+ "typeAnnotation": {
836
+ "$ref": "#/definitions/TypeAnnotation"
837
+ },
838
+ "defaultValue": {
839
+ "$ref": "#/definitions/DefaultValue"
840
+ }
841
+ },
842
+ "required": [
843
+ "concept",
844
+ "name",
845
+ "description",
846
+ "typeAnnotation"
847
+ ],
848
+ "additionalProperties": false,
849
+ "description": "输入参数"
850
+ },
851
+ "Return": {
852
+ "type": "object",
853
+ "properties": {
854
+ "concept": {
855
+ "type": "string",
856
+ "const": "Return"
857
+ },
858
+ "name": {
859
+ "type": "string"
860
+ },
861
+ "description": {
862
+ "type": "string"
863
+ },
864
+ "typeAnnotation": {
865
+ "$ref": "#/definitions/TypeAnnotation"
866
+ },
867
+ "defaultValue": {
868
+ "$ref": "#/definitions/DefaultValue"
869
+ }
870
+ },
871
+ "required": [
872
+ "concept",
873
+ "name",
874
+ "description",
875
+ "typeAnnotation"
876
+ ],
877
+ "additionalProperties": false,
878
+ "description": "输出参数"
794
879
  },
795
880
  "ThemeVariable": {
796
881
  "type": "object",
@@ -4,7 +4,7 @@ declare namespace nasl.ui {
4
4
  /**
5
5
  * 设置器基类
6
6
  */
7
- export type BaseSetter = InputSetter | SwitchSetter | EnumSelectSetter | CapsulesSetter | NumberInputSetter | IconSetter | ImageSetter | PropertySelectSetter;
7
+ export type BaseSetter<T, K> = InputSetter | SwitchSetter | EnumSelectSetter<T, K> | CapsulesSetter<T, K> | NumberInputSetter | IconSetter | ImageSetter | PropertySelectSetter;
8
8
 
9
9
  /**
10
10
  * 输入框设置器
@@ -25,17 +25,17 @@ declare namespace nasl.ui {
25
25
  /**
26
26
  * 枚举选择设置器
27
27
  */
28
- export interface EnumSelectSetter {
28
+ export interface EnumSelectSetter<T, K> {
29
29
  concept: 'EnumSelectSetter';
30
- options: Array<SetterOption>;
30
+ options: Array<SetterOption<T, K>>;
31
31
  }
32
32
 
33
33
  /**
34
34
  * 胶囊设置器
35
35
  */
36
- export interface CapsulesSetter {
36
+ export interface CapsulesSetter<T, K> {
37
37
  concept: 'CapsulesSetter';
38
- options: Array<SetterOption>;
38
+ options: Array<SetterOption<T, K>>;
39
39
  }
40
40
 
41
41
  /**
@@ -89,7 +89,7 @@ declare namespace nasl.ui {
89
89
  /**
90
90
  * 组件属性
91
91
  */
92
- export interface PropOptions<T extends ViewComponent, K extends keyof T> {
92
+ export interface PropOptions<T extends object, K extends keyof T> {
93
93
  title: string;
94
94
  group?: '基础信息' | '数据属性' | '主要属性' | '交互属性' | '状态属性' | '样式属性' | '工具属性';
95
95
  icon?: string;
@@ -100,7 +100,7 @@ declare namespace nasl.ui {
100
100
  bindHide?: boolean;
101
101
  bindOpen?: boolean;
102
102
  tabKind?: 'property' | 'style';
103
- setter?: BaseSetter;
103
+ setter?: BaseSetter<T, K>;
104
104
  designerValue?: any;
105
105
  if?: (target: T) => boolean;
106
106
  disabledIf?: (target: T) => boolean;
@@ -133,21 +133,6 @@ declare namespace nasl.ui {
133
133
  description: string;
134
134
  }
135
135
 
136
- /**
137
- * 输入参数声明
138
- */
139
- export interface ParamOptions {
140
- title: string;
141
- description: string;
142
- }
143
-
144
- /**
145
- * 输出参数声明
146
- */
147
- export interface ReturnOptions {
148
- description: string;
149
- }
150
-
151
136
  /**
152
137
  * 设置器枚举选项
153
138
  */
package/package.json CHANGED
@@ -1,9 +1,11 @@
1
1
  {
2
2
  "name": "@nasl/types",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "NASL types for TypeScript Declaration",
5
5
  "main": "index.d.ts",
6
- "scripts": {},
6
+ "scripts": {
7
+ "build": "node ../../out/bin/genUIOptionsForTS.js && node ../../out/bin/genUIAstForTS.js"
8
+ },
7
9
  "author": "Forrest <rainforest92@126.com>",
8
10
  "license": "MIT",
9
11
  "contributors": [],