@nestia/sdk 1.2.1 → 1.2.2-dev.20230504
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/bundle/distribute/README.md +38 -0
- package/assets/bundle/distribute/package.json +22 -0
- package/assets/bundle/distribute/tsconfig.json +109 -0
- package/assets/bundle/e2e/index.ts +1 -1
- package/lib/INestiaConfig.d.ts +32 -9
- package/lib/executable/internal/NestiaSdkConfig.js +5 -1
- package/lib/executable/internal/NestiaSdkConfig.js.map +1 -1
- package/lib/generates/SdkGenerator.js +4 -0
- package/lib/generates/SdkGenerator.js.map +1 -1
- package/lib/generates/internal/DistributionComposer.d.ts +4 -0
- package/lib/generates/internal/DistributionComposer.js +88 -0
- package/lib/generates/internal/DistributionComposer.js.map +1 -0
- package/package.json +1 -1
- package/src/INestiaConfig.ts +33 -9
- package/src/generates/SdkGenerator.ts +5 -0
- package/src/generates/internal/DistributionComposer.ts +106 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# SDK Library
|
|
2
|
+
This is a SDK library generated by [`nestia`](https://nestia.io).
|
|
3
|
+
|
|
4
|
+
With this SDK library, you can easily and safely interact with backend server.
|
|
5
|
+
|
|
6
|
+
Just import and call some API functions like gif image below:
|
|
7
|
+
|
|
8
|
+

|
|
9
|
+
|
|
10
|
+
> Left is server code, and right is client code utilizing the SDK
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
# What [`Nestia`](https://nestia.io) is:
|
|
16
|
+

|
|
17
|
+
|
|
18
|
+
[](https://github.com/samchon/nestia/blob/master/LICENSE)
|
|
19
|
+
[](https://www.npmjs.com/package/@nestia/core)
|
|
20
|
+
[](https://www.npmjs.com/package/nestia)
|
|
21
|
+
[](https://github.com/samchon/nestia/actions?query=workflow%3Abuild)
|
|
22
|
+
[](https://nestia.io/docs/)
|
|
23
|
+
|
|
24
|
+
[Nestia](https://nestia.io) is a set of helper libraries for NestJS, supporting below features:
|
|
25
|
+
|
|
26
|
+
- `@nestia/core`: super-fast decorators
|
|
27
|
+
- `@nestia/sdk`
|
|
28
|
+
- SDK generator for clients
|
|
29
|
+
- Swagger generator evolved than ever
|
|
30
|
+
- Automatic E2E test functions generator
|
|
31
|
+
- `nestia`: just CLI (command line interface) tool
|
|
32
|
+
|
|
33
|
+
> **Note**
|
|
34
|
+
>
|
|
35
|
+
> - **Only one line** required, with pure TypeScript type
|
|
36
|
+
> - Runtime validator is **20,000x faster** than `class-validator`
|
|
37
|
+
> - JSON serialization is **200x faster** than `class-transformer`
|
|
38
|
+
> - SDK is similar with [tRPC](https://trpc.io), but much advanced
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ORGANIZATION/PROJECT-api",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "SDK library generated by Nestia",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"typings": "lib/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "npm run build:sdk && npm run compile",
|
|
9
|
+
"build:sdk": "rimraf ${output}/functional && cd ${root} && npx nestia sdk && cd ${current}",
|
|
10
|
+
"compile": "rimraf lib && tsc"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/samchon/nestia"
|
|
15
|
+
},
|
|
16
|
+
"author": "Jeongho Nam",
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/samchon/nestia/issues"
|
|
20
|
+
},
|
|
21
|
+
"homepage": "https://github.com/samchon/nestia#readme"
|
|
22
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
/* Visit https://aka.ms/tsconfig to read more about this file */
|
|
4
|
+
|
|
5
|
+
/* Projects */
|
|
6
|
+
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
|
|
7
|
+
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
|
|
8
|
+
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
|
|
9
|
+
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
|
|
10
|
+
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
|
|
11
|
+
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
|
12
|
+
|
|
13
|
+
/* Language and Environment */
|
|
14
|
+
"target": "ES5", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
|
15
|
+
"lib": [
|
|
16
|
+
"DOM",
|
|
17
|
+
"ES2015"
|
|
18
|
+
], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
|
19
|
+
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
|
20
|
+
// "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
|
|
21
|
+
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
|
|
22
|
+
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
|
|
23
|
+
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
|
|
24
|
+
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
|
|
25
|
+
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
|
|
26
|
+
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
|
|
27
|
+
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
|
|
28
|
+
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
|
29
|
+
|
|
30
|
+
/* Modules */
|
|
31
|
+
"module": "commonjs", /* Specify what module code is generated. */
|
|
32
|
+
// "rootDir": "./", /* Specify the root folder within your source files. */
|
|
33
|
+
// "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
|
|
34
|
+
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
|
35
|
+
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
|
36
|
+
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
|
37
|
+
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
|
|
38
|
+
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
|
|
39
|
+
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
40
|
+
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
|
|
41
|
+
// "resolveJsonModule": true, /* Enable importing .json files. */
|
|
42
|
+
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
|
|
43
|
+
|
|
44
|
+
/* JavaScript Support */
|
|
45
|
+
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
|
|
46
|
+
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
|
|
47
|
+
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
|
|
48
|
+
|
|
49
|
+
/* Emit */
|
|
50
|
+
"declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
|
|
51
|
+
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
|
|
52
|
+
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
|
53
|
+
"sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
|
54
|
+
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
|
55
|
+
"outDir": "./lib", /* Specify an output folder for all emitted files. */
|
|
56
|
+
// "removeComments": true, /* Disable emitting comments. */
|
|
57
|
+
// "noEmit": true, /* Disable emitting files from a compilation. */
|
|
58
|
+
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
|
59
|
+
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
|
|
60
|
+
"downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
|
61
|
+
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
|
|
62
|
+
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
63
|
+
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
|
64
|
+
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
|
|
65
|
+
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
|
|
66
|
+
"newLine": "lf", /* Set the newline character for emitting files. */
|
|
67
|
+
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
|
|
68
|
+
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
|
|
69
|
+
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
|
|
70
|
+
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
|
|
71
|
+
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
|
|
72
|
+
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
|
|
73
|
+
|
|
74
|
+
/* Interop Constraints */
|
|
75
|
+
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
|
|
76
|
+
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
|
77
|
+
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
|
|
78
|
+
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
|
79
|
+
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
|
|
80
|
+
|
|
81
|
+
/* Type Checking */
|
|
82
|
+
"strict": true, /* Enable all strict type-checking options. */
|
|
83
|
+
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
|
|
84
|
+
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
|
|
85
|
+
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
|
86
|
+
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
|
|
87
|
+
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
|
|
88
|
+
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
|
|
89
|
+
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
|
|
90
|
+
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
|
|
91
|
+
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
|
|
92
|
+
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
|
|
93
|
+
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
|
|
94
|
+
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
|
95
|
+
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
|
|
96
|
+
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
|
|
97
|
+
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
|
|
98
|
+
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
|
|
99
|
+
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
|
|
100
|
+
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
|
|
101
|
+
|
|
102
|
+
/* Completeness */
|
|
103
|
+
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
|
104
|
+
"skipLibCheck": true, /* Skip type checking all .d.ts files. */
|
|
105
|
+
},
|
|
106
|
+
"include": [
|
|
107
|
+
"${output}"
|
|
108
|
+
]
|
|
109
|
+
}
|
|
@@ -29,7 +29,7 @@ async function main(): Promise<void> {
|
|
|
29
29
|
console.log("Success");
|
|
30
30
|
console.log("Elapsed time", report.time.toLocaleString(), `ms`);
|
|
31
31
|
} else {
|
|
32
|
-
|
|
32
|
+
for (const exp of exceptions) console.log(exp);
|
|
33
33
|
console.log("Failed");
|
|
34
34
|
console.log("Elapsed time", report.time.toLocaleString(), `ms`);
|
|
35
35
|
process.exit(-1);
|
package/lib/INestiaConfig.d.ts
CHANGED
|
@@ -18,11 +18,28 @@ export interface INestiaConfig {
|
|
|
18
18
|
*/
|
|
19
19
|
output?: string;
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
21
|
+
* Target directory that e2e test functions would be placed in.
|
|
22
22
|
*
|
|
23
|
-
* If
|
|
23
|
+
* If you configure this property and runs `npx nestia e2e` command,
|
|
24
|
+
* `@nestia/sdk` will analyze your NestJS backend server code, and
|
|
25
|
+
* generates e2e test functions for every API endpoints.
|
|
26
|
+
*
|
|
27
|
+
* If not configured, you can't run `npx nestia e2e` command.
|
|
24
28
|
*/
|
|
25
29
|
e2e?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Target directory that SDK distribution files would be placed in.
|
|
32
|
+
*
|
|
33
|
+
* If you configure this property and runs `npx nestia sdk` command,
|
|
34
|
+
* distribution environments for the SDK library would be generated.
|
|
35
|
+
*
|
|
36
|
+
* After the SDK library generation, move to the `distribute` directory,
|
|
37
|
+
* and runs `npm publish` command, then you can share SDK library with
|
|
38
|
+
* other client (frontend) developers.
|
|
39
|
+
*
|
|
40
|
+
* Recommend to use `"packages/api"` value.
|
|
41
|
+
*/
|
|
42
|
+
distribute?: string;
|
|
26
43
|
/**
|
|
27
44
|
* Compiler options for the TypeScript.
|
|
28
45
|
*
|
|
@@ -47,20 +64,26 @@ export interface INestiaConfig {
|
|
|
47
64
|
/**
|
|
48
65
|
* Whether to assert parameter types or not.
|
|
49
66
|
*
|
|
50
|
-
* If you configure this property to be `true`, all of the function
|
|
51
|
-
* would be checked through
|
|
52
|
-
*
|
|
53
|
-
*
|
|
67
|
+
* If you configure this property to be `true`, all of the function
|
|
68
|
+
* parameters of SDK library would be checked through
|
|
69
|
+
* [`typia.assert<T>()` function](https://typia.io/docs/validators/assert/).
|
|
70
|
+
*
|
|
71
|
+
* This option would make your SDK library compilation time a little bit slower,
|
|
72
|
+
* but would enahcne the type safety even in the runtime level.
|
|
54
73
|
*
|
|
55
74
|
* @default false
|
|
56
75
|
*/
|
|
57
76
|
assert?: boolean;
|
|
58
77
|
/**
|
|
59
|
-
* Whether to optimize JSON string conversion
|
|
78
|
+
* Whether to optimize JSON string conversion 10x faster or not.
|
|
60
79
|
*
|
|
61
80
|
* If you configure this property to be `true`, the SDK library would utilize the
|
|
62
|
-
* [typia](https://github.com/samchon/typia#enhanced-json)
|
|
63
|
-
*
|
|
81
|
+
* [`typia.assertStringify<T>() function`](https://github.com/samchon/typia#enhanced-json)
|
|
82
|
+
* to boost up JSON serialization speed and ensure type safety.
|
|
83
|
+
*
|
|
84
|
+
* This option would make your SDK library compilation time a little bit slower,
|
|
85
|
+
* but would enhance JSON serialization speed 10x faster. Also, it can ensure type
|
|
86
|
+
* safety even in the rumtime level.
|
|
64
87
|
*
|
|
65
88
|
* @default false
|
|
66
89
|
*/
|
|
@@ -70,7 +70,7 @@ var NestiaSdkConfig;
|
|
|
70
70
|
const __is = input => {
|
|
71
71
|
const $join = typia_1.assert.join;
|
|
72
72
|
const $is_custom = typia_1.assert.is_custom;
|
|
73
|
-
const $io0 = input => null !== input.input && undefined !== input.input && ("string" === typeof input.input || (Array.isArray(input.input) && input.input.every(elem => "string" === typeof elem) || "object" === typeof input.input && null !== input.input && $io1(input.input))) && (undefined === input.output || "string" === typeof input.output) && (undefined === input.e2e || "string" === typeof input.e2e) && (undefined === input.compilerOptions || "object" === typeof input.compilerOptions && null !== input.compilerOptions && false === Array.isArray(input.compilerOptions) && $io2(input.compilerOptions)) && (undefined === input.assert || "boolean" === typeof input.assert) && (undefined === input.json || "boolean" === typeof input.json) && (undefined === input.primitive || "boolean" === typeof input.primitive) && (undefined === input.swagger || "object" === typeof input.swagger && null !== input.swagger && $io4(input.swagger));
|
|
73
|
+
const $io0 = input => null !== input.input && undefined !== input.input && ("string" === typeof input.input || (Array.isArray(input.input) && input.input.every(elem => "string" === typeof elem) || "object" === typeof input.input && null !== input.input && $io1(input.input))) && (undefined === input.output || "string" === typeof input.output) && (undefined === input.e2e || "string" === typeof input.e2e) && (undefined === input.distribute || "string" === typeof input.distribute) && (undefined === input.compilerOptions || "object" === typeof input.compilerOptions && null !== input.compilerOptions && false === Array.isArray(input.compilerOptions) && $io2(input.compilerOptions)) && (undefined === input.assert || "boolean" === typeof input.assert) && (undefined === input.json || "boolean" === typeof input.json) && (undefined === input.primitive || "boolean" === typeof input.primitive) && (undefined === input.swagger || "object" === typeof input.swagger && null !== input.swagger && $io4(input.swagger));
|
|
74
74
|
const $io1 = input => Array.isArray(input.include) && input.include.every(elem => "string" === typeof elem) && (undefined === input.exclude || Array.isArray(input.exclude) && input.exclude.every(elem => "string" === typeof elem));
|
|
75
75
|
const $io2 = input => (undefined === input.allowJs || "boolean" === typeof input.allowJs) && (undefined === input.allowSyntheticDefaultImports || "boolean" === typeof input.allowSyntheticDefaultImports) && (undefined === input.allowUmdGlobalAccess || "boolean" === typeof input.allowUmdGlobalAccess) && (undefined === input.allowUnreachableCode || "boolean" === typeof input.allowUnreachableCode) && (undefined === input.allowUnusedLabels || "boolean" === typeof input.allowUnusedLabels) && (undefined === input.alwaysStrict || "boolean" === typeof input.alwaysStrict) && (undefined === input.baseUrl || "string" === typeof input.baseUrl) && (undefined === input.charset || "string" === typeof input.charset) && (undefined === input.checkJs || "boolean" === typeof input.checkJs) && (undefined === input.declaration || "boolean" === typeof input.declaration) && (undefined === input.declarationMap || "boolean" === typeof input.declarationMap) && (undefined === input.emitDeclarationOnly || "boolean" === typeof input.emitDeclarationOnly) && (undefined === input.declarationDir || "string" === typeof input.declarationDir) && (undefined === input.disableSizeLimit || "boolean" === typeof input.disableSizeLimit) && (undefined === input.disableSourceOfProjectReferenceRedirect || "boolean" === typeof input.disableSourceOfProjectReferenceRedirect) && (undefined === input.disableSolutionSearching || "boolean" === typeof input.disableSolutionSearching) && (undefined === input.disableReferencedProjectLoad || "boolean" === typeof input.disableReferencedProjectLoad) && (undefined === input.downlevelIteration || "boolean" === typeof input.downlevelIteration) && (undefined === input.emitBOM || "boolean" === typeof input.emitBOM) && (undefined === input.emitDecoratorMetadata || "boolean" === typeof input.emitDecoratorMetadata) && (undefined === input.exactOptionalPropertyTypes || "boolean" === typeof input.exactOptionalPropertyTypes) && (undefined === input.experimentalDecorators || "boolean" === typeof input.experimentalDecorators) && (undefined === input.forceConsistentCasingInFileNames || "boolean" === typeof input.forceConsistentCasingInFileNames) && (undefined === input.importHelpers || "boolean" === typeof input.importHelpers) && true && (undefined === input.inlineSourceMap || "boolean" === typeof input.inlineSourceMap) && (undefined === input.inlineSources || "boolean" === typeof input.inlineSources) && (undefined === input.isolatedModules || "boolean" === typeof input.isolatedModules) && true && (undefined === input.keyofStringsOnly || "boolean" === typeof input.keyofStringsOnly) && (undefined === input.lib || Array.isArray(input.lib) && input.lib.every(elem => "string" === typeof elem)) && (undefined === input.locale || "string" === typeof input.locale) && (undefined === input.mapRoot || "string" === typeof input.mapRoot) && true && true && true && (undefined === input.moduleSuffixes || Array.isArray(input.moduleSuffixes) && input.moduleSuffixes.every(elem => "string" === typeof elem)) && true && true && (undefined === input.noEmit || "boolean" === typeof input.noEmit) && (undefined === input.noEmitHelpers || "boolean" === typeof input.noEmitHelpers) && (undefined === input.noEmitOnError || "boolean" === typeof input.noEmitOnError) && (undefined === input.noErrorTruncation || "boolean" === typeof input.noErrorTruncation) && (undefined === input.noFallthroughCasesInSwitch || "boolean" === typeof input.noFallthroughCasesInSwitch) && (undefined === input.noImplicitAny || "boolean" === typeof input.noImplicitAny) && (undefined === input.noImplicitReturns || "boolean" === typeof input.noImplicitReturns) && (undefined === input.noImplicitThis || "boolean" === typeof input.noImplicitThis) && (undefined === input.noStrictGenericChecks || "boolean" === typeof input.noStrictGenericChecks) && (undefined === input.noUnusedLocals || "boolean" === typeof input.noUnusedLocals) && (undefined === input.noUnusedParameters || "boolean" === typeof input.noUnusedParameters) && (undefined === input.noImplicitUseStrict || "boolean" === typeof input.noImplicitUseStrict) && (undefined === input.noPropertyAccessFromIndexSignature || "boolean" === typeof input.noPropertyAccessFromIndexSignature) && (undefined === input.assumeChangesOnlyAffectDirectDependencies || "boolean" === typeof input.assumeChangesOnlyAffectDirectDependencies) && (undefined === input.noLib || "boolean" === typeof input.noLib) && (undefined === input.noResolve || "boolean" === typeof input.noResolve) && (undefined === input.noUncheckedIndexedAccess || "boolean" === typeof input.noUncheckedIndexedAccess) && (undefined === input.out || "string" === typeof input.out) && (undefined === input.outDir || "string" === typeof input.outDir) && (undefined === input.outFile || "string" === typeof input.outFile) && (undefined === input.paths || "object" === typeof input.paths && null !== input.paths && false === Array.isArray(input.paths) && $io3(input.paths)) && (undefined === input.preserveConstEnums || "boolean" === typeof input.preserveConstEnums) && (undefined === input.noImplicitOverride || "boolean" === typeof input.noImplicitOverride) && (undefined === input.preserveSymlinks || "boolean" === typeof input.preserveSymlinks) && (undefined === input.preserveValueImports || "boolean" === typeof input.preserveValueImports) && (undefined === input.project || "string" === typeof input.project) && (undefined === input.reactNamespace || "string" === typeof input.reactNamespace) && (undefined === input.jsxFactory || "string" === typeof input.jsxFactory) && (undefined === input.jsxFragmentFactory || "string" === typeof input.jsxFragmentFactory) && (undefined === input.jsxImportSource || "string" === typeof input.jsxImportSource) && (undefined === input.composite || "boolean" === typeof input.composite) && (undefined === input.incremental || "boolean" === typeof input.incremental) && (undefined === input.tsBuildInfoFile || "string" === typeof input.tsBuildInfoFile) && (undefined === input.removeComments || "boolean" === typeof input.removeComments) && (undefined === input.rootDir || "string" === typeof input.rootDir) && (undefined === input.rootDirs || Array.isArray(input.rootDirs) && input.rootDirs.every(elem => "string" === typeof elem)) && (undefined === input.skipLibCheck || "boolean" === typeof input.skipLibCheck) && (undefined === input.skipDefaultLibCheck || "boolean" === typeof input.skipDefaultLibCheck) && (undefined === input.sourceMap || "boolean" === typeof input.sourceMap) && (undefined === input.sourceRoot || "string" === typeof input.sourceRoot) && (undefined === input.strict || "boolean" === typeof input.strict) && (undefined === input.strictFunctionTypes || "boolean" === typeof input.strictFunctionTypes) && (undefined === input.strictBindCallApply || "boolean" === typeof input.strictBindCallApply) && (undefined === input.strictNullChecks || "boolean" === typeof input.strictNullChecks) && (undefined === input.strictPropertyInitialization || "boolean" === typeof input.strictPropertyInitialization) && (undefined === input.stripInternal || "boolean" === typeof input.stripInternal) && (undefined === input.suppressExcessPropertyErrors || "boolean" === typeof input.suppressExcessPropertyErrors) && (undefined === input.suppressImplicitAnyIndexErrors || "boolean" === typeof input.suppressImplicitAnyIndexErrors) && true && (undefined === input.traceResolution || "boolean" === typeof input.traceResolution) && (undefined === input.useUnknownInCatchVariables || "boolean" === typeof input.useUnknownInCatchVariables) && (undefined === input.resolveJsonModule || "boolean" === typeof input.resolveJsonModule) && (undefined === input.types || Array.isArray(input.types) && input.types.every(elem => "string" === typeof elem)) && (undefined === input.typeRoots || Array.isArray(input.typeRoots) && input.typeRoots.every(elem => "string" === typeof elem)) && (undefined === input.esModuleInterop || "boolean" === typeof input.esModuleInterop) && (undefined === input.useDefineForClassFields || "boolean" === typeof input.useDefineForClassFields) && Object.keys(input).every(key => {
|
|
76
76
|
const value = input[key];
|
|
@@ -151,6 +151,10 @@ var NestiaSdkConfig;
|
|
|
151
151
|
path: _path + ".e2e",
|
|
152
152
|
expected: "(string | undefined)",
|
|
153
153
|
value: input.e2e
|
|
154
|
+
})) && (undefined === input.distribute || "string" === typeof input.distribute || $guard(_exceptionable, {
|
|
155
|
+
path: _path + ".distribute",
|
|
156
|
+
expected: "(string | undefined)",
|
|
157
|
+
value: input.distribute
|
|
154
158
|
})) && (undefined === input.compilerOptions || ("object" === typeof input.compilerOptions && null !== input.compilerOptions && false === Array.isArray(input.compilerOptions) || $guard(_exceptionable, {
|
|
155
159
|
path: _path + ".compilerOptions",
|
|
156
160
|
expected: "(StripEnums<ts.CompilerOptions> | undefined)",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NestiaSdkConfig.js","sourceRoot":"","sources":["../../../src/executable/internal/NestiaSdkConfig.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AACxB,gDAAkC;AAClC,qDAAkD;AAElD,iCAA+B;AAI/B,IAAiB,eAAe,CA0B/B;AA1BD,WAAiB,eAAe;IAC5B,SAAgB,GAAG;QACf,OAAO,SAAS,CAAC,GAAG,EAAE,CAAC;IAC3B,CAAC;IAFe,mBAAG,MAElB,CAAA;IAED,MAAM,SAAS,GAAG,IAAI,qBAAS,CAAC,GAAS,EAAE;;QACvC,IAAI,YAAE,CAAC,UAAU,CAAC,kBAAkB,CAAC,KAAK,KAAK;YAAE,OAAO,IAAI,CAAC;QAE7D,MAAM,CAAC,QAAQ,CAAC;YACZ,IAAI,EAAE,KAAK;YACX,eAAe,EAAE;gBACb,MAAM,EAAE,UAAU;gBAClB,MAAM,EAAE,IAAI;aACf;SACJ,CAAC,CAAC;QAEH,MAAM,MAAM,GACR,YAAa,cAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,0DAAC,CAAC;QACnD,IAAI,OAAO,MAAM,KAAK,QAAQ;YAC1B,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;QAExE,MAAM,MAAM,GACR,OAAO,MAAM,CAAC,OAAO,K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AC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;QACjE;2BAAO,cAAM;0BAAN,cAAM;+BAAN,cAAM;;8BAAN,cAAM;mCAAN,cAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAAC,MAAM,EAAE;IAC1B,CAAC,CAAA,CAAC,CAAC;AACP,CAAC,EA1BgB,eAAe,GAAf,uBAAe,KAAf,uBAAe,QA0B/B"}
|
|
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.SdkGenerator = void 0;
|
|
16
16
|
const fs_1 = __importDefault(require("fs"));
|
|
17
17
|
const path_1 = __importDefault(require("path"));
|
|
18
|
+
const DistributionComposer_1 = require("./internal/DistributionComposer");
|
|
18
19
|
const SdkFileProgrammer_1 = require("./internal/SdkFileProgrammer");
|
|
19
20
|
var SdkGenerator;
|
|
20
21
|
(function (SdkGenerator) {
|
|
@@ -37,6 +38,9 @@ var SdkGenerator;
|
|
|
37
38
|
}
|
|
38
39
|
// FUNCTIONAL
|
|
39
40
|
yield SdkFileProgrammer_1.SdkFileProgrammer.generate(config)(routes);
|
|
41
|
+
// DISTRIBUTION
|
|
42
|
+
if (config.distribute !== undefined)
|
|
43
|
+
yield DistributionComposer_1.DistributionComposer.compose(config);
|
|
40
44
|
});
|
|
41
45
|
SdkGenerator.BUNDLE_PATH = path_1.default.join(__dirname, "..", "..", "assets", "bundle", "api");
|
|
42
46
|
})(SdkGenerator = exports.SdkGenerator || (exports.SdkGenerator = {}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SdkGenerator.js","sourceRoot":"","sources":["../../src/generates/SdkGenerator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,4CAAoB;AACpB,gDAA4B;AAI5B,oEAAiE;AAEjE,IAAiB,YAAY,
|
|
1
|
+
{"version":3,"file":"SdkGenerator.js","sourceRoot":"","sources":["../../src/generates/SdkGenerator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,4CAAoB;AACpB,gDAA4B;AAI5B,0EAAuE;AACvE,oEAAiE;AAEjE,IAAiB,YAAY,CA6C5B;AA7CD,WAAiB,YAAY;IACZ,qBAAQ,GACjB,CAAC,MAAqB,EAAE,EAAE,CAC1B,CAAO,MAAgB,EAAiB,EAAE;QACtC,0BAA0B;QAC1B,IAAI;YACA,MAAM,YAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,MAAO,CAAC,CAAC;SAC3C;QAAC,WAAM,GAAE;QAEV,WAAW;QACX,MAAM,MAAM,GAAa,MAAM,YAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,aAAA,WAAW,CAAC,CAAC;QAChE,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE;YACvB,MAAM,OAAO,GAAW,GAAG,aAAA,WAAW,IAAI,IAAI,EAAE,CAAC;YACjD,MAAM,KAAK,GAAa,MAAM,YAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAExD,IAAI,KAAK,CAAC,MAAM,EAAE,KAAK,IAAI,EAAE;gBACzB,MAAM,OAAO,GAAW,MAAM,YAAE,CAAC,QAAQ,CAAC,QAAQ,CAC9C,OAAO,EACP,MAAM,CACT,CAAC;gBACF,IAAI,YAAE,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,MAAM,IAAI,IAAI,EAAE,CAAC,KAAK,KAAK;oBACnD,MAAM,YAAE,CAAC,QAAQ,CAAC,SAAS,CACvB,GAAG,MAAM,CAAC,MAAM,IAAI,IAAI,EAAE,EAC1B,OAAO,EACP,MAAM,CACT,CAAC;aACT;SACJ;QAED,aAAa;QACb,MAAM,qCAAiB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;QAEjD,eAAe;QACf,IAAI,MAAM,CAAC,UAAU,KAAK,SAAS;YAC/B,MAAM,2CAAoB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACnD,CAAC,CAAA,CAAC;IAEO,wBAAW,GAAG,cAAQ,CAAC,IAAI,CACpC,SAAS,EACT,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,KAAK,CACR,CAAC;AACN,CAAC,EA7CgB,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QA6C5B"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.DistributionComposer = void 0;
|
|
16
|
+
const child_process_1 = __importDefault(require("child_process"));
|
|
17
|
+
const fs_1 = __importDefault(require("fs"));
|
|
18
|
+
const path_1 = __importDefault(require("path"));
|
|
19
|
+
var DistributionComposer;
|
|
20
|
+
(function (DistributionComposer) {
|
|
21
|
+
DistributionComposer.compose = (config) => __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
if (!fs_1.default.existsSync(config.distribute))
|
|
23
|
+
yield fs_1.default.promises.mkdir(config.distribute);
|
|
24
|
+
const root = process.cwd();
|
|
25
|
+
const output = path_1.default.resolve(config.output);
|
|
26
|
+
process.chdir(config.distribute);
|
|
27
|
+
const exit = () => {
|
|
28
|
+
process.chdir(root);
|
|
29
|
+
};
|
|
30
|
+
const typia = !!config.assert || !!config.json;
|
|
31
|
+
if ((yield configured({
|
|
32
|
+
typia,
|
|
33
|
+
distribute: config.distribute,
|
|
34
|
+
})) === true)
|
|
35
|
+
return exit();
|
|
36
|
+
// COPY FILES
|
|
37
|
+
console.log("Composing SDK distribution environments...");
|
|
38
|
+
for (const file of yield fs_1.default.promises.readdir(BUNDLE))
|
|
39
|
+
yield fs_1.default.promises.copyFile(`${BUNDLE}/${file}`, file);
|
|
40
|
+
// CONFIGURE PATHS
|
|
41
|
+
for (const file of ["package.json", "tsconfig.json"])
|
|
42
|
+
yield replace({ root, output })(file);
|
|
43
|
+
// INSTALL PACKAGES
|
|
44
|
+
execute("npm install --save-dev rimraf");
|
|
45
|
+
execute("npm install --save @nestia/fetcher@latest");
|
|
46
|
+
if (typia) {
|
|
47
|
+
execute("npm install --save typia@latest");
|
|
48
|
+
execute("npx typia setup --manager npm");
|
|
49
|
+
}
|
|
50
|
+
else
|
|
51
|
+
execute("npm install --save-dev typescript");
|
|
52
|
+
exit();
|
|
53
|
+
});
|
|
54
|
+
const configured = (config) => __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
return ["package.json", "tsconfig.json"].every((file) => fs_1.default.existsSync(`${config.distribute}/${file}`)) &&
|
|
56
|
+
(yield (() => __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
var _a, _b;
|
|
58
|
+
const content = JSON.parse(yield fs_1.default.promises.readFile(`${config.distribute}/package.json`, "utf8"));
|
|
59
|
+
return (!!((_a = content.dependencies) === null || _a === void 0 ? void 0 : _a["@nestia/fetcher"]) &&
|
|
60
|
+
(config.typia === false || !!((_b = content.dependencies) === null || _b === void 0 ? void 0 : _b["typia"])));
|
|
61
|
+
}))()) &&
|
|
62
|
+
(config.typia === false ||
|
|
63
|
+
(yield (() => __awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
const content = yield fs_1.default.promises.readFile(`${config.distribute}/tsconfig.json`);
|
|
65
|
+
return content.includes("typia/lib/transform");
|
|
66
|
+
}))()));
|
|
67
|
+
});
|
|
68
|
+
const execute = (command) => {
|
|
69
|
+
console.log(` - ${command}`);
|
|
70
|
+
child_process_1.default.execSync(command, { stdio: "ignore" });
|
|
71
|
+
};
|
|
72
|
+
const replace = (props) => (file) => __awaiter(this, void 0, void 0, function* () {
|
|
73
|
+
const relative = (from) => (to) => path_1.default.relative(from, to).split("\\").join("/");
|
|
74
|
+
const root = relative(process.cwd())(props.root);
|
|
75
|
+
const output = relative(process.cwd())(props.output);
|
|
76
|
+
const current = relative(props.root)(process.cwd());
|
|
77
|
+
const content = yield fs_1.default.promises.readFile(file, "utf8");
|
|
78
|
+
yield fs_1.default.promises.writeFile(file, content
|
|
79
|
+
.split("${root}")
|
|
80
|
+
.join(root)
|
|
81
|
+
.split("${output}")
|
|
82
|
+
.join(output)
|
|
83
|
+
.split("${current}")
|
|
84
|
+
.join(current), "utf8");
|
|
85
|
+
});
|
|
86
|
+
})(DistributionComposer = exports.DistributionComposer || (exports.DistributionComposer = {}));
|
|
87
|
+
const BUNDLE = __dirname + "/../../../assets/bundle/distribute";
|
|
88
|
+
//# sourceMappingURL=DistributionComposer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DistributionComposer.js","sourceRoot":"","sources":["../../../src/generates/internal/DistributionComposer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kEAA+B;AAC/B,4CAAoB;AACpB,gDAAwB;AAIxB,IAAiB,oBAAoB,CAiGpC;AAjGD,WAAiB,oBAAoB;IACpB,4BAAO,GAAG,CAAO,MAAqB,EAAiB,EAAE;QAClE,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,MAAM,CAAC,UAAW,CAAC;YAClC,MAAM,YAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,UAAW,CAAC,CAAC;QAEhD,MAAM,IAAI,GAAW,OAAO,CAAC,GAAG,EAAE,CAAC;QACnC,MAAM,MAAM,GAAW,cAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAO,CAAC,CAAC;QACpD,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,UAAW,CAAC,CAAC;QAElC,MAAM,IAAI,GAAG,GAAG,EAAE;YACd,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACxB,CAAC,CAAC;QAEF,MAAM,KAAK,GAAY,CAAC,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC;QACxD,IACI,CAAC,MAAM,UAAU,CAAC;YACd,KAAK;YACL,UAAU,EAAE,MAAM,CAAC,UAAW;SACjC,CAAC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,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QAE5D,MAAM,OAAO,GAAW,MAAM,YAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACjE,MAAM,YAAE,CAAC,QAAQ,CAAC,SAAS,CACvB,IAAI,EACJ,OAAO;aACF,KAAK,CAAC,SAAS,CAAC;aAChB,IAAI,CAAC,IAAI,CAAC;aACV,KAAK,CAAC,WAAW,CAAC;aAClB,IAAI,CAAC,MAAM,CAAC;aACZ,KAAK,CAAC,YAAY,CAAC;aACnB,IAAI,CAAC,OAAO,CAAC,EAClB,MAAM,CACT,CAAC;IACN,CAAC,CAAA,CAAC;AACV,CAAC,EAjGgB,oBAAoB,GAApB,4BAAoB,KAApB,4BAAoB,QAiGpC;AAED,MAAM,MAAM,GAAG,SAAS,GAAG,oCAAoC,CAAC"}
|
package/package.json
CHANGED
package/src/INestiaConfig.ts
CHANGED
|
@@ -22,12 +22,30 @@ export interface INestiaConfig {
|
|
|
22
22
|
output?: string;
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
25
|
+
* Target directory that e2e test functions would be placed in.
|
|
26
26
|
*
|
|
27
|
-
* If
|
|
27
|
+
* If you configure this property and runs `npx nestia e2e` command,
|
|
28
|
+
* `@nestia/sdk` will analyze your NestJS backend server code, and
|
|
29
|
+
* generates e2e test functions for every API endpoints.
|
|
30
|
+
*
|
|
31
|
+
* If not configured, you can't run `npx nestia e2e` command.
|
|
28
32
|
*/
|
|
29
33
|
e2e?: string;
|
|
30
34
|
|
|
35
|
+
/**
|
|
36
|
+
* Target directory that SDK distribution files would be placed in.
|
|
37
|
+
*
|
|
38
|
+
* If you configure this property and runs `npx nestia sdk` command,
|
|
39
|
+
* distribution environments for the SDK library would be generated.
|
|
40
|
+
*
|
|
41
|
+
* After the SDK library generation, move to the `distribute` directory,
|
|
42
|
+
* and runs `npm publish` command, then you can share SDK library with
|
|
43
|
+
* other client (frontend) developers.
|
|
44
|
+
*
|
|
45
|
+
* Recommend to use `"packages/api"` value.
|
|
46
|
+
*/
|
|
47
|
+
distribute?: string;
|
|
48
|
+
|
|
31
49
|
/**
|
|
32
50
|
* Compiler options for the TypeScript.
|
|
33
51
|
*
|
|
@@ -53,21 +71,27 @@ export interface INestiaConfig {
|
|
|
53
71
|
/**
|
|
54
72
|
* Whether to assert parameter types or not.
|
|
55
73
|
*
|
|
56
|
-
* If you configure this property to be `true`, all of the function
|
|
57
|
-
* would be checked through
|
|
58
|
-
*
|
|
59
|
-
*
|
|
74
|
+
* If you configure this property to be `true`, all of the function
|
|
75
|
+
* parameters of SDK library would be checked through
|
|
76
|
+
* [`typia.assert<T>()` function](https://typia.io/docs/validators/assert/).
|
|
77
|
+
*
|
|
78
|
+
* This option would make your SDK library compilation time a little bit slower,
|
|
79
|
+
* but would enahcne the type safety even in the runtime level.
|
|
60
80
|
*
|
|
61
81
|
* @default false
|
|
62
82
|
*/
|
|
63
83
|
assert?: boolean;
|
|
64
84
|
|
|
65
85
|
/**
|
|
66
|
-
* Whether to optimize JSON string conversion
|
|
86
|
+
* Whether to optimize JSON string conversion 10x faster or not.
|
|
67
87
|
*
|
|
68
88
|
* If you configure this property to be `true`, the SDK library would utilize the
|
|
69
|
-
* [typia](https://github.com/samchon/typia#enhanced-json)
|
|
70
|
-
*
|
|
89
|
+
* [`typia.assertStringify<T>() function`](https://github.com/samchon/typia#enhanced-json)
|
|
90
|
+
* to boost up JSON serialization speed and ensure type safety.
|
|
91
|
+
*
|
|
92
|
+
* This option would make your SDK library compilation time a little bit slower,
|
|
93
|
+
* but would enhance JSON serialization speed 10x faster. Also, it can ensure type
|
|
94
|
+
* safety even in the rumtime level.
|
|
71
95
|
*
|
|
72
96
|
* @default false
|
|
73
97
|
*/
|
|
@@ -3,6 +3,7 @@ import NodePath from "path";
|
|
|
3
3
|
|
|
4
4
|
import { INestiaConfig } from "../INestiaConfig";
|
|
5
5
|
import { IRoute } from "../structures/IRoute";
|
|
6
|
+
import { DistributionComposer } from "./internal/DistributionComposer";
|
|
6
7
|
import { SdkFileProgrammer } from "./internal/SdkFileProgrammer";
|
|
7
8
|
|
|
8
9
|
export namespace SdkGenerator {
|
|
@@ -36,6 +37,10 @@ export namespace SdkGenerator {
|
|
|
36
37
|
|
|
37
38
|
// FUNCTIONAL
|
|
38
39
|
await SdkFileProgrammer.generate(config)(routes);
|
|
40
|
+
|
|
41
|
+
// DISTRIBUTION
|
|
42
|
+
if (config.distribute !== undefined)
|
|
43
|
+
await DistributionComposer.compose(config);
|
|
39
44
|
};
|
|
40
45
|
|
|
41
46
|
export const BUNDLE_PATH = NodePath.join(
|
|
@@ -0,0 +1,106 @@
|
|
|
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 = !!config.assert || !!config.json;
|
|
21
|
+
if (
|
|
22
|
+
(await configured({
|
|
23
|
+
typia,
|
|
24
|
+
distribute: config.distribute!,
|
|
25
|
+
})) === true
|
|
26
|
+
)
|
|
27
|
+
return exit();
|
|
28
|
+
|
|
29
|
+
// COPY FILES
|
|
30
|
+
console.log("Composing SDK distribution environments...");
|
|
31
|
+
for (const file of await fs.promises.readdir(BUNDLE))
|
|
32
|
+
await fs.promises.copyFile(`${BUNDLE}/${file}`, file);
|
|
33
|
+
|
|
34
|
+
// CONFIGURE PATHS
|
|
35
|
+
for (const file of ["package.json", "tsconfig.json"])
|
|
36
|
+
await replace({ root, output })(file);
|
|
37
|
+
|
|
38
|
+
// INSTALL PACKAGES
|
|
39
|
+
execute("npm install --save-dev rimraf");
|
|
40
|
+
execute("npm install --save @nestia/fetcher@latest");
|
|
41
|
+
|
|
42
|
+
if (typia) {
|
|
43
|
+
execute("npm install --save typia@latest");
|
|
44
|
+
execute("npx typia setup --manager npm");
|
|
45
|
+
} else execute("npm install --save-dev typescript");
|
|
46
|
+
|
|
47
|
+
exit();
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const configured = async (config: {
|
|
51
|
+
typia: boolean;
|
|
52
|
+
distribute: string;
|
|
53
|
+
}): Promise<boolean> =>
|
|
54
|
+
["package.json", "tsconfig.json"].every((file) =>
|
|
55
|
+
fs.existsSync(`${config.distribute!}/${file}`),
|
|
56
|
+
) &&
|
|
57
|
+
(await (async () => {
|
|
58
|
+
const content = JSON.parse(
|
|
59
|
+
await fs.promises.readFile(
|
|
60
|
+
`${config.distribute!}/package.json`,
|
|
61
|
+
"utf8",
|
|
62
|
+
),
|
|
63
|
+
);
|
|
64
|
+
return (
|
|
65
|
+
!!content.dependencies?.["@nestia/fetcher"] &&
|
|
66
|
+
(config.typia === false || !!content.dependencies?.["typia"])
|
|
67
|
+
);
|
|
68
|
+
})()) &&
|
|
69
|
+
(config.typia === false ||
|
|
70
|
+
(await (async () => {
|
|
71
|
+
const content = await fs.promises.readFile(
|
|
72
|
+
`${config.distribute!}/tsconfig.json`,
|
|
73
|
+
);
|
|
74
|
+
return content.includes("typia/lib/transform");
|
|
75
|
+
})()));
|
|
76
|
+
|
|
77
|
+
const execute = (command: string) => {
|
|
78
|
+
console.log(` - ${command}`);
|
|
79
|
+
cp.execSync(command, { stdio: "ignore" });
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const replace =
|
|
83
|
+
(props: { root: string; output: string }) =>
|
|
84
|
+
async (file: string): Promise<void> => {
|
|
85
|
+
const relative = (from: string) => (to: string) =>
|
|
86
|
+
path.relative(from, to).split("\\").join("/");
|
|
87
|
+
const root: string = relative(process.cwd())(props.root);
|
|
88
|
+
const output: string = relative(process.cwd())(props.output);
|
|
89
|
+
const current: string = relative(props.root)(process.cwd());
|
|
90
|
+
|
|
91
|
+
const content: string = await fs.promises.readFile(file, "utf8");
|
|
92
|
+
await fs.promises.writeFile(
|
|
93
|
+
file,
|
|
94
|
+
content
|
|
95
|
+
.split("${root}")
|
|
96
|
+
.join(root)
|
|
97
|
+
.split("${output}")
|
|
98
|
+
.join(output)
|
|
99
|
+
.split("${current}")
|
|
100
|
+
.join(current),
|
|
101
|
+
"utf8",
|
|
102
|
+
);
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const BUNDLE = __dirname + "/../../../assets/bundle/distribute";
|