Skip to content

Releases: sanity-io/client

v7.6.0

13 Jun 12:53
eb5bf1c
Compare
Choose a tag to compare

7.6.0 (2025-06-13)

Features

  • transform: adds support for optional imageUrl param in for target.operation image-description (#1105) (c47214f)

Agent Action: Transform – Image descriptions

Targeting images outside the document (URL)

If the source image is available on a https URL outside the target document, it is possible to get a description for it using imageUrl.

Example:

client.agent.action.transform({
  schemaId,
  documentId,
  instruction: 'describe the image in great detail',
  target: [
    {
      path: ['imageDescription'],
      operation: {
        type: 'image-description',
        imageUrl: 'https://www.sanity.io/static/images/favicons/android-icon-192x192.png?v=2',
      },
    },
  ],
})

v7.5.0

06 Jun 14:07
a8821ea
Compare
Choose a tag to compare

7.5.0 (2025-06-06)

  • agent.action.transform can now transform images to text descriptions (#1096) (609e572)

Image descriptions

Images can be transformed to a textual description by targeting a string, text or Portable Text field (array with block)
with operation: {type: 'image-description'}.

Custom instructions for image description targets will be used to generate the description.

Targeting image fields

If a target is a descendant field of an image object, no sourcePath is required in the operation:

For example:

  • target: {path: ['image', 'description'], operation: {type: 'image-description'} }
  • target: {path: ['array', {_key: 'abc'}, 'alt'], operation: {type: 'image-description'} } //assuming the item in the array on the key-ed path is an image
  • target: {path: ['image'], include: ['portableTextField'], operation: {type: 'image-description'}, instruction: 'Use formatting and headings to describe the image in great detail' }

Targeting non-image fields

If the target image description lives outside an image object, use the sourcePath option to specify the path to the image field.
sourcePath must be an image or image asset field.

For example:

  • target: {path: ['description'], operation: {type: 'image-description', sourcePath: ['image', 'asset'] }
  • target: {path: ['wrapper', 'title'], operation: {type: 'image-description', sourcePath: ['array', {_key: 'abc'}, 'image'] }
  • target: {path: ['wrapper'], include: ['portableTextField'], operation: {type: 'image-description', sourcePath: ['image', 'asset'] }, instruction: 'Use formatting and headings to describe the image in great detail' }

This PR was generated with Release Please. See documentation.

v7.4.1

04 Jun 11:14
b92a34d
Compare
Choose a tag to compare

7.4.1 (2025-06-04)

Bug Fixes

  • only allow non-nullable values in search params (#1043) (19c00ea)

v7.4.0

30 May 12:18
8ae294f
Compare
Choose a tag to compare

7.4.0 (2025-05-29)

Highlights

Agent Actions no longer mutate published documents by default (#1092) (7587e2c)

API Breaking Change: As of this release, Agent Actions will never write to published documents by default. Use forcePublishedWrite: true in the request to write to published documents.

Agent Actions require apiVersion: 'vX'. Therefore, this is new behavior will apply to all users of agent actions, regardless of client version. Using this release (or later) will be required to opt out of the new behavior using forcePublishedWrite: true.

As of this going out, by default:

  • Agent Actions will not mutate a published document. It will use a drafts id if a published id is provided
  • Operations on drafts will get initial state from published doc if no draft exists.
  • Callers should check the _id in the response as needed; when a publishedId is provided a drafts.publishedId will be returned.

To opt out of the default behavior, pass forcePublishedWrite: true

Exceptions:

  • Documents with liveEdit: true in the schema definition will behave as if forcePublishedWrite: true, and also will not accept drafts IDs in requests.
  • Versioned Ids on the form "versions.release-id.document-id" will always behave as if forcePublishedWrite: true, and will not consider draft nor published state; only the version itself.

New Agent Actions

Patch: a schema aware patch API(#1091) (0bf6de3)

The client.patch and client.transaction API are not schema aware. These allows patching documents any way you want, but the operations will not fail if they deviate from the document schema.

To ensure schema-compliant operation, client.agent.action.patch is available. It will ensure that provided paths and values adhere to the document schema, ensure no duplicate keys are inserted, and merge object values so set operations don't accidentally remove existing values. Learn more in the quick start.

await client.agent.action.patch({
  schemaId: '_.schema.default',
  documentId: 'documentId',
  target: {
    path: ['metadata', 'title'], // path to metadata.title
    operation: 'set',
    value: 'New title'
  }
})

Prompt: Make LLM requests without mutating documents (#1078) (d6b08b7)

agent.action.prompt is an API for sending instructions to the LLM and receiving text or json back. Useful if you want to use the same Sanity client and feed in your content, but don't want to incorporate a third-party library or API key. Learn more in the quick start.

await client.agent.action.prompt({
  instruction: `Give me some ideas for a blog post 
    about using AI with structured content.`
})

Generate and Transform for images(#1093) (475214d)

Generating images

Generate can generate images the same way as AI Assist, for images that have been configured using AI Assist schema options.

To generate images without changing the schema, you can now directly target an image asset path.

For example, all the following will generate an image into the provided asset:

  • target: {path: ['image', 'asset'] }
  • target: {path: 'image', include: ['asset'] }

Image generation can be combined with regular content targets:

  • target: [{path: ['image', 'asset'] }, {include: ['title', 'description']}]

As Generate happens in a single LLM pass, the image will be contextually related to other generated content.

Transforming images

To transform an existing image, directly target an image asset path with Transform.

For example, all the following will transform the image into the provided asset:

  • target: {path: ['image', 'asset'] }

target: {path: 'image', include: ['asset'] }

Image transform can be combined with regular content targets:

  • target: [{path: ['image', 'asset'] }, {include: ['title', 'description']}]

Image transform can have per-path instructions, just like any other target paths:

  • target: [{path: ['image', 'asset'], instruction: 'Make the sky blue' }

See the updated image generation documentation for more details.

Bug Fixes

  • add support for custom headers in listen and live clients (#1087) (11a103f)

v7.3.0

20 May 15:21
580a524
Compare
Choose a tag to compare

7.3.0 (2025-05-20)

Features

  • pass default headers to createClient for all requests (#1079) (e99c852)

v7.2.2

19 May 08:41
010e75e
Compare
Choose a tag to compare

7.2.2 (2025-05-19)

Bug Fixes

  • deps: update dependency get-it to ^8.6.9 (#1080) (7a7c6be)

v7.2.1

09 May 15:58
7db7b9a
Compare
Choose a tag to compare

7.2.1 (2025-05-09)

Bug Fixes

  • downgrade nanoid to ensure compatibility with node < 22 (#1076) (368a12d)

v7.2.0

09 May 13:45
3e3f398
Compare
Choose a tag to compare

7.2.0 (2025-05-09)

Features

Content Release and Document Version operations (#1067) (9b80bd8)

The client now has complete abstractions and types for all Content Lake release and version actions.

These are available to be used directly interfacing with the server action:

client.action(
  {
    actionType: 'sanity.action.document.version.create',
    publishedId: 'bike-123',
    document: {
      _id: 'versions.new-bike-release.bike-123'
      _type: 'bike'
    }
  }
)

Or additionally through method abstractions which provide more unified concepts such as releaseId and publishedId, in addition to client side guards on mismatching IDs:

client.createVersion(
  {
    publishedId: 'bike-123',
    releaseId: 'new-bike-release',
    document: {
      _type: 'bike'
    }
  }
)

Important

Deprecation notice of some document server actions
The discard and replaceDraft actions now have deprecation notices in the client, to reflect updates on the underlying Content Lake API.

discard is superseded by discardVersion and replaceDraft by replaceVersion

v7.1.0

06 May 08:51
4529e0d
Compare
Choose a tag to compare

7.1.0 (2025-05-05)

Features

v7.0.0

30 Apr 13:15
f678b54
Compare
Choose a tag to compare

7.0.0 (2025-04-30)

⚠ BREAKING CHANGES

  • Dropping support for Node.js < v20 as Node.js v18 is EOL as of 2025-04-30

Bug Fixes