@tapcart/mobile-components 0.7.91 → 0.7.92

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.
@@ -7,7 +7,7 @@ export declare enum NostoRecommendationsType {
7
7
  BEST_SELLERS = "BEST_SELLERS",
8
8
  VIEWED_CATEGORY = "VIEWED_CATEGORY"
9
9
  }
10
- export declare function useNostoRecommendations(integrations: Integrations, baseURL: string, slotId?: string, recommendationsType?: NostoRecommendationsType | "", productIds?: string[], skip?: boolean, mockFallback?: boolean, mockFallbackAppId?: string): {
10
+ export declare function useNostoRecommendations(integrations: Integrations, baseURL: string, slotId?: string, country?: string, recommendationsType?: NostoRecommendationsType | "", productIds?: string[], skip?: boolean, mockFallback?: boolean, mockFallbackAppId?: string): {
11
11
  recommendations: import("app-studio-types").Product[];
12
12
  isLoading: boolean;
13
13
  error: any;
@@ -1 +1 @@
1
- {"version":3,"file":"use-nosto-recommendation.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-nosto-recommendation.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAe/C,oBAAY,wBAAwB;IAClC,eAAe,oBAAoB;IACnC,eAAe,oBAAoB;IACnC,qBAAqB,0BAA0B;IAC/C,WAAW,gBAAgB;IAC3B,YAAY,iBAAiB;IAC7B,eAAe,oBAAoB;CACpC;AAyRD,wBAAgB,uBAAuB,CACrC,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,MAAM,EACf,MAAM,SAAK,EACX,mBAAmB,CAAC,EAAE,wBAAwB,GAAG,EAAE,EACnD,UAAU,CAAC,EAAE,MAAM,EAAE,EACrB,IAAI,CAAC,EAAE,OAAO,EACd,YAAY,CAAC,EAAE,OAAO,EACtB,iBAAiB,CAAC,EAAE,MAAM;;;;;EA4C3B"}
1
+ {"version":3,"file":"use-nosto-recommendation.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-nosto-recommendation.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAe/C,oBAAY,wBAAwB;IAClC,eAAe,oBAAoB;IACnC,eAAe,oBAAoB;IACnC,qBAAqB,0BAA0B;IAC/C,WAAW,gBAAgB;IAC3B,YAAY,iBAAiB;IAC7B,eAAe,oBAAoB;CACpC;AAyRD,wBAAgB,uBAAuB,CACrC,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,MAAM,EACf,MAAM,SAAK,EACX,OAAO,SAAO,EACd,mBAAmB,CAAC,EAAE,wBAAwB,GAAG,EAAE,EACnD,UAAU,CAAC,EAAE,MAAM,EAAE,EACrB,IAAI,CAAC,EAAE,OAAO,EACd,YAAY,CAAC,EAAE,OAAO,EACtB,iBAAiB,CAAC,EAAE,MAAM;;;;;EA6C3B"}
@@ -169,7 +169,7 @@ function useNostoRecommendationsProductIds(nostoKey, slotId = "", recommendation
169
169
  error,
170
170
  };
171
171
  }
172
- export function useNostoRecommendations(integrations, baseURL, slotId = "", recommendationsType, productIds, skip, mockFallback, mockFallbackAppId) {
172
+ export function useNostoRecommendations(integrations, baseURL, slotId = "", country = "US", recommendationsType, productIds, skip, mockFallback, mockFallbackAppId) {
173
173
  var _a;
174
174
  if (recommendationsType === "") {
175
175
  recommendationsType = NostoRecommendationsType.BOUGHT_TOGETHER;
@@ -184,6 +184,7 @@ export function useNostoRecommendations(integrations, baseURL, slotId = "", reco
184
184
  productHandles: [],
185
185
  queryVariables: {
186
186
  appId,
187
+ country: country,
187
188
  },
188
189
  mock: shouldMock,
189
190
  });
@@ -112,7 +112,7 @@ describe("useNostoRecommendations", () => {
112
112
  });
113
113
  it("should return front page recommendations if productIds is empty and slotId is provided", () => __awaiter(void 0, void 0, void 0, function* () {
114
114
  const slotId = "mockSlotId";
115
- const { result } = renderHook(() => useNostoRecommendations(mockIntegrations, mockBaseURL, slotId, undefined, undefined, undefined));
115
+ const { result } = renderHook(() => useNostoRecommendations(mockIntegrations, mockBaseURL, slotId, "US", undefined, undefined, undefined));
116
116
  // Initial state check
117
117
  expect(result.current.isLoading).toBe(true);
118
118
  // Wait for all promises with act
@@ -128,13 +128,14 @@ describe("useNostoRecommendations", () => {
128
128
  productHandles: [],
129
129
  queryVariables: {
130
130
  appId: undefined,
131
+ country: "US",
131
132
  },
132
133
  mock: false,
133
134
  });
134
135
  }));
135
136
  it("should return best sellers recommendations if productIds is empty and slotId is not provided", () => __awaiter(void 0, void 0, void 0, function* () {
136
137
  const slotId = "";
137
- const { result } = renderHook(() => useNostoRecommendations(mockIntegrations, mockBaseURL, slotId, undefined, undefined));
138
+ const { result } = renderHook(() => useNostoRecommendations(mockIntegrations, mockBaseURL, slotId, "US", undefined, undefined));
138
139
  // Initial state check
139
140
  expect(result.current.isLoading).toBe(true);
140
141
  // Wait for all promises with act
@@ -150,6 +151,7 @@ describe("useNostoRecommendations", () => {
150
151
  productHandles: [],
151
152
  queryVariables: {
152
153
  appId: undefined,
154
+ country: "US",
153
155
  },
154
156
  mock: false,
155
157
  });
@@ -157,7 +159,7 @@ describe("useNostoRecommendations", () => {
157
159
  it("should return best sellers recommendations if productIds is not empty, Best Sellers is the recommendation type and slotId is not provided", () => __awaiter(void 0, void 0, void 0, function* () {
158
160
  const slotId = "";
159
161
  const productIds = ["mockProductId"];
160
- const { result } = renderHook(() => useNostoRecommendations(mockIntegrations, mockBaseURL, slotId, NostoRecommendationsType.BEST_SELLERS, productIds));
162
+ const { result } = renderHook(() => useNostoRecommendations(mockIntegrations, mockBaseURL, slotId, "US", NostoRecommendationsType.BEST_SELLERS, productIds));
161
163
  // Initial state check
162
164
  expect(result.current.isLoading).toBe(true);
163
165
  // Wait for all promises with act
@@ -173,13 +175,14 @@ describe("useNostoRecommendations", () => {
173
175
  productHandles: [],
174
176
  queryVariables: {
175
177
  appId: undefined,
178
+ country: "US",
176
179
  },
177
180
  mock: false,
178
181
  });
179
182
  }));
180
183
  it("should return default front page recommendations if slotId is provided but layoutType is not", () => __awaiter(void 0, void 0, void 0, function* () {
181
184
  const slotId = "mockSlotId";
182
- const { result } = renderHook(() => useNostoRecommendations(mockIntegrations, mockBaseURL, slotId));
185
+ const { result } = renderHook(() => useNostoRecommendations(mockIntegrations, mockBaseURL, slotId, "US"));
183
186
  // Initial state check
184
187
  expect(result.current.isLoading).toBe(true);
185
188
  // Wait for all promises with act
@@ -195,12 +198,13 @@ describe("useNostoRecommendations", () => {
195
198
  productHandles: [],
196
199
  queryVariables: {
197
200
  appId: undefined,
201
+ country: "US",
198
202
  },
199
203
  mock: false,
200
204
  });
201
205
  }));
202
206
  it("should return the correct recommendations for best sellers", () => __awaiter(void 0, void 0, void 0, function* () {
203
- const { result } = renderHook(() => useNostoRecommendations(mockIntegrations, mockBaseURL, "", NostoRecommendationsType.BEST_SELLERS, undefined, undefined));
207
+ const { result } = renderHook(() => useNostoRecommendations(mockIntegrations, mockBaseURL, "", "US", NostoRecommendationsType.BEST_SELLERS, undefined, undefined));
204
208
  // Initial state check
205
209
  expect(result.current.isLoading).toBe(true);
206
210
  // Wait for all promises with act
@@ -216,13 +220,14 @@ describe("useNostoRecommendations", () => {
216
220
  productHandles: [],
217
221
  queryVariables: {
218
222
  appId: undefined,
223
+ country: "US",
219
224
  },
220
225
  mock: false,
221
226
  });
222
227
  }));
223
228
  it("should return the related recommendations when only productIds and a recommendation type are provided on a non-home layout", () => __awaiter(void 0, void 0, void 0, function* () {
224
229
  const productIds = ["mockProductId"];
225
- const { result } = renderHook(() => useNostoRecommendations(mockIntegrations, mockBaseURL, "", NostoRecommendationsType.VIEWED_TOGETHER, productIds, undefined));
230
+ const { result } = renderHook(() => useNostoRecommendations(mockIntegrations, mockBaseURL, "", "US", NostoRecommendationsType.VIEWED_TOGETHER, productIds, undefined));
226
231
  // Initial state check
227
232
  expect(result.current.isLoading).toBe(true);
228
233
  // Wait for all promises with act
@@ -238,6 +243,7 @@ describe("useNostoRecommendations", () => {
238
243
  productHandles: [],
239
244
  queryVariables: {
240
245
  appId: undefined,
246
+ country: "US",
241
247
  },
242
248
  mock: false,
243
249
  });
@@ -245,7 +251,7 @@ describe("useNostoRecommendations", () => {
245
251
  it("should return the correct recommendations when productIds and slotIds are provided", () => __awaiter(void 0, void 0, void 0, function* () {
246
252
  const slotId = "mockSlotId";
247
253
  const productIds = ["mockProductId"];
248
- const { result } = renderHook(() => useNostoRecommendations(mockIntegrations, mockBaseURL, slotId, NostoRecommendationsType.VIEWED_TOGETHER, productIds, undefined));
254
+ const { result } = renderHook(() => useNostoRecommendations(mockIntegrations, mockBaseURL, slotId, "US", NostoRecommendationsType.VIEWED_TOGETHER, productIds, undefined));
249
255
  // Initial state check
250
256
  expect(result.current.isLoading).toBe(true);
251
257
  // Wait for all promises with act
@@ -261,13 +267,14 @@ describe("useNostoRecommendations", () => {
261
267
  productHandles: [],
262
268
  queryVariables: {
263
269
  appId: undefined,
270
+ country: "US",
264
271
  },
265
272
  mock: false,
266
273
  });
267
274
  }));
268
275
  it("should return the related products fallback recommendations when productIds are provided and no slotId and a type other than viewed_category and best_sellers is provided", () => __awaiter(void 0, void 0, void 0, function* () {
269
276
  const productIds = ["mockProductId"];
270
- const { result } = renderHook(() => useNostoRecommendations(mockIntegrations, mockBaseURL, "", NostoRecommendationsType.VIEWED_TOGETHER, productIds, undefined));
277
+ const { result } = renderHook(() => useNostoRecommendations(mockIntegrations, mockBaseURL, "", "US", NostoRecommendationsType.VIEWED_TOGETHER, productIds, undefined));
271
278
  // Initial state check
272
279
  expect(result.current.isLoading).toBe(true);
273
280
  // Wait for all promises with act
@@ -283,13 +290,14 @@ describe("useNostoRecommendations", () => {
283
290
  productHandles: [],
284
291
  queryVariables: {
285
292
  appId: undefined,
293
+ country: "US",
286
294
  },
287
295
  mock: false,
288
296
  });
289
297
  }));
290
298
  it("should return the category fallback recommendations when no slotId, productIds are provided and a recommendation type of viewed_category is provided", () => __awaiter(void 0, void 0, void 0, function* () {
291
299
  const productIds = ["mockProductId"];
292
- const { result } = renderHook(() => useNostoRecommendations(mockIntegrations, mockBaseURL, "", NostoRecommendationsType.VIEWED_CATEGORY, productIds, undefined));
300
+ const { result } = renderHook(() => useNostoRecommendations(mockIntegrations, mockBaseURL, "", "US", NostoRecommendationsType.VIEWED_CATEGORY, productIds, undefined));
293
301
  // Initial state check
294
302
  expect(result.current.isLoading).toBe(true);
295
303
  // Wait for all promises with act
@@ -305,12 +313,13 @@ describe("useNostoRecommendations", () => {
305
313
  productHandles: [],
306
314
  queryVariables: {
307
315
  appId: undefined,
316
+ country: "US",
308
317
  },
309
318
  mock: false,
310
319
  });
311
320
  }));
312
321
  it("should handle loading state", () => __awaiter(void 0, void 0, void 0, function* () {
313
- const { result } = renderHook(() => useNostoRecommendations(mockIntegrations, mockBaseURL, ""));
322
+ const { result } = renderHook(() => useNostoRecommendations(mockIntegrations, mockBaseURL, "", "US"));
314
323
  // Check initial loading state
315
324
  expect(result.current.isLoading).toBe(true);
316
325
  // Wait for all state updates to complete
@@ -342,7 +351,7 @@ describe("useNostoRecommendations", () => {
342
351
  }));
343
352
  it("should default to best sellers if productIds are empty but a recommendation type other than Best Sellers is used", () => __awaiter(void 0, void 0, void 0, function* () {
344
353
  const productIds = [];
345
- const { result } = renderHook(() => useNostoRecommendations(mockIntegrations, mockBaseURL, "", NostoRecommendationsType.VIEWED_TOGETHER, productIds, undefined));
354
+ const { result } = renderHook(() => useNostoRecommendations(mockIntegrations, mockBaseURL, "", "US", NostoRecommendationsType.VIEWED_TOGETHER, productIds, undefined));
346
355
  // Initial state check
347
356
  expect(result.current.isLoading).toBe(true);
348
357
  // Wait for all promises with act
@@ -358,12 +367,13 @@ describe("useNostoRecommendations", () => {
358
367
  productHandles: [],
359
368
  queryVariables: {
360
369
  appId: undefined,
370
+ country: "US",
361
371
  },
362
372
  mock: false,
363
373
  });
364
374
  }));
365
375
  it("should return an empty array if skip is true", () => __awaiter(void 0, void 0, void 0, function* () {
366
- const { result } = renderHook(() => useNostoRecommendations(mockIntegrations, mockBaseURL, "", NostoRecommendationsType.BEST_SELLERS, undefined, true));
376
+ const { result } = renderHook(() => useNostoRecommendations(mockIntegrations, mockBaseURL, "", "US", NostoRecommendationsType.BEST_SELLERS, undefined, true));
367
377
  // Initial state check
368
378
  expect(result.current.isLoading).toBe(true);
369
379
  // Wait for all promises with act
@@ -378,6 +388,7 @@ describe("useNostoRecommendations", () => {
378
388
  productHandles: [],
379
389
  queryVariables: {
380
390
  appId: undefined,
391
+ country: "US",
381
392
  },
382
393
  mock: false,
383
394
  });
@@ -12,6 +12,7 @@ type UseProductsProps = {
12
12
  queryVariables?: Record<string, any>;
13
13
  fetcher?: (url: string, body?: Record<string, any> | null) => Promise<any>;
14
14
  metafields?: MetafieldInput[];
15
+ mediaLimit?: number;
15
16
  mock?: boolean;
16
17
  onlyAvailableProducts?: boolean;
17
18
  };
@@ -1 +1 @@
1
- {"version":3,"file":"use-products.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-products.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAI1C,KAAK,GAAG,GAAG,MAAM,CAAA;AACjB,KAAK,cAAc,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAA;AACxD,KAAK,gBAAgB,GAAG;IACtB,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,cAAc,EAAE,MAAM,EAAE,CAAA;IACxB,OAAO,EAAE,GAAG,CAAA;IACZ,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACpC,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;IAC1E,UAAU,CAAC,EAAE,cAAc,EAAE,CAAA;IAC7B,IAAI,CAAC,EAAE,OA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,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI,GAAG,iBAAiB,CA2F7E"}
@@ -19,7 +19,7 @@ const formatProductData = ({ data, onlyAvailableProducts = false, }) => {
19
19
  : products;
20
20
  };
21
21
  export function useProducts(props) {
22
- var _a, _b, _c;
22
+ var _a, _b, _c, _d;
23
23
  let url = null;
24
24
  let body = null;
25
25
  const shouldMockProducts = Boolean(props === null || props === void 0 ? void 0 : props.mock);
@@ -60,6 +60,7 @@ export function useProducts(props) {
60
60
  if (queryVariables === null || queryVariables === void 0 ? void 0 : queryVariables.language) {
61
61
  queryParams.set("language", queryVariables.language);
62
62
  }
63
+ queryParams.set("mediaLimit", (_d = queryVariables === null || queryVariables === void 0 ? void 0 : queryVariables.mediaLimit) !== null && _d !== void 0 ? _d : 10);
63
64
  url = `${baseURL}/products/by-ids?${queryParams.toString()}`;
64
65
  }
65
66
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tapcart/mobile-components",
3
- "version": "0.7.91",
3
+ "version": "0.7.92",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "style": "dist/styles.css",