@salesforce/webapp-template-app-react-b2e-experimental 1.35.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 (144) hide show
  1. package/LICENSE.txt +82 -0
  2. package/dist/.a4drules/build-validation.md +81 -0
  3. package/dist/.a4drules/code-quality.md +150 -0
  4. package/dist/.a4drules/graphql/tools/knowledge/lds-explore-graphql-schema.md +227 -0
  5. package/dist/.a4drules/graphql/tools/knowledge/lds-generate-graphql-mutationquery.md +212 -0
  6. package/dist/.a4drules/graphql/tools/knowledge/lds-generate-graphql-readquery.md +185 -0
  7. package/dist/.a4drules/graphql/tools/knowledge/lds-guide-graphql.md +205 -0
  8. package/dist/.a4drules/graphql/tools/schemas/shared.graphqls +1150 -0
  9. package/dist/.a4drules/graphql.md +408 -0
  10. package/dist/.a4drules/images.md +13 -0
  11. package/dist/.a4drules/react.md +361 -0
  12. package/dist/.a4drules/react_image_processing.md +45 -0
  13. package/dist/.a4drules/skills/install-feature/SKILL.md +67 -0
  14. package/dist/.a4drules/skills/install-feature/scripts/copy-feature-assets.sh +36 -0
  15. package/dist/.a4drules/typescript.md +224 -0
  16. package/dist/.forceignore +15 -0
  17. package/dist/.husky/pre-commit +4 -0
  18. package/dist/.prettierignore +11 -0
  19. package/dist/.prettierrc +17 -0
  20. package/dist/CHANGELOG.md +479 -0
  21. package/dist/README.md +18 -0
  22. package/dist/config/project-scratch-def.json +13 -0
  23. package/dist/force-app/main/default/applications/Property_Management.app-meta.xml +26 -0
  24. package/dist/force-app/main/default/data/Application__c.json +124 -0
  25. package/dist/force-app/main/default/data/Maintenance_Request__c.json +514 -0
  26. package/dist/force-app/main/default/data/Maintenance_Worker__c.json +304 -0
  27. package/dist/force-app/main/default/data/Notification__c.json +214 -0
  28. package/dist/force-app/main/default/data/Property__c.json +654 -0
  29. package/dist/force-app/main/default/data/Tenant__c.json +184 -0
  30. package/dist/force-app/main/default/data/data-plan.json +38 -0
  31. package/dist/force-app/main/default/objects/Application__c/Application__c.object-meta.xml +67 -0
  32. package/dist/force-app/main/default/objects/Application__c/fields/Employment__c.field-meta.xml +10 -0
  33. package/dist/force-app/main/default/objects/Application__c/fields/Property__c.field-meta.xml +15 -0
  34. package/dist/force-app/main/default/objects/Application__c/fields/References__c.field-meta.xml +10 -0
  35. package/dist/force-app/main/default/objects/Application__c/fields/Start_Date__c.field-meta.xml +9 -0
  36. package/dist/force-app/main/default/objects/Application__c/fields/Status__c.field-meta.xml +42 -0
  37. package/dist/force-app/main/default/objects/Application__c/fields/User__c.field-meta.xml +15 -0
  38. package/dist/force-app/main/default/objects/Maintenance_Request__c/Maintenance_Request__c.object-meta.xml +67 -0
  39. package/dist/force-app/main/default/objects/Maintenance_Request__c/fields/Actual_Cost__c.field-meta.xml +13 -0
  40. package/dist/force-app/main/default/objects/Maintenance_Request__c/fields/Completed__c.field-meta.xml +11 -0
  41. package/dist/force-app/main/default/objects/Maintenance_Request__c/fields/Description__c.field-meta.xml +12 -0
  42. package/dist/force-app/main/default/objects/Maintenance_Request__c/fields/Est_Cost__c.field-meta.xml +13 -0
  43. package/dist/force-app/main/default/objects/Maintenance_Request__c/fields/Priority__c.field-meta.xml +32 -0
  44. package/dist/force-app/main/default/objects/Maintenance_Request__c/fields/Property__c.field-meta.xml +15 -0
  45. package/dist/force-app/main/default/objects/Maintenance_Request__c/fields/Scheduled__c.field-meta.xml +11 -0
  46. package/dist/force-app/main/default/objects/Maintenance_Request__c/fields/Status__c.field-meta.xml +42 -0
  47. package/dist/force-app/main/default/objects/Maintenance_Request__c/fields/Tenant_Home__c.field-meta.xml +11 -0
  48. package/dist/force-app/main/default/objects/Maintenance_Request__c/fields/Type__c.field-meta.xml +42 -0
  49. package/dist/force-app/main/default/objects/Maintenance_Request__c/fields/User__c.field-meta.xml +15 -0
  50. package/dist/force-app/main/default/objects/Maintenance_Worker__c/Maintenance_Worker__c.object-meta.xml +66 -0
  51. package/dist/force-app/main/default/objects/Maintenance_Worker__c/fields/Certifications__c.field-meta.xml +12 -0
  52. package/dist/force-app/main/default/objects/Maintenance_Worker__c/fields/Employment_Type__c.field-meta.xml +32 -0
  53. package/dist/force-app/main/default/objects/Maintenance_Worker__c/fields/Hourly_Rate__c.field-meta.xml +13 -0
  54. package/dist/force-app/main/default/objects/Maintenance_Worker__c/fields/IsActive__c.field-meta.xml +11 -0
  55. package/dist/force-app/main/default/objects/Maintenance_Worker__c/fields/Location__c.field-meta.xml +13 -0
  56. package/dist/force-app/main/default/objects/Maintenance_Worker__c/fields/Phone__c.field-meta.xml +11 -0
  57. package/dist/force-app/main/default/objects/Maintenance_Worker__c/fields/Rating__c.field-meta.xml +14 -0
  58. package/dist/force-app/main/default/objects/Maintenance_Worker__c/fields/Type__c.field-meta.xml +57 -0
  59. package/dist/force-app/main/default/objects/Notification__c/Notification__c.object-meta.xml +67 -0
  60. package/dist/force-app/main/default/objects/Notification__c/fields/Is_Read__c.field-meta.xml +10 -0
  61. package/dist/force-app/main/default/objects/Notification__c/fields/Message__c.field-meta.xml +11 -0
  62. package/dist/force-app/main/default/objects/Notification__c/fields/Priority__c.field-meta.xml +36 -0
  63. package/dist/force-app/main/default/objects/Notification__c/fields/Related_Object_Type__c.field-meta.xml +12 -0
  64. package/dist/force-app/main/default/objects/Notification__c/fields/Related_Record_Id__c.field-meta.xml +12 -0
  65. package/dist/force-app/main/default/objects/Notification__c/fields/Title__c.field-meta.xml +12 -0
  66. package/dist/force-app/main/default/objects/Notification__c/fields/Type__c.field-meta.xml +36 -0
  67. package/dist/force-app/main/default/objects/Notification__c/fields/User__c.field-meta.xml +14 -0
  68. package/dist/force-app/main/default/objects/Property__c/Property__c.object-meta.xml +66 -0
  69. package/dist/force-app/main/default/objects/Property__c/fields/Address__c.field-meta.xml +13 -0
  70. package/dist/force-app/main/default/objects/Property__c/fields/Agent__c.field-meta.xml +15 -0
  71. package/dist/force-app/main/default/objects/Property__c/fields/Available_Date__c.field-meta.xml +11 -0
  72. package/dist/force-app/main/default/objects/Property__c/fields/Bathrooms__c.field-meta.xml +14 -0
  73. package/dist/force-app/main/default/objects/Property__c/fields/Bedrooms__c.field-meta.xml +14 -0
  74. package/dist/force-app/main/default/objects/Property__c/fields/Deposit__c.field-meta.xml +13 -0
  75. package/dist/force-app/main/default/objects/Property__c/fields/Description__c.field-meta.xml +12 -0
  76. package/dist/force-app/main/default/objects/Property__c/fields/Features__c.field-meta.xml +38 -0
  77. package/dist/force-app/main/default/objects/Property__c/fields/Hero_Image__c.field-meta.xml +11 -0
  78. package/dist/force-app/main/default/objects/Property__c/fields/Lease_Term__c.field-meta.xml +14 -0
  79. package/dist/force-app/main/default/objects/Property__c/fields/Monthly_Rent__c.field-meta.xml +13 -0
  80. package/dist/force-app/main/default/objects/Property__c/fields/Parking__c.field-meta.xml +14 -0
  81. package/dist/force-app/main/default/objects/Property__c/fields/Pet_Friendly__c.field-meta.xml +11 -0
  82. package/dist/force-app/main/default/objects/Property__c/fields/Sq_Ft__c.field-meta.xml +14 -0
  83. package/dist/force-app/main/default/objects/Property__c/fields/Status__c.field-meta.xml +37 -0
  84. package/dist/force-app/main/default/objects/Property__c/fields/Tour_URL__c.field-meta.xml +11 -0
  85. package/dist/force-app/main/default/objects/Property__c/fields/Type__c.field-meta.xml +37 -0
  86. package/dist/force-app/main/default/objects/Property__c/fields/Utilities__c.field-meta.xml +38 -0
  87. package/dist/force-app/main/default/objects/Property__c/fields/Year_Built__c.field-meta.xml +14 -0
  88. package/dist/force-app/main/default/objects/Tenant__c/Tenant__c.object-meta.xml +67 -0
  89. package/dist/force-app/main/default/objects/Tenant__c/fields/End_Date__c.field-meta.xml +11 -0
  90. package/dist/force-app/main/default/objects/Tenant__c/fields/Property__c.field-meta.xml +15 -0
  91. package/dist/force-app/main/default/objects/Tenant__c/fields/Start_Date__c.field-meta.xml +11 -0
  92. package/dist/force-app/main/default/objects/Tenant__c/fields/Status__c.field-meta.xml +37 -0
  93. package/dist/force-app/main/default/objects/Tenant__c/fields/User_Status__c.field-meta.xml +42 -0
  94. package/dist/force-app/main/default/objects/Tenant__c/fields/User__c.field-meta.xml +15 -0
  95. package/dist/force-app/main/default/permissionsets/Property_Management_Access.permissionset-meta.xml +453 -0
  96. package/dist/force-app/main/default/tabs/Application__c.tab-meta.xml +6 -0
  97. package/dist/force-app/main/default/tabs/Maintenance_Request__c.tab-meta.xml +7 -0
  98. package/dist/force-app/main/default/tabs/Maintenance_Worker__c.tab-meta.xml +6 -0
  99. package/dist/force-app/main/default/tabs/Notification__c.tab-meta.xml +6 -0
  100. package/dist/force-app/main/default/tabs/Property__c.tab-meta.xml +7 -0
  101. package/dist/force-app/main/default/tabs/Tenant__c.tab-meta.xml +7 -0
  102. package/dist/force-app/main/default/webapplications/appreactb2e/.prettierignore +9 -0
  103. package/dist/force-app/main/default/webapplications/appreactb2e/.prettierrc +11 -0
  104. package/dist/force-app/main/default/webapplications/appreactb2e/appreactb2e.webapplication-meta.xml +7 -0
  105. package/dist/force-app/main/default/webapplications/appreactb2e/build/vite.config.d.ts +2 -0
  106. package/dist/force-app/main/default/webapplications/appreactb2e/build/vite.config.js +76 -0
  107. package/dist/force-app/main/default/webapplications/appreactb2e/e2e/app.spec.ts +24 -0
  108. package/dist/force-app/main/default/webapplications/appreactb2e/eslint.config.js +113 -0
  109. package/dist/force-app/main/default/webapplications/appreactb2e/index.html +13 -0
  110. package/dist/force-app/main/default/webapplications/appreactb2e/package-lock.json +7157 -0
  111. package/dist/force-app/main/default/webapplications/appreactb2e/package.json +45 -0
  112. package/dist/force-app/main/default/webapplications/appreactb2e/playwright.config.ts +24 -0
  113. package/dist/force-app/main/default/webapplications/appreactb2e/scripts/rewrite-e2e-assets.mjs +23 -0
  114. package/dist/force-app/main/default/webapplications/appreactb2e/src/api/graphql-operations-types.ts +127 -0
  115. package/dist/force-app/main/default/webapplications/appreactb2e/src/api/utils/query/highRevenueAccountsQuery.graphql +29 -0
  116. package/dist/force-app/main/default/webapplications/appreactb2e/src/app.tsx +22 -0
  117. package/dist/force-app/main/default/webapplications/appreactb2e/src/appLayout.tsx +29 -0
  118. package/dist/force-app/main/default/webapplications/appreactb2e/src/assets/icons/book.svg +3 -0
  119. package/dist/force-app/main/default/webapplications/appreactb2e/src/assets/icons/copy.svg +4 -0
  120. package/dist/force-app/main/default/webapplications/appreactb2e/src/assets/icons/rocket.svg +3 -0
  121. package/dist/force-app/main/default/webapplications/appreactb2e/src/assets/icons/star.svg +3 -0
  122. package/dist/force-app/main/default/webapplications/appreactb2e/src/assets/images/codey-1.png +0 -0
  123. package/dist/force-app/main/default/webapplications/appreactb2e/src/assets/images/codey-2.png +0 -0
  124. package/dist/force-app/main/default/webapplications/appreactb2e/src/assets/images/codey-3.png +0 -0
  125. package/dist/force-app/main/default/webapplications/appreactb2e/src/assets/images/vibe-codey.svg +194 -0
  126. package/dist/force-app/main/default/webapplications/appreactb2e/src/pages/About.tsx +12 -0
  127. package/dist/force-app/main/default/webapplications/appreactb2e/src/pages/Home.tsx +12 -0
  128. package/dist/force-app/main/default/webapplications/appreactb2e/src/pages/NotFound.tsx +18 -0
  129. package/dist/force-app/main/default/webapplications/appreactb2e/src/routes.tsx +28 -0
  130. package/dist/force-app/main/default/webapplications/appreactb2e/src/styles/global.css +13 -0
  131. package/dist/force-app/main/default/webapplications/appreactb2e/tsconfig.json +36 -0
  132. package/dist/force-app/main/default/webapplications/appreactb2e/tsconfig.node.json +13 -0
  133. package/dist/force-app/main/default/webapplications/appreactb2e/vite-env.d.ts +1 -0
  134. package/dist/force-app/main/default/webapplications/appreactb2e/vite.config.ts +85 -0
  135. package/dist/force-app/main/default/webapplications/appreactb2e/vitest-env.d.ts +2 -0
  136. package/dist/force-app/main/default/webapplications/appreactb2e/vitest.config.ts +11 -0
  137. package/dist/force-app/main/default/webapplications/appreactb2e/vitest.setup.ts +1 -0
  138. package/dist/force-app/main/default/webapplications/appreactb2e/webapplication.json +7 -0
  139. package/dist/jest.config.js +6 -0
  140. package/dist/package.json +37 -0
  141. package/dist/scripts/apex/hello.apex +10 -0
  142. package/dist/scripts/soql/account.soql +6 -0
  143. package/dist/sfdx-project.json +12 -0
  144. package/package.json +34 -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,67 @@
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
+ | **Micro frontends** | `@salesforce/webapp-template-feature-micro-frontend-experimental` | Embed an App into Salesforce UI
24
+
25
+
26
+
27
+ If no feature matches, tell the user and offer to build it from scratch following the project's existing patterns.
28
+
29
+ ## 2. Install the npm package
30
+
31
+ ```bash
32
+ npm install <package-name>
33
+ ```
34
+
35
+ ## 3. Copy skills and rules from the package
36
+
37
+ 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.
38
+
39
+ ```bash
40
+ # Default (e.g. Cline): .cline/skills, .clinerules
41
+ bash <this-skill>/scripts/copy-feature-assets.sh <package-name>
42
+
43
+ # Agentforce: .a4drules/ ([docs](https://developer.salesforce.com/docs/platform/einstein-for-devs/guide/devagent-rules.html))
44
+ bash <this-skill>/scripts/copy-feature-assets.sh <package-name> .a4drules/skills .a4drules
45
+
46
+ # Cursor: .cursor/skills, .cursor/rules
47
+ bash <this-skill>/scripts/copy-feature-assets.sh <package-name> .cursor/skills .cursor/rules
48
+ ```
49
+
50
+ ## 4. Read the feature's exports and components
51
+
52
+ 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.
53
+
54
+ 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.
55
+
56
+ ## 5. Implement the feature in the current app
57
+
58
+ - **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.
59
+ - **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.
60
+
61
+ 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.
62
+
63
+ ## 6. Verify
64
+
65
+ - Confirm the app builds without errors.
66
+ - Confirm any new routes are accessible and render correctly.
67
+
@@ -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