@betterportal/framework 10.7.0 → 11.0.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/lib/adapters/h3.d.ts +1 -1
- package/lib/adapters/h3.d.ts.map +1 -1
- package/lib/adapters/h3.js +51 -43
- package/lib/adapters/h3.js.map +1 -1
- package/lib/codegen/init.js +12 -0
- package/lib/codegen/init.js.map +1 -1
- package/lib/codegen/routeUrlPolicy.d.ts +2 -0
- package/lib/codegen/routeUrlPolicy.d.ts.map +1 -1
- package/lib/codegen/routeUrlPolicy.js +215 -35
- package/lib/codegen/routeUrlPolicy.js.map +1 -1
- package/lib/codegen/routingRules.d.ts +8 -0
- package/lib/codegen/routingRules.d.ts.map +1 -0
- package/lib/codegen/routingRules.js +54 -0
- package/lib/codegen/routingRules.js.map +1 -0
- package/lib/contracts/registry.d.ts +9 -22
- package/lib/contracts/registry.d.ts.map +1 -1
- package/lib/contracts/route.d.ts +4 -4
- package/lib/contracts/route.d.ts.map +1 -1
- package/lib/contracts/{routeUrl.d.ts → routing.d.ts} +13 -7
- package/lib/contracts/routing.d.ts.map +1 -0
- package/lib/contracts/routing.js +2 -0
- package/lib/contracts/routing.js.map +1 -0
- package/lib/contracts/streaming.d.ts +1 -1
- package/lib/eslint.d.ts +48 -0
- package/lib/eslint.d.ts.map +1 -0
- package/lib/eslint.js +20 -0
- package/lib/eslint.js.map +1 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/jsx-dev-runtime.d.ts +3 -0
- package/lib/jsx-dev-runtime.d.ts.map +1 -0
- package/lib/jsx-dev-runtime.js +2 -0
- package/lib/jsx-dev-runtime.js.map +1 -0
- package/lib/jsx-runtime.d.ts +32 -0
- package/lib/jsx-runtime.d.ts.map +1 -0
- package/lib/jsx-runtime.js +15 -0
- package/lib/jsx-runtime.js.map +1 -0
- package/lib/runtime/auth/redirect.d.ts +2 -2
- package/lib/runtime/auth/redirect.d.ts.map +1 -1
- package/lib/runtime/auth/redirect.js +1 -1
- package/lib/runtime/auth/redirect.js.map +1 -1
- package/lib/runtime/element.d.ts +23 -7
- package/lib/runtime/element.d.ts.map +1 -1
- package/lib/runtime/element.js +116 -33
- package/lib/runtime/element.js.map +1 -1
- package/lib/runtime/llms.d.ts.map +1 -1
- package/lib/runtime/llms.js +17 -6
- package/lib/runtime/llms.js.map +1 -1
- package/lib/runtime/registry.d.ts +2 -2
- package/lib/runtime/registry.d.ts.map +1 -1
- package/lib/runtime/routeResult.d.ts +14 -0
- package/lib/runtime/routeResult.d.ts.map +1 -0
- package/lib/runtime/routeResult.js +23 -0
- package/lib/runtime/routeResult.js.map +1 -0
- package/package.json +27 -1
- package/lib/contracts/routeUrl.d.ts.map +0 -1
- package/lib/contracts/routeUrl.js +0 -2
- package/lib/contracts/routeUrl.js.map +0 -1
package/lib/codegen/init.js
CHANGED
|
@@ -92,6 +92,18 @@ function run() {
|
|
|
92
92
|
console.log("[bp-init] prebuild script already configured.");
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
|
+
const tsconfigPath = path.join(packageDir, "tsconfig.json");
|
|
96
|
+
if (fs.existsSync(tsconfigPath)) {
|
|
97
|
+
try {
|
|
98
|
+
const tsconfig = JSON.parse(fs.readFileSync(tsconfigPath, "utf8"));
|
|
99
|
+
if (tsconfig.compilerOptions?.jsxImportSource === "jsx-htmx") {
|
|
100
|
+
tsconfig.compilerOptions.jsxImportSource = "@betterportal/framework";
|
|
101
|
+
fs.writeFileSync(tsconfigPath, JSON.stringify(tsconfig, null, 2) + "\n");
|
|
102
|
+
console.log("[bp-init] Installed the typed BPRoute JSX facade.");
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
catch { /* JSONC/custom configurations are documented for manual migration. */ }
|
|
106
|
+
}
|
|
95
107
|
// Ensure betterportal key exists
|
|
96
108
|
if (!raw.betterportal) {
|
|
97
109
|
raw.betterportal = { rout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AAC;AACjC,CAAC;AAED,GAAG,EAAE,CAAC"}
|
|
@@ -2,6 +2,8 @@ export interface RouteUrlPolicyError {
|
|
|
2
2
|
file: string;
|
|
3
3
|
message: string;
|
|
4
4
|
severity: "error";
|
|
5
|
+
start?: number;
|
|
6
|
+
length?: number;
|
|
5
7
|
}
|
|
6
8
|
/** Reject the old routing API and renderer-only URL payloads even in loosely typed source. */
|
|
7
9
|
export declare function inspectRouteUrlSource(file: string, source: string): RouteUrlPolicyError[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routeUrlPolicy.d.ts","sourceRoot":"","sources":["../../src/codegen/routeUrlPolicy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"routeUrlPolicy.d.ts","sourceRoot":"","sources":["../../src/codegen/routeUrlPolicy.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,mBAAmB;IAAG,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE;AAK1H,8FAA8F;AAC9F,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,mBAAmB,EAAE,CA43BzF;AAED,mGAAmG;AACnG,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,mBAAmB,EAAE,CAO9E;AAGD,kFAAkF;AAClF,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,GAAE;IAAE,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAAC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAAO,GAAG,mBAAmB,EAAE,CAQ3J"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { routingDiagnostics } from "./routingRules.js";
|
|
1
2
|
import * as fs from "node:fs";
|
|
2
3
|
import * as path from "node:path";
|
|
3
4
|
import ts from "typescript";
|
|
@@ -6,7 +7,7 @@ const internalPaths = new Set(["apiPath", "viewPath", "uiPath", "absoluteApiPath
|
|
|
6
7
|
/** Reject the old routing API and renderer-only URL payloads even in loosely typed source. */
|
|
7
8
|
export function inspectRouteUrlSource(file, source) {
|
|
8
9
|
const tree = ts.createSourceFile(file, source, ts.ScriptTarget.Latest, true, file.endsWith(".tsx") ? ts.ScriptKind.TSX : ts.ScriptKind.TS);
|
|
9
|
-
const errors =
|
|
10
|
+
const errors = routingDiagnostics(file, source).map(item => ({ file, message: item.message, severity: "error", start: item.start, length: item.length }));
|
|
10
11
|
const rendererFunctions = new Set();
|
|
11
12
|
const declarations = new Map();
|
|
12
13
|
const selections = new Map();
|
|
@@ -264,6 +265,8 @@ export function inspectRouteUrlSource(file, source) {
|
|
|
264
265
|
return expression;
|
|
265
266
|
if (ts.isParenthesizedExpression(expression) || ts.isAsExpression(expression) || ts.isNonNullExpression(expression))
|
|
266
267
|
return resolveCallback(expression.expression, seen);
|
|
268
|
+
if (ts.isCallExpression(expression) && ts.isPropertyAccessExpression(expression.expression) && expression.expression.name.text === "bind")
|
|
269
|
+
return resolveCallback(expression.expression.expression, seen);
|
|
267
270
|
if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression) && ts.isStringLiteralLike(expression.argumentExpression)) {
|
|
268
271
|
const field = ts.isPropertyAccessExpression(expression) ? expression.name.text : expression.argumentExpression.text;
|
|
269
272
|
return resolveCallback(selectedProperty(expression.expression, field), seen);
|
|
@@ -289,8 +292,20 @@ export function inspectRouteUrlSource(file, source) {
|
|
|
289
292
|
const arrayValues = (expression, seen = new Set()) => {
|
|
290
293
|
if (ts.isParenthesizedExpression(expression) || ts.isAsExpression(expression) || ts.isNonNullExpression(expression))
|
|
291
294
|
return arrayValues(expression.expression, seen);
|
|
292
|
-
if (ts.isArrayLiteralExpression(expression)
|
|
293
|
-
|
|
295
|
+
if (ts.isArrayLiteralExpression(expression)) {
|
|
296
|
+
const values = [];
|
|
297
|
+
for (const element of expression.elements) {
|
|
298
|
+
if (ts.isSpreadElement(element)) {
|
|
299
|
+
const spread = arrayValues(element.expression, seen);
|
|
300
|
+
if (!spread)
|
|
301
|
+
return undefined;
|
|
302
|
+
values.push(...spread);
|
|
303
|
+
}
|
|
304
|
+
else
|
|
305
|
+
values.push(element);
|
|
306
|
+
}
|
|
307
|
+
return values;
|
|
308
|
+
}
|
|
294
309
|
if (ts.isCallExpression(expression) && ts.isPropertyAccessExpression(expression.expression) && isGlobal(expression.expression.expression, "Array") && expression.expression.name.text === "of")
|
|
295
310
|
return expression.arguments;
|
|
296
311
|
if (ts.isNewExpression(expression) && isGlobal(expression.expression, "Array"))
|
|
@@ -304,12 +319,83 @@ export function inspectRouteUrlSource(file, source) {
|
|
|
304
319
|
return arrayValues(initializer, new Set([...seen, expression.text]));
|
|
305
320
|
if (declarations.get(scope)?.has(expression.text) || selections.get(scope)?.has(expression.text))
|
|
306
321
|
return undefined;
|
|
307
|
-
if (ts.isFunctionLike(scope)
|
|
308
|
-
|
|
322
|
+
if (ts.isFunctionLike(scope)) {
|
|
323
|
+
const parameter = scope.parameters.find(parameter => ts.isIdentifier(parameter.name) && parameter.name.text === expression.text);
|
|
324
|
+
if (parameter) {
|
|
325
|
+
const input = parameterInputs.get(parameter);
|
|
326
|
+
return input ? arrayValues(input, new Set([...seen, expression.text])) : undefined;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
309
329
|
scope = scope.parent;
|
|
310
330
|
}
|
|
311
331
|
return undefined;
|
|
312
332
|
};
|
|
333
|
+
const argumentValues = (inputs) => inputs.flatMap(input => input && ts.isSpreadElement(input) ? arrayValues(input.expression) ?? [input.expression] : [input]);
|
|
334
|
+
const boundInputs = (expression, inputs, seen = new Set()) => {
|
|
335
|
+
if (seen.has(expression))
|
|
336
|
+
return inputs;
|
|
337
|
+
const next = new Set([...seen, expression]);
|
|
338
|
+
if (ts.isCallExpression(expression) && ts.isPropertyAccessExpression(expression.expression) && expression.expression.name.text === "bind")
|
|
339
|
+
return boundInputs(expression.expression.expression, [...argumentValues(expression.arguments).slice(1), ...inputs], next);
|
|
340
|
+
if (ts.isParenthesizedExpression(expression) || ts.isAsExpression(expression) || ts.isNonNullExpression(expression))
|
|
341
|
+
return boundInputs(expression.expression, inputs, next);
|
|
342
|
+
if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression) && ts.isStringLiteralLike(expression.argumentExpression)) {
|
|
343
|
+
const field = ts.isPropertyAccessExpression(expression) ? expression.name.text : expression.argumentExpression.text;
|
|
344
|
+
const selected = selectedProperty(expression.expression, field);
|
|
345
|
+
if (selected)
|
|
346
|
+
return boundInputs(selected, inputs, next);
|
|
347
|
+
}
|
|
348
|
+
if (ts.isIdentifier(expression)) {
|
|
349
|
+
let scope = expression.parent;
|
|
350
|
+
while (scope) {
|
|
351
|
+
const initializer = initializers.get(scope)?.get(expression.text);
|
|
352
|
+
if (initializer)
|
|
353
|
+
return boundInputs(initializer, inputs, next);
|
|
354
|
+
if (declarations.get(scope)?.has(expression.text))
|
|
355
|
+
break;
|
|
356
|
+
scope = scope.parent;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
return inputs;
|
|
360
|
+
};
|
|
361
|
+
const rejectedValue = (expression, seen = new Set()) => {
|
|
362
|
+
if (seen.has(expression))
|
|
363
|
+
return undefined;
|
|
364
|
+
const next = new Set([...seen, expression]);
|
|
365
|
+
if (ts.isCallExpression(expression) && ts.isPropertyAccessExpression(expression.expression)
|
|
366
|
+
&& isGlobal(expression.expression.expression, "Promise") && expression.expression.name.text === "reject")
|
|
367
|
+
return expression.arguments[0];
|
|
368
|
+
if (ts.isCallExpression(expression) && ts.isPropertyAccessExpression(expression.expression)) {
|
|
369
|
+
const operation = expression.expression.name.text;
|
|
370
|
+
const handler = expression.arguments[operation === "then" ? 1 : 0];
|
|
371
|
+
if (operation === "finally" || ["then", "catch"].includes(operation)
|
|
372
|
+
&& (!handler || handler.kind === ts.SyntaxKind.NullKeyword || isGlobal(handler, "undefined")))
|
|
373
|
+
return rejectedValue(expression.expression.expression, next);
|
|
374
|
+
if (["then", "catch"].includes(operation) && handler)
|
|
375
|
+
return callbackRejection(handler, rejectedValue(expression.expression.expression, next), next);
|
|
376
|
+
}
|
|
377
|
+
if (ts.isParenthesizedExpression(expression) || ts.isAsExpression(expression) || ts.isNonNullExpression(expression))
|
|
378
|
+
return rejectedValue(expression.expression, next);
|
|
379
|
+
if (ts.isIdentifier(expression)) {
|
|
380
|
+
let scope = expression.parent;
|
|
381
|
+
while (scope) {
|
|
382
|
+
const initializer = initializers.get(scope)?.get(expression.text);
|
|
383
|
+
if (initializer)
|
|
384
|
+
return rejectedValue(initializer, next);
|
|
385
|
+
if (declarations.get(scope)?.has(expression.text))
|
|
386
|
+
break;
|
|
387
|
+
if (ts.isFunctionLike(scope)) {
|
|
388
|
+
const parameter = scope.parameters.find(parameter => ts.isIdentifier(parameter.name) && parameter.name.text === expression.text);
|
|
389
|
+
if (parameter) {
|
|
390
|
+
const input = parameterInputs.get(parameter);
|
|
391
|
+
return input ? rejectedValue(input, next) : undefined;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
scope = scope.parent;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
return undefined;
|
|
398
|
+
};
|
|
313
399
|
const selectedElements = (selected) => {
|
|
314
400
|
const values = arrayValues(selected.expression);
|
|
315
401
|
return values && selected.element !== undefined ? selected.rest ? values.slice(selected.element) : values.slice(selected.element, selected.element + 1) : [selected.expression];
|
|
@@ -409,13 +495,14 @@ export function inspectRouteUrlSource(file, source) {
|
|
|
409
495
|
return false;
|
|
410
496
|
};
|
|
411
497
|
const evaluatingFunctions = new Set();
|
|
498
|
+
const parameterValue = (parameter, index, inputs) => parameter.dotDotDotToken ? ts.factory.createArrayLiteralExpression(inputs.slice(index).map(input => input ?? ts.factory.createIdentifier("undefined"))) : inputs[index];
|
|
412
499
|
const callbackInternal = (callback, seen, inputs = [], elements = [], fulfillOnly = false) => {
|
|
413
500
|
if (!callback?.body || evaluatingFunctions.has(callback))
|
|
414
501
|
return false;
|
|
415
502
|
evaluatingFunctions.add(callback);
|
|
416
503
|
const previous = callback.parameters.map(parameter => ({ parameter, input: parameterInputs.get(parameter), element: elementParameters.has(parameter) }));
|
|
417
504
|
for (const [index, parameter] of callback.parameters.entries()) {
|
|
418
|
-
const input = inputs
|
|
505
|
+
const input = parameterValue(parameter, index, inputs);
|
|
419
506
|
if (input)
|
|
420
507
|
parameterInputs.set(parameter, input);
|
|
421
508
|
else
|
|
@@ -440,10 +527,10 @@ export function inspectRouteUrlSource(file, source) {
|
|
|
440
527
|
internal = true;
|
|
441
528
|
}
|
|
442
529
|
else {
|
|
443
|
-
if (
|
|
530
|
+
if (callbackValue(node.expression, seen, node.arguments, [], true))
|
|
444
531
|
internal = true;
|
|
445
532
|
for (const argument of node.arguments)
|
|
446
|
-
if (
|
|
533
|
+
if (callbackValue(argument, seen, [], [], true))
|
|
447
534
|
internal = true;
|
|
448
535
|
}
|
|
449
536
|
}
|
|
@@ -466,6 +553,74 @@ export function inspectRouteUrlSource(file, source) {
|
|
|
466
553
|
evaluatingFunctions.delete(callback);
|
|
467
554
|
}
|
|
468
555
|
};
|
|
556
|
+
const callbackValue = (expression, seen, inputs = [], elements = [], fulfillOnly = false) => {
|
|
557
|
+
if (!expression)
|
|
558
|
+
return false;
|
|
559
|
+
const expanded = argumentValues(inputs);
|
|
560
|
+
const combined = boundInputs(expression, expanded);
|
|
561
|
+
const offset = combined.length - expanded.length;
|
|
562
|
+
return callbackInternal(resolveCallback(expression), seen, combined, elements.map(index => index + offset), fulfillOnly);
|
|
563
|
+
};
|
|
564
|
+
const rejectionOrigin = (expression, seen = new Set()) => {
|
|
565
|
+
if (seen.has(expression) || !ts.isIdentifier(expression))
|
|
566
|
+
return expression;
|
|
567
|
+
const next = new Set([...seen, expression]);
|
|
568
|
+
let scope = expression.parent;
|
|
569
|
+
while (scope) {
|
|
570
|
+
const initializer = initializers.get(scope)?.get(expression.text);
|
|
571
|
+
if (initializer)
|
|
572
|
+
return rejectionOrigin(initializer, next);
|
|
573
|
+
if (declarations.get(scope)?.has(expression.text))
|
|
574
|
+
break;
|
|
575
|
+
if (ts.isFunctionLike(scope)) {
|
|
576
|
+
const parameter = scope.parameters.find(parameter => ts.isIdentifier(parameter.name) && parameter.name.text === expression.text);
|
|
577
|
+
if (parameter) {
|
|
578
|
+
const input = parameterInputs.get(parameter);
|
|
579
|
+
return input ? rejectionOrigin(input, next) : expression;
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
scope = scope.parent;
|
|
583
|
+
}
|
|
584
|
+
return expression;
|
|
585
|
+
};
|
|
586
|
+
const callbackRejection = (expression, input, seen) => {
|
|
587
|
+
const callback = resolveCallback(expression);
|
|
588
|
+
if (!callback?.body || evaluatingFunctions.has(callback))
|
|
589
|
+
return undefined;
|
|
590
|
+
evaluatingFunctions.add(callback);
|
|
591
|
+
const inputs = boundInputs(expression, input ? [input] : []);
|
|
592
|
+
const previous = callback.parameters.map(parameter => ({ parameter, input: parameterInputs.get(parameter) }));
|
|
593
|
+
for (const [index, parameter] of callback.parameters.entries()) {
|
|
594
|
+
const value = parameterValue(parameter, index, inputs);
|
|
595
|
+
if (value)
|
|
596
|
+
parameterInputs.set(parameter, value);
|
|
597
|
+
else
|
|
598
|
+
parameterInputs.delete(parameter);
|
|
599
|
+
}
|
|
600
|
+
try {
|
|
601
|
+
const reasons = [];
|
|
602
|
+
const returned = (node) => {
|
|
603
|
+
if (node !== callback.body && ts.isFunctionLike(node))
|
|
604
|
+
return;
|
|
605
|
+
const value = ts.isThrowStatement(node) ? node.expression : ts.isReturnStatement(node) ? node.expression : node === callback.body && !ts.isBlock(node) ? node : undefined;
|
|
606
|
+
const reason = value && (ts.isThrowStatement(node) ? value : rejectedValue(value, seen));
|
|
607
|
+
if (reason)
|
|
608
|
+
reasons.push(rejectionOrigin(reason));
|
|
609
|
+
ts.forEachChild(node, returned);
|
|
610
|
+
};
|
|
611
|
+
returned(callback.body);
|
|
612
|
+
return reasons.length === 1 ? reasons[0] : reasons.length ? ts.factory.createArrayLiteralExpression(reasons) : undefined;
|
|
613
|
+
}
|
|
614
|
+
finally {
|
|
615
|
+
for (const { parameter, input: previousInput } of previous) {
|
|
616
|
+
if (previousInput)
|
|
617
|
+
parameterInputs.set(parameter, previousInput);
|
|
618
|
+
else
|
|
619
|
+
parameterInputs.delete(parameter);
|
|
620
|
+
}
|
|
621
|
+
evaluatingFunctions.delete(callback);
|
|
622
|
+
}
|
|
623
|
+
};
|
|
469
624
|
const selectedProperty = (expression, field, seen = new Set()) => {
|
|
470
625
|
if (seen.has(expression))
|
|
471
626
|
return undefined;
|
|
@@ -491,6 +646,16 @@ export function inspectRouteUrlSource(file, source) {
|
|
|
491
646
|
return undefined;
|
|
492
647
|
};
|
|
493
648
|
const internalValue = (expression, seen = new Set()) => {
|
|
649
|
+
if (ts.isArrayLiteralExpression(expression))
|
|
650
|
+
return expression.elements.some(value => internalValue(value, seen));
|
|
651
|
+
if (ts.isElementAccessExpression(expression) && ts.isNumericLiteral(expression.argumentExpression)) {
|
|
652
|
+
const values = arrayValues(expression.expression);
|
|
653
|
+
const binding = reference(expression.expression);
|
|
654
|
+
if (values && (!binding || !mutations.get(binding.scope)?.get(binding.name)?.length)) {
|
|
655
|
+
const value = values[Number(expression.argumentExpression.text)];
|
|
656
|
+
return !!value && internalValue(value, seen);
|
|
657
|
+
}
|
|
658
|
+
}
|
|
494
659
|
if (ts.isElementAccessExpression(expression) && isStringValue(expression.expression)) {
|
|
495
660
|
const index = expression.argumentExpression;
|
|
496
661
|
if (ts.isNumericLiteral(index) || ts.isStringLiteralLike(index) && /^\d+$/.test(index.text)
|
|
@@ -567,11 +732,25 @@ export function inspectRouteUrlSource(file, source) {
|
|
|
567
732
|
return internalValue(expression.expression, seen);
|
|
568
733
|
if (ts.isPropertyAssignment(expression))
|
|
569
734
|
return internalValue(expression.initializer, seen);
|
|
735
|
+
if (ts.isCallExpression(expression) && ts.isPropertyAccessExpression(expression.expression)
|
|
736
|
+
&& ["component", "fragment", "toString"].includes(expression.expression.name.text)
|
|
737
|
+
&& internalValue(expression.expression.expression, seen))
|
|
738
|
+
return true;
|
|
570
739
|
// An arbitrary function may consume a URL while returning unrelated domain data.
|
|
571
740
|
if (ts.isCallExpression(expression)) {
|
|
572
741
|
const localCallback = resolveCallback(expression.expression);
|
|
573
742
|
if (localCallback)
|
|
574
|
-
return
|
|
743
|
+
return callbackValue(expression.expression, seen, expression.arguments);
|
|
744
|
+
if (ts.isPropertyAccessExpression(expression.expression) && ["call", "apply"].includes(expression.expression.name.text)) {
|
|
745
|
+
const receiver = expression.expression.expression;
|
|
746
|
+
const callback = resolveCallback(receiver);
|
|
747
|
+
if (callback) {
|
|
748
|
+
const arguments_ = argumentValues(expression.arguments);
|
|
749
|
+
const inputs = expression.expression.name.text === "call" ? arguments_.slice(1)
|
|
750
|
+
: arguments_[1] ? arrayValues(arguments_[1]) ?? [arguments_[1]] : [];
|
|
751
|
+
return callbackValue(receiver, seen, inputs);
|
|
752
|
+
}
|
|
753
|
+
}
|
|
575
754
|
if (isPromiseResolver(expression.expression))
|
|
576
755
|
return !!expression.arguments[0] && internalValue(expression.arguments[0], seen);
|
|
577
756
|
if (["encodeURI", "encodeURIComponent", "decodeURI", "decodeURIComponent", "escape", "unescape", "btoa", "atob"].some(name => isGlobal(expression.expression, name)))
|
|
@@ -584,10 +763,9 @@ export function inspectRouteUrlSource(file, source) {
|
|
|
584
763
|
if (expression.expression.name.text === "of")
|
|
585
764
|
return expression.arguments.some(argument => internalValue(argument, seen));
|
|
586
765
|
if (expression.expression.name.text === "from") {
|
|
587
|
-
const callback = resolveCallback(expression.arguments[1]);
|
|
588
766
|
if (!expression.arguments[1])
|
|
589
767
|
return !!expression.arguments[0] && internalValue(expression.arguments[0], seen);
|
|
590
|
-
return
|
|
768
|
+
return callbackValue(expression.arguments[1], seen, [expression.arguments[0]], [0]);
|
|
591
769
|
}
|
|
592
770
|
}
|
|
593
771
|
if (ts.isPropertyAccessExpression(expression.expression) && isGlobal(expression.expression.expression, "Object")) {
|
|
@@ -613,7 +791,7 @@ export function inspectRouteUrlSource(file, source) {
|
|
|
613
791
|
const replacement = expression.arguments[1];
|
|
614
792
|
const callback = resolveCallback(replacement);
|
|
615
793
|
return internalValue(expression.expression.expression, seen) || (callback
|
|
616
|
-
?
|
|
794
|
+
? callbackValue(replacement, seen, [expression.expression.expression]) : !!replacement && internalValue(replacement, seen));
|
|
617
795
|
}
|
|
618
796
|
if (["toString", "valueOf", "join", "trim", "trimStart", "trimEnd", "trimLeft", "trimRight", "replace", "replaceAll", "toLowerCase", "toUpperCase", "toLocaleLowerCase", "toLocaleUpperCase", "normalize", "substring", "substr", "charAt", "at", "padStart", "padEnd", "repeat", "split"].includes(operation))
|
|
619
797
|
return internalValue(expression.expression.expression, seen);
|
|
@@ -653,13 +831,13 @@ export function inspectRouteUrlSource(file, source) {
|
|
|
653
831
|
const replacement = expression.arguments[1];
|
|
654
832
|
const callback = resolveCallback(replacement);
|
|
655
833
|
return internalValue(expression.expression.expression, seen) || (callback
|
|
656
|
-
?
|
|
834
|
+
? callbackValue(replacement, seen, [expression.expression.expression]) : !!replacement && internalValue(replacement, seen));
|
|
657
835
|
}
|
|
658
836
|
if (operation === "finally")
|
|
659
837
|
return internalValue(expression.expression.expression, seen);
|
|
660
|
-
for (const argument of expression.arguments) {
|
|
661
|
-
const
|
|
662
|
-
if (
|
|
838
|
+
for (const [index, argument] of expression.arguments.slice(0, operation === "then" ? 2 : 1).entries()) {
|
|
839
|
+
const input = operation === "then" && index === 0 ? expression.expression.expression : rejectedValue(expression.expression.expression);
|
|
840
|
+
if (callbackValue(argument, seen, input ? [input] : []))
|
|
663
841
|
return true;
|
|
664
842
|
}
|
|
665
843
|
return (operation === "catch" || !expression.arguments[0]) && internalValue(expression.expression.expression, seen);
|
|
@@ -670,21 +848,21 @@ export function inspectRouteUrlSource(file, source) {
|
|
|
670
848
|
if (ts.isPropertyAccessExpression(expression.expression) && ["map", "flatMap", "reduce", "reduceRight"].includes(expression.expression.name.text)) {
|
|
671
849
|
if (["reduce", "reduceRight"].includes(expression.expression.name.text) && expression.arguments[1] && internalValue(expression.arguments[1], seen))
|
|
672
850
|
return true;
|
|
673
|
-
const callback = resolveCallback(expression.arguments[0]);
|
|
674
851
|
return ["reduce", "reduceRight"].includes(expression.expression.name.text)
|
|
675
|
-
?
|
|
676
|
-
:
|
|
852
|
+
? callbackValue(expression.arguments[0], seen, [expression.arguments[1], expression.expression.expression], [1])
|
|
853
|
+
: callbackValue(expression.arguments[0], seen, [expression.expression.expression], [0]);
|
|
677
854
|
}
|
|
678
|
-
return
|
|
855
|
+
return callbackValue(expression.expression, seen, expression.arguments);
|
|
679
856
|
}
|
|
680
857
|
if (ts.isNewExpression(expression) && isGlobal(expression.expression, "Promise")) {
|
|
681
858
|
const executor = resolveCallback(expression.arguments?.[0]);
|
|
682
|
-
const
|
|
859
|
+
const prefix = expression.arguments?.[0] ? boundInputs(expression.arguments[0], []).length : 0;
|
|
860
|
+
const parameter = executor?.parameters[prefix];
|
|
683
861
|
if (!executor || !parameter)
|
|
684
862
|
return false;
|
|
685
863
|
promiseResolvers.add(parameter);
|
|
686
864
|
try {
|
|
687
|
-
return
|
|
865
|
+
return callbackValue(expression.arguments?.[0], seen, [], [], true);
|
|
688
866
|
}
|
|
689
867
|
finally {
|
|
690
868
|
promiseResolvers.delete(parameter);
|
|
@@ -736,7 +914,9 @@ export function inspectRouteUrlSource(file, source) {
|
|
|
736
914
|
: ts.isPropertyAccessExpression(expression) ? factoryNames.has(expression.name.text) && factoryImport(expression.expression, true, seen)
|
|
737
915
|
|| expression.name.text === "forContext" && factory(expression.expression, seen)
|
|
738
916
|
: ts.isCallExpression(expression) ? factory(expression.expression, seen) : false;
|
|
739
|
-
const
|
|
917
|
+
const pathSegments = file.replace(/\\/g, "/").split("/");
|
|
918
|
+
const routeHandlerFile = pathSegments.slice(0, -1).includes("bp-routes")
|
|
919
|
+
&& /^(?:GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS|SSE|STREAM)\.(?:[cm]?ts|tsx)$/.test(pathSegments.at(-1) ?? "");
|
|
740
920
|
const isReturnedValue = (node) => {
|
|
741
921
|
let current = node.parent;
|
|
742
922
|
while (current && !ts.isFunctionLike(current)) {
|
|
@@ -836,16 +1016,16 @@ export function inspectRouteUrlSource(file, source) {
|
|
|
836
1016
|
if (ts.isParenthesizedExpression(expression) || ts.isAsExpression(expression) || ts.isNonNullExpression(expression))
|
|
837
1017
|
return isResolverFunction(expression.expression, seen);
|
|
838
1018
|
if (ts.isPropertyAccessExpression(expression))
|
|
839
|
-
return expression.name.text === "
|
|
1019
|
+
return expression.name.text === "route" && contextValue(expression.expression);
|
|
840
1020
|
if (ts.isElementAccessExpression(expression))
|
|
841
|
-
return ts.isStringLiteralLike(expression.argumentExpression) && expression.argumentExpression.text === "
|
|
1021
|
+
return ts.isStringLiteralLike(expression.argumentExpression) && expression.argumentExpression.text === "route" && contextValue(expression.expression);
|
|
842
1022
|
if (!ts.isIdentifier(expression) || seen.has(expression.text))
|
|
843
1023
|
return false;
|
|
844
1024
|
let scope = expression.parent;
|
|
845
1025
|
while (scope) {
|
|
846
1026
|
const selected = selections.get(scope)?.get(expression.text);
|
|
847
1027
|
if (selected)
|
|
848
|
-
return selected.element !== undefined ? !selected.rest && selectedElements(selected).some(value => isResolverFunction(value, new Set([...seen, expression.text]))) : selected.field === "
|
|
1028
|
+
return selected.element !== undefined ? !selected.rest && selectedElements(selected).some(value => isResolverFunction(value, new Set([...seen, expression.text]))) : selected.field === "route" && contextValue(selected.expression);
|
|
849
1029
|
const initializer = initializers.get(scope)?.get(expression.text);
|
|
850
1030
|
if (initializer)
|
|
851
1031
|
return isResolverFunction(initializer, new Set([...seen, expression.text]));
|
|
@@ -926,18 +1106,18 @@ export function inspectRouteUrlSource(file, source) {
|
|
|
926
1106
|
|| isGlobal(expression.expression, "Promise") && ["resolve", "all", "allSettled", "race", "any"].includes(expression.name.text));
|
|
927
1107
|
};
|
|
928
1108
|
const visit = (node) => {
|
|
929
|
-
if (ts.isPropertyAccessExpression(node) && node.name.text
|
|
930
|
-
|| ts.isElementAccessExpression(node) && ts.isStringLiteralLike(node.argumentExpression) && node.argumentExpression.text
|
|
931
|
-
|| ts.isBindingElement(node) && (node.propertyName ?? node.name).getText(tree).replace(/^["']|["']$/g, "")
|
|
1109
|
+
if (ts.isPropertyAccessExpression(node) && ["uiRouteUrl", "routeUrl", "routeUi"].includes(node.name.text) && contextValue(node.expression)
|
|
1110
|
+
|| ts.isElementAccessExpression(node) && ts.isStringLiteralLike(node.argumentExpression) && ["uiRouteUrl", "routeUrl", "routeUi"].includes(node.argumentExpression.text) && contextValue(node.expression)
|
|
1111
|
+
|| ts.isBindingElement(node) && ["uiRouteUrl", "routeUrl", "routeUi"].includes((node.propertyName ?? node.name).getText(tree).replace(/^["']|["']$/g, ""))
|
|
932
1112
|
&& ts.isObjectBindingPattern(node.parent) && ts.isVariableDeclaration(node.parent.parent)
|
|
933
1113
|
&& !!node.parent.parent.initializer && contextValue(node.parent.parent.initializer)
|
|
934
|
-
|| ts.isBindingElement(node) && (node.propertyName ?? node.name).getText(tree).replace(/^["']|["']$/g, "")
|
|
1114
|
+
|| ts.isBindingElement(node) && ["uiRouteUrl", "routeUrl", "routeUi"].includes((node.propertyName ?? node.name).getText(tree).replace(/^["']|["']$/g, ""))
|
|
935
1115
|
&& ts.isObjectBindingPattern(node.parent) && ts.isParameter(node.parent.parent) && contextValue(node.parent)) {
|
|
936
|
-
report(node, "
|
|
1116
|
+
report(node, "Legacy routing helpers were removed. Prefer BPRoute; use ctx.route({ ... }) for explicit destinations.");
|
|
937
1117
|
}
|
|
938
1118
|
if (ts.isPropertyAccessExpression(node) && ["route", "uiRoute", "current", "path"].includes(node.name.text)
|
|
939
1119
|
&& ts.isPropertyAccessExpression(node.expression) && node.expression.name.text === "url" && contextValue(node.expression.expression)) {
|
|
940
|
-
report(node, "ctx.url helpers were removed. Use ctx.
|
|
1120
|
+
report(node, "ctx.url helpers were removed. Use ctx.route({ ... }); omit the target for self.");
|
|
941
1121
|
}
|
|
942
1122
|
if (ts.isCallExpression(node) && isResolverFunction(node.expression)) {
|
|
943
1123
|
if (node.arguments[0] && ts.isObjectLiteralExpression(node.arguments[0])
|
|
@@ -945,7 +1125,7 @@ export function inspectRouteUrlSource(file, source) {
|
|
|
945
1125
|
report(node, "absolute/origin options were removed. Select the corresponding absolute destination field.");
|
|
946
1126
|
}
|
|
947
1127
|
if ((node.arguments.length > 1 || node.arguments[0] && ts.isStringLiteralLike(node.arguments[0]))) {
|
|
948
|
-
report(node, "
|
|
1128
|
+
report(node, "route no longer accepts a positional view id or returns a string. Pass one options object and select a destination field.");
|
|
949
1129
|
}
|
|
950
1130
|
}
|
|
951
1131
|
let field;
|
|
@@ -975,12 +1155,12 @@ export function inspectRouteUrlSource(file, source) {
|
|
|
975
1155
|
report(node, "Do not return internal route paths as API response fields. Resolve them at the point of use; only public absoluteUiPath links belong in domain responses.");
|
|
976
1156
|
}
|
|
977
1157
|
if ((ts.isStringLiteralLike(node) || ts.isNoSubstitutionTemplateLiteral(node)) && /(?:href|action|hx-(?:get|post|put|patch|delete|download))=["']\{[A-Za-z0-9_$.-]+\}["']/.test(node.text)) {
|
|
978
|
-
report(node, "Legacy route tokens were removed. Resolve the destination with ctx.
|
|
1158
|
+
report(node, "Legacy route tokens were removed. Resolve the destination with ctx.route in the renderer.");
|
|
979
1159
|
}
|
|
980
1160
|
if (ts.isJsxAttribute(node) && node.initializer && ts.isStringLiteralLike(node.initializer)
|
|
981
1161
|
&& ["href", "action", "hx-get", "hx-post", "hx-put", "hx-patch", "hx-delete", "hx-download", "sse-connect"].includes(node.name.getText(tree))
|
|
982
1162
|
&& /^\{[A-Za-z0-9_$.-]+\}$/.test(node.initializer.text)) {
|
|
983
|
-
report(node, "Legacy route tokens were removed. Resolve the destination with ctx.
|
|
1163
|
+
report(node, "Legacy route tokens were removed. Resolve the destination with ctx.route in the renderer.");
|
|
984
1164
|
}
|
|
985
1165
|
ts.forEachChild(node, visit);
|
|
986
1166
|
};
|