@salesforce/webapp-template-base-sfdx-project-experimental 1.103.2

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 (60) hide show
  1. package/.a4drules/skills/webapp-csp-trusted-sites/SKILL.md +90 -0
  2. package/.a4drules/skills/webapp-csp-trusted-sites/implementation/metadata-format.md +281 -0
  3. package/.a4drules/skills/webapp-features/SKILL.md +210 -0
  4. package/.a4drules/skills/webapp-react/SKILL.md +80 -0
  5. package/.a4drules/skills/webapp-react/implementation/component.md +78 -0
  6. package/.a4drules/skills/webapp-react/implementation/header-footer.md +132 -0
  7. package/.a4drules/skills/webapp-react/implementation/page.md +93 -0
  8. package/.a4drules/skills/webapp-react-data-visualization/SKILL.md +72 -0
  9. package/.a4drules/skills/webapp-react-data-visualization/implementation/dashboard-layout.md +189 -0
  10. package/.a4drules/skills/webapp-react-data-visualization/implementation/donut-chart.md +181 -0
  11. package/.a4drules/skills/webapp-react-data-visualization/implementation/stat-card.md +150 -0
  12. package/.a4drules/skills/webapp-react-interactive-map/SKILL.md +92 -0
  13. package/.a4drules/skills/webapp-react-interactive-map/implementation/geocoding.md +245 -0
  14. package/.a4drules/skills/webapp-react-interactive-map/implementation/leaflet-map.md +279 -0
  15. package/.a4drules/skills/webapp-react-weather-widget/SKILL.md +65 -0
  16. package/.a4drules/skills/webapp-react-weather-widget/implementation/weather-hook.md +258 -0
  17. package/.a4drules/skills/webapp-react-weather-widget/implementation/weather-ui.md +216 -0
  18. package/.a4drules/skills/webapp-ui-ux/SKILL.md +271 -0
  19. package/.a4drules/skills/webapp-ui-ux/data/charts.csv +26 -0
  20. package/.a4drules/skills/webapp-ui-ux/data/colors.csv +97 -0
  21. package/.a4drules/skills/webapp-ui-ux/data/icons.csv +101 -0
  22. package/.a4drules/skills/webapp-ui-ux/data/landing.csv +31 -0
  23. package/.a4drules/skills/webapp-ui-ux/data/products.csv +97 -0
  24. package/.a4drules/skills/webapp-ui-ux/data/react-performance.csv +45 -0
  25. package/.a4drules/skills/webapp-ui-ux/data/stacks/html-tailwind.csv +56 -0
  26. package/.a4drules/skills/webapp-ui-ux/data/stacks/react.csv +54 -0
  27. package/.a4drules/skills/webapp-ui-ux/data/stacks/shadcn.csv +61 -0
  28. package/.a4drules/skills/webapp-ui-ux/data/styles.csv +68 -0
  29. package/.a4drules/skills/webapp-ui-ux/data/typography.csv +58 -0
  30. package/.a4drules/skills/webapp-ui-ux/data/ui-reasoning.csv +101 -0
  31. package/.a4drules/skills/webapp-ui-ux/data/ux-guidelines.csv +100 -0
  32. package/.a4drules/skills/webapp-ui-ux/data/web-interface.csv +31 -0
  33. package/.a4drules/skills/webapp-ui-ux/scripts/core.js +255 -0
  34. package/.a4drules/skills/webapp-ui-ux/scripts/design_system.js +861 -0
  35. package/.a4drules/skills/webapp-ui-ux/scripts/search.js +98 -0
  36. package/.a4drules/skills/webapp-unsplash-images/SKILL.md +71 -0
  37. package/.a4drules/skills/webapp-unsplash-images/implementation/usage.md +159 -0
  38. package/.a4drules/webapp-cli-commands.md +88 -0
  39. package/.a4drules/webapp-react-code-quality.md +136 -0
  40. package/.a4drules/webapp-react-typescript.md +205 -0
  41. package/.a4drules/webapp-react.md +202 -0
  42. package/.a4drules/webapp-skills-first.md +26 -0
  43. package/.a4drules/webapp-webapplication.md +159 -0
  44. package/.a4drules/webapp.md +98 -0
  45. package/.forceignore +15 -0
  46. package/.husky/pre-commit +4 -0
  47. package/.prettierignore +11 -0
  48. package/.prettierrc +17 -0
  49. package/AGENT.md +81 -0
  50. package/CHANGELOG.md +1577 -0
  51. package/LICENSE.txt +82 -0
  52. package/README.md +18 -0
  53. package/config/project-scratch-def.json +13 -0
  54. package/jest.config.js +6 -0
  55. package/package.json +39 -0
  56. package/scripts/apex/hello.apex +10 -0
  57. package/scripts/prepare-import-unique-fields.js +122 -0
  58. package/scripts/setup-cli.mjs +533 -0
  59. package/scripts/soql/account.soql +6 -0
  60. package/sfdx-project.json +12 -0
@@ -0,0 +1,90 @@
1
+ ---
2
+ name: webapp-csp-trusted-sites
3
+ description: Creates Salesforce CSP Trusted Site metadata when adding external domains. Use when the user adds an external API, CDN, image host, font provider, map tile server, or any third-party URL that the web application needs to load resources from — or when a browser console shows a CSP violation error.
4
+ ---
5
+
6
+ # CSP Trusted Sites
7
+
8
+ ## When to Use
9
+
10
+ Use this skill whenever the application references a new external domain that is not already registered as a CSP Trusted Site. This includes:
11
+
12
+ - Adding images from a new CDN (Unsplash, Pexels, Cloudinary, etc.)
13
+ - Loading fonts from an external provider (Google Fonts, Adobe Fonts)
14
+ - Calling a third-party API (Open-Meteo, Nominatim, Mapbox, etc.)
15
+ - Loading map tiles from a tile server (OpenStreetMap, Mapbox)
16
+ - Embedding iframes from external services (YouTube, Vimeo)
17
+ - Loading external stylesheets or scripts
18
+
19
+ Salesforce enforces Content Security Policy (CSP) headers on all web applications. Any external domain not registered as a CSP Trusted Site will be blocked by the browser, causing images to not load, API calls to fail, or fonts to be missing.
20
+
21
+ **Reference:** [Salesforce CspTrustedSite Object Reference](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_csptrustedsite.htm)
22
+
23
+ ---
24
+
25
+ ## Step 1 — Identify external domains
26
+
27
+ Scan the code for any URLs pointing to external domains. Common patterns:
28
+
29
+ - `fetch("https://api.example.com/...")` — API calls
30
+ - `<img src="https://images.example.com/..." />` — images
31
+ - `<link href="https://fonts.example.com/..." />` — stylesheets
32
+ - `url="https://tiles.example.com/{z}/{x}/{y}.png"` — map tiles
33
+ - `@import url("https://cdn.example.com/...")` — CSS imports
34
+
35
+ Extract the **origin** (scheme + host) from each URL. For example:
36
+ - `https://api.open-meteo.com/v1/forecast?lat=...` → `https://api.open-meteo.com`
37
+ - `https://images.unsplash.com/photo-123?w=800` → `https://images.unsplash.com`
38
+
39
+ ---
40
+
41
+ ## Step 2 — Check existing CSP Trusted Sites
42
+
43
+ Before creating a new file, check if the domain already has a CSP Trusted Site:
44
+
45
+ ```bash
46
+ ls force-app/main/default/cspTrustedSites/
47
+ ```
48
+
49
+ If the domain is already registered, no action is needed.
50
+
51
+ ---
52
+
53
+ ## Step 3 — Determine the CSP directive(s)
54
+
55
+ Map the resource type to the correct CSP `isApplicableTo*Src` fields. Read `implementation/metadata-format.md` for the full reference.
56
+
57
+ Quick reference:
58
+
59
+ | Resource type | CSP directive field(s) to set `true` |
60
+ |--------------|--------------------------------------|
61
+ | Images (img, background-image) | `isApplicableToImgSrc` |
62
+ | API calls (fetch, XMLHttpRequest) | `isApplicableToConnectSrc` |
63
+ | Fonts (.woff, .woff2, .ttf) | `isApplicableToFontSrc` |
64
+ | Stylesheets (CSS) | `isApplicableToStyleSrc` |
65
+ | Video / audio | `isApplicableToMediaSrc` |
66
+ | Iframes | `isApplicableToFrameSrc` |
67
+
68
+ **Always also set `isApplicableToConnectSrc` to `true`** — most resources also require connect-src for preflight/redirect handling.
69
+
70
+ ---
71
+
72
+ ## Step 4 — Create the metadata file
73
+
74
+ Read `implementation/metadata-format.md` and follow the instructions to create the `.cspTrustedSite-meta.xml` file.
75
+
76
+ ---
77
+
78
+ ## Step 5 — Verify
79
+
80
+ 1. Confirm the file is valid XML and matches the expected schema.
81
+ 2. Confirm the file is placed in `force-app/main/default/cspTrustedSites/`.
82
+ 3. Confirm only the necessary `isApplicableTo*Src` fields are set to `true`.
83
+ 4. Run from the web app directory:
84
+
85
+ ```bash
86
+ cd force-app/main/default/webapplications/<appName> && npm run lint && npm run build
87
+ ```
88
+
89
+ - **Lint:** MUST result in 0 errors.
90
+ - **Build:** MUST succeed.
@@ -0,0 +1,281 @@
1
+ # CSP Trusted Site Metadata — Implementation Guide
2
+
3
+ ## File location
4
+
5
+ ```
6
+ force-app/main/default/cspTrustedSites/{Name}.cspTrustedSite-meta.xml
7
+ ```
8
+
9
+ The `cspTrustedSites/` directory must be a direct child of `force-app/main/default/`. Create it if it does not exist.
10
+
11
+ ---
12
+
13
+ ## File naming convention
14
+
15
+ The file name must match the `<fullName>` value inside the XML, with `.cspTrustedSite-meta.xml` appended.
16
+
17
+ | Domain | fullName | File name |
18
+ |--------|----------|-----------|
19
+ | `https://images.unsplash.com` | `Unsplash_Images` | `Unsplash_Images.cspTrustedSite-meta.xml` |
20
+ | `https://api.open-meteo.com` | `Open_Meteo_API` | `Open_Meteo_API.cspTrustedSite-meta.xml` |
21
+ | `https://tile.openstreetmap.org` | `OpenStreetMap_Tiles` | `OpenStreetMap_Tiles.cspTrustedSite-meta.xml` |
22
+
23
+ **Naming rules:**
24
+ - Use PascalCase with underscores separating words (e.g. `Google_Fonts_Static`)
25
+ - Name should describe the provider and resource type (e.g. `Pexels_Videos`, not just `Pexels`)
26
+ - Must be unique across the org
27
+ - Maximum 80 characters
28
+
29
+ ---
30
+
31
+ ## XML template
32
+
33
+ ```xml
34
+ <?xml version="1.0" encoding="UTF-8" ?>
35
+ <CspTrustedSite xmlns="http://soap.sforce.com/2006/04/metadata">
36
+ <fullName>{UNIQUE_NAME}</fullName>
37
+ <description>{DESCRIPTION}</description>
38
+ <endpointUrl>{HTTPS_ORIGIN}</endpointUrl>
39
+ <isActive>true</isActive>
40
+ <context>All</context>
41
+ <isApplicableToConnectSrc>{true|false}</isApplicableToConnectSrc>
42
+ <isApplicableToFontSrc>{true|false}</isApplicableToFontSrc>
43
+ <isApplicableToFrameSrc>{true|false}</isApplicableToFrameSrc>
44
+ <isApplicableToImgSrc>{true|false}</isApplicableToImgSrc>
45
+ <isApplicableToMediaSrc>{true|false}</isApplicableToMediaSrc>
46
+ <isApplicableToStyleSrc>{true|false}</isApplicableToStyleSrc>
47
+ </CspTrustedSite>
48
+ ```
49
+
50
+ ---
51
+
52
+ ## Field reference
53
+
54
+ | Field | Required | Description |
55
+ |-------|----------|-------------|
56
+ | `fullName` | Yes | Unique API name. Must match the file name (before `.cspTrustedSite-meta.xml`). |
57
+ | `description` | Yes | Human-readable purpose. Start with "Allow access to..." |
58
+ | `endpointUrl` | Yes | The external origin (scheme + host). Must start with `https://`. No trailing slash. No path. |
59
+ | `isActive` | Yes | Always `true` for new entries. Set `false` to disable without deleting. |
60
+ | `context` | Yes | `All` (applies to all contexts). Other values: `LEX` (Lightning Experience only), `Communities` (Experience Cloud only), `VisualForce`. Use `All` unless there is a specific reason to restrict. |
61
+ | `isApplicableToConnectSrc` | Yes | `true` if the domain is called via `fetch()`, `XMLHttpRequest`, or WebSocket. |
62
+ | `isApplicableToFontSrc` | Yes | `true` if the domain serves font files (`.woff`, `.woff2`, `.ttf`, `.otf`). |
63
+ | `isApplicableToFrameSrc` | Yes | `true` if the domain is loaded in an `<iframe>` or `<object>`. |
64
+ | `isApplicableToImgSrc` | Yes | `true` if the domain serves images (`<img>`, CSS `background-image`, `<svg>`). |
65
+ | `isApplicableToMediaSrc` | Yes | `true` if the domain serves audio or video (`<audio>`, `<video>`). |
66
+ | `isApplicableToStyleSrc` | Yes | `true` if the domain serves CSS stylesheets (`<link rel="stylesheet">`). |
67
+
68
+ **Reference:** [CspTrustedSite — Salesforce Object Reference](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_csptrustedsite.htm)
69
+
70
+ ---
71
+
72
+ ## CSP directive mapping
73
+
74
+ | CSP header directive | Metadata field | What it allows |
75
+ |---------------------|----------------|----------------|
76
+ | `connect-src` | `isApplicableToConnectSrc` | `fetch()`, `XMLHttpRequest`, WebSocket, `EventSource` |
77
+ | `font-src` | `isApplicableToFontSrc` | `@font-face` sources |
78
+ | `frame-src` | `isApplicableToFrameSrc` | `<iframe>`, `<frame>`, `<object>`, `<embed>` |
79
+ | `img-src` | `isApplicableToImgSrc` | `<img>`, `background-image`, `favicon`, `<picture>` |
80
+ | `media-src` | `isApplicableToMediaSrc` | `<audio>`, `<video>`, `<source>`, `<track>` |
81
+ | `style-src` | `isApplicableToStyleSrc` | `<link rel="stylesheet">`, `@import` in CSS |
82
+
83
+ ---
84
+
85
+ ## Common external domains and their directives
86
+
87
+ Use this table as a quick reference when adding new domains:
88
+
89
+ | Domain | connect-src | font-src | frame-src | img-src | media-src | style-src |
90
+ |--------|:-----------:|:--------:|:---------:|:-------:|:---------:|:---------:|
91
+ | `https://images.unsplash.com` | true | false | false | true | false | false |
92
+ | `https://images.pexels.com` | true | false | false | true | false | false |
93
+ | `https://videos.pexels.com` | true | false | false | false | true | false |
94
+ | `https://fonts.googleapis.com` | true | false | false | false | false | true |
95
+ | `https://fonts.gstatic.com` | true | true | false | false | false | false |
96
+ | `https://avatars.githubusercontent.com` | true | false | false | true | false | false |
97
+ | `https://api.open-meteo.com` | true | false | false | false | false | false |
98
+ | `https://nominatim.openstreetmap.org` | true | false | false | false | false | false |
99
+ | `https://tile.openstreetmap.org` | true | false | false | true | false | false |
100
+ | `https://api.mapbox.com` | true | false | false | true | false | false |
101
+ | `https://cdn.jsdelivr.net` | true | false | false | false | false | true |
102
+ | `https://www.youtube.com` | false | false | true | true | false | false |
103
+ | `https://player.vimeo.com` | false | false | true | false | false | false |
104
+ | `https://res.cloudinary.com` | true | false | false | true | false | false |
105
+
106
+ ---
107
+
108
+ ## Complete examples
109
+
110
+ ### Image CDN (Unsplash)
111
+
112
+ ```xml
113
+ <?xml version="1.0" encoding="UTF-8" ?>
114
+ <CspTrustedSite xmlns="http://soap.sforce.com/2006/04/metadata">
115
+ <fullName>Unsplash_Images</fullName>
116
+ <description>Allow access to Unsplash image content for static app media</description>
117
+ <endpointUrl>https://images.unsplash.com</endpointUrl>
118
+ <isActive>true</isActive>
119
+ <context>All</context>
120
+ <isApplicableToConnectSrc>true</isApplicableToConnectSrc>
121
+ <isApplicableToFontSrc>false</isApplicableToFontSrc>
122
+ <isApplicableToFrameSrc>false</isApplicableToFrameSrc>
123
+ <isApplicableToImgSrc>true</isApplicableToImgSrc>
124
+ <isApplicableToMediaSrc>false</isApplicableToMediaSrc>
125
+ <isApplicableToStyleSrc>false</isApplicableToStyleSrc>
126
+ </CspTrustedSite>
127
+ ```
128
+
129
+ ### REST API (Open-Meteo weather)
130
+
131
+ ```xml
132
+ <?xml version="1.0" encoding="UTF-8" ?>
133
+ <CspTrustedSite xmlns="http://soap.sforce.com/2006/04/metadata">
134
+ <fullName>Open_Meteo_API</fullName>
135
+ <description>Allow access to Open-Meteo weather forecast API</description>
136
+ <endpointUrl>https://api.open-meteo.com</endpointUrl>
137
+ <isActive>true</isActive>
138
+ <context>All</context>
139
+ <isApplicableToConnectSrc>true</isApplicableToConnectSrc>
140
+ <isApplicableToFontSrc>false</isApplicableToFontSrc>
141
+ <isApplicableToFrameSrc>false</isApplicableToFrameSrc>
142
+ <isApplicableToImgSrc>false</isApplicableToImgSrc>
143
+ <isApplicableToMediaSrc>false</isApplicableToMediaSrc>
144
+ <isApplicableToStyleSrc>false</isApplicableToStyleSrc>
145
+ </CspTrustedSite>
146
+ ```
147
+
148
+ ### Font provider (Google Fonts — requires two entries)
149
+
150
+ Google Fonts needs two CSP entries because CSS is served from `fonts.googleapis.com` and font files from `fonts.gstatic.com`:
151
+
152
+ **Entry 1: Stylesheets**
153
+ ```xml
154
+ <?xml version="1.0" encoding="UTF-8" ?>
155
+ <CspTrustedSite xmlns="http://soap.sforce.com/2006/04/metadata">
156
+ <fullName>Google_Fonts</fullName>
157
+ <description>Allow access to Google Fonts stylesheets for custom typography</description>
158
+ <endpointUrl>https://fonts.googleapis.com</endpointUrl>
159
+ <isActive>true</isActive>
160
+ <context>All</context>
161
+ <isApplicableToConnectSrc>true</isApplicableToConnectSrc>
162
+ <isApplicableToFontSrc>false</isApplicableToFontSrc>
163
+ <isApplicableToFrameSrc>false</isApplicableToFrameSrc>
164
+ <isApplicableToImgSrc>false</isApplicableToImgSrc>
165
+ <isApplicableToMediaSrc>false</isApplicableToMediaSrc>
166
+ <isApplicableToStyleSrc>true</isApplicableToStyleSrc>
167
+ </CspTrustedSite>
168
+ ```
169
+
170
+ **Entry 2: Font files**
171
+ ```xml
172
+ <?xml version="1.0" encoding="UTF-8" ?>
173
+ <CspTrustedSite xmlns="http://soap.sforce.com/2006/04/metadata">
174
+ <fullName>Google_Fonts_Static</fullName>
175
+ <description>Allow access to Google Fonts static files for font loading</description>
176
+ <endpointUrl>https://fonts.gstatic.com</endpointUrl>
177
+ <isActive>true</isActive>
178
+ <context>All</context>
179
+ <isApplicableToConnectSrc>true</isApplicableToConnectSrc>
180
+ <isApplicableToFontSrc>true</isApplicableToFontSrc>
181
+ <isApplicableToFrameSrc>false</isApplicableToFrameSrc>
182
+ <isApplicableToImgSrc>false</isApplicableToImgSrc>
183
+ <isApplicableToMediaSrc>false</isApplicableToMediaSrc>
184
+ <isApplicableToStyleSrc>false</isApplicableToStyleSrc>
185
+ </CspTrustedSite>
186
+ ```
187
+
188
+ ### Map tiles (OpenStreetMap)
189
+
190
+ ```xml
191
+ <?xml version="1.0" encoding="UTF-8" ?>
192
+ <CspTrustedSite xmlns="http://soap.sforce.com/2006/04/metadata">
193
+ <fullName>OpenStreetMap_Tiles</fullName>
194
+ <description>Allow access to OpenStreetMap tile images for map rendering</description>
195
+ <endpointUrl>https://tile.openstreetmap.org</endpointUrl>
196
+ <isActive>true</isActive>
197
+ <context>All</context>
198
+ <isApplicableToConnectSrc>true</isApplicableToConnectSrc>
199
+ <isApplicableToFontSrc>false</isApplicableToFontSrc>
200
+ <isApplicableToFrameSrc>false</isApplicableToFrameSrc>
201
+ <isApplicableToImgSrc>true</isApplicableToImgSrc>
202
+ <isApplicableToMediaSrc>false</isApplicableToMediaSrc>
203
+ <isApplicableToStyleSrc>false</isApplicableToStyleSrc>
204
+ </CspTrustedSite>
205
+ ```
206
+
207
+ ### Geocoding API (Nominatim)
208
+
209
+ ```xml
210
+ <?xml version="1.0" encoding="UTF-8" ?>
211
+ <CspTrustedSite xmlns="http://soap.sforce.com/2006/04/metadata">
212
+ <fullName>OpenStreetMap_Nominatim</fullName>
213
+ <description>Allow access to OpenStreetMap Nominatim geocoding API</description>
214
+ <endpointUrl>https://nominatim.openstreetmap.org</endpointUrl>
215
+ <isActive>true</isActive>
216
+ <context>All</context>
217
+ <isApplicableToConnectSrc>true</isApplicableToConnectSrc>
218
+ <isApplicableToFontSrc>false</isApplicableToFontSrc>
219
+ <isApplicableToFrameSrc>false</isApplicableToFrameSrc>
220
+ <isApplicableToImgSrc>false</isApplicableToImgSrc>
221
+ <isApplicableToMediaSrc>false</isApplicableToMediaSrc>
222
+ <isApplicableToStyleSrc>false</isApplicableToStyleSrc>
223
+ </CspTrustedSite>
224
+ ```
225
+
226
+ ---
227
+
228
+ ## Endpoint URL rules
229
+
230
+ | Rule | Correct | Incorrect |
231
+ |------|---------|-----------|
232
+ | Must be HTTPS | `https://api.example.com` | `http://api.example.com` |
233
+ | No trailing slash | `https://api.example.com` | `https://api.example.com/` |
234
+ | No path | `https://api.example.com` | `https://api.example.com/v1/forecast` |
235
+ | No port (unless non-standard) | `https://api.example.com` | `https://api.example.com:443` |
236
+ | No wildcards | `https://api.example.com` | `https://*.example.com` |
237
+
238
+ Each subdomain needs its own entry. For example, `fonts.googleapis.com` and `fonts.gstatic.com` are separate entries.
239
+
240
+ ---
241
+
242
+ ## When a service requires multiple domains
243
+
244
+ Some services split resources across multiple subdomains. Create one CSP Trusted Site per domain:
245
+
246
+ | Service | Domains needed |
247
+ |---------|---------------|
248
+ | Google Fonts | `fonts.googleapis.com` (CSS) + `fonts.gstatic.com` (font files) |
249
+ | Mapbox | `api.mapbox.com` (tiles/API) + `events.mapbox.com` (telemetry) |
250
+ | YouTube embed | `www.youtube.com` (iframe) + `i.ytimg.com` (thumbnails) |
251
+ | Cloudflare CDN | `cdnjs.cloudflare.com` (scripts/CSS) |
252
+
253
+ ---
254
+
255
+ ## Troubleshooting CSP violations
256
+
257
+ If the browser console shows a CSP error like:
258
+
259
+ ```
260
+ Refused to load the image 'https://example.com/image.png' because it violates
261
+ the following Content Security Policy directive: "img-src 'self' ..."
262
+ ```
263
+
264
+ 1. Extract the **blocked origin** from the URL (e.g. `https://example.com`).
265
+ 2. Identify the **directive** from the error message (e.g. `img-src` → `isApplicableToImgSrc`).
266
+ 3. Check if a CSP Trusted Site already exists for that origin.
267
+ 4. If not, create one using this skill.
268
+ 5. Deploy the metadata and refresh the page.
269
+
270
+ ---
271
+
272
+ ## Common mistakes
273
+
274
+ | Mistake | Fix |
275
+ |---------|-----|
276
+ | Including a path in `endpointUrl` | Use only the origin: `https://api.example.com` |
277
+ | Adding trailing slash | Remove it: `https://api.example.com` not `https://api.example.com/` |
278
+ | Using HTTP instead of HTTPS | Salesforce requires HTTPS. If the service only supports HTTP, it cannot be added. |
279
+ | Forgetting `isApplicableToConnectSrc` | Most resources also need connect-src for redirects/preflight. Set to `true` by default. |
280
+ | One entry for multiple subdomains | Each subdomain needs its own file (e.g. `api.example.com` and `cdn.example.com` are separate) |
281
+ | File name doesn't match `fullName` | They must be identical (excluding the `.cspTrustedSite-meta.xml` extension) |
@@ -0,0 +1,210 @@
1
+ ---
2
+ name: webapp-features
3
+ description: Search, describe, and install pre-built UI features (authentication, shadcn components, navigation, charts, search, GraphQL, Agentforce AI) into Salesforce webapps. Use this when the user wants to add functionality to a webapp, or when determining what salesforce-provided features are available — whether prompted by the user or on your own initiative. Always check for an existing feature before building from scratch.
4
+ ---
5
+
6
+ # webapps-features-experimental CLI — Agent Reference
7
+
8
+ **Always check for an existing feature before building something yourself.** This CLI installs pre-built, tested feature packages into Salesforce webapps. Features range from foundational UI component libraries (shadcn/ui with Button, Card, Input, Table, etc.) to full-stack application capabilities like authentication (login, registration, password flows, session management, and Apex backend classes), global search, navigation menus, data visualization charts, GraphQL integrations, and Agentforce AI conversation UIs. Each feature ships as a complete implementation — including React components, context providers, route guards, and any required Salesforce server-side code — that already handles platform-specific concerns like Salesforce API integration, session management, and SFDX metadata structure. Building these from scratch is error-prone and unnecessary when a feature exists. **If no existing feature is found, ask the user before proceeding with a custom implementation — a relevant feature may exist under a different name or keyword.**
9
+
10
+ ```
11
+ npx @salesforce/webapps-features-experimental <command> [options]
12
+ ```
13
+
14
+ ## Workflow: Search Project → Search Features → Describe → Install
15
+
16
+ **MANDATORY**: When the user asks to add ANY webapp functionality, follow this entire workflow. Do not skip steps.
17
+
18
+ ### 1. Search existing project code
19
+
20
+ Before installing anything, check whether the functionality already exists in the **project source code** (not dependencies).
21
+
22
+ - **Always scope searches to `src/`** to avoid matching files in `node_modules/`, `dist/`, or `build/` output
23
+ - Use Glob with a scoped path: e.g., `src/**/Button.tsx`, `src/**/*auth*.tsx`
24
+ - Use Grep with the `path` parameter set to the `src/` directory, or use `glob: "*.{ts,tsx}"` to restrict file types
25
+ - Check common directories: `src/components/`, `src/lib/`, `src/pages/`, `src/hooks/`
26
+ - **Never** search from the project root without a path or glob filter — this will crawl `node_modules` and produce massive, unhelpful output
27
+
28
+ **If existing code is found** — read the files, present them to the user, and ask if they want to reuse or extend what's there. If yes, use the existing code and stop. If no, proceed to step 2.
29
+
30
+ **If nothing is found** — proceed to step 2.
31
+
32
+ ### 2. Search available features
33
+
34
+ ```bash
35
+ npx @salesforce/webapps-features-experimental list [options]
36
+ ```
37
+
38
+ Options:
39
+
40
+ - `-v, --verbose` — Show full descriptions, packages, and dependencies
41
+ - `--search <query>` — Filter features by keyword (ranked by relevance)
42
+
43
+ ```bash
44
+ npx @salesforce/webapps-features-experimental list
45
+ npx @salesforce/webapps-features-experimental list --search "auth"
46
+ npx @salesforce/webapps-features-experimental list --search "button"
47
+ ```
48
+
49
+ **If no matching feature is found** — ask the user before proceeding with a custom implementation. A relevant feature may exist under a different name or keyword.
50
+
51
+ ### 3. Describe a feature
52
+
53
+ ```bash
54
+ npx @salesforce/webapps-features-experimental describe <feature>
55
+ ```
56
+
57
+ Shows description, package name, dependencies, components, copy operations, and example files.
58
+
59
+ ```bash
60
+ npx @salesforce/webapps-features-experimental describe authentication
61
+ npx @salesforce/webapps-features-experimental describe shadcn
62
+ ```
63
+
64
+ ### 4. Install a feature
65
+
66
+ ```bash
67
+ npx @salesforce/webapps-features-experimental install <feature> --webapp-dir <path> [options]
68
+ ```
69
+
70
+ Resolves the feature name to an npm package, installs it and its dependencies (including transitive feature dependencies like `shadcn`), copies source files into your project, and reports any `__example__` files that require manual integration.
71
+
72
+ Options:
73
+
74
+ - `--webapp-dir <name>` (required) — Webapp name, resolves to `<sfdx-source>/webapplications/<name>`
75
+ - `--sfdx-source <path>` (default: `force-app/main/default`) — SFDX source directory
76
+ - `--dry-run` (default: `false`) — Preview changes without writing files
77
+ - `-v, --verbose` (default: `false`) — Enable verbose logging
78
+ - `-y, --yes` (default: `false`) — Skip all prompts (auto-skip conflicts)
79
+ - `--on-conflict <mode>` (default: `prompt`) — `prompt`, `error`, `skip`, or `overwrite`
80
+ - `--conflict-resolution <file>` — Path to JSON file with per-file resolutions
81
+
82
+ ```bash
83
+ # Install authentication (also installs shadcn dependency)
84
+ npx @salesforce/webapps-features-experimental install authentication \
85
+ --webapp-dir mywebapp
86
+
87
+ # Dry run to preview changes
88
+ npx @salesforce/webapps-features-experimental install shadcn \
89
+ --webapp-dir mywebapp \
90
+ --dry-run
91
+
92
+ # Non-interactive install (skip all file conflicts)
93
+ npx @salesforce/webapps-features-experimental install authentication \
94
+ --webapp-dir mywebapp \
95
+ --yes
96
+ ```
97
+
98
+ ## Conflict Handling
99
+
100
+ Since you are running in a non-interactive environment, you cannot use `--on-conflict prompt` directly. When conflicts are likely (e.g. installing into an existing project), you have two options:
101
+
102
+ **Option A — Let the user resolve conflicts interactively.** Suggest the user run the install command themselves with `--on-conflict prompt` so they can decide per-file.
103
+
104
+ **Option B — Two-pass automated resolution:**
105
+
106
+ ```bash
107
+ # Pass 1: detect conflicts
108
+ npx @salesforce/webapps-features-experimental install authentication \
109
+ --webapp-dir mywebapp \
110
+ --on-conflict error
111
+
112
+ # The CLI will exit with an error listing every conflicting file path.
113
+
114
+ # Pass 2: create a resolution file and re-run
115
+ echo '{ "src/styles/global.css": "overwrite", "src/lib/utils.ts": "skip" }' > resolutions.json
116
+
117
+ npx @salesforce/webapps-features-experimental install authentication \
118
+ --webapp-dir mywebapp \
119
+ --conflict-resolution resolutions.json
120
+ ```
121
+
122
+ Resolution values per file: `"skip"` (keep existing) or `"overwrite"` (replace). When unsure how to resolve a conflict, ask the user rather than guessing.
123
+
124
+ ## Hint Placeholders in Copy Paths
125
+
126
+ Some copy operations use **hint placeholders** in the `"to"` path — descriptive segments like `<desired-page-with-search-input>` that are NOT resolved by the CLI. These are guidance for the user or LLM to choose an appropriate destination.
127
+
128
+ **How they work:** The file is copied with the literal placeholder name (e.g., `src/pages/<desired-page-with-search-input>.tsx`). After installation, you should:
129
+
130
+ 1. Read the copied file to understand its purpose
131
+ 2. Rename or relocate it to the intended target (e.g., `src/pages/Home.tsx`)
132
+ 3. Or integrate its patterns into an existing file, then delete it
133
+
134
+ **How to identify them:** Hint placeholders use `<descriptive-name>` syntax but are NOT one of the system placeholders (`<sfdxSource>`, `<webappDir>`, `<webapp>`). They always appear in the middle or end of a path, never as the leading segment.
135
+
136
+ **Example from features.json:**
137
+
138
+ ```json
139
+ {
140
+ "to": "<webappDir>/src/pages/<desired-page-with-search-input>.tsx",
141
+ "description": "Example home page showing GlobalSearchInput integration",
142
+ "integrationTarget": "src/pages/Home.tsx"
143
+ }
144
+ ```
145
+
146
+ The `integrationTarget` field tells you the suggested destination. Use your judgment — if the user already has a different page where search should go, integrate there instead.
147
+
148
+ **When `integrationTarget` itself is a placeholder:** Some features use a hint placeholder in the `integrationTarget` value (e.g., `"integrationTarget": "src/<path-to-desired-page-with-search-input>.tsx"`). This means there is no single default target — the user must decide which existing file to integrate into. When you encounter this:
149
+
150
+ 1. Ask the user which page or file they want to integrate the feature into
151
+ 2. Read the `__example__` file to understand the integration pattern
152
+ 3. Read the user's chosen target file
153
+ 4. Apply the pattern from the example into the target file
154
+
155
+ ## Post Installation: Integrating **example** Files
156
+
157
+ Features may include `__example__` files (e.g., `__example__auth-app.tsx`) showing integration patterns.
158
+
159
+ **The describe command shows**:
160
+
161
+ - Which **example** files will be copied
162
+ - Target file to integrate into (e.g., `src/app.tsx`)
163
+ - What the example demonstrates
164
+
165
+ ### How to Integrate Example Files (CRITICAL FOR LLMs)
166
+
167
+ ⚠️ **ONLY USE Read AND Edit TOOLS - NO BASH COMMANDS** ⚠️
168
+
169
+ **DO NOT DO THIS**:
170
+
171
+ - ❌ `git status` or any git commands
172
+ - ❌ `ls`, `cat`, `sed`, `awk`, or ANY bash file commands
173
+ - ❌ Chaining bash commands to read multiple files
174
+ - ❌ Using bash to check directories or file existence
175
+
176
+ **DO THIS INSTEAD**:
177
+
178
+ - ✅ Use Read tool with `file_path` parameter to read each file
179
+ - ✅ Use Edit tool with `file_path`, `old_string`, `new_string` to modify files
180
+ - ✅ That's it! Just Read and Edit tools.
181
+
182
+ **Integration steps**:
183
+
184
+ 1. **Read each example file** (use Read tool)
185
+ - Example: Read tool with `file_path: "force-app/main/default/webapplications/mywebapp/src/__example__auth-app.tsx"`
186
+ - Note the imports and patterns to integrate
187
+
188
+ 2. **Read each target file** (use Read tool)
189
+ - Example: Read tool with `file_path: "force-app/main/default/webapplications/mywebapp/src/app.tsx"`
190
+ - Understand where the new code should go
191
+
192
+ 3. **Edit each target file** (use Edit tool)
193
+ - Add imports from the example
194
+ - Add or modify code following the example's patterns
195
+ - Preserve existing functionality
196
+
197
+ 4. **Delete the example file after successful integration** (use Bash tool)
198
+ - Example: `rm force-app/main/default/webapplications/mywebapp/src/__example__authentication-routes.tsx`
199
+ - Only delete after you have successfully integrated the pattern
200
+ - This keeps the codebase clean and removes temporary example files
201
+
202
+ ## Troubleshooting
203
+
204
+ **Directory not found**: Check paths are correct, use absolute or correct relative paths
205
+
206
+ **Feature not found**: Use `npx @salesforce/webapps-features-experimental list` to see available feature names
207
+
208
+ **Conflicts in error mode**: Follow CLI instructions to create resolution file
209
+
210
+ **Need help?**: Run `npx @salesforce/webapps-features-experimental --help` to see all commands and options
@@ -0,0 +1,80 @@
1
+ ---
2
+ name: webapp-react
3
+ description: Use when editing any React code in the web application — creating or modifying components, pages, layout, headers, footers, or any TSX/JSX files. Follow this skill for add component, add page, header/footer, and general React UI implementation patterns (shadcn UI and Tailwind CSS).
4
+ ---
5
+
6
+ # React Web App (Components, Pages, Layout)
7
+
8
+ Use this skill whenever you are editing React/TSX code in the web app (creating or modifying components, pages, header/footer, or layout).
9
+
10
+ ## Step 1 — Identify the type of component
11
+
12
+ Determine which of these three categories the request falls into, then follow the corresponding section below:
13
+
14
+ - **Page** — user wants a new routed page (e.g. "add a contacts page", "create a dashboard page", "add a settings section")
15
+ - **Header / Footer** — user wants a site-wide header, footer, nav bar, or page footer that appears on every page
16
+ - **Component** — everything else: a widget, card, table, form, dialog, or other UI element placed within an existing page
17
+
18
+ If it is not immediately clear from the user's message, ask:
19
+
20
+ > "Are you looking to add a new page, a site-wide header or footer, or a component within an existing page?"
21
+
22
+ Then follow the matching section.
23
+
24
+ ---
25
+
26
+ ## Clarifying Questions
27
+
28
+ Ask **one question at a time** and wait for the response before asking the next. Stop when you have enough to build accurately — do not guess or assume.
29
+
30
+ ### For a Page
31
+
32
+ 1. **What is the name and purpose of the page?** (e.g., Contacts, Dashboard, Settings)
33
+ 2. **What URL path should it use?** (e.g., `/contacts`, `/dashboard`) — or derive from the page name?
34
+ 3. **Should the page appear in the navigation menu?**
35
+ 4. **Who can access it?** Public, authenticated users only (`PrivateRoute`), or unauthenticated only (e.g., login — `AuthenticationRoute`)?
36
+ 5. **What content or sections should the page include?** (list, form, table, detail view, etc.)
37
+ 6. **Does it need to fetch any data?** If so, from where?
38
+
39
+ ### For a Header / Footer
40
+
41
+ 1. **Header, footer, or both?**
42
+ 2. **What should the header contain?** (logo/app name, nav links, user avatar, CTA button, etc.)
43
+ 3. **What should the footer contain?** (copyright text, links, social icons, etc.)
44
+ 4. **Should the header be sticky (fixed to top while scrolling)?**
45
+ 5. **Is there a logo or brand name to display?** (or placeholder?)
46
+ 6. **Any specific color scheme or style direction?** (dark background, branded primary color, minimal, etc.)
47
+ 7. **Should navigation links appear in the header?** If so, which pages?
48
+
49
+ ### For a Component
50
+
51
+ 1. **What should the component do?** (display data, accept input, trigger an action, etc.)
52
+ 2. **What page or location should it appear on?**
53
+ 3. **Is this shared/reusable across pages, or specific to one feature?** (determines file location)
54
+ 4. **What data or props does it need?** (static content, props, fetched data)
55
+ 5. **Does it need internal state?** (loading, toggle, form state, etc.)
56
+ 6. **Are there any specific shadcn components to use?** (Card, Table, Dialog, Form, etc.)
57
+ 7. **Should it appear in a specific layout position?** (full-width, sidebar, inline, etc.)
58
+
59
+ ---
60
+
61
+ ## Implementation
62
+
63
+ Once you have identified the type and gathered answers to the clarifying questions, read and follow the corresponding implementation guide:
64
+
65
+ - **Page** — read `implementation/page.md` and follow the instructions there.
66
+ - **Header / Footer** — read `implementation/header-footer.md` and follow the instructions there.
67
+ - **Component** — read `implementation/component.md` and follow the instructions there.
68
+
69
+ ---
70
+
71
+ ## Verification
72
+
73
+ Before completing, run from the web app directory `force-app/main/default/webapplications/<appName>/` (use the actual app folder name):
74
+
75
+ ```bash
76
+ cd force-app/main/default/webapplications/<appName> && npm run lint && npm run build
77
+ ```
78
+
79
+ - **Lint:** MUST result in 0 errors. Fix any ESLint or TypeScript issues.
80
+ - **Build:** MUST succeed. Resolve any compilation or Vite build failures before finishing.