# Changelog

All notable changes to `@structdk/extension-sdk` are documented in this file.

The format is loosely based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.2.0] - 2026-10-01

### Added
- `WidgetContextPayload` now carries `widgetUid` and `isSettingsMode`, so a widget
  extension can tell which dashboard widget it renders in and whether it is being
  shown on the dashboard or in the widget settings surface. Together they let an app
  store configuration scoped to a single widget on its own backend. `widgetUid` is a
  render-slot identifier rather than a credential: authorize with `getToken()` and
  scope stored configuration by the token's `tenantSlug`. See "Widget context" in the
  README for the full rules, including the fact that a widget uid can refer to a
  widget that is never saved.

## [1.1.0] — 2026-08-11

### Changed
- `getToken()` and `getContext()` now reject as soon as Struct PIM reports it cannot serve
  the request, instead of waiting out the timeout. The rejection carries the host's reason,
  e.g. `Struct PIM rejected getToken: Failed to mint a token for this app instance`.
  A rejection addressed to a different action is ignored.
- Timeout errors now describe what the SDK could observe rather than guessing at a cause:
  whether the page is embedded at all, the configured host origin, and whether another
  script or browser extension has replaced `window.postMessage` or `window.addEventListener`.
  The previous wording ("is the SDK running inside a Struct PIM iframe?") was reported even
  when the SDK was correctly embedded.

## [1.0.8] — 2026-06-03

### Added
- `struct.actions.navigate({ path })` — navigate the Struct PIM host to a
  relative path within the PIM (e.g. `/pim/search`). The host resolves the
  path against the current tenant origin, so extensions do not need to know
  the tenant host. Absolute and protocol-relative URLs are rejected.
  Supported on all extension points.
- `struct.actions.getToken()` — request a short-lived signed token (JWT)
  from Struct PIM for the current app. The token is minted server-side and
  signed with the app's client secret, and can be verified with the same
  secret to confirm it originates from a genuine Struct embedded session.
  Resolves with `{ token, expiresAt, issuedAt }`. Supported on all
  extension points.

## [1.0.7] — 2026-05-26

### Added
- `struct.actions.navigateToEntity({ entityType, entityId })` — navigate the
  Struct PIM host to the editor for a given entity. Supported entity types:
  `Product`, `Variant`, `VariantGroup`, `Category`, `Asset`, `GlobalList`,
  `GlobalListValue`.
- `struct.actions.refreshEditor()` — ask the host to refresh the editor that
  is hosting the extension iframe. Re-fetches the editor model, breadcrumbs
  and thumbnail without a page reload. If the user has unsaved changes the
  host prompts them to confirm before discarding their work. Supported on
  `Tab`, `Section`, `Property`, and `SidebarWidget` extension points.
- `struct.actions.setIsDirtyState({ isDirty })` — notify the host whether
  the extension currently has unsaved changes, so the surrounding editor
  can show its standard unsaved-changes confirmation dialog when the user
  attempts to navigate away. Supported on `Tab`, `Section`, and `Property`
  extension points.

## [1.0.6] — 2026-04-08

### Added
- `struct.actions.closeHostContainer()` — ask the host to dismiss the
  dialog hosting the extension iframe. Supported on the `Exporter` and
  `SearchAction` extension points.

## [1.0.5] — 2026-03-23

### Changed
- README rewritten to document the post-`createStructSDK` API surface
  (actions, events, context payload types, cleanup).

## [1.0.4] — 2026-03-19

### Added
- `createStructSDK(options?)` factory — returns the `{ actions, events,
  destroy }` object that is now the SDK's primary entry point. Replaces
  the previous module-level action/event imports.
- `struct.actions.enableAutoResize({ maxHeight?, debounceMs? })` — auto-
  adjusts the iframe height based on content via a `ResizeObserver`.
- `struct.events.onActionRejectedEvent(handler)` — fired when the host
  rejects an action (e.g. an unsupported action for the current extension
  point type).
- `struct.destroy()` — unsubscribes all event listeners and stops any
  active auto-resize observer.
- `StructSDKOptions.hostOrigin` — when provided, the SDK only accepts
  messages from that origin. If omitted, all origins are accepted and a
  warning is logged.

## [1.0.3] — 2026-03-18

### Changed
- **Breaking:** Initialisation switched from push-based to pull-based.
  Extensions now call `struct.actions.getContext()` (returns a Promise)
  instead of subscribing to `onInitEvent`. This removes the race between
  iframe load and the host's init message.

### Removed
- `onInitEvent` — replaced by `getContext`.

## [1.0.1] — 2026-03-12

### Fixed
- Internal messaging and packaging fixes following the initial publish.

## [1.0.0] — 2026-03-10

### Added
- Initial public release.
- `openModal`, `closeModal`, `showSnackbarMessage`, `resizeContainer`
  actions.
- `onInitEvent` for receiving the extension's startup context from the
  host (replaced in 1.0.3).
