@snowcone-app/sdk 0.9.1 → 0.10.0
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/dist/index.cjs +12 -1
- package/dist/index.d.cts +36 -13
- package/dist/index.d.ts +36 -13
- package/dist/index.js +10 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.10.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#588](https://github.com/snowcone-app/snowcone-monorepo/pull/588) [`e1e9b7e`](https://github.com/snowcone-app/snowcone-monorepo/commit/e1e9b7e716d0d33c763e6a633ee540cd2aa24408) Thanks [@kevinsproles](https://github.com/kevinsproles)! - Add `getBuyUrl` — the hosted-checkout twin of `getMockupUrl` (same options shape, `buy.snowcone.app` host) — and correct the `aspect`/`width` JSDoc: `aspect` is an opt-in center-crop (`2:3`); omitted (or `16:9`) means no crop, so the image keeps the scene's native shape, and `width` snaps down with a default of 1400. `CatalogProduct` from the data-transformation and product-context modules is now the real generated catalog type instead of `any`.
|
|
8
|
+
|
|
3
9
|
## 0.9.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -37,6 +37,7 @@ __export(index_exports, {
|
|
|
37
37
|
ContextSynchronizer: () => ContextSynchronizer,
|
|
38
38
|
DEFAULT_ARTWORK_URL: () => DEFAULT_ARTWORK_URL,
|
|
39
39
|
DEFAULT_ASPECT_RATIO: () => DEFAULT_ASPECT_RATIO,
|
|
40
|
+
DEFAULT_BUY_BASE: () => DEFAULT_BUY_BASE,
|
|
40
41
|
DEFAULT_COLOR: () => DEFAULT_COLOR,
|
|
41
42
|
DEFAULT_GRANT_BASE: () => DEFAULT_GRANT_BASE,
|
|
42
43
|
DEFAULT_MOCKUP_BASE: () => DEFAULT_MOCKUP_BASE,
|
|
@@ -108,6 +109,7 @@ __export(index_exports, {
|
|
|
108
109
|
findVariantForSelection: () => findVariantForSelection,
|
|
109
110
|
formatPrice: () => formatPrice,
|
|
110
111
|
formatValidationErrors: () => formatValidationErrors,
|
|
112
|
+
getBuyUrl: () => getBuyUrl,
|
|
111
113
|
getDefaultVariantId: () => getDefaultVariantId,
|
|
112
114
|
getEffectiveAlignment: () => getEffectiveAlignment,
|
|
113
115
|
getIncompleteSelectionMessage: () => getIncompleteSelectionMessage,
|
|
@@ -982,6 +984,13 @@ function getMockupUrl(a, b, c) {
|
|
|
982
984
|
const signature = hmacSha256Hex(opts.secret, canonicalForSig(url)).slice(0, 16);
|
|
983
985
|
return `${url}&signature=${signature}`;
|
|
984
986
|
}
|
|
987
|
+
var DEFAULT_BUY_BASE = "https://buy.snowcone.app";
|
|
988
|
+
function getBuyUrl(productCode, opts) {
|
|
989
|
+
return getMockupUrl(productCode, {
|
|
990
|
+
...opts,
|
|
991
|
+
base: opts.base ?? DEFAULT_BUY_BASE
|
|
992
|
+
});
|
|
993
|
+
}
|
|
985
994
|
|
|
986
995
|
// src/mockup/bffSigner.ts
|
|
987
996
|
function bffSigner(endpoint = "/api/sign", opts) {
|
|
@@ -3014,7 +3023,7 @@ var ProductLoader = class {
|
|
|
3014
3023
|
const { items } = await this.fetcher.listProducts(options);
|
|
3015
3024
|
const product = items?.[0];
|
|
3016
3025
|
if (product) {
|
|
3017
|
-
const productId = product.id
|
|
3026
|
+
const productId = product.id;
|
|
3018
3027
|
if (productId) {
|
|
3019
3028
|
this.cache.set(productId, product);
|
|
3020
3029
|
}
|
|
@@ -6191,6 +6200,7 @@ function createClient(config) {
|
|
|
6191
6200
|
ContextSynchronizer,
|
|
6192
6201
|
DEFAULT_ARTWORK_URL,
|
|
6193
6202
|
DEFAULT_ASPECT_RATIO,
|
|
6203
|
+
DEFAULT_BUY_BASE,
|
|
6194
6204
|
DEFAULT_COLOR,
|
|
6195
6205
|
DEFAULT_GRANT_BASE,
|
|
6196
6206
|
DEFAULT_MOCKUP_BASE,
|
|
@@ -6262,6 +6272,7 @@ function createClient(config) {
|
|
|
6262
6272
|
findVariantForSelection,
|
|
6263
6273
|
formatPrice,
|
|
6264
6274
|
formatValidationErrors,
|
|
6275
|
+
getBuyUrl,
|
|
6265
6276
|
getDefaultVariantId,
|
|
6266
6277
|
getEffectiveAlignment,
|
|
6267
6278
|
getIncompleteSelectionMessage,
|
package/dist/index.d.cts
CHANGED
|
@@ -3,7 +3,7 @@ import { PublicDesign, PublicFill, PublicOptions } from '@snowcone-app/mockup-ur
|
|
|
3
3
|
import { O as OptionAttribute, a as OptionSelection, C as Combination, F as FrameworkAdapter, b as ComponentProps, c as ComponentDescriptor, d as ComponentState, e as ComponentContext, f as ComponentLifecycleHooks, E as EventHandler, g as FrameworkUtilities, P as PlacementSettings, M as MockupResult, R as RealtimeMockupService } from './websocket-X4tcUm78.cjs';
|
|
4
4
|
export { A as AdapterRegistry, h as ProductComponentContext, i as RealtimeMockupCallbacks, j as RealtimeMockupState, k as RenderResult, W as WebSocketConfig, l as WebSocketMessage, m as adapterRegistry, n as computeDisabledChoices, o as createComponent, p as defineComponent, q as deriveDefaultSelection, r as findBestCombination, s as getPricePreview, t as isOptionAvailable, u as resolveBestCombination } from './websocket-X4tcUm78.cjs';
|
|
5
5
|
|
|
6
|
-
interface CatalogProduct
|
|
6
|
+
interface CatalogProduct {
|
|
7
7
|
id: string;
|
|
8
8
|
name: string;
|
|
9
9
|
slug: string;
|
|
@@ -240,7 +240,12 @@ interface GetMockupUrlOptions {
|
|
|
240
240
|
secret?: string;
|
|
241
241
|
/** Override the public host. Default: `https://img.snowcone.app`. */
|
|
242
242
|
base?: string;
|
|
243
|
-
/**
|
|
243
|
+
/**
|
|
244
|
+
* Render width in px. Snaps DOWN to the nearest allowed size
|
|
245
|
+
* (400 600 800 1000 1200 1400 1600 1800 2000 2500 3000 4000); omitted →
|
|
246
|
+
* 1400. Height follows from the scene shape — see
|
|
247
|
+
* {@link GetMockupUrlOptions.aspect}.
|
|
248
|
+
*/
|
|
244
249
|
width?: number;
|
|
245
250
|
/** Camera view / mockup scene override (`view=<mockupId>`). Emitted as `mockup=`. */
|
|
246
251
|
view?: string;
|
|
@@ -250,7 +255,12 @@ interface GetMockupUrlOptions {
|
|
|
250
255
|
variant?: string;
|
|
251
256
|
/** Specific placement label override (only meaningful with a single `asset`). */
|
|
252
257
|
placement?: string;
|
|
253
|
-
/**
|
|
258
|
+
/**
|
|
259
|
+
* Center-crop of the mockup scene. `"2:3"` crops to portrait. `"16:9"` (or
|
|
260
|
+
* omitting it) applies NO crop: the image keeps the scene's native shape —
|
|
261
|
+
* 16:9 for most products, square for some — so don't assume the output
|
|
262
|
+
* dimensions; measure or crop client-side with `object-fit: cover`.
|
|
263
|
+
*/
|
|
254
264
|
aspect?: "16:9" | "2:3";
|
|
255
265
|
}
|
|
256
266
|
/**
|
|
@@ -271,6 +281,21 @@ interface GetMockupUrlOptions {
|
|
|
271
281
|
*/
|
|
272
282
|
declare function getMockupUrl(productCode: string, opts: GetMockupUrlOptions): string;
|
|
273
283
|
declare function getMockupUrl(assetUrl: string, productCode: string, opts: GetMockupUrlOptions): string;
|
|
284
|
+
/** Default public host for the hosted buy page. */
|
|
285
|
+
declare const DEFAULT_BUY_BASE = "https://buy.snowcone.app";
|
|
286
|
+
/**
|
|
287
|
+
* Build the hosted buy-page URL — the checkout counterpart of
|
|
288
|
+
* {@link getMockupUrl}. Same wire grammar, same options shape, different host:
|
|
289
|
+
* where the mockup URL renders the design as an image, this URL opens the
|
|
290
|
+
* Snowcone-hosted checkout with that exact design in the cart.
|
|
291
|
+
*
|
|
292
|
+
* const img = getMockupUrl("BEEB77", { shop, asset }); // the picture
|
|
293
|
+
* const buy = getBuyUrl("BEEB77", { shop, asset }); // the purchase
|
|
294
|
+
*
|
|
295
|
+
* Pure + synchronous, like `getMockupUrl` — drop the result into an
|
|
296
|
+
* `<a href>`. Pass `base` to override the host.
|
|
297
|
+
*/
|
|
298
|
+
declare function getBuyUrl(productCode: string, opts: GetMockupUrlOptions): string;
|
|
274
299
|
|
|
275
300
|
/**
|
|
276
301
|
* Client-side signer for `<Shop signMockupUrl={…}>` (signed / L3 shops).
|
|
@@ -920,32 +945,31 @@ declare function resolveMockupId(context: any, variantId: string, providedMockup
|
|
|
920
945
|
* Product data transformation utilities
|
|
921
946
|
* Converts catalog product data to component-friendly formats
|
|
922
947
|
*/
|
|
923
|
-
type CatalogProduct$1 = any;
|
|
924
948
|
|
|
925
949
|
/**
|
|
926
950
|
* Transforms product options attributes into the standard OptionAttribute format
|
|
927
951
|
* @param product - The catalog product from the API
|
|
928
952
|
* @returns Normalized option attributes with choice objects
|
|
929
953
|
*/
|
|
930
|
-
declare function toOptionAttributes(product?: CatalogProduct
|
|
954
|
+
declare function toOptionAttributes(product?: CatalogProduct): Record<string, OptionAttribute>;
|
|
931
955
|
/**
|
|
932
956
|
* Extracts combinations from product options
|
|
933
957
|
* @param product - The catalog product from the API
|
|
934
958
|
* @returns Array of valid combinations
|
|
935
959
|
*/
|
|
936
|
-
declare function toCombinations(product?: CatalogProduct
|
|
960
|
+
declare function toCombinations(product?: CatalogProduct): Combination[];
|
|
937
961
|
/**
|
|
938
962
|
* Extracts product ID from various possible locations in the product data
|
|
939
963
|
* @param product - The catalog product from the API
|
|
940
964
|
* @returns The product ID or undefined
|
|
941
965
|
*/
|
|
942
|
-
declare function extractProductId(product?: CatalogProduct
|
|
966
|
+
declare function extractProductId(product?: CatalogProduct): string | undefined;
|
|
943
967
|
/**
|
|
944
968
|
* Gets the default variant ID for a product
|
|
945
969
|
* @param product - The catalog product from the API
|
|
946
970
|
* @returns The default variant ID or 'default' as fallback
|
|
947
971
|
*/
|
|
948
|
-
declare function getDefaultVariantId(product?: CatalogProduct
|
|
972
|
+
declare function getDefaultVariantId(product?: CatalogProduct): string;
|
|
949
973
|
|
|
950
974
|
/**
|
|
951
975
|
* Product selection validation utilities
|
|
@@ -1433,7 +1457,6 @@ declare function createEventManager(element?: HTMLElement): ComponentEventManage
|
|
|
1433
1457
|
* Framework-agnostic product state and context handling
|
|
1434
1458
|
*/
|
|
1435
1459
|
|
|
1436
|
-
type CatalogProduct = any;
|
|
1437
1460
|
/**
|
|
1438
1461
|
* Product context interface
|
|
1439
1462
|
*/
|
|
@@ -3062,7 +3085,7 @@ interface ProductMockupData {
|
|
|
3062
3085
|
}
|
|
3063
3086
|
|
|
3064
3087
|
interface CatalogListResponse {
|
|
3065
|
-
items: CatalogProduct
|
|
3088
|
+
items: CatalogProduct[];
|
|
3066
3089
|
total: number;
|
|
3067
3090
|
}
|
|
3068
3091
|
|
|
@@ -3081,15 +3104,15 @@ interface SdkConfig {
|
|
|
3081
3104
|
interface SnowconeClient {
|
|
3082
3105
|
catalog: {
|
|
3083
3106
|
listProducts(config?: Partial<SdkConfig>): Promise<CatalogListResponse>;
|
|
3084
|
-
getProduct(idOrSlug: string, config?: Partial<SdkConfig>): Promise<CatalogProduct
|
|
3107
|
+
getProduct(idOrSlug: string, config?: Partial<SdkConfig>): Promise<CatalogProduct>;
|
|
3085
3108
|
};
|
|
3086
3109
|
mockup: MockupService;
|
|
3087
3110
|
}
|
|
3088
3111
|
declare function listProducts(config?: Partial<SdkConfig>): Promise<CatalogListResponse>;
|
|
3089
|
-
declare function getProduct(idOrSlug: string, config?: Partial<SdkConfig>): Promise<CatalogProduct
|
|
3112
|
+
declare function getProduct(idOrSlug: string, config?: Partial<SdkConfig>): Promise<CatalogProduct>;
|
|
3090
3113
|
/**
|
|
3091
3114
|
* Create a unified Snowcone client with catalog and mockup services
|
|
3092
3115
|
*/
|
|
3093
3116
|
declare function createClient(config: SdkConfig): SnowconeClient;
|
|
3094
3117
|
|
|
3095
|
-
export { AbstractTemplateRenderer, type AddToCartOptions, Animations, type ArtSelectorContext, type ArtSelectorDescriptor, type ArtSelectorOptions, type ArtworkData, type AspectRatio, Attributes, type BaseDescriptor, type BlendConfig, type BuildMockupUrlConfig, type CartDetail, type CatalogListResponse, type CatalogProduct
|
|
3118
|
+
export { AbstractTemplateRenderer, type AddToCartOptions, Animations, type ArtSelectorContext, type ArtSelectorDescriptor, type ArtSelectorOptions, type ArtworkData, type AspectRatio, Attributes, type BaseDescriptor, type BlendConfig, type BuildMockupUrlConfig, type CartDetail, type CatalogListResponse, type CatalogProduct, ClassNames, type ColorDesignElement, ColorPickerUtils, Combination, CommonProps, ComponentContext, type ComponentDefinition, ComponentDescriptor, ComponentEventManager, ComponentFactory, ComponentLifecycle, ComponentLifecycleHooks, type ComponentMetadata, ComponentProps, ComponentRegistry, ComponentState, type ComponentTemplate, ComponentTemplates, type ContainerDescriptor, ContextBridge, type ContextComparator, type ContextConsumer, ContextInjector, type ContextProviderConfig, type ContextSubscriber, ContextSynchronizer, type CreateDesignStateInput, type CreatedDesignState, DEFAULT_ARTWORK_URL, DEFAULT_ASPECT_RATIO, DEFAULT_BUY_BASE, DEFAULT_COLOR, DEFAULT_GRANT_BASE, DEFAULT_MOCKUP_BASE, DEFAULT_PLACEMENT_DIMENSIONS, type Descriptor, type Design, type DesignElement, type DesignGenerationContext, type DesignLike, type Effects, Elements, type ErrorContext, type ErrorHandler, ErrorManager, type EventDefinition, EventDelegator, EventEmitter, EventHandler, type EventListener, type EventPayload, type Fill, Focus, FrameworkAdapter, FrameworkUtilities, type GetMockupUrlOptions, type ImageAlignment, type ImageDesignElement, type LifecycleHook, LifecycleManager, type LifecyclePhase, type LifecycleTransition, LitAdapter, type MaskOverride, type MockupGenerationOptions, MockupResult, type MockupService, type MockupServiceConfig, OptionAttribute, type OptionChoice, type OptionChoiceRenderData, type OptionRenderData, OptionSelection, type Placement, type PlacementDesign, PlacementSettings, type ProductArtAlignmentContext, type ProductArtAlignmentDescriptor, type ProductArtAlignmentOptions, type ProductContext, type ProductContextEvents, ProductContextManager, type ProductData, type ProductFetcher, type ProductImageDescriptor, type ProductImageOptions, ProductLoader, type ProductMockupData, type ProductOptionChoice, type ProductOptionData, type ProductOptionsDescriptor, type ProductOptionsOptions, type ProductPlacement, type ProductPriceDescriptor, type ProductPriceOptions, ProductProps, type ProductSpec, type ProductTitleDescriptor, type ProductTitleOptions, type ProductVariant, type PropDefinition, type PropSchema, type PropType, PropertyManager, REALTIME_WS_URL, type RateLimitState, type RealtimeGrant, RealtimeMockupService, type RegularArtwork, type RenderProduct, type RenderProductAttribute, type RenderProductAttributeChoice, type RenderProductCombination, type RenderProductMockup, type RenderProductOptions, type RenderProductRequiredPlacement, RenderSession, type RenderSessionOptions, type RenderState, type SdkConfig, type SeamlessPattern, type SignedUrlResponse, type SnowconeClient, StandardComponents, StandardEvents, StateManager, type StateManagerOptions, type StateMiddleware, type StateSelector, type StateSubscriber, type StateUpdater, Styles, SvelteAdapter, SwatchUtils, type TagName, TemplateBuilder, type TemplateNode, type TemplateNodeType, type TemplateRenderer, type TextDescriptor, type TileCount, UniversalContextProvider, type UserSelection, type ValidationError, type ValidationResult, VueAdapter, assertVariantSelected, autoRegister, bffSigner, buildMockupUrl, componentRegistry, createAddToCartEvent, createAddToCartHandler, createCartDetail, createClient, createContextProvider, createDesignForPlacements, createDesignState, createErrorHandler, createEventManager, createLifecycle, createLitComponent, createProductContext, createProductLoader, createPropertyManager, createStateHook, createStateStore, createSvelteComponent, createUniversalProvider, createVueComponent, describeArtSelector, describeProductArtAlignment, describeProductImage, describeProductOptions, describeProductPrice, describeProductTitle, extractProductId, fetchRealtimeGrant, filterImagePlacements, findClosestSnapPoint, findVariantForSelection, formatPrice, formatValidationErrors, getBuyUrl, getDefaultVariantId, getEffectiveAlignment, getIncompleteSelectionMessage, getMissingSelections, getMockupUrl, getOptionRenderType, getProduct, getSelectionDisplayText, getSnapPoints, getVariant, handleOptionChange, isSelectionComplete, isValidAlignment, isValidTileCount, listProducts, mintRealtimeGrant, mockupUrl, normalizeChoice, prepareOptionRenderData, registerStandardComponents, resolveMockupId, resolveVariantId, retryOperation, simulateCartOperation, toCombinations, toOptionAttributes, useFrameworkAdapter as useVueAdapter, validateAlignment, validateDesignElement, validateEffects, validateImageUrl, validateMockupOptions, validateProductSelection, validateProductSpec, validateRequiredOptions, validateTileCount, warnVariantNotSelected, withContext, withErrorHandling, withSyncErrorHandling };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { PublicDesign, PublicFill, PublicOptions } from '@snowcone-app/mockup-ur
|
|
|
3
3
|
import { O as OptionAttribute, a as OptionSelection, C as Combination, F as FrameworkAdapter, b as ComponentProps, c as ComponentDescriptor, d as ComponentState, e as ComponentContext, f as ComponentLifecycleHooks, E as EventHandler, g as FrameworkUtilities, P as PlacementSettings, M as MockupResult, R as RealtimeMockupService } from './websocket-X4tcUm78.js';
|
|
4
4
|
export { A as AdapterRegistry, h as ProductComponentContext, i as RealtimeMockupCallbacks, j as RealtimeMockupState, k as RenderResult, W as WebSocketConfig, l as WebSocketMessage, m as adapterRegistry, n as computeDisabledChoices, o as createComponent, p as defineComponent, q as deriveDefaultSelection, r as findBestCombination, s as getPricePreview, t as isOptionAvailable, u as resolveBestCombination } from './websocket-X4tcUm78.js';
|
|
5
5
|
|
|
6
|
-
interface CatalogProduct
|
|
6
|
+
interface CatalogProduct {
|
|
7
7
|
id: string;
|
|
8
8
|
name: string;
|
|
9
9
|
slug: string;
|
|
@@ -240,7 +240,12 @@ interface GetMockupUrlOptions {
|
|
|
240
240
|
secret?: string;
|
|
241
241
|
/** Override the public host. Default: `https://img.snowcone.app`. */
|
|
242
242
|
base?: string;
|
|
243
|
-
/**
|
|
243
|
+
/**
|
|
244
|
+
* Render width in px. Snaps DOWN to the nearest allowed size
|
|
245
|
+
* (400 600 800 1000 1200 1400 1600 1800 2000 2500 3000 4000); omitted →
|
|
246
|
+
* 1400. Height follows from the scene shape — see
|
|
247
|
+
* {@link GetMockupUrlOptions.aspect}.
|
|
248
|
+
*/
|
|
244
249
|
width?: number;
|
|
245
250
|
/** Camera view / mockup scene override (`view=<mockupId>`). Emitted as `mockup=`. */
|
|
246
251
|
view?: string;
|
|
@@ -250,7 +255,12 @@ interface GetMockupUrlOptions {
|
|
|
250
255
|
variant?: string;
|
|
251
256
|
/** Specific placement label override (only meaningful with a single `asset`). */
|
|
252
257
|
placement?: string;
|
|
253
|
-
/**
|
|
258
|
+
/**
|
|
259
|
+
* Center-crop of the mockup scene. `"2:3"` crops to portrait. `"16:9"` (or
|
|
260
|
+
* omitting it) applies NO crop: the image keeps the scene's native shape —
|
|
261
|
+
* 16:9 for most products, square for some — so don't assume the output
|
|
262
|
+
* dimensions; measure or crop client-side with `object-fit: cover`.
|
|
263
|
+
*/
|
|
254
264
|
aspect?: "16:9" | "2:3";
|
|
255
265
|
}
|
|
256
266
|
/**
|
|
@@ -271,6 +281,21 @@ interface GetMockupUrlOptions {
|
|
|
271
281
|
*/
|
|
272
282
|
declare function getMockupUrl(productCode: string, opts: GetMockupUrlOptions): string;
|
|
273
283
|
declare function getMockupUrl(assetUrl: string, productCode: string, opts: GetMockupUrlOptions): string;
|
|
284
|
+
/** Default public host for the hosted buy page. */
|
|
285
|
+
declare const DEFAULT_BUY_BASE = "https://buy.snowcone.app";
|
|
286
|
+
/**
|
|
287
|
+
* Build the hosted buy-page URL — the checkout counterpart of
|
|
288
|
+
* {@link getMockupUrl}. Same wire grammar, same options shape, different host:
|
|
289
|
+
* where the mockup URL renders the design as an image, this URL opens the
|
|
290
|
+
* Snowcone-hosted checkout with that exact design in the cart.
|
|
291
|
+
*
|
|
292
|
+
* const img = getMockupUrl("BEEB77", { shop, asset }); // the picture
|
|
293
|
+
* const buy = getBuyUrl("BEEB77", { shop, asset }); // the purchase
|
|
294
|
+
*
|
|
295
|
+
* Pure + synchronous, like `getMockupUrl` — drop the result into an
|
|
296
|
+
* `<a href>`. Pass `base` to override the host.
|
|
297
|
+
*/
|
|
298
|
+
declare function getBuyUrl(productCode: string, opts: GetMockupUrlOptions): string;
|
|
274
299
|
|
|
275
300
|
/**
|
|
276
301
|
* Client-side signer for `<Shop signMockupUrl={…}>` (signed / L3 shops).
|
|
@@ -920,32 +945,31 @@ declare function resolveMockupId(context: any, variantId: string, providedMockup
|
|
|
920
945
|
* Product data transformation utilities
|
|
921
946
|
* Converts catalog product data to component-friendly formats
|
|
922
947
|
*/
|
|
923
|
-
type CatalogProduct$1 = any;
|
|
924
948
|
|
|
925
949
|
/**
|
|
926
950
|
* Transforms product options attributes into the standard OptionAttribute format
|
|
927
951
|
* @param product - The catalog product from the API
|
|
928
952
|
* @returns Normalized option attributes with choice objects
|
|
929
953
|
*/
|
|
930
|
-
declare function toOptionAttributes(product?: CatalogProduct
|
|
954
|
+
declare function toOptionAttributes(product?: CatalogProduct): Record<string, OptionAttribute>;
|
|
931
955
|
/**
|
|
932
956
|
* Extracts combinations from product options
|
|
933
957
|
* @param product - The catalog product from the API
|
|
934
958
|
* @returns Array of valid combinations
|
|
935
959
|
*/
|
|
936
|
-
declare function toCombinations(product?: CatalogProduct
|
|
960
|
+
declare function toCombinations(product?: CatalogProduct): Combination[];
|
|
937
961
|
/**
|
|
938
962
|
* Extracts product ID from various possible locations in the product data
|
|
939
963
|
* @param product - The catalog product from the API
|
|
940
964
|
* @returns The product ID or undefined
|
|
941
965
|
*/
|
|
942
|
-
declare function extractProductId(product?: CatalogProduct
|
|
966
|
+
declare function extractProductId(product?: CatalogProduct): string | undefined;
|
|
943
967
|
/**
|
|
944
968
|
* Gets the default variant ID for a product
|
|
945
969
|
* @param product - The catalog product from the API
|
|
946
970
|
* @returns The default variant ID or 'default' as fallback
|
|
947
971
|
*/
|
|
948
|
-
declare function getDefaultVariantId(product?: CatalogProduct
|
|
972
|
+
declare function getDefaultVariantId(product?: CatalogProduct): string;
|
|
949
973
|
|
|
950
974
|
/**
|
|
951
975
|
* Product selection validation utilities
|
|
@@ -1433,7 +1457,6 @@ declare function createEventManager(element?: HTMLElement): ComponentEventManage
|
|
|
1433
1457
|
* Framework-agnostic product state and context handling
|
|
1434
1458
|
*/
|
|
1435
1459
|
|
|
1436
|
-
type CatalogProduct = any;
|
|
1437
1460
|
/**
|
|
1438
1461
|
* Product context interface
|
|
1439
1462
|
*/
|
|
@@ -3062,7 +3085,7 @@ interface ProductMockupData {
|
|
|
3062
3085
|
}
|
|
3063
3086
|
|
|
3064
3087
|
interface CatalogListResponse {
|
|
3065
|
-
items: CatalogProduct
|
|
3088
|
+
items: CatalogProduct[];
|
|
3066
3089
|
total: number;
|
|
3067
3090
|
}
|
|
3068
3091
|
|
|
@@ -3081,15 +3104,15 @@ interface SdkConfig {
|
|
|
3081
3104
|
interface SnowconeClient {
|
|
3082
3105
|
catalog: {
|
|
3083
3106
|
listProducts(config?: Partial<SdkConfig>): Promise<CatalogListResponse>;
|
|
3084
|
-
getProduct(idOrSlug: string, config?: Partial<SdkConfig>): Promise<CatalogProduct
|
|
3107
|
+
getProduct(idOrSlug: string, config?: Partial<SdkConfig>): Promise<CatalogProduct>;
|
|
3085
3108
|
};
|
|
3086
3109
|
mockup: MockupService;
|
|
3087
3110
|
}
|
|
3088
3111
|
declare function listProducts(config?: Partial<SdkConfig>): Promise<CatalogListResponse>;
|
|
3089
|
-
declare function getProduct(idOrSlug: string, config?: Partial<SdkConfig>): Promise<CatalogProduct
|
|
3112
|
+
declare function getProduct(idOrSlug: string, config?: Partial<SdkConfig>): Promise<CatalogProduct>;
|
|
3090
3113
|
/**
|
|
3091
3114
|
* Create a unified Snowcone client with catalog and mockup services
|
|
3092
3115
|
*/
|
|
3093
3116
|
declare function createClient(config: SdkConfig): SnowconeClient;
|
|
3094
3117
|
|
|
3095
|
-
export { AbstractTemplateRenderer, type AddToCartOptions, Animations, type ArtSelectorContext, type ArtSelectorDescriptor, type ArtSelectorOptions, type ArtworkData, type AspectRatio, Attributes, type BaseDescriptor, type BlendConfig, type BuildMockupUrlConfig, type CartDetail, type CatalogListResponse, type CatalogProduct
|
|
3118
|
+
export { AbstractTemplateRenderer, type AddToCartOptions, Animations, type ArtSelectorContext, type ArtSelectorDescriptor, type ArtSelectorOptions, type ArtworkData, type AspectRatio, Attributes, type BaseDescriptor, type BlendConfig, type BuildMockupUrlConfig, type CartDetail, type CatalogListResponse, type CatalogProduct, ClassNames, type ColorDesignElement, ColorPickerUtils, Combination, CommonProps, ComponentContext, type ComponentDefinition, ComponentDescriptor, ComponentEventManager, ComponentFactory, ComponentLifecycle, ComponentLifecycleHooks, type ComponentMetadata, ComponentProps, ComponentRegistry, ComponentState, type ComponentTemplate, ComponentTemplates, type ContainerDescriptor, ContextBridge, type ContextComparator, type ContextConsumer, ContextInjector, type ContextProviderConfig, type ContextSubscriber, ContextSynchronizer, type CreateDesignStateInput, type CreatedDesignState, DEFAULT_ARTWORK_URL, DEFAULT_ASPECT_RATIO, DEFAULT_BUY_BASE, DEFAULT_COLOR, DEFAULT_GRANT_BASE, DEFAULT_MOCKUP_BASE, DEFAULT_PLACEMENT_DIMENSIONS, type Descriptor, type Design, type DesignElement, type DesignGenerationContext, type DesignLike, type Effects, Elements, type ErrorContext, type ErrorHandler, ErrorManager, type EventDefinition, EventDelegator, EventEmitter, EventHandler, type EventListener, type EventPayload, type Fill, Focus, FrameworkAdapter, FrameworkUtilities, type GetMockupUrlOptions, type ImageAlignment, type ImageDesignElement, type LifecycleHook, LifecycleManager, type LifecyclePhase, type LifecycleTransition, LitAdapter, type MaskOverride, type MockupGenerationOptions, MockupResult, type MockupService, type MockupServiceConfig, OptionAttribute, type OptionChoice, type OptionChoiceRenderData, type OptionRenderData, OptionSelection, type Placement, type PlacementDesign, PlacementSettings, type ProductArtAlignmentContext, type ProductArtAlignmentDescriptor, type ProductArtAlignmentOptions, type ProductContext, type ProductContextEvents, ProductContextManager, type ProductData, type ProductFetcher, type ProductImageDescriptor, type ProductImageOptions, ProductLoader, type ProductMockupData, type ProductOptionChoice, type ProductOptionData, type ProductOptionsDescriptor, type ProductOptionsOptions, type ProductPlacement, type ProductPriceDescriptor, type ProductPriceOptions, ProductProps, type ProductSpec, type ProductTitleDescriptor, type ProductTitleOptions, type ProductVariant, type PropDefinition, type PropSchema, type PropType, PropertyManager, REALTIME_WS_URL, type RateLimitState, type RealtimeGrant, RealtimeMockupService, type RegularArtwork, type RenderProduct, type RenderProductAttribute, type RenderProductAttributeChoice, type RenderProductCombination, type RenderProductMockup, type RenderProductOptions, type RenderProductRequiredPlacement, RenderSession, type RenderSessionOptions, type RenderState, type SdkConfig, type SeamlessPattern, type SignedUrlResponse, type SnowconeClient, StandardComponents, StandardEvents, StateManager, type StateManagerOptions, type StateMiddleware, type StateSelector, type StateSubscriber, type StateUpdater, Styles, SvelteAdapter, SwatchUtils, type TagName, TemplateBuilder, type TemplateNode, type TemplateNodeType, type TemplateRenderer, type TextDescriptor, type TileCount, UniversalContextProvider, type UserSelection, type ValidationError, type ValidationResult, VueAdapter, assertVariantSelected, autoRegister, bffSigner, buildMockupUrl, componentRegistry, createAddToCartEvent, createAddToCartHandler, createCartDetail, createClient, createContextProvider, createDesignForPlacements, createDesignState, createErrorHandler, createEventManager, createLifecycle, createLitComponent, createProductContext, createProductLoader, createPropertyManager, createStateHook, createStateStore, createSvelteComponent, createUniversalProvider, createVueComponent, describeArtSelector, describeProductArtAlignment, describeProductImage, describeProductOptions, describeProductPrice, describeProductTitle, extractProductId, fetchRealtimeGrant, filterImagePlacements, findClosestSnapPoint, findVariantForSelection, formatPrice, formatValidationErrors, getBuyUrl, getDefaultVariantId, getEffectiveAlignment, getIncompleteSelectionMessage, getMissingSelections, getMockupUrl, getOptionRenderType, getProduct, getSelectionDisplayText, getSnapPoints, getVariant, handleOptionChange, isSelectionComplete, isValidAlignment, isValidTileCount, listProducts, mintRealtimeGrant, mockupUrl, normalizeChoice, prepareOptionRenderData, registerStandardComponents, resolveMockupId, resolveVariantId, retryOperation, simulateCartOperation, toCombinations, toOptionAttributes, useFrameworkAdapter as useVueAdapter, validateAlignment, validateDesignElement, validateEffects, validateImageUrl, validateMockupOptions, validateProductSelection, validateProductSpec, validateRequiredOptions, validateTileCount, warnVariantNotSelected, withContext, withErrorHandling, withSyncErrorHandling };
|
package/dist/index.js
CHANGED
|
@@ -618,6 +618,13 @@ function getMockupUrl(a, b, c) {
|
|
|
618
618
|
const signature = hmacSha256Hex(opts.secret, canonicalForSig(url)).slice(0, 16);
|
|
619
619
|
return `${url}&signature=${signature}`;
|
|
620
620
|
}
|
|
621
|
+
var DEFAULT_BUY_BASE = "https://buy.snowcone.app";
|
|
622
|
+
function getBuyUrl(productCode, opts) {
|
|
623
|
+
return getMockupUrl(productCode, {
|
|
624
|
+
...opts,
|
|
625
|
+
base: opts.base ?? DEFAULT_BUY_BASE
|
|
626
|
+
});
|
|
627
|
+
}
|
|
621
628
|
|
|
622
629
|
// src/mockup/bffSigner.ts
|
|
623
630
|
function bffSigner(endpoint = "/api/sign", opts) {
|
|
@@ -2650,7 +2657,7 @@ var ProductLoader = class {
|
|
|
2650
2657
|
const { items } = await this.fetcher.listProducts(options);
|
|
2651
2658
|
const product = items?.[0];
|
|
2652
2659
|
if (product) {
|
|
2653
|
-
const productId = product.id
|
|
2660
|
+
const productId = product.id;
|
|
2654
2661
|
if (productId) {
|
|
2655
2662
|
this.cache.set(productId, product);
|
|
2656
2663
|
}
|
|
@@ -5064,6 +5071,7 @@ export {
|
|
|
5064
5071
|
ContextSynchronizer,
|
|
5065
5072
|
DEFAULT_ARTWORK_URL,
|
|
5066
5073
|
DEFAULT_ASPECT_RATIO,
|
|
5074
|
+
DEFAULT_BUY_BASE,
|
|
5067
5075
|
DEFAULT_COLOR,
|
|
5068
5076
|
DEFAULT_GRANT_BASE,
|
|
5069
5077
|
DEFAULT_MOCKUP_BASE,
|
|
@@ -5135,6 +5143,7 @@ export {
|
|
|
5135
5143
|
findVariantForSelection,
|
|
5136
5144
|
formatPrice,
|
|
5137
5145
|
formatValidationErrors,
|
|
5146
|
+
getBuyUrl,
|
|
5138
5147
|
getDefaultVariantId,
|
|
5139
5148
|
getEffectiveAlignment,
|
|
5140
5149
|
getIncompleteSelectionMessage,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@snowcone-app/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Snowcone SDK for product mockups and print-on-demand",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"merch",
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"tsup": "^8.1.0",
|
|
86
86
|
"typescript": "^5.5.4",
|
|
87
87
|
"vitest": "^2.0.5",
|
|
88
|
-
"@snowcone-app/mockup-url": "0.1.
|
|
88
|
+
"@snowcone-app/mockup-url": "0.1.1"
|
|
89
89
|
},
|
|
90
90
|
"engines": {
|
|
91
91
|
"node": ">=18"
|