Skip to content

TemplatePropertiesBuilder

Declares the typed Properties of a Template.

readonly properties: Record<string, JsonPropertyBuilder | TemplatePropertyBuilder>

Declared Properties, keyed by Property key.

addProperty<TType>(key, type, options?): TType extends keyof TemplatePropertyBuilderMap ? TemplatePropertyBuilderMap[TType] : TemplatePropertyBuilder

Declares a Property of the given primitive, temporal, select or Zod type.

TType extends ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>> | PropertyDefinitionType

Declared type, which selects the returned builder.

string

Property key within the Template.

TType

Data type name or Zod type for the value.

PropertyDefinitionOptions<TType>

Label and format options.

TType extends keyof TemplatePropertyBuilderMap ? TemplatePropertyBuilderMap[TType] : TemplatePropertyBuilder

A select builder for select types, a JSON builder for schemas, otherwise a Property builder.

A string type declares a typed Property; a Zod type declares a json Property whose values that type parses. Property keys follow the resource key rules and may not be id or state. A declaration does not guarantee the value is present or visible in every Item.

When key is not a valid Property key.

Declaring Properties of different types

location.addProperty('code', 'string', { label: 'Code' }).index();
poll.addProperty('fields', zPropertyDefinition.array());
const tier = workspace.addProperty('tier', 'single-select');
tier.addOption('free', {});
tier.addOption('team', {});

Handle incomplete data