@scayle/storefront-core 8.3.2 → 8.5.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 +22 -0
- package/dist/api/customer.d.ts +19 -13
- package/dist/api/customer.mjs +16 -10
- package/dist/api/oauth.d.ts +45 -11
- package/dist/api/oauth.mjs +43 -10
- package/dist/rpc/methods/checkout/checkout.mjs +1 -1
- package/dist/rpc/methods/search.d.ts +22 -0
- package/dist/types/user.d.ts +1 -1
- package/package.json +9 -19
- package/dist/api/customer.cjs +0 -158
- package/dist/api/oauth.cjs +0 -205
- package/dist/cache/cache.cjs +0 -1
- package/dist/cache/cached.cjs +0 -90
- package/dist/cache/index.cjs +0 -27
- package/dist/cache/providers/unstorage.cjs +0 -55
- package/dist/constants/basket.cjs +0 -26
- package/dist/constants/cache.cjs +0 -7
- package/dist/constants/hash.cjs +0 -11
- package/dist/constants/httpStatus.cjs +0 -634
- package/dist/constants/index.cjs +0 -93
- package/dist/constants/product.cjs +0 -10
- package/dist/constants/promotion.cjs +0 -12
- package/dist/constants/sorting.cjs +0 -22
- package/dist/constants/withParameters.cjs +0 -132
- package/dist/errors/errorResponse.cjs +0 -27
- package/dist/errors/index.cjs +0 -16
- package/dist/helpers/advancedAttributeHelpers.cjs +0 -30
- package/dist/helpers/arrayHelpers.cjs +0 -10
- package/dist/helpers/attributeHelpers.cjs +0 -24
- package/dist/helpers/basketHelpers.cjs +0 -12
- package/dist/helpers/categoryHelper.cjs +0 -61
- package/dist/helpers/filterHelper.cjs +0 -185
- package/dist/helpers/formHelpers.cjs +0 -114
- package/dist/helpers/imageHelpers.cjs +0 -20
- package/dist/helpers/index.cjs +0 -181
- package/dist/helpers/localization.cjs +0 -13
- package/dist/helpers/objectHelpers.cjs +0 -19
- package/dist/helpers/orderHelpers.cjs +0 -10
- package/dist/helpers/product.fixture.cjs +0 -766
- package/dist/helpers/productDisruptorHelper.cjs +0 -37
- package/dist/helpers/productHelpers.cjs +0 -156
- package/dist/helpers/sanitizationHelpers.cjs +0 -35
- package/dist/helpers/sortingHelper.cjs +0 -68
- package/dist/helpers/stringHelpers.cjs +0 -8
- package/dist/index.cjs +0 -100
- package/dist/rpc/methods/basket/basket.cjs +0 -270
- package/dist/rpc/methods/brands.cjs +0 -33
- package/dist/rpc/methods/categories.cjs +0 -129
- package/dist/rpc/methods/cbd.cjs +0 -38
- package/dist/rpc/methods/checkout/checkout.cjs +0 -48
- package/dist/rpc/methods/checkout/index.cjs +0 -49
- package/dist/rpc/methods/checkout/order.cjs +0 -42
- package/dist/rpc/methods/checkout/shopUser.cjs +0 -110
- package/dist/rpc/methods/checkout/shopUserAddresses.cjs +0 -12
- package/dist/rpc/methods/index.cjs +0 -225
- package/dist/rpc/methods/navigationTrees.cjs +0 -54
- package/dist/rpc/methods/oauth/idp.cjs +0 -59
- package/dist/rpc/methods/products.cjs +0 -309
- package/dist/rpc/methods/promotion.cjs +0 -51
- package/dist/rpc/methods/search.cjs +0 -40
- package/dist/rpc/methods/session.cjs +0 -257
- package/dist/rpc/methods/shopConfiguration.cjs +0 -15
- package/dist/rpc/methods/user.cjs +0 -103
- package/dist/rpc/methods/variants.cjs +0 -29
- package/dist/rpc/methods/wishlist.cjs +0 -104
- package/dist/server.cjs +0 -47
- package/dist/test/factories/index.cjs +0 -16
- package/dist/types/api/auth.cjs +0 -1
- package/dist/types/api/context.cjs +0 -15
- package/dist/types/api/rpc.cjs +0 -1
- package/dist/types/breadcrumb.cjs +0 -1
- package/dist/types/index.cjs +0 -267
- package/dist/types/promises.cjs +0 -1
- package/dist/types/sapi/basket.cjs +0 -1
- package/dist/types/sapi/brand.cjs +0 -1
- package/dist/types/sapi/campaign.cjs +0 -1
- package/dist/types/sapi/category.cjs +0 -1
- package/dist/types/sapi/filter.cjs +0 -1
- package/dist/types/sapi/navigation.cjs +0 -1
- package/dist/types/sapi/order.cjs +0 -1
- package/dist/types/sapi/product.cjs +0 -1
- package/dist/types/sapi/productFilter.cjs +0 -1
- package/dist/types/sapi/promotion.cjs +0 -1
- package/dist/types/sapi/redirects.cjs +0 -1
- package/dist/types/sapi/router.cjs +0 -1
- package/dist/types/sapi/search.cjs +0 -1
- package/dist/types/sapi/sorting.cjs +0 -1
- package/dist/types/sapi/variant.cjs +0 -1
- package/dist/types/sapi/wishlist.cjs +0 -1
- package/dist/types/user.cjs +0 -1
- package/dist/utils/basket.cjs +0 -14
- package/dist/utils/fetch.cjs +0 -19
- package/dist/utils/hash.cjs +0 -72
- package/dist/utils/index.cjs +0 -49
- package/dist/utils/keys.cjs +0 -67
- package/dist/utils/log.cjs +0 -93
- package/dist/utils/response.cjs +0 -13
- package/dist/utils/sapi.cjs +0 -26
- package/dist/utils/timeout.cjs +0 -18
- package/dist/utils/user.cjs +0 -90
- /package/dist/api/{README.md → INFO.md} +0 -0
package/dist/api/oauth.cjs
DELETED
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.OAuthClient = void 0;
|
|
7
|
-
exports.getOAuthClient = getOAuthClient;
|
|
8
|
-
var _jose = require("jose");
|
|
9
|
-
var _fetch = require("../utils/fetch.cjs");
|
|
10
|
-
var _hash = require("../utils/hash.cjs");
|
|
11
|
-
class MissingCredentialsError extends Error {
|
|
12
|
-
constructor() {
|
|
13
|
-
super("[OAuth API] No credentials configured");
|
|
14
|
-
this.name = "MissingCredentialsError";
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
async function oauthResponseHandler(response) {
|
|
18
|
-
const data = await response.json();
|
|
19
|
-
if (!response.ok) {
|
|
20
|
-
throw new _fetch.FetchError(response, data);
|
|
21
|
-
}
|
|
22
|
-
return data;
|
|
23
|
-
}
|
|
24
|
-
function emptyOAuthResponseHandler(response) {
|
|
25
|
-
if (!response.ok) {
|
|
26
|
-
throw new _fetch.FetchError(response);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
function getOAuthClient(context) {
|
|
30
|
-
if (!context.oauth) {
|
|
31
|
-
throw new Error("OAuth configuration is missing");
|
|
32
|
-
}
|
|
33
|
-
const clientId = context.oauth.clientId;
|
|
34
|
-
const clientSecret = context.oauth.clientSecret;
|
|
35
|
-
const apiHost = context.oauth.apiHost;
|
|
36
|
-
const accessHeader = context.internalAccessHeader;
|
|
37
|
-
return new OAuthClient({
|
|
38
|
-
clientId,
|
|
39
|
-
clientSecret,
|
|
40
|
-
apiHost,
|
|
41
|
-
additionalHeaders: accessHeader ? {
|
|
42
|
-
"x-internal-access": accessHeader
|
|
43
|
-
} : {}
|
|
44
|
-
}, context.log);
|
|
45
|
-
}
|
|
46
|
-
class OAuthClient {
|
|
47
|
-
headers;
|
|
48
|
-
baseURL;
|
|
49
|
-
logger;
|
|
50
|
-
clientId;
|
|
51
|
-
constructor(options, logger) {
|
|
52
|
-
const {
|
|
53
|
-
clientId,
|
|
54
|
-
clientSecret,
|
|
55
|
-
apiHost,
|
|
56
|
-
additionalHeaders
|
|
57
|
-
} = options;
|
|
58
|
-
if (!clientId || !clientSecret) {
|
|
59
|
-
throw new MissingCredentialsError();
|
|
60
|
-
}
|
|
61
|
-
this.clientId = clientId;
|
|
62
|
-
this.baseURL = `${apiHost}/v1`;
|
|
63
|
-
this.logger = logger ? logger.space("auth-client") : void 0;
|
|
64
|
-
const basicAuthHash = (0, _hash.encodeBase64)(`${clientId}:${clientSecret}`);
|
|
65
|
-
this.headers = {
|
|
66
|
-
Authorization: `Basic ${basicAuthHash}`,
|
|
67
|
-
Accept: "application/json",
|
|
68
|
-
"Content-Type": "application/json",
|
|
69
|
-
...additionalHeaders
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Register a user and retrieve a token set
|
|
74
|
-
* @param payload
|
|
75
|
-
*/
|
|
76
|
-
async register(payload) {
|
|
77
|
-
this.logger?.debug("Registering user");
|
|
78
|
-
return await fetch(`${this.baseURL}/auth/register`, {
|
|
79
|
-
method: "POST",
|
|
80
|
-
headers: this.headers,
|
|
81
|
-
body: JSON.stringify(payload)
|
|
82
|
-
}).then(oauthResponseHandler);
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Execute a user login on the OAuth API and receive a token set
|
|
86
|
-
* @param payload
|
|
87
|
-
*/
|
|
88
|
-
async login(payload) {
|
|
89
|
-
this.logger?.debug("Logging in");
|
|
90
|
-
return await fetch(`${this.baseURL}/auth/login`, {
|
|
91
|
-
method: "POST",
|
|
92
|
-
headers: this.headers,
|
|
93
|
-
body: JSON.stringify(payload)
|
|
94
|
-
}).then(oauthResponseHandler);
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Execute a guest user login on the OAuth API and receive a token set
|
|
98
|
-
* @param payload
|
|
99
|
-
*/
|
|
100
|
-
async guestLogin(payload) {
|
|
101
|
-
this.logger?.debug("Logging in as guest");
|
|
102
|
-
return await fetch(`${this.baseURL}/auth/login/guest`, {
|
|
103
|
-
method: "POST",
|
|
104
|
-
headers: this.headers,
|
|
105
|
-
body: JSON.stringify(payload)
|
|
106
|
-
}).then(oauthResponseHandler);
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Send a password reset email
|
|
110
|
-
* @param payload
|
|
111
|
-
*/
|
|
112
|
-
async sendPasswordResetEmail(payload) {
|
|
113
|
-
this.logger?.debug("Sending password reset email");
|
|
114
|
-
await fetch(`${this.baseURL}/auth/password/send-reset-email`, {
|
|
115
|
-
method: "POST",
|
|
116
|
-
headers: this.headers,
|
|
117
|
-
body: JSON.stringify(payload)
|
|
118
|
-
}).then(emptyOAuthResponseHandler);
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Update password by hash
|
|
122
|
-
* @param payload
|
|
123
|
-
*/
|
|
124
|
-
async updatePasswordByHash(payload) {
|
|
125
|
-
this.logger?.debug("Updating password by hash");
|
|
126
|
-
return await fetch(`${this.baseURL}/auth/password/update-by-hash`, {
|
|
127
|
-
method: "PUT",
|
|
128
|
-
headers: this.headers,
|
|
129
|
-
body: JSON.stringify(payload)
|
|
130
|
-
}).then(oauthResponseHandler);
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Update a user's password
|
|
134
|
-
* @param payload
|
|
135
|
-
* @param accessToken
|
|
136
|
-
*/
|
|
137
|
-
async updatePassword(payload, accessToken) {
|
|
138
|
-
this.logger?.debug("Updating password");
|
|
139
|
-
return await fetch(`${this.baseURL}/auth/password`, {
|
|
140
|
-
method: "PUT",
|
|
141
|
-
headers: {
|
|
142
|
-
...this.headers,
|
|
143
|
-
Authorization: `Bearer ${accessToken}`
|
|
144
|
-
},
|
|
145
|
-
body: JSON.stringify(payload)
|
|
146
|
-
}).then(emptyOAuthResponseHandler);
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Generate a new access token via a refresh token
|
|
150
|
-
* @param payload
|
|
151
|
-
*/
|
|
152
|
-
async refreshToken(payload) {
|
|
153
|
-
this.logger?.debug("Refreshing access token");
|
|
154
|
-
return await fetch(`${this.baseURL}/oauth/token`, {
|
|
155
|
-
method: "POST",
|
|
156
|
-
headers: this.headers,
|
|
157
|
-
body: JSON.stringify(payload)
|
|
158
|
-
}).then(oauthResponseHandler);
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Validate an access token
|
|
162
|
-
* @param accessToken
|
|
163
|
-
*/
|
|
164
|
-
async validateToken(accessToken) {
|
|
165
|
-
this.logger?.debug("Validating access token");
|
|
166
|
-
await fetch(`${this.baseURL}/oauth/token/validate`, {
|
|
167
|
-
headers: {
|
|
168
|
-
...this.headers,
|
|
169
|
-
Authorization: `Bearer ${accessToken}`
|
|
170
|
-
}
|
|
171
|
-
}).then(emptyOAuthResponseHandler);
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Revoke an access token
|
|
175
|
-
* @param shopId
|
|
176
|
-
* @param accessToken
|
|
177
|
-
*/
|
|
178
|
-
async revokeToken(shopId, accessToken) {
|
|
179
|
-
this.logger?.debug("Revoking access token");
|
|
180
|
-
const decodedAccessToken = (0, _jose.decodeJwt)(accessToken);
|
|
181
|
-
await fetch(`${this.baseURL}/oauth/tokens/${decodedAccessToken.jti}`, {
|
|
182
|
-
method: "DELETE",
|
|
183
|
-
headers: {
|
|
184
|
-
...this.headers,
|
|
185
|
-
"X-Shop-Id": `${shopId}`,
|
|
186
|
-
Authorization: `Bearer ${accessToken}`
|
|
187
|
-
}
|
|
188
|
-
}).then(emptyOAuthResponseHandler);
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Generate a new token based on authorization code
|
|
192
|
-
* @param code
|
|
193
|
-
*/
|
|
194
|
-
async generateToken(code) {
|
|
195
|
-
return await fetch(`${this.baseURL}/oauth/token`, {
|
|
196
|
-
method: "POST",
|
|
197
|
-
headers: this.headers,
|
|
198
|
-
body: JSON.stringify({
|
|
199
|
-
grant_type: "authorization_code",
|
|
200
|
-
code
|
|
201
|
-
})
|
|
202
|
-
}).then(oauthResponseHandler);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
exports.OAuthClient = OAuthClient;
|
package/dist/cache/cache.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
package/dist/cache/cached.cjs
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.MINUTE = exports.Cached = void 0;
|
|
7
|
-
var _utils = require("../utils/index.cjs");
|
|
8
|
-
var _hash = require("../utils/hash.cjs");
|
|
9
|
-
var _constants = require("../constants/index.cjs");
|
|
10
|
-
const MINUTE = exports.MINUTE = 60;
|
|
11
|
-
const CACHE_NOT_INITIALIZED_MSG = "Cache is not initialized";
|
|
12
|
-
class Cached {
|
|
13
|
-
cache;
|
|
14
|
-
log;
|
|
15
|
-
prefix;
|
|
16
|
-
enabled;
|
|
17
|
-
constructor(cache, log, prefix = "", enabled) {
|
|
18
|
-
if (!cache) {
|
|
19
|
-
log.error(CACHE_NOT_INITIALIZED_MSG);
|
|
20
|
-
throw new Error(CACHE_NOT_INITIALIZED_MSG);
|
|
21
|
-
}
|
|
22
|
-
this.cache = cache;
|
|
23
|
-
this.log = log.space("cached.init");
|
|
24
|
-
this.prefix = prefix;
|
|
25
|
-
this.enabled = enabled;
|
|
26
|
-
}
|
|
27
|
-
get isCacheEnabled() {
|
|
28
|
-
return this.enabled;
|
|
29
|
-
}
|
|
30
|
-
execute(fn, options) {
|
|
31
|
-
return async (...args) => {
|
|
32
|
-
const prefix = options?.cacheKeyPrefix ?? fn.name;
|
|
33
|
-
const params = [...args, this?.prefix];
|
|
34
|
-
const cacheKey = options?.cacheKey ?? (await this.createCacheKey(params, prefix));
|
|
35
|
-
try {
|
|
36
|
-
const cachedResponse = await this.getCacheValue(cacheKey, options);
|
|
37
|
-
if (cachedResponse !== void 0 && cachedResponse !== null) {
|
|
38
|
-
return cachedResponse;
|
|
39
|
-
}
|
|
40
|
-
} catch (e) {
|
|
41
|
-
if (e instanceof Error) {
|
|
42
|
-
this.handleError(e);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
const response = await fn(...args);
|
|
46
|
-
if (response === void 0 || response === null) {
|
|
47
|
-
return response;
|
|
48
|
-
}
|
|
49
|
-
if (response instanceof Response && !response.ok) {
|
|
50
|
-
return response;
|
|
51
|
-
}
|
|
52
|
-
try {
|
|
53
|
-
await this.setCacheValue(cacheKey, response, options);
|
|
54
|
-
} catch (e) {
|
|
55
|
-
if (e instanceof Error) {
|
|
56
|
-
this.handleError(e);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return response;
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
async getCacheValue(cacheKey, options) {
|
|
63
|
-
if (!this.isCacheEnabled) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
const data = await (0, _utils.timeout)(options?.timeout ?? _constants.CACHE_TIMEOUT, this.cache.get(cacheKey));
|
|
67
|
-
if (data !== null) {
|
|
68
|
-
return data;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
async setCacheValue(cacheKey, value, options) {
|
|
72
|
-
if (!this.isCacheEnabled) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
const ttl = options?.ttl ?? 60 * MINUTE;
|
|
76
|
-
if (ttl) {
|
|
77
|
-
await (0, _utils.timeout)(_constants.CACHE_TIMEOUT, this.cache.set(cacheKey, value, ttl));
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
async createCacheKey(params, prefix = "") {
|
|
81
|
-
return [prefix, await (0, _hash.sha256)(JSON.stringify(params))].join(":");
|
|
82
|
-
}
|
|
83
|
-
handleError(error) {
|
|
84
|
-
if (error.message === "timeout") {
|
|
85
|
-
return this.log.error("Cache timeout");
|
|
86
|
-
}
|
|
87
|
-
this.log.error(error);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
exports.Cached = Cached;
|
package/dist/cache/index.cjs
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _cache = require("./cache.cjs");
|
|
7
|
-
Object.keys(_cache).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _cache[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _cache[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
var _cached = require("./cached.cjs");
|
|
18
|
-
Object.keys(_cached).forEach(function (key) {
|
|
19
|
-
if (key === "default" || key === "__esModule") return;
|
|
20
|
-
if (key in exports && exports[key] === _cached[key]) return;
|
|
21
|
-
Object.defineProperty(exports, key, {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function () {
|
|
24
|
-
return _cached[key];
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.UnstorageCache = void 0;
|
|
7
|
-
class UnstorageCache {
|
|
8
|
-
storage;
|
|
9
|
-
prefix;
|
|
10
|
-
constructor(storage, prefix = "") {
|
|
11
|
-
this.storage = storage;
|
|
12
|
-
this.prefix = prefix;
|
|
13
|
-
}
|
|
14
|
-
async get(key) {
|
|
15
|
-
const value = await this.storage.getItem(this.getKey(key));
|
|
16
|
-
if (value === null) {
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
return value;
|
|
20
|
-
}
|
|
21
|
-
async has(key) {
|
|
22
|
-
return await this.storage.hasItem(this.getKey(key));
|
|
23
|
-
}
|
|
24
|
-
async purgeTags(tags) {
|
|
25
|
-
await Promise.all(tags.map(tag => this.purgeTag(tag)));
|
|
26
|
-
}
|
|
27
|
-
async purgeTag(tag) {
|
|
28
|
-
const keys = await this.storage.getItem(this.getKey(`tag:${tag}`));
|
|
29
|
-
await this.purgeKeys(keys ?? []);
|
|
30
|
-
await this.storage.removeItem(this.getKey(`tag:${tag}`));
|
|
31
|
-
}
|
|
32
|
-
async purgeKeys(keys) {
|
|
33
|
-
await Promise.all(keys.map(k => this.storage.removeItem(k)));
|
|
34
|
-
}
|
|
35
|
-
async purgeAll() {
|
|
36
|
-
const keys = await this.storage.getKeys(this.prefix);
|
|
37
|
-
await Promise.all(keys.map(k => this.storage.removeItem(k)));
|
|
38
|
-
}
|
|
39
|
-
async set(key, value, ttl, tags = []) {
|
|
40
|
-
await this.storage.setItem(this.getKey(key), value, {
|
|
41
|
-
ttl
|
|
42
|
-
});
|
|
43
|
-
await Promise.all(tags.map(tag => this.addKeyToTag(tag, this.getKey(key))));
|
|
44
|
-
}
|
|
45
|
-
async addKeyToTag(tag, key) {
|
|
46
|
-
const keys = await this.storage.getItem(tag);
|
|
47
|
-
const set = new Set(keys ?? []);
|
|
48
|
-
set.add(key);
|
|
49
|
-
await this.storage.setItem(this.getKey(`tag:${tag}`), Array.from(set));
|
|
50
|
-
}
|
|
51
|
-
getKey(key) {
|
|
52
|
-
return [this.prefix, key].join(":");
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
exports.UnstorageCache = UnstorageCache;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.UpdateBasketItemFailureKind = exports.ExistingItemHandling = exports.AddToBasketFailureKind = void 0;
|
|
7
|
-
const ExistingItemHandling = exports.ExistingItemHandling = {
|
|
8
|
-
KeepExisting: 0,
|
|
9
|
-
AddQuantityToExisting: 1,
|
|
10
|
-
ReplaceExisting: 2,
|
|
11
|
-
ReplaceExistingWithCombinedQuantity: 3
|
|
12
|
-
};
|
|
13
|
-
const AddToBasketFailureKind = exports.AddToBasketFailureKind = {
|
|
14
|
-
VariantAlreadyPresent: "VariantAlreadyPresent",
|
|
15
|
-
ItemUnvailable: "ItemUnvailable",
|
|
16
|
-
MaximumItemCountReached: "MaximumItemCountReached",
|
|
17
|
-
ItemDataNotFound: "ItemDataNotFound",
|
|
18
|
-
ItemAddedWithReducedQuantity: "ItemAddedWithReducedQuantity",
|
|
19
|
-
Unknown: "Unknown"
|
|
20
|
-
};
|
|
21
|
-
const UpdateBasketItemFailureKind = exports.UpdateBasketItemFailureKind = {
|
|
22
|
-
ItemUnvailable: "ItemUnvailable",
|
|
23
|
-
BasketItemNotFound: "BasketItemNotFound",
|
|
24
|
-
ItemAddedWithReducedQuantity: "ItemAddedWithReducedQuantity",
|
|
25
|
-
Unknown: "Unknown"
|
|
26
|
-
};
|
package/dist/constants/cache.cjs
DELETED
package/dist/constants/hash.cjs
DELETED