@salesforce/webapp-template-feature-react-chart-experimental 1.107.2 → 1.107.4
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/dist/.a4drules/features/feature-react-agentforce-conversation-client-embedded-agent-rule.md +30 -6
- package/dist/.a4drules/skills/creating-webapp/SKILL.md +20 -0
- package/dist/.a4drules/skills/deploying-to-salesforce/SKILL.md +229 -0
- package/dist/.a4drules/skills/exploring-graphql-schema/SKILL.md +7 -18
- package/dist/.a4drules/skills/managing-agentforce-conversation-client/SKILL.md +186 -0
- package/dist/.a4drules/skills/managing-agentforce-conversation-client/references/constraints.md +134 -0
- package/dist/.a4drules/skills/managing-agentforce-conversation-client/references/examples.md +132 -0
- package/dist/.a4drules/skills/managing-agentforce-conversation-client/references/style-tokens.md +101 -0
- package/dist/.a4drules/skills/{integrating-agentforce-conversation-client/docs → managing-agentforce-conversation-client/references}/troubleshooting.md +9 -12
- package/dist/.a4drules/skills/using-graphql/SKILL.md +2 -1
- package/dist/.a4drules/webapp-code-quality.md +5 -2
- package/dist/.a4drules/webapp-data-access.md +25 -0
- package/dist/.a4drules/webapp-deployment.md +32 -0
- package/dist/.a4drules/webapp-react-typescript.md +4 -12
- package/dist/.a4drules/webapp-react.md +7 -13
- package/dist/AGENT.md +3 -0
- package/dist/CHANGELOG.md +19 -0
- package/dist/eslint.config.js +7 -0
- package/dist/force-app/main/default/webapplications/feature-react-chart/eslint.config.js +2 -0
- package/dist/force-app/main/default/webapplications/feature-react-chart/package.json +3 -9
- package/dist/force-app/main/default/webapplications/feature-react-chart/src/app.tsx +4 -1
- package/dist/force-app/main/default/webapplications/feature-react-chart/src/components/alerts/status-alert.tsx +1 -1
- package/dist/force-app/main/default/webapplications/feature-react-chart/tsconfig.json +7 -1
- package/dist/package-lock.json +9995 -0
- package/dist/package.json +7 -7
- package/package.json +2 -2
- package/dist/.a4drules/skills/generating-micro-frontend-lwc/SKILL.md +0 -137
- package/dist/.a4drules/skills/integrating-agentforce-conversation-client/SKILL.md +0 -92
- package/dist/.a4drules/skills/integrating-agentforce-conversation-client/docs/embed-examples.md +0 -116
- package/dist/force-app/main/default/webapplications/feature-react-chart/tsconfig.tsbuildinfo +0 -1
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# Additional Examples
|
|
2
|
+
|
|
3
|
+
Essential examples for common patterns and combinations. All use flat props API.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Layout Patterns
|
|
8
|
+
|
|
9
|
+
### Sidebar Chat
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
export default function DashboardWithChat() {
|
|
13
|
+
return (
|
|
14
|
+
<div style={{ display: "flex", height: "100vh" }}>
|
|
15
|
+
<main style={{ flex: 1 }}>{/* Main content */}</main>
|
|
16
|
+
<aside style={{ width: 400 }}>
|
|
17
|
+
<AgentforceConversationClient agentId="0Xx..." inline width="100%" height="100%" />
|
|
18
|
+
</aside>
|
|
19
|
+
</div>
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Full Page Chat
|
|
25
|
+
|
|
26
|
+
```tsx
|
|
27
|
+
export default function SupportPage() {
|
|
28
|
+
return (
|
|
29
|
+
<div>
|
|
30
|
+
<h1>Customer Support</h1>
|
|
31
|
+
<AgentforceConversationClient agentId="0Xx..." inline width="100%" height="600px" />
|
|
32
|
+
</div>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Size Variations
|
|
40
|
+
|
|
41
|
+
### Responsive sizing
|
|
42
|
+
|
|
43
|
+
```tsx
|
|
44
|
+
<AgentforceConversationClient agentId="0Xx..." inline width="100%" height="80vh" />
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Calculated dimensions
|
|
48
|
+
|
|
49
|
+
```tsx
|
|
50
|
+
<AgentforceConversationClient agentId="0Xx..." inline width="500px" height="calc(100vh - 100px)" />
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## Theming Combinations
|
|
56
|
+
|
|
57
|
+
### Brand theme with custom sizing
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
<AgentforceConversationClient
|
|
61
|
+
agentId="0Xx..."
|
|
62
|
+
inline
|
|
63
|
+
width="500px"
|
|
64
|
+
height="700px"
|
|
65
|
+
styleTokens={{
|
|
66
|
+
headerBlockBackground: "#0176d3",
|
|
67
|
+
headerBlockTextColor: "#ffffff",
|
|
68
|
+
messageBlockInboundBackgroundColor: "#0176d3",
|
|
69
|
+
messageBlockInboundTextColor: "#ffffff",
|
|
70
|
+
messageInputFooterSendButton: "#0176d3",
|
|
71
|
+
}}
|
|
72
|
+
/>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Dark theme
|
|
76
|
+
|
|
77
|
+
```tsx
|
|
78
|
+
<AgentforceConversationClient
|
|
79
|
+
agentId="0Xx..."
|
|
80
|
+
styleTokens={{
|
|
81
|
+
headerBlockBackground: "#1a1a1a",
|
|
82
|
+
headerBlockTextColor: "#ffffff",
|
|
83
|
+
messageBlockInboundBackgroundColor: "#2d2d2d",
|
|
84
|
+
messageBlockInboundTextColor: "#ffffff",
|
|
85
|
+
messageBlockOutboundBackgroundColor: "#3a3a3a",
|
|
86
|
+
messageBlockOutboundTextColor: "#f0f0f0",
|
|
87
|
+
}}
|
|
88
|
+
/>
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Inline without header
|
|
92
|
+
|
|
93
|
+
```tsx
|
|
94
|
+
<AgentforceConversationClient
|
|
95
|
+
agentId="0Xx..."
|
|
96
|
+
inline
|
|
97
|
+
width="100%"
|
|
98
|
+
height="600px"
|
|
99
|
+
headerEnabled={false}
|
|
100
|
+
styleTokens={{
|
|
101
|
+
messageBlockBorderRadius: "12px",
|
|
102
|
+
}}
|
|
103
|
+
/>
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## Complete Host Component Example
|
|
109
|
+
|
|
110
|
+
```tsx
|
|
111
|
+
import { Outlet } from "react-router";
|
|
112
|
+
import { AgentforceConversationClient } from "@salesforce/webapp-template-feature-react-agentforce-conversation-client-experimental";
|
|
113
|
+
|
|
114
|
+
export default function AgentChatHost() {
|
|
115
|
+
return (
|
|
116
|
+
<>
|
|
117
|
+
<Outlet />
|
|
118
|
+
<AgentforceConversationClient
|
|
119
|
+
agentId="0Xx..."
|
|
120
|
+
styleTokens={{
|
|
121
|
+
headerBlockBackground: "#0176d3",
|
|
122
|
+
headerBlockTextColor: "#ffffff",
|
|
123
|
+
}}
|
|
124
|
+
/>
|
|
125
|
+
</>
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
For complete style token reference, see `references/style-tokens.md` or `node_modules/@salesforce/agentforce-conversation-client/README.md`.
|
package/dist/.a4drules/skills/managing-agentforce-conversation-client/references/style-tokens.md
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# Style Tokens Reference
|
|
2
|
+
|
|
3
|
+
This document explains how to use `styleTokens` for theming and styling the AgentforceConversationClient.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The `styleTokens` prop is the **ONLY** way to customize the appearance of the Agentforce conversation client. It accepts an object with style token keys and CSS values.
|
|
8
|
+
|
|
9
|
+
## Source of Truth
|
|
10
|
+
|
|
11
|
+
For the complete and always up-to-date list of all 60+ style tokens, see:
|
|
12
|
+
|
|
13
|
+
**[@salesforce/agentforce-conversation-client on npm](https://www.npmjs.com/package/@salesforce/agentforce-conversation-client)**
|
|
14
|
+
|
|
15
|
+
The npm package README contains the definitive documentation with all available style tokens.
|
|
16
|
+
|
|
17
|
+
## Token Categories
|
|
18
|
+
|
|
19
|
+
Style tokens are organized by UI area:
|
|
20
|
+
|
|
21
|
+
- **Header** (7 tokens): background, text color, hover, active, focus, border, font family
|
|
22
|
+
- **Messages** (10 tokens): colors, padding, margins, border radius, fonts, body width
|
|
23
|
+
- **Inbound messages** (5 tokens): background, text color, width, alignment, hover
|
|
24
|
+
- **Outbound messages** (5 tokens): background, text color, width, alignment, margin
|
|
25
|
+
- **Input** (33 tokens): colors, borders, fonts, padding, buttons, scrollbar, textarea, actions
|
|
26
|
+
|
|
27
|
+
## Common Use Cases
|
|
28
|
+
|
|
29
|
+
### Change header color
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
<AgentforceConversationClient
|
|
33
|
+
agentId="0Xx..."
|
|
34
|
+
styleTokens={{
|
|
35
|
+
headerBlockBackground: "#0176d3",
|
|
36
|
+
headerBlockTextColor: "#ffffff",
|
|
37
|
+
}}
|
|
38
|
+
/>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Change message colors
|
|
42
|
+
|
|
43
|
+
```tsx
|
|
44
|
+
<AgentforceConversationClient
|
|
45
|
+
agentId="0Xx..."
|
|
46
|
+
styleTokens={{
|
|
47
|
+
messageBlockInboundBackgroundColor: "#4CAF50",
|
|
48
|
+
messageBlockInboundTextColor: "#ffffff",
|
|
49
|
+
messageBlockOutboundBackgroundColor: "#f5f5f5",
|
|
50
|
+
messageBlockOutboundTextColor: "#333333",
|
|
51
|
+
}}
|
|
52
|
+
/>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Apply brand colors
|
|
56
|
+
|
|
57
|
+
```tsx
|
|
58
|
+
<AgentforceConversationClient
|
|
59
|
+
agentId="0Xx..."
|
|
60
|
+
styleTokens={{
|
|
61
|
+
headerBlockBackground: "#1a73e8",
|
|
62
|
+
headerBlockTextColor: "#ffffff",
|
|
63
|
+
messageBlockInboundBackgroundColor: "#1a73e8",
|
|
64
|
+
messageBlockInboundTextColor: "#ffffff",
|
|
65
|
+
messageInputFooterSendButton: "#1a73e8",
|
|
66
|
+
messageInputFooterSendButtonHoverColor: "#1557b0",
|
|
67
|
+
}}
|
|
68
|
+
/>
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Adjust spacing and fonts
|
|
72
|
+
|
|
73
|
+
```tsx
|
|
74
|
+
<AgentforceConversationClient
|
|
75
|
+
agentId="0Xx..."
|
|
76
|
+
styleTokens={{
|
|
77
|
+
messageInputFontSize: "16px",
|
|
78
|
+
messageBlockBorderRadius: "12px",
|
|
79
|
+
messageBlockPadding: "16px",
|
|
80
|
+
messageInputPadding: "12px",
|
|
81
|
+
}}
|
|
82
|
+
/>
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## How to Find Token Names
|
|
86
|
+
|
|
87
|
+
1. Check the [@salesforce/agentforce-conversation-client npm package](https://www.npmjs.com/package/@salesforce/agentforce-conversation-client) for the complete list of all tokens
|
|
88
|
+
|
|
89
|
+
2. Token names follow a pattern:
|
|
90
|
+
- `headerBlock*` - Header area
|
|
91
|
+
- `messageBlock*` - Message bubbles
|
|
92
|
+
- `messageBlockInbound*` - Messages from customer to agent
|
|
93
|
+
- `messageBlockOutbound*` - Messages from agent to customer
|
|
94
|
+
- `messageInput*` - Input field and send button
|
|
95
|
+
|
|
96
|
+
## Important Notes
|
|
97
|
+
|
|
98
|
+
- You do NOT need to provide all tokens - only override the ones you want to change
|
|
99
|
+
- Token values are CSS strings (e.g., `"#FF0000"`, `"16px"`, `"bold"`)
|
|
100
|
+
- Invalid token names are silently ignored
|
|
101
|
+
- The component uses default values for any tokens you don't specify
|
|
@@ -23,7 +23,7 @@ Common issues when using the Agentforce Conversation Client.
|
|
|
23
23
|
**Solution:**
|
|
24
24
|
|
|
25
25
|
1. Confirm the id is correct (18-char Salesforce id, starts with `0Xx`).
|
|
26
|
-
2. Ensure the agent is Active in **Setup → Agents**.
|
|
26
|
+
2. Ensure the agent is Active in **Setup → Agentforce Agents**.
|
|
27
27
|
3. Verify the agent is deployed to the target channel.
|
|
28
28
|
|
|
29
29
|
---
|
|
@@ -36,25 +36,22 @@ Common issues when using the Agentforce Conversation Client.
|
|
|
36
36
|
|
|
37
37
|
1. Go to **Setup → Session Settings → Trusted Domains for Inline Frames**.
|
|
38
38
|
2. Add `localhost:<PORT>` (example: `localhost:3000`).
|
|
39
|
-
|
|
39
|
+
|
|
40
|
+
**Important:**
|
|
41
|
+
|
|
42
|
+
- This setting should be **temporary for local development only**.
|
|
43
|
+
- **Remove `localhost:<PORT>` from trusted domains after development**.
|
|
44
|
+
- **Recommended:** Test the Agentforce conversation client in a deployed app instead of relying on localhost trusted domains for extended periods.
|
|
40
45
|
|
|
41
46
|
---
|
|
42
47
|
|
|
43
48
|
### Blank iframe / auth session issues
|
|
44
49
|
|
|
45
|
-
**
|
|
50
|
+
**Possible cause:** First-party Salesforce cookie restriction may block embedded auth flow in some environments.
|
|
46
51
|
|
|
47
52
|
**Solution:**
|
|
48
53
|
|
|
49
54
|
1. Go to **Setup → Session Settings**.
|
|
50
55
|
2. Find **Require first party use of Salesforce cookies**.
|
|
51
|
-
3. Disable it
|
|
56
|
+
3. Disable it **only if needed and approved by your security/admin team**.
|
|
52
57
|
4. Save and reload.
|
|
53
|
-
|
|
54
|
-
---
|
|
55
|
-
|
|
56
|
-
### Multiple chat widgets appear
|
|
57
|
-
|
|
58
|
-
**Cause:** Component rendered more than once.
|
|
59
|
-
|
|
60
|
-
**Solution:** Render one instance in app layout only.
|
|
@@ -59,7 +59,8 @@ The base React app (`base-react-app`) ships with all GraphQL dependencies and to
|
|
|
59
59
|
Before using this skill, ensure:
|
|
60
60
|
|
|
61
61
|
1. The `@salesforce/sdk-data` package is available (provides `createDataSDK`, `gql`, `NodeOfConnection`)
|
|
62
|
-
2.
|
|
62
|
+
2. **Deployment order**: Metadata must be deployed before schema fetch; schema must be refetched after any metadata deployment. Invoke the `deploying-to-salesforce` skill when deploying or syncing with the org.
|
|
63
|
+
3. A `schema.graphql` file exists at the project root. If missing, generate it:
|
|
63
64
|
```bash
|
|
64
65
|
# Run from webapp dir (force-app/main/default/webapplications/<app-name>/)
|
|
65
66
|
npm run graphql:schema
|
|
@@ -15,7 +15,6 @@ Enforces ESLint, TypeScript, and build validation for consistent, maintainable c
|
|
|
15
15
|
```bash
|
|
16
16
|
npm run lint # MUST result in 0 errors
|
|
17
17
|
npm run build # MUST succeed (includes TypeScript check)
|
|
18
|
-
npm run graphql:codegen # MUST succeed (verifies graphql queries)
|
|
19
18
|
```
|
|
20
19
|
|
|
21
20
|
**Must Pass:**
|
|
@@ -25,4 +24,8 @@ npm run graphql:codegen # MUST succeed (verifies graphql queries)
|
|
|
25
24
|
|
|
26
25
|
**Can Be Warnings:**
|
|
27
26
|
- ESLint warnings (fix when convenient)
|
|
28
|
-
- Minor TypeScript warnings
|
|
27
|
+
- Minor TypeScript warnings
|
|
28
|
+
|
|
29
|
+
## When Failures Occur
|
|
30
|
+
|
|
31
|
+
If `npm run lint` or `npm run build` fails, the agent **must** attempt to resolve the issues and retry. Do not leave the session with failing quality gates. Fix the reported errors (TypeScript, ESLint), then re-run the failing command. Repeat until all steps pass.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Salesforce data access for web apps — when and how to use the accessing-data skill
|
|
3
|
+
paths:
|
|
4
|
+
- "**/*"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Web App Data Access
|
|
8
|
+
|
|
9
|
+
For all Salesforce data access from web apps (GraphQL, REST, Chatter, Connect, Apex REST, UI API, Einstein LLM), invoke the **`accessing-data`** skill (`.a4drules/skills/accessing-data/`). It enforces Data SDK usage (`createDataSDK()` + `sdk.graphql` or `sdk.fetch`), GraphQL-first preference, optional chaining, and documents when to use `sdk.fetch` via the `fetching-rest-api` skill.
|
|
10
|
+
|
|
11
|
+
## Sub-skills
|
|
12
|
+
|
|
13
|
+
- **GraphQL** — For queries and mutations, invoke the **`using-graphql`** skill (`.a4drules/skills/using-graphql/`). Covers schema exploration, query patterns, codegen, and type generation.
|
|
14
|
+
- **REST / UI API** — When GraphQL cannot cover the use case, use `sdk.fetch?.()`. See the **`fetching-rest-api`** skill (`.a4drules/skills/fetching-rest-api/`) for Chatter, Connect REST, Apex REST, UI API REST, and Einstein LLM.
|
|
15
|
+
|
|
16
|
+
## Clarifying Vague Data Requests
|
|
17
|
+
|
|
18
|
+
When a user asks about data and the request is vague, **clarify before implementing**. Ask which of the following they want:
|
|
19
|
+
|
|
20
|
+
- **Application code** — Add or modify code in a specific web app so the app performs the data interaction at runtime (e.g., GraphQL query in the React app)
|
|
21
|
+
- **Local SF CLI** — Run Salesforce CLI commands locally (e.g., `sf data query`, `sf data import tree`) to interact with the org from the terminal
|
|
22
|
+
- **Local example data** — Update or add local fixture/example data files (e.g., JSON in `data/`) for development or testing
|
|
23
|
+
- **Other** — Data export, report generation, setup script, etc.
|
|
24
|
+
|
|
25
|
+
Do not assume. A request like "fetch accounts" could mean: (1) add a GraphQL query to the app, (2) run `sf data query` in the terminal, or (3) update sample data files. Confirm the intent before proceeding.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Always invoke the deploying-to-salesforce skill for deployment, schema fetch, or org sync
|
|
3
|
+
paths:
|
|
4
|
+
- "**/*"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Web App Deployment
|
|
8
|
+
|
|
9
|
+
**This rule always applies.** Before running any deployment, schema fetch, codegen, or org sync command, you MUST invoke the **deploying-to-salesforce** skill (`.a4drules/skills/deploying-to-salesforce/SKILL.md`).
|
|
10
|
+
|
|
11
|
+
## When to Invoke
|
|
12
|
+
|
|
13
|
+
Invoke the skill whenever the task involves:
|
|
14
|
+
|
|
15
|
+
- Deploying metadata (`sf project deploy start`)
|
|
16
|
+
- Assigning permission sets, permission set groups, or profiles
|
|
17
|
+
- Fetching GraphQL schema (`npm run graphql:schema`)
|
|
18
|
+
- Running GraphQL codegen (`npm run graphql:codegen`)
|
|
19
|
+
- Data import or cleaning existing records
|
|
20
|
+
- Any command that touches the Salesforce org
|
|
21
|
+
|
|
22
|
+
## Required Behavior
|
|
23
|
+
|
|
24
|
+
1. **Read the skill first** — Open and read the full deploying-to-salesforce skill before executing deployment-related steps.
|
|
25
|
+
2. **Follow the canonical sequence** — Execute steps in the exact order defined in the skill.
|
|
26
|
+
3. **Evaluate before each step** — Use the skill's "Run when" / "Omit when" criteria; do not run steps blindly.
|
|
27
|
+
4. **Proactive post-deploy actions** — After a successful deploy, the agent MUST either run or explicitly offer:
|
|
28
|
+
- **Permission set assignment:** Discover permsets in `force-app/main/default/permissionsets/` and assign each to the org (or ask: "Do you want me to assign the permission sets?")
|
|
29
|
+
- **Data import:** If `data/data-plan.json` exists, ask: "Do you want me to import the sample data now?" — never import without explicit user confirmation.
|
|
30
|
+
5. **Ask before data operations** — Never import data or clean existing records without explicit user confirmation.
|
|
31
|
+
|
|
32
|
+
Do not bypass this skill. It enforces the correct deployment order and prevents schema/codegen failures.
|
|
@@ -9,7 +9,7 @@ paths:
|
|
|
9
9
|
### Never Use `any`
|
|
10
10
|
```typescript
|
|
11
11
|
// FORBIDDEN
|
|
12
|
-
const
|
|
12
|
+
const result: any = getSomething();
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
## React TypeScript Patterns
|
|
@@ -27,25 +27,17 @@ const handleSubmit = (event: React.FormEvent<HTMLFormElement>): void => {
|
|
|
27
27
|
const [user, setUser] = useState<User | null>(null);
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
-
### GraphQL via DataSDK
|
|
31
|
-
|
|
32
|
-
See **webapp-react.md** for DataSDK usage patterns. Type your GraphQL responses:
|
|
33
|
-
|
|
34
|
-
```typescript
|
|
35
|
-
const response = await sdk.graphql?.<GetAccountsQuery>(QUERY, variables);
|
|
36
|
-
```
|
|
37
|
-
|
|
38
30
|
### Type Assertions
|
|
39
31
|
```typescript
|
|
40
32
|
// FORBIDDEN: Unsafe assertions
|
|
41
|
-
const user =
|
|
33
|
+
const user = obj as User;
|
|
42
34
|
|
|
43
35
|
// REQUIRED: Type guards
|
|
44
36
|
function isUser(obj: unknown): obj is User {
|
|
45
37
|
return typeof obj === 'object' && obj !== null && typeof (obj as User).id === 'string';
|
|
46
38
|
}
|
|
47
39
|
|
|
48
|
-
if (isUser(
|
|
49
|
-
console.log(
|
|
40
|
+
if (isUser(obj)) {
|
|
41
|
+
console.log(obj.name); // Now safely typed
|
|
50
42
|
}
|
|
51
43
|
```
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: React-specific patterns
|
|
2
|
+
description: React-specific patterns for SFDX web apps
|
|
3
3
|
paths:
|
|
4
4
|
- "**/webapplications/**/*"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# React Web App (SFDX)
|
|
8
8
|
|
|
9
|
-
For layout, navigation, and generation rules, see **webapp.md
|
|
9
|
+
For layout, navigation, and generation rules, see **creating-webapp** (`.a4drules/skills/creating-webapp/SKILL.md`).
|
|
10
|
+
|
|
11
|
+
## Deployment
|
|
12
|
+
|
|
13
|
+
For deployment, schema fetch, codegen, or org sync, invoke the **`deploying-to-salesforce`** skill (`.a4drules/skills/deploying-to-salesforce/`).
|
|
10
14
|
|
|
11
15
|
## Routing (React Router)
|
|
12
16
|
|
|
@@ -21,14 +25,4 @@ Use a **single** router package for the app. When using `createBrowserRouter` an
|
|
|
21
25
|
|
|
22
26
|
React apps must NOT import Salesforce platform modules like `lightning/*` or `@wire` (LWC-only)
|
|
23
27
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
For all Salesforce data access (GraphQL, REST, Chatter, Connect, Apex REST, UI API, Einstein LLM), invoke the **`accessing-data`** skill (`.a4drules/skills/accessing-data/`). It enforces Data SDK usage, GraphQL-first preference, optional chaining, and documents when to use `sdk.fetch` via the `fetching-rest-api` skill.
|
|
27
|
-
|
|
28
|
-
### GraphQL (Preferred)
|
|
29
|
-
|
|
30
|
-
For queries and mutations, invoke the **`using-graphql`** skill (`.a4drules/skills/using-graphql/`). It covers schema exploration, query patterns, codegen, type generation, and guardrails.
|
|
31
|
-
|
|
32
|
-
### UI API (Fallback)
|
|
33
|
-
|
|
34
|
-
When GraphQL cannot cover the use case, use `sdk.fetch?.()` for UI API endpoints. See the **`fetching-rest-api`** skill (`.a4drules/skills/fetching-rest-api/`) for full REST API documentation.
|
|
28
|
+
For Salesforce data access, see **webapp-data-access** (`.a4drules/webapp-data-access.md`).
|
package/dist/AGENT.md
CHANGED
|
@@ -61,11 +61,14 @@ This project includes **.a4drules/** at the project root. Follow them when gener
|
|
|
61
61
|
- **Accessing Data** (`.a4drules/skills/accessing-data/`): Use for all Salesforce data fetches. Enforces Data SDK usage (`createDataSDK()` + `sdk.graphql` or `sdk.fetch`); GraphQL preferred, fetch when GraphQL is not sufficient.
|
|
62
62
|
- **Fetching REST API** (`.a4drules/skills/fetching-rest-api/`): Use when implementing Chatter, Connect REST, Apex REST, UI API REST, or Einstein LLM calls via `sdk.fetch`.
|
|
63
63
|
- **Using GraphQL** (`.a4drules/skills/using-graphql/`): Use when implementing Salesforce GraphQL queries or mutations. Sub-skills: `exploring-graphql-schema`, `generating-graphql-read-query`, `generating-graphql-mutation-query`.
|
|
64
|
+
- **Deploying to Salesforce** (`.a4drules/skills/deploying-to-salesforce/`): Use when deploying metadata, fetching GraphQL schema, or generating deploy/setup commands. Enforces deploy → permset → schema → codegen order; schema refetch after metadata deployment.
|
|
64
65
|
|
|
65
66
|
When rules refer to "web app directory" or `<sfdx-source>/webapplications/<appName>/`, resolve `<sfdx-source>` from `sfdx-project.json` and use the **actual app folder name** for this project.
|
|
66
67
|
|
|
67
68
|
## Deploying
|
|
68
69
|
|
|
70
|
+
**Deployment order:** Metadata (objects, permission sets) must be deployed before GraphQL schema fetch. After any metadata deployment, re-run `npm run graphql:schema` and `npm run graphql:codegen` from the webapp dir. **One-command setup:** `node scripts/setup-cli.mjs --target-org <alias>` runs deploy → permset → schema → codegen in the correct order. Invoke the `deploying-to-salesforce` skill for full guidance.
|
|
71
|
+
|
|
69
72
|
From **this project root** (resolve the actual SFDX source path from `sfdx-project.json`):
|
|
70
73
|
|
|
71
74
|
```bash
|
package/dist/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,25 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.107.4](https://github.com/salesforce-experience-platform-emu/webapps/compare/v1.107.3...v1.107.4) (2026-03-18)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @salesforce/webapp-template-base-sfdx-project-experimental
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [1.107.3](https://github.com/salesforce-experience-platform-emu/webapps/compare/v1.107.2...v1.107.3) (2026-03-18)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* **lint-and-metadata:** Linting in template apps, metadata and query fixes, and skills for deployment orders ([#304](https://github.com/salesforce-experience-platform-emu/webapps/issues/304)) ([980b931](https://github.com/salesforce-experience-platform-emu/webapps/commit/980b9318cba0f7d5d93620e08bf4138df51b3700))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
6
25
|
## [1.107.2](https://github.com/salesforce-experience-platform-emu/webapps/compare/v1.107.1...v1.107.2) (2026-03-18)
|
|
7
26
|
|
|
8
27
|
**Note:** Version bump only for package @salesforce/webapp-template-base-sfdx-project-experimental
|
|
@@ -15,14 +15,8 @@
|
|
|
15
15
|
"graphql:schema": "node scripts/get-graphql-schema.mjs"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@salesforce/
|
|
19
|
-
"@salesforce/
|
|
20
|
-
"@salesforce/sdk-chat": "file:../../../../../../../../../sdk/sdk-chat",
|
|
21
|
-
"@salesforce/sdk-core": "file:../../../../../../../../../sdk/sdk-core",
|
|
22
|
-
"@salesforce/sdk-data": "file:../../../../../../../../../sdk/sdk-data",
|
|
23
|
-
"@salesforce/sdk-lightning": "file:../../../../../../../../../sdk/sdk-lightning",
|
|
24
|
-
"@salesforce/sdk-view": "file:../../../../../../../../../sdk/sdk-view",
|
|
25
|
-
"@salesforce/webapp-experimental": "file:../../../../../../../../../webapps",
|
|
18
|
+
"@salesforce/sdk-data": "^1.107.4",
|
|
19
|
+
"@salesforce/webapp-experimental": "^1.107.4",
|
|
26
20
|
"@tailwindcss/vite": "^4.1.17",
|
|
27
21
|
"class-variance-authority": "^0.7.1",
|
|
28
22
|
"clsx": "^2.1.1",
|
|
@@ -47,7 +41,7 @@
|
|
|
47
41
|
"@graphql-eslint/eslint-plugin": "^4.1.0",
|
|
48
42
|
"@graphql-tools/utils": "^11.0.0",
|
|
49
43
|
"@playwright/test": "^1.49.0",
|
|
50
|
-
"@salesforce/vite-plugin-webapp-experimental": "
|
|
44
|
+
"@salesforce/vite-plugin-webapp-experimental": "^1.107.4",
|
|
51
45
|
"@testing-library/jest-dom": "^6.6.3",
|
|
52
46
|
"@testing-library/react": "^16.1.0",
|
|
53
47
|
"@testing-library/user-event": "^14.5.2",
|
|
@@ -4,7 +4,10 @@ import { StrictMode } from 'react';
|
|
|
4
4
|
import { createRoot } from 'react-dom/client';
|
|
5
5
|
import './styles/global.css';
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
// Normalize basename: strip trailing slash so it matches URLs like /lwr/application/ai/c-app
|
|
8
|
+
const rawBasePath = (globalThis as any).SFDC_ENV?.basePath;
|
|
9
|
+
const basename =
|
|
10
|
+
typeof rawBasePath === 'string' ? rawBasePath.replace(/\/+$/, '') : undefined;
|
|
8
11
|
const router = createBrowserRouter(routes, { basename });
|
|
9
12
|
|
|
10
13
|
createRoot(document.getElementById('root')!).render(
|
|
@@ -26,10 +26,10 @@ interface StatusAlertProps extends VariantProps<typeof statusAlertVariants> {
|
|
|
26
26
|
* Returns null if no children are provided.
|
|
27
27
|
*/
|
|
28
28
|
export function StatusAlert({ children, variant = 'error' }: StatusAlertProps) {
|
|
29
|
+
const descriptionId = useId();
|
|
29
30
|
if (!children) return null;
|
|
30
31
|
|
|
31
32
|
const isError = variant === 'error';
|
|
32
|
-
const descriptionId = useId();
|
|
33
33
|
|
|
34
34
|
return (
|
|
35
35
|
<Alert
|
|
@@ -31,6 +31,12 @@
|
|
|
31
31
|
"@assets/*": ["./src/assets/*"]
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
|
-
"include": [
|
|
34
|
+
"include": [
|
|
35
|
+
"src",
|
|
36
|
+
"e2e",
|
|
37
|
+
"vite-env.d.ts",
|
|
38
|
+
"vitest-env.d.ts",
|
|
39
|
+
"vitest.setup.ts"
|
|
40
|
+
],
|
|
35
41
|
"references": [{ "path": "./tsconfig.node.json" }]
|
|
36
42
|
}
|