@salesforce/pwa-kit-create-app 3.12.0-preview.2 → 3.12.0-preview.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.
@@ -6,7 +6,7 @@
6
6
  */
7
7
  /* eslint-disable @typescript-eslint/no-var-requires */
8
8
  const sites = require('./sites.js')
9
- const {parseCommerceAgentSettings} = require('./utils.js')
9
+ const {parseSettings} = require('./utils.js')
10
10
 
11
11
  module.exports = {
12
12
  app: {
@@ -23,9 +23,17 @@ module.exports = {
23
23
  // Commerce shopping agent configuration for embedded messaging service
24
24
  // This enables an agentic shopping experience in the application
25
25
  // This property accepts either a JSON string or a plain JavaScript object.
26
- // The value is set from the COMMERCE_AGENT_SETTINGS environment variable.
27
- // If the COMMERCE_AGENT_SETTINGS environment variable is not set, the feature is disabled.
28
- commerceAgent: parseCommerceAgentSettings(process.env.COMMERCE_AGENT_SETTINGS),
26
+ commerceAgent: parseSettings(process.env.COMMERCE_AGENT_SETTINGS) || {
27
+ enabled: 'false',
28
+ askAgentOnSearch: 'false',
29
+ embeddedServiceName: '',
30
+ embeddedServiceEndpoint: '',
31
+ scriptSourceUrl: '',
32
+ scrt2Url: '',
33
+ salesforceOrgId: '',
34
+ commerceOrgId: '',
35
+ siteId: ''
36
+ },
29
37
  // Customize how your 'site' and 'locale' are displayed in the url.
30
38
  url: {
31
39
  {{#if answers.project.demo.enableDemoSettings}}
@@ -0,0 +1,35 @@
1
+ /*
2
+ * Copyright (c) 2021, salesforce.com, inc.
3
+ * All rights reserved.
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6
+ */
7
+
8
+ /**
9
+ * Safely parses settings from either a JSON string or object
10
+ * @param {string|object} settings - The settings
11
+ * @returns {object} Parsed settings object
12
+ */
13
+ function parseSettings(settings) {
14
+ // If settings is already an object, return it
15
+ if (typeof settings === 'object' && settings !== null) {
16
+ return settings
17
+ }
18
+
19
+ // If settings is a string, try to parse it
20
+ if (typeof settings === 'string') {
21
+ try {
22
+ return JSON.parse(settings)
23
+ } catch (error) {
24
+ console.warn('Invalid json format:', error.message)
25
+ return
26
+ }
27
+ }
28
+
29
+ console.warn('Cannot parse settings from:', settings)
30
+ return
31
+ }
32
+
33
+ module.exports = {
34
+ parseSettings
35
+ }
@@ -97,7 +97,7 @@ const AppConfig = ({children, locals = {}}) => {
97
97
  headers={headers}
98
98
  defaultDnt={DEFAULT_DNT_STATE}
99
99
  logger={createLogger({packageName: 'commerce-sdk-react'})}
100
- passwordlessLoginCallbackURI={passwordlessCallback}
100
+ passwordlessLoginCallbackURI={passwordlessLoginCallbackURI}
101
101
  // Set 'enablePWAKitPrivateClient' to true to use SLAS private client login flows.
102
102
  // Make sure to also enable useSLASPrivateClient in ssr.js when enabling this setting.
103
103
  {{#if answers.project.commerce.isSlasPrivate}}
@@ -6,7 +6,7 @@
6
6
  */
7
7
  /* eslint-disable @typescript-eslint/no-var-requires */
8
8
  const sites = require('./sites.js')
9
- const {parseCommerceAgentSettings} = require('./utils.js')
9
+ const {parseSettings} = require('./utils.js')
10
10
 
11
11
  module.exports = {
12
12
  app: {
@@ -23,9 +23,17 @@ module.exports = {
23
23
  // Commerce shopping agent configuration for embedded messaging service
24
24
  // This enables an agentic shopping experience in the application
25
25
  // This property accepts either a JSON string or a plain JavaScript object.
26
- // The value is set from the COMMERCE_AGENT_SETTINGS environment variable.
27
- // If the COMMERCE_AGENT_SETTINGS environment variable is not set, the feature is disabled.
28
- commerceAgent: parseCommerceAgentSettings(process.env.COMMERCE_AGENT_SETTINGS),
26
+ commerceAgent: parseSettings(process.env.COMMERCE_AGENT_SETTINGS) || {
27
+ enabled: 'false',
28
+ askAgentOnSearch: 'false',
29
+ embeddedServiceName: '',
30
+ embeddedServiceEndpoint: '',
31
+ scriptSourceUrl: '',
32
+ scrt2Url: '',
33
+ salesforceOrgId: '',
34
+ commerceOrgId: '',
35
+ siteId: ''
36
+ },
29
37
  // Customize settings for your url
30
38
  url: {
31
39
  {{#if answers.project.demo.enableDemoSettings}}
@@ -0,0 +1,35 @@
1
+ /*
2
+ * Copyright (c) 2021, salesforce.com, inc.
3
+ * All rights reserved.
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6
+ */
7
+
8
+ /**
9
+ * Safely parses settings from either a JSON string or object
10
+ * @param {string|object} settings - The settings
11
+ * @returns {object} Parsed settings object
12
+ */
13
+ function parseSettings(settings) {
14
+ // If settings is already an object, return it
15
+ if (typeof settings === 'object' && settings !== null) {
16
+ return settings
17
+ }
18
+
19
+ // If settings is a string, try to parse it
20
+ if (typeof settings === 'string') {
21
+ try {
22
+ return JSON.parse(settings)
23
+ } catch (error) {
24
+ console.warn('Invalid json format:', error.message)
25
+ return
26
+ }
27
+ }
28
+
29
+ console.warn('Cannot parse settings from:', settings)
30
+ return
31
+ }
32
+
33
+ module.exports = {
34
+ parseSettings
35
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/pwa-kit-create-app",
3
- "version": "3.12.0-preview.2",
3
+ "version": "3.12.0-preview.3",
4
4
  "description": "Salesforce's project generator tool",
5
5
  "homepage": "https://github.com/SalesforceCommerceCloud/pwa-kit/tree/develop/packages/pwa-kit-create-app#readme",
6
6
  "bugs": {
@@ -39,13 +39,13 @@
39
39
  "tar": "^6.2.1"
40
40
  },
41
41
  "devDependencies": {
42
- "@salesforce/pwa-kit-dev": "3.12.0-preview.2",
43
- "internal-lib-build": "3.12.0-preview.2",
42
+ "@salesforce/pwa-kit-dev": "3.12.0-preview.3",
43
+ "internal-lib-build": "3.12.0-preview.3",
44
44
  "verdaccio": "^5.22.1"
45
45
  },
46
46
  "engines": {
47
47
  "node": "^16.11.0 || ^18.0.0 || ^20.0.0 || ^22.0.0",
48
48
  "npm": "^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0"
49
49
  },
50
- "gitHead": "c0d7ff4673e54ecb119ca4aff5b919f0064b6539"
50
+ "gitHead": "36ffe8203fe8661e07571b1e6035ee5a3c9d310f"
51
51
  }
package/program.json CHANGED
@@ -363,7 +363,7 @@
363
363
  "description": "",
364
364
  "templateId": "retail-react-app",
365
365
  "answers": {
366
- "project.extend": true,
366
+ "project.extend": false,
367
367
  "project.hybrid": false,
368
368
  "project.name": "retail-react-app",
369
369
  "project.commerce.instanceUrl": "https://zzrf-001.dx.commercecloud.salesforce.com",
Binary file
Binary file
Binary file
Binary file
@@ -1,48 +0,0 @@
1
- /*
2
- * Copyright (c) 2021, salesforce.com, inc.
3
- * All rights reserved.
4
- * SPDX-License-Identifier: BSD-3-Clause
5
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6
- */
7
-
8
- /**
9
- * Safely parses commerce agent settings from either a JSON string or object
10
- * @param {string|object} settings - The commerce agent settings
11
- * @returns {object} Parsed commerce agent settings object
12
- */
13
- function parseCommerceAgentSettings(settings) {
14
- // Default configuration when no settings are provided
15
- const defaultConfig = {
16
- enabled: 'false',
17
- askAgentOnSearch: 'false',
18
- embeddedServiceName: '',
19
- embeddedServiceEndpoint: '',
20
- scriptSourceUrl: '',
21
- scrt2Url: '',
22
- salesforceOrgId: '',
23
- commerceOrgId: '',
24
- siteId: ''
25
- }
26
-
27
- // If settings is already an object, return it
28
- if (typeof settings === 'object' && settings !== null) {
29
- return settings
30
- }
31
-
32
- // If settings is a string, try to parse it
33
- if (typeof settings === 'string') {
34
- try {
35
- return JSON.parse(settings)
36
- } catch (error) {
37
- console.warn('Invalid COMMERCE_AGENT_SETTINGS format, using defaults:', error.message)
38
- return defaultConfig
39
- }
40
- }
41
-
42
- // If settings is undefined/null, return defaults
43
- return defaultConfig
44
- }
45
-
46
- module.exports = {
47
- parseCommerceAgentSettings
48
- }
@@ -1,48 +0,0 @@
1
- /*
2
- * Copyright (c) 2021, salesforce.com, inc.
3
- * All rights reserved.
4
- * SPDX-License-Identifier: BSD-3-Clause
5
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6
- */
7
-
8
- /**
9
- * Safely parses commerce agent settings from either a JSON string or object
10
- * @param {string|object} settings - The commerce agent settings
11
- * @returns {object} Parsed commerce agent settings object
12
- */
13
- function parseCommerceAgentSettings(settings) {
14
- // Default configuration when no settings are provided
15
- const defaultConfig = {
16
- enabled: 'false',
17
- askAgentOnSearch: 'false',
18
- embeddedServiceName: '',
19
- embeddedServiceEndpoint: '',
20
- scriptSourceUrl: '',
21
- scrt2Url: '',
22
- salesforceOrgId: '',
23
- commerceOrgId: '',
24
- siteId: ''
25
- }
26
-
27
- // If settings is already an object, return it
28
- if (typeof settings === 'object' && settings !== null) {
29
- return settings
30
- }
31
-
32
- // If settings is a string, try to parse it
33
- if (typeof settings === 'string') {
34
- try {
35
- return JSON.parse(settings)
36
- } catch (error) {
37
- console.warn('Invalid COMMERCE_AGENT_SETTINGS format, using defaults:', error.message)
38
- return defaultConfig
39
- }
40
- }
41
-
42
- // If settings is undefined/null, return defaults
43
- return defaultConfig
44
- }
45
-
46
- module.exports = {
47
- parseCommerceAgentSettings
48
- }