@depict-ai/ui 4.10.31 → 4.10.33

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.
@@ -11,7 +11,7 @@ import { GetListingRequest } from "@depict-ai/types/api/GetListingRequest";
11
11
  import { BaseSearchRequestV3 } from "@depict-ai/types/api/BaseSearchRequestV3";
12
12
  import { FeaturedInDisplay } from "@depict-ai/types/api/FeaturedInResponseV3";
13
13
  import { SearchFilter as _SearchFilter3 } from "@depict-ai/types/api/SearchRequestV2";
14
- export const version = "4.10.31";
14
+ export const version = "4.10.33";
15
15
  /**
16
16
  * Use `javascript_media_query` but return a reactive accessor instead of taking a callback function
17
17
  */
@@ -217,6 +217,41 @@ interface GetListingOptions extends Omit<GetListingRequest, "listing_id"> {
217
217
  id_to_query_for_: string;
218
218
  id_type_: typeof LISTING_ID | typeof EXTERNAL_ID;
219
219
  }
220
+ /**
221
+ * One read DepictAPI makes, as the transport sees it. `request_` is the v3 request as DepictAPI would send it (with
222
+ * session_id and metadata added), `body_` its JSON. A transport answers with the v3-shaped JSON response, or undefined
223
+ * when the request failed (DepictAPI then serves its fallback response).
224
+ */
225
+ type DepictAPIRawCall = {
226
+ kind_: "search" | "related";
227
+ endpoint_: string;
228
+ method_: "POST" | "GET";
229
+ request_: SearchRequestV3 & {
230
+ session_id?: string;
231
+ metadata?: unknown;
232
+ };
233
+ body_: string;
234
+ } | {
235
+ kind_: "listing" | "listing_products";
236
+ endpoint_: string;
237
+ method_: "POST" | "GET";
238
+ request_: (Omit<GetListingOptions, "id_type_" | "id_to_query_for_"> | ProductListingRequestV3) & {
239
+ session_id?: string;
240
+ metadata?: unknown;
241
+ };
242
+ body_: string;
243
+ id_to_query_for_: string;
244
+ id_type_: typeof LISTING_ID | typeof EXTERNAL_ID;
245
+ } | {
246
+ kind_: "suggest";
247
+ endpoint_: string;
248
+ method_: "GET";
249
+ request_: SearchSuggestionsRequestV3 & {
250
+ session_id?: string;
251
+ metadata?: string;
252
+ };
253
+ body_?: never;
254
+ };
220
255
  /**
221
256
  * Class that handles all communication done in PLP code with the Depict API. (Notably not for recommendations currently).
222
257
  * It handles caching, retries and errors and is the only place that should be making requests to the Depict API.
@@ -224,6 +259,12 @@ interface GetListingOptions extends Omit<GetListingRequest, "listing_id"> {
224
259
  export class DepictAPI<InputDisplay extends Display, OutputDisplay extends ModernDisplay | never = InputDisplay extends ModernDisplay ? ModernDisplayWithPageUrl<InputDisplay> : never> {
225
260
  #private;
226
261
  display_transformers: DisplayTransformers<ModernDisplay, OutputDisplay> | undefined;
262
+ /**
263
+ * The network step of every read: sends `call` to the v3 API and returns the decoded JSON, or undefined when the
264
+ * request failed. NativeDepictAPI overrides this to read the native V4 API instead and map its answers to v3 shapes,
265
+ * so caching, display transformers and fallbacks stay the same for both.
266
+ */
267
+ protected request_raw_(call: DepictAPIRawCall): Promise<any>;
227
268
  constructor(options: DepictAPIConstructorOptions<InputDisplay, OutputDisplay>);
228
269
  suggest(input_req: SearchSuggestionsRequestV3): Promise<SearchSuggestionsResponseAfterURLCreator & {
229
270
  failed?: true;
@@ -459,6 +500,31 @@ export function useSlidableInformation(): {
459
500
  slider_: Amazing_Slider;
460
501
  intersectionEntries_: Accessor<IntersectionObserverEntry[]>;
461
502
  } | undefined;
503
+ /** Which API an SDK reads: `v3` (the default) or the native V4 API (`https://api.depict.ai/v4/{merchant}/…`). */
504
+ export type DepictAPIVersion = "v3" | "v4";
505
+ /**
506
+ * DepictAPI over the native V4 API. Search, listing pages (products and header) and search suggestions read
507
+ * `/v4/{merchant}/browse`, `/listings` and `/suggest`, and the search page's related products (`get_recommended`)
508
+ * read `/recommendations` (fetch_native_recommendations.ts). Every answer is mapped to the v3 shape DepictAPI
509
+ * returns, so the UI and merchant display transformers work unchanged (see cards.ts for the card mapping).
510
+ *
511
+ * Not native yet, and on v3 instead:
512
+ * - looks and shop the look (V4 has no endpoint for them)
513
+ *
514
+ * Creating one also sends tracking events to the native `/v4/{merchant}/events` (`set_event_api("v4")`), for the
515
+ * Performance Client and anything else on this page that shares this `@depict-ai/utilishared`. Events V4 can't take
516
+ * as v3 did (a v3 recommendation's click, say) stay on `/create-events`.
517
+ *
518
+ * The native API is strict: it rejects unknown parameters and fields, and content requests carry no session or
519
+ * metadata, so `get_metadata`/`get_session_id` only affect the cache key here.
520
+ */
521
+ export class NativeDepictAPI<InputDisplay extends Display, OutputDisplay extends ModernDisplay | never = InputDisplay extends ModernDisplay ? ModernDisplayWithPageUrl<InputDisplay> : never> extends DepictAPI<InputDisplay, OutputDisplay> {
522
+ #private;
523
+ constructor(options: DepictAPIConstructorOptions<InputDisplay, OutputDisplay>);
524
+ protected request_raw_(call: DepictAPIRawCall): Promise<any>;
525
+ }
526
+ /** A DepictAPI for `version`: v3, or the native V4 API. */
527
+ export function create_depict_api<InputDisplay extends Display, OutputDisplay extends ModernDisplay | never>(version: DepictAPIVersion | undefined, options: DepictAPIConstructorOptions<InputDisplay, OutputDisplay>): DepictAPI<InputDisplay, OutputDisplay>;
462
528
  export type SDKColsAtSize = [number, number?][];
463
529
  /**
464
530
  * Transform SDK ColsAtSize into valid Layout ColsAtSize
@@ -885,6 +951,15 @@ export type BaseProviderConfig<InputDisplay extends Display, PossibleTransformed
885
951
  * resizer for Shopify CDN images.
886
952
  */
887
953
  imageResizer?: (url: string, width: number) => string;
954
+ /**
955
+ * Which Depict API to read: `"v3"` (the default) or `"v4"`, the native V4 API (`https://api.depict.ai/v4/{merchant}`).
956
+ * V4 serves search, listing pages, search suggestions and the search page's related products; looks, shop the look
957
+ * and anything else not named here stay on v3. Recommendations take their own `api` option
958
+ * (fetchDepictRecommendations; React's useFetchRecommendations follows its DepictProvider).
959
+ * Opt-in while V4 is rolled out.
960
+ * With `"v4"`, the tracking events V4 can carry go to it too (see the Performance Client's `api` option).
961
+ */
962
+ api?: DepictAPIVersion;
888
963
  } & (InputDisplay extends ModernDisplay ? "page_url" extends keyof InputDisplay["variant_displays"][number] ? {
889
964
  /**
890
965
  * Functions that take in a list of categories, content search results or products and then can transform or enrich the data for each category, content search result or product card in a batched way.
@@ -1343,6 +1418,13 @@ type RecsAPIWrapperOptions = {
1343
1418
  sessionId?: string;
1344
1419
  headers?: HeadersInit;
1345
1420
  metadata?: Record<string, any>;
1421
+ /**
1422
+ * Which Depict API to read: `"v3"` (the default) or `"v4"`, the native V4 API
1423
+ * (`https://api.depict.ai/v4/{merchant}/recommendations`). On V4, `sessionId`, `metadata` and `headers` aren't sent:
1424
+ * V4 content requests carry no session, and history-based recommendations get the shopper's recently viewed products
1425
+ * from the browser instead. Opt-in while V4 is rolled out.
1426
+ */
1427
+ api?: DepictAPIVersion;
1346
1428
  } & ExclusiveId;
1347
1429
  /**
1348
1430
  * Fetches recommendations from Depict's API.
@@ -1357,6 +1439,7 @@ type RecsAPIWrapperOptions = {
1357
1439
  * @param sessionId Optional unique identifier of the current session. Only necessary when performing server side requests to Depict.
1358
1440
  * @param metadata Custom metadata to be sent with each request to the Depict API. Only necessary if specifically instructed by Depict.
1359
1441
  * @param headers Optional headers to send to the Depict API. This could be authentication for example. 99% of integrations can leave this unset.
1442
+ * @param api Which Depict API to read: `"v3"` (the default) or `"v4"`, the native V4 API.
1360
1443
  * When no id is provided (none out of `categoryId`, `productId` and `productIds`) general recommendations will be fetched. This is for, for example, the frontpage where generally popular products get returned.
1361
1444
  *
1362
1445
  * @note If you only get recommendations when specifying the wrong id type (i.e. you only get basket recommendations if you provide a single product id while the recommendations should be based on everything in the basket) please ask Depict to re-configure the endpoint for you.
@@ -1400,7 +1483,15 @@ type CategoryConstructorOptionsWithApi<InputDisplay extends Display, OutputDispl
1400
1483
  display_transformers?: never;
1401
1484
  };
1402
1485
  type CategoryConstructorOptionsWithoutApi<InputDisplay extends Display, OutputDisplay extends ModernDisplay | never> = GeneralCategoryListingOptions & {
1403
- api?: never;
1486
+ /**
1487
+ * Which Depict API to read: `"v3"` (the default) or `"v4"`, the native V4 API (`https://api.depict.ai/v4/{merchant}`).
1488
+ * V4 serves search, listing pages, search suggestions and the search page's related products; looks, shop the look
1489
+ * and anything else not named here stay on v3. Recommendations take their own `api` option
1490
+ * (fetchDepictRecommendations; React's useFetchRecommendations follows its DepictProvider).
1491
+ * Opt-in while V4 is rolled out.
1492
+ * With `"v4"`, the tracking events V4 can carry go to it too (see the Performance Client's `api` option).
1493
+ */
1494
+ api?: DepictAPIVersion;
1404
1495
  } & SomethingTakingADisplayTransformers<InputDisplay, OutputDisplay>;
1405
1496
  type DepictCategoryConstructorOptions<InputDisplay extends Display, OutputDisplay extends ModernDisplay> = CategoryConstructorOptionsWithApi<InputDisplay, OutputDisplay> | CategoryConstructorOptionsWithoutApi<InputDisplay, OutputDisplay>;
1406
1497
  export class DepictCategory<InputDisplay extends Display, OutputDisplay extends ModernDisplay | never = InputDisplay extends ModernDisplay ? ModernDisplayWithPageUrl<InputDisplay> : never> {
@@ -1473,7 +1564,15 @@ type ConstructorOptionsWithApi<InputDisplay extends Display, OutputDisplay exten
1473
1564
  display_transformers?: never;
1474
1565
  };
1475
1566
  type ConstructorOptionsWithoutAPI<InputDisplay extends Display, OutputDisplay extends ModernDisplay | never> = GeneralConstructorOptions<InputDisplay, OutputDisplay> & {
1476
- api?: never;
1567
+ /**
1568
+ * Which Depict API to read: `"v3"` (the default) or `"v4"`, the native V4 API (`https://api.depict.ai/v4/{merchant}`).
1569
+ * V4 serves search, listing pages, search suggestions and the search page's related products; looks, shop the look
1570
+ * and anything else not named here stay on v3. Recommendations take their own `api` option
1571
+ * (fetchDepictRecommendations; React's useFetchRecommendations follows its DepictProvider).
1572
+ * Opt-in while V4 is rolled out.
1573
+ * With `"v4"`, the tracking events V4 can carry go to it too (see the Performance Client's `api` option).
1574
+ */
1575
+ api?: DepictAPIVersion;
1477
1576
  } & SomethingTakingADisplayTransformers<InputDisplay, OutputDisplay>;
1478
1577
  type ConstructorOptions<InputDisplay extends Display, OutputDisplay extends ModernDisplay> = ConstructorOptionsWithApi<InputDisplay, OutputDisplay> | ConstructorOptionsWithoutAPI<InputDisplay, OutputDisplay>;
1479
1578
  export type OpenModalArguments = [options_for_modal?: {