@astralweb/nova-recently-viewed 1.0.0 → 1.0.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/LICENSE +17 -16
- package/README.md +96 -233
- package/dist/module.d.mts +5 -0
- package/dist/module.json +12 -0
- package/dist/module.mjs +26 -0
- package/dist/{api → runtime/api}/extendMiddleware.d.ts +4 -5
- package/dist/runtime/api/extendMiddleware.js +64 -0
- package/dist/runtime/api/index.d.ts +1 -0
- package/dist/runtime/api/index.js +1 -0
- package/dist/runtime/composables/index.d.ts +3 -0
- package/dist/runtime/composables/index.js +3 -0
- package/dist/runtime/composables/useRecentlyViewedApi.d.ts +5 -0
- package/dist/runtime/composables/useRecentlyViewedApi.js +21 -0
- package/dist/runtime/composables/useRecentlyViewedList.d.ts +2 -0
- package/dist/runtime/composables/useRecentlyViewedList.js +67 -0
- package/dist/runtime/composables/useRecentlyViewedStorage.d.ts +3 -0
- package/dist/runtime/composables/useRecentlyViewedStorage.js +133 -0
- package/dist/runtime/index.d.ts +3 -0
- package/dist/runtime/index.js +3 -0
- package/dist/runtime/server/tsconfig.json +3 -0
- package/dist/{types → runtime/types}/api.d.ts +0 -1
- package/dist/runtime/types/api.js +0 -0
- package/dist/{types → runtime/types}/composables.d.ts +11 -3
- package/dist/runtime/types/composables.js +0 -0
- package/dist/runtime/types/index.d.ts +2 -0
- package/dist/runtime/types/index.js +2 -0
- package/dist/types.d.mts +7 -0
- package/package.json +50 -60
- package/dist/api/extendMiddleware.d.ts.map +0 -1
- package/dist/api/index.d.ts +0 -4
- package/dist/api/index.d.ts.map +0 -1
- package/dist/api/queryFields.d.ts +0 -3
- package/dist/api/queryFields.d.ts.map +0 -1
- package/dist/api/web.d.ts +0 -27
- package/dist/api/web.d.ts.map +0 -1
- package/dist/api.cjs +0 -46
- package/dist/api.js +0 -2201
- package/dist/chunks/useRecentlyViewed-BMqCM4G9.js +0 -1
- package/dist/chunks/useRecentlyViewed-DmIwibiG.js +0 -96
- package/dist/chunks/web-DMlcd6E0.js +0 -1
- package/dist/chunks/web-WoqqfD6L.js +0 -26
- package/dist/composables/index.d.ts +0 -2
- package/dist/composables/index.d.ts.map +0 -1
- package/dist/composables/useRecentlyViewed.d.ts +0 -7
- package/dist/composables/useRecentlyViewed.d.ts.map +0 -1
- package/dist/composables.cjs +0 -1
- package/dist/composables.js +0 -4
- package/dist/index.cjs +0 -1
- package/dist/index.d.ts +0 -4
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -14
- package/dist/types/api.d.ts.map +0 -1
- package/dist/types/composables.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -3
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types.cjs +0 -1
- package/dist/types.js +0 -1
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ref,
|
|
3
|
+
watch,
|
|
4
|
+
onMounted,
|
|
5
|
+
nextTick
|
|
6
|
+
} from "vue";
|
|
7
|
+
import { useRecentlyViewedStorage } from "./useRecentlyViewedStorage.js";
|
|
8
|
+
export function useRecentlyViewedList(options) {
|
|
9
|
+
const {
|
|
10
|
+
currentSku,
|
|
11
|
+
isLoggedIn,
|
|
12
|
+
autoInit = true,
|
|
13
|
+
...config
|
|
14
|
+
} = options;
|
|
15
|
+
const recentlyViewedSkus = ref([]);
|
|
16
|
+
const {
|
|
17
|
+
addRecentlyViewed,
|
|
18
|
+
getRecentlyViewedSkus,
|
|
19
|
+
getSkusFromLocalStorage,
|
|
20
|
+
mergeGuestToCustomer
|
|
21
|
+
} = useRecentlyViewedStorage(config, isLoggedIn);
|
|
22
|
+
const initialize = async () => {
|
|
23
|
+
const sku = currentSku.value;
|
|
24
|
+
if (!sku) return;
|
|
25
|
+
try {
|
|
26
|
+
if (isLoggedIn.value) {
|
|
27
|
+
await mergeGuestToCustomer();
|
|
28
|
+
await addRecentlyViewed(sku);
|
|
29
|
+
recentlyViewedSkus.value = getSkusFromLocalStorage(sku);
|
|
30
|
+
} else {
|
|
31
|
+
recentlyViewedSkus.value = await getRecentlyViewedSkus(sku);
|
|
32
|
+
await addRecentlyViewed(sku);
|
|
33
|
+
}
|
|
34
|
+
} catch (error) {
|
|
35
|
+
throw new Error(`[useRecentlyViewedList] Initialize failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const handleLoginUpdate = async () => {
|
|
39
|
+
const sku = currentSku.value;
|
|
40
|
+
if (!sku) return;
|
|
41
|
+
try {
|
|
42
|
+
await mergeGuestToCustomer();
|
|
43
|
+
const newSkus = await getRecentlyViewedSkus(sku);
|
|
44
|
+
recentlyViewedSkus.value = newSkus;
|
|
45
|
+
await nextTick();
|
|
46
|
+
} catch (error) {
|
|
47
|
+
throw new Error(`[useRecentlyViewedList] Login update failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
watch(isLoggedIn, async (newIsLoggedIn, oldIsLoggedIn) => {
|
|
51
|
+
if (newIsLoggedIn && !oldIsLoggedIn) {
|
|
52
|
+
try {
|
|
53
|
+
await handleLoginUpdate();
|
|
54
|
+
} catch (error) {
|
|
55
|
+
throw new Error(`[useRecentlyViewedList] Failed to update after login: ${error instanceof Error ? error.message : String(error)}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}, { immediate: false });
|
|
59
|
+
if (autoInit) {
|
|
60
|
+
onMounted(() => {
|
|
61
|
+
initialize();
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
recentlyViewedSkus
|
|
66
|
+
};
|
|
67
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type ComputedRef } from 'vue';
|
|
2
|
+
import type { RecentlyViewedConfig, UseRecentlyViewedStorageReturn } from '../types/index.js';
|
|
3
|
+
export declare function useRecentlyViewedStorage(config: RecentlyViewedConfig | undefined, isLoggedIn: ComputedRef<boolean>): UseRecentlyViewedStorageReturn;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { computed } from "vue";
|
|
2
|
+
import { useRecentlyViewedApi } from "./useRecentlyViewedApi.js";
|
|
3
|
+
const STORAGE_KEYS = {
|
|
4
|
+
GUEST: "recently_viewed_products_guest",
|
|
5
|
+
CUSTOMER: "recently_viewed_products_customer"
|
|
6
|
+
};
|
|
7
|
+
const DEFAULT_VALUES = {
|
|
8
|
+
MAX_ITEMS: 20
|
|
9
|
+
};
|
|
10
|
+
const TIME_CONVERSION = {
|
|
11
|
+
JS_TO_SERVER_DIVISOR: 1e3,
|
|
12
|
+
// JavaScript timestamp 轉 Unix timestamp
|
|
13
|
+
SERVER_TO_JS_MULTIPLIER: 1e3
|
|
14
|
+
// Unix timestamp 轉 JavaScript timestamp
|
|
15
|
+
};
|
|
16
|
+
const DEFAULT_CONFIG = {
|
|
17
|
+
maxItems: DEFAULT_VALUES.MAX_ITEMS,
|
|
18
|
+
guestStorageKey: STORAGE_KEYS.GUEST,
|
|
19
|
+
customerStorageKey: STORAGE_KEYS.CUSTOMER,
|
|
20
|
+
enableServerSync: true
|
|
21
|
+
};
|
|
22
|
+
export function useRecentlyViewedStorage(config = {}, isLoggedIn) {
|
|
23
|
+
const finalConfig = { ...DEFAULT_CONFIG, ...config };
|
|
24
|
+
const api = useRecentlyViewedApi();
|
|
25
|
+
const currentStorageKey = computed(() => isLoggedIn.value ? finalConfig.customerStorageKey : finalConfig.guestStorageKey);
|
|
26
|
+
const isBrowser = () => typeof window !== "undefined" && typeof localStorage !== "undefined";
|
|
27
|
+
const toServerTimestamp = (jsTimestamp) => Math.floor(jsTimestamp / TIME_CONVERSION.JS_TO_SERVER_DIVISOR);
|
|
28
|
+
const toJSTimestamp = (serverTimestamp) => serverTimestamp * TIME_CONVERSION.SERVER_TO_JS_MULTIPLIER;
|
|
29
|
+
const readLocalStorage = (key) => {
|
|
30
|
+
if (!isBrowser()) return [];
|
|
31
|
+
try {
|
|
32
|
+
const raw = localStorage.getItem(key);
|
|
33
|
+
const parsed = JSON.parse(raw ?? "[]");
|
|
34
|
+
return Array.isArray(parsed) ? parsed : [];
|
|
35
|
+
} catch {
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const writeLocalStorage = (key, items) => {
|
|
40
|
+
if (!isBrowser()) return;
|
|
41
|
+
localStorage.setItem(key, JSON.stringify(items));
|
|
42
|
+
};
|
|
43
|
+
const addToLocalStorage = (sku) => {
|
|
44
|
+
const items = readLocalStorage(currentStorageKey.value);
|
|
45
|
+
const filteredItems = items.filter((item) => item.sku !== sku);
|
|
46
|
+
filteredItems.unshift({ sku, viewedAt: Date.now() });
|
|
47
|
+
writeLocalStorage(currentStorageKey.value, filteredItems.slice(0, finalConfig.maxItems));
|
|
48
|
+
};
|
|
49
|
+
const getSkusFromLocalStorage = (excludeSku) => {
|
|
50
|
+
const items = readLocalStorage(currentStorageKey.value);
|
|
51
|
+
const seenSkus = /* @__PURE__ */ new Set();
|
|
52
|
+
const result = [];
|
|
53
|
+
for (const item of items) {
|
|
54
|
+
if (!item?.sku || typeof item.sku !== "string") continue;
|
|
55
|
+
const sku = item.sku;
|
|
56
|
+
if (!seenSkus.has(sku) && sku !== excludeSku) {
|
|
57
|
+
seenSkus.add(sku);
|
|
58
|
+
result.push(sku);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return result.slice(0, finalConfig.maxItems);
|
|
62
|
+
};
|
|
63
|
+
const addRecentlyViewed = async (sku) => {
|
|
64
|
+
if (!sku || typeof sku !== "string") return;
|
|
65
|
+
if (isLoggedIn.value && finalConfig.enableServerSync) {
|
|
66
|
+
try {
|
|
67
|
+
await api.syncToServer([
|
|
68
|
+
{
|
|
69
|
+
product_sku: sku,
|
|
70
|
+
viewed_at: toServerTimestamp(Date.now())
|
|
71
|
+
}
|
|
72
|
+
]);
|
|
73
|
+
addToLocalStorage(sku);
|
|
74
|
+
} catch (error) {
|
|
75
|
+
addToLocalStorage(sku);
|
|
76
|
+
throw new Error(`Failed to sync to server: ${error instanceof Error ? error.message : String(error)}`);
|
|
77
|
+
}
|
|
78
|
+
} else {
|
|
79
|
+
addToLocalStorage(sku);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
const getRecentlyViewedSkus = async (excludeSku) => {
|
|
83
|
+
if (isLoggedIn.value && finalConfig.enableServerSync) {
|
|
84
|
+
try {
|
|
85
|
+
const items = await api.fetchFromServer();
|
|
86
|
+
if (items && items.length > 0) {
|
|
87
|
+
const localItems = items.map((item) => ({
|
|
88
|
+
sku: item.product_sku,
|
|
89
|
+
viewedAt: toJSTimestamp(item.viewed_at)
|
|
90
|
+
}));
|
|
91
|
+
writeLocalStorage(currentStorageKey.value, localItems);
|
|
92
|
+
return items.map((item) => item.product_sku).filter((sku) => sku && sku !== excludeSku);
|
|
93
|
+
}
|
|
94
|
+
return getSkusFromLocalStorage(excludeSku);
|
|
95
|
+
} catch {
|
|
96
|
+
return getSkusFromLocalStorage(excludeSku);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return getSkusFromLocalStorage(excludeSku);
|
|
100
|
+
};
|
|
101
|
+
const mergeGuestToCustomer = async () => {
|
|
102
|
+
if (!isLoggedIn.value || !finalConfig.enableServerSync) return;
|
|
103
|
+
const guestItems = readLocalStorage(finalConfig.guestStorageKey);
|
|
104
|
+
if (guestItems.length === 0) return;
|
|
105
|
+
const toBackfill = guestItems.filter((item) => item?.sku).map((item) => ({
|
|
106
|
+
product_sku: item.sku,
|
|
107
|
+
viewed_at: toServerTimestamp(item.viewedAt)
|
|
108
|
+
}));
|
|
109
|
+
if (isBrowser()) {
|
|
110
|
+
localStorage.removeItem(finalConfig.guestStorageKey);
|
|
111
|
+
}
|
|
112
|
+
if (toBackfill.length > 0) {
|
|
113
|
+
try {
|
|
114
|
+
await api.syncToServer(toBackfill);
|
|
115
|
+
} catch (error) {
|
|
116
|
+
throw new Error(`Failed to backfill guest data: ${error instanceof Error ? error.message : String(error)}`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
const clearAllRecentlyViewed = () => {
|
|
121
|
+
if (!isBrowser()) return;
|
|
122
|
+
localStorage.removeItem(STORAGE_KEYS.GUEST);
|
|
123
|
+
localStorage.removeItem(STORAGE_KEYS.CUSTOMER);
|
|
124
|
+
};
|
|
125
|
+
return {
|
|
126
|
+
addRecentlyViewed,
|
|
127
|
+
getRecentlyViewedSkus,
|
|
128
|
+
getSkusFromLocalStorage,
|
|
129
|
+
clearAllRecentlyViewed,
|
|
130
|
+
mergeGuestToCustomer,
|
|
131
|
+
isLoggedIn
|
|
132
|
+
};
|
|
133
|
+
}
|
|
File without changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ComputedRef } from 'vue';
|
|
1
|
+
import type { ComputedRef, Ref } from 'vue';
|
|
2
2
|
export interface RecentlyViewedItem {
|
|
3
3
|
sku: string;
|
|
4
4
|
viewedAt: number;
|
|
@@ -9,11 +9,19 @@ export interface RecentlyViewedConfig {
|
|
|
9
9
|
customerStorageKey?: string;
|
|
10
10
|
enableServerSync?: boolean;
|
|
11
11
|
}
|
|
12
|
-
export interface
|
|
12
|
+
export interface UseRecentlyViewedStorageReturn {
|
|
13
13
|
addRecentlyViewed: (sku: string) => Promise<void>;
|
|
14
14
|
getRecentlyViewedSkus: (excludeSku?: string) => Promise<string[]>;
|
|
15
|
+
getSkusFromLocalStorage: (excludeSku?: string) => string[];
|
|
15
16
|
clearAllRecentlyViewed: () => void;
|
|
16
17
|
mergeGuestToCustomer: () => Promise<void>;
|
|
17
18
|
isLoggedIn: ComputedRef<boolean>;
|
|
18
19
|
}
|
|
19
|
-
|
|
20
|
+
export interface UseRecentlyViewedListOptions extends RecentlyViewedConfig {
|
|
21
|
+
currentSku: Ref<string> | ComputedRef<string>;
|
|
22
|
+
isLoggedIn: ComputedRef<boolean>;
|
|
23
|
+
autoInit?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface UseRecentlyViewedListReturn {
|
|
26
|
+
recentlyViewedSkus: Ref<string[]>;
|
|
27
|
+
}
|
|
File without changes
|
package/dist/types.d.mts
ADDED
package/package.json
CHANGED
|
@@ -1,95 +1,85 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astralweb/nova-recently-viewed",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Recently Viewed module for Nova e-commerce platform
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Recently Viewed module for Nova e-commerce platform (Internal Use Only)",
|
|
5
|
+
"license": "Proprietary",
|
|
5
6
|
"type": "module",
|
|
6
|
-
"main": "dist/index.cjs",
|
|
7
|
-
"module": "dist/index.js",
|
|
8
|
-
"types": "dist/index.d.ts",
|
|
9
7
|
"exports": {
|
|
10
8
|
".": {
|
|
11
|
-
"types": "./dist/
|
|
12
|
-
"import": "./dist/
|
|
13
|
-
"require": "./dist/index.cjs"
|
|
9
|
+
"types": "./dist/module.d.mts",
|
|
10
|
+
"import": "./dist/module.mjs"
|
|
14
11
|
},
|
|
15
12
|
"./api": {
|
|
16
|
-
"types": "./dist/api/index.d.ts",
|
|
17
|
-
"import": "./dist/api.js"
|
|
18
|
-
"require": "./dist/api.cjs"
|
|
19
|
-
},
|
|
20
|
-
"./types": {
|
|
21
|
-
"types": "./dist/types/index.d.ts",
|
|
22
|
-
"import": "./dist/types.js",
|
|
23
|
-
"require": "./dist/types.cjs"
|
|
13
|
+
"types": "./dist/runtime/api/index.d.ts",
|
|
14
|
+
"import": "./dist/runtime/api/index.js"
|
|
24
15
|
},
|
|
25
16
|
"./composables": {
|
|
26
|
-
"types": "./dist/composables/index.d.ts",
|
|
27
|
-
"import": "./dist/composables.js"
|
|
28
|
-
|
|
17
|
+
"types": "./dist/runtime/composables/index.d.ts",
|
|
18
|
+
"import": "./dist/runtime/composables/index.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"main": "./dist/module.mjs",
|
|
22
|
+
"typesVersions": {
|
|
23
|
+
"*": {
|
|
24
|
+
".": [
|
|
25
|
+
"./dist/types.d.mts"
|
|
26
|
+
]
|
|
29
27
|
}
|
|
30
28
|
},
|
|
31
29
|
"files": [
|
|
32
30
|
"dist"
|
|
33
31
|
],
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@nuxt/kit": "^4.1.3"
|
|
34
|
+
},
|
|
34
35
|
"peerDependencies": {
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"vue": "^3.
|
|
36
|
+
"@vue-storefront/magento-api": "^6.3.0",
|
|
37
|
+
"@vue-storefront/middleware": "^5.4.0",
|
|
38
|
+
"@vue-storefront/sdk": "^3.2.0",
|
|
39
|
+
"nuxt": "^3.0.0 || ^4.0.0"
|
|
38
40
|
},
|
|
39
41
|
"devDependencies": {
|
|
40
|
-
"@
|
|
41
|
-
"@
|
|
42
|
-
"@
|
|
43
|
-
"@
|
|
44
|
-
"@
|
|
45
|
-
"@
|
|
46
|
-
"eslint": "^9.
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"stylelint": "^16.23.1",
|
|
50
|
-
"terser": "^5.43.1",
|
|
51
|
-
"tsup": "^8.0.0",
|
|
52
|
-
"typescript": "^5.8.2",
|
|
53
|
-
"vite": "^7.1.11",
|
|
54
|
-
"vite-plugin-css-injected-by-js": "^3.5.2",
|
|
55
|
-
"vite-plugin-dts": "^4.3.0",
|
|
42
|
+
"@nuxt/devtools": "^2.6.5",
|
|
43
|
+
"@nuxt/eslint-config": "^1.9.0",
|
|
44
|
+
"@nuxt/module-builder": "^1.0.2",
|
|
45
|
+
"@nuxt/schema": "^4.1.3",
|
|
46
|
+
"@nuxt/test-utils": "^3.19.2",
|
|
47
|
+
"@types/node": "latest",
|
|
48
|
+
"eslint": "^9.37.0",
|
|
49
|
+
"nuxt": "^4.1.3",
|
|
50
|
+
"typescript": "^5.9.3",
|
|
56
51
|
"vitest": "^3.2.4",
|
|
57
|
-
"vue-tsc": "^
|
|
58
|
-
|
|
59
|
-
"publishConfig": {
|
|
60
|
-
"access": "public"
|
|
52
|
+
"vue-tsc": "^3.1.1",
|
|
53
|
+
"@astralweb/eslint-config": "1.0.6"
|
|
61
54
|
},
|
|
62
55
|
"repository": {
|
|
63
56
|
"type": "git",
|
|
64
57
|
"url": "https://github.com/AstralWebTW/nova-packages",
|
|
65
|
-
"directory": "packages/recently-viewed"
|
|
58
|
+
"directory": "packages/recently-viewed-product"
|
|
66
59
|
},
|
|
67
60
|
"keywords": [
|
|
68
|
-
"recently-viewed",
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"nuxt"
|
|
61
|
+
"recently-viewed-product",
|
|
62
|
+
"magento",
|
|
63
|
+
"nuxt-module"
|
|
72
64
|
],
|
|
73
65
|
"author": "Astral Web",
|
|
74
|
-
"
|
|
75
|
-
"homepage": "https://github.com/AstralWebTW/nova-packages/tree/main/packages/recently-viewed",
|
|
66
|
+
"homepage": "https://github.com/AstralWebTW/nova-packages/tree/main/packages/recently-viewed-product",
|
|
76
67
|
"engines": {
|
|
77
68
|
"node": ">=20.0.0",
|
|
78
69
|
"pnpm": ">=10.0.0"
|
|
79
70
|
},
|
|
80
71
|
"scripts": {
|
|
81
|
-
"build": "
|
|
82
|
-
"
|
|
72
|
+
"build:prepare": "nuxt-module-build prepare && nuxi prepare playground",
|
|
73
|
+
"build": "nuxt-module-build build",
|
|
74
|
+
"dev": "pnpm run dev:prepare && nuxi dev playground",
|
|
75
|
+
"dev:build": "nuxi build playground",
|
|
76
|
+
"dev:preview": "nuxi preview playground --port 3001",
|
|
77
|
+
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
|
|
83
78
|
"typecheck": "tsc --noEmit",
|
|
84
|
-
"
|
|
85
|
-
"lint": "eslint
|
|
86
|
-
"lint:fix": "eslint src/ --fix",
|
|
87
|
-
"lint:types": "tsc --noEmit && eslint .",
|
|
79
|
+
"lint": "eslint .",
|
|
80
|
+
"lint:fix": "eslint . --fix",
|
|
88
81
|
"test": "vitest run",
|
|
89
|
-
"test:watch": "vitest",
|
|
90
|
-
"test:
|
|
91
|
-
"test:coverage": "vitest run --coverage",
|
|
92
|
-
"test:typecheck": "vitest typecheck",
|
|
93
|
-
"ci": "pnpm typecheck && pnpm lint && pnpm test && pnpm build"
|
|
82
|
+
"test:watch": "vitest watch",
|
|
83
|
+
"test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit"
|
|
94
84
|
}
|
|
95
85
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extendMiddleware.d.ts","sourceRoot":"","sources":["../../src/api/extendMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAe,MAAM,qBAAqB,CAAC;AAC1E,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAEnE,OAAO,KAAK,EACV,0BAA0B,EAC1B,yBAAyB,EAC1B,MAAM,SAAS,CAAC;AAYjB;;GAEG;AACH,eAAO,MAAM,sBAAsB,GACjC,SAAS,OAAO,EAChB,WAAW,OAAO,KACjB,OAAO,CAAC,iBAAiB,CAAC;IAAE,sBAAsB,EAAE,0BAA0B,EAAE,CAAC;CAAE,CAAC,CAoBtF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,yBAAyB,GACpC,SAAS,OAAO,EAChB,WAAW,OAAO,KACjB,OAAO,CAAC,iBAAiB,CAAC;IAAE,yBAAyB,EAAE,yBAAyB,CAAC;CAAE,CAAC,CAoBtF,CAAC"}
|
package/dist/api/index.d.ts
DELETED
package/dist/api/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,OAAO,CAAC;AACtB,cAAc,oBAAoB,CAAC"}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export declare const recentlyViewedProductsFields = "\n recently_viewed_products {\n product_sku\n viewed_at\n }\n";
|
|
2
|
-
export declare const addRecentlyViewedProductsFields = "\n add_recently_viewed_products(input: $input) {\n success\n message\n }\n";
|
|
3
|
-
//# sourceMappingURL=queryFields.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"queryFields.d.ts","sourceRoot":"","sources":["../../src/api/queryFields.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,4BAA4B,0EAKxC,CAAC;AAEF,eAAO,MAAM,+BAA+B,uFAK3C,CAAC"}
|
package/dist/api/web.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { WithoutContext } from '@vue-storefront/middleware';
|
|
2
|
-
import { AddRecentlyViewedInputItem, AddRecentlyViewedResponse } from '../types';
|
|
3
|
-
import type * as extensionApiMethods from '../api/extendMiddleware';
|
|
4
|
-
type ExtensionEndpoints = WithoutContext<typeof extensionApiMethods>;
|
|
5
|
-
export interface SdkInstance {
|
|
6
|
-
magento: ExtensionEndpoints;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* 設定 SDK
|
|
10
|
-
* @param sdk SDK 實例
|
|
11
|
-
*/
|
|
12
|
-
export declare function setSdk(sdk: SdkInstance): void;
|
|
13
|
-
/**
|
|
14
|
-
* 獲取 SDK
|
|
15
|
-
* @returns SDK 實例
|
|
16
|
-
*/
|
|
17
|
-
export declare function getSdk(): SdkInstance;
|
|
18
|
-
/**
|
|
19
|
-
* 獲取最近瀏覽商品列表
|
|
20
|
-
*/
|
|
21
|
-
export declare const fetchRecentlyViewedWeb: () => Promise<AddRecentlyViewedInputItem[]>;
|
|
22
|
-
/**
|
|
23
|
-
* 添加商品到最近瀏覽列表
|
|
24
|
-
*/
|
|
25
|
-
export declare const addRecentlyViewedWeb: (input: AddRecentlyViewedInputItem[]) => Promise<AddRecentlyViewedResponse>;
|
|
26
|
-
export {};
|
|
27
|
-
//# sourceMappingURL=web.d.ts.map
|
package/dist/api/web.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../../src/api/web.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,KAAK,mBAAmB,MAAM,yBAAyB,CAAC;AACpE,OAAO,KAAK,EACV,0BAA0B,EAC1B,yBAAyB,EAC1B,MAAM,UAAU,CAAC;AAElB,KAAK,kBAAkB,GAAG,cAAc,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAErE,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,kBAAkB,CAAC;CAC7B;AAID;;;GAGG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,CAE7C;AAED;;;GAGG;AACH,wBAAgB,MAAM,IAAI,WAAW,CAKpC;AAED;;GAEG;AACH,eAAO,MAAM,sBAAsB,QAAa,OAAO,CAAC,0BAA0B,EAAE,CAQnF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,oBAAoB,GAC/B,OAAO,0BAA0B,EAAE,KAClC,OAAO,CAAC,yBAAyB,CAQnC,CAAC"}
|
package/dist/api.cjs
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("./chunks/web-DMlcd6E0.js"),ne=`
|
|
2
|
-
recently_viewed_products {
|
|
3
|
-
product_sku
|
|
4
|
-
viewed_at
|
|
5
|
-
}
|
|
6
|
-
`,ie=`
|
|
7
|
-
add_recently_viewed_products(input: $input) {
|
|
8
|
-
success
|
|
9
|
-
message
|
|
10
|
-
}
|
|
11
|
-
`;var k=function(){return k=Object.assign||function(t){for(var n,s=1,i=arguments.length;s<i;s++){n=arguments[s];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},k.apply(this,arguments)};function F(e,t){if(!!!e)throw new Error(t)}function se(e){return typeof e=="object"&&e!==null}function re(e,t){if(!!!e)throw new Error("Unexpected invariant triggered.")}const oe=/\r\n|[\n\r]/g;function P(e,t){let n=0,s=1;for(const i of e.body.matchAll(oe)){if(typeof i.index=="number"||re(!1),i.index>=t)break;n=i.index+i[0].length,s+=1}return{line:s,column:t+1-n}}function ae(e){return G(e.source,P(e.source,e.start))}function G(e,t){const n=e.locationOffset.column-1,s="".padStart(n)+e.body,i=t.line-1,r=e.locationOffset.line-1,a=t.line+r,u=t.line===1?n:0,l=t.column+u,E=`${e.name}:${a}:${l}
|
|
12
|
-
`,h=s.split(/\r\n|[\n\r]/g),N=h[i];if(N.length>120){const m=Math.floor(l/80),L=l%80,f=[];for(let x=0;x<N.length;x+=80)f.push(N.slice(x,x+80));return E+B([[`${a} |`,f[0]],...f.slice(1,m+1).map(x=>["|",x]),["|","^".padStart(L)],["|",f[m+1]]])}return E+B([[`${a-1} |`,h[i-1]],[`${a} |`,N],["|","^".padStart(l)],[`${a+1} |`,h[i+1]]])}function B(e){const t=e.filter(([s,i])=>i!==void 0),n=Math.max(...t.map(([s])=>s.length));return t.map(([s,i])=>s.padStart(n)+(i?" "+i:"")).join(`
|
|
13
|
-
`)}function ce(e){const t=e[0];return t==null||"kind"in t||"length"in t?{nodes:t,source:e[1],positions:e[2],path:e[3],originalError:e[4],extensions:e[5]}:t}class U extends Error{constructor(t,...n){var s,i,r;const{nodes:a,source:u,positions:l,path:E,originalError:h,extensions:N}=ce(n);super(t),this.name="GraphQLError",this.path=E??void 0,this.originalError=h??void 0,this.nodes=j(Array.isArray(a)?a:a?[a]:void 0);const m=j((s=this.nodes)===null||s===void 0?void 0:s.map(f=>f.loc).filter(f=>f!=null));this.source=u??(m==null||(i=m[0])===null||i===void 0?void 0:i.source),this.positions=l??m?.map(f=>f.start),this.locations=l&&u?l.map(f=>P(u,f)):m?.map(f=>P(f.source,f.start));const L=se(h?.extensions)?h?.extensions:void 0;this.extensions=(r=N??L)!==null&&r!==void 0?r:Object.create(null),Object.defineProperties(this,{message:{writable:!0,enumerable:!0},name:{enumerable:!1},nodes:{enumerable:!1},source:{enumerable:!1},positions:{enumerable:!1},originalError:{enumerable:!1}}),h!=null&&h.stack?Object.defineProperty(this,"stack",{value:h.stack,writable:!0,configurable:!0}):Error.captureStackTrace?Error.captureStackTrace(this,U):Object.defineProperty(this,"stack",{value:Error().stack,writable:!0,configurable:!0})}get[Symbol.toStringTag](){return"GraphQLError"}toString(){let t=this.message;if(this.nodes)for(const n of this.nodes)n.loc&&(t+=`
|
|
14
|
-
|
|
15
|
-
`+ae(n.loc));else if(this.source&&this.locations)for(const n of this.locations)t+=`
|
|
16
|
-
|
|
17
|
-
`+G(this.source,n);return t}toJSON(){const t={message:this.message};return this.locations!=null&&(t.locations=this.locations),this.path!=null&&(t.path=this.path),this.extensions!=null&&Object.keys(this.extensions).length>0&&(t.extensions=this.extensions),t}}function j(e){return e===void 0||e.length===0?void 0:e}function d(e,t,n){return new U(`Syntax Error: ${n}`,{source:e,positions:[t]})}class ue{constructor(t,n,s){this.start=t.start,this.end=n.end,this.startToken=t,this.endToken=n,this.source=s}get[Symbol.toStringTag](){return"Location"}toJSON(){return{start:this.start,end:this.end}}}class Y{constructor(t,n,s,i,r,a){this.kind=t,this.start=n,this.end=s,this.line=i,this.column=r,this.value=a,this.prev=null,this.next=null}get[Symbol.toStringTag](){return"Token"}toJSON(){return{kind:this.kind,value:this.value,line:this.line,column:this.column}}}const le={Name:[],Document:["definitions"],OperationDefinition:["name","variableDefinitions","directives","selectionSet"],VariableDefinition:["variable","type","defaultValue","directives"],Variable:["name"],SelectionSet:["selections"],Field:["alias","name","arguments","directives","selectionSet"],Argument:["name","value"],FragmentSpread:["name","directives"],InlineFragment:["typeCondition","directives","selectionSet"],FragmentDefinition:["name","variableDefinitions","typeCondition","directives","selectionSet"],IntValue:[],FloatValue:[],StringValue:[],BooleanValue:[],NullValue:[],EnumValue:[],ListValue:["values"],ObjectValue:["fields"],ObjectField:["name","value"],Directive:["name","arguments"],NamedType:["name"],ListType:["type"],NonNullType:["type"],SchemaDefinition:["description","directives","operationTypes"],OperationTypeDefinition:["type"],ScalarTypeDefinition:["description","name","directives"],ObjectTypeDefinition:["description","name","interfaces","directives","fields"],FieldDefinition:["description","name","arguments","type","directives"],InputValueDefinition:["description","name","type","defaultValue","directives"],InterfaceTypeDefinition:["description","name","interfaces","directives","fields"],UnionTypeDefinition:["description","name","directives","types"],EnumTypeDefinition:["description","name","directives","values"],EnumValueDefinition:["description","name","directives"],InputObjectTypeDefinition:["description","name","directives","fields"],DirectiveDefinition:["description","name","arguments","locations"],SchemaExtension:["directives","operationTypes"],ScalarTypeExtension:["name","directives"],ObjectTypeExtension:["name","interfaces","directives","fields"],InterfaceTypeExtension:["name","interfaces","directives","fields"],UnionTypeExtension:["name","directives","types"],EnumTypeExtension:["name","directives","values"],InputObjectTypeExtension:["name","directives","fields"]};new Set(Object.keys(le));var y;(function(e){e.QUERY="query",e.MUTATION="mutation",e.SUBSCRIPTION="subscription"})(y||(y={}));var V;(function(e){e.QUERY="QUERY",e.MUTATION="MUTATION",e.SUBSCRIPTION="SUBSCRIPTION",e.FIELD="FIELD",e.FRAGMENT_DEFINITION="FRAGMENT_DEFINITION",e.FRAGMENT_SPREAD="FRAGMENT_SPREAD",e.INLINE_FRAGMENT="INLINE_FRAGMENT",e.VARIABLE_DEFINITION="VARIABLE_DEFINITION",e.SCHEMA="SCHEMA",e.SCALAR="SCALAR",e.OBJECT="OBJECT",e.FIELD_DEFINITION="FIELD_DEFINITION",e.ARGUMENT_DEFINITION="ARGUMENT_DEFINITION",e.INTERFACE="INTERFACE",e.UNION="UNION",e.ENUM="ENUM",e.ENUM_VALUE="ENUM_VALUE",e.INPUT_OBJECT="INPUT_OBJECT",e.INPUT_FIELD_DEFINITION="INPUT_FIELD_DEFINITION"})(V||(V={}));var c;(function(e){e.NAME="Name",e.DOCUMENT="Document",e.OPERATION_DEFINITION="OperationDefinition",e.VARIABLE_DEFINITION="VariableDefinition",e.SELECTION_SET="SelectionSet",e.FIELD="Field",e.ARGUMENT="Argument",e.FRAGMENT_SPREAD="FragmentSpread",e.INLINE_FRAGMENT="InlineFragment",e.FRAGMENT_DEFINITION="FragmentDefinition",e.VARIABLE="Variable",e.INT="IntValue",e.FLOAT="FloatValue",e.STRING="StringValue",e.BOOLEAN="BooleanValue",e.NULL="NullValue",e.ENUM="EnumValue",e.LIST="ListValue",e.OBJECT="ObjectValue",e.OBJECT_FIELD="ObjectField",e.DIRECTIVE="Directive",e.NAMED_TYPE="NamedType",e.LIST_TYPE="ListType",e.NON_NULL_TYPE="NonNullType",e.SCHEMA_DEFINITION="SchemaDefinition",e.OPERATION_TYPE_DEFINITION="OperationTypeDefinition",e.SCALAR_TYPE_DEFINITION="ScalarTypeDefinition",e.OBJECT_TYPE_DEFINITION="ObjectTypeDefinition",e.FIELD_DEFINITION="FieldDefinition",e.INPUT_VALUE_DEFINITION="InputValueDefinition",e.INTERFACE_TYPE_DEFINITION="InterfaceTypeDefinition",e.UNION_TYPE_DEFINITION="UnionTypeDefinition",e.ENUM_TYPE_DEFINITION="EnumTypeDefinition",e.ENUM_VALUE_DEFINITION="EnumValueDefinition",e.INPUT_OBJECT_TYPE_DEFINITION="InputObjectTypeDefinition",e.DIRECTIVE_DEFINITION="DirectiveDefinition",e.SCHEMA_EXTENSION="SchemaExtension",e.SCALAR_TYPE_EXTENSION="ScalarTypeExtension",e.OBJECT_TYPE_EXTENSION="ObjectTypeExtension",e.INTERFACE_TYPE_EXTENSION="InterfaceTypeExtension",e.UNION_TYPE_EXTENSION="UnionTypeExtension",e.ENUM_TYPE_EXTENSION="EnumTypeExtension",e.INPUT_OBJECT_TYPE_EXTENSION="InputObjectTypeExtension"})(c||(c={}));function pe(e){return e===9||e===32}function g(e){return e>=48&&e<=57}function J(e){return e>=97&&e<=122||e>=65&&e<=90}function q(e){return J(e)||e===95}function he(e){return J(e)||g(e)||e===95}function de(e){var t;let n=Number.MAX_SAFE_INTEGER,s=null,i=-1;for(let a=0;a<e.length;++a){var r;const u=e[a],l=fe(u);l!==u.length&&(s=(r=s)!==null&&r!==void 0?r:a,i=a,a!==0&&l<n&&(n=l))}return e.map((a,u)=>u===0?a:a.slice(n)).slice((t=s)!==null&&t!==void 0?t:0,i+1)}function fe(e){let t=0;for(;t<e.length&&pe(e.charCodeAt(t));)++t;return t}var o;(function(e){e.SOF="<SOF>",e.EOF="<EOF>",e.BANG="!",e.DOLLAR="$",e.AMP="&",e.PAREN_L="(",e.PAREN_R=")",e.SPREAD="...",e.COLON=":",e.EQUALS="=",e.AT="@",e.BRACKET_L="[",e.BRACKET_R="]",e.BRACE_L="{",e.PIPE="|",e.BRACE_R="}",e.NAME="Name",e.INT="Int",e.FLOAT="Float",e.STRING="String",e.BLOCK_STRING="BlockString",e.COMMENT="Comment"})(o||(o={}));class Ee{constructor(t){const n=new Y(o.SOF,0,0,0,0);this.source=t,this.lastToken=n,this.token=n,this.line=1,this.lineStart=0}get[Symbol.toStringTag](){return"Lexer"}advance(){return this.lastToken=this.token,this.token=this.lookahead()}lookahead(){let t=this.token;if(t.kind!==o.EOF)do if(t.next)t=t.next;else{const n=Ne(this,t.end);t.next=n,n.prev=t,t=n}while(t.kind===o.COMMENT);return t}}function me(e){return e===o.BANG||e===o.DOLLAR||e===o.AMP||e===o.PAREN_L||e===o.PAREN_R||e===o.SPREAD||e===o.COLON||e===o.EQUALS||e===o.AT||e===o.BRACKET_L||e===o.BRACKET_R||e===o.BRACE_L||e===o.PIPE||e===o.BRACE_R}function O(e){return e>=0&&e<=55295||e>=57344&&e<=1114111}function b(e,t){return X(e.charCodeAt(t))&&Q(e.charCodeAt(t+1))}function X(e){return e>=55296&&e<=56319}function Q(e){return e>=56320&&e<=57343}function T(e,t){const n=e.source.body.codePointAt(t);if(n===void 0)return o.EOF;if(n>=32&&n<=126){const s=String.fromCodePoint(n);return s==='"'?`'"'`:`"${s}"`}return"U+"+n.toString(16).toUpperCase().padStart(4,"0")}function p(e,t,n,s,i){const r=e.line,a=1+n-e.lineStart;return new Y(t,n,s,r,a,i)}function Ne(e,t){const n=e.source.body,s=n.length;let i=t;for(;i<s;){const r=n.charCodeAt(i);switch(r){case 65279:case 9:case 32:case 44:++i;continue;case 10:++i,++e.line,e.lineStart=i;continue;case 13:n.charCodeAt(i+1)===10?i+=2:++i,++e.line,e.lineStart=i;continue;case 35:return Te(e,i);case 33:return p(e,o.BANG,i,i+1);case 36:return p(e,o.DOLLAR,i,i+1);case 38:return p(e,o.AMP,i,i+1);case 40:return p(e,o.PAREN_L,i,i+1);case 41:return p(e,o.PAREN_R,i,i+1);case 46:if(n.charCodeAt(i+1)===46&&n.charCodeAt(i+2)===46)return p(e,o.SPREAD,i,i+3);break;case 58:return p(e,o.COLON,i,i+1);case 61:return p(e,o.EQUALS,i,i+1);case 64:return p(e,o.AT,i,i+1);case 91:return p(e,o.BRACKET_L,i,i+1);case 93:return p(e,o.BRACKET_R,i,i+1);case 123:return p(e,o.BRACE_L,i,i+1);case 124:return p(e,o.PIPE,i,i+1);case 125:return p(e,o.BRACE_R,i,i+1);case 34:return n.charCodeAt(i+1)===34&&n.charCodeAt(i+2)===34?Ae(e,i):xe(e,i)}if(g(r)||r===45)return Ie(e,i,r);if(q(r))return ge(e,i);throw d(e.source,i,r===39?`Unexpected single quote character ('), did you mean to use a double quote (")?`:O(r)||b(n,i)?`Unexpected character: ${T(e,i)}.`:`Invalid character: ${T(e,i)}.`)}return p(e,o.EOF,s,s)}function Te(e,t){const n=e.source.body,s=n.length;let i=t+1;for(;i<s;){const r=n.charCodeAt(i);if(r===10||r===13)break;if(O(r))++i;else if(b(n,i))i+=2;else break}return p(e,o.COMMENT,t,i,n.slice(t+1,i))}function Ie(e,t,n){const s=e.source.body;let i=t,r=n,a=!1;if(r===45&&(r=s.charCodeAt(++i)),r===48){if(r=s.charCodeAt(++i),g(r))throw d(e.source,i,`Invalid number, unexpected digit after 0: ${T(e,i)}.`)}else i=w(e,i,r),r=s.charCodeAt(i);if(r===46&&(a=!0,r=s.charCodeAt(++i),i=w(e,i,r),r=s.charCodeAt(i)),(r===69||r===101)&&(a=!0,r=s.charCodeAt(++i),(r===43||r===45)&&(r=s.charCodeAt(++i)),i=w(e,i,r),r=s.charCodeAt(i)),r===46||q(r))throw d(e.source,i,`Invalid number, expected digit but got: ${T(e,i)}.`);return p(e,a?o.FLOAT:o.INT,t,i,s.slice(t,i))}function w(e,t,n){if(!g(n))throw d(e.source,t,`Invalid number, expected digit but got: ${T(e,t)}.`);const s=e.source.body;let i=t+1;for(;g(s.charCodeAt(i));)++i;return i}function xe(e,t){const n=e.source.body,s=n.length;let i=t+1,r=i,a="";for(;i<s;){const u=n.charCodeAt(i);if(u===34)return a+=n.slice(r,i),p(e,o.STRING,t,i+1,a);if(u===92){a+=n.slice(r,i);const l=n.charCodeAt(i+1)===117?n.charCodeAt(i+2)===123?ye(e,i):Oe(e,i):_e(e,i);a+=l.value,i+=l.size,r=i;continue}if(u===10||u===13)break;if(O(u))++i;else if(b(n,i))i+=2;else throw d(e.source,i,`Invalid character within String: ${T(e,i)}.`)}throw d(e.source,i,"Unterminated string.")}function ye(e,t){const n=e.source.body;let s=0,i=3;for(;i<12;){const r=n.charCodeAt(t+i++);if(r===125){if(i<5||!O(s))break;return{value:String.fromCodePoint(s),size:i}}if(s=s<<4|A(r),s<0)break}throw d(e.source,t,`Invalid Unicode escape sequence: "${n.slice(t,t+i)}".`)}function Oe(e,t){const n=e.source.body,s=$(n,t+2);if(O(s))return{value:String.fromCodePoint(s),size:6};if(X(s)&&n.charCodeAt(t+6)===92&&n.charCodeAt(t+7)===117){const i=$(n,t+8);if(Q(i))return{value:String.fromCodePoint(s,i),size:12}}throw d(e.source,t,`Invalid Unicode escape sequence: "${n.slice(t,t+6)}".`)}function $(e,t){return A(e.charCodeAt(t))<<12|A(e.charCodeAt(t+1))<<8|A(e.charCodeAt(t+2))<<4|A(e.charCodeAt(t+3))}function A(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:-1}function _e(e,t){const n=e.source.body;switch(n.charCodeAt(t+1)){case 34:return{value:'"',size:2};case 92:return{value:"\\",size:2};case 47:return{value:"/",size:2};case 98:return{value:"\b",size:2};case 102:return{value:"\f",size:2};case 110:return{value:`
|
|
18
|
-
`,size:2};case 114:return{value:"\r",size:2};case 116:return{value:" ",size:2}}throw d(e.source,t,`Invalid character escape sequence: "${n.slice(t,t+2)}".`)}function Ae(e,t){const n=e.source.body,s=n.length;let i=e.lineStart,r=t+3,a=r,u="";const l=[];for(;r<s;){const E=n.charCodeAt(r);if(E===34&&n.charCodeAt(r+1)===34&&n.charCodeAt(r+2)===34){u+=n.slice(a,r),l.push(u);const h=p(e,o.BLOCK_STRING,t,r+3,de(l).join(`
|
|
19
|
-
`));return e.line+=l.length-1,e.lineStart=i,h}if(E===92&&n.charCodeAt(r+1)===34&&n.charCodeAt(r+2)===34&&n.charCodeAt(r+3)===34){u+=n.slice(a,r),a=r+1,r+=4;continue}if(E===10||E===13){u+=n.slice(a,r),l.push(u),E===13&&n.charCodeAt(r+1)===10?r+=2:++r,u="",a=r,i=r;continue}if(O(E))++r;else if(b(n,r))r+=2;else throw d(e.source,r,`Invalid character within String: ${T(e,r)}.`)}throw d(e.source,r,"Unterminated string.")}function ge(e,t){const n=e.source.body,s=n.length;let i=t+1;for(;i<s;){const r=n.charCodeAt(i);if(he(r))++i;else break}return p(e,o.NAME,t,i,n.slice(t,i))}const ve=10,z=2;function W(e){return R(e,[])}function R(e,t){switch(typeof e){case"string":return JSON.stringify(e);case"function":return e.name?`[function ${e.name}]`:"[function]";case"object":return De(e,t);default:return String(e)}}function De(e,t){if(e===null)return"null";if(t.includes(e))return"[Circular]";const n=[...t,e];if(ke(e)){const s=e.toJSON();if(s!==e)return typeof s=="string"?s:R(s,n)}else if(Array.isArray(e))return Ce(e,n);return Se(e,n)}function ke(e){return typeof e.toJSON=="function"}function Se(e,t){const n=Object.entries(e);return n.length===0?"{}":t.length>z?"["+be(e)+"]":"{ "+n.map(([i,r])=>i+": "+R(r,t)).join(", ")+" }"}function Ce(e,t){if(e.length===0)return"[]";if(t.length>z)return"[Array]";const n=Math.min(ve,e.length),s=e.length-n,i=[];for(let r=0;r<n;++r)i.push(R(e[r],t));return s===1?i.push("... 1 more item"):s>1&&i.push(`... ${s} more items`),"["+i.join(", ")+"]"}function be(e){const t=Object.prototype.toString.call(e).replace(/^\[object /,"").replace(/]$/,"");if(t==="Object"&&typeof e.constructor=="function"){const n=e.constructor.name;if(typeof n=="string"&&n!=="")return n}return t}const Re=globalThis.process&&process.env.NODE_ENV==="production",Le=Re?function(t,n){return t instanceof n}:function(t,n){if(t instanceof n)return!0;if(typeof t=="object"&&t!==null){var s;const i=n.prototype[Symbol.toStringTag],r=Symbol.toStringTag in t?t[Symbol.toStringTag]:(s=t.constructor)===null||s===void 0?void 0:s.name;if(i===r){const a=W(t);throw new Error(`Cannot use ${i} "${a}" from another module or realm.
|
|
20
|
-
|
|
21
|
-
Ensure that there is only one instance of "graphql" in the node_modules
|
|
22
|
-
directory. If different versions of "graphql" are the dependencies of other
|
|
23
|
-
relied on modules, use "resolutions" to ensure only one version is installed.
|
|
24
|
-
|
|
25
|
-
https://yarnpkg.com/en/docs/selective-version-resolutions
|
|
26
|
-
|
|
27
|
-
Duplicate "graphql" modules cannot be used at the same time since different
|
|
28
|
-
versions may have different capabilities and behavior. The data from one
|
|
29
|
-
version used in the function from another could produce confusing and
|
|
30
|
-
spurious results.`)}}return!1};class H{constructor(t,n="GraphQL request",s={line:1,column:1}){typeof t=="string"||F(!1,`Body must be a string. Received: ${W(t)}.`),this.body=t,this.name=n,this.locationOffset=s,this.locationOffset.line>0||F(!1,"line in locationOffset is 1-indexed and must be positive."),this.locationOffset.column>0||F(!1,"column in locationOffset is 1-indexed and must be positive.")}get[Symbol.toStringTag](){return"Source"}}function Fe(e){return Le(e,H)}function we(e,t){const n=new Pe(e,t),s=n.parseDocument();return Object.defineProperty(s,"tokenCount",{enumerable:!1,value:n.tokenCount}),s}class Pe{constructor(t,n={}){const s=Fe(t)?t:new H(t);this._lexer=new Ee(s),this._options=n,this._tokenCounter=0}get tokenCount(){return this._tokenCounter}parseName(){const t=this.expectToken(o.NAME);return this.node(t,{kind:c.NAME,value:t.value})}parseDocument(){return this.node(this._lexer.token,{kind:c.DOCUMENT,definitions:this.many(o.SOF,this.parseDefinition,o.EOF)})}parseDefinition(){if(this.peek(o.BRACE_L))return this.parseOperationDefinition();const t=this.peekDescription(),n=t?this._lexer.lookahead():this._lexer.token;if(n.kind===o.NAME){switch(n.value){case"schema":return this.parseSchemaDefinition();case"scalar":return this.parseScalarTypeDefinition();case"type":return this.parseObjectTypeDefinition();case"interface":return this.parseInterfaceTypeDefinition();case"union":return this.parseUnionTypeDefinition();case"enum":return this.parseEnumTypeDefinition();case"input":return this.parseInputObjectTypeDefinition();case"directive":return this.parseDirectiveDefinition()}if(t)throw d(this._lexer.source,this._lexer.token.start,"Unexpected description, descriptions are supported only on type definitions.");switch(n.value){case"query":case"mutation":case"subscription":return this.parseOperationDefinition();case"fragment":return this.parseFragmentDefinition();case"extend":return this.parseTypeSystemExtension()}}throw this.unexpected(n)}parseOperationDefinition(){const t=this._lexer.token;if(this.peek(o.BRACE_L))return this.node(t,{kind:c.OPERATION_DEFINITION,operation:y.QUERY,name:void 0,variableDefinitions:[],directives:[],selectionSet:this.parseSelectionSet()});const n=this.parseOperationType();let s;return this.peek(o.NAME)&&(s=this.parseName()),this.node(t,{kind:c.OPERATION_DEFINITION,operation:n,name:s,variableDefinitions:this.parseVariableDefinitions(),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseOperationType(){const t=this.expectToken(o.NAME);switch(t.value){case"query":return y.QUERY;case"mutation":return y.MUTATION;case"subscription":return y.SUBSCRIPTION}throw this.unexpected(t)}parseVariableDefinitions(){return this.optionalMany(o.PAREN_L,this.parseVariableDefinition,o.PAREN_R)}parseVariableDefinition(){return this.node(this._lexer.token,{kind:c.VARIABLE_DEFINITION,variable:this.parseVariable(),type:(this.expectToken(o.COLON),this.parseTypeReference()),defaultValue:this.expectOptionalToken(o.EQUALS)?this.parseConstValueLiteral():void 0,directives:this.parseConstDirectives()})}parseVariable(){const t=this._lexer.token;return this.expectToken(o.DOLLAR),this.node(t,{kind:c.VARIABLE,name:this.parseName()})}parseSelectionSet(){return this.node(this._lexer.token,{kind:c.SELECTION_SET,selections:this.many(o.BRACE_L,this.parseSelection,o.BRACE_R)})}parseSelection(){return this.peek(o.SPREAD)?this.parseFragment():this.parseField()}parseField(){const t=this._lexer.token,n=this.parseName();let s,i;return this.expectOptionalToken(o.COLON)?(s=n,i=this.parseName()):i=n,this.node(t,{kind:c.FIELD,alias:s,name:i,arguments:this.parseArguments(!1),directives:this.parseDirectives(!1),selectionSet:this.peek(o.BRACE_L)?this.parseSelectionSet():void 0})}parseArguments(t){const n=t?this.parseConstArgument:this.parseArgument;return this.optionalMany(o.PAREN_L,n,o.PAREN_R)}parseArgument(t=!1){const n=this._lexer.token,s=this.parseName();return this.expectToken(o.COLON),this.node(n,{kind:c.ARGUMENT,name:s,value:this.parseValueLiteral(t)})}parseConstArgument(){return this.parseArgument(!0)}parseFragment(){const t=this._lexer.token;this.expectToken(o.SPREAD);const n=this.expectOptionalKeyword("on");return!n&&this.peek(o.NAME)?this.node(t,{kind:c.FRAGMENT_SPREAD,name:this.parseFragmentName(),directives:this.parseDirectives(!1)}):this.node(t,{kind:c.INLINE_FRAGMENT,typeCondition:n?this.parseNamedType():void 0,directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseFragmentDefinition(){const t=this._lexer.token;return this.expectKeyword("fragment"),this._options.allowLegacyFragmentVariables===!0?this.node(t,{kind:c.FRAGMENT_DEFINITION,name:this.parseFragmentName(),variableDefinitions:this.parseVariableDefinitions(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()}):this.node(t,{kind:c.FRAGMENT_DEFINITION,name:this.parseFragmentName(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseFragmentName(){if(this._lexer.token.value==="on")throw this.unexpected();return this.parseName()}parseValueLiteral(t){const n=this._lexer.token;switch(n.kind){case o.BRACKET_L:return this.parseList(t);case o.BRACE_L:return this.parseObject(t);case o.INT:return this.advanceLexer(),this.node(n,{kind:c.INT,value:n.value});case o.FLOAT:return this.advanceLexer(),this.node(n,{kind:c.FLOAT,value:n.value});case o.STRING:case o.BLOCK_STRING:return this.parseStringLiteral();case o.NAME:switch(this.advanceLexer(),n.value){case"true":return this.node(n,{kind:c.BOOLEAN,value:!0});case"false":return this.node(n,{kind:c.BOOLEAN,value:!1});case"null":return this.node(n,{kind:c.NULL});default:return this.node(n,{kind:c.ENUM,value:n.value})}case o.DOLLAR:if(t)if(this.expectToken(o.DOLLAR),this._lexer.token.kind===o.NAME){const s=this._lexer.token.value;throw d(this._lexer.source,n.start,`Unexpected variable "$${s}" in constant value.`)}else throw this.unexpected(n);return this.parseVariable();default:throw this.unexpected()}}parseConstValueLiteral(){return this.parseValueLiteral(!0)}parseStringLiteral(){const t=this._lexer.token;return this.advanceLexer(),this.node(t,{kind:c.STRING,value:t.value,block:t.kind===o.BLOCK_STRING})}parseList(t){const n=()=>this.parseValueLiteral(t);return this.node(this._lexer.token,{kind:c.LIST,values:this.any(o.BRACKET_L,n,o.BRACKET_R)})}parseObject(t){const n=()=>this.parseObjectField(t);return this.node(this._lexer.token,{kind:c.OBJECT,fields:this.any(o.BRACE_L,n,o.BRACE_R)})}parseObjectField(t){const n=this._lexer.token,s=this.parseName();return this.expectToken(o.COLON),this.node(n,{kind:c.OBJECT_FIELD,name:s,value:this.parseValueLiteral(t)})}parseDirectives(t){const n=[];for(;this.peek(o.AT);)n.push(this.parseDirective(t));return n}parseConstDirectives(){return this.parseDirectives(!0)}parseDirective(t){const n=this._lexer.token;return this.expectToken(o.AT),this.node(n,{kind:c.DIRECTIVE,name:this.parseName(),arguments:this.parseArguments(t)})}parseTypeReference(){const t=this._lexer.token;let n;if(this.expectOptionalToken(o.BRACKET_L)){const s=this.parseTypeReference();this.expectToken(o.BRACKET_R),n=this.node(t,{kind:c.LIST_TYPE,type:s})}else n=this.parseNamedType();return this.expectOptionalToken(o.BANG)?this.node(t,{kind:c.NON_NULL_TYPE,type:n}):n}parseNamedType(){return this.node(this._lexer.token,{kind:c.NAMED_TYPE,name:this.parseName()})}peekDescription(){return this.peek(o.STRING)||this.peek(o.BLOCK_STRING)}parseDescription(){if(this.peekDescription())return this.parseStringLiteral()}parseSchemaDefinition(){const t=this._lexer.token,n=this.parseDescription();this.expectKeyword("schema");const s=this.parseConstDirectives(),i=this.many(o.BRACE_L,this.parseOperationTypeDefinition,o.BRACE_R);return this.node(t,{kind:c.SCHEMA_DEFINITION,description:n,directives:s,operationTypes:i})}parseOperationTypeDefinition(){const t=this._lexer.token,n=this.parseOperationType();this.expectToken(o.COLON);const s=this.parseNamedType();return this.node(t,{kind:c.OPERATION_TYPE_DEFINITION,operation:n,type:s})}parseScalarTypeDefinition(){const t=this._lexer.token,n=this.parseDescription();this.expectKeyword("scalar");const s=this.parseName(),i=this.parseConstDirectives();return this.node(t,{kind:c.SCALAR_TYPE_DEFINITION,description:n,name:s,directives:i})}parseObjectTypeDefinition(){const t=this._lexer.token,n=this.parseDescription();this.expectKeyword("type");const s=this.parseName(),i=this.parseImplementsInterfaces(),r=this.parseConstDirectives(),a=this.parseFieldsDefinition();return this.node(t,{kind:c.OBJECT_TYPE_DEFINITION,description:n,name:s,interfaces:i,directives:r,fields:a})}parseImplementsInterfaces(){return this.expectOptionalKeyword("implements")?this.delimitedMany(o.AMP,this.parseNamedType):[]}parseFieldsDefinition(){return this.optionalMany(o.BRACE_L,this.parseFieldDefinition,o.BRACE_R)}parseFieldDefinition(){const t=this._lexer.token,n=this.parseDescription(),s=this.parseName(),i=this.parseArgumentDefs();this.expectToken(o.COLON);const r=this.parseTypeReference(),a=this.parseConstDirectives();return this.node(t,{kind:c.FIELD_DEFINITION,description:n,name:s,arguments:i,type:r,directives:a})}parseArgumentDefs(){return this.optionalMany(o.PAREN_L,this.parseInputValueDef,o.PAREN_R)}parseInputValueDef(){const t=this._lexer.token,n=this.parseDescription(),s=this.parseName();this.expectToken(o.COLON);const i=this.parseTypeReference();let r;this.expectOptionalToken(o.EQUALS)&&(r=this.parseConstValueLiteral());const a=this.parseConstDirectives();return this.node(t,{kind:c.INPUT_VALUE_DEFINITION,description:n,name:s,type:i,defaultValue:r,directives:a})}parseInterfaceTypeDefinition(){const t=this._lexer.token,n=this.parseDescription();this.expectKeyword("interface");const s=this.parseName(),i=this.parseImplementsInterfaces(),r=this.parseConstDirectives(),a=this.parseFieldsDefinition();return this.node(t,{kind:c.INTERFACE_TYPE_DEFINITION,description:n,name:s,interfaces:i,directives:r,fields:a})}parseUnionTypeDefinition(){const t=this._lexer.token,n=this.parseDescription();this.expectKeyword("union");const s=this.parseName(),i=this.parseConstDirectives(),r=this.parseUnionMemberTypes();return this.node(t,{kind:c.UNION_TYPE_DEFINITION,description:n,name:s,directives:i,types:r})}parseUnionMemberTypes(){return this.expectOptionalToken(o.EQUALS)?this.delimitedMany(o.PIPE,this.parseNamedType):[]}parseEnumTypeDefinition(){const t=this._lexer.token,n=this.parseDescription();this.expectKeyword("enum");const s=this.parseName(),i=this.parseConstDirectives(),r=this.parseEnumValuesDefinition();return this.node(t,{kind:c.ENUM_TYPE_DEFINITION,description:n,name:s,directives:i,values:r})}parseEnumValuesDefinition(){return this.optionalMany(o.BRACE_L,this.parseEnumValueDefinition,o.BRACE_R)}parseEnumValueDefinition(){const t=this._lexer.token,n=this.parseDescription(),s=this.parseEnumValueName(),i=this.parseConstDirectives();return this.node(t,{kind:c.ENUM_VALUE_DEFINITION,description:n,name:s,directives:i})}parseEnumValueName(){if(this._lexer.token.value==="true"||this._lexer.token.value==="false"||this._lexer.token.value==="null")throw d(this._lexer.source,this._lexer.token.start,`${v(this._lexer.token)} is reserved and cannot be used for an enum value.`);return this.parseName()}parseInputObjectTypeDefinition(){const t=this._lexer.token,n=this.parseDescription();this.expectKeyword("input");const s=this.parseName(),i=this.parseConstDirectives(),r=this.parseInputFieldsDefinition();return this.node(t,{kind:c.INPUT_OBJECT_TYPE_DEFINITION,description:n,name:s,directives:i,fields:r})}parseInputFieldsDefinition(){return this.optionalMany(o.BRACE_L,this.parseInputValueDef,o.BRACE_R)}parseTypeSystemExtension(){const t=this._lexer.lookahead();if(t.kind===o.NAME)switch(t.value){case"schema":return this.parseSchemaExtension();case"scalar":return this.parseScalarTypeExtension();case"type":return this.parseObjectTypeExtension();case"interface":return this.parseInterfaceTypeExtension();case"union":return this.parseUnionTypeExtension();case"enum":return this.parseEnumTypeExtension();case"input":return this.parseInputObjectTypeExtension()}throw this.unexpected(t)}parseSchemaExtension(){const t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("schema");const n=this.parseConstDirectives(),s=this.optionalMany(o.BRACE_L,this.parseOperationTypeDefinition,o.BRACE_R);if(n.length===0&&s.length===0)throw this.unexpected();return this.node(t,{kind:c.SCHEMA_EXTENSION,directives:n,operationTypes:s})}parseScalarTypeExtension(){const t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("scalar");const n=this.parseName(),s=this.parseConstDirectives();if(s.length===0)throw this.unexpected();return this.node(t,{kind:c.SCALAR_TYPE_EXTENSION,name:n,directives:s})}parseObjectTypeExtension(){const t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("type");const n=this.parseName(),s=this.parseImplementsInterfaces(),i=this.parseConstDirectives(),r=this.parseFieldsDefinition();if(s.length===0&&i.length===0&&r.length===0)throw this.unexpected();return this.node(t,{kind:c.OBJECT_TYPE_EXTENSION,name:n,interfaces:s,directives:i,fields:r})}parseInterfaceTypeExtension(){const t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("interface");const n=this.parseName(),s=this.parseImplementsInterfaces(),i=this.parseConstDirectives(),r=this.parseFieldsDefinition();if(s.length===0&&i.length===0&&r.length===0)throw this.unexpected();return this.node(t,{kind:c.INTERFACE_TYPE_EXTENSION,name:n,interfaces:s,directives:i,fields:r})}parseUnionTypeExtension(){const t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("union");const n=this.parseName(),s=this.parseConstDirectives(),i=this.parseUnionMemberTypes();if(s.length===0&&i.length===0)throw this.unexpected();return this.node(t,{kind:c.UNION_TYPE_EXTENSION,name:n,directives:s,types:i})}parseEnumTypeExtension(){const t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("enum");const n=this.parseName(),s=this.parseConstDirectives(),i=this.parseEnumValuesDefinition();if(s.length===0&&i.length===0)throw this.unexpected();return this.node(t,{kind:c.ENUM_TYPE_EXTENSION,name:n,directives:s,values:i})}parseInputObjectTypeExtension(){const t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("input");const n=this.parseName(),s=this.parseConstDirectives(),i=this.parseInputFieldsDefinition();if(s.length===0&&i.length===0)throw this.unexpected();return this.node(t,{kind:c.INPUT_OBJECT_TYPE_EXTENSION,name:n,directives:s,fields:i})}parseDirectiveDefinition(){const t=this._lexer.token,n=this.parseDescription();this.expectKeyword("directive"),this.expectToken(o.AT);const s=this.parseName(),i=this.parseArgumentDefs(),r=this.expectOptionalKeyword("repeatable");this.expectKeyword("on");const a=this.parseDirectiveLocations();return this.node(t,{kind:c.DIRECTIVE_DEFINITION,description:n,name:s,arguments:i,repeatable:r,locations:a})}parseDirectiveLocations(){return this.delimitedMany(o.PIPE,this.parseDirectiveLocation)}parseDirectiveLocation(){const t=this._lexer.token,n=this.parseName();if(Object.prototype.hasOwnProperty.call(V,n.value))return n;throw this.unexpected(t)}node(t,n){return this._options.noLocation!==!0&&(n.loc=new ue(t,this._lexer.lastToken,this._lexer.source)),n}peek(t){return this._lexer.token.kind===t}expectToken(t){const n=this._lexer.token;if(n.kind===t)return this.advanceLexer(),n;throw d(this._lexer.source,n.start,`Expected ${Z(t)}, found ${v(n)}.`)}expectOptionalToken(t){return this._lexer.token.kind===t?(this.advanceLexer(),!0):!1}expectKeyword(t){const n=this._lexer.token;if(n.kind===o.NAME&&n.value===t)this.advanceLexer();else throw d(this._lexer.source,n.start,`Expected "${t}", found ${v(n)}.`)}expectOptionalKeyword(t){const n=this._lexer.token;return n.kind===o.NAME&&n.value===t?(this.advanceLexer(),!0):!1}unexpected(t){const n=t??this._lexer.token;return d(this._lexer.source,n.start,`Unexpected ${v(n)}.`)}any(t,n,s){this.expectToken(t);const i=[];for(;!this.expectOptionalToken(s);)i.push(n.call(this));return i}optionalMany(t,n,s){if(this.expectOptionalToken(t)){const i=[];do i.push(n.call(this));while(!this.expectOptionalToken(s));return i}return[]}many(t,n,s){this.expectToken(t);const i=[];do i.push(n.call(this));while(!this.expectOptionalToken(s));return i}delimitedMany(t,n){this.expectOptionalToken(t);const s=[];do s.push(n.call(this));while(this.expectOptionalToken(t));return s}advanceLexer(){const{maxTokens:t}=this._options,n=this._lexer.advance();if(n.kind!==o.EOF&&(++this._tokenCounter,t!==void 0&&this._tokenCounter>t))throw d(this._lexer.source,n.start,`Document contains more that ${t} tokens. Parsing aborted.`)}}function v(e){const t=e.value;return Z(e.kind)+(t!=null?` "${t}"`:"")}function Z(e){return me(e)?`"${e}"`:e}var D=new Map,M=new Map,K=!0,S=!1;function ee(e){return e.replace(/[\s,]+/g," ").trim()}function Ve(e){return ee(e.source.body.substring(e.start,e.end))}function Me(e){var t=new Set,n=[];return e.definitions.forEach(function(s){if(s.kind==="FragmentDefinition"){var i=s.name.value,r=Ve(s.loc),a=M.get(i);a&&!a.has(r)?K&&console.warn("Warning: fragment with name "+i+` already exists.
|
|
31
|
-
graphql-tag enforces all fragment names across your application to be unique; read more about
|
|
32
|
-
this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names`):a||M.set(i,a=new Set),a.add(r),t.has(r)||(t.add(r),n.push(s))}else n.push(s)}),k(k({},e),{definitions:n})}function Ue(e){var t=new Set(e.definitions);t.forEach(function(s){s.loc&&delete s.loc,Object.keys(s).forEach(function(i){var r=s[i];r&&typeof r=="object"&&t.add(r)})});var n=e.loc;return n&&(delete n.startToken,delete n.endToken),e}function Be(e){var t=ee(e);if(!D.has(t)){var n=we(e,{experimentalFragmentVariables:S,allowLegacyFragmentVariables:S});if(!n||n.kind!=="Document")throw new Error("Not a valid GraphQL document.");D.set(t,Ue(Me(n)))}return D.get(t)}function I(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];typeof e=="string"&&(e=[e]);var s=e[0];return t.forEach(function(i,r){i&&i.kind==="Document"?s+=i.loc.source.body:s+=i,s+=e[r+1]}),Be(s)}function je(){D.clear(),M.clear()}function $e(){K=!1}function Ge(){S=!0}function Ye(){S=!1}var _={gql:I,resetCaches:je,disableFragmentWarnings:$e,enableExperimentalFragmentVariables:Ge,disableExperimentalFragmentVariables:Ye};(function(e){e.gql=_.gql,e.resetCaches=_.resetCaches,e.disableFragmentWarnings=_.disableFragmentWarnings,e.enableExperimentalFragmentVariables=_.enableExperimentalFragmentVariables,e.disableExperimentalFragmentVariables=_.disableExperimentalFragmentVariables})(I||(I={}));I.default=I;const te=(e,t={})=>{const{getCustomerToken:n,getStore:s,getCurrency:i}=e.config.state;return{...n()&&{Authorization:`Bearer ${n()}`},...s()&&{store:s()},...i()&&{"Content-Currency":i()},...t}},Je=async(e,t)=>{const{client:n}=e;try{return await n.query({query:I`
|
|
33
|
-
query recentlyViewedProducts {
|
|
34
|
-
recentlyViewedProducts {
|
|
35
|
-
product_sku
|
|
36
|
-
viewed_at
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
`,variables:t,context:{headers:te(e)}})}catch(s){throw s}},qe=async(e,t)=>{const{client:n}=e;try{return await n.mutate({mutation:I`
|
|
40
|
-
mutation addRecentlyViewedProducts($input: [RecentlyViewedProductInput!]!) {
|
|
41
|
-
addRecentlyViewedProducts(input: $input) {
|
|
42
|
-
success
|
|
43
|
-
message
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
`,variables:t,context:{headers:te(e)}})}catch(s){throw s}};exports.addRecentlyViewedWeb=C.addRecentlyViewedWeb;exports.fetchRecentlyViewedWeb=C.fetchRecentlyViewedWeb;exports.getSdk=C.getSdk;exports.setSdk=C.setSdk;exports.addRecentlyViewedProducts=qe;exports.addRecentlyViewedProductsFields=ie;exports.recentlyViewedProducts=Je;exports.recentlyViewedProductsFields=ne;
|