fix(javascript): honor final RPC object properties

Resolve final object writes once at the RPC endpoint producer. Unknown computed writes and spreads remain barriers; overridden properties do not invent endpoints. Source, CLI and stdio MCP regressions cover the behavior.

Co-authored-by: Vaishnavi220506 <vaishnaviharish2006@gmail.com>
This commit is contained in:
morluto
2026-10-14 15:20:05 +08:00
parent 9d00d7d7fa
commit b8eea783da
4 changed files with 124 additions and 20 deletions
+17 -20
View File
@@ -122,33 +122,30 @@ const objectKeys = (node: t.Node | undefined): readonly string[] =>
})
: [];
const objectStringProperty = (
node: t.ObjectExpression,
key: string,
): string | undefined => {
for (const property of node.properties)
if (
t.isObjectProperty(property) &&
semanticStaticPropertyKey(property.key, property.computed) === key &&
t.isStringLiteral(property.value)
)
return property.value.value;
return undefined;
};
/** Later properties own a key; an intervening dynamic write leaves it unknown. */
const objectProperty = (
node: t.ObjectExpression,
key: string,
): t.Node | undefined => {
for (const property of node.properties)
if (
t.isObjectProperty(property) &&
semanticStaticPropertyKey(property.key, property.computed) === key
)
return property.value;
for (let index = node.properties.length - 1; index >= 0; index -= 1) {
const property = node.properties[index];
if (property === undefined || t.isSpreadElement(property)) return undefined;
const name = semanticStaticPropertyKey(property.key, property.computed);
if (name === null) return undefined;
if (name === key)
return t.isObjectProperty(property) ? property.value : undefined;
}
return undefined;
};
const objectStringProperty = (
node: t.ObjectExpression,
key: string,
): string | undefined => {
const value = objectProperty(node, key);
return t.isStringLiteral(value) ? value.value : undefined;
};
const GRAPHQL_OPERATION_TYPES: ReadonlySet<string> = new Set([
"query",
"mutation",