@snowcone-app/sdk 0.24.3 → 0.24.4
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/CHANGELOG.md +6 -0
- package/README.md +7 -7
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.24.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#4283](https://github.com/snowcone-app/snowcone-monorepo/pull/4283) [`4fbaaf1`](https://github.com/snowcone-app/snowcone-monorepo/commit/4fbaaf161d0c580a1c56790a9a4c54f676a92abc) Thanks [@kevinsproles](https://github.com/kevinsproles)! - Examples and tool descriptions use live demo products: the iPhone 17 Pro Max Case (`BC43BE`), the Canvas Tote (`CAXHQC`) and the All-Over Print Zip Hoodie (`XTNA6J`), in place of the Framed Canvas (`BEEB77`) and Women's Tee (`KMYKUK`), which are no longer for sale. No API change.
|
|
8
|
+
|
|
3
9
|
## 0.24.3
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -27,7 +27,7 @@ import { getProduct, listProducts, getMockupUrl } from '@snowcone-app/sdk';
|
|
|
27
27
|
|
|
28
28
|
// 1. Find a product (public catalog read — no key needed)
|
|
29
29
|
const products = await listProducts({ limit: 10 });
|
|
30
|
-
const product = await getProduct('
|
|
30
|
+
const product = await getProduct('BC43BE'); // by id or slug
|
|
31
31
|
|
|
32
32
|
// 2. Build a mockup URL. A mockup is a PUBLIC image URL — getMockupUrl is a
|
|
33
33
|
// pure, synchronous builder (no await, no fetch, no secret). The result
|
|
@@ -66,7 +66,7 @@ const products = await listProducts(options?: {
|
|
|
66
66
|
**Product Object Structure:**
|
|
67
67
|
```typescript
|
|
68
68
|
{
|
|
69
|
-
id: string; // Product ID (e.g., "
|
|
69
|
+
id: string; // Product ID (e.g., "BC43BE")
|
|
70
70
|
name: string; // Product name
|
|
71
71
|
description?: string; // Product description
|
|
72
72
|
basePrice: number; // Base price in cents
|
|
@@ -126,16 +126,16 @@ type Design = Record<string, Fill>; // placement key → fill
|
|
|
126
126
|
#### Multi-placement + variant options
|
|
127
127
|
|
|
128
128
|
```typescript
|
|
129
|
-
// A front + back
|
|
130
|
-
const url = getMockupUrl('
|
|
129
|
+
// A hoodie's left front + back, size M.
|
|
130
|
+
const url = getMockupUrl('XTNA6J', {
|
|
131
131
|
shop: shop.id,
|
|
132
132
|
options: { size: 'm' },
|
|
133
133
|
design: {
|
|
134
|
-
|
|
134
|
+
front_left: 'https://cdn.example.com/front.png',
|
|
135
135
|
back: { src: 'https://cdn.example.com/back.png', tile: 2, align: 'top' },
|
|
136
136
|
},
|
|
137
137
|
});
|
|
138
|
-
// → …/
|
|
138
|
+
// → …/XTNA6J?shop=…&asset.back=…&tile.back=2&align.back=top&asset.front_left=…&opt.size=m
|
|
139
139
|
|
|
140
140
|
// A cap with a printed front + chosen Crown/Strap colors (color placements).
|
|
141
141
|
const cap = getMockupUrl('RQNU68', {
|
|
@@ -211,7 +211,7 @@ const session = new RenderSession({
|
|
|
211
211
|
grantUrl: '/api/realtime/grant', // your proxy above
|
|
212
212
|
// mockupIds are catalog SCENE CODES (product.mockups[].id) — not placement
|
|
213
213
|
// names. variantId is required for products with a color/size option.
|
|
214
|
-
product: { productId: '
|
|
214
|
+
product: { productId: 'BC43BE', mockupIds: ['947QAD'], variantId: 'e92f40' },
|
|
215
215
|
});
|
|
216
216
|
|
|
217
217
|
session.onMockups((results) => { img.src = results[0].imageUrl; });
|
package/dist/index.d.cts
CHANGED
|
@@ -401,7 +401,7 @@ interface GetMockupUrlOptions {
|
|
|
401
401
|
*
|
|
402
402
|
* // Code-first (preferred): productCode then options.
|
|
403
403
|
* getMockupUrl("hoodie-black", { shop, asset });
|
|
404
|
-
* getMockupUrl("
|
|
404
|
+
* getMockupUrl("XTNA6J", { shop, options: { size: "m" }, design: {…} });
|
|
405
405
|
*
|
|
406
406
|
* // Legacy positional: (assetUrl, productCode, opts).
|
|
407
407
|
* getMockupUrl(assetUrl, "hoodie-black", { shop });
|
|
@@ -419,8 +419,8 @@ declare const DEFAULT_BUY_BASE = "https://buy.snowcone.app";
|
|
|
419
419
|
* where the mockup URL renders the design as an image, this URL opens the
|
|
420
420
|
* Snowcone-hosted checkout with that exact design in the cart.
|
|
421
421
|
*
|
|
422
|
-
* const img = getMockupUrl("
|
|
423
|
-
* const buy = getBuyUrl("
|
|
422
|
+
* const img = getMockupUrl("BC43BE", { shop, asset }); // the picture
|
|
423
|
+
* const buy = getBuyUrl("BC43BE", { shop, asset }); // the purchase
|
|
424
424
|
*
|
|
425
425
|
* Pure + synchronous, like `getMockupUrl` — drop the result into an
|
|
426
426
|
* `<a href>`. Pass `base` to override the host.
|
|
@@ -2876,7 +2876,7 @@ declare function fetchRealtimeGrant(grantUrl: string, shop: string, fetchImpl?:
|
|
|
2876
2876
|
* grantUrl: '/api/realtime/grant', // your proxy → mintRealtimeGrant (server)
|
|
2877
2877
|
* // mockupIds are opaque catalog SCENE CODES (product.mockups[].id) — NOT
|
|
2878
2878
|
* // placement names. variantId is required for products with a color/size axis.
|
|
2879
|
-
* product: { productId: '
|
|
2879
|
+
* product: { productId: 'BC43BE', mockupIds: ['947QAD'], variantId: 'e92f40' },
|
|
2880
2880
|
* });
|
|
2881
2881
|
* session.onMockups((results) => { img.src = results[0].imageUrl; });
|
|
2882
2882
|
* // First arg is the PLACEMENT name (placements[].label, e.g. 'Front') — a
|
|
@@ -2919,11 +2919,11 @@ interface DesignLike {
|
|
|
2919
2919
|
interface RenderProductCombination {
|
|
2920
2920
|
/** The variant (gvid) this combination resolves to. */
|
|
2921
2921
|
variantId?: string;
|
|
2922
|
-
/** Attribute selections (e.g. `{
|
|
2922
|
+
/** Attribute selections (e.g. `{ Size: 'M', color: 'Black' }`). */
|
|
2923
2923
|
[attribute: string]: string | number | undefined;
|
|
2924
2924
|
}
|
|
2925
2925
|
/**
|
|
2926
|
-
* One choice of a variant attribute (e.g. `{ label: '
|
|
2926
|
+
* One choice of a variant attribute (e.g. `{ label: 'Black', hex: '#000000' }`).
|
|
2927
2927
|
* A `hex` value marks the attribute as a COLOR axis — the one kind of variant
|
|
2928
2928
|
* the renderer treats as a required placement (auto-filled from `variantId`).
|
|
2929
2929
|
*/
|
|
@@ -2991,7 +2991,7 @@ interface RenderProduct {
|
|
|
2991
2991
|
productId: string;
|
|
2992
2992
|
/**
|
|
2993
2993
|
* The mockup scenes to render — opaque catalog codes (the product's
|
|
2994
|
-
* `mockups[].id`, e.g. `'
|
|
2994
|
+
* `mockups[].id`, e.g. `'947QAD'`). These are a DIFFERENT namespace from the
|
|
2995
2995
|
* `placement` you pass to {@link RenderSession.renderState} (a print-area name
|
|
2996
2996
|
* like `'Front'`). Don't pass a placement name here.
|
|
2997
2997
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -401,7 +401,7 @@ interface GetMockupUrlOptions {
|
|
|
401
401
|
*
|
|
402
402
|
* // Code-first (preferred): productCode then options.
|
|
403
403
|
* getMockupUrl("hoodie-black", { shop, asset });
|
|
404
|
-
* getMockupUrl("
|
|
404
|
+
* getMockupUrl("XTNA6J", { shop, options: { size: "m" }, design: {…} });
|
|
405
405
|
*
|
|
406
406
|
* // Legacy positional: (assetUrl, productCode, opts).
|
|
407
407
|
* getMockupUrl(assetUrl, "hoodie-black", { shop });
|
|
@@ -419,8 +419,8 @@ declare const DEFAULT_BUY_BASE = "https://buy.snowcone.app";
|
|
|
419
419
|
* where the mockup URL renders the design as an image, this URL opens the
|
|
420
420
|
* Snowcone-hosted checkout with that exact design in the cart.
|
|
421
421
|
*
|
|
422
|
-
* const img = getMockupUrl("
|
|
423
|
-
* const buy = getBuyUrl("
|
|
422
|
+
* const img = getMockupUrl("BC43BE", { shop, asset }); // the picture
|
|
423
|
+
* const buy = getBuyUrl("BC43BE", { shop, asset }); // the purchase
|
|
424
424
|
*
|
|
425
425
|
* Pure + synchronous, like `getMockupUrl` — drop the result into an
|
|
426
426
|
* `<a href>`. Pass `base` to override the host.
|
|
@@ -2876,7 +2876,7 @@ declare function fetchRealtimeGrant(grantUrl: string, shop: string, fetchImpl?:
|
|
|
2876
2876
|
* grantUrl: '/api/realtime/grant', // your proxy → mintRealtimeGrant (server)
|
|
2877
2877
|
* // mockupIds are opaque catalog SCENE CODES (product.mockups[].id) — NOT
|
|
2878
2878
|
* // placement names. variantId is required for products with a color/size axis.
|
|
2879
|
-
* product: { productId: '
|
|
2879
|
+
* product: { productId: 'BC43BE', mockupIds: ['947QAD'], variantId: 'e92f40' },
|
|
2880
2880
|
* });
|
|
2881
2881
|
* session.onMockups((results) => { img.src = results[0].imageUrl; });
|
|
2882
2882
|
* // First arg is the PLACEMENT name (placements[].label, e.g. 'Front') — a
|
|
@@ -2919,11 +2919,11 @@ interface DesignLike {
|
|
|
2919
2919
|
interface RenderProductCombination {
|
|
2920
2920
|
/** The variant (gvid) this combination resolves to. */
|
|
2921
2921
|
variantId?: string;
|
|
2922
|
-
/** Attribute selections (e.g. `{
|
|
2922
|
+
/** Attribute selections (e.g. `{ Size: 'M', color: 'Black' }`). */
|
|
2923
2923
|
[attribute: string]: string | number | undefined;
|
|
2924
2924
|
}
|
|
2925
2925
|
/**
|
|
2926
|
-
* One choice of a variant attribute (e.g. `{ label: '
|
|
2926
|
+
* One choice of a variant attribute (e.g. `{ label: 'Black', hex: '#000000' }`).
|
|
2927
2927
|
* A `hex` value marks the attribute as a COLOR axis — the one kind of variant
|
|
2928
2928
|
* the renderer treats as a required placement (auto-filled from `variantId`).
|
|
2929
2929
|
*/
|
|
@@ -2991,7 +2991,7 @@ interface RenderProduct {
|
|
|
2991
2991
|
productId: string;
|
|
2992
2992
|
/**
|
|
2993
2993
|
* The mockup scenes to render — opaque catalog codes (the product's
|
|
2994
|
-
* `mockups[].id`, e.g. `'
|
|
2994
|
+
* `mockups[].id`, e.g. `'947QAD'`). These are a DIFFERENT namespace from the
|
|
2995
2995
|
* `placement` you pass to {@link RenderSession.renderState} (a print-area name
|
|
2996
2996
|
* like `'Front'`). Don't pass a placement name here.
|
|
2997
2997
|
*/
|