Sanity Library Reference Docs
    Preparing search index...

    Interface GenerateTargetBeta

    Hierarchy (View Summary)

    Index

    Properties

    By default, all children up to target.maxPathDepth are included. Fields or array items not on the exclude list, are implicitly included.

    By default, all children up to target.maxPathDepth are included.

    When include is specified, only segments explicitly listed will be included.

    Fields or array items not on the include list, are implicitly excluded.

    maxPathDepth?: number

    maxPathDepth controls how deep into the schema from the target root the instruction will affect.

    Depth is based on path segments:

    • title has depth 1
    • array[_key="no"].title has depth 3

    Be careful not to set this too high in studios with recursive document schemas, as it could have negative impact on performance; both for runtime and quality of responses.

    Default: 4

    operation?: GenerateOperation

    Sets the default operation for all paths in the target. Generate runs in 'mixed' operation mode by default: Changes are set in all non-array fields, and append to all array fields.

    • 'set' – an overwriting operation, and replaces the full field value.
    • 'append': – array fields: appends new items to the end of the array,
      • string fields: '"existing content" "new content"'
      • text fields: '"existing content"\n"new content"'
      • number fields: existing + new
      • other field types not mentioned will set instead (dates, url)
    • 'mixed' – (default) sets non-array fields, and appends to array fields

    The default operation can be overridden on a per-path basis using include.

    Nested fields inherit the operation specified by their parent and falls back to the top level target operation if not otherwise specified.

    Use include to change the operation of individual fields or items.

    target: {path: ['array'], operation: 'append'} will append the output of the instruction to the end of the array.

    To insert in the middle of the array, use target: {path: ['array', {_key: 'appendAfterKey'}], operation: 'append'}. Here, the output of the instruction will be appended after the array item with key 'appendAfterKey'.

    • #AgentActionTargetInclude.operation
    • #include
    • #AgentActionTargetInclude.include
    • #AgentActionSchema.forcePublishedWrite

    Root target path.

    Use this to have the instruction only affect a part of the document.

    To further control the behavior of individual paths under the root, use include, exclude, types.include and types.exclude.

    Example:

    path: ['body', {_key: 'someKey'}, 'nestedObject']

    Here, the instruction will only write to fields under the nestedObject.

    Default: [] = the document itself

    • #AgentActionPathSegment
    • #AgentActionPath

    Types can be used to exclude array item types or all fields directly under the target path of a certain type. If you do exclude: ['string'] all string fields under the target will be excluded, for instance.

    types.include and types.exclude are mutually exclusive.