@salesforce/webapp-template-app-react-b2c-sample-experimental 1.29.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/LICENSE.txt +82 -0
- package/dist/.a4drules/build-validation.md +81 -0
- package/dist/.a4drules/code-quality.md +150 -0
- package/dist/.a4drules/graphql/tools/knowledge/lds-explore-graphql-schema.md +227 -0
- package/dist/.a4drules/graphql/tools/knowledge/lds-generate-graphql-mutationquery.md +212 -0
- package/dist/.a4drules/graphql/tools/knowledge/lds-generate-graphql-readquery.md +185 -0
- package/dist/.a4drules/graphql/tools/knowledge/lds-guide-graphql.md +205 -0
- package/dist/.a4drules/graphql/tools/schemas/shared.graphqls +1150 -0
- package/dist/.a4drules/graphql.md +408 -0
- package/dist/.a4drules/images.md +13 -0
- package/dist/.a4drules/react.md +361 -0
- package/dist/.a4drules/react_image_processing.md +45 -0
- package/dist/.a4drules/skills/install-feature/SKILL.md +66 -0
- package/dist/.a4drules/skills/install-feature/scripts/copy-feature-assets.sh +36 -0
- package/dist/.a4drules/typescript.md +224 -0
- package/dist/.forceignore +15 -0
- package/dist/.husky/pre-commit +4 -0
- package/dist/.prettierignore +11 -0
- package/dist/.prettierrc +17 -0
- package/dist/CHANGELOG.md +364 -0
- package/dist/README.md +18 -0
- package/dist/config/project-scratch-def.json +13 -0
- package/dist/force-app/main/default/digitalExperienceConfigs/appreactb2csample1.digitalExperienceConfig +8 -0
- package/dist/force-app/main/default/digitalExperiences/site/appreactb2csample1/appreactb2csample1.digitalExperience-meta.xml +11 -0
- package/dist/force-app/main/default/digitalExperiences/site/appreactb2csample1/sfdc_cms__site/appreactb2csample1/_meta.json +5 -0
- package/dist/force-app/main/default/digitalExperiences/site/appreactb2csample1/sfdc_cms__site/appreactb2csample1/content.json +10 -0
- package/dist/force-app/main/default/networks/appreactb2csample.network +60 -0
- package/dist/force-app/main/default/package.xml +20 -0
- package/dist/force-app/main/default/sites/appreactb2csample.site +31 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/.prettierignore +9 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/.prettierrc +11 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/appreactb2csample.webapplication-meta.xml +7 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/build/vite.config.d.ts +2 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/build/vite.config.js +74 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/e2e/app.spec.ts +24 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/eslint.config.js +113 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/index.html +13 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/package-lock.json +7157 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/package.json +45 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/playwright.config.ts +24 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/scripts/rewrite-e2e-assets.mjs +23 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/src/api/graphql-operations-types.ts +127 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/src/api/utils/query/highRevenueAccountsQuery.graphql +29 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/src/app.tsx +41 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/src/appLayout.tsx +161 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/src/assets/icons/book.svg +3 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/src/assets/icons/copy.svg +4 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/src/assets/icons/rocket.svg +3 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/src/assets/icons/star.svg +3 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/src/assets/images/codey-1.png +0 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/src/assets/images/codey-2.png +0 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/src/assets/images/codey-3.png +0 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/src/assets/images/vibe-codey.svg +194 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/src/components/ui/alert.tsx +65 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/src/components/ui/button.tsx +54 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/src/components/ui/card.tsx +77 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/src/components/ui/field.tsx +111 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/src/components/ui/index.ts +71 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/src/components/ui/input.tsx +19 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/src/components/ui/label.tsx +19 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/src/components/ui/pagination.tsx +99 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/src/components/ui/select.tsx +151 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/src/components/ui/skeleton.tsx +7 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/src/components/ui/spinner.tsx +26 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/src/components/ui/table.tsx +114 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/src/components/ui/tabs.tsx +115 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/src/lib/utils.ts +6 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/src/pages/About.tsx +8 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/src/pages/Application.tsx +101 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/src/pages/Dashboard.tsx +101 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/src/pages/HelpCenter.tsx +29 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/src/pages/Home.tsx +30 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/src/pages/Maintenance.tsx +132 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/src/pages/NotFound.tsx +14 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/src/pages/PropertyDetails.tsx +68 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/src/pages/PropertyListings.tsx +84 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/src/routes.tsx +62 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/src/styles/global.css +80 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/tsconfig.json +36 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/tsconfig.node.json +13 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/vite-env.d.ts +1 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/vite.config.ts +83 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/vitest-env.d.ts +2 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/vitest.config.ts +11 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/vitest.setup.ts +1 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/webapplication.json +7 -0
- package/dist/jest.config.js +6 -0
- package/dist/package.json +37 -0
- package/dist/scripts/apex/hello.apex +10 -0
- package/dist/scripts/soql/account.soql +6 -0
- package/dist/sfdx-project.json +12 -0
- package/package.json +28 -0
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
# AI Customization Rule: React Web App (SFDX)
|
|
2
|
+
|
|
3
|
+
This rule consolidates React web application guidelines, data access rules, security standards, anti-patterns, and project integration requirements for consistent AI-generated code.
|
|
4
|
+
|
|
5
|
+
## Targets (File Pattern Matching)
|
|
6
|
+
|
|
7
|
+
Apply these rules to the React web app files under the SFDX package directory:
|
|
8
|
+
|
|
9
|
+
- `force-app/main/default/webapplications/*/**/*.js`
|
|
10
|
+
- `force-app/main/default/webapplications/*/**/*.jsx`
|
|
11
|
+
- `force-app/main/default/webapplications/*/**/*.ts`
|
|
12
|
+
- `force-app/main/default/webapplications/*/**/*.tsx`
|
|
13
|
+
|
|
14
|
+
## Rule Objectives
|
|
15
|
+
|
|
16
|
+
- Enforce secure, performant, and maintainable patterns for Salesforce data access.
|
|
17
|
+
- Standardize UI with shadcn/ui and Tailwind.
|
|
18
|
+
- Prevent prohibited patterns that break React or Salesforce constraints.
|
|
19
|
+
|
|
20
|
+
## Project & Entry Points
|
|
21
|
+
|
|
22
|
+
- React web app root: `force-app/main/default/webapplications/<appName>/`
|
|
23
|
+
- Main entry component: `force-app/main/default/webapplications/<appName>/src/App.tsx`
|
|
24
|
+
- Running Development Server:
|
|
25
|
+
- `npm run dev`
|
|
26
|
+
- You can generally assume the dev server is already running and don't need to start it.
|
|
27
|
+
- Keep build/deploy workflow intact:
|
|
28
|
+
- `npm run build`
|
|
29
|
+
- `npm run deploy`
|
|
30
|
+
- `npm run open`
|
|
31
|
+
|
|
32
|
+
## Component Library (MANDATORY)
|
|
33
|
+
|
|
34
|
+
- Use shadcn/ui for UI components (Buttons, Cards, Inputs, Dialogs, etc.).
|
|
35
|
+
- Import patterns:
|
|
36
|
+
|
|
37
|
+
```javascript
|
|
38
|
+
import { Button } from '@/components/ui/button';
|
|
39
|
+
import { Card, CardHeader, CardContent } from '@/components/ui/card';
|
|
40
|
+
import { Input } from '@/components/ui/input';
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Styling Standards
|
|
44
|
+
|
|
45
|
+
- Use Tailwind CSS utility classes.
|
|
46
|
+
- Follow consistent spacing, color, and typography conventions.
|
|
47
|
+
|
|
48
|
+
## Module & Platform Restrictions
|
|
49
|
+
|
|
50
|
+
- React apps must NOT import or rely on Salesforce platform modules; do not use:
|
|
51
|
+
- `@salesforce/*`
|
|
52
|
+
- `lightning/*`
|
|
53
|
+
- `@wire` (LWC-only)
|
|
54
|
+
- Use standard web APIs and npm packages only.
|
|
55
|
+
|
|
56
|
+
## LWC MCP Server Integration (Data Access Guidance)
|
|
57
|
+
|
|
58
|
+
The LWC MCP server (via Agentforce Vibes extension) provides framework-agnostic data access guidance for UI API and GraphQL patterns.
|
|
59
|
+
|
|
60
|
+
### Primary Tool: `orchestrate_lds_data_requirements`
|
|
61
|
+
|
|
62
|
+
The `orchestrate_lds_data_requirements` tool analyzes data requirements and routes to appropriate guidance tools (UI API or GraphQL). **Note:** Tool names may change, but the purpose remains orchestrating LDS data requirements.
|
|
63
|
+
|
|
64
|
+
**Important for React Applications:** If the MCP tool recommends Apex REST, React applications should ignore this recommendation. Apex REST is not available in React applications. Follow the [Apex REST Strategy](#data-access-priority-order) section above to evaluate whether GraphQL can handle the requirement, or inform the user that the feature is not currently supported in React.
|
|
65
|
+
|
|
66
|
+
### Tool Availability Check (MANDATORY)
|
|
67
|
+
|
|
68
|
+
Before implementing data access, **MUST** verify `orchestrate_lds_data_requirements` is available. If unavailable:
|
|
69
|
+
|
|
70
|
+
1. Notify user: "LWC MCP data access tools not enabled. Add 'lwc-experts' to --toolsets in a4d_mcp_settings.json"
|
|
71
|
+
2. Offer to update the file if you have write access
|
|
72
|
+
3. Otherwise, provide manual instructions
|
|
73
|
+
|
|
74
|
+
**Configuration:** Add `"lwc-experts"` to `--toolsets` in `a4d_mcp_settings.json` (typically at `{VSCode/Cursor globalStorage}/salesforce.salesforcedx-einstein-gpt/settings/a4d_mcp_settings.json`). Example: `"metadata,lwc-experts"` in the args array.
|
|
75
|
+
|
|
76
|
+
### LWC MCP Server Tool Usage Restrictions (CRITICAL)
|
|
77
|
+
|
|
78
|
+
**This rule applies when building React applications. Do NOT create LWC components or use LWC-specific development tools.**
|
|
79
|
+
|
|
80
|
+
**Allowed MCP Tools (Data Access Only):**
|
|
81
|
+
|
|
82
|
+
- `orchestrate_lds_data_requirements` - Primary tool for data access guidance
|
|
83
|
+
- Any data access guidance tools referenced by `orchestrate_lds_data_requirements` (e.g., UI API or GraphQL guidance tools)
|
|
84
|
+
|
|
85
|
+
**Note:** If the MCP tool recommends Apex REST guidance tools, React applications should ignore these recommendations as Apex REST is not available in React.
|
|
86
|
+
|
|
87
|
+
**Prohibited MCP Tools (LWC Component Development):**
|
|
88
|
+
|
|
89
|
+
- `guide_lwc_development` - LWC component development guidance
|
|
90
|
+
- `orchestrate_lwc_component_creation` - LWC component creation orchestration
|
|
91
|
+
- `create_lwc_component_from_prd` - LWC component creation from PRD
|
|
92
|
+
- Any other LWC component creation, development, or framework-specific tools
|
|
93
|
+
|
|
94
|
+
**Enforcement:**
|
|
95
|
+
|
|
96
|
+
- **NEVER** call LWC component creation or development tools from the LWC MCP server
|
|
97
|
+
- **ONLY** use data access related tools that provide framework-agnostic guidance
|
|
98
|
+
- If you encounter a request to create LWC components, remind the user that you are building a React app and redirect them to use React patterns instead
|
|
99
|
+
|
|
100
|
+
## Data Access Rules (CRITICAL)
|
|
101
|
+
|
|
102
|
+
- MANDATORY: Use `axios` for all API calls from React.
|
|
103
|
+
|
|
104
|
+
### Data Access Workflow (MANDATORY)
|
|
105
|
+
|
|
106
|
+
**Before implementing any data access functionality:**
|
|
107
|
+
|
|
108
|
+
1. **Proactively check** for LWC MCP server tool availability (see [LWC MCP Server Integration](#lwc-mcp-server-integration-data-access-guidance) section above)
|
|
109
|
+
2. **Use the LWC MCP server's `orchestrate_lds_data_requirements` tool** to get guidance on the appropriate data access pattern
|
|
110
|
+
3. The MCP tool will analyze your requirements and guide you to the appropriate Salesforce data access pattern (GraphQL or UI API)
|
|
111
|
+
4. **Follow the MCP tool's recommendations** when implementing data access code, prioritizing GraphQL for all operations
|
|
112
|
+
5. **If the tool recommends Apex REST**, ignore this recommendation and follow the [Apex REST Strategy](#data-access-priority-order) to evaluate if GraphQL can handle the requirement
|
|
113
|
+
|
|
114
|
+
**Note:** The code examples below serve as reference patterns, but your implementation should be informed by the MCP tool's guidance, which provides the most up-to-date best practices and framework-agnostic patterns.
|
|
115
|
+
|
|
116
|
+
### Data Access Priority Order
|
|
117
|
+
|
|
118
|
+
The LWC MCP server's `orchestrate_lds_data_requirements` tool follows this priority order when recommending data access patterns:
|
|
119
|
+
|
|
120
|
+
1. **GraphQL** (queries & mutations) - Preferred for all data operations including reads, writes, complex queries, relationships, and multi-entity operations
|
|
121
|
+
2. **Salesforce UI API** - For standard CRUD operations when GraphQL is not suitable
|
|
122
|
+
|
|
123
|
+
**Apex REST Strategy (CRITICAL):**
|
|
124
|
+
|
|
125
|
+
- **Apex REST is NOT available in React applications.** If the MCP tool recommends Apex REST, or if you believe Apex is needed:
|
|
126
|
+
1. **Reflect** on why Apex seems necessary
|
|
127
|
+
2. **Evaluate** whether GraphQL queries or mutations can accomplish the task
|
|
128
|
+
3. **If GraphQL cannot handle the requirement**, inform the user that the feature is not currently supported in React applications
|
|
129
|
+
4. **Do NOT** implement Apex REST endpoints or attempt to call them from React
|
|
130
|
+
|
|
131
|
+
**Note:** For AI/generative features, see the [Einstein LLM Gateway](#einstein-llm-gateway-aigenerative-features) section below.
|
|
132
|
+
|
|
133
|
+
### Reference Code Examples
|
|
134
|
+
|
|
135
|
+
The following code examples serve as reference patterns for React applications. **Always consult the LWC MCP server's `orchestrate_lds_data_requirements` tool first** to ensure you're using the most appropriate pattern and latest best practices for your specific use case.
|
|
136
|
+
|
|
137
|
+
UI API example (read):
|
|
138
|
+
|
|
139
|
+
```javascript
|
|
140
|
+
async function fetchRecord(recordId) {
|
|
141
|
+
try {
|
|
142
|
+
const res = await axios.get(
|
|
143
|
+
`/services/data/v62.0/ui-api/records/${recordId}`
|
|
144
|
+
);
|
|
145
|
+
return res.data;
|
|
146
|
+
} catch (error) {
|
|
147
|
+
const text = error.message;
|
|
148
|
+
throw new Error(`UI API failed: ${error.status} ${text}`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
GraphQL utility (supports both queries and mutations):
|
|
154
|
+
|
|
155
|
+
```javascript
|
|
156
|
+
export async function sfGraphQL(query, variables = {}) {
|
|
157
|
+
try {
|
|
158
|
+
const res = await axios.post('/services/data/v62.0/graphql', {
|
|
159
|
+
query,
|
|
160
|
+
variables,
|
|
161
|
+
});
|
|
162
|
+
const json = res.data;
|
|
163
|
+
if (Array.isArray(json.errors) && json.errors.length) {
|
|
164
|
+
throw new Error(json.errors.map(e => e.message).join('; '));
|
|
165
|
+
}
|
|
166
|
+
return json.data;
|
|
167
|
+
} catch (error) {
|
|
168
|
+
throw new Error(`GraphQL error: ${error.status}`);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
GraphQL query example:
|
|
174
|
+
|
|
175
|
+
```javascript
|
|
176
|
+
const GET_ACCOUNT = `
|
|
177
|
+
query GetAccount($id: ID!) {
|
|
178
|
+
uiapi {
|
|
179
|
+
query {
|
|
180
|
+
Account(where: { Id: { eq: $id } }) {
|
|
181
|
+
edges {
|
|
182
|
+
node {
|
|
183
|
+
Id
|
|
184
|
+
Name {
|
|
185
|
+
value
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
`;
|
|
194
|
+
|
|
195
|
+
const account = await sfGraphQL(GET_ACCOUNT, { id: '001...' });
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
GraphQL mutation example:
|
|
199
|
+
|
|
200
|
+
```javascript
|
|
201
|
+
const UPDATE_ACCOUNT = `
|
|
202
|
+
mutation UpdateAccount($id: ID!, $name: String!) {
|
|
203
|
+
uiapi {
|
|
204
|
+
AccountUpdate(input: {
|
|
205
|
+
Id: $id
|
|
206
|
+
Account: {
|
|
207
|
+
Name: { value: $name }
|
|
208
|
+
}
|
|
209
|
+
}) {
|
|
210
|
+
Record {
|
|
211
|
+
Id
|
|
212
|
+
Name {
|
|
213
|
+
value
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
`;
|
|
220
|
+
|
|
221
|
+
const result = await sfGraphQL(UPDATE_ACCOUNT, {
|
|
222
|
+
id: '001...',
|
|
223
|
+
name: 'New Name',
|
|
224
|
+
});
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
## Einstein LLM Gateway (AI/Generative Features)
|
|
228
|
+
|
|
229
|
+
Einstein LLM Gateway provides AI and generative capabilities for your React application. Use this service when you want to add features such as:
|
|
230
|
+
|
|
231
|
+
- Text generation
|
|
232
|
+
- Prompt-based AI responses
|
|
233
|
+
- LLM-powered content creation
|
|
234
|
+
- AI-assisted workflows
|
|
235
|
+
|
|
236
|
+
### Einstein LLM Gateway Pattern
|
|
237
|
+
|
|
238
|
+
```javascript
|
|
239
|
+
async function callEinsteinGenerations({ prompt, model = 'gpt-4', signal }) {
|
|
240
|
+
const url = '/services/data/v62.0/einstein/llm/prompt/generations';
|
|
241
|
+
try {
|
|
242
|
+
const resp = await axios.post(
|
|
243
|
+
url,
|
|
244
|
+
{
|
|
245
|
+
additionalConfig: {
|
|
246
|
+
applicationName: 'PromptTemplateGenerationsInvocable',
|
|
247
|
+
model,
|
|
248
|
+
},
|
|
249
|
+
promptTextorId: prompt,
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
signal,
|
|
253
|
+
}
|
|
254
|
+
);
|
|
255
|
+
const data = resp.data;
|
|
256
|
+
return data?.generations?.[0]?.text || '';
|
|
257
|
+
} catch (error) {
|
|
258
|
+
throw new Error(
|
|
259
|
+
error.message || `Einstein LLM request failed (${error.status})`
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
## Error Handling Pattern
|
|
266
|
+
|
|
267
|
+
- Always implement robust try/catch for async operations.
|
|
268
|
+
- Provide useful but safe error messages (no sensitive data leakage).
|
|
269
|
+
|
|
270
|
+
```javascript
|
|
271
|
+
async function safeFetch(recordId) {
|
|
272
|
+
try {
|
|
273
|
+
const data = await fetchRecord(recordId);
|
|
274
|
+
return data;
|
|
275
|
+
} catch (err) {
|
|
276
|
+
console.error('Salesforce UI API Error:', err);
|
|
277
|
+
throw err;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
## Anti-Patterns (Do NOT do these)
|
|
283
|
+
|
|
284
|
+
- **Apex REST is not available in React applications** - Do NOT attempt to use or call Apex REST endpoints from React code
|
|
285
|
+
- Unnecessary Apex controllers for simple UI API/GraphQL operations
|
|
286
|
+
- Missing error handling for async operations
|
|
287
|
+
- Hardcoded Salesforce URLs, IDs, or sensitive data
|
|
288
|
+
- Ignoring field-level security and permission checks
|
|
289
|
+
- Direct DOM manipulation in React components
|
|
290
|
+
- Using LWC-specific patterns (`@wire`, LDS) or `@salesforce/*` modules in React
|
|
291
|
+
|
|
292
|
+
## Security Standards (CRITICAL)
|
|
293
|
+
|
|
294
|
+
- Validate user permissions before data operations.
|
|
295
|
+
- Respect record sharing rules and field-level security.
|
|
296
|
+
- Never hardcode credentials or secrets in client code.
|
|
297
|
+
- Sanitize all user inputs.
|
|
298
|
+
- Use HTTPS for all API calls.
|
|
299
|
+
|
|
300
|
+
### Authentication Error Handling (MANDATORY)
|
|
301
|
+
|
|
302
|
+
- All axios clients MUST include response interceptors that handle 401/403 errors.
|
|
303
|
+
- When a 401 (Unauthorized) or 403 (Forbidden) response is received, trigger a page refresh with `window.location.reload()` to redirect to login.
|
|
304
|
+
- Always return `Promise.reject(error)` after handling authentication errors to maintain proper error flow.
|
|
305
|
+
|
|
306
|
+
### Notes
|
|
307
|
+
|
|
308
|
+
- avoid swallowing errors.
|
|
309
|
+
|
|
310
|
+
Input sanitization example:
|
|
311
|
+
|
|
312
|
+
```javascript
|
|
313
|
+
function sanitizeInput(input) {
|
|
314
|
+
if (typeof input !== 'string') return '';
|
|
315
|
+
return input
|
|
316
|
+
.trim()
|
|
317
|
+
.replace(/<script[^>]*>.*?<\/script>/gi, '')
|
|
318
|
+
.replace(/javascript:/gi, '')
|
|
319
|
+
.slice(0, 255);
|
|
320
|
+
}
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
## Performance Standards
|
|
324
|
+
|
|
325
|
+
- Implement client-side caching (e.g., RTK Query or React Query) for API data.
|
|
326
|
+
- Use `React.memo`, `useMemo`, and `useCallback` where appropriate.
|
|
327
|
+
- Implement proper loading and error states.
|
|
328
|
+
|
|
329
|
+
## TypeScript Standards
|
|
330
|
+
|
|
331
|
+
- Prefer TypeScript for React components and utilities.
|
|
332
|
+
- Define clear and explicit interfaces for props and API data.
|
|
333
|
+
|
|
334
|
+
## Testing Requirements
|
|
335
|
+
|
|
336
|
+
- Use Jest + React Testing Library for UI tests.
|
|
337
|
+
- Test loading, success, and error states for data-fetching components.
|
|
338
|
+
|
|
339
|
+
## Application Generation Rules
|
|
340
|
+
|
|
341
|
+
- When requested to generate a new application:
|
|
342
|
+
- Replace existing template content; do not append to the starter.
|
|
343
|
+
- Preserve the entry point and routes under `force-app/main/default/webapplications/<appName>/src/`.
|
|
344
|
+
- Keep existing build and deploy commands working.
|
|
345
|
+
- Follow the Data Access and Security standards above.
|
|
346
|
+
|
|
347
|
+
## Debugging Guidance
|
|
348
|
+
|
|
349
|
+
- Use React DevTools for component inspection.
|
|
350
|
+
- Monitor the browser Network tab for REST/GraphQL calls and auth headers.
|
|
351
|
+
- Implement Error Boundaries for unhandled exceptions.
|
|
352
|
+
|
|
353
|
+
## Quality Checklist (for generated code)
|
|
354
|
+
|
|
355
|
+
- Entry point maintained (`App.js` present and wired in pages).
|
|
356
|
+
- Uses shadcn/ui and Tailwind for UI.
|
|
357
|
+
- Follows Data Access rules with proper auth and error handling.
|
|
358
|
+
- Enforces Security standards and input sanitization.
|
|
359
|
+
- Includes loading and error states.
|
|
360
|
+
- Performance optimizations present where reasonable.
|
|
361
|
+
- Tests cover core UI and data interactions.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#Goal
|
|
2
|
+
|
|
3
|
+
- You are configuring image usage for React applications generated through Vibe Coding.
|
|
4
|
+
- Your goal is to ensure Unsplash is used as the default image source unless the developer provides their own images.
|
|
5
|
+
|
|
6
|
+
# AI Customization Rule: React Image Processing
|
|
7
|
+
|
|
8
|
+
Image handling standards for React web apps (SFDX): CSP compliance, accessibility, and proper image sources.
|
|
9
|
+
|
|
10
|
+
## Targets (File Pattern Matching)
|
|
11
|
+
|
|
12
|
+
- `force-app/main/default/webapplications/*/**/*.tsx`
|
|
13
|
+
- `force-app/main/default/webapplications/*/**/*.ts`
|
|
14
|
+
- `force-app/main/default/webapplications/*/**/*.jsx`
|
|
15
|
+
- `force-app/main/default/webapplications/*/**/*.js`
|
|
16
|
+
- `force-app/main/default/webapplications/*/**/*.html`
|
|
17
|
+
|
|
18
|
+
## Core Rules
|
|
19
|
+
|
|
20
|
+
### Default Image Source: Unsplash
|
|
21
|
+
|
|
22
|
+
Use Unsplash by default (pre-configured in CSP):
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
https://images.unsplash.com/photo-{PHOTO_ID}?w={WIDTH}&h={HEIGHT}&fit=crop&q=80
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Sample Photo IDs: `1557683316-973673baf926` (tech), `1506905925346-21bda4d32df4` (nature)
|
|
29
|
+
|
|
30
|
+
### Alternative Sources
|
|
31
|
+
|
|
32
|
+
If user requests another source (Pexels, custom):
|
|
33
|
+
|
|
34
|
+
- Use requested source
|
|
35
|
+
- Inform user: "Add CSP Trusted Site in Setup → Security → CSP Trusted Sites"
|
|
36
|
+
|
|
37
|
+
### Accessibility (MANDATORY)
|
|
38
|
+
|
|
39
|
+
- Always include descriptive `alt` text
|
|
40
|
+
- Use `alt=""` for decorative images only
|
|
41
|
+
|
|
42
|
+
### Avoid (CSP Violations)
|
|
43
|
+
|
|
44
|
+
- Avoid until requested `placeholder.com`, `picsum.photos`, `via.placeholder.com`
|
|
45
|
+
- Pre-configured: `images.unsplash.com`, `source.unsplash.com`, `images.pexels.com`
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: install-feature
|
|
3
|
+
description: Install a feature into the current app. Use when the user asks to add a feature, capability, or functionality like authentication, search, charts, or navigation to their React web app. Do this when user wants to do _anything_ to webapplications/webapps.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Install feature
|
|
7
|
+
|
|
8
|
+
When the user asks to add a feature to their app, follow this workflow.
|
|
9
|
+
|
|
10
|
+
## 1. Match the request to a feature
|
|
11
|
+
|
|
12
|
+
Available features (npm packages):
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
| Feature | Package | Description |
|
|
16
|
+
| ---------------------- | ----------------------------------------------------------------------- | ---------------------------------------------------------------------- |
|
|
17
|
+
| **Authentication** | `@salesforce/webapp-template-feature-react-authentication-experimental` | Login, register, password reset, protected routes |
|
|
18
|
+
| **Global search** | `@salesforce/webapp-template-feature-react-global-search-experimental` | Search Salesforce objects with filters and pagination |
|
|
19
|
+
| **Navigation menu** | `@salesforce/webapp-template-feature-react-nav-menu-experimental` | App layout with responsive navigation menu |
|
|
20
|
+
| **Analytics charts** | `@salesforce/webapp-template-feature-react-chart-experimental` | Recharts line/bar charts with theming (AnalyticsChart, ChartContainer) |
|
|
21
|
+
| **GraphQL data access**| `@salesforce/webapp-template-feature-graphql-experimental` | executeGraphQL utilities, codegen tooling, and example AccountsTable |
|
|
22
|
+
| **Shared UI (shadcn)** | `@salesforce/webapp-template-feature-react-shadcn-experimental` | Button, Card, Input, Select, Table, Tabs, etc. |
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
If no feature matches, tell the user and offer to build it from scratch following the project's existing patterns.
|
|
27
|
+
|
|
28
|
+
## 2. Install the npm package
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm install <package-name>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## 3. Copy skills and rules from the package
|
|
35
|
+
|
|
36
|
+
Run the script so skills and rules from the package are copied into your project. Pass `[skills-dir]` and `[rules-dir]` for your environment; the script reports what it copied.
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
# Default (e.g. Cline): .cline/skills, .clinerules
|
|
40
|
+
bash <this-skill>/scripts/copy-feature-assets.sh <package-name>
|
|
41
|
+
|
|
42
|
+
# Agentforce: .a4drules/ ([docs](https://developer.salesforce.com/docs/platform/einstein-for-devs/guide/devagent-rules.html))
|
|
43
|
+
bash <this-skill>/scripts/copy-feature-assets.sh <package-name> .a4drules/skills .a4drules
|
|
44
|
+
|
|
45
|
+
# Cursor: .cursor/skills, .cursor/rules
|
|
46
|
+
bash <this-skill>/scripts/copy-feature-assets.sh <package-name> .cursor/skills .cursor/rules
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## 4. Read the feature's exports and components
|
|
50
|
+
|
|
51
|
+
Read the package's entry point (usually `index.ts` or the `main` field in its `package.json`) to understand what components and types it exports.
|
|
52
|
+
|
|
53
|
+
Also read the `feature.ts` file if it exists — it lists dependencies on other features (e.g. shadcn) and any npm dependencies the feature needs (e.g. `recharts`). Install any missing dependencies.
|
|
54
|
+
|
|
55
|
+
## 5. Implement the feature in the current app
|
|
56
|
+
|
|
57
|
+
- **If the package exports reusable components** (e.g. `AnalyticsChart`, `ChartContainer`): import and use them directly. Follow the package's README or skill instructions for props, data shapes, and usage patterns.
|
|
58
|
+
- **If the package is a reference implementation** (e.g. authentication pages, search pages): read its source code under `src/` as a reference, then create equivalent pages/components in the current app following the app's existing patterns and conventions.
|
|
59
|
+
|
|
60
|
+
Place new routes inside the existing app's router (e.g. `routes.tsx`). Do not replace the app shell; add the feature as new routes or sections within it.
|
|
61
|
+
|
|
62
|
+
## 6. Verify
|
|
63
|
+
|
|
64
|
+
- Confirm the app builds without errors.
|
|
65
|
+
- Confirm any new routes are accessible and render correctly.
|
|
66
|
+
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Copies skills/ and rules/ from an installed npm package into the current project.
|
|
3
|
+
# Usage: bash <this-script> <package-name> [skills-dir] [rules-dir]
|
|
4
|
+
#
|
|
5
|
+
# Examples:
|
|
6
|
+
# bash copy-feature-assets.sh @salesforce/webapp-template-feature-graphql-experimental
|
|
7
|
+
# bash copy-feature-assets.sh @salesforce/webapp-template-feature-graphql-experimental .cursor/skills .cursor/rules
|
|
8
|
+
set -euo pipefail
|
|
9
|
+
|
|
10
|
+
PKG="${1:?Usage: copy-feature-assets.sh <package-name> [skills-dir] [rules-dir]}"
|
|
11
|
+
SKILLS_DIR="${2:-.cline/skills}"
|
|
12
|
+
RULES_DIR="${3:-.clinerules}"
|
|
13
|
+
|
|
14
|
+
PKG_DIR="node_modules/$PKG"
|
|
15
|
+
|
|
16
|
+
if [ ! -d "$PKG_DIR" ]; then
|
|
17
|
+
echo "Error: Package not found at $PKG_DIR" >&2
|
|
18
|
+
echo "Run 'npm install $PKG' first." >&2
|
|
19
|
+
exit 1
|
|
20
|
+
fi
|
|
21
|
+
|
|
22
|
+
if [ -d "$PKG_DIR/skills" ] && [ "$(ls -A "$PKG_DIR/skills")" ]; then
|
|
23
|
+
mkdir -p "$SKILLS_DIR"
|
|
24
|
+
cp -r "$PKG_DIR"/skills/* "$SKILLS_DIR"/
|
|
25
|
+
echo "Copied skills → $SKILLS_DIR/"
|
|
26
|
+
else
|
|
27
|
+
echo "No skills/ found in $PKG_DIR — nothing to copy."
|
|
28
|
+
fi
|
|
29
|
+
|
|
30
|
+
if [ -d "$PKG_DIR/rules" ] && [ "$(ls -A "$PKG_DIR/rules")" ]; then
|
|
31
|
+
mkdir -p "$RULES_DIR"
|
|
32
|
+
cp -r "$PKG_DIR"/rules/* "$RULES_DIR"/
|
|
33
|
+
echo "Copied rules → $RULES_DIR/"
|
|
34
|
+
else
|
|
35
|
+
echo "No rules/ found in $PKG_DIR — nothing to copy."
|
|
36
|
+
fi
|