@salesforce/webapp-template-app-react-template-b2x-experimental 1.109.5 → 1.109.6

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.
Files changed (102) hide show
  1. package/dist/CHANGELOG.md +8 -0
  2. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/package.json +4 -3
  3. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/api/graphql-operations-types.ts +11260 -0
  4. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/components/ui/sonner.tsx +20 -0
  5. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/object-search/__examples__/api/accountSearchService.ts +46 -0
  6. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/object-search/__examples__/api/query/distinctAccountIndustries.graphql +19 -0
  7. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/object-search/__examples__/api/query/distinctAccountTypes.graphql +19 -0
  8. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/object-search/__examples__/api/query/getAccountDetail.graphql +121 -0
  9. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/object-search/__examples__/api/query/searchAccounts.graphql +51 -0
  10. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/object-search/__examples__/pages/AccountObjectDetailPage.tsx +357 -0
  11. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/object-search/__examples__/pages/AccountSearch.tsx +275 -0
  12. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/object-search/__examples__/pages/Home.tsx +34 -0
  13. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/object-search/api/objectSearchService.ts +84 -0
  14. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/object-search/components/ActiveFilters.tsx +89 -0
  15. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/object-search/components/FilterPanel.tsx +127 -0
  16. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/object-search/components/ObjectBreadcrumb.tsx +66 -0
  17. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/object-search/components/PaginationControls.tsx +151 -0
  18. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/object-search/components/SearchBar.tsx +41 -0
  19. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/object-search/components/SortControl.tsx +143 -0
  20. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/object-search/components/filters/BooleanFilter.tsx +94 -0
  21. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/object-search/components/filters/DateFilter.tsx +138 -0
  22. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/object-search/components/filters/DateRangeFilter.tsx +78 -0
  23. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/object-search/components/filters/MultiSelectFilter.tsx +106 -0
  24. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/object-search/components/filters/NumericRangeFilter.tsx +102 -0
  25. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/object-search/components/filters/SearchFilter.tsx +40 -0
  26. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/object-search/components/filters/SelectFilter.tsx +97 -0
  27. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/object-search/components/filters/TextFilter.tsx +77 -0
  28. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/object-search/hooks/useAsyncData.ts +53 -0
  29. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/object-search/hooks/useCachedAsyncData.ts +183 -0
  30. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/object-search/hooks/useObjectSearchParams.ts +225 -0
  31. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/object-search/utils/debounce.ts +22 -0
  32. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/object-search/utils/fieldUtils.ts +29 -0
  33. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/object-search/utils/filterUtils.ts +372 -0
  34. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/object-search/utils/sortUtils.ts +38 -0
  35. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/pages/Home.tsx +10 -11
  36. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/routes.tsx +8 -20
  37. package/dist/package-lock.json +2 -2
  38. package/dist/package.json +1 -1
  39. package/package.json +1 -1
  40. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/api/objectDetailService.ts +0 -102
  41. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/api/objectInfoGraphQLService.ts +0 -137
  42. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/api/objectInfoService.ts +0 -95
  43. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/api/recordListGraphQLService.ts +0 -364
  44. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/components/detail/DetailFields.tsx +0 -55
  45. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/components/detail/DetailForm.tsx +0 -146
  46. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/components/detail/DetailHeader.tsx +0 -34
  47. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/components/detail/DetailLayoutSections.tsx +0 -80
  48. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/components/detail/Section.tsx +0 -108
  49. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/components/detail/SectionRow.tsx +0 -20
  50. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/components/detail/UiApiDetailForm.tsx +0 -140
  51. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/components/detail/formatted/FieldValueDisplay.tsx +0 -73
  52. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/components/detail/formatted/FormattedAddress.tsx +0 -29
  53. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/components/detail/formatted/FormattedEmail.tsx +0 -17
  54. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/components/detail/formatted/FormattedPhone.tsx +0 -24
  55. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/components/detail/formatted/FormattedText.tsx +0 -11
  56. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/components/detail/formatted/FormattedUrl.tsx +0 -29
  57. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/components/filters/FilterField.tsx +0 -54
  58. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/components/filters/FilterInput.tsx +0 -55
  59. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/components/filters/FilterSelect.tsx +0 -72
  60. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/components/filters/FiltersPanel.tsx +0 -380
  61. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/components/forms/filters-form.tsx +0 -114
  62. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/components/forms/submit-button.tsx +0 -47
  63. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/components/search/GlobalSearchInput.tsx +0 -114
  64. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/components/search/ResultCardFields.tsx +0 -71
  65. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/components/search/SearchHeader.tsx +0 -31
  66. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/components/search/SearchPagination.tsx +0 -144
  67. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/components/search/SearchResultCard.tsx +0 -138
  68. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/components/search/SearchResultsPanel.tsx +0 -197
  69. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/components/shared/LoadingFallback.tsx +0 -61
  70. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/constants.ts +0 -39
  71. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/filters/FilterInput.tsx +0 -55
  72. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/filters/FilterSelect.tsx +0 -72
  73. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/hooks/form.tsx +0 -209
  74. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/hooks/useObjectInfoBatch.ts +0 -72
  75. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/hooks/useObjectSearchData.ts +0 -174
  76. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/hooks/useRecordDetailLayout.ts +0 -137
  77. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/hooks/useRecordListGraphQL.ts +0 -135
  78. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/pages/DetailPage.tsx +0 -109
  79. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/pages/GlobalSearch.tsx +0 -235
  80. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/types/filters/filters.ts +0 -121
  81. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/types/filters/picklist.ts +0 -6
  82. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/types/objectInfo/objectInfo.ts +0 -49
  83. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/types/recordDetail/recordDetail.ts +0 -61
  84. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/types/schema.d.ts +0 -200
  85. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/types/search/searchResults.ts +0 -229
  86. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/utils/apiUtils.ts +0 -59
  87. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/utils/cacheUtils.ts +0 -76
  88. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/utils/debounce.ts +0 -90
  89. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/utils/fieldUtils.ts +0 -354
  90. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/utils/fieldValueExtractor.ts +0 -67
  91. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/utils/filterUtils.ts +0 -32
  92. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/utils/formDataTransformUtils.ts +0 -260
  93. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/utils/formUtils.ts +0 -142
  94. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/utils/graphQLNodeFieldUtils.ts +0 -186
  95. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/utils/graphQLObjectInfoAdapter.ts +0 -77
  96. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/utils/graphQLRecordAdapter.ts +0 -90
  97. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/utils/layoutTransformUtils.ts +0 -236
  98. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/utils/linkUtils.ts +0 -14
  99. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/utils/paginationUtils.ts +0 -49
  100. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/utils/recordUtils.ts +0 -159
  101. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/features/global-search/utils/sanitizationUtils.ts +0 -50
  102. package/dist/force-app/main/default/webapplications/appreacttemplateb2x/src/index.ts +0 -120
@@ -1,13 +1,12 @@
1
- import { GlobalSearchInput } from "../features/global-search/components/search/GlobalSearchInput";
2
-
3
1
  export default function Home() {
4
- return (
5
- <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
6
- <div className="text-center">
7
- <h1 className="text-4xl font-bold text-gray-900 mb-4">Home</h1>
8
- <p className="text-lg text-gray-600 mb-8">Welcome to your React application.</p>
9
- </div>
10
- <GlobalSearchInput />
11
- </div>
12
- );
2
+ return (
3
+ <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
4
+ <div className="text-center">
5
+ <h1 className="text-4xl font-bold text-gray-900 mb-4">Home</h1>
6
+ <p className="text-lg text-gray-600 mb-8">
7
+ Welcome to your React application.
8
+ </p>
9
+ </div>
10
+ </div>
11
+ );
13
12
  }
@@ -1,5 +1,5 @@
1
1
  import type { RouteObject } from 'react-router';
2
- import Home from './pages/Home';
2
+ import Home from './features/object-search/__examples__/pages/Home';
3
3
  import NotFound from './pages/NotFound';
4
4
  import Login from "./features/authentication/pages/Login";
5
5
  import Register from "./features/authentication/pages/Register";
@@ -10,10 +10,8 @@ import ChangePassword from "./features/authentication/pages/ChangePassword";
10
10
  import AuthenticationRoute from "./features/authentication/layouts/authenticationRouteLayout";
11
11
  import PrivateRoute from "./features/authentication/layouts/privateRouteLayout";
12
12
  import { ROUTES } from "./features/authentication/authenticationConfig";
13
- import GlobalSearch from "./features/global-search/pages/GlobalSearch";
14
- import DetailPage from "./features/global-search/pages/DetailPage";
15
- import { Suspense } from "react";
16
- import LoadingFallback from "./features/global-search/components/shared/LoadingFallback";
13
+ import AccountSearch from "./features/object-search/__examples__/pages/AccountSearch";
14
+ import AccountObjectDetail from "./features/object-search/__examples__/pages/AccountObjectDetailPage";
17
15
  import AuthAppLayout from "./features/authentication/layouts/AuthAppLayout";
18
16
 
19
17
  export const routes: RouteObject[] = [
@@ -24,7 +22,7 @@ export const routes: RouteObject[] = [
24
22
  {
25
23
  index: true,
26
24
  element: <Home />,
27
- handle: { showInNavigation: true, label: 'Home' }
25
+ handle: { showInNavigation: true, label: "Home" }
28
26
  },
29
27
  {
30
28
  path: '*',
@@ -71,22 +69,12 @@ export const routes: RouteObject[] = [
71
69
  ]
72
70
  },
73
71
  {
74
- path: "global-search/:query",
75
- element: (
76
- <Suspense fallback={<LoadingFallback />}>
77
- <GlobalSearch />
78
- </Suspense>
79
- ),
80
- handle: { showInNavigation: false }
72
+ path: "accounts/:recordId",
73
+ element: <AccountObjectDetail />
81
74
  },
82
75
  {
83
- path: "object/:objectApiName/:recordId",
84
- element: (
85
- <Suspense fallback={<LoadingFallback />}>
86
- <DetailPage />
87
- </Suspense>
88
- ),
89
- handle: { showInNavigation: false }
76
+ path: "accounts",
77
+ element: <AccountSearch />
90
78
  }
91
79
  ]
92
80
  }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@salesforce/webapp-template-base-sfdx-project-experimental",
3
- "version": "1.109.5",
3
+ "version": "1.109.6",
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.109.5",
9
+ "version": "1.109.6",
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/webapp-template-base-sfdx-project-experimental",
3
- "version": "1.109.5",
3
+ "version": "1.109.6",
4
4
  "description": "Base SFDX project template",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "publishConfig": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/webapp-template-app-react-template-b2x-experimental",
3
- "version": "1.109.5",
3
+ "version": "1.109.6",
4
4
  "description": "Base reference app template",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "author": "",
@@ -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
- };