@builder.io/plugin-sfcc-commerce-api 0.0.6 → 0.0.7-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/README.md CHANGED
@@ -1,30 +1,31 @@
1
- # Builder.io Salesforce Commerce Api plugin [alpha]
1
+ # Builder.io Salesforce Commerce Api plugin
2
2
 
3
- Easily connect your SalesForce B2C Commerce PWA APP to your Builder.io content!
3
+ Easily connect your SalesForce B2C Commerce API to your Builder.io content!
4
4
 
5
- ## SalesForce Setup API Access
5
+ ## Setup Salesforce Commerce API Access
6
6
  Read through this [get started guide](https://developer.salesforce.com/docs/commerce/pwa-kit-managed-runtime/guide/setting-up-api-access.html) to make sure you have your *Shopper Login and API Access Service (SLAS)* client setup ready.
7
7
 
8
8
 
9
9
  ## Installation
10
10
 
11
- Go to [builder.io/account/organization](https://builder.io/account/organization) and type `@builder.io/plugin-sfcc-commerce-api` in the input, then hit save.
12
-
11
+ On any builder space, go to the [integrations tab](https://builder.io/app/integrations) and find the Salesforce B2C Commerce API integration
12
+ ![screenshot](https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F395a09d16129469d862851d23a56522c) and click `enable`,
13
+ Following, you'll be prompted to enter the following data:
14
+ * Client ID
15
+ * Organization ID
16
+ * Proxy Address
17
+ * Short Code
18
+ * Site ID
13
19
 
14
- ![Installation screenshot](https://cdn.builder.io/api/v1/image/assets%2Fd1ed12c3338144da8dd6b63b35d14c30%2F2c0da6f6b3104d6d87bdf62caa9ee271)
20
+ And optionally:
21
+ * Einstein API Client ID.
22
+ * Einstein Site ID.
15
23
 
16
- Following, you'll be prompted to enter the following data:
17
- * Client id
18
- * Organization id
19
- * Proxy address
20
- * Short code
21
- * Site id
22
24
 
23
- **The same configuration you find at your config/default.js file**
25
+ **If you're using Salesforce's Composable Storefront kit it should be the same configuration you find at your config/default.js file**
24
26
  ![Config screenshot](https://cdn.builder.io/api/v1/image/assets%2F1fa6810c36c54e87bfe1a6cc0f0be906%2Fa1e74597f82e46d390fd0b328c19bf78)
25
27
 
26
- Log into your Administration panel with your SFCC credentials at your [account administrator panel](https://account.demandware.com/)
27
-
28
+ Then enter it in your Builder's space integration configuration options:
28
29
  ![Credentials screenshot](https://cdn.builder.io/api/v1/image/assets%2Fd1ed12c3338144da8dd6b63b35d14c30%2F92cfc4b9885d41eaa4d5c23b00ebeace)
29
30
 
30
31
 
@@ -39,20 +40,76 @@ After putting the required info, hit the connect button. You will now see a few
39
40
  Custom targeting in Builder.io allow users to target content by a multitude of attributes, and in this plugin you'll be able to add specific content from SFCC products, for this you'll need first to set the target attributes on the host site, either by setting the `userAttributes` if you're rendering client side:
40
41
 
41
42
  ```ts
42
- builder.setUserAttributes({
43
- product: currentProduct.id,
44
- });
43
+ // example for fetching content specific for a product in a product details page
44
+ const productFooterContent = await builder.get('product-footer', {
45
+ userAttributes: {
46
+ product: product.productId,
47
+ }
48
+ })
45
49
  ```
46
50
 
47
51
  Or by passing it as a query param to the [content API](https://www.builder.io/c/docs/query-api#:~:text=userAttributes) call, or in [graqhql query](https://www.builder.io/c/docs/graphql-api#:~:text=with%20targeting) for e.g in Gatsby or nextjs.
48
52
 
49
- - `SfCommerceProduct` when used as a custom targeting type, it'll target contexts where the field is set to the product ID, you'll need to set the product ID on the host environment, using one of the methods above.
50
53
 
51
- - `SfCommerceProductsList` when used as a custom targeting type, it'll target contexts where the field is set to the a list of product Ids, you'll need to set the list of product Ids on the host environment, using one of the methods above.
54
+ ### Custom Components and input types
55
+ Once you install the plugin, you will also be able to use the SFCC types as inputs for your components, such as:
56
+
57
+ - `SFCommerceProduct` when used as an input type, you will be able to search and select a specific Product to provide to your component and consume the product data however you want from inside the component.
58
+
59
+ - `SFCommerceCategory` when used as an input type, you will be able to search and select a specific category of products to provide to your component, as example you can fetch products from a specific category from inside your component.
60
+
61
+ - `SFCommerceProductsList` when used as an input type, it enables users to select multiple products to provide to your component. As an example you can select multiple products and display them on a grid.
62
+
63
+ - `SFCommerceCategoriesList` when used as an input type enables users to select multiple categories to provide to your component.
64
+
65
+ #### Example of a Custom Component with SFCommerceProduct input type:
66
+
67
+ Example of a custom component called 'ProductBox' that receives a SFCommerceProduct as input:
52
68
 
53
- - `SfCommerceCategory` can be used as custom targeting attribute to target specific category by ID, you'll need to set the category ID on the host environment, using one of the methods above.
69
+ ```JSX
70
+ import React from 'react'
71
+ import {Builder} from '@builder.io/react'
72
+ import ProductBox from './ProductBox' // this is your component with it's logic
73
+
74
+ Builder.registerComponent(ProductBox, {
75
+ name: 'ProductBox',
76
+ image: 'https://unpkg.com/css.gg@2.0.0/icons/svg/box.svg',
77
+ inputs: [
78
+ {
79
+ name: 'productRef',
80
+ friendlyName: 'Product',
81
+ type: 'SFCommerceProduct',
82
+ required: true
83
+ }
84
+ ]
85
+ })
86
+ ```
87
+ To see more details about the usage of this component see [here](https://github.com/BuilderIO/sfcc-composable-storefront-starter/tree/main/app/components/blocks/product-box).
88
+
89
+ To understanding more about custom components also see [this article](https://www.builder.io/c/docs/custom-components-setup).
90
+
91
+ ### Fetch Content and References
92
+
93
+ On our [docs](https://www.builder.io/c/docs/query-api), you can check more about how to fetch content from [builder.io](https://builder.io) and also see how the option ```includeRefs=true``` works, fecthing any specific content from a given reference, such as a chosen SFCommerceProduct in the example above to support server side rendering.
94
+
95
+
96
+ ### Auto-resolving the Product/Categories data
97
+ In an effort to support SSR and making sure all the input data are available at the time of render, Builder’s support the resolving of the inputs for your custom components, for example if you have a product box with input of ```SFCommerceProduct``` you can get the json value of that product by passsing includeRefs: true when you fetch the content json:
98
+ ```JSX
99
+ const page = await builder.get('page', {
100
+ url: '...',
101
+ options: {
102
+ includeRefs: true
103
+ }
104
+ })
105
+ ```
106
+ Also passing the same option to the rendering component to auto-resolve while editing:
107
+
108
+ ```JSX
109
+ <BuilderComponent model="page" options={{ includeRefs: true}} content={page} />
110
+ ```
54
111
 
55
- - `SfCommerceCategoriesList` when used as a custom targeting type, it'll target contexts where the field is set to the a list of category Ids, you'll need to set the list of category Ids on the host environment, using one of the methods above.
112
+ For more information on the available options check our [Content API documentation](https://www.builder.io/c/docs/query-api).
56
113
 
57
114
 
58
115
  ### Seeing the plugin in action
@@ -33563,7 +33563,7 @@ System.register(['@builder.io/react', '@emotion/core', '@material-ui/core', 'rea
33563
33563
  }); };
33564
33564
 
33565
33565
  var name = "@builder.io/plugin-sfcc-commerce-api";
33566
- var version = "0.0.5";
33566
+ var version = "0.0.6";
33567
33567
  var description = "";
33568
33568
  var keywords = [
33569
33569
  ];
@@ -33634,7 +33634,7 @@ System.register(['@builder.io/react', '@emotion/core', '@material-ui/core', 'rea
33634
33634
  ]
33635
33635
  };
33636
33636
  var devDependencies = {
33637
- "@builder.io/react": "^1.1.29",
33637
+ "@builder.io/react": "^2.0.4",
33638
33638
  "@commitlint/cli": "^7.1.2",
33639
33639
  "@commitlint/config-conventional": "^7.1.2",
33640
33640
  "@rollup/plugin-commonjs": "^19.0.1",
@@ -33760,7 +33760,7 @@ System.register(['@builder.io/react', '@emotion/core', '@material-ui/core', 'rea
33760
33760
  pluginId: this.pluginId,
33761
33761
  apiKey: this.apiKey
33762
33762
  });
33763
- const root = "https://qa.builder.io";
33763
+ const root = appState.config.apiRoot();
33764
33764
  const baseUrl = new URL(`${root}/api/v1/sfcc-commerce/${path}`);
33765
33765
  baseUrl.search = params.toString();
33766
33766
  return baseUrl.toString();