import type { CustomObjectCategoryDefinition } from "./category.mjs"; import type { AnyCustomObjectDefinition, AnyFieldDefinition, CategoryApiName, CustomObjectApiName, CustomObjectDefinition, FieldDefinitions, FieldNames, LogicalCategoryName, LogicalCustomFieldName, LogicalCustomObjectName, NameFieldDefinition, SectionDefinitions } from "./types.mjs"; /** * Internal input shape accepted by {@link defineCustomObject} before normalization. * * @typeParam TObjectName - Logical custom-object name for the definition. * @typeParam TCategoryName - Logical category name associated with the object. * @typeParam TSections - Section map available to field definitions. * @typeParam TFields - Field map keyed by logical custom-field names. * @typeParam TNameField - Optional name-field behavior supplied by the caller. */ type CategoryInput = LogicalCategoryName | CustomObjectCategoryDefinition>; /** * Internal input shape accepted by {@link defineCustomObject} before normalization. * * @typeParam TObjectName - Logical custom-object name for the definition. * @typeParam TCategoryName - Logical category name associated with the object. * @typeParam TSections - Section map available to field definitions. * @typeParam TFields - Field map keyed by logical custom-field names. * @typeParam TNameField - Optional name-field behavior supplied by the caller. */ interface CustomObjectDefinitionInput { readonly name: LogicalCustomObjectName; readonly displayName: string; readonly pluralLabel?: string; readonly category: CategoryInput; readonly ownerRole?: string; readonly enableHistory?: boolean; readonly description: string; readonly icon?: { readonly emoji?: string | null; readonly ripplingIcon?: string | null; readonly s3Bucket?: string; readonly s3Key?: string; }; readonly nameField?: TNameField; readonly sections?: TSections; readonly fields: ValidateFieldMap; } /** * Rejects extension objects that try to redefine keys already present on the base definition. * * @typeParam TExisting - Existing key set on the base definition. * @typeParam TAdded - Proposed extension object. */ type NoOverlappingKeys = Extract extends never ? TAdded : never; /** * Converts a logical field map into a version whose keys must all satisfy the * logical custom-field name contract. * * @typeParam TFields - Candidate logical field map supplied by callers. */ type ValidateFieldMap = { readonly [K in keyof TFields]: K extends string ? LogicalCustomFieldName extends never ? never : TFields[K] : never; }; /** * Appends the platform-required `__c` suffix to a logical custom-object name. * * @param name - Logical unsuffixed custom-object name. * @returns Wire-level custom-object API name with the required `__c` suffix. * @typeParam TObjectName - Logical custom-object name to compile. */ export declare function toCustomObjectApiName(name: LogicalCustomObjectName): CustomObjectApiName; /** * Appends the platform-required `__c` suffix to a logical custom-field name. * * @param name - Logical unsuffixed custom-field name. * @returns Wire-level custom-field API name with the required `__c` suffix. * @typeParam TFieldName - Logical custom-field name to compile. */ export declare function toCustomFieldApiName(name: LogicalCustomFieldName): `${TFieldName}__c`; /** * Appends the platform-required `__c` suffix to a logical category name. * * @param name - Logical unsuffixed category name. * @returns Wire-level category API name with the required `__c` suffix. * @typeParam TCategoryName - Logical category name to compile. */ export declare function toCustomCategoryApiName(name: LogicalCategoryName): CategoryApiName; /** * Defines an immutable, strongly typed custom-object schema. * * Callers author only logical snake_case names. The returned value includes the * derived wire-level api names so downstream tooling can emit valid manifest * payloads without requiring authors to know about the `__c` suffix contract. * * @typeParam TObjectName - Logical custom-object name for the definition. * @typeParam TCategoryName - Logical category name associated with the object. * @typeParam TSections - Section map available to field definitions. * @typeParam TFields - Field map keyed by logical custom-field names. * @param definition - Author-facing typed schema definition to normalize, validate, and freeze. * @returns Immutable normalized custom-object definition with compiled field and object API names. * @typeParam TNameField - Name-field behavior for the object. */ export declare function defineCustomObject(definition: CustomObjectDefinitionInput): Readonly, LogicalCategoryName, TSections, TFields, TNameField>>; /** * Extends an existing object definition without losing type information. * * This helper is useful when a platform package wants to publish a base schema * and another package wants to add fields or sections in a type-safe way. * * @typeParam TBase - Existing object definition being extended. * @typeParam TAddedSections - New section definitions merged into the base object. * @param base - Existing typed object definition to extend. * @param extension - Additional metadata, sections, and fields to merge into the base definition. * @returns New immutable custom-object definition preserving the combined type information. * @typeParam TAddedFields - New field definitions merged into the base object. */ export declare function extendCustomObject(base: TBase, extension: { readonly displayName?: string; readonly pluralLabel?: string; readonly ownerRole?: string; readonly enableHistory?: boolean; readonly description?: string; readonly icon?: TBase['icon']; readonly sections?: NoOverlappingKeys; readonly fields?: NoOverlappingKeys>; }): Readonly & TAddedFields, TBase['nameField']>>; /** * Returns the logical custom field names defined on an object. * * @param definition - Object definition whose logical field names should be returned. * @returns Frozen array of logical field names from the definition. * @typeParam TDefinition - Object definition whose field names should be returned. */ export declare function fieldNames(definition: TDefinition): ReadonlyArray>; /** * Retrieves a field definition by logical field name with precise typing. * * @param definition - Object definition that owns the field. * @param fieldName - Logical field name to retrieve. * @returns Precisely typed field definition for the requested logical field name. * @typeParam TDefinition - Object definition that owns the field. * @typeParam TFieldName - Logical field name being retrieved. */ export declare function getFieldDefinition>(definition: TDefinition, fieldName: TFieldName): TDefinition['fields'][TFieldName]; /** * Returns whether one typed field definition is writable by record create/update helpers. * * @param field - Typed field definition to inspect. * @returns Whether the field may be written by callers. */ export declare function isWritableField(field: AnyFieldDefinition): boolean; export {}; //# sourceMappingURL=definition.d.mts.map