@snowcone-app/sdk 0.12.1 → 0.14.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 +16 -0
- package/dist/index.cjs +33 -1
- package/dist/index.d.cts +58 -1
- package/dist/index.d.ts +58 -1
- package/dist/index.js +32 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.14.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#646](https://github.com/snowcone-app/snowcone-monorepo/pull/646) [`e2c6f42`](https://github.com/snowcone-app/snowcone-monorepo/commit/e2c6f424c74eaf60402ce55bac7b081fe5e0ed18) Thanks [@kevinsproles](https://github.com/kevinsproles)! - Designs catalog now indexes every published marketplace design, not just first-party-curated picks. The design doc's `firstParty: true` field is replaced by a `curated: boolean` filterable facet (`curated = true` selects Snowcone-curated designs); `curated` is also added to the index's filterable attributes.
|
|
8
|
+
|
|
9
|
+
## 0.13.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#625](https://github.com/snowcone-app/snowcone-monorepo/pull/625) [`1f9e32d`](https://github.com/snowcone-app/snowcone-monorepo/commit/1f9e32d65a53cd9be2fea4f858cba485837f19e7) Thanks [@kevinsproles](https://github.com/kevinsproles)! - New `searchDesigns(query, options)` + `client.catalog.designs.search()` for the
|
|
14
|
+
public pre-made designs catalog (`snowcone-designs` Meilisearch index), with
|
|
15
|
+
`meilisearch.designsIndex` config / `NEXT_PUBLIC_MEILISEARCH_DESIGNS_INDEX` env
|
|
16
|
+
override and a loose `CatalogDesign` type carrying mockup-URL components
|
|
17
|
+
(`productId`, `asset`, `assets`, `variant`, reserved `slots`).
|
|
18
|
+
|
|
3
19
|
## 0.12.1
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -136,6 +136,7 @@ __export(index_exports, {
|
|
|
136
136
|
resolveMockupId: () => resolveMockupId,
|
|
137
137
|
resolveVariantId: () => resolveVariantId,
|
|
138
138
|
retryOperation: () => retryOperation,
|
|
139
|
+
searchDesigns: () => searchDesigns,
|
|
139
140
|
simulateCartOperation: () => simulateCartOperation,
|
|
140
141
|
toCombinations: () => toCombinations,
|
|
141
142
|
toOptionAttributes: () => toOptionAttributes,
|
|
@@ -6101,13 +6102,43 @@ async function getProduct(idOrSlug, config) {
|
|
|
6101
6102
|
const raw = await res.json();
|
|
6102
6103
|
return validateProductLoose(raw);
|
|
6103
6104
|
}
|
|
6105
|
+
async function searchDesigns(query = "", options) {
|
|
6106
|
+
const f = getFetcher(options);
|
|
6107
|
+
const meilisearchHost = options?.meilisearch?.host || typeof process !== "undefined" && process.env?.NEXT_PUBLIC_MEILISEARCH_HOST || "https://search.snowcone.app";
|
|
6108
|
+
const meilisearchApiKey = options?.meilisearch?.apiKey || typeof process !== "undefined" && process.env?.NEXT_PUBLIC_MEILISEARCH_API_KEY || "eee819b849798ad9091228c486ec05d0931e5292";
|
|
6109
|
+
const designsIndex = options?.meilisearch?.designsIndex || typeof process !== "undefined" && process.env?.NEXT_PUBLIC_MEILISEARCH_DESIGNS_INDEX || "snowcone-designs";
|
|
6110
|
+
const headers = {
|
|
6111
|
+
"Content-Type": "application/json"
|
|
6112
|
+
};
|
|
6113
|
+
if (meilisearchApiKey) {
|
|
6114
|
+
headers["Authorization"] = `Bearer ${meilisearchApiKey}`;
|
|
6115
|
+
}
|
|
6116
|
+
const url = `${meilisearchHost}/indexes/${designsIndex}/search`;
|
|
6117
|
+
const res = await f(url, {
|
|
6118
|
+
method: "POST",
|
|
6119
|
+
headers,
|
|
6120
|
+
body: JSON.stringify({
|
|
6121
|
+
q: query,
|
|
6122
|
+
limit: options?.limit || 50,
|
|
6123
|
+
...options?.offset ? { offset: options.offset } : {},
|
|
6124
|
+
...options?.filter ? { filter: options.filter } : {}
|
|
6125
|
+
})
|
|
6126
|
+
});
|
|
6127
|
+
if (!res.ok) throw new Error(`searchDesigns failed: ${res.status}`);
|
|
6128
|
+
const data = await res.json();
|
|
6129
|
+
const items = data.hits || [];
|
|
6130
|
+
return { items, total: data.estimatedTotalHits || items.length };
|
|
6131
|
+
}
|
|
6104
6132
|
function createClient(config) {
|
|
6105
6133
|
const fetcher = getFetcher(config);
|
|
6106
6134
|
const mockupService = new MockupServiceImpl(config.mockup || {}, fetcher);
|
|
6107
6135
|
return {
|
|
6108
6136
|
catalog: {
|
|
6109
6137
|
listProducts: (overrides) => listProducts({ ...config, ...overrides }),
|
|
6110
|
-
getProduct: (idOrSlug, overrides) => getProduct(idOrSlug, { ...config, ...overrides })
|
|
6138
|
+
getProduct: (idOrSlug, overrides) => getProduct(idOrSlug, { ...config, ...overrides }),
|
|
6139
|
+
designs: {
|
|
6140
|
+
search: (query, options) => searchDesigns(query, { ...config, ...options })
|
|
6141
|
+
}
|
|
6111
6142
|
},
|
|
6112
6143
|
mockup: mockupService
|
|
6113
6144
|
};
|
|
@@ -6230,6 +6261,7 @@ function createClient(config) {
|
|
|
6230
6261
|
resolveMockupId,
|
|
6231
6262
|
resolveVariantId,
|
|
6232
6263
|
retryOperation,
|
|
6264
|
+
searchDesigns,
|
|
6233
6265
|
simulateCartOperation,
|
|
6234
6266
|
toCombinations,
|
|
6235
6267
|
toOptionAttributes,
|
package/dist/index.d.cts
CHANGED
|
@@ -3097,20 +3097,77 @@ interface SdkConfig {
|
|
|
3097
3097
|
host?: string;
|
|
3098
3098
|
apiKey?: string;
|
|
3099
3099
|
index?: string;
|
|
3100
|
+
/** Public designs-catalog index (pre-made, remixable designs). */
|
|
3101
|
+
designsIndex?: string;
|
|
3100
3102
|
};
|
|
3101
3103
|
}
|
|
3104
|
+
/**
|
|
3105
|
+
* A pre-made design from the public designs catalog (loosely typed). Docs
|
|
3106
|
+
* carry mockup-URL COMPONENTS (productId + per-placement asset URLs +
|
|
3107
|
+
* variant), never assembled URLs — build render URLs via @snowcone-app/mockup-url
|
|
3108
|
+
* (or pass `design`/`asset` straight into the canvas/embed primitives).
|
|
3109
|
+
*/
|
|
3110
|
+
interface CatalogDesign {
|
|
3111
|
+
/** = pairingId (the catalog document id). */
|
|
3112
|
+
id: string;
|
|
3113
|
+
pairingId?: string;
|
|
3114
|
+
slug?: string | null;
|
|
3115
|
+
title?: string;
|
|
3116
|
+
description?: string | null;
|
|
3117
|
+
tags?: string[];
|
|
3118
|
+
occasion?: string | null;
|
|
3119
|
+
style?: string | null;
|
|
3120
|
+
/** Product short code — the mockup URL path segment. */
|
|
3121
|
+
productId?: string;
|
|
3122
|
+
variant?: string | null;
|
|
3123
|
+
/** Bare-asset render component (flattened full-canvas export). */
|
|
3124
|
+
asset?: string | null;
|
|
3125
|
+
/** Per-placement render components: placement KEY → image URL. */
|
|
3126
|
+
assets?: Record<string, string> | null;
|
|
3127
|
+
previewThumbnail?: string | null;
|
|
3128
|
+
minPriceCents?: number | null;
|
|
3129
|
+
license?: {
|
|
3130
|
+
remixable?: boolean;
|
|
3131
|
+
};
|
|
3132
|
+
/** First-party curation flag — filterable facet (`curated = true`). */
|
|
3133
|
+
curated?: boolean;
|
|
3134
|
+
/** RESERVED — always null today; future structured slot metadata. */
|
|
3135
|
+
slots?: unknown;
|
|
3136
|
+
[key: string]: unknown;
|
|
3137
|
+
}
|
|
3138
|
+
interface DesignsSearchResponse {
|
|
3139
|
+
items: CatalogDesign[];
|
|
3140
|
+
total: number;
|
|
3141
|
+
}
|
|
3142
|
+
interface SearchDesignsOptions extends Partial<SdkConfig> {
|
|
3143
|
+
limit?: number;
|
|
3144
|
+
offset?: number;
|
|
3145
|
+
/** Meilisearch filter, e.g. "occasion = 'christmas' AND style = 'watercolor'". */
|
|
3146
|
+
filter?: string;
|
|
3147
|
+
}
|
|
3102
3148
|
interface SnowconeClient {
|
|
3103
3149
|
catalog: {
|
|
3104
3150
|
listProducts(config?: Partial<SdkConfig>): Promise<CatalogListResponse>;
|
|
3105
3151
|
getProduct(idOrSlug: string, config?: Partial<SdkConfig>): Promise<CatalogProduct>;
|
|
3152
|
+
designs: {
|
|
3153
|
+
search(query?: string, options?: SearchDesignsOptions): Promise<DesignsSearchResponse>;
|
|
3154
|
+
};
|
|
3106
3155
|
};
|
|
3107
3156
|
mockup: MockupService;
|
|
3108
3157
|
}
|
|
3109
3158
|
declare function listProducts(config?: Partial<SdkConfig>): Promise<CatalogListResponse>;
|
|
3110
3159
|
declare function getProduct(idOrSlug: string, config?: Partial<SdkConfig>): Promise<CatalogProduct>;
|
|
3160
|
+
/**
|
|
3161
|
+
* Search the public designs catalog (every published marketplace design;
|
|
3162
|
+
* filter `curated = true` for first-party-curated picks) so an integration
|
|
3163
|
+
* never starts from a blank canvas. Returns mockup-URL components per
|
|
3164
|
+
* design — feed `assets` (or `asset`) into @snowcone-app/mockup-url's
|
|
3165
|
+
* builder or the canvas/embed primitives.
|
|
3166
|
+
*/
|
|
3167
|
+
declare function searchDesigns(query?: string, options?: SearchDesignsOptions): Promise<DesignsSearchResponse>;
|
|
3111
3168
|
/**
|
|
3112
3169
|
* Create a unified Snowcone client with catalog and mockup services
|
|
3113
3170
|
*/
|
|
3114
3171
|
declare function createClient(config: SdkConfig): SnowconeClient;
|
|
3115
3172
|
|
|
3116
|
-
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 };
|
|
3173
|
+
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 CatalogDesign, 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 DesignsSearchResponse, 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 SearchDesignsOptions, 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, searchDesigns, 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
|
@@ -3097,20 +3097,77 @@ interface SdkConfig {
|
|
|
3097
3097
|
host?: string;
|
|
3098
3098
|
apiKey?: string;
|
|
3099
3099
|
index?: string;
|
|
3100
|
+
/** Public designs-catalog index (pre-made, remixable designs). */
|
|
3101
|
+
designsIndex?: string;
|
|
3100
3102
|
};
|
|
3101
3103
|
}
|
|
3104
|
+
/**
|
|
3105
|
+
* A pre-made design from the public designs catalog (loosely typed). Docs
|
|
3106
|
+
* carry mockup-URL COMPONENTS (productId + per-placement asset URLs +
|
|
3107
|
+
* variant), never assembled URLs — build render URLs via @snowcone-app/mockup-url
|
|
3108
|
+
* (or pass `design`/`asset` straight into the canvas/embed primitives).
|
|
3109
|
+
*/
|
|
3110
|
+
interface CatalogDesign {
|
|
3111
|
+
/** = pairingId (the catalog document id). */
|
|
3112
|
+
id: string;
|
|
3113
|
+
pairingId?: string;
|
|
3114
|
+
slug?: string | null;
|
|
3115
|
+
title?: string;
|
|
3116
|
+
description?: string | null;
|
|
3117
|
+
tags?: string[];
|
|
3118
|
+
occasion?: string | null;
|
|
3119
|
+
style?: string | null;
|
|
3120
|
+
/** Product short code — the mockup URL path segment. */
|
|
3121
|
+
productId?: string;
|
|
3122
|
+
variant?: string | null;
|
|
3123
|
+
/** Bare-asset render component (flattened full-canvas export). */
|
|
3124
|
+
asset?: string | null;
|
|
3125
|
+
/** Per-placement render components: placement KEY → image URL. */
|
|
3126
|
+
assets?: Record<string, string> | null;
|
|
3127
|
+
previewThumbnail?: string | null;
|
|
3128
|
+
minPriceCents?: number | null;
|
|
3129
|
+
license?: {
|
|
3130
|
+
remixable?: boolean;
|
|
3131
|
+
};
|
|
3132
|
+
/** First-party curation flag — filterable facet (`curated = true`). */
|
|
3133
|
+
curated?: boolean;
|
|
3134
|
+
/** RESERVED — always null today; future structured slot metadata. */
|
|
3135
|
+
slots?: unknown;
|
|
3136
|
+
[key: string]: unknown;
|
|
3137
|
+
}
|
|
3138
|
+
interface DesignsSearchResponse {
|
|
3139
|
+
items: CatalogDesign[];
|
|
3140
|
+
total: number;
|
|
3141
|
+
}
|
|
3142
|
+
interface SearchDesignsOptions extends Partial<SdkConfig> {
|
|
3143
|
+
limit?: number;
|
|
3144
|
+
offset?: number;
|
|
3145
|
+
/** Meilisearch filter, e.g. "occasion = 'christmas' AND style = 'watercolor'". */
|
|
3146
|
+
filter?: string;
|
|
3147
|
+
}
|
|
3102
3148
|
interface SnowconeClient {
|
|
3103
3149
|
catalog: {
|
|
3104
3150
|
listProducts(config?: Partial<SdkConfig>): Promise<CatalogListResponse>;
|
|
3105
3151
|
getProduct(idOrSlug: string, config?: Partial<SdkConfig>): Promise<CatalogProduct>;
|
|
3152
|
+
designs: {
|
|
3153
|
+
search(query?: string, options?: SearchDesignsOptions): Promise<DesignsSearchResponse>;
|
|
3154
|
+
};
|
|
3106
3155
|
};
|
|
3107
3156
|
mockup: MockupService;
|
|
3108
3157
|
}
|
|
3109
3158
|
declare function listProducts(config?: Partial<SdkConfig>): Promise<CatalogListResponse>;
|
|
3110
3159
|
declare function getProduct(idOrSlug: string, config?: Partial<SdkConfig>): Promise<CatalogProduct>;
|
|
3160
|
+
/**
|
|
3161
|
+
* Search the public designs catalog (every published marketplace design;
|
|
3162
|
+
* filter `curated = true` for first-party-curated picks) so an integration
|
|
3163
|
+
* never starts from a blank canvas. Returns mockup-URL components per
|
|
3164
|
+
* design — feed `assets` (or `asset`) into @snowcone-app/mockup-url's
|
|
3165
|
+
* builder or the canvas/embed primitives.
|
|
3166
|
+
*/
|
|
3167
|
+
declare function searchDesigns(query?: string, options?: SearchDesignsOptions): Promise<DesignsSearchResponse>;
|
|
3111
3168
|
/**
|
|
3112
3169
|
* Create a unified Snowcone client with catalog and mockup services
|
|
3113
3170
|
*/
|
|
3114
3171
|
declare function createClient(config: SdkConfig): SnowconeClient;
|
|
3115
3172
|
|
|
3116
|
-
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 };
|
|
3173
|
+
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 CatalogDesign, 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 DesignsSearchResponse, 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 SearchDesignsOptions, 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, searchDesigns, simulateCartOperation, toCombinations, toOptionAttributes, useFrameworkAdapter as useVueAdapter, validateAlignment, validateDesignElement, validateEffects, validateImageUrl, validateMockupOptions, validateProductSelection, validateProductSpec, validateRequiredOptions, validateTileCount, warnVariantNotSelected, withContext, withErrorHandling, withSyncErrorHandling };
|
package/dist/index.js
CHANGED
|
@@ -4977,13 +4977,43 @@ async function getProduct(idOrSlug, config) {
|
|
|
4977
4977
|
const raw = await res.json();
|
|
4978
4978
|
return validateProductLoose(raw);
|
|
4979
4979
|
}
|
|
4980
|
+
async function searchDesigns(query = "", options) {
|
|
4981
|
+
const f = getFetcher(options);
|
|
4982
|
+
const meilisearchHost = options?.meilisearch?.host || typeof process !== "undefined" && process.env?.NEXT_PUBLIC_MEILISEARCH_HOST || "https://search.snowcone.app";
|
|
4983
|
+
const meilisearchApiKey = options?.meilisearch?.apiKey || typeof process !== "undefined" && process.env?.NEXT_PUBLIC_MEILISEARCH_API_KEY || "eee819b849798ad9091228c486ec05d0931e5292";
|
|
4984
|
+
const designsIndex = options?.meilisearch?.designsIndex || typeof process !== "undefined" && process.env?.NEXT_PUBLIC_MEILISEARCH_DESIGNS_INDEX || "snowcone-designs";
|
|
4985
|
+
const headers = {
|
|
4986
|
+
"Content-Type": "application/json"
|
|
4987
|
+
};
|
|
4988
|
+
if (meilisearchApiKey) {
|
|
4989
|
+
headers["Authorization"] = `Bearer ${meilisearchApiKey}`;
|
|
4990
|
+
}
|
|
4991
|
+
const url = `${meilisearchHost}/indexes/${designsIndex}/search`;
|
|
4992
|
+
const res = await f(url, {
|
|
4993
|
+
method: "POST",
|
|
4994
|
+
headers,
|
|
4995
|
+
body: JSON.stringify({
|
|
4996
|
+
q: query,
|
|
4997
|
+
limit: options?.limit || 50,
|
|
4998
|
+
...options?.offset ? { offset: options.offset } : {},
|
|
4999
|
+
...options?.filter ? { filter: options.filter } : {}
|
|
5000
|
+
})
|
|
5001
|
+
});
|
|
5002
|
+
if (!res.ok) throw new Error(`searchDesigns failed: ${res.status}`);
|
|
5003
|
+
const data = await res.json();
|
|
5004
|
+
const items = data.hits || [];
|
|
5005
|
+
return { items, total: data.estimatedTotalHits || items.length };
|
|
5006
|
+
}
|
|
4980
5007
|
function createClient(config) {
|
|
4981
5008
|
const fetcher = getFetcher(config);
|
|
4982
5009
|
const mockupService = new MockupServiceImpl(config.mockup || {}, fetcher);
|
|
4983
5010
|
return {
|
|
4984
5011
|
catalog: {
|
|
4985
5012
|
listProducts: (overrides) => listProducts({ ...config, ...overrides }),
|
|
4986
|
-
getProduct: (idOrSlug, overrides) => getProduct(idOrSlug, { ...config, ...overrides })
|
|
5013
|
+
getProduct: (idOrSlug, overrides) => getProduct(idOrSlug, { ...config, ...overrides }),
|
|
5014
|
+
designs: {
|
|
5015
|
+
search: (query, options) => searchDesigns(query, { ...config, ...options })
|
|
5016
|
+
}
|
|
4987
5017
|
},
|
|
4988
5018
|
mockup: mockupService
|
|
4989
5019
|
};
|
|
@@ -5105,6 +5135,7 @@ export {
|
|
|
5105
5135
|
resolveMockupId,
|
|
5106
5136
|
resolveVariantId,
|
|
5107
5137
|
retryOperation,
|
|
5138
|
+
searchDesigns,
|
|
5108
5139
|
simulateCartOperation,
|
|
5109
5140
|
toCombinations,
|
|
5110
5141
|
toOptionAttributes,
|