Object Selector
The Object selector provides a structured object input with nested fields.
Options
All object selectors accept these common metadata options:
default?: Record<string, unknown>- Default object valuedescription?: string- Human-readable description shown in the UIrequired?: boolean- Whether the field must be provided
Object-specific options (from ServiceListSelector["object"]):
fields?: Record<string, { selector: ServiceListSelector; required?: boolean; label?: string }>- Nested field definitions for the object structuremultiple?: boolean- Whentrue, allows selecting multiple objects (returns array)label_field?: string- Field name to use as the label for each objectdescription_field?: string- Field name to use as the description for each objecttranslation_key?: string- Translation key for the object selector
Return Type
Record<string, unknown>whenmultipleis not set orfalseRecord<string, unknown>[]whenmultiple: true
When fields are provided, the return type is inferred from the nested field selectors, creating a typed object structure.
Example
import { TServiceParams } from "@digital-alchemy/core";
import { ServiceField } from "@digital-alchemy/synapse";
export function SynapseServiceCreate({
synapse,
context,
logger,
}: TServiceParams) {
synapse.service.create(
{
context,
description: "Configure settings object",
fields: {
// Object selector with nested fields
config: ServiceField.Object({
description: "Configuration object",
required: true,
}),
},
},
async data => {
// data.config is typed as: Record<string, unknown>
logger.info(`Configuration: ${JSON.stringify(data.config)}`);
}
);
}