@nestia/migrate 7.0.0-dev.20250608 → 7.0.0

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.
Files changed (52) hide show
  1. package/README.md +92 -92
  2. package/lib/analyzers/NestiaMigrateControllerAnalyzer.js +1 -1
  3. package/lib/analyzers/NestiaMigrateControllerAnalyzer.js.map +1 -1
  4. package/lib/bundles/NEST_TEMPLATE.js +47 -47
  5. package/lib/bundles/NEST_TEMPLATE.js.map +1 -1
  6. package/lib/bundles/SDK_TEMPLATE.js +21 -21
  7. package/lib/bundles/SDK_TEMPLATE.js.map +1 -1
  8. package/lib/index.mjs +69 -69
  9. package/lib/index.mjs.map +1 -1
  10. package/lib/utils/openapi-down-convert/converter.js +2 -2
  11. package/package.json +7 -7
  12. package/src/NestiaMigrateApplication.ts +144 -144
  13. package/src/analyzers/NestiaMigrateControllerAnalyzer.ts +51 -51
  14. package/src/archivers/NestiaMigrateFileArchiver.ts +28 -28
  15. package/src/bundles/NEST_TEMPLATE.ts +47 -47
  16. package/src/bundles/SDK_TEMPLATE.ts +21 -21
  17. package/src/executable/NestiaMigrateCommander.ts +98 -98
  18. package/src/executable/NestiaMigrateInquirer.ts +106 -106
  19. package/src/executable/bundle.js +129 -129
  20. package/src/executable/migrate.ts +7 -7
  21. package/src/factories/TypeLiteralFactory.ts +57 -57
  22. package/src/index.ts +4 -4
  23. package/src/module.ts +2 -2
  24. package/src/programmers/NestiaMigrateApiFileProgrammer.ts +55 -55
  25. package/src/programmers/NestiaMigrateApiFunctionProgrammer.ts +256 -256
  26. package/src/programmers/NestiaMigrateApiNamespaceProgrammer.ts +515 -515
  27. package/src/programmers/NestiaMigrateApiProgrammer.ts +107 -107
  28. package/src/programmers/NestiaMigrateApiSimulationProgrammer.ts +340 -340
  29. package/src/programmers/NestiaMigrateApiStartProgrammer.ts +198 -198
  30. package/src/programmers/NestiaMigrateDtoProgrammer.ts +101 -101
  31. package/src/programmers/NestiaMigrateE2eFileProgrammer.ts +153 -153
  32. package/src/programmers/NestiaMigrateE2eProgrammer.ts +46 -46
  33. package/src/programmers/NestiaMigrateImportProgrammer.ts +118 -118
  34. package/src/programmers/NestiaMigrateNestControllerProgrammer.ts +66 -66
  35. package/src/programmers/NestiaMigrateNestMethodProgrammer.ts +406 -406
  36. package/src/programmers/NestiaMigrateNestModuleProgrammer.ts +65 -65
  37. package/src/programmers/NestiaMigrateNestProgrammer.ts +88 -88
  38. package/src/programmers/NestiaMigrateSchemaProgrammer.ts +475 -475
  39. package/src/structures/INestiaMigrateConfig.ts +10 -10
  40. package/src/structures/INestiaMigrateContext.ts +15 -15
  41. package/src/structures/INestiaMigrateController.ts +8 -8
  42. package/src/structures/INestiaMigrateDto.ts +8 -8
  43. package/src/structures/INestiaMigrateFile.ts +5 -5
  44. package/src/structures/INestiaMigrateProgram.ts +11 -11
  45. package/src/structures/INestiaMigrateSchema.ts +4 -4
  46. package/src/utils/FilePrinter.ts +38 -38
  47. package/src/utils/MapUtil.ts +13 -13
  48. package/src/utils/OpenApiTypeChecker.ts +73 -73
  49. package/src/utils/SetupWizard.ts +12 -12
  50. package/src/utils/StringUtil.ts +113 -113
  51. package/src/utils/openapi-down-convert/RefVisitor.ts +139 -139
  52. package/src/utils/openapi-down-convert/converter.ts +527 -527
@@ -1,10 +1,10 @@
1
- export interface INestiaMigrateConfig {
2
- simulate: boolean;
3
- e2e: boolean;
4
- package?: string;
5
- keyword?: boolean;
6
- author?: {
7
- tag: string;
8
- value: string;
9
- };
10
- }
1
+ export interface INestiaMigrateConfig {
2
+ simulate: boolean;
3
+ e2e: boolean;
4
+ package?: string;
5
+ keyword?: boolean;
6
+ author?: {
7
+ tag: string;
8
+ value: string;
9
+ };
10
+ }
@@ -1,15 +1,15 @@
1
- import {
2
- IHttpMigrateApplication,
3
- IHttpMigrateRoute,
4
- OpenApi,
5
- } from "@samchon/openapi";
6
-
7
- import { INestiaMigrateConfig } from "./INestiaMigrateConfig";
8
-
9
- export interface INestiaMigrateContext {
10
- mode: "nest" | "sdk";
11
- document: OpenApi.IDocument;
12
- config: INestiaMigrateConfig;
13
- routes: IHttpMigrateRoute[];
14
- errors: IHttpMigrateApplication.IError[];
15
- }
1
+ import {
2
+ IHttpMigrateApplication,
3
+ IHttpMigrateRoute,
4
+ OpenApi,
5
+ } from "@samchon/openapi";
6
+
7
+ import { INestiaMigrateConfig } from "./INestiaMigrateConfig";
8
+
9
+ export interface INestiaMigrateContext {
10
+ mode: "nest" | "sdk";
11
+ document: OpenApi.IDocument;
12
+ config: INestiaMigrateConfig;
13
+ routes: IHttpMigrateRoute[];
14
+ errors: IHttpMigrateApplication.IError[];
15
+ }
@@ -1,8 +1,8 @@
1
- import { IHttpMigrateRoute } from "@samchon/openapi";
2
-
3
- export interface INestiaMigrateController {
4
- name: string;
5
- path: string;
6
- location: string;
7
- routes: IHttpMigrateRoute[];
8
- }
1
+ import { IHttpMigrateRoute } from "@samchon/openapi";
2
+
3
+ export interface INestiaMigrateController {
4
+ name: string;
5
+ path: string;
6
+ location: string;
7
+ routes: IHttpMigrateRoute[];
8
+ }
@@ -1,8 +1,8 @@
1
- import { OpenApi } from "@samchon/openapi";
2
-
3
- export interface INestiaMigrateDto {
4
- name: string;
5
- location: string;
6
- schema: OpenApi.IJsonSchema | null;
7
- children: INestiaMigrateDto[];
8
- }
1
+ import { OpenApi } from "@samchon/openapi";
2
+
3
+ export interface INestiaMigrateDto {
4
+ name: string;
5
+ location: string;
6
+ schema: OpenApi.IJsonSchema | null;
7
+ children: INestiaMigrateDto[];
8
+ }
@@ -1,5 +1,5 @@
1
- export interface INestiaMigrateFile {
2
- location: string;
3
- file: string;
4
- content: string;
5
- }
1
+ export interface INestiaMigrateFile {
2
+ location: string;
3
+ file: string;
4
+ content: string;
5
+ }
@@ -1,11 +1,11 @@
1
- import { IHttpMigrateApplication, OpenApi } from "@samchon/openapi";
2
-
3
- import { INestiaMigrateConfig } from "./INestiaMigrateConfig";
4
-
5
- export interface INestiaMigrateProgram {
6
- mode: "nest" | "sdk";
7
- document: OpenApi.IDocument;
8
- config: INestiaMigrateConfig;
9
- files: Record<string, string>;
10
- errors: IHttpMigrateApplication.IError[];
11
- }
1
+ import { IHttpMigrateApplication, OpenApi } from "@samchon/openapi";
2
+
3
+ import { INestiaMigrateConfig } from "./INestiaMigrateConfig";
4
+
5
+ export interface INestiaMigrateProgram {
6
+ mode: "nest" | "sdk";
7
+ document: OpenApi.IDocument;
8
+ config: INestiaMigrateConfig;
9
+ files: Record<string, string>;
10
+ errors: IHttpMigrateApplication.IError[];
11
+ }
@@ -1,4 +1,4 @@
1
- export interface INestiaMigrateSchema {
2
- name: string;
3
- children: INestiaMigrateSchema[];
4
- }
1
+ export interface INestiaMigrateSchema {
2
+ name: string;
3
+ children: INestiaMigrateSchema[];
4
+ }
@@ -1,38 +1,38 @@
1
- import ts from "typescript";
2
-
3
- export namespace FilePrinter {
4
- export const description = <Node extends ts.Node>(
5
- node: Node,
6
- comment: string,
7
- ): Node => {
8
- if (comment.length === 0) return node;
9
- ts.addSyntheticLeadingComment(
10
- node,
11
- ts.SyntaxKind.MultiLineCommentTrivia,
12
- ["*", ...comment.split("\n").map((str) => ` * ${str}`), ""].join("\n"),
13
- true,
14
- );
15
- return node;
16
- };
17
-
18
- export const newLine = () =>
19
- ts.factory.createExpressionStatement(ts.factory.createIdentifier("\n"));
20
-
21
- export const write = (props: {
22
- statements: ts.Statement[];
23
- top?: string;
24
- }): string => {
25
- const script: string = ts
26
- .createPrinter({
27
- newLine: ts.NewLineKind.LineFeed,
28
- })
29
- .printFile(
30
- ts.factory.createSourceFile(
31
- props.statements,
32
- ts.factory.createToken(ts.SyntaxKind.EndOfFileToken),
33
- ts.NodeFlags.None,
34
- ),
35
- );
36
- return (props.top ?? "") + script;
37
- };
38
- }
1
+ import ts from "typescript";
2
+
3
+ export namespace FilePrinter {
4
+ export const description = <Node extends ts.Node>(
5
+ node: Node,
6
+ comment: string,
7
+ ): Node => {
8
+ if (comment.length === 0) return node;
9
+ ts.addSyntheticLeadingComment(
10
+ node,
11
+ ts.SyntaxKind.MultiLineCommentTrivia,
12
+ ["*", ...comment.split("\n").map((str) => ` * ${str}`), ""].join("\n"),
13
+ true,
14
+ );
15
+ return node;
16
+ };
17
+
18
+ export const newLine = () =>
19
+ ts.factory.createExpressionStatement(ts.factory.createIdentifier("\n"));
20
+
21
+ export const write = (props: {
22
+ statements: ts.Statement[];
23
+ top?: string;
24
+ }): string => {
25
+ const script: string = ts
26
+ .createPrinter({
27
+ newLine: ts.NewLineKind.LineFeed,
28
+ })
29
+ .printFile(
30
+ ts.factory.createSourceFile(
31
+ props.statements,
32
+ ts.factory.createToken(ts.SyntaxKind.EndOfFileToken),
33
+ ts.NodeFlags.None,
34
+ ),
35
+ );
36
+ return (props.top ?? "") + script;
37
+ };
38
+ }
@@ -1,13 +1,13 @@
1
- export namespace MapUtil {
2
- export const take =
3
- <Key, T>(dict: Map<Key, T>) =>
4
- (key: Key) =>
5
- (generator: () => T): T => {
6
- const oldbie: T | undefined = dict.get(key);
7
- if (oldbie) return oldbie;
8
-
9
- const value: T = generator();
10
- dict.set(key, value);
11
- return value;
12
- };
13
- }
1
+ export namespace MapUtil {
2
+ export const take =
3
+ <Key, T>(dict: Map<Key, T>) =>
4
+ (key: Key) =>
5
+ (generator: () => T): T => {
6
+ const oldbie: T | undefined = dict.get(key);
7
+ if (oldbie) return oldbie;
8
+
9
+ const value: T = generator();
10
+ dict.set(key, value);
11
+ return value;
12
+ };
13
+ }
@@ -1,73 +1,73 @@
1
- import { OpenApi } from "@samchon/openapi";
2
-
3
- export namespace OpenApiTypeChecker {
4
- export const isOneOf = (
5
- schema: OpenApi.IJsonSchema,
6
- ): schema is OpenApi.IJsonSchema.IOneOf =>
7
- (schema as any).oneOf !== undefined;
8
-
9
- export const isNull = (
10
- schema: OpenApi.IJsonSchema,
11
- ): schema is OpenApi.IJsonSchema.INull =>
12
- (schema as OpenApi.IJsonSchema.INull).type === "null";
13
-
14
- export const isConstant = (
15
- schema: OpenApi.IJsonSchema,
16
- ): schema is OpenApi.IJsonSchema.IConstant =>
17
- (schema as OpenApi.IJsonSchema.IConstant).const !== undefined;
18
-
19
- export const isBoolean = (
20
- schema: OpenApi.IJsonSchema,
21
- ): schema is OpenApi.IJsonSchema.IBoolean =>
22
- (schema as OpenApi.IJsonSchema.IBoolean).type === "boolean";
23
-
24
- export const isInteger = (
25
- schema: OpenApi.IJsonSchema,
26
- ): schema is OpenApi.IJsonSchema.IInteger =>
27
- (schema as OpenApi.IJsonSchema.IInteger).type === "integer";
28
-
29
- export const isNumber = (
30
- schema: OpenApi.IJsonSchema,
31
- ): schema is OpenApi.IJsonSchema.INumber =>
32
- (schema as OpenApi.IJsonSchema.INumber).type === "number";
33
-
34
- export const isString = (
35
- schema: OpenApi.IJsonSchema,
36
- ): schema is OpenApi.IJsonSchema.IString =>
37
- (schema as OpenApi.IJsonSchema.IString).type === "string";
38
-
39
- export const isArray = (
40
- schema: OpenApi.IJsonSchema,
41
- ): schema is OpenApi.IJsonSchema.IArray =>
42
- (schema as OpenApi.IJsonSchema.IArray).type === "array" &&
43
- (schema as OpenApi.IJsonSchema.IArray).items !== undefined;
44
-
45
- export const isTuple = (
46
- schema: OpenApi.IJsonSchema,
47
- ): schema is OpenApi.IJsonSchema.ITuple =>
48
- (schema as OpenApi.IJsonSchema.ITuple).type === "array" &&
49
- (schema as OpenApi.IJsonSchema.ITuple).prefixItems !== undefined;
50
-
51
- export const isObject = (
52
- schema: OpenApi.IJsonSchema,
53
- ): schema is OpenApi.IJsonSchema.IObject =>
54
- (schema as OpenApi.IJsonSchema.IObject).type === "object";
55
-
56
- export const isReference = (
57
- schema: OpenApi.IJsonSchema,
58
- ): schema is OpenApi.IJsonSchema.IReference =>
59
- (schema as OpenApi.IJsonSchema.IReference).$ref !== undefined;
60
-
61
- export const isUnknown = (
62
- schema: OpenApi.IJsonSchema,
63
- ): schema is OpenApi.IJsonSchema.IUnknown =>
64
- (schema as OpenApi.IJsonSchema.__ISignificant<any>).type === undefined &&
65
- !isOneOf(schema) &&
66
- !isReference(schema) &&
67
- !isConstant(schema);
68
-
69
- // export const isNullable = (schema: OpenApi.IJsonSchema): boolean =>
70
- // SwaggerTypeChecker.isOneOf(schema)
71
- // ? schema.oneOf.some(isNullable)
72
- // : (schema as OpenApi.IJsonSchema.INullOnly).type === "null";
73
- }
1
+ import { OpenApi } from "@samchon/openapi";
2
+
3
+ export namespace OpenApiTypeChecker {
4
+ export const isOneOf = (
5
+ schema: OpenApi.IJsonSchema,
6
+ ): schema is OpenApi.IJsonSchema.IOneOf =>
7
+ (schema as any).oneOf !== undefined;
8
+
9
+ export const isNull = (
10
+ schema: OpenApi.IJsonSchema,
11
+ ): schema is OpenApi.IJsonSchema.INull =>
12
+ (schema as OpenApi.IJsonSchema.INull).type === "null";
13
+
14
+ export const isConstant = (
15
+ schema: OpenApi.IJsonSchema,
16
+ ): schema is OpenApi.IJsonSchema.IConstant =>
17
+ (schema as OpenApi.IJsonSchema.IConstant).const !== undefined;
18
+
19
+ export const isBoolean = (
20
+ schema: OpenApi.IJsonSchema,
21
+ ): schema is OpenApi.IJsonSchema.IBoolean =>
22
+ (schema as OpenApi.IJsonSchema.IBoolean).type === "boolean";
23
+
24
+ export const isInteger = (
25
+ schema: OpenApi.IJsonSchema,
26
+ ): schema is OpenApi.IJsonSchema.IInteger =>
27
+ (schema as OpenApi.IJsonSchema.IInteger).type === "integer";
28
+
29
+ export const isNumber = (
30
+ schema: OpenApi.IJsonSchema,
31
+ ): schema is OpenApi.IJsonSchema.INumber =>
32
+ (schema as OpenApi.IJsonSchema.INumber).type === "number";
33
+
34
+ export const isString = (
35
+ schema: OpenApi.IJsonSchema,
36
+ ): schema is OpenApi.IJsonSchema.IString =>
37
+ (schema as OpenApi.IJsonSchema.IString).type === "string";
38
+
39
+ export const isArray = (
40
+ schema: OpenApi.IJsonSchema,
41
+ ): schema is OpenApi.IJsonSchema.IArray =>
42
+ (schema as OpenApi.IJsonSchema.IArray).type === "array" &&
43
+ (schema as OpenApi.IJsonSchema.IArray).items !== undefined;
44
+
45
+ export const isTuple = (
46
+ schema: OpenApi.IJsonSchema,
47
+ ): schema is OpenApi.IJsonSchema.ITuple =>
48
+ (schema as OpenApi.IJsonSchema.ITuple).type === "array" &&
49
+ (schema as OpenApi.IJsonSchema.ITuple).prefixItems !== undefined;
50
+
51
+ export const isObject = (
52
+ schema: OpenApi.IJsonSchema,
53
+ ): schema is OpenApi.IJsonSchema.IObject =>
54
+ (schema as OpenApi.IJsonSchema.IObject).type === "object";
55
+
56
+ export const isReference = (
57
+ schema: OpenApi.IJsonSchema,
58
+ ): schema is OpenApi.IJsonSchema.IReference =>
59
+ (schema as OpenApi.IJsonSchema.IReference).$ref !== undefined;
60
+
61
+ export const isUnknown = (
62
+ schema: OpenApi.IJsonSchema,
63
+ ): schema is OpenApi.IJsonSchema.IUnknown =>
64
+ (schema as OpenApi.IJsonSchema.__ISignificant<any>).type === undefined &&
65
+ !isOneOf(schema) &&
66
+ !isReference(schema) &&
67
+ !isConstant(schema);
68
+
69
+ // export const isNullable = (schema: OpenApi.IJsonSchema): boolean =>
70
+ // SwaggerTypeChecker.isOneOf(schema)
71
+ // ? schema.oneOf.some(isNullable)
72
+ // : (schema as OpenApi.IJsonSchema.INullOnly).type === "null";
73
+ }
@@ -1,12 +1,12 @@
1
- import cp from "child_process";
2
-
3
- export namespace SetupWizard {
4
- export const setup = (output: string) => {
5
- execute(output)("npm install");
6
- };
7
-
8
- const execute = (cwd: string) => (command: string, fake?: string) => {
9
- console.log(fake ?? command);
10
- cp.execSync(command, { cwd, stdio: "inherit" });
11
- };
12
- }
1
+ import cp from "child_process";
2
+
3
+ export namespace SetupWizard {
4
+ export const setup = (output: string) => {
5
+ execute(output)("npm install");
6
+ };
7
+
8
+ const execute = (cwd: string) => (command: string, fake?: string) => {
9
+ console.log(fake ?? command);
10
+ cp.execSync(command, { cwd, stdio: "inherit" });
11
+ };
12
+ }
@@ -1,113 +1,113 @@
1
- export namespace StringUtil {
2
- export const capitalize = (str: string) =>
3
- str[0].toUpperCase() + str.slice(1).toLowerCase();
4
-
5
- export const splitWithNormalization = (path: string) =>
6
- path
7
- .split("/")
8
- .map((str) => normalize(str.trim()))
9
- .filter((str) => !!str.length);
10
-
11
- export const escapeDuplicate =
12
- (keep: string[]) =>
13
- (change: string): string =>
14
- keep.includes(change) ? escapeDuplicate(keep)(`_${change}`) : change;
15
-
16
- export const escapeNonVariable = (str: string): string => {
17
- str = escape(str);
18
- for (const [before, after] of VARIABLE_REPLACERS)
19
- str = str.split(before).join(after);
20
- for (let i: number = 0; i <= 9; ++i)
21
- if (str[0] === i.toString()) {
22
- str = "_" + str;
23
- break;
24
- }
25
- if (str === "") return "_empty_";
26
- return str;
27
- };
28
- }
29
-
30
- const escape = (str: string): string => {
31
- str = str.trim();
32
- if (RESERVED.has(str)) return `_${str}`;
33
- else if (str.length !== 0 && "0" <= str[0] && str[0] <= "9") str = `_${str}`;
34
- return str;
35
- };
36
-
37
- const normalize = (str: string): string =>
38
- escape(str.split(".").join("_").split("-").join("_"));
39
-
40
- const RESERVED: Set<string> = new Set([
41
- "break",
42
- "case",
43
- "catch",
44
- "class",
45
- "const",
46
- "continue",
47
- "debugger",
48
- "default",
49
- "delete",
50
- "do",
51
- "else",
52
- "enum",
53
- "export",
54
- "extends",
55
- "false",
56
- "finally",
57
- "for",
58
- "function",
59
- "if",
60
- "import",
61
- "in",
62
- "instanceof",
63
- "module",
64
- "new",
65
- "null",
66
- "package",
67
- "public",
68
- "private",
69
- "protected",
70
- "return",
71
- "super",
72
- "switch",
73
- "this",
74
- "throw",
75
- "true",
76
- "try",
77
- "typeof",
78
- "var",
79
- "void",
80
- "while",
81
- "with",
82
- ]);
83
-
84
- const VARIABLE_REPLACERS: [string, string][] = [
85
- ["`", "_backquote_"],
86
- ["!", "_exclamation_"],
87
- ["@", "_at_"],
88
- ["#", "_hash_"],
89
- ["$", "_dollar_"],
90
- ["%", "_percent_"],
91
- ["^", "_caret_"],
92
- ["&", "_and_"],
93
- ["*", "_star_"],
94
- ["(", "_lparen_"],
95
- [")", "_rparen_"],
96
- ["-", "_"],
97
- ["+", "_plus_"],
98
- ["|", "_or_"],
99
- ["{", "_blt_"],
100
- ["}", "_bgt_"],
101
- ["<", "_lt_"],
102
- [">", "_gt_"],
103
- ["[", "_alt_"],
104
- ["]", "_agt_"],
105
- [",", "_comma_"],
106
- ["'", "_singlequote_"],
107
- ['"', "_doublequote_"],
108
- [" ", "_space_"],
109
- ["?", "_question_"],
110
- [":", "_colon_"],
111
- [";", "_semicolon_"],
112
- ["...", "_rest_"],
113
- ];
1
+ export namespace StringUtil {
2
+ export const capitalize = (str: string) =>
3
+ str[0].toUpperCase() + str.slice(1).toLowerCase();
4
+
5
+ export const splitWithNormalization = (path: string) =>
6
+ path
7
+ .split("/")
8
+ .map((str) => normalize(str.trim()))
9
+ .filter((str) => !!str.length);
10
+
11
+ export const escapeDuplicate =
12
+ (keep: string[]) =>
13
+ (change: string): string =>
14
+ keep.includes(change) ? escapeDuplicate(keep)(`_${change}`) : change;
15
+
16
+ export const escapeNonVariable = (str: string): string => {
17
+ str = escape(str);
18
+ for (const [before, after] of VARIABLE_REPLACERS)
19
+ str = str.split(before).join(after);
20
+ for (let i: number = 0; i <= 9; ++i)
21
+ if (str[0] === i.toString()) {
22
+ str = "_" + str;
23
+ break;
24
+ }
25
+ if (str === "") return "_empty_";
26
+ return str;
27
+ };
28
+ }
29
+
30
+ const escape = (str: string): string => {
31
+ str = str.trim();
32
+ if (RESERVED.has(str)) return `_${str}`;
33
+ else if (str.length !== 0 && "0" <= str[0] && str[0] <= "9") str = `_${str}`;
34
+ return str;
35
+ };
36
+
37
+ const normalize = (str: string): string =>
38
+ escape(str.split(".").join("_").split("-").join("_"));
39
+
40
+ const RESERVED: Set<string> = new Set([
41
+ "break",
42
+ "case",
43
+ "catch",
44
+ "class",
45
+ "const",
46
+ "continue",
47
+ "debugger",
48
+ "default",
49
+ "delete",
50
+ "do",
51
+ "else",
52
+ "enum",
53
+ "export",
54
+ "extends",
55
+ "false",
56
+ "finally",
57
+ "for",
58
+ "function",
59
+ "if",
60
+ "import",
61
+ "in",
62
+ "instanceof",
63
+ "module",
64
+ "new",
65
+ "null",
66
+ "package",
67
+ "public",
68
+ "private",
69
+ "protected",
70
+ "return",
71
+ "super",
72
+ "switch",
73
+ "this",
74
+ "throw",
75
+ "true",
76
+ "try",
77
+ "typeof",
78
+ "var",
79
+ "void",
80
+ "while",
81
+ "with",
82
+ ]);
83
+
84
+ const VARIABLE_REPLACERS: [string, string][] = [
85
+ ["`", "_backquote_"],
86
+ ["!", "_exclamation_"],
87
+ ["@", "_at_"],
88
+ ["#", "_hash_"],
89
+ ["$", "_dollar_"],
90
+ ["%", "_percent_"],
91
+ ["^", "_caret_"],
92
+ ["&", "_and_"],
93
+ ["*", "_star_"],
94
+ ["(", "_lparen_"],
95
+ [")", "_rparen_"],
96
+ ["-", "_"],
97
+ ["+", "_plus_"],
98
+ ["|", "_or_"],
99
+ ["{", "_blt_"],
100
+ ["}", "_bgt_"],
101
+ ["<", "_lt_"],
102
+ [">", "_gt_"],
103
+ ["[", "_alt_"],
104
+ ["]", "_agt_"],
105
+ [",", "_comma_"],
106
+ ["'", "_singlequote_"],
107
+ ['"', "_doublequote_"],
108
+ [" ", "_space_"],
109
+ ["?", "_question_"],
110
+ [":", "_colon_"],
111
+ [";", "_semicolon_"],
112
+ ["...", "_rest_"],
113
+ ];