@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
|
@@ -12,8 +12,28 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.NestiaMigrateInquirer = void 0;
|
|
13
13
|
const commander_1 = require("commander");
|
|
14
14
|
const inquirer_1 = require("inquirer");
|
|
15
|
+
/**
|
|
16
|
+
* Reads the options of the command from flags, asking interactively for what is
|
|
17
|
+
* missing.
|
|
18
|
+
*
|
|
19
|
+
* @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.
|
|
20
|
+
* @evidence contracts/common.md#clear-and-simple-design One function and the output type; the prompt helpers are local.
|
|
21
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The prompts are the standard `inquirer` ones, and a flag always wins over a prompt.
|
|
22
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
|
|
23
|
+
*/
|
|
15
24
|
var NestiaMigrateInquirer;
|
|
16
25
|
(function (NestiaMigrateInquirer) {
|
|
26
|
+
/**
|
|
27
|
+
* Parses the flags and asks for the missing options.
|
|
28
|
+
*
|
|
29
|
+
* A boolean flag given without a value is `true`, and one given a value is
|
|
30
|
+
* true only for the text `true`.
|
|
31
|
+
*
|
|
32
|
+
* @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.
|
|
33
|
+
* @evidence contracts/common.md#clear-and-simple-design One function that wires the parser and the prompts around one action.
|
|
34
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It asks only for what is missing.
|
|
35
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the boolean flag rule.
|
|
36
|
+
*/
|
|
17
37
|
NestiaMigrateInquirer.parse = () => __awaiter(this, void 0, void 0, function* () {
|
|
18
38
|
// PREPARE ASSETS
|
|
19
39
|
commander_1.program.option("--mode [nest/sdk]", "migration mode");
|
|
@@ -55,35 +75,17 @@ var NestiaMigrateInquirer;
|
|
|
55
75
|
});
|
|
56
76
|
// DO CONSTRUCT
|
|
57
77
|
return action((partial) => __awaiter(this, void 0, void 0, function* () {
|
|
58
|
-
var _a, _b, _c, _d, _e;
|
|
78
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
59
79
|
(_a = partial.mode) !== null && _a !== void 0 ? _a : (partial.mode = yield select("mode")("Migration mode")(["NestJS", "SDK"], (value) => (value === "NestJS" ? "nest" : "sdk")));
|
|
60
80
|
(_b = partial.input) !== null && _b !== void 0 ? _b : (partial.input = yield input("input")("Swagger file location"));
|
|
61
81
|
(_c = partial.output) !== null && _c !== void 0 ? _c : (partial.output = yield input("output")("Response directory path"));
|
|
62
82
|
(_d = partial.package) !== null && _d !== void 0 ? _d : (partial.package = yield input("package")("Package name"));
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
else
|
|
70
|
-
partial.keyword =
|
|
71
|
-
(yield select("keyword")("Keyword parameter mode")([
|
|
72
|
-
"true",
|
|
73
|
-
"false",
|
|
74
|
-
])) === "true";
|
|
75
|
-
if (partial.simulate)
|
|
76
|
-
partial.simulate = partial.simulate === "true";
|
|
77
|
-
else
|
|
78
|
-
partial.simulate =
|
|
79
|
-
(yield select("simulate")("Mokup Simulator")(["true", "false"])) ===
|
|
80
|
-
"true";
|
|
81
|
-
if (partial.e2e)
|
|
82
|
-
partial.e2e = partial.e2e === "true";
|
|
83
|
-
else
|
|
84
|
-
partial.e2e =
|
|
85
|
-
(yield select("e2e")("Generate E2E tests")(["true", "false"])) ===
|
|
86
|
-
"true";
|
|
83
|
+
// a flag given alone is `true`, and one given a value is its text
|
|
84
|
+
const flag = (value) => value === undefined ? undefined : value === true || value === "true";
|
|
85
|
+
const ask = (name, message) => __awaiter(this, void 0, void 0, function* () { return (yield select(name)(message)(["true", "false"])) === "true"; });
|
|
86
|
+
partial.keyword = (_e = flag(partial.keyword)) !== null && _e !== void 0 ? _e : (yield ask("keyword", "Keyword parameter mode"));
|
|
87
|
+
partial.simulate = (_f = flag(partial.simulate)) !== null && _f !== void 0 ? _f : (yield ask("simulate", "Mokup Simulator"));
|
|
88
|
+
partial.e2e = (_g = flag(partial.e2e)) !== null && _g !== void 0 ? _g : (yield ask("e2e", "Generate E2E tests"));
|
|
87
89
|
return partial;
|
|
88
90
|
}));
|
|
89
91
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NestiaMigrateInquirer.js","sourceRoot":"","sources":["../../src/executable/NestiaMigrateInquirer.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAoC;AACpC,uCAA8C;AAE9C,IAAiB,qBAAqB,
|
|
1
|
+
{"version":3,"file":"NestiaMigrateInquirer.js","sourceRoot":"","sources":["../../src/executable/NestiaMigrateInquirer.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAoC;AACpC,uCAA8C;AAE9C;;;;;;;;GAQG;AACH,IAAiB,qBAAqB,CA4GrC;AA5GD,W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CACnD,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,MAAM,CAAC;YACvE,MAAM,GAAG,GAAG,CAAO,IAAY,EAAE,OAAe,EAAoB,EAAE,gDACpE,OAAA,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,MAAM,CAAA,CAAA,CAAC,CAAD,CAAC;YAC9D,OAAO,CAAC,OAAO,SACb,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,mCACrB,CAAC,MAAM,GAAG,CAAC,SAAS,EAAE,wBAAwB,CAAC,CAAC,CAAC;YACnD,OAAO,CAAC,QAAQ,SACd,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,mCAAI,CAAC,MAAM,GAAG,CAAC,UAAU,EAAE,iBAAiB,CAAC,CAAC,CAAC;YACvE,OAAO,CAAC,GAAG,SACT,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,mCAAI,CAAC,MAAM,GAAG,CAAC,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC;YAChE,OAAO,OAAkB,CAAC;QAC5B,CAAC,CAAA,CAAC,CAAC;IACL,CAAC,CAAA,CAAC;AACJ,CAAC,EA5GgB,qBAAqB,aAArB,qBAAqB,GAArB,qBAAqB,QA4GrC"}
|
|
@@ -42,13 +42,11 @@ let NestiaMigrateInquirer;
|
|
|
42
42
|
partial.input ??= await input("input")("Swagger file location");
|
|
43
43
|
partial.output ??= await input("output")("Response directory path");
|
|
44
44
|
partial.package ??= await input("package")("Package name");
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if (partial.e2e) partial.e2e = partial.e2e === "true";
|
|
51
|
-
else partial.e2e = await select("e2e")("Generate E2E tests")(["true", "false"]) === "true";
|
|
45
|
+
const flag = (value) => value === void 0 ? void 0 : value === true || value === "true";
|
|
46
|
+
const ask = async (name, message) => await select(name)(message)(["true", "false"]) === "true";
|
|
47
|
+
partial.keyword = flag(partial.keyword) ?? await ask("keyword", "Keyword parameter mode");
|
|
48
|
+
partial.simulate = flag(partial.simulate) ?? await ask("simulate", "Mokup Simulator");
|
|
49
|
+
partial.e2e = flag(partial.e2e) ?? await ask("e2e", "Generate E2E tests");
|
|
52
50
|
return partial;
|
|
53
51
|
});
|
|
54
52
|
};
|
|
@@ -3,7 +3,21 @@ import { type NumericLiteral, type PrefixUnaryExpression } from "@ttsc/factory";
|
|
|
3
3
|
* Numeric-literal helper that handles negative values via a leading
|
|
4
4
|
* `MinusToken` prefix unary, matching how the TypeScript factory itself emits
|
|
5
5
|
* negative numeric literals.
|
|
6
|
+
*
|
|
7
|
+
* @evidence contracts/common.md#principled-implementation The namespace holds the number literal builder that the generators need.
|
|
8
|
+
* @evidence contracts/common.md#clear-and-simple-design One function.
|
|
9
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It only builds nodes.
|
|
10
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
|
|
6
11
|
*/
|
|
7
12
|
export declare namespace ExpressionFactory {
|
|
13
|
+
/**
|
|
14
|
+
* Builds a numeric literal, using a prefix minus for a negative value,
|
|
15
|
+
* because a negative numeric literal is not a valid node.
|
|
16
|
+
*
|
|
17
|
+
* @evidence contracts/common.md#principled-implementation TypeScript represents a negative number as a prefix unary minus applied to a positive literal, so the function builds that shape for values below zero and a plain literal otherwise.
|
|
18
|
+
* @evidence contracts/common.md#clear-and-simple-design One conditional.
|
|
19
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It follows the syntax tree grammar.
|
|
20
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the negative case.
|
|
21
|
+
*/
|
|
8
22
|
const number: (value: number) => NumericLiteral | PrefixUnaryExpression;
|
|
9
23
|
}
|
|
@@ -6,9 +6,23 @@ const factory_1 = require("@ttsc/factory");
|
|
|
6
6
|
* Numeric-literal helper that handles negative values via a leading
|
|
7
7
|
* `MinusToken` prefix unary, matching how the TypeScript factory itself emits
|
|
8
8
|
* negative numeric literals.
|
|
9
|
+
*
|
|
10
|
+
* @evidence contracts/common.md#principled-implementation The namespace holds the number literal builder that the generators need.
|
|
11
|
+
* @evidence contracts/common.md#clear-and-simple-design One function.
|
|
12
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It only builds nodes.
|
|
13
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
|
|
9
14
|
*/
|
|
10
15
|
var ExpressionFactory;
|
|
11
16
|
(function (ExpressionFactory) {
|
|
17
|
+
/**
|
|
18
|
+
* Builds a numeric literal, using a prefix minus for a negative value,
|
|
19
|
+
* because a negative numeric literal is not a valid node.
|
|
20
|
+
*
|
|
21
|
+
* @evidence contracts/common.md#principled-implementation TypeScript represents a negative number as a prefix unary minus applied to a positive literal, so the function builds that shape for values below zero and a plain literal otherwise.
|
|
22
|
+
* @evidence contracts/common.md#clear-and-simple-design One conditional.
|
|
23
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It follows the syntax tree grammar.
|
|
24
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the negative case.
|
|
25
|
+
*/
|
|
12
26
|
ExpressionFactory.number = (value) => value < 0
|
|
13
27
|
? factory_1.factory.createPrefixUnaryExpression(factory_1.SyntaxKind.MinusToken, factory_1.factory.createNumericLiteral(Math.abs(value)))
|
|
14
28
|
: factory_1.factory.createNumericLiteral(value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpressionFactory.js","sourceRoot":"","sources":["../../src/factories/ExpressionFactory.ts"],"names":[],"mappings":";;;AAAA,2CAKuB;AAEvB
|
|
1
|
+
{"version":3,"file":"ExpressionFactory.js","sourceRoot":"","sources":["../../src/factories/ExpressionFactory.ts"],"names":[],"mappings":";;;AAAA,2CAKuB;AAEvB;;;;;;;;;GASG;AACH,IAAiB,iBAAiB,CAmBjC;AAnBD,WAAiB,iBAAiB;IAChC;;;;;;;;OAQG;IACU,wBAAM,GAAG,CACpB,KAAa,EAC2B,EAAE,CAC1C,KAAK,GAAG,CAAC;QACP,CAAC,CAAC,iBAAO,CAAC,2BAA2B,CACjC,oBAAU,CAAC,UAAU,EACrB,iBAAO,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAC9C;QACH,CAAC,CAAC,iBAAO,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC;AAC5C,CAAC,EAnBgB,iBAAiB,aAAjB,iBAAiB,GAAjB,iBAAiB,QAmBjC"}
|
|
@@ -2,21 +2,41 @@ import { type Expression, type Identifier, type ParameterDeclaration, type Strin
|
|
|
2
2
|
/**
|
|
3
3
|
* Identifier and member-access helpers. The surface kept here is the subset
|
|
4
4
|
* nestia generators actually call (`identifier`, `access`, `parameter`).
|
|
5
|
+
*
|
|
6
|
+
* @evidence contracts/common.md#principled-implementation The functions decide between an identifier and a string literal by the syntax of the name, so any string can be used as a key.
|
|
7
|
+
* @evidence contracts/common.md#clear-and-simple-design Three small functions and one private predicate.
|
|
8
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The variable-name test is a regular expression of the language's identifier syntax, which is inlined so that the package need not load a larger namespace.
|
|
9
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
|
|
5
10
|
*/
|
|
6
11
|
export declare namespace IdentifierFactory {
|
|
7
12
|
/**
|
|
8
13
|
* Build an identifier or string literal depending on whether `name` is a
|
|
9
14
|
* valid JavaScript identifier.
|
|
15
|
+
*
|
|
16
|
+
* @evidence contracts/common.md#principled-implementation The name is tested against the identifier grammar `[A-Za-z_$][A-Za-z0-9_$]*`, which is conservative: a valid name outside it, such as one with non-ASCII letters, becomes a quoted key, which is equivalent.
|
|
17
|
+
* @evidence contracts/common.md#clear-and-simple-design One conditional.
|
|
18
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The test applies to every name.
|
|
19
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the two results.
|
|
10
20
|
*/
|
|
11
21
|
const identifier: (name: string) => Identifier | StringLiteral;
|
|
12
22
|
/**
|
|
13
23
|
* Member access on `input` by `key`. Falls back to element access when the
|
|
14
24
|
* key is not a valid identifier.
|
|
25
|
+
*
|
|
26
|
+
* @evidence contracts/common.md#principled-implementation The postfix is built by `identifier`, and its kind selects the property form or the element form, with the chain token added when requested.
|
|
27
|
+
* @evidence contracts/common.md#clear-and-simple-design One function delegating the naming rule.
|
|
28
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It never concatenates source text.
|
|
29
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the forms.
|
|
15
30
|
*/
|
|
16
31
|
const access: (input: Expression, key: string, chain?: boolean) => Expression;
|
|
17
32
|
/**
|
|
18
33
|
* Parameter declaration with default `any` type when the caller omits one.
|
|
19
34
|
* Passing a `QuestionToken` as `init` marks the parameter optional.
|
|
35
|
+
*
|
|
36
|
+
* @evidence contracts/common.md#principled-implementation An initializer that is the question token becomes the optional marker and is not an initializer, and any other initializer is passed through.
|
|
37
|
+
* @evidence contracts/common.md#clear-and-simple-design One function with one branch.
|
|
38
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It follows the declaration grammar.
|
|
39
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the optional marker and the default type.
|
|
20
40
|
*/
|
|
21
41
|
const parameter: (name: string | Identifier, type?: TypeNode, init?: Expression | Token) => ParameterDeclaration;
|
|
22
42
|
}
|
|
@@ -10,12 +10,22 @@ const isVariableName = (str) => VARIABLE_REGEX.test(str);
|
|
|
10
10
|
/**
|
|
11
11
|
* Identifier and member-access helpers. The surface kept here is the subset
|
|
12
12
|
* nestia generators actually call (`identifier`, `access`, `parameter`).
|
|
13
|
+
*
|
|
14
|
+
* @evidence contracts/common.md#principled-implementation The functions decide between an identifier and a string literal by the syntax of the name, so any string can be used as a key.
|
|
15
|
+
* @evidence contracts/common.md#clear-and-simple-design Three small functions and one private predicate.
|
|
16
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The variable-name test is a regular expression of the language's identifier syntax, which is inlined so that the package need not load a larger namespace.
|
|
17
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
|
|
13
18
|
*/
|
|
14
19
|
var IdentifierFactory;
|
|
15
20
|
(function (IdentifierFactory) {
|
|
16
21
|
/**
|
|
17
22
|
* Build an identifier or string literal depending on whether `name` is a
|
|
18
23
|
* valid JavaScript identifier.
|
|
24
|
+
*
|
|
25
|
+
* @evidence contracts/common.md#principled-implementation The name is tested against the identifier grammar `[A-Za-z_$][A-Za-z0-9_$]*`, which is conservative: a valid name outside it, such as one with non-ASCII letters, becomes a quoted key, which is equivalent.
|
|
26
|
+
* @evidence contracts/common.md#clear-and-simple-design One conditional.
|
|
27
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The test applies to every name.
|
|
28
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the two results.
|
|
19
29
|
*/
|
|
20
30
|
IdentifierFactory.identifier = (name) => isVariableName(name)
|
|
21
31
|
? factory_1.factory.createIdentifier(name)
|
|
@@ -23,6 +33,11 @@ var IdentifierFactory;
|
|
|
23
33
|
/**
|
|
24
34
|
* Member access on `input` by `key`. Falls back to element access when the
|
|
25
35
|
* key is not a valid identifier.
|
|
36
|
+
*
|
|
37
|
+
* @evidence contracts/common.md#principled-implementation The postfix is built by `identifier`, and its kind selects the property form or the element form, with the chain token added when requested.
|
|
38
|
+
* @evidence contracts/common.md#clear-and-simple-design One function delegating the naming rule.
|
|
39
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It never concatenates source text.
|
|
40
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the forms.
|
|
26
41
|
*/
|
|
27
42
|
IdentifierFactory.access = (input, key, chain) => {
|
|
28
43
|
const postfix = IdentifierFactory.identifier(key);
|
|
@@ -37,6 +52,11 @@ var IdentifierFactory;
|
|
|
37
52
|
/**
|
|
38
53
|
* Parameter declaration with default `any` type when the caller omits one.
|
|
39
54
|
* Passing a `QuestionToken` as `init` marks the parameter optional.
|
|
55
|
+
*
|
|
56
|
+
* @evidence contracts/common.md#principled-implementation An initializer that is the question token becomes the optional marker and is not an initializer, and any other initializer is passed through.
|
|
57
|
+
* @evidence contracts/common.md#clear-and-simple-design One function with one branch.
|
|
58
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It follows the declaration grammar.
|
|
59
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the optional marker and the default type.
|
|
40
60
|
*/
|
|
41
61
|
IdentifierFactory.parameter = (name, type, init) => {
|
|
42
62
|
const isQuestionToken = !!init &&
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IdentifierFactory.js","sourceRoot":"","sources":["../../src/factories/IdentifierFactory.ts"],"names":[],"mappings":";;;AAAA,2CASuB;AAEvB,+CAA4C;AAE5C,yEAAyE;AACzE,yEAAyE;AACzE,MAAM,cAAc,GAAG,4BAA4B,CAAC;AACpD,MAAM,cAAc,GAAG,CAAC,GAAW,EAAW,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE1E
|
|
1
|
+
{"version":3,"file":"IdentifierFactory.js","sourceRoot":"","sources":["../../src/factories/IdentifierFactory.ts"],"names":[],"mappings":";;;AAAA,2CASuB;AAEvB,+CAA4C;AAE5C,yEAAyE;AACzE,yEAAyE;AACzE,MAAM,cAAc,GAAG,4BAA4B,CAAC;AACpD,MAAM,cAAc,GAAG,CAAC,GAAW,EAAW,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE1E;;;;;;;;GAQG;AACH,IAAiB,iBAAiB,CA4EjC;AA5ED,WAAiB,iBAAiB;IAChC;;;;;;;;OAQG;IACU,4BAAU,GAAG,CAAC,IAAY,EAA8B,EAAE,CACrE,cAAc,CAAC,IAAI,CAAC;QAClB,CAAC,CAAC,iBAAO,CA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C,EAClC,eAAe,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAE,IAA+B,CAC/D,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC,EA5EgB,iBAAiB,aAAjB,iBAAiB,GAAjB,iBAAiB,QA4EjC"}
|
|
@@ -1,9 +1,25 @@
|
|
|
1
1
|
import { type Expression } from "@ttsc/factory";
|
|
2
2
|
/**
|
|
3
3
|
* Recursive value-to-AST-literal builder. Hands back already-AST inputs
|
|
4
|
-
* unchanged
|
|
5
|
-
*
|
|
4
|
+
* unchanged for arrow functions, calls and identifiers (so callers can mix
|
|
5
|
+
* those factory expressions with raw values inside objects/arrays), and emits
|
|
6
|
+
* the appropriate literal node otherwise.
|
|
7
|
+
*
|
|
8
|
+
* @evidence contracts/common.md#principled-implementation The namespace maps null, booleans, numbers, strings, bigint text, arrays and object entries to literal expressions, passes through the three accepted AST kinds, maps functions to undefined and refuses unsupported primitive types.
|
|
9
|
+
* @evidence contracts/common.md#clear-and-simple-design One entry function and two private helpers for containers.
|
|
10
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The mapping is by type, with no value special-cased.
|
|
11
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
|
|
6
12
|
*/
|
|
7
13
|
export declare namespace LiteralFactory {
|
|
14
|
+
/**
|
|
15
|
+
* Builds the expression of a value: `null`, a boolean, a number, a string, a
|
|
16
|
+
* bigint as its text, an array, an object without its `undefined` members, or
|
|
17
|
+
* an expression node as it is.
|
|
18
|
+
*
|
|
19
|
+
* @evidence contracts/common.md#principled-implementation The value is dispatched by type in a fixed order; nodes of the kinds arrow function, call, and identifier pass through, functions become `undefined`, and an unsupported type is a `TypeError`, so the result is total over the listed types.
|
|
20
|
+
* @evidence contracts/common.md#clear-and-simple-design One function with one branch per type.
|
|
21
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The dispatch is general, and a bigint becomes text because a literal bigint is not supported by the target syntax here.
|
|
22
|
+
* @evidence contracts/common.md#meaningful-documentation The comment lists the mapping.
|
|
23
|
+
*/
|
|
8
24
|
const write: (input: any) => Expression;
|
|
9
25
|
}
|
|
@@ -14,11 +14,27 @@ const isNode = (value) => typeof value === "object" &&
|
|
|
14
14
|
typeof value.kind === "string";
|
|
15
15
|
/**
|
|
16
16
|
* Recursive value-to-AST-literal builder. Hands back already-AST inputs
|
|
17
|
-
* unchanged
|
|
18
|
-
*
|
|
17
|
+
* unchanged for arrow functions, calls and identifiers (so callers can mix
|
|
18
|
+
* those factory expressions with raw values inside objects/arrays), and emits
|
|
19
|
+
* the appropriate literal node otherwise.
|
|
20
|
+
*
|
|
21
|
+
* @evidence contracts/common.md#principled-implementation The namespace maps null, booleans, numbers, strings, bigint text, arrays and object entries to literal expressions, passes through the three accepted AST kinds, maps functions to undefined and refuses unsupported primitive types.
|
|
22
|
+
* @evidence contracts/common.md#clear-and-simple-design One entry function and two private helpers for containers.
|
|
23
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The mapping is by type, with no value special-cased.
|
|
24
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
|
|
19
25
|
*/
|
|
20
26
|
var LiteralFactory;
|
|
21
27
|
(function (LiteralFactory) {
|
|
28
|
+
/**
|
|
29
|
+
* Builds the expression of a value: `null`, a boolean, a number, a string, a
|
|
30
|
+
* bigint as its text, an array, an object without its `undefined` members, or
|
|
31
|
+
* an expression node as it is.
|
|
32
|
+
*
|
|
33
|
+
* @evidence contracts/common.md#principled-implementation The value is dispatched by type in a fixed order; nodes of the kinds arrow function, call, and identifier pass through, functions become `undefined`, and an unsupported type is a `TypeError`, so the result is total over the listed types.
|
|
34
|
+
* @evidence contracts/common.md#clear-and-simple-design One function with one branch per type.
|
|
35
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The dispatch is general, and a bigint becomes text because a literal bigint is not supported by the target syntax here.
|
|
36
|
+
* @evidence contracts/common.md#meaningful-documentation The comment lists the mapping.
|
|
37
|
+
*/
|
|
22
38
|
LiteralFactory.write = (input) => {
|
|
23
39
|
if (input === null)
|
|
24
40
|
return factory_1.factory.createNull();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LiteralFactory.js","sourceRoot":"","sources":["../../src/factories/LiteralFactory.ts"],"names":[],"mappings":";;;AAAA,2CAAyD;AAEzD,2DAAwD;AACxD,2DAAwD;AAExD,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAS;IACxC,eAAe;IACf,gBAAgB;IAChB,YAAY;CACb,CAAC,CAAC;AAEH,MAAM,MAAM,GAAG,CAAC,KAAc,EAAuB,EAAE,CACrD,OAAO,KAAK,KAAK,QAAQ;IACzB,KAAK,KAAK,IAAI;IACd,OAAQ,KAA4B,CAAC,IAAI,KAAK,QAAQ,CAAC;AAEzD
|
|
1
|
+
{"version":3,"file":"LiteralFactory.js","sourceRoot":"","sources":["../../src/factories/LiteralFactory.ts"],"names":[],"mappings":";;;AAAA,2CAAyD;AAEzD,2DAAwD;AACxD,2DAAwD;AAExD,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAS;IACxC,eAAe;IACf,gBAAgB;IAChB,YAAY;CACb,CAAC,CAAC;AAEH,MAAM,MAAM,GAAG,CAAC,KAAc,EAAuB,EAAE,CACrD,OAAO,KAAK,KAAK,QAAQ;IACzB,KAAK,KAAK,IAAI;IACd,OAAQ,KAA4B,CAAC,IAAI,KAAK,QAAQ,CAAC;AAEzD;;;;;;;;;;GAUG;AACH,IAAiB,cAAc,CA0C9B;AA1CD,WAAiB,cAAc;IAC7B;;;;;;;;;OASG;IACU,oBAAK,GAAG,CAAC,KAAU,EAAc,EAAE;QAC9C,IAAI,KAAK,KAAK,IAAI;YAAE,OAAO,iBAAO,CAAC,UAAU,EAAE,CAAC;QAChD,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,iBAAiB,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC;YAAE,OAAO,KAAK,CAAC;QACrE,IAAI,KAAK,CAAC,OAAO,CAAC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AC,4BAA4B,CAAC,KAAK,CAAC,GAAG,CAAC,oBAAK,CAAC,EAAE,IAAI,CAAC,CAAC;AACjE,CAAC,EA1CgB,cAAc,aAAd,cAAc,GAAd,cAAc,QA0C9B"}
|
|
@@ -1,11 +1,36 @@
|
|
|
1
1
|
import { type Expression, type TypeNode, type VariableStatement } from "@ttsc/factory";
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Variable-statement helpers. `constant` emits `const`, `mut` emits `let`.
|
|
4
|
+
*
|
|
5
|
+
* @evidence contracts/common.md#principled-implementation The namespace builds `let` and `const` statements from a name, an optional type, and an optional value.
|
|
6
|
+
* @evidence contracts/common.md#clear-and-simple-design Two functions.
|
|
7
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It only builds nodes.
|
|
8
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
|
|
9
|
+
*/
|
|
3
10
|
export declare namespace StatementFactory {
|
|
11
|
+
/**
|
|
12
|
+
* Builds a `let` statement; a declaration without a type and without an
|
|
13
|
+
* initializer is typed `any`.
|
|
14
|
+
*
|
|
15
|
+
* @evidence contracts/common.md#principled-implementation A `let` without both a type and an initializer would be implicitly any, so the type is stated explicitly in that case.
|
|
16
|
+
* @evidence contracts/common.md#clear-and-simple-design One expression.
|
|
17
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It follows the declaration grammar.
|
|
18
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the default type.
|
|
19
|
+
*/
|
|
4
20
|
const mut: (props: {
|
|
5
21
|
name: string;
|
|
6
22
|
type?: TypeNode | undefined;
|
|
7
23
|
initializer?: Expression | undefined;
|
|
8
24
|
}) => VariableStatement;
|
|
25
|
+
/**
|
|
26
|
+
* Builds a `const` statement from a name, an optional type, and an optional
|
|
27
|
+
* value.
|
|
28
|
+
*
|
|
29
|
+
* @evidence contracts/common.md#principled-implementation The declaration list carries the const flag and the given parts.
|
|
30
|
+
* @evidence contracts/common.md#clear-and-simple-design One expression.
|
|
31
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It follows the declaration grammar.
|
|
32
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its inputs.
|
|
33
|
+
*/
|
|
9
34
|
const constant: (props: {
|
|
10
35
|
name: string;
|
|
11
36
|
type?: TypeNode | undefined;
|
|
@@ -3,9 +3,25 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.StatementFactory = void 0;
|
|
4
4
|
const factory_1 = require("@ttsc/factory");
|
|
5
5
|
const TypeFactory_1 = require("./TypeFactory");
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Variable-statement helpers. `constant` emits `const`, `mut` emits `let`.
|
|
8
|
+
*
|
|
9
|
+
* @evidence contracts/common.md#principled-implementation The namespace builds `let` and `const` statements from a name, an optional type, and an optional value.
|
|
10
|
+
* @evidence contracts/common.md#clear-and-simple-design Two functions.
|
|
11
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It only builds nodes.
|
|
12
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
|
|
13
|
+
*/
|
|
7
14
|
var StatementFactory;
|
|
8
15
|
(function (StatementFactory) {
|
|
16
|
+
/**
|
|
17
|
+
* Builds a `let` statement; a declaration without a type and without an
|
|
18
|
+
* initializer is typed `any`.
|
|
19
|
+
*
|
|
20
|
+
* @evidence contracts/common.md#principled-implementation A `let` without both a type and an initializer would be implicitly any, so the type is stated explicitly in that case.
|
|
21
|
+
* @evidence contracts/common.md#clear-and-simple-design One expression.
|
|
22
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It follows the declaration grammar.
|
|
23
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the default type.
|
|
24
|
+
*/
|
|
9
25
|
StatementFactory.mut = (props) => factory_1.factory.createVariableStatement(undefined, factory_1.factory.createVariableDeclarationList([
|
|
10
26
|
factory_1.factory.createVariableDeclaration(props.name, undefined, props.type !== undefined
|
|
11
27
|
? props.type
|
|
@@ -13,6 +29,15 @@ var StatementFactory;
|
|
|
13
29
|
? TypeFactory_1.TypeFactory.keyword("any")
|
|
14
30
|
: undefined, props.initializer),
|
|
15
31
|
], factory_1.NodeFlags.Let));
|
|
32
|
+
/**
|
|
33
|
+
* Builds a `const` statement from a name, an optional type, and an optional
|
|
34
|
+
* value.
|
|
35
|
+
*
|
|
36
|
+
* @evidence contracts/common.md#principled-implementation The declaration list carries the const flag and the given parts.
|
|
37
|
+
* @evidence contracts/common.md#clear-and-simple-design One expression.
|
|
38
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It follows the declaration grammar.
|
|
39
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its inputs.
|
|
40
|
+
*/
|
|
16
41
|
StatementFactory.constant = (props) => factory_1.factory.createVariableStatement(undefined, factory_1.factory.createVariableDeclarationList([
|
|
17
42
|
factory_1.factory.createVariableDeclaration(props.name, undefined, props.type, props.value),
|
|
18
43
|
], factory_1.NodeFlags.Const));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StatementFactory.js","sourceRoot":"","sources":["../../src/factories/StatementFactory.ts"],"names":[],"mappings":";;;AAAA,2CAMuB;AAEvB,+CAA4C;AAE5C
|
|
1
|
+
{"version":3,"file":"StatementFactory.js","sourceRoot":"","sources":["../../src/factories/StatementFactory.ts"],"names":[],"mappings":";;;AAAA,2CAMuB;AAEvB,+CAA4C;AAE5C;;;;;;;GAOG;AACH,IAAiB,gBAAgB,CA8DhC;AA9DD,WAAiB,gBAAgB;IAC/B;;;;;;;;OAQG;IACU,oBAAG,GAAG,CAAC,KAInB,EAAqB,EAAE,CACtB,iBAAO,CAAC,uBAAuB,CAC7B,SAAS,EACT,iBAAO,CAAC,6BAA6B,CACnC;QACE,iBAAO,CAAC,yBAAyB,CAC/B,KAAK,CAAC,IAAI,EACV,SAAS,EACT,KAAK,CAAC,IAAI,KAAK,SAAS;YACtB,CAAC,CAAC,KAAK,CAAC,IAAI;YACZ,CAAC,CAAC,KAAK,CAAC,WAAW,KAAK,SAAS;gBAC/B,CAAC,CAAC,yBAAW,CAAC,OAAO,CAAC,KAAK,CAAC;gBAC5B,CAAC,CAAC,SAAS,EACf,KAAK,CAAC,WAAW,CAClB;KACF,EACD,mBAAS,CAAC,GAAG,CACd,CACF,CAAC;IAEJ;;;;;;;;OAQG;IACU,yBAAQ,GAAG,CAAC,KAIxB,EAAqB,EAAE,CACtB,iBAAO,CAAC,uBAAuB,CAC7B,SAAS,EACT,iBAAO,CAAC,6BAA6B,CACnC;QACE,iBAAO,CAAC,yBAAyB,CAC/B,KAAK,CAAC,IAAI,EACV,SAAS,EACT,KAAK,CAAC,IAAI,EACV,KAAK,CAAC,KAAK,CACZ;KACF,EACD,mBAAS,CAAC,KAAK,CAChB,CACF,CAAC;AACN,CAAC,EA9DgB,gBAAgB,aAAhB,gBAAgB,GAAhB,gBAAgB,QA8DhC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The string formats of the OpenAPI document that the typia `Format` tag
|
|
3
|
+
* validates, so a schema carrying one of them is generated as a `Format` tag
|
|
4
|
+
* and a schema carrying any other format stays a plain `string`.
|
|
5
|
+
*/
|
|
6
|
+
export declare const SUPPORTED_STRING_FORMATS: ReadonlySet<string>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SUPPORTED_STRING_FORMATS = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The string formats of the OpenAPI document that the typia `Format` tag
|
|
6
|
+
* validates, so a schema carrying one of them is generated as a `Format` tag
|
|
7
|
+
* and a schema carrying any other format stays a plain `string`.
|
|
8
|
+
*/
|
|
9
|
+
exports.SUPPORTED_STRING_FORMATS = new Set([
|
|
10
|
+
"byte",
|
|
11
|
+
"password",
|
|
12
|
+
"regex",
|
|
13
|
+
"uuid",
|
|
14
|
+
"email",
|
|
15
|
+
"hostname",
|
|
16
|
+
"idn-email",
|
|
17
|
+
"idn-hostname",
|
|
18
|
+
"iri",
|
|
19
|
+
"iri-reference",
|
|
20
|
+
"ipv4",
|
|
21
|
+
"ipv6",
|
|
22
|
+
"uri",
|
|
23
|
+
"uri-reference",
|
|
24
|
+
"uri-template",
|
|
25
|
+
"url",
|
|
26
|
+
"date-time",
|
|
27
|
+
"date",
|
|
28
|
+
"time",
|
|
29
|
+
"duration",
|
|
30
|
+
"json-pointer",
|
|
31
|
+
"relative-json-pointer",
|
|
32
|
+
]);
|
|
33
|
+
//# sourceMappingURL=SupportedStringFormats.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SupportedStringFormats.js","sourceRoot":"","sources":["../../src/factories/SupportedStringFormats.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACU,QAAA,wBAAwB,GAAwB,IAAI,GAAG,CAAC;IACnE,MAAM;IACN,UAAU;IACV,OAAO;IACP,MAAM;IACN,OAAO;IACP,UAAU;IACV,WAAW;IACX,cAAc;IACd,KAAK;IACL,eAAe;IACf,MAAM;IACN,MAAM;IACN,KAAK;IACL,eAAe;IACf,cAAc;IACd,KAAK;IACL,WAAW;IACX,MAAM;IACN,MAAM;IACN,UAAU;IACV,cAAc;IACd,uBAAuB;CACxB,CAAC,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
//#region src/factories/SupportedStringFormats.ts
|
|
2
|
+
/**
|
|
3
|
+
* The string formats of the OpenAPI document that the typia `Format` tag
|
|
4
|
+
* validates, so a schema carrying one of them is generated as a `Format` tag
|
|
5
|
+
* and a schema carrying any other format stays a plain `string`.
|
|
6
|
+
*/
|
|
7
|
+
const SUPPORTED_STRING_FORMATS = /* @__PURE__ */ new Set([
|
|
8
|
+
"byte",
|
|
9
|
+
"password",
|
|
10
|
+
"regex",
|
|
11
|
+
"uuid",
|
|
12
|
+
"email",
|
|
13
|
+
"hostname",
|
|
14
|
+
"idn-email",
|
|
15
|
+
"idn-hostname",
|
|
16
|
+
"iri",
|
|
17
|
+
"iri-reference",
|
|
18
|
+
"ipv4",
|
|
19
|
+
"ipv6",
|
|
20
|
+
"uri",
|
|
21
|
+
"uri-reference",
|
|
22
|
+
"uri-template",
|
|
23
|
+
"url",
|
|
24
|
+
"date-time",
|
|
25
|
+
"date",
|
|
26
|
+
"time",
|
|
27
|
+
"duration",
|
|
28
|
+
"json-pointer",
|
|
29
|
+
"relative-json-pointer"
|
|
30
|
+
]);
|
|
31
|
+
//#endregion
|
|
32
|
+
export { SUPPORTED_STRING_FORMATS };
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=SupportedStringFormats.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SupportedStringFormats.mjs","names":[],"sources":[],"mappings":""}
|
|
@@ -5,6 +5,11 @@ import { type KeywordTypeNode, SyntaxKind } from "@ttsc/factory";
|
|
|
5
5
|
* Wraps {@link factory.createKeywordTypeNode} with a name-based interface so
|
|
6
6
|
* generator code reads as `TypeFactory.keyword("any")` instead of selecting the
|
|
7
7
|
* `SyntaxKind.AnyKeyword` token by hand.
|
|
8
|
+
*
|
|
9
|
+
* @evidence contracts/common.md#principled-implementation The namespace maps the names of the nine keyword types to their syntax kinds.
|
|
10
|
+
* @evidence contracts/common.md#clear-and-simple-design One table, one type, and one function.
|
|
11
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It only builds nodes.
|
|
12
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
|
|
8
13
|
*/
|
|
9
14
|
export declare namespace TypeFactory {
|
|
10
15
|
const KEYWORDS: {
|
|
@@ -18,7 +23,23 @@ export declare namespace TypeFactory {
|
|
|
18
23
|
readonly never: SyntaxKind.NeverKeyword;
|
|
19
24
|
readonly undefined: SyntaxKind.UndefinedKeyword;
|
|
20
25
|
};
|
|
26
|
+
/**
|
|
27
|
+
* The names of the supported keyword types.
|
|
28
|
+
*
|
|
29
|
+
* @evidence contracts/common.md#principled-implementation The type is the key set of the table that maps names to syntax kinds, so a new keyword is one table entry.
|
|
30
|
+
* @evidence contracts/common.md#clear-and-simple-design One derived type.
|
|
31
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
|
|
32
|
+
* @evidence contracts/common.md#meaningful-documentation The comment names the set.
|
|
33
|
+
*/
|
|
21
34
|
export type Keyword = keyof typeof KEYWORDS;
|
|
35
|
+
/**
|
|
36
|
+
* Builds the keyword type node of a keyword name.
|
|
37
|
+
*
|
|
38
|
+
* @evidence contracts/common.md#principled-implementation The name is looked up in the table, so an unsupported name is a compile error.
|
|
39
|
+
* @evidence contracts/common.md#clear-and-simple-design One lookup.
|
|
40
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It follows the type grammar.
|
|
41
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its input.
|
|
42
|
+
*/
|
|
22
43
|
export const keyword: (type: Keyword) => KeywordTypeNode;
|
|
23
44
|
export {};
|
|
24
45
|
}
|
|
@@ -8,6 +8,11 @@ const factory_1 = require("@ttsc/factory");
|
|
|
8
8
|
* Wraps {@link factory.createKeywordTypeNode} with a name-based interface so
|
|
9
9
|
* generator code reads as `TypeFactory.keyword("any")` instead of selecting the
|
|
10
10
|
* `SyntaxKind.AnyKeyword` token by hand.
|
|
11
|
+
*
|
|
12
|
+
* @evidence contracts/common.md#principled-implementation The namespace maps the names of the nine keyword types to their syntax kinds.
|
|
13
|
+
* @evidence contracts/common.md#clear-and-simple-design One table, one type, and one function.
|
|
14
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It only builds nodes.
|
|
15
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
|
|
11
16
|
*/
|
|
12
17
|
var TypeFactory;
|
|
13
18
|
(function (TypeFactory) {
|
|
@@ -22,6 +27,14 @@ var TypeFactory;
|
|
|
22
27
|
never: factory_1.SyntaxKind.NeverKeyword,
|
|
23
28
|
undefined: factory_1.SyntaxKind.UndefinedKeyword,
|
|
24
29
|
};
|
|
30
|
+
/**
|
|
31
|
+
* Builds the keyword type node of a keyword name.
|
|
32
|
+
*
|
|
33
|
+
* @evidence contracts/common.md#principled-implementation The name is looked up in the table, so an unsupported name is a compile error.
|
|
34
|
+
* @evidence contracts/common.md#clear-and-simple-design One lookup.
|
|
35
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It follows the type grammar.
|
|
36
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its input.
|
|
37
|
+
*/
|
|
25
38
|
TypeFactory.keyword = (type) => factory_1.factory.createKeywordTypeNode(KEYWORDS[type]);
|
|
26
39
|
})(TypeFactory || (exports.TypeFactory = TypeFactory = {}));
|
|
27
40
|
//# sourceMappingURL=TypeFactory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeFactory.js","sourceRoot":"","sources":["../../src/factories/TypeFactory.ts"],"names":[],"mappings":";;;AAAA,2CAA0E;AAE1E
|
|
1
|
+
{"version":3,"file":"TypeFactory.js","sourceRoot":"","sources":["../../src/factories/TypeFactory.ts"],"names":[],"mappings":";;;AAAA,2CAA0E;AAE1E;;;;;;;;;;;GAWG;AACH,IAAiB,WAAW,CAiC3B;AAjCD,WAAiB,WAAW;IAC1B,MAAM,QAAQ,GAAG;QACf,IAAI,EAAE,oBAAU,CAAC,WAAW;QAC5B,GAAG,EAAE,oBAAU,CAAC,UAAU;QAC1B,OAAO,EAAE,oBAAU,CAAC,cAAc;QAClC,OAAO,EAAE,oBAAU,CAAC,cAAc;QAClC,MAAM,EAAE,oBAAU,CAAC,aAAa;QAChC,MAAM,EAAE,oBAAU,CAAC,aAAa;QAChC,MAAM,EAAE,oBAAU,CAAC,aAAa;QAChC,KAAK,EAAE,oBAAU,CAAC,YAAY;QAC9B,SAAS,EAAE,oBAAU,CAAC,gBAAgB;KAC9B,CAAC;IAYX;;;;;;;OAOG;IACU,mBAAO,GAAG,CAAC,IAAa,EAAmB,EAAE,CACxD,iBAAO,CAAC,qBAAqB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;AAClD,CAAC,EAjCgB,WAAW,aAAX,WAAW,GAAX,WAAW,QAiC3B"}
|
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
import ts from "../internal/ts";
|
|
2
|
+
/**
|
|
3
|
+
* Builds type nodes from JavaScript values, so a value can be written as a
|
|
4
|
+
* literal type.
|
|
5
|
+
*
|
|
6
|
+
* @evidence contracts/common.md#principled-implementation The namespace maps booleans, numbers, strings, null, arrays as tuples, and objects as type literals, and anything else to `any`.
|
|
7
|
+
* @evidence contracts/common.md#clear-and-simple-design One entry function and small private builders per kind.
|
|
8
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The mapping is by type, with no value special-cased.
|
|
9
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
|
|
10
|
+
*/
|
|
2
11
|
export declare namespace TypeLiteralFactory {
|
|
12
|
+
/**
|
|
13
|
+
* Builds the literal type of a value: a literal for a primitive, a tuple for
|
|
14
|
+
* an array, a type literal for an object, and `any` for other values.
|
|
15
|
+
*
|
|
16
|
+
* @evidence contracts/common.md#principled-implementation The value is dispatched by type, negative numbers use a prefix minus as expressions do, and object keys that are not identifiers are quoted.
|
|
17
|
+
* @evidence contracts/common.md#clear-and-simple-design One function with one branch per kind.
|
|
18
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The dispatch is general.
|
|
19
|
+
* @evidence contracts/common.md#meaningful-documentation The comment lists the mapping.
|
|
20
|
+
*/
|
|
3
21
|
const generate: (value: any) => ts.TypeNode;
|
|
4
22
|
}
|