@salesforce/webapp-template-app-react-sample-b2e-experimental 1.61.3 → 1.62.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.
Files changed (35) hide show
  1. package/dist/.a4drules/{graphql.md → features/feature-graphql-graphql-data-access-rule.md} +127 -117
  2. package/dist/.a4drules/features/feature-react-agentforce-conversation-client-embedded-agent-rule.md +32 -0
  3. package/dist/.a4drules/features/feature-react-chart-analytics-charts-rule.md +27 -0
  4. package/dist/.a4drules/skills/feature-graphql-graphql-data-access/SKILL.md +155 -0
  5. package/dist/.a4drules/{graphql/tools/knowledge/lds-explore-graphql-schema.md → skills/feature-graphql-graphql-data-access/docs/explore-schema.md} +58 -29
  6. package/dist/.a4drules/{graphql/tools/knowledge/lds-generate-graphql-mutationquery.md → skills/feature-graphql-graphql-data-access/docs/generate-mutation-query.md} +52 -42
  7. package/dist/.a4drules/{graphql/tools/knowledge/lds-generate-graphql-readquery.md → skills/feature-graphql-graphql-data-access/docs/generate-read-query.md} +32 -22
  8. package/dist/.a4drules/{graphql/tools/schemas/shared.graphqls → skills/feature-graphql-graphql-data-access/docs/shared-schema.graphqls} +1 -1
  9. package/dist/.a4drules/skills/feature-micro-frontend-micro-frontend/SKILL.md +137 -0
  10. package/dist/.a4drules/skills/feature-react-agentforce-conversation-client-embedded-agent/SKILL.md +108 -0
  11. package/dist/.a4drules/skills/feature-react-agentforce-conversation-client-embedded-agent/docs/embed-examples.md +182 -0
  12. package/dist/.a4drules/skills/feature-react-chart-analytics-charts/SKILL.md +41 -0
  13. package/dist/.a4drules/skills/feature-react-chart-analytics-charts/docs/schema-mapping.md +4 -0
  14. package/dist/.a4drules/webapp-code-quality.md +136 -0
  15. package/dist/.a4drules/{images.md → webapp-images.md} +6 -4
  16. package/dist/.a4drules/webapp-no-node-e.md +3 -2
  17. package/dist/.a4drules/webapp-react.md +149 -0
  18. package/dist/.a4drules/{typescript.md → webapp-typescript.md} +9 -17
  19. package/dist/.a4drules/webapp.md +62 -45
  20. package/dist/CHANGELOG.md +16 -0
  21. package/dist/force-app/main/default/webapplications/appreactsampleb2e/vite.config.ts +2 -2
  22. package/dist/package.json +1 -1
  23. package/package.json +2 -2
  24. package/dist/.a4drules/README.md +0 -35
  25. package/dist/.a4drules/a4d-webapp-generate.md +0 -27
  26. package/dist/.a4drules/build-validation.md +0 -78
  27. package/dist/.a4drules/code-quality.md +0 -136
  28. package/dist/.a4drules/graphql/tools/knowledge/lds-guide-graphql.md +0 -205
  29. package/dist/.a4drules/react.md +0 -388
  30. package/dist/.a4drules/react_image_processing.md +0 -45
  31. package/dist/.a4drules/ui-layout.md +0 -23
  32. package/dist/.a4drules/webapp-nav-and-placeholders.md +0 -33
  33. package/dist/.a4drules/webapp-ui-first.md +0 -32
  34. package/dist/force-app/main/default/webapplications/appreactsampleb2e/build/vite.config.d.ts +0 -2
  35. package/dist/force-app/main/default/webapplications/appreactsampleb2e/build/vite.config.js +0 -93
@@ -1,30 +1,32 @@
1
1
  # GraphQL Read Query Generation
2
2
 
3
3
  **Triggering conditions**
4
- 1. Only if the `LDS_Guide_GraphQL` rule completed successfully
4
+
5
+ 1. Only if the schema exploration phase completed successfully
5
6
  2. Only if the query to generate is a read query
6
7
 
7
8
  ## Your Role
8
9
 
9
10
  You are a GraphQL expert and your role is to help generate Salesforce compatible GraphQL read queries once the exploration phase has completed.
10
11
 
11
- You will leverage the context provided by the requesting user as well as the validation phase provided by the `LDS_Guide_GraphQL` rule.
12
+ You will leverage the context provided by the requesting user as well as the validation phase provided by the schema exploration. This tool will also provide you with a method to dynamically query the target org instance that you will use to test the generated query.
12
13
 
13
- If the `LDS_Guide_GraphQL` rule has not been executed yet, you **MUST** run it first, and then get back to read query generation. This tool will also provide you with a method to dynamically query the target org instance that you will use to test the generated query.
14
+ If the schema exploration has not been executed yet, you **MUST** run it first, and then get back to read query generation.
14
15
 
15
16
  ## Read Query Generation Workflow
16
17
 
17
18
  Strictly follow the rules below when generating the GraphQL read query:
19
+
18
20
  1. **No Proliferation** - Only generate for the explicitly requested fields, nothing else
19
21
  2. **Unique Query** - Leverage child relationships to query entities in one single query
20
22
  3. **Navigate Entities** - Always use `relationshipName` to access reference fields and child entities
21
- 1. **Exception** - if the `relationshipName` field is null, you can't navigate the related entity, and will have to return the `Id` itself
23
+ 1. **Exception** - if the `relationshipName` field is null, you can't navigate the related entity, and will have to return the `Id` itself
22
24
  4. **Leverage Fragments** - Generate one fragment per possible type on polymorphic fields (field with `dataType="REFERENCE"` and more than one entry in `referenceToInfos` introspection attribute)
23
25
  5. **Type Consistency** - Make sure variables used as query arguments and their related fields share the same GraphQL type
24
26
  6. **Type Enforcement** - Make sure to leverage field type information from introspection and GraphQL schema to generate field access
25
27
  7. **Semi and anti joins** - Use the semi-join or anti-join templates to filter an entity with conditions on child entities
26
28
  8. **Query Generation** - Use the [template](#read-query-template) to generate the query
27
- 9. **Output Format** - Use the [standalone](#read-standalone-default-output-format---clean-code-only)
29
+ 9. **Output Format** - Use the [standalone](#read-standalone-default-output-format---clean-code-only)
28
30
  10. **Test the Query** - Use the [Generated Read Query Testing](#generated-read-query-testing) workflow to test the generated query
29
31
  1. **Report First** - Always report first, using the proper output format, before testing
30
32
 
@@ -86,6 +88,7 @@ fragment TypeBInfo on TypeB {
86
88
 
87
89
  Semi-joins (resp. anti-joins) condition leverage parent-child relationships and allow filtering the parent entity using a condition on child entities.
88
90
  This is a standard `where` condition, on the parent entity's `Id`, expressed using the `inq` (resp. `ninq`, i.e. not `inq`) operator. This operator accepts two attributes:
91
+
89
92
  - The child entity camelcase name to apply the condition on, with a value expressing the condition
90
93
  - The field name on the child entity containing the parent entity `Id`, which is the `fieldName` from the `childRelationships` information for the child entity
91
94
  - If the only condition is related child entity existence, you can use an `Id: { ne: null }` condition
@@ -96,7 +99,7 @@ This is a standard `where` condition, on the parent entity's `Id`, expressed usi
96
99
  query testSemiJoin {
97
100
  uiapi {
98
101
  query {
99
- ParentEntity (
102
+ ParentEntity(
100
103
  where: {
101
104
  Id: {
102
105
  inq: {
@@ -104,7 +107,7 @@ query testSemiJoin {
104
107
  # standard conditions here
105
108
  Name: { like: "test%" }
106
109
  Type: { eq: "some value" }
107
- },
110
+ }
108
111
  ApiName: "parentIdFieldInChild"
109
112
  }
110
113
  }
@@ -113,7 +116,9 @@ query testSemiJoin {
113
116
  edges {
114
117
  node {
115
118
  Id
116
- Name { value }
119
+ Name {
120
+ value
121
+ }
117
122
  }
118
123
  }
119
124
  }
@@ -141,45 +146,50 @@ const QUERY_VARIABLES = {
141
146
  ```
142
147
 
143
148
  **❌ DO NOT INCLUDE:**
149
+
144
150
  - Explanatory comments about the query
145
151
  - Field descriptions
146
152
  - Additional text about what the query does
147
153
  - Workflow step descriptions
148
154
 
149
155
  **✅ ONLY INCLUDE:**
156
+
150
157
  - Raw query string
151
158
  - Variables object
152
159
  - Nothing else
153
160
 
154
161
  ## Generated Read Query Testing
155
162
 
156
- **Triggering conditions** - **ALL CONDITIONS MUST VALIDATE***
163
+ **Triggering conditions** - **ALL CONDITIONS MUST VALIDATE\***
164
+
157
165
  1. Only if the [Read Query Generation Workflow](#read-query-generation-workflow) step global status is `SUCCESS` and you have a generated query
158
166
  2. Only if the query to generate is a read query
159
- 3. Only if non manual method was used during `LDS_Guide_GraphQL` rule execution to retrieve introspection data
167
+ 3. Only if non manual method was used during schema exploration to retrieve introspection data
160
168
 
161
169
  **Workflow**
170
+
162
171
  1. **Report Step** - Explain that you are able to test the query using the same method used during introspection
163
- 1. You **MUST** report the method you will use, based on the one you used during `LDS_Guide_GraphQL` rule execution
172
+ 1. You **MUST** report the method you will use, based on the one you used during schema exploration
164
173
  2. **Interactive Step** - Ask the user whether they want you to test the query using the proposed method
165
- 1. **WAIT** for the user's answer.
174
+ 1. **WAIT** for the user's answer.
166
175
  3. **Test Query** - If the user are OK with you testing the query:
167
- 1. Use the selected method to test the query
168
- 2. Report the result of the test as `SUCCESS` if the query executed without error, or `FAILED` if you got errors
169
- 3. If the query executed without any errors, but you received no data, then the query is valid, and the result of the test is `SUCCESS`
176
+ 1. Use the selected method to test the query
177
+ 2. Report the result of the test as `SUCCESS` if the query executed without error, or `FAILED` if you got errors
178
+ 3. If the query executed without any errors, but you received no data, then the query is valid, and the result of the test is `SUCCESS`
170
179
  4. **Remediation Step** - If status is `FAILED`, use the [`FAILED` status handling workflows](#failed-status-handling-workflow)
171
180
 
172
181
  ### `FAILED` Status Handling Workflow
173
182
 
174
183
  The query is invalid:
184
+
175
185
  1. **Error Analysis** - Parse and categorize the specific error messages
176
186
  2. **Root Cause Identification** - Use error message to identify the root cause:
177
- - **Syntax** - Error contains `invalid syntax`
178
- - **Validation** - Error contains `validation error`
179
- - **Type** - Error contains `VariableTypeMismatch` or `UnknownType`
187
+ - **Syntax** - Error contains `invalid syntax`
188
+ - **Validation** - Error contains `validation error`
189
+ - **Type** - Error contains `VariableTypeMismatch` or `UnknownType`
180
190
  3. **Targeted Resolution** - Depending on the root cause categorization
181
- - **Syntax** - Update the query using the error message information to fix the syntax errors
182
- - **Validation** - This field's name is most probably invalid, ask user for clarification and **WAIT** for the user's answer
183
- - **Type** - Use the error details and GraphQL schema to correct argument's type, and adjust variables accordingly
191
+ - **Syntax** - Update the query using the error message information to fix the syntax errors
192
+ - **Validation** - This field's name is most probably invalid, ask user for clarification and **WAIT** for the user's answer
193
+ - **Type** - Use the error details and GraphQL schema to correct argument's type, and adjust variables accordingly
184
194
  4. **Test Again** - Resume the [query testing workflow](#generated-read-query-testing) with the updated query (increment and track attempt counter)
185
- 5. **Escalation Path** - If targeted resolution fails after 2 attempts, ask for additional details and restart the entire GraphQL workflow, going again through the introspection phase
195
+ 5. **Escalation Path** - If targeted resolution fails after 2 attempts, ask for additional details and restart the entire GraphQL workflow, going again through the introspection phase
@@ -1147,4 +1147,4 @@ directive @ignoreRule(rules: [IgnoreRule!]!) on OBJECT
1147
1147
  | INPUT_FIELD_DEFINITION
1148
1148
  | ARGUMENT_DEFINITION
1149
1149
  | ENUM_VALUE
1150
- directive @optional on FIELD
1150
+ directive @optional on FIELD
@@ -0,0 +1,137 @@
1
+ ---
2
+ name: micro-frontends
3
+ description: Generate a Micro Frontend LWC component for a Web Application.
4
+ license: Proprietary. LICENSE.txt has complete terms
5
+ metadata:
6
+ author: salesforce-experience-platform-emu/lwc-admins
7
+ ---
8
+
9
+ # Micro Frontend generation (workflow)
10
+
11
+ When the user wants a Micro Frontend for a Web Application, follow this workflow.
12
+
13
+ ## 1. Install the dependency
14
+
15
+ Micro Frontends are generated using the `generate-micro-frontend` CLI command from the `@salesforce/micro-frontends-experimental` package.
16
+
17
+ ```bash
18
+ npm install @salesforce/micro-frontends-experimental
19
+ ```
20
+
21
+ The dependency should be added to the project's `package.json` dependencies.
22
+
23
+ ## 2. Identify the Web Application
24
+
25
+ - Verify the Web Application exists in `force-app/main/default/webapplications/<web-app-name>/`.
26
+ - Confirm the Web Application has a `lightningOut` target in its `webapplication-meta.xml` file.
27
+ - If no Web Application exists, the user must create one first using the Web Apps template system.
28
+
29
+ ## 3. Generate the Micro Frontend component
30
+
31
+ Run the `generate-micro-frontend` command with the Web Application name from the root of an SFDX project:
32
+
33
+ ```bash
34
+ npx generate-micro-frontend <web-app-name>
35
+ ```
36
+
37
+ This creates:
38
+
39
+ - A custom wrapper LWC component in `force-app/main/default/lwc/<webAppName>/`. This is the "Micro Frontend component".
40
+ - The static `microFrontendShell` component that handles iframe communication.
41
+
42
+ Notes:
43
+
44
+ - The command may be added to the project's `package.json` scripts for convenience.
45
+ - The Micro Frontend component uses the Web Application name (e.g. `my-web-app/`) in camelCase for its folder and file names (e.g. `myWebApp/myWebApp.js`, `myWebApp/myWebApp.html`).
46
+
47
+ ## 4. Customize the Micro Frontend component metadata
48
+
49
+ Edit the `<webAppName>.js-meta.xml` file to:
50
+
51
+ - Set appropriate `targets` (e.g. `lightning__HomePage`, `lightning__AppPage`, `lightning__RecordPage`, `lightningCommunity__Page`)
52
+ - Add `targetConfigs` for page-specific properties
53
+ - Optionally update the `masterLabel` and `description`
54
+
55
+ Example:
56
+
57
+ ```xml
58
+ <targetConfigs>
59
+ <targetConfig targets="lightning__HomePage">
60
+ <property name="height" type="Integer" min="0" max="600" default="300" />
61
+ </targetConfig>
62
+ </targetConfigs>
63
+ ```
64
+
65
+ ## 5. Pass properties to the Micro Frontend component
66
+
67
+ Edit the `<webAppName>.js` file to customize the `properties` getter:
68
+
69
+ ```javascript
70
+ @api height;
71
+
72
+ @api get properties() {
73
+ return {
74
+ height: this.height,
75
+ // Add any other data your Web Application needs
76
+ };
77
+ }
78
+ ```
79
+
80
+ All properties are passed to the embedded Web Application via `postMessage` and can be accessed in the app's code.
81
+
82
+ ## 6. Deploy and test
83
+
84
+ Deploy the Micro Frontend component using standard SF CLI commands:
85
+
86
+ ```bash
87
+ sf project deploy start --source-dir force-app/main/default
88
+ ```
89
+
90
+ Add the component to a page using Lightning App Builder or Experience Builder and verify it loads correctly.
91
+
92
+ # Micro Frontend component customization examples
93
+
94
+ ## Record page example
95
+
96
+ Command to generate a Micro Frontend component for the `my-site` Web Application:
97
+
98
+ ```bash
99
+ npx generate-micro-frontend my-site
100
+ ```
101
+
102
+ `mySite.js-meta.xml` file with a `lightning__RecordPage` target:
103
+
104
+ ```xml
105
+ <?xml version="1.0" encoding="UTF-8"?>
106
+ <LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
107
+ <apiVersion>66.0</apiVersion>
108
+ <isExposed>true</isExposed>
109
+ <masterLabel>Micro Frontend for "My Site"</masterLabel>
110
+ <targets>
111
+ <target>lightning__RecordPage</target>
112
+ </targets>
113
+ <targetConfigs>
114
+ <targetConfig targets="lightning__RecordPage">
115
+ <property name="mode" type="String" default="dark" />
116
+ </targetConfig>
117
+ </targetConfigs>
118
+ </LightningComponentBundle>
119
+ ```
120
+
121
+ `mySite.js` file with public properties and `properties` getter:
122
+
123
+ ```js
124
+ // Micro Frontend component
125
+ export default class mySite extends LightningElement {
126
+ @api recordId;
127
+ @api mode;
128
+
129
+ @api get properties() {
130
+ // This data is passed to the Micro Frontend
131
+ return {
132
+ recordId: this.recordId, // automatically populated for lightning__RecordPage target
133
+ mode: this.mode, // matches the mode targetConfig
134
+ };
135
+ }
136
+ }
137
+ ```
@@ -0,0 +1,108 @@
1
+ ---
2
+ name: embedded-agent
3
+ description: Embed an Agentforce conversation client (chat UI) into a React web application. Use when the user wants to add an employee agent, a chat client, chatbot, chat widget, chat component, conversation client, or conversational interface to their React app. Also applies when the user asks to embed or integrate any Salesforce agent — including employee agent, travel agent, HR agent, service agent, or any custom-named agent — or mentions Agentforce, Agentforce widget, Agentforce chat, or agent chat.
4
+ ---
5
+
6
+ # Embedded Agentforce chat (workflow)
7
+
8
+ When the user wants an embedded Agentforce chat client in a React app, follow this workflow.
9
+
10
+ ## 1. Install the package
11
+
12
+ ```bash
13
+ npm install @salesforce/webapp-template-feature-react-agentforce-conversation-client-experimental
14
+ ```
15
+
16
+ This single install also brings in `@salesforce/agentforce-conversation-client` (the underlying SDK) automatically.
17
+
18
+ ## 2. Use the shared wrapper
19
+
20
+ Use the `AgentforceConversationClient` React component. It resolves auth automatically:
21
+
22
+ - **Dev (localhost)**: fetches `frontdoorUrl` from `/__lo/frontdoor`
23
+ - **Prod (hosted in org)**: uses `salesforceOrigin` from `window.location.origin`
24
+
25
+ ## 3. Embed in the layout
26
+
27
+ Render `<AgentforceConversationClient />` in the app layout so the chat client loads globally. Keep it alongside the existing layout (do not replace the page shell).
28
+
29
+ ```tsx
30
+ import { Outlet } from "react-router";
31
+ import { AgentforceConversationClient } from "@salesforce/webapp-template-feature-react-agentforce-conversation-client-experimental";
32
+
33
+ export default function AppLayout() {
34
+ return (
35
+ <>
36
+ <Outlet />
37
+ <AgentforceConversationClient />
38
+ </>
39
+ );
40
+ }
41
+ ```
42
+
43
+ ## 4. Configure the agent
44
+
45
+ Pass options via the `agentforceClientConfig` prop:
46
+
47
+ | Option | Purpose |
48
+ | ---------------------------------- | ------------------------------------------------- |
49
+ | `renderingConfig.mode` | `"floating"` (default) or `"inline"` |
50
+ | `renderingConfig.width` / `height` | Inline dimensions (number for px, string for CSS) |
51
+ | `agentId` | Select a specific agent from the org |
52
+ | `styleTokens` | Theme colors and style overrides |
53
+
54
+ See [embed-examples.md](docs/embed-examples.md) for complete examples of each mode.
55
+
56
+ ## 5. Validate prerequisites
57
+
58
+ - The org must allow `localhost:<PORT>` in **Trusted Domains for Inline Frames** (session settings).
59
+
60
+ ## Quick reference: rendering modes
61
+
62
+ ### Floating (default)
63
+
64
+ A persistent chat widget overlay pinned to the bottom-right corner. No extra config needed — floating is the default.
65
+
66
+ ```tsx
67
+ <AgentforceConversationClient />
68
+ ```
69
+
70
+ ### Inline
71
+
72
+ The chat renders within the page layout at a specific size.
73
+
74
+ ```tsx
75
+ <AgentforceConversationClient
76
+ agentforceClientConfig={{
77
+ renderingConfig: { mode: "inline", width: 420, height: 600 },
78
+ }}
79
+ />
80
+ ```
81
+
82
+ ### Theming
83
+
84
+ Use `styleTokens` to customize the chat appearance.
85
+
86
+ ```tsx
87
+ <AgentforceConversationClient
88
+ agentforceClientConfig={{
89
+ styleTokens: {
90
+ headerBlockBackground: "#0176d3",
91
+ headerBlockTextColor: "#ffffff",
92
+ messageBlockInboundColor: "#0176d3",
93
+ },
94
+ }}
95
+ />
96
+ ```
97
+
98
+ ### Agent selection
99
+
100
+ Pass `agentId` to load a specific agent (e.g. travel agent, HR agent).
101
+
102
+ ```tsx
103
+ <AgentforceConversationClient
104
+ agentforceClientConfig={{
105
+ agentId: "0Xx000000000000",
106
+ }}
107
+ />
108
+ ```
@@ -0,0 +1,182 @@
1
+ # Embed examples
2
+
3
+ Detailed examples for configuring the Agentforce Conversation Client. All examples use the `AgentforceConversationClient` React component; the underlying `embedAgentforceClient` API accepts the same `agentforceClientConfig` shape.
4
+
5
+ ---
6
+
7
+ ## Floating mode (default)
8
+
9
+ A floating chat widget appears in the bottom-right corner. It starts minimized and expands when the user clicks it. This is the default — no `renderingConfig` is required.
10
+
11
+ ### Minimal (no config)
12
+
13
+ ```tsx
14
+ <AgentforceConversationClient />
15
+ ```
16
+
17
+ ### Explicit floating
18
+
19
+ ```tsx
20
+ <AgentforceConversationClient
21
+ agentforceClientConfig={{
22
+ renderingConfig: { mode: "floating" },
23
+ }}
24
+ />
25
+ ```
26
+
27
+ ### Floating with a specific agent and theme
28
+
29
+ ```tsx
30
+ <AgentforceConversationClient
31
+ agentforceClientConfig={{
32
+ renderingConfig: { mode: "floating" },
33
+ agentId: "0Xx000000000000",
34
+ styleTokens: {
35
+ headerBlockBackground: "#032D60",
36
+ headerBlockTextColor: "#ffffff",
37
+ },
38
+ }}
39
+ />
40
+ ```
41
+
42
+ ---
43
+
44
+ ## Inline mode
45
+
46
+ The chat renders inside the parent container at a specific size. Use this when the chat should be part of the page layout rather than an overlay.
47
+
48
+ ### Fixed pixel dimensions
49
+
50
+ ```tsx
51
+ <AgentforceConversationClient
52
+ agentforceClientConfig={{
53
+ renderingConfig: { mode: "inline", width: 420, height: 600 },
54
+ }}
55
+ />
56
+ ```
57
+
58
+ ### CSS string dimensions
59
+
60
+ ```tsx
61
+ <AgentforceConversationClient
62
+ agentforceClientConfig={{
63
+ renderingConfig: { mode: "inline", width: "100%", height: "80vh" },
64
+ }}
65
+ />
66
+ ```
67
+
68
+ ### Inline filling a sidebar
69
+
70
+ ```tsx
71
+ <div style={{ display: "flex", height: "100vh" }}>
72
+ <main style={{ flex: 1 }}>{/* App content */}</main>
73
+ <aside style={{ width: 400 }}>
74
+ <AgentforceConversationClient
75
+ agentforceClientConfig={{
76
+ renderingConfig: { mode: "inline", width: "100%", height: "100%" },
77
+ }}
78
+ />
79
+ </aside>
80
+ </div>
81
+ ```
82
+
83
+ ---
84
+
85
+ ## Theming
86
+
87
+ Use `styleTokens` to customize colors. Tokens are passed directly to the Agentforce client.
88
+
89
+ ### Brand-colored header
90
+
91
+ ```tsx
92
+ <AgentforceConversationClient
93
+ agentforceClientConfig={{
94
+ styleTokens: {
95
+ headerBlockBackground: "#0176d3",
96
+ headerBlockTextColor: "#ffffff",
97
+ },
98
+ }}
99
+ />
100
+ ```
101
+
102
+ ### Full theme example
103
+
104
+ ```tsx
105
+ <AgentforceConversationClient
106
+ agentforceClientConfig={{
107
+ styleTokens: {
108
+ headerBlockBackground: "#0176d3",
109
+ headerBlockTextColor: "#ffffff",
110
+ messageBlockInboundColor: "#0176d3",
111
+ },
112
+ }}
113
+ />
114
+ ```
115
+
116
+ ### Dark theme example
117
+
118
+ ```tsx
119
+ <AgentforceConversationClient
120
+ agentforceClientConfig={{
121
+ styleTokens: {
122
+ headerBlockBackground: "#1a1a2e",
123
+ headerBlockTextColor: "#e0e0e0",
124
+ messageBlockInboundColor: "#16213e",
125
+ },
126
+ }}
127
+ />
128
+ ```
129
+
130
+ ---
131
+
132
+ ## Agent selection
133
+
134
+ Use `agentId` to load a specific agent from the org. If omitted, the org's default employee agent is used.
135
+
136
+ ### Specific agent by ID
137
+
138
+ ```tsx
139
+ <AgentforceConversationClient
140
+ agentforceClientConfig={{
141
+ agentId: "0Xx000000000000",
142
+ }}
143
+ />
144
+ ```
145
+
146
+ ### Agent with inline mode and theming
147
+
148
+ ```tsx
149
+ <AgentforceConversationClient
150
+ agentforceClientConfig={{
151
+ agentId: "0Xx000000000000",
152
+ renderingConfig: { mode: "inline", width: 400, height: 700 },
153
+ styleTokens: {
154
+ headerBlockBackground: "#0176d3",
155
+ headerBlockTextColor: "#ffffff",
156
+ },
157
+ }}
158
+ />
159
+ ```
160
+
161
+ ---
162
+
163
+ ## Using the low-level `embedAgentforceClient` API
164
+
165
+ The React component wraps `embedAgentforceClient`. If you need the raw API (e.g. in a non-React context), the config shape is the same:
166
+
167
+ ```ts
168
+ import { embedAgentforceClient } from "@salesforce/agentforce-conversation-client";
169
+
170
+ const { loApp, chatClientComponent } = embedAgentforceClient({
171
+ container: "#agentforce-container",
172
+ salesforceOrigin: "https://myorg.my.salesforce.com",
173
+ agentforceClientConfig: {
174
+ agentId: "0Xx000000000000",
175
+ renderingConfig: { mode: "floating" },
176
+ styleTokens: {
177
+ headerBlockBackground: "#0176d3",
178
+ headerBlockTextColor: "#ffffff",
179
+ },
180
+ },
181
+ });
182
+ ```
@@ -0,0 +1,41 @@
1
+ ---
2
+ name: analytics-charts
3
+ description: Add or change charts from raw data. Use when the user asks for a chart, graph, or analytics visualization from JSON/data.
4
+ ---
5
+
6
+ # Analytics charts (workflow)
7
+
8
+ When the user wants a chart or visualization from data, follow this workflow. Charts use **Recharts** via the **AnalyticsChart** component.
9
+
10
+ ## Dependencies
11
+
12
+ Ensure the following package is installed in the project:
13
+
14
+ ```bash
15
+ npm install recharts
16
+ ```
17
+
18
+ ## 1. Interpret data type
19
+
20
+ - **Time-series**: data over time or ordered (dates, timestamps). Use a line chart. Raw shape often has date-like keys and a numeric value.
21
+ - **Categorical**: data by category (labels, segments). Use a bar chart. Raw shape often has a category name and a numeric value.
22
+
23
+ If the user says "over time", "trend", or uses date-like keys → time-series. If they say "by category", "by X", or use label-like keys → categorical.
24
+
25
+ ## 2. Map data to chart shape
26
+
27
+ - **Time-series**: produce `[{ x: string, y: number }, ...]` (e.g. map `date`→`x`, `value`→`y`).
28
+ - **Categorical**: produce `[{ name: string, value: number }, ...]` (e.g. map `category`→`name`, `total`→`value`).
29
+
30
+ See [schema-mapping.md](docs/schema-mapping.md) for examples.
31
+
32
+ ## 3. Choose theme
33
+
34
+ - **red**: declining, loss, negative trend.
35
+ - **green**: growth, gain, positive trend.
36
+ - **neutral**: default or mixed.
37
+
38
+ ## 4. Generate and place the chart
39
+
40
+ - Use **AnalyticsChart** with `chartType` (`"time-series"` or `"categorical"`), `data` (mapped array), `theme`, and optional `title`. Wrap in **ChartContainer** if the app uses it for chart blocks.
41
+ - Insert the chart inside the existing app (e.g. main content or a route), not as the entire page.
@@ -0,0 +1,4 @@
1
+ # Schema mapping (Recharts)
2
+
3
+ - **Time-series**: `{ x: string, y: number }` — e.g. map `date`→`x`, `value`→`y`.
4
+ - **Categorical**: `{ name: string, value: number }` — e.g. map `category`→`name`, `total`→`value`.