Skip to content

[Prototype] POS UI extension intercept declaration (capabilities.intercepts)#8057

Draft
henryStelle wants to merge 6 commits into
mainfrom
henry/pos-intercept-failsafe-config
Draft

[Prototype] POS UI extension intercept declaration (capabilities.intercepts)#8057
henryStelle wants to merge 6 commits into
mainfrom
henry/pos-intercept-failsafe-config

Conversation

@henryStelle

Copy link
Copy Markdown
Contributor

Prototype — not for merge. The CLI slice of a cross-repo POS intercept prototype (paired with shop/world PR #925699).

What this adds

TOML schema support for a POS UI extension to declare which intercept events it may block:

[capabilities]
intercepts = ["beforecheckout", "beforepayment"]

Changes

  • models/extensions/specifications/pos_ui_extension.tsPOS_INTERCEPT_EVENTS const; PosCapabilitiesSchema extends the shared CapabilitiesSchema with an optional intercepts array of known event enums + a uniqueness superRefine; POS spec overrides capabilities; deployConfig passes intercepts through.
  • models/extensions/schemas.ts — only added export to the shared CapabilitiesSchema. The shared block_progress boolean is untouched (checkout unaffected).

Prototype scope notes

  • POS-specific capability key; does not overload checkout's shared block_progress.
  • Tests intentionally removed — prototype, no new tests gating it.
  • Backend deploy wiring is consumed downstream in shop/world (config.intercepts).

POS UI extensions can now declare, in shopify.extension.toml, which
host-mediated intercept events they participate in and whether they
intend to block progress on each. This is the event-scoped POS analogue
of checkout's single `capabilities.block_progress` capability.

TOML shape (top-level array of tables):

  [[intercepts]]
  event = "beforecheckout"
  block_progress = true

- event: required, validated against POS_INTERCEPT_EVENTS
  (beforecheckout, beforepayment) — extensible const
- block_progress: optional boolean, defaults to false
- duplicate events are rejected
- declarations flow through deployConfig for later backend wiring

Prototype: schema + parsing + validation + tests (Area B, step 1).
Assisted-By: devx/a246d980-dba0-4a06-b4d4-27c89d8ca9bf
Per design confirmation, replace the [[intercepts]] array-of-tables with
a single POS-specific capability: a string array of blockable events.

  [capabilities]
  intercepts = ["beforecheckout", "beforepayment"]

Membership in the array = the extension may block that event (collapses
"intercepts at all" vs "can block" into one blockable set, intended for
the prototype).

- Export shared CapabilitiesSchema; POS extends it with an optional
  `intercepts` array of POS_INTERCEPT_EVENTS enums. Shared block_progress
  boolean is untouched (checkout depends on it); intercepts is POS-only.
- Unknown events rejected with a clear message; duplicates rejected via
  a uniqueness superRefine on the array.
- deployConfig emits capabilities (incl. intercepts); mapping kept thin
  for the pending cross-repo field rename.
- Tests updated: valid/empty parse, coexists-with-shared-capabilities,
  unknown-event + duplicate rejection, deployConfig includes/omits.

Assisted-By: devx/a246d980-dba0-4a06-b4d4-27c89d8ca9bf
Drop the newly-added pos_ui_extension.test.ts. This is a prototype and
the tests should not gate it. All source/schema changes are kept.

Note: with the test gone, knip flags POS_INTERCEPT_EVENTS as an unused
export (the test was its only external consumer). The const is still
used internally by the schema; left as-is intentionally.

Assisted-By: devx/a246d980-dba0-4a06-b4d4-27c89d8ca9bf
The const is still used internally by the intercept schema, but has no
external consumer now that the prototype tests are gone. Keep it local
to satisfy knip; re-add `export` when real consumers land.

Assisted-By: devx/a246d980-dba0-4a06-b4d4-27c89d8ca9bf
@github-actions github-actions Bot added the Area: @shopify/cli @shopify/cli package issues label Jul 10, 2026
Intercept events are functionally equivalent to extension targets, which
are free-form strings validated server-side (the CLI never hardcodes the
valid target list). Match that precedent so the intercept event set stays
forward-compatible: new events can ship without a CLI release and won't be
rejected by older CLI installs.

- intercepts: array(enum(POS_INTERCEPT_EVENTS)) -> array(string) with a
  light lowercase-identifier format check (structural only, not a value
  allowlist). Server remains the source of truth for valid event names.
- Keep the duplicate-rejection superRefine (structural, forward-compatible).
- Delete the POS_INTERCEPT_EVENTS const entirely.

Assisted-By: devx/a246d980-dba0-4a06-b4d4-27c89d8ca9bf
Per design: intercept event names are lowercase a-z only, no digits.
Change the format check from /^[a-z][a-z0-9]*$/ to /^[a-z]+$/.
Everything else (array(string), dedupe refine) unchanged.

Assisted-By: devx/a246d980-dba0-4a06-b4d4-27c89d8ca9bf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: @shopify/cli @shopify/cli package issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant