@salesforce/webapp-template-base-sfdx-project-experimental 1.112.5 → 1.112.7

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 (22) hide show
  1. package/.a4drules/webapp-data.md +5 -5
  2. package/.a4drules/webapp-ui.md +2 -2
  3. package/AGENT.md +6 -10
  4. package/CHANGELOG.md +16 -0
  5. package/package.json +1 -1
  6. package/{.a4drules/skills/using-salesforce-data → scripts}/graphql-search.sh +4 -4
  7. package/.a4drules/skills/building-data-visualization/SKILL.md +0 -72
  8. package/.a4drules/skills/building-data-visualization/implementation/bar-line-chart.md +0 -316
  9. package/.a4drules/skills/building-data-visualization/implementation/dashboard-layout.md +0 -189
  10. package/.a4drules/skills/building-data-visualization/implementation/donut-chart.md +0 -181
  11. package/.a4drules/skills/building-data-visualization/implementation/stat-card.md +0 -150
  12. package/.a4drules/skills/building-react-components/SKILL.md +0 -96
  13. package/.a4drules/skills/building-react-components/implementation/component.md +0 -78
  14. package/.a4drules/skills/building-react-components/implementation/header-footer.md +0 -132
  15. package/.a4drules/skills/building-react-components/implementation/page.md +0 -93
  16. package/.a4drules/skills/configuring-csp-trusted-sites/SKILL.md +0 -90
  17. package/.a4drules/skills/configuring-csp-trusted-sites/implementation/metadata-format.md +0 -281
  18. package/.a4drules/skills/configuring-webapp-metadata/SKILL.md +0 -158
  19. package/.a4drules/skills/creating-webapp/SKILL.md +0 -140
  20. package/.a4drules/skills/deploying-to-salesforce/SKILL.md +0 -226
  21. package/.a4drules/skills/installing-webapp-features/SKILL.md +0 -210
  22. package/.a4drules/skills/using-salesforce-data/SKILL.md +0 -363
@@ -1,210 +0,0 @@
1
- ---
2
- name: installing-webapp-features
3
- description: Search, describe, and install pre-built UI features (authentication, shadcn components, navigation, 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, 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
@@ -1,363 +0,0 @@
1
- ---
2
- name: using-salesforce-data
3
- description: Salesforce data access for reading, writing, and querying records via REST, GraphQL, Apex, or Platform SDK. Use when the user wants to fetch, search, filter, sort, display, create, update, delete, or attach files to Salesforce records (standard objects like Accounts, Contacts, Opportunities, Cases, Quotes, or any custom object) in a web app or UI component (React, Angular, Vue, etc.); call Chatter, Connect, or Apex REST APIs; or invoke AuraEnabled Apex methods from an external app. Does not apply to authentication/OAuth setup, schema changes (adding fields, relationships), Bulk/Tooling/Metadata API usage, declarative automation (Flows, Process Builder), general LWC/Apex coding guidance without a specific data operation, or Salesforce admin/configuration tasks.
4
- ---
5
-
6
- # Salesforce Data Access
7
-
8
- ## When to Use
9
-
10
- Use this skill when the user wants to:
11
-
12
- - **Fetch or display Salesforce data** — Query records (Account, Contact, Opportunity, custom objects) to show in a component
13
- - **Create, update, or delete records** — Perform mutations on Salesforce data
14
- - **Add data fetching to a component** — Wire up a React component to Salesforce data
15
- - **Call REST APIs** — Use Connect REST, Apex REST, or UI API endpoints
16
- - **Explore the org schema** — Discover available objects, fields, or relationships
17
-
18
- ## Data SDK Requirement
19
-
20
- > **All Salesforce data access MUST use the Data SDK** (`@salesforce/sdk-data`). The SDK handles authentication, CSRF, and base URL resolution. Never use `fetch()` or `axios` directly.
21
-
22
- ```typescript
23
- import { createDataSDK, gql } from "@salesforce/sdk-data";
24
-
25
- const sdk = await createDataSDK();
26
-
27
- // GraphQL for record queries/mutations (PREFERRED)
28
- const response = await sdk.graphql?.<ResponseType>(query, variables);
29
-
30
- // REST for Connect REST, Apex REST, UI API (when GraphQL insufficient)
31
- const res = await sdk.fetch?.("/services/apexrest/my-resource");
32
- ```
33
-
34
- **Always use optional chaining** (`sdk.graphql?.()`, `sdk.fetch?.()`) — these methods may be undefined in some surfaces.
35
-
36
- ## Supported APIs
37
-
38
- **Only the following APIs are permitted.** Any endpoint not listed here must not be used.
39
-
40
- | API | Method | Endpoints / Use Case |
41
- |-----|--------|----------------------|
42
- | GraphQL | `sdk.graphql` | All record queries and mutations via `uiapi { }` namespace |
43
- | UI API REST | `sdk.fetch` | `/services/data/v{ver}/ui-api/records/{id}` — record metadata when GraphQL is insufficient |
44
- | Apex REST | `sdk.fetch` | `/services/apexrest/{resource}` — custom server-side logic, aggregates, multi-step transactions |
45
- | Connect REST | `sdk.fetch` | `/services/data/v{ver}/connect/file/upload/config` — file upload config |
46
- | Einstein LLM | `sdk.fetch` | `/services/data/v{ver}/einstein/llm/prompt/generations` — AI text generation |
47
-
48
- **Not supported:**
49
-
50
- - **Enterprise REST query endpoint** (`/services/data/v*/query` with SOQL) — blocked at the proxy level. Use GraphQL for record reads; use Apex REST if server-side SOQL aggregates are required.
51
- - **Aura-enabled Apex** (`@AuraEnabled`) — an LWC/Aura pattern with no invocation path from React webapps.
52
- - **Chatter API** (`/chatter/users/me`) — use `uiapi { currentUser { ... } }` in a GraphQL query instead.
53
- - **Any other Salesforce REST endpoint** not listed in the supported table above.
54
-
55
- ## Decision: GraphQL vs REST
56
-
57
- | Need | Method | Example |
58
- |------|--------|---------|
59
- | Query/mutate records | `sdk.graphql` | Account, Contact, custom objects |
60
- | Current user info | `sdk.graphql` | `uiapi { currentUser { Id Name { value } } }` |
61
- | UI API record metadata | `sdk.fetch` | `/ui-api/records/{id}` |
62
- | Connect REST | `sdk.fetch` | `/connect/file/upload/config` |
63
- | Apex REST | `sdk.fetch` | `/services/apexrest/auth/login` |
64
- | Einstein LLM | `sdk.fetch` | `/einstein/llm/prompt/generations` |
65
-
66
- **GraphQL is preferred** for record operations. Use REST only when GraphQL doesn't cover the use case.
67
-
68
- ---
69
-
70
- ## GraphQL Workflow
71
-
72
- ### Step 1: Acquire Schema
73
-
74
- The `schema.graphql` file (265K+ lines) is the source of truth. **Never open or parse it directly.**
75
-
76
- 1. Check if `schema.graphql` exists at the SFDX project root
77
- 2. If missing, run from the **webapp dir**: `npm run graphql:schema`
78
- 3. Custom objects appear only after metadata is deployed
79
-
80
- ### Step 2: Look Up Entity Schema
81
-
82
- Map user intent to PascalCase names ("accounts" → `Account`), then **run the search script from the project root**:
83
-
84
- ```bash
85
- # From project root — look up all relevant schema info for one or more entities
86
- bash .a4drules/skills/using-salesforce-data/graphql-search.sh Account
87
-
88
- # Multiple entities at once
89
- bash .a4drules/skills/using-salesforce-data/graphql-search.sh Account Contact Opportunity
90
- ```
91
-
92
- The script outputs five sections per entity:
93
- 1. **Type definition** — all queryable fields and relationships
94
- 2. **Filter options** — available fields for `where:` conditions
95
- 3. **Sort options** — available fields for `orderBy:`
96
- 4. **Create input** — fields accepted by create mutations
97
- 5. **Update input** — fields accepted by update mutations
98
-
99
- Use this output to determine exact field names before writing any query or mutation. **Maximum 2 script runs.** If the entity still can't be found, ask the user — the object may not be deployed.
100
-
101
- ### Step 3: Generate Query
102
-
103
- Use the templates below. Every field name **must** be verified from the script output in Step 2.
104
-
105
- #### Read Query Template
106
-
107
- ```graphql
108
- query GetAccounts {
109
- uiapi {
110
- query {
111
- Account(where: { Industry: { eq: "Technology" } }, first: 10) {
112
- edges {
113
- node {
114
- Id
115
- Name @optional { value }
116
- Industry @optional { value }
117
- # Parent relationship
118
- Owner @optional { Name { value } }
119
- # Child relationship
120
- Contacts @optional {
121
- edges { node { Name @optional { value } } }
122
- }
123
- }
124
- }
125
- }
126
- }
127
- }
128
- }
129
- ```
130
-
131
- **FLS Resilience**: Apply `@optional` to all record fields. The server omits inaccessible fields instead of failing. Consuming code must use optional chaining:
132
-
133
- ```typescript
134
- const name = node.Name?.value ?? "";
135
- ```
136
-
137
- #### Mutation Template
138
-
139
- ```graphql
140
- mutation CreateAccount($input: AccountCreateInput!) {
141
- uiapi {
142
- AccountCreate(input: $input) {
143
- Record { Id Name { value } }
144
- }
145
- }
146
- }
147
- ```
148
-
149
- **Mutation constraints:**
150
- - Create: Include required fields, only `createable` fields, no child relationships
151
- - Update: Include `Id`, only `updateable` fields
152
- - Delete: Include `Id` only
153
-
154
- #### Object Metadata & Picklist Values
155
-
156
- Use `uiapi { objectInfos(...) }` to fetch field metadata or picklist values. Pass **either** `apiNames` or `objectInfoInputs` — never both in the same query.
157
-
158
- **Object metadata** (field labels, data types, CRUD flags):
159
-
160
- ```typescript
161
- const GET_OBJECT_INFO = gql`
162
- query GetObjectInfo($apiNames: [String!]!) {
163
- uiapi {
164
- objectInfos(apiNames: $apiNames) {
165
- ApiName
166
- label
167
- labelPlural
168
- fields {
169
- ApiName
170
- label
171
- dataType
172
- updateable
173
- createable
174
- }
175
- }
176
- }
177
- }
178
- `;
179
-
180
- const sdk = await createDataSDK();
181
- const response = await sdk.graphql?.(GET_OBJECT_INFO, { apiNames: ["Account"] });
182
- const objectInfos = response?.data?.uiapi?.objectInfos ?? [];
183
- ```
184
-
185
- **Picklist values** (use `objectInfoInputs` + `... on PicklistField` inline fragment):
186
-
187
- ```typescript
188
- const GET_PICKLIST_VALUES = gql`
189
- query GetPicklistValues($objectInfoInputs: [ObjectInfoInput!]!) {
190
- uiapi {
191
- objectInfos(objectInfoInputs: $objectInfoInputs) {
192
- ApiName
193
- fields {
194
- ApiName
195
- ... on PicklistField {
196
- picklistValuesByRecordTypeIDs {
197
- recordTypeID
198
- picklistValues {
199
- label
200
- value
201
- }
202
- }
203
- }
204
- }
205
- }
206
- }
207
- }
208
- `;
209
-
210
- const response = await sdk.graphql?.(GET_PICKLIST_VALUES, {
211
- objectInfoInputs: [{ objectApiName: "Account" }],
212
- });
213
- const fields = response?.data?.uiapi?.objectInfos?.[0]?.fields ?? [];
214
- ```
215
-
216
- ### Step 4: Validate & Test
217
-
218
- 1. **Lint**: `npx eslint <file>` from webapp dir
219
- 2. **Test**: Ask user before testing. For mutations, request input values — never fabricate data.
220
-
221
- **If ESLint reports a GraphQL error** (e.g. `Cannot query field`, `Unknown type`, `Unknown argument`), the field or type name is wrong. Re-run the schema search script to find the correct name — do not guess:
222
-
223
- ```bash
224
- # From project root — re-check the entity that caused the error
225
- bash .a4drules/skills/using-salesforce-data/graphql-search.sh <EntityName>
226
- ```
227
-
228
- Then fix the query using the exact names from the script output.
229
-
230
- ---
231
-
232
- ## Webapp Integration (React)
233
-
234
- ```typescript
235
- import { createDataSDK, gql } from "@salesforce/sdk-data";
236
-
237
- const GET_ACCOUNTS = gql`
238
- query GetAccounts {
239
- uiapi {
240
- query {
241
- Account(first: 10) {
242
- edges {
243
- node {
244
- Id
245
- Name @optional { value }
246
- Industry @optional { value }
247
- }
248
- }
249
- }
250
- }
251
- }
252
- }
253
- `;
254
-
255
- const sdk = await createDataSDK();
256
- const response = await sdk.graphql?.(GET_ACCOUNTS);
257
-
258
- if (response?.errors?.length) {
259
- throw new Error(response.errors.map(e => e.message).join("; "));
260
- }
261
-
262
- const accounts = response?.data?.uiapi?.query?.Account?.edges?.map(e => e.node) ?? [];
263
- ```
264
-
265
- ---
266
-
267
- ## REST API Patterns
268
-
269
- Use `sdk.fetch` when GraphQL is insufficient. See the [Supported APIs](#supported-apis) table for the full allowlist.
270
-
271
- ```typescript
272
- declare const __SF_API_VERSION__: string;
273
- const API_VERSION = typeof __SF_API_VERSION__ !== "undefined" ? __SF_API_VERSION__ : "65.0";
274
-
275
- // Connect — file upload config
276
- const res = await sdk.fetch?.(`/services/data/v${API_VERSION}/connect/file/upload/config`);
277
-
278
- // Apex REST (no version in path)
279
- const res = await sdk.fetch?.("/services/apexrest/auth/login", {
280
- method: "POST",
281
- body: JSON.stringify({ email, password }),
282
- headers: { "Content-Type": "application/json" },
283
- });
284
-
285
- // UI API — record with metadata (prefer GraphQL for simple reads)
286
- const res = await sdk.fetch?.(`/services/data/v${API_VERSION}/ui-api/records/${recordId}`);
287
-
288
- // Einstein LLM
289
- const res = await sdk.fetch?.(`/services/data/v${API_VERSION}/einstein/llm/prompt/generations`, {
290
- method: "POST",
291
- body: JSON.stringify({ promptTextorId: prompt }),
292
- });
293
- ```
294
-
295
- **Current user**: Do not use Chatter (`/chatter/users/me`). Use GraphQL instead:
296
-
297
- ```typescript
298
- const GET_CURRENT_USER = gql`
299
- query CurrentUser {
300
- uiapi { currentUser { Id Name { value } } }
301
- }
302
- `;
303
- const response = await sdk.graphql?.(GET_CURRENT_USER);
304
- ```
305
-
306
- ---
307
-
308
- ## Directory Structure
309
-
310
- ```
311
- <project-root>/ ← SFDX project root
312
- ├── schema.graphql ← grep target (lives here)
313
- ├── sfdx-project.json
314
- └── force-app/main/default/webapplications/<app-name>/ ← webapp dir
315
- ├── package.json ← npm scripts
316
- └── src/
317
- ```
318
-
319
- | Command | Run From | Why |
320
- |---------|----------|-----|
321
- | `npm run graphql:schema` | webapp dir | Script in webapp's package.json |
322
- | `npx eslint <file>` | webapp dir | Reads eslint.config.js |
323
- | `bash .a4drules/skills/using-salesforce-data/graphql-search.sh <Entity>` | project root | Schema lookup |
324
- | `sf api request rest` | project root | Needs sfdx-project.json |
325
-
326
- ---
327
-
328
- ## Quick Reference
329
-
330
- ### Schema Lookup (from project root)
331
-
332
- Run the search script to get all relevant schema info in one step:
333
-
334
- ```bash
335
- bash .a4drules/skills/using-salesforce-data/graphql-search.sh <EntityName>
336
- ```
337
-
338
- | Script Output Section | Used For |
339
- |-----------------------|----------|
340
- | Type definition | Field names, parent/child relationships |
341
- | Filter options | `where:` conditions |
342
- | Sort options | `orderBy:` |
343
- | CreateRepresentation | Create mutation field list |
344
- | UpdateRepresentation | Update mutation field list |
345
-
346
- ### Error Categories
347
-
348
- | Error Contains | Resolution |
349
- |----------------|------------|
350
- | `Cannot query field` | Field name is wrong — run `graphql-search.sh <Entity>` and use the exact name from the Type definition section |
351
- | `Unknown type` | Type name is wrong — run `graphql-search.sh <Entity>` to confirm the correct PascalCase entity name |
352
- | `Unknown argument` | Argument name is wrong — run `graphql-search.sh <Entity>` and check Filter or OrderBy sections |
353
- | `invalid syntax` | Fix syntax per error message |
354
- | `validation error` | Field name is wrong — run `graphql-search.sh <Entity>` to verify |
355
- | `VariableTypeMismatch` | Correct argument type from schema |
356
- | `invalid cross reference id` | Entity deleted — ask for valid Id |
357
-
358
- ### Checklist
359
-
360
- - [ ] All field names verified via search script (Step 2)
361
- - [ ] `@optional` applied to record fields (reads)
362
- - [ ] Optional chaining in consuming code
363
- - [ ] Lint passes: `npx eslint <file>`