@salesforce/ui-bundle-template-app-react-sample-b2x 1.119.0 → 1.119.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/AGENT.md CHANGED
@@ -45,7 +45,7 @@ Replace `<appName>` with the actual folder name found under `uiBundles/`. The so
45
45
  └── data/ # Sample data for import (optional)
46
46
  ```
47
47
 
48
- ## Web application source structure
48
+ ## UI Bundle source structure
49
49
 
50
50
  All application code lives inside the UI Bundle's `src/` directory:
51
51
 
@@ -95,9 +95,11 @@ Used for SFDX metadata tooling. Scripts here target LWC/Aura, not the React app.
95
95
 
96
96
  **One-time org setup:** `node scripts/org-setup.mjs --target-org <alias>` runs login, deploy, permset assignment, data import, GraphQL schema/codegen, UI Bundle build, and optionally the dev server. Use `--help` for all flags.
97
97
 
98
- ### 2. Web app directory (primary workspace)
98
+ ### 2. UI Bundle directory (primary workspace)
99
99
 
100
- **Always `cd` into the UI Bundle directory for dev/build/lint/test:**
100
+ **ALL dev, build, lint, and test commands MUST be run from inside the UI Bundle directory (`<sfdx-source>/uiBundles/<appName>/`). Never run them from the project root.**
101
+
102
+ Resolve the correct path from `sfdx-project.json` before running any command. Do not hardcode the path.
101
103
 
102
104
  | Command | Purpose |
103
105
  |---------|---------|
@@ -109,13 +111,17 @@ Used for SFDX metadata tooling. Scripts here target LWC/Aura, not the React app.
109
111
  | `npm run graphql:codegen` | Generate GraphQL types from schema |
110
112
  | `npm run graphql:schema` | Fetch GraphQL schema from org |
111
113
 
112
- **Before completing any change:** run `npm run build` and `npm run lint` from the UI Bundle directory. Both must pass with zero errors.
114
+ **After every task, without exception:**
115
+ 1. Run `npm run build` from the UI Bundle directory — must pass with zero errors.
116
+ 2. Run `npm run lint` from the UI Bundle directory — must pass with zero errors.
117
+ 3. Run `npm run dev` to start the dev server so the user can verify the result.
113
118
 
119
+ Do not consider a task complete until all three steps have been run successfully.
114
120
  ## Development conventions
115
121
 
116
122
  ### UI
117
123
 
118
- - **Component library:** shadcn/ui primitives in `src/components/ui/`. Always use these over raw HTML equivalents.
124
+ - **Component library:** shadcn/ui primitives in `src/components/ui/`. Always use these over raw HTML equivalents. **Before importing any component, verify both the file exists in `src/components/ui/` AND the named export exists within that file.** Never assume a component or export is available — read the file to confirm the exact exports before importing.
119
125
  - **Styling:** Tailwind CSS only. No inline `style={{}}`. Use `cn()` from `@/lib/utils` for conditional classes.
120
126
  - **Icons:** Lucide React.
121
127
  - **Path alias:** `@/*` maps to `src/*`. Use it for all imports.
@@ -140,6 +146,10 @@ Used for SFDX metadata tooling. Scripts here target LWC/Aura, not the React app.
140
146
 
141
147
  ### Data access (Salesforce)
142
148
 
149
+ **Before writing any code that connects to Salesforce, you MUST invoke the `using-ui-bundle-salesforce-data` skill. Do not write any data access code without consulting it first.**
150
+
151
+ This applies to: GraphQL queries/mutations, REST calls, SDK initialization, custom hooks that fetch data, or any code that imports from `@salesforce/sdk-data`.
152
+
143
153
  - **All data access uses the Data SDK** (`@salesforce/sdk-data`) via `createDataSDK()`.
144
154
  - **Never** use `fetch()` or `axios` directly for Salesforce data.
145
155
  - **GraphQL is preferred** for record operations (`sdk.graphql`). Use `sdk.fetch` only when GraphQL cannot cover the case (UI API REST, Apex REST, Connect REST, Einstein LLM).
@@ -149,25 +159,74 @@ Used for SFDX metadata tooling. Scripts here target LWC/Aura, not the React app.
149
159
  - Use `__SF_API_VERSION__` global for API version in REST calls.
150
160
  - **Blocked APIs:** Enterprise REST query endpoint (`/query` with SOQL), `@AuraEnabled` Apex, Chatter API.
151
161
 
162
+ #### Permitted APIs
163
+
164
+ | API | Method | Endpoints / Use Case |
165
+ |-----|--------|----------------------|
166
+ | GraphQL | `sdk.graphql` | All record queries and mutations via `uiapi { }` namespace |
167
+ | UI API REST | `sdk.fetch` | `/services/data/v{ver}/ui-api/records/{id}` |
168
+ | Apex REST | `sdk.fetch` | `/services/apexrest/{resource}` |
169
+ | Connect REST | `sdk.fetch` | `/services/data/v{ver}/connect/...` |
170
+ | Einstein LLM | `sdk.fetch` | `/services/data/v{ver}/einstein/llm/prompt/generations` |
171
+
172
+ Any endpoint not listed above is not permitted.
173
+
174
+ #### GraphQL non-negotiable rules
175
+
176
+ 1. **Schema is the single source of truth** — every entity and field name must be confirmed via the schema search script before use. Never guess.
177
+ 2. **`@optional` on all record fields** — FLS causes entire queries to fail if any field is inaccessible. Apply to every scalar, parent, and child relationship field.
178
+ 3. **Correct mutation syntax** — mutations wrap under `uiapi(input: { allOrNone: true/false })`, not bare `uiapi { ... }`.
179
+ 4. **Explicit `first:` in every query** — omitting it silently defaults to 10 records. Always include `pageInfo { hasNextPage endCursor }` for paginated queries.
180
+ 5. **SOQL-derived execution limits** — max 10 subqueries per request, max 5 levels of child-to-parent traversal, max 1 level parent-to-child, max 2,000 records per subquery.
181
+ 6. **HTTP 200 does not mean success** — Salesforce returns HTTP 200 even on failure. Always check the `errors` array in the response body.
182
+
183
+ #### GraphQL inline queries
184
+ Must use the `gql` template tag from `@salesforce/sdk-data` — plain template strings bypass `@graphql-eslint` schema validation. For complex queries, use external `.graphql` files with codegen.
185
+
186
+ #### Current user info
187
+ Use GraphQL (`uiapi { currentUser { Id Name { value } } }`), not Chatter (`/chatter/users/me`).
188
+
189
+ #### Schema file (`schema.graphql`)
190
+
191
+ The `schema.graphql` file at the SFDX project root is the source of truth for all entity and field name lookups. It is 265K+ lines — never open or parse it directly. Use the schema search script instead.
192
+
193
+ - **Generate/refresh:** Run `npm run graphql:schema` from the UI bundle directory
194
+ - **When to regenerate:** After any metadata deployment that changes objects, fields, or permission sets
195
+ - **Custom objects** only appear in the schema after metadata deployment AND permission set assignment
196
+ - **After regenerating:** Always re-run `npm run graphql:codegen` and `npm run build` (schema changes may affect generated types)
197
+
152
198
  ### CSP trusted sites
153
199
 
154
200
  Any external domain the app calls (APIs, CDNs, fonts) must have a `.cspTrustedSite-meta.xml` file under `<sfdx-source>/cspTrustedSites/`. Unregistered domains are blocked at runtime. Each subdomain needs its own entry. URLs must be HTTPS with no trailing slash, no path, and no wildcards.
155
201
 
202
+ ## Building and launching the app
203
+
204
+ All build, dev, and test commands run from the UI Bundle directory. Before running any command, read the UI Bundle's `package.json` to confirm available scripts — do not assume script names.
205
+
206
+ Typical scripts found in the UI Bundle:
207
+
208
+ | Command | Purpose |
209
+ |---------|---------|
210
+ | `npm run build` | TypeScript check + Vite production build |
211
+ | `npm run dev` | Start Vite dev server |
212
+ | `npm run lint` | ESLint |
213
+ | `npm run test` | Vitest unit tests |
214
+ | `npm run graphql:codegen` | Generate GraphQL types |
215
+ | `npm run graphql:schema` | Fetch GraphQL schema from org |
216
+
217
+ If dependencies have not been installed yet, run `npm install` in the UI Bundle directory first. Alternatively, run `npm run sf-project-setup` from the project root — it resolves the UI Bundle directory automatically and runs install, build, and dev in sequence.
218
+
219
+ **After any JavaScript or TypeScript change, run `npm run build` to validate the change.** If the build fails, read the error output, identify the cause, fix it, and run `npm run build` again. Do not move on until the build passes.
220
+
156
221
  ## Deploying
157
222
 
158
223
  **Deployment order matters.** Metadata (objects, permission sets) must be deployed before fetching the GraphQL schema. After any metadata deployment that changes objects, fields, or permissions, re-run schema fetch and codegen.
159
224
 
160
- **Recommended sequence:**
225
+ **Deployment steps:**
161
226
 
162
227
  1. Authenticate to the target org
163
228
  2. Build the UI Bundle (`npm run build` in the UI Bundle directory)
164
229
  3. Deploy metadata (`sf project deploy start --source-dir <packageDir> --target-org <alias>`)
165
- 4. Assign permission sets
166
- 5. Import data (only with user confirmation)
167
- 6. Fetch GraphQL schema + run codegen (`npm run graphql:schema && npm run graphql:codegen`)
168
- 7. Rebuild the UI Bundle (schema changes may affect generated types)
169
-
170
- **Or use the one-time org setup:** `node scripts/org-setup.mjs --target-org <alias>`
171
230
 
172
231
  ```bash
173
232
  # Deploy UI Bundle only
@@ -177,17 +236,17 @@ sf project deploy start --source-dir <sfdx-source>/ui-bundles --target-org <alia
177
236
  sf project deploy start --source-dir <packageDir> --target-org <alias>
178
237
  ```
179
238
 
180
- ## Skills
239
+ **Do not open the app after deployment.** Do not run `sf org open`, do not guess the runtime URL, and do not construct paths like `/s/<appName>`. Deployment is complete when the `sf project deploy start` command succeeds.
181
240
 
182
- Check for available skills before implementing any of the following:
241
+ ## Post-deployment org setup
183
242
 
184
- | Area | When to consult |
185
- |------|----------------|
186
- | UI generation | Building pages, components, modifying header/footer/layout |
187
- | Salesforce data access | Reading/writing records, GraphQL queries, REST calls |
188
- | Metadata and deployment | Scaffolding apps, configuring CSP, deployment sequencing |
189
- | Feature installation | Before building something from scratch check if a pre-built feature exists |
190
- | File upload | Adding file upload with Salesforce ContentVersion |
191
- | Agentforce conversation | Adding or modifying the Agentforce chat widget |
243
+ These steps apply after a fresh deployment to configure the org. They are not part of routine deployment.
244
+
245
+ 1. Assign permission sets
246
+ 2. Import data (only with user confirmation)
247
+ 3. Fetch GraphQL schema + run codegen (`npm run graphql:schema && npm run graphql:codegen`)
248
+ 4. Rebuild the UI Bundle (`npm run build`schema changes may affect generated types)
249
+
250
+ ## Skills
192
251
 
193
- Skills are the authoritative source for detailed patterns, constraints, and code examples in each area. This file provides project-level orientation; skills provide implementation depth.
252
+ Before starting any task, check whether a relevant skill exists. If one does, invoke it before writing any code or making any implementation decision. Skills are the authoritative source for patterns, constraints, and code examples.
package/dist/CHANGELOG.md CHANGED
@@ -3,6 +3,22 @@
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.119.2](https://github.com/salesforce-experience-platform-emu/webapps/compare/v1.119.1...v1.119.2) (2026-03-31)
7
+
8
+ **Note:** Version bump only for package @salesforce/ui-bundle-template-base-sfdx-project
9
+
10
+
11
+
12
+
13
+
14
+ ## [1.119.1](https://github.com/salesforce-experience-platform-emu/webapps/compare/v1.119.0...v1.119.1) (2026-03-31)
15
+
16
+ **Note:** Version bump only for package @salesforce/ui-bundle-template-base-sfdx-project
17
+
18
+
19
+
20
+
21
+
6
22
  # [1.119.0](https://github.com/salesforce-experience-platform-emu/webapps/compare/v1.118.4...v1.119.0) (2026-03-31)
7
23
 
8
24
  **Note:** Version bump only for package @salesforce/ui-bundle-template-base-sfdx-project
package/dist/README.md CHANGED
@@ -2,51 +2,180 @@
2
2
 
3
3
  A property rental sample React UI Bundle for Salesforce Experience Cloud. Demonstrates property listings, maintenance requests, and a dashboard with an app shell designed for external-facing deployment. Built with React, Vite, TypeScript, and Tailwind/shadcn.
4
4
 
5
- ## What's included
5
+ ## Table of Contents
6
+
7
+ 1. [What's Included](#whats-included)
8
+ 2. [Prerequisites](#prerequisites)
9
+ 3. [Quick Start (Automated)](#quick-start-automated)
10
+ 4. [Step-by-Step Setup](#step-by-step-setup)
11
+ - [1. Install Dependencies](#1-install-dependencies)
12
+ - [2. Authenticate Your Org](#2-authenticate-your-org)
13
+ - [3. Deploy Metadata](#3-deploy-metadata)
14
+ - [4. Assign Permission Sets](#4-assign-permission-sets)
15
+ - [5. Import Sample Data](#5-import-sample-data)
16
+ - [6. Generate GraphQL Types](#6-generate-graphql-types)
17
+ - [7. Rebuild the UI Bundle](#7-rebuild-the-ui-bundle)
18
+ - [8. Deploy the UI Bundle](#8-deploy-the-ui-bundle)
19
+ 5. [Org Configuration](#org-configuration)
20
+ - [Step 1: Assign a Role to Your Admin User](#step-1-assign-a-role-to-your-admin-user)
21
+ - [Step 2: Create and Configure the Community Profile](#step-2-create-and-configure-the-community-profile)
22
+ - [Step 3: Configure the Experience Cloud Site](#step-3-configure-the-experience-cloud-site)
23
+ - [Step 4: Configure the Guest User Profile](#step-4-configure-the-guest-user-profile)
24
+ - [Step 5: Create Criteria-Based Sharing Rules for Guest Access](#step-5-create-criteria-based-sharing-rules-for-guest-access)
25
+ 6. [Local Development](#local-development)
26
+ 7. [Resources](#resources)
27
+
28
+ ---
29
+
30
+ ## What's Included
6
31
 
7
32
  | Path | Description |
8
33
  | ----------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
9
34
  | `force-app/main/default/uiBundles/propertyrentalapp/` | React UI Bundle (source, config, tests) |
10
- | `force-app/main/default/objects/` | 17 custom objects — Agent\_\_c, Application\_\_c, KPI_Snapshot\_\_c, Lease\_\_c, Maintenance_Request\_\_c, Maintenance_Worker\_\_c, Notification\_\_c, Payment\_\_c, Property\_\_c, Property_Cost\_\_c, Property_Feature\_\_c, Property_Image\_\_c, Property_Listing\_\_c, Property_Management_Company\_\_c, Property_Owner\_\_c, Property_Sale\_\_c, Tenant\_\_c |
35
+ | `force-app/main/default/objects/` | 17 custom objects — `Agent__c`, `Application__c`, `KPI_Snapshot__c`, `Lease__c`, `Maintenance_Request__c`, `Maintenance_Worker__c`, `Notification__c`, `Payment__c`, `Property__c`, `Property_Cost__c`, `Property_Feature__c`, `Property_Image__c`, `Property_Listing__c`, `Property_Management_Company__c`, `Property_Owner__c`, `Property_Sale__c`, `Tenant__c` |
11
36
  | `force-app/main/default/layouts/` | Page layouts for each custom object |
12
- | `force-app/main/default/permissionsets/` | `Property_Management_Access` permission set |
13
- | `force-app/main/default/classes/` | Apex classes — `MaintenanceRequestListAction`, `MaintenanceRequestUpdatePriorityAction` |
14
- | `force-app/main/default/cspTrustedSites/` | CSP trusted sites for external resources (Google Fonts, Pexels, Unsplash, GitHub Avatars) |
37
+ | `force-app/main/default/permissionsets/` | `Property_Management_Access` (full admin access) and `Tenant_Maintenance_Access` (scoped tenant access) |
38
+ | `force-app/main/default/classes/` | Apex classes — `MaintenanceRequestTriggerHandler`, `TenantTriggerHandler`, `UIBundleAuthUtils`, `UIBundleChangePassword`, `UIBundleForgotPassword`, `UIBundleLogin`, `UIBundleAppRegistration` |
39
+ | `force-app/main/default/triggers/` | Apex triggers `MaintenanceRequestTrigger`, `TenantTrigger` |
40
+ | `force-app/main/default/cspTrustedSites/` | CSP trusted sites for external resources (Google Fonts, Pexels, Unsplash, GitHub Avatars, OpenStreetMap, Open-Meteo) |
15
41
  | `force-app/main/default/data/` | Sample data (JSON) for all objects, importable via `sf data import tree` |
16
42
  | `force-app/main/default/digitalExperienceConfigs/` | Experience Cloud site configuration |
17
43
  | `force-app/main/default/digitalExperiences/` | Experience Cloud site definition |
18
- | `force-app/main/default/networks/` | Experience Cloud network |
19
- | `force-app/main/default/sites/` | Salesforce site |
44
+ | `force-app/main/default/networks/` | Experience Cloud network metadata |
45
+ | `force-app/main/default/sites/` | Salesforce Sites configuration |
46
+
47
+ ---
48
+
49
+ ## Prerequisites
50
+
51
+ Before you begin, ensure the following are in place.
52
+
53
+ ### Tools
54
+
55
+ | Tool | Minimum Version | Install |
56
+ | ----------------------------------------------------------------------------- | ------------------ | ----------------------------------- |
57
+ | [Salesforce CLI (`sf`)](https://developer.salesforce.com/tools/salesforcecli) | v2+ | `npm install -g @salesforce/cli` |
58
+ | [Node.js](https://nodejs.org/) | v22+ | [nodejs.org](https://nodejs.org/) |
59
+ | [Git](https://git-scm.com/) | Any recent version | [git-scm.com](https://git-scm.com/) |
60
+
61
+ Verify your Salesforce CLI version with:
62
+
63
+ ```bash
64
+ sf --version
65
+ ```
66
+
67
+ ### Salesforce Org Requirements
68
+
69
+ This project requires a Salesforce org with the following features and licenses. **Developer Edition orgs do not include these by default.** Use a sandbox, an org configured with add-ons, or request a pre-configured org from your Salesforce account team.
70
+
71
+ - **Digital Experiences (Experience Cloud) enabled** — required to deploy and run the Experience Cloud site. To verify, go to **Setup > Digital Experiences > Settings** and confirm "Enable Digital Experiences" is checked.
72
+ - **Customer Community** or **Customer Community Plus** user licenses — required to create community (portal) users. Customer Community Plus is recommended if you need record-level sharing via sharing rules.
73
+ - **Salesforce Sites enabled** — required for guest user access.
20
74
 
21
- ## Getting started
75
+ > **Note:** If Digital Experiences is not yet enabled in your org, go to **Setup > Digital Experiences > Settings**, check "Enable Digital Experiences", set a domain name, and save. This action cannot be undone.
22
76
 
23
- Navigate to the UI Bundle and install dependencies:
77
+ ---
78
+
79
+ ## Quick Start (Automated)
80
+
81
+ Two npm scripts at the project root streamline getting started and deployment.
82
+
83
+ **`npm run sf-project-setup`** — installs the UI Bundle dependencies, builds the app, and starts the dev server (see [Local Development](#local-development)).
84
+
85
+ **`npm run setup`** — automates the full setup: login, deploy metadata, assign permission sets, import sample data, fetch the GraphQL schema, run codegen, build the UI Bundle, and optionally launch the dev server:
86
+
87
+ ```bash
88
+ npm run setup -- --target-org <alias>
89
+ ```
90
+
91
+ Replace `<alias>` with your target org alias or username. Running without flags presents an interactive step picker. Pass `--yes` to skip it and run all steps immediately:
92
+
93
+ ```bash
94
+ npm run setup -- --target-org <alias> --yes
95
+ ```
96
+
97
+ ### Common Options
98
+
99
+ | Option | Description |
100
+ | ------------------------- | ------------------------------------------------------------------------------------ |
101
+ | `--skip-login` | Skip browser login (auto-skipped if org is already connected) |
102
+ | `--skip-deploy` | Skip the metadata deploy step |
103
+ | `--skip-permset` | Skip permission set assignment |
104
+ | `--skip-data` | Skip data preparation and import |
105
+ | `--skip-graphql` | Skip GraphQL schema fetch and codegen |
106
+ | `--skip-ui-bundle-build` | Skip `npm install` and UI Bundle build |
107
+ | `--skip-dev` | Do not launch the dev server at the end |
108
+ | `--permset-name <name>` | Assign only a specific permission set (repeatable). Default: all sets in the project |
109
+ | `--ui-bundle-name <name>` | UI Bundle folder name under `uiBundles/` (default: auto-detected) |
110
+ | `-y, --yes` | Skip interactive step picker and run all enabled steps immediately |
111
+
112
+ For a full list of options:
113
+
114
+ ```bash
115
+ npm run setup -- --help
116
+ ```
117
+
118
+ > **After the automated setup completes**, proceed to [Org Configuration](#org-configuration) for the manual steps that cannot be automated via CLI (profile cloning, site member configuration, guest user setup, and publishing the Experience Cloud site).
119
+
120
+ ---
121
+
122
+ ## Step-by-Step Setup
123
+
124
+ Use this section if you prefer to run each step manually, or if the automated script is not available.
125
+
126
+ ### 1. Install Dependencies
127
+
128
+ Install root-level project dependencies:
129
+
130
+ ```bash
131
+ npm install
132
+ ```
133
+
134
+ Install the UI Bundle dependencies and build it:
24
135
 
25
136
  ```bash
26
137
  cd force-app/main/default/uiBundles/propertyrentalapp
27
138
  npm install
28
- npm run dev
139
+ npm run build
140
+ cd -
29
141
  ```
30
142
 
31
- Opens at http://localhost:5173 by default. For build and test instructions, see the [UI Bundle README](force-app/main/default/uiBundles/propertyrentalapp/README.md).
143
+ This produces the static bundle artifacts that are packaged into the Salesforce metadata. Having them built now means any deploy option in [Step 3](#3-deploy-metadata) is ready to run without an additional build step.
32
144
 
33
- ## Deploy
145
+ ### 2. Authenticate Your Org
34
146
 
35
- ### Deploy everything (metadata + Experience Cloud site + UI Bundle)
147
+ Log in to your target org using the Salesforce CLI. This opens a browser window for OAuth authentication:
36
148
 
37
149
  ```bash
38
- cd force-app/main/default/uiBundles/propertyrentalapp && npm install && npm run build && cd -
39
- sf project deploy start --source-dir force-app --target-org <alias>
150
+ sf org login web --alias <alias>
40
151
  ```
41
152
 
42
- ### Deploy the UI Bundle only
153
+ To verify the login was successful:
43
154
 
44
155
  ```bash
45
- cd force-app/main/default/uiBundles/propertyrentalapp && npm install && npm run build && cd -
46
- sf project deploy start --source-dir force-app/main/default/ui-bundles --target-org <alias>
156
+ sf org display --target-org <alias>
47
157
  ```
48
158
 
49
- ### Deploy metadata only (objects, layouts, permission sets, Apex classes)
159
+ If you are working with a sandbox, use:
160
+
161
+ ```bash
162
+ sf org login web --alias <alias> --instance-url https://test.salesforce.com
163
+ ```
164
+
165
+ ### 3. Deploy Metadata
166
+
167
+ #### Option A: Deploy Everything (metadata + Experience Cloud site + UI Bundle)
168
+
169
+ Build the UI Bundle first, then deploy all source directories in a single command:
170
+
171
+ ```bash
172
+ cd force-app/main/default/uiBundles/propertyrentalapp && npm run build && cd -
173
+ sf project deploy start --source-dir force-app --target-org <alias>
174
+ ```
175
+
176
+ #### Option B: Deploy Metadata Only (objects, layouts, permission sets, Apex)
177
+
178
+ Use this approach for an initial deploy to verify metadata before deploying the Experience Cloud site:
50
179
 
51
180
  ```bash
52
181
  sf project deploy start \
@@ -54,10 +183,12 @@ sf project deploy start \
54
183
  --source-dir force-app/main/default/layouts \
55
184
  --source-dir force-app/main/default/permissionsets \
56
185
  --source-dir force-app/main/default/classes \
186
+ --source-dir force-app/main/default/triggers \
187
+ --source-dir force-app/main/default/cspTrustedSites \
57
188
  --target-org <alias>
58
189
  ```
59
190
 
60
- ### Deploy Experience Cloud site only
191
+ #### Option C: Deploy Experience Cloud Site Only
61
192
 
62
193
  ```bash
63
194
  sf project deploy start \
@@ -68,45 +199,307 @@ sf project deploy start \
68
199
  --target-org <alias>
69
200
  ```
70
201
 
71
- Replace `<alias>` with your target org alias.
202
+ #### Option D: Deploy the UI Bundle Only
203
+
204
+ ```bash
205
+ cd force-app/main/default/uiBundles/propertyrentalapp && npm run build && cd -
206
+ sf project deploy start --source-dir force-app/main/default/uiBundles --target-org <alias>
207
+ ```
208
+
209
+ > **Deployment order matters.** Deploy metadata (Option B) before deploying the Experience Cloud site (Option C). The site configuration depends on the custom objects and classes being present in the org.
210
+
211
+ ### 4. Assign Permission Sets
212
+
213
+ Two permission sets are included in this project:
214
+
215
+ | Permission Set | Purpose | Assign To |
216
+ | ---------------------------- | ------------------------------------------------------------------------------------------------------- | ------------------------------- |
217
+ | `Property_Management_Access` | Full CRUD access to all custom objects. Intended for property managers and admin users. | Internal users managing the app |
218
+ | `Tenant_Maintenance_Access` | Scoped read/write access for tenants. Allows creating and updating their own maintenance requests only. | Tenant community users |
72
219
 
73
- ## Import sample data
220
+ Assign permission sets using the CLI:
221
+
222
+ ```bash
223
+ # Assign Property_Management_Access to a specific user
224
+ sf org assign permset --name Property_Management_Access --on-behalf-of <username> --target-org <alias>
225
+
226
+ # Assign Tenant_Maintenance_Access to a tenant user
227
+ sf org assign permset --name Tenant_Maintenance_Access --on-behalf-of <username> --target-org <alias>
228
+ ```
229
+
230
+ To assign to multiple users, repeat the command for each user, or use the automated script which assigns all permission sets to the running user by default.
231
+
232
+ ### 5. Import Sample Data
233
+
234
+ Once the metadata has been successfully deployed:
74
235
 
75
236
  ```bash
76
237
  sf data import tree --plan force-app/main/default/data/data-plan.json --target-org <alias>
77
238
  ```
78
239
 
79
- ## Using org-setup.mjs
240
+ The data plan imports records in dependency order: Contacts, Agents, Maintenance Workers, Properties, Tenants, Applications, Maintenance Requests, Notifications, Property Management Companies, Property Owners, Leases, Property Sales, Property Costs, Payments, KPI Snapshots, Property Listings, Property Images, and Property Features.
241
+
242
+ > **Note:** If you re-run the import, duplicate records will be created. Wipe existing records first or use the `--upsert` flag if your plan supports it.
243
+
244
+ ### 6. Generate GraphQL Types
245
+
246
+ After metadata is deployed, generate the GraphQL schema and TypeScript types for the UI Bundle. These are used to provide type-safe queries against the Salesforce GraphQL API.
247
+
248
+ ```bash
249
+ cd force-app/main/default/uiBundles/propertyrentalapp
250
+ npm run graphql:schema # Fetches schema from org → outputs schema.graphql
251
+ npm run graphql:codegen # Generates TypeScript types → updates src/api/graphql-operations-types.ts
252
+ cd -
253
+ ```
254
+
255
+ > **Prerequisite:** The org must be authenticated and metadata must already be deployed before running these commands, as the schema is generated from the org's live metadata.
256
+
257
+ ### 7. Rebuild the UI Bundle
258
+
259
+ Step 6 updates the generated GraphQL types in the UI Bundle source. Rebuild the app to compile those changes into the bundle before deploying:
260
+
261
+ ```bash
262
+ cd force-app/main/default/uiBundles/propertyrentalapp
263
+ npm run build
264
+ cd -
265
+ ```
80
266
 
81
- When this app is built (e.g. from the monorepo or from a published package), an `org-setup.mjs` script is included at the project root. It runs the full setup in one go: login (if needed), deploy metadata, assign the `Property_Management_Access` permission set, prepare and import sample data, fetch GraphQL schema and run codegen, build the UI Bundle, and optionally start the dev server.
267
+ ### 8. Deploy the UI Bundle
82
268
 
83
- Run from the **project root** (the directory that contains `force-app/`, `sfdx-project.json`, and `org-setup.mjs`):
269
+ Once the build is complete, deploy the UI Bundle to your org:
84
270
 
85
271
  ```bash
86
- node org-setup.mjs --target-org <alias>
272
+ sf project deploy start --source-dir force-app/main/default/uiBundles --target-org <alias>
87
273
  ```
88
274
 
89
- Common options:
275
+ ---
276
+
277
+ ## Org Configuration
278
+
279
+ The following steps must be completed manually in the Salesforce Setup UI. They configure Experience Cloud, user profiles, and data sharing for guest and community users. Complete these steps **after** the metadata and UI Bundle have been deployed.
280
+
281
+ > **License requirement:** Your org must have **Customer Community** or **Customer Community Plus** user licenses available before you can complete these steps. Customer Community Plus licenses are required if you need ownership-based record sharing (Private OWD with sharing rules). Verify available licenses at **Setup > Company Settings > Company Information**, in the "User Licenses" section.
282
+
283
+ ---
284
+
285
+ ### Step 1: Assign a Role to Your Admin User
286
+
287
+ Salesforce requires that the org's admin user has a role assigned before Experience Cloud sites can be created or managed. If your admin user already has a role, skip this step.
288
+
289
+ 1. Go to **Setup > Users > Roles**.
290
+ 2. Click **Set Up Roles**.
291
+ 3. Click **Add Role**. Provide a label (e.g., `CEO`) and save.
292
+ 4. From the role hierarchy, click the role you just created, then click **Assign Users to Role**.
293
+ 5. Add your system administrator user and click **Save**.
294
+
295
+ > **Why this matters:** Salesforce prevents users without a role in the hierarchy from owning Experience Cloud sites. This is a platform-level requirement, not specific to this app.
296
+
297
+ ---
298
+
299
+ ### Step 2: Create and Configure the Community Profile
300
+
301
+ Community users require a profile that is based on one of the standard community profile templates. You will clone one of these templates and configure its permissions for this app.
302
+
303
+ #### 2a. Clone the Base Profile
304
+
305
+ 1. Go to **Setup > Users > Profiles**.
306
+ 2. Locate either **Customer Community User** or **Customer Community Plus User**.
307
+ - Choose **Customer Community Plus User** if you need ownership-based record-level sharing (recommended).
308
+ 3. Click **Clone** next to the profile. Give it a descriptive name such as `Property Rental Tenant`.
309
+ 4. Click **Save**.
310
+
311
+ #### 2b. Edit the Cloned Profile
312
+
313
+ Open the newly cloned profile and configure the following settings.
314
+
315
+ **Administrative Permissions:**
316
+
317
+ | Permission | Setting |
318
+ | ----------- | ------- |
319
+ | API Enabled | Checked |
320
+
321
+ **Custom Object Permissions:**
322
+
323
+ Set the following object-level access. After saving, also review field-level security for each object to ensure all relevant fields are readable.
324
+
325
+ | Object | Read | Create | Edit | Delete |
326
+ | :--------------------------------------------------------------- | :--: | :----: | :--: | :----: |
327
+ | Agents (`Agent__c`) | ✓ | | | |
328
+ | Applications (`Application__c`) | ✓ | ✓ | ✓ | ✓ |
329
+ | KPI Snapshots (`KPI_Snapshot__c`) | ✓ | | | |
330
+ | Leases (`Lease__c`) | ✓ | | | |
331
+ | Maintenance Requests (`Maintenance_Request__c`) | ✓ | ✓ | ✓ | ✓ |
332
+ | Maintenance Workers (`Maintenance_Worker__c`) | ✓ | | ✓ | |
333
+ | Notifications (`Notification__c`) | ✓ | | | |
334
+ | Payments (`Payment__c`) | ✓ | | | |
335
+ | Properties (`Property__c`) | ✓ | | | |
336
+ | Property Costs (`Property_Cost__c`) | ✓ | | | |
337
+ | Property Features (`Property_Feature__c`) | ✓ | | | |
338
+ | Property Images (`Property_Image__c`) | ✓ | | | |
339
+ | Property Listings (`Property_Listing__c`) | ✓ | | | |
340
+ | Property Management Companies (`Property_Management_Company__c`) | ✓ | | | |
341
+ | Property Owners (`Property_Owner__c`) | ✓ | | | |
342
+ | Property Sales (`Property_Sale__c`) | ✓ | | | |
343
+ | Tenants (`Tenant__c`) | ✓ | | | |
344
+
345
+ **Apex Class Access:**
346
+
347
+ Scroll to the **Enabled Apex Class Access** section and add the following classes. These classes handle authentication flows called by the UI Bundle:
348
+
349
+ - `UIBundleAuthUtils`
350
+ - `UIBundleChangePassword`
351
+ - `UIBundleForgotPassword`
352
+
353
+ > **Note:** `MaintenanceRequestTriggerHandler` and `TenantTriggerHandler` are trigger handler classes that run in system context when DML operations are performed. They do not need to be explicitly enabled in community profiles.
354
+
355
+ #### 2c. Configure View All for Property, Property Listing, Maintenance Worker
356
+
357
+ Tenants need to see all available properties and listings, not just records they own. Enable **View All** on these three objects for the community profile:
358
+
359
+ 1. Go to **Setup > Object Manager**.
360
+ 2. Search for and open **Property**.
361
+ 3. Click **Object Access** in the left navigation.
362
+ 4. Set the profile's access to allow viewing all records.
363
+ 5. Repeat for **Property Listing** and **Maintenance Worker**.
364
+
365
+ - **Note**: the access for the **Maintenance Worker** is required for the `MaintenanceRequestTriggerHandler` to auto assign a worker on submission
366
+
367
+ #### 2d. Configure Field Level Security for the Application
368
+
369
+ 1. Go to **Setup > Object Manager**.
370
+ 2. Search for and open **Application**.
371
+ 3. Click **Fields and Relationships** in the left navigation.
372
+ 4. Select the `References__c` field, then click **Set Field-Level Security**.
373
+ 5. Enable the field to be "Visible" to the community profile.
374
+ 6. Click **Save**.
375
+ 7. Repeat for the following fields:
376
+
377
+ - `Property__c`
378
+ - `Employment__c`
379
+ - `User__c`
380
+ - `Status__c`
381
+ - `Start_Date__c`
382
+
383
+ ---
90
384
 
91
- | Option | Description |
92
- | ------------------------ | ---------------------------------------------------------------- |
93
- | `--skip-login` | Skip browser login (org already authenticated) |
94
- | `--skip-data` | Skip data preparation and import |
95
- | `--skip-graphql` | Skip GraphQL schema fetch and codegen |
96
- | `--skip-ui-bundle-build` | Skip `npm install` and UI Bundle build |
97
- | `--skip-dev` | Do not start the dev server at the end |
98
- | `--permset <name>` | Permission set to assign (default: `Property_Management_Access`) |
99
- | `--app <name>` | Web app folder name when multiple exist |
385
+ ### Step 3: Configure the Experience Cloud Site
100
386
 
101
- For all options: `node org-setup.mjs --help`.
387
+ After deploying the Experience Cloud site metadata, configure its membership and self-registration settings.
388
+
389
+ 1. In the App Launcher, open the **Digital Experiences** app (search for it if needed).
390
+ 2. Find the **Property Rental App** site and click **Workspaces**.
391
+ 3. Click the **Administration** tile.
392
+
393
+ #### Members
394
+
395
+ 1. In the left navigation, click **Members**.
396
+ 2. Under **Select Profiles**, add the cloned community profile (`Property Rental Tenant`) to the **Selected Profiles** list.
397
+ 3. Click **Save**.
398
+
399
+ #### Login & Registration
400
+
401
+ 1. In the left navigation, click **Login & Registration**.
402
+ 2. Check **Allow customers and partners to self-register**.
403
+ 3. Under **Registration**, set:
404
+ - **Profile**: Select your cloned community profile (`Property Rental Tenant`).
405
+ - **Account**: Select or create an account record to associate self-registered users with (e.g., a generic "Portal Account").
406
+ 4. Click **Save**.
407
+
408
+ #### Guest User Profile
409
+
410
+ The site's guest user profile controls what unauthenticated visitors can see. You will configure this profile in [Step 4](#step-4-configure-the-guest-user-profile). To navigate to it:
411
+
412
+ 1. In the **Administration** area, click **Preferences** in the left navigation.
413
+ 2. Click the link next to **Guest user profile** to open it directly.
414
+
415
+ ---
416
+
417
+ ### Step 4: Configure the Guest User Profile
418
+
419
+ The guest user profile is auto-generated by Salesforce when an Experience Cloud site is created. It controls what unauthenticated visitors can access. Configure it to allow browsing of available properties only.
420
+
421
+ Open the guest user profile (linked from the site's Preferences page, as described above) and apply the following settings.
422
+
423
+ **Administrative Permissions:**
424
+
425
+ | Permission | Setting |
426
+ | ----------- | ------- |
427
+ | API Enabled | Checked |
428
+
429
+ > **Security note:** Enabling API access for the guest profile is required for the UI Bundle to make GraphQL API calls on behalf of unauthenticated users. Ensure that object-level and field-level permissions are restrictive (as listed below) to avoid exposing sensitive data.
430
+
431
+ **Custom Object Permissions:**
432
+
433
+ Guest users can only browse available properties and listings. All other objects are restricted.
434
+
435
+ | Object | Read | Create | Edit | Delete |
436
+ | :---------------------------------------- | :--: | :----: | :--: | :----: |
437
+ | Properties (`Property__c`) | ✓ | | | |
438
+ | Property Costs (`Property_Cost__c`) | ✓ | | | |
439
+ | Property Features (`Property_Feature__c`) | ✓ | | | |
440
+ | Property Images (`Property_Image__c`) | ✓ | | | |
441
+ | Property Listings (`Property_Listing__c`) | ✓ | | | |
442
+ | All other objects | — | — | — | — |
443
+
444
+ **Apex Class Access:**
445
+
446
+ Add the following classes. These are required for the self-registration and login flows available to unauthenticated users:
447
+
448
+ - `UIBundleLogin`
449
+ - `UIBundleRegistration`
450
+
451
+ ---
452
+
453
+ ### Step 5: Create Criteria-Based Sharing Rules for Guest Access
454
+
455
+ By default, Salesforce does not expose any records to guest users. You must create **criteria-based sharing rules** to make available properties and listings visible to unauthenticated site visitors.
456
+
457
+ > **Organization-Wide Defaults (OWD):** Criteria-based sharing rules for guest users only work correctly when the object's OWD is set to **Public Read Only** or **Private**. Verify your OWD settings at **Setup > Sharing Settings** before proceeding.
458
+
459
+ #### Create a Sharing Rule for Properties
460
+
461
+ 1. Go to **Setup > Sharing Settings**.
462
+ 2. Scroll to the **Property Sharing Rules** section and click **New**.
463
+ 3. Configure the rule:
464
+ - **Label**: `Available Properties for Guest Users`
465
+ - **Rule Type**: Select **Based on criteria**
466
+ - **Criteria**: `Status Equals Available` (adjust the field and value to match your data model)
467
+ - **Share with**: Select **Guests of the Property Rental App site** (the guest user group for your Experience Cloud site)
468
+ - **Access Level**: `Read Only`
469
+ 4. Click **Save**.
470
+
471
+ #### Create a Sharing Rule for Property Listings
472
+
473
+ Repeat the same steps in the **Property Listing Sharing Rules** section:
474
+
475
+ - **Label**: `Available Property Listings for Guest Users`
476
+ - **Rule Type**: `Based on criteria`
477
+ - **Criteria**: Match listings you want to expose (e.g., `Status Equals Active`)
478
+ - **Share with**: `Guests of the Property Rental App site`
479
+ - **Access Level**: `Read Only`
480
+
481
+ > **Note:** The "Guests of [site name]" option only appears in the sharing rule target list after the Experience Cloud site has been created and saved. If you do not see it, confirm the site metadata has been deployed and the site exists in the org.
482
+
483
+ ---
484
+
485
+ ## Local Development
486
+
487
+ Install project dependencies and start the dev server:
488
+
489
+ ```bash
490
+ npm install
491
+ npm run sf-project-setup
492
+ ```
102
493
 
103
- ## Configure Your Salesforce DX Project
494
+ This installs the UI Bundle dependencies, builds the app, and opens the dev server at `http://localhost:5173`. For manual build and test instructions, see the [UI Bundle README](force-app/main/default/uiBundles/propertyrentalapp/README.md).
104
495
 
105
- The `sfdx-project.json` file contains useful configuration information for your project. See [Salesforce DX Project Configuration](https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_ws_config.htm) in the _Salesforce DX Developer Guide_ for details about this file.
496
+ ---
106
497
 
107
- ## Read All About It
498
+ ## Resources
108
499
 
109
500
  - [Salesforce Extensions Documentation](https://developer.salesforce.com/tools/vscode/)
110
501
  - [Salesforce CLI Setup Guide](https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_setup_intro.htm)
111
502
  - [Salesforce DX Developer Guide](https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_intro.htm)
112
503
  - [Salesforce CLI Command Reference](https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference.htm)
504
+ - [Experience Cloud Developer Guide](https://developer.salesforce.com/docs/atlas.en-us.communities_dev.meta/communities_dev/communities_dev_intro.htm)
505
+ - [Salesforce DX Project Configuration](https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_ws_config.htm)
@@ -15,8 +15,8 @@
15
15
  "graphql:schema": "node scripts/get-graphql-schema.mjs"
16
16
  },
17
17
  "dependencies": {
18
- "@salesforce/sdk-data": "^1.119.0",
19
- "@salesforce/ui-bundle": "^1.119.0",
18
+ "@salesforce/sdk-data": "^1.119.2",
19
+ "@salesforce/ui-bundle": "^1.119.2",
20
20
  "@tailwindcss/vite": "^4.1.17",
21
21
  "class-variance-authority": "^0.7.1",
22
22
  "clsx": "^2.1.1",
@@ -47,7 +47,7 @@
47
47
  "@graphql-eslint/eslint-plugin": "^4.1.0",
48
48
  "@graphql-tools/utils": "^11.0.0",
49
49
  "@playwright/test": "^1.49.0",
50
- "@salesforce/vite-plugin-ui-bundle": "^1.119.0",
50
+ "@salesforce/vite-plugin-ui-bundle": "^1.119.2",
51
51
  "@testing-library/jest-dom": "^6.6.3",
52
52
  "@testing-library/react": "^16.1.0",
53
53
  "@testing-library/user-event": "^14.5.2",
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@salesforce/webapp-template-base-sfdx-project-experimental",
3
- "version": "1.119.0",
3
+ "version": "1.119.2",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@salesforce/webapp-template-base-sfdx-project-experimental",
9
- "version": "1.119.0",
9
+ "version": "1.119.2",
10
10
  "license": "SEE LICENSE IN LICENSE.txt",
11
11
  "devDependencies": {
12
12
  "@lwc/eslint-plugin-lwc": "^3.3.0",
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/ui-bundle-template-base-sfdx-project",
3
- "version": "1.119.0",
3
+ "version": "1.119.2",
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/ui-bundle-template-app-react-sample-b2x",
3
- "version": "1.119.0",
3
+ "version": "1.119.2",
4
4
  "description": "Salesforce sample property rental React app",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "author": "",