@nestia/sdk 3.0.0-dev.20231209 → 3.0.0-dev.20240412

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 (168) hide show
  1. package/README.md +12 -9
  2. package/assets/config/nestia.config.ts +82 -79
  3. package/lib/INestiaConfig.d.ts +28 -6
  4. package/lib/NestiaSdkApplication.js +12 -10
  5. package/lib/NestiaSdkApplication.js.map +1 -1
  6. package/lib/analyses/ConfigAnalyzer.js +1 -1
  7. package/lib/analyses/ConfigAnalyzer.js.map +1 -1
  8. package/lib/analyses/ControllerAnalyzer.js +30 -15
  9. package/lib/analyses/ControllerAnalyzer.js.map +1 -1
  10. package/lib/analyses/ExceptionAnalyzer.js +35 -6
  11. package/lib/analyses/ExceptionAnalyzer.js.map +1 -1
  12. package/lib/analyses/ImportAnalyzer.d.ts +1 -2
  13. package/lib/analyses/ImportAnalyzer.js +2 -2
  14. package/lib/analyses/ImportAnalyzer.js.map +1 -1
  15. package/lib/analyses/PathAnalyzer.d.ts +2 -4
  16. package/lib/analyses/PathAnalyzer.js +27 -11
  17. package/lib/analyses/PathAnalyzer.js.map +1 -1
  18. package/lib/analyses/ReflectAnalyzer.js +34 -22
  19. package/lib/analyses/ReflectAnalyzer.js.map +1 -1
  20. package/lib/analyses/SecurityAnalyzer.js +13 -8
  21. package/lib/analyses/SecurityAnalyzer.js.map +1 -1
  22. package/lib/executable/internal/NestiaConfigLoader.js +300 -220
  23. package/lib/executable/internal/NestiaConfigLoader.js.map +1 -1
  24. package/lib/executable/sdk.js +11 -11
  25. package/lib/generates/CloneGenerator.d.ts +6 -0
  26. package/lib/generates/CloneGenerator.js +62 -0
  27. package/lib/generates/CloneGenerator.js.map +1 -0
  28. package/lib/generates/E2eGenerator.d.ts +2 -1
  29. package/lib/generates/E2eGenerator.js +2 -2
  30. package/lib/generates/E2eGenerator.js.map +1 -1
  31. package/lib/generates/SdkGenerator.js +3 -11
  32. package/lib/generates/SdkGenerator.js.map +1 -1
  33. package/lib/generates/SwaggerGenerator.d.ts +2 -0
  34. package/lib/generates/SwaggerGenerator.js +119 -62
  35. package/lib/generates/SwaggerGenerator.js.map +1 -1
  36. package/lib/generates/internal/E2eFileProgrammer.d.ts +2 -1
  37. package/lib/generates/internal/E2eFileProgrammer.js +49 -53
  38. package/lib/generates/internal/E2eFileProgrammer.js.map +1 -1
  39. package/lib/generates/internal/FilePrinter.d.ts +10 -0
  40. package/lib/generates/internal/FilePrinter.js +46 -0
  41. package/lib/generates/internal/FilePrinter.js.map +1 -0
  42. package/lib/{utils → generates/internal}/ImportDictionary.d.ts +2 -1
  43. package/lib/{utils → generates/internal}/ImportDictionary.js +20 -14
  44. package/lib/generates/internal/ImportDictionary.js.map +1 -0
  45. package/lib/generates/internal/SdkAliasCollection.d.ts +12 -0
  46. package/lib/generates/internal/SdkAliasCollection.js +97 -0
  47. package/lib/generates/internal/SdkAliasCollection.js.map +1 -0
  48. package/lib/generates/internal/SdkCloneProgrammer.d.ts +12 -0
  49. package/lib/generates/internal/SdkCloneProgrammer.js +99 -0
  50. package/lib/generates/internal/SdkCloneProgrammer.js.map +1 -0
  51. package/lib/generates/internal/SdkFileProgrammer.d.ts +2 -1
  52. package/lib/generates/internal/SdkFileProgrammer.js +27 -28
  53. package/lib/generates/internal/SdkFileProgrammer.js.map +1 -1
  54. package/lib/generates/internal/SdkFunctionProgrammer.d.ts +7 -2
  55. package/lib/generates/internal/SdkFunctionProgrammer.js +115 -322
  56. package/lib/generates/internal/SdkFunctionProgrammer.js.map +1 -1
  57. package/lib/generates/internal/SdkImportWizard.d.ts +1 -1
  58. package/lib/generates/internal/SdkNamespaceProgrammer.d.ts +11 -0
  59. package/lib/generates/internal/SdkNamespaceProgrammer.js +180 -0
  60. package/lib/generates/internal/SdkNamespaceProgrammer.js.map +1 -0
  61. package/lib/generates/internal/SdkRouteProgrammer.d.ts +7 -0
  62. package/lib/generates/internal/SdkRouteProgrammer.js +55 -0
  63. package/lib/generates/internal/SdkRouteProgrammer.js.map +1 -0
  64. package/lib/generates/internal/SdkSimulationProgrammer.d.ts +8 -2
  65. package/lib/generates/internal/SdkSimulationProgrammer.js +103 -89
  66. package/lib/generates/internal/SdkSimulationProgrammer.js.map +1 -1
  67. package/lib/generates/internal/SdkTypeProgrammer.d.ts +9 -0
  68. package/lib/generates/internal/SdkTypeProgrammer.js +228 -0
  69. package/lib/generates/internal/SdkTypeProgrammer.js.map +1 -0
  70. package/lib/generates/internal/SwaggerSchemaGenerator.d.ts +4 -4
  71. package/lib/generates/internal/SwaggerSchemaGenerator.js +30 -28
  72. package/lib/generates/internal/SwaggerSchemaGenerator.js.map +1 -1
  73. package/lib/structures/IController.d.ts +4 -2
  74. package/lib/structures/IRoute.d.ts +5 -4
  75. package/lib/structures/ISwaggerLazyProperty.d.ts +2 -2
  76. package/lib/structures/ISwaggerLazySchema.d.ts +2 -2
  77. package/lib/structures/ParamCategory.d.ts +1 -1
  78. package/lib/structures/TypeEntry.js +2 -2
  79. package/lib/structures/TypeEntry.js.map +1 -1
  80. package/lib/utils/StringUtil.d.ts +3 -0
  81. package/lib/utils/StringUtil.js +8 -0
  82. package/lib/utils/StringUtil.js.map +1 -0
  83. package/package.json +12 -16
  84. package/src/INestiaConfig.ts +30 -6
  85. package/src/NestiaSdkApplication.ts +255 -253
  86. package/src/analyses/AccessorAnalyzer.ts +60 -60
  87. package/src/analyses/ConfigAnalyzer.ts +147 -147
  88. package/src/analyses/ControllerAnalyzer.ts +42 -19
  89. package/src/analyses/ExceptionAnalyzer.ts +148 -115
  90. package/src/analyses/GenericAnalyzer.ts +51 -51
  91. package/src/analyses/ImportAnalyzer.ts +1 -2
  92. package/src/analyses/PathAnalyzer.ts +110 -98
  93. package/src/analyses/ReflectAnalyzer.ts +39 -35
  94. package/src/analyses/SecurityAnalyzer.ts +24 -20
  95. package/src/executable/internal/CommandParser.ts +15 -15
  96. package/src/executable/internal/NestiaConfigLoader.ts +67 -67
  97. package/src/executable/internal/NestiaSdkCommand.ts +60 -60
  98. package/src/executable/sdk.ts +73 -73
  99. package/src/generates/CloneGenerator.ts +62 -0
  100. package/src/generates/E2eGenerator.ts +66 -64
  101. package/src/generates/SdkGenerator.ts +84 -96
  102. package/src/generates/SwaggerGenerator.ts +145 -53
  103. package/src/generates/internal/E2eFileProgrammer.ts +182 -123
  104. package/src/generates/internal/FilePrinter.ts +53 -0
  105. package/src/{utils → generates/internal}/ImportDictionary.ts +35 -13
  106. package/src/generates/internal/SdkAliasCollection.ts +152 -0
  107. package/src/generates/internal/SdkCloneProgrammer.ts +155 -0
  108. package/src/generates/internal/SdkDistributionComposer.ts +91 -91
  109. package/src/generates/internal/SdkFileProgrammer.ts +115 -106
  110. package/src/generates/internal/SdkFunctionProgrammer.ts +298 -518
  111. package/src/generates/internal/SdkImportWizard.ts +55 -55
  112. package/src/generates/internal/SdkNamespaceProgrammer.ts +510 -0
  113. package/src/generates/internal/SdkRouteDirectory.ts +17 -17
  114. package/src/generates/internal/SdkRouteProgrammer.ts +83 -0
  115. package/src/generates/internal/SdkSimulationProgrammer.ts +365 -133
  116. package/src/generates/internal/SdkTypeProgrammer.ts +386 -0
  117. package/src/generates/internal/SwaggerSchemaGenerator.ts +437 -427
  118. package/src/generates/internal/SwaggerSchemaValidator.ts +198 -198
  119. package/src/index.ts +4 -4
  120. package/src/module.ts +2 -2
  121. package/src/structures/IController.ts +94 -95
  122. package/src/structures/IErrorReport.ts +6 -6
  123. package/src/structures/INestiaProject.ts +13 -13
  124. package/src/structures/INormalizedInput.ts +20 -20
  125. package/src/structures/IRoute.ts +53 -53
  126. package/src/structures/ISwaggerLazyProperty.ts +2 -2
  127. package/src/structures/ISwaggerLazySchema.ts +2 -2
  128. package/src/structures/ITypeTuple.ts +6 -6
  129. package/src/structures/MethodType.ts +5 -5
  130. package/src/structures/ParamCategory.ts +1 -1
  131. package/src/structures/TypeEntry.ts +1 -1
  132. package/src/utils/ArrayUtil.ts +26 -26
  133. package/src/utils/FileRetriever.ts +22 -22
  134. package/src/utils/MapUtil.ts +14 -14
  135. package/src/utils/PathUtil.ts +10 -10
  136. package/src/utils/SourceFinder.ts +66 -66
  137. package/src/utils/StringUtil.ts +6 -0
  138. package/src/utils/StripEnums.ts +5 -5
  139. package/assets/bundle/api/utils/NestiaSimulator.ts +0 -70
  140. package/lib/generates/internal/SdkDtoGenerator.d.ts +0 -9
  141. package/lib/generates/internal/SdkDtoGenerator.js +0 -294
  142. package/lib/generates/internal/SdkDtoGenerator.js.map +0 -1
  143. package/lib/generates/internal/SdkTypeDefiner.d.ts +0 -11
  144. package/lib/generates/internal/SdkTypeDefiner.js +0 -82
  145. package/lib/generates/internal/SdkTypeDefiner.js.map +0 -1
  146. package/lib/structures/ISwagger.d.ts +0 -72
  147. package/lib/structures/ISwagger.js +0 -3
  148. package/lib/structures/ISwagger.js.map +0 -1
  149. package/lib/structures/ISwaggerComponents.d.ts +0 -26
  150. package/lib/structures/ISwaggerComponents.js +0 -3
  151. package/lib/structures/ISwaggerComponents.js.map +0 -1
  152. package/lib/structures/ISwaggerInfo.d.ts +0 -71
  153. package/lib/structures/ISwaggerInfo.js +0 -3
  154. package/lib/structures/ISwaggerInfo.js.map +0 -1
  155. package/lib/structures/ISwaggerRoute.d.ts +0 -47
  156. package/lib/structures/ISwaggerRoute.js +0 -3
  157. package/lib/structures/ISwaggerRoute.js.map +0 -1
  158. package/lib/structures/ISwaggerSecurityScheme.d.ts +0 -56
  159. package/lib/structures/ISwaggerSecurityScheme.js +0 -3
  160. package/lib/structures/ISwaggerSecurityScheme.js.map +0 -1
  161. package/lib/utils/ImportDictionary.js.map +0 -1
  162. package/src/generates/internal/SdkDtoGenerator.ts +0 -424
  163. package/src/generates/internal/SdkTypeDefiner.ts +0 -119
  164. package/src/structures/ISwagger.ts +0 -91
  165. package/src/structures/ISwaggerComponents.ts +0 -29
  166. package/src/structures/ISwaggerInfo.ts +0 -80
  167. package/src/structures/ISwaggerRoute.ts +0 -51
  168. package/src/structures/ISwaggerSecurityScheme.ts +0 -65
@@ -0,0 +1,62 @@
1
+ import fs from "fs";
2
+ import ts from "typescript";
3
+
4
+ import { INestiaConfig } from "../INestiaConfig";
5
+ import { IRoute } from "../structures/IRoute";
6
+ import { FilePrinter } from "./internal/FilePrinter";
7
+ import { ImportDictionary } from "./internal/ImportDictionary";
8
+ import { SdkCloneProgrammer } from "./internal/SdkCloneProgrammer";
9
+
10
+ export namespace CloneGenerator {
11
+ export const write =
12
+ (checker: ts.TypeChecker) =>
13
+ (config: INestiaConfig) =>
14
+ async (routes: IRoute[]): Promise<void> => {
15
+ const dict: Map<string, SdkCloneProgrammer.IModule> =
16
+ SdkCloneProgrammer.write(checker)(config)(routes);
17
+ if (dict.size === 0) return;
18
+ try {
19
+ await fs.promises.mkdir(`${config.output}/structures`);
20
+ } catch {}
21
+ for (const [key, value] of dict) await writeDtoFile(config)(key, value);
22
+ };
23
+
24
+ const writeDtoFile =
25
+ (config: INestiaConfig) =>
26
+ async (key: string, value: SdkCloneProgrammer.IModule): Promise<void> => {
27
+ const location: string = `${config.output}/structures/${key}.ts`;
28
+ const importer: ImportDictionary = new ImportDictionary(location);
29
+ const statements: ts.Statement[] = iterate(importer)(value);
30
+ if (statements.length === 0) return;
31
+
32
+ await FilePrinter.write({
33
+ location,
34
+ statements: [
35
+ ...importer.toStatements(`${config.output}/structures`),
36
+ ...(importer.empty() ? [] : [FilePrinter.enter()]),
37
+ ...statements,
38
+ ],
39
+ });
40
+ };
41
+
42
+ const iterate =
43
+ (importer: ImportDictionary) =>
44
+ (modulo: SdkCloneProgrammer.IModule): ts.Statement[] => {
45
+ const output: ts.Statement[] = [];
46
+ if (modulo.programmer !== null) output.push(modulo.programmer(importer));
47
+ if (modulo.children.size) {
48
+ const internal: ts.Statement[] = [];
49
+ for (const child of modulo.children.values())
50
+ internal.push(...iterate(importer)(child));
51
+ output.push(
52
+ ts.factory.createModuleDeclaration(
53
+ [ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)],
54
+ ts.factory.createIdentifier(modulo.name),
55
+ ts.factory.createModuleBlock(internal),
56
+ ts.NodeFlags.Namespace,
57
+ ),
58
+ );
59
+ }
60
+ return output;
61
+ };
62
+ }
@@ -1,64 +1,66 @@
1
- import fs from "fs";
2
- import path from "path";
3
-
4
- import { INestiaConfig } from "../INestiaConfig";
5
- import { ConfigAnalyzer } from "../analyses/ConfigAnalyzer";
6
- import { IRoute } from "../structures/IRoute";
7
- import { E2eFileProgrammer } from "./internal/E2eFileProgrammer";
8
-
9
- export namespace E2eGenerator {
10
- export const generate =
11
- (config: INestiaConfig) =>
12
- async (routeList: IRoute[]): Promise<void> => {
13
- console.log("Generating E2E Test Functions");
14
-
15
- // PREPARE DIRECTORIES
16
- const output: string = path.resolve(config.e2e!);
17
- await mkdir(output);
18
- await mkdir(path.join(output, "features"));
19
- await mkdir(path.join(output, "features", "api"));
20
- await mkdir(path.join(output, "features", "api", "automated"));
21
-
22
- // GENERATE TEST INDEX FILE
23
- await index(config)(path.join(config.e2e!, "index.ts"));
24
-
25
- // GENERATE EACH TEST FILES
26
- for (const route of routeList)
27
- await E2eFileProgrammer.generate(config)({
28
- api: path.resolve(config.output!),
29
- current: path.join(output, "features", "api", "automated"),
30
- })(route);
31
- };
32
-
33
- const index =
34
- (config: INestiaConfig) =>
35
- async (output: string): Promise<void> => {
36
- if (fs.existsSync(output)) return;
37
-
38
- const location: string = path.join(
39
- __dirname,
40
- "..",
41
- "..",
42
- "assets",
43
- "bundle",
44
- "e2e",
45
- "index.ts",
46
- );
47
- const content: string = await fs.promises.readFile(location, "utf8");
48
-
49
- await fs.promises.writeFile(
50
- output,
51
- content.replace(
52
- "${input}",
53
- JSON.stringify(await ConfigAnalyzer.input(config)),
54
- ),
55
- "utf8",
56
- );
57
- };
58
- }
59
-
60
- const mkdir = async (location: string): Promise<void> => {
61
- try {
62
- await fs.promises.mkdir(location);
63
- } catch {}
64
- };
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import ts from "typescript";
4
+
5
+ import { INestiaConfig } from "../INestiaConfig";
6
+ import { ConfigAnalyzer } from "../analyses/ConfigAnalyzer";
7
+ import { IRoute } from "../structures/IRoute";
8
+ import { E2eFileProgrammer } from "./internal/E2eFileProgrammer";
9
+
10
+ export namespace E2eGenerator {
11
+ export const generate =
12
+ (checker: ts.TypeChecker) =>
13
+ (config: INestiaConfig) =>
14
+ async (routeList: IRoute[]): Promise<void> => {
15
+ console.log("Generating E2E Test Functions");
16
+
17
+ // PREPARE DIRECTORIES
18
+ const output: string = path.resolve(config.e2e!);
19
+ await mkdir(output);
20
+ await mkdir(path.join(output, "features"));
21
+ await mkdir(path.join(output, "features", "api"));
22
+ await mkdir(path.join(output, "features", "api", "automated"));
23
+
24
+ // GENERATE TEST INDEX FILE
25
+ await index(config)(path.join(config.e2e!, "index.ts"));
26
+
27
+ // GENERATE EACH TEST FILES
28
+ for (const route of routeList)
29
+ await E2eFileProgrammer.generate(checker)(config)({
30
+ api: path.resolve(config.output!),
31
+ current: path.join(output, "features", "api", "automated"),
32
+ })(route);
33
+ };
34
+
35
+ const index =
36
+ (config: INestiaConfig) =>
37
+ async (output: string): Promise<void> => {
38
+ if (fs.existsSync(output)) return;
39
+
40
+ const location: string = path.join(
41
+ __dirname,
42
+ "..",
43
+ "..",
44
+ "assets",
45
+ "bundle",
46
+ "e2e",
47
+ "index.ts",
48
+ );
49
+ const content: string = await fs.promises.readFile(location, "utf8");
50
+
51
+ await fs.promises.writeFile(
52
+ output,
53
+ content.replace(
54
+ "${input}",
55
+ JSON.stringify(await ConfigAnalyzer.input(config)),
56
+ ),
57
+ "utf8",
58
+ );
59
+ };
60
+ }
61
+
62
+ const mkdir = async (location: string): Promise<void> => {
63
+ try {
64
+ await fs.promises.mkdir(location);
65
+ } catch {}
66
+ };
@@ -1,96 +1,84 @@
1
- import fs from "fs";
2
- import NodePath from "path";
3
- import { IPointer } from "tstl";
4
- import ts from "typescript";
5
-
6
- import { INestiaConfig } from "../INestiaConfig";
7
- import { IRoute } from "../structures/IRoute";
8
- import { SdkDistributionComposer } from "./internal/SdkDistributionComposer";
9
- import { SdkDtoGenerator } from "./internal/SdkDtoGenerator";
10
- import { SdkFileProgrammer } from "./internal/SdkFileProgrammer";
11
-
12
- export namespace SdkGenerator {
13
- export const generate =
14
- (checker: ts.TypeChecker) =>
15
- (config: INestiaConfig) =>
16
- async (routes: IRoute[]): Promise<void> => {
17
- console.log("Generating SDK Library");
18
-
19
- // PREPARE NEW DIRECTORIES
20
- try {
21
- await fs.promises.mkdir(config.output!);
22
- } catch {}
23
-
24
- // BUNDLING
25
- const bundle: string[] = await fs.promises.readdir(BUNDLE_PATH);
26
- for (const file of bundle) {
27
- const current: string = `${BUNDLE_PATH}/${file}`;
28
- const target: string = `${config.output}/${file}`;
29
- const stats: fs.Stats = await fs.promises.stat(current);
30
-
31
- if (stats.isFile() === true) {
32
- const content: string = await fs.promises.readFile(current, "utf8");
33
- if (fs.existsSync(target) === false)
34
- await fs.promises.writeFile(target, content, "utf8");
35
- else if (BUNDLE_CHANGES[file] !== undefined) {
36
- const r: IPointer<string> = {
37
- value: await fs.promises.readFile(target, "utf8"),
38
- };
39
- for (const [before, after] of BUNDLE_CHANGES[file])
40
- r.value = r.value.replace(before, after);
41
- await fs.promises.writeFile(target, r.value, "utf8");
42
- }
43
- }
44
- }
45
- if (
46
- config.simulate === true &&
47
- routes.some((r) => !!r.parameters.length)
48
- ) {
49
- try {
50
- await fs.promises.mkdir(`${config.output}/utils`);
51
- } catch {}
52
- await fs.promises.copyFile(
53
- `${BUNDLE_PATH}/utils/NestiaSimulator.ts`,
54
- `${config.output}/utils/NestiaSimulator.ts`,
55
- );
56
- }
57
-
58
- // STRUCTURES
59
- if (config.clone) await SdkDtoGenerator.generate(checker)(config)(routes);
60
-
61
- // FUNCTIONAL
62
- await SdkFileProgrammer.generate(config)(routes);
63
-
64
- // DISTRIBUTION
65
- if (config.distribute !== undefined)
66
- await SdkDistributionComposer.compose(config);
67
- };
68
-
69
- export const BUNDLE_PATH = NodePath.join(
70
- __dirname,
71
- "..",
72
- "..",
73
- "assets",
74
- "bundle",
75
- "api",
76
- );
77
- }
78
-
79
- const BUNDLE_CHANGES: Record<string, [string, string][]> = {
80
- "IConnection.ts": [
81
- [
82
- `export { IConnection } from "@nestia/fetcher"`,
83
- `export type { IConnection } from "@nestia/fetcher"`,
84
- ],
85
- ],
86
- "module.ts": [
87
- [`export * from "./IConnection"`, `export type * from "./IConnection"`],
88
- [`export * from "./Primitive"`, `export type * from "./Primitive"`],
89
- ],
90
- "Primitive.ts": [
91
- [
92
- `export { Primitive } from "@nestia/fetcher"`,
93
- `export type { Primitive } from "@nestia/fetcher"`,
94
- ],
95
- ],
96
- };
1
+ import fs from "fs";
2
+ import NodePath from "path";
3
+ import { IPointer } from "tstl";
4
+ import ts from "typescript";
5
+
6
+ import { INestiaConfig } from "../INestiaConfig";
7
+ import { IRoute } from "../structures/IRoute";
8
+ import { CloneGenerator } from "./CloneGenerator";
9
+ import { SdkDistributionComposer } from "./internal/SdkDistributionComposer";
10
+ import { SdkFileProgrammer } from "./internal/SdkFileProgrammer";
11
+
12
+ export namespace SdkGenerator {
13
+ export const generate =
14
+ (checker: ts.TypeChecker) =>
15
+ (config: INestiaConfig) =>
16
+ async (routes: IRoute[]): Promise<void> => {
17
+ console.log("Generating SDK Library");
18
+
19
+ // PREPARE NEW DIRECTORIES
20
+ try {
21
+ await fs.promises.mkdir(config.output!);
22
+ } catch {}
23
+
24
+ // BUNDLING
25
+ const bundle: string[] = await fs.promises.readdir(BUNDLE_PATH);
26
+ for (const file of bundle) {
27
+ const current: string = `${BUNDLE_PATH}/${file}`;
28
+ const target: string = `${config.output}/${file}`;
29
+ const stats: fs.Stats = await fs.promises.stat(current);
30
+
31
+ if (stats.isFile() === true) {
32
+ const content: string = await fs.promises.readFile(current, "utf8");
33
+ if (fs.existsSync(target) === false)
34
+ await fs.promises.writeFile(target, content, "utf8");
35
+ else if (BUNDLE_CHANGES[file] !== undefined) {
36
+ const r: IPointer<string> = {
37
+ value: await fs.promises.readFile(target, "utf8"),
38
+ };
39
+ for (const [before, after] of BUNDLE_CHANGES[file])
40
+ r.value = r.value.replace(before, after);
41
+ await fs.promises.writeFile(target, r.value, "utf8");
42
+ }
43
+ }
44
+ }
45
+
46
+ // STRUCTURES
47
+ if (config.clone) await CloneGenerator.write(checker)(config)(routes);
48
+
49
+ // FUNCTIONAL
50
+ await SdkFileProgrammer.generate(checker)(config)(routes);
51
+
52
+ // DISTRIBUTION
53
+ if (config.distribute !== undefined)
54
+ await SdkDistributionComposer.compose(config);
55
+ };
56
+
57
+ export const BUNDLE_PATH = NodePath.join(
58
+ __dirname,
59
+ "..",
60
+ "..",
61
+ "assets",
62
+ "bundle",
63
+ "api",
64
+ );
65
+ }
66
+
67
+ const BUNDLE_CHANGES: Record<string, [string, string][]> = {
68
+ "IConnection.ts": [
69
+ [
70
+ `export { IConnection } from "@nestia/fetcher"`,
71
+ `export type { IConnection } from "@nestia/fetcher"`,
72
+ ],
73
+ ],
74
+ "module.ts": [
75
+ [`export * from "./IConnection"`, `export type * from "./IConnection"`],
76
+ [`export * from "./Primitive"`, `export type * from "./Primitive"`],
77
+ ],
78
+ "Primitive.ts": [
79
+ [
80
+ `export { Primitive } from "@nestia/fetcher"`,
81
+ `export type { Primitive } from "@nestia/fetcher"`,
82
+ ],
83
+ ],
84
+ };