@iheartjane/dm-sdk 2.24.1 → 2.25.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/dist/chunk-TGCEYA6I.js +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +3 -232
- package/dist/index.d.ts +3 -232
- package/dist/index.js +1 -1
- package/dist/{smartSort-DJFM0D_n.d.cts → smartSort-Bzn30738.d.cts} +10 -76
- package/dist/{smartSort-DJFM0D_n.d.ts → smartSort-Bzn30738.d.ts} +10 -76
- package/dist/test-utils.cjs +1 -1
- package/dist/test-utils.d.cts +2 -15
- package/dist/test-utils.d.ts +2 -15
- package/dist/test-utils.js +1 -1
- package/package.json +9 -6
- package/dist/chunk-VEW5EGZ2.js +0 -1
|
@@ -38,8 +38,7 @@ declare enum Placement {
|
|
|
38
38
|
MenuTopRow = "menu_top_row",
|
|
39
39
|
PdpRow = "pdp_row",
|
|
40
40
|
Sale = "sale",
|
|
41
|
-
Specials = "specials"
|
|
42
|
-
VirtualBudtenderSearch = "virtual_budtender_search"
|
|
41
|
+
Specials = "specials"
|
|
43
42
|
}
|
|
44
43
|
declare enum ProductKindEnum {
|
|
45
44
|
Edible = "edible",
|
|
@@ -108,7 +107,7 @@ type Click = {
|
|
|
108
107
|
*/
|
|
109
108
|
distinctId?: string;
|
|
110
109
|
/**
|
|
111
|
-
* Should be true if the click
|
|
110
|
+
* Should be true if the click adds the product to the cart
|
|
112
111
|
*/
|
|
113
112
|
isAddToCart?: boolean;
|
|
114
113
|
/**
|
|
@@ -193,16 +192,13 @@ interface Product {
|
|
|
193
192
|
}
|
|
194
193
|
interface ProductReviewsResponse$1 {
|
|
195
194
|
aggregate: ReviewAggregate;
|
|
195
|
+
ai_summary?: string;
|
|
196
196
|
product_id: number;
|
|
197
197
|
reviews: Review[];
|
|
198
198
|
total_count: number;
|
|
199
199
|
}
|
|
200
200
|
interface ProductsPlacementResponse {
|
|
201
201
|
creative_ids?: number[];
|
|
202
|
-
/**
|
|
203
|
-
* @deprecated true
|
|
204
|
-
*/
|
|
205
|
-
custom_image_data?: CustomImageData$1;
|
|
206
202
|
custom_images?: CustomImageData$1[];
|
|
207
203
|
nb_hits?: number;
|
|
208
204
|
placement?: Placement;
|
|
@@ -284,74 +280,6 @@ interface SpecialsPlacementResponse {
|
|
|
284
280
|
specials?: SpecialResponse[];
|
|
285
281
|
title?: string;
|
|
286
282
|
}
|
|
287
|
-
type VirtualBudtenderProduct = {
|
|
288
|
-
/**
|
|
289
|
-
* AI-generated explanation for why this product matches the query
|
|
290
|
-
*
|
|
291
|
-
* @example This product contains CBD which is known for its calming effects and may help with sleep
|
|
292
|
-
*/
|
|
293
|
-
reasoning?: string;
|
|
294
|
-
/**
|
|
295
|
-
* Relevance score for this product (0 to 10)
|
|
296
|
-
*
|
|
297
|
-
* @example 8.5
|
|
298
|
-
* @format float
|
|
299
|
-
* @maximum 10
|
|
300
|
-
* @minimum 0
|
|
301
|
-
*/
|
|
302
|
-
score?: number;
|
|
303
|
-
} & Product;
|
|
304
|
-
interface VirtualBudtenderQuery {
|
|
305
|
-
/**
|
|
306
|
-
* Human-readable display text for the query
|
|
307
|
-
*
|
|
308
|
-
* @example Help me sleep
|
|
309
|
-
*/
|
|
310
|
-
displayText: string;
|
|
311
|
-
/**
|
|
312
|
-
* The natural language query string
|
|
313
|
-
*
|
|
314
|
-
* @example help me sleep
|
|
315
|
-
*/
|
|
316
|
-
query: string;
|
|
317
|
-
}
|
|
318
|
-
interface VirtualBudtenderSearchResponse {
|
|
319
|
-
/**
|
|
320
|
-
* AI-generated response in HTML format
|
|
321
|
-
*
|
|
322
|
-
* @example <p>Based on your request for sleep help, I recommend these products...</p>
|
|
323
|
-
*/
|
|
324
|
-
htmlResponse: string;
|
|
325
|
-
/**
|
|
326
|
-
* AI-generated response in markdown format
|
|
327
|
-
*
|
|
328
|
-
* @example Based on your request for sleep help, I recommend these products that contain CBD and indica strains...
|
|
329
|
-
*/
|
|
330
|
-
markdownResponse: string;
|
|
331
|
-
/**
|
|
332
|
-
* List of products matching the query
|
|
333
|
-
*/
|
|
334
|
-
products: VirtualBudtenderProduct[];
|
|
335
|
-
/**
|
|
336
|
-
* The original query that was searched
|
|
337
|
-
*
|
|
338
|
-
* @example help me sleep
|
|
339
|
-
*/
|
|
340
|
-
query: string;
|
|
341
|
-
/**
|
|
342
|
-
* Total number of products found
|
|
343
|
-
*
|
|
344
|
-
* @example 15
|
|
345
|
-
* @minimum 0
|
|
346
|
-
*/
|
|
347
|
-
totalResults: number;
|
|
348
|
-
/**
|
|
349
|
-
* Raw AI-generated response without formatting
|
|
350
|
-
*
|
|
351
|
-
* @example Based on your request for sleep help, I recommend these products that contain CBD and indica strains...
|
|
352
|
-
*/
|
|
353
|
-
unformattedResponse: string;
|
|
354
|
-
}
|
|
355
283
|
|
|
356
284
|
/**
|
|
357
285
|
* Configuration options for the Jane DM SDK client.
|
|
@@ -597,6 +525,12 @@ type ProductReviewsIterable = PaginatedIterable<ProductReview, ProductReviewsRes
|
|
|
597
525
|
*/
|
|
598
526
|
interface ProductReviewsResponse extends PaginatedResponse<ProductReview> {
|
|
599
527
|
aggregate: ProductReviewsAggregate;
|
|
528
|
+
/**
|
|
529
|
+
* AI-generated summary of the product's reviews. Absent when no
|
|
530
|
+
* summary has been generated for the product. Whole-product: does not
|
|
531
|
+
* vary with the request's filters or pagination.
|
|
532
|
+
*/
|
|
533
|
+
aiSummary?: string;
|
|
600
534
|
productId: number;
|
|
601
535
|
}
|
|
602
536
|
|
|
@@ -1072,4 +1006,4 @@ interface SmartSortProps<ProductShape extends object = Record<string, unknown>>
|
|
|
1072
1006
|
totalProducts: number;
|
|
1073
1007
|
}
|
|
1074
1008
|
|
|
1075
|
-
export {
|
|
1009
|
+
export { priceHalfGramDesc as $, AdMode as A, JaneDeviceIdSentinel as B, type CustomImageData as C, DEFAULT_PAGE_SIZE as D, type PaginationInfo as E, type FilterContext as F, ProductKindEnum as G, type ProductReview as H, type IterateProductReviewsProps as I, type JaneDMPublicConfig as J, type ProductReviewsAggregate as K, ReviewSortEnum as L, type SearchSort as M, type SmartSortNextPageProps as N, bestSellerRank as O, Placement as P, categoryAndNameAsc as Q, type RequiredConfig as R, SearchSortEnum as S, defaultOrder as T, priceAsc as U, priceDesc as V, priceEighthOunceAsc as W, priceEighthOunceDesc as X, priceGramAsc as Y, priceGramDesc as Z, priceHalfGramAsc as _, PageContextEnum as a, priceHalfOunceAsc as a0, priceHalfOunceDesc as a1, priceOunceAsc as a2, priceOunceDesc as a3, priceQuarterOunceAsc as a4, priceQuarterOunceDesc as a5, priceTwoGramAsc as a6, priceTwoGramDesc as a7, rating as a8, recommendation as a9, searchSorts as aa, thcPotencyAsc as ab, thcPotencyDesc as ac, type PlacementResponse as ad, type Product as ae, type ProductReviewsResponse$1 as af, type ProductsPlacementResponse as ag, type PageResponse as ah, type CustomImageData$1 as ai, type SmartSortProductProps as b, type SmartSortClickIntent as c, type SmartSortProps as d, type ConversionExternalProduct as e, type SessionEvent as f, type JaneDMInternalConfig as g, type FetchCartTopperRowProps as h, type FetchCustomImageRowProps as i, type Facets as j, type FetchMenuRowProps as k, type FetchMenuTopRowProps as l, type FetchProductReviewsProps as m, type ProductReviewsResponse as n, type FetchRecommendedPDPRowProps as o, type FetchRecommendedRowProps as p, type FetchRecommendedSortProps as q, type ProductReviewsIterable as r, AppMode as s, type FetchCartTopperRowByPosProductId as t, type FetchCartTopperRowByProductProps as u, type FetchRecommendedPDPRowByPosProductId as v, type FetchRecommendedPDPRowByProductId as w, IntendedDisplay as x, type JaneDMConfig as y, type JaneDMIdentifiers as z };
|
package/dist/test-utils.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var O=Object.defineProperty;var te=Object.getOwnPropertyDescriptor;var re=Object.getOwnPropertyNames;var oe=Object.prototype.hasOwnProperty;var ne=(e,t)=>{for(var r in t)O(e,r,{get:t[r],enumerable:!0})},se=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of re(t))!oe.call(e,n)&&n!==r&&O(e,n,{get:()=>t[n],enumerable:!(o=te(t,n))||o.enumerable});return e};var ce=e=>se(O({},"__esModule",{value:!0}),e);var me={};ne(me,{buildCustomImageData:()=>N,buildProduct:()=>k,buildProductReview:()=>J,buildProductReviewsAggregate:()=>V,buildProductsPlacementResponse:()=>p,buildSmartSortProductProps:()=>C,buildSmartSortProps:()=>H,mockClick:()=>T,mockFacets:()=>E,mockFetchProduct:()=>L,mockFetchProductReviews:()=>Q,mockFingerprint:()=>B,mockImpression:()=>F,mockMultiFeaturedPlacements:()=>U,mockSessionEvent:()=>z,mockSmartSortPage:()=>W,mockSmartSortPlacements:()=>Z});module.exports=ce(me);var c={click:"/v2/event/2",externalCheckout:"/v2/event/3e",facets:"/v2/facets",fingerprint:"/fp/token",impression:"/v2/event/1",multi:"/v2/multi",page:"/v2/smartpage",product:"/v2/product",productReviews:"/v2/product/reviews",sessionEvent:"/v2/event/session",smart:"/v2/smart"};var y=(o=>(o.Desktop="desktop",o.Kiosk="kiosk",o.Mobile="mobile",o))(y||{});var w=require("msw"),T=(e,t)=>w.http.post(`${e}${c.click}*`,async({request:r})=>{let o=new URL(r.url);if(t){let n=await r.json();t({reqBody:n,url:o})}return w.HttpResponse.json({},{status:200})}),F=(e,t)=>w.http.post(`${e}${c.impression}*`,async({request:r})=>{let o=new URL(r.url);if(t){let n=await r.json();t({reqBody:n,url:o})}return w.HttpResponse.json({},{status:200})});var q=require("@faker-js/faker");var j=(e={})=>{let{identifier:t,...r}=e;return{apiKey:q.faker.string.uuid(),appMode:"default",endpoint:"http://localhost:4200",eventsEndpoint:"http://localhost:4200",identifier:{jdid:q.faker.string.uuid(),...t},pageEndpoint:"http://localhost:4200",skipAutoSmartSortOnLoad:!1,source:"test",...r}};var S=require("msw"),ae=(e={})=>({searchFacets:e}),E=({callback:e,endpoint:t,facets:r})=>S.http.post(`${t}${c.facets}`,async({request:o})=>{if(e){let n=new URL(o.url),i=await o.json();e({reqBody:i,url:n})}return S.HttpResponse.json(ae(r),{status:200})});var v=require("msw"),B=({callback:e,endpoint:t,response:r})=>v.http.get(`${t}${c.fingerprint}`,async({request:o})=>{if(e){let n=new URL(o.url);e({reqBody:{},url:n})}return v.HttpResponse.json(r??{},{status:200})});var pe=require("@faker-js/faker");var M=require("msw");var s=require("@faker-js/faker");var k=(e={})=>({ad_token:s.faker.string.uuid(),object_id:s.faker.string.uuid(),product_id:s.faker.number.int(),store_id:s.faker.number.int(),...e}),N=(e={})=>({headline:s.faker.company.catchPhrase(),image_url:s.faker.image.url(),intended_display:s.faker.helpers.arrayElement(Object.values(y)),logo_url:s.faker.internet.url(),overlay_color:s.faker.color.rgb(),position_x:s.faker.number.int({max:100,min:0}),position_y:s.faker.number.int({max:100,min:0}),scale_number:s.faker.number.float({max:2,min:.5}),text_color:s.faker.color.rgb(),...e}),p=(e={})=>{let{products:t=[k()],...r}=e;return{nb_hits:t.length,placement:"menu_dynamic_row",products:t,search_facets:{},...r}},C=(e={})=>({...$(e),attributes:e.attributes??{},hasBeenImpressed:e.hasBeenImpressed??!1}),$=(e={})=>{let{endpoint:t="http://localhost:4242",eventsEndpoint:r,...o}=e,n=r??t,i=s.faker.string.uuid(),P=s.faker.datatype.boolean(),m=s.faker.string.uuid(),g=s.faker.string.uuid(),b=s.faker.string.uuid(),f=s.faker.number.int(),_=s.faker.number.int(),l=`${n}${c.click}`,x=`${n}${c.impression}`;return{clickPayload:{adToken:i,distinctId:m,isAddToCart:P,janeDeviceId:m,kevelToken:g,myHighD:b,productId:f,storeId:_},clickUrl:l,impressPayload:{distinctId:m,engagements:[{adToken:i,kevelToken:g,myHighD:b,productId:f}],janeDeviceId:m},impressUrl:x,isSponsored:!1,objectId:s.faker.string.uuid(),...o}},K=(e={})=>({object_id:s.faker.string.uuid(),...e}),G=(e={})=>({products:[K()],...e}),H=(e={creativeIds:[],endpoint:"http://localhost:4242",searchFacets:{},title:s.faker.company.catchPhrase()})=>{let{cachedProducts:t=[$()],endpoint:r="http://localhost:4242",eventsEndpoint:o,config:n=j({endpoint:r,eventsEndpoint:o??r}),creativeIds:i=[],customImages:P=[],placement:m="menu_dynamic_row",products:g=[C()],searchFacets:b={},title:f=s.faker.company.catchPhrase(),..._}=e,{totalProducts:l=t.length+g.length}=_,x=`${r}${c.page}`;return{cachedProducts:t,config:n,creativeIds:i,customImages:P,nextPageProps:{pageSize:60,searchAttributes:["*"]},nextPageUrl:x,placement:m,products:g,searchFacets:b,title:f,totalProducts:l}};var U=e=>{let{callback:t,endpoint:r,placements:o=[p({placement:"menu_top_row"}),p({placement:"menu_dynamic_row"}),p({placement:"menu_inline"})]}=e;return M.http.post(`${r}${c.multi}`,async({request:n})=>{let i=await n.json();return t&&t({reqBody:i,url:new URL(n.url)}),M.HttpResponse.json({placements:o},{status:200})})};var X=require("msw");var I=require("msw");var L=e=>{let{callback:t,endpoint:r,product:o=k()}=e;return I.http.post(`${r}${c.product}`,async({request:n})=>{let i=await n.json();return t&&t({reqBody:i,url:new URL(n.url)}),I.HttpResponse.json(o,{status:200})})};var d=require("@faker-js/faker");var D=require("msw"),J=(e={})=>({activities:[],avatar:d.faker.number.int({max:11,min:0}),comment:d.faker.lorem.sentence(),createdAt:d.faker.date.anytime().toISOString(),feelings:[],hasComment:!0,id:d.faker.number.int(),nickname:"w******a",productId:d.faker.number.int(),rating:d.faker.number.float({fractionDigits:1,max:5,min:0}),updatedAt:d.faker.date.anytime().toISOString(),upvoteCount:d.faker.number.int(),...e}),V=(e={})=>({activitiesDistribution:{},averageRating:d.faker.number.float({fractionDigits:1,max:5,min:0}),distribution:{1:1,2:2,3:5,4:10,5:20},feelingsDistribution:{},reviewCount:d.faker.number.int({max:100,min:0}),...e}),Y=(e={})=>({created_at:"2026-01-15T12:00:00Z",has_comment:!0,id:1,product_id:123,rating:5,updated_at:"2026-01-15T12:00:00Z",upvote_count:0,...e}),ee=(e={})=>({average_rating:4.5,distribution:{1:1,2:2,3:5,4:10,5:20},review_count:38,...e}),ue=(e={})=>({aggregate:ee(),product_id:123,reviews:[Y()],total_count:1,...e}),Q=({callback:e,endpoint:t,response:r})=>D.http.post(`${t}${c.productReviews}`,async({request:o})=>{if(e){let n=new URL(o.url),i=await o.json();e({reqBody:i,url:n})}return D.HttpResponse.json(ue(r),{status:200})});var A=require("msw"),z=(e,t)=>A.http.post(`${e}${c.sessionEvent}`,async({request:r})=>{if(t){let o=new URL(r.url),n=await r.json();t({reqBody:n,url:o})}return A.HttpResponse.json({},{status:200})});var u=require("msw");var Z=e=>{let{callback:t,endpoint:r,...o}=e;if(!Object.values(o).some(l=>l!==void 0)){let l=Object.keys(o).join(", ");throw new Error(`At least one of [${l}] must be defined in props.`)}let{cartToppers:i,customImageRow:P,menuRow:m,menuTopRow:g,pdpRow:b,recommendedRow:f,recommendedSort:_}=o;return u.http.post(`${r}${c.smart}`,async({request:l})=>{let x=await l.json();if(t){let a=new URL(l.url);t({reqBody:x,url:a})}let{placement:R}=x;if(R==="cart_toppers"&&i){let a=p(i);return u.HttpResponse.json(a,{status:200})}if(R==="menu_inline"&&m){let a=p(m);return u.HttpResponse.json(a,{status:200})}if(R==="menu_inline_table"&&_){let a=p(_);return u.HttpResponse.json(a,{status:200})}if(R==="menu_dynamic_row"&&f){let a=p(f);return u.HttpResponse.json(a,{status:200})}if(R==="custom_image_row"&&P){let a=p(P);return u.HttpResponse.json(a,{status:200})}if(R==="menu_top_row"&&g){let a=p(g);return u.HttpResponse.json(a,{status:200})}if(R==="pdp_row"&&b){let a=p(b);return u.HttpResponse.json(a,{status:200})}return u.HttpResponse.text("Invalid placement",{status:400})})},W=(e={endpoint:"https://the.weed.shop",response:{}})=>{let{callback:t,endpoint:r,response:o}=e,n=G(o);return u.http.post(`${r}${c.page}`,async({request:i})=>{if(t){let P=new URL(i.url),m=await i.json();t({reqBody:m,url:P})}return u.HttpResponse.json(n,{status:200})})};0&&(module.exports={buildCustomImageData,buildProduct,buildProductReview,buildProductReviewsAggregate,buildProductsPlacementResponse,buildSmartSortProductProps,buildSmartSortProps,mockClick,mockFacets,mockFetchProduct,mockFetchProductReviews,mockFingerprint,mockImpression,mockMultiFeaturedPlacements,mockSessionEvent,mockSmartSortPage,mockSmartSortPlacements});
|
package/dist/test-utils.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as msw from 'msw';
|
|
2
2
|
import { DefaultBodyType } from 'msw';
|
|
3
|
-
import {
|
|
3
|
+
import { ad as PlacementResponse, ae as Product, H as ProductReview, K as ProductReviewsAggregate, af as ProductReviewsResponse, P as Placement, ag as ProductsPlacementResponse, ah as PageResponse, j as Facets, ai as CustomImageData, b as SmartSortProductProps, d as SmartSortProps } from './smartSort-Bzn30738.cjs';
|
|
4
4
|
|
|
5
5
|
interface FingerprintTokenResponse {
|
|
6
6
|
endpoint: string;
|
|
@@ -173,17 +173,4 @@ type BuildSmartSortProps<ProductShape extends object = Record<string, unknown>>
|
|
|
173
173
|
} & Omit<SmartSortProps<ProductShape>, 'nextPageProps' | 'nextPageUrl'>>;
|
|
174
174
|
declare const buildSmartSortProps: <ProductShape extends object = Record<string, unknown>>(props?: BuildSmartSortProps<ProductShape>) => SmartSortProps<ProductShape>;
|
|
175
175
|
|
|
176
|
-
|
|
177
|
-
callback?: MockCallback;
|
|
178
|
-
endpoint: string;
|
|
179
|
-
queries?: VirtualBudtenderQuery[];
|
|
180
|
-
}
|
|
181
|
-
interface MockVirtualBudtenderSearchProps {
|
|
182
|
-
callback?: MockCallback;
|
|
183
|
-
endpoint: string;
|
|
184
|
-
response?: Partial<VirtualBudtenderSearchResponse>;
|
|
185
|
-
}
|
|
186
|
-
declare const mockVirtualBudtenderQueries: ({ callback, endpoint, queries, }: MockVirtualBudtenderQueriesProps) => msw.HttpHandler;
|
|
187
|
-
declare const mockVirtualBudtenderSearch: ({ callback, endpoint, response, }: MockVirtualBudtenderSearchProps) => msw.HttpHandler;
|
|
188
|
-
|
|
189
|
-
export { type AvailableMocks, buildCustomImageData, buildProduct, buildProductReview, buildProductReviewsAggregate, buildProductsPlacementResponse, buildSmartSortProductProps, buildSmartSortProps, mockClick, mockFacets, mockFetchProduct, mockFetchProductReviews, mockFingerprint, mockImpression, mockMultiFeaturedPlacements, mockSessionEvent, mockSmartSortPage, mockSmartSortPlacements, mockVirtualBudtenderQueries, mockVirtualBudtenderSearch };
|
|
176
|
+
export { type AvailableMocks, buildCustomImageData, buildProduct, buildProductReview, buildProductReviewsAggregate, buildProductsPlacementResponse, buildSmartSortProductProps, buildSmartSortProps, mockClick, mockFacets, mockFetchProduct, mockFetchProductReviews, mockFingerprint, mockImpression, mockMultiFeaturedPlacements, mockSessionEvent, mockSmartSortPage, mockSmartSortPlacements };
|
package/dist/test-utils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as msw from 'msw';
|
|
2
2
|
import { DefaultBodyType } from 'msw';
|
|
3
|
-
import {
|
|
3
|
+
import { ad as PlacementResponse, ae as Product, H as ProductReview, K as ProductReviewsAggregate, af as ProductReviewsResponse, P as Placement, ag as ProductsPlacementResponse, ah as PageResponse, j as Facets, ai as CustomImageData, b as SmartSortProductProps, d as SmartSortProps } from './smartSort-Bzn30738.js';
|
|
4
4
|
|
|
5
5
|
interface FingerprintTokenResponse {
|
|
6
6
|
endpoint: string;
|
|
@@ -173,17 +173,4 @@ type BuildSmartSortProps<ProductShape extends object = Record<string, unknown>>
|
|
|
173
173
|
} & Omit<SmartSortProps<ProductShape>, 'nextPageProps' | 'nextPageUrl'>>;
|
|
174
174
|
declare const buildSmartSortProps: <ProductShape extends object = Record<string, unknown>>(props?: BuildSmartSortProps<ProductShape>) => SmartSortProps<ProductShape>;
|
|
175
175
|
|
|
176
|
-
|
|
177
|
-
callback?: MockCallback;
|
|
178
|
-
endpoint: string;
|
|
179
|
-
queries?: VirtualBudtenderQuery[];
|
|
180
|
-
}
|
|
181
|
-
interface MockVirtualBudtenderSearchProps {
|
|
182
|
-
callback?: MockCallback;
|
|
183
|
-
endpoint: string;
|
|
184
|
-
response?: Partial<VirtualBudtenderSearchResponse>;
|
|
185
|
-
}
|
|
186
|
-
declare const mockVirtualBudtenderQueries: ({ callback, endpoint, queries, }: MockVirtualBudtenderQueriesProps) => msw.HttpHandler;
|
|
187
|
-
declare const mockVirtualBudtenderSearch: ({ callback, endpoint, response, }: MockVirtualBudtenderSearchProps) => msw.HttpHandler;
|
|
188
|
-
|
|
189
|
-
export { type AvailableMocks, buildCustomImageData, buildProduct, buildProductReview, buildProductReviewsAggregate, buildProductsPlacementResponse, buildSmartSortProductProps, buildSmartSortProps, mockClick, mockFacets, mockFetchProduct, mockFetchProductReviews, mockFingerprint, mockImpression, mockMultiFeaturedPlacements, mockSessionEvent, mockSmartSortPage, mockSmartSortPlacements, mockVirtualBudtenderQueries, mockVirtualBudtenderSearch };
|
|
176
|
+
export { type AvailableMocks, buildCustomImageData, buildProduct, buildProductReview, buildProductReviewsAggregate, buildProductsPlacementResponse, buildSmartSortProductProps, buildSmartSortProps, mockClick, mockFacets, mockFetchProduct, mockFetchProductReviews, mockFingerprint, mockImpression, mockMultiFeaturedPlacements, mockSessionEvent, mockSmartSortPage, mockSmartSortPlacements };
|
package/dist/test-utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as
|
|
1
|
+
import{b as a,e as C}from"./chunk-TGCEYA6I.js";import{http as j,HttpResponse as I}from"msw";var F=(e,t)=>j.post(`${e}${a.click}*`,async({request:o})=>{let r=new URL(o.url);if(t){let n=await o.json();t({reqBody:n,url:r})}return I.json({},{status:200})}),T=(e,t)=>j.post(`${e}${a.impression}*`,async({request:o})=>{let r=new URL(o.url);if(t){let n=await o.json();t({reqBody:n,url:r})}return I.json({},{status:200})});import{faker as D}from"@faker-js/faker";var h=(e={})=>{let{identifier:t,...o}=e;return{apiKey:D.string.uuid(),appMode:"default",endpoint:"http://localhost:4200",eventsEndpoint:"http://localhost:4200",identifier:{jdid:D.string.uuid(),...t},pageEndpoint:"http://localhost:4200",skipAutoSmartSortOnLoad:!1,source:"test",...o}};import{http as Q,HttpResponse as V}from"msw";var W=(e={})=>({searchFacets:e}),A=({callback:e,endpoint:t,facets:o})=>Q.post(`${t}${a.facets}`,async({request:r})=>{if(e){let n=new URL(r.url),c=await r.json();e({reqBody:c,url:n})}return V.json(W(o),{status:200})});import{http as X,HttpResponse as Y}from"msw";var O=({callback:e,endpoint:t,response:o})=>X.get(`${t}${a.fingerprint}`,async({request:r})=>{if(e){let n=new URL(r.url);e({reqBody:{},url:n})}return Y.json(o??{},{status:200})});import{faker as we}from"@faker-js/faker";import{http as ee,HttpResponse as te}from"msw";import{faker as s}from"@faker-js/faker";var y=(e={})=>({ad_token:s.string.uuid(),object_id:s.string.uuid(),product_id:s.number.int(),store_id:s.number.int(),...e}),E=(e={})=>({headline:s.company.catchPhrase(),image_url:s.image.url(),intended_display:s.helpers.arrayElement(Object.values(C)),logo_url:s.internet.url(),overlay_color:s.color.rgb(),position_x:s.number.int({max:100,min:0}),position_y:s.number.int({max:100,min:0}),scale_number:s.number.float({max:2,min:.5}),text_color:s.color.rgb(),...e}),p=(e={})=>{let{products:t=[y()],...o}=e;return{nb_hits:t.length,placement:"menu_dynamic_row",products:t,search_facets:{},...o}},M=(e={})=>({...x(e),attributes:e.attributes??{},hasBeenImpressed:e.hasBeenImpressed??!1}),x=(e={})=>{let{endpoint:t="http://localhost:4242",eventsEndpoint:o,...r}=e,n=o??t,c=s.string.uuid(),P=s.datatype.boolean(),m=s.string.uuid(),k=s.string.uuid(),R=s.string.uuid(),f=s.number.int(),b=s.number.int(),u=`${n}${a.click}`,S=`${n}${a.impression}`;return{clickPayload:{adToken:c,distinctId:m,isAddToCart:P,janeDeviceId:m,kevelToken:k,myHighD:R,productId:f,storeId:b},clickUrl:u,impressPayload:{distinctId:m,engagements:[{adToken:c,kevelToken:k,myHighD:R,productId:f}],janeDeviceId:m},impressUrl:S,isSponsored:!1,objectId:s.string.uuid(),...r}},$=(e={})=>({object_id:s.string.uuid(),...e}),v=(e={})=>({products:[$()],...e}),N=(e={creativeIds:[],endpoint:"http://localhost:4242",searchFacets:{},title:s.company.catchPhrase()})=>{let{cachedProducts:t=[x()],endpoint:o="http://localhost:4242",eventsEndpoint:r,config:n=h({endpoint:o,eventsEndpoint:r??o}),creativeIds:c=[],customImages:P=[],placement:m="menu_dynamic_row",products:k=[M()],searchFacets:R={},title:f=s.company.catchPhrase(),...b}=e,{totalProducts:u=t.length+k.length}=b,S=`${o}${a.page}`;return{cachedProducts:t,config:n,creativeIds:c,customImages:P,nextPageProps:{pageSize:60,searchAttributes:["*"]},nextPageUrl:S,placement:m,products:k,searchFacets:R,title:f,totalProducts:u}};var _=e=>{let{callback:t,endpoint:o,placements:r=[p({placement:"menu_top_row"}),p({placement:"menu_dynamic_row"}),p({placement:"menu_inline"})]}=e;return ee.post(`${o}${a.multi}`,async({request:n})=>{let c=await n.json();return t&&t({reqBody:c,url:new URL(n.url)}),te.json({placements:r},{status:200})})};import{http as $e,HttpResponse as Ne}from"msw";import{http as oe,HttpResponse as re}from"msw";var B=e=>{let{callback:t,endpoint:o,product:r=y()}=e;return oe.post(`${o}${a.product}`,async({request:n})=>{let c=await n.json();return t&&t({reqBody:c,url:new URL(n.url)}),re.json(r,{status:200})})};import{faker as l}from"@faker-js/faker";import{http as ne,HttpResponse as se}from"msw";var U=(e={})=>({activities:[],avatar:l.number.int({max:11,min:0}),comment:l.lorem.sentence(),createdAt:l.date.anytime().toISOString(),feelings:[],hasComment:!0,id:l.number.int(),nickname:"w******a",productId:l.number.int(),rating:l.number.float({fractionDigits:1,max:5,min:0}),updatedAt:l.date.anytime().toISOString(),upvoteCount:l.number.int(),...e}),L=(e={})=>({activitiesDistribution:{},averageRating:l.number.float({fractionDigits:1,max:5,min:0}),distribution:{1:1,2:2,3:5,4:10,5:20},feelingsDistribution:{},reviewCount:l.number.int({max:100,min:0}),...e}),q=(e={})=>({created_at:"2026-01-15T12:00:00Z",has_comment:!0,id:1,product_id:123,rating:5,updated_at:"2026-01-15T12:00:00Z",upvote_count:0,...e}),H=(e={})=>({average_rating:4.5,distribution:{1:1,2:2,3:5,4:10,5:20},review_count:38,...e}),ae=(e={})=>({aggregate:H(),product_id:123,reviews:[q()],total_count:1,...e}),J=({callback:e,endpoint:t,response:o})=>ne.post(`${t}${a.productReviews}`,async({request:r})=>{if(e){let n=new URL(r.url),c=await r.json();e({reqBody:c,url:n})}return se.json(ae(o),{status:200})});import{http as ce,HttpResponse as ie}from"msw";var K=(e,t)=>ce.post(`${e}${a.sessionEvent}`,async({request:o})=>{if(t){let r=new URL(o.url),n=await o.json();t({reqBody:n,url:r})}return ie.json({},{status:200})});import{http as Z,HttpResponse as d}from"msw";var z=e=>{let{callback:t,endpoint:o,...r}=e;if(!Object.values(r).some(u=>u!==void 0)){let u=Object.keys(r).join(", ");throw new Error(`At least one of [${u}] must be defined in props.`)}let{cartToppers:c,customImageRow:P,menuRow:m,menuTopRow:k,pdpRow:R,recommendedRow:f,recommendedSort:b}=r;return Z.post(`${o}${a.smart}`,async({request:u})=>{let S=await u.json();if(t){let i=new URL(u.url);t({reqBody:S,url:i})}let{placement:g}=S;if(g==="cart_toppers"&&c){let i=p(c);return d.json(i,{status:200})}if(g==="menu_inline"&&m){let i=p(m);return d.json(i,{status:200})}if(g==="menu_inline_table"&&b){let i=p(b);return d.json(i,{status:200})}if(g==="menu_dynamic_row"&&f){let i=p(f);return d.json(i,{status:200})}if(g==="custom_image_row"&&P){let i=p(P);return d.json(i,{status:200})}if(g==="menu_top_row"&&k){let i=p(k);return d.json(i,{status:200})}if(g==="pdp_row"&&R){let i=p(R);return d.json(i,{status:200})}return d.text("Invalid placement",{status:400})})},G=(e={endpoint:"https://the.weed.shop",response:{}})=>{let{callback:t,endpoint:o,response:r}=e,n=v(r);return Z.post(`${o}${a.page}`,async({request:c})=>{if(t){let P=new URL(c.url),m=await c.json();t({reqBody:m,url:P})}return d.json(n,{status:200})})};export{E as buildCustomImageData,y as buildProduct,U as buildProductReview,L as buildProductReviewsAggregate,p as buildProductsPlacementResponse,M as buildSmartSortProductProps,N as buildSmartSortProps,F as mockClick,A as mockFacets,B as mockFetchProduct,J as mockFetchProductReviews,O as mockFingerprint,T as mockImpression,_ as mockMultiFeaturedPlacements,K as mockSessionEvent,G as mockSmartSortPage,z as mockSmartSortPlacements};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iheartjane/dm-sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.25.0",
|
|
4
4
|
"description": "Jane's Digital Merchandising Tool",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "@janetechinc",
|
|
@@ -17,9 +17,12 @@
|
|
|
17
17
|
},
|
|
18
18
|
"repository": {
|
|
19
19
|
"type": "git",
|
|
20
|
-
"url": "git+https://github.com/
|
|
20
|
+
"url": "git+https://github.com/janetechinc/dm-sdk.git",
|
|
21
21
|
"directory": "packages/sdk"
|
|
22
22
|
},
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
23
26
|
"sideEffects": false,
|
|
24
27
|
"main": "dist/index.cjs",
|
|
25
28
|
"module": "dist/index.js",
|
|
@@ -38,12 +41,12 @@
|
|
|
38
41
|
"typecheck": "tsc --build"
|
|
39
42
|
},
|
|
40
43
|
"dependencies": {
|
|
41
|
-
"@fingerprintjs/fingerprintjs-pro": "^3.12.
|
|
42
|
-
"nanoid": "^
|
|
44
|
+
"@fingerprintjs/fingerprintjs-pro": "^3.12.13",
|
|
45
|
+
"nanoid": "^6.0.1"
|
|
43
46
|
},
|
|
44
47
|
"devDependencies": {
|
|
45
48
|
"@faker-js/faker": "^10.0.0",
|
|
46
|
-
"msw": "^2.
|
|
49
|
+
"msw": "^2.15.0",
|
|
47
50
|
"typescript": "^6.0.3"
|
|
48
51
|
},
|
|
49
52
|
"peerDependencies": {
|
|
@@ -63,6 +66,6 @@
|
|
|
63
66
|
}
|
|
64
67
|
},
|
|
65
68
|
"engines": {
|
|
66
|
-
"node": "
|
|
69
|
+
"node": ">=22.11.0"
|
|
67
70
|
}
|
|
68
71
|
}
|
package/dist/chunk-VEW5EGZ2.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var N=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var Z=(p,i,c,t)=>{for(var o=t>1?void 0:t?U(i,c):i,a=p.length-1,u;a>=0;a--)(u=p[a])&&(o=(t?u(i,c,o):u(o))||o);return t&&o&&N(i,c,o),o};var d=(t=>(t.All="all",t.Default="default",t.Off="off",t))(d||{}),m=(s=>(s.Bloom="bloom",s.Default="default",s.Embedded="embedded",s.FramelessEmbed="framelessEmbed",s.Headless="headless",s.Kiosk="kiosk",s.OperatorEmbed="operatorEmbed",s.WhiteLabel="whiteLabel",s))(m||{}),l=(t=>(t.Desktop="desktop",t.Kiosk="kiosk",t.Mobile="mobile",t))(l||{}),g=(i=>(i.UserOptOut="user-opt-out",i))(g||{});var _=(c=>(c.Featured="featured",c.Midgrid="midgrid",c))(_||{}),P=(r=>(r.BestSelling="best_selling",r.BrandSpecials="brand_specials",r.BuyAgainRow="buy_again_row",r.CartToppers="cart_toppers",r.CustomImageRow="custom_image_row",r.FeaturedRow="featured_row",r.MenuDynamicRow="menu_dynamic_row",r.MenuInline="menu_inline",r.MenuInlineTable="menu_inline_table",r.MenuTopRow="menu_top_row",r.PdpRow="pdp_row",r.Sale="sale",r.Specials="specials",r.VirtualBudtenderSearch="virtual_budtender_search",r))(P||{}),R=(n=>(n.Edible="edible",n.Extract="extract",n.Flower="flower",n.Gear="gear",n.Grow="grow",n.Merch="merch",n.PreRoll="pre-roll",n.Tincture="tincture",n.Topical="topical",n.Vape="vape",n))(R||{}),b=(t=>(t.Rating="rating",t.Recent="recent",t.Upvote="upvote",t))(b||{}),x=(e=>(e.BestSellerRank="best-seller-rank",e.CategoryAndNameAsc="category-and-name-asc",e.Default="default",e.PriceAsc="price-asc",e.PriceDesc="price-desc",e.PriceEighthOunceAsc="price-eighth-ounce-asc",e.PriceEighthOunceDesc="price-eighth-ounce-desc",e.PriceGramAsc="price-gram-asc",e.PriceGramDesc="price-gram-desc",e.PriceHalfGramAsc="price-half-gram-asc",e.PriceHalfGramDesc="price-half-gram-desc",e.PriceHalfOunceAsc="price-half-ounce-asc",e.PriceHalfOunceDesc="price-half-ounce-desc",e.PriceOunceAsc="price-ounce-asc",e.PriceOunceDesc="price-ounce-desc",e.PriceQuarterOunceAsc="price-quarter-ounce-asc",e.PriceQuarterOunceDesc="price-quarter-ounce-desc",e.PriceTwoGramAsc="price-two-gram-asc",e.PriceTwoGramDesc="price-two-gram-desc",e.Rating="rating",e.Recommendation="recommendation",e.ThcPotencyAsc="thc-potency-asc",e.ThcPotencyDesc="thc-potency-desc",e))(x||{});var z=50;var f="best-seller-rank",w="category-and-name-asc",v="default",h="price-asc",y="price-desc",C="price-eighth-ounce-asc",I="price-eighth-ounce-desc",q="price-gram-asc",S="price-gram-desc",D="price-half-gram-asc",A="price-half-gram-desc",O="price-half-ounce-asc",M="price-half-ounce-desc",T="price-ounce-asc",B="price-ounce-desc",F="price-quarter-ounce-asc",k="price-quarter-ounce-desc",V="price-two-gram-asc",G="price-two-gram-desc",E="rating",j="recommendation",Q="thc-potency-asc",H="thc-potency-desc",J=[f,w,v,h,y,C,I,q,S,D,A,O,M,T,B,F,k,V,G,E,j,Q,H];var L={click:"/v2/event/2",externalCheckout:"/v2/event/3e",facets:"/v2/facets",fingerprint:"/fp/token",impression:"/v2/event/1",multi:"/v2/multi",page:"/v2/smartpage",product:"/v2/product",productReviews:"/v2/product/reviews",sessionEvent:"/v2/event/session",smart:"/v2/smart",virtualBudtenderQueries:"/v2/virtual-budtender/queries",virtualBudtenderSearch:"/v2/virtual-budtender"};export{Z as a,L as b,d as c,m as d,l as e,g as f,_ as g,P as h,R as i,b as j,x as k,z as l,f as m,w as n,v as o,h as p,y as q,C as r,I as s,q as t,S as u,D as v,A as w,O as x,M as y,T as z,B as A,F as B,k as C,V as D,G as E,E as F,j as G,Q as H,H as I,J};
|