@salesforce/webapp-template-app-react-sample-b2x-experimental 1.112.7 → 1.112.9
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 +19 -0
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/package.json +6 -5
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/api/graphql-operations-types.ts +12058 -214
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/api/graphqlClient.ts +18 -15
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/api/{propertyListingGraphQL.ts → properties/propertyListingGraphQL.ts} +1 -1
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/appLayout.tsx +4 -2
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/components/{TopBar.tsx → layout/TopBar.tsx} +2 -2
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/components/{MaintenanceRequestList.tsx → maintenanceRequests/MaintenanceRequestList.tsx} +4 -4
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/components/{MaintenanceRequestListItem.tsx → maintenanceRequests/MaintenanceRequestListItem.tsx} +3 -3
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/components/maintenanceRequests/MaintenanceSummaryDetailsModal.tsx +87 -0
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/components/{PropertyListingCard.tsx → properties/PropertyListingCard.tsx} +1 -1
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/{features/global-search/components/search/SearchPagination.tsx → components/properties/PropertyListingSearchPagination.tsx} +20 -28
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/constants/propertyListing.ts +4 -0
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/object-search/__examples__/api/accountSearchService.ts +46 -0
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/object-search/__examples__/api/query/distinctAccountIndustries.graphql +19 -0
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/object-search/__examples__/api/query/distinctAccountTypes.graphql +19 -0
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/object-search/__examples__/api/query/getAccountDetail.graphql +121 -0
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/object-search/__examples__/api/query/searchAccounts.graphql +51 -0
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/object-search/__examples__/pages/AccountObjectDetailPage.tsx +357 -0
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/object-search/__examples__/pages/AccountSearch.tsx +303 -0
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/object-search/__examples__/pages/Home.tsx +34 -0
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/object-search/api/objectSearchService.ts +84 -0
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/object-search/components/ActiveFilters.tsx +89 -0
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/object-search/components/FilterContext.tsx +73 -0
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/object-search/components/ObjectBreadcrumb.tsx +66 -0
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/object-search/components/PaginationControls.tsx +109 -0
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/object-search/components/SearchBar.tsx +41 -0
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/object-search/components/SortControl.tsx +143 -0
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/object-search/components/filters/BooleanFilter.tsx +74 -0
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/object-search/components/filters/DateFilter.tsx +121 -0
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/object-search/components/filters/DateRangeFilter.tsx +69 -0
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/object-search/components/filters/MultiSelectFilter.tsx +98 -0
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/object-search/components/filters/NumericRangeFilter.tsx +85 -0
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/object-search/components/filters/SearchFilter.tsx +37 -0
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/object-search/components/filters/SelectFilter.tsx +93 -0
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/object-search/components/filters/TextFilter.tsx +74 -0
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/object-search/hooks/useAsyncData.ts +54 -0
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/object-search/hooks/useCachedAsyncData.ts +184 -0
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/object-search/hooks/useObjectSearchParams.ts +247 -0
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/object-search/utils/debounce.ts +22 -0
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/object-search/utils/fieldUtils.ts +29 -0
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/object-search/utils/filterUtils.ts +372 -0
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/object-search/utils/sortUtils.ts +38 -0
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/hooks/useMaintenanceRequests.ts +1 -1
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/hooks/usePropertyAddresses.ts +2 -2
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/hooks/usePropertyDetail.ts +1 -1
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/hooks/usePropertyListingAmenities.ts +2 -2
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/hooks/usePropertyListingSearch.ts +2 -2
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/hooks/usePropertyMapMarkers.ts +3 -3
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/hooks/usePropertyPrimaryImages.ts +2 -2
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/pages/Application.tsx +3 -3
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/pages/Dashboard.tsx +2 -2
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/pages/Home.tsx +4 -2
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/pages/Maintenance.tsx +2 -2
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/pages/PropertyDetails.tsx +1 -1
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/pages/PropertySearch.tsx +12 -10
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/routes.tsx +6 -18
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/utils/propertyListingPaginationUtils.ts +18 -0
- package/dist/package-lock.json +2 -2
- package/dist/package.json +1 -1
- package/dist/scripts/graphql-search.sh +69 -17
- package/package.json +1 -1
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/components/MaintenanceDetailsModal.tsx +0 -128
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/api/objectDetailService.ts +0 -102
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/api/objectInfoGraphQLService.ts +0 -137
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/api/objectInfoService.ts +0 -95
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/api/recordListGraphQLService.ts +0 -364
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/components/detail/DetailFields.tsx +0 -55
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/components/detail/DetailForm.tsx +0 -146
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/components/detail/DetailHeader.tsx +0 -34
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/components/detail/DetailLayoutSections.tsx +0 -80
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/components/detail/Section.tsx +0 -108
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/components/detail/SectionRow.tsx +0 -20
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/components/detail/UiApiDetailForm.tsx +0 -140
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/components/detail/formatted/FieldValueDisplay.tsx +0 -73
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/components/detail/formatted/FormattedAddress.tsx +0 -29
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/components/detail/formatted/FormattedEmail.tsx +0 -17
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/components/detail/formatted/FormattedPhone.tsx +0 -24
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/components/detail/formatted/FormattedText.tsx +0 -11
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/components/detail/formatted/FormattedUrl.tsx +0 -29
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/components/filters/FilterField.tsx +0 -54
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/components/filters/FilterInput.tsx +0 -55
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/components/filters/FilterSelect.tsx +0 -72
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/components/filters/FiltersPanel.tsx +0 -380
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/components/forms/filters-form.tsx +0 -114
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/components/forms/submit-button.tsx +0 -47
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/components/search/GlobalSearchInput.tsx +0 -114
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/components/search/ResultCardFields.tsx +0 -71
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/components/search/SearchHeader.tsx +0 -31
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/components/search/SearchResultCard.tsx +0 -138
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/components/search/SearchResultsPanel.tsx +0 -197
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/components/shared/LoadingFallback.tsx +0 -61
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/constants.ts +0 -39
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/filters/FilterInput.tsx +0 -55
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/filters/FilterSelect.tsx +0 -72
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/hooks/form.tsx +0 -209
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/hooks/useObjectInfoBatch.ts +0 -72
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/hooks/useObjectSearchData.ts +0 -174
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/hooks/useRecordDetailLayout.ts +0 -137
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/hooks/useRecordListGraphQL.ts +0 -135
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/pages/DetailPage.tsx +0 -109
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/pages/GlobalSearch.tsx +0 -235
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/types/filters/filters.ts +0 -121
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/types/filters/picklist.ts +0 -6
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/types/objectInfo/objectInfo.ts +0 -49
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/types/recordDetail/recordDetail.ts +0 -61
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/types/schema.d.ts +0 -200
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/utils/apiUtils.ts +0 -59
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/utils/cacheUtils.ts +0 -76
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/utils/debounce.ts +0 -90
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/utils/fieldUtils.ts +0 -354
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/utils/fieldValueExtractor.ts +0 -67
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/utils/filterUtils.ts +0 -32
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/utils/formDataTransformUtils.ts +0 -260
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/utils/formUtils.ts +0 -142
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/utils/graphQLNodeFieldUtils.ts +0 -186
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/utils/graphQLObjectInfoAdapter.ts +0 -77
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/utils/graphQLRecordAdapter.ts +0 -90
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/utils/layoutTransformUtils.ts +0 -236
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/utils/linkUtils.ts +0 -14
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/utils/paginationUtils.ts +0 -49
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/utils/recordUtils.ts +0 -159
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/features/global-search/utils/sanitizationUtils.ts +0 -50
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/hooks/usePropertyListingPriceRange.ts +0 -64
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/index.ts +0 -120
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/pages/About.tsx +0 -8
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/pages/HelpCenter.tsx +0 -29
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/pages/PropertyListings.tsx +0 -100
- /package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/api/{applicationApi.ts → applications/applicationApi.ts} +0 -0
- /package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/api/{maintenanceRequestApi.ts → maintenanceRequests/maintenanceRequestApi.ts} +0 -0
- /package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/api/{propertyDetailGraphQL.ts → properties/propertyDetailGraphQL.ts} +0 -0
- /package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/components/{WeatherWidget.tsx → dashboard/WeatherWidget.tsx} +0 -0
- /package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/components/{NavMenu.tsx → layout/VerticalNav.tsx} +0 -0
- /package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/components/{MaintenanceRequestIcon.tsx → maintenanceRequests/MaintenanceRequestIcon.tsx} +0 -0
- /package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/components/{StatusBadge.tsx → maintenanceRequests/StatusBadge.tsx} +0 -0
- /package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/components/{PropertyMap.tsx → properties/PropertyMap.tsx} +0 -0
- /package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/components/{PropertySearchFilters.tsx → properties/PropertySearchFilters.tsx} +0 -0
- /package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/{features/global-search/types/search → types}/searchResults.ts +0 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Page size options for property listing (token-based) pagination.
|
|
3
|
+
*/
|
|
4
|
+
export const PAGE_SIZE_OPTIONS = [
|
|
5
|
+
{ value: "10", label: "10" },
|
|
6
|
+
{ value: "20", label: "20" },
|
|
7
|
+
{ value: "50", label: "50" },
|
|
8
|
+
] as const;
|
|
9
|
+
|
|
10
|
+
export const VALID_PAGE_SIZES = PAGE_SIZE_OPTIONS.map((opt) => parseInt(opt.value, 10));
|
|
11
|
+
|
|
12
|
+
export function isValidPageSize(size: number): boolean {
|
|
13
|
+
return VALID_PAGE_SIZES.includes(size);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function getValidPageSize(size: number): number {
|
|
17
|
+
return isValidPageSize(size) ? size : VALID_PAGE_SIZES[0];
|
|
18
|
+
}
|
package/dist/package-lock.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/webapp-template-base-sfdx-project-experimental",
|
|
3
|
-
"version": "1.112.
|
|
3
|
+
"version": "1.112.9",
|
|
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.112.
|
|
9
|
+
"version": "1.112.9",
|
|
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,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail # exit on error (-e), undefined vars (-u), and propagate pipeline failures (-o pipefail)
|
|
2
3
|
# graphql-search.sh — Look up one or more Salesforce entities in schema.graphql.
|
|
3
4
|
#
|
|
4
5
|
# Run from the SFDX project root (where schema.graphql lives):
|
|
@@ -10,11 +11,13 @@
|
|
|
10
11
|
# bash scripts/graphql-search.sh --schema ./other/schema.graphql Account Contact
|
|
11
12
|
#
|
|
12
13
|
# Output sections per entity:
|
|
13
|
-
# 1. Type definition
|
|
14
|
-
# 2. Filter options
|
|
15
|
-
# 3. Sort options
|
|
16
|
-
# 4. Create
|
|
17
|
-
# 5.
|
|
14
|
+
# 1. Type definition — all fields and relationships
|
|
15
|
+
# 2. Filter options — <Entity>_Filter input (for `where:`)
|
|
16
|
+
# 3. Sort options — <Entity>_OrderBy input (for `orderBy:`)
|
|
17
|
+
# 4. Create mutation wrapper — <Entity>CreateInput
|
|
18
|
+
# 5. Create mutation fields — <Entity>CreateRepresentation (for create mutations)
|
|
19
|
+
# 6. Update mutation wrapper — <Entity>UpdateInput
|
|
20
|
+
# 7. Update mutation fields — <Entity>UpdateRepresentation (for update mutations)
|
|
18
21
|
|
|
19
22
|
SCHEMA="./schema.graphql"
|
|
20
23
|
|
|
@@ -62,6 +65,19 @@ if [ ! -f "$SCHEMA" ]; then
|
|
|
62
65
|
exit 1
|
|
63
66
|
fi
|
|
64
67
|
|
|
68
|
+
if [ ! -r "$SCHEMA" ]; then
|
|
69
|
+
echo "ERROR: schema.graphql is not readable at $SCHEMA"
|
|
70
|
+
echo " Check file permissions: ls -la $SCHEMA"
|
|
71
|
+
exit 1
|
|
72
|
+
fi
|
|
73
|
+
|
|
74
|
+
if [ ! -s "$SCHEMA" ]; then
|
|
75
|
+
echo "ERROR: schema.graphql is empty at $SCHEMA"
|
|
76
|
+
echo " Regenerate it from the webapp dir:"
|
|
77
|
+
echo " cd force-app/main/default/webapplications/<app-name> && npm run graphql:schema"
|
|
78
|
+
exit 1
|
|
79
|
+
fi
|
|
80
|
+
|
|
65
81
|
# ── Helper: extract lines from a grep match through the closing brace ────────
|
|
66
82
|
# Prints up to MAX_LINES lines after (and including) the first match of PATTERN.
|
|
67
83
|
# Uses a generous line count — blocks are always closed by a "}" line.
|
|
@@ -72,68 +88,104 @@ extract_block() {
|
|
|
72
88
|
local max_lines="$3"
|
|
73
89
|
|
|
74
90
|
local match
|
|
75
|
-
|
|
91
|
+
local grep_exit=0
|
|
92
|
+
match=$(grep -nE "$pattern" "$SCHEMA" | head -1) || grep_exit=$?
|
|
93
|
+
|
|
94
|
+
if [ "$grep_exit" -eq 2 ]; then
|
|
95
|
+
echo " ERROR: grep failed on pattern: $pattern" >&2
|
|
96
|
+
return 1
|
|
97
|
+
fi
|
|
76
98
|
|
|
77
99
|
if [ -z "$match" ]; then
|
|
78
100
|
echo " (not found: $pattern)"
|
|
79
|
-
return
|
|
101
|
+
return 3
|
|
80
102
|
fi
|
|
81
103
|
|
|
82
104
|
echo "### $label"
|
|
83
105
|
grep -E "$pattern" "$SCHEMA" -A "$max_lines" | \
|
|
84
106
|
awk '/^\}$/{print; exit} {print}' | \
|
|
85
|
-
head -n "$max_lines"
|
|
107
|
+
head -n "$max_lines" || true
|
|
86
108
|
echo ""
|
|
87
109
|
}
|
|
88
110
|
|
|
89
111
|
# ── Main loop ────────────────────────────────────────────────────────────────
|
|
90
112
|
|
|
91
113
|
for ENTITY in "$@"; do
|
|
114
|
+
# Validate entity name: must be a valid PascalCase identifier (letters, digits, underscores)
|
|
115
|
+
if [[ ! "$ENTITY" =~ ^[A-Za-z_][A-Za-z0-9_]*$ ]]; then
|
|
116
|
+
echo "ERROR: Invalid entity name: '$ENTITY'"
|
|
117
|
+
echo " Entity names must start with a letter or underscore, followed by letters, digits, or underscores."
|
|
118
|
+
echo " Examples: Account, My_Custom_Object__c"
|
|
119
|
+
continue
|
|
120
|
+
fi
|
|
121
|
+
|
|
92
122
|
echo ""
|
|
93
123
|
echo "======================================================================"
|
|
94
124
|
echo " SCHEMA LOOKUP: $ENTITY"
|
|
95
125
|
echo "======================================================================"
|
|
96
126
|
echo ""
|
|
97
127
|
|
|
128
|
+
found=0
|
|
129
|
+
|
|
130
|
+
# Helper: call extract_block, track matches, surface errors
|
|
131
|
+
try_extract() {
|
|
132
|
+
local rc=0
|
|
133
|
+
extract_block "$@" || rc=$?
|
|
134
|
+
if [ "$rc" -eq 0 ]; then
|
|
135
|
+
found=$((found + 1))
|
|
136
|
+
elif [ "$rc" -eq 1 ]; then
|
|
137
|
+
echo " Aborting lookup for '$ENTITY' due to grep error" >&2
|
|
138
|
+
fi
|
|
139
|
+
# rc=3 is not-found — continue silently (already printed by extract_block)
|
|
140
|
+
}
|
|
141
|
+
|
|
98
142
|
# 1. Type definition — all fields and relationships
|
|
99
|
-
|
|
143
|
+
try_extract \
|
|
100
144
|
"Type definition — fields and relationships" \
|
|
101
145
|
"^type ${ENTITY} implements Record" \
|
|
102
146
|
200
|
|
103
147
|
|
|
104
148
|
# 2. Filter input — used in `where:` arguments
|
|
105
|
-
|
|
149
|
+
try_extract \
|
|
106
150
|
"Filter options — use in where: { ... }" \
|
|
107
151
|
"^input ${ENTITY}_Filter" \
|
|
108
152
|
100
|
|
109
153
|
|
|
110
154
|
# 3. OrderBy input — used in `orderBy:` arguments
|
|
111
|
-
|
|
155
|
+
try_extract \
|
|
112
156
|
"Sort options — use in orderBy: { ... }" \
|
|
113
157
|
"^input ${ENTITY}_OrderBy" \
|
|
114
158
|
60
|
|
115
159
|
|
|
116
|
-
# 4. Create mutation
|
|
117
|
-
|
|
160
|
+
# 4. Create mutation wrapper
|
|
161
|
+
try_extract \
|
|
118
162
|
"Create mutation wrapper — ${ENTITY}CreateInput" \
|
|
119
163
|
"^input ${ENTITY}CreateInput" \
|
|
120
164
|
10
|
|
121
165
|
|
|
122
|
-
|
|
166
|
+
# 5. Create mutation fields
|
|
167
|
+
try_extract \
|
|
123
168
|
"Create mutation fields — ${ENTITY}CreateRepresentation" \
|
|
124
169
|
"^input ${ENTITY}CreateRepresentation" \
|
|
125
170
|
100
|
|
126
171
|
|
|
127
|
-
#
|
|
128
|
-
|
|
172
|
+
# 6. Update mutation wrapper
|
|
173
|
+
try_extract \
|
|
129
174
|
"Update mutation wrapper — ${ENTITY}UpdateInput" \
|
|
130
175
|
"^input ${ENTITY}UpdateInput" \
|
|
131
176
|
10
|
|
132
177
|
|
|
133
|
-
|
|
178
|
+
# 7. Update mutation fields
|
|
179
|
+
try_extract \
|
|
134
180
|
"Update mutation fields — ${ENTITY}UpdateRepresentation" \
|
|
135
181
|
"^input ${ENTITY}UpdateRepresentation" \
|
|
136
182
|
100
|
|
137
183
|
|
|
184
|
+
if [ "$found" -eq 0 ]; then
|
|
185
|
+
echo "WARNING: No schema entries found for '$ENTITY'."
|
|
186
|
+
echo " - Names are PascalCase (e.g., 'Account' not 'account')"
|
|
187
|
+
echo " - Custom objects may need deployment first"
|
|
188
|
+
fi
|
|
189
|
+
|
|
138
190
|
echo ""
|
|
139
191
|
done
|
package/package.json
CHANGED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Modal showing maintenance request details. Read-only (no status update in B2X).
|
|
3
|
-
* Layout matches B2E MaintenanceDetailsModal.
|
|
4
|
-
*/
|
|
5
|
-
import { useEffect } from "react";
|
|
6
|
-
import { X } from "lucide-react";
|
|
7
|
-
import { StatusBadge } from "@/components/StatusBadge";
|
|
8
|
-
import type { MaintenanceRequestSummary } from "@/api/maintenanceRequestApi";
|
|
9
|
-
|
|
10
|
-
export interface MaintenanceDetailsModalProps {
|
|
11
|
-
request: MaintenanceRequestSummary;
|
|
12
|
-
onClose: () => void;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function formatDate(value: string | null): string {
|
|
16
|
-
if (!value?.trim()) return "—";
|
|
17
|
-
try {
|
|
18
|
-
const d = new Date(value);
|
|
19
|
-
return d.toLocaleDateString("en-US", {
|
|
20
|
-
month: "short",
|
|
21
|
-
day: "numeric",
|
|
22
|
-
year: "numeric",
|
|
23
|
-
hour: "numeric",
|
|
24
|
-
minute: "2-digit",
|
|
25
|
-
hour12: true,
|
|
26
|
-
});
|
|
27
|
-
} catch {
|
|
28
|
-
return value;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export default function MaintenanceDetailsModal({
|
|
33
|
-
request,
|
|
34
|
-
onClose,
|
|
35
|
-
}: MaintenanceDetailsModalProps) {
|
|
36
|
-
useEffect(() => {
|
|
37
|
-
const handleEscape = (e: KeyboardEvent) => {
|
|
38
|
-
if (e.key === "Escape") onClose();
|
|
39
|
-
};
|
|
40
|
-
document.addEventListener("keydown", handleEscape);
|
|
41
|
-
return () => document.removeEventListener("keydown", handleEscape);
|
|
42
|
-
}, [onClose]);
|
|
43
|
-
|
|
44
|
-
const description = request.description?.trim() || request.title?.trim() || "—";
|
|
45
|
-
|
|
46
|
-
return (
|
|
47
|
-
<div className="fixed inset-0 z-50 flex items-center justify-center">
|
|
48
|
-
{/* Backdrop */}
|
|
49
|
-
<div className="fixed inset-0 bg-black/50" onClick={onClose} aria-hidden />
|
|
50
|
-
|
|
51
|
-
{/* Modal */}
|
|
52
|
-
<div
|
|
53
|
-
className="relative z-10 w-full max-w-2xl mx-4 max-h-[90vh] overflow-y-auto rounded-2xl bg-card shadow-xl border border-border"
|
|
54
|
-
role="dialog"
|
|
55
|
-
aria-modal="true"
|
|
56
|
-
aria-labelledby="maintenance-details-title"
|
|
57
|
-
>
|
|
58
|
-
{/* Header */}
|
|
59
|
-
<div className="flex items-center justify-between border-b border-border p-6">
|
|
60
|
-
<h2 id="maintenance-details-title" className="text-xl font-semibold text-foreground">
|
|
61
|
-
Maintenance Request Details
|
|
62
|
-
</h2>
|
|
63
|
-
<button
|
|
64
|
-
type="button"
|
|
65
|
-
onClick={onClose}
|
|
66
|
-
className="rounded-lg p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring"
|
|
67
|
-
aria-label="Close"
|
|
68
|
-
>
|
|
69
|
-
<X className="size-6" />
|
|
70
|
-
</button>
|
|
71
|
-
</div>
|
|
72
|
-
|
|
73
|
-
{/* Content */}
|
|
74
|
-
<div className="space-y-6 p-6">
|
|
75
|
-
<div>
|
|
76
|
-
<h3 className="mb-2 text-sm font-semibold uppercase tracking-wide text-muted-foreground">
|
|
77
|
-
Description
|
|
78
|
-
</h3>
|
|
79
|
-
<p className="text-base text-foreground">{description}</p>
|
|
80
|
-
</div>
|
|
81
|
-
|
|
82
|
-
<div className="grid grid-cols-2 gap-4">
|
|
83
|
-
<div>
|
|
84
|
-
<h3 className="mb-2 text-sm font-semibold uppercase tracking-wide text-muted-foreground">
|
|
85
|
-
Issue Type
|
|
86
|
-
</h3>
|
|
87
|
-
<p className="text-base text-foreground">{request.type ?? "—"}</p>
|
|
88
|
-
</div>
|
|
89
|
-
<div>
|
|
90
|
-
<h3 className="mb-2 text-sm font-semibold uppercase tracking-wide text-muted-foreground">
|
|
91
|
-
Priority
|
|
92
|
-
</h3>
|
|
93
|
-
<p className="text-base text-foreground">{request.priority ?? "—"}</p>
|
|
94
|
-
</div>
|
|
95
|
-
</div>
|
|
96
|
-
|
|
97
|
-
<div>
|
|
98
|
-
<h3 className="mb-2 text-sm font-semibold uppercase tracking-wide text-muted-foreground">
|
|
99
|
-
Property
|
|
100
|
-
</h3>
|
|
101
|
-
<p className="text-base text-foreground">{request.propertyAddress?.trim() || "—"}</p>
|
|
102
|
-
</div>
|
|
103
|
-
|
|
104
|
-
<div>
|
|
105
|
-
<h3 className="mb-2 text-sm font-semibold uppercase tracking-wide text-muted-foreground">
|
|
106
|
-
Tenant
|
|
107
|
-
</h3>
|
|
108
|
-
<p className="text-base text-foreground">{request.tenantName?.trim() || "—"}</p>
|
|
109
|
-
</div>
|
|
110
|
-
|
|
111
|
-
<div>
|
|
112
|
-
<h3 className="mb-2 text-sm font-semibold uppercase tracking-wide text-muted-foreground">
|
|
113
|
-
Scheduled Date
|
|
114
|
-
</h3>
|
|
115
|
-
<p className="text-base text-foreground">{formatDate(request.dateRequested)}</p>
|
|
116
|
-
</div>
|
|
117
|
-
|
|
118
|
-
<div>
|
|
119
|
-
<h3 className="mb-2 text-sm font-semibold uppercase tracking-wide text-muted-foreground">
|
|
120
|
-
Status
|
|
121
|
-
</h3>
|
|
122
|
-
<StatusBadge status={request.status ?? "—"} />
|
|
123
|
-
</div>
|
|
124
|
-
</div>
|
|
125
|
-
</div>
|
|
126
|
-
</div>
|
|
127
|
-
);
|
|
128
|
-
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Record detail service: layout (REST), object metadata (GraphQL), single record (GraphQL).
|
|
3
|
-
*
|
|
4
|
-
* getRecordDetail orchestrates layout + objectInfoBatch + getRecordByIdGraphQL for the detail page.
|
|
5
|
-
* Layout is still REST (uiApiClient); record and object info are GraphQL-backed.
|
|
6
|
-
*
|
|
7
|
-
* @module api/objectDetailService
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { uiApiClient } from "@salesforce/webapp-experimental/api";
|
|
11
|
-
import type { LayoutResponse } from "../types/recordDetail/recordDetail";
|
|
12
|
-
import { LayoutResponseSchema } from "../types/recordDetail/recordDetail";
|
|
13
|
-
import { fetchAndValidate, safeEncodePath } from "../utils/apiUtils";
|
|
14
|
-
import { objectInfoService } from "./objectInfoService";
|
|
15
|
-
import type { ObjectInfoResult } from "../types/objectInfo/objectInfo";
|
|
16
|
-
import { getRecordByIdGraphQL, type GraphQLRecordNode } from "./recordListGraphQLService";
|
|
17
|
-
import type { Column } from "../types/search/searchResults";
|
|
18
|
-
import { calculateFieldsToFetch } from "../utils/recordUtils";
|
|
19
|
-
|
|
20
|
-
/** Fallback when record type is unknown. Prefer recordTypeId from the record (e.g. from search or record response) when available. */
|
|
21
|
-
const DEFAULT_RECORD_TYPE_ID = "012000000000000AAA";
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Returns field API names to request for a record from the given layout and object metadata.
|
|
25
|
-
* Used to derive GraphQL columns from layout (detail view). Delegates to recordUtils.calculateFieldsToFetch.
|
|
26
|
-
*
|
|
27
|
-
* @param objectMetadata - Object info (fields, relationshipName, etc.).
|
|
28
|
-
* @param layout - Layout response (sections, layoutItems, layoutComponents).
|
|
29
|
-
* @returns Array of field API names (e.g. ["Name", "OwnerId", "Owner", "CreatedDate"]).
|
|
30
|
-
*/
|
|
31
|
-
export function extractFieldsFromLayout(
|
|
32
|
-
objectMetadata: ObjectInfoResult,
|
|
33
|
-
layout: LayoutResponse,
|
|
34
|
-
): string[] {
|
|
35
|
-
const [optionalFields] = calculateFieldsToFetch(objectMetadata, layout, false);
|
|
36
|
-
return optionalFields;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export async function getLayout(
|
|
40
|
-
objectApiName: string,
|
|
41
|
-
recordTypeId: string = DEFAULT_RECORD_TYPE_ID,
|
|
42
|
-
): Promise<LayoutResponse> {
|
|
43
|
-
const params = new URLSearchParams({
|
|
44
|
-
layoutType: "Full",
|
|
45
|
-
mode: "View",
|
|
46
|
-
recordTypeId,
|
|
47
|
-
});
|
|
48
|
-
return fetchAndValidate(
|
|
49
|
-
() => uiApiClient.get(`/layout/${safeEncodePath(objectApiName)}?${params.toString()}`),
|
|
50
|
-
{
|
|
51
|
-
schema: LayoutResponseSchema,
|
|
52
|
-
errorContext: `layout for ${objectApiName}`,
|
|
53
|
-
},
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export interface RecordDetailResult {
|
|
58
|
-
layout: LayoutResponse;
|
|
59
|
-
record: GraphQLRecordNode;
|
|
60
|
-
objectMetadata: ObjectInfoResult;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Converts layout-derived optionalFields (field API names) to Column[] for GraphQL node selection.
|
|
65
|
-
* Uses unqualified names (no entity prefix) so the GraphQL query matches UI API shape.
|
|
66
|
-
* Other Column fields (label, searchable, sortable) are only required by the type; GraphQL selection uses fieldApiName only.
|
|
67
|
-
*/
|
|
68
|
-
function optionalFieldsToColumns(optionalFields: string[]): Column[] {
|
|
69
|
-
return optionalFields.map((fieldApiName) => ({
|
|
70
|
-
fieldApiName,
|
|
71
|
-
label: "",
|
|
72
|
-
searchable: false,
|
|
73
|
-
sortable: false,
|
|
74
|
-
}));
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export async function getRecordDetail(
|
|
78
|
-
objectApiName: string,
|
|
79
|
-
recordId: string,
|
|
80
|
-
recordTypeId: string = DEFAULT_RECORD_TYPE_ID,
|
|
81
|
-
): Promise<RecordDetailResult> {
|
|
82
|
-
const layout = await getLayout(objectApiName, recordTypeId);
|
|
83
|
-
const objectMetadata = await objectInfoService.getObjectInfoBatch(objectApiName);
|
|
84
|
-
const firstResult = objectMetadata?.results?.[0]?.result;
|
|
85
|
-
if (!firstResult) {
|
|
86
|
-
throw new Error(`Object metadata not found for ${objectApiName}`);
|
|
87
|
-
}
|
|
88
|
-
// Layout-driven optionalFields (fields shown on the detail layout), not list columns
|
|
89
|
-
const [optionalFields] = calculateFieldsToFetch(firstResult, layout, false);
|
|
90
|
-
const columns = optionalFieldsToColumns(optionalFields);
|
|
91
|
-
const record = await getRecordByIdGraphQL(objectApiName, recordId, columns);
|
|
92
|
-
if (!record) {
|
|
93
|
-
throw new Error(`Record not found: ${recordId}`);
|
|
94
|
-
}
|
|
95
|
-
return { layout, record, objectMetadata: firstResult };
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export const objectDetailService = {
|
|
99
|
-
extractFieldsFromLayout,
|
|
100
|
-
getLayout,
|
|
101
|
-
getRecordDetail,
|
|
102
|
-
};
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Object metadata GraphQL service (uiapi.objectInfos).
|
|
3
|
-
*
|
|
4
|
-
* Single endpoint for object describe and picklist values. Used by objectInfoService
|
|
5
|
-
* to implement getObjectInfoBatch and getPicklistValues. Not used directly by UI.
|
|
6
|
-
*
|
|
7
|
-
* @module api/objectInfoGraphQLService
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { createDataSDK, gql } from "@salesforce/sdk-data";
|
|
11
|
-
import type {
|
|
12
|
-
GetObjectInfosQuery,
|
|
13
|
-
GetObjectInfosQueryVariables,
|
|
14
|
-
GetPicklistValuesQuery,
|
|
15
|
-
GetPicklistValuesQueryVariables,
|
|
16
|
-
ObjectInfoInput,
|
|
17
|
-
} from "../types/schema";
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Builds objectInfos query (metadata only). Uses apiNames only — do not pass objectInfoInputs.
|
|
21
|
-
*/
|
|
22
|
-
const OBJECT_INFOS_QUERY = gql`
|
|
23
|
-
query GetObjectInfos($apiNames: [String!]!) {
|
|
24
|
-
uiapi {
|
|
25
|
-
objectInfos(apiNames: $apiNames) {
|
|
26
|
-
ApiName
|
|
27
|
-
label
|
|
28
|
-
labelPlural
|
|
29
|
-
nameFields
|
|
30
|
-
defaultRecordTypeId
|
|
31
|
-
keyPrefix
|
|
32
|
-
layoutable
|
|
33
|
-
queryable
|
|
34
|
-
searchable
|
|
35
|
-
updateable
|
|
36
|
-
deletable
|
|
37
|
-
createable
|
|
38
|
-
custom
|
|
39
|
-
mruEnabled
|
|
40
|
-
feedEnabled
|
|
41
|
-
fields {
|
|
42
|
-
ApiName
|
|
43
|
-
label
|
|
44
|
-
dataType
|
|
45
|
-
relationshipName
|
|
46
|
-
reference
|
|
47
|
-
compound
|
|
48
|
-
compoundFieldName
|
|
49
|
-
compoundComponentName
|
|
50
|
-
controllingFields
|
|
51
|
-
controllerName
|
|
52
|
-
referenceToInfos {
|
|
53
|
-
ApiName
|
|
54
|
-
nameFields
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
recordTypeInfos {
|
|
58
|
-
recordTypeId
|
|
59
|
-
name
|
|
60
|
-
master
|
|
61
|
-
available
|
|
62
|
-
defaultRecordTypeMapping
|
|
63
|
-
}
|
|
64
|
-
themeInfo {
|
|
65
|
-
color
|
|
66
|
-
iconUrl
|
|
67
|
-
}
|
|
68
|
-
childRelationships {
|
|
69
|
-
relationshipName
|
|
70
|
-
fieldName
|
|
71
|
-
childObjectApiName
|
|
72
|
-
}
|
|
73
|
-
dependentFields {
|
|
74
|
-
controllingField
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
`;
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Builds objectInfos query with picklist values (API v65.0+).
|
|
83
|
-
* Schema requires objectInfos to be called with either apiNames or objectInfoInputs, not both.
|
|
84
|
-
* This query uses objectInfoInputs only.
|
|
85
|
-
* Optimized to only fetch fields used by extractPicklistValuesFromGraphQLObjectInfo.
|
|
86
|
-
*/
|
|
87
|
-
const PICKLIST_VALUES_QUERY = gql`
|
|
88
|
-
query GetPicklistValues($objectInfoInputs: [ObjectInfoInput!]!) {
|
|
89
|
-
uiapi {
|
|
90
|
-
objectInfos(objectInfoInputs: $objectInfoInputs) {
|
|
91
|
-
ApiName
|
|
92
|
-
fields {
|
|
93
|
-
ApiName
|
|
94
|
-
... on PicklistField {
|
|
95
|
-
picklistValuesByRecordTypeIDs {
|
|
96
|
-
recordTypeID
|
|
97
|
-
defaultValue {
|
|
98
|
-
value
|
|
99
|
-
}
|
|
100
|
-
picklistValues {
|
|
101
|
-
label
|
|
102
|
-
value
|
|
103
|
-
validFor
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
`;
|
|
112
|
-
|
|
113
|
-
export async function queryForObjectInfos(apiNames: string[]): Promise<GetObjectInfosQuery> {
|
|
114
|
-
return runQuery<GetObjectInfosQuery, GetObjectInfosQueryVariables>(OBJECT_INFOS_QUERY, {
|
|
115
|
-
apiNames,
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export async function queryForPicklistValues(
|
|
120
|
-
objectInfoInputs: ObjectInfoInput[],
|
|
121
|
-
): Promise<GetPicklistValuesQuery> {
|
|
122
|
-
return runQuery<GetPicklistValuesQuery, GetPicklistValuesQueryVariables>(PICKLIST_VALUES_QUERY, {
|
|
123
|
-
objectInfoInputs,
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
async function runQuery<Q, V>(query: string, variables: V): Promise<Q> {
|
|
128
|
-
const data = await createDataSDK();
|
|
129
|
-
const response = await data.graphql?.<Q, V>(query, variables);
|
|
130
|
-
|
|
131
|
-
if (response?.errors?.length) {
|
|
132
|
-
const errorMessages = response.errors.map((e) => e.message).join("; ");
|
|
133
|
-
throw new Error(`GraphQL Error: ${errorMessages}`);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
return response?.data ?? ({} as Q);
|
|
137
|
-
}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { uiApiClient } from "@salesforce/webapp-experimental/api";
|
|
2
|
-
import type { Filter } from "../types/filters/filters";
|
|
3
|
-
import { FilterArraySchema } from "../types/filters/filters";
|
|
4
|
-
import type { PicklistValue } from "../types/filters/picklist";
|
|
5
|
-
import type { ObjectInfoBatchResponse } from "../types/objectInfo/objectInfo";
|
|
6
|
-
import { fetchAndValidate, safeEncodePath } from "../utils/apiUtils";
|
|
7
|
-
import { queryForObjectInfos, queryForPicklistValues } from "./objectInfoGraphQLService";
|
|
8
|
-
import {
|
|
9
|
-
graphQLObjectInfosToBatchResponse,
|
|
10
|
-
extractPicklistValuesFromGraphQLObjectInfo,
|
|
11
|
-
} from "../utils/graphQLObjectInfoAdapter";
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Object info and search service.
|
|
15
|
-
*
|
|
16
|
-
* - getObjectInfoBatch / getPicklistValues: GraphQL (objectInfoGraphQLService).
|
|
17
|
-
* - getObjectListFilters: REST (search-info).
|
|
18
|
-
* Hooks use this service; components do not call it directly.
|
|
19
|
-
*
|
|
20
|
-
* @module api/objectInfoService
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
/** Cache key: sorted, comma-joined object API names. */
|
|
24
|
-
function getObjectInfoBatchCacheKey(objectApiNames: string): string {
|
|
25
|
-
const names = objectApiNames
|
|
26
|
-
.split(",")
|
|
27
|
-
.map((s) => s.trim())
|
|
28
|
-
.filter(Boolean);
|
|
29
|
-
return [...names].sort().join(",");
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const objectInfoBatchCache = new Map<string, ObjectInfoBatchResponse>();
|
|
33
|
-
const objectInfoBatchInFlight = new Map<string, Promise<ObjectInfoBatchResponse>>();
|
|
34
|
-
|
|
35
|
-
export async function getObjectInfoBatch(objectApiNames: string): Promise<ObjectInfoBatchResponse> {
|
|
36
|
-
const names = objectApiNames
|
|
37
|
-
.split(",")
|
|
38
|
-
.map((s) => s.trim())
|
|
39
|
-
.filter(Boolean);
|
|
40
|
-
if (names.length === 0) {
|
|
41
|
-
return { results: [] };
|
|
42
|
-
}
|
|
43
|
-
const key = getObjectInfoBatchCacheKey(objectApiNames);
|
|
44
|
-
const cached = objectInfoBatchCache.get(key);
|
|
45
|
-
if (cached) return Promise.resolve(cached);
|
|
46
|
-
const inFlight = objectInfoBatchInFlight.get(key);
|
|
47
|
-
if (inFlight) return inFlight;
|
|
48
|
-
const promise = (async () => {
|
|
49
|
-
try {
|
|
50
|
-
const response = await queryForObjectInfos(names);
|
|
51
|
-
const nodes = response?.uiapi?.objectInfos ?? [];
|
|
52
|
-
const result = graphQLObjectInfosToBatchResponse(nodes, names);
|
|
53
|
-
objectInfoBatchCache.set(key, result);
|
|
54
|
-
return result;
|
|
55
|
-
} finally {
|
|
56
|
-
objectInfoBatchInFlight.delete(key);
|
|
57
|
-
}
|
|
58
|
-
})();
|
|
59
|
-
objectInfoBatchInFlight.set(key, promise);
|
|
60
|
-
return promise;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export async function getObjectListFilters(objectApiName: string): Promise<Filter[]> {
|
|
64
|
-
return fetchAndValidate(
|
|
65
|
-
() => uiApiClient.get(`/search-info/${safeEncodePath(objectApiName)}/filters`),
|
|
66
|
-
{
|
|
67
|
-
schema: FilterArraySchema,
|
|
68
|
-
errorContext: `filters for ${objectApiName}`,
|
|
69
|
-
extractData: (data: unknown) => {
|
|
70
|
-
if (!data) return [];
|
|
71
|
-
return Array.isArray(data) ? data : (data as { filters?: unknown }).filters || [];
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export async function getPicklistValues(
|
|
78
|
-
objectApiName: string,
|
|
79
|
-
fieldName: string,
|
|
80
|
-
recordTypeId: string = "012000000000000AAA",
|
|
81
|
-
): Promise<PicklistValue[]> {
|
|
82
|
-
const response = await queryForPicklistValues([
|
|
83
|
-
{ apiName: objectApiName, fieldNames: [fieldName] },
|
|
84
|
-
]);
|
|
85
|
-
const nodes = response?.uiapi?.objectInfos ?? [];
|
|
86
|
-
const node = nodes[0];
|
|
87
|
-
if (!node) return [];
|
|
88
|
-
return extractPicklistValuesFromGraphQLObjectInfo(node, fieldName, recordTypeId);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export const objectInfoService = {
|
|
92
|
-
getObjectInfoBatch,
|
|
93
|
-
getObjectListFilters,
|
|
94
|
-
getPicklistValues,
|
|
95
|
-
};
|