@financedistrict/saleor-agentic-commerce-nextjs 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +150 -0
- package/package.json +4 -4
package/README.md
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# @financedistrict/saleor-agentic-commerce-nextjs
|
|
2
|
+
|
|
3
|
+
Drop-in Next.js App Router route handlers that expose your [Saleor](https://saleor.io/) storefront to AI shopping agents via [UCP](https://ucp.dev/) and [ACP](https://github.com/agentic-commerce-protocol/agentic-commerce-protocol).
|
|
4
|
+
|
|
5
|
+
One config file, a few one-line route files, and your store is agent-ready. Zero runtime dependencies.
|
|
6
|
+
|
|
7
|
+
Part of the [Saleor Agentic Commerce](https://github.com/financedistrict-platform/saleor-agentic-commerce) SDK.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @financedistrict/saleor-agentic-commerce-core @financedistrict/saleor-agentic-commerce-nextjs
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Peer Dependencies
|
|
16
|
+
|
|
17
|
+
- `@financedistrict/saleor-agentic-commerce-core` ^0.2.0
|
|
18
|
+
- `next` >= 14.0.0
|
|
19
|
+
|
|
20
|
+
## Quick Start
|
|
21
|
+
|
|
22
|
+
### 1. Create the config
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
// src/lib/agentic-commerce.ts
|
|
26
|
+
import { createAgenticCommerce, createUcpRoutes, createAcpRoutes } from "@financedistrict/saleor-agentic-commerce-nextjs"
|
|
27
|
+
|
|
28
|
+
const agenticCommerce = createAgenticCommerce({
|
|
29
|
+
saleorApiUrl: process.env.NEXT_PUBLIC_SALEOR_API_URL!,
|
|
30
|
+
saleorAuthToken: process.env.SALEOR_AGENTIC_AUTH_TOKEN!,
|
|
31
|
+
storefrontUrl: process.env.NEXT_PUBLIC_STOREFRONT_URL!,
|
|
32
|
+
storeName: process.env.SALEOR_AGENTIC_STORE_NAME!,
|
|
33
|
+
channel: process.env.NEXT_PUBLIC_DEFAULT_CHANNEL,
|
|
34
|
+
// paymentHandlers: [new PrismPaymentHandler({ ... })],
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
export const ucpRoutes = createUcpRoutes(agenticCommerce)
|
|
38
|
+
export const acpRoutes = createAcpRoutes(agenticCommerce)
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### 2. Wire up route handlers
|
|
42
|
+
|
|
43
|
+
Each route file is a one-liner:
|
|
44
|
+
|
|
45
|
+
**UCP Routes**
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
src/app/api/ucp/
|
|
49
|
+
├── checkout-sessions/
|
|
50
|
+
│ ├── route.ts → POST (create)
|
|
51
|
+
│ └── [id]/
|
|
52
|
+
│ ├── route.ts → GET (read), PUT (update)
|
|
53
|
+
│ ├── complete/route.ts → POST
|
|
54
|
+
│ └── cancel/route.ts → POST
|
|
55
|
+
└── orders/
|
|
56
|
+
└── [id]/route.ts → GET
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
// src/app/api/ucp/checkout-sessions/route.ts
|
|
61
|
+
import { ucpRoutes } from "@/lib/agentic-commerce"
|
|
62
|
+
export const { POST } = ucpRoutes.checkoutSessions
|
|
63
|
+
|
|
64
|
+
// src/app/api/ucp/checkout-sessions/[id]/route.ts
|
|
65
|
+
import { ucpRoutes } from "@/lib/agentic-commerce"
|
|
66
|
+
export const { GET, PUT } = ucpRoutes.checkoutSession
|
|
67
|
+
|
|
68
|
+
// src/app/api/ucp/checkout-sessions/[id]/complete/route.ts
|
|
69
|
+
import { ucpRoutes } from "@/lib/agentic-commerce"
|
|
70
|
+
export const { POST } = ucpRoutes.checkoutSessionComplete
|
|
71
|
+
|
|
72
|
+
// src/app/api/ucp/checkout-sessions/[id]/cancel/route.ts
|
|
73
|
+
import { ucpRoutes } from "@/lib/agentic-commerce"
|
|
74
|
+
export const { POST } = ucpRoutes.checkoutSessionCancel
|
|
75
|
+
|
|
76
|
+
// src/app/api/ucp/orders/[id]/route.ts
|
|
77
|
+
import { ucpRoutes } from "@/lib/agentic-commerce"
|
|
78
|
+
export const { GET } = ucpRoutes.order
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**ACP Routes**
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
src/app/api/acp/
|
|
85
|
+
└── checkout_sessions/
|
|
86
|
+
├── route.ts → POST (create)
|
|
87
|
+
└── [id]/
|
|
88
|
+
├── route.ts → GET (read), POST (update)
|
|
89
|
+
├── complete/route.ts → POST
|
|
90
|
+
└── cancel/route.ts → POST
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
// src/app/api/acp/checkout_sessions/route.ts
|
|
95
|
+
import { acpRoutes } from "@/lib/agentic-commerce"
|
|
96
|
+
export const { POST } = acpRoutes.checkoutSessions
|
|
97
|
+
|
|
98
|
+
// src/app/api/acp/checkout_sessions/[id]/route.ts
|
|
99
|
+
import { acpRoutes } from "@/lib/agentic-commerce"
|
|
100
|
+
export const { GET, POST } = acpRoutes.checkoutSession
|
|
101
|
+
|
|
102
|
+
// src/app/api/acp/checkout_sessions/[id]/complete/route.ts
|
|
103
|
+
import { acpRoutes } from "@/lib/agentic-commerce"
|
|
104
|
+
export const { POST } = acpRoutes.checkoutSessionComplete
|
|
105
|
+
|
|
106
|
+
// src/app/api/acp/checkout_sessions/[id]/cancel/route.ts
|
|
107
|
+
import { acpRoutes } from "@/lib/agentic-commerce"
|
|
108
|
+
export const { POST } = acpRoutes.checkoutSessionCancel
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### 3. Verify
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
curl http://localhost:3000/.well-known/ucp
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Configuration
|
|
118
|
+
|
|
119
|
+
```ts
|
|
120
|
+
createAgenticCommerce({
|
|
121
|
+
// Required
|
|
122
|
+
saleorApiUrl: string, // Saleor GraphQL endpoint
|
|
123
|
+
saleorAuthToken: string, // App token (MANAGE_CHECKOUTS + MANAGE_ORDERS)
|
|
124
|
+
storefrontUrl: string, // Public storefront URL
|
|
125
|
+
storeName: string, // Store name for discovery profiles
|
|
126
|
+
|
|
127
|
+
// Optional
|
|
128
|
+
channel?: string, // Saleor channel slug (default: "default-channel")
|
|
129
|
+
storeDescription?: string, // Store description for discovery
|
|
130
|
+
ucpVersion?: string, // UCP version (default: "2026-04-08")
|
|
131
|
+
acpVersion?: string, // ACP version (default: "2026-01-30")
|
|
132
|
+
acpApiKey?: string, // API key for ACP Bearer token auth
|
|
133
|
+
paymentHandlers?: PaymentHandlerAdapter[], // Payment handler adapters
|
|
134
|
+
})
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Middleware
|
|
138
|
+
|
|
139
|
+
UCP header parsing utilities for custom route handling:
|
|
140
|
+
|
|
141
|
+
```ts
|
|
142
|
+
import { parseUcpHeaders, validateUcpHeaders } from "@financedistrict/saleor-agentic-commerce-nextjs/middleware/ucp-headers"
|
|
143
|
+
|
|
144
|
+
const headers = parseUcpHeaders(request)
|
|
145
|
+
// { agentProfile, requestId, idempotencyKey, contentDigest }
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## License
|
|
149
|
+
|
|
150
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@financedistrict/saleor-agentic-commerce-nextjs",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Drop-in Next.js route handlers that expose your Saleor storefront to AI shopping agents via UCP and ACP protocols.",
|
|
5
|
-
"author": "Finance District <
|
|
5
|
+
"author": "Finance District <developers@fd.xyz>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "./dist/index.js",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {},
|
|
64
64
|
"peerDependencies": {
|
|
65
|
-
"@financedistrict/saleor-agentic-commerce-core": "
|
|
65
|
+
"@financedistrict/saleor-agentic-commerce-core": "^0.2.0",
|
|
66
66
|
"next": ">=14.0.0"
|
|
67
67
|
},
|
|
68
68
|
"peerDependenciesMeta": {
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"typescript": "^5.3.0",
|
|
75
|
-
"@financedistrict/saleor-agentic-commerce-core": "0.2.
|
|
75
|
+
"@financedistrict/saleor-agentic-commerce-core": "0.2.2"
|
|
76
76
|
},
|
|
77
77
|
"scripts": {
|
|
78
78
|
"build": "tsc",
|