@se-studio/contentful-cms 1.0.91 → 1.1.0

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 (150) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +49 -2
  3. package/dist/cli/program.d.ts.map +1 -1
  4. package/dist/cli/program.js +10 -1
  5. package/dist/cli/program.js.map +1 -1
  6. package/dist/commands/asset.d.ts.map +1 -1
  7. package/dist/commands/asset.js +232 -56
  8. package/dist/commands/asset.js.map +1 -1
  9. package/dist/commands/create-from-json.d.ts.map +1 -1
  10. package/dist/commands/create-from-json.js +63 -69
  11. package/dist/commands/create-from-json.js.map +1 -1
  12. package/dist/commands/create-taxonomy-from-json.d.ts +4 -0
  13. package/dist/commands/create-taxonomy-from-json.d.ts.map +1 -0
  14. package/dist/commands/create-taxonomy-from-json.js +79 -0
  15. package/dist/commands/create-taxonomy-from-json.js.map +1 -0
  16. package/dist/commands/create-taxonomy.d.ts +29 -0
  17. package/dist/commands/create-taxonomy.d.ts.map +1 -0
  18. package/dist/commands/create-taxonomy.js +187 -0
  19. package/dist/commands/create-taxonomy.js.map +1 -0
  20. package/dist/commands/create.d.ts.map +1 -1
  21. package/dist/commands/create.js +14 -36
  22. package/dist/commands/create.js.map +1 -1
  23. package/dist/commands/ensure.d.ts +4 -0
  24. package/dist/commands/ensure.d.ts.map +1 -0
  25. package/dist/commands/ensure.js +95 -0
  26. package/dist/commands/ensure.js.map +1 -0
  27. package/dist/commands/help.js +1 -1
  28. package/dist/commands/help.js.map +1 -1
  29. package/dist/commands/index-dump.d.ts +13 -0
  30. package/dist/commands/index-dump.d.ts.map +1 -0
  31. package/dist/commands/index-dump.js +161 -0
  32. package/dist/commands/index-dump.js.map +1 -0
  33. package/dist/commands/index.d.ts +4 -0
  34. package/dist/commands/index.d.ts.map +1 -0
  35. package/dist/commands/index.js +101 -0
  36. package/dist/commands/index.js.map +1 -0
  37. package/dist/commands/list.d.ts.map +1 -1
  38. package/dist/commands/list.js +91 -17
  39. package/dist/commands/list.js.map +1 -1
  40. package/dist/commands/resolve-options.d.ts +13 -0
  41. package/dist/commands/resolve-options.d.ts.map +1 -0
  42. package/dist/commands/resolve-options.js +29 -0
  43. package/dist/commands/resolve-options.js.map +1 -0
  44. package/dist/commands/resolve.d.ts.map +1 -1
  45. package/dist/commands/resolve.js +70 -26
  46. package/dist/commands/resolve.js.map +1 -1
  47. package/dist/config/load.d.ts.map +1 -1
  48. package/dist/config/load.js +10 -0
  49. package/dist/config/load.js.map +1 -1
  50. package/dist/config/types.d.ts +14 -0
  51. package/dist/config/types.d.ts.map +1 -1
  52. package/dist/contentful/asset-link-from-json.d.ts +17 -0
  53. package/dist/contentful/asset-link-from-json.d.ts.map +1 -0
  54. package/dist/contentful/asset-link-from-json.js +41 -0
  55. package/dist/contentful/asset-link-from-json.js.map +1 -0
  56. package/dist/contentful/assets.d.ts +19 -8
  57. package/dist/contentful/assets.d.ts.map +1 -1
  58. package/dist/contentful/assets.js +82 -31
  59. package/dist/contentful/assets.js.map +1 -1
  60. package/dist/contentful/cda-sync.d.ts +37 -0
  61. package/dist/contentful/cda-sync.d.ts.map +1 -0
  62. package/dist/contentful/cda-sync.js +115 -0
  63. package/dist/contentful/cda-sync.js.map +1 -0
  64. package/dist/contentful/delivery-token.d.ts +17 -0
  65. package/dist/contentful/delivery-token.d.ts.map +1 -0
  66. package/dist/contentful/delivery-token.js +103 -0
  67. package/dist/contentful/delivery-token.js.map +1 -0
  68. package/dist/contentful/entry-fields.d.ts +71 -0
  69. package/dist/contentful/entry-fields.d.ts.map +1 -0
  70. package/dist/contentful/entry-fields.js +334 -0
  71. package/dist/contentful/entry-fields.js.map +1 -0
  72. package/dist/contentful/fetch.d.ts +11 -1
  73. package/dist/contentful/fetch.d.ts.map +1 -1
  74. package/dist/contentful/fetch.js +30 -6
  75. package/dist/contentful/fetch.js.map +1 -1
  76. package/dist/contentful/field-value-from-json.d.ts +24 -0
  77. package/dist/contentful/field-value-from-json.d.ts.map +1 -0
  78. package/dist/contentful/field-value-from-json.js +205 -0
  79. package/dist/contentful/field-value-from-json.js.map +1 -0
  80. package/dist/contentful/list-entry-format.d.ts +18 -0
  81. package/dist/contentful/list-entry-format.d.ts.map +1 -0
  82. package/dist/contentful/list-entry-format.js +45 -0
  83. package/dist/contentful/list-entry-format.js.map +1 -0
  84. package/dist/contentful/media.d.ts +24 -0
  85. package/dist/contentful/media.d.ts.map +1 -0
  86. package/dist/contentful/media.js +70 -0
  87. package/dist/contentful/media.js.map +1 -0
  88. package/dist/contentful/regex.d.ts +14 -0
  89. package/dist/contentful/regex.d.ts.map +1 -0
  90. package/dist/contentful/regex.js +38 -0
  91. package/dist/contentful/regex.js.map +1 -0
  92. package/dist/contentful/resolve-content-type.d.ts +9 -0
  93. package/dist/contentful/resolve-content-type.d.ts.map +1 -0
  94. package/dist/contentful/resolve-content-type.js +38 -0
  95. package/dist/contentful/resolve-content-type.js.map +1 -0
  96. package/dist/contentful/upload-fetch.d.ts +11 -0
  97. package/dist/contentful/upload-fetch.d.ts.map +1 -0
  98. package/dist/contentful/upload-fetch.js +26 -0
  99. package/dist/contentful/upload-fetch.js.map +1 -0
  100. package/dist/contentful/upload-limits.d.ts +7 -0
  101. package/dist/contentful/upload-limits.d.ts.map +1 -0
  102. package/dist/contentful/upload-limits.js +13 -0
  103. package/dist/contentful/upload-limits.js.map +1 -0
  104. package/dist/generated/version.d.ts +1 -1
  105. package/dist/generated/version.d.ts.map +1 -1
  106. package/dist/generated/version.js +1 -1
  107. package/dist/generated/version.js.map +1 -1
  108. package/dist/index/db.d.ts +10 -0
  109. package/dist/index/db.d.ts.map +1 -0
  110. package/dist/index/db.js +29 -0
  111. package/dist/index/db.js.map +1 -0
  112. package/dist/index/mode.d.ts +7 -0
  113. package/dist/index/mode.d.ts.map +1 -0
  114. package/dist/index/mode.js +9 -0
  115. package/dist/index/mode.js.map +1 -0
  116. package/dist/index/paths.d.ts +6 -0
  117. package/dist/index/paths.d.ts.map +1 -0
  118. package/dist/index/paths.js +23 -0
  119. package/dist/index/paths.js.map +1 -0
  120. package/dist/index/query.d.ts +75 -0
  121. package/dist/index/query.d.ts.map +1 -0
  122. package/dist/index/query.js +214 -0
  123. package/dist/index/query.js.map +1 -0
  124. package/dist/index/require.d.ts +16 -0
  125. package/dist/index/require.d.ts.map +1 -0
  126. package/dist/index/require.js +28 -0
  127. package/dist/index/require.js.map +1 -0
  128. package/dist/index/schema.d.ts +3 -0
  129. package/dist/index/schema.d.ts.map +1 -0
  130. package/dist/index/schema.js +34 -0
  131. package/dist/index/schema.js.map +1 -0
  132. package/dist/index/sync.d.ts +29 -0
  133. package/dist/index/sync.d.ts.map +1 -0
  134. package/dist/index/sync.js +116 -0
  135. package/dist/index/sync.js.map +1 -0
  136. package/dist/output/terminal-table.d.ts +15 -0
  137. package/dist/output/terminal-table.d.ts.map +1 -0
  138. package/dist/output/terminal-table.js +60 -0
  139. package/dist/output/terminal-table.js.map +1 -0
  140. package/docs/FUNCTIONAL_SPEC.md +11 -0
  141. package/docs/MEDIA_INDEX_PLAN.md +238 -0
  142. package/docs/help/create-from-json.md +54 -2
  143. package/docs/help/fields-article.md +5 -0
  144. package/docs/help/fields-component.md +11 -1
  145. package/docs/help/fields-page.md +2 -0
  146. package/docs/help/fields-taxonomy.md +154 -0
  147. package/docs/help/index-sync.md +73 -0
  148. package/docs/help/index.md +16 -0
  149. package/docs/help/taxonomy-from-json.md +115 -0
  150. package/package.json +5 -1
@@ -5,8 +5,11 @@
5
5
  ```bash
6
6
  cms-edit create from-json --file my-page.json
7
7
  cms-edit create from-json --file my-page.json --dry-run # validate without writing
8
+ cms-edit create from-json --file my-page.json --strict # fail on unknown JSON keys
8
9
  ```
9
10
 
11
+ Run `cms-edit index sync` before using any `*AssetFilename` shorthand (index-backed exact `file.fileName` lookup).
12
+
10
13
  ---
11
14
 
12
15
  ## Full JSON Schema
@@ -31,8 +34,16 @@ cms-edit create from-json --file my-page.json --dry-run # validate without wri
31
34
  // Page-only: link to an existing template entry by ID.
32
35
  "templateId": "4xKpzQ2abc123",
33
36
 
34
- // Page-only: link to an existing asset (featured image) by ID.
35
- "featuredImageId": "7yBnmR9xyz456",
37
+ // Page/article: featured image — asset ID (either key; warn if both differ).
38
+ "featuredImage": "7yBnmR9xyz456",
39
+ // "featuredImageId": "7yBnmR9xyz456", // alias
40
+
41
+ // Exact Contentful asset fileName (requires cms-edit index sync).
42
+ // "featuredImageAssetFilename": "hero.jpg",
43
+
44
+ // Article-only: download asset (ID or fileName shorthands).
45
+ // "download": "assetId",
46
+ // "downloadAssetFilename": "report.pdf",
36
47
 
37
48
  // Page-only: whether the page is indexed by search engines (default: not set = inherit).
38
49
  "indexed": true,
@@ -56,6 +67,47 @@ cms-edit create from-json --file my-page.json --dry-run # validate without wri
56
67
 
57
68
  ---
58
69
 
70
+ ## Explicit link shorthands (no guessing)
71
+
72
+ Use **named keys** only — the CLI does not infer whether a string is an asset ID, Media entry ID, or file name.
73
+
74
+ ### Page / article (top-level)
75
+
76
+ | JSON key | Sets field | Value |
77
+ |----------|------------|-------|
78
+ | `featuredImage` or `featuredImageId` | `featuredImage` | Asset ID |
79
+ | `featuredImageAssetFilename` | `featuredImage` | Exact asset `fileName` (index) |
80
+ | `download` or `downloadId` | `download` | Asset ID (article) |
81
+ | `downloadAssetFilename` | `download` | Exact asset `fileName` (article) |
82
+ | `icon` / `iconId` / `iconAssetFilename` | `icon` | Asset (article, when field exists) |
83
+ | `templateId` | `template` | Entry ID |
84
+ | `articleTypeId` | `articleType` | Entry ID (articles) |
85
+ | `topContentIds`, `visualsIds`, … | See `cms-edit help fields-taxonomy` | Entry ID arrays |
86
+
87
+ ### Component `fields`
88
+
89
+ | JSON key | Sets field | Value |
90
+ |----------|------------|-------|
91
+ | `visualId` | `visual` | Media / video entry ID |
92
+ | `visual` (string) | `visual` | Entry ID only (same as `visualId`) |
93
+ | `visualAssetId` | `visual` | Asset ID when the field is an Asset link |
94
+ | `visualAssetFilename` | `visual` | Exact asset `fileName` → reuse or create Media |
95
+ | `visualMediaName` | (with `visualAssetFilename`) | Optional Media entry name when creating |
96
+ | `visualMedia` | `visual` | `{ "assetId", "name", "position?", "width?" }` — always creates Media |
97
+ | `mobileVisualId`, `mobileVisualAssetFilename`, … | `mobileVisual` | Same pattern |
98
+
99
+ Unknown top-level or `fields` keys that are not on the content type: **warning** by default; use `--strict` or `--dry-run` to **fail** instead.
100
+
101
+ ### Comparison with `taxonomy-from-json`
102
+
103
+ | | `taxonomy-from-json` | `create from-json` |
104
+ |--|----------------------|-------------------|
105
+ | Unknown fields on dry-run | Error (strict) | Error (strict) |
106
+ | Unknown fields on create | Warn | Warn |
107
+ | `--strict` on create | — | Supported |
108
+
109
+ ---
110
+
59
111
  ## Component Schema
60
112
 
61
113
  Each item in `components` (and `items` for collections) follows this shape:
@@ -15,6 +15,9 @@ An `article` entry is a blog post or news item. It has a slug, date, article typ
15
15
  | `date` | Date | Yes | Publication date in `YYYY-MM-DD` format. Defaults to today in `create from-json` |
16
16
  | `articleType` | Link (Entry) | Yes | Link to an `articleType` entry (categorises the article) |
17
17
  | `content` | Array of Links | No | Content components (same as page content) |
18
+ | `featuredImage` | Link (Asset) | No | Featured / hero image asset |
19
+ | `download` | Link (Asset) | No | Downloadable file (e.g. PDF) |
20
+ | `icon` | Link (Asset) | No | Icon asset |
18
21
 
19
22
  ---
20
23
 
@@ -74,6 +77,8 @@ cms-edit add Generic component --after @c3
74
77
  "description": "A landmark study on hepatology cohort data.",
75
78
  "date": "2025-06-01",
76
79
  "articleTypeId": "<articleType entry ID>",
80
+ "featuredImage": "<asset-id>",
81
+ "downloadAssetFilename": "report.pdf",
77
82
  "components": [
78
83
  {
79
84
  "contentType": "component",
@@ -150,4 +150,14 @@ cms-edit asset info <assetId>
150
150
  }
151
151
  ```
152
152
 
153
- Visual fields (images) cannot be set directly in `create from-json` — link them afterwards with `cms-edit set @cN visual --asset <assetId>`.
153
+ Use explicit visual shorthands in `fields` (see `cms-edit help create-from-json`). Examples:
154
+
155
+ ```json
156
+ "fields": {
157
+ "visualId": "<existing-media-entry-id>",
158
+ "visualAssetFilename": "hero.jpg",
159
+ "visualMedia": { "assetId": "<asset-id>", "name": "Hero", "position": "Middle", "width": 40 }
160
+ }
161
+ ```
162
+
163
+ Do not put a bare filename on `visual` — use `visualAssetFilename`. Requires `cms-edit index sync` for `*AssetFilename` keys.
@@ -107,6 +107,8 @@ cms-edit add TextBlock component --after @c3
107
107
  "description": "Evidence generation for hepatology research.",
108
108
  "cmsLabel": "Hepatology Solutions Page",
109
109
  "templateId": "optionalTemplateId",
110
+ "featuredImage": "<asset-id>",
111
+ "featuredImageAssetFilename": "social-share.jpg",
110
112
  "indexed": true,
111
113
  "hidden": false,
112
114
  "components": [
@@ -0,0 +1,154 @@
1
+ # cms-edit — Taxonomy Field Reference
2
+
3
+ Taxonomy entries (`tagType`, `articleType`, `tag`) can be created as **drafts** with the CLI. Use `--json-file` for full field control, or `--slug` / `--name` for minimal creates.
4
+
5
+ ```bash
6
+ cms-edit create tag-type --slug conference-venue --name "Conference Venue"
7
+ cms-edit create article-type --slug resources/publications --name "Publications"
8
+ cms-edit create tag --slug poster-presentation --name "Poster Presentation" --tag-type presentation-type
9
+
10
+ # Idempotent import helpers
11
+ cms-edit ensure tag-type --slug conference-venue --name "Conference Venue"
12
+ cms-edit resolve --type tagType --slug presentation-type
13
+ ```
14
+
15
+ All creates are draft-only. See `cms-edit help taxonomy-from-json` for batch bootstrap.
16
+
17
+ ---
18
+
19
+ ## tagType fields
20
+
21
+ | Field | Type | Required | Description |
22
+ |---|---|---|---|
23
+ | `name` | Text | Yes | Display name |
24
+ | `slug` | Text | No | URL slug (normalized; leading `/` stripped) |
25
+ | `show` | Boolean | No | Whether tags of this type show visually on cards/detail |
26
+ | `template` | Link (Entry) | No | Template for tag detail pages |
27
+ | `topContent` | Array of Links | No | Content above main area on tag detail |
28
+ | `menu` | Link (Entry) | No | Navigation entry |
29
+ | `footer` | Link (Entry) | No | Footer navigation entry |
30
+ | `indexPageTemplate` | Link (Entry) | No | Template for tag-type index page |
31
+ | `indexPageTopContent` | Array of Links | No | Top content on tag-type index |
32
+
33
+ ---
34
+
35
+ ## articleType fields
36
+
37
+ | Field | Type | Required | Description |
38
+ |---|---|---|---|
39
+ | `name` | Text | Yes | Display name |
40
+ | `cmsLabel` | Text | Yes | Label in Contentful entry list (defaults to `--name`) |
41
+ | `slug` | Text | Yes | URL slug (supports multi-segment paths, e.g. `resources/publications`) |
42
+ | `indexPageTitle` | Text | Yes | Title on article index page (defaults to `--name`) |
43
+ | `indexPageDescription` | Text | Yes | Description on article index (defaults to `""`) |
44
+ | `featuredImage` | Link (Asset) | No | Featured image for index/social |
45
+ | `menu` | Link (Entry) | No | Navigation entry |
46
+ | `footer` | Link (Entry) | No | Footer navigation entry |
47
+ | `indexPageTemplate` | Link (Entry) | No | Template for article index |
48
+ | `indexPageTopContent` | Array of Links | No | Top content on article index |
49
+ | `indexPageStructuredData` | Array of Links | No | Schema entries for index page |
50
+ | `visuals` | Array of Links | No | Media/externalVideo entries |
51
+ | `articleTemplate` | Link (Entry) | No | Template for article detail pages |
52
+ | `articlePageTopContent` | Array of Links | No | Top content on article detail |
53
+ | `structuredData` | Array of Links | No | Schema entries for article pages |
54
+ | `backgroundColour` | Symbol | No | Valid values: `cms-edit colours` |
55
+ | `textColour` | Symbol | No | Valid values: `cms-edit colours` |
56
+ | `indexed` | Boolean | Yes | Search indexing (default: `true`) |
57
+ | `hidden` | Boolean | Yes | Sitemap visibility (default: `false`) |
58
+ | `indexPageHidden` | Boolean | No | Hide article index page |
59
+ | `articlePageHidden` | Boolean | No | Hide article detail pages |
60
+ | `flags` | Array of Symbols | No | e.g. `"Sticky nav"` |
61
+ | `searchTemplate` | Link (Entry) | No | Template for search results |
62
+ | `searchTopContent` | Array of Links | No | Top content on search results |
63
+ | `breadcrumbTitle` | Text | No | Override for breadcrumb label |
64
+
65
+ ---
66
+
67
+ ## tag fields
68
+
69
+ | Field | Type | Required | Description |
70
+ |---|---|---|---|
71
+ | `cmsLabel` | Text | Yes | Label in Contentful (defaults to `--name`) |
72
+ | `name` | Text | Yes | Display name |
73
+ | `tagType` | Link (Entry) | Yes | Parent tagType entry |
74
+ | `slug` | Text | Yes | URL slug within the tag type |
75
+ | `description` | Text | No | Short description |
76
+ | `featuredImage` | Link (Asset) | No | Featured image |
77
+ | `visuals` | Array of Links | No | Media/externalVideo entries |
78
+ | `menu` | Link (Entry) | No | Navigation entry |
79
+ | `footer` | Link (Entry) | No | Footer navigation entry |
80
+ | `template` | Link (Entry) | No | Template for tag detail |
81
+ | `topContent` | Array of Links | No | Top content on tag detail |
82
+ | `structuredData` | Array of Links | No | Schema entries |
83
+ | `backgroundColour` | Symbol | No | Valid values: `cms-edit colours` |
84
+ | `textColour` | Symbol | No | Valid values: `cms-edit colours` |
85
+ | `indexed` | Boolean | Yes | Search indexing (default: `true`) |
86
+ | `hidden` | Boolean | Yes | Sitemap visibility (default: `false`) |
87
+ | `show` | Boolean | No | Visual display on cards/detail |
88
+ | `breadcrumbTitle` | Text | No | Override for breadcrumb label |
89
+
90
+ Tags require `--tag-type <slug>` or `--tag-type-id <id>` (or `tagTypeSlug` / `tagTypeId` in JSON).
91
+
92
+ ---
93
+
94
+ ## JSON file shape
95
+
96
+ Use `--json-file` with any taxonomy create command. CLI flags override JSON values.
97
+
98
+ ```jsonc
99
+ {
100
+ "fields": {
101
+ "name": "Poster Presentation",
102
+ "slug": "poster-presentation",
103
+ "description": "Poster session at ASCO 2025",
104
+ "show": true,
105
+ "indexed": true,
106
+ "hidden": false,
107
+ "backgroundColour": "White",
108
+ "textColour": "Navy"
109
+ },
110
+ "tagTypeSlug": "presentation-type",
111
+ "featuredImageId": "abc123",
112
+ "templateId": "tmpl456",
113
+ "topContentIds": ["comp1", "comp2"]
114
+ }
115
+ ```
116
+
117
+ ### Link shorthands
118
+
119
+ These top-level keys resolve to Contentful Entry/Asset links (same conventions as `create from-json`):
120
+
121
+ | Shorthand | Resolves to field |
122
+ |---|---|
123
+ | `tagTypeId`, `tagTypeSlug` | `tagType` (tags only) |
124
+ | `templateId` | `template` |
125
+ | `indexPageTemplateId` | `indexPageTemplate` |
126
+ | `articleTemplateId` | `articleTemplate` |
127
+ | `searchTemplateId` | `searchTemplate` |
128
+ | `menuId` | `menu` |
129
+ | `footerId` | `footer` |
130
+ | `featuredImageId` | `featuredImage` |
131
+ | `topContentIds` | `topContent` |
132
+ | `indexPageTopContentIds` | `indexPageTopContent` |
133
+ | `articlePageTopContentIds` | `articlePageTopContent` |
134
+ | `searchTopContentIds` | `searchTopContent` |
135
+ | `structuredDataIds` | `structuredData` |
136
+ | `indexPageStructuredDataIds` | `indexPageStructuredData` |
137
+ | `visualsIds` | `visuals` |
138
+
139
+ ---
140
+
141
+ ## Common options
142
+
143
+ | Option | Description |
144
+ |---|---|
145
+ | `--slug <slug>` | Required URL slug |
146
+ | `--name <name>` | Required display name |
147
+ | `--cms-label <label>` | CMS label (articleType/tag; defaults to name) |
148
+ | `--json-file <path>` | Full field spec (see above) |
149
+ | `--if-not-exists` | Return existing entry ID when slug matches (exit 0) |
150
+ | `--dry-run` | Validate field build and link resolution without writing |
151
+
152
+ **Idempotency:** `--if-not-exists` and `ensure` check Contentful then create. They work for **sequential** import scripts. Do not run two creates for the same slug in parallel — both may succeed. Re-run with `--if-not-exists` to converge.
153
+
154
+ Use `CMS_EDIT_JSON=1` or `--json` for machine-readable output: `{ ok, id, slug, contentType, status: "created"|"existing"|"dry-run" }` (`id` is empty on dry-run).
@@ -0,0 +1,73 @@
1
+ # Media index sync
2
+
3
+ cms-edit keeps a **local SQLite index** per space/environment for fast asset and media discovery. The default index is built from the **Content Preview API** (draft content) — matching cms-edit’s draft-only upload workflow.
4
+
5
+ ## When you need it
6
+
7
+ These commands **require** a built index:
8
+
9
+ - `cms-edit asset search` (title, `--filename`, `--filename-match`)
10
+ - `cms-edit asset audit`
11
+ - `cms-edit list --type media --asset-id <id>`
12
+ - `cms-edit list --type media --asset-filename …` / `--asset-filename-match …`
13
+ - `cms-edit asset upload --if-exists-by-filename` (lookup uses the index)
14
+
15
+ General `cms-edit list --type media` without asset filters still uses the management API (entry pagination).
16
+
17
+ ## Commands
18
+
19
+ ```bash
20
+ # Full rebuild (draft/preview content — default)
21
+ cms-edit index sync
22
+
23
+ # Check freshness and row counts
24
+ cms-edit index status
25
+
26
+ # Browse index contents in the terminal
27
+ cms-edit index dump
28
+ cms-edit index dump --all
29
+ cms-edit index dump --type image/ -n 20
30
+ cms-edit index dump --assets-only --skip 50
31
+
32
+ # Published content only (separate database file suffix -published)
33
+ cms-edit index sync --published
34
+ cms-edit index status --published
35
+ ```
36
+
37
+ Index path: `~/.contentful-cms/index/<spaceId>/<environment>/media.db` (add `-published` suffix for published-only mode).
38
+
39
+ ## Preview / delivery API token
40
+
41
+ The management token cannot call the CDN. For default `index sync`:
42
+
43
+ | Config field | Purpose |
44
+ |--------------|---------|
45
+ | `previewAccessToken` | Explicit Preview API token (`${CONTENTFUL_PREVIEW_ACCESS_TOKEN}`) |
46
+ | *(auto)* | Linked preview key from a space delivery key via CMA |
47
+
48
+ For `index sync --published`:
49
+
50
+ | Config field | Purpose |
51
+ |--------------|---------|
52
+ | `deliveryAccessToken` | Explicit CDA token (`${CONTENTFUL_ACCESS_TOKEN}`) |
53
+ | `deliveryApiKeyName` | Pick a space delivery key by name via CMA |
54
+ | *(auto)* | First delivery key matching the configured environment |
55
+ | `autoCreateDeliveryApiKey` | Create `cms-edit-index` key if none match (needs PAT permissions; warns when used) |
56
+
57
+ If CMA cannot read API keys, set `previewAccessToken` or `deliveryAccessToken` manually.
58
+
59
+ ## Freshness
60
+
61
+ - `index status` warns when the index is older than 24 hours.
62
+ - Search/list commands also warn but still run.
63
+ - After `asset upload`, a single asset row is upserted when the index already exists (optional; full accuracy needs `index sync`).
64
+
65
+ ## Typical workflow before imports
66
+
67
+ ```bash
68
+ cms-edit index sync
69
+ cms-edit asset search --filename-match 'istock.*'
70
+ cms-edit list --type media --asset-filename hero.jpg
71
+ ```
72
+
73
+ See [MEDIA_INDEX_PLAN.md](../MEDIA_INDEX_PLAN.md) for architecture details.
@@ -18,6 +18,7 @@ Available topics for `cms-edit help <topic>`:
18
18
  |---|---|
19
19
  | `workflow` | Standard editing workflow — open, snapshot, edit, save |
20
20
  | `create-from-json` | Create a new page or article from a JSON file (single-shot) |
21
+ | `taxonomy-from-json` | Batch-create tagType, articleType, and tag entries from JSON |
21
22
  | `run` | Execute a batch of operations from a JSON file |
22
23
  | `batch` | Edit multiple entries by Contentful entry ID, then save once |
23
24
  | `fields` | Overview of all content types |
@@ -25,6 +26,8 @@ Available topics for `cms-edit help <topic>`:
25
26
  | `fields-article` | All fields on an `article` entry |
26
27
  | `fields-component` | All fields on a `component` entry |
27
28
  | `fields-collection` | All fields on a `collection` entry |
29
+ | `fields-taxonomy` | All fields on `tagType`, `articleType`, and `tag` entries |
30
+ | `index-sync` | Build and use the local media index (CDA sync) |
28
31
 
29
32
  ---
30
33
 
@@ -48,6 +51,11 @@ cms-edit create from-json --file my-page.json
48
51
  # Validate a JSON file without writing anything
49
52
  cms-edit create from-json --file my-page.json --dry-run
50
53
 
54
+ # Bootstrap taxonomy for import scripts
55
+ cms-edit create taxonomy-from-json --file taxonomy.json --if-not-exists
56
+
57
+ Asset/media search: run `cms-edit index sync` first — see [index-sync.md](./index-sync.md).
58
+
51
59
  # Run a batch of edits
52
60
  cms-edit run --file patch.json
53
61
  ```
@@ -70,6 +78,8 @@ cms-edit run --file patch.json
70
78
  | `list --type <ct>` | List all entries of a content type |
71
79
  | `search <query>` | Full-text search across entries |
72
80
  | `resolve <id>` | Resolve a Contentful entry or asset ID |
81
+ | `resolve --type <type> --slug <slug>` | Resolve an entry by content type and slug (no session) |
82
+ | `ensure tag-type\|tag\|article-type …` | Idempotent taxonomy create (returns existing entry if slug matches) |
73
83
  | `types` | List valid type-discriminator values |
74
84
  | `colours` | List valid backgroundColour / textColour values |
75
85
  | `schema` | Display the content model schema |
@@ -99,6 +109,10 @@ cms-edit run --file patch.json
99
109
  | Command | Description |
100
110
  |---|---|
101
111
  | `create from-json` | Create a page/article from a JSON file |
112
+ | `create taxonomy-from-json` | Batch-create tagType, articleType, and tag entries |
113
+ | `create tag-type` | Create a tagType entry (draft) |
114
+ | `create article-type` | Create an articleType entry (draft) |
115
+ | `create tag` | Create a tag entry (draft) |
102
116
  | `create page` | Create a blank page interactively |
103
117
  | `create article` | Create a blank article interactively |
104
118
 
@@ -135,6 +149,8 @@ cms-edit run --file patch.json
135
149
 
136
150
  - `cms-edit help workflow` — step-by-step editing guide
137
151
  - `cms-edit help create-from-json` — single-shot page creation
152
+ - `cms-edit help taxonomy-from-json` — batch taxonomy bootstrap
153
+ - `cms-edit help fields-taxonomy` — tagType, articleType, and tag field reference
138
154
  - `cms-edit help run` — batch operations and variable binding
139
155
  - `cms-edit help fields-page` — complete page field reference
140
156
  - `cms-edit --docs` — full README path (for reading in an editor)
@@ -0,0 +1,115 @@
1
+ # cms-edit create taxonomy-from-json — Batch Taxonomy Bootstrap
2
+
3
+ `create taxonomy-from-json` creates multiple `tagType`, `articleType`, and `tag` entries from a single JSON file. It is the recommended way to bootstrap taxonomy for import scripts and publication workflows.
4
+
5
+ ```bash
6
+ cms-edit create taxonomy-from-json --file taxonomy.json --dry-run
7
+ cms-edit create taxonomy-from-json --file taxonomy.json --if-not-exists
8
+ ```
9
+
10
+ Processing order: **tagTypes → articleTypes → tags** (tags depend on tagTypes).
11
+
12
+ All entries are created as **drafts**. Nothing is published automatically.
13
+
14
+ **Not transactional:** If the command fails partway through (e.g. a tag fails validation), entries created earlier in the same run remain in the space. Re-run with `--if-not-exists` to continue idempotently, or fix the JSON and run again.
15
+
16
+ **Not parallel-safe:** `--if-not-exists` is check-then-create. Running two imports concurrently for the same slug can create duplicates. Process items sequentially per slug, or re-run to converge.
17
+
18
+ ---
19
+
20
+ ## JSON schema
21
+
22
+ ```jsonc
23
+ {
24
+ "tagTypes": [
25
+ {
26
+ "slug": "presentation-type",
27
+ "name": "Presentation Type",
28
+ "fields": { "show": true }
29
+ }
30
+ ],
31
+ "articleTypes": [
32
+ {
33
+ "slug": "resources/publications",
34
+ "name": "Publications",
35
+ "cmsLabel": "Publications",
36
+ "fields": { "indexed": true, "hidden": false }
37
+ }
38
+ ],
39
+ "tags": [
40
+ {
41
+ "slug": "asco-2025",
42
+ "name": "ASCO 2025",
43
+ "tagTypeSlug": "conference-venue",
44
+ "fields": { "description": "ASCO Annual Meeting 2025" }
45
+ }
46
+ ]
47
+ }
48
+ ```
49
+
50
+ Each item supports the same field shorthands as single-entry creates. See `cms-edit help fields-taxonomy` for the full field reference and link shorthand table.
51
+
52
+ | Key | Required on item | Description |
53
+ |---|---|---|
54
+ | `slug` | Yes | URL slug |
55
+ | `name` | Yes | Display name |
56
+ | `cmsLabel` | No | CMS label (articleType/tag) |
57
+ | `fields` | No | Raw Contentful field values |
58
+ | `tagTypeSlug` / `tagTypeId` | Tags only | Parent tagType link |
59
+
60
+ Top-level link shorthands (`templateId`, `featuredImageId`, `topContentIds`, etc.) can also appear on each item.
61
+
62
+ ---
63
+
64
+ ## Options
65
+
66
+ | Option | Description |
67
+ |---|---|
68
+ | `--file <path>` | Path to taxonomy JSON (required) |
69
+ | `--if-not-exists` | Skip creation when slug already exists; return existing ID |
70
+ | `--dry-run` | Validate all entries and link targets without writing |
71
+
72
+ ---
73
+
74
+ ## Output
75
+
76
+ Human mode prints a summary per entry. JSON mode (`CMS_EDIT_JSON=1` or `--json`):
77
+
78
+ ```json
79
+ {
80
+ "ok": true,
81
+ "tagTypes": [{ "id": "...", "slug": "...", "contentType": "tagType", "status": "created" }],
82
+ "articleTypes": [{ "id": "...", "slug": "...", "contentType": "articleType", "status": "existing" }],
83
+ "tags": [{ "id": "...", "slug": "...", "contentType": "tag", "status": "created" }]
84
+ }
85
+ ```
86
+
87
+ ---
88
+
89
+ ## Idempotent import pattern
90
+
91
+ Combine batch bootstrap with `ensure` and `resolve` for script-friendly imports:
92
+
93
+ ```bash
94
+ # One-time taxonomy bootstrap
95
+ cms-edit create taxonomy-from-json --file taxonomy.json --if-not-exists
96
+
97
+ # Look up IDs in scripts
98
+ cms-edit resolve --type tagType --slug presentation-type --json
99
+ cms-edit resolve --type tag --slug asco-2025 --json
100
+
101
+ # Add a single entry idempotently
102
+ cms-edit ensure tag --slug new-tag --name "New Tag" --tag-type presentation-type
103
+ ```
104
+
105
+ ---
106
+
107
+ ## Related commands
108
+
109
+ | Command | Purpose |
110
+ |---|---|
111
+ | `cms-edit create tag-type` | Create one tagType |
112
+ | `cms-edit create article-type` | Create one articleType |
113
+ | `cms-edit create tag` | Create one tag |
114
+ | `cms-edit ensure …` | Alias for create with `--if-not-exists` |
115
+ | `cms-edit help fields-taxonomy` | Full field reference |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@se-studio/contentful-cms",
3
- "version": "1.0.91",
3
+ "version": "1.1.0",
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",
@@ -8,6 +8,9 @@
8
8
  "directory": "packages/contentful-cms"
9
9
  },
10
10
  "license": "MIT",
11
+ "engines": {
12
+ "node": ">=22.5.0"
13
+ },
11
14
  "type": "module",
12
15
  "main": "./dist/index.js",
13
16
  "types": "./dist/index.d.ts",
@@ -39,6 +42,7 @@
39
42
  "@contentful/rich-text-types": "^17.2.7",
40
43
  "@modelcontextprotocol/sdk": "^1.29.0",
41
44
  "commander": "^15.0.0",
45
+ "contentful": "^11.12.3",
42
46
  "contentful-management": "^12.5.0",
43
47
  "dotenv": "^17.4.2",
44
48
  "picocolors": "^1.1.1",