@shopgate/pwa-core 7.32.2-alpha.1 → 7.32.2-alpha.10

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.
@@ -1,4 +1,3 @@
1
- import "core-js/modules/es.array.includes.js";
2
1
  import { logger, hasSGJavaScriptBridge } from "../../helpers";
3
2
  import { isValidVersion, getLibVersion, isVersionAtLeast } from "../../helpers/version";
4
3
  import logGroup from "../../helpers/logGroup";
@@ -1,5 +1,4 @@
1
1
  import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
2
- import "core-js/modules/es.string.replace.js";
3
2
  import AppCommandRequest from "../AppCommandRequest";
4
3
 
5
4
  /**
@@ -1,5 +1,4 @@
1
1
  import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
2
- import "core-js/modules/es.array.includes.js";
3
2
  import AppPermissionsRequest from "./AppPermissionsRequest";
4
3
  import { availablePermissionsIds } from "../../constants/AppPermissions";
5
4
  import { COMMAND_GET_APP_PERMISSIONS } from "../../constants/AppCommands";
@@ -1,5 +1,4 @@
1
1
  import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
2
- import "core-js/modules/es.array.includes.js";
3
2
  import AppPermissionsRequest from "./AppPermissionsRequest";
4
3
  import { availablePermissionsIds } from "../../constants/AppPermissions";
5
4
  import { COMMAND_REQUEST_APP_PERMISSIONS } from "../../constants/AppCommands";
@@ -1,5 +1,4 @@
1
1
  import _createClass from "@babel/runtime/helpers/createClass";
2
- import "core-js/modules/es.array.includes.js";
3
2
  import { logger } from "../../helpers";
4
3
  import event from "../Event";
5
4
  import { TYPE_TRUSTED } from "../../constants/Pipeline";
@@ -1,4 +1,3 @@
1
- import "core-js/modules/es.array.includes.js";
2
1
  import { logger } from "../../helpers";
3
2
  import event from "../Event";
4
3
 
@@ -1,4 +1,3 @@
1
- import "core-js/modules/es.string.replace.js";
2
1
  import EventEmitter from 'events';
3
2
  import { DEFAULT_CONTEXT, SOURCE_PIPELINE, DEFAULT_SEVERITY } from "../../constants/ErrorManager";
4
3
  export const emitter = new EventEmitter();
@@ -1,5 +1,4 @@
1
1
  import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
2
- import "core-js/modules/es.array.includes.js";
3
2
  import EventEmitter from 'events';
4
3
  import { logger } from "../../helpers";
5
4
  const HANDLER_ADD = 'add';
@@ -1,5 +1,4 @@
1
1
  import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
2
- import "core-js/modules/es.array.includes.js";
3
2
  import { logger } from "../../helpers";
4
3
  import logGroup from "../../helpers/logGroup";
5
4
  import event from "../Event";
@@ -1,4 +1,3 @@
1
- import "core-js/modules/es.array.includes.js";
2
1
  import AppCommand from "../AppCommand";
3
2
  import event from "../Event";
4
3
  import errorManager from "../ErrorManager";
@@ -1,5 +1,4 @@
1
1
  import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
2
- import "core-js/modules/es.array.includes.js";
3
2
  import Request from "../Request";
4
3
  import pipelineManager from "../PipelineManager";
5
4
  import { CURRENT_VERSION } from "../../constants/Pipeline";
@@ -1,6 +1,5 @@
1
1
  import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
2
2
  import _createClass from "@babel/runtime/helpers/createClass";
3
- import "core-js/modules/es.array.includes.js";
4
3
  import { logger } from "../../helpers";
5
4
  import * as errorHandleTypes from "../../constants/ErrorHandleTypes";
6
5
  import * as processTypes from "../../constants/ProcessTypes";
@@ -1,4 +1,3 @@
1
- import "core-js/modules/es.array.includes.js";
2
1
  import { logger } from "../../helpers";
3
2
  import { isLibVersionAtLeast } from "../../helpers/version";
4
3
  import ScannerEvent from "../ScannerEvent";
@@ -1,4 +1,3 @@
1
- import "core-js/modules/es.array.includes.js";
2
1
  import { logger } from "../../helpers";
3
2
  import AppScanner from "../Scanner";
4
3
 
@@ -1,4 +1,3 @@
1
- import "core-js/modules/es.array.includes.js";
2
1
  import { logger } from "../../helpers";
3
2
  import event from "../Event";
4
3
  import registerEvents from "../../commands/registerEvents";
@@ -1,4 +1,3 @@
1
- import "core-js/modules/es.array.includes.js";
2
1
  import AppCommand from "../classes/AppCommand";
3
2
  import { logger } from "../helpers";
4
3
 
@@ -1,4 +1,3 @@
1
- import "core-js/modules/es.string.replace.js";
2
1
  import AppCommand from "../classes/AppCommand";
3
2
 
4
3
  /**
@@ -0,0 +1,75 @@
1
+ const UNDESCRIBABLE = 'a value that could not be described';
2
+
3
+ /**
4
+ * Describes a value without its content.
5
+ * @param {*} value The value.
6
+ * @param {Array[]} parents The arrays the value is nested in.
7
+ * @returns {string} The description.
8
+ */
9
+ const describe = (value, parents) => {
10
+ if (Array.isArray(value)) {
11
+ if (parents.includes(value)) {
12
+ return '[circular]';
13
+ }
14
+ return `[${value.map(entry => describe(entry, [].concat(parents, [value]))).join(', ')}]`;
15
+ }
16
+ if (!value || typeof value !== 'object' || value instanceof Error) {
17
+ return String(value);
18
+ }
19
+ const code = typeof value.code === 'string' ? `code: "${value.code}", ` : '';
20
+ return `{${code}keys: ${Object.keys(value).join(', ')}}`;
21
+ };
22
+
23
+ /**
24
+ * Describes a value without its content, since it can be personal data. It never throws.
25
+ * @param {*} value The value.
26
+ * @returns {string} Primitives and errors as text, objects as their keys and their error code.
27
+ */
28
+ export const describeValue = value => {
29
+ try {
30
+ return describe(value, []);
31
+ } catch (error) {
32
+ return UNDESCRIBABLE;
33
+ }
34
+ };
35
+
36
+ /**
37
+ * Defines properties on an error itself, so that they also replace properties the error only
38
+ * has a getter for.
39
+ * @param {Error} error The error.
40
+ * @param {Object} properties The properties to add.
41
+ * @returns {Error} The error.
42
+ */
43
+ const defineProperties = (error, properties) => {
44
+ Object.keys(properties).forEach(key => {
45
+ Object.defineProperty(error, key, {
46
+ value: properties[key],
47
+ writable: true,
48
+ enumerable: true,
49
+ configurable: true
50
+ });
51
+ });
52
+ return error;
53
+ };
54
+
55
+ /**
56
+ * Turns a thrown value into an error and adds properties to it. It never throws.
57
+ * @param {*} thrown The thrown value.
58
+ * @param {Object} [properties={}] The properties to add.
59
+ * @returns {Error} The value itself when it is an error that takes the properties, otherwise an
60
+ * error that describes it.
61
+ */
62
+ export const toError = (thrown, properties = {}) => {
63
+ /**
64
+ * @returns {Error} A new error that describes the thrown value.
65
+ */
66
+ const describeThrown = () => defineProperties(new Error(describeValue(thrown)), properties);
67
+ if (!(thrown instanceof Error)) {
68
+ return describeThrown();
69
+ }
70
+ try {
71
+ return defineProperties(thrown, properties);
72
+ } catch (error) {
73
+ return describeThrown();
74
+ }
75
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopgate/pwa-core",
3
- "version": "7.32.2-alpha.1",
3
+ "version": "7.32.2-alpha.10",
4
4
  "description": "Core library for the Shopgate Connect PWA.",
5
5
  "author": "Support <support@shopgate.com>",
6
6
  "license": "Apache-2.0",
@@ -19,12 +19,12 @@
19
19
  "connect"
20
20
  ],
21
21
  "devDependencies": {
22
- "@types/lodash": "^4.17.24"
22
+ "@types/lodash": "^4.17.25"
23
23
  },
24
24
  "dependencies": {
25
25
  "crypto-js": "3.1.9-1",
26
26
  "detector": "^2.5.0",
27
- "lodash": "^4.17.23",
27
+ "lodash": "^4.18.1",
28
28
  "mobile-detect": "^1.4.3"
29
29
  }
30
30
  }