@scayle/storefront-core 7.26.0 → 7.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/api/oauth.cjs +136 -0
- package/dist/api/oauth.d.ts +57 -0
- package/dist/api/oauth.mjs +125 -0
- package/dist/cache/providers/unstorage.cjs +25 -2
- package/dist/cache/providers/unstorage.d.ts +10 -0
- package/dist/cache/providers/unstorage.mjs +25 -2
- package/dist/constants/basket.cjs +2 -3
- package/dist/constants/cache.cjs +1 -2
- package/dist/constants/hash.cjs +2 -3
- package/dist/constants/httpStatus.cjs +3 -5
- package/dist/constants/product.cjs +2 -3
- package/dist/constants/promotion.cjs +4 -7
- package/dist/constants/sorting.cjs +3 -5
- package/dist/constants/withParameters.cjs +7 -13
- package/dist/helpers/product.fixture.cjs +4 -8
- package/dist/index.cjs +2 -2
- package/dist/rpc/methods/basket/basket.cjs +6 -12
- package/dist/rpc/methods/brands.cjs +3 -5
- package/dist/rpc/methods/categories.cjs +4 -7
- package/dist/rpc/methods/cbd.cjs +4 -9
- package/dist/rpc/methods/cbd.mjs +2 -3
- package/dist/rpc/methods/checkout/order.cjs +5 -8
- package/dist/rpc/methods/checkout/order.mjs +3 -4
- package/dist/rpc/methods/checkout/shopUser.cjs +32 -31
- package/dist/rpc/methods/checkout/shopUser.mjs +18 -23
- package/dist/rpc/methods/checkout/shopUserAddresses.cjs +9 -8
- package/dist/rpc/methods/checkout/shopUserAddresses.mjs +7 -4
- package/dist/rpc/methods/navigationTrees.cjs +3 -5
- package/dist/rpc/methods/products.cjs +6 -12
- package/dist/rpc/methods/promotion.cjs +4 -7
- package/dist/rpc/methods/search.cjs +1 -2
- package/dist/rpc/methods/session.cjs +52 -99
- package/dist/rpc/methods/session.d.ts +9 -4
- package/dist/rpc/methods/session.mjs +62 -139
- package/dist/rpc/methods/shopConfiguration.cjs +2 -3
- package/dist/rpc/methods/user.cjs +24 -21
- package/dist/rpc/methods/user.mjs +20 -13
- package/dist/rpc/methods/variants.cjs +2 -3
- package/dist/rpc/methods/wishlist.cjs +5 -9
- package/dist/types/api/auth.d.ts +9 -4
- package/dist/utils/fetch.cjs +19 -0
- package/dist/utils/fetch.d.ts +9 -0
- package/dist/utils/fetch.mjs +12 -0
- package/dist/utils/index.cjs +11 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.mjs +1 -0
- package/package.json +7 -12
- package/dist/utils/rpc.cjs +0 -41
- package/dist/utils/rpc.d.ts +0 -6
- package/dist/utils/rpc.mjs +0 -35
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @scayle/storefront-core
|
|
2
2
|
|
|
3
|
+
## 7.28.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Use native fetch instead of axios
|
|
8
|
+
|
|
9
|
+
## 7.27.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- Introduce gzip-based compression for unstorage cache interface
|
|
14
|
+
- Upgrade package `@aboutyou/backbone`to `v15.14.3`
|
|
15
|
+
|
|
3
16
|
## 7.26.0
|
|
4
17
|
|
|
5
18
|
### Minor Changes
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.OAuthClient = void 0;
|
|
7
|
+
var _jose = require("jose");
|
|
8
|
+
var _fetch = require("../utils/fetch.cjs");
|
|
9
|
+
var _hash = require("../utils/hash.cjs");
|
|
10
|
+
class MissingCredentialsError extends Error {
|
|
11
|
+
constructor() {
|
|
12
|
+
super("[OAuth API] No credentials configured");
|
|
13
|
+
this.name = "MissingCredentialsError";
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
async function oauthResponseHandler(response) {
|
|
17
|
+
const data = await response.json();
|
|
18
|
+
if (!response.ok) {
|
|
19
|
+
throw new _fetch.FetchError(response, data);
|
|
20
|
+
}
|
|
21
|
+
return data;
|
|
22
|
+
}
|
|
23
|
+
class OAuthClient {
|
|
24
|
+
headers;
|
|
25
|
+
baseURL;
|
|
26
|
+
constructor(options) {
|
|
27
|
+
const {
|
|
28
|
+
clientId,
|
|
29
|
+
clientSecret,
|
|
30
|
+
apiHost
|
|
31
|
+
} = options;
|
|
32
|
+
if (!clientId || !clientSecret) {
|
|
33
|
+
throw new MissingCredentialsError();
|
|
34
|
+
}
|
|
35
|
+
this.baseURL = `${apiHost}/v1`;
|
|
36
|
+
const basicAuthHash = (0, _hash.encodeBase64)(`${clientId}:${clientSecret}`);
|
|
37
|
+
this.headers = {
|
|
38
|
+
Authorization: `Basic ${basicAuthHash}`,
|
|
39
|
+
Accept: "application/json",
|
|
40
|
+
"Content-Type": "application/json"
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Register a user and retrieve a token set
|
|
45
|
+
* @param payload
|
|
46
|
+
*/
|
|
47
|
+
async register(payload) {
|
|
48
|
+
return await fetch(`${this.baseURL}/auth/register`, {
|
|
49
|
+
method: "POST",
|
|
50
|
+
headers: this.headers,
|
|
51
|
+
body: JSON.stringify(payload)
|
|
52
|
+
}).then(oauthResponseHandler);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Execute a user login on the OAuth API and receive a token set
|
|
56
|
+
* @param payload
|
|
57
|
+
*/
|
|
58
|
+
async login(payload) {
|
|
59
|
+
return await fetch(`${this.baseURL}/auth/login`, {
|
|
60
|
+
method: "POST",
|
|
61
|
+
headers: this.headers,
|
|
62
|
+
body: JSON.stringify(payload)
|
|
63
|
+
}).then(oauthResponseHandler);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Execute a guest user login on the OAuth API and receive a token set
|
|
67
|
+
* @param payload
|
|
68
|
+
*/
|
|
69
|
+
async guestLogin(payload) {
|
|
70
|
+
return await fetch(`${this.baseURL}/auth/login/guest`, {
|
|
71
|
+
method: "POST",
|
|
72
|
+
headers: this.headers,
|
|
73
|
+
body: JSON.stringify(payload)
|
|
74
|
+
}).then(oauthResponseHandler);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Send a password reset email
|
|
78
|
+
* @param payload
|
|
79
|
+
*/
|
|
80
|
+
async sendPasswordResetEmail(payload) {
|
|
81
|
+
await fetch(`${this.baseURL}/auth/password/send-reset-email`, {
|
|
82
|
+
method: "POST",
|
|
83
|
+
headers: this.headers,
|
|
84
|
+
body: JSON.stringify(payload)
|
|
85
|
+
}).then(oauthResponseHandler);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Update password by hash
|
|
89
|
+
* @param payload
|
|
90
|
+
*/
|
|
91
|
+
async updatePasswordByHash(payload) {
|
|
92
|
+
return await fetch(`${this.baseURL}/auth/password/update-by-hash`, {
|
|
93
|
+
method: "PUT",
|
|
94
|
+
headers: this.headers,
|
|
95
|
+
body: JSON.stringify(payload)
|
|
96
|
+
}).then(oauthResponseHandler);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Generate a new access token via a refresh token
|
|
100
|
+
* @param payload
|
|
101
|
+
*/
|
|
102
|
+
async refreshToken(payload) {
|
|
103
|
+
return await fetch(`${this.baseURL}/oauth/token`, {
|
|
104
|
+
method: "POST",
|
|
105
|
+
headers: this.headers,
|
|
106
|
+
body: JSON.stringify(payload)
|
|
107
|
+
}).then(oauthResponseHandler);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Validate an access token
|
|
111
|
+
* @param accessToken
|
|
112
|
+
*/
|
|
113
|
+
async validateToken(accessToken) {
|
|
114
|
+
await fetch(`${this.baseURL}/oauth/token/validate`, {
|
|
115
|
+
headers: {
|
|
116
|
+
...headers,
|
|
117
|
+
Authorization: `Bearer ${accessToken}`
|
|
118
|
+
}
|
|
119
|
+
}).then(oauthResponseHandler);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Revoke an access token
|
|
123
|
+
* @param accessToken
|
|
124
|
+
*/
|
|
125
|
+
async revokeToken(accessToken) {
|
|
126
|
+
const decodedAccessToken = (0, _jose.decodeJwt)(accessToken);
|
|
127
|
+
await fetch(`${this.baseURL}/oauth/tokens/${decodedAccessToken.jti}`, {
|
|
128
|
+
method: "DELETE",
|
|
129
|
+
headers: {
|
|
130
|
+
...headers,
|
|
131
|
+
Authorization: `Bearer ${accessToken}`
|
|
132
|
+
}
|
|
133
|
+
}).then(oauthResponseHandler);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
exports.OAuthClient = OAuthClient;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { GuestRequest, LoginRequest, Oauth, RefreshTokenRequest, RegisterRequest, SendResetPasswordEmailRequest, UpdatePasswordByHashRequest } from '../types/api/auth';
|
|
2
|
+
export interface OAuthOptions {
|
|
3
|
+
clientId: string;
|
|
4
|
+
clientSecret: string;
|
|
5
|
+
apiHost: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* A client for interacting with the Checkout OAuth API
|
|
9
|
+
* Docs for all the routes: https://gitlab.com/aboutyou/checkout/schemas/checkout-auth-api/-/blob/main/build/openapi.yaml
|
|
10
|
+
*/
|
|
11
|
+
export declare class OAuthClient {
|
|
12
|
+
headers: HeadersInit;
|
|
13
|
+
baseURL: string;
|
|
14
|
+
constructor(options: OAuthOptions);
|
|
15
|
+
/**
|
|
16
|
+
* Register a user and retrieve a token set
|
|
17
|
+
* @param payload
|
|
18
|
+
*/
|
|
19
|
+
register(payload: RegisterRequest): Oauth;
|
|
20
|
+
/**
|
|
21
|
+
* Execute a user login on the OAuth API and receive a token set
|
|
22
|
+
* @param payload
|
|
23
|
+
*/
|
|
24
|
+
login(payload: LoginRequest & {
|
|
25
|
+
shopId: string;
|
|
26
|
+
}): Oauth;
|
|
27
|
+
/**
|
|
28
|
+
* Execute a guest user login on the OAuth API and receive a token set
|
|
29
|
+
* @param payload
|
|
30
|
+
*/
|
|
31
|
+
guestLogin(payload: GuestRequest): Oauth;
|
|
32
|
+
/**
|
|
33
|
+
* Send a password reset email
|
|
34
|
+
* @param payload
|
|
35
|
+
*/
|
|
36
|
+
sendPasswordResetEmail(payload: SendResetPasswordEmailRequest): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Update password by hash
|
|
39
|
+
* @param payload
|
|
40
|
+
*/
|
|
41
|
+
updatePasswordByHash(payload: UpdatePasswordByHashRequest): Oauth;
|
|
42
|
+
/**
|
|
43
|
+
* Generate a new access token via a refresh token
|
|
44
|
+
* @param payload
|
|
45
|
+
*/
|
|
46
|
+
refreshToken(payload: RefreshTokenRequest): Promise<Oauth>;
|
|
47
|
+
/**
|
|
48
|
+
* Validate an access token
|
|
49
|
+
* @param accessToken
|
|
50
|
+
*/
|
|
51
|
+
validateToken(accessToken: string): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Revoke an access token
|
|
54
|
+
* @param accessToken
|
|
55
|
+
*/
|
|
56
|
+
revokeToken(accessToken: string): Promise<void>;
|
|
57
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { decodeJwt } from "jose";
|
|
2
|
+
import { FetchError } from "../utils/fetch.mjs";
|
|
3
|
+
import { encodeBase64 } from "../utils/hash.mjs";
|
|
4
|
+
class MissingCredentialsError extends Error {
|
|
5
|
+
constructor() {
|
|
6
|
+
super("[OAuth API] No credentials configured");
|
|
7
|
+
this.name = "MissingCredentialsError";
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
async function oauthResponseHandler(response) {
|
|
11
|
+
const data = await response.json();
|
|
12
|
+
if (!response.ok) {
|
|
13
|
+
throw new FetchError(response, data);
|
|
14
|
+
}
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
export class OAuthClient {
|
|
18
|
+
headers;
|
|
19
|
+
baseURL;
|
|
20
|
+
constructor(options) {
|
|
21
|
+
const { clientId, clientSecret, apiHost } = options;
|
|
22
|
+
if (!clientId || !clientSecret) {
|
|
23
|
+
throw new MissingCredentialsError();
|
|
24
|
+
}
|
|
25
|
+
this.baseURL = `${apiHost}/v1`;
|
|
26
|
+
const basicAuthHash = encodeBase64(`${clientId}:${clientSecret}`);
|
|
27
|
+
this.headers = {
|
|
28
|
+
Authorization: `Basic ${basicAuthHash}`,
|
|
29
|
+
Accept: "application/json",
|
|
30
|
+
"Content-Type": "application/json"
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Register a user and retrieve a token set
|
|
35
|
+
* @param payload
|
|
36
|
+
*/
|
|
37
|
+
async register(payload) {
|
|
38
|
+
return await fetch(`${this.baseURL}/auth/register`, {
|
|
39
|
+
method: "POST",
|
|
40
|
+
headers: this.headers,
|
|
41
|
+
body: JSON.stringify(payload)
|
|
42
|
+
}).then(oauthResponseHandler);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Execute a user login on the OAuth API and receive a token set
|
|
46
|
+
* @param payload
|
|
47
|
+
*/
|
|
48
|
+
async login(payload) {
|
|
49
|
+
return await fetch(`${this.baseURL}/auth/login`, {
|
|
50
|
+
method: "POST",
|
|
51
|
+
headers: this.headers,
|
|
52
|
+
body: JSON.stringify(payload)
|
|
53
|
+
}).then(oauthResponseHandler);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Execute a guest user login on the OAuth API and receive a token set
|
|
57
|
+
* @param payload
|
|
58
|
+
*/
|
|
59
|
+
async guestLogin(payload) {
|
|
60
|
+
return await fetch(`${this.baseURL}/auth/login/guest`, {
|
|
61
|
+
method: "POST",
|
|
62
|
+
headers: this.headers,
|
|
63
|
+
body: JSON.stringify(payload)
|
|
64
|
+
}).then(oauthResponseHandler);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Send a password reset email
|
|
68
|
+
* @param payload
|
|
69
|
+
*/
|
|
70
|
+
async sendPasswordResetEmail(payload) {
|
|
71
|
+
await fetch(`${this.baseURL}/auth/password/send-reset-email`, {
|
|
72
|
+
method: "POST",
|
|
73
|
+
headers: this.headers,
|
|
74
|
+
body: JSON.stringify(payload)
|
|
75
|
+
}).then(oauthResponseHandler);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Update password by hash
|
|
79
|
+
* @param payload
|
|
80
|
+
*/
|
|
81
|
+
async updatePasswordByHash(payload) {
|
|
82
|
+
return await fetch(`${this.baseURL}/auth/password/update-by-hash`, {
|
|
83
|
+
method: "PUT",
|
|
84
|
+
headers: this.headers,
|
|
85
|
+
body: JSON.stringify(payload)
|
|
86
|
+
}).then(oauthResponseHandler);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Generate a new access token via a refresh token
|
|
90
|
+
* @param payload
|
|
91
|
+
*/
|
|
92
|
+
async refreshToken(payload) {
|
|
93
|
+
return await fetch(`${this.baseURL}/oauth/token`, {
|
|
94
|
+
method: "POST",
|
|
95
|
+
headers: this.headers,
|
|
96
|
+
body: JSON.stringify(payload)
|
|
97
|
+
}).then(oauthResponseHandler);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Validate an access token
|
|
101
|
+
* @param accessToken
|
|
102
|
+
*/
|
|
103
|
+
async validateToken(accessToken) {
|
|
104
|
+
await fetch(`${this.baseURL}/oauth/token/validate`, {
|
|
105
|
+
headers: {
|
|
106
|
+
...headers,
|
|
107
|
+
Authorization: `Bearer ${accessToken}`
|
|
108
|
+
}
|
|
109
|
+
}).then(oauthResponseHandler);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Revoke an access token
|
|
113
|
+
* @param accessToken
|
|
114
|
+
*/
|
|
115
|
+
async revokeToken(accessToken) {
|
|
116
|
+
const decodedAccessToken = decodeJwt(accessToken);
|
|
117
|
+
await fetch(`${this.baseURL}/oauth/tokens/${decodedAccessToken.jti}`, {
|
|
118
|
+
method: "DELETE",
|
|
119
|
+
headers: {
|
|
120
|
+
...headers,
|
|
121
|
+
Authorization: `Bearer ${accessToken}`
|
|
122
|
+
}
|
|
123
|
+
}).then(oauthResponseHandler);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.UnstorageCache = void 0;
|
|
7
|
+
var _compression = require("../../utils/compression.cjs");
|
|
7
8
|
class UnstorageCache {
|
|
8
9
|
storage;
|
|
9
10
|
prefix;
|
|
@@ -16,7 +17,7 @@ class UnstorageCache {
|
|
|
16
17
|
if (value === null) {
|
|
17
18
|
return null;
|
|
18
19
|
}
|
|
19
|
-
return value;
|
|
20
|
+
return typeof value === "string" ? this.deserialize(value) : value;
|
|
20
21
|
}
|
|
21
22
|
async has(key) {
|
|
22
23
|
return await this.storage.hasItem(this.getKey(key));
|
|
@@ -37,7 +38,8 @@ class UnstorageCache {
|
|
|
37
38
|
await Promise.all(keys.map(k => this.storage.removeItem(k)));
|
|
38
39
|
}
|
|
39
40
|
async set(key, value, ttl, tags = []) {
|
|
40
|
-
await this.
|
|
41
|
+
const _value = await this.serialize(value);
|
|
42
|
+
await this.storage.setItem(this.getKey(key), _value, {
|
|
41
43
|
ttl
|
|
42
44
|
});
|
|
43
45
|
await Promise.all(tags.map(tag => this.addKeyToTag(tag, this.getKey(key))));
|
|
@@ -51,5 +53,26 @@ class UnstorageCache {
|
|
|
51
53
|
getKey(key) {
|
|
52
54
|
return [this.prefix, key].join(":");
|
|
53
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* First iteration copied from `packages/storefront-core/src/cache/providers/redis.ts`
|
|
58
|
+
* @param value String to be deserialized and decompressed
|
|
59
|
+
*/
|
|
60
|
+
async deserialize(value) {
|
|
61
|
+
try {
|
|
62
|
+
const data = await (0, _compression.decompress)(value);
|
|
63
|
+
return JSON.parse(data);
|
|
64
|
+
} catch (error) {
|
|
65
|
+
console.warn("UnstorageCache: Unable to decompress data", error);
|
|
66
|
+
return value;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* First iteration copied from `packages/storefront-core/src/cache/providers/redis.ts`
|
|
71
|
+
* @param value String to be deserialized and decompressed
|
|
72
|
+
*/
|
|
73
|
+
async serialize(value) {
|
|
74
|
+
const data = JSON.stringify(value);
|
|
75
|
+
return await (0, _compression.compress)(data);
|
|
76
|
+
}
|
|
54
77
|
}
|
|
55
78
|
exports.UnstorageCache = UnstorageCache;
|
|
@@ -13,4 +13,14 @@ export declare class UnstorageCache implements CacheInterface {
|
|
|
13
13
|
set(key: string, value: any, ttl: number, tags?: string[]): Promise<void>;
|
|
14
14
|
private addKeyToTag;
|
|
15
15
|
private getKey;
|
|
16
|
+
/**
|
|
17
|
+
* First iteration copied from `packages/storefront-core/src/cache/providers/redis.ts`
|
|
18
|
+
* @param value String to be deserialized and decompressed
|
|
19
|
+
*/
|
|
20
|
+
private deserialize;
|
|
21
|
+
/**
|
|
22
|
+
* First iteration copied from `packages/storefront-core/src/cache/providers/redis.ts`
|
|
23
|
+
* @param value String to be deserialized and decompressed
|
|
24
|
+
*/
|
|
25
|
+
private serialize;
|
|
16
26
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { compress, decompress } from "../../utils/compression.mjs";
|
|
1
2
|
export class UnstorageCache {
|
|
2
3
|
storage;
|
|
3
4
|
prefix;
|
|
@@ -10,7 +11,7 @@ export class UnstorageCache {
|
|
|
10
11
|
if (value === null) {
|
|
11
12
|
return null;
|
|
12
13
|
}
|
|
13
|
-
return value;
|
|
14
|
+
return typeof value === "string" ? this.deserialize(value) : value;
|
|
14
15
|
}
|
|
15
16
|
async has(key) {
|
|
16
17
|
return await this.storage.hasItem(this.getKey(key));
|
|
@@ -31,7 +32,8 @@ export class UnstorageCache {
|
|
|
31
32
|
await Promise.all(keys.map((k) => this.storage.removeItem(k)));
|
|
32
33
|
}
|
|
33
34
|
async set(key, value, ttl, tags = []) {
|
|
34
|
-
await this.
|
|
35
|
+
const _value = await this.serialize(value);
|
|
36
|
+
await this.storage.setItem(this.getKey(key), _value, {
|
|
35
37
|
ttl
|
|
36
38
|
});
|
|
37
39
|
await Promise.all(
|
|
@@ -47,4 +49,25 @@ export class UnstorageCache {
|
|
|
47
49
|
getKey(key) {
|
|
48
50
|
return [this.prefix, key].join(":");
|
|
49
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* First iteration copied from `packages/storefront-core/src/cache/providers/redis.ts`
|
|
54
|
+
* @param value String to be deserialized and decompressed
|
|
55
|
+
*/
|
|
56
|
+
async deserialize(value) {
|
|
57
|
+
try {
|
|
58
|
+
const data = await decompress(value);
|
|
59
|
+
return JSON.parse(data);
|
|
60
|
+
} catch (error) {
|
|
61
|
+
console.warn("UnstorageCache: Unable to decompress data", error);
|
|
62
|
+
return value;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* First iteration copied from `packages/storefront-core/src/cache/providers/redis.ts`
|
|
67
|
+
* @param value String to be deserialized and decompressed
|
|
68
|
+
*/
|
|
69
|
+
async serialize(value) {
|
|
70
|
+
const data = JSON.stringify(value);
|
|
71
|
+
return await compress(data);
|
|
72
|
+
}
|
|
50
73
|
}
|
|
@@ -4,10 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.ExistingItemHandling = void 0;
|
|
7
|
-
const ExistingItemHandling = {
|
|
7
|
+
const ExistingItemHandling = exports.ExistingItemHandling = {
|
|
8
8
|
KeepExisting: 0,
|
|
9
9
|
AddQuantityToExisting: 1,
|
|
10
10
|
ReplaceExisting: 2,
|
|
11
11
|
ReplaceExistingWithCombinedQuantity: 3
|
|
12
|
-
};
|
|
13
|
-
exports.ExistingItemHandling = ExistingItemHandling;
|
|
12
|
+
};
|
package/dist/constants/cache.cjs
CHANGED
package/dist/constants/hash.cjs
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.HttpStatusMessage = exports.HttpStatusCode = void 0;
|
|
7
|
-
const HttpStatusCode = {
|
|
7
|
+
const HttpStatusCode = exports.HttpStatusCode = {
|
|
8
8
|
/**
|
|
9
9
|
* The server has received the request headers and the client should proceed to send the request body
|
|
10
10
|
* (in the case of a request for which a body needs to be sent; for example, a POST request).
|
|
@@ -318,8 +318,7 @@ const HttpStatusCode = {
|
|
|
318
318
|
*/
|
|
319
319
|
NETWORK_AUTHENTICATION_REQUIRED: 511
|
|
320
320
|
};
|
|
321
|
-
exports.
|
|
322
|
-
const HttpStatusMessage = {
|
|
321
|
+
const HttpStatusMessage = exports.HttpStatusMessage = {
|
|
323
322
|
/**
|
|
324
323
|
* The server has received the request headers and the client should proceed to send the request body
|
|
325
324
|
* (in the case of a request for which a body needs to be sent; for example, a POST request).
|
|
@@ -632,5 +631,4 @@ const HttpStatusMessage = {
|
|
|
632
631
|
* to require agreement to Terms of Service before granting full Internet access via a Wi-Fi hotspot).
|
|
633
632
|
*/
|
|
634
633
|
NETWORK_AUTHENTICATION_REQUIRED: "NETWORK AUTHENTICATION REQUIRED"
|
|
635
|
-
};
|
|
636
|
-
exports.HttpStatusMessage = HttpStatusMessage;
|
|
634
|
+
};
|
|
@@ -4,8 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.ProductImageType = void 0;
|
|
7
|
-
const ProductImageType = {
|
|
7
|
+
const ProductImageType = exports.ProductImageType = {
|
|
8
8
|
MODEL: "model",
|
|
9
9
|
BUST: "bust"
|
|
10
|
-
};
|
|
11
|
-
exports.ProductImageType = ProductImageType;
|
|
10
|
+
};
|
|
@@ -4,12 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.PromotionEffectType = exports.PROMOTION_PER_PAGE_DEFAULT = exports.PROMOTION_PAGE_DEFAULT = void 0;
|
|
7
|
-
const PROMOTION_PAGE_DEFAULT = 1;
|
|
8
|
-
exports.
|
|
9
|
-
const
|
|
10
|
-
exports.PROMOTION_PER_PAGE_DEFAULT = PROMOTION_PER_PAGE_DEFAULT;
|
|
11
|
-
const PromotionEffectType = {
|
|
7
|
+
const PROMOTION_PAGE_DEFAULT = exports.PROMOTION_PAGE_DEFAULT = 1;
|
|
8
|
+
const PROMOTION_PER_PAGE_DEFAULT = exports.PROMOTION_PER_PAGE_DEFAULT = 100;
|
|
9
|
+
const PromotionEffectType = exports.PromotionEffectType = {
|
|
12
10
|
AUTOMATIC_DISCOUNT: "automatic_discount",
|
|
13
11
|
BUY_X_GET_Y: "buy_x_get_y"
|
|
14
|
-
};
|
|
15
|
-
exports.PromotionEffectType = PromotionEffectType;
|
|
12
|
+
};
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.SortQuery = exports.SortName = void 0;
|
|
7
|
-
const SortName = {
|
|
7
|
+
const SortName = exports.SortName = {
|
|
8
8
|
TOPSELLER: "topseller",
|
|
9
9
|
DATE_NEWEST: "date_newest",
|
|
10
10
|
PRICE_DESC: "price_desc",
|
|
@@ -12,13 +12,11 @@ const SortName = {
|
|
|
12
12
|
REDUCTION_DESC: "reduction_desc",
|
|
13
13
|
REDUCTION_ASC: "reduction_asc"
|
|
14
14
|
};
|
|
15
|
-
exports.
|
|
16
|
-
const SortQuery = {
|
|
15
|
+
const SortQuery = exports.SortQuery = {
|
|
17
16
|
TOPSELLER: "topseller",
|
|
18
17
|
DATE_NEWEST: "date-newest",
|
|
19
18
|
PRICE_DESC: "price-desc",
|
|
20
19
|
PRICE_ASC: "price-asc",
|
|
21
20
|
REDUCTION_DESC: "reduction-desc",
|
|
22
21
|
REDUCTION_ASC: "reduction-asc"
|
|
23
|
-
};
|
|
24
|
-
exports.SortQuery = SortQuery;
|
|
22
|
+
};
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.MIN_WITH_PARAMS_WISHLIST = exports.MIN_WITH_PARAMS_VARIANT = exports.MIN_WITH_PARAMS_SEARCH = exports.MIN_WITH_PARAMS_PRODUCT = exports.MIN_WITH_PARAMS_BASKET = exports.DEFAULT_WITH_LISTING = void 0;
|
|
7
|
-
const DEFAULT_WITH_LISTING = {
|
|
7
|
+
const DEFAULT_WITH_LISTING = exports.DEFAULT_WITH_LISTING = {
|
|
8
8
|
items: {
|
|
9
9
|
product: {
|
|
10
10
|
attributes: "all",
|
|
@@ -24,8 +24,7 @@ const DEFAULT_WITH_LISTING = {
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
|
-
exports.
|
|
28
|
-
const MIN_WITH_PARAMS_SEARCH = {
|
|
27
|
+
const MIN_WITH_PARAMS_SEARCH = exports.MIN_WITH_PARAMS_SEARCH = {
|
|
29
28
|
products: {
|
|
30
29
|
attributes: {
|
|
31
30
|
withKey: ["brand", "color", "colorDetail", "name"]
|
|
@@ -40,8 +39,7 @@ const MIN_WITH_PARAMS_SEARCH = {
|
|
|
40
39
|
}
|
|
41
40
|
}
|
|
42
41
|
};
|
|
43
|
-
exports.
|
|
44
|
-
const MIN_WITH_PARAMS_PRODUCT = {
|
|
42
|
+
const MIN_WITH_PARAMS_PRODUCT = exports.MIN_WITH_PARAMS_PRODUCT = {
|
|
45
43
|
attributes: {
|
|
46
44
|
withKey: ["color", "brand", "name", "material", "careSymbol"]
|
|
47
45
|
},
|
|
@@ -69,8 +67,7 @@ const MIN_WITH_PARAMS_PRODUCT = {
|
|
|
69
67
|
}
|
|
70
68
|
}
|
|
71
69
|
};
|
|
72
|
-
exports.
|
|
73
|
-
const MIN_WITH_PARAMS_BASKET = {
|
|
70
|
+
const MIN_WITH_PARAMS_BASKET = exports.MIN_WITH_PARAMS_BASKET = {
|
|
74
71
|
items: {
|
|
75
72
|
product: {
|
|
76
73
|
attributes: {
|
|
@@ -99,8 +96,7 @@ const MIN_WITH_PARAMS_BASKET = {
|
|
|
99
96
|
}
|
|
100
97
|
}
|
|
101
98
|
};
|
|
102
|
-
exports.
|
|
103
|
-
const MIN_WITH_PARAMS_WISHLIST = {
|
|
99
|
+
const MIN_WITH_PARAMS_WISHLIST = exports.MIN_WITH_PARAMS_WISHLIST = {
|
|
104
100
|
items: {
|
|
105
101
|
product: {
|
|
106
102
|
attributes: {
|
|
@@ -129,10 +125,8 @@ const MIN_WITH_PARAMS_WISHLIST = {
|
|
|
129
125
|
}
|
|
130
126
|
}
|
|
131
127
|
};
|
|
132
|
-
exports.
|
|
133
|
-
const MIN_WITH_PARAMS_VARIANT = {
|
|
128
|
+
const MIN_WITH_PARAMS_VARIANT = exports.MIN_WITH_PARAMS_VARIANT = {
|
|
134
129
|
attributes: {
|
|
135
130
|
withKey: ["size", "shopSize", "vendorSize"]
|
|
136
131
|
}
|
|
137
|
-
};
|
|
138
|
-
exports.MIN_WITH_PARAMS_VARIANT = MIN_WITH_PARAMS_VARIANT;
|
|
132
|
+
};
|
|
@@ -7,7 +7,7 @@ exports.productFromEDT = exports.product = exports.priceFixtureWithReductions =
|
|
|
7
7
|
const BILD_HINTERGRUND_LABEL = "Bild Hintergrund";
|
|
8
8
|
const CREATED_AT = "2022-04-26T15:04:56+00:00";
|
|
9
9
|
const WOMEN_CLOTHING_CATEGORY_URL = "/women/kleidung";
|
|
10
|
-
const product = {
|
|
10
|
+
const product = exports.product = {
|
|
11
11
|
id: 6,
|
|
12
12
|
isActive: true,
|
|
13
13
|
isSoldOut: false,
|
|
@@ -178,8 +178,7 @@ const product = {
|
|
|
178
178
|
categoryProperties: []
|
|
179
179
|
}]]
|
|
180
180
|
};
|
|
181
|
-
exports.
|
|
182
|
-
const productFromEDT = {
|
|
181
|
+
const productFromEDT = exports.productFromEDT = {
|
|
183
182
|
id: 5703863,
|
|
184
183
|
isActive: true,
|
|
185
184
|
isSoldOut: false,
|
|
@@ -763,8 +762,5 @@ const productFromEDT = {
|
|
|
763
762
|
categoryProperties: []
|
|
764
763
|
}]]
|
|
765
764
|
};
|
|
766
|
-
exports.
|
|
767
|
-
const
|
|
768
|
-
exports.priceFixture = priceFixture;
|
|
769
|
-
const priceFixtureWithReductions = productFromEDT.variants[0].price;
|
|
770
|
-
exports.priceFixtureWithReductions = priceFixtureWithReductions;
|
|
765
|
+
const priceFixture = exports.priceFixture = product.variants[0].price;
|
|
766
|
+
const priceFixtureWithReductions = exports.priceFixtureWithReductions = productFromEDT.variants[0].price;
|
package/dist/index.cjs
CHANGED
|
@@ -81,5 +81,5 @@ Object.keys(_types).forEach(function (key) {
|
|
|
81
81
|
}
|
|
82
82
|
});
|
|
83
83
|
});
|
|
84
|
-
function _getRequireWildcardCache(
|
|
85
|
-
function _interopRequireWildcard(
|
|
84
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
85
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|