@salesforce/webapp-template-app-react-template-b2e-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/appreacttemplateb2e/package.json +5 -6
  3. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/api/graphql-operations-types.ts +11260 -0
  4. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/components/ui/sonner.tsx +20 -0
  5. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/object-search/__examples__/api/accountSearchService.ts +46 -0
  6. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/object-search/__examples__/api/query/distinctAccountIndustries.graphql +19 -0
  7. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/object-search/__examples__/api/query/distinctAccountTypes.graphql +19 -0
  8. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/object-search/__examples__/api/query/getAccountDetail.graphql +121 -0
  9. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/object-search/__examples__/api/query/searchAccounts.graphql +51 -0
  10. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/object-search/__examples__/pages/AccountObjectDetailPage.tsx +357 -0
  11. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/object-search/__examples__/pages/AccountSearch.tsx +275 -0
  12. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/object-search/__examples__/pages/Home.tsx +34 -0
  13. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/object-search/api/objectSearchService.ts +84 -0
  14. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/object-search/components/ActiveFilters.tsx +89 -0
  15. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/object-search/components/FilterPanel.tsx +127 -0
  16. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/object-search/components/ObjectBreadcrumb.tsx +66 -0
  17. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/object-search/components/PaginationControls.tsx +151 -0
  18. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/object-search/components/SearchBar.tsx +41 -0
  19. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/object-search/components/SortControl.tsx +143 -0
  20. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/object-search/components/filters/BooleanFilter.tsx +94 -0
  21. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/object-search/components/filters/DateFilter.tsx +138 -0
  22. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/object-search/components/filters/DateRangeFilter.tsx +78 -0
  23. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/object-search/components/filters/MultiSelectFilter.tsx +106 -0
  24. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/object-search/components/filters/NumericRangeFilter.tsx +102 -0
  25. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/object-search/components/filters/SearchFilter.tsx +40 -0
  26. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/object-search/components/filters/SelectFilter.tsx +97 -0
  27. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/object-search/components/filters/TextFilter.tsx +77 -0
  28. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/object-search/hooks/useAsyncData.ts +53 -0
  29. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/object-search/hooks/useCachedAsyncData.ts +183 -0
  30. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/object-search/hooks/useObjectSearchParams.ts +225 -0
  31. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/object-search/utils/debounce.ts +22 -0
  32. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/object-search/utils/fieldUtils.ts +29 -0
  33. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/object-search/utils/filterUtils.ts +372 -0
  34. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/object-search/utils/sortUtils.ts +38 -0
  35. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/index.ts +3 -117
  36. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/pages/Home.tsx +10 -11
  37. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/routes.tsx +8 -20
  38. package/dist/package-lock.json +2 -2
  39. package/dist/package.json +1 -1
  40. package/package.json +1 -1
  41. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/api/objectDetailService.ts +0 -102
  42. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/api/objectInfoGraphQLService.ts +0 -137
  43. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/api/objectInfoService.ts +0 -95
  44. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/api/recordListGraphQLService.ts +0 -364
  45. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/components/detail/DetailFields.tsx +0 -55
  46. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/components/detail/DetailForm.tsx +0 -146
  47. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/components/detail/DetailHeader.tsx +0 -34
  48. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/components/detail/DetailLayoutSections.tsx +0 -80
  49. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/components/detail/Section.tsx +0 -108
  50. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/components/detail/SectionRow.tsx +0 -20
  51. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/components/detail/UiApiDetailForm.tsx +0 -140
  52. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/components/detail/formatted/FieldValueDisplay.tsx +0 -73
  53. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/components/detail/formatted/FormattedAddress.tsx +0 -29
  54. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/components/detail/formatted/FormattedEmail.tsx +0 -17
  55. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/components/detail/formatted/FormattedPhone.tsx +0 -24
  56. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/components/detail/formatted/FormattedText.tsx +0 -11
  57. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/components/detail/formatted/FormattedUrl.tsx +0 -29
  58. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/components/filters/FilterField.tsx +0 -54
  59. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/components/filters/FilterInput.tsx +0 -55
  60. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/components/filters/FilterSelect.tsx +0 -72
  61. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/components/filters/FiltersPanel.tsx +0 -380
  62. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/components/forms/filters-form.tsx +0 -114
  63. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/components/forms/submit-button.tsx +0 -47
  64. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/components/search/GlobalSearchInput.tsx +0 -114
  65. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/components/search/ResultCardFields.tsx +0 -71
  66. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/components/search/SearchHeader.tsx +0 -31
  67. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/components/search/SearchPagination.tsx +0 -144
  68. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/components/search/SearchResultCard.tsx +0 -138
  69. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/components/search/SearchResultsPanel.tsx +0 -197
  70. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/components/shared/LoadingFallback.tsx +0 -61
  71. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/constants.ts +0 -39
  72. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/filters/FilterInput.tsx +0 -55
  73. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/filters/FilterSelect.tsx +0 -72
  74. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/hooks/form.tsx +0 -209
  75. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/hooks/useObjectInfoBatch.ts +0 -72
  76. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/hooks/useObjectSearchData.ts +0 -174
  77. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/hooks/useRecordDetailLayout.ts +0 -137
  78. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/hooks/useRecordListGraphQL.ts +0 -135
  79. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/pages/DetailPage.tsx +0 -109
  80. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/pages/GlobalSearch.tsx +0 -235
  81. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/types/filters/filters.ts +0 -121
  82. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/types/filters/picklist.ts +0 -6
  83. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/types/objectInfo/objectInfo.ts +0 -49
  84. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/types/recordDetail/recordDetail.ts +0 -61
  85. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/types/schema.d.ts +0 -200
  86. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/types/search/searchResults.ts +0 -229
  87. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/utils/apiUtils.ts +0 -59
  88. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/utils/cacheUtils.ts +0 -76
  89. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/utils/debounce.ts +0 -90
  90. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/utils/fieldUtils.ts +0 -354
  91. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/utils/fieldValueExtractor.ts +0 -67
  92. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/utils/filterUtils.ts +0 -32
  93. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/utils/formDataTransformUtils.ts +0 -260
  94. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/utils/formUtils.ts +0 -142
  95. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/utils/graphQLNodeFieldUtils.ts +0 -186
  96. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/utils/graphQLObjectInfoAdapter.ts +0 -77
  97. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/utils/graphQLRecordAdapter.ts +0 -90
  98. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/utils/layoutTransformUtils.ts +0 -236
  99. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/utils/linkUtils.ts +0 -14
  100. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/utils/paginationUtils.ts +0 -49
  101. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/utils/recordUtils.ts +0 -159
  102. package/dist/force-app/main/default/webapplications/appreacttemplateb2e/src/features/global-search/utils/sanitizationUtils.ts +0 -50
@@ -1,120 +1,6 @@
1
1
  /**
2
- * Public API for the Global Search feature package.
3
- *
4
- * Design goals:
5
- * - Export **API services, hooks, types, schemas, and utilities** that customers can import from node_modules.
6
- * - Do **not** export UI components or feature constants (customers build their own UI).
7
- *
8
- * Source implementation lives under `src/features/global-search/**`.
2
+ * feature-react-agentforce-conversation-client ACC Conversation Client
9
3
  */
10
4
 
11
- // ---------------------------------------------------------------------------
12
- // API layer
13
- // ---------------------------------------------------------------------------
14
-
15
- export { objectInfoService } from "./features/global-search/api/objectInfoService";
16
- export {
17
- objectDetailService,
18
- extractFieldsFromLayout,
19
- } from "./features/global-search/api/objectDetailService";
20
- export type { RecordDetailResult } from "./features/global-search/api/objectDetailService";
21
-
22
- export {
23
- getRecordsGraphQL,
24
- getRecordByIdGraphQL,
25
- buildGetRecordsQuery,
26
- buildWhereFromCriteria,
27
- buildOrderByFromSort,
28
- } from "./features/global-search/api/recordListGraphQLService";
29
- export type {
30
- RecordListGraphQLResult,
31
- RecordListGraphQLVariables,
32
- RecordListGraphQLOptions,
33
- GraphQLRecordNode,
34
- } from "./features/global-search/api/recordListGraphQLService";
35
-
36
- // ---------------------------------------------------------------------------
37
- // Hooks
38
- // ---------------------------------------------------------------------------
39
-
40
- export { useObjectInfoBatch } from "./features/global-search/hooks/useObjectInfoBatch";
41
- export {
42
- useObjectListMetadata,
43
- useObjectColumns,
44
- useObjectFilters,
45
- } from "./features/global-search/hooks/useObjectSearchData";
46
- export { useRecordListGraphQL } from "./features/global-search/hooks/useRecordListGraphQL";
47
- export { useRecordDetailLayout } from "./features/global-search/hooks/useRecordDetailLayout";
48
-
49
- export type { ObjectListMetadata } from "./features/global-search/hooks/useObjectSearchData";
50
-
51
- export type {
52
- UseRecordListGraphQLOptions,
53
- UseRecordListGraphQLReturn,
54
- } from "./features/global-search/hooks/useRecordListGraphQL";
55
-
56
- export type {
57
- UseRecordDetailLayoutParams,
58
- UseRecordDetailLayoutReturn,
59
- } from "./features/global-search/hooks/useRecordDetailLayout";
60
-
61
- // ---------------------------------------------------------------------------
62
- // Types + Zod schemas (runtime validation)
63
- // ---------------------------------------------------------------------------
64
-
65
- export {
66
- ColumnArraySchema,
67
- SearchResultRecordArraySchema,
68
- KeywordSearchResultSchema,
69
- SearchResultsResponseSchema,
70
- } from "./features/global-search/types/search/searchResults";
71
- export type {
72
- Column,
73
- SearchResultRecord,
74
- KeywordSearchResult,
75
- SearchResultsResponse,
76
- } from "./features/global-search/types/search/searchResults";
77
-
78
- export {
79
- FilterArraySchema,
80
- FilterCriteriaArraySchema,
81
- FILTER_OPERATORS,
82
- } from "./features/global-search/types/filters/filters";
83
- export type {
84
- Filter,
85
- FilterCriteria,
86
- FilterOperator,
87
- FiltersResponse,
88
- } from "./features/global-search/types/filters/filters";
89
-
90
- export type { PicklistValue } from "./features/global-search/types/filters/picklist";
91
-
92
- export type {
93
- ObjectInfoBatchResponse,
94
- ObjectInfoResult,
95
- } from "./features/global-search/types/objectInfo/objectInfo";
96
-
97
- export { LayoutResponseSchema } from "./features/global-search/types/recordDetail/recordDetail";
98
- export type { LayoutResponse } from "./features/global-search/types/recordDetail/recordDetail";
99
-
100
- // ---------------------------------------------------------------------------
101
- // Utilities
102
- // ---------------------------------------------------------------------------
103
-
104
- export { fetchAndValidate, safeEncodePath } from "./features/global-search/utils/apiUtils";
105
- export { debounce } from "./features/global-search/utils/debounce";
106
- export { createFiltersKey } from "./features/global-search/utils/cacheUtils";
107
- export {
108
- calculateFieldsToFetch,
109
- getSafeKey,
110
- isValidSalesforceId,
111
- } from "./features/global-search/utils/recordUtils";
112
- export { parseFilterValue } from "./features/global-search/utils/filterUtils";
113
- export { sanitizeFilterValue } from "./features/global-search/utils/sanitizationUtils";
114
- export {
115
- getGraphQLNodeValue,
116
- getDisplayValueForDetailFieldFromNode,
117
- getDisplayValueForLayoutItemFromNode,
118
- getGraphQLRecordDisplayName,
119
- } from "./features/global-search/utils/graphQLNodeFieldUtils";
120
- export { graphQLNodeToSearchResultRecordData } from "./features/global-search/utils/graphQLRecordAdapter";
5
+ export { AgentforceConversationClient } from "./components/AgentforceConversationClient";
6
+ export type { AgentforceConversationClientProps, ResolvedEmbedOptions } from "./types/conversation";
@@ -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,12 +1,10 @@
1
1
  import type { RouteObject } from 'react-router';
2
2
  import AppLayout from './appLayout';
3
- import Home from './pages/Home';
3
+ import Home from './features/object-search/__examples__/pages/Home';
4
4
  import NotFound from './pages/NotFound';
5
5
  import TestAccPage from "./pages/TestAccPage";
6
- import GlobalSearch from "./features/global-search/pages/GlobalSearch";
7
- import DetailPage from "./features/global-search/pages/DetailPage";
8
- import { Suspense } from "react";
9
- import LoadingFallback from "./features/global-search/components/shared/LoadingFallback";
6
+ import AccountSearch from "./features/object-search/__examples__/pages/AccountSearch";
7
+ import AccountObjectDetail from "./features/object-search/__examples__/pages/AccountObjectDetailPage";
10
8
 
11
9
  export const routes: RouteObject[] = [
12
10
  {
@@ -16,7 +14,7 @@ export const routes: RouteObject[] = [
16
14
  {
17
15
  index: true,
18
16
  element: <Home />,
19
- handle: { showInNavigation: true, label: 'Home' }
17
+ handle: { showInNavigation: true, label: "Home" }
20
18
  },
21
19
  {
22
20
  path: '*',
@@ -28,22 +26,12 @@ export const routes: RouteObject[] = [
28
26
  handle: { showInNavigation: true, label: "Test ACC" }
29
27
  },
30
28
  {
31
- path: "global-search/:query",
32
- element: (
33
- <Suspense fallback={<LoadingFallback />}>
34
- <GlobalSearch />
35
- </Suspense>
36
- ),
37
- handle: { showInNavigation: false }
29
+ path: "accounts/:recordId",
30
+ element: <AccountObjectDetail />
38
31
  },
39
32
  {
40
- path: "object/:objectApiName/:recordId",
41
- element: (
42
- <Suspense fallback={<LoadingFallback />}>
43
- <DetailPage />
44
- </Suspense>
45
- ),
46
- handle: { showInNavigation: false }
33
+ path: "accounts",
34
+ element: <AccountSearch />
47
35
  }
48
36
  ]
49
37
  }
@@ -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-b2e-experimental",
3
- "version": "1.109.5",
3
+ "version": "1.109.6",
4
4
  "description": "B2E template app (from BYO)",
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
- };