@salesforce/webapp-template-feature-react-authentication-experimental 1.3.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/LICENSE.txt +82 -0
- package/README.md +77 -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 +211 -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 +98 -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/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 +19 -0
- package/dist/README.md +18 -0
- package/dist/config/project-scratch-def.json +13 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/.prettierignore +9 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/.prettierrc +11 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/eslint.config.js +113 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/feature-react-authentication.webapplication-meta.xml +7 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/index.html +13 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/package.json +42 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/src/api/graphql-operations-types.ts +127 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/src/api/utils/query/highRevenueAccountsQuery.graphql +29 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/src/app.tsx +16 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/src/appLayout.tsx +9 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/src/assets/icons/book.svg +3 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/src/assets/icons/copy.svg +4 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/src/assets/icons/rocket.svg +3 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/src/assets/icons/star.svg +3 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/src/assets/images/codey-1.png +0 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/src/assets/images/codey-2.png +0 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/src/assets/images/codey-3.png +0 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/src/assets/images/vibe-codey.svg +194 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/src/components/alerts/status-alert.tsx +45 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/src/components/auth/authentication-route.tsx +21 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/src/components/auth/private-route.tsx +36 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/src/components/footers/footer-link.tsx +36 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/src/components/forms/auth-form.tsx +79 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/src/components/forms/submit-button.tsx +49 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/src/components/layout/card-layout.tsx +23 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/src/components/layout/centered-page-layout.tsx +73 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/src/components/layout/loading-page.tsx +46 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/src/components/ui/alert.tsx +65 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/src/components/ui/button.tsx +56 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/src/components/ui/card.tsx +77 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/src/components/ui/field.tsx +111 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/src/components/ui/index.ts +71 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/src/components/ui/input.tsx +19 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/src/components/ui/label.tsx +19 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/src/components/ui/pagination.tsx +99 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/src/components/ui/select.tsx +151 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/src/components/ui/skeleton.tsx +7 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/src/components/ui/spinner.tsx +21 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/src/components/ui/table.tsx +114 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/src/components/ui/tabs.tsx +115 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/src/context/AuthContext.tsx +83 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/src/hooks/form.tsx +116 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/src/lib/utils.ts +6 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/src/pages/About.tsx +12 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/src/pages/ChangePassword.tsx +105 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/src/pages/ForgotPassword.tsx +67 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/src/pages/Home.tsx +12 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/src/pages/Login.tsx +84 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/src/pages/NotFound.tsx +18 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/src/pages/Profile.tsx +146 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/src/pages/Register.tsx +117 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/src/pages/ResetPassword.tsx +101 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/src/routes.tsx +77 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/src/styles/global.css +94 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/src/utils/authenticationConfig.ts +52 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/src/utils/helpers.ts +161 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/tsconfig.json +36 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/tsconfig.node.json +13 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/vite-env.d.ts +1 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/vite.config.ts +82 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/vitest-env.d.ts +2 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/vitest.config.ts +11 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/vitest.setup.ts +1 -0
- package/dist/force-app/main/default/webapplications/feature-react-authentication/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 +31 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# AI Rule: GraphQL Data Access
|
|
2
|
+
|
|
3
|
+
Instructs agents to use the established GraphQL utilities for Salesforce data access.
|
|
4
|
+
|
|
5
|
+
## Targets
|
|
6
|
+
- `force-app/main/default/webapplications/*/**/*.ts`
|
|
7
|
+
- `force-app/main/default/webapplications/*/**/*.tsx`
|
|
8
|
+
|
|
9
|
+
## Required: Use executeGraphQL Function
|
|
10
|
+
|
|
11
|
+
When fetching data via GraphQL in the web app, **always** use the `executeGraphQL` function from `force-app/main/default/webapplications/<appName>/src/api/graphql.ts`.
|
|
12
|
+
|
|
13
|
+
### Import Pattern
|
|
14
|
+
```typescript
|
|
15
|
+
import { executeGraphQL } from '../api/graphql';
|
|
16
|
+
// or adjust relative path as needed based on file location
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Usage Pattern
|
|
20
|
+
```typescript
|
|
21
|
+
interface MyQueryResponse {
|
|
22
|
+
uiapi: {
|
|
23
|
+
query: {
|
|
24
|
+
MyObject: {
|
|
25
|
+
edges: Array<{
|
|
26
|
+
node: {
|
|
27
|
+
Id: string;
|
|
28
|
+
Name: { value: string };
|
|
29
|
+
// ... other fields
|
|
30
|
+
};
|
|
31
|
+
}>;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const MY_QUERY = `
|
|
38
|
+
query GetMyData {
|
|
39
|
+
uiapi {
|
|
40
|
+
query {
|
|
41
|
+
MyObject(first: 10) {
|
|
42
|
+
edges {
|
|
43
|
+
node {
|
|
44
|
+
Id
|
|
45
|
+
Name { value }
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
`;
|
|
53
|
+
|
|
54
|
+
const response = await executeGraphQL<MyQueryResponse>(MY_QUERY, { /* variables */ });
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Reference Example
|
|
58
|
+
|
|
59
|
+
See `force-app/main/default/webapplications/<appName>/src/api/utils/accounts.ts` for a complete working example that demonstrates:
|
|
60
|
+
1. TypeScript interface definitions for GraphQL response shapes
|
|
61
|
+
2. GraphQL query construction using UIAPI syntax
|
|
62
|
+
3. Proper typing with `executeGraphQL<T>()`
|
|
63
|
+
4. Data extraction from the response
|
|
64
|
+
|
|
65
|
+
## Anti-Patterns (FORBIDDEN)
|
|
66
|
+
|
|
67
|
+
### Direct API Calls
|
|
68
|
+
```typescript
|
|
69
|
+
// FORBIDDEN: Direct axios/fetch calls for GraphQL
|
|
70
|
+
const response = await axios.post('/graphql', { query });
|
|
71
|
+
|
|
72
|
+
// REQUIRED: Use executeGraphQL
|
|
73
|
+
const data = await executeGraphQL<ResponseType>(query, variables);
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Missing Type Definitions
|
|
77
|
+
```typescript
|
|
78
|
+
// FORBIDDEN: Untyped GraphQL calls
|
|
79
|
+
const data = await executeGraphQL(query);
|
|
80
|
+
|
|
81
|
+
// REQUIRED: Provide response type
|
|
82
|
+
const data = await executeGraphQL<MyTypedResponse>(query);
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Benefits of executeGraphQL
|
|
86
|
+
- Centralized error handling for GraphQL errors
|
|
87
|
+
- Consistent typing with `GraphQLResponse<T>` interface
|
|
88
|
+
- Uses the configured `baseDataClient` with proper authentication
|
|
89
|
+
- Automatic extraction of `data` from response envelope
|
|
90
|
+
|
|
91
|
+
## Quality Checklist
|
|
92
|
+
Before completing GraphQL data access code:
|
|
93
|
+
1. Import `executeGraphQL` from the correct path
|
|
94
|
+
2. Define TypeScript interfaces for the query response
|
|
95
|
+
3. Use proper generic typing: `executeGraphQL<ResponseType>`
|
|
96
|
+
4. Handle the returned data appropriately
|
|
97
|
+
5. Follow the pattern established in `force-app/main/default/webapplications/<appName>/src/api/utils/accounts.ts`
|
|
98
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Rule: Images
|
|
2
|
+
|
|
3
|
+
**Description:** Image rules for React web apps (SFDX): default to Unsplash, CSP compliance, and accessibility. Ensures Unsplash is used as the default image source unless the developer provides their own.
|
|
4
|
+
|
|
5
|
+
**Applies to:** `force-app/main/default/webapplications/*/**/*.{js,jsx,ts,tsx,css,html}`
|
|
6
|
+
|
|
7
|
+
**Guidelines:**
|
|
8
|
+
- Default to Unsplash when the user does not specify an image source; it is pre-configured in CSP and works in Salesforce without extra setup.
|
|
9
|
+
- Use URL format: `https://images.unsplash.com/photo-{PHOTO_ID}?w={WIDTH}&h={HEIGHT}&fit=crop&q=80&auto=format` (e.g. photo ID `1557683316-973673baf926`).
|
|
10
|
+
- If the user requests a different source, use it and inform: "Add CSP Trusted Site in Setup → Security → CSP Trusted Sites".
|
|
11
|
+
- Always add descriptive `alt` text; use `alt=""` only for decorative images.
|
|
12
|
+
- Avoid `placeholder.com`, `picsum.photos`, `via.placeholder.com` unless requested.
|
|
13
|
+
- CSP-approved domains: `images.unsplash.com` (primary), `source.unsplash.com`, `images.pexels.com`.
|
|
@@ -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`
|