@salesforce/webapp-template-feature-react-file-upload-experimental 1.55.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/LICENSE.txt +82 -0
- package/README.md +102 -0
- package/dist/.a4drules/README.md +35 -0
- package/dist/.a4drules/a4d-webapp-generate.md +27 -0
- package/dist/.a4drules/build-validation.md +78 -0
- package/dist/.a4drules/code-quality.md +137 -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 +212 -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 +409 -0
- package/dist/.a4drules/images.md +13 -0
- package/dist/.a4drules/react.md +387 -0
- package/dist/.a4drules/react_image_processing.md +45 -0
- package/dist/.a4drules/typescript.md +224 -0
- package/dist/.a4drules/ui-layout.md +23 -0
- package/dist/.a4drules/webapp-nav-and-placeholders.md +33 -0
- package/dist/.a4drules/webapp-no-node-e.md +25 -0
- package/dist/.a4drules/webapp-ui-first.md +32 -0
- package/dist/.a4drules/webapp.md +75 -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/AGENT.md +75 -0
- package/dist/CHANGELOG.md +803 -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-file-upload/.graphqlrc.yml +2 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/.prettierignore +9 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/.prettierrc +11 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/build/vite.config.d.ts +2 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/build/vite.config.js +93 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/codegen.yml +94 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/e2e/app.spec.ts +17 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/eslint.config.js +141 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/feature-react-file-upload.webapplication-meta.xml +7 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/index.html +13 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/package-lock.json +18396 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/package.json +66 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/playwright.config.ts +24 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/scripts/get-graphql-schema.mjs +68 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/scripts/rewrite-e2e-assets.mjs +23 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/api/fileUpload.ts +154 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/api/graphql-operations-types.ts +116 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/api/utils/accounts.ts +41 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/api/utils/query/highRevenueAccountsQuery.graphql +29 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/app.tsx +22 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/appLayout.tsx +9 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/assets/icons/book.svg +3 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/assets/icons/copy.svg +4 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/assets/icons/rocket.svg +3 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/assets/icons/star.svg +3 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/assets/images/codey-1.png +0 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/assets/images/codey-2.png +0 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/assets/images/codey-3.png +0 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/assets/images/vibe-codey.svg +194 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/assets/symbols.svg +1 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/assets/utility.svg +1 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/components/FileUpload.tsx +83 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/components/FileUploadDialog.tsx +79 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/components/FileUploadDropZone.tsx +82 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/components/FileUploadFileItem.tsx +99 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/components/FileUploadIcons.tsx +58 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/components/ui/alert.tsx +69 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/components/ui/button.tsx +67 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/components/ui/card.tsx +92 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/components/ui/dialog.tsx +143 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/components/ui/field.tsx +222 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/components/ui/index.ts +84 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/components/ui/input.tsx +19 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/components/ui/label.tsx +19 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/components/ui/pagination.tsx +112 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/components/ui/select.tsx +183 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/components/ui/separator.tsx +26 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/components/ui/skeleton.tsx +14 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/components/ui/spinner.tsx +15 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/components/ui/table.tsx +87 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/components/ui/tabs.tsx +78 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/components.json +18 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/hooks/useFileUpload.ts +299 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/hooks/useFileUploadDialog.ts +70 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/index.ts +56 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/lib/utils.ts +6 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/navigationMenu.tsx +80 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/pages/Home.tsx +25 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/pages/NotFound.tsx +18 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/router-utils.tsx +35 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/routes.tsx +22 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/styles/global.css +135 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/types/fileUpload.ts +26 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/utils/fileUploadUtils.ts +44 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/utils/labels.ts +21 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/tsconfig.json +36 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/tsconfig.node.json +13 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/vite-env.d.ts +1 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/vite.config.ts +43 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/vitest-env.d.ts +2 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/vitest.config.ts +11 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/vitest.setup.ts +1 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/webapplication.json +7 -0
- package/dist/jest.config.js +6 -0
- package/dist/package.json +38 -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 +53 -0
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/api/fileUpload.ts +154 -0
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/appLayout.tsx +9 -0
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/assets/symbols.svg +1 -0
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/assets/utility.svg +1 -0
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/components/FileUpload.tsx +83 -0
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/components/FileUploadDialog.tsx +79 -0
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/components/FileUploadDropZone.tsx +82 -0
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/components/FileUploadFileItem.tsx +99 -0
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/components/FileUploadIcons.tsx +58 -0
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/hooks/useFileUpload.ts +299 -0
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/hooks/useFileUploadDialog.ts +70 -0
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/index.ts +56 -0
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/pages/Home.tsx +25 -0
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/routes.tsx +17 -0
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/types/fileUpload.ts +26 -0
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/utils/fileUploadUtils.ts +44 -0
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/utils/labels.ts +21 -0
- package/src/force-app/main/default/webapplications/feature-react-file-upload/vite.config.ts +43 -0
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
Terms of Use
|
|
2
|
+
|
|
3
|
+
Copyright 2026 Salesforce, Inc. All rights reserved.
|
|
4
|
+
|
|
5
|
+
These Terms of Use govern the download, installation, and/or use of this
|
|
6
|
+
software provided by Salesforce, Inc. ("Salesforce") (the "Software"), were
|
|
7
|
+
last updated on April 15, 2025, and constitute a legally binding
|
|
8
|
+
agreement between you and Salesforce. If you do not agree to these Terms of
|
|
9
|
+
Use, do not install or use the Software.
|
|
10
|
+
|
|
11
|
+
Salesforce grants you a worldwide, non-exclusive, no-charge, royalty-free
|
|
12
|
+
copyright license to reproduce, prepare derivative works of, publicly
|
|
13
|
+
display, publicly perform, sublicense, and distribute the Software and
|
|
14
|
+
derivative works subject to these Terms. These Terms shall be included in
|
|
15
|
+
all copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
Subject to the limited rights expressly granted hereunder, Salesforce
|
|
18
|
+
reserves all rights, title, and interest in and to all intellectual
|
|
19
|
+
property subsisting in the Software. No rights are granted to you hereunder
|
|
20
|
+
other than as expressly set forth herein. Users residing in countries on
|
|
21
|
+
the United States Office of Foreign Assets Control sanction list, or which
|
|
22
|
+
are otherwise subject to a US export embargo, may not use the Software.
|
|
23
|
+
|
|
24
|
+
Implementation of the Software may require development work, for which you
|
|
25
|
+
are responsible. The Software may contain bugs, errors and
|
|
26
|
+
incompatibilities and is made available on an AS IS basis without support,
|
|
27
|
+
updates, or service level commitments.
|
|
28
|
+
|
|
29
|
+
Salesforce reserves the right at any time to modify, suspend, or
|
|
30
|
+
discontinue, the Software (or any part thereof) with or without notice. You
|
|
31
|
+
agree that Salesforce shall not be liable to you or to any third party for
|
|
32
|
+
any modification, suspension, or discontinuance.
|
|
33
|
+
|
|
34
|
+
You agree to defend Salesforce against any claim, demand, suit or
|
|
35
|
+
proceeding made or brought against Salesforce by a third party arising out
|
|
36
|
+
of or accruing from (a) your use of the Software, and (b) any application
|
|
37
|
+
you develop with the Software that infringes any copyright, trademark,
|
|
38
|
+
trade secret, trade dress, patent, or other intellectual property right of
|
|
39
|
+
any person or defames any person or violates their rights of publicity or
|
|
40
|
+
privacy (each a "Claim Against Salesforce"), and will indemnify Salesforce
|
|
41
|
+
from any damages, attorney fees, and costs finally awarded against
|
|
42
|
+
Salesforce as a result of, or for any amounts paid by Salesforce under a
|
|
43
|
+
settlement approved by you in writing of, a Claim Against Salesforce,
|
|
44
|
+
provided Salesforce (x) promptly gives you written notice of the Claim
|
|
45
|
+
Against Salesforce, (y) gives you sole control of the defense and
|
|
46
|
+
settlement of the Claim Against Salesforce (except that you may not settle
|
|
47
|
+
any Claim Against Salesforce unless it unconditionally releases Salesforce
|
|
48
|
+
of all liability), and (z) gives you all reasonable assistance, at your
|
|
49
|
+
expense.
|
|
50
|
+
|
|
51
|
+
WITHOUT LIMITING THE GENERALITY OF THE FOREGOING, THE SOFTWARE IS NOT
|
|
52
|
+
SUPPORTED AND IS PROVIDED "AS IS," WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
53
|
+
IMPLIED. IN NO EVENT SHALL SALESFORCE HAVE ANY LIABILITY FOR ANY DAMAGES,
|
|
54
|
+
INCLUDING, BUT NOT LIMITED TO, DIRECT, INDIRECT, SPECIAL, INCIDENTAL,
|
|
55
|
+
PUNITIVE, OR CONSEQUENTIAL DAMAGES, OR DAMAGES BASED ON LOST PROFITS, DATA,
|
|
56
|
+
OR USE, IN CONNECTION WITH THE SOFTWARE, HOWEVER CAUSED AND WHETHER IN
|
|
57
|
+
CONTRACT, TORT, OR UNDER ANY OTHER THEORY OF LIABILITY, WHETHER OR NOT YOU
|
|
58
|
+
HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
|
59
|
+
|
|
60
|
+
These Terms of Use shall be governed exclusively by the internal laws of
|
|
61
|
+
the State of California, without regard to its conflicts of laws
|
|
62
|
+
rules. Each party hereby consents to the exclusive jurisdiction of the
|
|
63
|
+
state and federal courts located in San Francisco County, California to
|
|
64
|
+
adjudicate any dispute arising out of or relating to these Terms of Use and
|
|
65
|
+
the download, installation, and/or use of the Software. Except as expressly
|
|
66
|
+
stated herein, these Terms of Use constitute the entire agreement between
|
|
67
|
+
the parties, and supersede all prior and contemporaneous agreements,
|
|
68
|
+
proposals, or representations, written or oral, concerning their subject
|
|
69
|
+
matter. No modification, amendment, or waiver of any provision of these
|
|
70
|
+
Terms of Use shall be effective unless it is by an update to these Terms of
|
|
71
|
+
Use that Salesforce makes available, or is in writing and signed by the
|
|
72
|
+
party against whom the modification, amendment, or waiver is to be
|
|
73
|
+
asserted.
|
|
74
|
+
|
|
75
|
+
Data Privacy: Salesforce may collect, process, and store device,
|
|
76
|
+
system, and other information related to your use of the Software. This
|
|
77
|
+
information includes, but is not limited to, IP address, user metrics, and
|
|
78
|
+
other data ("Usage Data"). Salesforce may use Usage Data for analytics,
|
|
79
|
+
product development, and marketing purposes. You acknowledge that files
|
|
80
|
+
generated in conjunction with the Software may contain sensitive or
|
|
81
|
+
confidential data, and you are solely responsible for anonymizing and
|
|
82
|
+
protecting such data.
|
package/README.md
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# Feature: File Upload
|
|
2
|
+
|
|
3
|
+
File upload feature: use the **FileUpload** component as-is with out-of-the-box UI, or build a **custom UI** with the `useFileUpload` hook (custom trigger, drop zone, or both).
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
### Option 1: FileUpload component (OOTB UI)
|
|
8
|
+
|
|
9
|
+
Use the component as-is for a ready-made drop zone, dialog, and progress display.
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import { FileUpload } from "@salesforce/webapp-template-feature-react-file-upload-experimental";
|
|
13
|
+
|
|
14
|
+
<FileUpload
|
|
15
|
+
multiple
|
|
16
|
+
accept="image/*,.pdf"
|
|
17
|
+
onUploadComplete={(files) => console.log("Uploaded:", files)}
|
|
18
|
+
/>;
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Option 2: Custom UI with your own trigger
|
|
22
|
+
|
|
23
|
+
Use the `useFileUpload` hook to control when the file picker opens. Render a hidden input and your own button or action.
|
|
24
|
+
|
|
25
|
+
```tsx
|
|
26
|
+
import {
|
|
27
|
+
useFileUpload,
|
|
28
|
+
type UseFileUploadOptions,
|
|
29
|
+
} from "@salesforce/webapp-template-feature-react-file-upload-experimental";
|
|
30
|
+
|
|
31
|
+
function CustomUploadButton() {
|
|
32
|
+
const { getInputProps, openFilePicker } = useFileUpload({
|
|
33
|
+
multiple: true,
|
|
34
|
+
onUploadComplete: (files) => console.log("Uploaded:", files),
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<>
|
|
39
|
+
<input {...getInputProps()} style={{ display: "none" }} />
|
|
40
|
+
<button type="button" onClick={openFilePicker}>
|
|
41
|
+
Upload files
|
|
42
|
+
</button>
|
|
43
|
+
</>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Option 3: Custom UI with drop zone and progress
|
|
49
|
+
|
|
50
|
+
Build a custom drop zone and inline progress list (no dialog) using `getDropZoneProps` and `fileItems`:
|
|
51
|
+
|
|
52
|
+
```tsx
|
|
53
|
+
import { useFileUpload } from "@salesforce/webapp-template-feature-react-file-upload-experimental";
|
|
54
|
+
|
|
55
|
+
function MyUpload() {
|
|
56
|
+
const { fileItems, getInputProps, getDropZoneProps, reset } = useFileUpload({
|
|
57
|
+
multiple: true,
|
|
58
|
+
onUploadComplete: (files) => console.log("Uploaded files:", files),
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const input = getInputProps();
|
|
62
|
+
const drop = getDropZoneProps();
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<div>
|
|
66
|
+
<div {...drop}>
|
|
67
|
+
<input {...input} style={{ display: "none" }} />
|
|
68
|
+
Drop files here
|
|
69
|
+
</div>
|
|
70
|
+
{fileItems.map((item) => (
|
|
71
|
+
<div key={item.file.name}>
|
|
72
|
+
{item.file.name}: {item.state} {item.progress}%
|
|
73
|
+
</div>
|
|
74
|
+
))}
|
|
75
|
+
</div>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Exports
|
|
81
|
+
|
|
82
|
+
- **FileUpload** – Component with OOTB drop zone, dialog, and progress. Props: `accept?`, `multiple?`, `recordId?`, `onUploadComplete?`, `onUploadError?`, `className?`.
|
|
83
|
+
- **useFileUpload** – Headless hook for custom UIs. Returns `getInputProps`, `openFilePicker`, `fileItems`, `getDropZoneProps`, `cancelFile`, `reset`, etc.
|
|
84
|
+
- **UseFileUploadOptions** – Type for the `useFileUpload` options.
|
|
85
|
+
|
|
86
|
+
## Dependencies
|
|
87
|
+
|
|
88
|
+
This feature depends on:
|
|
89
|
+
|
|
90
|
+
- **feature-react-shadcn** – For UI components (Button, Dialog, etc.)
|
|
91
|
+
- **@salesforce/webapp-experimental** – For API client and Salesforce integration
|
|
92
|
+
|
|
93
|
+
## Build & Testing
|
|
94
|
+
|
|
95
|
+
You can test the extension of the base app and the components via the following:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
npm run build
|
|
99
|
+
npm run start
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Open the app and use the Home page to test the FileUpload component.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# A4D Rules Index
|
|
2
|
+
|
|
3
|
+
Rules in this folder guide the agent for this SFDX project. **Knowledge** (expert content) lives in the **local-expert MCP** repo (e.g. `local-expert-mcp`); rules here reference when to call which expert.
|
|
4
|
+
|
|
5
|
+
## Always-apply rules (MUST follow)
|
|
6
|
+
|
|
7
|
+
| File | Purpose |
|
|
8
|
+
|------|--------|
|
|
9
|
+
| **webapp.md** | Main web app rules: invoke local-expert MCP (`webapplications-design-system` + `webapplications`), no `node -e`, React/SFDX workflow; **replace default boilerplate**; **populate home page**; **frontend aesthetics**—avoid AI slop, follow design-system expert. |
|
|
10
|
+
| **webapp-no-node-e.md** | No `node -e` for any file/config/shell work; use `replace_in_file` or `write_to_file` only. |
|
|
11
|
+
| **a4d-webapp-generate.md** | Before `sf webapp generate`: call `get_expert_knowledge` with `webapplications-design-system` and `webapplications`; then run CLI. |
|
|
12
|
+
| **webapp-ui-first.md** | Build UI (layout, components, styling) first; then implement business logic (APIs, state, handlers). |
|
|
13
|
+
| **webapp-nav-and-placeholders.md** | **Build navigation into the app layout** (`appLayout.tsx`). Always update nav menu (app-specific items/labels) and placeholder name/design (header/nav/footer/title). Often missed—mandatory. |
|
|
14
|
+
|
|
15
|
+
## Context-specific rules (by file pattern or topic)
|
|
16
|
+
|
|
17
|
+
| File | Purpose |
|
|
18
|
+
|------|--------|
|
|
19
|
+
| **react.md** | React web app structure, shadcn/Tailwind, data access, security; edit `appLayout.tsx` when changing layout. |
|
|
20
|
+
| **ui-layout.md** | When changing UI/nav/header/footer/sidebar/theme, always update `appLayout.tsx`. |
|
|
21
|
+
| **code-quality.md** | ESLint, Prettier, import order, naming, lint/build before completion; no `node -e`. |
|
|
22
|
+
| **build-validation.md** | `npm run build` must succeed from web app dir before completing. |
|
|
23
|
+
| **typescript.md** | TypeScript strictness, return types, interfaces. |
|
|
24
|
+
| **images.md** | Images: Unsplash default, CSP, alt text, error handling. |
|
|
25
|
+
| **react_image_processing.md** | Image handling (Unsplash, CSP, accessibility) for React components. |
|
|
26
|
+
| **graphql/** | GraphQL tools and knowledge (schemas, LDS guides). |
|
|
27
|
+
|
|
28
|
+
## Knowledge repository (experts)
|
|
29
|
+
|
|
30
|
+
Expert knowledge is served by the **local-expert MCP** (e.g. at `local-expert-mcp`). The agent must call **`get_expert_knowledge`** with the appropriate topic:
|
|
31
|
+
|
|
32
|
+
- **webapplications-design-system** — Always use for web app UI/design work (design system, typography, color, motion).
|
|
33
|
+
- **webapplications** — Use for app generation and structure; then call sub-topics as needed (e.g. `webapplications-best-practice`, `webapplications-feature-*`).
|
|
34
|
+
|
|
35
|
+
See the MCP repo's **rule-expert-mcp.md** for full topic list and when to call which expert.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: A4D rule — call expert MCP (webapplications + webapplications-design-system) before sf webapp generate
|
|
3
|
+
alwaysApply: true
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# A4D Rule: Before `sf webapp generate`
|
|
7
|
+
|
|
8
|
+
Before running **`sf webapp generate`**, you **must**:
|
|
9
|
+
|
|
10
|
+
1. **Call the expert MCP** (`get_expert_knowledge`) with topic **`webapplications-design-system`** — always invoke this expert for UI/design direction.
|
|
11
|
+
2. **Call the expert MCP** with topic **`webapplications`** to get generation and structure guidance.
|
|
12
|
+
3. Follow the instructions from the MCP responses.
|
|
13
|
+
4. Only after that, run `sf webapp generate` (e.g. `sf webapp generate -n <AppName> -t <template>`).
|
|
14
|
+
|
|
15
|
+
**Webapp name (`-n` / `<AppName>`):** Must be **alphanumerical only**—no spaces, hyphens, underscores, or other special characters. Use only letters (A–Z, a–z) and digits (0–9). If the desired name has spaces or special characters, use a single alphanumeric word (e.g. `CoffeeBoutique` instead of `Coffee Boutique` or `coffee-boutique`).
|
|
16
|
+
|
|
17
|
+
Do not run `sf webapp generate` without having invoked the expert MCP with **`webapplications-design-system`** and **`webapplications`** first.
|
|
18
|
+
|
|
19
|
+
When modifying an existing web app (UI, layout, or new features), **always** call `get_expert_knowledge` with topic **`webapplications-design-system`** before making UI or design changes.
|
|
20
|
+
|
|
21
|
+
**After generating (or when touching a new app):** Replace all default boilerplate content (e.g. "React App", "Vite + React", default document title in `index.html`, placeholder text in the shell) with the actual app name or user-facing copy. Do not leave generic template text in the UI or `<title>`.
|
|
22
|
+
|
|
23
|
+
**Home page content:** Populate the home page (root route) with real, app-specific content (e.g. landing section, banners, tiles, hero, links to features). Never leave the home page as the default template or placeholder.
|
|
24
|
+
|
|
25
|
+
**Navigation menu and placeholder name/design:** After generating or when delivering a web app, **you must** (1) **Edit the navigation menu** in `appLayout.tsx`: replace every default nav item and label with app-specific routes and names; do not leave template "Home"/"About" or placeholder links. (2) **Replace the placeholder app name** in the header, nav brand, footer, and `index.html` `<title>` with the actual app name. (3) **Update placeholder design** in the shell (header/footer/branding) so it is not the template default. See **webapp-nav-and-placeholders.md**. Agents often skip this—do not.
|
|
26
|
+
|
|
27
|
+
Prioritize webapplications generation first, and then generate the metadata.
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# AI Rule: Build Validation
|
|
2
|
+
|
|
3
|
+
Build validation for successful deployments with minimal friction.
|
|
4
|
+
|
|
5
|
+
## Targets
|
|
6
|
+
- `force-app/main/default/webapplications/*/**/*`
|
|
7
|
+
- `**/*.{js,ts,jsx,tsx}`
|
|
8
|
+
|
|
9
|
+
## MANDATORY: Build Success
|
|
10
|
+
|
|
11
|
+
**Before completing any coding session** (from the web app directory `force-app/main/default/webapplications/<appName>/`):
|
|
12
|
+
```bash
|
|
13
|
+
npm run build # MUST succeed with no errors
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Quick Quality Checks
|
|
17
|
+
Run from the web app directory (`force-app/main/default/webapplications/<appName>/`):
|
|
18
|
+
```bash
|
|
19
|
+
npm run lint # ESLint; fix issues before completing
|
|
20
|
+
npm run build # Runs tsc -b && vite build; catches TypeScript and build issues
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Requirements
|
|
24
|
+
|
|
25
|
+
**Must Pass:**
|
|
26
|
+
- `npm run build` completes successfully
|
|
27
|
+
- No TypeScript compilation errors
|
|
28
|
+
- No critical ESLint errors
|
|
29
|
+
|
|
30
|
+
**Can Be Warnings:**
|
|
31
|
+
- ESLint warnings
|
|
32
|
+
- Minor TypeScript warnings
|
|
33
|
+
|
|
34
|
+
## Fix Commands (when available in the web app's package.json)
|
|
35
|
+
```bash
|
|
36
|
+
npm run lint # Run ESLint (always available)
|
|
37
|
+
# If your project adds Prettier/format scripts, use those before completing
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Workflow
|
|
41
|
+
|
|
42
|
+
**During Development:**
|
|
43
|
+
1. Write code with AI assistance
|
|
44
|
+
2. Save frequently (auto-format on save)
|
|
45
|
+
3. Check periodically: `npm run lint` (optional)
|
|
46
|
+
|
|
47
|
+
**Before Completion:**
|
|
48
|
+
1. Run `npm run build` from the web app directory
|
|
49
|
+
2. If it fails: fix TypeScript/ESLint errors (run `npm run lint`), then retry build
|
|
50
|
+
|
|
51
|
+
## Error Priority
|
|
52
|
+
|
|
53
|
+
**Fix Immediately:**
|
|
54
|
+
- TypeScript compilation errors
|
|
55
|
+
- Import/export errors
|
|
56
|
+
- Syntax errors
|
|
57
|
+
|
|
58
|
+
**Fix When Convenient:**
|
|
59
|
+
- ESLint warnings
|
|
60
|
+
- Unused variables
|
|
61
|
+
|
|
62
|
+
## Hard Requirements
|
|
63
|
+
- Build must complete without errors
|
|
64
|
+
- No broken imports
|
|
65
|
+
- Basic TypeScript type safety
|
|
66
|
+
|
|
67
|
+
## Key Commands (web app directory)
|
|
68
|
+
```bash
|
|
69
|
+
npm run dev # Start development server (vite)
|
|
70
|
+
npm run build # TypeScript + Vite build; check deployment readiness
|
|
71
|
+
npm run lint # Run ESLint
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Troubleshooting Import Errors
|
|
75
|
+
```bash
|
|
76
|
+
npm install # Check missing dependencies
|
|
77
|
+
# Verify file exists, case sensitivity, export/import match
|
|
78
|
+
```
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# AI Rule: Code Quality Standards
|
|
2
|
+
|
|
3
|
+
Enforces ESLint, Prettier, and coding best practices for consistent, maintainable code.
|
|
4
|
+
|
|
5
|
+
**Execution rule:** Do not use `node -e` for any file or config edits. Use `replace_in_file` or `write_to_file` only (see **webapp-no-node-e.md**).
|
|
6
|
+
|
|
7
|
+
## Targets
|
|
8
|
+
- `force-app/main/default/webapplications/*/**/*`
|
|
9
|
+
- `**/*.{js,ts,jsx,tsx,json,md}`
|
|
10
|
+
|
|
11
|
+
## MANDATORY Checks
|
|
12
|
+
|
|
13
|
+
**Before completing code** (run from the web app directory `force-app/main/default/webapplications/<appName>/`):
|
|
14
|
+
```bash
|
|
15
|
+
npm run lint # MUST result in: 0 errors (0 warnings preferred)
|
|
16
|
+
npm run build # MUST succeed (includes TypeScript check)
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
If your project adds Prettier, use a consistent config (e.g. `.prettierrc` with `semi`, `singleQuote`, `printWidth`, etc.) and run format checks before completing.
|
|
20
|
+
|
|
21
|
+
## Lint / Fix
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm run lint # Run ESLint (always available in the template web app)
|
|
25
|
+
# Use your editor's format-on-save or add npm scripts for Prettier if desired
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Import Order (MANDATORY)
|
|
29
|
+
```typescript
|
|
30
|
+
// 1. React ecosystem
|
|
31
|
+
import { useState, useEffect } from 'react';
|
|
32
|
+
|
|
33
|
+
// 2. External libraries (alphabetical)
|
|
34
|
+
import axios from 'axios';
|
|
35
|
+
import clsx from 'clsx';
|
|
36
|
+
|
|
37
|
+
// 3. UI components (alphabetical)
|
|
38
|
+
import { Button } from '@/components/ui/button';
|
|
39
|
+
import { Card } from '@/components/ui/card';
|
|
40
|
+
|
|
41
|
+
// 4. Internal utilities (alphabetical)
|
|
42
|
+
import { useAuth } from '../hooks/useAuth';
|
|
43
|
+
import { formatDate } from '../utils/dateUtils';
|
|
44
|
+
|
|
45
|
+
// 5. Relative imports
|
|
46
|
+
import { ComponentA } from './ComponentA';
|
|
47
|
+
|
|
48
|
+
// 6. Type imports (separate, at end)
|
|
49
|
+
import type { User, ApiResponse } from '../types';
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Naming Conventions
|
|
53
|
+
```typescript
|
|
54
|
+
// PascalCase: Components, classes
|
|
55
|
+
const UserProfile = () => {};
|
|
56
|
+
const ApiClient = class {};
|
|
57
|
+
|
|
58
|
+
// camelCase: Variables, functions, properties
|
|
59
|
+
const userName = 'john';
|
|
60
|
+
const fetchUserData = async () => {};
|
|
61
|
+
|
|
62
|
+
// SCREAMING_SNAKE_CASE: Constants
|
|
63
|
+
const API_BASE_URL = 'https://api.example.com';
|
|
64
|
+
|
|
65
|
+
// kebab-case: Files
|
|
66
|
+
// user-profile.tsx, api-client.ts
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## React Component Structure
|
|
70
|
+
```typescript
|
|
71
|
+
interface ComponentProps {
|
|
72
|
+
// Props interface first
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const Component: React.FC<ComponentProps> = ({ prop1, prop2 }) => {
|
|
76
|
+
// 1. Hooks
|
|
77
|
+
// 2. Computed values
|
|
78
|
+
// 3. Event handlers
|
|
79
|
+
// 4. JSX return
|
|
80
|
+
|
|
81
|
+
return <div />;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export default Component;
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## JSX Standards
|
|
88
|
+
```typescript
|
|
89
|
+
// Self-closing tags
|
|
90
|
+
<Button onClick={handleClick} />
|
|
91
|
+
|
|
92
|
+
// Conditional rendering
|
|
93
|
+
{isLoading && <Spinner />}
|
|
94
|
+
{error ? <ErrorMessage error={error} /> : <Content />}
|
|
95
|
+
|
|
96
|
+
// Lists with keys
|
|
97
|
+
{items.map(item => <Item key={item.id} data={item} />)}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Error Handling
|
|
101
|
+
```typescript
|
|
102
|
+
// Async functions with try-catch
|
|
103
|
+
const fetchData = async (id: string): Promise<Data> => {
|
|
104
|
+
try {
|
|
105
|
+
const response = await api.get(`/data/${id}`);
|
|
106
|
+
return response.data;
|
|
107
|
+
} catch (error) {
|
|
108
|
+
console.error('Failed to fetch data:', error);
|
|
109
|
+
throw error;
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Anti-Patterns (FORBIDDEN)
|
|
115
|
+
```typescript
|
|
116
|
+
// NEVER disable ESLint without justification
|
|
117
|
+
// eslint-disable-next-line
|
|
118
|
+
|
|
119
|
+
// NEVER mutate state directly
|
|
120
|
+
state.items.push(newItem); // Wrong
|
|
121
|
+
setItems(prev => [...prev, newItem]); // Correct
|
|
122
|
+
|
|
123
|
+
// NEVER use magic numbers/strings
|
|
124
|
+
setTimeout(() => {}, 5000); // Wrong
|
|
125
|
+
const DEBOUNCE_DELAY = 5000; // Correct
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Quality Workflow
|
|
129
|
+
|
|
130
|
+
**Before Committing:**
|
|
131
|
+
1. `npm run lint` - 0 errors (and 0 warnings when possible)
|
|
132
|
+
2. `npm run build` - Build must succeed (TypeScript + Vite)
|
|
133
|
+
|
|
134
|
+
## Zero Tolerance Policy
|
|
135
|
+
- ESLint errors: MUST be 0
|
|
136
|
+
- ESLint warnings: MUST be 0 (fix when convenient)
|
|
137
|
+
- TypeScript errors: MUST be 0 (enforced by `npm run build`)
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
# GraphQL Schema Reference
|
|
2
|
+
|
|
3
|
+
This document provides guidance for AI agents working with the Salesforce GraphQL API schema in this project.
|
|
4
|
+
|
|
5
|
+
## Schema File Location
|
|
6
|
+
|
|
7
|
+
**The complete GraphQL schema is located at: `@schema.graphql`** (in the project root)
|
|
8
|
+
|
|
9
|
+
> ⚠️ **Important**: The schema file is very large (~265,000+ lines). Do NOT read it entirely. Instead, use targeted searches to find specific types, fields, or operations.
|
|
10
|
+
|
|
11
|
+
If the file is not present, generate it by running:
|
|
12
|
+
```bash
|
|
13
|
+
npm run graphql:get-schema
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Required Pre-Flight Check
|
|
17
|
+
|
|
18
|
+
**BEFORE generating any GraphQL query, you MUST:**
|
|
19
|
+
|
|
20
|
+
1. **Check if schema exists**: Look for `schema.graphql` in the project root
|
|
21
|
+
2. **If schema is missing**:
|
|
22
|
+
- Run `npm run graphql:get-schema` to download it
|
|
23
|
+
- Wait for the command to complete successfully
|
|
24
|
+
- Then proceed with schema exploration
|
|
25
|
+
3. **If schema exists**: Proceed with targeted searches as described below
|
|
26
|
+
|
|
27
|
+
> ⚠️ **DO NOT** generate GraphQL queries without first having access to the schema. Standard field assumptions may not match the target org's configuration.
|
|
28
|
+
|
|
29
|
+
## Schema Structure Overview
|
|
30
|
+
|
|
31
|
+
The schema follows the Salesforce GraphQL Wire Adapter pattern with these main entry points:
|
|
32
|
+
|
|
33
|
+
### Query Entry Point
|
|
34
|
+
```graphql
|
|
35
|
+
type Query {
|
|
36
|
+
uiapi: UIAPI!
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### UIAPI Structure
|
|
41
|
+
```graphql
|
|
42
|
+
type UIAPI {
|
|
43
|
+
query: RecordQuery! # For querying records
|
|
44
|
+
aggregate: RecordQueryAggregate! # For aggregate queries
|
|
45
|
+
objectInfos: [ObjectInfo] # For metadata
|
|
46
|
+
relatedListByName: RelatedListInfo
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Mutation Entry Point
|
|
51
|
+
```graphql
|
|
52
|
+
type Mutation {
|
|
53
|
+
uiapi(input: UIAPIMutationsInput): UIAPIMutations!
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## How to Explore the Schema
|
|
58
|
+
|
|
59
|
+
When you need to build a GraphQL query, use these search patterns:
|
|
60
|
+
|
|
61
|
+
### 1. Find Available Fields for a Record Type
|
|
62
|
+
Search for `type <ObjectName> implements Record` to find all queryable fields:
|
|
63
|
+
```bash
|
|
64
|
+
# Example: Find Account fields
|
|
65
|
+
grep "^type Account implements Record" schema.graphql -A 50
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### 2. Find Filter Options for a Record Type
|
|
69
|
+
Search for `input <ObjectName>_Filter` to find filterable fields and operators:
|
|
70
|
+
```bash
|
|
71
|
+
# Example: Find Account filter options
|
|
72
|
+
grep "^input Account_Filter" schema.graphql -A 30
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### 3. Find OrderBy Options
|
|
76
|
+
Search for `input <ObjectName>_OrderBy` for sorting options:
|
|
77
|
+
```bash
|
|
78
|
+
# Example: Find Account ordering options
|
|
79
|
+
grep "^input Account_OrderBy" schema.graphql -A 20
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### 4. Find Mutation Operations
|
|
83
|
+
Search for operations in `UIAPIMutations`:
|
|
84
|
+
```bash
|
|
85
|
+
# Example: Find Account mutations
|
|
86
|
+
grep "Account.*Create\|Account.*Update\|Account.*Delete" schema.graphql
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### 5. Find Input Types for Mutations
|
|
90
|
+
Search for `input <ObjectName>CreateInput` or `input <ObjectName>UpdateInput`:
|
|
91
|
+
```bash
|
|
92
|
+
# Example: Find Account create input
|
|
93
|
+
grep "^input AccountCreateInput" schema.graphql -A 30
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Common Operator Types
|
|
97
|
+
|
|
98
|
+
### StringOperators (for text fields)
|
|
99
|
+
```graphql
|
|
100
|
+
input StringOperators {
|
|
101
|
+
eq: String # equals
|
|
102
|
+
ne: String # not equals
|
|
103
|
+
like: String # pattern matching (use % as wildcard)
|
|
104
|
+
lt: String # less than
|
|
105
|
+
gt: String # greater than
|
|
106
|
+
lte: String # less than or equal
|
|
107
|
+
gte: String # greater than or equal
|
|
108
|
+
in: [String] # in list
|
|
109
|
+
nin: [String] # not in list
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### OrderByClause
|
|
114
|
+
```graphql
|
|
115
|
+
input OrderByClause {
|
|
116
|
+
order: ResultOrder # ASC or DESC
|
|
117
|
+
nulls: NullOrder # FIRST or LAST
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Query Pattern Examples
|
|
122
|
+
|
|
123
|
+
### Basic Query Structure
|
|
124
|
+
All record queries follow this pattern:
|
|
125
|
+
```graphql
|
|
126
|
+
query {
|
|
127
|
+
uiapi {
|
|
128
|
+
query {
|
|
129
|
+
<ObjectName>(
|
|
130
|
+
first: Int # pagination limit
|
|
131
|
+
after: String # pagination cursor
|
|
132
|
+
where: <Object>_Filter
|
|
133
|
+
orderBy: <Object>_OrderBy
|
|
134
|
+
) {
|
|
135
|
+
edges {
|
|
136
|
+
node {
|
|
137
|
+
Id
|
|
138
|
+
<Field> { value }
|
|
139
|
+
# ... more fields
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Example: Query Accounts with Filter
|
|
149
|
+
```graphql
|
|
150
|
+
query GetHighRevenueAccounts($minRevenue: Currency) {
|
|
151
|
+
uiapi {
|
|
152
|
+
query {
|
|
153
|
+
Account(
|
|
154
|
+
where: { AnnualRevenue: { gt: $minRevenue } }
|
|
155
|
+
orderBy: { AnnualRevenue: { order: DESC } }
|
|
156
|
+
first: 50
|
|
157
|
+
) {
|
|
158
|
+
edges {
|
|
159
|
+
node {
|
|
160
|
+
Id
|
|
161
|
+
Name { value }
|
|
162
|
+
AnnualRevenue { value }
|
|
163
|
+
Industry { value }
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Mutation Pattern
|
|
173
|
+
```graphql
|
|
174
|
+
mutation CreateAccount($input: AccountCreateInput!) {
|
|
175
|
+
uiapi(input: { AccountCreate: { input: $input } }) {
|
|
176
|
+
AccountCreate {
|
|
177
|
+
Record {
|
|
178
|
+
Id
|
|
179
|
+
Name { value }
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## Field Value Wrappers
|
|
187
|
+
|
|
188
|
+
Salesforce GraphQL returns field values wrapped in typed objects:
|
|
189
|
+
|
|
190
|
+
| Wrapper Type | Access Pattern |
|
|
191
|
+
|-------------|----------------|
|
|
192
|
+
| `StringValue` | `FieldName { value }` |
|
|
193
|
+
| `IntValue` | `FieldName { value }` |
|
|
194
|
+
| `BooleanValue` | `FieldName { value }` |
|
|
195
|
+
| `DateTimeValue` | `FieldName { value displayValue }` |
|
|
196
|
+
| `PicklistValue` | `FieldName { value displayValue }` |
|
|
197
|
+
| `CurrencyValue` | `FieldName { value displayValue }` |
|
|
198
|
+
|
|
199
|
+
## Agent Workflow for Building Queries
|
|
200
|
+
|
|
201
|
+
**Pre-requisites (MANDATORY):**
|
|
202
|
+
- [ ] Verified `schema.graphql` exists in project root
|
|
203
|
+
- [ ] If missing, ran `npm run graphql:get-schema` and waited for completion
|
|
204
|
+
- [ ] Confirmed connection to correct Salesforce org (if downloading fresh schema)
|
|
205
|
+
|
|
206
|
+
**Workflow Steps:**
|
|
207
|
+
|
|
208
|
+
1. **Identify the target object** (e.g., Account, Contact, Opportunity)
|
|
209
|
+
2. **Search the schema** for the object type to discover available fields
|
|
210
|
+
3. **Search for filter input** (`<Object>_Filter`) to understand filtering options
|
|
211
|
+
4. **Search for orderBy input** (`<Object>_OrderBy`) for sorting capabilities
|
|
212
|
+
5. **Build the query** following the patterns above
|
|
213
|
+
6. **Validate field names** match exactly as defined in the schema (case-sensitive)
|
|
214
|
+
|
|
215
|
+
## Tips for Agents
|
|
216
|
+
|
|
217
|
+
- **Always verify field names** by searching the schema before generating queries
|
|
218
|
+
- **Use grep/search** to explore the schema efficiently—never read the entire file
|
|
219
|
+
- **Check relationships** by looking for `parentRelationship` and `childRelationship` comments in type definitions
|
|
220
|
+
- **Look for Connection types** (e.g., `AccountConnection`) to understand pagination structure
|
|
221
|
+
- **Custom objects** end with `__c` (e.g., `CustomObject__c`)
|
|
222
|
+
- **Custom fields** also end with `__c` (e.g., `Custom_Field__c`)
|
|
223
|
+
|
|
224
|
+
## Related Documentation
|
|
225
|
+
|
|
226
|
+
- For generating mutations and queries, see `lds-generate-graphql-mutationquery.md`
|
|
227
|
+
- For GraphQL best practices, see `lds-guide-graphql.md`
|