@lcap/nasl 3.5.0-beta.4 → 3.6.0-alpha.1
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/bak/translator.js +39 -119
- package/out/bak/translator.js.map +1 -1
- package/out/breakpoint/generator/BreakpointNode.d.ts +0 -3
- package/out/breakpoint/generator/BreakpointNode.js +0 -9
- package/out/breakpoint/generator/BreakpointNode.js.map +1 -1
- package/out/breakpoint/shared/constants.js +0 -1
- package/out/breakpoint/shared/constants.js.map +1 -1
- package/out/breakpoint/shared/utils.js +7 -31
- package/out/breakpoint/shared/utils.js.map +1 -1
- package/out/common/BaseNode.d.ts +13 -1
- package/out/common/BaseNode.js +52 -23
- package/out/common/BaseNode.js.map +1 -1
- package/out/common/Command.js +1 -0
- package/out/common/Command.js.map +1 -1
- package/out/common/EventEmitter.d.ts +1 -1
- package/out/common/EventEmitter.js +0 -4
- package/out/common/EventEmitter.js.map +1 -1
- package/out/concepts/App__.d.ts +76 -51
- package/out/concepts/App__.js +190 -87
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/BackendVariable__.js +2 -10
- package/out/concepts/BackendVariable__.js.map +1 -1
- package/out/concepts/BindAttribute__.js +6 -16
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.d.ts +0 -1
- package/out/concepts/BindDirective__.js +4 -19
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BindEvent__.d.ts +1 -3
- package/out/concepts/BindEvent__.js +13 -38
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/CallFunction__.js +2 -10
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallLogic__.d.ts +0 -2
- package/out/concepts/CallLogic__.js +27 -38
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/Constant__.js +6 -7
- package/out/concepts/Constant__.js.map +1 -1
- package/out/concepts/Destination__.d.ts +1 -1
- package/out/concepts/Destination__.js +4 -6
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/End__.js +1 -2
- package/out/concepts/End__.js.map +1 -1
- package/out/concepts/Entity__.d.ts +1 -1
- package/out/concepts/Entity__.js +2 -0
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/Event__.d.ts +0 -14
- package/out/concepts/Event__.js +0 -61
- package/out/concepts/Event__.js.map +1 -1
- package/out/concepts/Frontend__.d.ts +88 -0
- package/out/concepts/Frontend__.js +143 -1
- package/out/concepts/Frontend__.js.map +1 -1
- package/out/concepts/Identifier__.d.ts +0 -5
- package/out/concepts/Identifier__.js +9 -19
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/LogicItem__.d.ts +1 -1
- package/out/concepts/LogicItem__.js.map +1 -1
- package/out/concepts/Logic__.d.ts +1 -3
- package/out/concepts/Logic__.js +13 -16
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/MemberExpression__.d.ts +1 -1
- package/out/concepts/MemberExpression__.js +3 -3
- package/out/concepts/MemberExpression__.js.map +1 -1
- package/out/concepts/NewComposite__.js.map +1 -1
- package/out/concepts/Param__.js +3 -11
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/ProcessElement__.js +1 -9
- package/out/concepts/ProcessElement__.js.map +1 -1
- package/out/concepts/Return__.js +9 -17
- package/out/concepts/Return__.js.map +1 -1
- package/out/concepts/Variable__.js +8 -17
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewElement__.d.ts +2 -17
- package/out/concepts/ViewElement__.js +31 -143
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.js +6 -6
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/index__.d.ts +0 -5
- package/out/concepts/index__.js +0 -5
- package/out/concepts/index__.js.map +1 -1
- package/out/concepts/utils/asserts.d.ts +3 -258
- package/out/concepts/utils/asserts.js +13 -351
- package/out/concepts/utils/asserts.js.map +1 -1
- package/out/concepts/utils/types.d.ts +3 -20
- package/out/generator/genBundleFiles.js +11 -25
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genReleaseBody.js +3 -12
- package/out/generator/genReleaseBody.js.map +1 -1
- package/out/generator/permission.js +3 -3
- package/out/generator/permission.js.map +1 -1
- package/out/natural/transformTSCode.js +1 -1
- package/out/natural/transformTSCode.js.map +1 -1
- package/out/server/extendBaseNode.js +22 -6
- package/out/server/extendBaseNode.js.map +1 -1
- package/out/server/getLogics.js +27 -62
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getMemberIdentifier.js +1 -6
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/naslServer.js +11 -28
- package/out/server/naslServer.js.map +1 -1
- package/out/server/translator.js +1 -6
- package/out/server/translator.js.map +1 -1
- package/out/service/storage/init.js +26 -2
- package/out/service/storage/init.js.map +1 -1
- package/out/templator/genCreateBlock.js +6 -6
- package/out/templator/genCreateBlock.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js +16 -16
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.d.ts +27 -0
- package/out/templator/genCurdMultipleKeyBlock.js +709 -37
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genGetBlock.js +4 -4
- package/out/templator/genGetBlock.js.map +1 -1
- package/out/templator/genGridViewBlock.js +12 -12
- package/out/templator/genGridViewBlock.js.map +1 -1
- package/out/templator/genListViewBlock.js +4 -4
- package/out/templator/genListViewBlock.js.map +1 -1
- package/out/templator/genSelectBlock.js +3 -3
- package/out/templator/genSelectBlock.js.map +1 -1
- package/out/templator/genTableBlock.d.ts +2 -0
- package/out/templator/genTableBlock.js +124 -11
- package/out/templator/genTableBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.js +8 -8
- package/out/templator/genUpdateBlock.js.map +1 -1
- package/out/templator/utils.d.ts +2 -2
- package/out/templator/utils.js.map +1 -1
- package/out/translator/utils.js +18 -0
- package/out/translator/utils.js.map +1 -1
- package/out/utils/i18nInfo.js +2 -7
- package/out/utils/i18nInfo.js.map +1 -1
- package/package.json +2 -2
- package/src/bak/translator.js +43 -121
- package/src/breakpoint/generator/BreakpointNode.ts +0 -12
- package/src/breakpoint/shared/constants.ts +0 -1
- package/src/breakpoint/shared/utils.ts +10 -37
- package/src/common/BaseNode.ts +60 -22
- package/src/common/Command.ts +1 -0
- package/src/common/EventEmitter.ts +1 -6
- package/src/concepts/App__.ts +251 -139
- package/src/concepts/BackendVariable__.ts +2 -10
- package/src/concepts/BindAttribute__.ts +6 -15
- package/src/concepts/BindDirective__.ts +4 -19
- package/src/concepts/BindEvent__.ts +12 -40
- package/src/concepts/CallFunction__.ts +2 -10
- package/src/concepts/CallLogic__.ts +32 -45
- package/src/concepts/Constant__.ts +7 -5
- package/src/concepts/Destination__.ts +4 -6
- package/src/concepts/End__.ts +0 -1
- package/src/concepts/Entity__.ts +3 -1
- package/src/concepts/Event__.ts +0 -70
- package/src/concepts/Frontend__.ts +251 -3
- package/src/concepts/Identifier__.ts +13 -29
- package/src/concepts/LogicItem__.ts +0 -1
- package/src/concepts/Logic__.ts +14 -21
- package/src/concepts/MemberExpression__.ts +3 -3
- package/src/concepts/NewComposite__.ts +6 -4
- package/src/concepts/Param__.ts +3 -11
- package/src/concepts/ProcessElement__.ts +1 -8
- package/src/concepts/Return__.ts +12 -15
- package/src/concepts/Variable__.ts +9 -17
- package/src/concepts/ViewElement__.ts +54 -166
- package/src/concepts/View__.ts +6 -8
- package/src/concepts/index__.ts +0 -5
- package/src/concepts/utils/asserts.ts +4 -367
- package/src/concepts/utils/types.ts +0 -28
- package/src/generator/genBundleFiles.ts +15 -33
- package/src/generator/genReleaseBody.ts +3 -14
- package/src/generator/permission.ts +6 -8
- package/src/natural/transformTSCode.ts +1 -1
- package/src/server/extendBaseNode.ts +41 -22
- package/src/server/getLogics.ts +41 -79
- package/src/server/getMemberIdentifier.ts +1 -7
- package/src/server/naslServer.ts +12 -30
- package/src/server/translator.ts +1 -7
- package/src/service/storage/init.ts +33 -2
- package/src/templator/genCreateBlock.ts +6 -6
- package/src/templator/genCurdEditMultipleKeyBlock.ts +16 -16
- package/src/templator/genCurdMultipleKeyBlock.ts +817 -93
- package/src/templator/genGetBlock.ts +4 -4
- package/src/templator/genGridViewBlock.ts +12 -12
- package/src/templator/genListViewBlock.ts +4 -4
- package/src/templator/genSelectBlock.ts +3 -3
- package/src/templator/genTableBlock.ts +137 -12
- package/src/templator/genUpdateBlock.ts +8 -8
- package/src/templator/utils.ts +2 -2
- package/src/translator/utils.ts +20 -0
- package/src/utils/i18nInfo.ts +2 -7
- package/test/concepts/call-function/fixtures/from-string.json +59 -68
- package/test/concepts/call-function/fixtures/to-string-global-tz.json +58 -67
- package/test/concepts/call-function/fixtures/to-string-no-tz.json +48 -57
- package/test/concepts/call-function/fixtures/to-string-user-tz.json +60 -69
- package/test/concepts/call-function/fixtures/to-string-utc-tz.json +60 -69
- package/test/concepts/call-interface/fixtures/only-interface.json +72 -81
- package/test/concepts/call-interface/fixtures/with-body-complex-argument.json +214 -223
- package/test/concepts/call-interface/fixtures/with-body-no-argument.json +76 -85
- package/test/concepts/call-interface/fixtures/with-body-simple-argument.json +91 -100
- package/test/concepts/call-interface/fixtures/with-headers-no-argument.json +79 -88
- package/test/concepts/call-interface/fixtures/with-headers.json +81 -90
- package/test/concepts/call-interface/fixtures/with-query-no-argument.json +79 -88
- package/test/concepts/call-interface/fixtures/with-query.json +81 -90
- package/test/concepts/call-logic/__snapshots__/getQuickInfoOffset.spec.ts.snap +2 -4
- package/test/concepts/call-logic/fixtures/entries-get-with-arguments.json +95 -104
- package/test/concepts/call-logic/fixtures/entries-update-with-arguments.json +200 -209
- package/test/concepts/call-logic/fixtures/global-logic-argument-no-expression.json +88 -97
- package/test/concepts/call-logic/fixtures/global-logic-argument-some-expression.json +115 -124
- package/test/concepts/call-logic/fixtures/json-deserialize.json +111 -120
- package/test/concepts/call-logic/fixtures/json-serialize-with-string.json +115 -124
- package/test/concepts/call-logic/fixtures/json-serialize.json +115 -124
- package/test/concepts/call-logic/fixtures/view-buildin-logic-with-argument.json +82 -91
- package/test/concepts/call-logic/fixtures/view-component-logic-no-argument.json +79 -88
- package/test/concepts/call-logic/fixtures/view-component-with-validation.json +135 -144
- package/test/concepts/identifier/fixtures/view-variable.json +136 -145
- package/test/concepts/view-element/__snapshots__/toVue.spec.ts.snap +1 -1
- package/test/concepts/view-element/fixtures/default-login.json +212 -221
- package/test/concepts/view-element/fixtures/default-not-found.json +174 -183
- package/test/concepts/view-element/fixtures/with-role-auth.json +82 -91
- package/test/concepts/view-element/fixtures/with-table.json +1834 -1843
- package/test/concepts/view-element/toVue.spec.ts +0 -1
- package/ts-worker/package.json +1 -1
- package/out/concepts/BusinessComponent__.d.ts +0 -641
- package/out/concepts/BusinessComponent__.js +0 -1901
- package/out/concepts/BusinessComponent__.js.map +0 -1
- package/out/concepts/BusinessLogic__.d.ts +0 -38
- package/out/concepts/BusinessLogic__.js +0 -358
- package/out/concepts/BusinessLogic__.js.map +0 -1
- package/out/concepts/CallEvent__.d.ts +0 -97
- package/out/concepts/CallEvent__.js +0 -263
- package/out/concepts/CallEvent__.js.map +0 -1
- package/out/concepts/FrontendType__.d.ts +0 -308
- package/out/concepts/FrontendType__.js +0 -605
- package/out/concepts/FrontendType__.js.map +0 -1
- package/out/concepts/ParamWithGroup__.d.ts +0 -39
- package/out/concepts/ParamWithGroup__.js +0 -85
- package/out/concepts/ParamWithGroup__.js.map +0 -1
- package/src/concepts/BusinessComponent__.ts +0 -2669
- package/src/concepts/BusinessLogic__.ts +0 -376
- package/src/concepts/CallEvent__.ts +0 -334
- package/src/concepts/FrontendType__.ts +0 -919
- package/src/concepts/ParamWithGroup__.ts +0 -101
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
withGenerator,
|
|
10
10
|
TranslatorGenerator,
|
|
11
11
|
} from '../translator';
|
|
12
|
+
import { AssetsInfo } from './App__';
|
|
12
13
|
import type Namespace from './Namespace__';
|
|
13
14
|
import { languageList } from '../utils/i18nInfo';
|
|
14
15
|
|
|
@@ -28,6 +29,7 @@ import type BindEvent from './BindEvent__';
|
|
|
28
29
|
import type View from './View__';
|
|
29
30
|
import type FrontendVariable from './FrontendVariable__';
|
|
30
31
|
import Theme from './Theme__';
|
|
32
|
+
import type Module from './Module__';
|
|
31
33
|
import type I18nInfo from './I18nInfo__';
|
|
32
34
|
import type App from './App__';
|
|
33
35
|
import type Variable from './Variable__';
|
|
@@ -124,6 +126,16 @@ export class Frontend extends BaseNode {
|
|
|
124
126
|
})
|
|
125
127
|
theme: Theme = new Theme();
|
|
126
128
|
|
|
129
|
+
/**
|
|
130
|
+
* 扩展组件列表(兼容老版)
|
|
131
|
+
*/
|
|
132
|
+
@property({
|
|
133
|
+
objectRef: 'Module',
|
|
134
|
+
isArray: true,
|
|
135
|
+
defaultValue: [],
|
|
136
|
+
})
|
|
137
|
+
componentDependencies: Array<Module> = [];
|
|
138
|
+
|
|
127
139
|
/**
|
|
128
140
|
* 全局缩放开关
|
|
129
141
|
*/
|
|
@@ -724,6 +736,162 @@ export class Frontend extends BaseNode {
|
|
|
724
736
|
return node;
|
|
725
737
|
}
|
|
726
738
|
|
|
739
|
+
getModuleExistingNames(excludedList: Array<Module> = []) {
|
|
740
|
+
const excludedSet = new Set(excludedList);
|
|
741
|
+
return ((this.componentDependencies as Module[]) || [])
|
|
742
|
+
.filter((item) => !excludedSet.has(item))
|
|
743
|
+
.map((item) => item?.name);
|
|
744
|
+
}
|
|
745
|
+
getModuleUniqueName(name = 'module1') {
|
|
746
|
+
return utils.unique(name, this.getModuleExistingNames(), undefined, false);
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
/**
|
|
750
|
+
* 插入模块
|
|
751
|
+
* @internal
|
|
752
|
+
* @param name 模块名称,如果不填会自动生成一个唯一名称
|
|
753
|
+
*/
|
|
754
|
+
_insertModuleAt(name: string, index: number): Module;
|
|
755
|
+
|
|
756
|
+
/**
|
|
757
|
+
* 插入模块
|
|
758
|
+
* @internal
|
|
759
|
+
* @param moduleOptions 模块参数
|
|
760
|
+
*/
|
|
761
|
+
_insertModuleAt(moduleOptions: Partial<Module>, index: number): Module;
|
|
762
|
+
|
|
763
|
+
/**
|
|
764
|
+
* 插入模块
|
|
765
|
+
* @internal
|
|
766
|
+
* @param module 已有的模块实例
|
|
767
|
+
*/
|
|
768
|
+
_insertModuleAt(module: Module, index: number): Module;
|
|
769
|
+
|
|
770
|
+
_insertModuleAt(options: string | Partial<Module> | Module, index: number) {
|
|
771
|
+
const moduleOptions: any = {};
|
|
772
|
+
const relationOptions = { parentNode: this, parentKey: 'componentDependencies' };
|
|
773
|
+
const Module = getConceptConstructor('Module');
|
|
774
|
+
let module: Module;
|
|
775
|
+
if (!options) {
|
|
776
|
+
module = Module.from(
|
|
777
|
+
{
|
|
778
|
+
...moduleOptions,
|
|
779
|
+
name: this.getModuleUniqueName(),
|
|
780
|
+
},
|
|
781
|
+
this,
|
|
782
|
+
'componentDependencies',
|
|
783
|
+
);
|
|
784
|
+
} else if (typeof options === 'string') {
|
|
785
|
+
module = Module.from(
|
|
786
|
+
{
|
|
787
|
+
...moduleOptions,
|
|
788
|
+
name: options,
|
|
789
|
+
},
|
|
790
|
+
this,
|
|
791
|
+
'componentDependencies',
|
|
792
|
+
);
|
|
793
|
+
} else if (asserts.isModule(options)) {
|
|
794
|
+
options.ensureDelete(); // 同一实例不支持多处存在
|
|
795
|
+
module = options;
|
|
796
|
+
Object.assign(module, relationOptions);
|
|
797
|
+
} else {
|
|
798
|
+
module = Module.from(
|
|
799
|
+
{
|
|
800
|
+
...moduleOptions,
|
|
801
|
+
...options,
|
|
802
|
+
},
|
|
803
|
+
this,
|
|
804
|
+
'componentDependencies',
|
|
805
|
+
);
|
|
806
|
+
}
|
|
807
|
+
this.componentDependencies.splice(index, 0, module);
|
|
808
|
+
return module;
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
/**
|
|
812
|
+
* 插入模块
|
|
813
|
+
* @param name 模块名称,如果不填会自动生成一个唯一名称
|
|
814
|
+
*/
|
|
815
|
+
insertModuleAt(name: string, index: number): Module;
|
|
816
|
+
|
|
817
|
+
/**
|
|
818
|
+
* 插入模块
|
|
819
|
+
* @param moduleOptions 模块参数
|
|
820
|
+
*/
|
|
821
|
+
insertModuleAt(moduleOptions: Partial<Module>, index: number): Module;
|
|
822
|
+
|
|
823
|
+
/**
|
|
824
|
+
* 插入模块
|
|
825
|
+
* @param module 已有的模块实例
|
|
826
|
+
*/
|
|
827
|
+
insertModuleAt(module: Module, index: number): Module;
|
|
828
|
+
|
|
829
|
+
insertModuleAt(options: string | Partial<Module> | Module, index: number) {
|
|
830
|
+
const node = this._insertModuleAt(options as any, index);
|
|
831
|
+
node.create({
|
|
832
|
+
index,
|
|
833
|
+
parentNode: this,
|
|
834
|
+
parentKey: 'componentDependencies',
|
|
835
|
+
});
|
|
836
|
+
return node;
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
/**
|
|
840
|
+
* 添加模块
|
|
841
|
+
* @internal
|
|
842
|
+
* @param name 模块名称,如果不填会自动生成一个唯一名称
|
|
843
|
+
*/
|
|
844
|
+
_addModule(name?: string): Module;
|
|
845
|
+
|
|
846
|
+
/**
|
|
847
|
+
* 添加模块
|
|
848
|
+
* @internal
|
|
849
|
+
* @param moduleOptions 模块参数
|
|
850
|
+
*/
|
|
851
|
+
_addModule(moduleOptions: Partial<Module>): Module;
|
|
852
|
+
|
|
853
|
+
/**
|
|
854
|
+
* 添加模块
|
|
855
|
+
* @internal
|
|
856
|
+
* @param module 已有的模块实例
|
|
857
|
+
*/
|
|
858
|
+
_addModule(module: Module): Module;
|
|
859
|
+
|
|
860
|
+
_addModule(options?: string | Partial<Module> | Module) {
|
|
861
|
+
const index = this.componentDependencies.length;
|
|
862
|
+
return this._insertModuleAt(options as any, index);
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
/**
|
|
866
|
+
* 添加模块
|
|
867
|
+
* @internal
|
|
868
|
+
* @param name 模块名称,如果不填会自动生成一个唯一名称
|
|
869
|
+
*/
|
|
870
|
+
addModule(name?: string): Module;
|
|
871
|
+
|
|
872
|
+
/**
|
|
873
|
+
* 添加模块
|
|
874
|
+
* @param moduleOptions 模块参数
|
|
875
|
+
*/
|
|
876
|
+
addModule(moduleOptions: Partial<Module>): Module;
|
|
877
|
+
|
|
878
|
+
/**
|
|
879
|
+
* 添加模块
|
|
880
|
+
* @param module 已有的模块实例
|
|
881
|
+
*/
|
|
882
|
+
addModule(module: Module): Module;
|
|
883
|
+
|
|
884
|
+
addModule(options?: string | Partial<Module> | Module) {
|
|
885
|
+
const node = this._addModule(options as any);
|
|
886
|
+
const index = this.componentDependencies.indexOf(node);
|
|
887
|
+
node.create({
|
|
888
|
+
index,
|
|
889
|
+
parentNode: this,
|
|
890
|
+
parentKey: 'componentDependencies',
|
|
891
|
+
});
|
|
892
|
+
return node;
|
|
893
|
+
}
|
|
894
|
+
|
|
727
895
|
/**
|
|
728
896
|
* 删除元素绑定事件
|
|
729
897
|
* @param name 元素绑定事件名称
|
|
@@ -948,6 +1116,62 @@ export class Frontend extends BaseNode {
|
|
|
948
1116
|
return params;
|
|
949
1117
|
}
|
|
950
1118
|
|
|
1119
|
+
/**
|
|
1120
|
+
* 删除模块
|
|
1121
|
+
* @param name 模块名称
|
|
1122
|
+
*/
|
|
1123
|
+
removeModule(name: string): void;
|
|
1124
|
+
|
|
1125
|
+
/**
|
|
1126
|
+
* 删除模块
|
|
1127
|
+
* @param module 已有的模块实例
|
|
1128
|
+
*/
|
|
1129
|
+
removeModule(module: Module): void;
|
|
1130
|
+
|
|
1131
|
+
removeModule(options: string | Module) {
|
|
1132
|
+
let module: Module;
|
|
1133
|
+
if (typeof options === 'string') {
|
|
1134
|
+
module = (this.componentDependencies as Module[]).find((item) => item.name === options);
|
|
1135
|
+
if (!module) {
|
|
1136
|
+
throw new Error('找不到模块 ' + options);
|
|
1137
|
+
}
|
|
1138
|
+
} else {
|
|
1139
|
+
module = options;
|
|
1140
|
+
}
|
|
1141
|
+
return module.delete();
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
__removeModule(module: Module) {
|
|
1145
|
+
const parentKey = module.parentKey;
|
|
1146
|
+
const params: Params = {
|
|
1147
|
+
parentNode: this,
|
|
1148
|
+
parentKey,
|
|
1149
|
+
index: -1,
|
|
1150
|
+
object: null,
|
|
1151
|
+
oldObject: module,
|
|
1152
|
+
};
|
|
1153
|
+
if (parentKey) {
|
|
1154
|
+
params.parentKey = parentKey;
|
|
1155
|
+
// @ts-ignore
|
|
1156
|
+
const t = this.__v_raw || this;
|
|
1157
|
+
// @ts-ignore
|
|
1158
|
+
const n = module.__v_raw || module;
|
|
1159
|
+
if (Array.isArray((t as any)[parentKey])) {
|
|
1160
|
+
// @ts-ignore
|
|
1161
|
+
const index = (t as any)[parentKey].findIndex((el) => (el.__v_raw || el) === n);
|
|
1162
|
+
~index && (this as any)[parentKey].splice(index, 1);
|
|
1163
|
+
params.index = index;
|
|
1164
|
+
} else {
|
|
1165
|
+
const q = (t as any)[parentKey];
|
|
1166
|
+
if ((q.__v_raw || q) === n) {
|
|
1167
|
+
params.index = 0;
|
|
1168
|
+
(this as any)[parentKey] = undefined;
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
return params;
|
|
1173
|
+
}
|
|
1174
|
+
|
|
951
1175
|
/**
|
|
952
1176
|
* 删除国际化信息
|
|
953
1177
|
* @param name 国际化信息名称
|
|
@@ -1009,6 +1233,10 @@ export class Frontend extends BaseNode {
|
|
|
1009
1233
|
// 自动生成的代码已结束。下面可以手动编写。
|
|
1010
1234
|
//================================================================================
|
|
1011
1235
|
|
|
1236
|
+
findComponentDependencyByName(name: string) {
|
|
1237
|
+
return this.componentDependencies.find((componentDependency) => componentDependency.name === name);
|
|
1238
|
+
}
|
|
1239
|
+
|
|
1012
1240
|
/**
|
|
1013
1241
|
* @param path 路径
|
|
1014
1242
|
* path 为要查找路径:如 /dashboard/student/list、/dashboard/student/list
|
|
@@ -1072,9 +1300,7 @@ export class Frontend extends BaseNode {
|
|
|
1072
1300
|
* @param name 一般不用传,用于 rename
|
|
1073
1301
|
*/
|
|
1074
1302
|
getEmbeddedFilePath(name = this.name) {
|
|
1075
|
-
return `/embedded/${this.
|
|
1076
|
-
this.getAncestor('FrontendType')?.name
|
|
1077
|
-
}/frontends/${name}.ts`;
|
|
1303
|
+
return `/embedded/${this.rootNode?.name || this.parentNode.name}/frontends/${name}.ts`;
|
|
1078
1304
|
}
|
|
1079
1305
|
|
|
1080
1306
|
@withSourceMapGenerator
|
|
@@ -1132,6 +1358,28 @@ export class Frontend extends BaseNode {
|
|
|
1132
1358
|
return basePath;
|
|
1133
1359
|
}
|
|
1134
1360
|
|
|
1361
|
+
genCustomAssetsInfo(prefix: string) {
|
|
1362
|
+
const custom: AssetsInfo = {
|
|
1363
|
+
js: [],
|
|
1364
|
+
css: [],
|
|
1365
|
+
names: [],
|
|
1366
|
+
};
|
|
1367
|
+
const existingSet = new Set();
|
|
1368
|
+
this.componentDependencies.forEach((dep) => {
|
|
1369
|
+
const { name, version } = dep;
|
|
1370
|
+
const jsName = `${prefix}/packages/${name}@${version}/dist-theme/index.js`;
|
|
1371
|
+
if (!existingSet.has(jsName)) {
|
|
1372
|
+
existingSet.add(jsName);
|
|
1373
|
+
custom.js.push(jsName);
|
|
1374
|
+
if (utils.shouldLoadCss(name, version)) {
|
|
1375
|
+
custom.css.push(`${prefix}/packages/${name}@${version}/dist-theme/index.css`);
|
|
1376
|
+
}
|
|
1377
|
+
custom.names.push(name);
|
|
1378
|
+
}
|
|
1379
|
+
});
|
|
1380
|
+
return custom;
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1135
1383
|
getExtensionsCallbackLogics() {
|
|
1136
1384
|
let resultLogics: string[] = [];
|
|
1137
1385
|
this.views.forEach((item: View) => {
|
|
@@ -10,9 +10,6 @@ import {
|
|
|
10
10
|
import { BindAttribute, CallLogic, TypeAnnotation } from '..';
|
|
11
11
|
import { ElementToVueOptions } from './ViewElement__';
|
|
12
12
|
import { findConceptKeyWordByNamespace } from '../utils';
|
|
13
|
-
import type View from './View__';
|
|
14
|
-
import BusinessComponent from './BusinessComponent__';
|
|
15
|
-
import FrontendType from './FrontendType__';
|
|
16
13
|
|
|
17
14
|
//================================================================================
|
|
18
15
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
@@ -81,20 +78,15 @@ export class Identifier extends LogicItem {
|
|
|
81
78
|
globalDataMap: {
|
|
82
79
|
[name: string]: boolean;
|
|
83
80
|
} = {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
81
|
+
$route: true,
|
|
82
|
+
$global: true,
|
|
83
|
+
$refs: true,
|
|
84
|
+
};
|
|
88
85
|
|
|
89
86
|
isEnum() {
|
|
90
87
|
return findConceptKeyWordByNamespace(this.namespace) === 'enums';
|
|
91
88
|
}
|
|
92
89
|
|
|
93
|
-
get isFrontendVariables() {
|
|
94
|
-
const frontendType = this.getAncestor('FrontendType') as FrontendType;
|
|
95
|
-
return this.namespace?.startsWith(`app.frontendTypes.${frontendType?.kind}.frontends`) && this.namespace?.endsWith('variables');
|
|
96
|
-
}
|
|
97
|
-
|
|
98
90
|
toVue(options?: ElementToVueOptions): string {
|
|
99
91
|
let { name } = this;
|
|
100
92
|
const { namespace } = this;
|
|
@@ -106,7 +98,7 @@ export class Identifier extends LogicItem {
|
|
|
106
98
|
this.namespace.endsWith('nasl.process')
|
|
107
99
|
) {
|
|
108
100
|
name = `$global.${this.name}`;
|
|
109
|
-
} else if (this.
|
|
101
|
+
} else if (this.namespace.startsWith('app.frontends') && this.namespace.endsWith('variables')) {
|
|
110
102
|
name = `$global.frontendVariables.${this.name}`;
|
|
111
103
|
} else if (this.isEnum()) {
|
|
112
104
|
let enumName = this.name;
|
|
@@ -127,7 +119,7 @@ export class Identifier extends LogicItem {
|
|
|
127
119
|
if (namespace) {
|
|
128
120
|
if (namespace.startsWith('nasl.')) {
|
|
129
121
|
name = `${namespace}.${this.name}`;
|
|
130
|
-
} else if (
|
|
122
|
+
} else if (namespace.startsWith('app.frontends') && namespace.endsWith('variables')) {
|
|
131
123
|
name = `nasl.frontendVariables.${this.name}`;
|
|
132
124
|
} else if (this.isEnum()) {
|
|
133
125
|
let enumName = this.name;
|
|
@@ -152,7 +144,7 @@ export class Identifier extends LogicItem {
|
|
|
152
144
|
this.namespace.endsWith('nasl.process')
|
|
153
145
|
) {
|
|
154
146
|
name = `$global.${this.name}`;
|
|
155
|
-
} else if (
|
|
147
|
+
} else if (namespace.startsWith('app.frontends') && namespace.endsWith('variables')) {
|
|
156
148
|
name = `$global.frontendVariables.${this.name}`;
|
|
157
149
|
} else if (this.isEnum()) {
|
|
158
150
|
let enumName = this.name;
|
|
@@ -175,23 +167,19 @@ export class Identifier extends LogicItem {
|
|
|
175
167
|
return this.isViewOrGlobalDataVariable() ? `this.${name}` : name;
|
|
176
168
|
}
|
|
177
169
|
|
|
178
|
-
get likeComponent(): View | BusinessComponent {
|
|
179
|
-
return this.view || (this?.getAncestor('BusinessComponent') as BusinessComponent);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
170
|
// 页面/全局 级别的变量
|
|
183
171
|
isViewOrGlobalDataVariable() {
|
|
184
172
|
const dataMap: {
|
|
185
173
|
[name: string]: boolean;
|
|
186
174
|
} = {};
|
|
187
|
-
this.
|
|
175
|
+
this.view?.params?.forEach((param) => {
|
|
188
176
|
dataMap[param.name] = true;
|
|
189
177
|
});
|
|
190
|
-
this.
|
|
178
|
+
this.view?.variables?.forEach((variable) => {
|
|
191
179
|
dataMap[variable.name] = true;
|
|
192
180
|
});
|
|
193
181
|
// 目前前端逻辑也会被当成可选变量(以datasource为典型)
|
|
194
|
-
this.
|
|
182
|
+
this.view?.logics?.forEach((logics) => {
|
|
195
183
|
dataMap[logics.name] = true;
|
|
196
184
|
});
|
|
197
185
|
const { parentNode, namespace, jsName: name } = this;
|
|
@@ -207,7 +195,7 @@ export class Identifier extends LogicItem {
|
|
|
207
195
|
namespace?.endsWith('nasl.auth') ||
|
|
208
196
|
namespace?.endsWith('nasl.configuration') ||
|
|
209
197
|
namespace?.endsWith('nasl.process') ||
|
|
210
|
-
(
|
|
198
|
+
(namespace?.startsWith('app.frontends') && namespace?.endsWith('variables')) ||
|
|
211
199
|
this.isEnum()) &&
|
|
212
200
|
!isMemberExpressionProperty
|
|
213
201
|
);
|
|
@@ -217,10 +205,6 @@ export class Identifier extends LogicItem {
|
|
|
217
205
|
return this.name || '-';
|
|
218
206
|
}
|
|
219
207
|
|
|
220
|
-
get businessComponent() {
|
|
221
|
-
return this.getAncestor('BusinessComponent') as BusinessComponent;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
208
|
@withSourceMapGenerator
|
|
225
209
|
*toEmbeddedTS(state = createCompilerState(), options?: any): TranslatorGenerator {
|
|
226
210
|
const self = this;
|
|
@@ -230,7 +214,7 @@ export class Identifier extends LogicItem {
|
|
|
230
214
|
}
|
|
231
215
|
// 只有data-source可以是函数 ,也可能是属性
|
|
232
216
|
if (asserts.isBindAttribute(self.parentNode) && self.parentNode.name === 'data-source') {
|
|
233
|
-
const view = self
|
|
217
|
+
const { view } = self;
|
|
234
218
|
const viewLogics = view.logics;
|
|
235
219
|
const findLogic = viewLogics.find((item) => item.name === self.name);
|
|
236
220
|
if (findLogic) {
|
|
@@ -238,7 +222,7 @@ export class Identifier extends LogicItem {
|
|
|
238
222
|
}
|
|
239
223
|
}
|
|
240
224
|
// 全局变量在不是页面的地方放置,就会报错
|
|
241
|
-
if (self.
|
|
225
|
+
if (self.namespace?.startsWith('app.frontends') && self.namespace?.endsWith('variables') && !self.frontend) {
|
|
242
226
|
return '__FRONTENDVARIABLES__';
|
|
243
227
|
}
|
|
244
228
|
// 如果是nasl.util.Enum 的子集里的 Identifier > MemberExpression > Argument > callfunction
|
package/src/concepts/Logic__.ts
CHANGED
|
@@ -33,7 +33,6 @@ import type CallInterface from './CallInterface__';
|
|
|
33
33
|
import type CallLogic from './CallLogic__';
|
|
34
34
|
import { CUSTOM_CONNECTOR_EDITABLE_SUFFIX } from './basics/constants';
|
|
35
35
|
import type Interface from './Interface__';
|
|
36
|
-
import type BusinessComponent from './BusinessComponent__';
|
|
37
36
|
|
|
38
37
|
//================================================================================
|
|
39
38
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
@@ -77,7 +76,7 @@ export class Logic extends BaseNode {
|
|
|
77
76
|
*/
|
|
78
77
|
@property('concept')
|
|
79
78
|
// @ts-ignore
|
|
80
|
-
readonly concept!: 'Logic' | 'AuthLogic' | 'AuthLogicForCallInterface'
|
|
79
|
+
readonly concept!: 'Logic' | 'AuthLogic' | 'AuthLogicForCallInterface';
|
|
81
80
|
|
|
82
81
|
/**
|
|
83
82
|
* 逻辑名称
|
|
@@ -1546,15 +1545,15 @@ export class Logic extends BaseNode {
|
|
|
1546
1545
|
if (Array.isArray(this.variables)) {
|
|
1547
1546
|
varList.push(...this.variables);
|
|
1548
1547
|
}
|
|
1549
|
-
if (this.
|
|
1550
|
-
//
|
|
1548
|
+
if (this.view) {
|
|
1549
|
+
// 页面下,变量名不可以跟逻辑名相同,会有js 翻译问题
|
|
1551
1550
|
varList.push(this);
|
|
1552
1551
|
|
|
1553
|
-
if (Array.isArray(this.
|
|
1554
|
-
varList.push(...this.
|
|
1552
|
+
if (Array.isArray(this.view.params)) {
|
|
1553
|
+
varList.push(...this.view.params);
|
|
1555
1554
|
}
|
|
1556
|
-
if (Array.isArray(this.
|
|
1557
|
-
varList.push(...this.
|
|
1555
|
+
if (Array.isArray(this.view.variables)) {
|
|
1556
|
+
varList.push(...this.view.variables);
|
|
1558
1557
|
}
|
|
1559
1558
|
}
|
|
1560
1559
|
|
|
@@ -1806,11 +1805,11 @@ export class Logic extends BaseNode {
|
|
|
1806
1805
|
const IDENTIFIERMAP = new Set<Variable | Return>();
|
|
1807
1806
|
|
|
1808
1807
|
if (!prefix) {
|
|
1809
|
-
code += `export function ${self.
|
|
1808
|
+
code += `export function ${self.name}`;
|
|
1810
1809
|
} else if (prefix === 'noExport') {
|
|
1811
|
-
code += `function ${self.
|
|
1810
|
+
code += `function ${self.name}`;
|
|
1812
1811
|
} else if (prefix === 'inObject') {
|
|
1813
|
-
code += `${self.
|
|
1812
|
+
code += `${self.name}`;
|
|
1814
1813
|
}
|
|
1815
1814
|
if (self.typeParams?.length) {
|
|
1816
1815
|
code += '<';
|
|
@@ -2370,12 +2369,10 @@ ${indent(state.tabSize)} */\n`;
|
|
|
2370
2369
|
}
|
|
2371
2370
|
if (asserts.isFrontendLibrary(this.parentNode)) {
|
|
2372
2371
|
_path += `/frontends/${this.parentNode.type}`;
|
|
2373
|
-
} else if (this.parentNode.concept === 'BindEvent' && this.
|
|
2374
|
-
_path += `/
|
|
2375
|
-
this.getAncestor('Frontend')?.name
|
|
2376
|
-
}/bindEvents/${name}.ts`;
|
|
2372
|
+
} else if (this.parentNode.concept === 'BindEvent' && this.parentNode?.parentNode.concept === 'Frontend') {
|
|
2373
|
+
_path += `/frontends/${this.parentNode.parentNode.name}/bindEvents/${name}.ts`;
|
|
2377
2374
|
}
|
|
2378
|
-
return `/embedded/${this.
|
|
2375
|
+
return `/embedded/${this.app.name}${_path}/logics/${name}.ts`;
|
|
2379
2376
|
}
|
|
2380
2377
|
|
|
2381
2378
|
*toEmbeddedTSFile(): EmbeddedTSFileGenerator {
|
|
@@ -2493,7 +2490,7 @@ ${indent(state.tabSize)} */\n`;
|
|
|
2493
2490
|
}
|
|
2494
2491
|
|
|
2495
2492
|
get pathName(): string {
|
|
2496
|
-
if (this.
|
|
2493
|
+
if (this.view) {
|
|
2497
2494
|
return this.getEventLogicName('chinese');
|
|
2498
2495
|
}
|
|
2499
2496
|
|
|
@@ -2583,10 +2580,6 @@ ${indent(state.tabSize)} */\n`;
|
|
|
2583
2580
|
return this.getAncestor('Integration');
|
|
2584
2581
|
}
|
|
2585
2582
|
|
|
2586
|
-
get likeComponent(): View | BusinessComponent {
|
|
2587
|
-
return this.view || (this?.getAncestor('BusinessComponent') as BusinessComponent);
|
|
2588
|
-
}
|
|
2589
|
-
|
|
2590
2583
|
//================================================================================
|
|
2591
2584
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
2592
2585
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -276,7 +276,7 @@ export class MemberExpression extends LogicItem {
|
|
|
276
276
|
(this.object as Identifier)?.isEnum() &&
|
|
277
277
|
this.property?.concept === 'Identifier'
|
|
278
278
|
) {
|
|
279
|
-
return this.isDefaultValueExpression(
|
|
279
|
+
return this.isDefaultValueExpression() ? this.property?.name : `"${this.property?.name}"`;
|
|
280
280
|
}
|
|
281
281
|
if (
|
|
282
282
|
this.object?.__TypeAnnotation?.sortedTypeKey?.startsWith('nasl.collection.Map') &&
|
|
@@ -379,8 +379,8 @@ export class MemberExpression extends LogicItem {
|
|
|
379
379
|
return (this.object as Identifier)?.isEnum?.();
|
|
380
380
|
}
|
|
381
381
|
|
|
382
|
-
isDefaultValueExpression(
|
|
383
|
-
return this.parentNode instanceof DefaultValue
|
|
382
|
+
isDefaultValueExpression() {
|
|
383
|
+
return this.parentNode instanceof DefaultValue;
|
|
384
384
|
}
|
|
385
385
|
|
|
386
386
|
// 方便快速取值,遍历获取value
|
|
@@ -1179,11 +1179,13 @@ export class NewComposite extends LogicItem {
|
|
|
1179
1179
|
} else if (typeAnnotation.typeKind !== 'anonymousStructure') {
|
|
1180
1180
|
// 实体、数据结构默认值使用new时需要改成vue.prototype才能获取到方法
|
|
1181
1181
|
if (state?.getVuePrototype) {
|
|
1182
|
-
code += `const obj = Vue.prototype.$genInitFromSchema('${
|
|
1183
|
-
|
|
1182
|
+
code += `const obj = Vue.prototype.$genInitFromSchema('${
|
|
1183
|
+
typeAnnotation.sortedTypeKey
|
|
1184
|
+
}', Vue.prototype.$utils['New'](${typeAnnotation.toJS(state)}));\n`;
|
|
1184
1185
|
} else {
|
|
1185
|
-
code += `const obj = this.$genInitFromSchema('${
|
|
1186
|
-
|
|
1186
|
+
code += `const obj = this.$genInitFromSchema('${
|
|
1187
|
+
typeAnnotation.sortedTypeKey
|
|
1188
|
+
}', this.$utils['New'](${typeAnnotation.toJS(state)}));\n`;
|
|
1187
1189
|
}
|
|
1188
1190
|
const rightMap = new Map();
|
|
1189
1191
|
this.assignmentLines.forEach(({ leftIndex, rightIndex }) => {
|
package/src/concepts/Param__.ts
CHANGED
|
@@ -361,25 +361,17 @@ export class Param extends BaseNode {
|
|
|
361
361
|
toJS(state?: TranslatorState): string {
|
|
362
362
|
if (this.view) {
|
|
363
363
|
const typeAnnotation = this.typeAnnotation || this.__TypeAnnotation;
|
|
364
|
-
let { sortedTypeKey, typeKind, typeName, typeNamespace } = typeAnnotation || {};
|
|
365
|
-
if (typeNamespace?.endsWith('.metadataTypes')) {
|
|
366
|
-
const referenceNode = this.app.findNodeByCompleteName(typeNamespace + '.' + typeName) || {};
|
|
367
|
-
const typeAn = referenceNode.typeAnnotation || {};
|
|
368
|
-
sortedTypeKey = `${typeAn.typeNamespace}.${typeAn.typeName}`;
|
|
369
|
-
typeKind = typeAn.typeKind;
|
|
370
|
-
typeName = typeAn.typeName;
|
|
371
|
-
}
|
|
372
364
|
const needGenInitFromSchema =
|
|
373
365
|
typeAnnotation &&
|
|
374
|
-
(!['primitive', 'union'].includes(typeKind) || typeName === 'DateTime');
|
|
366
|
+
(!['primitive', 'union'].includes(typeAnnotation.typeKind) || typeAnnotation.typeName === 'DateTime');
|
|
375
367
|
let code = `${this.name} = `;
|
|
376
368
|
if (needGenInitFromSchema) {
|
|
377
|
-
code += `this.$genInitFromSchema('${sortedTypeKey}',`;
|
|
369
|
+
code += `this.$genInitFromSchema('${typeAnnotation?.sortedTypeKey}',`;
|
|
378
370
|
}
|
|
379
371
|
|
|
380
372
|
const expressionJS = this.defaultValue?.toJS?.();
|
|
381
373
|
|
|
382
|
-
code += `${this.name} || (this.$route.query.hasOwnProperty('${this.name}') ? this.$genInitFromSchema('${sortedTypeKey}', this.$route.query.${this.name}) : ${expressionJS})`;
|
|
374
|
+
code += `${this.name} || (this.$route.query.hasOwnProperty('${this.name}') ? this.$genInitFromSchema('${typeAnnotation?.sortedTypeKey}', this.$route.query.${this.name}) : ${expressionJS})`;
|
|
383
375
|
if (needGenInitFromSchema) {
|
|
384
376
|
code += `)`;
|
|
385
377
|
}
|
|
@@ -1915,14 +1915,7 @@ export class ProcessElement extends BaseNode {
|
|
|
1915
1915
|
if (Array.isArray(self.bindEvents)) {
|
|
1916
1916
|
yield* wrapForEach(self.bindEvents, function* warpForEachGenerator(bindEvent) {
|
|
1917
1917
|
// 任务完成时可以拿到输出参数
|
|
1918
|
-
|
|
1919
|
-
if(bindEvent.name !== 'OnClose') {
|
|
1920
|
-
currentPrevCode = prevCode;
|
|
1921
|
-
// 除了任务完成时的逻辑,其他逻辑拿不到自己任务下的输出参数,所以不需要__ProcessIdentification__标注
|
|
1922
|
-
currentPrevCode = currentPrevCode.replace('__ProcessIdentification__', '');
|
|
1923
|
-
} else {
|
|
1924
|
-
currentPrevCode = prevCodeClose;
|
|
1925
|
-
}
|
|
1918
|
+
const currentPrevCode = bindEvent.name === 'OnClose' ? prevCodeClose : prevCode;
|
|
1926
1919
|
code += `${tab1}${bindEvent.name}: () => [\n`;
|
|
1927
1920
|
yield* wrapForEach(bindEvent.logics, function* warpForEachGenerator(logic) {
|
|
1928
1921
|
code += `${yield* logic.toEmbeddedTSInProcess(
|
package/src/concepts/Return__.ts
CHANGED
|
@@ -322,20 +322,12 @@ export class Return extends BaseNode {
|
|
|
322
322
|
toJS(state?: TranslatorState): string {
|
|
323
323
|
const context = this.view ? 'this' : 'Vue.prototype';
|
|
324
324
|
const typeAnnotation = this.typeAnnotation || this.__TypeAnnotation;
|
|
325
|
-
let { sortedTypeKey, typeKind, typeName, typeNamespace } = typeAnnotation || {};
|
|
326
|
-
if (typeNamespace?.endsWith('.metadataTypes')) {
|
|
327
|
-
const referenceNode = this.app.findNodeByCompleteName(typeNamespace + '.' + typeName) || {};
|
|
328
|
-
const typeAn = referenceNode.typeAnnotation || {};
|
|
329
|
-
sortedTypeKey = `${typeAn.typeNamespace}.${typeAn.typeName}`;
|
|
330
|
-
typeKind = typeAn.typeKind;
|
|
331
|
-
typeName = typeAn.typeName;
|
|
332
|
-
}
|
|
333
325
|
const needGenInitFromSchema =
|
|
334
326
|
typeAnnotation &&
|
|
335
|
-
(!['primitive', 'union'].includes(typeKind) || typeName === 'DateTime');
|
|
327
|
+
(!['primitive', 'union'].includes(typeAnnotation.typeKind) || typeAnnotation.typeName === 'DateTime');
|
|
336
328
|
let code = `${this.name} = `;
|
|
337
329
|
if (needGenInitFromSchema) {
|
|
338
|
-
code += `${context}.$genInitFromSchema('${sortedTypeKey}',`;
|
|
330
|
+
code += `${context}.$genInitFromSchema('${typeAnnotation?.sortedTypeKey}',`;
|
|
339
331
|
}
|
|
340
332
|
|
|
341
333
|
if (this.defaultValue?.expression) {
|
|
@@ -409,13 +401,18 @@ export class Return extends BaseNode {
|
|
|
409
401
|
let code = this.name;
|
|
410
402
|
if (this.typeAnnotation) {
|
|
411
403
|
code += `: `;
|
|
412
|
-
if (
|
|
413
|
-
|
|
404
|
+
if (
|
|
405
|
+
this.defaultValue?.expression &&
|
|
406
|
+
!(
|
|
407
|
+
this.typeAnnotation &&
|
|
408
|
+
['nasl.core.DateTime', 'nasl.core.Time', 'nasl.core.Date'].includes(this.typeAnnotation.typeKey)
|
|
409
|
+
)
|
|
410
|
+
) {
|
|
411
|
+
code += `${yield* this.defaultValue.toEmbeddedTS(shiftState(state, code))}`;
|
|
412
|
+
} else {
|
|
413
|
+
if (['nasl.core.DateTime', 'nasl.core.Time', 'nasl.core.Date'].includes(this.typeAnnotation?.typeKey)) {
|
|
414
414
|
code += yield* this.defaultValue.toEmbeddedTS(shiftState(state, code), true);
|
|
415
|
-
} else {
|
|
416
|
-
code += `${yield* this.defaultValue.toEmbeddedTS(shiftState(state, code))}`;
|
|
417
415
|
}
|
|
418
|
-
} else {
|
|
419
416
|
code += 'undefined';
|
|
420
417
|
}
|
|
421
418
|
code += ' as ';
|