@depict-ai/ui 0.0.83 → 1.0.2

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/dist/index.d.ts CHANGED
@@ -7,7 +7,7 @@ import { SearchSuggestionsResponse, CategorySuggestion } from "@depict-ai/types/
7
7
  import { SearchSuggestionsRequest } from "@depict-ai/types/api/SearchSuggestionsRequest";
8
8
  import { ProductListingRequest } from "@depict-ai/types/api/ProductListingRequest";
9
9
  import { ProductListingResponse } from "@depict-ai/types/api/ProductListingResponse";
10
- export const version = "0.0.83";
10
+ export const version = "1.0.2";
11
11
  export type OnNavigation = ((options: {
12
12
  is_replace: boolean;
13
13
  new_url: URL;
@@ -33,6 +33,8 @@ type RecsAPIWrapperOptions = {
33
33
  type: string;
34
34
  merchant: string;
35
35
  market: string;
36
+ userId?: string;
37
+ sessionId?: string;
36
38
  headers?: HeadersInit;
37
39
  } & ExclusiveId;
38
40
  /**
@@ -45,6 +47,8 @@ type RecsAPIWrapperOptions = {
45
47
  * @param categoryId When requesting recommendations for a category page, pass the id of the category page as `categoryId`.
46
48
  * @param productId When requesting recommendations for a single product, e.g. on a product detail page, pass the id of the product as `productId`.
47
49
  * @param productIds When requesting recommendations that should take multiple products into account, i.e. the contents of the basket/cart, pass an array of product ids as `productIds`
50
+ * @param userId Optional unique identifier of a logged in user. Should be persistent across devices and sessions.
51
+ * @param sessionId Optional unique identifer of the current session. Only necessary when performing server side requests to Depict.
48
52
  * @param headers Optional headers to send to the Depict API. This could be authentication for example. 99% of integrations can leave this unset.
49
53
  * 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.
50
54
  *
@@ -158,11 +162,16 @@ export type InstantCard<T extends Display> = (display: T, context: {
158
162
  merchant: string;
159
163
  market: string;
160
164
  }) => JSX.Element;
165
+ interface DepictAPIConstructorOptions {
166
+ get_metadata?: () => Promise<{
167
+ [k: string]: string;
168
+ } | undefined>;
169
+ get_user_id?: () => string | undefined;
170
+ get_session_id?: () => string | undefined;
171
+ }
161
172
  export class DepictAPI {
162
173
  #private;
163
- constructor(get_metadata?: () => Promise<{
164
- [k: string]: string;
165
- } | undefined>);
174
+ constructor({ get_metadata, get_user_id, get_session_id }?: DepictAPIConstructorOptions);
166
175
  suggest(input_req: SearchSuggestionsRequest): Promise<SearchSuggestionsResponse & {
167
176
  failed?: true;
168
177
  }>;
@@ -374,6 +383,18 @@ export type BaseProviderConfig = {
374
383
  * @example "YOUR_MARKET", "no", "en-de"
375
384
  */
376
385
  market: string;
386
+ /**
387
+ * Optional unique identifier of a logged in user. Should be persistent across devices and sessions.
388
+ */
389
+ userId?: string;
390
+ /**
391
+ * Optional unique identifer of the current session. Only necessary when performing server side requests to Depict.
392
+ */
393
+ sessionId?: string;
394
+ /**
395
+ * Custom metadata to be sent with each request to the Depict API. Only necessary if specifically instructed by Depict.
396
+ */
397
+ metaData?: Record<string, string>;
377
398
  };
378
399
  export type BaseSearchProviderConfig = {
379
400
  /**