@nestia/sdk 1.3.2 → 1.3.3
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 +70 -70
- package/lib/INestiaConfig.d.ts +13 -0
- package/lib/executable/internal/NestiaSdkConfig.js +6 -2
- package/lib/executable/internal/NestiaSdkConfig.js.map +1 -1
- package/lib/executable/sdk.js +11 -11
- package/lib/generates/SwaggerGenerator.js +9 -9
- package/lib/generates/internal/DistributionComposer.js +1 -1
- package/lib/generates/internal/DistributionComposer.js.map +1 -1
- package/lib/generates/internal/E2eFileProgrammer.js +12 -12
- package/lib/generates/internal/SdkFileProgrammer.js +3 -1
- package/lib/generates/internal/SdkFileProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkFunctionProgrammer.js +24 -43
- package/lib/generates/internal/SdkFunctionProgrammer.js.map +1 -1
- package/package.json +4 -4
- package/src/INestiaConfig.ts +204 -190
- package/src/NestiaSdkApplication.ts +262 -262
- package/src/analyses/ControllerAnalyzer.ts +261 -261
- package/src/analyses/GenericAnalyzer.ts +53 -53
- package/src/analyses/ImportAnalyzer.ts +164 -164
- package/src/analyses/PathAnalyzer.ts +58 -58
- package/src/analyses/ReflectAnalyzer.ts +321 -321
- package/src/executable/internal/CommandParser.ts +15 -15
- package/src/executable/internal/NestiaConfigCompilerOptions.ts +18 -18
- package/src/executable/internal/NestiaSdkCommand.ts +156 -156
- package/src/executable/internal/NestiaSdkConfig.ts +36 -36
- package/src/executable/internal/nestia.config.getter.ts +12 -12
- package/src/executable/sdk.ts +70 -70
- package/src/generates/E2eGenerator.ts +67 -67
- package/src/generates/SdkGenerator.ts +56 -56
- package/src/generates/SwaggerGenerator.ts +504 -504
- package/src/generates/internal/DistributionComposer.ts +98 -97
- package/src/generates/internal/E2eFileProgrammer.ts +135 -135
- package/src/generates/internal/SdkFileProgrammer.ts +148 -144
- package/src/generates/internal/SdkFunctionProgrammer.ts +30 -52
- package/src/generates/internal/SdkRouteDirectory.ts +21 -21
- package/src/index.ts +4 -4
- package/src/module.ts +2 -2
- package/src/structures/IController.ts +31 -31
- package/src/structures/IRoute.ts +39 -39
- package/src/structures/ISwaggerDocument.ts +120 -120
- package/src/structures/ITypeTuple.ts +6 -6
- package/src/structures/MethodType.ts +11 -11
- package/src/structures/ParamCategory.ts +1 -1
- package/src/structures/TypeEntry.ts +22 -22
- package/src/utils/ArrayUtil.ts +26 -26
- package/src/utils/FileRetriever.ts +22 -22
- package/src/utils/ImportDictionary.ts +56 -56
- package/src/utils/MapUtil.ts +14 -14
- package/src/utils/NestiaConfigUtil.ts +21 -21
- package/src/utils/SourceFinder.ts +60 -60
- package/src/utils/StripEnums.ts +10 -10
|
@@ -1,97 +1,98 @@
|
|
|
1
|
-
import cp from "child_process";
|
|
2
|
-
import fs from "fs";
|
|
3
|
-
import path from "path";
|
|
4
|
-
|
|
5
|
-
import { INestiaConfig } from "../../INestiaConfig";
|
|
6
|
-
|
|
7
|
-
export namespace DistributionComposer {
|
|
8
|
-
export const compose = async (config: INestiaConfig): Promise<void> => {
|
|
9
|
-
if (!fs.existsSync(config.distribute!))
|
|
10
|
-
await fs.promises.mkdir(config.distribute!);
|
|
11
|
-
|
|
12
|
-
const root: string = process.cwd();
|
|
13
|
-
const output: string = path.resolve(config.output!);
|
|
14
|
-
process.chdir(config.distribute!);
|
|
15
|
-
|
|
16
|
-
const exit = () => {
|
|
17
|
-
process.chdir(root);
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const typia: boolean =
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
execute("npm install --save
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
execute("
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
await fs.promises.
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
.
|
|
88
|
-
.
|
|
89
|
-
.
|
|
90
|
-
.
|
|
91
|
-
.
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
1
|
+
import cp from "child_process";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
|
|
5
|
+
import { INestiaConfig } from "../../INestiaConfig";
|
|
6
|
+
|
|
7
|
+
export namespace DistributionComposer {
|
|
8
|
+
export const compose = async (config: INestiaConfig): Promise<void> => {
|
|
9
|
+
if (!fs.existsSync(config.distribute!))
|
|
10
|
+
await fs.promises.mkdir(config.distribute!);
|
|
11
|
+
|
|
12
|
+
const root: string = process.cwd();
|
|
13
|
+
const output: string = path.resolve(config.output!);
|
|
14
|
+
process.chdir(config.distribute!);
|
|
15
|
+
|
|
16
|
+
const exit = () => {
|
|
17
|
+
process.chdir(root);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const typia: boolean =
|
|
21
|
+
!!config.assert || !!config.json || !!config.random;
|
|
22
|
+
const done: boolean = await configured({
|
|
23
|
+
typia,
|
|
24
|
+
distribute: config.distribute!,
|
|
25
|
+
});
|
|
26
|
+
if (done) return exit();
|
|
27
|
+
|
|
28
|
+
// COPY FILES
|
|
29
|
+
console.log("Composing SDK distribution environments...");
|
|
30
|
+
for (const file of await fs.promises.readdir(BUNDLE))
|
|
31
|
+
await fs.promises.copyFile(`${BUNDLE}/${file}`, file);
|
|
32
|
+
|
|
33
|
+
// CONFIGURE PATHS
|
|
34
|
+
for (const file of ["package.json", "tsconfig.json"])
|
|
35
|
+
await replace({ root, output })(file);
|
|
36
|
+
|
|
37
|
+
// INSTALL PACKAGES
|
|
38
|
+
execute("npm install --save-dev rimraf");
|
|
39
|
+
execute("npm install --save @nestia/fetcher@latest");
|
|
40
|
+
|
|
41
|
+
if (typia) {
|
|
42
|
+
execute("npm install --save typia@latest");
|
|
43
|
+
execute("npx typia setup --manager npm");
|
|
44
|
+
} else execute("npm install --save-dev typescript");
|
|
45
|
+
|
|
46
|
+
exit();
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const configured = async (config: {
|
|
50
|
+
typia: boolean;
|
|
51
|
+
distribute: string;
|
|
52
|
+
}): Promise<boolean> =>
|
|
53
|
+
["package.json", "tsconfig.json"].every(fs.existsSync) &&
|
|
54
|
+
(await (async () => {
|
|
55
|
+
const content = JSON.parse(
|
|
56
|
+
await fs.promises.readFile("package.json", "utf8"),
|
|
57
|
+
);
|
|
58
|
+
return (
|
|
59
|
+
!!content.dependencies?.["@nestia/fetcher"] &&
|
|
60
|
+
(config.typia === false || !!content.dependencies?.["typia"])
|
|
61
|
+
);
|
|
62
|
+
})()) &&
|
|
63
|
+
(config.typia === false ||
|
|
64
|
+
(await (async () => {
|
|
65
|
+
const content = await fs.promises.readFile("tsconfig.json");
|
|
66
|
+
return content.includes("typia/lib/transform");
|
|
67
|
+
})()));
|
|
68
|
+
|
|
69
|
+
const execute = (command: string) => {
|
|
70
|
+
console.log(` - ${command}`);
|
|
71
|
+
cp.execSync(command, { stdio: "ignore" });
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const replace =
|
|
75
|
+
(props: { root: string; output: string }) =>
|
|
76
|
+
async (file: string): Promise<void> => {
|
|
77
|
+
const relative = (from: string) => (to: string) =>
|
|
78
|
+
path.relative(from, to).split("\\").join("/");
|
|
79
|
+
const root: string = relative(process.cwd())(props.root);
|
|
80
|
+
const output: string = relative(process.cwd())(props.output);
|
|
81
|
+
const current: string = relative(props.root)(process.cwd());
|
|
82
|
+
|
|
83
|
+
const content: string = await fs.promises.readFile(file, "utf8");
|
|
84
|
+
await fs.promises.writeFile(
|
|
85
|
+
file,
|
|
86
|
+
content
|
|
87
|
+
.split("${root}")
|
|
88
|
+
.join(root)
|
|
89
|
+
.split("${output}")
|
|
90
|
+
.join(output)
|
|
91
|
+
.split("${current}")
|
|
92
|
+
.join(current),
|
|
93
|
+
"utf8",
|
|
94
|
+
);
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const BUNDLE = __dirname + "/../../../assets/bundle/distribute";
|
|
@@ -1,135 +1,135 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import path from "path";
|
|
3
|
-
|
|
4
|
-
import { INestiaConfig } from "../../INestiaConfig";
|
|
5
|
-
import { IRoute } from "../../structures/IRoute";
|
|
6
|
-
import { ImportDictionary } from "../../utils/ImportDictionary";
|
|
7
|
-
|
|
8
|
-
export namespace E2eFileProgrammer {
|
|
9
|
-
export const generate =
|
|
10
|
-
(config: INestiaConfig) =>
|
|
11
|
-
(props: { api: string; current: string }) =>
|
|
12
|
-
async (route: IRoute): Promise<void> => {
|
|
13
|
-
const importDict: ImportDictionary = new ImportDictionary();
|
|
14
|
-
for (const tuple of route.imports)
|
|
15
|
-
for (const instance of tuple[1])
|
|
16
|
-
importDict.emplace(tuple[0], false, instance);
|
|
17
|
-
|
|
18
|
-
const additional: string[] = [];
|
|
19
|
-
for (const param of route.parameters)
|
|
20
|
-
if (param.category === "param")
|
|
21
|
-
if (param.meta?.type === "uuid") additional.push(UUID);
|
|
22
|
-
else if (param.meta?.type === "date") additional.push(DATE);
|
|
23
|
-
const content: string = [
|
|
24
|
-
...(route.parameters.length || route.output.name !== "void"
|
|
25
|
-
? [
|
|
26
|
-
config.primitive === false
|
|
27
|
-
? `import typia from "typia";`
|
|
28
|
-
: `import typia, { Primitive } from "typia";`,
|
|
29
|
-
"",
|
|
30
|
-
]
|
|
31
|
-
: []),
|
|
32
|
-
`import api from "./${path
|
|
33
|
-
.relative(props.current, props.api)
|
|
34
|
-
.split("\\")
|
|
35
|
-
.join("/")}";`,
|
|
36
|
-
...(importDict.empty()
|
|
37
|
-
? []
|
|
38
|
-
: [importDict.toScript(props.current)]),
|
|
39
|
-
"",
|
|
40
|
-
arrow(config)(route),
|
|
41
|
-
...(additional.length ? ["", ...additional] : []),
|
|
42
|
-
].join("\n");
|
|
43
|
-
|
|
44
|
-
await fs.promises.writeFile(
|
|
45
|
-
`${props.current}/${name(route)}.ts`,
|
|
46
|
-
content,
|
|
47
|
-
"utf8",
|
|
48
|
-
);
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const arrow =
|
|
52
|
-
(config: INestiaConfig) =>
|
|
53
|
-
(route: IRoute): string => {
|
|
54
|
-
const tab: number = route.output.name === "void" ? 2 : 3;
|
|
55
|
-
const output = [
|
|
56
|
-
`await ${accessor(route)}(`,
|
|
57
|
-
`${" ".repeat(tab * 4)}connection,`,
|
|
58
|
-
...route.parameters.map(parameter(config)(tab)),
|
|
59
|
-
`${" ".repeat((tab - 1) * 4)});`,
|
|
60
|
-
].join("\n");
|
|
61
|
-
return [
|
|
62
|
-
`export const ${name(route)} = async (`,
|
|
63
|
-
` connection: api.IConnection`,
|
|
64
|
-
`): Promise<void> => {`,
|
|
65
|
-
...(route.output.name === "void"
|
|
66
|
-
? [` ${output}`]
|
|
67
|
-
: [
|
|
68
|
-
` const output: ${primitive(config)(
|
|
69
|
-
route.output.name,
|
|
70
|
-
)} = `,
|
|
71
|
-
` ${output}`,
|
|
72
|
-
` typia.assert(output);`,
|
|
73
|
-
]),
|
|
74
|
-
`};`,
|
|
75
|
-
].join("\n");
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
const parameter =
|
|
79
|
-
(config: INestiaConfig) =>
|
|
80
|
-
(tab: number) =>
|
|
81
|
-
(param: IRoute.IParameter): string => {
|
|
82
|
-
const middle: string =
|
|
83
|
-
param.category === "param" &&
|
|
84
|
-
(param.meta?.type === "uuid" || param.meta?.type === "date")
|
|
85
|
-
? param.meta.nullable
|
|
86
|
-
? `Math.random() < .2 ? null : ${param.meta.type}()`
|
|
87
|
-
: `${param.meta.type}()`
|
|
88
|
-
: `typia.random<${primitive(config)(param.type.name)}>()`;
|
|
89
|
-
return `${" ".repeat(4 * tab)}${middle},`;
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
const name = (route: IRoute): string =>
|
|
93
|
-
postfix([
|
|
94
|
-
"test_api",
|
|
95
|
-
...route.path
|
|
96
|
-
.split("/")
|
|
97
|
-
.filter((str) => str.length && str[0] !== ":")
|
|
98
|
-
.map(normalize),
|
|
99
|
-
])(route.name).join("_");
|
|
100
|
-
|
|
101
|
-
const accessor = (route: IRoute): string =>
|
|
102
|
-
postfix([
|
|
103
|
-
"api.functional",
|
|
104
|
-
...route.path
|
|
105
|
-
.split("/")
|
|
106
|
-
.filter((str) => str.length && str[0] !== ":")
|
|
107
|
-
.map(normalize),
|
|
108
|
-
])(route.name).join(".");
|
|
109
|
-
|
|
110
|
-
const normalize = (str: string) =>
|
|
111
|
-
str.split("-").join("_").split(".").join("_");
|
|
112
|
-
|
|
113
|
-
const postfix = (array: string[]) => (name: string) =>
|
|
114
|
-
array.at(-1) === name ? array : [...array, name];
|
|
115
|
-
|
|
116
|
-
const primitive =
|
|
117
|
-
(config: INestiaConfig) =>
|
|
118
|
-
(name: string): string =>
|
|
119
|
-
config.primitive !== false ? `Primitive<${name}>` : name;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
const UUID = `const uuid = (): string =>
|
|
123
|
-
"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
|
124
|
-
const r = (Math.random() * 16) | 0;
|
|
125
|
-
const v = c === "x" ? r : (r & 0x3) | 0x8;
|
|
126
|
-
return v.toString(16);
|
|
127
|
-
});`;
|
|
128
|
-
const DATE = `const date = (): string => {
|
|
129
|
-
const date: Date = new Date(Math.floor(Math.random() * Date.now() * 2));
|
|
130
|
-
return [
|
|
131
|
-
date.getFullYear(),
|
|
132
|
-
(date.getMonth() + 1).toString().padStart(2, "0"),
|
|
133
|
-
date.getDate().toString().padStart(2, "0"),
|
|
134
|
-
].join("-");
|
|
135
|
-
}`;
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
|
|
4
|
+
import { INestiaConfig } from "../../INestiaConfig";
|
|
5
|
+
import { IRoute } from "../../structures/IRoute";
|
|
6
|
+
import { ImportDictionary } from "../../utils/ImportDictionary";
|
|
7
|
+
|
|
8
|
+
export namespace E2eFileProgrammer {
|
|
9
|
+
export const generate =
|
|
10
|
+
(config: INestiaConfig) =>
|
|
11
|
+
(props: { api: string; current: string }) =>
|
|
12
|
+
async (route: IRoute): Promise<void> => {
|
|
13
|
+
const importDict: ImportDictionary = new ImportDictionary();
|
|
14
|
+
for (const tuple of route.imports)
|
|
15
|
+
for (const instance of tuple[1])
|
|
16
|
+
importDict.emplace(tuple[0], false, instance);
|
|
17
|
+
|
|
18
|
+
const additional: string[] = [];
|
|
19
|
+
for (const param of route.parameters)
|
|
20
|
+
if (param.category === "param")
|
|
21
|
+
if (param.meta?.type === "uuid") additional.push(UUID);
|
|
22
|
+
else if (param.meta?.type === "date") additional.push(DATE);
|
|
23
|
+
const content: string = [
|
|
24
|
+
...(route.parameters.length || route.output.name !== "void"
|
|
25
|
+
? [
|
|
26
|
+
config.primitive === false
|
|
27
|
+
? `import typia from "typia";`
|
|
28
|
+
: `import typia, { Primitive } from "typia";`,
|
|
29
|
+
"",
|
|
30
|
+
]
|
|
31
|
+
: []),
|
|
32
|
+
`import api from "./${path
|
|
33
|
+
.relative(props.current, props.api)
|
|
34
|
+
.split("\\")
|
|
35
|
+
.join("/")}";`,
|
|
36
|
+
...(importDict.empty()
|
|
37
|
+
? []
|
|
38
|
+
: [importDict.toScript(props.current)]),
|
|
39
|
+
"",
|
|
40
|
+
arrow(config)(route),
|
|
41
|
+
...(additional.length ? ["", ...additional] : []),
|
|
42
|
+
].join("\n");
|
|
43
|
+
|
|
44
|
+
await fs.promises.writeFile(
|
|
45
|
+
`${props.current}/${name(route)}.ts`,
|
|
46
|
+
content,
|
|
47
|
+
"utf8",
|
|
48
|
+
);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const arrow =
|
|
52
|
+
(config: INestiaConfig) =>
|
|
53
|
+
(route: IRoute): string => {
|
|
54
|
+
const tab: number = route.output.name === "void" ? 2 : 3;
|
|
55
|
+
const output = [
|
|
56
|
+
`await ${accessor(route)}(`,
|
|
57
|
+
`${" ".repeat(tab * 4)}connection,`,
|
|
58
|
+
...route.parameters.map(parameter(config)(tab)),
|
|
59
|
+
`${" ".repeat((tab - 1) * 4)});`,
|
|
60
|
+
].join("\n");
|
|
61
|
+
return [
|
|
62
|
+
`export const ${name(route)} = async (`,
|
|
63
|
+
` connection: api.IConnection`,
|
|
64
|
+
`): Promise<void> => {`,
|
|
65
|
+
...(route.output.name === "void"
|
|
66
|
+
? [` ${output}`]
|
|
67
|
+
: [
|
|
68
|
+
` const output: ${primitive(config)(
|
|
69
|
+
route.output.name,
|
|
70
|
+
)} = `,
|
|
71
|
+
` ${output}`,
|
|
72
|
+
` typia.assert(output);`,
|
|
73
|
+
]),
|
|
74
|
+
`};`,
|
|
75
|
+
].join("\n");
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const parameter =
|
|
79
|
+
(config: INestiaConfig) =>
|
|
80
|
+
(tab: number) =>
|
|
81
|
+
(param: IRoute.IParameter): string => {
|
|
82
|
+
const middle: string =
|
|
83
|
+
param.category === "param" &&
|
|
84
|
+
(param.meta?.type === "uuid" || param.meta?.type === "date")
|
|
85
|
+
? param.meta.nullable
|
|
86
|
+
? `Math.random() < .2 ? null : ${param.meta.type}()`
|
|
87
|
+
: `${param.meta.type}()`
|
|
88
|
+
: `typia.random<${primitive(config)(param.type.name)}>()`;
|
|
89
|
+
return `${" ".repeat(4 * tab)}${middle},`;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const name = (route: IRoute): string =>
|
|
93
|
+
postfix([
|
|
94
|
+
"test_api",
|
|
95
|
+
...route.path
|
|
96
|
+
.split("/")
|
|
97
|
+
.filter((str) => str.length && str[0] !== ":")
|
|
98
|
+
.map(normalize),
|
|
99
|
+
])(route.name).join("_");
|
|
100
|
+
|
|
101
|
+
const accessor = (route: IRoute): string =>
|
|
102
|
+
postfix([
|
|
103
|
+
"api.functional",
|
|
104
|
+
...route.path
|
|
105
|
+
.split("/")
|
|
106
|
+
.filter((str) => str.length && str[0] !== ":")
|
|
107
|
+
.map(normalize),
|
|
108
|
+
])(route.name).join(".");
|
|
109
|
+
|
|
110
|
+
const normalize = (str: string) =>
|
|
111
|
+
str.split("-").join("_").split(".").join("_");
|
|
112
|
+
|
|
113
|
+
const postfix = (array: string[]) => (name: string) =>
|
|
114
|
+
array.at(-1) === name ? array : [...array, name];
|
|
115
|
+
|
|
116
|
+
const primitive =
|
|
117
|
+
(config: INestiaConfig) =>
|
|
118
|
+
(name: string): string =>
|
|
119
|
+
config.primitive !== false ? `Primitive<${name}>` : name;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const UUID = `const uuid = (): string =>
|
|
123
|
+
"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
|
124
|
+
const r = (Math.random() * 16) | 0;
|
|
125
|
+
const v = c === "x" ? r : (r & 0x3) | 0x8;
|
|
126
|
+
return v.toString(16);
|
|
127
|
+
});`;
|
|
128
|
+
const DATE = `const date = (): string => {
|
|
129
|
+
const date: Date = new Date(Math.floor(Math.random() * Date.now() * 2));
|
|
130
|
+
return [
|
|
131
|
+
date.getFullYear(),
|
|
132
|
+
(date.getMonth() + 1).toString().padStart(2, "0"),
|
|
133
|
+
date.getDate().toString().padStart(2, "0"),
|
|
134
|
+
].join("-");
|
|
135
|
+
}`;
|