Parsing at the gate: Shopify and Webflow
Shopify and Webflow apps send the same kinds of data (customers, products, content, events) in different shapes. When both share one Cloudflare Worker as the gating endpoint, the Worker does the same five things to every request before anything reaches Xano, BigQuery or Basin:
Shopify Webflow
webhooks · app proxy · Web Pixel webhooks · Data API · site custom code · Designer Extension
│ │
└───────────────┬─────────────────────┘
▼
Cloudflare Worker (one gating endpoint)
1. verify the signature (HMAC), the timestamp, the shop or site
2. parse into a typed Rust struct (compiled to WebAssembly)
3. normalise ISO 3166 codes, UTC timestamps, money as micros, IDs as GIDs
4. decide consent and purpose from the ledger, through the release gate
5. record an idempotency key and a receipt, then forward
│
▼
Xano (system of record) · Basin Pipelines (events) · BigQuery (Google joins)
The rule from Function gating across clouds applies: steps 2 to 4 are one Rust crate, not a parser per app. The ECC side of the book already works this way; Shopify and Webflow are two more inputs to it.
Where each app’s data comes in
| App surface | What arrives | How it’s verified | Parsing notes |
|---|---|---|---|
| Shopify webhooks | JSON for orders, customers, products, refunds; the GDPR topics (customers/data_request, customers/redact, shop/redact) | X-Shopify-Hmac-Sha256 over the raw body | Payloads are REST-shaped: a numeric id plus admin_graphql_api_id (the GID). Keep the GID. Delivery is at least once and can arrive out of order: deduplicate on the webhook ID |
| Shopify app proxy | Storefront requests forwarded from /apps/… to the Worker | A signature query parameter (HMAC over the other parameters) | Shopify strips cookies on the proxy; the shopper arrives as logged_in_customer_id and shop, not as a session cookie |
| Shopify Web Pixel | Standard customer events: page_viewed, product_viewed, product_added_to_cart, checkout_started, checkout_completed | Runs in Shopify’s sandbox; posts to the Worker | Shopify applies its Customer Privacy API before the pixel runs; the gate records the consent the pixel ran under, it doesn’t override it |
| Shopify Functions | Discount, delivery and checkout logic, in WebAssembly | Runs inside Shopify | No network calls. A Function can’t ask the gate; the gate’s decision has to be written beforehand (to a metafield the Function’s input query reads) |
| Shopify Admin GraphQL | Products, variants, markets, translations, on request | App access token | camelCase fields, GIDs, MoneyV2 (amount as a decimal string, currencyCode) |
| Webflow webhooks | Form submissions, CMS item changes, site publish | x-webflow-signature (HMAC) with x-webflow-timestamp; reject stale timestamps | Retries on failure: deduplicate on the item ID and timestamp |
| Webflow Data API | CMS items, locales, assets | Site or app token | fieldData is keyed by each field’s slug; option fields return option IDs, reference fields return item IDs, rich text is HTML, images are {fileId, url, alt}; isDraft, isArchived, lastPublished decide what’s live; each locale is its own item version (cmsLocaleId) |
| Webflow site custom code | One tag in the head that loads the islands and the consent check | Served by the Worker | Webflow has no consent API of its own: the edge banner and the Worker’s session decision are the consent layer |
| Webflow Designer Extension | The designer’s app inside the Designer | Webflow’s extension auth | Reads classes, data-* attributes and components: the same contract Beautiful Soup reads from an export (see What is ABAP?) |
One record from three shapes
The same product, as each source sends it, and as the gate writes it:
| Field | ECC | Shopify | Webflow CMS | After the gate |
|---|---|---|---|---|
| ID | MATNR 000000000000012345 | gid://shopify/Product/9001 (webhook: id: 9001) | Item ID 64f…, slug heated-mat-queen | Product key from the Xano crosswalk, with all three kept |
| Title | MAKT-MAKTX per language key | title, translations per locale | fieldData.name per cmsLocaleId | Text per BCP 47 locale |
| Price | KONP-KBETR 129.00, KONWA USD | MoneyV2 {"amount": "129.0", "currencyCode": "USD"} | A number field, currency implied by the site | {amountMicros: 129000000, currency: "USD"} |
| Updated | DATS + server local time | ISO 8601 UTC | lastUpdated ISO 8601 | UTC with a sequence number |
| Live? | LVORM deletion flag | status ACTIVE / DRAFT / ARCHIVED | isDraft, isArchived | One status enum |
Gaps the shared endpoint has to cover
| Gap | Why | What the gate does |
|---|---|---|
| Shopify Functions can’t call out | No network access inside a Function | Writes the decision ahead of time where the Function reads it; a stale decision expires |
| Out-of-order webhooks | Both platforms retry; an update can arrive after a newer one | Compare the source’s timestamp with the stored one; the newer wins, the older is receipted and dropped |
| Two sources of consent | Shopify’s Customer Privacy API on the storefront, the edge banner on Webflow | One ledger subject per person; both decisions recorded with their source and banner version |
| No cookie on the app proxy | Shopify strips it | Session tied by the signed logged_in_customer_id or a signed token, never a cookie |
| Webflow fields keyed by slug | A designer renaming a field’s slug breaks a parser that hard-codes it | Map slugs in one place (the crosswalk), fail the build or the request loudly on an unknown slug |
| Drafts and locales | Webflow and Shopify both hold unpublished and per-locale versions | Only published, current-locale versions forward; drafts never leave |
| Personal data in events | Form submissions and checkout events can carry names and e-mails | Pseudonymise before Basin; personal data goes to Xano only, under the gate |
The rule: one endpoint, one parser, one ledger. Shopify and Webflow keep their own surfaces; the Worker verifies, parses into the same typed record, and asks the same gate, so a product, a person or a consent decision means the same thing whichever app sent it.
One Rust crate, layered into WebAssembly: ownership, Javy and conditional loading
The gate’s rules live in one Rust crate (src/release_gate.rs: decide(destination, subject, rows) -> Decision). The
same crate can be compiled into each layer that has to apply them, including a Shopify Function, which can’t call the
gate itself. What makes that safe is Rust’s ownership model; what makes it cheap is loading each piece only where and
when it’s needed.
Ownership, in one paragraph
In Rust every value has exactly one owner. Other code can borrow it, either read-only (many at once) or to change it (one at a time), and the compiler checks both rules before the program runs. When the owner goes out of scope the value is freed. There is no garbage collector, so a WebAssembly module built from Rust carries no runtime to manage memory: it is small, starts fast and behaves the same on every run. Two classes of bug that matter when parsing untrusted input, reading freed memory and two writers changing the same data, can’t compile.
The model maps onto the gate. One owner per decision: the Worker owns it, writes it once, and every other layer only borrows a read-only copy. The same rule in the type system is the same rule in the architecture.
The layers
| Layer | Build target | Who loads it, and when | Network | What it does with the decision |
|---|---|---|---|---|
| Cloudflare Worker (the gate’s endpoint) | WebAssembly for Workers, through workers-rs / wasm-bindgen | Bundled at deploy; your code decides per request which routes instantiate it | Yes | Owns it: reads the ledger, calls decide, writes the result |
| Shopify Function (discount, delivery, checkout validation) | WebAssembly (WASI), built by the Shopify CLI | Shopify runs it, only when that function is active for the shop and the cart or checkout reaches it | None | Borrows it: reads the decision the Worker wrote to a metafield, through the Function’s input query |
| Browser island | WebAssembly, wasm-bindgen | The Worker adds its tag to the page only after the session’s consent decision | Through the Worker | Uses it for display only (a price preview, a converter); never decides |
| Native and Python | Native binary; Python extension (PyO3) | Batch jobs, the design pipeline | Yes | Reads it, never writes consent |
Rust or Javy for a Shopify Function
Shopify Functions can be written in Rust or in JavaScript. JavaScript Functions are compiled with Javy, a Bytecode Alliance project started at Shopify, which builds a WebAssembly module that runs your JavaScript inside an embedded JavaScript engine (QuickJS).
| Rust | JavaScript through Javy | |
|---|---|---|
| What’s in the module | Your compiled logic only | Your script plus a JavaScript engine to run it (Javy can link the engine separately to keep the module small) |
| Memory | Ownership, decided at compile time; no garbage collector | The engine’s garbage collector, inside the module |
| Size and speed | Smaller and faster for the same logic | Larger, and more instructions per run |
| Shopify’s limits | Further from Functions’ size, memory and instruction limits | Closer to them as the logic grows |
| Reuse in other layers | The same crate as the Worker and the batch tools | The same JavaScript can run in a Worker directly, but not in the Rust core |
| Best for | Rules shared with the gate; anything heavy (many cart lines, pricing, parsing) | Small, Function-only logic a JavaScript team owns |
Shopify publishes the current Function limits and recommends Rust where performance matters; check them before choosing. For this layer the deciding point is reuse: a Rust Function reads the decision with the same type the Worker wrote it with, so the two can’t drift.
The decision as a shared type
The Worker serialises a decision with an expiry; the Function deserialises it with the same struct and refuses one
that’s stale. A sketch, built on the crate’s existing Decision:
#![allow(unused)]
fn main() {
use serde::{Deserialize, Serialize};
/// Written once by the Worker (the owner) to an app metafield; read-only everywhere else.
#[derive(Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PublishedDecision {
pub destination: String, // e.g. "member_price", "audience"
pub allowed: bool, // release_gate::Decision.allowed
pub reason: String, // release_gate::Decision.reason
pub rule_version: u32, // which version of the rules decided it
pub expires_at: i64, // Unix seconds; after this the decision is not trusted
}
impl PublishedDecision {
/// Borrows `self` read-only: checking a decision never changes it.
pub fn is_current(&self, now: i64) -> bool {
now < self.expires_at
}
}
}
In the Function, a missing, unreadable or expired decision falls back to the safe default for its purpose: deny for anything that grants a member price, a discount tied to consent or an audience; ignore (proceed normally) for anything that is part of fulfilling the order. The time the Function compares against has to come from its input, since a Function has no network and no clock of its own to trust.
Conditional loading, server side
Loading each piece only where it is needed keeps every layer small and keeps decisions where they belong:
- In the Worker, the module is bundled at deploy, but it doesn’t have to run on every request. Instantiate the Rust core only on routes that parse or decide (webhooks, the app proxy, exports), keep it for the isolate’s lifetime, and let static pages skip it.
- For the browser, the Worker decides on the server which island tags to add (HTMLRewriter), after the consent check. A visitor who hasn’t consented never downloads a module they aren’t allowed to run. That’s the same consent-first rule as What is ABAP? → islands, applied to WebAssembly.
- For Shopify Functions, Shopify does the loading: a Function runs only when it is active for the shop and the cart or checkout reaches it. What you control is its input: the input query asks only for the fields and the metafield the decision needs, so the Function reads less and runs fewer instructions.
The rule: one crate, one owner per decision. The Worker owns and writes; Shopify Functions, browser islands and batch tools borrow and read; each layer loads the module only when its route, its consent state or Shopify’s activation needs it.