@valkyrjaio/sindri 26.3.0 → 26.4.1
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 +447 -107
- package/package.json +2 -2
- package/src/Sindri/Ast/Abstract/AstReader.ts +170 -29
- package/src/Sindri/Ast/Data/Result/RouteProviderResult.ts +7 -0
- package/src/Sindri/Ast/RouteProviderReader.ts +31 -1
- package/src/Sindri/Constant/SindriInfo.ts +2 -2
- package/src/Sindri/Generate/Abstract/GenerateDataFromAst.ts +157 -5
- package/src/Sindri/Generator/Abstract/AstFileGenerator.ts +15 -1
- package/src/Sindri/Generator/Ast/Cli/AstCliDataFileGenerator.ts +51 -13
- package/src/Sindri/Generator/Ast/Container/AstContainerDataFileGenerator.ts +16 -3
- package/src/Sindri/Generator/Ast/Event/AstEventDataFileGenerator.ts +23 -4
- package/src/Sindri/Generator/Ast/Http/AstHttpDataFileGenerator.ts +25 -9
package/dist/bin/sindri.cjs
CHANGED
|
@@ -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";
|
|
@@ -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,
|
|
@@ -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;
|
|
@@ -241981,11 +241981,9 @@ var QuestionWriter = class {
|
|
|
241981
241981
|
output = output.writeMessage(question);
|
|
241982
241982
|
const answer = question.getAnswer();
|
|
241983
241983
|
const validResponses = answer.getAllowedResponses();
|
|
241984
|
-
|
|
241985
|
-
|
|
241986
|
-
|
|
241987
|
-
output = output.writeMessage(new Message(")"));
|
|
241988
|
-
}
|
|
241984
|
+
output = output.writeMessage(new Message(" ("));
|
|
241985
|
+
output = output.writeMessage(new Message(validResponses.map((v) => `\`${v}\``).join(" or ")));
|
|
241986
|
+
output = output.writeMessage(new Message(")"));
|
|
241989
241987
|
output = output.writeMessage(new Message(' [default: "'));
|
|
241990
241988
|
output = output.writeMessage(new Message(answer.getDefaultResponse(), new HighlightedTextFormatter()));
|
|
241991
241989
|
output = output.writeMessage(new Message('"]'));
|
|
@@ -242575,7 +242573,20 @@ var HandlerData = class {
|
|
|
242575
242573
|
};
|
|
242576
242574
|
|
|
242577
242575
|
// src/Sindri/Ast/Abstract/AstReader.ts
|
|
242578
|
-
var AstReader = class {
|
|
242576
|
+
var AstReader = class _AstReader {
|
|
242577
|
+
/**
|
|
242578
|
+
* Module resolution settings for {@link resolveModuleSpecifierToFilePath}.
|
|
242579
|
+
*
|
|
242580
|
+
* NodeNext mirrors how the application itself resolves its imports, and
|
|
242581
|
+
* `allowImportingTsExtensions` matches the framework convention of writing
|
|
242582
|
+
* the `.ts` extension in every import specifier.
|
|
242583
|
+
*/
|
|
242584
|
+
static MODULE_RESOLUTION_OPTIONS = {
|
|
242585
|
+
module: import_ts_morph.ts.ModuleKind.NodeNext,
|
|
242586
|
+
moduleResolution: import_ts_morph.ts.ModuleResolutionKind.NodeNext,
|
|
242587
|
+
allowImportingTsExtensions: true,
|
|
242588
|
+
noEmit: true
|
|
242589
|
+
};
|
|
242579
242590
|
parseFileToSourceFile(filePath) {
|
|
242580
242591
|
if (!fs.existsSync(filePath)) {
|
|
242581
242592
|
throw new AstFileReadException(`Cannot read file '${filePath}'.`);
|
|
@@ -242623,12 +242634,39 @@ var AstReader = class {
|
|
|
242623
242634
|
if (moduleSpecifier === void 0) {
|
|
242624
242635
|
return "";
|
|
242625
242636
|
}
|
|
242626
|
-
|
|
242637
|
+
return this.resolveModuleSpecifierToFilePath(moduleSpecifier, currentFilePath);
|
|
242638
|
+
}
|
|
242639
|
+
/**
|
|
242640
|
+
* Resolve a module specifier to the absolute path of the TypeScript file it points at.
|
|
242641
|
+
*
|
|
242642
|
+
* Relative specifiers resolve against the importing file's directory. Bare
|
|
242643
|
+
* package specifiers (`@valkyrjaio/valkyrja/Cli/Routing/Data/Route.ts`) go
|
|
242644
|
+
* through the TypeScript compiler's NodeNext resolver, which honors the
|
|
242645
|
+
* package's `exports` map — so a provider tree that reaches into an
|
|
242646
|
+
* installed package (the framework's own component providers, reached from
|
|
242647
|
+
* the app config) is walked exactly like application source.
|
|
242648
|
+
*
|
|
242649
|
+
* Returns '' when the specifier cannot be resolved to an existing `.ts`
|
|
242650
|
+
* source file. A package shipping only compiled `.js` — or only `.d.ts`
|
|
242651
|
+
* declarations, which carry no `getRoutes()` body to read — has nothing for
|
|
242652
|
+
* the AST readers to walk.
|
|
242653
|
+
*/
|
|
242654
|
+
resolveModuleSpecifierToFilePath(moduleSpecifier, currentFilePath) {
|
|
242655
|
+
if (moduleSpecifier.startsWith(".")) {
|
|
242656
|
+
const dir = path.dirname(currentFilePath);
|
|
242657
|
+
const resolved2 = path.resolve(dir, moduleSpecifier.replace(/\.js$/, ".ts"));
|
|
242658
|
+
return fs.existsSync(resolved2) ? resolved2 : "";
|
|
242659
|
+
}
|
|
242660
|
+
const resolved = import_ts_morph.ts.resolveModuleName(
|
|
242661
|
+
moduleSpecifier,
|
|
242662
|
+
currentFilePath,
|
|
242663
|
+
_AstReader.MODULE_RESOLUTION_OPTIONS,
|
|
242664
|
+
import_ts_morph.ts.sys
|
|
242665
|
+
).resolvedModule?.resolvedFileName;
|
|
242666
|
+
if (resolved === void 0 || !resolved.endsWith(".ts") || resolved.endsWith(".d.ts")) {
|
|
242627
242667
|
return "";
|
|
242628
242668
|
}
|
|
242629
|
-
|
|
242630
|
-
const resolved = path.resolve(dir, moduleSpecifier.replace(/\.js$/, ".ts"));
|
|
242631
|
-
return fs.existsSync(resolved) ? resolved : "";
|
|
242669
|
+
return resolved;
|
|
242632
242670
|
}
|
|
242633
242671
|
/**
|
|
242634
242672
|
* Extract class names from a method returning [new A(), new B(), ...].
|
|
@@ -242705,6 +242743,35 @@ var AstReader = class {
|
|
|
242705
242743
|
}
|
|
242706
242744
|
return paths;
|
|
242707
242745
|
}
|
|
242746
|
+
/**
|
|
242747
|
+
* Collect every identifier an expression references as a value.
|
|
242748
|
+
*
|
|
242749
|
+
* Expressions taken from a provider's `getRoutes()` body are emitted into
|
|
242750
|
+
* the generated data cache verbatim, so the cache must import everything
|
|
242751
|
+
* they name — not just the provider class, but the parameter/enum/constant
|
|
242752
|
+
* classes the route arguments reach for. Property *names* are skipped (the
|
|
242753
|
+
* `HELP` of `CommandName.HELP` is not an import) as are type positions,
|
|
242754
|
+
* which erase at runtime and must never become a value import.
|
|
242755
|
+
*/
|
|
242756
|
+
collectReferencedIdentifiers(node, names = /* @__PURE__ */ new Set()) {
|
|
242757
|
+
if (import_ts_morph.ts.isTypeNode(node)) {
|
|
242758
|
+
return names;
|
|
242759
|
+
}
|
|
242760
|
+
if (import_ts_morph.ts.isIdentifier(node)) {
|
|
242761
|
+
names.add(node.text);
|
|
242762
|
+
return names;
|
|
242763
|
+
}
|
|
242764
|
+
if (import_ts_morph.ts.isPropertyAccessExpression(node)) {
|
|
242765
|
+
return this.collectReferencedIdentifiers(node.expression, names);
|
|
242766
|
+
}
|
|
242767
|
+
if (import_ts_morph.ts.isPropertyAssignment(node)) {
|
|
242768
|
+
return this.collectReferencedIdentifiers(node.initializer, names);
|
|
242769
|
+
}
|
|
242770
|
+
import_ts_morph.ts.forEachChild(node, (child) => {
|
|
242771
|
+
this.collectReferencedIdentifiers(child, names);
|
|
242772
|
+
});
|
|
242773
|
+
return names;
|
|
242774
|
+
}
|
|
242708
242775
|
/**
|
|
242709
242776
|
* Extract service ID strings from keys of an object-returning method.
|
|
242710
242777
|
*
|
|
@@ -242806,7 +242873,7 @@ var AstReader = class {
|
|
|
242806
242873
|
return node.text;
|
|
242807
242874
|
}
|
|
242808
242875
|
if (import_ts_morph.ts.isIdentifier(node)) {
|
|
242809
|
-
return this.
|
|
242876
|
+
return this.resolveConstant(node.text, useMap, currentFilePath);
|
|
242810
242877
|
}
|
|
242811
242878
|
if (import_ts_morph.ts.isPropertyAccessExpression(node)) {
|
|
242812
242879
|
const objName = import_ts_morph.ts.isIdentifier(node.expression) ? node.expression.text : void 0;
|
|
@@ -242817,33 +242884,75 @@ var AstReader = class {
|
|
|
242817
242884
|
return void 0;
|
|
242818
242885
|
}
|
|
242819
242886
|
/**
|
|
242820
|
-
* Resolve a static property value by reading the
|
|
242887
|
+
* Resolve a static property value by reading the file that declares its class.
|
|
242821
242888
|
*/
|
|
242822
242889
|
resolveStaticProperty(className, propName, useMap, currentFilePath) {
|
|
242823
|
-
const
|
|
242824
|
-
if (
|
|
242890
|
+
const declaringClass = this.parseDeclaringSourceFile(className, useMap, currentFilePath)?.getClass(className);
|
|
242891
|
+
if (declaringClass === void 0) {
|
|
242892
|
+
return void 0;
|
|
242893
|
+
}
|
|
242894
|
+
const prop = declaringClass.getStaticProperty(propName);
|
|
242895
|
+
if (prop === void 0 || !import_ts_morph.Node.isPropertyDeclaration(prop)) {
|
|
242825
242896
|
return void 0;
|
|
242826
242897
|
}
|
|
242898
|
+
return this.stringValueOf(prop.getInitializer());
|
|
242899
|
+
}
|
|
242900
|
+
/**
|
|
242901
|
+
* Resolve a module-level `const` to its string value.
|
|
242902
|
+
*
|
|
242903
|
+
* Not every binding key is a class static — some are plain exported
|
|
242904
|
+
* constants, e.g. `export const LoggerContractId = 'Valkyrja.Log.Logger.LoggerContract' as const;`
|
|
242905
|
+
*/
|
|
242906
|
+
resolveConstant(name, useMap, currentFilePath) {
|
|
242907
|
+
const declaration = this.parseDeclaringSourceFile(name, useMap, currentFilePath)?.getVariableDeclaration(name);
|
|
242908
|
+
return this.stringValueOf(declaration?.getInitializer());
|
|
242909
|
+
}
|
|
242910
|
+
/**
|
|
242911
|
+
* Parse the file that declares a name: the module it is imported from, or
|
|
242912
|
+
* the current file when the name is not imported.
|
|
242913
|
+
*
|
|
242914
|
+
* A provider commonly declares the binding keys for its own services
|
|
242915
|
+
* alongside the publishers that use them, so `[Provider.SomeId]` names a
|
|
242916
|
+
* constant that no import map can resolve — it lives in the file being read.
|
|
242917
|
+
*
|
|
242918
|
+
* Returns undefined when the file cannot be read.
|
|
242919
|
+
*/
|
|
242920
|
+
parseDeclaringSourceFile(name, useMap, currentFilePath) {
|
|
242921
|
+
const importedFilePath = this.resolveImportToFilePath(name, useMap, currentFilePath);
|
|
242922
|
+
const filePath = importedFilePath !== "" ? importedFilePath : currentFilePath;
|
|
242827
242923
|
try {
|
|
242828
242924
|
const project = new import_ts_morph.Project({ skipAddingFilesFromTsConfig: true, skipFileDependencyResolution: true });
|
|
242829
|
-
|
|
242830
|
-
const importedClass = importedSource.getClass(className);
|
|
242831
|
-
if (importedClass === void 0 || propName === void 0) {
|
|
242832
|
-
return void 0;
|
|
242833
|
-
}
|
|
242834
|
-
const prop = importedClass.getStaticProperty(propName);
|
|
242835
|
-
if (prop === void 0) {
|
|
242836
|
-
return void 0;
|
|
242837
|
-
}
|
|
242838
|
-
if (import_ts_morph.Node.isPropertyDeclaration(prop)) {
|
|
242839
|
-
const initializer = prop.getInitializer();
|
|
242840
|
-
if (initializer?.isKind(import_ts_morph.SyntaxKind.StringLiteral) === true) {
|
|
242841
|
-
return initializer.compilerNode.text;
|
|
242842
|
-
}
|
|
242843
|
-
}
|
|
242925
|
+
return project.addSourceFileAtPath(filePath);
|
|
242844
242926
|
} catch {
|
|
242927
|
+
return void 0;
|
|
242845
242928
|
}
|
|
242846
|
-
|
|
242929
|
+
}
|
|
242930
|
+
/**
|
|
242931
|
+
* The string a declaration's initializer holds, once its type-only wrappers are stripped.
|
|
242932
|
+
*/
|
|
242933
|
+
stringValueOf(initializer) {
|
|
242934
|
+
if (initializer === void 0) {
|
|
242935
|
+
return void 0;
|
|
242936
|
+
}
|
|
242937
|
+
const value = this.unwrapTypeAssertions(initializer.compilerNode);
|
|
242938
|
+
return import_ts_morph.ts.isStringLiteral(value) ? value.text : void 0;
|
|
242939
|
+
}
|
|
242940
|
+
/**
|
|
242941
|
+
* Strip the type-only wrappers an expression may be dressed in — `as`,
|
|
242942
|
+
* `satisfies` and parentheses — to reach the value node underneath.
|
|
242943
|
+
*
|
|
242944
|
+
* Binding-key constants are declared `static readonly Data = 'Some.Id' as
|
|
242945
|
+
* const;`, so the initializer node is an `AsExpression`, not the
|
|
242946
|
+
* `StringLiteral` holding the value. Without unwrapping, every such key
|
|
242947
|
+
* resolves to nothing and the publishers it names are dropped from the
|
|
242948
|
+
* generated cache.
|
|
242949
|
+
*/
|
|
242950
|
+
unwrapTypeAssertions(node) {
|
|
242951
|
+
let current = node;
|
|
242952
|
+
while (import_ts_morph.ts.isAsExpression(current) || import_ts_morph.ts.isSatisfiesExpression(current) || import_ts_morph.ts.isParenthesizedExpression(current)) {
|
|
242953
|
+
current = current.expression;
|
|
242954
|
+
}
|
|
242955
|
+
return current;
|
|
242847
242956
|
}
|
|
242848
242957
|
/**
|
|
242849
242958
|
* Resolve a short class name — returns the name as-is (class names in TS are local).
|
|
@@ -244271,16 +244380,24 @@ var import_ts_morph6 = __toESM(require_ts_morph(), 1);
|
|
|
244271
244380
|
|
|
244272
244381
|
// src/Sindri/Ast/Data/Result/RouteProviderResult.ts
|
|
244273
244382
|
var RouteProviderResult = class _RouteProviderResult {
|
|
244274
|
-
|
|
244383
|
+
/**
|
|
244384
|
+
* @param routeImports Local name → absolute file path for every class the
|
|
244385
|
+
* imperative `routes` expressions reference, so the
|
|
244386
|
+
* generated data cache can import them.
|
|
244387
|
+
*/
|
|
244388
|
+
constructor(controllerClasses = [], routes = [], routeImports = {}) {
|
|
244275
244389
|
this.controllerClasses = controllerClasses;
|
|
244276
244390
|
this.routes = routes;
|
|
244391
|
+
this.routeImports = routeImports;
|
|
244277
244392
|
}
|
|
244278
244393
|
controllerClasses;
|
|
244279
244394
|
routes;
|
|
244395
|
+
routeImports;
|
|
244280
244396
|
merge(other) {
|
|
244281
244397
|
return new _RouteProviderResult(
|
|
244282
244398
|
[.../* @__PURE__ */ new Set([...this.controllerClasses, ...other.controllerClasses])],
|
|
244283
|
-
[...this.routes, ...other.routes]
|
|
244399
|
+
[...this.routes, ...other.routes],
|
|
244400
|
+
{ ...this.routeImports, ...other.routeImports }
|
|
244284
244401
|
);
|
|
244285
244402
|
}
|
|
244286
244403
|
};
|
|
@@ -244297,11 +244414,33 @@ var RouteProviderReader = class _RouteProviderReader extends AstReader {
|
|
|
244297
244414
|
}
|
|
244298
244415
|
const useMap = this.buildUseMap(sourceFile);
|
|
244299
244416
|
const methods = this.indexMethods(classDecl);
|
|
244417
|
+
const routes = this.extractRoutes(methods[_RouteProviderReader.METHOD_ROUTES], useMap, filePath);
|
|
244300
244418
|
return new RouteProviderResult(
|
|
244301
244419
|
this.extractClassListFromValues(methods[_RouteProviderReader.METHOD_CONTROLLER_CLASSES], useMap, filePath),
|
|
244302
|
-
|
|
244420
|
+
routes,
|
|
244421
|
+
this.extractRouteImports(routes, useMap, filePath)
|
|
244303
244422
|
);
|
|
244304
244423
|
}
|
|
244424
|
+
/**
|
|
244425
|
+
* Resolve every class the imperative route expressions reference to its
|
|
244426
|
+
* absolute file path, so the generated data cache can import them.
|
|
244427
|
+
*
|
|
244428
|
+
* Names that are not imported by the provider file — locals, globals, and
|
|
244429
|
+
* the provider's own class (which the generator imports separately) — have
|
|
244430
|
+
* no entry in the use map and are skipped.
|
|
244431
|
+
*/
|
|
244432
|
+
extractRouteImports(routes, useMap, filePath) {
|
|
244433
|
+
const imports = {};
|
|
244434
|
+
for (const route2 of routes) {
|
|
244435
|
+
for (const name of this.collectReferencedIdentifiers(route2)) {
|
|
244436
|
+
const resolved = this.resolveImportToFilePath(name, useMap, filePath);
|
|
244437
|
+
if (resolved !== "") {
|
|
244438
|
+
imports[name] = resolved;
|
|
244439
|
+
}
|
|
244440
|
+
}
|
|
244441
|
+
}
|
|
244442
|
+
return imports;
|
|
244443
|
+
}
|
|
244305
244444
|
/**
|
|
244306
244445
|
* Extract the route objects returned by a provider's `getRoutes()` method.
|
|
244307
244446
|
*
|
|
@@ -244443,12 +244582,23 @@ var AstFileGenerator = class {
|
|
|
244443
244582
|
* Build the `import { X } from '...';` block for the provider/handler classes
|
|
244444
244583
|
* a generated data cache references, followed by a trailing newline (or an
|
|
244445
244584
|
* empty string when there are no such imports).
|
|
244585
|
+
*
|
|
244586
|
+
* Names the generated file's fixed framework header already binds are
|
|
244587
|
+
* dropped: those are the same framework classes under the same names, and
|
|
244588
|
+
* emitting them twice is a duplicate-identifier error.
|
|
244446
244589
|
*/
|
|
244447
|
-
buildUserImportsBlock(classImportMap) {
|
|
244448
|
-
const userImports = Object.entries(classImportMap).map(([name, specifier]) => `import { ${name} } from '${specifier}';`).join("\n");
|
|
244590
|
+
buildUserImportsBlock(classImportMap, reservedNames) {
|
|
244591
|
+
const userImports = Object.entries(classImportMap).filter(([name]) => !reservedNames.includes(name)).map(([name, specifier]) => `import { ${name} } from '${specifier}';`).join("\n");
|
|
244449
244592
|
return userImports ? `${userImports}
|
|
244450
244593
|
` : "";
|
|
244451
244594
|
}
|
|
244595
|
+
/**
|
|
244596
|
+
* Render the fixed framework imports a generated data file always carries.
|
|
244597
|
+
*/
|
|
244598
|
+
buildFrameworkImportLines(imports, isType = false) {
|
|
244599
|
+
const keyword = isType ? "import type" : "import";
|
|
244600
|
+
return Object.entries(imports).map(([name, specifier]) => `${keyword} { ${name} } from '${specifier}';`);
|
|
244601
|
+
}
|
|
244452
244602
|
writeFile(directory, className, data) {
|
|
244453
244603
|
const filePath = directory.replace(/\/$/, "") + `/${className}.ts`;
|
|
244454
244604
|
try {
|
|
@@ -244466,7 +244616,22 @@ var AstFileGenerator = class {
|
|
|
244466
244616
|
};
|
|
244467
244617
|
|
|
244468
244618
|
// src/Sindri/Generator/Ast/Cli/AstCliDataFileGenerator.ts
|
|
244469
|
-
var AstCliDataFileGenerator = class extends AstFileGenerator {
|
|
244619
|
+
var AstCliDataFileGenerator = class _AstCliDataFileGenerator extends AstFileGenerator {
|
|
244620
|
+
/** The framework classes every generated CLI data file imports as values. */
|
|
244621
|
+
static FRAMEWORK_IMPORTS = {
|
|
244622
|
+
CliRoutingData: "@valkyrjaio/valkyrja/Cli/Routing/Data/CliRoutingData.ts",
|
|
244623
|
+
Route: "@valkyrjaio/valkyrja/Cli/Routing/Data/Route.ts",
|
|
244624
|
+
ArgumentParameter: "@valkyrjaio/valkyrja/Cli/Routing/Data/ArgumentParameter.ts",
|
|
244625
|
+
OptionParameter: "@valkyrjaio/valkyrja/Cli/Routing/Data/OptionParameter.ts",
|
|
244626
|
+
ArgumentMode: "@valkyrjaio/valkyrja/Cli/Routing/Enum/ArgumentMode.ts",
|
|
244627
|
+
ArgumentValueMode: "@valkyrjaio/valkyrja/Cli/Routing/Enum/ArgumentValueMode.ts",
|
|
244628
|
+
OptionMode: "@valkyrjaio/valkyrja/Cli/Routing/Enum/OptionMode.ts",
|
|
244629
|
+
OptionValueMode: "@valkyrjaio/valkyrja/Cli/Routing/Enum/OptionValueMode.ts"
|
|
244630
|
+
};
|
|
244631
|
+
/** The framework types every generated CLI data file imports. */
|
|
244632
|
+
static FRAMEWORK_TYPE_IMPORTS = {
|
|
244633
|
+
RouteContract: "@valkyrjaio/valkyrja/Cli/Routing/Data/Contract/RouteContract.ts"
|
|
244634
|
+
};
|
|
244470
244635
|
classImportMap = {};
|
|
244471
244636
|
printer = import_ts_morph9.ts.createPrinter({ newLine: import_ts_morph9.ts.NewLineKind.LineFeed });
|
|
244472
244637
|
dummySourceFile = import_ts_morph9.ts.createSourceFile(
|
|
@@ -244477,20 +244642,16 @@ var AstCliDataFileGenerator = class extends AstFileGenerator {
|
|
|
244477
244642
|
import_ts_morph9.ts.ScriptKind.TS
|
|
244478
244643
|
);
|
|
244479
244644
|
generateFile(directory, className, namespace, routes) {
|
|
244480
|
-
const userImportsBlock = this.buildUserImportsBlock(this.classImportMap
|
|
244645
|
+
const userImportsBlock = this.buildUserImportsBlock(this.classImportMap, [
|
|
244646
|
+
...Object.keys(_AstCliDataFileGenerator.FRAMEWORK_IMPORTS),
|
|
244647
|
+
...Object.keys(_AstCliDataFileGenerator.FRAMEWORK_TYPE_IMPORTS)
|
|
244648
|
+
]);
|
|
244481
244649
|
const contents = this.generateClassContents(routes);
|
|
244482
244650
|
const data = [
|
|
244483
244651
|
"// This file was automatically generated by Sindri.",
|
|
244484
244652
|
"",
|
|
244485
|
-
|
|
244486
|
-
|
|
244487
|
-
`import { ArgumentParameter } from '@valkyrjaio/valkyrja/Cli/Routing/Data/ArgumentParameter.ts';`,
|
|
244488
|
-
`import { OptionParameter } from '@valkyrjaio/valkyrja/Cli/Routing/Data/OptionParameter.ts';`,
|
|
244489
|
-
`import { ArgumentMode } from '@valkyrjaio/valkyrja/Cli/Routing/Enum/ArgumentMode.ts';`,
|
|
244490
|
-
`import { ArgumentValueMode } from '@valkyrjaio/valkyrja/Cli/Routing/Enum/ArgumentValueMode.ts';`,
|
|
244491
|
-
`import { OptionMode } from '@valkyrjaio/valkyrja/Cli/Routing/Enum/OptionMode.ts';`,
|
|
244492
|
-
`import { OptionValueMode } from '@valkyrjaio/valkyrja/Cli/Routing/Enum/OptionValueMode.ts';`,
|
|
244493
|
-
`import type { RouteContract } from '@valkyrjaio/valkyrja/Cli/Routing/Data/Contract/RouteContract.ts';`,
|
|
244653
|
+
...this.buildFrameworkImportLines(_AstCliDataFileGenerator.FRAMEWORK_IMPORTS),
|
|
244654
|
+
...this.buildFrameworkImportLines(_AstCliDataFileGenerator.FRAMEWORK_TYPE_IMPORTS, true),
|
|
244494
244655
|
userImportsBlock,
|
|
244495
244656
|
`export class ${className} extends CliRoutingData {`,
|
|
244496
244657
|
` constructor() {`,
|
|
@@ -244512,14 +244673,35 @@ var AstCliDataFileGenerator = class extends AstFileGenerator {
|
|
|
244512
244673
|
if (!import_ts_morph9.ts.isNewExpression(expr)) {
|
|
244513
244674
|
continue;
|
|
244514
244675
|
}
|
|
244515
|
-
const
|
|
244516
|
-
if (
|
|
244676
|
+
const key = this.routeKey((expr.arguments ?? [])[0]);
|
|
244677
|
+
if (key === void 0) {
|
|
244517
244678
|
continue;
|
|
244518
244679
|
}
|
|
244519
|
-
routes[
|
|
244680
|
+
routes[key] = expr;
|
|
244520
244681
|
}
|
|
244521
244682
|
return this.generateFile(directory, className, namespace, routes);
|
|
244522
244683
|
}
|
|
244684
|
+
/**
|
|
244685
|
+
* Derive the map key for a route from its name argument.
|
|
244686
|
+
*
|
|
244687
|
+
* A literal name keys the map by its own text. A constant reference
|
|
244688
|
+
* (`CliCommandName.LIST` — how the framework's own commands name
|
|
244689
|
+
* themselves) is kept as a `Class::CASE` marker, so the generated file
|
|
244690
|
+
* emits the constant reference as a computed key rather than baking in the
|
|
244691
|
+
* value it happens to hold today.
|
|
244692
|
+
*/
|
|
244693
|
+
routeKey(nameArg) {
|
|
244694
|
+
if (nameArg === void 0) {
|
|
244695
|
+
return void 0;
|
|
244696
|
+
}
|
|
244697
|
+
if (import_ts_morph9.ts.isStringLiteral(nameArg)) {
|
|
244698
|
+
return nameArg.text;
|
|
244699
|
+
}
|
|
244700
|
+
if (import_ts_morph9.ts.isPropertyAccessExpression(nameArg) && import_ts_morph9.ts.isIdentifier(nameArg.expression)) {
|
|
244701
|
+
return `${nameArg.expression.text}::${nameArg.name.text}`;
|
|
244702
|
+
}
|
|
244703
|
+
return void 0;
|
|
244704
|
+
}
|
|
244523
244705
|
generateClassContents(routes) {
|
|
244524
244706
|
const entries = Object.entries(routes);
|
|
244525
244707
|
if (entries.length === 0) {
|
|
@@ -244545,7 +244727,15 @@ var AstCliDataFileGenerator = class extends AstFileGenerator {
|
|
|
244545
244727
|
|
|
244546
244728
|
// src/Sindri/Generator/Ast/Container/AstContainerDataFileGenerator.ts
|
|
244547
244729
|
var import_ts_morph10 = __toESM(require_ts_morph(), 1);
|
|
244548
|
-
var AstContainerDataFileGenerator = class extends AstFileGenerator {
|
|
244730
|
+
var AstContainerDataFileGenerator = class _AstContainerDataFileGenerator extends AstFileGenerator {
|
|
244731
|
+
/** The framework class every generated container data file imports as a value. */
|
|
244732
|
+
static FRAMEWORK_IMPORTS = {
|
|
244733
|
+
ContainerData: "@valkyrjaio/valkyrja/Container/Data/ContainerData.ts"
|
|
244734
|
+
};
|
|
244735
|
+
/** The framework type every generated container data file imports. */
|
|
244736
|
+
static FRAMEWORK_TYPE_IMPORTS = {
|
|
244737
|
+
ContainerContract: "@valkyrjaio/valkyrja/Container/Manager/Contract/ContainerContract.ts"
|
|
244738
|
+
};
|
|
244549
244739
|
classImportMap = {};
|
|
244550
244740
|
printer = import_ts_morph10.ts.createPrinter({ newLine: import_ts_morph10.ts.NewLineKind.LineFeed });
|
|
244551
244741
|
dummySourceFile = import_ts_morph10.ts.createSourceFile(
|
|
@@ -244556,13 +244746,16 @@ var AstContainerDataFileGenerator = class extends AstFileGenerator {
|
|
|
244556
244746
|
import_ts_morph10.ts.ScriptKind.TS
|
|
244557
244747
|
);
|
|
244558
244748
|
generateFile(directory, className, namespace, publishers) {
|
|
244559
|
-
const userImportsBlock = this.buildUserImportsBlock(this.classImportMap
|
|
244749
|
+
const userImportsBlock = this.buildUserImportsBlock(this.classImportMap, [
|
|
244750
|
+
...Object.keys(_AstContainerDataFileGenerator.FRAMEWORK_IMPORTS),
|
|
244751
|
+
...Object.keys(_AstContainerDataFileGenerator.FRAMEWORK_TYPE_IMPORTS)
|
|
244752
|
+
]);
|
|
244560
244753
|
const contents = this.generateClassContents(publishers);
|
|
244561
244754
|
const data = [
|
|
244562
244755
|
"// This file was automatically generated by Sindri.",
|
|
244563
244756
|
"",
|
|
244564
|
-
|
|
244565
|
-
|
|
244757
|
+
...this.buildFrameworkImportLines(_AstContainerDataFileGenerator.FRAMEWORK_IMPORTS),
|
|
244758
|
+
...this.buildFrameworkImportLines(_AstContainerDataFileGenerator.FRAMEWORK_TYPE_IMPORTS, true),
|
|
244566
244759
|
userImportsBlock,
|
|
244567
244760
|
`export class ${className} extends ContainerData {`,
|
|
244568
244761
|
` constructor() {`,
|
|
@@ -244594,7 +244787,19 @@ var AstContainerDataFileGenerator = class extends AstFileGenerator {
|
|
|
244594
244787
|
|
|
244595
244788
|
// src/Sindri/Generator/Ast/Event/AstEventDataFileGenerator.ts
|
|
244596
244789
|
var import_ts_morph11 = __toESM(require_ts_morph(), 1);
|
|
244597
|
-
var AstEventDataFileGenerator = class extends AstFileGenerator {
|
|
244790
|
+
var AstEventDataFileGenerator = class _AstEventDataFileGenerator extends AstFileGenerator {
|
|
244791
|
+
/** The framework class every generated event data file imports as a value. */
|
|
244792
|
+
static FRAMEWORK_IMPORTS = {
|
|
244793
|
+
EventData: "@valkyrjaio/valkyrja/Event/Data/EventData.ts"
|
|
244794
|
+
};
|
|
244795
|
+
/** The framework classes a generated event data file imports only when it holds listeners. */
|
|
244796
|
+
static LISTENER_IMPORTS = {
|
|
244797
|
+
Listener: "@valkyrjaio/valkyrja/Event/Data/Listener.ts"
|
|
244798
|
+
};
|
|
244799
|
+
/** The framework types a generated event data file imports only when it holds listeners. */
|
|
244800
|
+
static LISTENER_TYPE_IMPORTS = {
|
|
244801
|
+
ListenerContract: "@valkyrjaio/valkyrja/Event/Data/Contract/ListenerContract.ts"
|
|
244802
|
+
};
|
|
244598
244803
|
classImportMap = {};
|
|
244599
244804
|
printer = import_ts_morph11.ts.createPrinter({ newLine: import_ts_morph11.ts.NewLineKind.LineFeed });
|
|
244600
244805
|
dummySourceFile = import_ts_morph11.ts.createSourceFile(
|
|
@@ -244605,16 +244810,20 @@ var AstEventDataFileGenerator = class extends AstFileGenerator {
|
|
|
244605
244810
|
import_ts_morph11.ts.ScriptKind.TS
|
|
244606
244811
|
);
|
|
244607
244812
|
generateFile(directory, className, namespace, listeners) {
|
|
244608
|
-
const userImportsBlock = this.buildUserImportsBlock(this.classImportMap
|
|
244813
|
+
const userImportsBlock = this.buildUserImportsBlock(this.classImportMap, [
|
|
244814
|
+
...Object.keys(_AstEventDataFileGenerator.FRAMEWORK_IMPORTS),
|
|
244815
|
+
...Object.keys(_AstEventDataFileGenerator.LISTENER_IMPORTS),
|
|
244816
|
+
...Object.keys(_AstEventDataFileGenerator.LISTENER_TYPE_IMPORTS)
|
|
244817
|
+
]);
|
|
244609
244818
|
const contents = this.generateClassContents(listeners);
|
|
244610
244819
|
const listenerImports = Object.keys(listeners).length > 0 ? [
|
|
244611
|
-
|
|
244612
|
-
|
|
244820
|
+
...this.buildFrameworkImportLines(_AstEventDataFileGenerator.LISTENER_IMPORTS),
|
|
244821
|
+
...this.buildFrameworkImportLines(_AstEventDataFileGenerator.LISTENER_TYPE_IMPORTS, true)
|
|
244613
244822
|
] : [];
|
|
244614
244823
|
const data = [
|
|
244615
244824
|
"// This file was automatically generated by Sindri.",
|
|
244616
244825
|
"",
|
|
244617
|
-
|
|
244826
|
+
...this.buildFrameworkImportLines(_AstEventDataFileGenerator.FRAMEWORK_IMPORTS),
|
|
244618
244827
|
...listenerImports,
|
|
244619
244828
|
userImportsBlock,
|
|
244620
244829
|
`export class ${className} extends EventData {`,
|
|
@@ -245015,8 +245224,8 @@ var Regex = class _Regex {
|
|
|
245015
245224
|
static ALPHA_UPPERCASE = "[A-Z]+";
|
|
245016
245225
|
static ALPHA_NUM = "[a-zA-Z0-9]+";
|
|
245017
245226
|
static ALPHA_NUM_UNDERSCORE = "\\w+";
|
|
245018
|
-
static START = "
|
|
245019
|
-
static END = "
|
|
245227
|
+
static START = "^";
|
|
245228
|
+
static END = "$";
|
|
245020
245229
|
static START_CAPTURE_GROUP = "(";
|
|
245021
245230
|
static START_NON_CAPTURE_GROUP = "(?:";
|
|
245022
245231
|
static END_CAPTURE_GROUP = ")";
|
|
@@ -245108,7 +245317,20 @@ var GeneratorUnreachableException = class extends GeneratorRuntimeException {
|
|
|
245108
245317
|
};
|
|
245109
245318
|
|
|
245110
245319
|
// src/Sindri/Generator/Ast/Http/AstHttpDataFileGenerator.ts
|
|
245111
|
-
var AstHttpDataFileGenerator = class extends AstFileGenerator {
|
|
245320
|
+
var AstHttpDataFileGenerator = class _AstHttpDataFileGenerator extends AstFileGenerator {
|
|
245321
|
+
/** The framework classes every generated HTTP data file imports as values. */
|
|
245322
|
+
static FRAMEWORK_IMPORTS = {
|
|
245323
|
+
HttpRoutingData: "@valkyrjaio/valkyrja/Http/Routing/Data/HttpRoutingData.ts",
|
|
245324
|
+
DynamicRoute: "@valkyrjaio/valkyrja/Http/Routing/Data/DynamicRoute.ts",
|
|
245325
|
+
Route: "@valkyrjaio/valkyrja/Http/Routing/Data/Route.ts",
|
|
245326
|
+
Parameter: "@valkyrjaio/valkyrja/Http/Routing/Data/Parameter.ts",
|
|
245327
|
+
RequestMethod: "@valkyrjaio/valkyrja/Http/Message/Enum/RequestMethod.ts",
|
|
245328
|
+
Regex: "@valkyrjaio/valkyrja/Http/Routing/Constant/Regex.ts"
|
|
245329
|
+
};
|
|
245330
|
+
/** The framework types every generated HTTP data file imports. */
|
|
245331
|
+
static FRAMEWORK_TYPE_IMPORTS = {
|
|
245332
|
+
RouteContract: "@valkyrjaio/valkyrja/Http/Routing/Data/Contract/RouteContract.ts"
|
|
245333
|
+
};
|
|
245112
245334
|
classImportMap = {};
|
|
245113
245335
|
processor;
|
|
245114
245336
|
printer = import_ts_morph12.ts.createPrinter({ newLine: import_ts_morph12.ts.NewLineKind.LineFeed });
|
|
@@ -245124,7 +245346,10 @@ var AstHttpDataFileGenerator = class extends AstFileGenerator {
|
|
|
245124
245346
|
this.processor = processor;
|
|
245125
245347
|
}
|
|
245126
245348
|
generateFile(directory, className, namespace, routes, routeData) {
|
|
245127
|
-
const userImportsBlock = this.buildUserImportsBlock(this.classImportMap
|
|
245349
|
+
const userImportsBlock = this.buildUserImportsBlock(this.classImportMap, [
|
|
245350
|
+
...Object.keys(_AstHttpDataFileGenerator.FRAMEWORK_IMPORTS),
|
|
245351
|
+
...Object.keys(_AstHttpDataFileGenerator.FRAMEWORK_TYPE_IMPORTS)
|
|
245352
|
+
]);
|
|
245128
245353
|
const routesContent = this.getRoutesAsContent(routes, routeData);
|
|
245129
245354
|
const paths = this.printNestedObject(this.buildPaths(routeData));
|
|
245130
245355
|
const dynamicPaths = this.printNestedObject(this.buildDynamicPaths(routeData));
|
|
@@ -245142,7 +245367,10 @@ var AstHttpDataFileGenerator = class extends AstFileGenerator {
|
|
|
245142
245367
|
* (literal path and regex, request methods defaulting to `[HEAD, GET]`).
|
|
245143
245368
|
*/
|
|
245144
245369
|
generateFileFromRoutes(directory, className, _namespace, routeExprs) {
|
|
245145
|
-
const userImportsBlock = this.buildUserImportsBlock(this.classImportMap
|
|
245370
|
+
const userImportsBlock = this.buildUserImportsBlock(this.classImportMap, [
|
|
245371
|
+
...Object.keys(_AstHttpDataFileGenerator.FRAMEWORK_IMPORTS),
|
|
245372
|
+
...Object.keys(_AstHttpDataFileGenerator.FRAMEWORK_TYPE_IMPORTS)
|
|
245373
|
+
]);
|
|
245146
245374
|
const metas = routeExprs.map((expr) => this.extractRouteMeta(expr)).filter((meta) => meta !== void 0);
|
|
245147
245375
|
const routesContent = this.getImperativeRoutesContent(metas);
|
|
245148
245376
|
const paths = this.printNestedObject(this.buildImperativePaths(metas, false));
|
|
@@ -245155,13 +245383,8 @@ var AstHttpDataFileGenerator = class extends AstFileGenerator {
|
|
|
245155
245383
|
return [
|
|
245156
245384
|
"// This file was automatically generated by Sindri.",
|
|
245157
245385
|
"",
|
|
245158
|
-
|
|
245159
|
-
|
|
245160
|
-
`import { Route } from '@valkyrjaio/valkyrja/Http/Routing/Data/Route.ts';`,
|
|
245161
|
-
`import { Parameter } from '@valkyrjaio/valkyrja/Http/Routing/Data/Parameter.ts';`,
|
|
245162
|
-
`import { RequestMethod } from '@valkyrjaio/valkyrja/Http/Message/Enum/RequestMethod.ts';`,
|
|
245163
|
-
`import { Regex } from '@valkyrjaio/valkyrja/Http/Routing/Constant/Regex.ts';`,
|
|
245164
|
-
`import type { RouteContract } from '@valkyrjaio/valkyrja/Http/Routing/Data/Contract/RouteContract.ts';`,
|
|
245386
|
+
...this.buildFrameworkImportLines(_AstHttpDataFileGenerator.FRAMEWORK_IMPORTS),
|
|
245387
|
+
...this.buildFrameworkImportLines(_AstHttpDataFileGenerator.FRAMEWORK_TYPE_IMPORTS, true),
|
|
245165
245388
|
userImportsBlock,
|
|
245166
245389
|
`export class ${className} extends HttpRoutingData {`,
|
|
245167
245390
|
` constructor() {`,
|
|
@@ -245459,8 +245682,8 @@ var WarningFormatter = class extends Formatter {
|
|
|
245459
245682
|
|
|
245460
245683
|
// node_modules/@valkyrjaio/valkyrja/src/Valkyrja/Application/Constant/ApplicationInfo.ts
|
|
245461
245684
|
var ApplicationInfo = class {
|
|
245462
|
-
static VERSION = "26.
|
|
245463
|
-
static VERSION_BUILD_DATE_TIME = "July
|
|
245685
|
+
static VERSION = "26.4.1";
|
|
245686
|
+
static VERSION_BUILD_DATE_TIME = "July 28 2026 21:18:39 MST";
|
|
245464
245687
|
static ASCII = `
|
|
245465
245688
|
_ _ _
|
|
245466
245689
|
/\\ /\\__ _| | | ___ _ _ __(_) __ _
|
|
@@ -245569,8 +245792,8 @@ var Header = class extends Message {
|
|
|
245569
245792
|
|
|
245570
245793
|
// src/Sindri/Constant/SindriInfo.ts
|
|
245571
245794
|
var SindriInfo = class {
|
|
245572
|
-
static VERSION = "26.
|
|
245573
|
-
static VERSION_BUILD_DATE_TIME = "July
|
|
245795
|
+
static VERSION = "26.4.1";
|
|
245796
|
+
static VERSION_BUILD_DATE_TIME = "July 28 2026 21:24:47 MST";
|
|
245574
245797
|
static ICON = ` \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588
|
|
245575
245798
|
\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588
|
|
245576
245799
|
\u2588\u2588\u2588\u2588
|
|
@@ -245725,6 +245948,117 @@ var GenerateDataFromAst = class {
|
|
|
245725
245948
|
const relative2 = path3.relative(fromDir, toFile).split(path3.sep).join("/");
|
|
245726
245949
|
return relative2.startsWith(".") ? relative2 : `./${relative2}`;
|
|
245727
245950
|
}
|
|
245951
|
+
/**
|
|
245952
|
+
* Build the specifier a generated data file should import a class file by.
|
|
245953
|
+
*
|
|
245954
|
+
* Application source is imported by a path relative to the data directory;
|
|
245955
|
+
* a file belonging to an installed package is imported by that package's
|
|
245956
|
+
* own public specifier — so the framework classes the cache references are
|
|
245957
|
+
* written exactly as hand-written application code writes them
|
|
245958
|
+
* (`@valkyrjaio/valkyrja/Cli/Routing/Data/Route.ts`), never as a brittle
|
|
245959
|
+
* reach into `node_modules`.
|
|
245960
|
+
*/
|
|
245961
|
+
importSpecifier(fromDir, toFile) {
|
|
245962
|
+
return this.packageSpecifier(toFile) ?? this.relativeSpecifier(fromDir, toFile);
|
|
245963
|
+
}
|
|
245964
|
+
/**
|
|
245965
|
+
* Map an absolute path inside an installed package back to the specifier
|
|
245966
|
+
* that package publicly exposes it as, or undefined when the file is not
|
|
245967
|
+
* part of one.
|
|
245968
|
+
*
|
|
245969
|
+
* The package's `exports` map is inverted: for `"./*.ts": "./src/*.ts"` a
|
|
245970
|
+
* file at `<package>/src/Foo.ts` maps back to `<name>/Foo.ts`. Packages
|
|
245971
|
+
* with no matching pattern fall back to the path as written under the
|
|
245972
|
+
* package root, which is what a package without an `exports` map exposes.
|
|
245973
|
+
*/
|
|
245974
|
+
packageSpecifier(filePath) {
|
|
245975
|
+
const normalized = filePath.split(path3.sep).join("/");
|
|
245976
|
+
const marker = normalized.lastIndexOf("/node_modules/");
|
|
245977
|
+
if (marker === -1) {
|
|
245978
|
+
return void 0;
|
|
245979
|
+
}
|
|
245980
|
+
const subject = normalized.substring(marker + "/node_modules/".length);
|
|
245981
|
+
const segments = subject.split("/");
|
|
245982
|
+
const nameLength = subject.startsWith("@") ? 2 : 1;
|
|
245983
|
+
if (segments.length <= nameLength) {
|
|
245984
|
+
return void 0;
|
|
245985
|
+
}
|
|
245986
|
+
const packageName = segments.slice(0, nameLength).join("/");
|
|
245987
|
+
const packageDir = normalized.substring(0, marker + "/node_modules/".length) + packageName;
|
|
245988
|
+
const relative2 = segments.slice(nameLength).join("/");
|
|
245989
|
+
return `${packageName}/${this.exportedSubpath(packageDir, relative2) ?? relative2}`;
|
|
245990
|
+
}
|
|
245991
|
+
/**
|
|
245992
|
+
* Invert a package's `exports` patterns to find the subpath a file inside
|
|
245993
|
+
* it is exposed as, or undefined when no pattern matches it.
|
|
245994
|
+
*/
|
|
245995
|
+
exportedSubpath(packageDir, relative2) {
|
|
245996
|
+
for (const [key, target] of Object.entries(this.readPackageExports(packageDir))) {
|
|
245997
|
+
const star = key.indexOf("*");
|
|
245998
|
+
const targetStar = target.indexOf("*");
|
|
245999
|
+
if (star === -1 || targetStar === -1) {
|
|
246000
|
+
continue;
|
|
246001
|
+
}
|
|
246002
|
+
const prefix = target.substring(0, targetStar).replace(/^\.\//, "");
|
|
246003
|
+
const suffix = target.substring(targetStar + 1);
|
|
246004
|
+
if (!relative2.startsWith(prefix) || !relative2.endsWith(suffix)) {
|
|
246005
|
+
continue;
|
|
246006
|
+
}
|
|
246007
|
+
const value = relative2.substring(prefix.length, relative2.length - suffix.length);
|
|
246008
|
+
return (key.substring(0, star) + value + key.substring(star + 1)).replace(/^\.\//, "");
|
|
246009
|
+
}
|
|
246010
|
+
return void 0;
|
|
246011
|
+
}
|
|
246012
|
+
/**
|
|
246013
|
+
* Read a package's `exports` map, flattened to subpath → file target.
|
|
246014
|
+
*
|
|
246015
|
+
* Conditional targets are collapsed to their first string value; every
|
|
246016
|
+
* condition a package declares for a subpath points at the same source
|
|
246017
|
+
* file in the layouts sindri generates for.
|
|
246018
|
+
*/
|
|
246019
|
+
readPackageExports(packageDir) {
|
|
246020
|
+
const manifestPath = path3.join(packageDir, "package.json");
|
|
246021
|
+
if (!fs3.existsSync(manifestPath)) {
|
|
246022
|
+
return {};
|
|
246023
|
+
}
|
|
246024
|
+
let manifest;
|
|
246025
|
+
try {
|
|
246026
|
+
manifest = JSON.parse(fs3.readFileSync(manifestPath, "utf-8"));
|
|
246027
|
+
} catch {
|
|
246028
|
+
return {};
|
|
246029
|
+
}
|
|
246030
|
+
const exports2 = manifest.exports;
|
|
246031
|
+
if (typeof exports2 !== "object" || exports2 === null) {
|
|
246032
|
+
return {};
|
|
246033
|
+
}
|
|
246034
|
+
const flattened = {};
|
|
246035
|
+
for (const [subpath, target] of Object.entries(exports2)) {
|
|
246036
|
+
const resolved = this.firstStringTarget(target);
|
|
246037
|
+
if (resolved !== void 0) {
|
|
246038
|
+
flattened[subpath] = resolved;
|
|
246039
|
+
}
|
|
246040
|
+
}
|
|
246041
|
+
return flattened;
|
|
246042
|
+
}
|
|
246043
|
+
/**
|
|
246044
|
+
* Reduce an `exports` target — a string, or a nested map of conditions — to
|
|
246045
|
+
* the first file path it names.
|
|
246046
|
+
*/
|
|
246047
|
+
firstStringTarget(target) {
|
|
246048
|
+
if (typeof target === "string") {
|
|
246049
|
+
return target;
|
|
246050
|
+
}
|
|
246051
|
+
if (typeof target !== "object" || target === null) {
|
|
246052
|
+
return void 0;
|
|
246053
|
+
}
|
|
246054
|
+
for (const value of Object.values(target)) {
|
|
246055
|
+
const resolved = this.firstStringTarget(value);
|
|
246056
|
+
if (resolved !== void 0) {
|
|
246057
|
+
return resolved;
|
|
246058
|
+
}
|
|
246059
|
+
}
|
|
246060
|
+
return void 0;
|
|
246061
|
+
}
|
|
245728
246062
|
generateContainerData(serviceProviders, config, output) {
|
|
245729
246063
|
output = output.withAddedMessages(new Message("Generating Container Data......................")).writeMessages();
|
|
245730
246064
|
const publishers = {};
|
|
@@ -245736,7 +246070,7 @@ var GenerateDataFromAst = class {
|
|
|
245736
246070
|
}
|
|
245737
246071
|
const result = this.serviceProviderReader.readFile(filePath);
|
|
245738
246072
|
if (Object.keys(result.publishers).length > 0) {
|
|
245739
|
-
importMap[path3.basename(filePath, ".ts")] = this.
|
|
246073
|
+
importMap[path3.basename(filePath, ".ts")] = this.importSpecifier(config.dataPath, filePath);
|
|
245740
246074
|
}
|
|
245741
246075
|
Object.assign(publishers, result.publishers);
|
|
245742
246076
|
}
|
|
@@ -245788,7 +246122,10 @@ var GenerateDataFromAst = class {
|
|
|
245788
246122
|
const providerResult = this.routeProviderReader.readFile(filePath);
|
|
245789
246123
|
if (providerResult.routes.length > 0) {
|
|
245790
246124
|
imperativeRoutes.push(...providerResult.routes);
|
|
245791
|
-
importMap[path3.basename(filePath, ".ts")] = this.
|
|
246125
|
+
importMap[path3.basename(filePath, ".ts")] = this.importSpecifier(config.dataPath, filePath);
|
|
246126
|
+
for (const [name, importPath] of Object.entries(providerResult.routeImports)) {
|
|
246127
|
+
importMap[name] = this.importSpecifier(config.dataPath, importPath);
|
|
246128
|
+
}
|
|
245792
246129
|
}
|
|
245793
246130
|
for (const controllerClass of providerResult.controllerClasses) {
|
|
245794
246131
|
const controllerPath = this.fqnToFilePath(controllerClass, config.namespace, config.dir);
|
|
@@ -245822,7 +246159,10 @@ var GenerateDataFromAst = class {
|
|
|
245822
246159
|
const providerResult = this.routeProviderReader.readFile(filePath);
|
|
245823
246160
|
if (providerResult.routes.length > 0) {
|
|
245824
246161
|
imperativeRoutes.push(...providerResult.routes);
|
|
245825
|
-
importMap[path3.basename(filePath, ".ts")] = this.
|
|
246162
|
+
importMap[path3.basename(filePath, ".ts")] = this.importSpecifier(config.dataPath, filePath);
|
|
246163
|
+
for (const [name, importPath] of Object.entries(providerResult.routeImports)) {
|
|
246164
|
+
importMap[name] = this.importSpecifier(config.dataPath, importPath);
|
|
246165
|
+
}
|
|
245826
246166
|
}
|
|
245827
246167
|
for (const controllerClass of providerResult.controllerClasses) {
|
|
245828
246168
|
const controllerPath = this.fqnToFilePath(controllerClass, config.namespace, config.dir);
|