@xpaysh/template-adapter
v0.1.0
Published
Reference PlatformAdapter implementation for an imaginary 'demo' eCommerce platform. Copy this directory to bootstrap a new agentic-commerce-for-<platform> plugin — every method is wired to a deterministic in-memory catalog so the sample boots and serves
Maintainers
Readme
@xpaysh/template-adapter
A working reference PlatformAdapter implementation, backed by a deterministic in-memory catalog.
Purpose: copy this directory when bootstrapping a new agentic-commerce-for-<platform> plugin. Every method in the contract is implemented; you swap the in-memory store for your platform's native client (Shopify, Magento, Saleor, …) and the protocol routes work end-to-end.
What's covered
| Method | Reference impl |
|---|---|
| listProducts(query) | Returns paginated DEMO_PRODUCTS. Honors query.search (case-insensitive title match), limit, offset. |
| getProduct(id) | Returns the demo product or null. |
| createCart(input) | Allocates an in-memory cart from input.lines; throws on unknown productId. |
| updateCart(id, mutation) | Applies add/remove/set_quantity operations; recomputes subtotal. |
| completeCheckout(input) | Finalises the cart → order; deletes the source cart. Emits a fake paymentReference. |
| getOrder(id) | Returns the demo order or null. |
State is per-instance — createTemplateAdapter() returns a fresh adapter; the exported templateAdapter is a process-wide singleton convenient for ad-hoc usage outside tests.
Use
const { createTemplateAdapter } = require('@xpaysh/template-adapter');
const adapter = createTemplateAdapter();
const products = await adapter.listProducts({ limit: 10 });
const cart = await adapter.createCart({
lines: [{ productId: 'demo-shirt-blue', variantId: 'demo-shirt-blue-m', quantity: 2 }],
});
const order = await adapter.completeCheckout({
cartId: cart.id,
buyer: { email: '[email protected]' },
});Pattern for contributing a new platform
- Fork
xpaysh/agentic-commerce-plugin-template. - Copy
packages/template-adaptertoagentic-commerce-for-<your-platform>/src/adapter.ts(rename the export). - Replace the in-memory
Maps with the platform's native client (axios, GraphQL, SDK). - Implement the same six methods. The
Cart/Product/Ordershapes are documented in@xpaysh/adapter-contract. - Reuse the route tables:
@xpaysh/discoveryfor/llms.txt+ JSON-LD +robots.txt;@xpaysh/ucp-schemasgenerateUcpProfile()for/.well-known/ucp;@xpaysh/cart-deeplinksfor HS256 cart-handoff URLs;@xpaysh/http-message-signaturesverifyRequest()for RFC 9421 sig verification on/ucp/*+/acp/*routes. - Wire conformance:
tests/conformance.test.tsloads fixtures from@xpaysh/conformance-fixturesand validates against the canonical schemas. Copy from any sibling plugin (e.g.agentic-commerce-for-commercetools). - Submit to
xpaysh/awesome-agentic-commerce— see itsBOUNTIES.mdfor reward amounts on accepted community plugins.
License
Apache-2.0.
