[APPS][Connections Part 3] Resolve same-module connection ID constants#351
Conversation
6cea58a to
d7aca74
Compare
958f598 to
903a98b
Compare
ec55fa9 to
908d3d4
Compare
908d3d4 to
cd42b54
Compare
cd42b54 to
2a5b6a3
Compare
| case 'Identifier': | ||
| return resolveIdentifierValue(node, context); | ||
| default: | ||
| throw unsupportedConnectionId(context.filePath, `unsupported ${node.type} values`); |
There was a problem hiding this comment.
We will expand upon this in a further PR (#354) to support object values such as CONNECTIONS.HTTP (
| // Imported values require following another module, which is deferred to | ||
| // the module graph PR: | ||
| // import { HTTP_CONNECTION_ID } from './connections'; | ||
| throw unsupportedConnectionId( |
There was a problem hiding this comment.
We plan on handling this in a future PR.
2a5b6a3 to
2826a40
Compare
| // const HTTP_CONNECTION_ID = 'abc'; | ||
| // request({ connectionId: HTTP_CONNECTION_ID }); | ||
| // } | ||
| throw unsupportedConnectionId( |
There was a problem hiding this comment.
Its probably worth handling this in a followup PR.
|
Codex Review: Didn't find any major issues. Delightful! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
| const { value } = connectionIdProperty; | ||
| if (value.type === 'Literal' && typeof value.value === 'string') { | ||
| return value.value; | ||
| return resolveConnectionIdValue(connectionIdProperty.value as Expression, { |
There was a problem hiding this comment.
nit: if we don't want to cast as Expression, we could narrow findConnectionIdProperty's return type to Property & { value: Expression }
type ConnectionIdProperty = Property & { value: Expression };
function hasExpressionValue(property: Property): property is ConnectionIdProperty {
const { value } = property;
return (
value.type !== 'ObjectPattern' &&
value.type !== 'ArrayPattern' &&
value.type !== 'RestElement' &&
value.type !== 'AssignmentPattern'
);
}
function findConnectionIdProperty(
objectExpression: ObjectExpression,
filePath: string,
): ConnectionIdProperty | undefined {
let connectionIdProperty: ConnectionIdProperty | undefined;
...
if (!hasExpressionValue(property)) {
throw unsupportedActionCatalogCall(
filePath,
'destructuring pattern in connectionId value',
);
}
connectionIdProperty = property;
}
}
return connectionIdProperty;
}There was a problem hiding this comment.
Good call 👍. I'll make the change.
2826a40 to
acbf509
Compare

Motivation
This builds on the inline connection ID extractor from #349. Inline string literals are safe, but backend code commonly assigns a connection ID to a same-file constant before passing it to action-catalog.
This PR adds the smallest useful same-module value resolver first so the follow-up object-map PR can be reviewed separately.
Changes
Adds same-module static value resolution for direct constant forms:
The resolver tracks declarations by
eslint-scopevariable identity, preserving shadowing behavior from #349. It supports top-level same-file const strings, exported top-level consts, const-to-const chains, and static template literals without interpolation.It intentionally rejects member expressions such as
CONNECTIONS.HTTP, imported values, mutable bindings, function-local bindings, dynamic templates, calls, binary expressions, environment reads, and const cycles. Same-module object-map support is split into the next PR.QA Instructions
Ran:
Parent branch result: 46 tests passed.
Blast Radius
This affects Apps backend function discovery/upload/dev-server manifest generation for action-catalog connection allowlists. Runtime backend execution is unchanged. Unsupported known action-catalog
connectionIdforms fail closed instead of producing an incomplete allowlist.Documentation