@iheartjane/dm-sdk 2.24.1
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-VEW5EGZ2.js +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +1181 -0
- package/dist/index.d.ts +1181 -0
- package/dist/index.js +1 -0
- package/dist/smartSort-DJFM0D_n.d.cts +1075 -0
- package/dist/smartSort-DJFM0D_n.d.ts +1075 -0
- package/dist/test-utils.cjs +1 -0
- package/dist/test-utils.d.cts +189 -0
- package/dist/test-utils.d.ts +189 -0
- package/dist/test-utils.js +1 -0
- package/package.json +68 -0
- package/test-utils/package.json +4 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var T=Object.defineProperty;var ne=Object.getOwnPropertyDescriptor;var se=Object.getOwnPropertyNames;var ae=Object.prototype.hasOwnProperty;var ie=(e,t)=>{for(var r in t)T(e,r,{get:t[r],enumerable:!0})},ce=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of se(t))!ae.call(e,n)&&n!==r&&T(e,n,{get:()=>t[n],enumerable:!(o=ne(t,n))||o.enumerable});return e};var pe=e=>ce(T({},"__esModule",{value:!0}),e);var Re={};ie(Re,{buildCustomImageData:()=>$,buildProduct:()=>k,buildProductReview:()=>L,buildProductReviewsAggregate:()=>J,buildProductsPlacementResponse:()=>p,buildSmartSortProductProps:()=>M,buildSmartSortProps:()=>H,mockClick:()=>A,mockFacets:()=>V,mockFetchProduct:()=>U,mockFetchProductReviews:()=>z,mockFingerprint:()=>E,mockImpression:()=>O,mockMultiFeaturedPlacements:()=>G,mockSessionEvent:()=>Z,mockSmartSortPage:()=>K,mockSmartSortPlacements:()=>W,mockVirtualBudtenderQueries:()=>X,mockVirtualBudtenderSearch:()=>Y});module.exports=pe(Re);var s={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"};var w=(o=>(o.Desktop="desktop",o.Kiosk="kiosk",o.Mobile="mobile",o))(w||{});var x=require("msw"),A=(e,t)=>x.http.post(`${e}${s.click}*`,async({request:r})=>{let o=new URL(r.url);if(t){let n=await r.json();t({reqBody:n,url:o})}return x.HttpResponse.json({},{status:200})}),O=(e,t)=>x.http.post(`${e}${s.impression}*`,async({request:r})=>{let o=new URL(r.url);if(t){let n=await r.json();t({reqBody:n,url:o})}return x.HttpResponse.json({},{status:200})});var F=require("@faker-js/faker");var j=(e={})=>{let{identifier:t,...r}=e;return{apiKey:F.faker.string.uuid(),appMode:"default",endpoint:"http://localhost:4200",eventsEndpoint:"http://localhost:4200",identifier:{jdid:F.faker.string.uuid(),...t},pageEndpoint:"http://localhost:4200",skipAutoSmartSortOnLoad:!1,source:"test",...r}};var v=require("msw"),de=(e={})=>({searchFacets:e}),V=({callback:e,endpoint:t,facets:r})=>v.http.post(`${t}${s.facets}`,async({request:o})=>{if(e){let n=new URL(o.url),i=await o.json();e({reqBody:i,url:n})}return v.HttpResponse.json(de(r),{status:200})});var C=require("msw"),E=({callback:e,endpoint:t,response:r})=>C.http.get(`${t}${s.fingerprint}`,async({request:o})=>{if(e){let n=new URL(o.url);e({reqBody:{},url:n})}return C.HttpResponse.json(r??{},{status:200})});var me=require("@faker-js/faker");var I=require("msw");var a=require("@faker-js/faker");var k=(e={})=>({ad_token:a.faker.string.uuid(),object_id:a.faker.string.uuid(),product_id:a.faker.number.int(),store_id:a.faker.number.int(),...e}),$=(e={})=>({headline:a.faker.company.catchPhrase(),image_url:a.faker.image.url(),intended_display:a.faker.helpers.arrayElement(Object.values(w)),logo_url:a.faker.internet.url(),overlay_color:a.faker.color.rgb(),position_x:a.faker.number.int({max:100,min:0}),position_y:a.faker.number.int({max:100,min:0}),scale_number:a.faker.number.float({max:2,min:.5}),text_color:a.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}},M=(e={})=>({...N(e),attributes:e.attributes??{},hasBeenImpressed:e.hasBeenImpressed??!1}),N=(e={})=>{let{endpoint:t="http://localhost:4242",eventsEndpoint:r,...o}=e,n=r??t,i=a.faker.string.uuid(),P=a.faker.datatype.boolean(),d=a.faker.string.uuid(),g=a.faker.string.uuid(),b=a.faker.string.uuid(),f=a.faker.number.int(),_=a.faker.number.int(),l=`${n}${s.click}`,y=`${n}${s.impression}`;return{clickPayload:{adToken:i,distinctId:d,isAddToCart:P,janeDeviceId:d,kevelToken:g,myHighD:b,productId:f,storeId:_},clickUrl:l,impressPayload:{distinctId:d,engagements:[{adToken:i,kevelToken:g,myHighD:b,productId:f}],janeDeviceId:d},impressUrl:y,isSponsored:!1,objectId:a.faker.string.uuid(),...o}},ee=(e={})=>({object_id:a.faker.string.uuid(),...e}),Q=(e={})=>({products:[ee()],...e}),H=(e={creativeIds:[],endpoint:"http://localhost:4242",searchFacets:{},title:a.faker.company.catchPhrase()})=>{let{cachedProducts:t=[N()],endpoint:r="http://localhost:4242",eventsEndpoint:o,config:n=j({endpoint:r,eventsEndpoint:o??r}),creativeIds:i=[],customImages:P=[],placement:d="menu_dynamic_row",products:g=[M()],searchFacets:b={},title:f=a.faker.company.catchPhrase(),..._}=e,{totalProducts:l=t.length+g.length}=_,y=`${r}${s.page}`;return{cachedProducts:t,config:n,creativeIds:i,customImages:P,nextPageProps:{pageSize:60,searchAttributes:["*"]},nextPageUrl:y,placement:d,products:g,searchFacets:b,title:f,totalProducts:l}};var G=e=>{let{callback:t,endpoint:r,placements:o=[p({placement:"menu_top_row"}),p({placement:"menu_dynamic_row"}),p({placement:"menu_inline"})]}=e;return I.http.post(`${r}${s.multi}`,async({request:n})=>{let i=await n.json();return t&&t({reqBody:i,url:new URL(n.url)}),I.HttpResponse.json({placements:o},{status:200})})};var te=require("msw");var D=require("msw");var U=e=>{let{callback:t,endpoint:r,product:o=k()}=e;return D.http.post(`${r}${s.product}`,async({request:n})=>{let i=await n.json();return t&&t({reqBody:i,url:new URL(n.url)}),D.HttpResponse.json(o,{status:200})})};var m=require("@faker-js/faker");var B=require("msw"),L=(e={})=>({activities:[],avatar:m.faker.number.int({max:11,min:0}),comment:m.faker.lorem.sentence(),createdAt:m.faker.date.anytime().toISOString(),feelings:[],hasComment:!0,id:m.faker.number.int(),nickname:"w******a",productId:m.faker.number.int(),rating:m.faker.number.float({fractionDigits:1,max:5,min:0}),updatedAt:m.faker.date.anytime().toISOString(),upvoteCount:m.faker.number.int(),...e}),J=(e={})=>({activitiesDistribution:{},averageRating:m.faker.number.float({fractionDigits:1,max:5,min:0}),distribution:{1:1,2:2,3:5,4:10,5:20},feelingsDistribution:{},reviewCount:m.faker.number.int({max:100,min:0}),...e}),re=(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}),oe=(e={})=>({average_rating:4.5,distribution:{1:1,2:2,3:5,4:10,5:20},review_count:38,...e}),le=(e={})=>({aggregate:oe(),product_id:123,reviews:[re()],total_count:1,...e}),z=({callback:e,endpoint:t,response:r})=>B.http.post(`${t}${s.productReviews}`,async({request:o})=>{if(e){let n=new URL(o.url),i=await o.json();e({reqBody:i,url:n})}return B.HttpResponse.json(le(r),{status:200})});var q=require("msw"),Z=(e,t)=>q.http.post(`${e}${s.sessionEvent}`,async({request:r})=>{if(t){let o=new URL(r.url),n=await r.json();t({reqBody:n,url:o})}return q.HttpResponse.json({},{status:200})});var u=require("msw");var W=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:d,menuTopRow:g,pdpRow:b,recommendedRow:f,recommendedSort:_}=o;return u.http.post(`${r}${s.smart}`,async({request:l})=>{let y=await l.json();if(t){let c=new URL(l.url);t({reqBody:y,url:c})}let{placement:R}=y;if(R==="cart_toppers"&&i){let c=p(i);return u.HttpResponse.json(c,{status:200})}if(R==="menu_inline"&&d){let c=p(d);return u.HttpResponse.json(c,{status:200})}if(R==="menu_inline_table"&&_){let c=p(_);return u.HttpResponse.json(c,{status:200})}if(R==="menu_dynamic_row"&&f){let c=p(f);return u.HttpResponse.json(c,{status:200})}if(R==="custom_image_row"&&P){let c=p(P);return u.HttpResponse.json(c,{status:200})}if(R==="menu_top_row"&&g){let c=p(g);return u.HttpResponse.json(c,{status:200})}if(R==="pdp_row"&&b){let c=p(b);return u.HttpResponse.json(c,{status:200})}return u.HttpResponse.text("Invalid placement",{status:400})})},K=(e={endpoint:"https://the.weed.shop",response:{}})=>{let{callback:t,endpoint:r,response:o}=e,n=Q(o);return u.http.post(`${r}${s.page}`,async({request:i})=>{if(t){let P=new URL(i.url),d=await i.json();t({reqBody:d,url:P})}return u.HttpResponse.json(n,{status:200})})};var h=require("msw"),Pe=(e=[])=>({queries:e}),ge=(e={})=>({htmlResponse:"<p>Here are some products to help you sleep...</p>",markdownResponse:"Here are some products to help you sleep...",products:[],query:"help me sleep",totalResults:0,unformattedResponse:"Here are some products to help you sleep...",...e}),X=({callback:e,endpoint:t,queries:r})=>h.http.post(`${t}${s.virtualBudtenderQueries}`,async({request:o})=>{if(e){let n=new URL(o.url),i=await o.json();e({reqBody:i,url:n})}return h.HttpResponse.json(Pe(r),{status:200})}),Y=({callback:e,endpoint:t,response:r})=>h.http.post(`${t}${s.virtualBudtenderSearch}`,async({request:o})=>{if(e){let n=new URL(o.url),i=await o.json();e({reqBody:i,url:n})}return h.HttpResponse.json(ge(r),{status:200})});0&&(module.exports={buildCustomImageData,buildProduct,buildProductReview,buildProductReviewsAggregate,buildProductsPlacementResponse,buildSmartSortProductProps,buildSmartSortProps,mockClick,mockFacets,mockFetchProduct,mockFetchProductReviews,mockFingerprint,mockImpression,mockMultiFeaturedPlacements,mockSessionEvent,mockSmartSortPage,mockSmartSortPlacements,mockVirtualBudtenderQueries,mockVirtualBudtenderSearch});
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import * as msw from 'msw';
|
|
2
|
+
import { DefaultBodyType } from 'msw';
|
|
3
|
+
import { ah as PlacementResponse, ai as Product, L as ProductReview, M as ProductReviewsAggregate, aj as ProductReviewsResponse, P as Placement, ak as ProductsPlacementResponse, al as PageResponse, k as Facets, am as CustomImageData, c as SmartSortProductProps, e as SmartSortProps, V as VirtualBudtenderQuery, T as VirtualBudtenderSearchResponse } from './smartSort-DJFM0D_n.cjs';
|
|
4
|
+
|
|
5
|
+
interface FingerprintTokenResponse {
|
|
6
|
+
endpoint: string;
|
|
7
|
+
scriptUrlPattern: string;
|
|
8
|
+
token: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
type MockCallback = (props: MockCallbackProps) => void;
|
|
12
|
+
interface MockCallbackProps {
|
|
13
|
+
reqBody?: DefaultBodyType;
|
|
14
|
+
url: URL;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface MockMultiFeaturedPlacementsProps {
|
|
18
|
+
callback?: MockCallback;
|
|
19
|
+
endpoint: string;
|
|
20
|
+
placements?: PlacementResponse[];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Mock the multi featured placements endpoint. This mock's response returns a set of three placements.
|
|
24
|
+
*
|
|
25
|
+
* The placements are:
|
|
26
|
+
* - MenuTopRow
|
|
27
|
+
* - MenuDynamicRow
|
|
28
|
+
* - MenuInline
|
|
29
|
+
*
|
|
30
|
+
* Modifying the placements is possible by passing in a custom array of placements.
|
|
31
|
+
*
|
|
32
|
+
* @param props - The props for the mock.
|
|
33
|
+
* @returns A mock for the multi featured placements endpoint.
|
|
34
|
+
*/
|
|
35
|
+
declare const mockMultiFeaturedPlacements: (props: MockMultiFeaturedPlacementsProps) => msw.HttpHandler;
|
|
36
|
+
|
|
37
|
+
interface MockFetchProductProps {
|
|
38
|
+
callback?: MockCallback;
|
|
39
|
+
endpoint: string;
|
|
40
|
+
product?: Product;
|
|
41
|
+
}
|
|
42
|
+
declare const mockFetchProduct: (props: MockFetchProductProps) => msw.HttpHandler;
|
|
43
|
+
|
|
44
|
+
declare const buildProductReview: (overrides?: Partial<ProductReview>) => ProductReview;
|
|
45
|
+
declare const buildProductReviewsAggregate: (overrides?: Partial<ProductReviewsAggregate>) => ProductReviewsAggregate;
|
|
46
|
+
interface MockFetchProductReviewsProps {
|
|
47
|
+
callback?: MockCallback;
|
|
48
|
+
endpoint: string;
|
|
49
|
+
response?: Partial<ProductReviewsResponse>;
|
|
50
|
+
}
|
|
51
|
+
declare const mockFetchProductReviews: ({ callback, endpoint, response }: MockFetchProductReviewsProps) => msw.HttpHandler;
|
|
52
|
+
|
|
53
|
+
type AvailableMocks = {
|
|
54
|
+
[key in keyof ExternalPlacementMap]?: Partial<ProductsPlacementResponse>;
|
|
55
|
+
};
|
|
56
|
+
type MockSmartSortPlacementsProps = {
|
|
57
|
+
callback?: MockCallback;
|
|
58
|
+
endpoint: string;
|
|
59
|
+
} & RequireAtLeastOne<AvailableMocks>;
|
|
60
|
+
type RequireAtLeastOne<T> = {
|
|
61
|
+
[K in keyof T]-?: Partial<Omit<T, K>> & Required<Pick<T, K>>;
|
|
62
|
+
}[keyof T];
|
|
63
|
+
interface ExternalPlacementMap {
|
|
64
|
+
cartToppers: typeof Placement.CartToppers;
|
|
65
|
+
customImageRow: typeof Placement.CustomImageRow;
|
|
66
|
+
menuRow: typeof Placement.MenuInline;
|
|
67
|
+
menuTopRow: typeof Placement.MenuTopRow;
|
|
68
|
+
pdpRow: typeof Placement.PdpRow;
|
|
69
|
+
recommendedRow: typeof Placement.MenuDynamicRow;
|
|
70
|
+
recommendedSort: typeof Placement.MenuInlineTable;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Mocks a specific SmartSort placement by providing mock responses
|
|
74
|
+
* for one or more placements in a SmartSort system.
|
|
75
|
+
*
|
|
76
|
+
* @param {MockSmartSortPlacementsProps} props - The configuration object for the mock.
|
|
77
|
+
* @param {string} props.endpoint - The API endpoint to mock.
|
|
78
|
+
* @param {MockCallback} [props.callback] - Optional callback invoked after the mock is set up.
|
|
79
|
+
* @param {Partial<ProductsPlacementResponse>} [props.menuTopRow] - Mock response for the `menu_top_row` placement.
|
|
80
|
+
* @param {Partial<ProductsPlacementResponse>} [props.customImageRow] - Mock response for the `custom_image_row` placement.
|
|
81
|
+
* @param {Partial<ProductsPlacementResponse>} [props.pdpRow] - Mock response for the `pdp_row` placement.
|
|
82
|
+
* @param {Partial<ProductsPlacementResponse>} [props.menuInline] - Mock response for the `menu_inline` placement.
|
|
83
|
+
* @param {Partial<ProductsPlacementResponse>} [props.menuInlineTable] - Mock response for the `menu_inline_table` placement.
|
|
84
|
+
* @param {Partial<ProductsPlacementResponse>} [props.cartToppers] - Mock response for the `cart_toppers` placement.
|
|
85
|
+
* @param {Partial<ProductsPlacementResponse>} [props.menuDynamicRow] - Mock response for the `menu_dynamic_row` placement.
|
|
86
|
+
*
|
|
87
|
+
* @throws {Error} Throws an error if no valid placement mock is provided.
|
|
88
|
+
*/
|
|
89
|
+
declare const mockSmartSortPlacements: (props: MockSmartSortPlacementsProps) => msw.HttpHandler;
|
|
90
|
+
interface MockSmartSortPageProps {
|
|
91
|
+
callback?: MockCallback;
|
|
92
|
+
endpoint: string;
|
|
93
|
+
response?: Partial<PageResponse>;
|
|
94
|
+
}
|
|
95
|
+
declare const mockSmartSortPage: (props?: MockSmartSortPageProps) => msw.HttpHandler;
|
|
96
|
+
|
|
97
|
+
declare const mockClick: (endpoint: string, callback?: MockCallback) => msw.HttpHandler;
|
|
98
|
+
declare const mockImpression: (endpoint: string, callback?: MockCallback) => msw.HttpHandler;
|
|
99
|
+
|
|
100
|
+
interface MockFacetsProps {
|
|
101
|
+
callback?: MockCallback;
|
|
102
|
+
endpoint: string;
|
|
103
|
+
facets?: Facets;
|
|
104
|
+
}
|
|
105
|
+
declare const mockFacets: ({ callback, endpoint, facets }: MockFacetsProps) => msw.HttpHandler;
|
|
106
|
+
|
|
107
|
+
interface MockFingerprintProps {
|
|
108
|
+
callback?: MockCallback;
|
|
109
|
+
endpoint: string;
|
|
110
|
+
response?: FingerprintTokenResponse | Record<string, never>;
|
|
111
|
+
}
|
|
112
|
+
declare const mockFingerprint: ({ callback, endpoint, response, }: MockFingerprintProps) => msw.HttpHandler;
|
|
113
|
+
|
|
114
|
+
declare const mockSessionEvent: (endpoint: string, callback?: MockCallback) => msw.HttpHandler;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* This function returns a Product object that gets
|
|
118
|
+
* transformed into a CachedSmartSortProduct object.
|
|
119
|
+
*
|
|
120
|
+
* In order to create a SmartSortProduct, you need to provide
|
|
121
|
+
* - search_attributes: Record<string, unknown>
|
|
122
|
+
*
|
|
123
|
+
* Search Attributes are essentially the object returned from algolia
|
|
124
|
+
* so using the `buildAlgoliaProduct` function is a good way to generate
|
|
125
|
+
* the search_attributes property.
|
|
126
|
+
*/
|
|
127
|
+
declare const buildProduct: (overrides?: Partial<Product>) => Product;
|
|
128
|
+
/**
|
|
129
|
+
* Returns an `ApiCustomImageData` object in the raw API (snake_case) shape the
|
|
130
|
+
* `/v2/smart` response uses for `custom_images`.
|
|
131
|
+
*
|
|
132
|
+
* Use it to exercise `fetchCustomImageRow`: feed it into a placement-response
|
|
133
|
+
* mock so the SDK massages it into `SmartSort.customImages`.
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* ```ts
|
|
137
|
+
* mockSmartSortPlacements({
|
|
138
|
+
* customImageRow: { custom_images: [buildCustomImageData()] },
|
|
139
|
+
* endpoint,
|
|
140
|
+
* });
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
declare const buildCustomImageData: (overrides?: Partial<CustomImageData>) => CustomImageData;
|
|
144
|
+
declare const buildProductsPlacementResponse: (overrides?: Partial<ProductsPlacementResponse>) => ProductsPlacementResponse;
|
|
145
|
+
type BuildSmartSortProductProps<ProductShape extends object = Record<string, unknown>, T = SmartSortProductProps<ProductShape>> = Partial<{
|
|
146
|
+
endpoint: string;
|
|
147
|
+
eventsEndpoint: string;
|
|
148
|
+
} & Omit<T, 'clickUrl' | 'impressUrl'>>;
|
|
149
|
+
/**
|
|
150
|
+
* Returns factory props that can be used to initialize a SmartSortProduct
|
|
151
|
+
* in a test environment.
|
|
152
|
+
*
|
|
153
|
+
* If you'd like to make this a sponsored product, pass `{ isSponsored: true }`
|
|
154
|
+
*
|
|
155
|
+
* In order to test click and impression tracking, you'll need to provide the URLs
|
|
156
|
+
* @example
|
|
157
|
+
* ```jsx
|
|
158
|
+
* import { mockJaneConfig } from '@jane/shared/testing-utils';
|
|
159
|
+
*
|
|
160
|
+
* const endpoint = 'http://the.weed.shop';
|
|
161
|
+
* mockJaneConfig({ dmEndpoint: endpoint });
|
|
162
|
+
*
|
|
163
|
+
* const productProps = buildSmartSortProductProps({ endpoint });
|
|
164
|
+
* const product = new SmartSortProduct(productProps);
|
|
165
|
+
*
|
|
166
|
+
* describe('SmartSortProduct', () => {}); // ...
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
169
|
+
declare const buildSmartSortProductProps: <ProductShape extends object = Record<string, unknown>>(overrides?: BuildSmartSortProductProps<ProductShape>) => SmartSortProductProps<ProductShape>;
|
|
170
|
+
type BuildSmartSortProps<ProductShape extends object = Record<string, unknown>> = Partial<{
|
|
171
|
+
endpoint: string;
|
|
172
|
+
eventsEndpoint?: string;
|
|
173
|
+
} & Omit<SmartSortProps<ProductShape>, 'nextPageProps' | 'nextPageUrl'>>;
|
|
174
|
+
declare const buildSmartSortProps: <ProductShape extends object = Record<string, unknown>>(props?: BuildSmartSortProps<ProductShape>) => SmartSortProps<ProductShape>;
|
|
175
|
+
|
|
176
|
+
interface MockVirtualBudtenderQueriesProps {
|
|
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 };
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import * as msw from 'msw';
|
|
2
|
+
import { DefaultBodyType } from 'msw';
|
|
3
|
+
import { ah as PlacementResponse, ai as Product, L as ProductReview, M as ProductReviewsAggregate, aj as ProductReviewsResponse, P as Placement, ak as ProductsPlacementResponse, al as PageResponse, k as Facets, am as CustomImageData, c as SmartSortProductProps, e as SmartSortProps, V as VirtualBudtenderQuery, T as VirtualBudtenderSearchResponse } from './smartSort-DJFM0D_n.js';
|
|
4
|
+
|
|
5
|
+
interface FingerprintTokenResponse {
|
|
6
|
+
endpoint: string;
|
|
7
|
+
scriptUrlPattern: string;
|
|
8
|
+
token: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
type MockCallback = (props: MockCallbackProps) => void;
|
|
12
|
+
interface MockCallbackProps {
|
|
13
|
+
reqBody?: DefaultBodyType;
|
|
14
|
+
url: URL;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface MockMultiFeaturedPlacementsProps {
|
|
18
|
+
callback?: MockCallback;
|
|
19
|
+
endpoint: string;
|
|
20
|
+
placements?: PlacementResponse[];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Mock the multi featured placements endpoint. This mock's response returns a set of three placements.
|
|
24
|
+
*
|
|
25
|
+
* The placements are:
|
|
26
|
+
* - MenuTopRow
|
|
27
|
+
* - MenuDynamicRow
|
|
28
|
+
* - MenuInline
|
|
29
|
+
*
|
|
30
|
+
* Modifying the placements is possible by passing in a custom array of placements.
|
|
31
|
+
*
|
|
32
|
+
* @param props - The props for the mock.
|
|
33
|
+
* @returns A mock for the multi featured placements endpoint.
|
|
34
|
+
*/
|
|
35
|
+
declare const mockMultiFeaturedPlacements: (props: MockMultiFeaturedPlacementsProps) => msw.HttpHandler;
|
|
36
|
+
|
|
37
|
+
interface MockFetchProductProps {
|
|
38
|
+
callback?: MockCallback;
|
|
39
|
+
endpoint: string;
|
|
40
|
+
product?: Product;
|
|
41
|
+
}
|
|
42
|
+
declare const mockFetchProduct: (props: MockFetchProductProps) => msw.HttpHandler;
|
|
43
|
+
|
|
44
|
+
declare const buildProductReview: (overrides?: Partial<ProductReview>) => ProductReview;
|
|
45
|
+
declare const buildProductReviewsAggregate: (overrides?: Partial<ProductReviewsAggregate>) => ProductReviewsAggregate;
|
|
46
|
+
interface MockFetchProductReviewsProps {
|
|
47
|
+
callback?: MockCallback;
|
|
48
|
+
endpoint: string;
|
|
49
|
+
response?: Partial<ProductReviewsResponse>;
|
|
50
|
+
}
|
|
51
|
+
declare const mockFetchProductReviews: ({ callback, endpoint, response }: MockFetchProductReviewsProps) => msw.HttpHandler;
|
|
52
|
+
|
|
53
|
+
type AvailableMocks = {
|
|
54
|
+
[key in keyof ExternalPlacementMap]?: Partial<ProductsPlacementResponse>;
|
|
55
|
+
};
|
|
56
|
+
type MockSmartSortPlacementsProps = {
|
|
57
|
+
callback?: MockCallback;
|
|
58
|
+
endpoint: string;
|
|
59
|
+
} & RequireAtLeastOne<AvailableMocks>;
|
|
60
|
+
type RequireAtLeastOne<T> = {
|
|
61
|
+
[K in keyof T]-?: Partial<Omit<T, K>> & Required<Pick<T, K>>;
|
|
62
|
+
}[keyof T];
|
|
63
|
+
interface ExternalPlacementMap {
|
|
64
|
+
cartToppers: typeof Placement.CartToppers;
|
|
65
|
+
customImageRow: typeof Placement.CustomImageRow;
|
|
66
|
+
menuRow: typeof Placement.MenuInline;
|
|
67
|
+
menuTopRow: typeof Placement.MenuTopRow;
|
|
68
|
+
pdpRow: typeof Placement.PdpRow;
|
|
69
|
+
recommendedRow: typeof Placement.MenuDynamicRow;
|
|
70
|
+
recommendedSort: typeof Placement.MenuInlineTable;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Mocks a specific SmartSort placement by providing mock responses
|
|
74
|
+
* for one or more placements in a SmartSort system.
|
|
75
|
+
*
|
|
76
|
+
* @param {MockSmartSortPlacementsProps} props - The configuration object for the mock.
|
|
77
|
+
* @param {string} props.endpoint - The API endpoint to mock.
|
|
78
|
+
* @param {MockCallback} [props.callback] - Optional callback invoked after the mock is set up.
|
|
79
|
+
* @param {Partial<ProductsPlacementResponse>} [props.menuTopRow] - Mock response for the `menu_top_row` placement.
|
|
80
|
+
* @param {Partial<ProductsPlacementResponse>} [props.customImageRow] - Mock response for the `custom_image_row` placement.
|
|
81
|
+
* @param {Partial<ProductsPlacementResponse>} [props.pdpRow] - Mock response for the `pdp_row` placement.
|
|
82
|
+
* @param {Partial<ProductsPlacementResponse>} [props.menuInline] - Mock response for the `menu_inline` placement.
|
|
83
|
+
* @param {Partial<ProductsPlacementResponse>} [props.menuInlineTable] - Mock response for the `menu_inline_table` placement.
|
|
84
|
+
* @param {Partial<ProductsPlacementResponse>} [props.cartToppers] - Mock response for the `cart_toppers` placement.
|
|
85
|
+
* @param {Partial<ProductsPlacementResponse>} [props.menuDynamicRow] - Mock response for the `menu_dynamic_row` placement.
|
|
86
|
+
*
|
|
87
|
+
* @throws {Error} Throws an error if no valid placement mock is provided.
|
|
88
|
+
*/
|
|
89
|
+
declare const mockSmartSortPlacements: (props: MockSmartSortPlacementsProps) => msw.HttpHandler;
|
|
90
|
+
interface MockSmartSortPageProps {
|
|
91
|
+
callback?: MockCallback;
|
|
92
|
+
endpoint: string;
|
|
93
|
+
response?: Partial<PageResponse>;
|
|
94
|
+
}
|
|
95
|
+
declare const mockSmartSortPage: (props?: MockSmartSortPageProps) => msw.HttpHandler;
|
|
96
|
+
|
|
97
|
+
declare const mockClick: (endpoint: string, callback?: MockCallback) => msw.HttpHandler;
|
|
98
|
+
declare const mockImpression: (endpoint: string, callback?: MockCallback) => msw.HttpHandler;
|
|
99
|
+
|
|
100
|
+
interface MockFacetsProps {
|
|
101
|
+
callback?: MockCallback;
|
|
102
|
+
endpoint: string;
|
|
103
|
+
facets?: Facets;
|
|
104
|
+
}
|
|
105
|
+
declare const mockFacets: ({ callback, endpoint, facets }: MockFacetsProps) => msw.HttpHandler;
|
|
106
|
+
|
|
107
|
+
interface MockFingerprintProps {
|
|
108
|
+
callback?: MockCallback;
|
|
109
|
+
endpoint: string;
|
|
110
|
+
response?: FingerprintTokenResponse | Record<string, never>;
|
|
111
|
+
}
|
|
112
|
+
declare const mockFingerprint: ({ callback, endpoint, response, }: MockFingerprintProps) => msw.HttpHandler;
|
|
113
|
+
|
|
114
|
+
declare const mockSessionEvent: (endpoint: string, callback?: MockCallback) => msw.HttpHandler;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* This function returns a Product object that gets
|
|
118
|
+
* transformed into a CachedSmartSortProduct object.
|
|
119
|
+
*
|
|
120
|
+
* In order to create a SmartSortProduct, you need to provide
|
|
121
|
+
* - search_attributes: Record<string, unknown>
|
|
122
|
+
*
|
|
123
|
+
* Search Attributes are essentially the object returned from algolia
|
|
124
|
+
* so using the `buildAlgoliaProduct` function is a good way to generate
|
|
125
|
+
* the search_attributes property.
|
|
126
|
+
*/
|
|
127
|
+
declare const buildProduct: (overrides?: Partial<Product>) => Product;
|
|
128
|
+
/**
|
|
129
|
+
* Returns an `ApiCustomImageData` object in the raw API (snake_case) shape the
|
|
130
|
+
* `/v2/smart` response uses for `custom_images`.
|
|
131
|
+
*
|
|
132
|
+
* Use it to exercise `fetchCustomImageRow`: feed it into a placement-response
|
|
133
|
+
* mock so the SDK massages it into `SmartSort.customImages`.
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* ```ts
|
|
137
|
+
* mockSmartSortPlacements({
|
|
138
|
+
* customImageRow: { custom_images: [buildCustomImageData()] },
|
|
139
|
+
* endpoint,
|
|
140
|
+
* });
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
declare const buildCustomImageData: (overrides?: Partial<CustomImageData>) => CustomImageData;
|
|
144
|
+
declare const buildProductsPlacementResponse: (overrides?: Partial<ProductsPlacementResponse>) => ProductsPlacementResponse;
|
|
145
|
+
type BuildSmartSortProductProps<ProductShape extends object = Record<string, unknown>, T = SmartSortProductProps<ProductShape>> = Partial<{
|
|
146
|
+
endpoint: string;
|
|
147
|
+
eventsEndpoint: string;
|
|
148
|
+
} & Omit<T, 'clickUrl' | 'impressUrl'>>;
|
|
149
|
+
/**
|
|
150
|
+
* Returns factory props that can be used to initialize a SmartSortProduct
|
|
151
|
+
* in a test environment.
|
|
152
|
+
*
|
|
153
|
+
* If you'd like to make this a sponsored product, pass `{ isSponsored: true }`
|
|
154
|
+
*
|
|
155
|
+
* In order to test click and impression tracking, you'll need to provide the URLs
|
|
156
|
+
* @example
|
|
157
|
+
* ```jsx
|
|
158
|
+
* import { mockJaneConfig } from '@jane/shared/testing-utils';
|
|
159
|
+
*
|
|
160
|
+
* const endpoint = 'http://the.weed.shop';
|
|
161
|
+
* mockJaneConfig({ dmEndpoint: endpoint });
|
|
162
|
+
*
|
|
163
|
+
* const productProps = buildSmartSortProductProps({ endpoint });
|
|
164
|
+
* const product = new SmartSortProduct(productProps);
|
|
165
|
+
*
|
|
166
|
+
* describe('SmartSortProduct', () => {}); // ...
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
169
|
+
declare const buildSmartSortProductProps: <ProductShape extends object = Record<string, unknown>>(overrides?: BuildSmartSortProductProps<ProductShape>) => SmartSortProductProps<ProductShape>;
|
|
170
|
+
type BuildSmartSortProps<ProductShape extends object = Record<string, unknown>> = Partial<{
|
|
171
|
+
endpoint: string;
|
|
172
|
+
eventsEndpoint?: string;
|
|
173
|
+
} & Omit<SmartSortProps<ProductShape>, 'nextPageProps' | 'nextPageUrl'>>;
|
|
174
|
+
declare const buildSmartSortProps: <ProductShape extends object = Record<string, unknown>>(props?: BuildSmartSortProps<ProductShape>) => SmartSortProps<ProductShape>;
|
|
175
|
+
|
|
176
|
+
interface MockVirtualBudtenderQueriesProps {
|
|
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 };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as n,e as j}from"./chunk-VEW5EGZ2.js";import{http as C,HttpResponse as B}from"msw";var I=(e,t)=>C.post(`${e}${n.click}*`,async({request:o})=>{let r=new URL(o.url);if(t){let s=await o.json();t({reqBody:s,url:r})}return B.json({},{status:200})}),T=(e,t)=>C.post(`${e}${n.impression}*`,async({request:o})=>{let r=new URL(o.url);if(t){let s=await o.json();t({reqBody:s,url:r})}return B.json({},{status:200})});import{faker as _}from"@faker-js/faker";var h=(e={})=>{let{identifier:t,...o}=e;return{apiKey:_.string.uuid(),appMode:"default",endpoint:"http://localhost:4200",eventsEndpoint:"http://localhost:4200",identifier:{jdid:_.string.uuid(),...t},pageEndpoint:"http://localhost:4200",skipAutoSmartSortOnLoad:!1,source:"test",...o}};import{http as Y,HttpResponse as ee}from"msw";var te=(e={})=>({searchFacets:e}),$=({callback:e,endpoint:t,facets:o})=>Y.post(`${t}${n.facets}`,async({request:r})=>{if(e){let s=new URL(r.url),c=await r.json();e({reqBody:c,url:s})}return ee.json(te(o),{status:200})});import{http as oe,HttpResponse as re}from"msw";var F=({callback:e,endpoint:t,response:o})=>oe.get(`${t}${n.fingerprint}`,async({request:r})=>{if(e){let s=new URL(r.url);e({reqBody:{},url:s})}return re.json(o??{},{status:200})});import{faker as Be}from"@faker-js/faker";import{http as se,HttpResponse as ne}from"msw";import{faker as a}from"@faker-js/faker";var S=(e={})=>({ad_token:a.string.uuid(),object_id:a.string.uuid(),product_id:a.number.int(),store_id:a.number.int(),...e}),D=(e={})=>({headline:a.company.catchPhrase(),image_url:a.image.url(),intended_display:a.helpers.arrayElement(Object.values(j)),logo_url:a.internet.url(),overlay_color:a.color.rgb(),position_x:a.number.int({max:100,min:0}),position_y:a.number.int({max:100,min:0}),scale_number:a.number.float({max:2,min:.5}),text_color:a.color.rgb(),...e}),p=(e={})=>{let{products:t=[S()],...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,s=o??t,c=a.string.uuid(),P=a.datatype.boolean(),u=a.string.uuid(),k=a.string.uuid(),f=a.string.uuid(),g=a.number.int(),b=a.number.int(),d=`${s}${n.click}`,y=`${s}${n.impression}`;return{clickPayload:{adToken:c,distinctId:u,isAddToCart:P,janeDeviceId:u,kevelToken:k,myHighD:f,productId:g,storeId:b},clickUrl:d,impressPayload:{distinctId:u,engagements:[{adToken:c,kevelToken:k,myHighD:f,productId:g}],janeDeviceId:u},impressUrl:y,isSponsored:!1,objectId:a.string.uuid(),...r}},A=(e={})=>({object_id:a.string.uuid(),...e}),v=(e={})=>({products:[A()],...e}),O=(e={creativeIds:[],endpoint:"http://localhost:4242",searchFacets:{},title:a.company.catchPhrase()})=>{let{cachedProducts:t=[x()],endpoint:o="http://localhost:4242",eventsEndpoint:r,config:s=h({endpoint:o,eventsEndpoint:r??o}),creativeIds:c=[],customImages:P=[],placement:u="menu_dynamic_row",products:k=[M()],searchFacets:f={},title:g=a.company.catchPhrase(),...b}=e,{totalProducts:d=t.length+k.length}=b,y=`${o}${n.page}`;return{cachedProducts:t,config:s,creativeIds:c,customImages:P,nextPageProps:{pageSize:60,searchAttributes:["*"]},nextPageUrl:y,placement:u,products:k,searchFacets:f,title:g,totalProducts:d}};var E=e=>{let{callback:t,endpoint:o,placements:r=[p({placement:"menu_top_row"}),p({placement:"menu_dynamic_row"}),p({placement:"menu_inline"})]}=e;return se.post(`${o}${n.multi}`,async({request:s})=>{let c=await s.json();return t&&t({reqBody:c,url:new URL(s.url)}),ne.json({placements:r},{status:200})})};import{http as Le,HttpResponse as qe}from"msw";import{http as ae,HttpResponse as ce}from"msw";var V=e=>{let{callback:t,endpoint:o,product:r=S()}=e;return ae.post(`${o}${n.product}`,async({request:s})=>{let c=await s.json();return t&&t({reqBody:c,url:new URL(s.url)}),ce.json(r,{status:200})})};import{faker as l}from"@faker-js/faker";import{http as ie,HttpResponse as pe}from"msw";var N=(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}),U=(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}),L=(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}),q=(e={})=>({average_rating:4.5,distribution:{1:1,2:2,3:5,4:10,5:20},review_count:38,...e}),ue=(e={})=>({aggregate:q(),product_id:123,reviews:[L()],total_count:1,...e}),H=({callback:e,endpoint:t,response:o})=>ie.post(`${t}${n.productReviews}`,async({request:r})=>{if(e){let s=new URL(r.url),c=await r.json();e({reqBody:c,url:s})}return pe.json(ue(o),{status:200})});import{http as de,HttpResponse as le}from"msw";var Q=(e,t)=>de.post(`${e}${n.sessionEvent}`,async({request:o})=>{if(t){let r=new URL(o.url),s=await o.json();t({reqBody:s,url:r})}return le.json({},{status:200})});import{http as J,HttpResponse as m}from"msw";var K=e=>{let{callback:t,endpoint:o,...r}=e;if(!Object.values(r).some(d=>d!==void 0)){let d=Object.keys(r).join(", ");throw new Error(`At least one of [${d}] must be defined in props.`)}let{cartToppers:c,customImageRow:P,menuRow:u,menuTopRow:k,pdpRow:f,recommendedRow:g,recommendedSort:b}=r;return J.post(`${o}${n.smart}`,async({request:d})=>{let y=await d.json();if(t){let i=new URL(d.url);t({reqBody:y,url:i})}let{placement:R}=y;if(R==="cart_toppers"&&c){let i=p(c);return m.json(i,{status:200})}if(R==="menu_inline"&&u){let i=p(u);return m.json(i,{status:200})}if(R==="menu_inline_table"&&b){let i=p(b);return m.json(i,{status:200})}if(R==="menu_dynamic_row"&&g){let i=p(g);return m.json(i,{status:200})}if(R==="custom_image_row"&&P){let i=p(P);return m.json(i,{status:200})}if(R==="menu_top_row"&&k){let i=p(k);return m.json(i,{status:200})}if(R==="pdp_row"&&f){let i=p(f);return m.json(i,{status:200})}return m.text("Invalid placement",{status:400})})},Z=(e={endpoint:"https://the.weed.shop",response:{}})=>{let{callback:t,endpoint:o,response:r}=e,s=v(r);return J.post(`${o}${n.page}`,async({request:c})=>{if(t){let P=new URL(c.url),u=await c.json();t({reqBody:u,url:P})}return m.json(s,{status:200})})};import{http as z,HttpResponse as G}from"msw";var me=(e=[])=>({queries:e}),Pe=(e={})=>({htmlResponse:"<p>Here are some products to help you sleep...</p>",markdownResponse:"Here are some products to help you sleep...",products:[],query:"help me sleep",totalResults:0,unformattedResponse:"Here are some products to help you sleep...",...e}),W=({callback:e,endpoint:t,queries:o})=>z.post(`${t}${n.virtualBudtenderQueries}`,async({request:r})=>{if(e){let s=new URL(r.url),c=await r.json();e({reqBody:c,url:s})}return G.json(me(o),{status:200})}),X=({callback:e,endpoint:t,response:o})=>z.post(`${t}${n.virtualBudtenderSearch}`,async({request:r})=>{if(e){let s=new URL(r.url),c=await r.json();e({reqBody:c,url:s})}return G.json(Pe(o),{status:200})});export{D as buildCustomImageData,S as buildProduct,N as buildProductReview,U as buildProductReviewsAggregate,p as buildProductsPlacementResponse,M as buildSmartSortProductProps,O as buildSmartSortProps,I as mockClick,$ as mockFacets,V as mockFetchProduct,H as mockFetchProductReviews,F as mockFingerprint,T as mockImpression,E as mockMultiFeaturedPlacements,Q as mockSessionEvent,Z as mockSmartSortPage,K as mockSmartSortPlacements,W as mockVirtualBudtenderQueries,X as mockVirtualBudtenderSearch};
|
package/package.json
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@iheartjane/dm-sdk",
|
|
3
|
+
"version": "2.24.1",
|
|
4
|
+
"description": "Jane's Digital Merchandising Tool",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "@janetechinc",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"require": "./dist/index.cjs"
|
|
12
|
+
},
|
|
13
|
+
"./test-utils": {
|
|
14
|
+
"import": "./dist/test-utils.js",
|
|
15
|
+
"require": "./dist/test-utils.cjs"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/iheartjane/dm-sdk.git",
|
|
21
|
+
"directory": "packages/sdk"
|
|
22
|
+
},
|
|
23
|
+
"sideEffects": false,
|
|
24
|
+
"main": "dist/index.cjs",
|
|
25
|
+
"module": "dist/index.js",
|
|
26
|
+
"types": "dist/index.d.ts",
|
|
27
|
+
"files": [
|
|
28
|
+
"dist",
|
|
29
|
+
"test-utils"
|
|
30
|
+
],
|
|
31
|
+
"scripts": {
|
|
32
|
+
"prebuild": "npm run clean",
|
|
33
|
+
"build": "tsup",
|
|
34
|
+
"postbuild": "attw --pack . && publint",
|
|
35
|
+
"clean": "rm -rf dist test-utils",
|
|
36
|
+
"prepack": "tsx scripts/generateSubpathDirectories",
|
|
37
|
+
"postpack": "rm -rf test-utils",
|
|
38
|
+
"typecheck": "tsc --build"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@fingerprintjs/fingerprintjs-pro": "^3.12.11",
|
|
42
|
+
"nanoid": "^5.1.5"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@faker-js/faker": "^10.0.0",
|
|
46
|
+
"msw": "^2.14.6",
|
|
47
|
+
"typescript": "^6.0.3"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"@faker-js/faker": "^9.0.0 || ^10.0.0",
|
|
51
|
+
"msw": "^2.0.0",
|
|
52
|
+
"typescript": "^5.0.0 || ^6.0.0"
|
|
53
|
+
},
|
|
54
|
+
"peerDependenciesMeta": {
|
|
55
|
+
"@faker-js/faker": {
|
|
56
|
+
"optional": true
|
|
57
|
+
},
|
|
58
|
+
"msw": {
|
|
59
|
+
"optional": true
|
|
60
|
+
},
|
|
61
|
+
"typescript": {
|
|
62
|
+
"optional": true
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"engines": {
|
|
66
|
+
"node": "^22.11.0 || ^24.0.0"
|
|
67
|
+
}
|
|
68
|
+
}
|