@shopgate/webpack 7.30.3-beta.1 → 7.30.3-beta.3

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.
Files changed (42) hide show
  1. package/local-packages/pwa-extension-kit/src/components/ProductCharacteristics/__snapshots__/spec.jsx.snap +428 -0
  2. package/local-packages/pwa-extension-kit/src/components/ProductCharacteristics/index.jsx +7 -0
  3. package/local-packages/pwa-extension-kit/src/components/ProductCharacteristics/spec.jsx +128 -0
  4. package/local-packages/pwa-extension-kit/src/components/README.md +38 -0
  5. package/local-packages/pwa-extension-kit/src/components/index.js +8 -0
  6. package/local-packages/pwa-extension-kit/src/components/index.spec.js +11 -0
  7. package/local-packages/pwa-extension-kit/src/connectors/README.md +222 -0
  8. package/local-packages/pwa-extension-kit/src/connectors/index.js +23 -0
  9. package/local-packages/pwa-extension-kit/src/connectors/index.spec.js +29 -0
  10. package/local-packages/pwa-extension-kit/src/connectors/selectors/user.js +24 -0
  11. package/local-packages/pwa-extension-kit/src/connectors/withHistoryActions.jsx +75 -0
  12. package/local-packages/pwa-extension-kit/src/connectors/withHistoryActions.spec.jsx +72 -0
  13. package/local-packages/pwa-extension-kit/src/connectors/withPageProductId.jsx +61 -0
  14. package/local-packages/pwa-extension-kit/src/connectors/withPageProductId.spec.jsx +73 -0
  15. package/local-packages/pwa-extension-kit/src/connectors/withPageState.jsx +49 -0
  16. package/local-packages/pwa-extension-kit/src/connectors/withPageState.spec.jsx +59 -0
  17. package/local-packages/pwa-extension-kit/src/connectors/withProductContext.jsx +38 -0
  18. package/local-packages/pwa-extension-kit/src/connectors/withProductContext.spec.jsx +55 -0
  19. package/local-packages/pwa-extension-kit/src/connectors/withThemeComponents.jsx +37 -0
  20. package/local-packages/pwa-extension-kit/src/connectors/withThemeComponents.spec.jsx +43 -0
  21. package/local-packages/pwa-extension-kit/src/connectors/withUser.jsx +61 -0
  22. package/local-packages/pwa-extension-kit/src/connectors/withUser.spec.jsx +101 -0
  23. package/local-packages/pwa-extension-kit/src/env/README.md +28 -0
  24. package/local-packages/pwa-extension-kit/src/env/helpers/index.js +7 -0
  25. package/local-packages/pwa-extension-kit/src/env/helpers/index.spec.js +12 -0
  26. package/local-packages/pwa-extension-kit/src/env/helpers/isIOSTheme.js +10 -0
  27. package/local-packages/pwa-extension-kit/src/env/helpers/isIOSTheme.spec.js +16 -0
  28. package/local-packages/pwa-extension-kit/src/env/index.js +7 -0
  29. package/local-packages/pwa-extension-kit/src/env/index.spec.js +13 -0
  30. package/local-packages/pwa-extension-kit/src/helpers/README.md +30 -0
  31. package/local-packages/pwa-extension-kit/src/helpers/TaggedLogger.js +50 -0
  32. package/local-packages/pwa-extension-kit/src/helpers/TaggedLogger.spec.js +41 -0
  33. package/local-packages/pwa-extension-kit/src/helpers/_getConsole.js +4 -0
  34. package/local-packages/pwa-extension-kit/src/helpers/index.js +7 -0
  35. package/local-packages/pwa-extension-kit/src/helpers/index.spec.js +12 -0
  36. package/local-packages/pwa-extension-kit/src/index.js +16 -0
  37. package/local-packages/pwa-extension-kit/src/index.spec.js +16 -0
  38. package/local-packages/pwa-extension-kit/src/proptypes/README.md +9 -0
  39. package/local-packages/pwa-extension-kit/src/proptypes/User.js +15 -0
  40. package/local-packages/pwa-extension-kit/src/proptypes/index.js +7 -0
  41. package/package.json +1 -1
  42. package/webpack.config.js +7 -15
@@ -0,0 +1,38 @@
1
+ import React, { Component } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { Theme } from '@shopgate/pwa-common/context';
4
+
5
+ /**
6
+ * WithProductContext component.
7
+ */
8
+ // eslint-disable-next-line react/prefer-stateless-function, require-jsdoc
9
+ class WithProductContext extends Component {
10
+ static propTypes = {
11
+ WrappedComponent: PropTypes.func.isRequired,
12
+ };
13
+
14
+ /**
15
+ * @inheritDoc
16
+ */
17
+ render() {
18
+ const { WrappedComponent, ...otherProps } = this.props;
19
+ return (
20
+ <Theme>
21
+ {(props) => {
22
+ const { contexts: { ProductContext } } = props;
23
+
24
+ return (
25
+ <ProductContext.Consumer>
26
+ {productParams =>
27
+ <WrappedComponent productContext={productParams} {...otherProps} />
28
+ }
29
+ </ProductContext.Consumer>
30
+ );
31
+ }}
32
+ </Theme>
33
+ );
34
+ }
35
+ }
36
+
37
+ export default WrappedComponent => props =>
38
+ <WithProductContext WrappedComponent={WrappedComponent} {...props} />;
@@ -0,0 +1,55 @@
1
+ import React from 'react';
2
+ import { mount } from 'enzyme';
3
+ import WithProductContext from './withProductContext';
4
+
5
+ // eslint-disable-next-line react/prop-types, require-jsdoc
6
+ const TestingComponent = props => <div>Other prop: {props.foo}</div>;
7
+
8
+ jest.mock('@shopgate/pwa-common/context', () => ({
9
+ // eslint-disable-next-line react/prop-types
10
+ Theme: ({ children, ...otherProps }) => {
11
+ const Child = children;
12
+
13
+ const props = {
14
+ AppBar: () => null,
15
+ Drawer: () => null,
16
+ View: () => null,
17
+ contexts: {
18
+ ProductContext: {
19
+ // eslint-disable-next-line react/prop-types
20
+ Consumer: ({ children: ContextChildren, ...contextProps }) => (
21
+ <ContextChildren
22
+ options={{}}
23
+ productId="123"
24
+ variantId="123-45"
25
+ conditioner={{}}
26
+ {...contextProps}
27
+ />
28
+ ),
29
+ },
30
+ },
31
+ ...otherProps,
32
+ };
33
+
34
+ return (
35
+ <Child {...props} />
36
+ );
37
+ },
38
+ }));
39
+
40
+ describe('connectors/withProductContext', () => {
41
+ it('should render with specified props', () => {
42
+ const ConnectedComponent = WithProductContext(TestingComponent);
43
+ const component = mount(<ConnectedComponent foo="bar" />);
44
+
45
+ expect(component.find('TestingComponent').props()).toEqual({
46
+ foo: 'bar',
47
+ productContext: {
48
+ options: {},
49
+ conditioner: {},
50
+ productId: '123',
51
+ variantId: '123-45',
52
+ },
53
+ });
54
+ });
55
+ });
@@ -0,0 +1,37 @@
1
+ import React, { Component } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { Theme } from '@shopgate/pwa-common/context';
4
+
5
+ /**
6
+ * WithThemeComponents component.
7
+ */
8
+ // eslint-disable-next-line react/prefer-stateless-function, require-jsdoc
9
+ class WithThemeComponents extends Component {
10
+ static propTypes = {
11
+ WrappedComponent: PropTypes.func.isRequired,
12
+ };
13
+
14
+ /**
15
+ * @inheritDoc
16
+ */
17
+ render() {
18
+ const { WrappedComponent, ...otherProps } = this.props;
19
+ return (
20
+ <Theme>
21
+ {(props) => {
22
+ const { contexts, ...components } = props;
23
+
24
+ return (
25
+ <WrappedComponent
26
+ {...components}
27
+ {...otherProps}
28
+ />
29
+ );
30
+ }}
31
+ </Theme>
32
+ );
33
+ }
34
+ }
35
+
36
+ export default WrappedComponent => props =>
37
+ <WithThemeComponents WrappedComponent={WrappedComponent} {...props} />;
@@ -0,0 +1,43 @@
1
+ import React from 'react';
2
+ import { mount } from 'enzyme';
3
+ import withThemeComponents from './withThemeComponents';
4
+
5
+ // eslint-disable-next-line react/prop-types, require-jsdoc
6
+ const TestingComponent = props => <div>Other prop: {props.foo}</div>;
7
+
8
+ jest.mock('@shopgate/pwa-common/context', () => ({
9
+ // eslint-disable-next-line react/prop-types
10
+ Theme: ({ children, ...otherProps }) => {
11
+ const Child = children;
12
+
13
+ const props = {
14
+ AppBar: () => null,
15
+ Drawer: () => null,
16
+ View: () => null,
17
+ contexts: {
18
+ ProductContext: {},
19
+ },
20
+ ...otherProps,
21
+ };
22
+
23
+ return (
24
+ <Child {...props} />
25
+ );
26
+ },
27
+ }));
28
+
29
+ describe('connectors/withThemeComponents', () => {
30
+ it('should render with specified props', () => {
31
+ const ConnectedComponent = withThemeComponents(TestingComponent);
32
+ const component = mount(<ConnectedComponent foo="bar" />);
33
+
34
+ expect(component.find('TestingComponent').prop('contexts')).toBeUndefined();
35
+
36
+ expect(Object.keys(component.find('TestingComponent').props())).toMatchObject([
37
+ 'AppBar',
38
+ 'Drawer',
39
+ 'View',
40
+ 'foo',
41
+ ]);
42
+ });
43
+ });
@@ -0,0 +1,61 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { connect } from 'react-redux';
4
+ import {
5
+ isUserLoggedIn,
6
+ getUserFirstName,
7
+ getUserEmail,
8
+ getUserDisplayName,
9
+ } from '@shopgate/pwa-common/selectors/user';
10
+ import {
11
+ getUserLastName,
12
+ getUserId,
13
+ } from './selectors/user';
14
+ import { User } from '../proptypes';
15
+
16
+ /**
17
+ * WithUser wrapper.
18
+ * @param {function} WrappedComponent Wrapped component.
19
+ * @param {Object} user Mapped user data.
20
+ * @returns {JSX}
21
+ */
22
+ const WithUser = ({ WrappedComponent, user, ...otherProps }) => (
23
+ <WrappedComponent
24
+ user={user}
25
+ {...otherProps}
26
+ />
27
+ );
28
+
29
+ WithUser.propTypes = {
30
+ user: User.isRequired,
31
+ WrappedComponent: PropTypes.func.isRequired,
32
+ };
33
+
34
+ /**
35
+ * Maps state to props.
36
+ * @param {Object} state State.
37
+ * @returns {Object}
38
+ */
39
+ const mapStateToProps = state => ({
40
+ user: {
41
+ isLoggedIn: isUserLoggedIn(state) || false,
42
+ id: getUserId(state) || null,
43
+ email: getUserEmail(state) || null,
44
+ firstName: getUserFirstName(state) || null,
45
+ lastName: getUserLastName(state) || null,
46
+ displayName: getUserDisplayName(state) || null,
47
+ },
48
+
49
+ });
50
+
51
+ const ConnectedWithUser = connect(mapStateToProps)(WithUser);
52
+
53
+ /**
54
+ * Returns a Wrapped Component with current user data.
55
+ * @param {function} WrappedComponent Component which will be wrapped with data connector.
56
+ * @returns {function} React component.
57
+ */
58
+ const withUser = WrappedComponent => props =>
59
+ <ConnectedWithUser WrappedComponent={WrappedComponent} {...props} />;
60
+
61
+ export default withUser;
@@ -0,0 +1,101 @@
1
+ import React from 'react';
2
+ import { mount } from 'enzyme';
3
+ import withUser from './withUser';
4
+
5
+ let mockedMapStateToPropsSpy = jest.fn();
6
+ const mockedMapStateToPropsResult = {
7
+ user: {
8
+ isLoggedIn: true,
9
+ id: 'test-id',
10
+ email: 'foo@example.com',
11
+ firstName: 'First name',
12
+ lastName: 'Last name',
13
+ displayName: 'First name Last name',
14
+ }
15
+ }
16
+ jest.mock('react-redux', () => ({
17
+ connect: (mapStateToProps) => Component => props => {
18
+ mockedMapStateToPropsSpy(mapStateToProps);
19
+ return (
20
+ <Component
21
+ user={mockedMapStateToPropsResult.user}
22
+ {...props}
23
+ />
24
+ )
25
+ }
26
+ }));
27
+ describe('/connectors/withUser', () => {
28
+ const TestedComponent = props => <div>Test</div>;
29
+ it('should create component and pass external props', () => {
30
+ const ConnectedComponent = withUser(TestedComponent);
31
+ const component = mount(<ConnectedComponent foo="bar" />);
32
+
33
+ expect(component.find('TestedComponent').props()).toEqual({
34
+ user: {
35
+ ...mockedMapStateToPropsResult.user,
36
+ },
37
+ foo: 'bar',
38
+ });
39
+ });
40
+
41
+ it('should map state to props correctly when data is available', () => {
42
+ const state = {
43
+ user: {
44
+ login: {
45
+ isLoggedIn: true,
46
+ },
47
+ data: {
48
+ id: 'foo',
49
+ mail: 'bar',
50
+ firstName: 'first name',
51
+ lastName: 'last name',
52
+ },
53
+ },
54
+ };
55
+
56
+ const mapStateToProps = mockedMapStateToPropsSpy.mock.calls[0][0];
57
+ expect(mapStateToProps(state).user).toEqual({
58
+ isLoggedIn: true,
59
+ id: 'foo',
60
+ email: 'bar',
61
+ firstName: 'first name',
62
+ lastName: 'last name',
63
+ displayName: 'first name last name',
64
+ });
65
+ });
66
+
67
+ it('should map state to props correctly when data is NOT available', () => {
68
+ const state = {
69
+ user: {
70
+ login: {},
71
+ data: {},
72
+ },
73
+ };
74
+
75
+ const mapStateToProps = mockedMapStateToPropsSpy.mock.calls[0][0];
76
+ expect(mapStateToProps(state).user).toEqual({
77
+ isLoggedIn: false,
78
+ id: null,
79
+ email: null,
80
+ firstName: null,
81
+ lastName: null,
82
+ displayName: null,
83
+ });
84
+ });
85
+
86
+ it('should map state to props correctly when data is NOT prepared', () => {
87
+ const state = {
88
+ user: {},
89
+ };
90
+
91
+ const mapStateToProps = mockedMapStateToPropsSpy.mock.calls[0][0];
92
+ expect(mapStateToProps(state).user).toEqual({
93
+ isLoggedIn: false,
94
+ id: null,
95
+ email: null,
96
+ firstName: null,
97
+ lastName: null,
98
+ displayName: null,
99
+ });
100
+ });
101
+ });
@@ -0,0 +1,28 @@
1
+ # Shopgate Connect - PWA Extension Kit
2
+ ## .env - environment helpers
3
+ ### isIOSTheme
4
+ This function checks the extension runs in an [ios theme](https://github.com/shopgate/theme-ios11).
5
+ Check if performed during the app lifetime. Every time the function is called.
6
+
7
+ #### Purpose
8
+ Most Shopgate apps are deployed with gmd and ios templates. Even though both templates are quite similar, there are some rare cases when it's needed to adjust your component in order to achieve better user experience, or avoid some pitfalls.
9
+
10
+ #### Not intended usage. When NOT to use it
11
+ It DOES NOT tests against the navigator / User Agent. Some Shopgate apps are configured in a way that in both iOS and Android same template is used.
12
+
13
+ It should not be used to obtain if current platform is either iOS or Android. To check what is the current platform please use `@shopgate/pwa-common/selectors/client` package.
14
+
15
+ #### Example usage:
16
+ ```jsx
17
+ import isIOSTheme from '@shopgate-ps/pwa-extension-kit/env/helpers/isIOSTheme';
18
+ import ButtonOptimisedForIOS from '../components/iosButton';
19
+ import ButtonOptimisedForGMD from '../components/gmdButton';
20
+
21
+ function renderButton() {
22
+ if (isIOSTheme()) {
23
+ return <ButtonOptimisedForIOS />;
24
+ }
25
+
26
+ return <ButtonOptimisedForGMD />;
27
+ }
28
+ ```
@@ -0,0 +1,7 @@
1
+ import isIOSTheme from './isIOSTheme';
2
+
3
+ export { isIOSTheme };
4
+
5
+ export default {
6
+ isIOSTheme,
7
+ };
@@ -0,0 +1,12 @@
1
+ import helpers, { isIOSTheme } from './index';
2
+
3
+ describe('env/helpers', () => {
4
+ it('should export all functions as default', () => {
5
+ expect(typeof helpers).toBe('object');
6
+ expect(typeof helpers.isIOSTheme).toBe('function');
7
+ });
8
+
9
+ it('should export isIOSTheme as named export', () => {
10
+ expect(typeof isIOSTheme).toBe('function');
11
+ });
12
+ });
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Checks if current theme is an iOS theme.
3
+ * @link https://github.com/shopgate-professional-services/pwa-extension-kit/src/env/README.md
4
+ * @returns {boolean}
5
+ */
6
+ function isIOSTheme() {
7
+ return process.env.THEME.includes('ios');
8
+ }
9
+
10
+ export default isIOSTheme;
@@ -0,0 +1,16 @@
1
+ import isiOSTheme from './isIOSTheme';
2
+
3
+ describe('isiOSTheme', () => {
4
+ const orgTHEME = process.env.THEME;
5
+ afterAll(() => {
6
+ process.env.THEME = orgTHEME;
7
+ });
8
+ it('should return false for gmd', () => {
9
+ process.env.THEME = 'gmd';
10
+ expect(isiOSTheme()).toBe(false);
11
+ });
12
+ it('should return true for ios', () => {
13
+ process.env.THEME = 'ios';
14
+ expect(isiOSTheme()).toBe(true);
15
+ });
16
+ });
@@ -0,0 +1,7 @@
1
+ import helpers from './helpers';
2
+
3
+ export { helpers };
4
+
5
+ export default {
6
+ helpers,
7
+ };
@@ -0,0 +1,13 @@
1
+ import env, { helpers } from './index';
2
+
3
+ describe('env/helpers', () => {
4
+ it('should export all functions as default', () => {
5
+ expect(typeof env).toBe('object');
6
+ expect(typeof env.helpers).toBe('object');
7
+ });
8
+
9
+ it('should export isIOSTheme as named export', () => {
10
+ expect(typeof helpers).toBe('object');
11
+ expect(typeof helpers.isIOSTheme).toBe('function');
12
+ });
13
+ });
@@ -0,0 +1,30 @@
1
+ # Shopgate Connect - PWA Extension Kit
2
+ ## .helpers
3
+ ### TaggedLogger
4
+ This class is handy for printing tagged logs in an extension or module. We encourage to use tagged logs since it helps everyone in case of debugging (also on production) by showing explicitly which extension/module prints the log.
5
+
6
+ #### Usage
7
+ To instantiate the `TaggedLogger` simply create new by adding a tag name: `new TaggedLogger('MyTagName')`.
8
+
9
+ `TaggedLogger` is a wrapper around `console` which works both in the node.js and browser environment in a similar way.
10
+
11
+ Currently supported methods are:
12
+ - `.log` - prints decorated `console.log`
13
+ - `.warn` - prints decorated `console.warn`
14
+ - `.error` - prints decorated `console.error`
15
+
16
+ #### Example usage:
17
+ ```jsx
18
+ import { TaggedLogger} from '@shopgate-ps/pwa-extension-kit/helpers'
19
+
20
+ function veryComplexFunctionOrClass() {
21
+ const logger = new TaggedLogger('MyVeryComplexFunctionOrClass');
22
+
23
+ // Will result in console.log("[MyVeryComplexFunctionOrClass] Starting my complex procedure")
24
+ logger.log('Starting my complex procedure');
25
+
26
+ const response = {foo: 'bar'};
27
+ // Will result in console.error("[MyVeryComplexFunctionOrClass] Unexpected response", response)
28
+ logger.error('Unexpected response', response);
29
+ }
30
+ ```
@@ -0,0 +1,50 @@
1
+ import getConsole from './_getConsole';
2
+
3
+ const console = getConsole();
4
+ /**
5
+ * Tagged Logger.
6
+ * @link https://github.com/shopgate-professional-services/pwa-extension-kit/blob/master/helpers/README.md
7
+ */
8
+ class TaggedLogger {
9
+ /**
10
+ * Instantiate TaggedLogger with given tag.
11
+ * @param {string} tag Tag which will be appended to all logs.
12
+ */
13
+ constructor(tag) {
14
+ this.tag = tag;
15
+ }
16
+
17
+ /**
18
+ * Prints actual log.
19
+ * @param {string} method Name of method (log, warn, error)
20
+ */
21
+ print(method, message, ...rest) {
22
+ console[method](`[${this.tag}] ${message}`, ...rest);
23
+ }
24
+
25
+ /**
26
+ * Prints tagged log.
27
+ * @param {string} message Log message.
28
+ */
29
+ log(message, ...args) {
30
+ this.print('log', message, ...args);
31
+ }
32
+
33
+ /**
34
+ * Prints tagged warning.
35
+ * @param {string} message Log message.
36
+ */
37
+ warn(message, ...args) {
38
+ this.print('warn', message, ...args);
39
+ }
40
+
41
+ /**
42
+ * Prints tagged error.
43
+ * @param {string} message Log message.
44
+ */
45
+ error(message, ...args) {
46
+ this.print('error', message, ...args);
47
+ }
48
+ }
49
+
50
+ export default TaggedLogger;
@@ -0,0 +1,41 @@
1
+ import TaggedLogger from './TaggedLogger';
2
+
3
+ const mockedLogMethod = jest.fn();
4
+
5
+ jest.mock('./_getConsole', () => () => ({
6
+ log: (...args) => mockedLogMethod('log', ...args),
7
+ warn: (...args) => mockedLogMethod('warn', ...args),
8
+ error: (...args) => mockedLogMethod('error', ...args),
9
+ }));
10
+
11
+ describe('helpers/TaggedLogger', () => {
12
+ const testTag = 'TEST_TAG';
13
+ const expectedTagPrefix = '[TEST_TAG]';
14
+ let instance;
15
+
16
+ beforeEach(() => {
17
+ jest.clearAllMocks();
18
+ });
19
+
20
+ it('should create object', () => {
21
+ instance = new TaggedLogger(testTag);
22
+ expect(typeof instance).toBe('object');
23
+ expect(instance.tag).toBe(testTag);
24
+ });
25
+
26
+ const supportedMethods = ['log', 'warn', 'error'];
27
+
28
+ supportedMethods.forEach((method) => {
29
+ it(`should send tagged .${method} with message only`, () => {
30
+ const text = `Log message only for ${method}`;
31
+ instance[method](text);
32
+ expect(mockedLogMethod).toHaveBeenCalledWith(method, `${expectedTagPrefix} ${text}`);
33
+ });
34
+
35
+ it(`should send tagged .${method} with arguments`, () => {
36
+ const text = `Log message with arguments for ${method}`;
37
+ instance[method](text, 1, 2);
38
+ expect(mockedLogMethod).toHaveBeenCalledWith(method, `${expectedTagPrefix} ${text}`, 1, 2);
39
+ });
40
+ });
41
+ });
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Warning: not intended for public usage!
3
+ */
4
+ export default () => console;
@@ -0,0 +1,7 @@
1
+ import TaggedLogger from './TaggedLogger';
2
+
3
+ export { TaggedLogger };
4
+
5
+ export default {
6
+ TaggedLogger,
7
+ };
@@ -0,0 +1,12 @@
1
+ import helpers, { TaggedLogger } from './index';
2
+
3
+ describe('/helpers', () => {
4
+ it('should export all functions as default', () => {
5
+ expect(typeof helpers).toBe('object');
6
+ expect(typeof helpers.TaggedLogger).toBe('function');
7
+ });
8
+
9
+ it('should export as named export', () => {
10
+ expect(typeof TaggedLogger).toBe('function');
11
+ });
12
+ });
@@ -0,0 +1,16 @@
1
+ import env from './env';
2
+ import connectors from './connectors';
3
+ import helpers from './helpers';
4
+
5
+ export { env };
6
+
7
+ export { connectors };
8
+
9
+ export { helpers };
10
+
11
+ export default {
12
+ env,
13
+ connectors,
14
+ helpers,
15
+ };
16
+
@@ -0,0 +1,16 @@
1
+ import kit, { env, connectors, helpers } from './index';
2
+
3
+ describe('index', () => {
4
+ it('should export all functions as default', () => {
5
+ expect(typeof kit).toBe('object');
6
+ expect(typeof kit.env).toBe('object');
7
+ expect(typeof kit.connectors).toBe('object');
8
+ expect(typeof kit.helpers).toBe('object');
9
+ });
10
+
11
+ it('should export as named export', () => {
12
+ expect(typeof env).toBe('object');
13
+ expect(typeof connectors).toBe('object');
14
+ expect(typeof helpers).toBe('object');
15
+ });
16
+ });
@@ -0,0 +1,9 @@
1
+ # Shopgate Connect - PWA Extension Kit
2
+ ## .propTypes
3
+ Common prop types definitions used within the extension kit.
4
+ All objects here are valid PropTypes objects (ready to be used in React component's prop types definition);
5
+
6
+ ### User
7
+ User data object. Properties and example usage is described in [withUser] connector.
8
+
9
+ [withUser]: https://github.com/shopgate-professional-services/pwa-extension-kit/blob/master/src/connectors/README.md#withUser
@@ -0,0 +1,15 @@
1
+ import PropTypes from 'prop-types';
2
+
3
+ const User = PropTypes.shape({
4
+ isLoggedIn: PropTypes.bool.isRequired,
5
+ id: PropTypes.oneOfType([
6
+ PropTypes.string,
7
+ PropTypes.number,
8
+ ]),
9
+ email: PropTypes.string,
10
+ firstName: PropTypes.string,
11
+ lastName: PropTypes.string,
12
+ displayName: PropTypes.string,
13
+ });
14
+
15
+ export default User;
@@ -0,0 +1,7 @@
1
+ import User from './User';
2
+
3
+ export { User };
4
+
5
+ export default {
6
+ User,
7
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopgate/webpack",
3
- "version": "7.30.3-beta.1",
3
+ "version": "7.30.3-beta.3",
4
4
  "description": "The webpack configuration for Shopgate's Engage.",
5
5
  "main": "webpack.config.js",
6
6
  "license": "Apache-2.0",