@salesforce/ui-bundle-template-app-react-template-b2x 11.18.0 → 11.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/dist/CHANGELOG.md +16 -0
  2. package/dist/force-app/main/default/uiBundles/reactexternalapp/package.json +4 -4
  3. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/{features/object-search/components → components}/ObjectBreadcrumb.tsx +7 -2
  4. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/search/api/distinctValuesService.ts +84 -0
  5. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/search/api/searchService.ts +71 -0
  6. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/search/components/MergedSearchResults.tsx +263 -0
  7. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/search/components/Search.tsx +185 -0
  8. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/search/components/SearchResults.tsx +77 -0
  9. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/search/components/SourceSection.tsx +166 -0
  10. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/search/components/controls/PaginationControls.tsx +185 -0
  11. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/search/components/controls/ScopeSelector.tsx +55 -0
  12. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/search/components/controls/SearchBar.tsx +55 -0
  13. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/search/components/controls/SortControl.tsx +62 -0
  14. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/search/components/filters/ActiveFilters.tsx +61 -0
  15. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/search/components/filters/DefaultFilterPanel.tsx +125 -0
  16. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/{object-search/components → search/components/filters}/FilterContext.tsx +7 -20
  17. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/search/components/filters/inputs/BooleanFilter.tsx +50 -0
  18. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/search/components/filters/inputs/DateRangeFilter.tsx +160 -0
  19. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/search/components/filters/inputs/FilterFieldWrapper.tsx +26 -0
  20. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/search/components/filters/inputs/MultiSelectFilter.tsx +88 -0
  21. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/search/components/filters/inputs/NumericRangeFilter.tsx +78 -0
  22. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/search/components/filters/inputs/SelectFilter.tsx +46 -0
  23. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/search/components/filters/inputs/TextFilter.tsx +52 -0
  24. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/search/components/results/DefaultResultRow.tsx +109 -0
  25. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/search/config.json +83 -0
  26. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/{object-search → search}/hooks/useAsyncData.ts +3 -10
  27. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/search/hooks/useDistinctValues.ts +59 -0
  28. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/search/hooks/useSearch.ts +703 -0
  29. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/search/index.ts +90 -0
  30. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/search/loadConfig.ts +14 -0
  31. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/search/queryBuilder.ts +156 -0
  32. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/search/types.ts +307 -0
  33. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/search/utils/debounce.ts +17 -0
  34. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/search/utils/fieldUtils.ts +14 -0
  35. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/search/utils/filterUtils.ts +285 -0
  36. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/search/utils/sortUtils.ts +34 -0
  37. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/pages/AccountObjectDetailPage.tsx +49 -16
  38. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/pages/AccountSearch.tsx +21 -293
  39. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/pages/Home.tsx +22 -7
  40. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/routes.tsx +1 -1
  41. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/{features/object-search/utils/fieldUtils.ts → utils/accountFields.ts} +9 -0
  42. package/dist/force-app/main/default/uiBundles/reactexternalapp/tsconfig.tsbuildinfo +1 -1
  43. package/dist/package-lock.json +2 -2
  44. package/dist/package.json +1 -1
  45. package/package.json +1 -1
  46. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/api/account/accountSearchService.ts +0 -46
  47. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/api/account/query/distinctAccountIndustries.graphql +0 -19
  48. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/api/account/query/distinctAccountTypes.graphql +0 -19
  49. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/api/account/query/searchAccounts.graphql +0 -51
  50. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/api/graphql-operations-types.ts +0 -11260
  51. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/object-search/__examples__/api/accountSearchService.ts +0 -46
  52. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/object-search/__examples__/api/query/distinctAccountIndustries.graphql +0 -19
  53. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/object-search/__examples__/api/query/distinctAccountTypes.graphql +0 -19
  54. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/object-search/__examples__/api/query/getAccountDetail.graphql +0 -121
  55. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/object-search/__examples__/api/query/searchAccounts.graphql +0 -51
  56. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/object-search/__examples__/pages/AccountObjectDetailPage.tsx +0 -355
  57. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/object-search/__examples__/pages/AccountSearch.tsx +0 -304
  58. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/object-search/__examples__/pages/Home.tsx +0 -34
  59. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/object-search/api/objectSearchService.ts +0 -82
  60. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/object-search/components/ActiveFilters.tsx +0 -89
  61. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/object-search/components/PaginationControls.tsx +0 -109
  62. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/object-search/components/SearchBar.tsx +0 -41
  63. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/object-search/components/SortControl.tsx +0 -143
  64. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/object-search/components/filters/BooleanFilter.tsx +0 -78
  65. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/object-search/components/filters/DateFilter.tsx +0 -128
  66. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/object-search/components/filters/DateRangeFilter.tsx +0 -70
  67. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/object-search/components/filters/FilterFieldWrapper.tsx +0 -43
  68. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/object-search/components/filters/MultiSelectFilter.tsx +0 -105
  69. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/object-search/components/filters/NumericRangeFilter.tsx +0 -171
  70. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/object-search/components/filters/SearchFilter.tsx +0 -52
  71. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/object-search/components/filters/SelectFilter.tsx +0 -97
  72. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/object-search/components/filters/TextFilter.tsx +0 -93
  73. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/object-search/hooks/useDebouncedCallback.ts +0 -34
  74. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/object-search/hooks/useObjectSearchParams.ts +0 -254
  75. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/object-search/utils/debounce.ts +0 -25
  76. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/object-search/utils/filterUtils.ts +0 -404
  77. package/dist/force-app/main/default/uiBundles/reactexternalapp/src/features/object-search/utils/sortUtils.ts +0 -38
@@ -0,0 +1,285 @@
1
+ /**
2
+ * Filter primitives for search.
3
+ *
4
+ * Two responsibilities:
5
+ * 1. Build a GraphQL `where` clause from a list of active filter values.
6
+ * 2. Serialize/deserialize active filters to/from URLSearchParams under a
7
+ * per-source namespace prefix (so multiple sources can coexist on one URL).
8
+ *
9
+ * The URL helpers are namespaced: each source declares its key, and filter
10
+ * params are written as `s.<key>.f.<field>=...`. Sort uses
11
+ * `s.<key>.sort=<field>&s.<key>.dir=ASC|DESC`. Page size and page index use
12
+ * `s.<key>.ps=<size>` and `s.<key>.page=<n>`.
13
+ *
14
+ * The global search term `q=...` is **not** scoped to a source — it's broadcast
15
+ * to every source's `searchableFields` by the query builder.
16
+ */
17
+
18
+ import type { SortState } from "./sortUtils";
19
+
20
+ export type FilterFieldType =
21
+ | "text"
22
+ | "picklist"
23
+ | "numeric"
24
+ | "boolean"
25
+ | "date"
26
+ | "daterange"
27
+ | "datetime"
28
+ | "datetimerange"
29
+ | "multipicklist";
30
+
31
+ /**
32
+ * Which comparison UI a date/datetime filter exposes:
33
+ * - `"range"`: a single Between control (two date inputs, lower–upper bound).
34
+ * - `"comparison"`: an After / Before selector with one date input.
35
+ * - `"both"`: a Between / After / Before selector that switches between the two.
36
+ *
37
+ * Applies only to the date-family `type`s (`date`, `daterange`, `datetime`,
38
+ * `datetimerange`); ignored for other field types. Defaults to `"comparison"`.
39
+ */
40
+ export type DateFilterMode = "range" | "comparison" | "both";
41
+
42
+ export type FilterFieldConfig<TFieldName extends string = string> = {
43
+ field: TFieldName;
44
+ label: string;
45
+ type: FilterFieldType;
46
+ placeholder?: string;
47
+ /** Required for picklist / multipicklist. */
48
+ options?: Array<{ value: string; label: string }>;
49
+ /** Date-family only — see {@link DateFilterMode}. Defaults to `"comparison"`. */
50
+ dateMode?: DateFilterMode;
51
+ helpText?: string;
52
+ };
53
+
54
+ export type ActiveFilterValue<TFieldName extends string = string> = {
55
+ field: TFieldName;
56
+ label: string;
57
+ type: FilterFieldType;
58
+ value?: string;
59
+ min?: string;
60
+ max?: string;
61
+ };
62
+
63
+ // ---------------------------------------------------------------------------
64
+ // URL serialization (per-source namespace)
65
+ // ---------------------------------------------------------------------------
66
+
67
+ const SOURCE_PREFIX = "s.";
68
+ const FILTER_INFIX = ".f.";
69
+ const SORT_SUFFIX = ".sort";
70
+ const DIR_SUFFIX = ".dir";
71
+ const PAGE_SIZE_SUFFIX = ".ps";
72
+ const PAGE_SUFFIX = ".page";
73
+
74
+ /** Global search term key (not source-scoped). */
75
+ export const GLOBAL_QUERY_KEY = "q";
76
+
77
+ function filterKey(sourceKey: string, field: string, suffix?: string) {
78
+ return `${SOURCE_PREFIX}${sourceKey}${FILTER_INFIX}${field}${suffix ? `.${suffix}` : ""}`;
79
+ }
80
+
81
+ /**
82
+ * The source's own default sort / page size. When a source's current state
83
+ * matches these, the corresponding URL params are omitted so the query string
84
+ * only ever reflects an *explicit* user choice — resetting filters or returning
85
+ * a source to its defaults yields a clean URL instead of one littered with the
86
+ * defaults. The read path falls back to these same defaults when the params are
87
+ * absent, so the round-trip is lossless.
88
+ */
89
+ export interface SourceParamDefaults {
90
+ sort?: SortState | null;
91
+ pageSize?: number;
92
+ }
93
+
94
+ function sortMatchesDefault(sort: SortState, defaultSort: SortState | null | undefined): boolean {
95
+ return (
96
+ !!defaultSort && sort.field === defaultSort.field && sort.direction === defaultSort.direction
97
+ );
98
+ }
99
+
100
+ export function writeSourceParams(
101
+ params: URLSearchParams,
102
+ sourceKey: string,
103
+ filters: ActiveFilterValue[],
104
+ sort: SortState | null,
105
+ pageSize?: number,
106
+ pageIndex?: number,
107
+ defaults?: SourceParamDefaults,
108
+ ): void {
109
+ for (const filter of filters) {
110
+ if (filter.value !== undefined && filter.value !== "") {
111
+ params.set(filterKey(sourceKey, filter.field), filter.value);
112
+ }
113
+ if (filter.min !== undefined && filter.min !== "") {
114
+ params.set(filterKey(sourceKey, filter.field, "min"), filter.min);
115
+ }
116
+ if (filter.max !== undefined && filter.max !== "") {
117
+ params.set(filterKey(sourceKey, filter.field, "max"), filter.max);
118
+ }
119
+ }
120
+ // Only serialize sort when it differs from the source default — otherwise
121
+ // the URL would carry the default the user never chose.
122
+ if (sort && !sortMatchesDefault(sort, defaults?.sort)) {
123
+ params.set(`${SOURCE_PREFIX}${sourceKey}${SORT_SUFFIX}`, sort.field);
124
+ params.set(`${SOURCE_PREFIX}${sourceKey}${DIR_SUFFIX}`, sort.direction);
125
+ }
126
+ if (pageSize !== undefined && pageSize !== defaults?.pageSize) {
127
+ params.set(`${SOURCE_PREFIX}${sourceKey}${PAGE_SIZE_SUFFIX}`, String(pageSize));
128
+ }
129
+ if (pageIndex !== undefined && pageIndex > 0) {
130
+ params.set(`${SOURCE_PREFIX}${sourceKey}${PAGE_SUFFIX}`, String(pageIndex + 1));
131
+ }
132
+ }
133
+
134
+ export interface ReadSourceParamsResult {
135
+ filters: ActiveFilterValue[];
136
+ sort: SortState | null;
137
+ pageSize: number | undefined;
138
+ pageIndex: number;
139
+ }
140
+
141
+ export function readSourceParams(
142
+ params: URLSearchParams,
143
+ sourceKey: string,
144
+ configs: FilterFieldConfig[],
145
+ ): ReadSourceParamsResult {
146
+ const filters: ActiveFilterValue[] = [];
147
+ for (const config of configs) {
148
+ const { field, label, type } = config;
149
+ const value = params.get(filterKey(sourceKey, field)) ?? undefined;
150
+ const min = params.get(filterKey(sourceKey, field, "min")) ?? undefined;
151
+ const max = params.get(filterKey(sourceKey, field, "max")) ?? undefined;
152
+
153
+ const hasValue = value !== undefined && value !== "";
154
+ const hasRange = (min !== undefined && min !== "") || (max !== undefined && max !== "");
155
+ if (hasValue || hasRange) {
156
+ filters.push({ field, label, type, value, min, max });
157
+ }
158
+ }
159
+
160
+ let sort: SortState | null = null;
161
+ const sortField = params.get(`${SOURCE_PREFIX}${sourceKey}${SORT_SUFFIX}`);
162
+ const sortDir = params.get(`${SOURCE_PREFIX}${sourceKey}${DIR_SUFFIX}`);
163
+ if (sortField) {
164
+ sort = { field: sortField, direction: sortDir === "DESC" ? "DESC" : "ASC" };
165
+ }
166
+
167
+ const pageSizeRaw = params.get(`${SOURCE_PREFIX}${sourceKey}${PAGE_SIZE_SUFFIX}`);
168
+ const pageSize = pageSizeRaw ? parseInt(pageSizeRaw, 10) : undefined;
169
+ const pageRaw = params.get(`${SOURCE_PREFIX}${sourceKey}${PAGE_SUFFIX}`);
170
+ const page = pageRaw ? parseInt(pageRaw, 10) : 1;
171
+ const pageIndex = !isNaN(page) && page > 1 ? page - 1 : 0;
172
+
173
+ return {
174
+ filters,
175
+ sort,
176
+ pageSize: pageSize && !isNaN(pageSize) ? pageSize : undefined,
177
+ pageIndex,
178
+ };
179
+ }
180
+
181
+ // ---------------------------------------------------------------------------
182
+ // GraphQL filter building
183
+ // ---------------------------------------------------------------------------
184
+
185
+ /**
186
+ * Combines active filter values into a GraphQL `where` clause for one source.
187
+ * Returns `undefined` when no constraints are active.
188
+ */
189
+ export function buildFilter(filters: ActiveFilterValue[], configs: FilterFieldConfig[]): unknown {
190
+ const configMap = new Map(configs.map((c) => [c.field, c]));
191
+ const clauses: unknown[] = [];
192
+ for (const filter of filters) {
193
+ const clause = buildSingleFilter(filter, configMap.get(filter.field));
194
+ if (clause) clauses.push(clause);
195
+ }
196
+ if (clauses.length === 0) return undefined;
197
+ if (clauses.length === 1) return clauses[0];
198
+ return { and: clauses };
199
+ }
200
+
201
+ function toStartOfDay(d: string) {
202
+ return `${d}T00:00:00.000Z`;
203
+ }
204
+ function toEndOfDay(d: string) {
205
+ return `${d}T23:59:59.999Z`;
206
+ }
207
+
208
+ function buildSingleFilter(filter: ActiveFilterValue, _config?: FilterFieldConfig): unknown {
209
+ const { field, type, value, min, max } = filter;
210
+ switch (type) {
211
+ case "text": {
212
+ if (!value) return null;
213
+ return { [field]: { like: `%${value}%` } };
214
+ }
215
+ case "picklist": {
216
+ if (!value) return null;
217
+ return { [field]: { eq: value } };
218
+ }
219
+ case "numeric": {
220
+ if (!min && !max) return null;
221
+ const ops: Record<string, number> = {};
222
+ if (min) ops.gte = Number(min);
223
+ if (max) ops.lte = Number(max);
224
+ return { [field]: ops };
225
+ }
226
+ case "boolean": {
227
+ if (value === undefined || value === "") return null;
228
+ return { [field]: { eq: value === "true" } };
229
+ }
230
+ case "multipicklist": {
231
+ if (!value) return null;
232
+ const values = value.split(",").filter(Boolean);
233
+ if (values.length === 0) return null;
234
+ if (values.length === 1) return { [field]: { eq: values[0] } };
235
+ return { [field]: { in: values } };
236
+ }
237
+ case "date": {
238
+ if (!min && !max) return null;
239
+ const op = min ? "gte" : "lte";
240
+ const dateStr = min ?? max;
241
+ return { [field]: { [op]: { value: dateStr } } };
242
+ }
243
+ case "daterange": {
244
+ if (!min && !max) return null;
245
+ const clauses: unknown[] = [];
246
+ if (min) clauses.push({ [field]: { gte: { value: min } } });
247
+ if (max) clauses.push({ [field]: { lte: { value: max } } });
248
+ return clauses.length === 1 ? clauses[0] : { and: clauses };
249
+ }
250
+ case "datetime": {
251
+ if (!min && !max) return null;
252
+ const op = min ? "gte" : "lte";
253
+ const dateStr = min ?? max;
254
+ const isoStr = op === "gte" ? toStartOfDay(dateStr!) : toEndOfDay(dateStr!);
255
+ return { [field]: { [op]: { value: isoStr } } };
256
+ }
257
+ case "datetimerange": {
258
+ if (!min && !max) return null;
259
+ const clauses: unknown[] = [];
260
+ if (min) clauses.push({ [field]: { gte: { value: toStartOfDay(min) } } });
261
+ if (max) clauses.push({ [field]: { lte: { value: toEndOfDay(max) } } });
262
+ return clauses.length === 1 ? clauses[0] : { and: clauses };
263
+ }
264
+ default:
265
+ return null;
266
+ }
267
+ }
268
+
269
+ /**
270
+ * Builds a global-q `or` clause across the source's searchable fields.
271
+ * Returns `undefined` when q is empty or the source has no searchable fields.
272
+ */
273
+ export function buildGlobalQueryClause(q: string, searchableFields: string[]): unknown {
274
+ const trimmed = q.trim();
275
+ if (!trimmed || searchableFields.length === 0) return undefined;
276
+ const clauses = searchableFields.map((path) => {
277
+ const parts = path.split(".");
278
+ let clause: Record<string, unknown> = { like: `%${trimmed}%` };
279
+ for (let i = parts.length - 1; i >= 0; i--) {
280
+ clause = { [parts[i]]: clause };
281
+ }
282
+ return clause;
283
+ });
284
+ return clauses.length === 1 ? clauses[0] : { or: clauses };
285
+ }
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Sort state and order-by builder for search.
3
+ *
4
+ * The order-by output shape matches the Salesforce uiapi GraphQL convention:
5
+ * { [field]: { order: ASC|DESC, nulls: LAST } }
6
+ *
7
+ * The constants are stringly-typed here (rather than imported from codegen)
8
+ * because search builds its query at runtime and isn't tied to a
9
+ * specific generated schema.
10
+ */
11
+
12
+ export type SortFieldConfig<TFieldName extends string = string> = {
13
+ field: TFieldName;
14
+ label: string;
15
+ };
16
+
17
+ export type SortState<TFieldName extends string = string> = {
18
+ field: TFieldName;
19
+ direction: "ASC" | "DESC";
20
+ };
21
+
22
+ const ORDER_ASC = "ASC";
23
+ const ORDER_DESC = "DESC";
24
+ const NULLS_LAST = "LAST";
25
+
26
+ export function buildOrderBy(sort: SortState | null): unknown {
27
+ if (!sort) return undefined;
28
+ return {
29
+ [sort.field]: {
30
+ order: sort.direction === "ASC" ? ORDER_ASC : ORDER_DESC,
31
+ nulls: NULLS_LAST,
32
+ },
33
+ };
34
+ }
@@ -3,18 +3,10 @@ import { useParams, useNavigate } from "react-router";
3
3
  import { createDataSDK } from "@salesforce/platform-sdk";
4
4
  import { AlertCircle, ChevronDown, ChevronRight, FileQuestion } from "lucide-react";
5
5
  import GET_ACCOUNT_DETAIL from "../api/account/query/getAccountDetail.graphql?raw";
6
- import type {
7
- GetAccountDetailQuery,
8
- GetAccountDetailQueryVariables,
9
- } from "../api/graphql-operations-types";
10
6
  import { Alert, AlertTitle, AlertDescription } from "../components/ui/alert";
11
7
  import { Button } from "../components/ui/button";
12
8
  import { Card, CardContent } from "../components/ui/card";
13
- import {
14
- fieldValue,
15
- getAddressFieldLines,
16
- formatDateTimeField,
17
- } from "../features/object-search/utils/fieldUtils";
9
+ import { fieldValue, getAddressFieldLines, formatDateTimeField } from "../utils/accountFields";
18
10
  import {
19
11
  Collapsible,
20
12
  CollapsibleTrigger,
@@ -23,17 +15,58 @@ import {
23
15
  import { Separator } from "../components/ui/separator";
24
16
  import { Skeleton } from "../components/ui/skeleton";
25
17
  import { useAsyncData } from "../hooks/useAsyncData";
26
- import { ObjectBreadcrumb } from "../features/object-search/components/ObjectBreadcrumb";
18
+ import { ObjectBreadcrumb } from "../components/ObjectBreadcrumb";
19
+
20
+ /**
21
+ * A uiapi scalar field as returned with `@optional { value displayValue }`.
22
+ * Typed locally so this page no longer depends on the generated
23
+ * `graphql-operations-types` that shipped with feature-react-object-search.
24
+ */
25
+ type FieldValue = { value?: unknown; displayValue?: string | null } | null;
26
+ type NameHolder = { Name?: FieldValue } | null;
27
+
28
+ interface AccountNode {
29
+ Id?: string;
30
+ Name?: FieldValue;
31
+ Owner?: NameHolder;
32
+ Phone?: FieldValue;
33
+ Fax?: FieldValue;
34
+ Parent?: NameHolder;
35
+ Website?: FieldValue;
36
+ Type?: FieldValue;
37
+ NumberOfEmployees?: FieldValue;
38
+ Industry?: FieldValue;
39
+ AnnualRevenue?: FieldValue;
40
+ Description?: FieldValue;
41
+ BillingStreet?: FieldValue;
42
+ BillingCity?: FieldValue;
43
+ BillingState?: FieldValue;
44
+ BillingPostalCode?: FieldValue;
45
+ BillingCountry?: FieldValue;
46
+ ShippingStreet?: FieldValue;
47
+ ShippingCity?: FieldValue;
48
+ ShippingState?: FieldValue;
49
+ ShippingPostalCode?: FieldValue;
50
+ ShippingCountry?: FieldValue;
51
+ CreatedBy?: NameHolder;
52
+ CreatedDate?: FieldValue;
53
+ LastModifiedBy?: NameHolder;
54
+ LastModifiedDate?: FieldValue;
55
+ }
27
56
 
28
- type AccountNode = NonNullable<
29
- NonNullable<
30
- NonNullable<NonNullable<GetAccountDetailQuery["uiapi"]["query"]["Account"]>["edges"]>[number]
31
- >["node"]
32
- >;
57
+ interface GetAccountDetailResponse {
58
+ uiapi?: {
59
+ query?: {
60
+ Account?: {
61
+ edges?: Array<{ node?: AccountNode } | null> | null;
62
+ } | null;
63
+ } | null;
64
+ } | null;
65
+ }
33
66
 
34
67
  async function fetchAccountDetail(recordId: string): Promise<AccountNode | null | undefined> {
35
68
  const data = await createDataSDK();
36
- const result = await data.graphql!.query<GetAccountDetailQuery, GetAccountDetailQueryVariables>({
69
+ const result = await data.graphql!.query<GetAccountDetailResponse, { id: string }>({
37
70
  query: GET_ACCOUNT_DETAIL,
38
71
  variables: { id: recordId },
39
72
  });