@nestia/migrate 14.0.1 → 14.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/lib/NestiaMigrateApplication.d.ts +111 -0
  2. package/lib/NestiaMigrateApplication.js +148 -9
  3. package/lib/NestiaMigrateApplication.js.map +1 -1
  4. package/lib/NestiaMigrateApplication.mjs +147 -5
  5. package/lib/_virtual/_rolldown/runtime.mjs +6 -1
  6. package/lib/analyzers/NestiaMigrateControllerAnalyzer.d.ts +45 -0
  7. package/lib/analyzers/NestiaMigrateControllerAnalyzer.js +59 -3
  8. package/lib/analyzers/NestiaMigrateControllerAnalyzer.js.map +1 -1
  9. package/lib/analyzers/NestiaMigrateControllerAnalyzer.mjs +9 -3
  10. package/lib/archivers/NestiaMigrateFileArchiver.d.ts +34 -0
  11. package/lib/archivers/NestiaMigrateFileArchiver.js +34 -0
  12. package/lib/archivers/NestiaMigrateFileArchiver.js.map +1 -1
  13. package/lib/bundles/NEST_TEMPLATE.js +1 -1
  14. package/lib/bundles/NEST_TEMPLATE.mjs +1 -1
  15. package/lib/bundles/SDK_TEMPLATE.js +1 -1
  16. package/lib/bundles/SDK_TEMPLATE.mjs +1 -1
  17. package/lib/executable/NestiaMigrateCommander.d.ts +39 -1
  18. package/lib/executable/NestiaMigrateCommander.js +42 -2
  19. package/lib/executable/NestiaMigrateCommander.js.map +1 -1
  20. package/lib/executable/NestiaMigrateCommander.mjs +5 -3
  21. package/lib/executable/NestiaMigrateInquirer.d.ts +32 -1
  22. package/lib/executable/NestiaMigrateInquirer.js +33 -10
  23. package/lib/executable/NestiaMigrateInquirer.js.map +1 -1
  24. package/lib/executable/NestiaMigrateInquirer.mjs +4 -3
  25. package/lib/executable/TemplateBundleCache.d.ts +23 -0
  26. package/lib/executable/TemplateBundleCache.js +60 -0
  27. package/lib/executable/TemplateBundleCache.js.map +1 -0
  28. package/lib/executable/TemplateBundleCache.mjs +39 -0
  29. package/lib/executable/TemplateBundleCache.mjs.map +1 -0
  30. package/lib/executable/bundle.d.ts +1 -0
  31. package/lib/executable/bundle.js +404 -0
  32. package/lib/executable/bundle.js.map +1 -0
  33. package/lib/executable/bundle.mjs +324 -0
  34. package/lib/executable/bundle.mjs.map +1 -0
  35. package/lib/factories/ExpressionFactory.d.ts +14 -0
  36. package/lib/factories/ExpressionFactory.js +14 -0
  37. package/lib/factories/ExpressionFactory.js.map +1 -1
  38. package/lib/factories/IdentifierFactory.d.ts +20 -0
  39. package/lib/factories/IdentifierFactory.js +20 -0
  40. package/lib/factories/IdentifierFactory.js.map +1 -1
  41. package/lib/factories/LiteralFactory.d.ts +18 -2
  42. package/lib/factories/LiteralFactory.js +18 -2
  43. package/lib/factories/LiteralFactory.js.map +1 -1
  44. package/lib/factories/StatementFactory.d.ts +26 -1
  45. package/lib/factories/StatementFactory.js +26 -1
  46. package/lib/factories/StatementFactory.js.map +1 -1
  47. package/lib/factories/SupportedStringFormats.d.ts +6 -0
  48. package/lib/factories/SupportedStringFormats.js +33 -0
  49. package/lib/factories/SupportedStringFormats.js.map +1 -0
  50. package/lib/factories/SupportedStringFormats.mjs +34 -0
  51. package/lib/factories/SupportedStringFormats.mjs.map +1 -0
  52. package/lib/factories/TypeFactory.d.ts +21 -0
  53. package/lib/factories/TypeFactory.js +13 -0
  54. package/lib/factories/TypeFactory.js.map +1 -1
  55. package/lib/factories/TypeLiteralFactory.d.ts +18 -0
  56. package/lib/factories/TypeLiteralFactory.js +18 -0
  57. package/lib/factories/TypeLiteralFactory.js.map +1 -1
  58. package/lib/internal/ts.d.ts +153 -0
  59. package/lib/internal/ts.js.map +1 -1
  60. package/lib/package.mjs +55 -0
  61. package/lib/package.mjs.map +1 -0
  62. package/lib/programmers/NestiaMigrateApiFileProgrammer.d.ts +31 -0
  63. package/lib/programmers/NestiaMigrateApiFileProgrammer.js +17 -0
  64. package/lib/programmers/NestiaMigrateApiFileProgrammer.js.map +1 -1
  65. package/lib/programmers/NestiaMigrateApiFunctionProgrammer.d.ts +40 -0
  66. package/lib/programmers/NestiaMigrateApiFunctionProgrammer.js +27 -0
  67. package/lib/programmers/NestiaMigrateApiFunctionProgrammer.js.map +1 -1
  68. package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.d.ts +39 -0
  69. package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.js +26 -0
  70. package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.js.map +1 -1
  71. package/lib/programmers/NestiaMigrateApiProgrammer.d.ts +18 -0
  72. package/lib/programmers/NestiaMigrateApiProgrammer.js +18 -0
  73. package/lib/programmers/NestiaMigrateApiProgrammer.js.map +1 -1
  74. package/lib/programmers/NestiaMigrateApiProgrammer.mjs +1 -1
  75. package/lib/programmers/NestiaMigrateApiSimulationProgrammer.d.ts +40 -0
  76. package/lib/programmers/NestiaMigrateApiSimulationProgrammer.js +27 -0
  77. package/lib/programmers/NestiaMigrateApiSimulationProgrammer.js.map +1 -1
  78. package/lib/programmers/NestiaMigrateApiStartProgrammer.d.ts +17 -0
  79. package/lib/programmers/NestiaMigrateApiStartProgrammer.js +19 -8
  80. package/lib/programmers/NestiaMigrateApiStartProgrammer.js.map +1 -1
  81. package/lib/programmers/NestiaMigrateApiStartProgrammer.mjs +1 -6
  82. package/lib/programmers/NestiaMigrateDtoProgrammer.d.ts +30 -0
  83. package/lib/programmers/NestiaMigrateDtoProgrammer.js +17 -0
  84. package/lib/programmers/NestiaMigrateDtoProgrammer.js.map +1 -1
  85. package/lib/programmers/NestiaMigrateE2eFileProgrammer.d.ts +39 -0
  86. package/lib/programmers/NestiaMigrateE2eFileProgrammer.js +26 -0
  87. package/lib/programmers/NestiaMigrateE2eFileProgrammer.js.map +1 -1
  88. package/lib/programmers/NestiaMigrateE2eProgrammer.d.ts +16 -0
  89. package/lib/programmers/NestiaMigrateE2eProgrammer.js +16 -0
  90. package/lib/programmers/NestiaMigrateE2eProgrammer.js.map +1 -1
  91. package/lib/programmers/NestiaMigrateImportProgrammer.d.ts +75 -0
  92. package/lib/programmers/NestiaMigrateImportProgrammer.js +58 -3
  93. package/lib/programmers/NestiaMigrateImportProgrammer.js.map +1 -1
  94. package/lib/programmers/NestiaMigrateImportProgrammer.mjs +58 -3
  95. package/lib/programmers/NestiaMigrateNestControllerProgrammer.d.ts +28 -0
  96. package/lib/programmers/NestiaMigrateNestControllerProgrammer.js +16 -0
  97. package/lib/programmers/NestiaMigrateNestControllerProgrammer.js.map +1 -1
  98. package/lib/programmers/NestiaMigrateNestMethodProgrammer.d.ts +30 -0
  99. package/lib/programmers/NestiaMigrateNestMethodProgrammer.js +16 -0
  100. package/lib/programmers/NestiaMigrateNestMethodProgrammer.js.map +1 -1
  101. package/lib/programmers/NestiaMigrateNestModuleProgrammer.d.ts +16 -0
  102. package/lib/programmers/NestiaMigrateNestModuleProgrammer.js +16 -0
  103. package/lib/programmers/NestiaMigrateNestModuleProgrammer.js.map +1 -1
  104. package/lib/programmers/NestiaMigrateNestProgrammer.d.ts +17 -0
  105. package/lib/programmers/NestiaMigrateNestProgrammer.js +17 -0
  106. package/lib/programmers/NestiaMigrateNestProgrammer.js.map +1 -1
  107. package/lib/programmers/NestiaMigrateSchemaProgrammer.d.ts +16 -0
  108. package/lib/programmers/NestiaMigrateSchemaProgrammer.js +20 -5
  109. package/lib/programmers/NestiaMigrateSchemaProgrammer.js.map +1 -1
  110. package/lib/programmers/NestiaMigrateSchemaProgrammer.mjs +4 -4
  111. package/lib/structures/INestiaMigrateConfig.d.ts +21 -0
  112. package/lib/structures/INestiaMigrateContext.d.ts +15 -0
  113. package/lib/structures/INestiaMigrateController.d.ts +13 -0
  114. package/lib/structures/INestiaMigrateFile.d.ts +11 -0
  115. package/lib/utils/FilePrinter.d.ts +33 -0
  116. package/lib/utils/FilePrinter.js +33 -0
  117. package/lib/utils/FilePrinter.js.map +1 -1
  118. package/lib/utils/MapUtil.d.ts +17 -0
  119. package/lib/utils/MapUtil.js +19 -3
  120. package/lib/utils/MapUtil.js.map +1 -1
  121. package/lib/utils/MapUtil.mjs +1 -2
  122. package/lib/utils/PathTemplate.d.ts +23 -1
  123. package/lib/utils/PathTemplate.js +15 -1
  124. package/lib/utils/PathTemplate.js.map +1 -1
  125. package/lib/utils/RequestBody.d.ts +13 -0
  126. package/lib/utils/RequestBody.js +13 -0
  127. package/lib/utils/RequestBody.js.map +1 -1
  128. package/lib/utils/StringUtil.d.ts +55 -0
  129. package/lib/utils/StringUtil.js +93 -8
  130. package/lib/utils/StringUtil.js.map +1 -1
  131. package/lib/utils/StringUtil.mjs +30 -8
  132. package/lib/utils/SuccessStatus.d.ts +21 -1
  133. package/lib/utils/SuccessStatus.js +21 -1
  134. package/lib/utils/SuccessStatus.js.map +1 -1
  135. package/package.json +5 -4
  136. package/src/NestiaMigrateApplication.ts +151 -13
  137. package/src/analyzers/NestiaMigrateControllerAnalyzer.ts +59 -4
  138. package/src/archivers/NestiaMigrateFileArchiver.ts +34 -0
  139. package/src/bundles/NEST_TEMPLATE.ts +1 -1
  140. package/src/bundles/SDK_TEMPLATE.ts +1 -1
  141. package/src/executable/NestiaMigrateCommander.ts +44 -2
  142. package/src/executable/NestiaMigrateInquirer.ts +35 -3
  143. package/src/executable/TemplateBundleCache.ts +65 -0
  144. package/src/executable/{bundle.js → bundle.ts} +110 -43
  145. package/src/factories/ExpressionFactory.ts +14 -0
  146. package/src/factories/IdentifierFactory.ts +20 -0
  147. package/src/factories/LiteralFactory.ts +18 -2
  148. package/src/factories/StatementFactory.ts +26 -1
  149. package/src/factories/SupportedStringFormats.ts +29 -0
  150. package/src/factories/TypeFactory.ts +21 -0
  151. package/src/factories/TypeLiteralFactory.ts +18 -0
  152. package/src/internal/ts.ts +153 -0
  153. package/src/programmers/NestiaMigrateApiFileProgrammer.ts +35 -0
  154. package/src/programmers/NestiaMigrateApiFunctionProgrammer.ts +43 -0
  155. package/src/programmers/NestiaMigrateApiNamespaceProgrammer.ts +42 -0
  156. package/src/programmers/NestiaMigrateApiProgrammer.ts +18 -0
  157. package/src/programmers/NestiaMigrateApiSimulationProgrammer.ts +43 -0
  158. package/src/programmers/NestiaMigrateApiStartProgrammer.ts +19 -10
  159. package/src/programmers/NestiaMigrateDtoProgrammer.ts +33 -0
  160. package/src/programmers/NestiaMigrateE2eFileProgrammer.ts +42 -0
  161. package/src/programmers/NestiaMigrateE2eProgrammer.ts +16 -0
  162. package/src/programmers/NestiaMigrateImportProgrammer.ts +86 -5
  163. package/src/programmers/NestiaMigrateNestControllerProgrammer.ts +30 -0
  164. package/src/programmers/NestiaMigrateNestMethodProgrammer.ts +34 -0
  165. package/src/programmers/NestiaMigrateNestModuleProgrammer.ts +16 -0
  166. package/src/programmers/NestiaMigrateNestProgrammer.ts +17 -0
  167. package/src/programmers/NestiaMigrateSchemaProgrammer.ts +25 -8
  168. package/src/structures/INestiaMigrateConfig.ts +26 -0
  169. package/src/structures/INestiaMigrateContext.ts +17 -0
  170. package/src/structures/INestiaMigrateController.ts +16 -0
  171. package/src/structures/INestiaMigrateFile.ts +13 -0
  172. package/src/utils/FilePrinter.ts +33 -0
  173. package/src/utils/MapUtil.ts +18 -2
  174. package/src/utils/PathTemplate.ts +23 -1
  175. package/src/utils/RequestBody.ts +13 -0
  176. package/src/utils/StringUtil.ts +101 -9
  177. package/src/utils/SuccessStatus.ts +21 -1
  178. package/lib/factories/FormatCheatSheet.d.ts +0 -25
  179. package/lib/factories/FormatCheatSheet.js +0 -34
  180. package/lib/factories/FormatCheatSheet.js.map +0 -1
  181. package/lib/factories/FormatCheatSheet.mjs +0 -31
  182. package/lib/factories/FormatCheatSheet.mjs.map +0 -1
  183. package/src/factories/FormatCheatSheet.ts +0 -71
@@ -0,0 +1,324 @@
1
+ import { __require } from "../_virtual/_rolldown/runtime.mjs";
2
+ import { run } from "./TemplateBundleCache.mjs";
3
+ import { require_package } from "../package.mjs";
4
+ import fs from "node:fs";
5
+ import cp from "node:child_process";
6
+ //#region src/executable/bundle.ts
7
+ const { version } = require_package();
8
+ const ROOT = `${__dirname}/../..`;
9
+ const ASSETS = `${ROOT}/assets`;
10
+ const CATALOGS = __require("js-yaml").load(fs.readFileSync(`${__dirname}/../../../../pnpm-lock.yaml`, "utf8")).catalogs;
11
+ const TYPIA = CATALOGS.samchon;
12
+ const TYPESCRIPT = CATALOGS.typescript ?? {};
13
+ const update = (content, options = {}) => {
14
+ const parsed = JSON.parse(content);
15
+ for (const record of [parsed.dependencies ?? {}, parsed.devDependencies ?? {}]) for (const key of Object.keys(record)) {
16
+ const current = record[key];
17
+ if (typeof current === "string" && (current.startsWith("catalog:") || current.startsWith("workspace:"))) continue;
18
+ if (key.startsWith("@nestia/") || key === "nestia") record[key] = `^${version}`;
19
+ else {
20
+ const catalog = TYPIA[key] ?? TYPESCRIPT[key];
21
+ if (catalog) record[key] = catalog.specifier;
22
+ }
23
+ }
24
+ migratePackageJson(parsed);
25
+ if (options.sdkAggregate) {
26
+ parsed.devDependencies ??= {};
27
+ parsed.devDependencies["@nestia/core"] = `^${version}`;
28
+ }
29
+ return JSON.stringify(parsed, null, 2);
30
+ };
31
+ const migratePackageJson = (parsed) => {
32
+ if (parsed.scripts) {
33
+ for (const [key, value] of Object.entries(parsed.scripts)) if (typeof value === "string") parsed.scripts[key] = normalizeScript(value);
34
+ }
35
+ const devDependencies = parsed.devDependencies;
36
+ if (devDependencies) {
37
+ const usesTypeScript = typeof devDependencies.typescript === "string" && devDependencies.typescript.startsWith("catalog:") === false;
38
+ delete devDependencies["typescript-transform-paths"];
39
+ if (usesTypeScript && TYPESCRIPT.ttsc) devDependencies.ttsc ??= TYPESCRIPT.ttsc.specifier;
40
+ }
41
+ };
42
+ const updateWorkspaceCatalog = (content) => {
43
+ const replace = (line) => {
44
+ const match = line.match(/^(\s+(?:"([^"]+)"|'([^']+)'|([^:\s]+)): (?:&[A-Za-z0-9_-]+ )?)\S[^\r\n]*(\r?)$/);
45
+ if (match === null) return line;
46
+ const name = match[2] ?? match[3] ?? match[4];
47
+ const specifier = name === "nestia" || name.startsWith("@nestia/") ? `^${version}` : TYPIA[name]?.specifier ?? TYPESCRIPT[name]?.specifier;
48
+ if (typeof specifier !== "string") return line;
49
+ return `${match[1]}${specifier}${match[5]}`;
50
+ };
51
+ return content.split("\n").map(replace).join("\n");
52
+ };
53
+ const trimTemplateDependencies = (parsed) => {
54
+ if (parsed.dependencies) {
55
+ delete parsed.dependencies.commander;
56
+ delete parsed.dependencies.inquirer;
57
+ }
58
+ if (parsed.devDependencies) {
59
+ delete parsed.devDependencies["@types/inquirer"];
60
+ delete parsed.devDependencies.commander;
61
+ delete parsed.devDependencies.inquirer;
62
+ }
63
+ };
64
+ const normalizeScript = (script) => script.replace(/(^|[^A-Za-z0-9_-])tsc(?=$|[^A-Za-z0-9_-])/g, "$1ttsc");
65
+ const ARGUMENT_PARSER = `import { createInterface } from "node:readline/promises";
66
+
67
+ export namespace ArgumentParser {
68
+ export interface Command {
69
+ option: (flags: string, description?: string) => Command;
70
+ }
71
+
72
+ export interface Prompt {
73
+ select: (
74
+ name: string,
75
+ ) => (
76
+ message: string,
77
+ ) => <Choice extends string>(choices: Choice[]) => Promise<Choice>;
78
+ boolean: (name: string) => (message: string) => Promise<boolean>;
79
+ number: (name: string) => (message: string) => Promise<number>;
80
+ }
81
+
82
+ export const parse = async <T>(
83
+ inquiry: (
84
+ command: Command,
85
+ prompt: Prompt,
86
+ action: (closure: (options: Partial<T>) => Promise<T>) => Promise<T>,
87
+ ) => Promise<T>,
88
+ ): Promise<T> => {
89
+ const command: Command = {
90
+ option: (_flags: string, _description?: string): Command => command,
91
+ };
92
+ const action = (closure: (options: Partial<T>) => Promise<T>) =>
93
+ closure(parseArguments() as Partial<T>);
94
+ return inquiry(
95
+ command,
96
+ { select, boolean, number },
97
+ action,
98
+ );
99
+ };
100
+
101
+ const select =
102
+ (_name: string) =>
103
+ (message: string) =>
104
+ async <Choice extends string>(choices: Choice[]): Promise<Choice> => {
105
+ const answer: string = await ask(\`\${message} (\${choices.join("/")})\`);
106
+ return (choices.find((choice) => choice === answer) ?? choices[0])!;
107
+ };
108
+
109
+ const boolean = (_name: string) => async (message: string) =>
110
+ /^(true|t|yes|y|1)$/i.test(await ask(\`\${message} [y/N]\`));
111
+
112
+ const number = (_name: string) => async (message: string) =>
113
+ Number(await ask(message));
114
+
115
+ const ask = async (message: string): Promise<string> => {
116
+ const reader = createInterface({
117
+ input: process.stdin,
118
+ output: process.stdout,
119
+ });
120
+ try {
121
+ return (await reader.question(\`\${message}: \`)).trim();
122
+ } finally {
123
+ reader.close();
124
+ }
125
+ };
126
+
127
+ const parseArguments = (): Record<string, string | string[] | boolean> => {
128
+ const output: Record<string, string | string[] | boolean> = {};
129
+ const args: string[] = process.argv.slice(2);
130
+ for (let i = 0; i < args.length; ++i) {
131
+ const raw: string = args[i]!;
132
+ if (raw.startsWith("--") === false) continue;
133
+
134
+ const equal: number = raw.indexOf("=");
135
+ const name: string = toCamelCase(
136
+ raw.slice(2, equal === -1 ? undefined : equal),
137
+ );
138
+ if (equal !== -1) {
139
+ assign(output, name, raw.slice(equal + 1));
140
+ continue;
141
+ }
142
+
143
+ const values: string[] = [];
144
+ while (i + 1 < args.length && args[i + 1]!.startsWith("--") === false)
145
+ values.push(args[++i]!);
146
+ assign(
147
+ output,
148
+ name,
149
+ values.length === 0 ? true : values.length === 1 ? values[0]! : values,
150
+ );
151
+ }
152
+ return output;
153
+ };
154
+
155
+ const assign = (
156
+ output: Record<string, string | string[] | boolean>,
157
+ name: string,
158
+ value: string | string[] | boolean,
159
+ ): void => {
160
+ const current: string | string[] | boolean | undefined = output[name];
161
+ if (current === undefined) output[name] = value;
162
+ else
163
+ output[name] = [
164
+ ...(Array.isArray(current) ? current : [String(current)]),
165
+ ...(Array.isArray(value) ? value : [String(value)]),
166
+ ];
167
+ };
168
+
169
+ const toCamelCase = (str: string): string =>
170
+ str.replace(/-([a-z])/g, (_matched, letter: string) =>
171
+ letter.toUpperCase(),
172
+ );
173
+ }
174
+ `;
175
+ const updateTsConfig = (content) => {
176
+ content = content.replace(/^\s*\{\s*"transform":\s*"typescript-transform-paths"\s*\},\r?\n/gm, "");
177
+ content = content.replace(/^\s*\{\s*"transform":\s*"typia\/lib\/transform"(?:,\s*"enabled":\s*false)?\s*\},?\r?\n/gm, "");
178
+ content = content.replace(/^\s*\{\s*"transform":\s*"@nestia\/core\/lib\/transform"\s*\},?\r?\n/gm, "");
179
+ content = content.replace(/^\s*\{\s*"transform":\s*"@nestia\/core\/native\/transform\.cjs"\s*\},?\r?\n/gm, "");
180
+ content = content.replace(/^\s*\{\s*"transform":\s*"@nestia\/sdk\/lib\/transform"\s*\},\r?\n/gm, "");
181
+ return content;
182
+ };
183
+ const bundle = async ({ mode, repository, revision, exceptions, transform }) => {
184
+ const template = `${`${`${__dirname}/../..`}/assets`}/${mode}`;
185
+ const clone = async () => {
186
+ if (fs.existsSync(template)) await fs.promises.rm(template, { recursive: true });
187
+ else try {
188
+ await fs.promises.mkdir(ASSETS);
189
+ } catch {}
190
+ await fs.promises.mkdir(template, { recursive: true });
191
+ cp.execFileSync("git", ["init", "--quiet"], { cwd: template });
192
+ cp.execFileSync("git", [
193
+ "fetch",
194
+ "--quiet",
195
+ "--depth=1",
196
+ "--no-auto-maintenance",
197
+ `https://github.com/samchon/${repository}`,
198
+ revision
199
+ ], { cwd: template });
200
+ cp.execFileSync("git", [
201
+ "-c",
202
+ "core.autocrlf=false",
203
+ "checkout",
204
+ "--quiet",
205
+ "--detach",
206
+ revision
207
+ ], {
208
+ cwd: template,
209
+ stdio: "pipe"
210
+ });
211
+ for (const location of exceptions ?? []) await fs.promises.rm(`${template}/${location}`, { recursive: true });
212
+ };
213
+ const iterate = (collection) => async (location) => {
214
+ const directory = await fs.promises.readdir(location);
215
+ for (const file of directory) {
216
+ const absolute = location + "/" + file;
217
+ if ((await fs.promises.stat(absolute)).isDirectory()) await iterate(collection)(absolute);
218
+ else {
219
+ const content = await fs.promises.readFile(absolute, "utf-8");
220
+ collection[(() => {
221
+ const str = absolute.replace(template, "");
222
+ return str[0] === "/" ? str.substring(1) : str;
223
+ })()] = content;
224
+ }
225
+ }
226
+ };
227
+ const archive = async (collection) => {
228
+ const name = `${mode.toUpperCase()}_TEMPLATE`;
229
+ const content = `export const ${name}: Record<string, string> = ${JSON.stringify(collection, null, 2)}`;
230
+ try {
231
+ await fs.promises.mkdir(`${ROOT}/src/bundles`);
232
+ } catch {}
233
+ await fs.promises.writeFile(`${ROOT}/src/bundles/${name}.ts`, content, "utf8");
234
+ };
235
+ const collection = {};
236
+ await clone();
237
+ await iterate(collection)(template);
238
+ if (transform) for (const [key, value] of Object.entries(collection)) collection[key] = await writeTransformedAsset(template, key, transform(key, value));
239
+ await archive(collection);
240
+ };
241
+ const writeTransformedAsset = async (template, key, value) => {
242
+ await fs.promises.writeFile(`${template}/${key}`, value, "utf8");
243
+ return value;
244
+ };
245
+ /**
246
+ * Generates both pinned templates using the current release and catalog stamps.
247
+ *
248
+ * The complete script is a cache input because it contains the revisions,
249
+ * exclusions and every transformation rule. A hit still verifies output bytes.
250
+ */
251
+ const generate = async () => {
252
+ await bundle({
253
+ mode: "nest",
254
+ repository: "nestia-start",
255
+ revision: "8188661cb1c1b0fb30e6184b06422764d64a5f68",
256
+ exceptions: [
257
+ ".git",
258
+ ".github/dependabot.yml",
259
+ ".github/workflows/dependabot-automerge.yml",
260
+ "pnpm-lock.yaml",
261
+ "packages/api/src/functional",
262
+ "packages/api/src/structures",
263
+ "packages/backend/src/MyModule.ts",
264
+ "packages/backend/src/controllers",
265
+ "packages/backend/src/providers",
266
+ "packages/backend/test/features"
267
+ ],
268
+ transform: (key, value) => {
269
+ if (key.endsWith("package.json")) {
270
+ const parsed = JSON.parse(update(value));
271
+ trimTemplateDependencies(parsed);
272
+ return JSON.stringify(parsed, null, 2);
273
+ }
274
+ if (key === "pnpm-workspace.yaml") return updateWorkspaceCatalog(value);
275
+ if (key === "packages/backend/test/helpers/ArgumentParser.ts") return ARGUMENT_PARSER;
276
+ if (key.endsWith("tsconfig.json")) return updateTsConfig(value);
277
+ return value;
278
+ }
279
+ });
280
+ await bundle({
281
+ mode: "sdk",
282
+ repository: "nestia-sdk-template",
283
+ revision: "37a019e2b8dea3d02237137aaec2f242f53dcd2d",
284
+ exceptions: [
285
+ ".git",
286
+ ".github/dependabot.yml",
287
+ ".github/workflows/build.yml",
288
+ ".github/workflows/dependabot-automerge.yml",
289
+ "pnpm-lock.yaml",
290
+ "src/functional",
291
+ "src/structures",
292
+ "test/features"
293
+ ],
294
+ transform: (key, value) => {
295
+ if (key.endsWith("package.json")) {
296
+ const parsed = JSON.parse(update(value, { sdkAggregate: key === "package.json" }));
297
+ trimTemplateDependencies(parsed);
298
+ return JSON.stringify(parsed, null, 2);
299
+ }
300
+ if (key === "test/utils/ArgumentParser.ts") return ARGUMENT_PARSER;
301
+ if (key.endsWith("tsconfig.json")) return updateTsConfig(value);
302
+ return value;
303
+ }
304
+ });
305
+ };
306
+ const main = async () => {
307
+ if (await run({
308
+ inputs: [
309
+ version,
310
+ CATALOGS,
311
+ fs.readFileSync(__filename, "utf8")
312
+ ],
313
+ outputs: ["NEST_TEMPLATE", "SDK_TEMPLATE"].map((name) => `${ROOT}/src/bundles/${name}.ts`),
314
+ stampFile: `${ASSETS}/.bundle-cache.json`,
315
+ generate
316
+ })) console.log("Reuse verified migration template bundles.");
317
+ };
318
+ main().catch((exp) => {
319
+ console.error(exp);
320
+ process.exit(-1);
321
+ });
322
+ //#endregion
323
+
324
+ //# sourceMappingURL=bundle.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundle.mjs","names":[],"sources":[],"mappings":""}
@@ -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;;;;GAIG;AACH,IAAiB,iBAAiB,CAUjC;AAVD,WAAiB,iBAAiB;IACnB,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,EAVgB,iBAAiB,aAAjB,iBAAiB,GAAjB,iBAAiB,QAUjC"}
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;;;GAGG;AACH,IAAiB,iBAAiB,CA6DjC;AA7DD,WAAiB,iBAAiB;IAChC;;;OAGG;IACU,4BAAU,GAAG,CAAC,IAAY,EAA8B,EAAE,CACrE,cAAc,CAAC,IAAI,CAAC;QAClB,CAAC,CAAC,iBAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC;QAChC,CAAC,CAAC,iBAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAExC;;;OAGG;IACU,wBAAM,GAAG,CACpB,KAAiB,EACjB,GAAW,EAC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AAC;IAEF;;;;;;;;OAQG;IACU,2BAAS,GAAG,CACvB,IAAyB,EACzB,IAAe,EACf,IAAyB,EACH,EAAE;QACxB,MAAM,eAAe,GACnB,CAAC,CAAC,IAAI;YACN,IAAI,CAAC,IAAI,KAAK,OAAO;YACpB,IAAc,CAAC,KAAK,KAAK,oBAAU,CAAC,aAAa,CAAC;QACrD,OAAO,iBAAO,CAAC,0BAA0B,CACvC,SAAS,EACT,SAAS,EACT,IAAI,EACJ,eAAe;YACb,CAAC,CAAC,iBAAO,CAAC,WAAW,CAAC,oBAAU,CAAC,aAAa,CAAC;YAC/C,CAAC,CAAC,SAAS,EACb,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,yBAAW,CAAC,OAAO,CAAC,KAAK,CAAC,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 (so callers can mix factory output with raw JS values inside the
5
- * same object/array), and emits the appropriate literal node otherwise.
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 (so callers can mix factory output with raw JS values inside the
18
- * same object/array), and emits the appropriate literal node otherwise.
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;;;;GAIG;AACH,IAAiB,cAAc,CAgC9B;AAhCD,WAAiB,cAAc;IAChB,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,KAAK,CAAC;YAAE,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC;QACnD,IAAI,OAAO,KAAK,KAAK,QAAQ;YAAE,OAAO,WAAW,CAAC,KAAe,CAAC,CAAC;QACnE,IAAI,OAAO,KAAK,KAAK,SAAS;YAC5B,OAAO,KAAK,CAAC,CAAC,CAAC,iBAAO,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,iBAAO,CAAC,WAAW,EAAE,C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C7B,OAAO,iBAAO,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC;QAC/C,MAAM,IAAI,SAAS,CAAC,+CAA+C,CAAC,CAAC;IACvE,CAAC,CAAC;IAEF,MAAM,WAAW,GAAG,CAAC,GAAW,EAAc,EAAE,CAC9C,iBAAO,CAAC,6BAA6B,CACnC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC;SAChB,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC;SAC1C,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CACpB,iBAAO,CAAC,wBAAwB,CAC9B,qCAAiB,CAAC,UAAU,CAAC,GAAG,CAAC,EACjC,oBAAK,CAAC,KAAK,CAAC,CACb,CACF,EACH,IAAI,CACL,CAAC;IAEJ,MAAM,UAAU,GAAG,CAAC,KAAqB,EAAc,EAAE,CACvD,iBAAO,CAAC,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
- /** Variable-statement helpers. `constant` emits `const`, `mut` emits `let`. */
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
- /** Variable-statement helpers. `constant` emits `const`, `mut` emits `let`. */
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,+EAA+E;AAC/E,IAAiB,gBAAgB,CA4ChC;AA5CD,WAAiB,gBAAgB;IAClB,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;IAES,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,EA5CgB,gBAAgB,aAAhB,gBAAgB,GAAhB,gBAAgB,QA4ChC"}
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>;