@salesforce/webapp-template-feature-react-chart-experimental 1.105.1 → 1.106.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/AGENT.md CHANGED
@@ -58,6 +58,10 @@ cd <sfdx-source>/webapplications/<appName>
58
58
 
59
59
  This project includes **.a4drules/** at the project root. Follow them when generating or editing code.
60
60
 
61
+ - **Salesforce Data Access** (`.a4drules/skills/salesforce-data-access/`): Use for all Salesforce data fetches. Enforces Data SDK usage (`createDataSDK()` + `sdk.graphql` or `sdk.fetch`); GraphQL preferred, fetch when GraphQL is not sufficient.
62
+ - **Salesforce REST API Fetch** (`.a4drules/skills/salesforce-rest-api-fetch/`): Use when implementing Chatter, Connect REST, Apex REST, UI API REST, or Einstein LLM calls via `sdk.fetch`.
63
+ - **Salesforce GraphQL** (`.a4drules/skills/salesforce-graphql/`): Use when implementing Salesforce GraphQL queries or mutations. Sub-skills: `salesforce-graphql-explore-schema`, `salesforce-graphql-read-query`, `salesforce-graphql-mutation-query`.
64
+
61
65
  When rules refer to "web app directory" or `<sfdx-source>/webapplications/<appName>/`, resolve `<sfdx-source>` from `sfdx-project.json` and use the **actual app folder name** for this project.
62
66
 
63
67
  ## Deploying
@@ -79,3 +83,4 @@ sf project deploy start --source-dir <packageDir> --target-org <alias>
79
83
 
80
84
  - **UI**: shadcn/ui + Tailwind. Import from `@/components/ui/...`.
81
85
  - **Entry**: Keep `App.tsx` and routes in `src/`; add features as new routes or sections, don't replace the app shell but you may modify it to match the requested design.
86
+ - **Data (Salesforce)**: Invoke the `salesforce-data-access` skill for all Salesforce data fetches. The skill enforces use of the Data SDK (`createDataSDK()` + `sdk.graphql` or `sdk.fetch`) — never use `fetch` or `axios` directly. GraphQL is preferred; use `sdk.fetch` when GraphQL is not sufficient (e.g., Chatter, Connect REST). For GraphQL implementation, invoke the `salesforce-graphql` skill.
package/dist/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [1.106.0](https://github.com/salesforce-experience-platform-emu/webapps/compare/v1.105.1...v1.106.0) (2026-03-17)
7
+
8
+
9
+ ### Features
10
+
11
+ * **data-skills:** Restructure data knowledge into composable skills ([#296](https://github.com/salesforce-experience-platform-emu/webapps/issues/296)) ([35e0223](https://github.com/salesforce-experience-platform-emu/webapps/commit/35e0223ac8e14c451f204fd206d5ca29fb5e684a))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [1.105.1](https://github.com/salesforce-experience-platform-emu/webapps/compare/v1.105.0...v1.105.1) (2026-03-17)
7
18
 
8
19
  **Note:** Version bump only for package @salesforce/webapp-template-base-sfdx-project-experimental
@@ -1,3 +1,7 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { resolve } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+ import { dirname } from 'node:path';
1
5
  import js from '@eslint/js';
2
6
  import tseslint from '@typescript-eslint/eslint-plugin';
3
7
  import tsparser from '@typescript-eslint/parser';
@@ -7,7 +11,11 @@ import reactRefresh from 'eslint-plugin-react-refresh';
7
11
  import globals from 'globals';
8
12
  import graphqlPlugin from '@graphql-eslint/eslint-plugin';
9
13
 
10
- export default [
14
+ const __dirname = dirname(fileURLToPath(import.meta.url));
15
+ const schemaPath = resolve(__dirname, '../../../../../schema.graphql');
16
+ const schemaExists = existsSync(schemaPath);
17
+
18
+ const config = [
11
19
  // Global ignores
12
20
  {
13
21
  ignores: ['build/**/*', 'dist/**/*', 'coverage/**/*'],
@@ -111,31 +119,38 @@ export default [
111
119
  '@typescript-eslint/no-explicit-any': 'off',
112
120
  },
113
121
  },
114
- // GraphQL processor - extracts GraphQL from gql template literals in TS/TSX files
115
- {
116
- files: ['**/*.{ts,tsx}'],
117
- processor: graphqlPlugin.processor,
118
- },
119
- // GraphQL linting configuration for .graphql files
120
- {
121
- files: ['**/*.graphql'],
122
- languageOptions: {
123
- parser: graphqlPlugin.parser,
124
- parserOptions: {
125
- graphQLConfig: {
126
- schema: '../../../../../schema.graphql',
122
+ ];
123
+
124
+ // Only add GraphQL rules when schema exists (e.g. after graphql:schema).
125
+ // In CI or when schema is not checked in, skip so lint succeeds.
126
+ if (schemaExists) {
127
+ config.push(
128
+ {
129
+ files: ['**/*.{ts,tsx}'],
130
+ processor: graphqlPlugin.processor,
131
+ },
132
+ {
133
+ files: ['**/*.graphql'],
134
+ languageOptions: {
135
+ parser: graphqlPlugin.parser,
136
+ parserOptions: {
137
+ graphQLConfig: {
138
+ schema: '../../../../../schema.graphql',
139
+ },
127
140
  },
128
141
  },
129
- },
130
- plugins: {
131
- '@graphql-eslint': graphqlPlugin,
132
- },
133
- rules: {
134
- '@graphql-eslint/no-anonymous-operations': 'error',
135
- '@graphql-eslint/no-duplicate-fields': 'error',
136
- '@graphql-eslint/known-fragment-names': 'error',
137
- '@graphql-eslint/no-undefined-variables': 'error',
138
- '@graphql-eslint/no-unused-variables': 'error',
139
- },
140
- },
141
- ];
142
+ plugins: {
143
+ '@graphql-eslint': graphqlPlugin,
144
+ },
145
+ rules: {
146
+ '@graphql-eslint/no-anonymous-operations': 'error',
147
+ '@graphql-eslint/no-duplicate-fields': 'error',
148
+ '@graphql-eslint/known-fragment-names': 'error',
149
+ '@graphql-eslint/no-undefined-variables': 'error',
150
+ '@graphql-eslint/no-unused-variables': 'error',
151
+ },
152
+ }
153
+ );
154
+ }
155
+
156
+ export default config;
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/webapp-template-base-sfdx-project-experimental",
3
- "version": "1.105.1",
3
+ "version": "1.106.0",
4
4
  "description": "Base SFDX project template",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "publishConfig": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/webapp-template-feature-react-chart-experimental",
3
- "version": "1.105.1",
3
+ "version": "1.106.0",
4
4
  "description": "Chart feature with analytics chart components, agent skills, and rules (Recharts)",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "author": "",
@@ -27,7 +27,7 @@
27
27
  "clean": "rm -rf dist"
28
28
  },
29
29
  "devDependencies": {
30
- "@salesforce/webapp-experimental": "^1.105.1",
30
+ "@salesforce/webapp-experimental": "^1.106.0",
31
31
  "@types/react": "^19.2.7",
32
32
  "@types/react-dom": "^19.2.3",
33
33
  "react-dom": "^19.2.1",
@@ -1,470 +0,0 @@
1
- ---
2
- paths:
3
- - "**/*.ts"
4
- - "**/*.tsx"
5
- ---
6
-
7
- # GraphQL Data Access
8
-
9
- Instructs agents to use the established GraphQL utilities for Salesforce data access.
10
-
11
- ## TypeScript Types & Code Generation
12
-
13
- ### Generated Types File
14
-
15
- Types are auto-generated at: `src/api/graphql-operations-types.ts`
16
-
17
- ### Generation Command
18
-
19
- ```bash
20
- npm run graphql:codegen
21
- ```
22
-
23
- The codegen configuration is at `codegen.yml` and generates types from:
24
-
25
- - Schema: `schema.graphql` (project root)
26
- - Documents: `src/**/*.{graphql,ts,tsx}`
27
-
28
- ### Type Naming Convention
29
-
30
- For a GraphQL operation named `GetHighRevenueAccounts`:
31
-
32
- - **Query/Mutation Response Type**: `GetHighRevenueAccountsQuery` or `GetHighRevenueAccountsMutation`
33
- - **Input Variables Type**: `GetHighRevenueAccountsQueryVariables` or `GetHighRevenueAccountsMutationVariables`
34
-
35
- ## Core Types & Function Signatures
36
-
37
- ### getDataSDK Function
38
-
39
- Available from `@salesforce/sdk-data`:
40
-
41
- ```typescript
42
- import { getDataSDK } from "@salesforce/sdk-data";
43
-
44
- const data = await getDataSDK();
45
- const response = await data.graphql?.<ResponseType, VariablesType>(query, variables);
46
- ```
47
-
48
- `getDataSDK()` returns a lazily-initialized `DataSDK` singleton. The `graphql` method uses optional chaining (`?.`) because not all surfaces support GraphQL.
49
-
50
- ### gql Template Tag
51
-
52
- Also available from `@salesforce/sdk-data` for inline query definitions:
53
-
54
- ```typescript
55
- import { gql } from "@salesforce/sdk-data";
56
-
57
- const MY_QUERY = gql`
58
- query MyQuery {
59
- uiapi {
60
- ...
61
- }
62
- }
63
- `;
64
- ```
65
-
66
- The `gql` tag is a template literal that allows defining GraphQL queries inline while maintaining syntax highlighting in most editors.
67
-
68
- ### GraphQLResponse Shape
69
-
70
- `data.graphql?.()` returns `GraphQLResponse<T>`. Callers destructure `{ data, errors }` and handle errors themselves:
71
-
72
- ```typescript
73
- interface GraphQLResponse<T> {
74
- data: T;
75
- errors?: Array<{
76
- message: string;
77
- locations?: Array<{ line: number; column: number }>;
78
- path?: string[];
79
- }>;
80
- }
81
- ```
82
-
83
- ### Handling Mixed Responses (Partial Success)
84
-
85
- GraphQL can return **both `data` and `errors`** in the same response (partial success). For example, some fields may resolve while others fail due to field-level security. Choose a strategy per use case:
86
-
87
- ```typescript
88
- // Strategy A: Strict — treat any errors as failure (default for most queries)
89
- if (response?.errors?.length) {
90
- throw new Error(response.errors.map((e) => e.message).join("; "));
91
- }
92
- const result = response?.data;
93
-
94
- // Strategy B: Tolerant — log errors but use partial data
95
- if (response?.errors?.length) {
96
- console.warn("GraphQL partial errors:", response.errors);
97
- }
98
- const result = response?.data;
99
-
100
- // Strategy C: Discriminated — fail only when no data came back
101
- if (response?.errors?.length && !response?.data) {
102
- throw new Error(response.errors.map((e) => e.message).join("; "));
103
- }
104
- if (response?.errors?.length) {
105
- console.warn("Partial success with errors:", response.errors);
106
- }
107
- const result = response?.data;
108
- ```
109
-
110
- **When to use each:**
111
-
112
- - **Strategy A** — Default. Use for queries where incomplete data would be misleading (e.g., financial summaries, approval workflows).
113
- - **Strategy B** — Use when partial data is still useful and the UI can degrade gracefully (e.g., dashboard tiles, optional fields).
114
- - **Strategy C** — Use for mutations where the operation may succeed but some return fields are inaccessible.
115
-
116
- For mutation-specific partial responses, see `docs/generate-mutation-query.md` which covers `PARTIAL` and `FAILED` status handling workflows.
117
-
118
- ### NodeOfConnection Utility Type
119
-
120
- Extract the node type from a connection (edges/node pattern):
121
-
122
- ```typescript
123
- import { type NodeOfConnection } from "@salesforce/sdk-data";
124
-
125
- // Extract Account node type from the query response
126
- type AccountNode = NodeOfConnection<GetHighRevenueAccountsQuery["uiapi"]["query"]["Account"]>;
127
- ```
128
-
129
- ### UIAPI Response Shape
130
-
131
- All Salesforce GraphQL record queries follow this structure (https://developer.salesforce.com/docs/platform/graphql/guide/query-record-objects.html):
132
-
133
- ```typescript
134
- interface UIAPIQueryResponse {
135
- uiapi: {
136
- query: {
137
- [ObjectName]: {
138
- edges?: Array<{
139
- node?: {
140
- Id: string;
141
- [FieldName]?: { value?: FieldType | null } | null;
142
- // Reference fields include the related record
143
- [ReferenceField]?: {
144
- value?: string | null; // The ID
145
- [RelatedField]?: { value?: RelatedType | null } | null;
146
- } | null;
147
- } | null;
148
- } | null> | null;
149
- } | null;
150
- };
151
- };
152
- }
153
- ```
154
-
155
- ## Required Workflow
156
-
157
- There are **two acceptable patterns** for defining GraphQL queries:
158
-
159
- ### Pattern 1: External .graphql File (Recommended for complex queries)
160
-
161
- #### Step 1: Create .graphql File
162
-
163
- Store queries in `.graphql` files for codegen to process:
164
-
165
- ```graphql
166
- # src/api/utils/query/myQuery.graphql
167
- query GetMyData($myVariable: String) {
168
- uiapi {
169
- query {
170
- MyObject(first: 10, where: { Field: { eq: $myVariable } }) {
171
- edges {
172
- node {
173
- Id
174
- Name {
175
- value
176
- }
177
- }
178
- }
179
- }
180
- }
181
- }
182
- }
183
- ```
184
-
185
- #### Step 2: Run Code Generation
186
-
187
- ```bash
188
- npm run graphql:codegen
189
- ```
190
-
191
- This generates types in `graphql-operations-types.ts`:
192
-
193
- - `GetMyDataQuery` - response type
194
- - `GetMyDataQueryVariables` - variables type
195
-
196
- #### Step 3: Import and Use
197
-
198
- ```typescript
199
- import { getDataSDK, type NodeOfConnection } from "@salesforce/sdk-data";
200
- import MY_QUERY from "./query/myQuery.graphql?raw";
201
- import type { GetMyDataQuery, GetMyDataQueryVariables } from "../graphql-operations-types";
202
-
203
- type MyNode = NodeOfConnection<GetMyDataQuery["uiapi"]["query"]["MyObject"]>;
204
-
205
- export async function getMyData(variables: GetMyDataQueryVariables): Promise<MyNode[]> {
206
- const data = await getDataSDK();
207
- const response = await data.graphql?.<GetMyDataQuery, GetMyDataQueryVariables>(
208
- MY_QUERY,
209
- variables,
210
- );
211
-
212
- if (response?.errors?.length) {
213
- const errorMessages = response.errors.map((e) => e.message).join("; ");
214
- throw new Error(`GraphQL Error: ${errorMessages}`);
215
- }
216
-
217
- return response?.data?.uiapi?.query?.MyObject?.edges?.map((edge) => edge?.node) || [];
218
- }
219
- ```
220
-
221
- **Key imports for Pattern 1:**
222
-
223
- - `getDataSDK` - Get the DataSDK singleton
224
- - `NodeOfConnection` - Extract node types from connection responses
225
- - Query from `.graphql` file with `?raw` suffix
226
- - Generated types from `graphql-operations-types.ts`
227
-
228
- **Pattern 1 Benefits:**
229
-
230
- - Full codegen support with automatic type generation
231
- - Syntax highlighting and validation in `.graphql` files
232
- - Easier to share queries across multiple files/components
233
- - Better for complex queries with fragments and multiple variables
234
- - IDE support for GraphQL (autocomplete, validation)
235
- - Queries can be tested independently
236
- - Clear separation of concerns between query definition and usage
237
-
238
- **Pattern 1 Limitations:**
239
-
240
- - Requires separate file management
241
- - Extra step to run codegen after query changes
242
- - More boilerplate (file import with `?raw`, separate file to maintain)
243
- - Slight overhead for very simple queries
244
- - Need to navigate between files during development
245
- - Doesn't support dynamic queries (e.g., the set of fields changes based on runtime conditions and cannot be predetermined)
246
-
247
- ### Pattern 2: Inline Query with gql Tag (Recommended for simple queries)
248
-
249
- For simpler queries without variables or when colocation is preferred:
250
-
251
- ```typescript
252
- import { getDataSDK, gql } from "@salesforce/sdk-data";
253
- import { type CurrentUserQuery } from "../graphql-operations-types";
254
-
255
- const CURRENT_USER_QUERY = gql`
256
- query CurrentUser {
257
- uiapi {
258
- currentUser {
259
- Id
260
- Name {
261
- value
262
- }
263
- }
264
- }
265
- }
266
- `;
267
-
268
- interface User {
269
- id: string;
270
- name: string;
271
- }
272
-
273
- export async function getCurrentUser(): Promise<User | null> {
274
- try {
275
- const data = await getDataSDK();
276
- const response = await data.graphql?.<CurrentUserQuery>(CURRENT_USER_QUERY);
277
-
278
- if (response?.errors?.length) {
279
- throw new Error(response.errors.map((e) => e.message).join("; "));
280
- }
281
-
282
- const userData = response?.data?.uiapi.currentUser;
283
-
284
- if (!userData) {
285
- throw new Error("No user data found");
286
- }
287
-
288
- return {
289
- id: userData.Id,
290
- name: userData.Name?.value || "User",
291
- };
292
- } catch (error) {
293
- console.error("Error fetching user data:", error);
294
- throw error;
295
- }
296
- }
297
- ```
298
-
299
- **Key imports for Pattern 2:**
300
-
301
- - `getDataSDK` - Get the DataSDK singleton
302
- - `gql` - Template tag for inline query definition
303
- - Generated types from `graphql-operations-types.ts`
304
-
305
- **Pattern 2 Benefits:**
306
-
307
- - Query is colocated with usage code
308
- - Supports dynamic queries (e.g., the set of fields changes based on runtime conditions and cannot be predetermined)
309
- - No separate file to maintain
310
- - Still gets type-checked against generated types
311
- - Simpler for straightforward queries
312
-
313
- **Pattern 2 Limitations:**
314
-
315
- - Inline queries without `gql` template tag are not processed by codegen
316
- - Must manually ensure query name matches generated types
317
- - Less suitable for complex queries with fragments
318
-
319
- ## Conditional Field Selection with Directives
320
-
321
- For dynamic fieldsets with known fields that should be conditionally included, use GraphQL directives instead of building queries dynamically. This preserves type generation while allowing runtime control.
322
-
323
- ### Directives
324
-
325
- - **`@include(if: $condition)`** - include field/fragment when `$condition` is `true`
326
- - **`@skip(if: $condition)`** - skip field/fragment when `$condition` is `true`
327
-
328
- ### Example with Fragments
329
-
330
- ```graphql
331
- query GetAccountDetails($id: ID!, $includeFinancials: Boolean!, $includeContacts: Boolean!) {
332
- uiapi {
333
- query {
334
- Account(where: { Id: { eq: $id } }) {
335
- edges {
336
- node {
337
- Id
338
- Name {
339
- value
340
- }
341
- ...FinancialFields @include(if: $includeFinancials)
342
- ...ContactFields @include(if: $includeContacts)
343
- }
344
- }
345
- }
346
- }
347
- }
348
- }
349
-
350
- fragment FinancialFields on Account {
351
- AnnualRevenue {
352
- value
353
- }
354
- NumberOfEmployees {
355
- value
356
- }
357
- }
358
-
359
- fragment ContactFields on Account {
360
- Phone {
361
- value
362
- }
363
- Website {
364
- value
365
- }
366
- }
367
- ```
368
-
369
- ### Usage
370
-
371
- ```typescript
372
- import { getDataSDK } from "@salesforce/sdk-data";
373
- import QUERY from "./query/getAccountDetails.graphql?raw";
374
- import type {
375
- GetAccountDetailsQuery,
376
- GetAccountDetailsQueryVariables,
377
- } from "../graphql-operations-types";
378
-
379
- const data = await getDataSDK();
380
- const response = await data.graphql?.<GetAccountDetailsQuery, GetAccountDetailsQueryVariables>(
381
- QUERY,
382
- {
383
- id: accountId,
384
- includeFinancials: userWantsFinancials,
385
- includeContacts: userWantsContacts,
386
- },
387
- );
388
- ```
389
-
390
- ## Anti-Patterns (Not Recommended)
391
-
392
- ### Direct API Calls
393
-
394
- ```typescript
395
- // NOT RECOMMENDED: Direct axios/fetch calls for GraphQL
396
- const response = await axios.post("/graphql", { query });
397
-
398
- // PREFERRED: Use the DataSDK
399
- const data = await getDataSDK();
400
- const response = await data.graphql?.<ResponseType>(query, variables);
401
- ```
402
-
403
- ### Missing Type Definitions
404
-
405
- ```typescript
406
- // NOT RECOMMENDED: Untyped GraphQL calls
407
- const data = await getDataSDK();
408
- await data.graphql?.(query);
409
-
410
- // PREFERRED: Provide response type
411
- const data = await getDataSDK();
412
- const response = await data.graphql?.<GetMyDataQuery>(query);
413
- ```
414
-
415
- ### Plain String Queries (Without gql Tag)
416
-
417
- ```typescript
418
- // NOT RECOMMENDED: Plain string queries without gql tag
419
- const query = `query { ... }`;
420
- const data = await getDataSDK();
421
- await data.graphql?.(query);
422
-
423
- // PREFERRED: Use gql tag for inline queries
424
- const QUERY = gql`query { ... }`;
425
- const data = await getDataSDK();
426
- const response = await data.graphql?.<ResponseType>(QUERY);
427
-
428
- // OR: Use .graphql file for complex queries
429
- import QUERY from "./query/myQuery.graphql?raw";
430
- const data = await getDataSDK();
431
- const response = await data.graphql?.<ResponseType>(QUERY);
432
- ```
433
-
434
- ## Benefits of the DataSDK GraphQL API
435
-
436
- - Uses the DataSDK with proper authentication and CSRF token handling
437
- - Consistent typing with `GraphQLResponse<T>` interface
438
- - Optional chaining (`?.`) safely handles surfaces where GraphQL is unavailable
439
- - Callers get full `GraphQLResponse<T>` for flexible error handling
440
-
441
- ## Quality Checklist
442
-
443
- Before completing GraphQL data access code:
444
-
445
- ### For Pattern 1 (.graphql files):
446
-
447
- 1. [ ] Create `.graphql` file for the query/mutation
448
- 2. [ ] Run `npm run graphql:codegen` to generate types
449
- 3. [ ] Import query with `?raw` suffix
450
- 4. [ ] Import generated types from `graphql-operations-types.ts`
451
- 5. [ ] Use `data.graphql?.<ResponseType>()` with proper generic
452
- 6. [ ] Handle `response.errors` and destructure `response.data`
453
- 7. [ ] Use `NodeOfConnection` for cleaner node types when needed
454
- 8. [ ] Handle optional chaining for nested response data
455
- 9. [ ] Follow the pattern in `accounts.ts`
456
-
457
- ### For Pattern 2 (inline with gql):
458
-
459
- 1. [ ] Define query using `gql` template tag
460
- 2. [ ] Ensure query name matches generated types in `graphql-operations-types.ts`
461
- 3. [ ] Import generated types for the query
462
- 4. [ ] Use `data.graphql?.<ResponseType>()` with proper generic
463
- 5. [ ] Handle `response.errors` and destructure `response.data`
464
- 6. [ ] Handle optional chaining for nested response data
465
- 7. [ ] Follow the pattern in `user.ts`
466
-
467
- ### General:
468
-
469
- - [ ] Choose Pattern 1 for complex queries with variables, fragments, or when shared
470
- - [ ] Choose Pattern 2 for simple, colocated queries without complex requirements