@se-studio/contentful-cms 3.4.3 → 3.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/commands/add-target-field.d.ts +15 -0
  3. package/dist/commands/add-target-field.d.ts.map +1 -0
  4. package/dist/commands/add-target-field.js +48 -0
  5. package/dist/commands/add-target-field.js.map +1 -0
  6. package/dist/commands/add.d.ts.map +1 -1
  7. package/dist/commands/add.js +89 -73
  8. package/dist/commands/add.js.map +1 -1
  9. package/dist/commands/media.d.ts.map +1 -1
  10. package/dist/commands/media.js +14 -0
  11. package/dist/commands/media.js.map +1 -1
  12. package/dist/generated/hosted-guide.d.ts +1 -1
  13. package/dist/generated/hosted-guide.d.ts.map +1 -1
  14. package/dist/generated/hosted-guide.js +1 -1
  15. package/dist/generated/hosted-guide.js.map +1 -1
  16. package/dist/generated/version.d.ts +1 -1
  17. package/dist/generated/version.js +1 -1
  18. package/dist/mcp/tools/cms-edit.d.ts.map +1 -1
  19. package/dist/mcp/tools/cms-edit.js +31 -2
  20. package/dist/mcp/tools/cms-edit.js.map +1 -1
  21. package/dist/mcp/tools/media.d.ts.map +1 -1
  22. package/dist/mcp/tools/media.js +33 -2
  23. package/dist/mcp/tools/media.js.map +1 -1
  24. package/dist/media-pipeline/import-filter.d.ts +36 -0
  25. package/dist/media-pipeline/import-filter.d.ts.map +1 -0
  26. package/dist/media-pipeline/import-filter.js +53 -0
  27. package/dist/media-pipeline/import-filter.js.map +1 -0
  28. package/dist/media-pipeline/import.d.ts +6 -0
  29. package/dist/media-pipeline/import.d.ts.map +1 -1
  30. package/dist/media-pipeline/import.js +28 -1
  31. package/dist/media-pipeline/import.js.map +1 -1
  32. package/dist/preview/entry-urls.d.ts +13 -2
  33. package/dist/preview/entry-urls.d.ts.map +1 -1
  34. package/dist/preview/entry-urls.js +49 -11
  35. package/dist/preview/entry-urls.js.map +1 -1
  36. package/docs/editor-tasks/create-from-document.md +3 -2
  37. package/docs/editor-tasks/media-pipeline-prepare.md +28 -8
  38. package/docs/editor-tasks/media-reuse-and-upload.md +13 -3
  39. package/docs/editor-tasks/preview-verify.md +7 -6
  40. package/docs/mcp/hosted-guide.md +11 -0
  41. package/package.json +1 -1
@@ -25,7 +25,8 @@ Normalize a **folder of designer masters** into short-lived **public HTTPS URLs*
25
25
  - `MEDIA_PIPELINE_TENANT` (e.g. `se`, not the cms-edit projectKey)
26
26
  - Drive folder shared **Viewer** with pipeline service account
27
27
  `media-pipeline-reader@se-media-pipeline.iam.gserviceaccount.com`
28
- (or “anyone with the link” if using API-key Drive mode on the pipeline)
28
+ (or “anyone with the link” if using API-key Drive mode on the pipeline).
29
+ **If prepare/status reports `drive_inaccessible` or `drive_empty_or_unshared`:** fix the share first, then re-prepare **once**. Do not treat “no media files” as a wrong folder path until share is confirmed.
29
30
  - Profile default: `case-study-v1`
30
31
 
31
32
  ## When to use
@@ -106,26 +107,44 @@ Each asset includes:
106
107
 
107
108
  After drafting titles/alts from **previewUrl** / **posterUrl**:
108
109
 
110
+ **Prefer filtering** so unused files in a shared Drive folder are not uploaded:
111
+
112
+ | Param | Use |
113
+ |-------|-----|
114
+ | `sourceNames` | Exact catalog `sourceName` allowlist (Drive file names) |
115
+ | `excludeSourceNames` | Skip specific files |
116
+ | `onlyWithOverrides` | Import only assets that have an `overrides` row (typical case-study path) |
117
+
109
118
  ```json
110
119
  {
111
120
  "action": "import",
112
121
  "jobId": "<jobId>",
113
122
  "withMedia": true,
123
+ "onlyWithOverrides": true,
114
124
  "overrides": [
115
- { "sourceName": "OM1_Hero.jpg", "title": "OM1 hero", "alt": "…" }
116
- ]
125
+ { "sourceName": "OM1_Hero.jpg", "title": "OM1 hero", "alt": "…", "fileName": "se-om1-hero-v3.jpg" }
126
+ ],
127
+ "dryRun": true
117
128
  }
118
129
  ```
119
130
 
120
- Optional: `"dryRun": true` to preview the map without writing.
131
+ 1. Always **`dryRun: true` first** — check `existing: true/false` per asset (reuse is by **fileName**).
132
+ 2. When you need **new** assets instead of reusing prior runs, set `overrides[].fileName` to unique names.
133
+ 3. Then import without `dryRun`.
121
134
 
122
- CLI: `cms-edit media import --job <id> [--dry-run] [--with-media] [--overrides-json '[…]']`
135
+ CLI:
136
+ `cms-edit media import --job <id> [--dry-run] [--with-media] [--only-with-overrides] [--source-names a.jpg,b.jpg] [--exclude-source-names x.jpg] [--overrides-json '[…]']`
123
137
 
124
138
  Import:
125
139
 
126
- 1. Searches existing assets by fileName
127
- 2. Else uploads from `readyUrl` as the authenticated Contentful user
128
- 3. Returns `map: { sourceName → { assetId, mediaId?, … } }` for page build
140
+ 1. Filters catalog (allowlist / exclude / onlyWithOverrides)
141
+ 2. Searches existing assets by fileName
142
+ 3. Else uploads from `readyUrl` as the authenticated Contentful user
143
+ 4. Returns `map`, `skipped[]`, and `counts` for page build
144
+
145
+ **Linking Media to components:** use singular Entry links with
146
+ `cms_edit ["set", "@cN", "visual", "<mediaId>", "--link"]`
147
+ — **never** `add … --target visual` (`add` only supports content **arrays**).
129
148
 
130
149
  Manual `asset upload --url` remains available for one-offs.
131
150
 
@@ -135,3 +154,4 @@ Manual `asset upload --url` remains available for one-offs.
135
154
  - Rate limits apply (prepares/hour, concurrent jobs).
136
155
  - Never document or request `MEDIA_PIPELINE_API_KEY` or Blob tokens in chat.
137
156
  - `provisioning` is **not** a real pipeline phase; do not treat it as “still encoding” for many minutes.
157
+ - If the MCP client times out (~180s) on `set`/`rtf`/`import`, **read / catalog / diff before retrying** — the server may already have applied the change.
@@ -23,8 +23,12 @@
23
23
  - `cms_edit ["asset", "search", "--filename-match", "<partial-name>"]`
24
24
  - `cms_edit ["list", "--type", "media", "--asset-filename-match", "<partial>"]`
25
25
  3. If match found — link by asset ID or filename in `set` / `create from-json` (`featuredImageAssetFilename`, `visualAssetFilename`, etc.)
26
- 4. For **`visuals`** (Media entry array): prefer an **existing Media entry** — `cms_edit ["list", "--type", "media", "--asset-id", "<assetId>"]` — then `set @root visuals <mediaEntryId> --links`. Do **not** `create media` or use `asset upload --with-media` when a wrapper already exists.
27
- 5. `create media` only when no Media entry wraps that asset (RTF embeds, or first article in a new composite batch — then **reuse that media ID** on sibling entries)
26
+ 4. For **`visuals`** (Media entry **array** on page/article): prefer an **existing Media entry** — `cms_edit ["list", "--type", "media", "--asset-id", "<assetId>"]` — then `set @root visuals <mediaEntryId> --links`. Do **not** `create media` or use `asset upload --with-media` when a wrapper already exists.
27
+ 5. For **singular** component fields (e.g. `visual` on a component):
28
+ `cms_edit ["set", "@cN", "visual", "<mediaEntryId>", "--link"]`
29
+ **Never** `add media --parent @cN --target visual` — `add --target` only works for Entry-link **arrays** (`content`, `contents`, …). Bad `add --target` is rejected; it used to orphan Media drafts.
30
+ 6. `create media` only when no Media entry wraps that asset (RTF embeds, or first article in a new composite batch — then **reuse that media ID** on sibling entries)
31
+ 7. Bare Contentful entry IDs work with `set` (no `@` required) for mid-session Media field tweaks (width/autoplay/loop) after import — `set <mediaEntryId> width 75`.
28
32
 
29
33
  ## Upload only when no match
30
34
 
@@ -89,7 +93,13 @@ cms_edit ["diff"]
89
93
  cms_edit ["save"]
90
94
  ```
91
95
 
92
- **Component visual / article featured image:** same pattern — `asset set <ref> <field> <asset-id>` (or `set … --asset`).
96
+ **Component `visual` (Media Entry link, singular):**
97
+
98
+ ```
99
+ cms_edit ["set", "@cN", "visual", "<media-entry-id>", "--link"]
100
+ ```
101
+
102
+ **Article featured image / asset fields:** `asset set <ref> <field> <asset-id>` (or `set … --asset`) when the field is an Asset link.
93
103
 
94
104
  Always `diff` → `save`. Verify with `preview urls` on the public path.
95
105
 
@@ -23,11 +23,11 @@ After saving a draft, agents should return **all applicable URLs** and explain w
23
23
 
24
24
  | Target | Label | When to use |
25
25
  |--------|-------|-------------|
26
- | **contentfulLivePreview** | Live preview (publish here) | **Primary for editors.** Opens `app.contentful.com/.../entries/.../preview/...` — in-app preview with inspector. User clicks the green **Publish** button at the top to go live. |
27
- | **staging** | Preview (staging site) | Full-page check on staging, e.g. `{devBaseUrl}/resources/news/{tag}/{slug}/` (includes Vercel bypass params when configured). |
26
+ | **contentfulLivePreview** | Live preview (publish here) | **Primary for editors when `url` is present.** Opens `app.contentful.com/.../entries/.../preview/...` — in-app preview with inspector. User clicks the green **Publish** button at the top to go live. If `url` is `null`, read `unavailableReason` / `notes` — do not invent a Live Preview link; use **staging** + **contentfulEntry** instead. |
27
+ | **staging** | Preview (staging site) | Full-page check on staging, e.g. `{devBaseUrl}/resources/news/{tag}/{slug}/` (includes Vercel bypass params when configured). Always valid for draft visibility when staging is configured. |
28
28
  | **siteLivePreview** | Preview redirect | `{devBaseUrl}/preview?id={entryId}` — entry-aware redirect to the staging path. |
29
29
  | **production** | Production site | Published content only — compare after publish. |
30
- | **contentfulEntry** | Contentful entry editor | Classic entry form. Prefer **Live preview** for review and publish. |
30
+ | **contentfulEntry** | Contentful entry editor | Classic entry form. Prefer **Live preview** when available; otherwise this is the publish path. |
31
31
 
32
32
  ## Steps
33
33
 
@@ -41,9 +41,10 @@ After saving a draft, agents should return **all applicable URLs** and explain w
41
41
  ```
42
42
  Use `--json` for machine-readable output.
43
43
 
44
- 2. **Hand off to the editor with both links:**
45
- - **Live preview** — for reviewing the draft and publishing (green Publish button in Contentful).
46
- - **Preview (staging site)** — for a full-screen check on the staging deployment.
44
+ 2. **Hand off to the editor:**
45
+ - **Live preview** — when `url` is non-null: reviewing the draft and publishing (green Publish button in Contentful).
46
+ - **Preview (staging site)** — full-screen check on the staging deployment (always offer when available).
47
+ - If Live Preview is unavailable, say so briefly using `unavailableReason` and point at staging + classic entry editor.
47
48
 
48
49
  3. Summarize what to check before publish handoff — use the checklist below (add multi-block items when relevant).
49
50
 
@@ -148,6 +148,17 @@ Hosted connectors have **no server filesystem** and **reject `asset upload --bas
148
148
 
149
149
  Full workflow: `cms-edit://customer/task-media-reuse-and-upload`.
150
150
 
151
+ ### Common pitfalls (agents)
152
+
153
+ | Issue | Do this |
154
+ |-------|---------|
155
+ | Singular Media on a component (`visual`) | `set @cN visual <mediaId> --link` — **not** `add … --target visual` |
156
+ | Shared Drive folder has extra files | Import with `sourceNames` or `onlyWithOverrides` after catalog |
157
+ | Prepare says no media / empty folder | Share folder **Viewer** with `media-pipeline-reader@se-media-pipeline.iam.gserviceaccount.com`, then re-prepare once |
158
+ | MCP tool times out ~180s | `read` / `diff` / re-`catalog` before retrying the same write — server may already have saved |
159
+ | `preview urls` has no Live Preview URL | Use staging + classic entry editor; row includes `unavailableReason` when CMA preview fails |
160
+ | Reuse-first import matches old fileNames | dry-run first; set `overrides[].fileName` for unique names when duplication is required |
161
+
151
162
  ### Staged upload
152
163
 
153
164
  Keeps binary **out of MCP tool args**. The agent uploads via `curl`, then passes only a short `uploadId`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@se-studio/contentful-cms",
3
- "version": "3.4.3",
3
+ "version": "3.4.4",
4
4
  "description": "CLI tool for AI agents to read and edit Contentful draft content without publish permissions",
5
5
  "repository": {
6
6
  "type": "git",