Support single-subscription events modules when reading remote configuration - #8425
Conversation
…uration Assisted-By: devx/aa56a38c-289a-416e-8a9a-0de281e4e3e7
33e9272 to
80e3b4b
Compare
…vents configuration Assisted-By: devx/aa56a38c-289a-416e-8a9a-0de281e4e3e7
1a14973 to
db2b32f
Compare
…nking config When Core returns events modules where subscriptions have no handle, fall back to the parent module's registration title (except for the default 'events' handle) so each single-subscription module retains its identity when merged into the local configuration. Pass the identity through the generic reverse-transform options as module.handle, matching the shared module context other specifications consume.
db2b32f to
f07a960
Compare
|
|
||
| const subscription = eventsConfig.events.subscription | ||
| const resolved = wrapSubscriptions(subscription).map((sub) => | ||
| typeof sub.uri === 'string' ? {...sub, uri: prependApplicationUrl(sub.uri, appUrl)} : sub, |
There was a problem hiding this comment.
I know this prepend already existed but... is it needed?
If this is true:
- On
deploy, the backend accepts relative URLs right? - On
dev, we don't want to use real URLs (we want to use the tunnel URL)
And assuming this:
- We don't update the toml with the tunnel URL anymore during
dev, so it will always have a "real" one.
So... isn't it better to keep the relative URLs in the toml and prepend them ONLY during dev?
There was a problem hiding this comment.
We could but this would change how link currently works as the module stores the full URI today and would return that as part of link. This isn't really a changing existing behaviour so maybe we can address this as a separate PR to unblock this one?
| if (Array.isArray(subscription)) { | ||
| cleanedSubscriptions = subscription.map(clean) | ||
| } else if (subscription) { | ||
| const handle = subscription.handle ?? moduleHandle |
There was a problem hiding this comment.
is there any risk on using the moduleHandle as default here? can it lead to duplicate handles in any way?
If yes -> maybe we need to use something random here
If not -> Can we then just use a hardcoded default to avoid passing the module handle to the transform function? It can be something like: events-handle or {subscription.identifier}
There was a problem hiding this comment.
In the function signature we are even saying that moduleHandle is optional, so there is even a possibility where handle is undefined here, with a hardcoded/computed value here we prevent that and also simplify the changes a lot in this PR
Core keeps a single-subscription handle on the module and rejects it inside the subscription. The handle is also the module uid and the seed of the subscription identifier, so a handle derived from the topic and actions changes the module identity after config link, and can collide when two subscriptions share a topic and actions. Pass the module handle to the reverse transform and keep the derived handle only as a fallback. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The remote side of the breakdown restores each single-subscription handle from its module. Pass the local module handle too, so matching modules don't show the events section as updated on every deploy. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…dules The platform derives a single-subscription module's runtime handle, uid and identifier from the module handle and rejects a nested handle on write, so a nested handle can only survive on older versions and must not win over the module handle when linking.
Context
As part of supporting shop-scoped event subscriptions, we now support a dual contract for the
eventsmodule where it may either be a single subscription object (new) or a list of subscriptions. We want to move away from having two contracts and move towards a single contract as it brings forth a better DX with regards to subscription management and maintains consistency across shop-scoped and app-versioned events modules.The CLI's events transforms are currently hard-typed to the list shape:
transformToEventsConfigcalls.maponsubscriptionand crashes on an object, andconfig linkwould need N single-subscription modules to merge back into one[[events.subscription]]list in the local TOML.WHAT is this pull request doing?
transformToEventsConfig(remote → local): accepts a single-subscription object or the legacy array. N single-subscription modules are transformed into a list in the TOML so as to maintain the existing TOML structure.transformToEventsConfigalso strips a subscription'sapi_versionwhen it equals the module-levelevents.api_version. Anapi_versionthat differs from the default is a genuine per-subscription override and is kept.transformFromEventsConfig(local → remote): resolves relative subscription URIs for both shapes, preserving the input shape.The local TOML format is unchanged:
[[events.subscription]]stays a list, andapi_versionappears on a subscription only when it overrides the section default. This is read-side tolerance only.How to test your changes?
With an app in your local environment, test
shopify app config link. It should continue working as normal.Post-release steps
None.
Measuring impact
Checklist