import { defineComponent, withApiName, validateCustomApiName, type ComponentDefinition } from './component'; import { CustomObjectFieldSection, type CustomObjectFieldSectionProps } from '../custom-object-field-section'; import { manifestObject, type ObjectReference, scopedDefinition, type ObjectScoped } from './custom-object'; export type DefineFieldSectionProps = Omit & { apiName: `${string}__c`; }; export function defineFieldSection( object: TObject, props: DefineFieldSectionProps, ): ObjectScoped { validateCustomApiName(props.apiName); return fieldSectionComponent.register( scopedDefinition( object, withApiName( new CustomObjectFieldSection(manifestObject(object), { ...props, sectionId: props.apiName }), props.apiName, ), ), object, props, ); } const fieldSectionComponent: ComponentDefinition = defineComponent({ type: 'CUSTOM_OBJECT_FIELD_SECTION', define: defineFieldSection, references: (_definition, object) => [object], });