@nestia/sdk 1.6.7 → 2.0.0-dev.20230830-2

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 (27) hide show
  1. package/lib/generates/E2eGenerator.js +2 -1
  2. package/lib/generates/E2eGenerator.js.map +1 -1
  3. package/lib/generates/internal/E2eFileProgrammer.d.ts +2 -1
  4. package/lib/generates/internal/E2eFileProgrammer.js +18 -19
  5. package/lib/generates/internal/E2eFileProgrammer.js.map +1 -1
  6. package/lib/generates/internal/SdkFileProgrammer.js +14 -30
  7. package/lib/generates/internal/SdkFileProgrammer.js.map +1 -1
  8. package/lib/generates/internal/SdkFunctionProgrammer.d.ts +2 -1
  9. package/lib/generates/internal/SdkFunctionProgrammer.js +49 -26
  10. package/lib/generates/internal/SdkFunctionProgrammer.js.map +1 -1
  11. package/lib/generates/internal/SdkImportWizard.d.ts +7 -0
  12. package/lib/generates/internal/SdkImportWizard.js +33 -0
  13. package/lib/generates/internal/SdkImportWizard.js.map +1 -0
  14. package/lib/generates/internal/SdkSimulationProgrammer.d.ts +3 -1
  15. package/lib/generates/internal/SdkSimulationProgrammer.js +33 -24
  16. package/lib/generates/internal/SdkSimulationProgrammer.js.map +1 -1
  17. package/lib/utils/ImportDictionary.d.ts +16 -2
  18. package/lib/utils/ImportDictionary.js +66 -25
  19. package/lib/utils/ImportDictionary.js.map +1 -1
  20. package/package.json +3 -3
  21. package/src/generates/E2eGenerator.ts +4 -1
  22. package/src/generates/internal/E2eFileProgrammer.ts +25 -19
  23. package/src/generates/internal/SdkFileProgrammer.ts +20 -56
  24. package/src/generates/internal/SdkFunctionProgrammer.ts +75 -25
  25. package/src/generates/internal/SdkImportWizard.ts +41 -0
  26. package/src/generates/internal/SdkSimulationProgrammer.ts +103 -74
  27. package/src/utils/ImportDictionary.ts +97 -33
@@ -1 +1 @@
1
- {"version":3,"file":"SdkSimulationProgrammer.js","sourceRoot":"","sources":["../../../src/generates/internal/SdkSimulation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BAAsB,iCAAe,CAAC,KAAK,CACvC,QAAQ,CACX,WAAW,CAAC,CAAC,IAAI,KAAK;oBACzB,CAAC,CAAC,CAAC,CAAC,QAAQ,KAAK,SAAS;wBAC1B,CAAC,CAAC,wBAAwB,iCAAe,CAAC,KAAK,CACzC,QAAQ,CACX,8BAA8B,CAAC,gBAAgB;wBAClD,CAAC,CAAC,iBAAiB,CAAC,CAAC,KAAK,OACpB,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAC9C,YAAY,iCAAe,CAAC,KAAK,CAC7B,QAAQ,CACX,WAAW,CAAC,CAAC,IAAI,KAAK,CAChC;SACR,CAAC;IACN,CAAC,CAAC;AACV,CAAC,EAtGgB,uBAAuB,uCAAvB,uBAAuB,QAsGvC"}
@@ -1,6 +1,20 @@
1
1
  export declare class ImportDictionary {
2
- private readonly dict_;
2
+ private readonly externals_;
3
+ private readonly internals_;
3
4
  empty(): boolean;
4
- emplace(file: string, realistic: boolean, instance: string): void;
5
+ external(props: ImportDictionary.IExternalProps): string;
6
+ internal(props: ImportDictionary.IInternalProps): string;
5
7
  toScript(outDir: string): string;
6
8
  }
9
+ export declare namespace ImportDictionary {
10
+ interface IInternalProps {
11
+ type: boolean;
12
+ file: string;
13
+ instance: string;
14
+ }
15
+ interface IExternalProps {
16
+ type: boolean;
17
+ library: string;
18
+ instance: string | null;
19
+ }
20
+ }
@@ -10,38 +10,79 @@ const HashSet_1 = require("tstl/container/HashSet");
10
10
  const Pair_1 = require("tstl/utility/Pair");
11
11
  class ImportDictionary {
12
12
  constructor() {
13
- this.dict_ = new HashMap_1.HashMap();
13
+ this.externals_ = new HashMap_1.HashMap();
14
+ this.internals_ = new HashMap_1.HashMap();
14
15
  }
15
16
  empty() {
16
- return this.dict_.empty();
17
+ return this.internals_.empty() && this.externals_.empty();
17
18
  }
18
- emplace(file, realistic, instance) {
19
- if (file.substr(-5) === ".d.ts")
20
- file = file.substr(0, file.length - 5);
21
- else if (file.substr(-3) === ".ts")
22
- file = file.substr(0, file.length - 3);
19
+ external(props) {
20
+ var _a;
21
+ const composition = this.externals_.take(new Pair_1.Pair(props.library, props.type), () => ({
22
+ location: props.library,
23
+ elements: new HashSet_1.HashSet(),
24
+ default: false,
25
+ type: props.type,
26
+ }));
27
+ if (props.instance === null)
28
+ composition.default = true;
23
29
  else
24
- throw new Error(`Error on ImportDictionary.emplace(): extension of the target file "${file}" is not "ts".`);
25
- const pair = this.dict_.take(file, () => new Pair_1.Pair(realistic, new HashSet_1.HashSet()));
26
- pair.second.insert(instance);
30
+ composition.elements.insert(props.instance);
31
+ return (_a = props.instance) !== null && _a !== void 0 ? _a : props.library;
32
+ }
33
+ internal(props) {
34
+ var _a;
35
+ const file = (() => {
36
+ if (props.file.substring(props.file.length - 5) === ".d.ts")
37
+ return props.file.substring(0, props.file.length - 5);
38
+ else if (props.file.substring(0, props.file.length - 3) === ".ts")
39
+ return props.file.substring(0, props.file.length - 3);
40
+ throw new Error(`Error on ImportDictionary.emplace(): extension of the target file "${props.file}" is not "ts".`);
41
+ })();
42
+ const composition = this.internals_.take(new Pair_1.Pair(file, props.type), () => ({
43
+ location: file,
44
+ elements: new HashSet_1.HashSet(),
45
+ default: false,
46
+ type: props.type,
47
+ }));
48
+ if (props.instance === null)
49
+ composition.default = true;
50
+ else
51
+ composition.elements.insert(props.instance);
52
+ return (_a = props.instance) !== null && _a !== void 0 ? _a : file;
27
53
  }
28
54
  toScript(outDir) {
29
55
  const statements = [];
30
- for (const it of this.dict_) {
31
- const file = (() => {
32
- const location = path_1.default
33
- .relative(outDir, it.first)
34
- .split("\\")
35
- .join("/");
36
- const index = location.lastIndexOf(NODE_MODULES);
37
- return index === -1
38
- ? `./${location}`
39
- : location.substring(index + NODE_MODULES.length);
40
- })();
41
- const realistic = it.second.first;
42
- const instances = it.second.second.toJSON();
43
- statements.push(`import ${!realistic ? "type " : ""}{ ${instances.join(", ")} } from "${file}";`);
44
- }
56
+ const enroll = (locator) => (dict) => {
57
+ const compositions = dict
58
+ .toJSON()
59
+ .map((e) => (Object.assign(Object.assign({}, e.second), { location: locator(e.second.location) })))
60
+ .sort((a, b) => a.location.localeCompare(b.location));
61
+ for (const c of compositions) {
62
+ const brackets = [];
63
+ if (c.default)
64
+ brackets.push(c.location);
65
+ if (c.elements.empty() === false)
66
+ brackets.push(`{${c.elements
67
+ .toJSON()
68
+ .sort((a, b) => a.localeCompare(b))
69
+ .join(", ")}`);
70
+ statements.push(`import ${c.type ? "type " : ""} ${brackets.join(", ")} from "${c.location}";`);
71
+ }
72
+ };
73
+ enroll((str) => str)(this.externals_);
74
+ if (this.internals_.size())
75
+ statements.push("");
76
+ enroll((str) => {
77
+ const location = path_1.default
78
+ .relative(outDir, str)
79
+ .split("\\")
80
+ .join("/");
81
+ const index = location.lastIndexOf(NODE_MODULES);
82
+ return index === -1
83
+ ? `./${location}`
84
+ : location.substring(index + NODE_MODULES.length);
85
+ })(this.internals_);
45
86
  return statements.join("\n");
46
87
  }
47
88
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ImportDictionary.js","sourceRoot":"","sources":["../../src/utils/ImportDictionary.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,oDAAiD;AACjD,oDAAiD;AACjD,4CAAyC;AAEzC,MAAa,gBAAgB;IAA7B;QACqB,UAAK,GAClB,IAAI,iBAAO,EAAE,CAAC;IA8CtB,CAAC;IA5CU,KAAK;QACR,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IAC9B,CAAC;IAEM,OAAO,CAAC,IAAY,EAAE,SAAkB,EAAE,QAAgB;QAC7D,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,OAAO;YAAE,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,GAAG,CAAC,C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AAU,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAChD,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE;YACX,MAAM,QAAQ,GAAW,cAAI;iBACxB,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC;iBACrB,KAAK,CAAC,IAAI,CAAC;iBACX,IAAI,CAAC,GAAG,CAAC,CAAC;YACf,MAAM,KAAK,GAAW,QAAQ,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;YACzD,OAAO,KAAK,KAAK,CAAC,CAAC;gBACf,CAAC,CAAC,KAAK,QAAQ,EAAE;gBACjB,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;QAC1D,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACpB,OAAO,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;CACJ;AA7FD,4CA6FC;AAqBD,MAAM,YAAY,GAAG,eAAe,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestia/sdk",
3
- "version": "1.6.7",
3
+ "version": "2.0.0-dev.20230830-2",
4
4
  "description": "Nestia SDK and Swagger generator",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -35,7 +35,7 @@
35
35
  },
36
36
  "homepage": "https://nestia.io",
37
37
  "dependencies": {
38
- "@nestia/fetcher": "^1.6.7",
38
+ "@nestia/fetcher": "^2.0.0-dev.20230830-2",
39
39
  "cli": "^1.0.1",
40
40
  "glob": "^7.2.0",
41
41
  "path-to-regexp": "^6.2.1",
@@ -47,7 +47,7 @@
47
47
  "typia": "^4.3.3"
48
48
  },
49
49
  "peerDependencies": {
50
- "@nestia/fetcher": ">=1.6.7",
50
+ "@nestia/fetcher": ">=2.0.0-dev.20230830-2",
51
51
  "@nestjs/common": ">=7.0.1",
52
52
  "@nestjs/core": ">=7.0.1",
53
53
  "reflect-metadata": ">=0.1.12",
@@ -3,6 +3,7 @@ import path from "path";
3
3
 
4
4
  import { INestiaConfig } from "../INestiaConfig";
5
5
  import { IRoute } from "../structures/IRoute";
6
+ import { ImportDictionary } from "../utils/ImportDictionary";
6
7
  import { NestiaConfigUtil } from "../utils/NestiaConfigUtil";
7
8
  import { E2eFileProgrammer } from "./internal/E2eFileProgrammer";
8
9
 
@@ -24,7 +25,9 @@ export namespace E2eGenerator {
24
25
 
25
26
  // GENERATE EACH TEST FILES
26
27
  for (const route of routeList)
27
- await E2eFileProgrammer.generate(config)({
28
+ await E2eFileProgrammer.generate(config)(
29
+ new ImportDictionary(),
30
+ )({
28
31
  api: path.resolve(config.output!),
29
32
  current: path.join(output, "features", "api", "automated"),
30
33
  })(route);
@@ -4,16 +4,22 @@ import path from "path";
4
4
  import { INestiaConfig } from "../../INestiaConfig";
5
5
  import { IRoute } from "../../structures/IRoute";
6
6
  import { ImportDictionary } from "../../utils/ImportDictionary";
7
+ import { SdkImportWizard } from "./SdkImportWizard";
7
8
 
8
9
  export namespace E2eFileProgrammer {
9
10
  export const generate =
10
11
  (config: INestiaConfig) =>
12
+ (importer: ImportDictionary) =>
11
13
  (props: { api: string; current: string }) =>
12
14
  async (route: IRoute): Promise<void> => {
13
15
  const importDict: ImportDictionary = new ImportDictionary();
14
16
  for (const tuple of route.imports)
15
17
  for (const instance of tuple[1])
16
- importDict.emplace(tuple[0], false, instance);
18
+ importDict.internal({
19
+ file: tuple[0],
20
+ type: true,
21
+ instance,
22
+ });
17
23
 
18
24
  const additional: string[] = [];
19
25
  for (const param of route.parameters.filter(
@@ -25,17 +31,6 @@ export namespace E2eFileProgrammer {
25
31
  }
26
32
 
27
33
  const content: string = [
28
- ...(!!route.parameters.filter(
29
- (p) =>
30
- p.category !== "headers" && getAdditional(p) === null,
31
- ).length || route.output.name !== "void"
32
- ? [
33
- config.primitive === false
34
- ? `import typia from "typia";`
35
- : `import typia, { Primitive } from "typia";`,
36
- "",
37
- ]
38
- : []),
39
34
  `import api from "./${path
40
35
  .relative(props.current, props.api)
41
36
  .split("\\")
@@ -44,7 +39,7 @@ export namespace E2eFileProgrammer {
44
39
  ? []
45
40
  : [importDict.toScript(props.current)]),
46
41
  "",
47
- arrow(config)(route),
42
+ arrow(config)(importer)(route),
48
43
  ...(additional.length ? ["", ...additional] : []),
49
44
  ].join("\n");
50
45
 
@@ -57,6 +52,7 @@ export namespace E2eFileProgrammer {
57
52
 
58
53
  const arrow =
59
54
  (config: INestiaConfig) =>
55
+ (importer: ImportDictionary) =>
60
56
  (route: IRoute): string => {
61
57
  const tab: number = route.output.name === "void" ? 2 : 3;
62
58
  const headers = route.parameters.find(
@@ -70,7 +66,9 @@ export namespace E2eFileProgrammer {
70
66
  " ...connection,",
71
67
  " headers: {",
72
68
  " ...(connection.headers ?? {}),",
73
- ` ...typia.random<${headers.type.name}>(),`,
69
+ ` ...${SdkImportWizard.typia(
70
+ importer,
71
+ )}.random<${headers.type.name}>(),`,
74
72
  " },",
75
73
  "},",
76
74
  ]
@@ -79,7 +77,7 @@ export namespace E2eFileProgrammer {
79
77
  : `${" ".repeat(tab * 4)}connection,`,
80
78
  ...route.parameters
81
79
  .filter((param) => param.category !== "headers")
82
- .map(parameter(config)(tab)),
80
+ .map(parameter(config)(importer)(tab)),
83
81
  `${" ".repeat((tab - 1) * 4)});`,
84
82
  ].join("\n");
85
83
  return [
@@ -89,11 +87,13 @@ export namespace E2eFileProgrammer {
89
87
  ...(route.output.name === "void"
90
88
  ? [` ${output}`]
91
89
  : [
92
- ` const output: ${primitive(config)(
90
+ ` const output: ${primitive(config)(importer)(
93
91
  route.output.name,
94
92
  )} = `,
95
93
  ` ${output}`,
96
- ` typia.assert(output);`,
94
+ ` ${SdkImportWizard.typia(
95
+ importer,
96
+ )}.assert(output);`,
97
97
  ]),
98
98
  `};`,
99
99
  ].join("\n");
@@ -101,6 +101,7 @@ export namespace E2eFileProgrammer {
101
101
 
102
102
  const parameter =
103
103
  (config: INestiaConfig) =>
104
+ (importer: ImportDictionary) =>
104
105
  (tab: number) =>
105
106
  (param: IRoute.IParameter): string => {
106
107
  const middle: string =
@@ -110,7 +111,9 @@ export namespace E2eFileProgrammer {
110
111
  ? param.meta.nullable
111
112
  ? `Math.random() < .2 ? null : ${param.meta.type}()`
112
113
  : `${param.meta.type}()`
113
- : `typia.random<${primitive(config)(param.type.name)}>()`;
114
+ : `${SdkImportWizard.typia(importer)}.random<${primitive(
115
+ config,
116
+ )(importer)(param.type.name)}>()`;
114
117
  return `${" ".repeat(4 * tab)}${middle},`;
115
118
  };
116
119
 
@@ -122,8 +125,11 @@ export namespace E2eFileProgrammer {
122
125
 
123
126
  const primitive =
124
127
  (config: INestiaConfig) =>
128
+ (importer: ImportDictionary) =>
125
129
  (name: string): string =>
126
- config.primitive !== false ? `Primitive<${name}>` : name;
130
+ config.primitive !== false
131
+ ? `${SdkImportWizard.Primitive(importer)}<${name}>`
132
+ : name;
127
133
 
128
134
  const getAdditional = (
129
135
  param: IRoute.IParameter,
@@ -62,74 +62,38 @@ export namespace SdkFileProgrammer {
62
62
  if (content.length && directory.routes.length) content.push("");
63
63
 
64
64
  // ITERATE ROUTES
65
- const importDict: ImportDictionary = new ImportDictionary();
65
+ const importer: ImportDictionary = new ImportDictionary();
66
66
  if (
67
67
  config.simulate === true &&
68
68
  directory.routes.some((r) => !!r.parameters.length)
69
69
  )
70
- importDict.emplace(
71
- `${config.output}/utils/NestiaSimulator.ts`,
72
- true,
73
- "NestiaSimulator",
74
- );
75
-
70
+ importer.internal({
71
+ file: `${config.output}/utils/NestiaSimulator.ts`,
72
+ instance: "NestiaSimulator",
73
+ type: false,
74
+ });
76
75
  directory.routes.forEach((route, i) => {
77
76
  for (const tuple of route.imports)
78
77
  for (const instance of tuple[1])
79
- importDict.emplace(tuple[0], false, instance);
78
+ importer.internal({
79
+ file: tuple[0],
80
+ instance,
81
+ type: true,
82
+ });
80
83
 
81
- content.push(SdkFunctionProgrammer.generate(config)(route));
84
+ content.push(
85
+ SdkFunctionProgrammer.generate(config)(importer)(route),
86
+ );
82
87
  if (i !== directory.routes.length - 1) content.push("");
83
88
  });
84
89
 
85
90
  // FINALIZE THE CONTENT
86
- if (directory.routes.length !== 0) {
87
- const primitived: boolean =
88
- config.primitive !== false &&
89
- directory.routes.some(
90
- (route) =>
91
- route.output.name !== "void" ||
92
- route.parameters.some(
93
- (param) => param.category !== "param",
94
- ),
95
- );
96
- const asserted: boolean =
97
- config.assert === true &&
98
- directory.routes.some(
99
- (route) => route.parameters.length !== 0,
100
- );
101
- const json: boolean =
102
- config.json === true &&
103
- directory.routes.some(
104
- (route) =>
105
- route.method === "POST" ||
106
- route.method === "PUT" ||
107
- route.method === "PATCH",
108
- );
109
- const random: boolean =
110
- config.simulate === true &&
111
- directory.routes.some(
112
- (s) =>
113
- !!s.parameters.length || s.output.name !== "void",
114
- );
115
-
116
- const classes: string[] = ["Fetcher"];
117
- const typings: string[] = ["IConnection"];
118
- if (primitived) typings.push("Primitive");
119
-
120
- const head: string[] = [
121
- `import { ${classes.join(", ")} } from "@nestia/fetcher";`,
122
- `import type { ${typings.join(
123
- ", ",
124
- )} } from "@nestia/fetcher";`,
125
- ];
126
- if (asserted || json || random)
127
- head.push(`import typia from "typia";`);
128
- if (!importDict.empty())
129
- head.push("", importDict.toScript(outDir));
130
-
131
- content.push(...head, "", ...content.splice(0, content.length));
132
- }
91
+ if (directory.routes.length !== 0)
92
+ content.push(
93
+ importer.toScript(outDir),
94
+ "",
95
+ ...content.splice(0, content.length),
96
+ );
133
97
 
134
98
  const script: string =
135
99
  "/**\n" +
@@ -6,14 +6,17 @@ import { Escaper } from "typia/lib/utils/Escaper";
6
6
  import { INestiaConfig } from "../../INestiaConfig";
7
7
  import { IController } from "../../structures/IController";
8
8
  import { IRoute } from "../../structures/IRoute";
9
+ import { ImportDictionary } from "../../utils/ImportDictionary";
10
+ import { SdkImportWizard } from "./SdkImportWizard";
9
11
  import { SdkSimulationProgrammer } from "./SdkSimulationProgrammer";
10
12
 
11
13
  export namespace SdkFunctionProgrammer {
12
14
  export const generate =
13
15
  (config: INestiaConfig) =>
16
+ (importer: ImportDictionary) =>
14
17
  (route: IRoute): string => {
15
18
  const [x, y, z] = [head, body, tail].map((closure) =>
16
- closure(config)(route)({
19
+ closure(config)(importer)(route)({
17
20
  headers: route.parameters.find(
18
21
  (param) =>
19
22
  param.category === "headers" &&
@@ -37,11 +40,19 @@ export namespace SdkFunctionProgrammer {
37
40
  --------------------------------------------------------- */
38
41
  const body =
39
42
  (config: INestiaConfig) =>
43
+ (importer: ImportDictionary) =>
40
44
  (route: IRoute) =>
41
45
  (props: {
42
46
  query: IRoute.IParameter | undefined;
43
47
  input: IRoute.IParameter | undefined;
44
48
  }): string => {
49
+ const encrypted: boolean =
50
+ route.encrypted === true ||
51
+ (props.input !== undefined &&
52
+ props.input.custom === true &&
53
+ props.input.category === "body" &&
54
+ props.input.encrypted === true);
55
+
45
56
  // FETCH ARGUMENTS WITH REQUST BODY
46
57
  const parameters: IRoute.IParameter[] = filter_path_parameters(
47
58
  route,
@@ -90,7 +101,11 @@ export namespace SdkFunctionProgrammer {
90
101
  )
91
102
  .map(
92
103
  (param) =>
93
- ` typia.assert<typeof ${param.name}>(${param.name});`,
104
+ ` ${SdkImportWizard.typia(
105
+ importer,
106
+ )}.assert<typeof ${param.name}>(${
107
+ param.name
108
+ });`,
94
109
  )
95
110
  .join("\n") + "\n\n"
96
111
  : "";
@@ -112,7 +127,9 @@ export namespace SdkFunctionProgrammer {
112
127
  .join("\n");
113
128
  const fetch = (tab: string) =>
114
129
  [
115
- `${awa ? "await " : ""}Fetcher.fetch(`,
130
+ `${awa ? "await " : ""}${SdkImportWizard.Fetcher(
131
+ encrypted,
132
+ )(importer)}.fetch(`,
116
133
  fetchArguments
117
134
  .map((param) =>
118
135
  typeof param === "string"
@@ -186,6 +203,7 @@ export namespace SdkFunctionProgrammer {
186
203
  --------------------------------------------------------- */
187
204
  const head =
188
205
  (config: INestiaConfig) =>
206
+ (importer: ImportDictionary) =>
189
207
  (route: IRoute) =>
190
208
  (props: {
191
209
  query: IRoute.IParameter | undefined;
@@ -249,8 +267,10 @@ export namespace SdkFunctionProgrammer {
249
267
  route.parameters.some(
250
268
  (p) => p.category === "headers" && p.field === undefined,
251
269
  )
252
- ? `connection: IConnection<${`${route.name}.Headers`}>`
253
- : "connection: IConnection",
270
+ ? `connection: ${SdkImportWizard.IConnection(
271
+ importer,
272
+ )}<${`${route.name}.Headers`}>`
273
+ : `connection: ${SdkImportWizard.IConnection(importer)}`,
254
274
  ...route.parameters
255
275
  .filter((p) => p.category !== "headers")
256
276
  .map((param) => {
@@ -286,6 +306,7 @@ export namespace SdkFunctionProgrammer {
286
306
 
287
307
  const tail =
288
308
  (config: INestiaConfig) =>
309
+ (importer: ImportDictionary) =>
289
310
  (route: IRoute) =>
290
311
  (props: {
291
312
  query: IRoute.IParameter | undefined;
@@ -312,7 +333,6 @@ export namespace SdkFunctionProgrammer {
312
333
  query: props.query,
313
334
  parameters,
314
335
  });
315
-
316
336
  return (
317
337
  `export namespace ${route.name} {\n` +
318
338
  (types.length !== 0
@@ -321,27 +341,49 @@ export namespace SdkFunctionProgrammer {
321
341
  (tuple) =>
322
342
  ` export type ${tuple.first} = ${
323
343
  config.primitive !== false
324
- ? `Primitive<${tuple.second}>`
344
+ ? `${SdkImportWizard.Primitive(
345
+ importer,
346
+ )}<${tuple.second}>`
325
347
  : tuple.second
326
348
  };`,
327
349
  )
328
350
  .join("\n") + "\n"
329
351
  : "") +
330
352
  "\n" +
331
- ` export const METHOD = "${route.method}" as const;\n` +
332
- ` export const PATH: string = "${route.path}";\n` +
333
- ` export const ENCRYPTED: Fetcher.IEncrypted = {\n` +
334
- ` request: ${
335
- props.input !== undefined &&
336
- props.input.custom === true &&
337
- props.input.category === "body" &&
338
- props.input.encrypted
339
- },\n` +
340
- ` response: ${route.encrypted},\n` +
341
- (route.status !== undefined
342
- ? ` status: ${route.status},\n`
343
- : "") +
344
- ` };\n` +
353
+ [
354
+ "export const METADATA = {",
355
+ ` method: "${route.method}",`,
356
+ ` path: "${route.path}",`,
357
+ ...(props.input
358
+ ? [
359
+ `request: {`,
360
+ ` type: "${
361
+ (props.input as IController.IBodyParameter)
362
+ .encrypted
363
+ ? "text/plain"
364
+ : (
365
+ props.input as IController.IBodyParameter
366
+ ).contentType ?? "application/json"
367
+ }",`,
368
+ ` encrypted: ${
369
+ props.input.custom &&
370
+ props.input.category === "body" &&
371
+ props.input.encrypted
372
+ }`,
373
+ `},`,
374
+ ].map((str) => ` ${str}`)
375
+ : []),
376
+ ...(route.output
377
+ ? [
378
+ `response: {`,
379
+ ` type: "${route.output.type}",`,
380
+ ` encrypted: ${route.encrypted},`,
381
+ `},`,
382
+ ].map((str) => ` ${str}`)
383
+ : []),
384
+ ...(route.status ? [` status: ${route.status},`] : []),
385
+ "}",
386
+ ].join("\n") +
345
387
  "\n" +
346
388
  ` export const path = (${parameters
347
389
  .map(
@@ -357,16 +399,24 @@ export namespace SdkFunctionProgrammer {
357
399
  `${path};\n` +
358
400
  ` }\n` +
359
401
  (config.simulate === true && route.output.name !== "void"
360
- ? ` export const random = (g?: Partial<typia.IRandomGenerator>): Output =>\n` +
361
- ` typia.random<Output>(g);\n`
402
+ ? ` export const random = (g?: Partial<${SdkImportWizard.typia(
403
+ importer,
404
+ )}.IRandomGenerator>): Output =>\n` +
405
+ ` ${SdkImportWizard.typia(
406
+ importer,
407
+ )}.random<Output>(g);\n`
362
408
  : "") +
363
409
  (config.simulate === true
364
- ? SdkSimulationProgrammer.generate(route) + "\n"
410
+ ? SdkSimulationProgrammer.generate(config)(importer)(
411
+ route,
412
+ ) + "\n"
365
413
  : "") +
366
414
  (config.json === true &&
367
415
  route.parameters.find((param) => param.category === "body") !==
368
416
  undefined
369
- ? ` export const stringify = (input: Input) => typia.assertStringify(input);\n`
417
+ ? ` export const stringify = (input: Input) => ${SdkImportWizard.typia(
418
+ importer,
419
+ )}.json.assertStringify(input);\n`
370
420
  : "") +
371
421
  "}"
372
422
  );