metatrondelivery/shopify.app.toml
metatroncubeswdev 381c52d01a fix: replace hand-scaffolded Functions with real CLI-generated ones
The user linked the app to a real Partner org and hit two live errors
running `shopify app dev`, which is exactly the verification the earlier
hand-scaffolded Functions couldn't get in this environment. Root-caused and
fixed both, then went further: regenerated both Functions from scratch via
`shopify app generate extension` (now possible — the user's session had
authenticated) instead of patching the guesses.

What broke and why:
- `shopify app config link` pulled a fresh app's (empty) remote config and
  overwrote shopify.app.toml, dropping the webhook subscriptions and
  app_proxy block — restored both, keeping the real client_id/name/scopes
  the CLI set.
- `[extensions.build.watch]` as a nested table was invalid TOML for this
  field — it's a plain `watch = [...]` array directly under
  `[extensions.build]`.
- The real failure ("doesn't have a build command or it's empty") turned
  out to be a red herring pointing at a stale filename
  (shopify.function.extension.toml, not the current shopify.extension.toml)
  — the actual problem was that `@shopify/shopify_function` was never
  installed for these extensions (confirmed: no node_modules), because
  hand-writing package.json doesn't run the install step
  `shopify app generate extension` does automatically.

Rather than keep guessing at the toolchain, regenerated both Functions for
real:
- `shopify app generate extension --template=cart_checkout_validation` and
  `--template=delivery_customization` (--flavor=vanilla-js), which produces
  a working vite/vitest-based build+test setup, real
  `@shopify/shopify-function-test-helpers` fixture testing (builds actual
  WASM and runs it via function-runner), and a generated GraphQL type file
  per extension.
- This surfaced several concrete corrections to what was hand-written
  before: the real target names are `cart.validations.generate.run` and
  `cart.delivery-options.transform.run` (not `purchase.validation.run` /
  `purchase.delivery-customization.run`), current api_version is 2026-07
  (not 2025-01), the validation output wraps errors in
  `operations: [{ validationAdd: { errors } }]` with a plain `message`
  field (not top-level `errors` with `localizedMessage`), and the rename
  operation is `deliveryOptionRename: { deliveryOptionHandle, title }` (not
  `rename: { deliveryOptionHandle, title }`).
- Rewrote each extension's `.graphql` input query to request our actual
  dd_* cart attributes (plus delivery option handles for the rename case),
  regenerated types via `npm run typegen` in each, and ported the pure
  evaluate.js decision logic (same exported function names/behavior as
  before, now proven correct against the live schema) into the adapter
  file the generator expects.
- Replaced each extension's demo fixture with ones matching our real
  logic; `npm test` inside each extension now compiles real WASM and runs
  function-runner against them — this is strictly stronger verification
  than the previous pure-JS-only unit tests (which are kept too, unchanged,
  since the evaluate.js files kept the same interface).

Repo-wide wiring: extensions/*/generated and extensions/*/dist are not
committed (matches the CLI's own per-extension .gitignore) — added
`npm run typegen:functions` (runs automatically before `npm run typecheck`
via a pretypecheck hook) and `npm run test:functions`, both now also in CI.
Root `npm install` picked these two folders up as proper npm workspace
members (they already have their own package.json from generation).

Verified: lint, typecheck, all 52 unit tests, all 8 integration tests, both
extensions' real WASM/function-runner test suites (5 fixtures total), and
both `npm run build` / `npm run build:widget` all pass.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-23 20:14:21 -04:00

74 lines
2.6 KiB
TOML

# Learn more about configuring your app at https://shopify.dev/docs/apps/tools/cli/configuration
client_id = "890f611da9f31c1a8e3183b5300b2f53"
name = "Metatron-delivery"
application_url = "https://shopify.dev/apps/default-app-home"
embedded = true
[access_scopes]
# Learn more at https://shopify.dev/docs/apps/tools/cli/configuration#access_scopes
scopes = "read_customers,read_locales,read_locations,read_markets,read_metaobjects,read_orders,read_products,write_cart_transforms,write_delivery_customizations,write_metaobjects,write_orders,write_payment_customizations"
[auth]
redirect_urls = [ "https://shopify.dev/apps/default-app-home/api/auth" ]
[webhooks]
api_version = "2026-10"
# Handled by: app/routes/webhooks.app.uninstalled.tsx
[[webhooks.subscriptions]]
uri = "/webhooks/app/uninstalled"
topics = ["app/uninstalled"]
# Handled by: app/routes/webhooks.app.scopes_update.tsx
[[webhooks.subscriptions]]
uri = "/webhooks/app/scopes_update"
topics = ["app/scopes_update"]
# Handled by: app/routes/webhooks.orders.create.tsx
[[webhooks.subscriptions]]
uri = "/webhooks/orders/create"
topics = ["orders/create"]
# Handled by: app/routes/webhooks.orders.updated.tsx
[[webhooks.subscriptions]]
uri = "/webhooks/orders/updated"
topics = ["orders/updated"]
# Handled by: app/routes/webhooks.orders.cancelled.tsx
[[webhooks.subscriptions]]
uri = "/webhooks/orders/cancelled"
topics = ["orders/cancelled"]
# Mandatory GDPR compliance topics — required for Built-for-Shopify / public app review.
# Handled by: app/routes/webhooks.customers.data_request.tsx
[[webhooks.subscriptions]]
uri = "/webhooks/customers/data_request"
compliance_topics = ["customers/data_request"]
# Handled by: app/routes/webhooks.customers.redact.tsx
[[webhooks.subscriptions]]
uri = "/webhooks/customers/redact"
compliance_topics = ["customers/redact"]
# Handled by: app/routes/webhooks.shop.redact.tsx
[[webhooks.subscriptions]]
uri = "/webhooks/shop/redact"
compliance_topics = ["shop/redact"]
# App proxy so the storefront Theme App Extension can call our backend
# without CORS issues (see IMPLEMENTATION_PLAN.md §5.3). `shopify app dev`
# points this at your dev tunnel automatically when
# automatically_update_urls_on_dev is true (see [build] below); if it
# doesn't, set it manually to `<your-tunnel-url>/apps/scheduling` — the
# Remix routes it forwards to (apps.scheduling.*.tsx) assume that exact
# prefix.
[app_proxy]
url = "https://replace-with-your-tunnel-url.example.com/apps/scheduling"
subpath = "scheduling"
prefix = "apps"
[build]
include_config_on_deploy = true
automatically_update_urls_on_dev = true