Working tree is now the canonical repo. Off-chain play-money + trustless on-chain (FPMM AMM + CLOB via UMA settlement), AI market factory, creator/social/distribution, mobile shell + push, one-command demo + deploy-kit. Secrets excluded (see ENV-AND-KEYS.md). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
64 lines
1.8 KiB
TypeScript
64 lines
1.8 KiB
TypeScript
// Quick script to fetch Printful sync variant IDs
|
|
// Run with: npx ts-node backend/scripts/get-printful-variants.ts
|
|
|
|
import { runScript } from './run-script'
|
|
import { PRINTFUL_API_URL } from 'common/shop/items'
|
|
|
|
runScript(async () => {
|
|
const token = process.env.PRINTFUL_API_TOKEN
|
|
|
|
if (!token) {
|
|
console.error('PRINTFUL_API_TOKEN not found in secrets')
|
|
return
|
|
}
|
|
|
|
console.log('Fetching Printful store products...\n')
|
|
|
|
// Get all products
|
|
const productsRes = await fetch(`${PRINTFUL_API_URL}/store/products`, {
|
|
headers: { Authorization: `Bearer ${token}` },
|
|
})
|
|
|
|
if (!productsRes.ok) {
|
|
console.error('Failed to fetch products:', await productsRes.text())
|
|
return
|
|
}
|
|
|
|
const productsData = await productsRes.json()
|
|
const products = productsData.result
|
|
|
|
console.log(`Found ${products.length} product(s):\n`)
|
|
|
|
// For each product, get its variants
|
|
for (const product of products) {
|
|
console.log(`\n========================================`)
|
|
console.log(`Product: ${product.name}`)
|
|
console.log(`Product ID: ${product.id}`)
|
|
console.log(`----------------------------------------`)
|
|
|
|
// Get product details with variants
|
|
const detailRes = await fetch(
|
|
`${PRINTFUL_API_URL}/store/products/${product.id}`,
|
|
{ headers: { Authorization: `Bearer ${token}` } }
|
|
)
|
|
|
|
if (!detailRes.ok) {
|
|
console.error(` Failed to fetch details: ${await detailRes.text()}`)
|
|
continue
|
|
}
|
|
|
|
const detailData = await detailRes.json()
|
|
const variants = detailData.result.sync_variants
|
|
|
|
console.log(`\nVariants (use these IDs in items.ts):\n`)
|
|
console.log(`variants: [`)
|
|
for (const variant of variants) {
|
|
const size = variant.name.split(' - ').pop() || variant.name
|
|
console.log(
|
|
` { size: '${size}', printfulSyncVariantId: '${variant.id}' },`
|
|
)
|
|
}
|
|
console.log(`]`)
|
|
}
|
|
})
|