@liquidcommerce/cloud-sdk 1.17.0 → 1.19.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.
@@ -94,6 +94,81 @@ export interface ICatalogParams extends ILocBase {
94
94
  orderDirection?: ENUM_NAVIGATION_ORDER_DIRECTION_TYPE;
95
95
  filters?: Array<ICategoryFilter | IPriceFilter | IAvailabilityFilter | IFulfillmentFilter | IEngravingFilter | IPresaleFilter | IFilter>;
96
96
  }
97
+ export interface ICatalogComposeSectionParams {
98
+ sectionId: string;
99
+ source?: 'query' | 'regionalPopularity';
100
+ search?: string;
101
+ perPage?: number;
102
+ orderBy?: ENUM_ORDER_BY;
103
+ orderDirection?: ENUM_NAVIGATION_ORDER_DIRECTION_TYPE;
104
+ filters?: ICatalogParams['filters'];
105
+ }
106
+ export interface ICatalogComposeParams {
107
+ /** Opaque Cloud-issued context; mutually exclusive with loc. */
108
+ locationContext?: string;
109
+ /** State and delivery area are resolved by Cloud from these coordinates. */
110
+ loc?: {
111
+ coords: {
112
+ lat: number;
113
+ long: number;
114
+ };
115
+ };
116
+ /** Cloud accepts at most one retailer ID; omit or pass [] for no hard retailer scope. */
117
+ retailers?: string[];
118
+ fulfillmentType?: 'onDemand' | 'shipping';
119
+ sections: ICatalogComposeSectionParams[];
120
+ }
121
+ export interface ICatalogComposeSectionResult {
122
+ sectionId: string;
123
+ status: 'ok' | 'partial' | 'exhausted' | 'error' | 'unavailable';
124
+ products: ICatalogComposeCardProduct[];
125
+ total: number;
126
+ requestedCount: number;
127
+ examinedCandidates: number;
128
+ selection?: IRegionalPopularitySelection;
129
+ reason?: string;
130
+ }
131
+ export interface IRegionalPopularityCandidate {
132
+ gtin14: string;
133
+ catalogVariantId: string;
134
+ catalogProductId: string;
135
+ rank: number;
136
+ }
137
+ export interface IRegionalPopularitySelection {
138
+ source: 'regionalPopularity';
139
+ status: 'fresh' | 'stale';
140
+ snapshotId: string;
141
+ policyVersion: 'v1';
142
+ generatedAtMs: number;
143
+ sourceWatermarkMs: number;
144
+ windowStart: string;
145
+ windowEndExclusive: string;
146
+ regionType: 'state' | 'national';
147
+ regionKey: string;
148
+ fallback: boolean;
149
+ fallbackReason?: 'no_state' | 'state_not_qualified';
150
+ }
151
+ export interface ICatalogComposeCardProduct extends Pick<IProduct, 'id' | 'name' | 'brand' | 'images' | 'priceInfo'> {
152
+ popularity?: IRegionalPopularityCandidate;
153
+ fulfillmentKind: 'onDemand' | 'shipping';
154
+ sizes: Array<Pick<IProductSize, 'id' | 'upc' | 'size' | 'image' | 'price' | 'pack' | 'packDesc'> & {
155
+ variants: Array<Pick<IProductVariant, 'partNumber' | 'retailerId' | 'price' | 'salePrice' | 'stock' | 'fulfillmentTypes'>>;
156
+ }>;
157
+ }
158
+ export interface ICatalogComposeRetailerSummary {
159
+ id: string;
160
+ name: string;
161
+ fulfillments: Array<{
162
+ id: string;
163
+ type: string;
164
+ fees: unknown;
165
+ expectation: unknown;
166
+ }>;
167
+ }
168
+ export interface ICatalogComposeResult {
169
+ sections: ICatalogComposeSectionResult[];
170
+ retailers: ICatalogComposeRetailerSummary[];
171
+ }
97
172
  /**
98
173
  * ICatalog interface represents a structured collection of retailers, products, and navigation schema.
99
174
  */
@@ -255,6 +330,19 @@ export interface IAttributesPersonalization {
255
330
  fee: number;
256
331
  availableFrom: Date;
257
332
  availableTo: Date;
333
+ isRequired?: boolean;
334
+ /** Ordered; pickers preselect the first font. Absent or empty means no font choice. */
335
+ fonts?: IPartnerEngravingFont[];
336
+ }
337
+ /**
338
+ * One font as a partner attached it to a size. `maxLines`/`maxCharsPerLine` may only tighten
339
+ * the size's own limits; `sampleImageUrl` is the partner's mock-up of this bottle in this font.
340
+ */
341
+ export interface IPartnerEngravingFont {
342
+ key: string;
343
+ maxLines?: number;
344
+ maxCharsPerLine?: number;
345
+ sampleImageUrl?: string;
258
346
  }
259
347
  /**
260
348
  * IAttributes interface represents the attributes of a product, including its origin,
@@ -301,8 +389,35 @@ export interface IProductVariant {
301
389
  fulfillments: string[];
302
390
  fulfillmentTypes: IProductFulfillmentTypes;
303
391
  }
392
+ /**
393
+ * An engraving font a shopper may pick for a size.
394
+ *
395
+ * `woff2Url` is the file to load in the browser (CSS Font Loading API), `previewImageUrl`
396
+ * the selector tile. `maxLines`/`maxCharsPerLine` are the effective limits for text in this
397
+ * font on this size (never more than `IProductSizeEngraving` allows), so apply them to the
398
+ * input once a font is chosen; `allowedCharsPattern` and `supportsAllCaps` describe what the
399
+ * font can draw.
400
+ */
401
+ export interface IEngravingFontOption {
402
+ key: string;
403
+ name: string;
404
+ woff2Url: string;
405
+ ttfUrl?: string;
406
+ previewImageUrl: string;
407
+ sampleImageUrl?: string;
408
+ maxLines: number;
409
+ maxCharsPerLine: number;
410
+ allowedCharsPattern?: string;
411
+ supportsAllCaps?: boolean;
412
+ }
304
413
  /**
305
414
  * Represents the engraving details for a product size.
415
+ *
416
+ * `fonts` is ordered: preselect the first one in a picker and send the shopper's choice as
417
+ * `personalization.fontKey`. Filter it by the chosen fulfillment's `engravingFontKeys` first.
418
+ * Limits to apply are the chosen font's, never looser than the size's. Cloud applies a font only when a key
419
+ * is sent; lines alone are engraved without a font. An empty list means no font choice;
420
+ * engraving then behaves as it always has.
306
421
  */
307
422
  export interface IProductSizeEngraving {
308
423
  status: boolean;
@@ -312,6 +427,7 @@ export interface IProductSizeEngraving {
312
427
  fee: number;
313
428
  location: string;
314
429
  isRequired: boolean;
430
+ fonts?: IEngravingFontOption[];
315
431
  }
316
432
  /**
317
433
  * Interface representing a product presale.
@@ -501,3 +617,16 @@ export interface ICatalogProductsPage {
501
617
  nextCursor?: string;
502
618
  counts: ICatalogProductPageCounts;
503
619
  }
620
+ /** Issue an opaque context through the authenticated partner's Cloud location semantics. */
621
+ export interface ICatalogLocationContextParams {
622
+ loc: {
623
+ coords: {
624
+ lat: number;
625
+ long: number;
626
+ };
627
+ };
628
+ }
629
+ export interface ICatalogLocationContext {
630
+ locationContext: string;
631
+ expiresAt: string;
632
+ }
@@ -1,7 +1,7 @@
1
1
  import type { IApiResponseWithData, IApiResponseWithoutData, IAuth, ILiquidCommerceConfig } from '../types';
2
2
  import type { IAddressAutocompleteParams, IAddressAutocompleteResult, IAddressDetailsParams, IAddressDetailsResult } from './address.interface';
3
3
  import type { ICart, ICartUpdateParams } from './cart.interface';
4
- import type { IAvailabilityParams, IAvailabilityResponse, ICatalog, ICatalogAutocompleteParams, ICatalogParams, ICatalogProductItem, ICatalogProductsPage, ICatalogProductsParams, ICatalogSuggestion } from './catalog.interface';
4
+ import type { IAvailabilityParams, IAvailabilityResponse, ICatalog, ICatalogAutocompleteParams, ICatalogComposeParams, ICatalogComposeResult, ICatalogLocationContext, ICatalogLocationContextParams, ICatalogParams, ICatalogProductItem, ICatalogProductsPage, ICatalogProductsParams, ICatalogSuggestion } from './catalog.interface';
5
5
  import type { ICheckoutCompleteParams, ICheckoutCompleteResponse, ICheckoutPrepareParams, ICheckoutPrepareResponse } from './checkout.interface';
6
6
  import type { ILiquidPaymentConfig, ILiquidPaymentToken, IPaymentElementEventMap } from './payment.interface';
7
7
  import type { BaseUser, IPurgeResponse, IUser, IUserAddress, IUserAddressParams, IUserPayment, IUserPaymentAddParams, IUserPaymentParams, IUserPaymentSession, IUserSession, IUserSessionParams } from './user.interface';
@@ -318,6 +318,10 @@ export interface ICatalogMethod {
318
318
  * @see {@link ICatalogProductItem} for the structure of one product.
319
319
  */
320
320
  iterateProducts: (params?: Omit<ICatalogProductsParams, 'cursor'>) => AsyncGenerator<ICatalogProductItem>;
321
+ /** Optional for existing custom clients; check this capability before calling. */
322
+ createLocationContext?: (params: ICatalogLocationContextParams) => Promise<IApiResponseWithoutData<ICatalogLocationContext>>;
323
+ /** Optional for existing custom clients; check this capability before calling. */
324
+ compose?: (params: ICatalogComposeParams) => Promise<IApiResponseWithoutData<ICatalogComposeResult>>;
321
325
  }
322
326
  /**
323
327
  * Interface for methods related to cart operations, including retrieving and updating cart data.
@@ -164,6 +164,11 @@ export interface IRetailerFulfillments {
164
164
  id: string;
165
165
  type: ENUM_MODALITIES;
166
166
  canEngrave: boolean;
167
+ /**
168
+ * Engraving font keys this retailer can engrave; shoppers get the overlap with the size's
169
+ * fonts. Absent, null or empty: the retailer engraves, but offers no font choice.
170
+ */
171
+ engravingFontKeys?: string[] | null;
167
172
  deliveryFee?: number;
168
173
  shippingFee?: number;
169
174
  engravingFee?: number;
@@ -1,5 +1,5 @@
1
1
  import type { AuthenticatedService, CatalogHelperService } from '../core';
2
- import type { IAvailabilityParams, IAvailabilityResponse, ICatalog, ICatalogAutocompleteParams, ICatalogParams, ICatalogProductItem, ICatalogProductsPage, ICatalogProductsParams, ICatalogSuggestion } from '../interfaces';
2
+ import type { IAvailabilityParams, IAvailabilityResponse, ICatalog, ICatalogAutocompleteParams, ICatalogComposeParams, ICatalogComposeResult, ICatalogLocationContext, ICatalogLocationContextParams, ICatalogParams, ICatalogProductItem, ICatalogProductsPage, ICatalogProductsParams, ICatalogSuggestion } from '../interfaces';
3
3
  import type { IApiResponseWithData, IApiResponseWithoutData } from '../types';
4
4
  /**
5
5
  * The CatalogService class provides methods for interacting with the catalog API.
@@ -84,4 +84,17 @@ export declare class CatalogService {
84
84
  * }
85
85
  */
86
86
  iterateProducts(params?: Omit<ICatalogProductsParams, 'cursor'>): AsyncGenerator<ICatalogProductItem>;
87
+ /**
88
+ * Issues an opaque location context for the authenticated partner.
89
+ * Rejects invalid coordinates before transport and forwards only coordinates.
90
+ * Does not log location-bearing requests or upstream error objects.
91
+ */
92
+ createLocationContext(params: ICatalogLocationContextParams): Promise<IApiResponseWithoutData<ICatalogLocationContext>>;
93
+ /**
94
+ * Requests delivery-first sections composed by Cloud in one catalog call.
95
+ * Rejects invalid section budgets and conflicting location inputs before transport.
96
+ * Does not log location-bearing requests or upstream error objects.
97
+ */
98
+ compose(params: ICatalogComposeParams): Promise<IApiResponseWithoutData<ICatalogComposeResult>>;
99
+ private validateComposeSection;
87
100
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liquidcommerce/cloud-sdk",
3
- "version": "1.17.0",
3
+ "version": "1.19.0",
4
4
  "description": "LiquidCommerce Cloud SDK",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.esm.js",