@scayle/storefront-core 8.1.5 → 8.2.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/CHANGELOG.md +14 -0
- package/dist/cache/cached.cjs +0 -2
- package/dist/cache/cached.mjs +0 -2
- package/dist/helpers/index.cjs +0 -11
- package/dist/helpers/index.d.ts +0 -1
- package/dist/helpers/index.mjs +0 -1
- package/dist/rpc/methods/checkout/checkout.cjs +1 -1
- package/dist/rpc/methods/checkout/checkout.mjs +1 -1
- package/dist/rpc/methods/search.d.ts +1 -1
- package/dist/utils/user.d.ts +3 -3
- package/package.json +2 -2
- package/dist/helpers/autobind.cjs +0 -44
- package/dist/helpers/autobind.d.ts +0 -39
- package/dist/helpers/autobind.mjs +0 -35
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @scayle/storefront-core
|
|
2
2
|
|
|
3
|
+
## 8.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
**Dependencies**
|
|
8
|
+
|
|
9
|
+
- Updated dependency to @scayle/storefront-api@17.16.0
|
|
10
|
+
|
|
11
|
+
## 8.2.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- [Performance] Remove the 'autobinding' of the methods on the `Cached` instance. Instead the `execute` method only is bound when constructing the `RpcContext`. This simplifies the code and improves the performance of the `bootstrap` function. This change is internal to `storefront-core` and the API of `RpcContext` is unchanged.
|
|
16
|
+
|
|
3
17
|
## 8.1.5
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/cache/cached.cjs
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.MINUTE = exports.Cached = void 0;
|
|
7
|
-
var _autobind = require("../helpers/autobind.cjs");
|
|
8
7
|
var _utils = require("../utils/index.cjs");
|
|
9
8
|
var _hash = require("../utils/hash.cjs");
|
|
10
9
|
var _constants = require("../constants/index.cjs");
|
|
@@ -24,7 +23,6 @@ class Cached {
|
|
|
24
23
|
this.log = log.space("cached.init");
|
|
25
24
|
this.prefix = prefix;
|
|
26
25
|
this.enabled = enabled;
|
|
27
|
-
(0, _autobind.autobind)(this);
|
|
28
26
|
}
|
|
29
27
|
get isCacheEnabled() {
|
|
30
28
|
return this.enabled;
|
package/dist/cache/cached.mjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { autobind } from "../helpers/autobind.mjs";
|
|
2
1
|
import { timeout } from "../utils/index.mjs";
|
|
3
2
|
import { sha256 } from "../utils/hash.mjs";
|
|
4
3
|
import { CACHE_TIMEOUT } from "../constants/index.mjs";
|
|
@@ -18,7 +17,6 @@ export class Cached {
|
|
|
18
17
|
this.log = log.space("cached.init");
|
|
19
18
|
this.prefix = prefix;
|
|
20
19
|
this.enabled = enabled;
|
|
21
|
-
autobind(this);
|
|
22
20
|
}
|
|
23
21
|
get isCacheEnabled() {
|
|
24
22
|
return this.enabled;
|
package/dist/helpers/index.cjs
CHANGED
|
@@ -36,17 +36,6 @@ Object.keys(_attributeHelpers).forEach(function (key) {
|
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
38
|
});
|
|
39
|
-
var _autobind = require("./autobind.cjs");
|
|
40
|
-
Object.keys(_autobind).forEach(function (key) {
|
|
41
|
-
if (key === "default" || key === "__esModule") return;
|
|
42
|
-
if (key in exports && exports[key] === _autobind[key]) return;
|
|
43
|
-
Object.defineProperty(exports, key, {
|
|
44
|
-
enumerable: true,
|
|
45
|
-
get: function () {
|
|
46
|
-
return _autobind[key];
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
39
|
var _basketHelpers = require("./basketHelpers.cjs");
|
|
51
40
|
Object.keys(_basketHelpers).forEach(function (key) {
|
|
52
41
|
if (key === "default" || key === "__esModule") return;
|
package/dist/helpers/index.d.ts
CHANGED
package/dist/helpers/index.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export * from "./advancedAttributeHelpers.mjs";
|
|
2
2
|
export * from "./arrayHelpers.mjs";
|
|
3
3
|
export * from "./attributeHelpers.mjs";
|
|
4
|
-
export * from "./autobind.mjs";
|
|
5
4
|
export * from "./basketHelpers.mjs";
|
|
6
5
|
export * from "./categoryHelper.mjs";
|
|
7
6
|
export * from "./filterHelper.mjs";
|
|
@@ -37,7 +37,7 @@ const getCheckoutToken = exports.getCheckoutToken = async function getCheckoutTo
|
|
|
37
37
|
carrier,
|
|
38
38
|
basketId: context.basketKey,
|
|
39
39
|
campaignKey: context.campaignKey
|
|
40
|
-
}).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"8.1
|
|
40
|
+
}).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"8.2.1"}`).setProtectedHeader({
|
|
41
41
|
alg: "HS256",
|
|
42
42
|
typ: "JWT"
|
|
43
43
|
}).sign(secret);
|
|
@@ -35,7 +35,7 @@ export const getCheckoutToken = async function getCheckoutToken2(jwtPayload = {}
|
|
|
35
35
|
carrier,
|
|
36
36
|
basketId: context.basketKey,
|
|
37
37
|
campaignKey: context.campaignKey
|
|
38
|
-
}).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"8.1
|
|
38
|
+
}).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"8.2.1"}`).setProtectedHeader({ alg: "HS256", typ: "JWT" }).sign(secret);
|
|
39
39
|
return {
|
|
40
40
|
accessToken: refreshedAccessToken,
|
|
41
41
|
checkoutJwt
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { SearchV2ResolveEndpointParameters, SearchV2SuggestionsEndpointParameters, SearchV2SuggestionsEndpointResponseData } from '../../types/sapi/search';
|
|
2
2
|
export declare const getSearchSuggestions: ({ term, with: _with, categoryId }: SearchV2SuggestionsEndpointParameters, { sapiClient, withParams }: import("../../types").RpcContext) => Promise<Response | SearchV2SuggestionsEndpointResponseData>;
|
|
3
|
-
export declare const resolveSearch: ({ term, with: _with, categoryId }: SearchV2ResolveEndpointParameters, { cached, sapiClient, withParams }: import("../../types").RpcContext) => Promise<import("@scayle/storefront-api").
|
|
3
|
+
export declare const resolveSearch: ({ term, with: _with, categoryId }: SearchV2ResolveEndpointParameters, { cached, sapiClient, withParams }: import("../../types").RpcContext) => Promise<import("@scayle/storefront-api/dist/shared/storefront-api.VFVDMd2H").S | null>;
|
package/dist/utils/user.d.ts
CHANGED
|
@@ -4,13 +4,13 @@ export declare const mergeBaskets: (fromBasketKey: string, toBasketKey: string,
|
|
|
4
4
|
}, context: RpcContext) => Promise<{
|
|
5
5
|
type: "failure";
|
|
6
6
|
statusCode: number;
|
|
7
|
-
basket: import("@scayle/storefront-api").
|
|
7
|
+
basket: import("@scayle/storefront-api/dist/shared/storefront-api.VFVDMd2H").f<import("@scayle/storefront-api/dist/shared/storefront-api.VFVDMd2H").a, import("@scayle/storefront-api/dist/shared/storefront-api.VFVDMd2H").V>;
|
|
8
8
|
} | {
|
|
9
9
|
readonly type: "success";
|
|
10
|
-
readonly basket: import("@scayle/storefront-api").
|
|
10
|
+
readonly basket: import("@scayle/storefront-api/dist/shared/storefront-api.VFVDMd2H").f<import("@scayle/storefront-api/dist/shared/storefront-api.VFVDMd2H").a, import("@scayle/storefront-api/dist/shared/storefront-api.VFVDMd2H").V>;
|
|
11
11
|
} | {
|
|
12
12
|
readonly type: "failure";
|
|
13
|
-
readonly basket: import("@scayle/storefront-api").
|
|
13
|
+
readonly basket: import("@scayle/storefront-api/dist/shared/storefront-api.VFVDMd2H").f<import("@scayle/storefront-api/dist/shared/storefront-api.VFVDMd2H").a, import("@scayle/storefront-api/dist/shared/storefront-api.VFVDMd2H").V>;
|
|
14
14
|
readonly errors: import("@scayle/storefront-api").AddOrUpdateItemError[];
|
|
15
15
|
} | undefined>;
|
|
16
16
|
export declare const mergeWishlists: (fromWishlistKey: string, toWishlistKey: string, withOptions: BasketWithOptions, context: RpcContext) => Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scayle/storefront-core",
|
|
3
|
-
"version": "8.1
|
|
3
|
+
"version": "8.2.1",
|
|
4
4
|
"description": "Collection of essential utilities to work with the Storefront API",
|
|
5
5
|
"author": "SCAYLE Commerce Engine",
|
|
6
6
|
"license": "MIT",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"test:ci": "vitest --run --passWithNoTests --coverage --reporter=default --reporter=junit --outputFile=./coverage/junit.xml"
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
|
-
"@scayle/storefront-api": "17.
|
|
74
|
+
"@scayle/storefront-api": "17.16.0",
|
|
75
75
|
"crypto-js": "^4.2.0",
|
|
76
76
|
"hookable": "^5.5.3",
|
|
77
77
|
"jose": "^5.6.3",
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.autobind = autobind;
|
|
7
|
-
const getAllProperties = obj => {
|
|
8
|
-
const properties = /* @__PURE__ */new Set();
|
|
9
|
-
if (!obj) {
|
|
10
|
-
return properties;
|
|
11
|
-
}
|
|
12
|
-
do {
|
|
13
|
-
for (const key of Reflect.ownKeys(obj)) {
|
|
14
|
-
properties.add([obj, key]);
|
|
15
|
-
}
|
|
16
|
-
} while ((obj = Reflect.getPrototypeOf(obj)) && obj !== Object.prototype);
|
|
17
|
-
return properties;
|
|
18
|
-
};
|
|
19
|
-
function autobind(self, {
|
|
20
|
-
include,
|
|
21
|
-
exclude
|
|
22
|
-
} = {}) {
|
|
23
|
-
const filter = key => {
|
|
24
|
-
const match = pattern => typeof pattern === "string" ? key === pattern : pattern.test(key);
|
|
25
|
-
if (include) {
|
|
26
|
-
return include.some(match);
|
|
27
|
-
}
|
|
28
|
-
if (exclude) {
|
|
29
|
-
return !exclude.some(match);
|
|
30
|
-
}
|
|
31
|
-
return true;
|
|
32
|
-
};
|
|
33
|
-
for (const it of getAllProperties(self.constructor.prototype)) {
|
|
34
|
-
const [object, key] = it;
|
|
35
|
-
if (key === "constructor" || !filter(key)) {
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
const descriptor = Reflect.getOwnPropertyDescriptor(object, key);
|
|
39
|
-
if (descriptor && typeof descriptor.value === "function") {
|
|
40
|
-
self[key] = self[key].bind(self);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return self;
|
|
44
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
type Options = Partial<{
|
|
2
|
-
readonly include: ReadonlyArray<string | RegExp>;
|
|
3
|
-
readonly exclude: ReadonlyArray<string | RegExp>;
|
|
4
|
-
}>;
|
|
5
|
-
/**
|
|
6
|
-
* Automatically bind methods to their class instance.
|
|
7
|
-
* @param self - An object with methods to bind.
|
|
8
|
-
* @example
|
|
9
|
-
```
|
|
10
|
-
import { autobind } from '@scayle/storefront-core'
|
|
11
|
-
|
|
12
|
-
class Unicorn {
|
|
13
|
-
constructor(name) {
|
|
14
|
-
this.name = name;
|
|
15
|
-
autobind(this);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
message() {
|
|
19
|
-
return `${this.name} is awesome!`;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const unicorn = new Unicorn('Rainbow');
|
|
24
|
-
|
|
25
|
-
// Grab the method off the class instance
|
|
26
|
-
const message = unicorn.message;
|
|
27
|
-
|
|
28
|
-
// Still bound to the class instance
|
|
29
|
-
message();
|
|
30
|
-
// => 'Rainbow is awesome!'
|
|
31
|
-
|
|
32
|
-
// Without `autobind(this)`, the above would have resulted in
|
|
33
|
-
|
|
34
|
-
message();
|
|
35
|
-
//=> Error: Cannot read property 'name' of undefined
|
|
36
|
-
```
|
|
37
|
-
*/
|
|
38
|
-
export declare function autobind<SelfType extends Record<string, any>>(self: SelfType, { include, exclude }?: Options): SelfType;
|
|
39
|
-
export {};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
const getAllProperties = (obj) => {
|
|
2
|
-
const properties = /* @__PURE__ */ new Set();
|
|
3
|
-
if (!obj) {
|
|
4
|
-
return properties;
|
|
5
|
-
}
|
|
6
|
-
do {
|
|
7
|
-
for (const key of Reflect.ownKeys(obj)) {
|
|
8
|
-
properties.add([obj, key]);
|
|
9
|
-
}
|
|
10
|
-
} while ((obj = Reflect.getPrototypeOf(obj)) && obj !== Object.prototype);
|
|
11
|
-
return properties;
|
|
12
|
-
};
|
|
13
|
-
export function autobind(self, { include, exclude } = {}) {
|
|
14
|
-
const filter = (key) => {
|
|
15
|
-
const match = (pattern) => typeof pattern === "string" ? key === pattern : pattern.test(key);
|
|
16
|
-
if (include) {
|
|
17
|
-
return include.some(match);
|
|
18
|
-
}
|
|
19
|
-
if (exclude) {
|
|
20
|
-
return !exclude.some(match);
|
|
21
|
-
}
|
|
22
|
-
return true;
|
|
23
|
-
};
|
|
24
|
-
for (const it of getAllProperties(self.constructor.prototype)) {
|
|
25
|
-
const [object, key] = it;
|
|
26
|
-
if (key === "constructor" || !filter(key)) {
|
|
27
|
-
continue;
|
|
28
|
-
}
|
|
29
|
-
const descriptor = Reflect.getOwnPropertyDescriptor(object, key);
|
|
30
|
-
if (descriptor && typeof descriptor.value === "function") {
|
|
31
|
-
self[key] = self[key].bind(self);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return self;
|
|
35
|
-
}
|