@salesforce/webapp-template-feature-react-global-search-experimental 1.76.1 → 1.77.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 (24) hide show
  1. package/dist/CHANGELOG.md +8 -0
  2. package/dist/force-app/main/default/webapplications/feature-react-global-search/package.json +3 -3
  3. package/dist/force-app/main/default/webapplications/feature-react-global-search/src/features/global-search/api/objectInfoGraphQLService.ts +108 -156
  4. package/dist/force-app/main/default/webapplications/feature-react-global-search/src/features/global-search/api/objectInfoService.ts +5 -10
  5. package/dist/force-app/main/default/webapplications/feature-react-global-search/src/features/global-search/components/detail/UiApiDetailForm.tsx +2 -2
  6. package/dist/force-app/main/default/webapplications/feature-react-global-search/src/features/global-search/hooks/useObjectInfoBatch.ts +1 -1
  7. package/dist/force-app/main/default/webapplications/feature-react-global-search/src/features/global-search/types/filters/picklist.ts +5 -31
  8. package/dist/force-app/main/default/webapplications/feature-react-global-search/src/features/global-search/types/objectInfo/objectInfo.ts +46 -163
  9. package/dist/force-app/main/default/webapplications/feature-react-global-search/src/features/global-search/types/schema.d.ts +200 -0
  10. package/dist/force-app/main/default/webapplications/feature-react-global-search/src/features/global-search/utils/graphQLObjectInfoAdapter.ts +37 -279
  11. package/dist/force-app/main/default/webapplications/feature-react-global-search/src/features/global-search/utils/recordUtils.ts +4 -4
  12. package/dist/force-app/main/default/webapplications/feature-react-global-search/src/index.ts +0 -5
  13. package/dist/package.json +1 -1
  14. package/package.json +1 -1
  15. package/src/force-app/main/default/webapplications/feature-react-global-search/src/features/global-search/api/objectInfoGraphQLService.ts +108 -156
  16. package/src/force-app/main/default/webapplications/feature-react-global-search/src/features/global-search/api/objectInfoService.ts +5 -10
  17. package/src/force-app/main/default/webapplications/feature-react-global-search/src/features/global-search/components/detail/UiApiDetailForm.tsx +2 -2
  18. package/src/force-app/main/default/webapplications/feature-react-global-search/src/features/global-search/hooks/useObjectInfoBatch.ts +1 -1
  19. package/src/force-app/main/default/webapplications/feature-react-global-search/src/features/global-search/types/filters/picklist.ts +5 -31
  20. package/src/force-app/main/default/webapplications/feature-react-global-search/src/features/global-search/types/objectInfo/objectInfo.ts +46 -163
  21. package/src/force-app/main/default/webapplications/feature-react-global-search/src/features/global-search/types/schema.d.ts +200 -0
  22. package/src/force-app/main/default/webapplications/feature-react-global-search/src/features/global-search/utils/graphQLObjectInfoAdapter.ts +37 -279
  23. package/src/force-app/main/default/webapplications/feature-react-global-search/src/features/global-search/utils/recordUtils.ts +4 -4
  24. package/src/force-app/main/default/webapplications/feature-react-global-search/src/index.ts +0 -5
package/dist/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [1.77.0](https://github.com/salesforce-experience-platform-emu/webapps/compare/v1.76.1...v1.77.0) (2026-03-06)
7
+
8
+ **Note:** Version bump only for package @salesforce/webapp-template-base-sfdx-project-experimental
9
+
10
+
11
+
12
+
13
+
6
14
  ## [1.76.1](https://github.com/salesforce-experience-platform-emu/webapps/compare/v1.76.0...v1.76.1) (2026-03-06)
7
15
 
8
16
  **Note:** Version bump only for package @salesforce/webapp-template-base-sfdx-project-experimental
@@ -15,8 +15,8 @@
15
15
  "graphql:schema": "node scripts/get-graphql-schema.mjs"
16
16
  },
17
17
  "dependencies": {
18
- "@salesforce/sdk-data": "^1.76.1",
19
- "@salesforce/webapp-experimental": "^1.76.1",
18
+ "@salesforce/sdk-data": "^1.77.0",
19
+ "@salesforce/webapp-experimental": "^1.77.0",
20
20
  "@tailwindcss/vite": "^4.1.17",
21
21
  "@tanstack/react-form": "^1.28.4",
22
22
  "class-variance-authority": "^0.7.1",
@@ -40,7 +40,7 @@
40
40
  "@graphql-eslint/eslint-plugin": "^4.1.0",
41
41
  "@graphql-tools/utils": "^11.0.0",
42
42
  "@playwright/test": "^1.49.0",
43
- "@salesforce/vite-plugin-webapp-experimental": "^1.76.1",
43
+ "@salesforce/vite-plugin-webapp-experimental": "^1.77.0",
44
44
  "@testing-library/jest-dom": "^6.6.3",
45
45
  "@testing-library/react": "^16.1.0",
46
46
  "@testing-library/user-event": "^14.5.2",
@@ -7,179 +7,131 @@
7
7
  * @module api/objectInfoGraphQLService
8
8
  */
9
9
 
10
- import { getDataSDK } from "@salesforce/sdk-data";
11
-
12
- /** GraphQL objectInfoInputs for requesting picklist values (API v65.0+). Only apiName and fieldNames are sent; record type filtering is done from the response. */
13
- export interface ObjectInfoInput {
14
- apiName: string;
15
- fieldNames?: string[] | null;
16
- }
17
-
18
- /** Raw GraphQL response shape for uiapi.objectInfos (flexible for schema casing). */
19
- export interface ObjectInfosGraphQLResponse {
20
- uiapi?: {
21
- objectInfos?: Array<Record<string, unknown>>;
22
- };
23
- }
10
+ import { getDataSDK, gql } from "@salesforce/sdk-data";
11
+ import type {
12
+ GetObjectInfosQuery,
13
+ GetObjectInfosQueryVariables,
14
+ GetPicklistValuesQuery,
15
+ GetPicklistValuesQueryVariables,
16
+ ObjectInfoInput,
17
+ } from "../types/schema";
24
18
 
25
19
  /**
26
20
  * Builds objectInfos query (metadata only). Uses apiNames only — do not pass objectInfoInputs.
27
21
  */
28
- function buildObjectInfosQuery(): string {
29
- return `query GetObjectInfos($apiNames: [String!]!) {
30
- uiapi {
31
- objectInfos(apiNames: $apiNames) {
32
- ApiName
33
- label
34
- labelPlural
35
- nameFields
36
- defaultRecordTypeId
37
- keyPrefix
38
- layoutable
39
- queryable
40
- searchable
41
- updateable
42
- deletable
43
- createable
44
- custom
45
- mruEnabled
46
- feedEnabled
47
- fields {
48
- ApiName
49
- label
50
- dataType
51
- relationshipName
52
- reference
53
- compound
54
- compoundFieldName
55
- compoundComponentName
56
- controllingFields
57
- controllerName
58
- referenceToInfos {
59
- ApiName
60
- nameFields
61
- }
62
- }
63
- recordTypeInfos {
64
- recordTypeId
65
- name
66
- master
67
- available
68
- defaultRecordTypeMapping
69
- }
70
- themeInfo {
71
- color
72
- iconUrl
73
- }
74
- childRelationships {
75
- relationshipName
76
- fieldName
77
- childObjectApiName
78
- }
79
- dependentFields {
80
- controllingField
81
- }
82
- }
83
- }
84
- }`;
85
- }
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
+ `;
86
80
 
87
81
  /**
88
82
  * Builds objectInfos query with picklist values (API v65.0+).
89
83
  * Schema requires objectInfos to be called with either apiNames or objectInfoInputs, not both.
90
84
  * This query uses objectInfoInputs only.
85
+ * Optimized to only fetch fields used by extractPicklistValuesFromGraphQLObjectInfo.
91
86
  */
92
- function buildObjectInfosWithPicklistsQuery(): string {
93
- return `query GetPicklistValues($objectInfoInputs: [ObjectInfoInput!]!) {
94
- uiapi {
95
- objectInfos(objectInfoInputs: $objectInfoInputs) {
96
- ApiName
97
- label
98
- labelPlural
99
- nameFields
100
- defaultRecordTypeId
101
- keyPrefix
102
- layoutable
103
- queryable
104
- searchable
105
- updateable
106
- deletable
107
- createable
108
- custom
109
- mruEnabled
110
- feedEnabled
111
- fields {
112
- ApiName
113
- label
114
- dataType
115
- relationshipName
116
- reference
117
- compound
118
- compoundFieldName
119
- compoundComponentName
120
- controllingFields
121
- controllerName
122
- referenceToInfos {
123
- ApiName
124
- nameFields
125
- }
126
- ... on PicklistField {
127
- picklistValuesByRecordTypeIDs {
128
- recordTypeID
129
- defaultValue {
130
- value
131
- }
132
- picklistValues {
133
- label
134
- value
135
- validFor
136
- }
137
- }
138
- }
139
- }
140
- recordTypeInfos {
141
- recordTypeId
142
- name
143
- master
144
- available
145
- defaultRecordTypeMapping
146
- }
147
- themeInfo {
148
- color
149
- iconUrl
150
- }
151
- childRelationships {
152
- relationshipName
153
- fieldName
154
- childObjectApiName
155
- }
156
- dependentFields {
157
- controllingField
158
- }
159
- }
160
- }
161
- }`;
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
+ });
162
125
  }
163
126
 
164
- export async function getObjectInfosGraphQL(
165
- apiNames: string[],
166
- options?: {
167
- objectInfoInputs?: ObjectInfoInput[] | null;
168
- },
169
- ): Promise<ObjectInfosGraphQLResponse> {
170
- const names = apiNames.length ? apiNames : [];
171
- const hasInputs = options?.objectInfoInputs != null && options.objectInfoInputs.length > 0;
172
- const query = hasInputs ? buildObjectInfosWithPicklistsQuery() : buildObjectInfosQuery();
173
- const variables: Record<string, unknown> = hasInputs
174
- ? { objectInfoInputs: options!.objectInfoInputs }
175
- : { apiNames: names };
127
+ async function runQuery<Q, V>(query: string, variables: V): Promise<Q> {
176
128
  const data = await getDataSDK();
177
- const response = await data.graphql?.<ObjectInfosGraphQLResponse>(query, variables);
129
+ const response = await data.graphql?.<Q, V>(query, variables);
178
130
 
179
131
  if (response?.errors?.length) {
180
132
  const errorMessages = response.errors.map((e) => e.message).join("; ");
181
133
  throw new Error(`GraphQL Error: ${errorMessages}`);
182
134
  }
183
135
 
184
- return response?.data ?? ({} as ObjectInfosGraphQLResponse);
136
+ return response?.data ?? ({} as Q);
185
137
  }
@@ -4,7 +4,7 @@ import { FilterArraySchema } from "../types/filters/filters";
4
4
  import type { PicklistValue } from "../types/filters/picklist";
5
5
  import type { ObjectInfoBatchResponse } from "../types/objectInfo/objectInfo";
6
6
  import { fetchAndValidate, safeEncodePath } from "../utils/apiUtils";
7
- import { getObjectInfosGraphQL } from "./objectInfoGraphQLService";
7
+ import { queryForObjectInfos, queryForPicklistValues } from "./objectInfoGraphQLService";
8
8
  import {
9
9
  graphQLObjectInfosToBatchResponse,
10
10
  extractPicklistValuesFromGraphQLObjectInfo,
@@ -47,7 +47,7 @@ export async function getObjectInfoBatch(objectApiNames: string): Promise<Object
47
47
  if (inFlight) return inFlight;
48
48
  const promise = (async () => {
49
49
  try {
50
- const response = await getObjectInfosGraphQL(names);
50
+ const response = await queryForObjectInfos(names);
51
51
  const nodes = response?.uiapi?.objectInfos ?? [];
52
52
  const result = graphQLObjectInfosToBatchResponse(nodes, names);
53
53
  objectInfoBatchCache.set(key, result);
@@ -79,14 +79,9 @@ export async function getPicklistValues(
79
79
  fieldName: string,
80
80
  recordTypeId: string = "012000000000000AAA",
81
81
  ): Promise<PicklistValue[]> {
82
- const response = await getObjectInfosGraphQL([objectApiName], {
83
- objectInfoInputs: [
84
- {
85
- apiName: objectApiName,
86
- fieldNames: [fieldName],
87
- },
88
- ],
89
- });
82
+ const response = await queryForPicklistValues([
83
+ { apiName: objectApiName, fieldNames: [fieldName] },
84
+ ]);
90
85
  const nodes = response?.uiapi?.objectInfos ?? [];
91
86
  const node = nodes[0];
92
87
  if (!node) return [];
@@ -75,7 +75,7 @@ export function UiApiDetailForm({
75
75
 
76
76
  const objectInfo: ObjectInfo | null = useMemo(() => {
77
77
  if (!metadata?.fields) return null;
78
- const apiName = typeof metadata.apiName === "string" ? metadata.apiName : undefined;
78
+ const apiName = metadata.ApiName;
79
79
  return {
80
80
  apiName,
81
81
  fields: Object.fromEntries(
@@ -83,7 +83,7 @@ export function UiApiDetailForm({
83
83
  name,
84
84
  {
85
85
  compoundFieldName: f.compoundFieldName ?? undefined,
86
- dataType: f.dataType,
86
+ dataType: f.dataType ?? "",
87
87
  },
88
88
  ]),
89
89
  ),
@@ -44,7 +44,7 @@ export function useObjectInfoBatch(objectApiNames: string[]): UseObjectInfoBatch
44
44
  .then((res) => {
45
45
  if (isCancelled.current) return;
46
46
  const objectInfos = names
47
- .map((apiName) => res.results?.find((r) => r.result?.apiName === apiName)?.result)
47
+ .map((apiName) => res.results?.find((r) => r.result?.ApiName === apiName)?.result)
48
48
  .filter((r) => r != null) as ObjectInfoResult[];
49
49
  setState({ objectInfos, loading: false, error: null });
50
50
  })
@@ -1,32 +1,6 @@
1
- import { z } from "zod";
1
+ import type { PicklistValue as GraphQLPicklistValue } from "../objectInfo/objectInfo";
2
2
 
3
- /**
4
- * Type definitions for picklist value structures
5
- */
6
-
7
- // Zod Schema for Picklist Value
8
- const PicklistValueSchema = z
9
- .object({
10
- // 1. Cleanup: Attributes are usually an object, not just 'unknown'
11
- attributes: z.record(z.string(), z.unknown()).nullish(),
12
- label: z.string(),
13
-
14
- // 2. Precise Typing: 'validFor' is an array of indices (numbers)
15
- // pointing to the controlling field's values.
16
- validFor: z.array(z.number()).nullish(),
17
- value: z.string(),
18
-
19
- // 3. Usability: Added common API fields that are useful for UI logic
20
- // (marked optional in case the specific API version omits them)
21
- defaultValue: z.boolean().nullish(),
22
- active: z.boolean().nullish(),
23
- })
24
- .passthrough();
25
-
26
- /**
27
- * Single picklist value from the API
28
- */
29
- export type PicklistValue = z.infer<typeof PicklistValueSchema>;
30
-
31
- // Export schema for validation
32
- export const PicklistValueArraySchema = z.array(PicklistValueSchema);
3
+ export type PicklistValue = GraphQLPicklistValue & {
4
+ value: NonNullable<GraphQLPicklistValue["value"]>;
5
+ label: NonNullable<GraphQLPicklistValue["label"]>;
6
+ };
@@ -1,166 +1,49 @@
1
- import { z } from "zod";
2
-
3
- /**
4
- * Type definitions and Zod schemas for Object Info Batch API response
5
- */
6
-
7
- // Zod Schema for Child Relationship
8
- const ChildRelationshipSchema = z.object({
9
- childObjectApiName: z.string(),
10
- fieldName: z.string(),
11
- junctionIdListNames: z.array(z.string()),
12
- junctionReferenceTo: z.array(z.string()),
13
- relationshipName: z.string(),
14
- });
15
-
16
- // Zod Schema for Reference To Info
17
- const ReferenceToInfoSchema = z.object({
18
- apiName: z.string(),
19
- nameFields: z.array(z.string()),
20
- });
21
-
22
- // Zod Schema for Filtered Lookup Info (can be null or object)
23
- const FilteredLookupInfoSchema = z.record(z.string(), z.unknown()).nullable();
24
-
25
- // Zod Schema for Field Definition
26
- // Using passthrough to allow extra fields that might be present in the API response
27
- const FieldSchema = z
28
- .object({
29
- apiName: z.string(),
30
- calculated: z.boolean(),
31
- compound: z.boolean(),
32
- compoundComponentName: z.string().nullable(),
33
- compoundFieldName: z.string().nullable(),
34
- controllerName: z.string().nullable(),
35
- controllingFields: z.array(z.string()),
36
- createable: z.boolean(),
37
- custom: z.boolean(),
38
- dataType: z.string(),
39
- defaultValue: z.unknown().nullable(),
40
- defaultedOnCreate: z.boolean(),
41
- digits: z.number(),
42
- externalId: z.boolean(),
43
- extraTypeInfo: z.string().nullable(),
44
- filterable: z.boolean(),
45
- filteredLookupInfo: FilteredLookupInfoSchema,
46
- highScaleNumber: z.boolean(),
47
- htmlFormatted: z.boolean(),
48
- inlineHelpText: z.string().nullable(),
49
- label: z.string(),
50
- length: z.number(),
51
- maskType: z.string().nullable(),
52
- nameField: z.boolean(),
53
- polymorphicForeignKey: z.boolean(),
54
- precision: z.number(),
55
- reference: z.boolean(),
56
- referenceTargetField: z.string().nullable(),
57
- referenceToInfos: z.array(ReferenceToInfoSchema),
58
- relationshipName: z.string().nullable(),
59
- required: z.boolean(),
60
- scale: z.number(),
61
- searchPrefilterable: z.boolean(),
62
- sortable: z.boolean(),
63
- unique: z.boolean(),
64
- updateable: z.boolean(),
65
- })
66
- .passthrough();
67
-
68
- // Zod Schema for Record Type Info
69
- // Using passthrough to allow extra fields that might be present in the API response
70
- const RecordTypeInfoSchema = z
71
- .object({
72
- available: z.boolean(),
73
- defaultRecordTypeMapping: z.boolean(),
74
- master: z.boolean(),
75
- name: z.string(),
76
- recordTypeId: z.string(),
77
- })
78
- .passthrough();
79
-
80
- // Zod Schema for Theme Info
81
- const ThemeInfoSchema = z.object({
82
- color: z.string(),
83
- iconUrl: z.string(),
84
- });
85
-
86
- // Zod Schema for Object Info Result
87
- // Using passthrough to allow extra fields and using FieldSchema/RecordTypeInfoSchema with passthrough
88
- const ObjectInfoResultSchema = z
89
- .object({
90
- apiName: z.string(),
91
- associateEntityType: z.string().nullable(),
92
- associateParentEntity: z.string().nullable(),
93
- childRelationships: z.array(ChildRelationshipSchema),
94
- compactLayoutable: z.boolean(),
95
- createable: z.boolean(),
96
- custom: z.boolean(),
97
- defaultRecordTypeId: z.string(),
98
- deletable: z.boolean(),
99
- dependentFields: z.record(z.string(), z.unknown()),
100
- eTag: z.string(),
101
- feedEnabled: z.boolean(),
102
- // Avoid using FieldSchema because of performance concerns with validating the high number of fields returned from the Salesforce API and causing the UI to freeze.
103
- fields: z.record(z.string(), z.any()),
104
- keyPrefix: z.string(),
105
- label: z.string(),
106
- labelPlural: z.string(),
107
- layoutable: z.boolean(),
108
- mruEnabled: z.boolean(),
109
- nameFields: z.array(z.string()),
110
- queryable: z.boolean(),
111
- // Avoid using RecordTypeInfoSchema because of performance concerns with validating the high number of fields returned from the Salesforce API and causing the UI to freeze.
112
- recordTypeInfos: z.record(z.string(), z.any()),
113
- searchLayoutable: z.boolean(),
114
- searchable: z.boolean(),
115
- themeInfo: ThemeInfoSchema,
116
- updateable: z.boolean(),
117
- })
118
- .passthrough();
119
-
120
- // Zod Schema for Object Info Batch Result Item
121
- const ObjectInfoBatchResultItemSchema = z.object({
122
- result: ObjectInfoResultSchema,
123
- statusCode: z.number(),
124
- });
125
-
126
- // Zod Schema for Object Info Batch Response (array of items)
127
- export const ObjectInfoBatchResponseSchema = z.object({
128
- results: z.array(ObjectInfoBatchResultItemSchema),
129
- });
130
-
131
- // TypeScript Types (inferred from Zod schemas)
132
- export type ChildRelationship = z.infer<typeof ChildRelationshipSchema>;
133
- export type ReferenceToInfo = z.infer<typeof ReferenceToInfoSchema>;
134
- export type FilteredLookupInfo = z.infer<typeof FilteredLookupInfoSchema>;
135
- export type Field = z.infer<typeof FieldSchema>;
136
- export type RecordTypeInfo = z.infer<typeof RecordTypeInfoSchema>;
137
- export type ThemeInfo = z.infer<typeof ThemeInfoSchema>;
138
- export type ObjectInfoBatchResponse = z.infer<typeof ObjectInfoBatchResponseSchema>;
139
- // Type Patching: Overwriting the "any" from the performance-optimized schema
140
- // with the strict types defined above. This ensures Developers get strict typing
141
- // even though the Runtime Validator skips the deep check.
142
- export type ObjectInfoResult = Omit<
143
- z.infer<typeof ObjectInfoResultSchema>,
144
- "fields" | "recordTypeInfos"
145
- > & {
146
- fields: Record<string, Field>;
147
- recordTypeInfos: Record<string, RecordTypeInfo>;
1
+ import type { GetObjectInfosQuery, GetPicklistValuesQuery } from "../schema";
2
+
3
+ // Generic utility types for extracting array item types
4
+ type ArrayItem<T> = T extends (infer Item)[] ? Item : never;
5
+ type NonNullableArrayItem<T> = NonNullable<ArrayItem<NonNullable<T>>>;
6
+
7
+ // ObjectInfos extraction
8
+ export type GetObjectInfosQueryObjectInfos = NonNullable<
9
+ GetObjectInfosQuery["uiapi"]["objectInfos"]
10
+ >;
11
+ export type GetObjectInfosQueryObjectInfo = NonNullableArrayItem<GetObjectInfosQueryObjectInfos>;
12
+ export type GetObjectInfosQueryField = NonNullableArrayItem<
13
+ GetObjectInfosQueryObjectInfo["fields"]
14
+ >;
15
+
16
+ // ObjectInfoResult types
17
+ export type ObjectInfoResult = Omit<GetObjectInfosQueryObjectInfo, "fields"> & {
18
+ fields: Record<string, GetObjectInfosQueryField>;
148
19
  };
149
- export type ObjectInfoBatchResultItem = Omit<
150
- z.infer<typeof ObjectInfoBatchResultItemSchema>,
151
- "result"
152
- > & {
153
- result: ObjectInfoResult;
20
+ export type ObjectInfoBatchResponse = {
21
+ results: { result: ObjectInfoResult; statusCode: number }[];
154
22
  };
155
23
 
156
- // Export schemas for validation
157
- export {
158
- ChildRelationshipSchema,
159
- ReferenceToInfoSchema,
160
- FilteredLookupInfoSchema,
161
- FieldSchema,
162
- RecordTypeInfoSchema,
163
- ThemeInfoSchema,
164
- ObjectInfoResultSchema,
165
- ObjectInfoBatchResultItemSchema,
166
- };
24
+ // Picklist values extraction
25
+ export type GetPicklistValuesQueryObjectInfos = GetPicklistValuesQuery["uiapi"]["objectInfos"];
26
+ export type GetPicklistValuesQueryObjectInfo =
27
+ NonNullableArrayItem<GetPicklistValuesQueryObjectInfos>;
28
+ export type GetPicklistValuesQueryField = NonNullableArrayItem<
29
+ GetPicklistValuesQueryObjectInfo["fields"]
30
+ >;
31
+
32
+ // Extract picklist-specific field type (the one with picklistValuesByRecordTypeIDs)
33
+ type GetPicklistValuesQueryPicklistField = Extract<
34
+ GetPicklistValuesQueryField,
35
+ { picklistValuesByRecordTypeIDs?: unknown }
36
+ >;
37
+
38
+ // Extract types from picklistValuesByRecordTypeIDs
39
+ type PicklistValuesByRecordTypeIDs =
40
+ GetPicklistValuesQueryPicklistField["picklistValuesByRecordTypeIDs"];
41
+ type PicklistValuesByRecordTypeID = NonNullable<
42
+ NonNullable<PicklistValuesByRecordTypeIDs> extends (infer Item)[] ? Item : null
43
+ >;
44
+
45
+ // Extract individual picklist value type
46
+ type PicklistValues = NonNullable<PicklistValuesByRecordTypeID>["picklistValues"];
47
+ export type PicklistValue = NonNullable<
48
+ NonNullable<PicklistValues> extends (infer Item)[] ? Item : null
49
+ >;