@nestia/migrate 14.0.0 → 14.0.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.
- package/README.md +1 -1
- package/lib/NestiaMigrateApplication.d.ts +111 -0
- package/lib/NestiaMigrateApplication.js +148 -9
- package/lib/NestiaMigrateApplication.js.map +1 -1
- package/lib/NestiaMigrateApplication.mjs +147 -5
- package/lib/analyzers/NestiaMigrateControllerAnalyzer.d.ts +58 -0
- package/lib/analyzers/NestiaMigrateControllerAnalyzer.js +88 -2
- package/lib/analyzers/NestiaMigrateControllerAnalyzer.js.map +1 -1
- package/lib/analyzers/NestiaMigrateControllerAnalyzer.mjs +20 -2
- package/lib/archivers/NestiaMigrateFileArchiver.d.ts +34 -0
- package/lib/archivers/NestiaMigrateFileArchiver.js +34 -0
- package/lib/archivers/NestiaMigrateFileArchiver.js.map +1 -1
- package/lib/bundles/NEST_TEMPLATE.js +1 -1
- package/lib/bundles/NEST_TEMPLATE.js.map +1 -1
- package/lib/bundles/NEST_TEMPLATE.mjs +1 -1
- package/lib/bundles/SDK_TEMPLATE.js +1 -1
- package/lib/bundles/SDK_TEMPLATE.js.map +1 -1
- package/lib/bundles/SDK_TEMPLATE.mjs +1 -1
- package/lib/executable/NestiaMigrateCommander.d.ts +36 -0
- package/lib/executable/NestiaMigrateCommander.js +43 -1
- package/lib/executable/NestiaMigrateCommander.js.map +1 -1
- package/lib/executable/NestiaMigrateCommander.mjs +4 -2
- package/lib/executable/NestiaMigrateInquirer.d.ts +29 -0
- package/lib/executable/NestiaMigrateInquirer.js +27 -25
- package/lib/executable/NestiaMigrateInquirer.js.map +1 -1
- package/lib/executable/NestiaMigrateInquirer.mjs +5 -7
- package/lib/factories/ExpressionFactory.d.ts +14 -0
- package/lib/factories/ExpressionFactory.js +14 -0
- package/lib/factories/ExpressionFactory.js.map +1 -1
- package/lib/factories/IdentifierFactory.d.ts +20 -0
- package/lib/factories/IdentifierFactory.js +20 -0
- package/lib/factories/IdentifierFactory.js.map +1 -1
- package/lib/factories/LiteralFactory.d.ts +18 -2
- package/lib/factories/LiteralFactory.js +18 -2
- package/lib/factories/LiteralFactory.js.map +1 -1
- package/lib/factories/StatementFactory.d.ts +26 -1
- package/lib/factories/StatementFactory.js +26 -1
- package/lib/factories/StatementFactory.js.map +1 -1
- package/lib/factories/SupportedStringFormats.d.ts +6 -0
- package/lib/factories/SupportedStringFormats.js +33 -0
- package/lib/factories/SupportedStringFormats.js.map +1 -0
- package/lib/factories/SupportedStringFormats.mjs +34 -0
- package/lib/factories/SupportedStringFormats.mjs.map +1 -0
- package/lib/factories/TypeFactory.d.ts +21 -0
- package/lib/factories/TypeFactory.js +13 -0
- package/lib/factories/TypeFactory.js.map +1 -1
- package/lib/factories/TypeLiteralFactory.d.ts +18 -0
- package/lib/factories/TypeLiteralFactory.js +18 -0
- package/lib/factories/TypeLiteralFactory.js.map +1 -1
- package/lib/internal/ts.d.ts +153 -0
- package/lib/internal/ts.js.map +1 -1
- package/lib/programmers/NestiaMigrateApiFileProgrammer.d.ts +31 -0
- package/lib/programmers/NestiaMigrateApiFileProgrammer.js +17 -0
- package/lib/programmers/NestiaMigrateApiFileProgrammer.js.map +1 -1
- package/lib/programmers/NestiaMigrateApiFunctionProgrammer.d.ts +40 -0
- package/lib/programmers/NestiaMigrateApiFunctionProgrammer.js +34 -5
- package/lib/programmers/NestiaMigrateApiFunctionProgrammer.js.map +1 -1
- package/lib/programmers/NestiaMigrateApiFunctionProgrammer.mjs +4 -2
- package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.d.ts +39 -0
- package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.js +57 -13
- package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.js.map +1 -1
- package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.mjs +17 -8
- package/lib/programmers/NestiaMigrateApiProgrammer.d.ts +18 -0
- package/lib/programmers/NestiaMigrateApiProgrammer.js +18 -0
- package/lib/programmers/NestiaMigrateApiProgrammer.js.map +1 -1
- package/lib/programmers/NestiaMigrateApiProgrammer.mjs +1 -1
- package/lib/programmers/NestiaMigrateApiSimulationProgrammer.d.ts +40 -0
- package/lib/programmers/NestiaMigrateApiSimulationProgrammer.js +51 -22
- package/lib/programmers/NestiaMigrateApiSimulationProgrammer.js.map +1 -1
- package/lib/programmers/NestiaMigrateApiSimulationProgrammer.mjs +13 -20
- package/lib/programmers/NestiaMigrateApiStartProgrammer.d.ts +17 -0
- package/lib/programmers/NestiaMigrateApiStartProgrammer.js +19 -8
- package/lib/programmers/NestiaMigrateApiStartProgrammer.js.map +1 -1
- package/lib/programmers/NestiaMigrateApiStartProgrammer.mjs +1 -6
- package/lib/programmers/NestiaMigrateDtoProgrammer.d.ts +30 -0
- package/lib/programmers/NestiaMigrateDtoProgrammer.js +17 -0
- package/lib/programmers/NestiaMigrateDtoProgrammer.js.map +1 -1
- package/lib/programmers/NestiaMigrateE2eFileProgrammer.d.ts +39 -0
- package/lib/programmers/NestiaMigrateE2eFileProgrammer.js +46 -5
- package/lib/programmers/NestiaMigrateE2eFileProgrammer.js.map +1 -1
- package/lib/programmers/NestiaMigrateE2eFileProgrammer.mjs +6 -2
- package/lib/programmers/NestiaMigrateE2eProgrammer.d.ts +16 -0
- package/lib/programmers/NestiaMigrateE2eProgrammer.js +16 -0
- package/lib/programmers/NestiaMigrateE2eProgrammer.js.map +1 -1
- package/lib/programmers/NestiaMigrateImportProgrammer.d.ts +75 -0
- package/lib/programmers/NestiaMigrateImportProgrammer.js +58 -3
- package/lib/programmers/NestiaMigrateImportProgrammer.js.map +1 -1
- package/lib/programmers/NestiaMigrateImportProgrammer.mjs +58 -3
- package/lib/programmers/NestiaMigrateNestControllerProgrammer.d.ts +28 -0
- package/lib/programmers/NestiaMigrateNestControllerProgrammer.js +16 -0
- package/lib/programmers/NestiaMigrateNestControllerProgrammer.js.map +1 -1
- package/lib/programmers/NestiaMigrateNestMethodProgrammer.d.ts +30 -0
- package/lib/programmers/NestiaMigrateNestMethodProgrammer.js +85 -13
- package/lib/programmers/NestiaMigrateNestMethodProgrammer.js.map +1 -1
- package/lib/programmers/NestiaMigrateNestMethodProgrammer.mjs +46 -9
- package/lib/programmers/NestiaMigrateNestModuleProgrammer.d.ts +16 -0
- package/lib/programmers/NestiaMigrateNestModuleProgrammer.js +16 -0
- package/lib/programmers/NestiaMigrateNestModuleProgrammer.js.map +1 -1
- package/lib/programmers/NestiaMigrateNestProgrammer.d.ts +17 -0
- package/lib/programmers/NestiaMigrateNestProgrammer.js +17 -0
- package/lib/programmers/NestiaMigrateNestProgrammer.js.map +1 -1
- package/lib/programmers/NestiaMigrateSchemaProgrammer.d.ts +16 -0
- package/lib/programmers/NestiaMigrateSchemaProgrammer.js +45 -9
- package/lib/programmers/NestiaMigrateSchemaProgrammer.js.map +1 -1
- package/lib/programmers/NestiaMigrateSchemaProgrammer.mjs +19 -8
- package/lib/structures/INestiaMigrateConfig.d.ts +21 -0
- package/lib/structures/INestiaMigrateContext.d.ts +15 -0
- package/lib/structures/INestiaMigrateController.d.ts +13 -0
- package/lib/structures/INestiaMigrateFile.d.ts +11 -0
- package/lib/utils/FilePrinter.d.ts +33 -0
- package/lib/utils/FilePrinter.js +33 -0
- package/lib/utils/FilePrinter.js.map +1 -1
- package/lib/utils/MapUtil.d.ts +17 -0
- package/lib/utils/MapUtil.js +19 -3
- package/lib/utils/MapUtil.js.map +1 -1
- package/lib/utils/MapUtil.mjs +1 -2
- package/lib/utils/PathTemplate.d.ts +41 -0
- package/lib/utils/PathTemplate.js +56 -0
- package/lib/utils/PathTemplate.js.map +1 -0
- package/lib/utils/PathTemplate.mjs +34 -0
- package/lib/utils/PathTemplate.mjs.map +1 -0
- package/lib/utils/RequestBody.d.ts +22 -0
- package/lib/utils/RequestBody.js +29 -0
- package/lib/utils/RequestBody.js.map +1 -0
- package/lib/utils/RequestBody.mjs +9 -0
- package/lib/utils/RequestBody.mjs.map +1 -0
- package/lib/utils/StringUtil.d.ts +55 -0
- package/lib/utils/StringUtil.js +93 -8
- package/lib/utils/StringUtil.js.map +1 -1
- package/lib/utils/StringUtil.mjs +30 -8
- package/lib/utils/SuccessStatus.d.ts +34 -0
- package/lib/utils/SuccessStatus.js +48 -0
- package/lib/utils/SuccessStatus.js.map +1 -0
- package/lib/utils/SuccessStatus.mjs +14 -0
- package/lib/utils/SuccessStatus.mjs.map +1 -0
- package/package.json +5 -4
- package/src/NestiaMigrateApplication.ts +151 -13
- package/src/analyzers/NestiaMigrateControllerAnalyzer.ts +94 -2
- package/src/archivers/NestiaMigrateFileArchiver.ts +34 -0
- package/src/bundles/NEST_TEMPLATE.ts +1 -1
- package/src/bundles/SDK_TEMPLATE.ts +1 -1
- package/src/executable/NestiaMigrateCommander.ts +47 -1
- package/src/executable/NestiaMigrateInquirer.ts +41 -26
- package/src/factories/ExpressionFactory.ts +14 -0
- package/src/factories/IdentifierFactory.ts +20 -0
- package/src/factories/LiteralFactory.ts +18 -2
- package/src/factories/StatementFactory.ts +26 -1
- package/src/factories/SupportedStringFormats.ts +29 -0
- package/src/factories/TypeFactory.ts +21 -0
- package/src/factories/TypeLiteralFactory.ts +18 -0
- package/src/internal/ts.ts +153 -0
- package/src/programmers/NestiaMigrateApiFileProgrammer.ts +35 -0
- package/src/programmers/NestiaMigrateApiFunctionProgrammer.ts +53 -4
- package/src/programmers/NestiaMigrateApiNamespaceProgrammer.ts +83 -20
- package/src/programmers/NestiaMigrateApiProgrammer.ts +18 -0
- package/src/programmers/NestiaMigrateApiSimulationProgrammer.ts +66 -73
- package/src/programmers/NestiaMigrateApiStartProgrammer.ts +19 -10
- package/src/programmers/NestiaMigrateDtoProgrammer.ts +33 -0
- package/src/programmers/NestiaMigrateE2eFileProgrammer.ts +83 -8
- package/src/programmers/NestiaMigrateE2eProgrammer.ts +16 -0
- package/src/programmers/NestiaMigrateImportProgrammer.ts +86 -5
- package/src/programmers/NestiaMigrateNestControllerProgrammer.ts +30 -0
- package/src/programmers/NestiaMigrateNestMethodProgrammer.ts +122 -29
- package/src/programmers/NestiaMigrateNestModuleProgrammer.ts +16 -0
- package/src/programmers/NestiaMigrateNestProgrammer.ts +17 -0
- package/src/programmers/NestiaMigrateSchemaProgrammer.ts +53 -18
- package/src/structures/INestiaMigrateConfig.ts +26 -0
- package/src/structures/INestiaMigrateContext.ts +17 -0
- package/src/structures/INestiaMigrateController.ts +16 -0
- package/src/structures/INestiaMigrateFile.ts +13 -0
- package/src/utils/FilePrinter.ts +33 -0
- package/src/utils/MapUtil.ts +18 -2
- package/src/utils/PathTemplate.ts +61 -0
- package/src/utils/RequestBody.ts +27 -0
- package/src/utils/StringUtil.ts +101 -9
- package/src/utils/SuccessStatus.ts +49 -0
- package/lib/factories/FormatCheatSheet.d.ts +0 -25
- package/lib/factories/FormatCheatSheet.js +0 -34
- package/lib/factories/FormatCheatSheet.js.map +0 -1
- package/lib/factories/FormatCheatSheet.mjs +0 -31
- package/lib/factories/FormatCheatSheet.mjs.map +0 -1
- package/src/factories/FormatCheatSheet.ts +0 -71
|
@@ -2,9 +2,47 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NestiaMigrateControllerAnalyzer = void 0;
|
|
4
4
|
const MapUtil_1 = require("../utils/MapUtil");
|
|
5
|
+
const PathTemplate_1 = require("../utils/PathTemplate");
|
|
5
6
|
const StringUtil_1 = require("../utils/StringUtil");
|
|
7
|
+
/**
|
|
8
|
+
* Groups the routes of an application into NestJS controllers.
|
|
9
|
+
*
|
|
10
|
+
* Generated controller locations use portable slash spelling and directoryName
|
|
11
|
+
* applies Windows filename constraints on every host: invalid/control
|
|
12
|
+
* characters and trailing dots/spaces become underscores, and device names,
|
|
13
|
+
* including extension and superscript-digit forms, receive a prefix. Router
|
|
14
|
+
* paths retain their original URL meaning. Directory normalization is
|
|
15
|
+
* intentionally many-to-one; distinct controllers retain their own filenames.
|
|
16
|
+
* Host filesystem case policy is not inferred.
|
|
17
|
+
*
|
|
18
|
+
* @evidence contracts/common.md#principled-implementation Routes are grouped by the controller name from the operation, or by the capitalized accessor prefix, and each controller path is the longest path prefix shared by all of its routes, so one controller covers one resource path.
|
|
19
|
+
* @evidence contracts/common.md#clear-and-simple-design One namespace with the grouping and the path formatting, and small private helpers for the shared-prefix computation.
|
|
20
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts Names and paths derive from the document, with no route or controller name special-cased.
|
|
21
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
|
|
22
|
+
*/
|
|
6
23
|
var NestiaMigrateControllerAnalyzer;
|
|
7
24
|
(function (NestiaMigrateControllerAnalyzer) {
|
|
25
|
+
/**
|
|
26
|
+
* Returns the controllers of the routes, each with its name, its path, its
|
|
27
|
+
* source location, and its routes.
|
|
28
|
+
*
|
|
29
|
+
* The name is the `x-samchon-controller` extension of the operation when
|
|
30
|
+
* present, and otherwise the capitalized accessor prefix followed by
|
|
31
|
+
* `Controller`.
|
|
32
|
+
*
|
|
33
|
+
* Generated controller locations use portable slash spelling and
|
|
34
|
+
* directoryName applies Windows filename constraints on every host:
|
|
35
|
+
* invalid/control characters and trailing dots/spaces become underscores, and
|
|
36
|
+
* device names, including extension and superscript-digit forms, receive a
|
|
37
|
+
* prefix. Router paths retain their original URL meaning. Directory
|
|
38
|
+
* normalization is intentionally many-to-one; distinct controllers retain
|
|
39
|
+
* their own filenames. Host filesystem case policy is not inferred.
|
|
40
|
+
*
|
|
41
|
+
* @evidence contracts/common.md#principled-implementation Grouping uses a map keyed by controller name, and the common path prefix and the directory prefix are found by removing every segment after the first difference across the routes, so a controller path is a prefix of every route it owns.
|
|
42
|
+
* @evidence contracts/common.md#clear-and-simple-design One function with two phases: grouping, then prefix computation.
|
|
43
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The extension name is part of the generated document contract; no other name is assumed.
|
|
44
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states how the name and the path are chosen.
|
|
45
|
+
*/
|
|
8
46
|
NestiaMigrateControllerAnalyzer.analyze = (routes) => {
|
|
9
47
|
var _a;
|
|
10
48
|
const collection = new Map();
|
|
@@ -22,8 +60,10 @@ var NestiaMigrateControllerAnalyzer;
|
|
|
22
60
|
}
|
|
23
61
|
const controllers = [...collection.values()];
|
|
24
62
|
for (const col of controllers) {
|
|
25
|
-
const splitPath = (r) => r.
|
|
26
|
-
const splitLocation = (r) => splitPath(r)
|
|
63
|
+
const splitPath = (r) => NestiaMigrateControllerAnalyzer.routePath(r).split("/");
|
|
64
|
+
const splitLocation = (r) => splitPath(r)
|
|
65
|
+
.filter((s) => s.length !== 0 && s[0] !== ":")
|
|
66
|
+
.map(directoryName);
|
|
27
67
|
const minPath = splitPath(col.routes[0]);
|
|
28
68
|
const minLocation = splitLocation(col.routes[0]);
|
|
29
69
|
for (const r of col.routes.slice(1)) {
|
|
@@ -35,7 +75,53 @@ var NestiaMigrateControllerAnalyzer;
|
|
|
35
75
|
}
|
|
36
76
|
return controllers;
|
|
37
77
|
};
|
|
78
|
+
/**
|
|
79
|
+
* The route's path as NestJS reads it: each path parameter under the key its
|
|
80
|
+
* handler reads with `@TypedParam()`. The document's name, such as `item-id`,
|
|
81
|
+
* is no path-to-regexp parameter name; it would read as `item` followed by
|
|
82
|
+
* the literal `-id`, and the handler's lookup would miss. Each parameter is
|
|
83
|
+
* found where the document's template writes it, beside literal text in its
|
|
84
|
+
* segment too (`/files/{id}.json`).
|
|
85
|
+
*
|
|
86
|
+
* A literal character the router reserves is escaped, so an AIP custom
|
|
87
|
+
* method's `/items:batchGet` stays a literal rather than a parameter
|
|
88
|
+
* `batchGet`, and `(` or `*` no syntax error.
|
|
89
|
+
*
|
|
90
|
+
* This operation emits router protocol spelling and does not select native
|
|
91
|
+
* filenames or filesystem identities.
|
|
92
|
+
*
|
|
93
|
+
* @evidence contracts/common.md#principled-implementation The path template is split into literal and parameter segments, and every character that path-to-regexp treats specially in a literal is escaped with a backslash, so a literal never changes the route's meaning.
|
|
94
|
+
* @evidence contracts/common.md#clear-and-simple-design One expression over the shared path segmenter.
|
|
95
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The reserved set is the router's syntax and is applied to every literal.
|
|
96
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the escaping and the parameter form.
|
|
97
|
+
*/
|
|
98
|
+
NestiaMigrateControllerAnalyzer.routePath = (route) => PathTemplate_1.PathTemplate.segments(route)
|
|
99
|
+
.map((segment) => segment.type === "literal"
|
|
100
|
+
? segment.value.replace(ROUTER_RESERVED, "\\$&")
|
|
101
|
+
: `:${segment.parameter.key}`)
|
|
102
|
+
.join("");
|
|
38
103
|
})(NestiaMigrateControllerAnalyzer || (exports.NestiaMigrateControllerAnalyzer = NestiaMigrateControllerAnalyzer = {}));
|
|
104
|
+
/**
|
|
105
|
+
* The characters path-to-regexp 8, Express 5's router, gives a meaning in a
|
|
106
|
+
* route: parameters, wildcards, optional groups, and its own escape.
|
|
107
|
+
*/
|
|
108
|
+
const ROUTER_RESERVED = /[\\:*?+!(){}[\]]/g;
|
|
109
|
+
/**
|
|
110
|
+
* Maps a route segment to a portable directory component. Router escapes are
|
|
111
|
+
* removed, Windows-invalid characters and trailing dots/spaces become
|
|
112
|
+
* underscores, and reserved device names receive an underscore prefix. Distinct
|
|
113
|
+
* route segments may share a directory; controller files retain their
|
|
114
|
+
* independently assigned controller names.
|
|
115
|
+
*/
|
|
116
|
+
const directoryName = (segment) => {
|
|
117
|
+
const name = segment
|
|
118
|
+
.replace(/\\(.)/g, "$1")
|
|
119
|
+
.replace(/[<>:"|?*\\\u0000-\u001f]/g, "_")
|
|
120
|
+
.replace(/[. ]+$/, (suffix) => "_".repeat(suffix.length));
|
|
121
|
+
return /^(?:CON|PRN|AUX|NUL|COM[1-9¹²³]|LPT[1-9¹²³])(?:\.|$)/i.test(name)
|
|
122
|
+
? `_${name}`
|
|
123
|
+
: name || "_";
|
|
124
|
+
};
|
|
39
125
|
const getSplitIndex = (x, y) => {
|
|
40
126
|
const n = Math.min(x.length, y.length);
|
|
41
127
|
for (let i = 0; i < n; ++i)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NestiaMigrateControllerAnalyzer.js","sourceRoot":"","sources":["../../src/analyzers/NestiaMigrateControllerAnalyzer.ts"],"names":[],"mappings":";;;AAGA,8CAA2C;AAC3C,oDAAiD;AAEjD,IAAiB,+BAA+B,
|
|
1
|
+
{"version":3,"file":"NestiaMigrateControllerAnalyzer.js","sourceRoot":"","sources":["../../src/analyzers/NestiaMigrateControllerAnalyzer.ts"],"names":[],"mappings":";;;AAGA,8CAA2C;AAC3C,wDAAqD;AACrD,oDAAiD;AAEjD;;;;;;;;;;;;;;;GAeG;AACH,IAAiB,+BAA+B,CA0F/C;AA1FD,WAAiB,+BAA+B;IAC9C;;;;;;;;;;;;;;;;;;;;OAoBG;IACU,uCAAO,GAAG,CACrB,MAA2B,EACC,EAAE;;QAC9B,MAAM,UAAU,GAA0C,IAAI,GAAG,EAAE,CAAC;QACpE,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;YACvB,MAAM,IAAI,SACR,CAAC,CAAC,SAAS,EAAE,CAAC,sBAAsB,CAAC,mCACrC,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,IAAI,CAAC;gBACrB,CAAC,CAAC,OAAO;gBACT,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,uBAAU,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBAC9D,YAAY,CAAC;YACjB,iBAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;gBACpC,IAAI;gBACJ,IAAI,EAAE,OAAO;gBACb,QAAQ,EAAE,OAAO;gBACjB,MAAM,EAAE,EAAE;aACX,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACr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E,OAAO,CAAC,CAAC;IAChE,OAAO,CAAC,CAAC;AACX,CAAC,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { StringUtil } from "../utils/StringUtil.mjs";
|
|
2
|
+
import { PathTemplate } from "../utils/PathTemplate.mjs";
|
|
2
3
|
import { MapUtil } from "../utils/MapUtil.mjs";
|
|
3
4
|
//#region src/analyzers/NestiaMigrateControllerAnalyzer.ts
|
|
4
5
|
let NestiaMigrateControllerAnalyzer;
|
|
@@ -16,8 +17,8 @@ let NestiaMigrateControllerAnalyzer;
|
|
|
16
17
|
}
|
|
17
18
|
const controllers = [...collection.values()];
|
|
18
19
|
for (const col of controllers) {
|
|
19
|
-
const splitPath = (r) => r.
|
|
20
|
-
const splitLocation = (r) => splitPath(r).filter((s) => s.length !== 0 && s[0] !== ":");
|
|
20
|
+
const splitPath = (r) => routePath(r).split("/");
|
|
21
|
+
const splitLocation = (r) => splitPath(r).filter((s) => s.length !== 0 && s[0] !== ":").map(directoryName);
|
|
21
22
|
const minPath = splitPath(col.routes[0]);
|
|
22
23
|
const minLocation = splitLocation(col.routes[0]);
|
|
23
24
|
for (const r of col.routes.slice(1)) {
|
|
@@ -33,7 +34,24 @@ let NestiaMigrateControllerAnalyzer;
|
|
|
33
34
|
}
|
|
34
35
|
return controllers;
|
|
35
36
|
};
|
|
37
|
+
const routePath = _NestiaMigrateControllerAnalyzer.routePath = (route) => PathTemplate.segments(route).map((segment) => segment.type === "literal" ? segment.value.replace(ROUTER_RESERVED, "\\$&") : `:${segment.parameter.key}`).join("");
|
|
36
38
|
})(NestiaMigrateControllerAnalyzer || (NestiaMigrateControllerAnalyzer = {}));
|
|
39
|
+
/**
|
|
40
|
+
* The characters path-to-regexp 8, Express 5's router, gives a meaning in a
|
|
41
|
+
* route: parameters, wildcards, optional groups, and its own escape.
|
|
42
|
+
*/
|
|
43
|
+
const ROUTER_RESERVED = /[\\:*?+!(){}[\]]/g;
|
|
44
|
+
/**
|
|
45
|
+
* Maps a route segment to a portable directory component. Router escapes are
|
|
46
|
+
* removed, Windows-invalid characters and trailing dots/spaces become
|
|
47
|
+
* underscores, and reserved device names receive an underscore prefix. Distinct
|
|
48
|
+
* route segments may share a directory; controller files retain their
|
|
49
|
+
* independently assigned controller names.
|
|
50
|
+
*/
|
|
51
|
+
const directoryName = (segment) => {
|
|
52
|
+
const name = segment.replace(/\\(.)/g, "$1").replace(/[<>:"|?*\\\u0000-\u001f]/g, "_").replace(/[. ]+$/, (suffix) => "_".repeat(suffix.length));
|
|
53
|
+
return /^(?:CON|PRN|AUX|NUL|COM[1-9¹²³]|LPT[1-9¹²³])(?:\.|$)/i.test(name) ? `_${name}` : name || "_";
|
|
54
|
+
};
|
|
37
55
|
const getSplitIndex = (x, y) => {
|
|
38
56
|
const n = Math.min(x.length, y.length);
|
|
39
57
|
for (let i = 0; i < n; ++i) if (x[i] !== y[i]) return i;
|
|
@@ -1,4 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Writes a file map into a directory through injected file-system functions.
|
|
3
|
+
*
|
|
4
|
+
* Each path is the root, a `/` and the key's `/`-separated segments, a spelling
|
|
5
|
+
* the filesystem calls of every supported platform accept, and creation and
|
|
6
|
+
* writing are delegated to injected functions, so the caller's filesystem
|
|
7
|
+
* decides existence, case policy and permissions. Directories are created one
|
|
8
|
+
* segment at a time because the injected creator is not recursive. Remaining
|
|
9
|
+
* assumptions: keys are trusted generated names, since a `..` or absolute
|
|
10
|
+
* segment would leave the root, and on a case-insensitive volume two keys that
|
|
11
|
+
* differ only in case write to the same file.
|
|
12
|
+
*
|
|
13
|
+
* @evidence contracts/common.md#principled-implementation Directories are created one path prefix at a time, each once, through a memoized creator, and the files are then written in the order of the map; injecting the functions keeps the archiver independent of Node and of the browser.
|
|
14
|
+
* @evidence contracts/common.md#clear-and-simple-design One function with one memoized directory creator.
|
|
15
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It writes exactly the given files, and injection is the supported boundary for the platform.
|
|
16
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
|
|
17
|
+
*/
|
|
1
18
|
export declare namespace NestiaMigrateFileArchiver {
|
|
19
|
+
/**
|
|
20
|
+
* Writes every file of `files` below `root`, creating the directories on the
|
|
21
|
+
* way.
|
|
22
|
+
*
|
|
23
|
+
* A directory that cannot be created is not reported, because the creator is
|
|
24
|
+
* also called for a directory that already exists; the failure surfaces when
|
|
25
|
+
* the file is written.
|
|
26
|
+
*
|
|
27
|
+
* The memo of created directories is keyed by the spelled path, so on a
|
|
28
|
+
* case-insensitive volume a second spelling attempts the creation again and
|
|
29
|
+
* receives the already-exists error, which is the swallowed outcome.
|
|
30
|
+
*
|
|
31
|
+
* @evidence contracts/common.md#principled-implementation The root and each prefix of each file's directory are created once, in order, before the file is written, and a creation failure is deferred to the write that needs the directory, since the injected creator is not recursive and reports an existing directory as an error.
|
|
32
|
+
* @evidence contracts/common.md#clear-and-simple-design One function; the memoized creator makes a repeated directory a no-op.
|
|
33
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The dropped creation error is a stated consequence of the non-recursive creator, and the write still fails loudly when the directory is missing.
|
|
34
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the order of creation and the deferred error.
|
|
35
|
+
*/
|
|
2
36
|
const archive: (props: {
|
|
3
37
|
mkdir: (path: string) => Promise<void>;
|
|
4
38
|
writeFile: (path: string, content: string) => Promise<void>;
|
|
@@ -11,8 +11,42 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.NestiaMigrateFileArchiver = void 0;
|
|
13
13
|
const tstl_1 = require("tstl");
|
|
14
|
+
/**
|
|
15
|
+
* Writes a file map into a directory through injected file-system functions.
|
|
16
|
+
*
|
|
17
|
+
* Each path is the root, a `/` and the key's `/`-separated segments, a spelling
|
|
18
|
+
* the filesystem calls of every supported platform accept, and creation and
|
|
19
|
+
* writing are delegated to injected functions, so the caller's filesystem
|
|
20
|
+
* decides existence, case policy and permissions. Directories are created one
|
|
21
|
+
* segment at a time because the injected creator is not recursive. Remaining
|
|
22
|
+
* assumptions: keys are trusted generated names, since a `..` or absolute
|
|
23
|
+
* segment would leave the root, and on a case-insensitive volume two keys that
|
|
24
|
+
* differ only in case write to the same file.
|
|
25
|
+
*
|
|
26
|
+
* @evidence contracts/common.md#principled-implementation Directories are created one path prefix at a time, each once, through a memoized creator, and the files are then written in the order of the map; injecting the functions keeps the archiver independent of Node and of the browser.
|
|
27
|
+
* @evidence contracts/common.md#clear-and-simple-design One function with one memoized directory creator.
|
|
28
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It writes exactly the given files, and injection is the supported boundary for the platform.
|
|
29
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
|
|
30
|
+
*/
|
|
14
31
|
var NestiaMigrateFileArchiver;
|
|
15
32
|
(function (NestiaMigrateFileArchiver) {
|
|
33
|
+
/**
|
|
34
|
+
* Writes every file of `files` below `root`, creating the directories on the
|
|
35
|
+
* way.
|
|
36
|
+
*
|
|
37
|
+
* A directory that cannot be created is not reported, because the creator is
|
|
38
|
+
* also called for a directory that already exists; the failure surfaces when
|
|
39
|
+
* the file is written.
|
|
40
|
+
*
|
|
41
|
+
* The memo of created directories is keyed by the spelled path, so on a
|
|
42
|
+
* case-insensitive volume a second spelling attempts the creation again and
|
|
43
|
+
* receives the already-exists error, which is the swallowed outcome.
|
|
44
|
+
*
|
|
45
|
+
* @evidence contracts/common.md#principled-implementation The root and each prefix of each file's directory are created once, in order, before the file is written, and a creation failure is deferred to the write that needs the directory, since the injected creator is not recursive and reports an existing directory as an error.
|
|
46
|
+
* @evidence contracts/common.md#clear-and-simple-design One function; the memoized creator makes a repeated directory a no-op.
|
|
47
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The dropped creation error is a stated consequence of the non-recursive creator, and the write still fails loudly when the directory is missing.
|
|
48
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the order of creation and the deferred error.
|
|
49
|
+
*/
|
|
16
50
|
NestiaMigrateFileArchiver.archive = (props) => __awaiter(this, void 0, void 0, function* () {
|
|
17
51
|
const mkdir = new tstl_1.VariadicSingleton((location) => __awaiter(this, void 0, void 0, function* () {
|
|
18
52
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NestiaMigrateFileArchiver.js","sourceRoot":"","sources":["../../src/archivers/NestiaMigrateFileArchiver.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+BAAyC;AAEzC,IAAiB,yBAAyB,
|
|
1
|
+
{"version":3,"file":"NestiaMigrateFileArchiver.js","sourceRoot":"","sources":["../../src/archivers/NestiaMigrateFileArchiver.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+BAAyC;AAEzC;;;;;;;;;;;;;;;;GAgBG;AACH,IAAiB,yBAAyB,CA8CzC;AA9CD,WAAiB,yBAAyB;IACxC;;;;;;;;;;;;;;;;OAgBG;IACU,iCAAO,GAAG,CAAO,KAK7B,EAAiB,EAAE;QAClB,MAAM,KAAK,GAAG,IAAI,wBAAiB,CACjC,CAAO,QAAgB,EAAiB,EAAE;YACxC,IAAI,CAAC;gBACH,MAAM,KAAK,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,IAAI,IAAI,QAAQ,EAAE,CAAC,CAAC;YACjD,CAAC;uBAAO,CAAC,CAAA,CAAC;QACZ,CAAC,CAAA,CACF,CAAC;QACF,MAAM,OAAO,GAAG,CAAO,QAAgB,EAAiB,EAAE;YACxD,MAAM,QAAQ,GAAa,QAAQ;iBAChC,KAAK,CAAC,GAAG,CAAC;iBACV,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;YAC9D,KAAK,MAAM,CAAC,IAAI,QAAQ;gBAAE,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC/C,CAAC,CAAA,CAAC;QACF,oEAAoE;QACpE,wEAAwE;QACxE,sDAAsD;QACtD,MAAM,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACpB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;YACvD,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;YACrD,MAAM,KAAK,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC,IAAI,IAAI,GAAG,EAAE,EAAE,KAAK,CAAC,CAAC;QACvD,CAAC;IACH,CAAC,CAAA,CAAC;AACJ,CAAC,EA9CgB,yBAAyB,aAAzB,yBAAyB,GAAzB,yBAAyB,QA8CzC"}
|
|
@@ -52,7 +52,7 @@ exports.NEST_TEMPLATE = {
|
|
|
52
52
|
"packages/backend/test/webpack.ts": "import { DynamicExecutor } from \"@nestia/e2e\";\nimport cp from \"node:child_process\";\nimport { sleep_for } from \"tstl\";\n\nimport { MyConfiguration } from \"../src/MyConfiguration\";\nimport { MyGlobal } from \"../src/MyGlobal\";\nimport { TestAutomation } from \"./helpers/TestAutomation\";\nimport { TestAutomationStdio } from \"./helpers/TestAutomationStdio\";\n\nconst wait = async (): Promise<void> => {\n while (true)\n try {\n await fetch(`http://localhost:${MyConfiguration.API_PORT()}/dsafdsafsd`);\n return;\n } catch (exp) {\n await sleep_for(100);\n }\n};\n\nconst main = async (): Promise<void> => {\n MyGlobal.testing = true;\n\n const report: DynamicExecutor.IReport = await TestAutomation.execute({\n open: async () => {\n const backend: cp.ChildProcess = cp.fork(\n `${MyConfiguration.ROOT}/dist/server.js`,\n {\n cwd: `${MyConfiguration.ROOT}/dist`,\n },\n );\n await wait();\n return backend;\n },\n close: async (backend) => {\n backend.kill();\n },\n options: await TestAutomationStdio.getOptions(),\n onComplete: TestAutomationStdio.onComplete,\n });\n TestAutomationStdio.report(report);\n};\nmain().catch((exp: unknown) => {\n console.log(exp);\n process.exit(-1);\n});\n",
|
|
53
53
|
"packages/backend/tsconfig.json": "{\n \"extends\": \"../../config/tsconfig.json\",\n \"compilerOptions\": {\n \"outDir\": \"lib\",\n \"rootDir\": \"src\",\n \"experimentalDecorators\": true,\n \"emitDecoratorMetadata\": true\n },\n \"include\": [\"src\"]\n}\n",
|
|
54
54
|
"packages/backend/webpack.config.js": "const path = require(\"path\");\n\nconst CopyWebpackPlugin = require(\"copy-webpack-plugin\");\nconst WriteFilePlugin = require(\"write-file-webpack-plugin\");\nconst { IgnorePlugin } = require(\"webpack\");\n\nconst lazyImports = [\n \"@modelcontextprotocol/sdk\",\n \"@fastify/static\",\n \"@fastify/view\",\n \"@nestjs/microservices\",\n \"@nestjs/websockets\",\n \"class-transformer\",\n \"class-validator\",\n];\n\n// @reference https://tech-blog.s-yoshiki.com/entry/297\nmodule.exports = {\n // CUSTOMIZE HERE\n entry: {\n server: \"./lib/executable/server.js\",\n },\n output: {\n path: path.join(__dirname, \"dist\"),\n filename: \"[name].js\",\n },\n optimization: {\n minimize: true,\n },\n\n // JUST KEEP THEM\n mode: \"production\",\n target: \"node\",\n plugins: [\n new CopyWebpackPlugin({\n patterns: [\n {\n from: \".env\",\n to: \"[name][ext]\",\n },\n ],\n }),\n new WriteFilePlugin(),\n new IgnorePlugin({\n checkResource: (resource) => {\n if (lazyImports.some((modulo) => resource.startsWith(modulo))) {\n try {\n require.resolve(resource);\n } catch (err) {\n return true;\n }\n }\n return false;\n },\n }),\n ],\n};\n",
|
|
55
|
-
"pnpm-workspace.yaml": "packages:\n - \"config\"\n - \"packages/*\"\ncatalogs:\n samchon:\n \"@nestia/benchmark\": ^14.0.
|
|
55
|
+
"pnpm-workspace.yaml": "packages:\n - \"config\"\n - \"packages/*\"\ncatalogs:\n samchon:\n \"@nestia/benchmark\": ^14.0.2\n \"@nestia/core\": ^14.0.2\n \"@nestia/e2e\": ^14.0.2\n \"@nestia/fetcher\": ^14.0.2\n \"@nestia/sdk\": ^14.0.2\n nestia: ^14.0.2\n tgrid: ^1.2.1\n tstl: ^3.0.0\n typia: 15.0.0\n rolldown:\n rolldown: ^1.1.5\n utils:\n rimraf: ^6.1.3\n uuid: ^13.0.0\n typescript:\n \"@ttsc/lint\": ^0.18.2\n \"@ttsc/paths\": ^0.18.2\n \"@ttsc/unplugin\": ^0.28.1\n ttsc: ^0.28.1\n typescript: ^7.0.2\n",
|
|
56
56
|
"typos.toml": "[default]\nlocale = 'en-us'\nextend-ignore-re = [\n \"(?Rm)^.*(<!--|#|//)\\\\s*spellchecker:disable-line(-->|\\n)?$\",\n \"(?s)(<!--|#|//)\\\\s*spellchecker:off\\\\s*(-->|\\n).*?(<!--|#|//)\\\\s*spellchecker:on\",\n]\n\n[default.extend-words]\nJeongho = \"Jeongho\"\nNam = \"Nam\"\ntypia = \"typia\"\n\n[files]\nextend-exclude = [\"*.json\"]"
|
|
57
57
|
};
|
|
58
58
|
//# sourceMappingURL=NEST_TEMPLATE.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NEST_TEMPLATE.js","sourceRoot":"","sources":["../../src/bundles/NEST_TEMPLATE.ts"],"names":[],"mappings":";;;AAAa,QAAA,aAAa,GAA2B;IACnD,6BAA6B,EAAE,scAAsc;IACre,6BAA6B,EAAE,oQAAoQ;IACnS,YAAY,EAAE,8EAA8E;IAC5F,qBAAqB,EAAE,s5BAAs5B;IAC76B,uBAAuB,EAAE,iCAAiC;IAC1D,SAAS,EAAE,ukCAAukC;IACllC,WAAW,EAAE,8+PAA8+P;IAC3/P,uBAAuB,EAAE,23OAA23O;IACp5O,qBAAqB,EAAE,+eAA+e;IACtgB,4BAA4B,EAAE,64BAA64B;IAC36B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E,6lBAA6lB;IACjoB,2CAA2C,EAAE,miBAAmiB;IAChlB,4CAA4C,EAAE,27BAA27B;IACz+B,yCAAyC,EAAE,4PAA4P;IACvS,uCAAuC,EAAE,sTAAsT;IAC/V,0CAA0C,EAAE,8vHAA8vH;IAC1yH,4CAA4C,EAAE,kbAAkb;IAChe,iDAAiD,EAAE,i4GAAi4G;IACp7G,iDAAiD,EAAE,qsDAAqsD;IACxvD,sDAAsD,EAAE,mlEAAmlE;IAC3oE,gCAAgC,EAAE,60BAA60B;IAC/2B,qCAAqC,EAAE,iKAAiK;IACxM,kCAAkC,EAAE,2xCAA2xC;IAC/zC,gCAAgC,EAAE,mPAAmP;IACrR,oCAAoC,EAAE,8xCAA8xC;IACp0C,qBAAqB,EAAE,giBAAgiB;IACvjB,YAAY,EAAE,yVAAyV;CACxW,CAAA"}
|
|
@@ -50,7 +50,7 @@ const NEST_TEMPLATE = {
|
|
|
50
50
|
"packages/backend/test/webpack.ts": "import { DynamicExecutor } from \"@nestia/e2e\";\nimport cp from \"node:child_process\";\nimport { sleep_for } from \"tstl\";\n\nimport { MyConfiguration } from \"../src/MyConfiguration\";\nimport { MyGlobal } from \"../src/MyGlobal\";\nimport { TestAutomation } from \"./helpers/TestAutomation\";\nimport { TestAutomationStdio } from \"./helpers/TestAutomationStdio\";\n\nconst wait = async (): Promise<void> => {\n while (true)\n try {\n await fetch(`http://localhost:${MyConfiguration.API_PORT()}/dsafdsafsd`);\n return;\n } catch (exp) {\n await sleep_for(100);\n }\n};\n\nconst main = async (): Promise<void> => {\n MyGlobal.testing = true;\n\n const report: DynamicExecutor.IReport = await TestAutomation.execute({\n open: async () => {\n const backend: cp.ChildProcess = cp.fork(\n `${MyConfiguration.ROOT}/dist/server.js`,\n {\n cwd: `${MyConfiguration.ROOT}/dist`,\n },\n );\n await wait();\n return backend;\n },\n close: async (backend) => {\n backend.kill();\n },\n options: await TestAutomationStdio.getOptions(),\n onComplete: TestAutomationStdio.onComplete,\n });\n TestAutomationStdio.report(report);\n};\nmain().catch((exp: unknown) => {\n console.log(exp);\n process.exit(-1);\n});\n",
|
|
51
51
|
"packages/backend/tsconfig.json": "{\n \"extends\": \"../../config/tsconfig.json\",\n \"compilerOptions\": {\n \"outDir\": \"lib\",\n \"rootDir\": \"src\",\n \"experimentalDecorators\": true,\n \"emitDecoratorMetadata\": true\n },\n \"include\": [\"src\"]\n}\n",
|
|
52
52
|
"packages/backend/webpack.config.js": "const path = require(\"path\");\n\nconst CopyWebpackPlugin = require(\"copy-webpack-plugin\");\nconst WriteFilePlugin = require(\"write-file-webpack-plugin\");\nconst { IgnorePlugin } = require(\"webpack\");\n\nconst lazyImports = [\n \"@modelcontextprotocol/sdk\",\n \"@fastify/static\",\n \"@fastify/view\",\n \"@nestjs/microservices\",\n \"@nestjs/websockets\",\n \"class-transformer\",\n \"class-validator\",\n];\n\n// @reference https://tech-blog.s-yoshiki.com/entry/297\nmodule.exports = {\n // CUSTOMIZE HERE\n entry: {\n server: \"./lib/executable/server.js\",\n },\n output: {\n path: path.join(__dirname, \"dist\"),\n filename: \"[name].js\",\n },\n optimization: {\n minimize: true,\n },\n\n // JUST KEEP THEM\n mode: \"production\",\n target: \"node\",\n plugins: [\n new CopyWebpackPlugin({\n patterns: [\n {\n from: \".env\",\n to: \"[name][ext]\",\n },\n ],\n }),\n new WriteFilePlugin(),\n new IgnorePlugin({\n checkResource: (resource) => {\n if (lazyImports.some((modulo) => resource.startsWith(modulo))) {\n try {\n require.resolve(resource);\n } catch (err) {\n return true;\n }\n }\n return false;\n },\n }),\n ],\n};\n",
|
|
53
|
-
"pnpm-workspace.yaml": "packages:\n - \"config\"\n - \"packages/*\"\ncatalogs:\n samchon:\n \"@nestia/benchmark\": ^14.0.
|
|
53
|
+
"pnpm-workspace.yaml": "packages:\n - \"config\"\n - \"packages/*\"\ncatalogs:\n samchon:\n \"@nestia/benchmark\": ^14.0.2\n \"@nestia/core\": ^14.0.2\n \"@nestia/e2e\": ^14.0.2\n \"@nestia/fetcher\": ^14.0.2\n \"@nestia/sdk\": ^14.0.2\n nestia: ^14.0.2\n tgrid: ^1.2.1\n tstl: ^3.0.0\n typia: 15.0.0\n rolldown:\n rolldown: ^1.1.5\n utils:\n rimraf: ^6.1.3\n uuid: ^13.0.0\n typescript:\n \"@ttsc/lint\": ^0.18.2\n \"@ttsc/paths\": ^0.18.2\n \"@ttsc/unplugin\": ^0.28.1\n ttsc: ^0.28.1\n typescript: ^7.0.2\n",
|
|
54
54
|
"typos.toml": "[default]\nlocale = 'en-us'\nextend-ignore-re = [\n \"(?Rm)^.*(<!--|#|//)\\\\s*spellchecker:disable-line(-->|\\n)?$\",\n \"(?s)(<!--|#|//)\\\\s*spellchecker:off\\\\s*(-->|\\n).*?(<!--|#|//)\\\\s*spellchecker:on\",\n]\n\n[default.extend-words]\nJeongho = \"Jeongho\"\nNam = \"Nam\"\ntypia = \"typia\"\n\n[files]\nextend-exclude = [\"*.json\"]"
|
|
55
55
|
};
|
|
56
56
|
//#endregion
|
|
@@ -8,7 +8,7 @@ exports.SDK_TEMPLATE = {
|
|
|
8
8
|
"LICENSE": "MIT License\n\nCopyright (c) 2024 Jeongho Nam\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n",
|
|
9
9
|
"README.md": "# Software Development Kit\nThis is a SDK library generated by [`@nestia/migrate`](https://nestia.io/docs/migrate) or [`@nestia/editor`](https://nestia.io/docs/editor).\n\nWith this SDK library, you can easily and safely interact with backend server.\n\nJust import and call some API functions like gif image below:\n\n\n\n> Left is server code, and right is client code utilizing the SDK\n\n\n\n\n## How to Test\n```bash\npnpm install\npnpm run start # run only \"test/start.ts\" file\npnpm run test # everything under the \"test/features\" directory\npnpm run test:simulate # \"test/features\" with mockup simulation mode\n```\n\nIf you run `pnpm run start` command, only [test/start.ts](test/start.ts) file would be executed.\n\nOtherwise you run `pnpm run test` command instead, run everything in the [test/features](test/features) directory.\n\nFor reference, the [test/features](test/features) directory and E2E test functions (for each API endpoints) would be automatically composed only when you've configured the \"E2E test function generation mode\" of the `@nestia/migrate` (or `@nestia/editor`).\n\n```bash\npnpm dlx @nestia/migrate\n? Migration mode (Use arrow keys):\n NestJS\n > SDK\n? Swagger file location: assets/input/clickhouse.json\n? Output directory path: assets/output/clickhouse-sdk-manual\n? Mokup Simulator: true\n? E2E Test Functions: true\n```\n\n\n\n\n## Deploy\n```bash\npnpm install\npnpm run deploy\n```\n\nJust run `pnpm run deploy` command, then your SDK library would be published.\n\nBy the way, the initial package name of this template repository is `@ORGANIZATION/PROJECT-api`. I think it would better to change the word to your own organization and project name. If you're utilizing `VsCode`, you can do it through `Edit > Replace in Files` (*Ctrl + Shift + H*) feature.\n\n-----------\n\n> ## What [`Nestia`](https://nestia.io) is:\n> \n> \n> [](https://github.com/samchon/nestia/blob/master/LICENSE)\n> [](https://www.npmjs.com/package/@nestia/core)\n> [](https://www.npmjs.com/package/@nestia/core)\n> [](https://github.com/samchon/nestia/actions?query=workflow%3Abuild)\n> [](https://nestia.io/docs/)\n> \n> Nestia is a set of helper libraries for NestJS, supporting below features:\n> \n> - `@nestia/core`: Super-fast decorators\n> - `@nestia/sdk`:\n> - Swagger generator evolved than ever\n> - SDK library generator for clients\n> - Mockup Simulator for client applications\n> - Automatic E2E test functions generator\n> - `@nestia/migrate`: Migration from Swagger to NestJS\n> - `@nestia/editor`: Online TypeScript Swagger Editor\n> - `nestia`: Just CLI (command line interface) tool\n> \n>> **Note**\n>> \n>> - **Only one line** required, with pure TypeScript type\n>> - Enhance performance **30x** up\n>> - Runtime validator is **20,000x faster** than `class-validator`\n>> - JSON serialization is **200x faster** than `class-transformer`\n>> - Software Development Kit\n>> - SDK is a collection of `fetch` functions with type definitions like [tRPC](https://> trpc.io/)\n>> - Mockup simulator means embedded backend simulator in SDK\n>> - similar with [msw](https://mswjs.io/), but fully automated\n",
|
|
10
10
|
"hello.js": "function print(command, description) {\n return console.log(`\\x1b[1m${command}\\x1b[2m: ${description}\\x1b[0m`);\n}\n\nconsole.log(\"-----------------------------------------\");\nconsole.log(\"\\x1b[7mGenerated by \\x1b[2m@nestia/editor\\x1b[0m\");\nconsole.log(\"\");\nconsole.log(\" - \\x1b[36mhttps://nestia.io/docs/editor\\x1b[0m\");\nconsole.log(\" - \\x1b[36mhttps://github.com/samchon/nestia\\x1b[0m\");\nconsole.log(\"-----------------------------------------\");\n\nprint(\"pnpm run start\", \"Run only test/start.ts\");\nprint(\"pnpm run test\", \"Run every test/features/**/*.ts files\");\nprint(\"pnpm run test:simulate\", \"Test with mockup simulator\");\n",
|
|
11
|
-
"package.json": "{\n \"name\": \"@ORGANIZATION/PROJECT-api\",\n \"version\": \"0.1.0\",\n \"description\": \"SDK library generated by Nestia\",\n \"main\": \"src/index.ts\",\n \"exports\": {\n \".\": \"./src/index.ts\",\n \"./lib/*\": \"./src/*.ts\",\n \"./package.json\": \"./package.json\"\n },\n \"publishConfig\": {\n \"main\": \"lib/index.mjs\",\n \"module\": \"lib/index.mjs\",\n \"types\": \"lib/index.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./lib/index.d.ts\",\n \"import\": \"./lib/index.mjs\",\n \"default\": \"./lib/index.js\"\n },\n \"./lib/*\": {\n \"types\": \"./lib/*.d.ts\",\n \"import\": \"./lib/*.mjs\",\n \"default\": \"./lib/*.js\"\n },\n \"./package.json\": \"./package.json\"\n }\n },\n \"scripts\": {\n \"build\": \"rimraf lib && ttsc && rolldown -c\",\n \"build:test\": \"rimraf bin && ttsc --project test/tsconfig.json\",\n \"deploy\": \"pnpm run build && pnpm publish\",\n \"dev\": \"pnpm run build:test --watch\",\n \"hello\": \"node hello\",\n \"start\": \"ttsx test/start.ts\",\n \"swagger\": \"ttsx test/swagger.ts\",\n \"test\": \"ttsx test/index.ts\",\n \"test:simulate\": \"ttsx test/index.ts --simulate true\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/samchon/nestia\"\n },\n \"author\": \"Jeongho Nam\",\n \"license\": \"MIT\",\n \"bugs\": {\n \"url\": \"https://github.com/samchon/nestia/issues\"\n },\n \"homepage\": \"https://nestia.io\",\n \"files\": [\n \"lib\",\n \"swagger.json\",\n \"package.json\",\n \"README.md\"\n ],\n \"dependencies\": {\n \"@nestia/fetcher\": \"^14.0.
|
|
11
|
+
"package.json": "{\n \"name\": \"@ORGANIZATION/PROJECT-api\",\n \"version\": \"0.1.0\",\n \"description\": \"SDK library generated by Nestia\",\n \"main\": \"src/index.ts\",\n \"exports\": {\n \".\": \"./src/index.ts\",\n \"./lib/*\": \"./src/*.ts\",\n \"./package.json\": \"./package.json\"\n },\n \"publishConfig\": {\n \"main\": \"lib/index.mjs\",\n \"module\": \"lib/index.mjs\",\n \"types\": \"lib/index.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./lib/index.d.ts\",\n \"import\": \"./lib/index.mjs\",\n \"default\": \"./lib/index.js\"\n },\n \"./lib/*\": {\n \"types\": \"./lib/*.d.ts\",\n \"import\": \"./lib/*.mjs\",\n \"default\": \"./lib/*.js\"\n },\n \"./package.json\": \"./package.json\"\n }\n },\n \"scripts\": {\n \"build\": \"rimraf lib && ttsc && rolldown -c\",\n \"build:test\": \"rimraf bin && ttsc --project test/tsconfig.json\",\n \"deploy\": \"pnpm run build && pnpm publish\",\n \"dev\": \"pnpm run build:test --watch\",\n \"hello\": \"node hello\",\n \"start\": \"ttsx test/start.ts\",\n \"swagger\": \"ttsx test/swagger.ts\",\n \"test\": \"ttsx test/index.ts\",\n \"test:simulate\": \"ttsx test/index.ts --simulate true\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/samchon/nestia\"\n },\n \"author\": \"Jeongho Nam\",\n \"license\": \"MIT\",\n \"bugs\": {\n \"url\": \"https://github.com/samchon/nestia/issues\"\n },\n \"homepage\": \"https://nestia.io\",\n \"files\": [\n \"lib\",\n \"swagger.json\",\n \"package.json\",\n \"README.md\"\n ],\n \"dependencies\": {\n \"@nestia/fetcher\": \"^14.0.2\",\n \"tgrid\": \"^1.2.1\",\n \"typia\": \"15.0.0\"\n },\n \"devDependencies\": {\n \"@nestia/e2e\": \"^14.0.2\",\n \"@ttsc/unplugin\": \"^0.28.1\",\n \"@types/express\": \"^4.17.21\",\n \"@types/swagger-ui-express\": \"^4.1.6\",\n \"chalk\": \"4.1.2\",\n \"express\": \"^4.19.2\",\n \"rimraf\": \"^5.0.5\",\n \"rolldown\": \"^1.1.5\",\n \"swagger-ui-express\": \"^5.0.0\",\n \"tinyglobby\": \"^0.2.17\",\n \"ttsc\": \"^0.28.1\",\n \"typescript\": \"^7.0.2\",\n \"@nestia/core\": \"^14.0.2\"\n },\n \"packageManager\": \"pnpm@10.19.0\"\n}",
|
|
12
12
|
"rolldown.config.mjs": "import ttsc from \"@ttsc/unplugin/rolldown\";\nimport path from \"node:path\";\nimport { globSync } from \"tinyglobby\";\n\nexport default {\n input: globSync(\"./src/**/*.ts\"),\n external: (id) => !id.startsWith(\".\") && !path.isAbsolute(id),\n output: {\n dir: \"./lib\",\n format: \"esm\",\n sourcemap: true,\n entryFileNames: \"[name].mjs\",\n preserveModules: true,\n preserveModulesRoot: \"src\",\n },\n plugins: [ttsc()],\n};\n",
|
|
13
13
|
"src/HttpError.ts": "export { HttpError } from \"@nestia/fetcher\";\n",
|
|
14
14
|
"src/IConnection.ts": "export type { IConnection } from \"@nestia/fetcher\";\n",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SDK_TEMPLATE.js","sourceRoot":"","sources":["../../src/bundles/SDK_TEMPLATE.ts"],"names":[],"mappings":";;;AAAa,QAAA,YAAY,GAA2B;IAClD,YAAY,EAAE,uDAAuD;IACrE,qBAAqB,EAAE,wuBAAwuB;IAC/vB,uBAAuB,EAAE,oQAAoQ;IAC7R,SAAS,EAAE,ukCAAukC;IACllC,WAAW,EAAE,knHAAknH;IAC/nH,UAAU,EAAE,mqBAAmqB;IAC/qB,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"SDK_TEMPLATE.js","sourceRoot":"","sources":["../../src/bundles/SDK_TEMPLATE.ts"],"names":[],"mappings":";;;AAAa,QAAA,YAAY,GAA2B;IAClD,YAAY,EAAE,uDAAuD;IACrE,qBAAqB,EAAE,wuBAAwuB;IAC/vB,uBAAuB,EAAE,oQAAoQ;IAC7R,SAAS,EAAE,ukCAAukC;IACllC,WAAW,EAAE,knHAAknH;IAC/nH,UAAU,EAAE,mqBAAmqB;IAC/qB,cAAc,EAAE,4vEAA4vE;IAC5wE,qBAAqB,EAAE,6cAA6c;IACpe,kBAAkB,EAAE,kDAAkD;IACtE,oBAAoB,EAAE,yDAAyD;IAC/E,cAAc,EAAE,0FAA0F;IAC1G,eAAe,EAAE,0HAA0H;IAC3I,cAAc,EAAE,g2lDAAg2lD;IACh3lD,oBAAoB,EAAE,yLAAyL;IAC/M,eAAe,EAAE,2uFAA2uF;IAC5vF,eAAe,EAAE,8rBAA8rB;IAC/sB,iBAAiB,EAAE,2jBAA2jB;IAC9kB,oBAAoB,EAAE,oLAAoL;IAC1M,8BAA8B,EAAE,i4GAAi4G;IACj6G,eAAe,EAAE,89VAA89V;CACh/V,CAAA"}
|
|
@@ -6,7 +6,7 @@ const SDK_TEMPLATE = {
|
|
|
6
6
|
"LICENSE": "MIT License\n\nCopyright (c) 2024 Jeongho Nam\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n",
|
|
7
7
|
"README.md": "# Software Development Kit\nThis is a SDK library generated by [`@nestia/migrate`](https://nestia.io/docs/migrate) or [`@nestia/editor`](https://nestia.io/docs/editor).\n\nWith this SDK library, you can easily and safely interact with backend server.\n\nJust import and call some API functions like gif image below:\n\n\n\n> Left is server code, and right is client code utilizing the SDK\n\n\n\n\n## How to Test\n```bash\npnpm install\npnpm run start # run only \"test/start.ts\" file\npnpm run test # everything under the \"test/features\" directory\npnpm run test:simulate # \"test/features\" with mockup simulation mode\n```\n\nIf you run `pnpm run start` command, only [test/start.ts](test/start.ts) file would be executed.\n\nOtherwise you run `pnpm run test` command instead, run everything in the [test/features](test/features) directory.\n\nFor reference, the [test/features](test/features) directory and E2E test functions (for each API endpoints) would be automatically composed only when you've configured the \"E2E test function generation mode\" of the `@nestia/migrate` (or `@nestia/editor`).\n\n```bash\npnpm dlx @nestia/migrate\n? Migration mode (Use arrow keys):\n NestJS\n > SDK\n? Swagger file location: assets/input/clickhouse.json\n? Output directory path: assets/output/clickhouse-sdk-manual\n? Mokup Simulator: true\n? E2E Test Functions: true\n```\n\n\n\n\n## Deploy\n```bash\npnpm install\npnpm run deploy\n```\n\nJust run `pnpm run deploy` command, then your SDK library would be published.\n\nBy the way, the initial package name of this template repository is `@ORGANIZATION/PROJECT-api`. I think it would better to change the word to your own organization and project name. If you're utilizing `VsCode`, you can do it through `Edit > Replace in Files` (*Ctrl + Shift + H*) feature.\n\n-----------\n\n> ## What [`Nestia`](https://nestia.io) is:\n> \n> \n> [](https://github.com/samchon/nestia/blob/master/LICENSE)\n> [](https://www.npmjs.com/package/@nestia/core)\n> [](https://www.npmjs.com/package/@nestia/core)\n> [](https://github.com/samchon/nestia/actions?query=workflow%3Abuild)\n> [](https://nestia.io/docs/)\n> \n> Nestia is a set of helper libraries for NestJS, supporting below features:\n> \n> - `@nestia/core`: Super-fast decorators\n> - `@nestia/sdk`:\n> - Swagger generator evolved than ever\n> - SDK library generator for clients\n> - Mockup Simulator for client applications\n> - Automatic E2E test functions generator\n> - `@nestia/migrate`: Migration from Swagger to NestJS\n> - `@nestia/editor`: Online TypeScript Swagger Editor\n> - `nestia`: Just CLI (command line interface) tool\n> \n>> **Note**\n>> \n>> - **Only one line** required, with pure TypeScript type\n>> - Enhance performance **30x** up\n>> - Runtime validator is **20,000x faster** than `class-validator`\n>> - JSON serialization is **200x faster** than `class-transformer`\n>> - Software Development Kit\n>> - SDK is a collection of `fetch` functions with type definitions like [tRPC](https://> trpc.io/)\n>> - Mockup simulator means embedded backend simulator in SDK\n>> - similar with [msw](https://mswjs.io/), but fully automated\n",
|
|
8
8
|
"hello.js": "function print(command, description) {\n return console.log(`\\x1b[1m${command}\\x1b[2m: ${description}\\x1b[0m`);\n}\n\nconsole.log(\"-----------------------------------------\");\nconsole.log(\"\\x1b[7mGenerated by \\x1b[2m@nestia/editor\\x1b[0m\");\nconsole.log(\"\");\nconsole.log(\" - \\x1b[36mhttps://nestia.io/docs/editor\\x1b[0m\");\nconsole.log(\" - \\x1b[36mhttps://github.com/samchon/nestia\\x1b[0m\");\nconsole.log(\"-----------------------------------------\");\n\nprint(\"pnpm run start\", \"Run only test/start.ts\");\nprint(\"pnpm run test\", \"Run every test/features/**/*.ts files\");\nprint(\"pnpm run test:simulate\", \"Test with mockup simulator\");\n",
|
|
9
|
-
"package.json": "{\n \"name\": \"@ORGANIZATION/PROJECT-api\",\n \"version\": \"0.1.0\",\n \"description\": \"SDK library generated by Nestia\",\n \"main\": \"src/index.ts\",\n \"exports\": {\n \".\": \"./src/index.ts\",\n \"./lib/*\": \"./src/*.ts\",\n \"./package.json\": \"./package.json\"\n },\n \"publishConfig\": {\n \"main\": \"lib/index.mjs\",\n \"module\": \"lib/index.mjs\",\n \"types\": \"lib/index.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./lib/index.d.ts\",\n \"import\": \"./lib/index.mjs\",\n \"default\": \"./lib/index.js\"\n },\n \"./lib/*\": {\n \"types\": \"./lib/*.d.ts\",\n \"import\": \"./lib/*.mjs\",\n \"default\": \"./lib/*.js\"\n },\n \"./package.json\": \"./package.json\"\n }\n },\n \"scripts\": {\n \"build\": \"rimraf lib && ttsc && rolldown -c\",\n \"build:test\": \"rimraf bin && ttsc --project test/tsconfig.json\",\n \"deploy\": \"pnpm run build && pnpm publish\",\n \"dev\": \"pnpm run build:test --watch\",\n \"hello\": \"node hello\",\n \"start\": \"ttsx test/start.ts\",\n \"swagger\": \"ttsx test/swagger.ts\",\n \"test\": \"ttsx test/index.ts\",\n \"test:simulate\": \"ttsx test/index.ts --simulate true\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/samchon/nestia\"\n },\n \"author\": \"Jeongho Nam\",\n \"license\": \"MIT\",\n \"bugs\": {\n \"url\": \"https://github.com/samchon/nestia/issues\"\n },\n \"homepage\": \"https://nestia.io\",\n \"files\": [\n \"lib\",\n \"swagger.json\",\n \"package.json\",\n \"README.md\"\n ],\n \"dependencies\": {\n \"@nestia/fetcher\": \"^14.0.
|
|
9
|
+
"package.json": "{\n \"name\": \"@ORGANIZATION/PROJECT-api\",\n \"version\": \"0.1.0\",\n \"description\": \"SDK library generated by Nestia\",\n \"main\": \"src/index.ts\",\n \"exports\": {\n \".\": \"./src/index.ts\",\n \"./lib/*\": \"./src/*.ts\",\n \"./package.json\": \"./package.json\"\n },\n \"publishConfig\": {\n \"main\": \"lib/index.mjs\",\n \"module\": \"lib/index.mjs\",\n \"types\": \"lib/index.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./lib/index.d.ts\",\n \"import\": \"./lib/index.mjs\",\n \"default\": \"./lib/index.js\"\n },\n \"./lib/*\": {\n \"types\": \"./lib/*.d.ts\",\n \"import\": \"./lib/*.mjs\",\n \"default\": \"./lib/*.js\"\n },\n \"./package.json\": \"./package.json\"\n }\n },\n \"scripts\": {\n \"build\": \"rimraf lib && ttsc && rolldown -c\",\n \"build:test\": \"rimraf bin && ttsc --project test/tsconfig.json\",\n \"deploy\": \"pnpm run build && pnpm publish\",\n \"dev\": \"pnpm run build:test --watch\",\n \"hello\": \"node hello\",\n \"start\": \"ttsx test/start.ts\",\n \"swagger\": \"ttsx test/swagger.ts\",\n \"test\": \"ttsx test/index.ts\",\n \"test:simulate\": \"ttsx test/index.ts --simulate true\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/samchon/nestia\"\n },\n \"author\": \"Jeongho Nam\",\n \"license\": \"MIT\",\n \"bugs\": {\n \"url\": \"https://github.com/samchon/nestia/issues\"\n },\n \"homepage\": \"https://nestia.io\",\n \"files\": [\n \"lib\",\n \"swagger.json\",\n \"package.json\",\n \"README.md\"\n ],\n \"dependencies\": {\n \"@nestia/fetcher\": \"^14.0.2\",\n \"tgrid\": \"^1.2.1\",\n \"typia\": \"15.0.0\"\n },\n \"devDependencies\": {\n \"@nestia/e2e\": \"^14.0.2\",\n \"@ttsc/unplugin\": \"^0.28.1\",\n \"@types/express\": \"^4.17.21\",\n \"@types/swagger-ui-express\": \"^4.1.6\",\n \"chalk\": \"4.1.2\",\n \"express\": \"^4.19.2\",\n \"rimraf\": \"^5.0.5\",\n \"rolldown\": \"^1.1.5\",\n \"swagger-ui-express\": \"^5.0.0\",\n \"tinyglobby\": \"^0.2.17\",\n \"ttsc\": \"^0.28.1\",\n \"typescript\": \"^7.0.2\",\n \"@nestia/core\": \"^14.0.2\"\n },\n \"packageManager\": \"pnpm@10.19.0\"\n}",
|
|
10
10
|
"rolldown.config.mjs": "import ttsc from \"@ttsc/unplugin/rolldown\";\nimport path from \"node:path\";\nimport { globSync } from \"tinyglobby\";\n\nexport default {\n input: globSync(\"./src/**/*.ts\"),\n external: (id) => !id.startsWith(\".\") && !path.isAbsolute(id),\n output: {\n dir: \"./lib\",\n format: \"esm\",\n sourcemap: true,\n entryFileNames: \"[name].mjs\",\n preserveModules: true,\n preserveModulesRoot: \"src\",\n },\n plugins: [ttsc()],\n};\n",
|
|
11
11
|
"src/HttpError.ts": "export { HttpError } from \"@nestia/fetcher\";\n",
|
|
12
12
|
"src/IConnection.ts": "export type { IConnection } from \"@nestia/fetcher\";\n",
|
|
@@ -1,3 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The command-line entry of `@nestia/migrate`.
|
|
3
|
+
*
|
|
4
|
+
* The output path is resolved with `path.resolve` and its parent tested with
|
|
5
|
+
* `existsSync` and `statSync`, with backslashes converted to `/`, which Windows
|
|
6
|
+
* accepts. The input is fetched when it parses as an http or https URL, so a
|
|
7
|
+
* Windows path whose drive letter parses as a scheme is read from disk, and it
|
|
8
|
+
* is read as UTF-8 otherwise. Only files with a `.ts`, `.cts`, `.mts` or `.tsx`
|
|
9
|
+
* extension, tested case-sensitively, are formatted, and text is written
|
|
10
|
+
* without a byte order mark and with the line endings the generator and
|
|
11
|
+
* Prettier produce, which are not the platform's. A failure ends the process
|
|
12
|
+
* through `process.exit(-1)`, whose status the platform truncates to a non-zero
|
|
13
|
+
* value.
|
|
14
|
+
*
|
|
15
|
+
* @evidence contracts/common.md#principled-implementation The command reads the options, validates the output directory, reads the document from a file or an http(s) URL, converts it, reports the operations that could not be migrated, and writes the files, formatting only TypeScript files.
|
|
16
|
+
* @evidence contracts/common.md#clear-and-simple-design One entry function, with formatting, halting, and URL detection as private helpers.
|
|
17
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts Every failure ends with a message and a non-zero exit, and unformattable content is written unformatted.
|
|
18
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
|
|
19
|
+
*/
|
|
1
20
|
export declare namespace NestiaMigrateCommander {
|
|
21
|
+
/**
|
|
22
|
+
* Runs the command: reads the options and the document, generates the
|
|
23
|
+
* project, and writes it to the output directory.
|
|
24
|
+
*
|
|
25
|
+
* It stops with an error when the output directory exists, when its parent
|
|
26
|
+
* does not exist or is not a directory, when the input cannot be read or
|
|
27
|
+
* fetched, or when the document is invalid.
|
|
28
|
+
*
|
|
29
|
+
* Creation and writing use `fs.promises` through the injected archiver, so
|
|
30
|
+
* the volume decides case policy and permissions, and the checks that precede
|
|
31
|
+
* any write are the filesystem's own answers.
|
|
32
|
+
*
|
|
33
|
+
* @evidence contracts/common.md#principled-implementation The checks run before any file is written, the document is fetched only for an http or https URL, a failed HTTP status stops the command, and only files with a TypeScript extension are formatted, because Prettier's TypeScript parser would rewrite a dotfile line into code.
|
|
34
|
+
* @evidence contracts/common.md#clear-and-simple-design One asynchronous function whose phases are marked in comments, with the option parsing in `NestiaMigrateInquirer`.
|
|
35
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The checks apply to every input, and a formatting failure keeps the original text.
|
|
36
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the conditions under which it stops.
|
|
37
|
+
*/
|
|
2
38
|
const main: () => Promise<void>;
|
|
3
39
|
}
|
|
@@ -54,8 +54,44 @@ const prettierPluginJsDoc = __importStar(require("prettier-plugin-jsdoc"));
|
|
|
54
54
|
const NestiaMigrateApplication_1 = require("../NestiaMigrateApplication");
|
|
55
55
|
const NestiaMigrateFileArchiver_1 = require("../archivers/NestiaMigrateFileArchiver");
|
|
56
56
|
const NestiaMigrateInquirer_1 = require("./NestiaMigrateInquirer");
|
|
57
|
+
/**
|
|
58
|
+
* The command-line entry of `@nestia/migrate`.
|
|
59
|
+
*
|
|
60
|
+
* The output path is resolved with `path.resolve` and its parent tested with
|
|
61
|
+
* `existsSync` and `statSync`, with backslashes converted to `/`, which Windows
|
|
62
|
+
* accepts. The input is fetched when it parses as an http or https URL, so a
|
|
63
|
+
* Windows path whose drive letter parses as a scheme is read from disk, and it
|
|
64
|
+
* is read as UTF-8 otherwise. Only files with a `.ts`, `.cts`, `.mts` or `.tsx`
|
|
65
|
+
* extension, tested case-sensitively, are formatted, and text is written
|
|
66
|
+
* without a byte order mark and with the line endings the generator and
|
|
67
|
+
* Prettier produce, which are not the platform's. A failure ends the process
|
|
68
|
+
* through `process.exit(-1)`, whose status the platform truncates to a non-zero
|
|
69
|
+
* value.
|
|
70
|
+
*
|
|
71
|
+
* @evidence contracts/common.md#principled-implementation The command reads the options, validates the output directory, reads the document from a file or an http(s) URL, converts it, reports the operations that could not be migrated, and writes the files, formatting only TypeScript files.
|
|
72
|
+
* @evidence contracts/common.md#clear-and-simple-design One entry function, with formatting, halting, and URL detection as private helpers.
|
|
73
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts Every failure ends with a message and a non-zero exit, and unformattable content is written unformatted.
|
|
74
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
|
|
75
|
+
*/
|
|
57
76
|
var NestiaMigrateCommander;
|
|
58
77
|
(function (NestiaMigrateCommander) {
|
|
78
|
+
/**
|
|
79
|
+
* Runs the command: reads the options and the document, generates the
|
|
80
|
+
* project, and writes it to the output directory.
|
|
81
|
+
*
|
|
82
|
+
* It stops with an error when the output directory exists, when its parent
|
|
83
|
+
* does not exist or is not a directory, when the input cannot be read or
|
|
84
|
+
* fetched, or when the document is invalid.
|
|
85
|
+
*
|
|
86
|
+
* Creation and writing use `fs.promises` through the injected archiver, so
|
|
87
|
+
* the volume decides case policy and permissions, and the checks that precede
|
|
88
|
+
* any write are the filesystem's own answers.
|
|
89
|
+
*
|
|
90
|
+
* @evidence contracts/common.md#principled-implementation The checks run before any file is written, the document is fetched only for an http or https URL, a failed HTTP status stops the command, and only files with a TypeScript extension are formatted, because Prettier's TypeScript parser would rewrite a dotfile line into code.
|
|
91
|
+
* @evidence contracts/common.md#clear-and-simple-design One asynchronous function whose phases are marked in comments, with the option parsing in `NestiaMigrateInquirer`.
|
|
92
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The checks apply to every input, and a formatting failure keeps the original text.
|
|
93
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the conditions under which it stops.
|
|
94
|
+
*/
|
|
59
95
|
NestiaMigrateCommander.main = () => __awaiter(this, void 0, void 0, function* () {
|
|
60
96
|
const resolve = (str) => str ? path_1.default.resolve(str).split("\\").join("/") : undefined;
|
|
61
97
|
const options = yield NestiaMigrateInquirer_1.NestiaMigrateInquirer.parse();
|
|
@@ -71,6 +107,8 @@ var NestiaMigrateCommander;
|
|
|
71
107
|
const document = yield (() => __awaiter(this, void 0, void 0, function* () {
|
|
72
108
|
if (isUri(options.input)) {
|
|
73
109
|
const response = yield fetch(options.input);
|
|
110
|
+
if (response.ok === false)
|
|
111
|
+
halt(`Unable to fetch the input swagger.json: ${response.status} ${response.statusText}`);
|
|
74
112
|
const content = yield response.text();
|
|
75
113
|
return JSON.parse(content);
|
|
76
114
|
}
|
|
@@ -96,7 +134,11 @@ var NestiaMigrateCommander;
|
|
|
96
134
|
console.error(`Failed to migrate ${error.method} ${error.path}`, ...error.messages.map((msg) => ` - ${msg}`));
|
|
97
135
|
yield NestiaMigrateFileArchiver_1.NestiaMigrateFileArchiver.archive({
|
|
98
136
|
mkdir: fs_1.default.promises.mkdir,
|
|
99
|
-
|
|
137
|
+
// only TypeScript is formatted: prettier's TypeScript parser also
|
|
138
|
+
// accepts a `.gitignore` or `.env` line, and rewrites it into code
|
|
139
|
+
writeFile: (file, content) => __awaiter(this, void 0, void 0, function* () {
|
|
140
|
+
return fs_1.default.promises.writeFile(file, /\.[cm]?tsx?$/.test(file) ? yield beautify(content) : content, "utf-8");
|
|
141
|
+
}),
|
|
100
142
|
root: options.output,
|
|
101
143
|
files,
|
|
102
144
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NestiaMigrateCommander.js","sourceRoot":"","sources":["../../src/executable/NestiaMigrateCommander.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,MAAY,wBAAwB,kEAA8C;AAOlF,4CAAoB;AACpB,gDAAwB;AACxB,uCAAkC;AAClC,MAAY,mBAAmB,kDAA8B;AAG7D,0EAAuE;AACvE,sFAAmF;AACnF,mEAAgE;AAEhE,IAAiB,sBAAsB,
|
|
1
|
+
{"version":3,"file":"NestiaMigrateCommander.js","sourceRoot":"","sources":["../../src/executable/NestiaMigrateCommander.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,MAAY,wBAAwB,kEAA8C;AAOlF,4CAAoB;AACpB,gDAAwB;AACxB,uCAAkC;AAClC,MAAY,mBAAmB,kDAA8B;AAG7D,0EAAuE;AACvE,sFAAmF;AACnF,mEAAgE;AAEhE;;;;;;;;;;;;;;;;;;GAkBG;AACH,IAAiB,sBAAsB,CA4HtC;AA5HD,WAAiB,sBAAsB;IACrC;;;;;;;;;;;;;;;;OAgBG;IACU,2BAAI,GAAG,GAAwB,EAAE;QAC5C,MAAM,OAAO,GAAG,CAAC,GAAuB,EAAE,EAAE,CAC1C,GAAG,CAAC,CAAC,CAAC,cAAI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GAAG,GAAQ,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;YAChC,OAAO,GAAG,CAAC,QAAQ,KAAK,OAAO,IAAI,GAAG,CAAC,QAAQ,KAAK,QAAQ,CAAC;QAC/D,CAAC;mBAAO,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC,CAAC;AACJ,CAAC,EA5HgB,sBAAsB,aAAtB,sBAAsB,GAAtB,sBAAsB,QA4HtC"}
|
|
@@ -18,7 +18,9 @@ let NestiaMigrateCommander;
|
|
|
18
18
|
else if (fs.statSync(parent).isDirectory() === false) halt("Response directory's parent is not a directory.");
|
|
19
19
|
const document = await (async () => {
|
|
20
20
|
if (isUri(options.input)) {
|
|
21
|
-
const
|
|
21
|
+
const response = await fetch(options.input);
|
|
22
|
+
if (response.ok === false) halt(`Unable to fetch the input swagger.json: ${response.status} ${response.statusText}`);
|
|
23
|
+
const content = await response.text();
|
|
22
24
|
return JSON.parse(content);
|
|
23
25
|
}
|
|
24
26
|
if (fs.existsSync(options.input) === false) halt("Unable to find the input swagger.json file.");
|
|
@@ -37,7 +39,7 @@ let NestiaMigrateCommander;
|
|
|
37
39
|
if (app.getData().errors) for (const error of app.getData().errors) console.error(`Failed to migrate ${error.method} ${error.path}`, ...error.messages.map((msg) => ` - ${msg}`));
|
|
38
40
|
await NestiaMigrateFileArchiver.archive({
|
|
39
41
|
mkdir: fs.promises.mkdir,
|
|
40
|
-
writeFile: async (file, content) => fs.promises.writeFile(file, await beautify(content), "utf-8"),
|
|
42
|
+
writeFile: async (file, content) => fs.promises.writeFile(file, /\.[cm]?tsx?$/.test(file) ? await beautify(content) : content, "utf-8"),
|
|
41
43
|
root: options.output,
|
|
42
44
|
files
|
|
43
45
|
});
|
|
@@ -1,4 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads the options of the command from flags, asking interactively for what is
|
|
3
|
+
* missing.
|
|
4
|
+
*
|
|
5
|
+
* @evidence contracts/common.md#principled-implementation Each option is taken from its flag when given, and asked with a prompt otherwise, so the same command runs non-interactively when every flag is present.
|
|
6
|
+
* @evidence contracts/common.md#clear-and-simple-design One function and the output type; the prompt helpers are local.
|
|
7
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The prompts are the standard `inquirer` ones, and a flag always wins over a prompt.
|
|
8
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
|
|
9
|
+
*/
|
|
1
10
|
export declare namespace NestiaMigrateInquirer {
|
|
11
|
+
/**
|
|
12
|
+
* The options of the command: the mode, the input and output locations, the
|
|
13
|
+
* flags, and the package name.
|
|
14
|
+
*
|
|
15
|
+
* @evidence contracts/common.md#principled-implementation The record holds the answers needed to run the migration, each as a value and not as an optional.
|
|
16
|
+
* @evidence contracts/common.md#clear-and-simple-design A flat record.
|
|
17
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
|
|
18
|
+
* @evidence contracts/common.md#meaningful-documentation The comment lists the options.
|
|
19
|
+
*/
|
|
2
20
|
interface IOutput {
|
|
3
21
|
mode: "nest" | "sdk";
|
|
4
22
|
input: string;
|
|
@@ -8,5 +26,16 @@ export declare namespace NestiaMigrateInquirer {
|
|
|
8
26
|
e2e: boolean;
|
|
9
27
|
package: string;
|
|
10
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Parses the flags and asks for the missing options.
|
|
31
|
+
*
|
|
32
|
+
* A boolean flag given without a value is `true`, and one given a value is
|
|
33
|
+
* true only for the text `true`.
|
|
34
|
+
*
|
|
35
|
+
* @evidence contracts/common.md#principled-implementation Commander parses the flags, the action asks a prompt for each undefined option, and boolean flags are normalized by one rule, so the result has every field set.
|
|
36
|
+
* @evidence contracts/common.md#clear-and-simple-design One function that wires the parser and the prompts around one action.
|
|
37
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It asks only for what is missing.
|
|
38
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the boolean flag rule.
|
|
39
|
+
*/
|
|
11
40
|
const parse: () => Promise<IOutput>;
|
|
12
41
|
}
|