@salesforce/webapp-template-app-react-sample-b2e-experimental 1.84.1 → 1.85.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/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
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.85.0](https://github.com/salesforce-experience-platform-emu/webapps/compare/v1.84.1...v1.85.0) (2026-03-10)
7
+
8
+ **Note:** Version bump only for package @salesforce/webapp-template-base-sfdx-project-experimental
9
+
10
+
11
+
12
+
13
+
6
14
  ## [1.84.1](https://github.com/salesforce-experience-platform-emu/webapps/compare/v1.84.0...v1.84.1) (2026-03-10)
7
15
 
8
16
  **Note:** Version bump only for package @salesforce/webapp-template-base-sfdx-project-experimental
package/dist/README.md CHANGED
@@ -58,6 +58,30 @@ Replace `<alias>` with your target org alias.
58
58
  sf data import tree --plan force-app/main/default/data/data-plan.json --target-org <alias>
59
59
  ```
60
60
 
61
+ ## Using setup-cli.mjs
62
+
63
+ When this app is built (e.g. from the monorepo or from a published package), a `setup-cli.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 web app, and optionally start the dev server.
64
+
65
+ Run from the **project root** (the directory that contains `force-app/`, `sfdx-project.json`, and `setup-cli.mjs`):
66
+
67
+ ```bash
68
+ node setup-cli.mjs --target-org <alias>
69
+ ```
70
+
71
+ Common options:
72
+
73
+ | Option | Description |
74
+ | --------------------- | ---------------------------------------------------------------- |
75
+ | `--skip-login` | Skip browser login (org already authenticated) |
76
+ | `--skip-data` | Skip data preparation and import |
77
+ | `--skip-graphql` | Skip GraphQL schema fetch and codegen |
78
+ | `--skip-webapp-build` | Skip `npm install` and web app build |
79
+ | `--skip-dev` | Do not start the dev server at the end |
80
+ | `--permset <name>` | Permission set to assign (default: `Property_Management_Access`) |
81
+ | `--app <name>` | Web app folder name when multiple exist |
82
+
83
+ For all options: `node setup-cli.mjs --help`.
84
+
61
85
  ## Configure Your Salesforce DX Project
62
86
 
63
87
  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.
@@ -138,7 +138,7 @@
138
138
  "referenceId": "ImageRef12"
139
139
  },
140
140
  "Name": "Beverly Hills Estate Primary",
141
- "Property__c": "@PropertyRef11",
141
+ "Property__c": "@PropertyRef10",
142
142
  "Image_URL__c": "https://images.unsplash.com/photo-1613490493576-7fde63acd811?w=800&h=600&fit=crop",
143
143
  "Image_Type__c": "Primary",
144
144
  "Display_Order__c": 1,
@@ -90,7 +90,7 @@
90
90
  "referenceId": "ListingRef7"
91
91
  },
92
92
  "Name": "Beverly Hills Estate",
93
- "Property__c": "@PropertyRef11",
93
+ "Property__c": "@PropertyRef10",
94
94
  "Listing_Price__c": 9200000.0,
95
95
  "Listing_Status__c": "Active",
96
96
  "Featured__c": true,
@@ -0,0 +1,85 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Updates unique fields in data JSON files so "sf data import tree" can be run
4
+ * repeatedly (e.g. after org already has data). Run before: node prepare-import-unique-fields.js
5
+ */
6
+ const fs = require("fs");
7
+ const path = require("path");
8
+ const dataDir = __dirname;
9
+ const runId = Date.now();
10
+ const runSuffix2 = String(runId % 100).padStart(2, "0"); // 00-99 for Company_Code__c (10-char limit)
11
+
12
+ // Contact: Email + LastName — unique so re-runs don't hit DUPLICATES_DETECTED (matching may use name)
13
+ const contactPath = path.join(dataDir, "Contact.json");
14
+ let contact = JSON.parse(fs.readFileSync(contactPath, "utf8"));
15
+ contact.records.forEach((r, i) => {
16
+ if (r.Email && r.Email.includes("@"))
17
+ r.Email = r.Email.replace(/\+[0-9]+@/, "@").replace("@", "+" + runId + "@");
18
+ if (r.LastName)
19
+ r.LastName = r.LastName.replace(/\s*\[[0-9-]+\]$/, "") + " [" + runId + "-" + i + "]";
20
+ });
21
+ fs.writeFileSync(contactPath, JSON.stringify(contact, null, 2));
22
+
23
+ // Agent__c: License_Number__c — strip any existing suffix and add run id + index (each record must be unique)
24
+ const agentPath = path.join(dataDir, "Agent__c.json");
25
+ let agent = JSON.parse(fs.readFileSync(agentPath, "utf8"));
26
+ agent.records.forEach((r, i) => {
27
+ if (r.License_Number__c)
28
+ r.License_Number__c =
29
+ r.License_Number__c.replace(/-[0-9]+(-[0-9]+)?$/, "") + "-" + runId + "-" + i;
30
+ });
31
+ fs.writeFileSync(agentPath, JSON.stringify(agent, null, 2));
32
+
33
+ // Property_Management_Company__c: Company_Code__c — max 10 chars, use 8-char base + 2-digit suffix
34
+ const companyPath = path.join(dataDir, "Property_Management_Company__c.json");
35
+ let company = JSON.parse(fs.readFileSync(companyPath, "utf8"));
36
+ company.records.forEach((r) => {
37
+ if (r.Company_Code__c) r.Company_Code__c = r.Company_Code__c.slice(0, 8) + runSuffix2; // 8-char base + 2-digit = 10 chars max
38
+ });
39
+ fs.writeFileSync(companyPath, JSON.stringify(company, null, 2));
40
+
41
+ // Property_Owner__c: Email__c — add +runId before @
42
+ const ownerPath = path.join(dataDir, "Property_Owner__c.json");
43
+ let owner = JSON.parse(fs.readFileSync(ownerPath, "utf8"));
44
+ owner.records.forEach((r) => {
45
+ if (r.Email__c && r.Email__c.includes("@"))
46
+ r.Email__c = r.Email__c.replace(/\+[0-9]+@/, "@").replace("@", "+" + runId + "@");
47
+ });
48
+ fs.writeFileSync(ownerPath, JSON.stringify(owner, null, 2));
49
+
50
+ // Remap @TenantRefN in dependent files to only use refs that exist in Tenant__c.json (fix UnresolvableRefsError)
51
+ const tenantPath = path.join(dataDir, "Tenant__c.json");
52
+ const tenantData = JSON.parse(fs.readFileSync(tenantPath, "utf8"));
53
+ const validTenantRefs = tenantData.records.map((r) => r.attributes?.referenceId).filter(Boolean);
54
+ if (validTenantRefs.length === 0) throw new Error("Tenant__c.json has no referenceIds");
55
+
56
+ function remapTenantRef(refValue) {
57
+ if (typeof refValue !== "string" || !refValue.startsWith("@TenantRef")) return refValue;
58
+ const match = refValue.match(/^@(TenantRef)(\d+)$/);
59
+ if (!match) return refValue;
60
+ const n = parseInt(match[2], 10);
61
+ const idx = (n - 1) % validTenantRefs.length;
62
+ return "@" + validTenantRefs[idx];
63
+ }
64
+
65
+ const leasePath = path.join(dataDir, "Lease__c.json");
66
+ let lease = JSON.parse(fs.readFileSync(leasePath, "utf8"));
67
+ lease.records.forEach((r) => {
68
+ if (r.Tenant__c) r.Tenant__c = remapTenantRef(r.Tenant__c);
69
+ });
70
+ fs.writeFileSync(leasePath, JSON.stringify(lease, null, 2));
71
+
72
+ const maintPath = path.join(dataDir, "Maintenance_Request__c.json");
73
+ let maint = JSON.parse(fs.readFileSync(maintPath, "utf8"));
74
+ maint.records.forEach((r) => {
75
+ if (r.User__c && String(r.User__c).startsWith("@TenantRef"))
76
+ r.User__c = remapTenantRef(r.User__c);
77
+ });
78
+ fs.writeFileSync(maintPath, JSON.stringify(maint, null, 2));
79
+
80
+ console.log(
81
+ "Unique fields updated: runId=%s companySuffix=%s validTenants=%s",
82
+ runId,
83
+ runSuffix2,
84
+ validTenantRefs.length,
85
+ );
@@ -367,43 +367,36 @@
367
367
  <field>Agent__c.License_Number__c</field>
368
368
  <readable>true</readable>
369
369
  </fieldPermissions>
370
-
371
370
  <fieldPermissions>
372
371
  <editable>true</editable>
373
372
  <field>Agent__c.License_Expiry__c</field>
374
373
  <readable>true</readable>
375
374
  </fieldPermissions>
376
-
377
375
  <fieldPermissions>
378
376
  <editable>true</editable>
379
377
  <field>Agent__c.Agent_Type__c</field>
380
378
  <readable>true</readable>
381
379
  </fieldPermissions>
382
-
383
380
  <fieldPermissions>
384
381
  <editable>true</editable>
385
382
  <field>Agent__c.Territory__c</field>
386
383
  <readable>true</readable>
387
384
  </fieldPermissions>
388
-
389
385
  <fieldPermissions>
390
386
  <editable>true</editable>
391
387
  <field>Agent__c.Emergency_Alt__c</field>
392
388
  <readable>true</readable>
393
389
  </fieldPermissions>
394
-
395
390
  <fieldPermissions>
396
391
  <editable>true</editable>
397
392
  <field>Agent__c.Language__c</field>
398
393
  <readable>true</readable>
399
394
  </fieldPermissions>
400
-
401
395
  <fieldPermissions>
402
396
  <editable>true</editable>
403
397
  <field>Agent__c.Availability__c</field>
404
398
  <readable>true</readable>
405
399
  </fieldPermissions>
406
-
407
400
  <fieldPermissions>
408
401
  <editable>true</editable>
409
402
  <field>Agent__c.Office_Location__c</field>
@@ -15,9 +15,9 @@
15
15
  "graphql:schema": "node scripts/get-graphql-schema.mjs"
16
16
  },
17
17
  "dependencies": {
18
- "@salesforce/agentforce-conversation-client": "^1.84.1",
19
- "@salesforce/sdk-data": "^1.84.1",
20
- "@salesforce/webapp-experimental": "^1.84.1",
18
+ "@salesforce/agentforce-conversation-client": "^1.85.0",
19
+ "@salesforce/sdk-data": "^1.85.0",
20
+ "@salesforce/webapp-experimental": "^1.85.0",
21
21
  "@tailwindcss/vite": "^4.1.17",
22
22
  "@tanstack/react-form": "^1.28.4",
23
23
  "class-variance-authority": "^0.7.1",
@@ -42,7 +42,7 @@
42
42
  "@graphql-eslint/eslint-plugin": "^4.1.0",
43
43
  "@graphql-tools/utils": "^11.0.0",
44
44
  "@playwright/test": "^1.49.0",
45
- "@salesforce/vite-plugin-webapp-experimental": "^1.84.1",
45
+ "@salesforce/vite-plugin-webapp-experimental": "^1.85.0",
46
46
  "@testing-library/jest-dom": "^6.6.3",
47
47
  "@testing-library/react": "^16.1.0",
48
48
  "@testing-library/user-event": "^14.5.2",
@@ -1,10 +1,11 @@
1
- import { getDataSDK, gql } from "@salesforce/sdk-data";
2
- import type { Application } from "../lib/types";
1
+ import { gql } from "@salesforce/sdk-data";
2
+ import type { Application } from "../lib/types.js";
3
3
  import type {
4
4
  GetApplicationsQuery,
5
5
  UpdateApplicationStatusMutationVariables,
6
6
  UpdateApplicationStatusMutation,
7
- } from "./graphql-operations-types";
7
+ } from "./graphql-operations-types.js";
8
+ import { executeGraphQL } from "./graphqlClient.js";
8
9
 
9
10
  // Query to get all applications
10
11
  const GET_APPLICATIONS = gql`
@@ -73,15 +74,8 @@ const UPDATE_APPLICATION_STATUS = gql`
73
74
 
74
75
  export async function getApplications(): Promise<Application[]> {
75
76
  try {
76
- const data = await getDataSDK();
77
- const result = await data.graphql?.<GetApplicationsQuery>(GET_APPLICATIONS);
78
-
79
- if (result?.errors?.length) {
80
- const errorMessages = result.errors.map((e) => e.message).join("; ");
81
- throw new Error(`GraphQL Error: ${errorMessages}`);
82
- }
83
-
84
- const edges = result?.data?.uiapi?.query?.Application__c?.edges || [];
77
+ const data = await executeGraphQL<GetApplicationsQuery>(GET_APPLICATIONS);
78
+ const edges = data?.uiapi?.query?.Application__c?.edges || [];
85
79
 
86
80
  return edges
87
81
  .map((edge) => {
@@ -123,18 +117,11 @@ export async function updateApplicationStatus(
123
117
  },
124
118
  };
125
119
  try {
126
- const data = await getDataSDK();
127
- const result = await data.graphql?.<
120
+ const data = await executeGraphQL<
128
121
  UpdateApplicationStatusMutation,
129
122
  UpdateApplicationStatusMutationVariables
130
123
  >(UPDATE_APPLICATION_STATUS, variables);
131
-
132
- if (result?.errors?.length) {
133
- const errorMessages = result.errors.map((e) => e.message).join("; ");
134
- throw new Error(`GraphQL Error: ${errorMessages}`);
135
- }
136
-
137
- return !!result?.data?.uiapi?.Application__cUpdate?.success;
124
+ return !!data?.uiapi?.Application__cUpdate?.success;
138
125
  } catch (error) {
139
126
  console.error("Error updating application status:", error);
140
127
  return false;
@@ -1,11 +1,12 @@
1
- import { getDataSDK, gql } from "@salesforce/sdk-data";
2
- import type { DashboardMetrics, Application } from "../lib/types";
1
+ import { gql } from "@salesforce/sdk-data";
2
+ import type { DashboardMetrics, Application } from "../lib/types.js";
3
3
  import type {
4
4
  GetDashboardMetricsQuery,
5
5
  GetOpenApplicationsQuery,
6
6
  GetOpenApplicationsQueryVariables,
7
7
  GetUserInfoQuery,
8
- } from "./graphql-operations-types";
8
+ } from "./graphql-operations-types.js";
9
+ import { executeGraphQL } from "./graphqlClient.js";
9
10
 
10
11
  // Query to get property counts for dashboard metrics
11
12
  const GET_DASHBOARD_METRICS = gql`
@@ -99,18 +100,10 @@ const GET_USER_INFO = gql`
99
100
 
100
101
  // Fetch dashboard metrics
101
102
  export async function getDashboardMetrics(): Promise<{
102
- properties: any[];
103
- maintenanceRequests: any[];
103
+ properties: unknown[];
104
+ maintenanceRequests: unknown[];
104
105
  }> {
105
- const data = await getDataSDK();
106
- const result = await data.graphql?.<GetDashboardMetricsQuery>(GET_DASHBOARD_METRICS);
107
-
108
- if (result?.errors?.length) {
109
- const errorMessages = result.errors.map((e) => e.message).join("; ");
110
- throw new Error(`GraphQL Error: ${errorMessages}`);
111
- }
112
-
113
- const response = result?.data;
106
+ const response = await executeGraphQL<GetDashboardMetricsQuery>(GET_DASHBOARD_METRICS);
114
107
  const properties = response?.uiapi?.query?.allProperties?.edges?.map((edge) => edge?.node) || [];
115
108
  const maintenanceRequests =
116
109
  response?.uiapi?.query?.maintenanceRequests?.edges?.map((edge) => edge?.node) || [];
@@ -120,36 +113,21 @@ export async function getDashboardMetrics(): Promise<{
120
113
  // Fetch open applications
121
114
  export async function getOpenApplications(first: number = 5): Promise<Application[]> {
122
115
  const variables: GetOpenApplicationsQueryVariables = { first };
123
- const data = await getDataSDK();
124
- const result = await data.graphql?.<GetOpenApplicationsQuery, GetOpenApplicationsQueryVariables>(
116
+ const data = await executeGraphQL<GetOpenApplicationsQuery, GetOpenApplicationsQueryVariables>(
125
117
  GET_OPEN_APPLICATIONS,
126
118
  variables,
127
119
  );
128
-
129
- if (result?.errors?.length) {
130
- const errorMessages = result.errors.map((e) => e.message).join("; ");
131
- throw new Error(`GraphQL Error: ${errorMessages}`);
132
- }
133
-
134
120
  const apps =
135
- result?.data?.uiapi?.query?.Application__c?.edges?.map((edge) =>
136
- transformApplication(edge?.node),
137
- ) || [];
121
+ data?.uiapi?.query?.Application__c?.edges?.map((edge) => transformApplication(edge?.node)) ||
122
+ [];
138
123
  return apps;
139
124
  }
140
125
 
141
126
  // Fetch current user information
142
127
  export async function getUserInfo(): Promise<{ name: string; id: string } | null> {
143
128
  try {
144
- const data = await getDataSDK();
145
- const result = await data.graphql?.<GetUserInfoQuery>(GET_USER_INFO);
146
-
147
- if (result?.errors?.length) {
148
- const errorMessages = result.errors.map((e) => e.message).join("; ");
149
- throw new Error(`GraphQL Error: ${errorMessages}`);
150
- }
151
-
152
- const user = result?.data?.uiapi?.query?.User?.edges?.[0]?.node;
129
+ const data = await executeGraphQL<GetUserInfoQuery>(GET_USER_INFO);
130
+ const user = data?.uiapi?.query?.User?.edges?.[0]?.node;
153
131
  if (user) {
154
132
  return {
155
133
  id: user.Id,
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Thin GraphQL client: getDataSDK + data.graphql with centralized error handling.
3
+ * Use with gql-tagged queries and generated operation types for type-safe calls.
4
+ */
5
+ import { getDataSDK } from "@salesforce/sdk-data";
6
+
7
+ export async function executeGraphQL<TData, TVariables = Record<string, unknown>>(
8
+ query: string | { kind: string; definitions: unknown[] },
9
+ variables?: TVariables,
10
+ ): Promise<TData> {
11
+ const data = await getDataSDK();
12
+ // SDK types graphql() first param as string; at runtime it may accept gql DocumentNode too
13
+ const response = await data.graphql?.<TData>(
14
+ query as unknown as string,
15
+ variables as Record<string, unknown>,
16
+ );
17
+ if (response?.errors?.length) {
18
+ const msg = response.errors.map((e) => e.message).join("; ");
19
+ throw new Error(`GraphQL Error: ${msg}`);
20
+ }
21
+ return (response?.data ?? {}) as TData;
22
+ }
@@ -1,5 +1,5 @@
1
- import { getDataSDK, gql } from "@salesforce/sdk-data";
2
- import type { MaintenanceRequest } from "../lib/types";
1
+ import { gql } from "@salesforce/sdk-data";
2
+ import type { MaintenanceRequest } from "../lib/types.js";
3
3
  import type {
4
4
  GetMaintenanceRequestsQuery,
5
5
  GetMaintenanceRequestsQueryVariables,
@@ -7,7 +7,8 @@ import type {
7
7
  GetAllMaintenanceRequestsQueryVariables,
8
8
  UpdateMaintenanceStatusMutation,
9
9
  UpdateMaintenanceStatusMutationVariables,
10
- } from "./graphql-operations-types";
10
+ } from "./graphql-operations-types.js";
11
+ import { executeGraphQL } from "./graphqlClient.js";
11
12
 
12
13
  // Query to get recent maintenance requests
13
14
  const GET_MAINTENANCE_REQUESTS = gql`
@@ -149,19 +150,12 @@ const UPDATE_MAINTENANCE_STATUS = gql`
149
150
  // Fetch maintenance requests for dashboard
150
151
  export async function getMaintenanceRequests(first: number = 5): Promise<MaintenanceRequest[]> {
151
152
  const variables: GetMaintenanceRequestsQueryVariables = { first };
152
- const data = await getDataSDK();
153
- const result = await data.graphql?.<
153
+ const data = await executeGraphQL<
154
154
  GetMaintenanceRequestsQuery,
155
155
  GetMaintenanceRequestsQueryVariables
156
156
  >(GET_MAINTENANCE_REQUESTS, variables);
157
-
158
- if (result?.errors?.length) {
159
- const errorMessages = result.errors.map((e) => e.message).join("; ");
160
- throw new Error(`GraphQL Error: ${errorMessages}`);
161
- }
162
-
163
157
  const requests =
164
- result?.data?.uiapi?.query?.Maintenance_Request__c?.edges?.map((edge) =>
158
+ data?.uiapi?.query?.Maintenance_Request__c?.edges?.map((edge) =>
165
159
  transformMaintenanceRequest(edge?.node),
166
160
  ) || [];
167
161
  return requests;
@@ -172,19 +166,12 @@ export async function getAllMaintenanceRequests(
172
166
  first: number = 100,
173
167
  ): Promise<MaintenanceRequest[]> {
174
168
  const variables: GetAllMaintenanceRequestsQueryVariables = { first };
175
- const data = await getDataSDK();
176
- const result = await data.graphql?.<
169
+ const data = await executeGraphQL<
177
170
  GetAllMaintenanceRequestsQuery,
178
171
  GetAllMaintenanceRequestsQueryVariables
179
172
  >(GET_ALL_MAINTENANCE_REQUESTS, variables);
180
-
181
- if (result?.errors?.length) {
182
- const errorMessages = result.errors.map((e) => e.message).join("; ");
183
- throw new Error(`GraphQL Error: ${errorMessages}`);
184
- }
185
-
186
173
  const requests =
187
- result?.data?.uiapi?.query?.Maintenance_Request__c?.edges?.map((edge: any) =>
174
+ data?.uiapi?.query?.Maintenance_Request__c?.edges?.map((edge) =>
188
175
  transformMaintenanceTaskFull(edge?.node),
189
176
  ) || [];
190
177
  return requests;
@@ -275,18 +262,11 @@ export async function updateMaintenanceStatus(requestId: string, status: string)
275
262
  },
276
263
  };
277
264
  try {
278
- const data = await getDataSDK();
279
- const result = await data.graphql?.<
265
+ const data = await executeGraphQL<
280
266
  UpdateMaintenanceStatusMutation,
281
267
  UpdateMaintenanceStatusMutationVariables
282
268
  >(UPDATE_MAINTENANCE_STATUS, variables);
283
-
284
- if (result?.errors?.length) {
285
- const errorMessages = result.errors.map((e) => e.message).join("; ");
286
- throw new Error(`GraphQL Error: ${errorMessages}`);
287
- }
288
-
289
- return !!result?.data?.uiapi?.Maintenance_Request__cUpdate?.success;
269
+ return !!data?.uiapi?.Maintenance_Request__cUpdate?.success;
290
270
  } catch (error) {
291
271
  console.error("Error updating maintenance status:", error);
292
272
  return false;
@@ -1,6 +1,10 @@
1
- import { getDataSDK, gql } from "@salesforce/sdk-data";
2
- import type { Property } from "../lib/types";
3
- import type { GetPropertiesQueryVariables, GetPropertiesQuery } from "./graphql-operations-types";
1
+ import { gql } from "@salesforce/sdk-data";
2
+ import type { Property } from "../lib/types.js";
3
+ import type {
4
+ GetPropertiesQueryVariables,
5
+ GetPropertiesQuery,
6
+ } from "./graphql-operations-types.js";
7
+ import { executeGraphQL } from "./graphqlClient.js";
4
8
 
5
9
  // GraphQL query to get properties with pagination
6
10
  const GET_PROPERTIES_PAGINATED = gql`
@@ -97,19 +101,10 @@ export async function getProperties(first: number = 12, after?: string): Promise
97
101
  if (after) {
98
102
  variables.after = after;
99
103
  }
100
-
101
- const data = await getDataSDK();
102
- const result = await data.graphql?.<GetPropertiesQuery, GetPropertiesQueryVariables>(
104
+ const response = await executeGraphQL<GetPropertiesQuery, GetPropertiesQueryVariables>(
103
105
  GET_PROPERTIES_PAGINATED,
104
106
  variables,
105
107
  );
106
-
107
- if (result?.errors?.length) {
108
- const errorMessages = result.errors.map((e) => e.message).join("; ");
109
- throw new Error(`GraphQL Error: ${errorMessages}`);
110
- }
111
-
112
- const response = result?.data;
113
108
  const edges = response?.uiapi?.query?.Property__c?.edges || [];
114
109
  const pageInfo = response?.uiapi?.query?.Property__c?.pageInfo || {
115
110
  hasNextPage: false,
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/webapp-template-base-sfdx-project-experimental",
3
- "version": "1.84.1",
3
+ "version": "1.85.0",
4
4
  "description": "Base SFDX project template",
5
5
  "private": true,
6
6
  "files": [
@@ -0,0 +1,271 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * One-command setup: login, deploy, data import, GraphQL schema/codegen, web app build.
4
+ * Provided by the property management feature. Run from the SFDX project root (e.g. dist/).
5
+ *
6
+ * Usage:
7
+ * node setup-cli.mjs --target-org <alias> # run all steps
8
+ * node setup-cli.mjs --target-org afv5 --skip-login
9
+ * node setup-cli.mjs --target-org afv5 --skip-data --skip-webapp-build
10
+ * node setup-cli.mjs --target-org myorg --app appreactsampleb2x # when multiple web apps
11
+ *
12
+ * Steps (in order):
13
+ * 1. login — sf org login web only if org not already connected (skip with --skip-login)
14
+ * 2. deploy — sf project deploy start --target-org <alias>
15
+ * 3. permset — sf org assign permset (default: Property_Management_Access; override with --permset)
16
+ * 4. data — prepare unique fields + sf data import tree (skipped if no data-plan.json)
17
+ * 5. graphql — (in webapp) npm run graphql:schema then npm run graphql:codegen
18
+ * 6. webapp — (in webapp) npm install && npm run build
19
+ * 7. dev — (in webapp) npm run dev — launch dev server (skip with --skip-dev)
20
+ */
21
+
22
+ import { spawnSync } from "node:child_process";
23
+ import { readdirSync, existsSync } from "node:fs";
24
+ import { resolve, dirname, basename } from "node:path";
25
+ import { fileURLToPath } from "node:url";
26
+
27
+ const __dirname = dirname(fileURLToPath(import.meta.url));
28
+ /** SFDX project root: when run from dist/, the script lives in dist/ and force-app is under dist/ */
29
+ const ROOT = __dirname;
30
+ const WEBAPPLICATIONS_DIR = resolve(ROOT, "force-app/main/default/webapplications");
31
+ const DATA_DIR = resolve(ROOT, "force-app/main/default/data");
32
+ const DATA_PLAN = resolve(DATA_DIR, "data-plan.json");
33
+ const PREPARE_SCRIPT = resolve(DATA_DIR, "prepare-import-unique-fields.js");
34
+
35
+ function parseArgs() {
36
+ const args = process.argv.slice(2);
37
+ let targetOrg = null;
38
+ let appName = null;
39
+ let permsetName = "Property_Management_Access";
40
+ const flags = {
41
+ skipLogin: false,
42
+ skipDeploy: false,
43
+ skipPermset: false,
44
+ skipData: false,
45
+ skipGraphql: false,
46
+ skipWebappBuild: false,
47
+ skipDev: false,
48
+ };
49
+ for (let i = 0; i < args.length; i++) {
50
+ if (args[i] === "--target-org" && args[i + 1]) {
51
+ targetOrg = args[++i];
52
+ } else if (args[i] === "--app" && args[i + 1]) {
53
+ appName = args[++i];
54
+ } else if (args[i] === "--permset" && args[i + 1]) {
55
+ permsetName = args[++i];
56
+ } else if (args[i] === "--skip-login") flags.skipLogin = true;
57
+ else if (args[i] === "--skip-deploy") flags.skipDeploy = true;
58
+ else if (args[i] === "--skip-permset") flags.skipPermset = true;
59
+ else if (args[i] === "--skip-data") flags.skipData = true;
60
+ else if (args[i] === "--skip-graphql") flags.skipGraphql = true;
61
+ else if (args[i] === "--skip-webapp-build") flags.skipWebappBuild = true;
62
+ else if (args[i] === "--skip-dev") flags.skipDev = true;
63
+ else if (args[i] === "--help" || args[i] === "-h") {
64
+ console.log(`
65
+ Setup CLI (property management feature)
66
+
67
+ Usage:
68
+ node setup-cli.mjs --target-org <alias> [options]
69
+
70
+ Required:
71
+ --target-org <alias> Target Salesforce org alias (e.g. afv5)
72
+
73
+ Options:
74
+ --app <name> Web app folder name (default: auto-detect if only one in force-app/.../webapplications/)
75
+ --permset <name> Permission set to assign (default: Property_Management_Access)
76
+ --skip-login Skip login step (login is auto-skipped if org is already connected)
77
+ --skip-deploy Do not deploy metadata
78
+ --skip-permset Do not assign permission set
79
+ --skip-data Do not prepare data or run data import
80
+ --skip-graphql Do not fetch schema or run GraphQL codegen
81
+ --skip-webapp-build Do not npm install / build the web application
82
+ --skip-dev Do not launch the dev server at the end
83
+ -h, --help Show this help
84
+ `);
85
+ process.exit(0);
86
+ }
87
+ }
88
+ if (!targetOrg) {
89
+ console.error("Error: --target-org <alias> is required.");
90
+ process.exit(1);
91
+ }
92
+ return { targetOrg, appName, permsetName, ...flags };
93
+ }
94
+
95
+ function discoverWebAppDir(appNameOverride) {
96
+ if (appNameOverride) {
97
+ const dir = resolve(WEBAPPLICATIONS_DIR, appNameOverride);
98
+ if (!existsSync(dir)) {
99
+ console.error(`Error: Web app directory not found: ${dir}`);
100
+ process.exit(1);
101
+ }
102
+ return dir;
103
+ }
104
+ if (!existsSync(WEBAPPLICATIONS_DIR)) {
105
+ console.error(`Error: Web applications directory not found: ${WEBAPPLICATIONS_DIR}`);
106
+ process.exit(1);
107
+ }
108
+ const entries = readdirSync(WEBAPPLICATIONS_DIR, { withFileTypes: true });
109
+ const dirs = entries.filter((e) => e.isDirectory());
110
+ if (dirs.length === 0) {
111
+ console.error(
112
+ "Error: No web application folder found under force-app/main/default/webapplications/",
113
+ );
114
+ process.exit(1);
115
+ }
116
+ if (dirs.length > 1) {
117
+ console.error(
118
+ "Error: Multiple web applications found. Specify one with --app <name>. Choices:",
119
+ dirs.map((d) => d.name).join(", "),
120
+ );
121
+ process.exit(1);
122
+ }
123
+ return resolve(WEBAPPLICATIONS_DIR, dirs[0].name);
124
+ }
125
+
126
+ function isOrgConnected(targetOrg) {
127
+ const result = spawnSync("sf", ["org", "display", "--target-org", targetOrg, "--json"], {
128
+ cwd: ROOT,
129
+ stdio: "pipe",
130
+ shell: true,
131
+ });
132
+ return result.status === 0;
133
+ }
134
+
135
+ function run(name, cmd, args, opts = {}) {
136
+ const { cwd = ROOT, optional = false } = opts;
137
+ console.log("\n---", name, "---");
138
+ const result = spawnSync(cmd, args, {
139
+ cwd,
140
+ stdio: "inherit",
141
+ shell: true,
142
+ ...(opts.timeout && { timeout: opts.timeout }),
143
+ });
144
+ if (result.status !== 0 && !optional) {
145
+ console.error(`\nSetup failed at step: ${name}`);
146
+ process.exit(result.status ?? 1);
147
+ }
148
+ return result;
149
+ }
150
+
151
+ function main() {
152
+ const {
153
+ targetOrg,
154
+ appName: appNameOverride,
155
+ permsetName,
156
+ skipLogin,
157
+ skipDeploy,
158
+ skipPermset,
159
+ skipData,
160
+ skipGraphql,
161
+ skipWebappBuild,
162
+ skipDev,
163
+ } = parseArgs();
164
+
165
+ const WEBAPP_DIR = discoverWebAppDir(appNameOverride);
166
+ const webAppName = appNameOverride || basename(WEBAPP_DIR);
167
+
168
+ console.log("Setup — target org:", targetOrg, "| web app:", webAppName);
169
+ console.log(
170
+ "Steps: login=%s deploy=%s permset=%s data=%s graphql=%s webapp=%s dev=%s",
171
+ !skipLogin,
172
+ !skipDeploy,
173
+ !skipPermset,
174
+ !skipData,
175
+ !skipGraphql,
176
+ !skipWebappBuild,
177
+ !skipDev,
178
+ );
179
+
180
+ if (!skipLogin) {
181
+ if (isOrgConnected(targetOrg)) {
182
+ console.log("\n--- Login ---");
183
+ console.log(`Org ${targetOrg} is already authenticated; skipping browser login.`);
184
+ } else {
185
+ run("Login (browser)", "sf", ["org", "login", "web", "--alias", targetOrg], {
186
+ optional: true,
187
+ });
188
+ }
189
+ }
190
+
191
+ if (!skipDeploy) {
192
+ run("Deploy metadata", "sf", ["project", "deploy", "start", "--target-org", targetOrg], {
193
+ timeout: 180000,
194
+ });
195
+ }
196
+
197
+ if (!skipPermset) {
198
+ console.log("\n--- Assign permission set ---");
199
+ const permsetResult = spawnSync(
200
+ "sf",
201
+ ["org", "assign", "permset", "--name", permsetName, "--target-org", targetOrg],
202
+ {
203
+ cwd: ROOT,
204
+ stdio: "pipe",
205
+ shell: true,
206
+ },
207
+ );
208
+ if (permsetResult.status === 0) {
209
+ console.log("Permission set assigned.");
210
+ } else {
211
+ const out =
212
+ (permsetResult.stderr?.toString() || "") + (permsetResult.stdout?.toString() || "");
213
+ if (out.includes("Duplicate") && out.includes("PermissionSet")) {
214
+ console.log("Permission set already assigned; skipping.");
215
+ } else {
216
+ process.stdout.write(permsetResult.stdout?.toString() || "");
217
+ process.stderr.write(permsetResult.stderr?.toString() || "");
218
+ console.error("\nSetup failed at step: Assign permission set");
219
+ process.exit(permsetResult.status ?? 1);
220
+ }
221
+ }
222
+ }
223
+
224
+ const hasDataPlan = existsSync(DATA_PLAN);
225
+ const hasPrepareScript = existsSync(PREPARE_SCRIPT);
226
+
227
+ if (!skipData) {
228
+ if (hasPrepareScript) {
229
+ run("Prepare data (unique fields)", "node", [PREPARE_SCRIPT], { cwd: DATA_DIR });
230
+ } else {
231
+ console.log("\n--- Prepare data ---");
232
+ console.log("No prepare-import-unique-fields.js found; skipping.");
233
+ }
234
+ if (hasDataPlan) {
235
+ run(
236
+ "Data import tree",
237
+ "sf",
238
+ ["data", "import", "tree", "--plan", DATA_PLAN, "--target-org", targetOrg],
239
+ {
240
+ timeout: 120000,
241
+ },
242
+ );
243
+ } else {
244
+ console.log("\n--- Data import ---");
245
+ console.log("No data-plan.json found; skipping data import.");
246
+ }
247
+ }
248
+
249
+ if (!skipGraphql || !skipWebappBuild) {
250
+ run("Web app npm install", "npm", ["install"], { cwd: WEBAPP_DIR });
251
+ }
252
+
253
+ if (!skipGraphql) {
254
+ run("Set default org for schema", "sf", ["config", "set", "target-org", targetOrg, "--global"]);
255
+ run("GraphQL schema (introspect)", "npm", ["run", "graphql:schema"], { cwd: WEBAPP_DIR });
256
+ run("GraphQL codegen", "npm", ["run", "graphql:codegen"], { cwd: WEBAPP_DIR });
257
+ }
258
+
259
+ if (!skipWebappBuild) {
260
+ run("Web app build", "npm", ["run", "build"], { cwd: WEBAPP_DIR });
261
+ }
262
+
263
+ console.log("\n--- Setup complete ---");
264
+
265
+ if (!skipDev) {
266
+ console.log("\n--- Launching dev server (Ctrl+C to stop) ---\n");
267
+ run("Dev server", "npm", ["run", "dev"], { cwd: WEBAPP_DIR });
268
+ }
269
+ }
270
+
271
+ main();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/webapp-template-app-react-sample-b2e-experimental",
3
- "version": "1.84.1",
3
+ "version": "1.85.0",
4
4
  "description": "B2E starter app template",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "author": "",
@@ -16,8 +16,8 @@
16
16
  "clean": "rm -rf dist"
17
17
  },
18
18
  "dependencies": {
19
- "@salesforce/webapp-experimental": "^1.84.1",
20
- "@salesforce/webapp-template-feature-react-global-search-experimental": "^1.84.1"
19
+ "@salesforce/webapp-experimental": "^1.85.0",
20
+ "@salesforce/webapp-template-feature-react-global-search-experimental": "^1.85.0"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@testing-library/jest-dom": "^6.6.3",