Skip to content

feat(pos): add TypeScript types for pos.app.ready.data background target#4123

Draft
vctrchu wants to merge 2 commits intovchu/fix-doc-gen-world-pathfrom
vchu/bgx-types-pos-app-ready-data
Draft

feat(pos): add TypeScript types for pos.app.ready.data background target#4123
vctrchu wants to merge 2 commits intovchu/fix-doc-gen-world-pathfrom
vchu/bgx-types-pos-app-ready-data

Conversation

@vctrchu
Copy link
Copy Markdown
Contributor

@vctrchu vctrchu commented Mar 17, 2026

What

Add TypeScript types for the pos.app.ready.data background extension target:

  • DataTargetApi with addEventListener/removeEventListener + PosEventMap
  • Target registration in extension-targets.ts

Why

Background extensions need typed APIs for the new pos.app.ready.data target to receive passive events (e.g., transaction_complete).

Base Branch

2026-04-rc

@github-actions
Copy link
Copy Markdown
Contributor

🚨🚨🚨 Docs migration in progress 🚨🚨🚨

We are actively migrating UI extension reference docs to MDX in the areas/platforms/shopify-dev zone of the monorepo. This impacts docs for the following surfaces:

During this migration, please be aware of the following:

.doc.ts files are being deprecated. Changes to .doc.ts files in this repo will not be reflected in the new MDX-based docs. If you need to update docs for a reference that has already been migrated, make your changes directly in the areas/platforms/shopify-dev zone of the monorepo instead.

Doc comments in .ts source files (the comment blocks above types and functions) are also affected. Generating docs from these comments currently requires a newer version of the @shopify/generate-docs library that isn't yet available. Updates to doc comments may not produce the expected output until the migration is complete.

Examples that previously lived in this repo are being moved to the areas/platforms/shopify-dev zone of the monorepo and should be authored there going forward.

What should I do?

  • If your PR includes changes to .doc.ts files, doc comments, or examples, please reach out to us in #devtools-proj-templated-refs so we can help ensure your updates are captured correctly.
  • If your PR is limited to source code changes (non-docs), you can ignore this notice.

Thanks for your patience while we complete the migration! 🙏

@vctrchu vctrchu self-assigned this Mar 17, 2026
@vctrchu vctrchu force-pushed the vchu/bgx-types-pos-app-ready-data branch from 1ac2792 to 405dc2b Compare March 17, 2026 23:23
@vctrchu vctrchu changed the base branch from 2026-04-rc to vchu/fix-doc-gen-world-path March 17, 2026 23:23
Copy link
Copy Markdown
Contributor Author

vctrchu commented Mar 17, 2026

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.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

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>
@vctrchu vctrchu force-pushed the vchu/bgx-types-pos-app-ready-data branch from 6528efa to 2d36a20 Compare March 18, 2026 18:44
Copy link
Copy Markdown
Contributor

@NathanJolly NathanJolly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR has the target definition and DataTargetApi, but it's missing two things that should ship together:

  1. 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-specific PosEventMap with concrete event types + payloads should be defined here.

  2. PosEventMap — the typed event map with transaction_complete, cash_tracking_session_start, cash_tracking_session_complete and 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.

…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>
@vctrchu
Copy link
Copy Markdown
Contributor Author

vctrchu commented Mar 18, 2026

Added both. DataTargetApi now includes addEventListener and removeEventListener using the generic types from the TAG proposal (ui-api-design #1418). Also added PosEventMap with transaction_complete, cash_tracking_session_start, and cash_tracking_session_complete — no cart_update since that's state, not an event.

@vctrchu vctrchu changed the title Add TypeScript types for pos.app.ready.data background target feat(pos): add BGX types — pos.app.ready.data target + storage.keys subscribable Mar 27, 2026
@vctrchu vctrchu force-pushed the vchu/bgx-types-pos-app-ready-data branch from 8ce7778 to 06eeda4 Compare March 27, 2026 23:15
@vctrchu vctrchu changed the title feat(pos): add BGX types — pos.app.ready.data target + storage.keys subscribable feat(pos): add TypeScript types for pos.app.ready.data background target Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants