Skip to content

Commit 819f087

Browse files
committed
- AssetsUnreferencedAction now accepts an optional previewToken parameter, skipping the SpaceApi call when provided (useful for OAuth-only applications)
1 parent aa455f7 commit 819f087

4 files changed

Lines changed: 8 additions & 4 deletions

File tree

.claude/commands/blokctl-api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Every CLI command is backed by a reusable Action class with no CLI dependencies:
4848
| `Story\StoryVersionsAction` | List story versions | `->versions`, `->storyId`, `->count()` |
4949
| `Story\StoriesWorkflowAssignAction` | Assign stage to unstaged stories (preflight+execute) | `->countWithoutStage`, `->workflowStages` |
5050
| `Asset\AssetsListAction` | List/search assets (MAPI only) | `->assets`, `->count()` |
51-
| `Asset\AssetsUnreferencedAction` | Find unreferenced assets | `->unreferencedAssets`, `->totalAssets`, `->referencedCount`, `->storiesAnalyzed` |
51+
| `Asset\AssetsUnreferencedAction` | Find unreferenced assets (optional `previewToken`) | `->unreferencedAssets`, `->totalAssets`, `->referencedCount`, `->storiesAnalyzed` |
5252
| `Workflow\WorkflowsListAction` | List workflows+stages | `->workflows`, `->count()` |
5353
| `Workflow\WorkflowStageShowAction` | Show stage details | `->stage`, `->workflowName` |
5454
| `Component\ComponentsListAction` | List/filter components | `->components`, `->count()` |

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
All notable changes to `blokctl` will be documented in this file.
44

5+
## 0.6.2 - 2026-04-03
6+
- `AssetsUnreferencedAction` now accepts an optional `previewToken` parameter, skipping the SpaceApi call when provided (useful for OAuth-only applications)
7+
58
## 0.6.1 - 2026-04-03
69
- Adding `assets:list`: List assets with optional search filter via Management API
710

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1319,6 +1319,7 @@ use Blokctl\Action\Asset\AssetsUnreferencedAction;
13191319
$result = (new AssetsUnreferencedAction($client))->execute(
13201320
spaceId: $spaceId,
13211321
region: 'EU',
1322+
previewToken: $token, // optional — skips SpaceApi call when provided
13221323
assetsPerPage: 1000,
13231324
storiesPerPage: 100,
13241325
);
@@ -1330,7 +1331,7 @@ $result->storiesAnalyzed; // int
13301331
$result->unreferencedCount(); // int
13311332
```
13321333

1333-
Fetches all assets via the Management API (up to 1000/page), then scans all stories via the Content Delivery API (higher rate limits) for asset references. Returns the set difference.
1334+
Fetches all assets via the Management API (up to 1000/page), then scans all stories via the Content Delivery API (higher rate limits) for asset references. Returns the set difference. Pass `previewToken` to skip the SpaceApi lookup (useful for OAuth-only applications).
13341335

13351336
### Components
13361337

src/Action/Asset/AssetsUnreferencedAction.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public function __construct(
2525
public function execute(
2626
string $spaceId,
2727
string $region = 'EU',
28+
?string $previewToken = null,
2829
int $assetsPerPage = 1000,
2930
int $storiesPerPage = 100,
3031
): AssetsUnreferencedResult {
@@ -62,8 +63,7 @@ public function execute(
6263
}
6364

6465
// Step 2: Get preview token and set up CDN client
65-
$space = (new SpaceApi($this->client))->get($spaceId)->data();
66-
$token = $space->firstToken();
66+
$token = $previewToken ?? (new SpaceApi($this->client))->get($spaceId)->data()->firstToken();
6767

6868
if ($token === '') {
6969
throw new \RuntimeException('No preview access token found for this space.');

0 commit comments

Comments
 (0)