feat(pos): add TypeScript types for pos.app.ready.data background target#4123
feat(pos): add TypeScript types for pos.app.ready.data background target#4123vctrchu wants to merge 7 commits into2026-04-rcfrom
Conversation
🚨🚨🚨 Docs migration in progress 🚨🚨🚨We are actively migrating UI extension reference docs to MDX in the
During this migration, please be aware of the following:
Doc comments in Examples that previously lived in this repo are being moved to the What should I do?
Thanks for your patience while we complete the migration! 🙏 |
1ac2792 to
405dc2b
Compare
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
6528efa to
2d36a20
Compare
NathanJolly
left a comment
There was a problem hiding this comment.
This PR has the target definition and DataTargetApi, but it's missing two things that should ship together:
-
addEventListener / removeEventListener — needs to be part of
DataTargetApi(or the target's API surface). The generic types are defined in the TAG proposal (ui-api-design PR #1418), and the surface-specificPosEventMapwith concrete event types + payloads should be defined here. -
PosEventMap — the typed event map with
transaction_complete,cash_tracking_session_start,cash_tracking_session_completeand their payload interfaces. This is what makes addEventListener type-safe for POS.
Without these, extensions targeting pos.app.ready.data have no way to type-safely listen for events.
|
Added both. |
8ce7778 to
06eeda4
Compare
e2c600a to
e63759e
Compare
c9e53ce to
83610ef
Compare
|
/snapit |
Add DataTargetApi type and DataExtensionTargets interface for the new persistent background extension target. DataTargetApi provides the full POS API surface excluding UI-presenting APIs (Toast, Print, Camera, PinPad). Background extensions that need UI should use companion targets. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…o DataTargetApi Adds type-safe event listener support for the pos.app.ready.data background target. PosEventMap defines three discrete events: transaction_complete, cash_tracking_session_start, cash_tracking_session_complete. The generic AddEventListener/RemoveEventListener types follow the TAG proposal (ui-api-design PR #1418) and match the existing Navigation API pattern. Cart changes are intentionally excluded — they are state, not events, and should use shopify.cart.current.subscribe() instead. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…mentation Remove addEventListener/removeEventListener from DataTargetApi. POS events are received via the standard window.addEventListener() Web API. PosEventMap augments WindowEventMap for type-safe event listening.
83610ef to
3b55663
Compare
|
🫰✨ Thanks @vctrchu! Your snapshots have been published to npm. Test the snapshots by updating your "@shopify/ui-extensions": "0.0.0-snapshot-20260330221356",
"@shopify/ui-extensions-tester": "0.0.0-snapshot-20260330221356" |
…consumers
Without this, PosEventMap never augments WindowEventMap for package
consumers — window.addEventListener('transaction_complete', ...) has
no type-safe autocomplete. Follows checkout surface precedent.
80a1547 to
93c4e1d
Compare
93c4e1d to
6edab18
Compare
Copy .d.ts event type definitions from ui-api-design build output instead of hand-writing PosEventMap. This follows the same pattern checkout uses for syncing types from the private repo. - Add events/events.d.ts (TransactionCompleteEvent, CashTracking* events) - Add events/index.d.ts (ShopifyEventMap, WindowEventMap augmentation) - Remove manual PosEventMap and old transaction data imports - Export ShopifyEventMap and individual event types from api.ts
6edab18 to
5d0a28d
Compare

What
Add TypeScript types for the
pos.app.ready.datapersistent background extension target.New types
DataTargetApi<T>— API surface for non-rendering data targets. Includes all non-UI APIs (cart, storage, session, locale, connectivity, device, product search) but excludes UI-presenting APIs (modals, toasts, scanners, pin pads).ShopifyEventMap— Maps event names to their typed Event subclasses (transactioncomplete,cashtrackingsessionstart,cashtrackingsessioncomplete). Sourced fromui-api-designbuild output.DataExtensionTargets— New target interface withpos.app.ready.dataas aRunnableExtension<DataTargetApi, undefined>.DataExtensionTarget— Type alias for data target keys.Event types (from ui-api-design)
Event type definitions are copied from the
ui-api-designbuild output (.d.tsfiles), following the same pattern checkout uses for syncing types from the private repo. Events are flatEventsubclasses with readonly properties:TransactionCompleteEvent—orderId(gid),transactionType(sale/return/exchange),customer?,grandTotal,executedAtCashTrackingSessionStartEvent—id(UUID),openingTimeCashTrackingSessionCompleteEvent—id(UUID),openingTime,closingTimeWindowEventMapaugmentationPOS host events are received via the standard
window.addEventListener()Web API.ShopifyEventMapaugmentsWindowEventMapso calls are fully type-safe.Why
POS apps need a persistent background extension that starts when POS loads and runs for the session lifetime. This replaces the existing fire-and-forget
.event.observetargets with a single long-lived target that receives events viawindow.addEventListener, aligning with web standards.Related PRs
eventListenerPlugin+eventDispatchFactory)