@valkyrjaio/sindri 26.2.0 → 26.4.0
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/dist/bin/sindri.cjs +820 -212
- package/package.json +2 -2
- package/src/Sindri/Ast/Abstract/AstReader.ts +250 -29
- package/src/Sindri/Ast/ComponentProviderReader.ts +9 -5
- package/src/Sindri/Ast/ConfigReader.ts +14 -6
- package/src/Sindri/Ast/Data/Result/RouteProviderResult.ts +7 -0
- package/src/Sindri/Ast/RouteProviderReader.ts +55 -4
- package/src/Sindri/Constant/SindriInfo.ts +2 -2
- package/src/Sindri/Generate/Abstract/GenerateDataFromAst.ts +218 -13
- package/src/Sindri/Generator/Abstract/AstFileGenerator.ts +27 -0
- package/src/Sindri/Generator/Ast/Cli/AstCliDataFileGenerator.ts +94 -20
- package/src/Sindri/Generator/Ast/Container/AstContainerDataFileGenerator.ts +19 -11
- package/src/Sindri/Generator/Ast/Event/AstEventDataFileGenerator.ts +33 -8
- package/src/Sindri/Generator/Ast/Http/AstHttpDataFileGenerator.ts +199 -19
- package/src/Sindri/Generator/Cli/Contract/CliDataFileGeneratorContract.ts +10 -0
- package/src/Sindri/Generator/Container/Contract/ContainerDataFileGeneratorContract.ts +3 -0
- package/src/Sindri/Generator/Http/Contract/HttpDataFileGeneratorContract.ts +10 -0
package/dist/bin/sindri.cjs
CHANGED
|
@@ -33,7 +33,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
33
33
|
// node_modules/@ts-morph/common/dist/typescript.js
|
|
34
34
|
var require_typescript = __commonJS({
|
|
35
35
|
"node_modules/@ts-morph/common/dist/typescript.js"(exports2, module2) {
|
|
36
|
-
var
|
|
36
|
+
var ts13 = {};
|
|
37
37
|
((module3) => {
|
|
38
38
|
"use strict";
|
|
39
39
|
var __defProp2 = Object.defineProperty;
|
|
@@ -193,7 +193,7 @@ var require_typescript = __commonJS({
|
|
|
193
193
|
SymbolDisplayPartKind: () => SymbolDisplayPartKind,
|
|
194
194
|
SymbolFlags: () => SymbolFlags,
|
|
195
195
|
SymbolFormatFlags: () => SymbolFormatFlags,
|
|
196
|
-
SyntaxKind: () =>
|
|
196
|
+
SyntaxKind: () => SyntaxKind,
|
|
197
197
|
Ternary: () => Ternary,
|
|
198
198
|
ThrottledCancellationToken: () => ThrottledCancellationToken,
|
|
199
199
|
TokenClass: () => TokenClass,
|
|
@@ -4084,7 +4084,7 @@ Node ${formatSyntaxKind(node.kind)} was unexpected.`,
|
|
|
4084
4084
|
function formatSyntaxKind(kind) {
|
|
4085
4085
|
return formatEnum(
|
|
4086
4086
|
kind,
|
|
4087
|
-
|
|
4087
|
+
SyntaxKind,
|
|
4088
4088
|
/*isFlags*/
|
|
4089
4089
|
false
|
|
4090
4090
|
);
|
|
@@ -5532,7 +5532,7 @@ ${lanes.join("\n")}
|
|
|
5532
5532
|
})(tracingEnabled || (tracingEnabled = {}));
|
|
5533
5533
|
var startTracing = tracingEnabled.startTracing;
|
|
5534
5534
|
var dumpTracingLegend = tracingEnabled.dumpLegend;
|
|
5535
|
-
var
|
|
5535
|
+
var SyntaxKind = /* @__PURE__ */ ((SyntaxKind5) => {
|
|
5536
5536
|
SyntaxKind5[SyntaxKind5["Unknown"] = 0] = "Unknown";
|
|
5537
5537
|
SyntaxKind5[SyntaxKind5["EndOfFileToken"] = 1] = "EndOfFileToken";
|
|
5538
5538
|
SyntaxKind5[SyntaxKind5["SingleLineCommentTrivia"] = 2] = "SingleLineCommentTrivia";
|
|
@@ -6038,7 +6038,7 @@ ${lanes.join("\n")}
|
|
|
6038
6038
|
/* LastKeyword */
|
|
6039
6039
|
] = "LastContextualKeyword";
|
|
6040
6040
|
return SyntaxKind5;
|
|
6041
|
-
})(
|
|
6041
|
+
})(SyntaxKind || {});
|
|
6042
6042
|
var NodeFlags = /* @__PURE__ */ ((NodeFlags3) => {
|
|
6043
6043
|
NodeFlags3[NodeFlags3["None"] = 0] = "None";
|
|
6044
6044
|
NodeFlags3[NodeFlags3["Let"] = 1] = "Let";
|
|
@@ -9433,11 +9433,11 @@ ${lanes.join("\n")}
|
|
|
9433
9433
|
return toComponents;
|
|
9434
9434
|
}
|
|
9435
9435
|
const components = toComponents.slice(start);
|
|
9436
|
-
const
|
|
9436
|
+
const relative2 = [];
|
|
9437
9437
|
for (; start < fromComponents.length; start++) {
|
|
9438
|
-
|
|
9438
|
+
relative2.push("..");
|
|
9439
9439
|
}
|
|
9440
|
-
return ["", ...
|
|
9440
|
+
return ["", ...relative2, ...components];
|
|
9441
9441
|
}
|
|
9442
9442
|
function getRelativePathFromDirectory(fromDirectory, to, getCanonicalFileNameOrIgnoreCase) {
|
|
9443
9443
|
Debug.assert(getRootLength(fromDirectory) > 0 === getRootLength(to) > 0, "Paths must either both be absolute or both be relative");
|
|
@@ -48133,11 +48133,11 @@ ${lanes.join("\n")}
|
|
|
48133
48133
|
if (i < rootLength) {
|
|
48134
48134
|
return void 0;
|
|
48135
48135
|
}
|
|
48136
|
-
const
|
|
48137
|
-
if (
|
|
48136
|
+
const sep2 = directory.lastIndexOf(directorySeparator, i - 1);
|
|
48137
|
+
if (sep2 === -1) {
|
|
48138
48138
|
return void 0;
|
|
48139
48139
|
}
|
|
48140
|
-
return directory.substr(0, Math.max(
|
|
48140
|
+
return directory.substr(0, Math.max(sep2, rootLength));
|
|
48141
48141
|
}
|
|
48142
48142
|
}
|
|
48143
48143
|
}
|
|
@@ -53980,9 +53980,9 @@ ${lanes.join("\n")}
|
|
|
53980
53980
|
if (!startsWithDirectory(target, realPathDirectory, getCanonicalFileName)) {
|
|
53981
53981
|
return;
|
|
53982
53982
|
}
|
|
53983
|
-
const
|
|
53983
|
+
const relative2 = getRelativePathFromDirectory(realPathDirectory, target, getCanonicalFileName);
|
|
53984
53984
|
for (const symlinkDirectory of symlinkDirectories) {
|
|
53985
|
-
const option = resolvePath(symlinkDirectory,
|
|
53985
|
+
const option = resolvePath(symlinkDirectory, relative2);
|
|
53986
53986
|
const result2 = cb(option, target === referenceRedirect);
|
|
53987
53987
|
shouldFilterIgnoredPaths = true;
|
|
53988
53988
|
if (result2) return result2;
|
|
@@ -137157,9 +137157,9 @@ ${lanes.join("\n")}
|
|
|
137157
137157
|
/*ignoreCase*/
|
|
137158
137158
|
false
|
|
137159
137159
|
)) {
|
|
137160
|
-
const
|
|
137161
|
-
if (
|
|
137162
|
-
const name = removeSuffix(removePrefix(
|
|
137160
|
+
const basename2 = getBaseFileName(a.fileName);
|
|
137161
|
+
if (basename2 === "lib.d.ts" || basename2 === "lib.es6.d.ts") return 0;
|
|
137162
|
+
const name = removeSuffix(removePrefix(basename2, "lib."), ".d.ts");
|
|
137163
137163
|
const index = libs.indexOf(name);
|
|
137164
137164
|
if (index !== -1) return index + 1;
|
|
137165
137165
|
}
|
|
@@ -196444,7 +196444,7 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
196444
196444
|
SymbolDisplayPartKind: () => SymbolDisplayPartKind,
|
|
196445
196445
|
SymbolFlags: () => SymbolFlags,
|
|
196446
196446
|
SymbolFormatFlags: () => SymbolFormatFlags,
|
|
196447
|
-
SyntaxKind: () =>
|
|
196447
|
+
SyntaxKind: () => SyntaxKind,
|
|
196448
196448
|
Ternary: () => Ternary,
|
|
196449
196449
|
ThrottledCancellationToken: () => ThrottledCancellationToken,
|
|
196450
196450
|
TokenClass: () => TokenClass,
|
|
@@ -201085,8 +201085,8 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
201085
201085
|
}
|
|
201086
201086
|
};
|
|
201087
201087
|
for (const file of files) {
|
|
201088
|
-
const
|
|
201089
|
-
if (
|
|
201088
|
+
const basename2 = getBaseFileName(file);
|
|
201089
|
+
if (basename2 === "package.json" || basename2 === "bower.json") {
|
|
201090
201090
|
createProjectWatcher(
|
|
201091
201091
|
file,
|
|
201092
201092
|
"FileWatcher"
|
|
@@ -204770,8 +204770,8 @@ All files are: ${JSON.stringify(names)}`,
|
|
|
204770
204770
|
var _a;
|
|
204771
204771
|
const fileOrDirectoryPath = removeIgnoredPath(this.toPath(fileOrDirectory));
|
|
204772
204772
|
if (!fileOrDirectoryPath) return;
|
|
204773
|
-
const
|
|
204774
|
-
if (((_a = result.affectedModuleSpecifierCacheProjects) == null ? void 0 : _a.size) && (
|
|
204773
|
+
const basename2 = getBaseFileName(fileOrDirectoryPath);
|
|
204774
|
+
if (((_a = result.affectedModuleSpecifierCacheProjects) == null ? void 0 : _a.size) && (basename2 === "package.json" || basename2 === "node_modules")) {
|
|
204775
204775
|
result.affectedModuleSpecifierCacheProjects.forEach((project) => {
|
|
204776
204776
|
var _a2;
|
|
204777
204777
|
(_a2 = project.getModuleSpecifierCache()) == null ? void 0 : _a2.clear();
|
|
@@ -211530,9 +211530,9 @@ Additional information: BADCLIENT: Bad error code, ${badCode} not found in range
|
|
|
211530
211530
|
};
|
|
211531
211531
|
}
|
|
211532
211532
|
})({ get exports() {
|
|
211533
|
-
return
|
|
211533
|
+
return ts13;
|
|
211534
211534
|
}, set exports(v) {
|
|
211535
|
-
|
|
211535
|
+
ts13 = v;
|
|
211536
211536
|
if (typeof module2 !== "undefined" && module2.exports) {
|
|
211537
211537
|
module2.exports = v;
|
|
211538
211538
|
}
|
|
@@ -213537,7 +213537,7 @@ var require_path_browserify = __commonJS({
|
|
|
213537
213537
|
}
|
|
213538
213538
|
return res;
|
|
213539
213539
|
}
|
|
213540
|
-
function _format(
|
|
213540
|
+
function _format(sep2, pathObject) {
|
|
213541
213541
|
var dir = pathObject.dir || pathObject.root;
|
|
213542
213542
|
var base = pathObject.base || (pathObject.name || "") + (pathObject.ext || "");
|
|
213543
213543
|
if (!dir) {
|
|
@@ -213546,7 +213546,7 @@ var require_path_browserify = __commonJS({
|
|
|
213546
213546
|
if (dir === pathObject.root) {
|
|
213547
213547
|
return dir + base;
|
|
213548
213548
|
}
|
|
213549
|
-
return dir +
|
|
213549
|
+
return dir + sep2 + base;
|
|
213550
213550
|
}
|
|
213551
213551
|
var posix = {
|
|
213552
213552
|
// path.resolve([from ...], to)
|
|
@@ -213615,7 +213615,7 @@ var require_path_browserify = __commonJS({
|
|
|
213615
213615
|
return ".";
|
|
213616
213616
|
return posix.normalize(joined);
|
|
213617
213617
|
},
|
|
213618
|
-
relative: function
|
|
213618
|
+
relative: function relative2(from, to) {
|
|
213619
213619
|
assertPath(from);
|
|
213620
213620
|
assertPath(to);
|
|
213621
213621
|
if (from === to) return "";
|
|
@@ -213706,7 +213706,7 @@ var require_path_browserify = __commonJS({
|
|
|
213706
213706
|
if (hasRoot && end === 1) return "//";
|
|
213707
213707
|
return path4.slice(0, end);
|
|
213708
213708
|
},
|
|
213709
|
-
basename: function
|
|
213709
|
+
basename: function basename2(path4, ext) {
|
|
213710
213710
|
if (ext !== void 0 && typeof ext !== "string") throw new TypeError('"ext" argument must be a string');
|
|
213711
213711
|
assertPath(path4);
|
|
213712
213712
|
var start = 0;
|
|
@@ -216463,12 +216463,12 @@ var require_dist2 = __commonJS({
|
|
|
216463
216463
|
return patterns.length > 0 ? buildCrawler(options, patterns) : [];
|
|
216464
216464
|
}
|
|
216465
216465
|
async function glob(globInput, options) {
|
|
216466
|
-
const [crawler,
|
|
216467
|
-
return crawler ? formatPaths(await crawler.withPromise(),
|
|
216466
|
+
const [crawler, relative2] = getCrawler(globInput, options);
|
|
216467
|
+
return crawler ? formatPaths(await crawler.withPromise(), relative2) : [];
|
|
216468
216468
|
}
|
|
216469
216469
|
function globSync(globInput, options) {
|
|
216470
|
-
const [crawler,
|
|
216471
|
-
return crawler ? formatPaths(crawler.sync(),
|
|
216470
|
+
const [crawler, relative2] = getCrawler(globInput, options);
|
|
216471
|
+
return crawler ? formatPaths(crawler.sync(), relative2) : [];
|
|
216472
216472
|
}
|
|
216473
216473
|
exports2.convertPathToPattern = convertPathToPattern;
|
|
216474
216474
|
exports2.escapePath = escapePath;
|
|
@@ -216482,7 +216482,7 @@ var require_dist2 = __commonJS({
|
|
|
216482
216482
|
var require_ts_morph_common = __commonJS({
|
|
216483
216483
|
"node_modules/@ts-morph/common/dist/ts-morph-common.js"(exports2) {
|
|
216484
216484
|
"use strict";
|
|
216485
|
-
var
|
|
216485
|
+
var ts13 = require_typescript();
|
|
216486
216486
|
var minimatch = require_commonjs3();
|
|
216487
216487
|
var path$1 = require_path_browserify();
|
|
216488
216488
|
var fs$1 = require("node:fs");
|
|
@@ -216512,7 +216512,7 @@ var require_ts_morph_common = __commonJS({
|
|
|
216512
216512
|
n.default = e;
|
|
216513
216513
|
return Object.freeze(n);
|
|
216514
216514
|
}
|
|
216515
|
-
var ts__namespace = /* @__PURE__ */ _interopNamespaceCompat(
|
|
216515
|
+
var ts__namespace = /* @__PURE__ */ _interopNamespaceCompat(ts13);
|
|
216516
216516
|
var minimatch__namespace = /* @__PURE__ */ _interopNamespaceCompat(minimatch);
|
|
216517
216517
|
var path__default = /* @__PURE__ */ _interopDefaultCompat(path$1);
|
|
216518
216518
|
var fs__namespace = /* @__PURE__ */ _interopNamespaceCompat(fs$1);
|
|
@@ -219622,85 +219622,85 @@ ${nodeLocation}` : message;
|
|
|
219622
219622
|
Object.defineProperty(exports2, "DiagnosticCategory", {
|
|
219623
219623
|
enumerable: true,
|
|
219624
219624
|
get: function() {
|
|
219625
|
-
return
|
|
219625
|
+
return ts13.DiagnosticCategory;
|
|
219626
219626
|
}
|
|
219627
219627
|
});
|
|
219628
219628
|
Object.defineProperty(exports2, "EmitHint", {
|
|
219629
219629
|
enumerable: true,
|
|
219630
219630
|
get: function() {
|
|
219631
|
-
return
|
|
219631
|
+
return ts13.EmitHint;
|
|
219632
219632
|
}
|
|
219633
219633
|
});
|
|
219634
219634
|
Object.defineProperty(exports2, "LanguageVariant", {
|
|
219635
219635
|
enumerable: true,
|
|
219636
219636
|
get: function() {
|
|
219637
|
-
return
|
|
219637
|
+
return ts13.LanguageVariant;
|
|
219638
219638
|
}
|
|
219639
219639
|
});
|
|
219640
219640
|
Object.defineProperty(exports2, "ModuleKind", {
|
|
219641
219641
|
enumerable: true,
|
|
219642
219642
|
get: function() {
|
|
219643
|
-
return
|
|
219643
|
+
return ts13.ModuleKind;
|
|
219644
219644
|
}
|
|
219645
219645
|
});
|
|
219646
219646
|
Object.defineProperty(exports2, "ModuleResolutionKind", {
|
|
219647
219647
|
enumerable: true,
|
|
219648
219648
|
get: function() {
|
|
219649
|
-
return
|
|
219649
|
+
return ts13.ModuleResolutionKind;
|
|
219650
219650
|
}
|
|
219651
219651
|
});
|
|
219652
219652
|
Object.defineProperty(exports2, "NewLineKind", {
|
|
219653
219653
|
enumerable: true,
|
|
219654
219654
|
get: function() {
|
|
219655
|
-
return
|
|
219655
|
+
return ts13.NewLineKind;
|
|
219656
219656
|
}
|
|
219657
219657
|
});
|
|
219658
219658
|
Object.defineProperty(exports2, "NodeFlags", {
|
|
219659
219659
|
enumerable: true,
|
|
219660
219660
|
get: function() {
|
|
219661
|
-
return
|
|
219661
|
+
return ts13.NodeFlags;
|
|
219662
219662
|
}
|
|
219663
219663
|
});
|
|
219664
219664
|
Object.defineProperty(exports2, "ObjectFlags", {
|
|
219665
219665
|
enumerable: true,
|
|
219666
219666
|
get: function() {
|
|
219667
|
-
return
|
|
219667
|
+
return ts13.ObjectFlags;
|
|
219668
219668
|
}
|
|
219669
219669
|
});
|
|
219670
219670
|
Object.defineProperty(exports2, "ScriptKind", {
|
|
219671
219671
|
enumerable: true,
|
|
219672
219672
|
get: function() {
|
|
219673
|
-
return
|
|
219673
|
+
return ts13.ScriptKind;
|
|
219674
219674
|
}
|
|
219675
219675
|
});
|
|
219676
219676
|
Object.defineProperty(exports2, "ScriptTarget", {
|
|
219677
219677
|
enumerable: true,
|
|
219678
219678
|
get: function() {
|
|
219679
|
-
return
|
|
219679
|
+
return ts13.ScriptTarget;
|
|
219680
219680
|
}
|
|
219681
219681
|
});
|
|
219682
219682
|
Object.defineProperty(exports2, "SymbolFlags", {
|
|
219683
219683
|
enumerable: true,
|
|
219684
219684
|
get: function() {
|
|
219685
|
-
return
|
|
219685
|
+
return ts13.SymbolFlags;
|
|
219686
219686
|
}
|
|
219687
219687
|
});
|
|
219688
219688
|
Object.defineProperty(exports2, "SyntaxKind", {
|
|
219689
219689
|
enumerable: true,
|
|
219690
219690
|
get: function() {
|
|
219691
|
-
return
|
|
219691
|
+
return ts13.SyntaxKind;
|
|
219692
219692
|
}
|
|
219693
219693
|
});
|
|
219694
219694
|
Object.defineProperty(exports2, "TypeFlags", {
|
|
219695
219695
|
enumerable: true,
|
|
219696
219696
|
get: function() {
|
|
219697
|
-
return
|
|
219697
|
+
return ts13.TypeFlags;
|
|
219698
219698
|
}
|
|
219699
219699
|
});
|
|
219700
219700
|
Object.defineProperty(exports2, "TypeFormatFlags", {
|
|
219701
219701
|
enumerable: true,
|
|
219702
219702
|
get: function() {
|
|
219703
|
-
return
|
|
219703
|
+
return ts13.TypeFormatFlags;
|
|
219704
219704
|
}
|
|
219705
219705
|
});
|
|
219706
219706
|
exports2.ts = ts__namespace;
|
|
@@ -231501,12 +231501,12 @@ Node text: ${this.#forgottenText}`;
|
|
|
231501
231501
|
}
|
|
231502
231502
|
};
|
|
231503
231503
|
}
|
|
231504
|
-
var
|
|
231504
|
+
var Expression2 = class extends Node2 {
|
|
231505
231505
|
getContextualType() {
|
|
231506
231506
|
return this._context.typeChecker.getContextualType(this);
|
|
231507
231507
|
}
|
|
231508
231508
|
};
|
|
231509
|
-
var BinaryExpressionBase =
|
|
231509
|
+
var BinaryExpressionBase = Expression2;
|
|
231510
231510
|
var BinaryExpression = class extends BinaryExpressionBase {
|
|
231511
231511
|
getLeft() {
|
|
231512
231512
|
return this._getNodeFromCompilerNode(this.compilerNode.left);
|
|
@@ -231530,7 +231530,7 @@ Node text: ${this.#forgottenText}`;
|
|
|
231530
231530
|
return this._getNodeFromCompilerNode(this.compilerNode.left);
|
|
231531
231531
|
}
|
|
231532
231532
|
};
|
|
231533
|
-
var UnaryExpression = class extends
|
|
231533
|
+
var UnaryExpression = class extends Expression2 {
|
|
231534
231534
|
};
|
|
231535
231535
|
var UpdateExpression = class extends UnaryExpression {
|
|
231536
231536
|
};
|
|
@@ -231660,7 +231660,7 @@ Node text: ${this.#forgottenText}`;
|
|
|
231660
231660
|
return BaseExpressionedNode(Base);
|
|
231661
231661
|
}
|
|
231662
231662
|
var createBase$E = (ctor) => TypedNode(ExpressionedNode(ctor));
|
|
231663
|
-
var AsExpressionBase = createBase$E(
|
|
231663
|
+
var AsExpressionBase = createBase$E(Expression2);
|
|
231664
231664
|
var AsExpression = class extends AsExpressionBase {
|
|
231665
231665
|
};
|
|
231666
231666
|
var AwaitExpressionBase = UnaryExpressionedNode(UnaryExpression);
|
|
@@ -231673,13 +231673,13 @@ Node text: ${this.#forgottenText}`;
|
|
|
231673
231673
|
return this._context.typeChecker.getTypeAtLocation(this);
|
|
231674
231674
|
}
|
|
231675
231675
|
};
|
|
231676
|
-
var CommaListExpressionBase =
|
|
231676
|
+
var CommaListExpressionBase = Expression2;
|
|
231677
231677
|
var CommaListExpression = class extends CommaListExpressionBase {
|
|
231678
231678
|
getElements() {
|
|
231679
231679
|
return this.compilerNode.elements.map((e) => this._getNodeFromCompilerNode(e));
|
|
231680
231680
|
}
|
|
231681
231681
|
};
|
|
231682
|
-
var ConditionalExpressionBase =
|
|
231682
|
+
var ConditionalExpressionBase = Expression2;
|
|
231683
231683
|
var ConditionalExpression = class extends ConditionalExpressionBase {
|
|
231684
231684
|
getCondition() {
|
|
231685
231685
|
return this._getNodeFromCompilerNode(this.compilerNode.condition);
|
|
@@ -232010,13 +232010,13 @@ Node text: ${this.#forgottenText}`;
|
|
|
232010
232010
|
});
|
|
232011
232011
|
}
|
|
232012
232012
|
};
|
|
232013
|
-
var OmittedExpressionBase =
|
|
232013
|
+
var OmittedExpressionBase = Expression2;
|
|
232014
232014
|
var OmittedExpression = class extends OmittedExpressionBase {
|
|
232015
232015
|
};
|
|
232016
|
-
var ParenthesizedExpressionBase = ExpressionedNode(
|
|
232016
|
+
var ParenthesizedExpressionBase = ExpressionedNode(Expression2);
|
|
232017
232017
|
var ParenthesizedExpression = class extends ParenthesizedExpressionBase {
|
|
232018
232018
|
};
|
|
232019
|
-
var PartiallyEmittedExpressionBase = ExpressionedNode(
|
|
232019
|
+
var PartiallyEmittedExpressionBase = ExpressionedNode(Expression2);
|
|
232020
232020
|
var PartiallyEmittedExpression = class extends PartiallyEmittedExpressionBase {
|
|
232021
232021
|
};
|
|
232022
232022
|
var PostfixUnaryExpressionBase = UnaryExpression;
|
|
@@ -232042,10 +232042,10 @@ Node text: ${this.#forgottenText}`;
|
|
|
232042
232042
|
var PropertyAccessExpression = class extends PropertyAccessExpressionBase {
|
|
232043
232043
|
};
|
|
232044
232044
|
var createBase$x = (ctor) => TypedNode(ExpressionedNode(ctor));
|
|
232045
|
-
var SatisfiesExpressionBase = createBase$x(
|
|
232045
|
+
var SatisfiesExpressionBase = createBase$x(Expression2);
|
|
232046
232046
|
var SatisfiesExpression = class extends SatisfiesExpressionBase {
|
|
232047
232047
|
};
|
|
232048
|
-
var SpreadElementBase = ExpressionedNode(
|
|
232048
|
+
var SpreadElementBase = ExpressionedNode(Expression2);
|
|
232049
232049
|
var SpreadElement = class extends SpreadElementBase {
|
|
232050
232050
|
};
|
|
232051
232051
|
var SuperElementAccessExpressionBase = SuperExpressionedNode(ElementAccessExpression);
|
|
@@ -232070,7 +232070,7 @@ Node text: ${this.#forgottenText}`;
|
|
|
232070
232070
|
var VoidExpressionBase = UnaryExpressionedNode(UnaryExpression);
|
|
232071
232071
|
var VoidExpression = class extends VoidExpressionBase {
|
|
232072
232072
|
};
|
|
232073
|
-
var YieldExpressionBase = ExpressionableNode(GeneratorableNode(
|
|
232073
|
+
var YieldExpressionBase = ExpressionableNode(GeneratorableNode(Expression2));
|
|
232074
232074
|
var YieldExpression = class extends YieldExpressionBase {
|
|
232075
232075
|
};
|
|
232076
232076
|
var StatementBase = ChildOrderableNode(Node2);
|
|
@@ -234569,7 +234569,7 @@ Node text: ${this.#forgottenText}`;
|
|
|
234569
234569
|
return JSDocableNode(TypeParameteredNode(SignaturedDeclaration(StatementedNode(ModifierableNode(Base)))));
|
|
234570
234570
|
}
|
|
234571
234571
|
var createBase$p = (ctor) => TextInsertableNode(BodiedNode(AsyncableNode(FunctionLikeDeclaration(ctor))));
|
|
234572
|
-
var ArrowFunctionBase = createBase$p(
|
|
234572
|
+
var ArrowFunctionBase = createBase$p(Expression2);
|
|
234573
234573
|
var ArrowFunction = class extends ArrowFunctionBase {
|
|
234574
234574
|
getEqualsGreaterThan() {
|
|
234575
234575
|
return this._getNodeFromCompilerNode(this.compilerNode.equalsGreaterThanToken);
|
|
@@ -237145,7 +237145,7 @@ Node text: ${this.#forgottenText}`;
|
|
|
237145
237145
|
var JsxClosingElementBase = createBase$3(Node2);
|
|
237146
237146
|
var JsxClosingElement = class extends JsxClosingElementBase {
|
|
237147
237147
|
};
|
|
237148
|
-
var JsxClosingFragment = class extends
|
|
237148
|
+
var JsxClosingFragment = class extends Expression2 {
|
|
237149
237149
|
};
|
|
237150
237150
|
var JsxElementBase = PrimaryExpression;
|
|
237151
237151
|
var JsxElement = class extends JsxElementBase {
|
|
@@ -237217,7 +237217,7 @@ Node text: ${this.#forgottenText}`;
|
|
|
237217
237217
|
}
|
|
237218
237218
|
});
|
|
237219
237219
|
}
|
|
237220
|
-
var JsxExpressionBase = ExpressionableNode(DotDotDotTokenableNode(
|
|
237220
|
+
var JsxExpressionBase = ExpressionableNode(DotDotDotTokenableNode(Expression2));
|
|
237221
237221
|
var JsxExpression = class extends JsxExpressionBase {
|
|
237222
237222
|
};
|
|
237223
237223
|
var JsxFragment = class extends PrimaryExpression {
|
|
@@ -237252,10 +237252,10 @@ Node text: ${this.#forgottenText}`;
|
|
|
237252
237252
|
}
|
|
237253
237253
|
};
|
|
237254
237254
|
var createBase$2 = (ctor) => JsxAttributedNode(JsxTagNamedNode(ctor));
|
|
237255
|
-
var JsxOpeningElementBase = createBase$2(
|
|
237255
|
+
var JsxOpeningElementBase = createBase$2(Expression2);
|
|
237256
237256
|
var JsxOpeningElement = class extends JsxOpeningElementBase {
|
|
237257
237257
|
};
|
|
237258
|
-
var JsxOpeningFragment = class extends
|
|
237258
|
+
var JsxOpeningFragment = class extends Expression2 {
|
|
237259
237259
|
};
|
|
237260
237260
|
var createBase$1 = (ctor) => JsxAttributedNode(JsxTagNamedNode(ctor));
|
|
237261
237261
|
var JsxSelfClosingElementBase = createBase$1(PrimaryExpression);
|
|
@@ -240078,21 +240078,21 @@ Node text: ${this.#forgottenText}`;
|
|
|
240078
240078
|
[common.SyntaxKind.WithStatement]: WithStatement,
|
|
240079
240079
|
[common.SyntaxKind.YieldExpression]: YieldExpression,
|
|
240080
240080
|
[common.SyntaxKind.SemicolonToken]: Node2,
|
|
240081
|
-
[common.SyntaxKind.AnyKeyword]:
|
|
240082
|
-
[common.SyntaxKind.BooleanKeyword]:
|
|
240081
|
+
[common.SyntaxKind.AnyKeyword]: Expression2,
|
|
240082
|
+
[common.SyntaxKind.BooleanKeyword]: Expression2,
|
|
240083
240083
|
[common.SyntaxKind.FalseKeyword]: FalseLiteral,
|
|
240084
240084
|
[common.SyntaxKind.ImportKeyword]: ImportExpression,
|
|
240085
240085
|
[common.SyntaxKind.InferKeyword]: Node2,
|
|
240086
240086
|
[common.SyntaxKind.NeverKeyword]: Node2,
|
|
240087
240087
|
[common.SyntaxKind.NullKeyword]: NullLiteral,
|
|
240088
|
-
[common.SyntaxKind.NumberKeyword]:
|
|
240089
|
-
[common.SyntaxKind.ObjectKeyword]:
|
|
240090
|
-
[common.SyntaxKind.StringKeyword]:
|
|
240091
|
-
[common.SyntaxKind.SymbolKeyword]:
|
|
240088
|
+
[common.SyntaxKind.NumberKeyword]: Expression2,
|
|
240089
|
+
[common.SyntaxKind.ObjectKeyword]: Expression2,
|
|
240090
|
+
[common.SyntaxKind.StringKeyword]: Expression2,
|
|
240091
|
+
[common.SyntaxKind.SymbolKeyword]: Expression2,
|
|
240092
240092
|
[common.SyntaxKind.SuperKeyword]: SuperExpression,
|
|
240093
240093
|
[common.SyntaxKind.ThisKeyword]: ThisExpression,
|
|
240094
240094
|
[common.SyntaxKind.TrueKeyword]: TrueLiteral,
|
|
240095
|
-
[common.SyntaxKind.UndefinedKeyword]:
|
|
240095
|
+
[common.SyntaxKind.UndefinedKeyword]: Expression2,
|
|
240096
240096
|
[common.SyntaxKind.VoidExpression]: VoidExpression
|
|
240097
240097
|
};
|
|
240098
240098
|
var CompilerFactory = class {
|
|
@@ -241356,7 +241356,7 @@ Node text: ${this.#forgottenText}`;
|
|
|
241356
241356
|
exports2.ExportSpecifier = ExportSpecifier;
|
|
241357
241357
|
exports2.ExportSpecifierBase = ExportSpecifierBase;
|
|
241358
241358
|
exports2.ExportableNode = ExportableNode;
|
|
241359
|
-
exports2.Expression =
|
|
241359
|
+
exports2.Expression = Expression2;
|
|
241360
241360
|
exports2.ExpressionStatement = ExpressionStatement;
|
|
241361
241361
|
exports2.ExpressionStatementBase = ExpressionStatementBase;
|
|
241362
241362
|
exports2.ExpressionWithTypeArguments = ExpressionWithTypeArguments;
|
|
@@ -242575,7 +242575,20 @@ var HandlerData = class {
|
|
|
242575
242575
|
};
|
|
242576
242576
|
|
|
242577
242577
|
// src/Sindri/Ast/Abstract/AstReader.ts
|
|
242578
|
-
var AstReader = class {
|
|
242578
|
+
var AstReader = class _AstReader {
|
|
242579
|
+
/**
|
|
242580
|
+
* Module resolution settings for {@link resolveModuleSpecifierToFilePath}.
|
|
242581
|
+
*
|
|
242582
|
+
* NodeNext mirrors how the application itself resolves its imports, and
|
|
242583
|
+
* `allowImportingTsExtensions` matches the framework convention of writing
|
|
242584
|
+
* the `.ts` extension in every import specifier.
|
|
242585
|
+
*/
|
|
242586
|
+
static MODULE_RESOLUTION_OPTIONS = {
|
|
242587
|
+
module: import_ts_morph.ts.ModuleKind.NodeNext,
|
|
242588
|
+
moduleResolution: import_ts_morph.ts.ModuleResolutionKind.NodeNext,
|
|
242589
|
+
allowImportingTsExtensions: true,
|
|
242590
|
+
noEmit: true
|
|
242591
|
+
};
|
|
242579
242592
|
parseFileToSourceFile(filePath) {
|
|
242580
242593
|
if (!fs.existsSync(filePath)) {
|
|
242581
242594
|
throw new AstFileReadException(`Cannot read file '${filePath}'.`);
|
|
@@ -242623,12 +242636,39 @@ var AstReader = class {
|
|
|
242623
242636
|
if (moduleSpecifier === void 0) {
|
|
242624
242637
|
return "";
|
|
242625
242638
|
}
|
|
242626
|
-
|
|
242639
|
+
return this.resolveModuleSpecifierToFilePath(moduleSpecifier, currentFilePath);
|
|
242640
|
+
}
|
|
242641
|
+
/**
|
|
242642
|
+
* Resolve a module specifier to the absolute path of the TypeScript file it points at.
|
|
242643
|
+
*
|
|
242644
|
+
* Relative specifiers resolve against the importing file's directory. Bare
|
|
242645
|
+
* package specifiers (`@valkyrjaio/valkyrja/Cli/Routing/Data/Route.ts`) go
|
|
242646
|
+
* through the TypeScript compiler's NodeNext resolver, which honors the
|
|
242647
|
+
* package's `exports` map — so a provider tree that reaches into an
|
|
242648
|
+
* installed package (the framework's own component providers, reached from
|
|
242649
|
+
* the app config) is walked exactly like application source.
|
|
242650
|
+
*
|
|
242651
|
+
* Returns '' when the specifier cannot be resolved to an existing `.ts`
|
|
242652
|
+
* source file. A package shipping only compiled `.js` — or only `.d.ts`
|
|
242653
|
+
* declarations, which carry no `getRoutes()` body to read — has nothing for
|
|
242654
|
+
* the AST readers to walk.
|
|
242655
|
+
*/
|
|
242656
|
+
resolveModuleSpecifierToFilePath(moduleSpecifier, currentFilePath) {
|
|
242657
|
+
if (moduleSpecifier.startsWith(".")) {
|
|
242658
|
+
const dir = path.dirname(currentFilePath);
|
|
242659
|
+
const resolved2 = path.resolve(dir, moduleSpecifier.replace(/\.js$/, ".ts"));
|
|
242660
|
+
return fs.existsSync(resolved2) ? resolved2 : "";
|
|
242661
|
+
}
|
|
242662
|
+
const resolved = import_ts_morph.ts.resolveModuleName(
|
|
242663
|
+
moduleSpecifier,
|
|
242664
|
+
currentFilePath,
|
|
242665
|
+
_AstReader.MODULE_RESOLUTION_OPTIONS,
|
|
242666
|
+
import_ts_morph.ts.sys
|
|
242667
|
+
).resolvedModule?.resolvedFileName;
|
|
242668
|
+
if (resolved === void 0 || !resolved.endsWith(".ts") || resolved.endsWith(".d.ts")) {
|
|
242627
242669
|
return "";
|
|
242628
242670
|
}
|
|
242629
|
-
|
|
242630
|
-
const resolved = path.resolve(dir, moduleSpecifier.replace(/\.js$/, ".ts"));
|
|
242631
|
-
return fs.existsSync(resolved) ? resolved : "";
|
|
242671
|
+
return resolved;
|
|
242632
242672
|
}
|
|
242633
242673
|
/**
|
|
242634
242674
|
* Extract class names from a method returning [new A(), new B(), ...].
|
|
@@ -242650,6 +242690,90 @@ var AstReader = class {
|
|
|
242650
242690
|
}
|
|
242651
242691
|
return classes;
|
|
242652
242692
|
}
|
|
242693
|
+
/**
|
|
242694
|
+
* Resolve a `new X()` or bare `X` identifier element to the absolute file
|
|
242695
|
+
* path of the class it references, using the current file's import map.
|
|
242696
|
+
*
|
|
242697
|
+
* Returns undefined when the element is neither form, or when the name is
|
|
242698
|
+
* not imported via a relative specifier (e.g. framework classes imported
|
|
242699
|
+
* from a package — those are intentionally skipped by the provider walk).
|
|
242700
|
+
*/
|
|
242701
|
+
resolveElementToFilePath(element, useMap, currentFilePath) {
|
|
242702
|
+
let name;
|
|
242703
|
+
if (import_ts_morph.ts.isNewExpression(element)) {
|
|
242704
|
+
name = import_ts_morph.ts.isIdentifier(element.expression) ? element.expression.text : void 0;
|
|
242705
|
+
} else if (import_ts_morph.ts.isIdentifier(element)) {
|
|
242706
|
+
name = element.text;
|
|
242707
|
+
}
|
|
242708
|
+
if (name === void 0) {
|
|
242709
|
+
return void 0;
|
|
242710
|
+
}
|
|
242711
|
+
const resolved = this.resolveImportToFilePath(name, useMap, currentFilePath);
|
|
242712
|
+
return resolved !== "" ? resolved : void 0;
|
|
242713
|
+
}
|
|
242714
|
+
/**
|
|
242715
|
+
* Extract the absolute file paths of the classes referenced by a method
|
|
242716
|
+
* returning [new A(), new B(), ...] (or [A, B, ...]).
|
|
242717
|
+
*
|
|
242718
|
+
* Unlike {@link extractClassListFromValues} (which returns bare class
|
|
242719
|
+
* names), this resolves each reference through the import map so provider
|
|
242720
|
+
* classes are located unambiguously — critical when the same short class
|
|
242721
|
+
* name exists in more than one component tree (e.g. an Http and a Cli
|
|
242722
|
+
* `ComponentProvider`).
|
|
242723
|
+
*/
|
|
242724
|
+
extractClassPathListFromValues(method, useMap, currentFilePath) {
|
|
242725
|
+
if (method === void 0) {
|
|
242726
|
+
return [];
|
|
242727
|
+
}
|
|
242728
|
+
const array = this.findReturnedArray(method);
|
|
242729
|
+
if (array === void 0) {
|
|
242730
|
+
return [];
|
|
242731
|
+
}
|
|
242732
|
+
return this.extractClassPathListFromArrayExpr(array, useMap, currentFilePath);
|
|
242733
|
+
}
|
|
242734
|
+
/**
|
|
242735
|
+
* Extract the absolute file paths of the classes referenced by the elements
|
|
242736
|
+
* of an array literal, using the current file's import map.
|
|
242737
|
+
*/
|
|
242738
|
+
extractClassPathListFromArrayExpr(array, useMap, currentFilePath) {
|
|
242739
|
+
const paths = [];
|
|
242740
|
+
for (const element of array.elements) {
|
|
242741
|
+
const resolved = this.resolveElementToFilePath(element, useMap, currentFilePath);
|
|
242742
|
+
if (resolved !== void 0) {
|
|
242743
|
+
paths.push(resolved);
|
|
242744
|
+
}
|
|
242745
|
+
}
|
|
242746
|
+
return paths;
|
|
242747
|
+
}
|
|
242748
|
+
/**
|
|
242749
|
+
* Collect every identifier an expression references as a value.
|
|
242750
|
+
*
|
|
242751
|
+
* Expressions taken from a provider's `getRoutes()` body are emitted into
|
|
242752
|
+
* the generated data cache verbatim, so the cache must import everything
|
|
242753
|
+
* they name — not just the provider class, but the parameter/enum/constant
|
|
242754
|
+
* classes the route arguments reach for. Property *names* are skipped (the
|
|
242755
|
+
* `HELP` of `CommandName.HELP` is not an import) as are type positions,
|
|
242756
|
+
* which erase at runtime and must never become a value import.
|
|
242757
|
+
*/
|
|
242758
|
+
collectReferencedIdentifiers(node, names = /* @__PURE__ */ new Set()) {
|
|
242759
|
+
if (import_ts_morph.ts.isTypeNode(node)) {
|
|
242760
|
+
return names;
|
|
242761
|
+
}
|
|
242762
|
+
if (import_ts_morph.ts.isIdentifier(node)) {
|
|
242763
|
+
names.add(node.text);
|
|
242764
|
+
return names;
|
|
242765
|
+
}
|
|
242766
|
+
if (import_ts_morph.ts.isPropertyAccessExpression(node)) {
|
|
242767
|
+
return this.collectReferencedIdentifiers(node.expression, names);
|
|
242768
|
+
}
|
|
242769
|
+
if (import_ts_morph.ts.isPropertyAssignment(node)) {
|
|
242770
|
+
return this.collectReferencedIdentifiers(node.initializer, names);
|
|
242771
|
+
}
|
|
242772
|
+
import_ts_morph.ts.forEachChild(node, (child) => {
|
|
242773
|
+
this.collectReferencedIdentifiers(child, names);
|
|
242774
|
+
});
|
|
242775
|
+
return names;
|
|
242776
|
+
}
|
|
242653
242777
|
/**
|
|
242654
242778
|
* Extract service ID strings from keys of an object-returning method.
|
|
242655
242779
|
*
|
|
@@ -242751,7 +242875,7 @@ var AstReader = class {
|
|
|
242751
242875
|
return node.text;
|
|
242752
242876
|
}
|
|
242753
242877
|
if (import_ts_morph.ts.isIdentifier(node)) {
|
|
242754
|
-
return this.
|
|
242878
|
+
return this.resolveConstant(node.text, useMap, currentFilePath);
|
|
242755
242879
|
}
|
|
242756
242880
|
if (import_ts_morph.ts.isPropertyAccessExpression(node)) {
|
|
242757
242881
|
const objName = import_ts_morph.ts.isIdentifier(node.expression) ? node.expression.text : void 0;
|
|
@@ -242762,33 +242886,75 @@ var AstReader = class {
|
|
|
242762
242886
|
return void 0;
|
|
242763
242887
|
}
|
|
242764
242888
|
/**
|
|
242765
|
-
* Resolve a static property value by reading the
|
|
242889
|
+
* Resolve a static property value by reading the file that declares its class.
|
|
242766
242890
|
*/
|
|
242767
242891
|
resolveStaticProperty(className, propName, useMap, currentFilePath) {
|
|
242768
|
-
const
|
|
242769
|
-
if (
|
|
242892
|
+
const declaringClass = this.parseDeclaringSourceFile(className, useMap, currentFilePath)?.getClass(className);
|
|
242893
|
+
if (declaringClass === void 0) {
|
|
242770
242894
|
return void 0;
|
|
242771
242895
|
}
|
|
242896
|
+
const prop = declaringClass.getStaticProperty(propName);
|
|
242897
|
+
if (prop === void 0 || !import_ts_morph.Node.isPropertyDeclaration(prop)) {
|
|
242898
|
+
return void 0;
|
|
242899
|
+
}
|
|
242900
|
+
return this.stringValueOf(prop.getInitializer());
|
|
242901
|
+
}
|
|
242902
|
+
/**
|
|
242903
|
+
* Resolve a module-level `const` to its string value.
|
|
242904
|
+
*
|
|
242905
|
+
* Not every binding key is a class static — some are plain exported
|
|
242906
|
+
* constants, e.g. `export const LoggerContractId = 'Valkyrja.Log.Logger.LoggerContract' as const;`
|
|
242907
|
+
*/
|
|
242908
|
+
resolveConstant(name, useMap, currentFilePath) {
|
|
242909
|
+
const declaration = this.parseDeclaringSourceFile(name, useMap, currentFilePath)?.getVariableDeclaration(name);
|
|
242910
|
+
return this.stringValueOf(declaration?.getInitializer());
|
|
242911
|
+
}
|
|
242912
|
+
/**
|
|
242913
|
+
* Parse the file that declares a name: the module it is imported from, or
|
|
242914
|
+
* the current file when the name is not imported.
|
|
242915
|
+
*
|
|
242916
|
+
* A provider commonly declares the binding keys for its own services
|
|
242917
|
+
* alongside the publishers that use them, so `[Provider.SomeId]` names a
|
|
242918
|
+
* constant that no import map can resolve — it lives in the file being read.
|
|
242919
|
+
*
|
|
242920
|
+
* Returns undefined when the file cannot be read.
|
|
242921
|
+
*/
|
|
242922
|
+
parseDeclaringSourceFile(name, useMap, currentFilePath) {
|
|
242923
|
+
const importedFilePath = this.resolveImportToFilePath(name, useMap, currentFilePath);
|
|
242924
|
+
const filePath = importedFilePath !== "" ? importedFilePath : currentFilePath;
|
|
242772
242925
|
try {
|
|
242773
242926
|
const project = new import_ts_morph.Project({ skipAddingFilesFromTsConfig: true, skipFileDependencyResolution: true });
|
|
242774
|
-
|
|
242775
|
-
const importedClass = importedSource.getClass(className);
|
|
242776
|
-
if (importedClass === void 0 || propName === void 0) {
|
|
242777
|
-
return void 0;
|
|
242778
|
-
}
|
|
242779
|
-
const prop = importedClass.getStaticProperty(propName);
|
|
242780
|
-
if (prop === void 0) {
|
|
242781
|
-
return void 0;
|
|
242782
|
-
}
|
|
242783
|
-
if (import_ts_morph.Node.isPropertyDeclaration(prop)) {
|
|
242784
|
-
const initializer = prop.getInitializer();
|
|
242785
|
-
if (initializer?.isKind(import_ts_morph.SyntaxKind.StringLiteral) === true) {
|
|
242786
|
-
return initializer.compilerNode.text;
|
|
242787
|
-
}
|
|
242788
|
-
}
|
|
242927
|
+
return project.addSourceFileAtPath(filePath);
|
|
242789
242928
|
} catch {
|
|
242929
|
+
return void 0;
|
|
242790
242930
|
}
|
|
242791
|
-
|
|
242931
|
+
}
|
|
242932
|
+
/**
|
|
242933
|
+
* The string a declaration's initializer holds, once its type-only wrappers are stripped.
|
|
242934
|
+
*/
|
|
242935
|
+
stringValueOf(initializer) {
|
|
242936
|
+
if (initializer === void 0) {
|
|
242937
|
+
return void 0;
|
|
242938
|
+
}
|
|
242939
|
+
const value = this.unwrapTypeAssertions(initializer.compilerNode);
|
|
242940
|
+
return import_ts_morph.ts.isStringLiteral(value) ? value.text : void 0;
|
|
242941
|
+
}
|
|
242942
|
+
/**
|
|
242943
|
+
* Strip the type-only wrappers an expression may be dressed in — `as`,
|
|
242944
|
+
* `satisfies` and parentheses — to reach the value node underneath.
|
|
242945
|
+
*
|
|
242946
|
+
* Binding-key constants are declared `static readonly Data = 'Some.Id' as
|
|
242947
|
+
* const;`, so the initializer node is an `AsExpression`, not the
|
|
242948
|
+
* `StringLiteral` holding the value. Without unwrapping, every such key
|
|
242949
|
+
* resolves to nothing and the publishers it names are dropped from the
|
|
242950
|
+
* generated cache.
|
|
242951
|
+
*/
|
|
242952
|
+
unwrapTypeAssertions(node) {
|
|
242953
|
+
let current = node;
|
|
242954
|
+
while (import_ts_morph.ts.isAsExpression(current) || import_ts_morph.ts.isSatisfiesExpression(current) || import_ts_morph.ts.isParenthesizedExpression(current)) {
|
|
242955
|
+
current = current.expression;
|
|
242956
|
+
}
|
|
242957
|
+
return current;
|
|
242792
242958
|
}
|
|
242793
242959
|
/**
|
|
242794
242960
|
* Resolve a short class name — returns the name as-is (class names in TS are local).
|
|
@@ -243427,11 +243593,11 @@ var ComponentProviderReader = class _ComponentProviderReader extends AstReader {
|
|
|
243427
243593
|
const useMap = this.buildUseMap(sourceFile);
|
|
243428
243594
|
const methods = this.indexMethods(classDecl);
|
|
243429
243595
|
return new ComponentProviderResult(
|
|
243430
|
-
this.
|
|
243431
|
-
this.
|
|
243432
|
-
this.
|
|
243433
|
-
this.
|
|
243434
|
-
this.
|
|
243596
|
+
this.extractClassPathListFromValues(methods[_ComponentProviderReader.METHOD_COMPONENT], useMap, filePath),
|
|
243597
|
+
this.extractClassPathListFromValues(methods[_ComponentProviderReader.METHOD_CONTAINER], useMap, filePath),
|
|
243598
|
+
this.extractClassPathListFromValues(methods[_ComponentProviderReader.METHOD_EVENT], useMap, filePath),
|
|
243599
|
+
this.extractClassPathListFromValues(methods[_ComponentProviderReader.METHOD_CLI], useMap, filePath),
|
|
243600
|
+
this.extractClassPathListFromValues(methods[_ComponentProviderReader.METHOD_HTTP], useMap, filePath)
|
|
243435
243601
|
);
|
|
243436
243602
|
}
|
|
243437
243603
|
};
|
|
@@ -243576,14 +243742,24 @@ var ConfigReader = class extends AstReader {
|
|
|
243576
243742
|
return dataPath;
|
|
243577
243743
|
}
|
|
243578
243744
|
/**
|
|
243579
|
-
* Extract
|
|
243580
|
-
*
|
|
243745
|
+
* Extract the absolute file paths of the configured provider classes.
|
|
243746
|
+
*
|
|
243747
|
+
* The providers array is the first array-literal argument after the
|
|
243748
|
+
* `dataNamespace` (index 8) — every preceding argument is a scalar. Its
|
|
243749
|
+
* exact position varies by config type (index 9 in `HttpConfig`, index 11
|
|
243750
|
+
* in `CliConfig` after `applicationName`/`defaultCommandName`), so the
|
|
243751
|
+
* array is located by scanning rather than by a fixed index.
|
|
243752
|
+
*
|
|
243753
|
+
* Each element (`new ComponentProvider()` or a bare `ComponentProvider`
|
|
243754
|
+
* identifier) is resolved through the config file's import map to an
|
|
243755
|
+
* absolute path, so the walk locates the right provider even when the same
|
|
243756
|
+
* short name exists in multiple trees.
|
|
243581
243757
|
*/
|
|
243582
243758
|
extractProvidersFromArgs(args, useMap, filePath) {
|
|
243583
|
-
for (let i =
|
|
243759
|
+
for (let i = 9; i < args.length; i++) {
|
|
243584
243760
|
const arg = args[i];
|
|
243585
243761
|
if (arg !== void 0 && import_ts_morph3.ts.isArrayLiteralExpression(arg)) {
|
|
243586
|
-
return this.
|
|
243762
|
+
return this.extractClassPathListFromArrayExpr(arg, useMap, filePath);
|
|
243587
243763
|
}
|
|
243588
243764
|
}
|
|
243589
243765
|
return [];
|
|
@@ -244201,18 +244377,29 @@ var ListenerProviderReader = class _ListenerProviderReader extends AstReader {
|
|
|
244201
244377
|
}
|
|
244202
244378
|
};
|
|
244203
244379
|
|
|
244380
|
+
// src/Sindri/Ast/RouteProviderReader.ts
|
|
244381
|
+
var import_ts_morph6 = __toESM(require_ts_morph(), 1);
|
|
244382
|
+
|
|
244204
244383
|
// src/Sindri/Ast/Data/Result/RouteProviderResult.ts
|
|
244205
244384
|
var RouteProviderResult = class _RouteProviderResult {
|
|
244206
|
-
|
|
244385
|
+
/**
|
|
244386
|
+
* @param routeImports Local name → absolute file path for every class the
|
|
244387
|
+
* imperative `routes` expressions reference, so the
|
|
244388
|
+
* generated data cache can import them.
|
|
244389
|
+
*/
|
|
244390
|
+
constructor(controllerClasses = [], routes = [], routeImports = {}) {
|
|
244207
244391
|
this.controllerClasses = controllerClasses;
|
|
244208
244392
|
this.routes = routes;
|
|
244393
|
+
this.routeImports = routeImports;
|
|
244209
244394
|
}
|
|
244210
244395
|
controllerClasses;
|
|
244211
244396
|
routes;
|
|
244397
|
+
routeImports;
|
|
244212
244398
|
merge(other) {
|
|
244213
244399
|
return new _RouteProviderResult(
|
|
244214
244400
|
[.../* @__PURE__ */ new Set([...this.controllerClasses, ...other.controllerClasses])],
|
|
244215
|
-
[...this.routes, ...other.routes]
|
|
244401
|
+
[...this.routes, ...other.routes],
|
|
244402
|
+
{ ...this.routeImports, ...other.routeImports }
|
|
244216
244403
|
);
|
|
244217
244404
|
}
|
|
244218
244405
|
};
|
|
@@ -244229,18 +244416,58 @@ var RouteProviderReader = class _RouteProviderReader extends AstReader {
|
|
|
244229
244416
|
}
|
|
244230
244417
|
const useMap = this.buildUseMap(sourceFile);
|
|
244231
244418
|
const methods = this.indexMethods(classDecl);
|
|
244419
|
+
const routes = this.extractRoutes(methods[_RouteProviderReader.METHOD_ROUTES], useMap, filePath);
|
|
244232
244420
|
return new RouteProviderResult(
|
|
244233
244421
|
this.extractClassListFromValues(methods[_RouteProviderReader.METHOD_CONTROLLER_CLASSES], useMap, filePath),
|
|
244234
|
-
|
|
244422
|
+
routes,
|
|
244423
|
+
this.extractRouteImports(routes, useMap, filePath)
|
|
244235
244424
|
);
|
|
244236
244425
|
}
|
|
244237
|
-
|
|
244238
|
-
|
|
244426
|
+
/**
|
|
244427
|
+
* Resolve every class the imperative route expressions reference to its
|
|
244428
|
+
* absolute file path, so the generated data cache can import them.
|
|
244429
|
+
*
|
|
244430
|
+
* Names that are not imported by the provider file — locals, globals, and
|
|
244431
|
+
* the provider's own class (which the generator imports separately) — have
|
|
244432
|
+
* no entry in the use map and are skipped.
|
|
244433
|
+
*/
|
|
244434
|
+
extractRouteImports(routes, useMap, filePath) {
|
|
244435
|
+
const imports = {};
|
|
244436
|
+
for (const route2 of routes) {
|
|
244437
|
+
for (const name of this.collectReferencedIdentifiers(route2)) {
|
|
244438
|
+
const resolved = this.resolveImportToFilePath(name, useMap, filePath);
|
|
244439
|
+
if (resolved !== "") {
|
|
244440
|
+
imports[name] = resolved;
|
|
244441
|
+
}
|
|
244442
|
+
}
|
|
244443
|
+
}
|
|
244444
|
+
return imports;
|
|
244445
|
+
}
|
|
244446
|
+
/**
|
|
244447
|
+
* Extract the route objects returned by a provider's `getRoutes()` method.
|
|
244448
|
+
*
|
|
244449
|
+
* TS route providers register routes imperatively — `getRoutes()` returns
|
|
244450
|
+
* the concrete `new Route(...)` / `new DynamicRoute(...)` (or CLI
|
|
244451
|
+
* `new Route(...)`) instances. Those expressions are returned verbatim for
|
|
244452
|
+
* the data-cache generator to emit as route closures and to derive the
|
|
244453
|
+
* path/regex lookup maps from. (Attribute/decorator scanning — the other,
|
|
244454
|
+
* optional source of routes — is handled separately via
|
|
244455
|
+
* {@link readFile}'s controller-class list.)
|
|
244456
|
+
*/
|
|
244457
|
+
extractRoutes(method, _useMap, _filePath) {
|
|
244458
|
+
if (method === void 0) {
|
|
244459
|
+
return [];
|
|
244460
|
+
}
|
|
244461
|
+
const array = this.findReturnedArray(method);
|
|
244462
|
+
if (array === void 0) {
|
|
244463
|
+
return [];
|
|
244464
|
+
}
|
|
244465
|
+
return array.elements.filter((element) => import_ts_morph6.ts.isNewExpression(element));
|
|
244239
244466
|
}
|
|
244240
244467
|
};
|
|
244241
244468
|
|
|
244242
244469
|
// src/Sindri/Ast/ServiceProviderReader.ts
|
|
244243
|
-
var
|
|
244470
|
+
var import_ts_morph7 = __toESM(require_ts_morph(), 1);
|
|
244244
244471
|
|
|
244245
244472
|
// src/Sindri/Ast/Data/Result/ServiceProviderResult.ts
|
|
244246
244473
|
var ServiceProviderResult = class _ServiceProviderResult {
|
|
@@ -244293,7 +244520,7 @@ var ServiceProviderReader = class _ServiceProviderReader extends AstReader {
|
|
|
244293
244520
|
}
|
|
244294
244521
|
const map = {};
|
|
244295
244522
|
for (const prop of obj.properties) {
|
|
244296
|
-
if (!
|
|
244523
|
+
if (!import_ts_morph7.ts.isPropertyAssignment(prop)) {
|
|
244297
244524
|
continue;
|
|
244298
244525
|
}
|
|
244299
244526
|
const serviceId = this.resolvePropertyKeyToString(prop.name, useMap, filePath);
|
|
@@ -244314,8 +244541,8 @@ var ServiceProviderReader = class _ServiceProviderReader extends AstReader {
|
|
|
244314
244541
|
* Handles: `ProviderClass.publishMethod` and `[ProviderClass, 'method']`.
|
|
244315
244542
|
*/
|
|
244316
244543
|
extractHandlerFromValue(node, useMap, filePath, currentClass) {
|
|
244317
|
-
if (
|
|
244318
|
-
const className =
|
|
244544
|
+
if (import_ts_morph7.ts.isPropertyAccessExpression(node)) {
|
|
244545
|
+
const className = import_ts_morph7.ts.isIdentifier(node.expression) ? node.expression.text : void 0;
|
|
244319
244546
|
if (className === void 0) {
|
|
244320
244547
|
return void 0;
|
|
244321
244548
|
}
|
|
@@ -244323,7 +244550,7 @@ var ServiceProviderReader = class _ServiceProviderReader extends AstReader {
|
|
|
244323
244550
|
const resolvedClass = className === "self" || className === "this" ? currentClass : className;
|
|
244324
244551
|
return [resolvedClass, methodName];
|
|
244325
244552
|
}
|
|
244326
|
-
if (
|
|
244553
|
+
if (import_ts_morph7.ts.isArrayLiteralExpression(node) && node.elements.length === 2) {
|
|
244327
244554
|
const raw = this.extractHandlerFromTsArray(node, useMap, filePath, currentClass);
|
|
244328
244555
|
if (raw !== void 0) {
|
|
244329
244556
|
return [raw.class, raw.method];
|
|
@@ -244334,11 +244561,11 @@ var ServiceProviderReader = class _ServiceProviderReader extends AstReader {
|
|
|
244334
244561
|
};
|
|
244335
244562
|
|
|
244336
244563
|
// src/Sindri/Generator/Ast/Cli/AstCliDataFileGenerator.ts
|
|
244337
|
-
var
|
|
244564
|
+
var import_ts_morph9 = __toESM(require_ts_morph(), 1);
|
|
244338
244565
|
|
|
244339
244566
|
// src/Sindri/Generator/Abstract/AstFileGenerator.ts
|
|
244340
244567
|
var fs2 = __toESM(require("fs"), 1);
|
|
244341
|
-
var
|
|
244568
|
+
var import_ts_morph8 = __toESM(require_ts_morph(), 1);
|
|
244342
244569
|
var AstFileGenerator = class {
|
|
244343
244570
|
/**
|
|
244344
244571
|
* Build a property access or string literal expression from a "ClassName::CASE" string.
|
|
@@ -244346,12 +244573,33 @@ var AstFileGenerator = class {
|
|
|
244346
244573
|
buildEnumCaseExpr(fqnColonCase) {
|
|
244347
244574
|
const pos = fqnColonCase.indexOf("::");
|
|
244348
244575
|
if (pos === -1) {
|
|
244349
|
-
return
|
|
244576
|
+
return import_ts_morph8.ts.factory.createStringLiteral(fqnColonCase);
|
|
244350
244577
|
}
|
|
244351
244578
|
const fqn = fqnColonCase.substring(0, pos);
|
|
244352
244579
|
const caseName = fqnColonCase.substring(pos + 2);
|
|
244353
244580
|
const className = fqn.slice(fqn.lastIndexOf("\\") + 1);
|
|
244354
|
-
return
|
|
244581
|
+
return import_ts_morph8.ts.factory.createPropertyAccessExpression(import_ts_morph8.ts.factory.createIdentifier(className), caseName);
|
|
244582
|
+
}
|
|
244583
|
+
/**
|
|
244584
|
+
* Build the `import { X } from '...';` block for the provider/handler classes
|
|
244585
|
+
* a generated data cache references, followed by a trailing newline (or an
|
|
244586
|
+
* empty string when there are no such imports).
|
|
244587
|
+
*
|
|
244588
|
+
* Names the generated file's fixed framework header already binds are
|
|
244589
|
+
* dropped: those are the same framework classes under the same names, and
|
|
244590
|
+
* emitting them twice is a duplicate-identifier error.
|
|
244591
|
+
*/
|
|
244592
|
+
buildUserImportsBlock(classImportMap, reservedNames) {
|
|
244593
|
+
const userImports = Object.entries(classImportMap).filter(([name]) => !reservedNames.includes(name)).map(([name, specifier]) => `import { ${name} } from '${specifier}';`).join("\n");
|
|
244594
|
+
return userImports ? `${userImports}
|
|
244595
|
+
` : "";
|
|
244596
|
+
}
|
|
244597
|
+
/**
|
|
244598
|
+
* Render the fixed framework imports a generated data file always carries.
|
|
244599
|
+
*/
|
|
244600
|
+
buildFrameworkImportLines(imports, isType = false) {
|
|
244601
|
+
const keyword = isType ? "import type" : "import";
|
|
244602
|
+
return Object.entries(imports).map(([name, specifier]) => `${keyword} { ${name} } from '${specifier}';`);
|
|
244355
244603
|
}
|
|
244356
244604
|
writeFile(directory, className, data) {
|
|
244357
244605
|
const filePath = directory.replace(/\/$/, "") + `/${className}.ts`;
|
|
@@ -244370,33 +244618,42 @@ var AstFileGenerator = class {
|
|
|
244370
244618
|
};
|
|
244371
244619
|
|
|
244372
244620
|
// src/Sindri/Generator/Ast/Cli/AstCliDataFileGenerator.ts
|
|
244373
|
-
var AstCliDataFileGenerator = class extends AstFileGenerator {
|
|
244621
|
+
var AstCliDataFileGenerator = class _AstCliDataFileGenerator extends AstFileGenerator {
|
|
244622
|
+
/** The framework classes every generated CLI data file imports as values. */
|
|
244623
|
+
static FRAMEWORK_IMPORTS = {
|
|
244624
|
+
CliRoutingData: "@valkyrjaio/valkyrja/Cli/Routing/Data/CliRoutingData.ts",
|
|
244625
|
+
Route: "@valkyrjaio/valkyrja/Cli/Routing/Data/Route.ts",
|
|
244626
|
+
ArgumentParameter: "@valkyrjaio/valkyrja/Cli/Routing/Data/ArgumentParameter.ts",
|
|
244627
|
+
OptionParameter: "@valkyrjaio/valkyrja/Cli/Routing/Data/OptionParameter.ts",
|
|
244628
|
+
ArgumentMode: "@valkyrjaio/valkyrja/Cli/Routing/Enum/ArgumentMode.ts",
|
|
244629
|
+
ArgumentValueMode: "@valkyrjaio/valkyrja/Cli/Routing/Enum/ArgumentValueMode.ts",
|
|
244630
|
+
OptionMode: "@valkyrjaio/valkyrja/Cli/Routing/Enum/OptionMode.ts",
|
|
244631
|
+
OptionValueMode: "@valkyrjaio/valkyrja/Cli/Routing/Enum/OptionValueMode.ts"
|
|
244632
|
+
};
|
|
244633
|
+
/** The framework types every generated CLI data file imports. */
|
|
244634
|
+
static FRAMEWORK_TYPE_IMPORTS = {
|
|
244635
|
+
RouteContract: "@valkyrjaio/valkyrja/Cli/Routing/Data/Contract/RouteContract.ts"
|
|
244636
|
+
};
|
|
244374
244637
|
classImportMap = {};
|
|
244375
|
-
printer =
|
|
244376
|
-
dummySourceFile =
|
|
244638
|
+
printer = import_ts_morph9.ts.createPrinter({ newLine: import_ts_morph9.ts.NewLineKind.LineFeed });
|
|
244639
|
+
dummySourceFile = import_ts_morph9.ts.createSourceFile(
|
|
244377
244640
|
"_dummy.ts",
|
|
244378
244641
|
"",
|
|
244379
|
-
|
|
244642
|
+
import_ts_morph9.ts.ScriptTarget.ESNext,
|
|
244380
244643
|
false,
|
|
244381
|
-
|
|
244644
|
+
import_ts_morph9.ts.ScriptKind.TS
|
|
244382
244645
|
);
|
|
244383
244646
|
generateFile(directory, className, namespace, routes) {
|
|
244384
|
-
const
|
|
244385
|
-
|
|
244386
|
-
|
|
244647
|
+
const userImportsBlock = this.buildUserImportsBlock(this.classImportMap, [
|
|
244648
|
+
...Object.keys(_AstCliDataFileGenerator.FRAMEWORK_IMPORTS),
|
|
244649
|
+
...Object.keys(_AstCliDataFileGenerator.FRAMEWORK_TYPE_IMPORTS)
|
|
244650
|
+
]);
|
|
244387
244651
|
const contents = this.generateClassContents(routes);
|
|
244388
244652
|
const data = [
|
|
244389
244653
|
"// This file was automatically generated by Sindri.",
|
|
244390
244654
|
"",
|
|
244391
|
-
|
|
244392
|
-
|
|
244393
|
-
`import { ArgumentParameter } from '@valkyrjaio/valkyrja/Cli/Routing/Data/ArgumentParameter.ts';`,
|
|
244394
|
-
`import { OptionParameter } from '@valkyrjaio/valkyrja/Cli/Routing/Data/OptionParameter.ts';`,
|
|
244395
|
-
`import { ArgumentMode } from '@valkyrjaio/valkyrja/Cli/Routing/Enum/ArgumentMode.ts';`,
|
|
244396
|
-
`import { ArgumentValueMode } from '@valkyrjaio/valkyrja/Cli/Routing/Enum/ArgumentValueMode.ts';`,
|
|
244397
|
-
`import { OptionMode } from '@valkyrjaio/valkyrja/Cli/Routing/Enum/OptionMode.ts';`,
|
|
244398
|
-
`import { OptionValueMode } from '@valkyrjaio/valkyrja/Cli/Routing/Enum/OptionValueMode.ts';`,
|
|
244399
|
-
`import type { RouteContract } from '@valkyrjaio/valkyrja/Cli/Routing/Data/Contract/RouteContract.ts';`,
|
|
244655
|
+
...this.buildFrameworkImportLines(_AstCliDataFileGenerator.FRAMEWORK_IMPORTS),
|
|
244656
|
+
...this.buildFrameworkImportLines(_AstCliDataFileGenerator.FRAMEWORK_TYPE_IMPORTS, true),
|
|
244400
244657
|
userImportsBlock,
|
|
244401
244658
|
`export class ${className} extends CliRoutingData {`,
|
|
244402
244659
|
` constructor() {`,
|
|
@@ -244407,6 +244664,46 @@ var AstCliDataFileGenerator = class extends AstFileGenerator {
|
|
|
244407
244664
|
].join("\n");
|
|
244408
244665
|
return this.writeFile(directory, className, data);
|
|
244409
244666
|
}
|
|
244667
|
+
/**
|
|
244668
|
+
* Generate the CLI routing data file from imperative `getRoutes()` route
|
|
244669
|
+
* objects — each `new Route(name, description, handler, ...)` is keyed by
|
|
244670
|
+
* its command name (the first constructor argument) and emitted verbatim.
|
|
244671
|
+
*/
|
|
244672
|
+
generateFileFromRoutes(directory, className, namespace, routeExprs) {
|
|
244673
|
+
const routes = {};
|
|
244674
|
+
for (const expr of routeExprs) {
|
|
244675
|
+
if (!import_ts_morph9.ts.isNewExpression(expr)) {
|
|
244676
|
+
continue;
|
|
244677
|
+
}
|
|
244678
|
+
const key = this.routeKey((expr.arguments ?? [])[0]);
|
|
244679
|
+
if (key === void 0) {
|
|
244680
|
+
continue;
|
|
244681
|
+
}
|
|
244682
|
+
routes[key] = expr;
|
|
244683
|
+
}
|
|
244684
|
+
return this.generateFile(directory, className, namespace, routes);
|
|
244685
|
+
}
|
|
244686
|
+
/**
|
|
244687
|
+
* Derive the map key for a route from its name argument.
|
|
244688
|
+
*
|
|
244689
|
+
* A literal name keys the map by its own text. A constant reference
|
|
244690
|
+
* (`CliCommandName.LIST` — how the framework's own commands name
|
|
244691
|
+
* themselves) is kept as a `Class::CASE` marker, so the generated file
|
|
244692
|
+
* emits the constant reference as a computed key rather than baking in the
|
|
244693
|
+
* value it happens to hold today.
|
|
244694
|
+
*/
|
|
244695
|
+
routeKey(nameArg) {
|
|
244696
|
+
if (nameArg === void 0) {
|
|
244697
|
+
return void 0;
|
|
244698
|
+
}
|
|
244699
|
+
if (import_ts_morph9.ts.isStringLiteral(nameArg)) {
|
|
244700
|
+
return nameArg.text;
|
|
244701
|
+
}
|
|
244702
|
+
if (import_ts_morph9.ts.isPropertyAccessExpression(nameArg) && import_ts_morph9.ts.isIdentifier(nameArg.expression)) {
|
|
244703
|
+
return `${nameArg.expression.text}::${nameArg.name.text}`;
|
|
244704
|
+
}
|
|
244705
|
+
return void 0;
|
|
244706
|
+
}
|
|
244410
244707
|
generateClassContents(routes) {
|
|
244411
244708
|
const entries = Object.entries(routes);
|
|
244412
244709
|
if (entries.length === 0) {
|
|
@@ -244414,38 +244711,53 @@ var AstCliDataFileGenerator = class extends AstFileGenerator {
|
|
|
244414
244711
|
}
|
|
244415
244712
|
const lines = [];
|
|
244416
244713
|
for (const [key, valueExpr] of entries) {
|
|
244417
|
-
const
|
|
244418
|
-
const
|
|
244419
|
-
const printedValue = this.printer.printNode(import_ts_morph8.ts.EmitHint.Unspecified, valueExpr, this.dummySourceFile);
|
|
244420
|
-
const formattedKey = key.includes("::") ? `[${printedKey}]` : `['${printedKey}']`;
|
|
244714
|
+
const printedValue = this.printExpr(valueExpr);
|
|
244715
|
+
const formattedKey = key.includes("::") ? `[${this.printer.printNode(import_ts_morph9.ts.EmitHint.Unspecified, this.buildEnumCaseExpr(key), this.dummySourceFile)}]` : `['${key}']`;
|
|
244421
244716
|
lines.push(` ${formattedKey}: (): RouteContract => ${printedValue},`);
|
|
244422
244717
|
}
|
|
244423
|
-
return ["super({",
|
|
244718
|
+
return ["super({", ...lines, " });"].join("\n ");
|
|
244719
|
+
}
|
|
244720
|
+
/**
|
|
244721
|
+
* Print an expression to source. Parsed nodes (from a `getRoutes()` body)
|
|
244722
|
+
* are emitted via their original source text; synthesized nodes (which
|
|
244723
|
+
* carry no source positions) are emitted through the printer.
|
|
244724
|
+
*/
|
|
244725
|
+
printExpr(expr) {
|
|
244726
|
+
return expr.pos >= 0 ? expr.getText() : this.printer.printNode(import_ts_morph9.ts.EmitHint.Unspecified, expr, this.dummySourceFile);
|
|
244424
244727
|
}
|
|
244425
244728
|
};
|
|
244426
244729
|
|
|
244427
244730
|
// src/Sindri/Generator/Ast/Container/AstContainerDataFileGenerator.ts
|
|
244428
|
-
var
|
|
244429
|
-
var AstContainerDataFileGenerator = class extends AstFileGenerator {
|
|
244731
|
+
var import_ts_morph10 = __toESM(require_ts_morph(), 1);
|
|
244732
|
+
var AstContainerDataFileGenerator = class _AstContainerDataFileGenerator extends AstFileGenerator {
|
|
244733
|
+
/** The framework class every generated container data file imports as a value. */
|
|
244734
|
+
static FRAMEWORK_IMPORTS = {
|
|
244735
|
+
ContainerData: "@valkyrjaio/valkyrja/Container/Data/ContainerData.ts"
|
|
244736
|
+
};
|
|
244737
|
+
/** The framework type every generated container data file imports. */
|
|
244738
|
+
static FRAMEWORK_TYPE_IMPORTS = {
|
|
244739
|
+
ContainerContract: "@valkyrjaio/valkyrja/Container/Manager/Contract/ContainerContract.ts"
|
|
244740
|
+
};
|
|
244430
244741
|
classImportMap = {};
|
|
244431
|
-
printer =
|
|
244432
|
-
dummySourceFile =
|
|
244742
|
+
printer = import_ts_morph10.ts.createPrinter({ newLine: import_ts_morph10.ts.NewLineKind.LineFeed });
|
|
244743
|
+
dummySourceFile = import_ts_morph10.ts.createSourceFile(
|
|
244433
244744
|
"_dummy.ts",
|
|
244434
244745
|
"",
|
|
244435
|
-
|
|
244746
|
+
import_ts_morph10.ts.ScriptTarget.ESNext,
|
|
244436
244747
|
false,
|
|
244437
|
-
|
|
244748
|
+
import_ts_morph10.ts.ScriptKind.TS
|
|
244438
244749
|
);
|
|
244439
244750
|
generateFile(directory, className, namespace, publishers) {
|
|
244440
|
-
const
|
|
244441
|
-
|
|
244442
|
-
|
|
244751
|
+
const userImportsBlock = this.buildUserImportsBlock(this.classImportMap, [
|
|
244752
|
+
...Object.keys(_AstContainerDataFileGenerator.FRAMEWORK_IMPORTS),
|
|
244753
|
+
...Object.keys(_AstContainerDataFileGenerator.FRAMEWORK_TYPE_IMPORTS)
|
|
244754
|
+
]);
|
|
244443
244755
|
const contents = this.generateClassContents(publishers);
|
|
244444
244756
|
const data = [
|
|
244445
244757
|
"// This file was automatically generated by Sindri.",
|
|
244446
244758
|
"",
|
|
244447
|
-
|
|
244448
|
-
|
|
244759
|
+
...this.buildFrameworkImportLines(_AstContainerDataFileGenerator.FRAMEWORK_IMPORTS),
|
|
244760
|
+
...this.buildFrameworkImportLines(_AstContainerDataFileGenerator.FRAMEWORK_TYPE_IMPORTS, true),
|
|
244449
244761
|
userImportsBlock,
|
|
244450
244762
|
`export class ${className} extends ContainerData {`,
|
|
244451
244763
|
` constructor() {`,
|
|
@@ -244463,10 +244775,8 @@ var AstContainerDataFileGenerator = class extends AstFileGenerator {
|
|
|
244463
244775
|
}
|
|
244464
244776
|
const lines = [];
|
|
244465
244777
|
for (const [serviceId, [providerClass, methodName]] of entries) {
|
|
244466
|
-
const keyExpr = this.buildEnumCaseExpr(serviceId);
|
|
244467
|
-
const printedKey = this.printer.printNode(import_ts_morph9.ts.EmitHint.Unspecified, keyExpr, this.dummySourceFile);
|
|
244468
244778
|
const shortProviderClass = providerClass.slice(providerClass.lastIndexOf("\\") + 1);
|
|
244469
|
-
const formattedKey = serviceId.includes("::") ? `[${
|
|
244779
|
+
const formattedKey = serviceId.includes("::") ? `[${this.printer.printNode(import_ts_morph10.ts.EmitHint.Unspecified, this.buildEnumCaseExpr(serviceId), this.dummySourceFile)}]` : `['${serviceId}']`;
|
|
244470
244780
|
lines.push(
|
|
244471
244781
|
` ${formattedKey}: (container: ContainerContract) => ${shortProviderClass}.${methodName}(container),`
|
|
244472
244782
|
);
|
|
@@ -244478,28 +244788,45 @@ var AstContainerDataFileGenerator = class extends AstFileGenerator {
|
|
|
244478
244788
|
};
|
|
244479
244789
|
|
|
244480
244790
|
// src/Sindri/Generator/Ast/Event/AstEventDataFileGenerator.ts
|
|
244481
|
-
var
|
|
244482
|
-
var AstEventDataFileGenerator = class extends AstFileGenerator {
|
|
244791
|
+
var import_ts_morph11 = __toESM(require_ts_morph(), 1);
|
|
244792
|
+
var AstEventDataFileGenerator = class _AstEventDataFileGenerator extends AstFileGenerator {
|
|
244793
|
+
/** The framework class every generated event data file imports as a value. */
|
|
244794
|
+
static FRAMEWORK_IMPORTS = {
|
|
244795
|
+
EventData: "@valkyrjaio/valkyrja/Event/Data/EventData.ts"
|
|
244796
|
+
};
|
|
244797
|
+
/** The framework classes a generated event data file imports only when it holds listeners. */
|
|
244798
|
+
static LISTENER_IMPORTS = {
|
|
244799
|
+
Listener: "@valkyrjaio/valkyrja/Event/Data/Listener.ts"
|
|
244800
|
+
};
|
|
244801
|
+
/** The framework types a generated event data file imports only when it holds listeners. */
|
|
244802
|
+
static LISTENER_TYPE_IMPORTS = {
|
|
244803
|
+
ListenerContract: "@valkyrjaio/valkyrja/Event/Data/Contract/ListenerContract.ts"
|
|
244804
|
+
};
|
|
244483
244805
|
classImportMap = {};
|
|
244484
|
-
printer =
|
|
244485
|
-
dummySourceFile =
|
|
244806
|
+
printer = import_ts_morph11.ts.createPrinter({ newLine: import_ts_morph11.ts.NewLineKind.LineFeed });
|
|
244807
|
+
dummySourceFile = import_ts_morph11.ts.createSourceFile(
|
|
244486
244808
|
"_dummy.ts",
|
|
244487
244809
|
"",
|
|
244488
|
-
|
|
244810
|
+
import_ts_morph11.ts.ScriptTarget.ESNext,
|
|
244489
244811
|
false,
|
|
244490
|
-
|
|
244812
|
+
import_ts_morph11.ts.ScriptKind.TS
|
|
244491
244813
|
);
|
|
244492
244814
|
generateFile(directory, className, namespace, listeners) {
|
|
244493
|
-
const
|
|
244494
|
-
|
|
244495
|
-
|
|
244815
|
+
const userImportsBlock = this.buildUserImportsBlock(this.classImportMap, [
|
|
244816
|
+
...Object.keys(_AstEventDataFileGenerator.FRAMEWORK_IMPORTS),
|
|
244817
|
+
...Object.keys(_AstEventDataFileGenerator.LISTENER_IMPORTS),
|
|
244818
|
+
...Object.keys(_AstEventDataFileGenerator.LISTENER_TYPE_IMPORTS)
|
|
244819
|
+
]);
|
|
244496
244820
|
const contents = this.generateClassContents(listeners);
|
|
244821
|
+
const listenerImports = Object.keys(listeners).length > 0 ? [
|
|
244822
|
+
...this.buildFrameworkImportLines(_AstEventDataFileGenerator.LISTENER_IMPORTS),
|
|
244823
|
+
...this.buildFrameworkImportLines(_AstEventDataFileGenerator.LISTENER_TYPE_IMPORTS, true)
|
|
244824
|
+
] : [];
|
|
244497
244825
|
const data = [
|
|
244498
244826
|
"// This file was automatically generated by Sindri.",
|
|
244499
244827
|
"",
|
|
244500
|
-
|
|
244501
|
-
|
|
244502
|
-
`import type { ListenerContract } from '@valkyrjaio/valkyrja/Event/Data/Contract/ListenerContract.ts';`,
|
|
244828
|
+
...this.buildFrameworkImportLines(_AstEventDataFileGenerator.FRAMEWORK_IMPORTS),
|
|
244829
|
+
...listenerImports,
|
|
244503
244830
|
userImportsBlock,
|
|
244504
244831
|
`export class ${className} extends EventData {`,
|
|
244505
244832
|
` constructor() {`,
|
|
@@ -244517,7 +244844,7 @@ var AstEventDataFileGenerator = class extends AstFileGenerator {
|
|
|
244517
244844
|
}
|
|
244518
244845
|
const lines = [];
|
|
244519
244846
|
for (const [key, valueExpr] of entries) {
|
|
244520
|
-
const printed = this.printer.printNode(
|
|
244847
|
+
const printed = this.printer.printNode(import_ts_morph11.ts.EmitHint.Unspecified, valueExpr, this.dummySourceFile);
|
|
244521
244848
|
lines.push(` ['${key}']: (): ListenerContract => ${printed},`);
|
|
244522
244849
|
}
|
|
244523
244850
|
return ["super(", " {},", " {", ...lines, " },", " );"].join(
|
|
@@ -244527,7 +244854,22 @@ var AstEventDataFileGenerator = class extends AstFileGenerator {
|
|
|
244527
244854
|
};
|
|
244528
244855
|
|
|
244529
244856
|
// src/Sindri/Generator/Ast/Http/AstHttpDataFileGenerator.ts
|
|
244530
|
-
var
|
|
244857
|
+
var import_ts_morph12 = __toESM(require_ts_morph(), 1);
|
|
244858
|
+
|
|
244859
|
+
// node_modules/@valkyrjaio/valkyrja/src/Valkyrja/Http/Message/Enum/RequestMethod.ts
|
|
244860
|
+
function allRequestMethods() {
|
|
244861
|
+
return [
|
|
244862
|
+
"GET" /* GET */,
|
|
244863
|
+
"HEAD" /* HEAD */,
|
|
244864
|
+
"POST" /* POST */,
|
|
244865
|
+
"PUT" /* PUT */,
|
|
244866
|
+
"DELETE" /* DELETE */,
|
|
244867
|
+
"CONNECT" /* CONNECT */,
|
|
244868
|
+
"OPTIONS" /* OPTIONS */,
|
|
244869
|
+
"TRACE" /* TRACE */,
|
|
244870
|
+
"PATCH" /* PATCH */
|
|
244871
|
+
];
|
|
244872
|
+
}
|
|
244531
244873
|
|
|
244532
244874
|
// node_modules/@valkyrjaio/valkyrja/src/Valkyrja/Http/Throwable/Exception/Abstract/HttpRuntimeException.ts
|
|
244533
244875
|
var HttpRuntimeException = class extends ValkyrjaRuntimeException {
|
|
@@ -244884,8 +245226,8 @@ var Regex = class _Regex {
|
|
|
244884
245226
|
static ALPHA_UPPERCASE = "[A-Z]+";
|
|
244885
245227
|
static ALPHA_NUM = "[a-zA-Z0-9]+";
|
|
244886
245228
|
static ALPHA_NUM_UNDERSCORE = "\\w+";
|
|
244887
|
-
static START = "
|
|
244888
|
-
static END = "
|
|
245229
|
+
static START = "^";
|
|
245230
|
+
static END = "$";
|
|
244889
245231
|
static START_CAPTURE_GROUP = "(";
|
|
244890
245232
|
static START_NON_CAPTURE_GROUP = "(?:";
|
|
244891
245233
|
static END_CAPTURE_GROUP = ")";
|
|
@@ -244977,39 +245319,74 @@ var GeneratorUnreachableException = class extends GeneratorRuntimeException {
|
|
|
244977
245319
|
};
|
|
244978
245320
|
|
|
244979
245321
|
// src/Sindri/Generator/Ast/Http/AstHttpDataFileGenerator.ts
|
|
244980
|
-
var AstHttpDataFileGenerator = class extends AstFileGenerator {
|
|
245322
|
+
var AstHttpDataFileGenerator = class _AstHttpDataFileGenerator extends AstFileGenerator {
|
|
245323
|
+
/** The framework classes every generated HTTP data file imports as values. */
|
|
245324
|
+
static FRAMEWORK_IMPORTS = {
|
|
245325
|
+
HttpRoutingData: "@valkyrjaio/valkyrja/Http/Routing/Data/HttpRoutingData.ts",
|
|
245326
|
+
DynamicRoute: "@valkyrjaio/valkyrja/Http/Routing/Data/DynamicRoute.ts",
|
|
245327
|
+
Route: "@valkyrjaio/valkyrja/Http/Routing/Data/Route.ts",
|
|
245328
|
+
Parameter: "@valkyrjaio/valkyrja/Http/Routing/Data/Parameter.ts",
|
|
245329
|
+
RequestMethod: "@valkyrjaio/valkyrja/Http/Message/Enum/RequestMethod.ts",
|
|
245330
|
+
Regex: "@valkyrjaio/valkyrja/Http/Routing/Constant/Regex.ts"
|
|
245331
|
+
};
|
|
245332
|
+
/** The framework types every generated HTTP data file imports. */
|
|
245333
|
+
static FRAMEWORK_TYPE_IMPORTS = {
|
|
245334
|
+
RouteContract: "@valkyrjaio/valkyrja/Http/Routing/Data/Contract/RouteContract.ts"
|
|
245335
|
+
};
|
|
244981
245336
|
classImportMap = {};
|
|
244982
245337
|
processor;
|
|
244983
|
-
printer =
|
|
244984
|
-
dummySourceFile =
|
|
245338
|
+
printer = import_ts_morph12.ts.createPrinter({ newLine: import_ts_morph12.ts.NewLineKind.LineFeed });
|
|
245339
|
+
dummySourceFile = import_ts_morph12.ts.createSourceFile(
|
|
244985
245340
|
"_dummy.ts",
|
|
244986
245341
|
"",
|
|
244987
|
-
|
|
245342
|
+
import_ts_morph12.ts.ScriptTarget.ESNext,
|
|
244988
245343
|
false,
|
|
244989
|
-
|
|
245344
|
+
import_ts_morph12.ts.ScriptKind.TS
|
|
244990
245345
|
);
|
|
244991
245346
|
constructor(processor = new Processor()) {
|
|
244992
245347
|
super();
|
|
244993
245348
|
this.processor = processor;
|
|
244994
245349
|
}
|
|
244995
245350
|
generateFile(directory, className, namespace, routes, routeData) {
|
|
244996
|
-
const
|
|
244997
|
-
|
|
244998
|
-
|
|
245351
|
+
const userImportsBlock = this.buildUserImportsBlock(this.classImportMap, [
|
|
245352
|
+
...Object.keys(_AstHttpDataFileGenerator.FRAMEWORK_IMPORTS),
|
|
245353
|
+
...Object.keys(_AstHttpDataFileGenerator.FRAMEWORK_TYPE_IMPORTS)
|
|
245354
|
+
]);
|
|
244999
245355
|
const routesContent = this.getRoutesAsContent(routes, routeData);
|
|
245000
245356
|
const paths = this.printNestedObject(this.buildPaths(routeData));
|
|
245001
245357
|
const dynamicPaths = this.printNestedObject(this.buildDynamicPaths(routeData));
|
|
245002
245358
|
const regexes = this.printNestedObject(this.buildRegexes(routeData));
|
|
245003
|
-
const data =
|
|
245359
|
+
const data = this.assembleFile(className, userImportsBlock, routesContent, paths, dynamicPaths, regexes);
|
|
245360
|
+
return this.writeFile(directory, className, data);
|
|
245361
|
+
}
|
|
245362
|
+
/**
|
|
245363
|
+
* Generate the routing data file from imperative `getRoutes()` route
|
|
245364
|
+
* objects (as opposed to attribute-scanned routes).
|
|
245365
|
+
*
|
|
245366
|
+
* Each route expression is emitted verbatim as a route closure and the
|
|
245367
|
+
* path/dynamic-path/regex lookup maps are derived from the route objects'
|
|
245368
|
+
* own arguments, mirroring the framework's runtime `RouteCollection`
|
|
245369
|
+
* (literal path and regex, request methods defaulting to `[HEAD, GET]`).
|
|
245370
|
+
*/
|
|
245371
|
+
generateFileFromRoutes(directory, className, _namespace, routeExprs) {
|
|
245372
|
+
const userImportsBlock = this.buildUserImportsBlock(this.classImportMap, [
|
|
245373
|
+
...Object.keys(_AstHttpDataFileGenerator.FRAMEWORK_IMPORTS),
|
|
245374
|
+
...Object.keys(_AstHttpDataFileGenerator.FRAMEWORK_TYPE_IMPORTS)
|
|
245375
|
+
]);
|
|
245376
|
+
const metas = routeExprs.map((expr) => this.extractRouteMeta(expr)).filter((meta) => meta !== void 0);
|
|
245377
|
+
const routesContent = this.getImperativeRoutesContent(metas);
|
|
245378
|
+
const paths = this.printNestedObject(this.buildImperativePaths(metas, false));
|
|
245379
|
+
const dynamicPaths = this.printNestedObject(this.buildImperativePaths(metas, true));
|
|
245380
|
+
const regexes = this.printNestedObject(this.buildImperativeRegexes(metas));
|
|
245381
|
+
const data = this.assembleFile(className, userImportsBlock, routesContent, paths, dynamicPaths, regexes);
|
|
245382
|
+
return this.writeFile(directory, className, data);
|
|
245383
|
+
}
|
|
245384
|
+
assembleFile(className, userImportsBlock, routesContent, paths, dynamicPaths, regexes) {
|
|
245385
|
+
return [
|
|
245004
245386
|
"// This file was automatically generated by Sindri.",
|
|
245005
245387
|
"",
|
|
245006
|
-
|
|
245007
|
-
|
|
245008
|
-
`import { Route } from '@valkyrjaio/valkyrja/Http/Routing/Data/Route.ts';`,
|
|
245009
|
-
`import { Parameter } from '@valkyrjaio/valkyrja/Http/Routing/Data/Parameter.ts';`,
|
|
245010
|
-
`import { RequestMethod } from '@valkyrjaio/valkyrja/Http/Message/Enum/RequestMethod.ts';`,
|
|
245011
|
-
`import { Regex } from '@valkyrjaio/valkyrja/Http/Routing/Constant/Regex.ts';`,
|
|
245012
|
-
`import type { RouteContract } from '@valkyrjaio/valkyrja/Http/Routing/Data/Contract/RouteContract.ts';`,
|
|
245388
|
+
...this.buildFrameworkImportLines(_AstHttpDataFileGenerator.FRAMEWORK_IMPORTS),
|
|
245389
|
+
...this.buildFrameworkImportLines(_AstHttpDataFileGenerator.FRAMEWORK_TYPE_IMPORTS, true),
|
|
245013
245390
|
userImportsBlock,
|
|
245014
245391
|
`export class ${className} extends HttpRoutingData {`,
|
|
245015
245392
|
` constructor() {`,
|
|
@@ -245023,7 +245400,6 @@ var AstHttpDataFileGenerator = class extends AstFileGenerator {
|
|
|
245023
245400
|
`}`,
|
|
245024
245401
|
""
|
|
245025
245402
|
].join("\n");
|
|
245026
|
-
return this.writeFile(directory, className, data);
|
|
245027
245403
|
}
|
|
245028
245404
|
generateClassContents(routes, routeData) {
|
|
245029
245405
|
const routesContent = this.getRoutesAsContent(routes, routeData);
|
|
@@ -245096,24 +245472,24 @@ var AstHttpDataFileGenerator = class extends AstFileGenerator {
|
|
|
245096
245472
|
const innerProps = [];
|
|
245097
245473
|
for (const [innerKey, value] of Object.entries(innerMap)) {
|
|
245098
245474
|
innerProps.push(
|
|
245099
|
-
|
|
245100
|
-
|
|
245101
|
-
|
|
245475
|
+
import_ts_morph12.ts.factory.createPropertyAssignment(
|
|
245476
|
+
import_ts_morph12.ts.factory.createStringLiteral(innerKey),
|
|
245477
|
+
import_ts_morph12.ts.factory.createStringLiteral(value)
|
|
245102
245478
|
)
|
|
245103
245479
|
);
|
|
245104
245480
|
}
|
|
245105
245481
|
outerProps.push(
|
|
245106
|
-
|
|
245107
|
-
|
|
245108
|
-
|
|
245482
|
+
import_ts_morph12.ts.factory.createPropertyAssignment(
|
|
245483
|
+
import_ts_morph12.ts.factory.createStringLiteral(outerKey),
|
|
245484
|
+
import_ts_morph12.ts.factory.createObjectLiteralExpression(innerProps, true)
|
|
245109
245485
|
)
|
|
245110
245486
|
);
|
|
245111
245487
|
}
|
|
245112
|
-
return
|
|
245488
|
+
return import_ts_morph12.ts.factory.createObjectLiteralExpression(outerProps, true);
|
|
245113
245489
|
}
|
|
245114
245490
|
printNestedObject(data) {
|
|
245115
245491
|
return this.printer.printNode(
|
|
245116
|
-
|
|
245492
|
+
import_ts_morph12.ts.EmitHint.Unspecified,
|
|
245117
245493
|
this.buildNestedStringArrayExpr(data),
|
|
245118
245494
|
this.dummySourceFile
|
|
245119
245495
|
);
|
|
@@ -245172,19 +245548,101 @@ var AstHttpDataFileGenerator = class extends AstFileGenerator {
|
|
|
245172
245548
|
for (const [key, routeExpr] of entries) {
|
|
245173
245549
|
const data = routeData[key] ?? null;
|
|
245174
245550
|
let expr = routeExpr;
|
|
245175
|
-
if (data !== null && data.isDynamic &&
|
|
245551
|
+
if (data !== null && data.isDynamic && import_ts_morph12.ts.isNewExpression(expr)) {
|
|
245176
245552
|
const computedRegex = data.parameters.length > 0 ? this.computeRegex(data) : "";
|
|
245177
|
-
const args = [...expr.arguments ?? [],
|
|
245178
|
-
expr =
|
|
245553
|
+
const args = [...expr.arguments ?? [], import_ts_morph12.ts.factory.createStringLiteral(computedRegex)];
|
|
245554
|
+
expr = import_ts_morph12.ts.factory.createNewExpression(expr.expression, expr.typeArguments, args);
|
|
245179
245555
|
}
|
|
245180
|
-
const
|
|
245181
|
-
const
|
|
245182
|
-
const printedRoute = this.printer.printNode(import_ts_morph11.ts.EmitHint.Unspecified, expr, this.dummySourceFile);
|
|
245183
|
-
const formattedKey = key.includes("::") ? `[${printedKey}]` : `['${printedKey}']`;
|
|
245556
|
+
const printedRoute = this.printer.printNode(import_ts_morph12.ts.EmitHint.Unspecified, expr, this.dummySourceFile);
|
|
245557
|
+
const formattedKey = key.includes("::") ? `[${this.printer.printNode(import_ts_morph12.ts.EmitHint.Unspecified, this.buildEnumCaseExpr(key), this.dummySourceFile)}]` : `['${key}']`;
|
|
245184
245558
|
lines.push(` ${formattedKey}: (): RouteContract => ${printedRoute},`);
|
|
245185
245559
|
}
|
|
245186
245560
|
return ["{", ...lines, " }"].join("\n ");
|
|
245187
245561
|
}
|
|
245562
|
+
// -------------------------------------------------------------------------
|
|
245563
|
+
// Imperative `getRoutes()` support
|
|
245564
|
+
// -------------------------------------------------------------------------
|
|
245565
|
+
/**
|
|
245566
|
+
* Extract routing metadata from a `new Route(...)` / `new DynamicRoute(...)`
|
|
245567
|
+
* expression, matching the framework constructor argument order:
|
|
245568
|
+
* Route(path, name, handler, requestMethods?)
|
|
245569
|
+
* DynamicRoute(path, name, regex, parameters, handler, requestMethods?)
|
|
245570
|
+
*/
|
|
245571
|
+
extractRouteMeta(expr) {
|
|
245572
|
+
if (!import_ts_morph12.ts.isNewExpression(expr) || !import_ts_morph12.ts.isIdentifier(expr.expression)) {
|
|
245573
|
+
return void 0;
|
|
245574
|
+
}
|
|
245575
|
+
const isDynamic = expr.expression.text === "DynamicRoute";
|
|
245576
|
+
const args = expr.arguments ?? import_ts_morph12.ts.factory.createNodeArray();
|
|
245577
|
+
const path4 = this.stringArg(args[0]);
|
|
245578
|
+
const name = this.stringArg(args[1]);
|
|
245579
|
+
if (name === void 0 || path4 === void 0) {
|
|
245580
|
+
return void 0;
|
|
245581
|
+
}
|
|
245582
|
+
const regex = isDynamic ? this.stringArg(args[2]) ?? "" : "";
|
|
245583
|
+
const methodsArg = isDynamic ? args[5] : args[3];
|
|
245584
|
+
const methods = this.extractMethodNamesFromArg(methodsArg);
|
|
245585
|
+
return { expr, name, path: path4, isDynamic, regex, methods };
|
|
245586
|
+
}
|
|
245587
|
+
stringArg(node) {
|
|
245588
|
+
return node !== void 0 && import_ts_morph12.ts.isStringLiteral(node) ? node.text : void 0;
|
|
245589
|
+
}
|
|
245590
|
+
/**
|
|
245591
|
+
* Resolve a `[RequestMethod.GET, ...]` argument to method-name strings,
|
|
245592
|
+
* defaulting to `[HEAD, GET]` (the framework `Route` default) when omitted
|
|
245593
|
+
* and expanding `RequestMethod.ANY` to every request method.
|
|
245594
|
+
*/
|
|
245595
|
+
extractMethodNamesFromArg(node) {
|
|
245596
|
+
if (node === void 0 || !import_ts_morph12.ts.isArrayLiteralExpression(node)) {
|
|
245597
|
+
return ["HEAD" /* HEAD */, "GET" /* GET */];
|
|
245598
|
+
}
|
|
245599
|
+
const methods = [];
|
|
245600
|
+
for (const element of node.elements) {
|
|
245601
|
+
if (!import_ts_morph12.ts.isPropertyAccessExpression(element)) {
|
|
245602
|
+
continue;
|
|
245603
|
+
}
|
|
245604
|
+
const method = element.name.text;
|
|
245605
|
+
if (method === "ANY") {
|
|
245606
|
+
return allRequestMethods();
|
|
245607
|
+
}
|
|
245608
|
+
methods.push(method);
|
|
245609
|
+
}
|
|
245610
|
+
return methods;
|
|
245611
|
+
}
|
|
245612
|
+
getImperativeRoutesContent(metas) {
|
|
245613
|
+
if (metas.length === 0) {
|
|
245614
|
+
return "{}";
|
|
245615
|
+
}
|
|
245616
|
+
const lines = [];
|
|
245617
|
+
for (const meta of metas) {
|
|
245618
|
+
lines.push(` ['${meta.name}']: (): RouteContract => ${meta.expr.getText()},`);
|
|
245619
|
+
}
|
|
245620
|
+
return ["{", ...lines, " }"].join("\n ");
|
|
245621
|
+
}
|
|
245622
|
+
buildImperativePaths(metas, dynamic) {
|
|
245623
|
+
const paths = {};
|
|
245624
|
+
for (const meta of metas) {
|
|
245625
|
+
if (meta.isDynamic !== dynamic) {
|
|
245626
|
+
continue;
|
|
245627
|
+
}
|
|
245628
|
+
for (const method of meta.methods) {
|
|
245629
|
+
(paths[method] ??= {})[meta.path] = meta.name;
|
|
245630
|
+
}
|
|
245631
|
+
}
|
|
245632
|
+
return paths;
|
|
245633
|
+
}
|
|
245634
|
+
buildImperativeRegexes(metas) {
|
|
245635
|
+
const regexes = {};
|
|
245636
|
+
for (const meta of metas) {
|
|
245637
|
+
if (!meta.isDynamic || meta.regex === "") {
|
|
245638
|
+
continue;
|
|
245639
|
+
}
|
|
245640
|
+
for (const method of meta.methods) {
|
|
245641
|
+
(regexes[method] ??= {})[meta.regex] = meta.name;
|
|
245642
|
+
}
|
|
245643
|
+
}
|
|
245644
|
+
return regexes;
|
|
245645
|
+
}
|
|
245188
245646
|
};
|
|
245189
245647
|
|
|
245190
245648
|
// src/Sindri/Generate/Abstract/GenerateDataFromAst.ts
|
|
@@ -245226,8 +245684,8 @@ var WarningFormatter = class extends Formatter {
|
|
|
245226
245684
|
|
|
245227
245685
|
// node_modules/@valkyrjaio/valkyrja/src/Valkyrja/Application/Constant/ApplicationInfo.ts
|
|
245228
245686
|
var ApplicationInfo = class {
|
|
245229
|
-
static VERSION = "26.
|
|
245230
|
-
static VERSION_BUILD_DATE_TIME = "July
|
|
245687
|
+
static VERSION = "26.4.0";
|
|
245688
|
+
static VERSION_BUILD_DATE_TIME = "July 27 2026 22:05:07 MST";
|
|
245231
245689
|
static ASCII = `
|
|
245232
245690
|
_ _ _
|
|
245233
245691
|
/\\ /\\__ _| | | ___ _ _ __(_) __ _
|
|
@@ -245336,8 +245794,8 @@ var Header = class extends Message {
|
|
|
245336
245794
|
|
|
245337
245795
|
// src/Sindri/Constant/SindriInfo.ts
|
|
245338
245796
|
var SindriInfo = class {
|
|
245339
|
-
static VERSION = "26.
|
|
245340
|
-
static VERSION_BUILD_DATE_TIME = "July
|
|
245797
|
+
static VERSION = "26.4.0";
|
|
245798
|
+
static VERSION_BUILD_DATE_TIME = "July 27 2026 22:16:03 MST";
|
|
245341
245799
|
static ICON = ` \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588
|
|
245342
245800
|
\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588
|
|
245343
245801
|
\u2588\u2588\u2588\u2588
|
|
@@ -245483,17 +245941,142 @@ var GenerateDataFromAst = class {
|
|
|
245483
245941
|
}
|
|
245484
245942
|
return "";
|
|
245485
245943
|
}
|
|
245944
|
+
/**
|
|
245945
|
+
* Build the `import { X } from '...'` specifier for a class file, relative
|
|
245946
|
+
* to the generated data file's output directory. Used to import the
|
|
245947
|
+
* provider/handler classes referenced by the generated data caches.
|
|
245948
|
+
*/
|
|
245949
|
+
relativeSpecifier(fromDir, toFile) {
|
|
245950
|
+
const relative2 = path3.relative(fromDir, toFile).split(path3.sep).join("/");
|
|
245951
|
+
return relative2.startsWith(".") ? relative2 : `./${relative2}`;
|
|
245952
|
+
}
|
|
245953
|
+
/**
|
|
245954
|
+
* Build the specifier a generated data file should import a class file by.
|
|
245955
|
+
*
|
|
245956
|
+
* Application source is imported by a path relative to the data directory;
|
|
245957
|
+
* a file belonging to an installed package is imported by that package's
|
|
245958
|
+
* own public specifier — so the framework classes the cache references are
|
|
245959
|
+
* written exactly as hand-written application code writes them
|
|
245960
|
+
* (`@valkyrjaio/valkyrja/Cli/Routing/Data/Route.ts`), never as a brittle
|
|
245961
|
+
* reach into `node_modules`.
|
|
245962
|
+
*/
|
|
245963
|
+
importSpecifier(fromDir, toFile) {
|
|
245964
|
+
return this.packageSpecifier(toFile) ?? this.relativeSpecifier(fromDir, toFile);
|
|
245965
|
+
}
|
|
245966
|
+
/**
|
|
245967
|
+
* Map an absolute path inside an installed package back to the specifier
|
|
245968
|
+
* that package publicly exposes it as, or undefined when the file is not
|
|
245969
|
+
* part of one.
|
|
245970
|
+
*
|
|
245971
|
+
* The package's `exports` map is inverted: for `"./*.ts": "./src/*.ts"` a
|
|
245972
|
+
* file at `<package>/src/Foo.ts` maps back to `<name>/Foo.ts`. Packages
|
|
245973
|
+
* with no matching pattern fall back to the path as written under the
|
|
245974
|
+
* package root, which is what a package without an `exports` map exposes.
|
|
245975
|
+
*/
|
|
245976
|
+
packageSpecifier(filePath) {
|
|
245977
|
+
const normalized = filePath.split(path3.sep).join("/");
|
|
245978
|
+
const marker = normalized.lastIndexOf("/node_modules/");
|
|
245979
|
+
if (marker === -1) {
|
|
245980
|
+
return void 0;
|
|
245981
|
+
}
|
|
245982
|
+
const subject = normalized.substring(marker + "/node_modules/".length);
|
|
245983
|
+
const segments = subject.split("/");
|
|
245984
|
+
const nameLength = subject.startsWith("@") ? 2 : 1;
|
|
245985
|
+
if (segments.length <= nameLength) {
|
|
245986
|
+
return void 0;
|
|
245987
|
+
}
|
|
245988
|
+
const packageName = segments.slice(0, nameLength).join("/");
|
|
245989
|
+
const packageDir = normalized.substring(0, marker + "/node_modules/".length) + packageName;
|
|
245990
|
+
const relative2 = segments.slice(nameLength).join("/");
|
|
245991
|
+
return `${packageName}/${this.exportedSubpath(packageDir, relative2) ?? relative2}`;
|
|
245992
|
+
}
|
|
245993
|
+
/**
|
|
245994
|
+
* Invert a package's `exports` patterns to find the subpath a file inside
|
|
245995
|
+
* it is exposed as, or undefined when no pattern matches it.
|
|
245996
|
+
*/
|
|
245997
|
+
exportedSubpath(packageDir, relative2) {
|
|
245998
|
+
for (const [key, target] of Object.entries(this.readPackageExports(packageDir))) {
|
|
245999
|
+
const star = key.indexOf("*");
|
|
246000
|
+
const targetStar = target.indexOf("*");
|
|
246001
|
+
if (star === -1 || targetStar === -1) {
|
|
246002
|
+
continue;
|
|
246003
|
+
}
|
|
246004
|
+
const prefix = target.substring(0, targetStar).replace(/^\.\//, "");
|
|
246005
|
+
const suffix = target.substring(targetStar + 1);
|
|
246006
|
+
if (!relative2.startsWith(prefix) || !relative2.endsWith(suffix)) {
|
|
246007
|
+
continue;
|
|
246008
|
+
}
|
|
246009
|
+
const value = relative2.substring(prefix.length, relative2.length - suffix.length);
|
|
246010
|
+
return (key.substring(0, star) + value + key.substring(star + 1)).replace(/^\.\//, "");
|
|
246011
|
+
}
|
|
246012
|
+
return void 0;
|
|
246013
|
+
}
|
|
246014
|
+
/**
|
|
246015
|
+
* Read a package's `exports` map, flattened to subpath → file target.
|
|
246016
|
+
*
|
|
246017
|
+
* Conditional targets are collapsed to their first string value; every
|
|
246018
|
+
* condition a package declares for a subpath points at the same source
|
|
246019
|
+
* file in the layouts sindri generates for.
|
|
246020
|
+
*/
|
|
246021
|
+
readPackageExports(packageDir) {
|
|
246022
|
+
const manifestPath = path3.join(packageDir, "package.json");
|
|
246023
|
+
if (!fs3.existsSync(manifestPath)) {
|
|
246024
|
+
return {};
|
|
246025
|
+
}
|
|
246026
|
+
let manifest;
|
|
246027
|
+
try {
|
|
246028
|
+
manifest = JSON.parse(fs3.readFileSync(manifestPath, "utf-8"));
|
|
246029
|
+
} catch {
|
|
246030
|
+
return {};
|
|
246031
|
+
}
|
|
246032
|
+
const exports2 = manifest.exports;
|
|
246033
|
+
if (typeof exports2 !== "object" || exports2 === null) {
|
|
246034
|
+
return {};
|
|
246035
|
+
}
|
|
246036
|
+
const flattened = {};
|
|
246037
|
+
for (const [subpath, target] of Object.entries(exports2)) {
|
|
246038
|
+
const resolved = this.firstStringTarget(target);
|
|
246039
|
+
if (resolved !== void 0) {
|
|
246040
|
+
flattened[subpath] = resolved;
|
|
246041
|
+
}
|
|
246042
|
+
}
|
|
246043
|
+
return flattened;
|
|
246044
|
+
}
|
|
246045
|
+
/**
|
|
246046
|
+
* Reduce an `exports` target — a string, or a nested map of conditions — to
|
|
246047
|
+
* the first file path it names.
|
|
246048
|
+
*/
|
|
246049
|
+
firstStringTarget(target) {
|
|
246050
|
+
if (typeof target === "string") {
|
|
246051
|
+
return target;
|
|
246052
|
+
}
|
|
246053
|
+
if (typeof target !== "object" || target === null) {
|
|
246054
|
+
return void 0;
|
|
246055
|
+
}
|
|
246056
|
+
for (const value of Object.values(target)) {
|
|
246057
|
+
const resolved = this.firstStringTarget(value);
|
|
246058
|
+
if (resolved !== void 0) {
|
|
246059
|
+
return resolved;
|
|
246060
|
+
}
|
|
246061
|
+
}
|
|
246062
|
+
return void 0;
|
|
246063
|
+
}
|
|
245486
246064
|
generateContainerData(serviceProviders, config, output) {
|
|
245487
246065
|
output = output.withAddedMessages(new Message("Generating Container Data......................")).writeMessages();
|
|
245488
246066
|
const publishers = {};
|
|
246067
|
+
const importMap = {};
|
|
245489
246068
|
for (const providerClass of serviceProviders) {
|
|
245490
246069
|
const filePath = this.fqnToFilePath(providerClass, config.namespace, config.dir);
|
|
245491
246070
|
if (filePath === "" || !fs3.existsSync(filePath)) {
|
|
245492
246071
|
continue;
|
|
245493
246072
|
}
|
|
245494
246073
|
const result = this.serviceProviderReader.readFile(filePath);
|
|
246074
|
+
if (Object.keys(result.publishers).length > 0) {
|
|
246075
|
+
importMap[path3.basename(filePath, ".ts")] = this.importSpecifier(config.dataPath, filePath);
|
|
246076
|
+
}
|
|
245495
246077
|
Object.assign(publishers, result.publishers);
|
|
245496
246078
|
}
|
|
246079
|
+
this.containerGenerator.classImportMap = importMap;
|
|
245497
246080
|
const status = this.containerGenerator.generateFile(
|
|
245498
246081
|
config.dataPath,
|
|
245499
246082
|
"AppContainerData",
|
|
@@ -245531,12 +246114,21 @@ var GenerateDataFromAst = class {
|
|
|
245531
246114
|
generateCliData(cliRouteProviders, config, output) {
|
|
245532
246115
|
output = output.withAddedMessages(new Message("Generating Cli Routes Data.....................")).writeMessages();
|
|
245533
246116
|
const allRoutes = {};
|
|
246117
|
+
const imperativeRoutes = [];
|
|
246118
|
+
const importMap = {};
|
|
245534
246119
|
for (const providerClass of cliRouteProviders) {
|
|
245535
246120
|
const filePath = this.fqnToFilePath(providerClass, config.namespace, config.dir);
|
|
245536
246121
|
if (filePath === "" || !fs3.existsSync(filePath)) {
|
|
245537
246122
|
continue;
|
|
245538
246123
|
}
|
|
245539
246124
|
const providerResult = this.routeProviderReader.readFile(filePath);
|
|
246125
|
+
if (providerResult.routes.length > 0) {
|
|
246126
|
+
imperativeRoutes.push(...providerResult.routes);
|
|
246127
|
+
importMap[path3.basename(filePath, ".ts")] = this.importSpecifier(config.dataPath, filePath);
|
|
246128
|
+
for (const [name, importPath] of Object.entries(providerResult.routeImports)) {
|
|
246129
|
+
importMap[name] = this.importSpecifier(config.dataPath, importPath);
|
|
246130
|
+
}
|
|
246131
|
+
}
|
|
245540
246132
|
for (const controllerClass of providerResult.controllerClasses) {
|
|
245541
246133
|
const controllerPath = this.fqnToFilePath(controllerClass, config.namespace, config.dir);
|
|
245542
246134
|
if (controllerPath === "" || !fs3.existsSync(controllerPath)) {
|
|
@@ -245546,24 +246138,34 @@ var GenerateDataFromAst = class {
|
|
|
245546
246138
|
Object.assign(allRoutes, attrResult.routes);
|
|
245547
246139
|
}
|
|
245548
246140
|
}
|
|
245549
|
-
|
|
246141
|
+
this.cliGenerator.classImportMap = importMap;
|
|
246142
|
+
const status = imperativeRoutes.length > 0 ? this.cliGenerator.generateFileFromRoutes(
|
|
245550
246143
|
config.dataPath,
|
|
245551
246144
|
"AppCliRoutingData",
|
|
245552
246145
|
config.dataNamespace,
|
|
245553
|
-
|
|
245554
|
-
);
|
|
246146
|
+
imperativeRoutes
|
|
246147
|
+
) : this.cliGenerator.generateFile(config.dataPath, "AppCliRoutingData", config.dataNamespace, allRoutes);
|
|
245555
246148
|
return this.addMessagesForGenerateStatus(output, status).withAddedMessages(new NewLine()).writeMessages();
|
|
245556
246149
|
}
|
|
245557
246150
|
generateHttpData(httpRouteProviders, config, output) {
|
|
245558
246151
|
output = output.withAddedMessages(new Message("Generating Http Routes Data....................")).writeMessages();
|
|
245559
246152
|
const allRoutes = {};
|
|
245560
246153
|
const allRouteData = {};
|
|
246154
|
+
const imperativeRoutes = [];
|
|
246155
|
+
const importMap = {};
|
|
245561
246156
|
for (const providerClass of httpRouteProviders) {
|
|
245562
246157
|
const filePath = this.fqnToFilePath(providerClass, config.namespace, config.dir);
|
|
245563
246158
|
if (filePath === "" || !fs3.existsSync(filePath)) {
|
|
245564
246159
|
continue;
|
|
245565
246160
|
}
|
|
245566
246161
|
const providerResult = this.routeProviderReader.readFile(filePath);
|
|
246162
|
+
if (providerResult.routes.length > 0) {
|
|
246163
|
+
imperativeRoutes.push(...providerResult.routes);
|
|
246164
|
+
importMap[path3.basename(filePath, ".ts")] = this.importSpecifier(config.dataPath, filePath);
|
|
246165
|
+
for (const [name, importPath] of Object.entries(providerResult.routeImports)) {
|
|
246166
|
+
importMap[name] = this.importSpecifier(config.dataPath, importPath);
|
|
246167
|
+
}
|
|
246168
|
+
}
|
|
245567
246169
|
for (const controllerClass of providerResult.controllerClasses) {
|
|
245568
246170
|
const controllerPath = this.fqnToFilePath(controllerClass, config.namespace, config.dir);
|
|
245569
246171
|
if (controllerPath === "" || !fs3.existsSync(controllerPath)) {
|
|
@@ -245574,7 +246176,13 @@ var GenerateDataFromAst = class {
|
|
|
245574
246176
|
Object.assign(allRouteData, attrResult.routeData);
|
|
245575
246177
|
}
|
|
245576
246178
|
}
|
|
245577
|
-
|
|
246179
|
+
this.httpGenerator.classImportMap = importMap;
|
|
246180
|
+
const status = imperativeRoutes.length > 0 ? this.httpGenerator.generateFileFromRoutes(
|
|
246181
|
+
config.dataPath,
|
|
246182
|
+
"AppHttpRoutingData",
|
|
246183
|
+
config.dataNamespace,
|
|
246184
|
+
imperativeRoutes
|
|
246185
|
+
) : this.httpGenerator.generateFile(
|
|
245578
246186
|
config.dataPath,
|
|
245579
246187
|
"AppHttpRoutingData",
|
|
245580
246188
|
config.dataNamespace,
|