@nestia/sdk 1.6.7-dev.20230830 → 2.0.0-dev.20230830
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/assets/config/nestia.config.ts +15 -40
- package/lib/executable/internal/NestiaSdkConfig.js +4 -0
- package/lib/executable/internal/NestiaSdkConfig.js.map +1 -1
- package/lib/generates/E2eGenerator.js +2 -1
- package/lib/generates/E2eGenerator.js.map +1 -1
- package/lib/generates/SwaggerGenerator.js +10 -10
- package/lib/generates/internal/E2eFileProgrammer.d.ts +2 -1
- package/lib/generates/internal/E2eFileProgrammer.js +30 -19
- package/lib/generates/internal/E2eFileProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkFileProgrammer.js +14 -30
- package/lib/generates/internal/SdkFileProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkFunctionProgrammer.d.ts +2 -1
- package/lib/generates/internal/SdkFunctionProgrammer.js +72 -26
- package/lib/generates/internal/SdkFunctionProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkSimulationProgrammer.d.ts +3 -1
- package/lib/generates/internal/SdkSimulationProgrammer.js +42 -24
- package/lib/generates/internal/SdkSimulationProgrammer.js.map +1 -1
- package/lib/utils/ImportDictionary.d.ts +16 -2
- package/lib/utils/ImportDictionary.js +66 -25
- package/lib/utils/ImportDictionary.js.map +1 -1
- package/package.json +5 -5
- package/src/generates/E2eGenerator.ts +4 -1
- package/src/generates/internal/E2eFileProgrammer.ts +36 -19
- package/src/generates/internal/SdkFileProgrammer.ts +20 -56
- package/src/generates/internal/SdkFunctionProgrammer.ts +85 -24
- package/src/generates/internal/SdkSimulationProgrammer.ts +107 -73
- package/src/utils/ImportDictionary.ts +97 -33
|
@@ -4,53 +4,117 @@ import { HashSet } from "tstl/container/HashSet";
|
|
|
4
4
|
import { Pair } from "tstl/utility/Pair";
|
|
5
5
|
|
|
6
6
|
export class ImportDictionary {
|
|
7
|
-
private readonly
|
|
7
|
+
private readonly externals_: HashMap<Pair<string, boolean>, IComposition> =
|
|
8
|
+
new HashMap();
|
|
9
|
+
private readonly internals_: HashMap<Pair<string, boolean>, IComposition> =
|
|
8
10
|
new HashMap();
|
|
9
11
|
|
|
10
12
|
public empty(): boolean {
|
|
11
|
-
return this.
|
|
13
|
+
return this.internals_.empty() && this.externals_.empty();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
public external(props: ImportDictionary.IExternalProps): string {
|
|
17
|
+
const composition: IComposition = this.externals_.take(
|
|
18
|
+
new Pair(props.library, props.type),
|
|
19
|
+
() => ({
|
|
20
|
+
location: props.library,
|
|
21
|
+
elements: new HashSet(),
|
|
22
|
+
default: false,
|
|
23
|
+
type: props.type,
|
|
24
|
+
}),
|
|
25
|
+
);
|
|
26
|
+
if (props.instance === null) composition.default = true;
|
|
27
|
+
else composition.elements.insert(props.instance);
|
|
28
|
+
return props.instance ?? props.library;
|
|
12
29
|
}
|
|
13
30
|
|
|
14
|
-
public
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
31
|
+
public internal(props: ImportDictionary.IInternalProps): string {
|
|
32
|
+
const file: string = (() => {
|
|
33
|
+
if (props.file.substring(props.file.length - 5) === ".d.ts")
|
|
34
|
+
return props.file.substring(0, props.file.length - 5);
|
|
35
|
+
else if (props.file.substring(0, props.file.length - 3) === ".ts")
|
|
36
|
+
return props.file.substring(0, props.file.length - 3);
|
|
19
37
|
throw new Error(
|
|
20
|
-
`Error on ImportDictionary.emplace(): extension of the target file "${file}" is not "ts".`,
|
|
38
|
+
`Error on ImportDictionary.emplace(): extension of the target file "${props.file}" is not "ts".`,
|
|
21
39
|
);
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
file,
|
|
25
|
-
() =>
|
|
40
|
+
})();
|
|
41
|
+
const composition: IComposition = this.internals_.take(
|
|
42
|
+
new Pair(file, props.type),
|
|
43
|
+
() => ({
|
|
44
|
+
location: file,
|
|
45
|
+
elements: new HashSet(),
|
|
46
|
+
default: false,
|
|
47
|
+
type: props.type,
|
|
48
|
+
}),
|
|
26
49
|
);
|
|
27
|
-
|
|
50
|
+
if (props.instance === null) composition.default = true;
|
|
51
|
+
else composition.elements.insert(props.instance);
|
|
52
|
+
return props.instance ?? file;
|
|
28
53
|
}
|
|
29
54
|
|
|
30
55
|
public toScript(outDir: string): string {
|
|
31
56
|
const statements: string[] = [];
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
.
|
|
37
|
-
.
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
57
|
+
const enroll =
|
|
58
|
+
(locator: (str: string) => string) =>
|
|
59
|
+
(dict: HashMap<Pair<string, boolean>, IComposition>) => {
|
|
60
|
+
const compositions: IComposition[] = dict
|
|
61
|
+
.toJSON()
|
|
62
|
+
.map((e) => ({
|
|
63
|
+
...e.second,
|
|
64
|
+
location: locator(e.second.location),
|
|
65
|
+
}))
|
|
66
|
+
.sort((a, b) => a.location.localeCompare(b.location));
|
|
67
|
+
for (const c of compositions) {
|
|
68
|
+
const brackets: string[] = [];
|
|
69
|
+
if (c.default) brackets.push(c.location);
|
|
70
|
+
if (c.elements.empty() === false)
|
|
71
|
+
brackets.push(
|
|
72
|
+
`{${c.elements
|
|
73
|
+
.toJSON()
|
|
74
|
+
.sort((a, b) => a.localeCompare(b))
|
|
75
|
+
.join(", ")}`,
|
|
76
|
+
);
|
|
77
|
+
statements.push(
|
|
78
|
+
`import ${c.type ? "type " : ""} ${brackets.join(
|
|
79
|
+
", ",
|
|
80
|
+
)} from "${c.location}";`,
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
enroll((str) => str)(this.externals_);
|
|
86
|
+
if (this.internals_.size()) statements.push("");
|
|
87
|
+
enroll((str) => {
|
|
88
|
+
const location: string = path
|
|
89
|
+
.relative(outDir, str)
|
|
90
|
+
.split("\\")
|
|
91
|
+
.join("/");
|
|
92
|
+
const index: number = location.lastIndexOf(NODE_MODULES);
|
|
93
|
+
return index === -1
|
|
94
|
+
? `./${location}`
|
|
95
|
+
: location.substring(index + NODE_MODULES.length);
|
|
96
|
+
})(this.internals_);
|
|
52
97
|
return statements.join("\n");
|
|
53
98
|
}
|
|
54
99
|
}
|
|
100
|
+
export namespace ImportDictionary {
|
|
101
|
+
export interface IInternalProps {
|
|
102
|
+
type: boolean;
|
|
103
|
+
file: string;
|
|
104
|
+
instance: string;
|
|
105
|
+
}
|
|
106
|
+
export interface IExternalProps {
|
|
107
|
+
type: boolean;
|
|
108
|
+
library: string;
|
|
109
|
+
instance: string | null;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
interface IComposition {
|
|
114
|
+
location: string;
|
|
115
|
+
type: boolean;
|
|
116
|
+
default: boolean;
|
|
117
|
+
elements: HashSet<string>;
|
|
118
|
+
}
|
|
55
119
|
|
|
56
120
|
const NODE_MODULES = "node_modules/";
|