@faststore/api 1.12.7 → 1.12.12

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.
@@ -5,6 +5,7 @@ export declare type SearchEvent = {
5
5
  misspelled: boolean;
6
6
  match: number;
7
7
  operator: 'and' | 'or';
8
+ locale: string;
8
9
  session?: string;
9
10
  anonymous?: string;
10
11
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faststore/api",
3
- "version": "1.12.7",
3
+ "version": "1.12.12",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -46,5 +46,5 @@
46
46
  "peerDependencies": {
47
47
  "graphql": "^15.6.0"
48
48
  },
49
- "gitHead": "864263fb8c6a7e3a49d0c724039545f9759c8559"
49
+ "gitHead": "9ef2cae11e8ae9458675d0fbfdcabe0eac0c8860"
50
50
  }
@@ -37,6 +37,7 @@ export type SearchEvent = {
37
37
  misspelled: boolean
38
38
  match: number
39
39
  operator: 'and' | 'or'
40
+ locale: string
40
41
  session?: string
41
42
  anonymous?: string
42
43
  }
@@ -50,10 +51,8 @@ export const SP = ({ account }: Options, _: Context) => {
50
51
  body: JSON.stringify({
51
52
  ...options,
52
53
  agent: '@faststore/api',
53
- anonymous: user.anonymous(),
54
- session: user.session(),
55
- // session: 'zZlNhqz1vFJP6iPG5Oqtt',
56
- // anonymous: 'Om1TNluGvgmSgU5OOTvkkd',
54
+ anonymous: user.anonymous(), // 'zZlNhqz1vFJP6iPG5Oqtt'
55
+ session: user.session(), // 'Om1TNluGvgmSgU5OOTvkkd'
57
56
  }),
58
57
  headers: {
59
58
  'content-type': 'application/json',
@@ -53,6 +53,22 @@ export const Query = {
53
53
 
54
54
  const sku = await skuLoader.load(skuId)
55
55
 
56
+ /**
57
+ * Here be dragons 🦄🦄🦄
58
+ *
59
+ * In some cases, the slug has a valid skuId for a different
60
+ * product. This condition makes sure that the fetched sku
61
+ * is the one we actually asked for
62
+ * */
63
+ if (
64
+ slug && sku.isVariantOf.linkText &&
65
+ !slug.startsWith(sku.isVariantOf.linkText)
66
+ ) {
67
+ throw new Error(
68
+ `Slug was set but the fetched sku does not satisfy the slug condition. slug: ${slug}, linkText: ${sku.isVariantOf.linkText}`,
69
+ )
70
+ }
71
+
56
72
  return sku
57
73
  } catch (err) {
58
74
  if (slug == null) {
@@ -60,6 +60,7 @@ export const StoreSearchResult: Record<string, Resolver<Root>> = {
60
60
  misspelled: products.correction?.misspelled ?? false,
61
61
  match: products.recordsFiltered,
62
62
  operator: products.operator,
63
+ locale: ctx.storage.locale,
63
64
  }).catch(console.error)
64
65
  }
65
66