@se-studio/contentful-cms 1.0.87 → 1.0.89
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.
- package/CHANGELOG.md +19 -0
- package/README.md +28 -0
- package/dist/cli/program.d.ts.map +1 -1
- package/dist/cli/program.js +2 -0
- package/dist/cli/program.js.map +1 -1
- package/dist/commands/batch-assignments.d.ts +16 -0
- package/dist/commands/batch-assignments.d.ts.map +1 -0
- package/dist/commands/batch-assignments.js +24 -0
- package/dist/commands/batch-assignments.js.map +1 -0
- package/dist/commands/batch.d.ts +5 -0
- package/dist/commands/batch.d.ts.map +1 -0
- package/dist/commands/batch.js +250 -0
- package/dist/commands/batch.js.map +1 -0
- package/dist/commands/create-from-json.d.ts.map +1 -1
- package/dist/commands/create-from-json.js +14 -40
- package/dist/commands/create-from-json.js.map +1 -1
- package/dist/commands/diff.d.ts.map +1 -1
- package/dist/commands/diff.js +3 -241
- package/dist/commands/diff.js.map +1 -1
- package/dist/commands/help.js +1 -1
- package/dist/commands/help.js.map +1 -1
- package/dist/commands/links.d.ts.map +1 -1
- package/dist/commands/links.js +146 -70
- package/dist/commands/links.js.map +1 -1
- package/dist/commands/run.d.ts.map +1 -1
- package/dist/commands/run.js +14 -28
- package/dist/commands/run.js.map +1 -1
- package/dist/commands/session-diff.d.ts +14 -0
- package/dist/commands/session-diff.d.ts.map +1 -0
- package/dist/commands/session-diff.js +238 -0
- package/dist/commands/session-diff.js.map +1 -0
- package/dist/commands/set.d.ts.map +1 -1
- package/dist/commands/set.js +10 -14
- package/dist/commands/set.js.map +1 -1
- package/dist/contentful/content-type-disk-cache.d.ts +7 -0
- package/dist/contentful/content-type-disk-cache.d.ts.map +1 -0
- package/dist/contentful/content-type-disk-cache.js +39 -0
- package/dist/contentful/content-type-disk-cache.js.map +1 -0
- package/dist/contentful/link-fields.d.ts +22 -0
- package/dist/contentful/link-fields.d.ts.map +1 -0
- package/dist/contentful/link-fields.js +58 -0
- package/dist/contentful/link-fields.js.map +1 -0
- package/dist/contentful/scalar-value.d.ts +19 -0
- package/dist/contentful/scalar-value.d.ts.map +1 -0
- package/dist/contentful/scalar-value.js +95 -0
- package/dist/contentful/scalar-value.js.map +1 -0
- package/dist/contentful/set-field-schema.d.ts.map +1 -1
- package/dist/contentful/set-field-schema.js +25 -2
- package/dist/contentful/set-field-schema.js.map +1 -1
- package/dist/generated/hosted-guide.d.ts +2 -0
- package/dist/generated/hosted-guide.d.ts.map +1 -0
- package/dist/generated/hosted-guide.js +3 -0
- package/dist/generated/hosted-guide.js.map +1 -0
- package/dist/generated/version.d.ts +3 -0
- package/dist/generated/version.d.ts.map +1 -0
- package/dist/generated/version.js +4 -0
- package/dist/generated/version.js.map +1 -0
- package/dist/mcp/guide.d.ts.map +1 -1
- package/dist/mcp/guide.js +2 -8
- package/dist/mcp/guide.js.map +1 -1
- package/dist/mcp/tools/cms-edit.d.ts +1 -1
- package/dist/mcp/tools/cms-edit.d.ts.map +1 -1
- package/dist/mcp/tools/cms-edit.js +4 -0
- package/dist/mcp/tools/cms-edit.js.map +1 -1
- package/dist/session/state.d.ts +10 -1
- package/dist/session/state.d.ts.map +1 -1
- package/dist/session/state.js +2 -0
- package/dist/session/state.js.map +1 -1
- package/dist/version.d.ts +2 -2
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +2 -11
- package/dist/version.js.map +1 -1
- package/docs/FUNCTIONAL_SPEC.md +14 -1
- package/docs/help/batch.md +78 -0
- package/docs/help/fields-component.md +3 -0
- package/docs/help/index.md +1 -0
- package/docs/help/run.md +2 -2
- package/package.json +7 -6
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/** Parse CLI token literals only (no numeric guessing). */
|
|
2
|
+
export function parseScalarToken(raw) {
|
|
3
|
+
if (raw === 'true')
|
|
4
|
+
return true;
|
|
5
|
+
if (raw === 'false')
|
|
6
|
+
return false;
|
|
7
|
+
if (raw === 'null')
|
|
8
|
+
return null;
|
|
9
|
+
return raw;
|
|
10
|
+
}
|
|
11
|
+
/** Extract enum values from Symbol/Text field validations (same rules as schema command). */
|
|
12
|
+
export function getFieldEnumValues(fieldDef) {
|
|
13
|
+
if (!fieldDef)
|
|
14
|
+
return undefined;
|
|
15
|
+
const validations = fieldDef.validations ?? [];
|
|
16
|
+
for (const v of validations) {
|
|
17
|
+
const inVals = v.in;
|
|
18
|
+
if (Array.isArray(inVals) && inVals.length > 0) {
|
|
19
|
+
return inVals;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Returns an error message if value is not in the field enum; null if valid or no enum.
|
|
26
|
+
*/
|
|
27
|
+
export function validateScalarEnum(value, fieldDef, fieldId) {
|
|
28
|
+
const allowed = getFieldEnumValues(fieldDef);
|
|
29
|
+
if (!allowed || allowed.length === 0)
|
|
30
|
+
return null;
|
|
31
|
+
const str = typeof value === 'string' ? value : String(value);
|
|
32
|
+
if (!allowed.includes(str)) {
|
|
33
|
+
return `Invalid value for '${fieldId}'. Allowed: ${allowed.join(', ')}`;
|
|
34
|
+
}
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Coerce a CLI scalar token to the CMA value type for the field.
|
|
39
|
+
* Symbol/Text always stay strings (no numeric guessing).
|
|
40
|
+
*/
|
|
41
|
+
export function coerceScalarForField(raw, fieldDef) {
|
|
42
|
+
const token = parseScalarToken(raw);
|
|
43
|
+
const type = fieldDef?.type;
|
|
44
|
+
if (type === 'Integer' || type === 'Number') {
|
|
45
|
+
if (token === null)
|
|
46
|
+
return null;
|
|
47
|
+
if (typeof token === 'boolean')
|
|
48
|
+
return token ? 1 : 0;
|
|
49
|
+
const num = Number(raw.trim());
|
|
50
|
+
if (Number.isNaN(num)) {
|
|
51
|
+
throw new Error(`Expected a number for field type ${type}, got "${raw}".`);
|
|
52
|
+
}
|
|
53
|
+
return num;
|
|
54
|
+
}
|
|
55
|
+
if (type === 'Boolean') {
|
|
56
|
+
if (typeof token === 'boolean')
|
|
57
|
+
return token;
|
|
58
|
+
if (token === null)
|
|
59
|
+
return false;
|
|
60
|
+
const lower = raw.trim().toLowerCase();
|
|
61
|
+
if (lower === 'true' || lower === '1')
|
|
62
|
+
return true;
|
|
63
|
+
if (lower === 'false' || lower === '0')
|
|
64
|
+
return false;
|
|
65
|
+
throw new Error(`Expected true/false for Boolean field, got "${raw}".`);
|
|
66
|
+
}
|
|
67
|
+
if (type === 'Symbol' || type === 'Text') {
|
|
68
|
+
if (token === null)
|
|
69
|
+
return '';
|
|
70
|
+
if (typeof token === 'boolean')
|
|
71
|
+
return token ? 'true' : 'false';
|
|
72
|
+
return raw;
|
|
73
|
+
}
|
|
74
|
+
if (token === null)
|
|
75
|
+
return null;
|
|
76
|
+
if (typeof token === 'boolean')
|
|
77
|
+
return token;
|
|
78
|
+
const num = Number(raw.trim());
|
|
79
|
+
if (!Number.isNaN(num) && raw.trim() !== '' && /^-?\d+(\.\d+)?$/.test(raw.trim())) {
|
|
80
|
+
return num;
|
|
81
|
+
}
|
|
82
|
+
return raw;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Coerce token and validate enum; throws with actionable message on failure.
|
|
86
|
+
*/
|
|
87
|
+
export function resolveScalarValueForField(raw, fieldDef, fieldId) {
|
|
88
|
+
const value = coerceScalarForField(raw, fieldDef);
|
|
89
|
+
const enumErr = validateScalarEnum(value, fieldDef, fieldId);
|
|
90
|
+
if (enumErr) {
|
|
91
|
+
throw new Error(enumErr);
|
|
92
|
+
}
|
|
93
|
+
return value;
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=scalar-value.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scalar-value.js","sourceRoot":"","sources":["../../src/contentful/scalar-value.ts"],"names":[],"mappings":"AAEA,2DAA2D;AAC3D,MAAM,UAAU,gBAAgB,CAAC,GAAW;IAC1C,IAAI,GAAG,KAAK,MAAM;QA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AAC,CAAC,CAAC,OAAO,CAAC;QAChE,OAAO,GAAG,CAAC;IACb,CAAC;IAED,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAChC,IAAI,OAAO,KAAK,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IAC7C,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;IAC/B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;QAClF,OAAO,GAAG,CAAC;IACb,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,0BAA0B,CACxC,GAAW,EACX,QAAmC,EACnC,OAAe;IAEf,MAAM,KAAK,GAAG,oBAAoB,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAClD,MAAM,OAAO,GAAG,kBAAkB,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC7D,IAAI,OAAO,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set-field-schema.d.ts","sourceRoot":"","sources":["../../src/contentful/set-field-schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"set-field-schema.d.ts","sourceRoot":"","sources":["../../src/contentful/set-field-schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AA+BnD,wDAAwD;AACxD,wBAAgB,6BAA6B,IAAI,IAAI,CAEpD;AAED,wBAAsB,oBAAoB,CACxC,GAAG,EAAE,eAAe,EACpB,OAAO,EAAE,YAAY,EACrB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,gBAAgB,CAAC,CAoB3B;AAED,wBAAgB,iBAAiB,CAC/B,EAAE,EAAE,gBAAgB,EACpB,OAAO,EAAE,MAAM,GACd,aAAa,GAAG,SAAS,CAE3B;AAED,MAAM,MAAM,iBAAiB,GACzB;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,GACrB;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,GACrB;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,GAC1B;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,CAAC;AAE/B;;;GAGG;AACH,wBAAgB,kCAAkC,CAChD,QAAQ,EAAE,aAAa,GAAG,SAAS,EACnC,OAAO,EAAE,MAAM,GACd,MAAM,GAAG,IAAI,CAoBf;AAED;;;GAGG;AACH,wBAAgB,mCAAmC,CACjD,QAAQ,EAAE,aAAa,GAAG,SAAS,GAClC,iBAAiB,GAAG,IAAI,CA2B1B"}
|
|
@@ -1,7 +1,20 @@
|
|
|
1
|
+
import { readContentTypeFromDisk, writeContentTypeToDisk } from './content-type-disk-cache.js';
|
|
1
2
|
const contentTypeCache = new Map();
|
|
2
3
|
function contentTypeCacheKey(session, ctId) {
|
|
3
4
|
return `${session.spaceId}\0${session.environment}\0${ctId}`;
|
|
4
5
|
}
|
|
6
|
+
function storeContentTypeInSession(session, ctId, ct) {
|
|
7
|
+
if (!session.contentTypes) {
|
|
8
|
+
session.contentTypes = {};
|
|
9
|
+
}
|
|
10
|
+
session.contentTypes[ctId] = ct;
|
|
11
|
+
}
|
|
12
|
+
function persistContentTypeEverywhere(session, ctId, ct) {
|
|
13
|
+
const key = contentTypeCacheKey(session, ctId);
|
|
14
|
+
contentTypeCache.set(key, ct);
|
|
15
|
+
storeContentTypeInSession(session, ctId, ct);
|
|
16
|
+
writeContentTypeToDisk(session.spaceId, session.environment, ctId, ct);
|
|
17
|
+
}
|
|
5
18
|
/** Clears in-process content-type cache (for tests). */
|
|
6
19
|
export function clearContentTypeCacheForTests() {
|
|
7
20
|
contentTypeCache.clear();
|
|
@@ -9,10 +22,20 @@ export function clearContentTypeCacheForTests() {
|
|
|
9
22
|
export async function getContentTypeCached(env, session, ctId) {
|
|
10
23
|
const key = contentTypeCacheKey(session, ctId);
|
|
11
24
|
let ct = contentTypeCache.get(key);
|
|
12
|
-
if (
|
|
13
|
-
ct
|
|
25
|
+
if (ct)
|
|
26
|
+
return ct;
|
|
27
|
+
ct = session.contentTypes?.[ctId];
|
|
28
|
+
if (ct) {
|
|
14
29
|
contentTypeCache.set(key, ct);
|
|
30
|
+
return ct;
|
|
31
|
+
}
|
|
32
|
+
ct = readContentTypeFromDisk(session.spaceId, session.environment, ctId) ?? undefined;
|
|
33
|
+
if (ct) {
|
|
34
|
+
persistContentTypeEverywhere(session, ctId, ct);
|
|
35
|
+
return ct;
|
|
15
36
|
}
|
|
37
|
+
ct = await env.getContentType(ctId);
|
|
38
|
+
persistContentTypeEverywhere(session, ctId, ct);
|
|
16
39
|
return ct;
|
|
17
40
|
}
|
|
18
41
|
export function getActiveFieldDef(ct, fieldId) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set-field-schema.js","sourceRoot":"","sources":["../../src/contentful/set-field-schema.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"set-field-schema.js","sourceRoot":"","sources":["../../src/contentful/set-field-schema.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,uBAAuB,EAAE,s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,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const HOSTED_GUIDE_TEMPLATE = "# cms-edit MCP guide\n\nUse this guide when editing Contentful draft content through Claude Desktop (hosted `.mcpb` extension) or local stdio MCP.\n\n{{SITE_INTRO}}\n\n## Safety rules\n\ncms-edit **cannot and will not**:\n\n- Publish or unpublish entries\n- Archive or delete published entries\n- Upload new assets (use Contentful UI for assets)\n\nAll `save` operations create **drafts only**. A human must review and publish in Contentful.\n\n## MCP tools\n\n| Tool | Purpose |\n|------|---------|\n| `cms_edit` | Run any cms-edit command via an `args` array |\n| `cms_edit_version` | Check the installed cms-edit version (no session required) |\n| `cms_edit_help` | Read this guide by topic (`overview`, `workflow`, `commands`, `troubleshooting`, `hosted`) |\n\n## MCP prompts\n\n| Prompt | Purpose |\n|--------|---------|\n| `cms_edit_verify` | Check version and connectivity |\n| `cms_edit_explore` | List site content and open a page |\n| `cms_edit_edit_page` | Edit a page through diff \u2192 save |\n\nRead the full guide anytime via the `cms-edit://guide` resource or `cms_edit_help`.\n\n## Core workflow\n\nStandard editing flow: **open \u2192 snapshot \u2192 read \u2192 set/rtf \u2192 diff \u2192 save**\n\nEach step is a separate `cms_edit` call. Sessions persist in Redis between calls (hosted) or on disk (local). MCP auto-uses session `_mcp`.\n\n### 1. Open a page\n\n```\n[\"open\", \"/\"]\n[\"open\", \"/pricing\"]\n[\"open\", \"<entry-id>\", \"--id\"]\n```\n\nHomepage slug is `/` (or `index` depending on the site).\n\n### 2. Snapshot \u2014 see the content tree\n\n```\n[\"snapshot\"]\n```\n\nOutput shows `@c0`, `@c1`, \u2026 refs for each component. Use these refs in `read`, `set`, and `rtf`.\n\n### 3. Read fields\n\n```\n[\"read\", \"@c1\"]\n[\"read\", \"@c1\", \"heading\"]\n```\n\n### 4. Edit fields\n\n```\n[\"set\", \"@c1\", \"heading\", \"New heading text\"]\n[\"rtf\", \"@c1\", \"body\", \"--content\", \"# Title\\n\\nParagraph text.\"]\n```\n\nFor rich text, prefer `--content` with inline markdown. Use `--base64` when special characters cause issues.\n\n### 5. Review and save\n\n```\n[\"diff\"]\n[\"save\"]\n```\n\nAlways run `diff` before `save`. To abandon changes: `[\"discard\"]`.\n\n## Common sequences\n\n### List all pages\n\n```\n[\"sitemap\"]\n```\n\n### Explore the homepage\n\n```\n[\"open\", \"/\"]\n[\"snapshot\"]\n[\"read\", \"@c1\"]\n```\n\n### Edit copy on a page\n\n```\n[\"open\", \"{{EXAMPLE_SLUG}}\"]\n[\"snapshot\"]\n[\"read\", \"@c1\", \"heading\"]\n[\"set\", \"@c1\", \"heading\", \"Updated heading\"]\n[\"diff\"]\n[\"save\"]\n```\n\n## Field discovery\n\n```\n[\"schema\", \"component\"]\n[\"list\", \"--type\", \"page\"]\n[\"search\", \"pricing\"]\n```\n\n## Hosted extension rules\n\n{{HOSTED_RULES}}\n\n## Session tips\n\n- After `open`, subsequent MCP commands share session `_mcp` automatically (stored in Redis on hosted).\n- Use `--session <name>` only when juggling multiple pages \u2014 pass it **before** the subcommand on every call: `[\"--session\", \"my-work\", \"open\", \"/\"]`.\n- Snapshot JSON includes `sessionName` and `sessionKey` for debugging.\n- If you see \"No active session\", check `/api/health` (Redis must be ok), then run `open` again. Set `LOG_CMS_SESSION=1` on Vercel and search runtime logs for `[cms-edit:session]` (`redis save ok` / `redis load hit` / `requireSession miss`).\n\n### peek vs open vs read\n\n| Goal | MCP args |\n|------|----------|\n| Edit workflow (session) | `[\"open\", \"/\"]` then `[\"read\", \"@c0\"]` |\n| Preview tree + fields, no session | `[\"peek\", \"/pricing\"]` or `[\"peek\", \"<entry-id>\", \"--id\"]` (JSON includes `rootFields`) |\n| Read fields by entry ID, no session | `[\"read\", \"<entry-id>\", \"--id\"]` or `[\"read\", \"<entry-id>\", \"--id\", \"heading\"]` |\n| Debug session persistence | `[\"diagnose\"]` \u2014 reports store, userId, active session key |\n\n- **`peek` is one-shot** \u2014 prints tree and **root field values** (`rootFields` in JSON). No session is created; do not chain `read @ref` afterward.\n- **Entry IDs need `--id`** for both `open` and `peek` (bare IDs are treated as slugs).\n- **`read @root`** only works after `open` (uses the active session). The hint in peek output is for terminal users who already ran `open`.\n- **Do not invent flags** \u2014 there is no `--read`, `--then`, or chained peek+read syntax. One command per `cms_edit` call.\n\n## Troubleshooting\n\n| Problem | What to do |\n|---------|------------|\n| **401 / invalid token** | Regenerate CMA token in Contentful; update token in Claude Desktop \u2192 Settings \u2192 Extensions |\n| **No cms_edit tool** | Quit Claude fully and reopen; confirm extension is enabled |\n| **No active session** | Do not pass `--space` on hosted. Check `/api/health` \u2014 `redis` must be ok. MCP uses `_mcp` session automatically. Manual session: `[\"--session\", \"name\", \"open\", \"/\"]`. Fallback: `[\"read\", \"<entry-id>\", \"--id\"]` |\n| **Wrong space** | Token must belong to this deployment's Contentful space |\n| **Check version** | Call `cms_edit_version` or `curl /api/health` and read `cmsEdit` |\n\n## Command reference (cms_edit args)\n\n**Discovery:** `sitemap`, `list --type <type>`, `search <query>`, `schema <contentType>`\n\n**Reading:** `open <slug>`, `open <id> --id`, `snapshot`, `read <ref>`, `read <ref> <field>`, `read <id> --id [field]`, `peek <slug>`, `peek <id> --id`\n\n**Diagnostics:** `diagnose` \u2014 session store, userId, active session (after open/read issues)\n\n**Editing:** `set <ref> <field> <value>`, `rtf <ref> <field> --content \"<md>\"`, `diff`, `save`, `discard`\n\n**Creating:** `create page --slug \u2026 --title \u2026`, `add <type> --content-type \u2026 --parent @c0 --target content`\n\n**Other:** `health`, `version`, `guide [topic]`\n";
|
|
2
|
+
//# sourceMappingURL=hosted-guide.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hosted-guide.d.ts","sourceRoot":"","sources":["../../src/generated/hosted-guide.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,qBAAqB,urLAAwlL,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// Generated by scripts/generate-embedded-assets.mjs — do not edit manually.
|
|
2
|
+
export const HOSTED_GUIDE_TEMPLATE = "# cms-edit MCP guide\n\nUse this guide when editing Contentful draft content through Claude Desktop (hosted `.mcpb` extension) or local stdio MCP.\n\n{{SITE_INTRO}}\n\n## Safety rules\n\ncms-edit **cannot and will not**:\n\n- Publish or unpublish entries\n- Archive or delete published entries\n- Upload new assets (use Contentful UI for assets)\n\nAll `save` operations create **drafts only**. A human must review and publish in Contentful.\n\n## MCP tools\n\n| Tool | Purpose |\n|------|---------|\n| `cms_edit` | Run any cms-edit command via an `args` array |\n| `cms_edit_version` | Check the installed cms-edit version (no session required) |\n| `cms_edit_help` | Read this guide by topic (`overview`, `workflow`, `commands`, `troubleshooting`, `hosted`) |\n\n## MCP prompts\n\n| Prompt | Purpose |\n|--------|---------|\n| `cms_edit_verify` | Check version and connectivity |\n| `cms_edit_explore` | List site content and open a page |\n| `cms_edit_edit_page` | Edit a page through diff → save |\n\nRead the full guide anytime via the `cms-edit://guide` resource or `cms_edit_help`.\n\n## Core workflow\n\nStandard editing flow: **open → snapshot → read → set/rtf → diff → save**\n\nEach step is a separate `cms_edit` call. Sessions persist in Redis between calls (hosted) or on disk (local). MCP auto-uses session `_mcp`.\n\n### 1. Open a page\n\n```\n[\"open\", \"/\"]\n[\"open\", \"/pricing\"]\n[\"open\", \"<entry-id>\", \"--id\"]\n```\n\nHomepage slug is `/` (or `index` depending on the site).\n\n### 2. Snapshot — see the content tree\n\n```\n[\"snapshot\"]\n```\n\nOutput shows `@c0`, `@c1`, … refs for each component. Use these refs in `read`, `set`, and `rtf`.\n\n### 3. Read fields\n\n```\n[\"read\", \"@c1\"]\n[\"read\", \"@c1\", \"heading\"]\n```\n\n### 4. Edit fields\n\n```\n[\"set\", \"@c1\", \"heading\", \"New heading text\"]\n[\"rtf\", \"@c1\", \"body\", \"--content\", \"# Title\\n\\nParagraph text.\"]\n```\n\nFor rich text, prefer `--content` with inline markdown. Use `--base64` when special characters cause issues.\n\n### 5. Review and save\n\n```\n[\"diff\"]\n[\"save\"]\n```\n\nAlways run `diff` before `save`. To abandon changes: `[\"discard\"]`.\n\n## Common sequences\n\n### List all pages\n\n```\n[\"sitemap\"]\n```\n\n### Explore the homepage\n\n```\n[\"open\", \"/\"]\n[\"snapshot\"]\n[\"read\", \"@c1\"]\n```\n\n### Edit copy on a page\n\n```\n[\"open\", \"{{EXAMPLE_SLUG}}\"]\n[\"snapshot\"]\n[\"read\", \"@c1\", \"heading\"]\n[\"set\", \"@c1\", \"heading\", \"Updated heading\"]\n[\"diff\"]\n[\"save\"]\n```\n\n## Field discovery\n\n```\n[\"schema\", \"component\"]\n[\"list\", \"--type\", \"page\"]\n[\"search\", \"pricing\"]\n```\n\n## Hosted extension rules\n\n{{HOSTED_RULES}}\n\n## Session tips\n\n- After `open`, subsequent MCP commands share session `_mcp` automatically (stored in Redis on hosted).\n- Use `--session <name>` only when juggling multiple pages — pass it **before** the subcommand on every call: `[\"--session\", \"my-work\", \"open\", \"/\"]`.\n- Snapshot JSON includes `sessionName` and `sessionKey` for debugging.\n- If you see \"No active session\", check `/api/health` (Redis must be ok), then run `open` again. Set `LOG_CMS_SESSION=1` on Vercel and search runtime logs for `[cms-edit:session]` (`redis save ok` / `redis load hit` / `requireSession miss`).\n\n### peek vs open vs read\n\n| Goal | MCP args |\n|------|----------|\n| Edit workflow (session) | `[\"open\", \"/\"]` then `[\"read\", \"@c0\"]` |\n| Preview tree + fields, no session | `[\"peek\", \"/pricing\"]` or `[\"peek\", \"<entry-id>\", \"--id\"]` (JSON includes `rootFields`) |\n| Read fields by entry ID, no session | `[\"read\", \"<entry-id>\", \"--id\"]` or `[\"read\", \"<entry-id>\", \"--id\", \"heading\"]` |\n| Debug session persistence | `[\"diagnose\"]` — reports store, userId, active session key |\n\n- **`peek` is one-shot** — prints tree and **root field values** (`rootFields` in JSON). No session is created; do not chain `read @ref` afterward.\n- **Entry IDs need `--id`** for both `open` and `peek` (bare IDs are treated as slugs).\n- **`read @root`** only works after `open` (uses the active session). The hint in peek output is for terminal users who already ran `open`.\n- **Do not invent flags** — there is no `--read`, `--then`, or chained peek+read syntax. One command per `cms_edit` call.\n\n## Troubleshooting\n\n| Problem | What to do |\n|---------|------------|\n| **401 / invalid token** | Regenerate CMA token in Contentful; update token in Claude Desktop → Settings → Extensions |\n| **No cms_edit tool** | Quit Claude fully and reopen; confirm extension is enabled |\n| **No active session** | Do not pass `--space` on hosted. Check `/api/health` — `redis` must be ok. MCP uses `_mcp` session automatically. Manual session: `[\"--session\", \"name\", \"open\", \"/\"]`. Fallback: `[\"read\", \"<entry-id>\", \"--id\"]` |\n| **Wrong space** | Token must belong to this deployment's Contentful space |\n| **Check version** | Call `cms_edit_version` or `curl /api/health` and read `cmsEdit` |\n\n## Command reference (cms_edit args)\n\n**Discovery:** `sitemap`, `list --type <type>`, `search <query>`, `schema <contentType>`\n\n**Reading:** `open <slug>`, `open <id> --id`, `snapshot`, `read <ref>`, `read <ref> <field>`, `read <id> --id [field]`, `peek <slug>`, `peek <id> --id`\n\n**Diagnostics:** `diagnose` — session store, userId, active session (after open/read issues)\n\n**Editing:** `set <ref> <field> <value>`, `rtf <ref> <field> --content \"<md>\"`, `diff`, `save`, `discard`\n\n**Creating:** `create page --slug … --title …`, `add <type> --content-type … --parent @c0 --target content`\n\n**Other:** `health`, `version`, `guide [topic]`\n";
|
|
3
|
+
//# sourceMappingURL=hosted-guide.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hosted-guide.js","sourceRoot":"","sources":["../../src/generated/hosted-guide.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,MAAM,CAAC,MAAM,qBAAqB,GAAG,qlLAAqlL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/generated/version.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,qBAAqB,8BAA8B,CAAC;AACjE,eAAO,MAAM,gBAAgB,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/generated/version.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,MAAM,CAAC,MAAM,qBAAqB,GAAG,2BAA2B,CAAC;AACjE,MAAM,CAAC,MAAM,gBAAgB,GAAG,QAAQ,CAAC"}
|
package/dist/mcp/guide.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guide.d.ts","sourceRoot":"","sources":["../../src/mcp/guide.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"guide.d.ts","sourceRoot":"","sources":["../../src/mcp/guide.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AAED,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,UAAU,GAAG,UAAU,GAAG,iBAAiB,GAAG,QAAQ,CAAC;AAE7F,eAAO,MAAM,YAAY,EAAE,UAAU,EAMpC,CAAC;AAEF,eAAO,MAAM,kBAAkB,qBAAqB,CAAC;AAErD,eAAO,MAAM,kBAAkB,wEAIrB,CAAC;AAEX,eAAO,MAAM,oBAAoB;;;;CAIvB,CAAC;AAWX,wBAAgB,uBAAuB,IAAI,MAAM,CAEhD;AA+BD,wBAAgB,kBAAkB,CAAC,MAAM,CAAC,EAAE,aAAa,GAAG,MAAM,CAMjE;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,MAAM,CAiB7E;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,aAAa,GAAG,MAAM,CAGvF;AAED,wBAAgB,eAAe,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,UAAU,CAQ1D"}
|
package/dist/mcp/guide.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import * as path from 'node:path';
|
|
3
|
-
import { fileURLToPath } from 'node:url';
|
|
1
|
+
import { HOSTED_GUIDE_TEMPLATE } from '../generated/hosted-guide.js';
|
|
4
2
|
export const GUIDE_TOPICS = [
|
|
5
3
|
'overview',
|
|
6
4
|
'workflow',
|
|
@@ -26,12 +24,8 @@ const TOPIC_HEADINGS = {
|
|
|
26
24
|
troubleshooting: '## Troubleshooting',
|
|
27
25
|
hosted: '## Hosted extension rules',
|
|
28
26
|
};
|
|
29
|
-
function packageRoot() {
|
|
30
|
-
return path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..');
|
|
31
|
-
}
|
|
32
27
|
export function loadHostedGuideTemplate() {
|
|
33
|
-
|
|
34
|
-
return readFileSync(guidePath, 'utf-8');
|
|
28
|
+
return HOSTED_GUIDE_TEMPLATE;
|
|
35
29
|
}
|
|
36
30
|
function buildSiteIntro(hosted) {
|
|
37
31
|
if (hosted) {
|
package/dist/mcp/guide.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guide.js","sourceRoot":"","sources":["../../src/mcp/guide.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"guide.js","sourceRoot":"","sources":["../../src/mcp/guide.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAUrE,MAAM,CAAC,MAAM,YAAY,GAAiB;IACxC,UAAU;IACV,UAAU;IACV,UAAU;IACV,iBAAiB;IACjB,QAAQ;CACT,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,kBAAkB,CAAC;AAErD,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,iBAAiB;IACjB,kBAAkB;IAClB,oBAAoB;CACZ,CAAC;AAEX,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,WAAW,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YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC9F,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
2
|
import type { RunCmsEditFn } from '../types.js';
|
|
3
|
-
export declare const TOOL_DESCRIPTION = "Run any cms-edit command. cms-edit edits Contentful draft content (no publishing).\n\nUse cms_edit_version (no args) to check the installed version.\nUse cms_edit_help to read the getting-started guide by topic.\nRead the cms-edit://guide resource for the full guide.\n\nWorkflow: open \u2192 snapshot \u2192 read/set/rtf/add/remove \u2192 diff \u2192 save\nAll saves create drafts only \u2014 a human must publish in Contentful.\n\nCommon command sequences:\n [\"open\", \"/pricing\"] \u2014 load a page by slug\n [\"open\", \"<entry-id>\", \"--id\"] \u2014 load by Contentful entry ID\n [\"snapshot\"] \u2014 print content tree with @refs\n [\"read\", \"@c0\"] \u2014 read all fields of a component (requires open session)\n [\"read\", \"@c0\", \"heading\"] \u2014 read a specific field (requires open session)\n [\"read\", \"@root\"] \u2014 read root entry fields (requires open session)\n [\"read\", \"<entry-id>\", \"--id\"] \u2014 read entry by ID (no session)\n [\"read\", \"<entry-id>\", \"--id\", \"heading\"] \u2014 read one field by entry ID (no session)\n [\"peek\", \"/pricing\"] \u2014 preview tree + root fields (no session)\n [\"peek\", \"<entry-id>\", \"--id\"] \u2014 preview component/page by entry ID with rootFields in JSON\n [\"set\", \"@c0\", \"heading\", \"New heading\"] \u2014 set a scalar field\n [\"rtf\", \"@c0\", \"body\", \"--content\", \"# H1\\n\\nBody.\"] \u2014 set rich text (preferred for AI)\n [\"rtf\", \"@c0\", \"body\", \"--base64\", \"<encoded>\"] \u2014 set rich text via base64 (no filesystem)\n [\"diff\"] \u2014 show pending changes\n [\"save\"] \u2014 write drafts to Contentful\n [\"discard\"] \u2014 discard unsaved changes\n [\"health\"] \u2014 verify config and connectivity\n [\"diagnose\"] \u2014 session/MCP diagnostics (store, userId, active session)\n [\"version\"] \u2014 print installed cms-edit version\n [\"guide\"] \u2014 print getting-started guide\n [\"guide\", \"workflow\"] \u2014 print a guide section\n\nSessions persist between MCP calls (Redis on hosted, disk locally). MCP auto-uses session \"_mcp\" unless you pass --session.\nUse --session <name> before the subcommand to isolate concurrent workflows, e.g. [\"--session\", \"my-work\", \"open\", \"/\"].\nUse --space <name> to target a specific Contentful space (local MCP only \u2014 omit for hosted .mcpb extensions).\nStateless read (no open required): [\"read\", \"<entry-id>\", \"--id\"] or [\"read\", \"<entry-id>\", \"--id\", \"heading\"].\npeek is one-shot (no session): use [\"peek\", \"<slug>\"] or [\"peek\", \"<entry-id>\", \"--id\"]. Includes rootFields in JSON \u2014 no follow-up read required.\nOutput is always JSON (CMS_EDIT_JSON=1 is forced by the MCP server).\n\nRich text tips:\n --content \"<markdown>\" preferred named flag for inline content (any length)\n --base64 \"<encoded>\" fully environment-agnostic, no filesystem needed\n --file \"<abs-path>\" platform-native absolute path required (C:\\\\Users\\\\... on Windows)\n stdin (\"-\") not supported via MCP";
|
|
3
|
+
export declare const TOOL_DESCRIPTION = "Run any cms-edit command. cms-edit edits Contentful draft content (no publishing).\n\nUse cms_edit_version (no args) to check the installed version.\nUse cms_edit_help to read the getting-started guide by topic.\nRead the cms-edit://guide resource for the full guide.\n\nWorkflow: open \u2192 snapshot \u2192 read/set/rtf/add/remove \u2192 diff \u2192 save\nAll saves create drafts only \u2014 a human must publish in Contentful.\n\nCommon command sequences:\n [\"open\", \"/pricing\"] \u2014 load a page by slug\n [\"open\", \"<entry-id>\", \"--id\"] \u2014 load by Contentful entry ID\n [\"snapshot\"] \u2014 print content tree with @refs\n [\"read\", \"@c0\"] \u2014 read all fields of a component (requires open session)\n [\"read\", \"@c0\", \"heading\"] \u2014 read a specific field (requires open session)\n [\"read\", \"@root\"] \u2014 read root entry fields (requires open session)\n [\"read\", \"<entry-id>\", \"--id\"] \u2014 read entry by ID (no session)\n [\"read\", \"<entry-id>\", \"--id\", \"heading\"] \u2014 read one field by entry ID (no session)\n [\"peek\", \"/pricing\"] \u2014 preview tree + root fields (no session)\n [\"peek\", \"<entry-id>\", \"--id\"] \u2014 preview component/page by entry ID with rootFields in JSON\n [\"set\", \"@c0\", \"heading\", \"New heading\"] \u2014 set a scalar field\n [\"rtf\", \"@c0\", \"body\", \"--content\", \"# H1\\n\\nBody.\"] \u2014 set rich text (preferred for AI)\n [\"rtf\", \"@c0\", \"body\", \"--base64\", \"<encoded>\"] \u2014 set rich text via base64 (no filesystem)\n [\"diff\"] \u2014 show pending changes\n [\"save\"] \u2014 write drafts to Contentful\n [\"discard\"] \u2014 discard unsaved changes\n [\"links\", \"set\", \"@c0\", \"0\", \"variant\", \"link\"] \u2014 set scalar field on link at index 0\n [\"batch\", \"set\", \"<entry-id>:variant=link\"] \u2014 queue scalar edit by entry ID\n [\"batch\", \"diff\"] \u2014 show pending batch edits\n [\"batch\", \"save\"] \u2014 save all batch edits as drafts\n [\"health\"] \u2014 verify config and connectivity\n [\"diagnose\"] \u2014 session/MCP diagnostics (store, userId, active session)\n [\"version\"] \u2014 print installed cms-edit version\n [\"guide\"] \u2014 print getting-started guide\n [\"guide\", \"workflow\"] \u2014 print a guide section\n\nSessions persist between MCP calls (Redis on hosted, disk locally). MCP auto-uses session \"_mcp\" unless you pass --session.\nUse --session <name> before the subcommand to isolate concurrent workflows, e.g. [\"--session\", \"my-work\", \"open\", \"/\"].\nUse --space <name> to target a specific Contentful space (local MCP only \u2014 omit for hosted .mcpb extensions).\nStateless read (no open required): [\"read\", \"<entry-id>\", \"--id\"] or [\"read\", \"<entry-id>\", \"--id\", \"heading\"].\npeek is one-shot (no session): use [\"peek\", \"<slug>\"] or [\"peek\", \"<entry-id>\", \"--id\"]. Includes rootFields in JSON \u2014 no follow-up read required.\nOutput is always JSON (CMS_EDIT_JSON=1 is forced by the MCP server).\n\nRich text tips:\n --content \"<markdown>\" preferred named flag for inline content (any length)\n --base64 \"<encoded>\" fully environment-agnostic, no filesystem needed\n --file \"<abs-path>\" platform-native absolute path required (C:\\\\Users\\\\... on Windows)\n stdin (\"-\") not supported via MCP";
|
|
4
4
|
export declare function registerCmsEditTools(server: McpServer, runCmsEdit: RunCmsEditFn): void;
|
|
5
5
|
export declare function getMcpServerInfo(): {
|
|
6
6
|
name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cms-edit.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/cms-edit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAKzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,eAAO,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"cms-edit.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/cms-edit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAKzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,eAAO,MAAM,gBAAgB,imIA+CoB,CAAC;AAElD,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,GAAG,IAAI,CA8BtF;AAED,wBAAgB,gBAAgB,IAAI;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAEpE"}
|
|
@@ -28,6 +28,10 @@ Common command sequences:
|
|
|
28
28
|
["diff"] — show pending changes
|
|
29
29
|
["save"] — write drafts to Contentful
|
|
30
30
|
["discard"] — discard unsaved changes
|
|
31
|
+
["links", "set", "@c0", "0", "variant", "link"] — set scalar field on link at index 0
|
|
32
|
+
["batch", "set", "<entry-id>:variant=link"] — queue scalar edit by entry ID
|
|
33
|
+
["batch", "diff"] — show pending batch edits
|
|
34
|
+
["batch", "save"] — save all batch edits as drafts
|
|
31
35
|
["health"] — verify config and connectivity
|
|
32
36
|
["diagnose"] — session/MCP diagnostics (store, userId, active session)
|
|
33
37
|
["version"] — print installed cms-edit version
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cms-edit.js","sourceRoot":"","sources":["../../../src/mcp/tools/cms-edit.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGpD,MAAM,CAAC,MAAM,gBAAgB,GAAG
|
|
1
|
+
{"version":3,"file":"cms-edit.js","sourceRoot":"","sources":["../../../src/mcp/tools/cms-edit.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGpD,MAAM,CAAC,MAAM,gBAAgB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iDA+CiB,CAAC;AAElD,MAAM,UAAU,oBAAoB,CAAC,MAAiB,EAAE,UAAwB;IAC9E,MAAM,CAAC,IAAI,CACT,kBAAkB,EAClB,+FAA+F,EAC/F,EAAE,EACF,KAAK,IAAI,EAAE;QACT,MAAM,IAAI,GAAG,cAAc,EAAE,CAAC;QAC9B,OAAO;YACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,CAAC,EAAE,CAAC;SAClF,CAAC;IACJ,CAAC,CACF,CAAC;IAEF,MAAM,CAAC,IAAI,CACT,UAAU,EACV,gBAAgB,EAChB;QACE,IAAI,EAAE,CAAC;aACJ,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;aACjB,QAAQ,CACP,2JAA2J,CAC5J;KACJ,EACD,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;QACjB,MAAM,cAAc,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC;QAC5C,iBAAiB,CAAC,oBAAoB,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,CAAC;QAC3E,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC,cAAc,CAAC,CAAC;QAC9C,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;IACxD,CAAC,CACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC;AACzD,CAAC"}
|
package/dist/session/state.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ContentTypeProps } from 'contentful-management';
|
|
1
2
|
/**
|
|
2
3
|
* Serialized representation of a Contentful CMA entry for session storage.
|
|
3
4
|
* Fields use the CMA locale-keyed format: { fieldId: { locale: value } }
|
|
@@ -39,11 +40,15 @@ export interface FieldPatch {
|
|
|
39
40
|
appliedAt: string;
|
|
40
41
|
}
|
|
41
42
|
/** Root entry kinds for a cms-edit session (maps from Contentful content type id via {@link mapContentTypeIdToRootEntryType}). */
|
|
42
|
-
export type RootEntryType = 'page' | 'article' | 'articleType' | 'tag' | 'navigation' | 'template';
|
|
43
|
+
export type RootEntryType = 'page' | 'article' | 'articleType' | 'tag' | 'navigation' | 'template' | 'batch';
|
|
43
44
|
/**
|
|
44
45
|
* Maps a CMA content type id to the session root kind. Unknown ids default to `page` (e.g. `--id` on a component).
|
|
45
46
|
*/
|
|
46
47
|
export declare function mapContentTypeIdToRootEntryType(contentTypeId: string): RootEntryType;
|
|
48
|
+
/** Sentinel root entry ID for batch edit sessions (multiple unrelated entries by ID). */
|
|
49
|
+
export declare const BATCH_ROOT_ENTRY_ID = "__batch__";
|
|
50
|
+
/** How the session was opened — tree (page open) or batch (entry ID edits). */
|
|
51
|
+
export type SessionKind = 'tree' | 'batch';
|
|
47
52
|
/**
|
|
48
53
|
* The full session state persisted between CLI commands.
|
|
49
54
|
*/
|
|
@@ -55,6 +60,8 @@ export interface SessionState {
|
|
|
55
60
|
defaultLocale: string;
|
|
56
61
|
rootEntryId: string;
|
|
57
62
|
rootEntryType: RootEntryType;
|
|
63
|
+
/** Defaults to 'tree' when omitted (backward compatible). */
|
|
64
|
+
sessionKind?: SessionKind;
|
|
58
65
|
fetchedAt: string;
|
|
59
66
|
/** All fetched entries keyed by entry ID */
|
|
60
67
|
entries: Record<string, SerializedEntry>;
|
|
@@ -70,6 +77,8 @@ export interface SessionState {
|
|
|
70
77
|
modifiedEntryIds: string[];
|
|
71
78
|
/** Draft-only entry IDs to delete on save (from remove operations) */
|
|
72
79
|
pendingDeletions: string[];
|
|
80
|
+
/** Cached CMA content type definitions (reused across CLI invocations for this session) */
|
|
81
|
+
contentTypes?: Record<string, ContentTypeProps>;
|
|
73
82
|
}
|
|
74
83
|
export type EntryStatus = 'published' | 'draft' | 'pending' | 'changed';
|
|
75
84
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/session/state.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE;QACH,EAAE,EAAE,MAAM,CAAC;QACX,OAAO,EAAE,MAAM,CAAC;QAChB,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,WAAW,EAAE;YAAE,GAAG,EAAE;gBAAE,EAAE,EAA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AC;IAC7B,oBAAoB;IACpB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,qCAAqC;IACrC,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,gDAAgD;IAChD,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,sEAAsE;IACtE,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,2FAA2F;IAC3F,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;CACjD;AAED,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,CAAC;AAExE;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,OAAO,GAAG,WAAW,CAM9F;AASD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAUhF;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAc5E;AAED,gEAAgE;AAChE,eAAO,MAAM,oBAAoB,uHAQvB,CAAC"}
|
package/dist/session/state.js
CHANGED
|
@@ -19,6 +19,8 @@ export function mapContentTypeIdToRootEntryType(contentTypeId) {
|
|
|
19
19
|
return 'page';
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
+
/** Sentinel root entry ID for batch edit sessions (multiple unrelated entries by ID). */
|
|
23
|
+
export const BATCH_ROOT_ENTRY_ID = '__batch__';
|
|
22
24
|
/**
|
|
23
25
|
* Derives the display status of an entry.
|
|
24
26
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.js","sourceRoot":"","sources":["../../src/session/state.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"state.js","sourceRoot":"","sources":["../../src/session/state.ts"],"names":[],"mappings":"AA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HANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { CMS_EDIT_PACKAGE_NAME, CMS_EDIT_VERSION } from './generated/version.js';
|
|
1
2
|
export interface CmsEditVersionInfo {
|
|
2
3
|
name: 'cms-edit';
|
|
3
4
|
version: string;
|
|
4
5
|
package: string;
|
|
5
6
|
}
|
|
6
|
-
export
|
|
7
|
-
export declare const CMS_EDIT_VERSION: string;
|
|
7
|
+
export { CMS_EDIT_PACKAGE_NAME, CMS_EDIT_VERSION };
|
|
8
8
|
export declare function getVersionInfo(): CmsEditVersionInfo;
|
|
9
9
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/version.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAEjF,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,UAAU,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,CAAC;AAEnD,wBAAgB,cAAc,IAAI,kBAAkB,CAMnD"}
|
package/dist/version.js
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { fileURLToPath } from 'node:url';
|
|
4
|
-
function readPackageJson() {
|
|
5
|
-
const packageRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
6
|
-
const raw = readFileSync(path.join(packageRoot, 'package.json'), 'utf-8');
|
|
7
|
-
return JSON.parse(raw);
|
|
8
|
-
}
|
|
9
|
-
const pkg = readPackageJson();
|
|
10
|
-
export const CMS_EDIT_PACKAGE_NAME = pkg.name ?? '@se-studio/contentful-cms';
|
|
11
|
-
export const CMS_EDIT_VERSION = pkg.version ?? '0.0.0';
|
|
1
|
+
import { CMS_EDIT_PACKAGE_NAME, CMS_EDIT_VERSION } from './generated/version.js';
|
|
2
|
+
export { CMS_EDIT_PACKAGE_NAME, CMS_EDIT_VERSION };
|
|
12
3
|
export function getVersionInfo() {
|
|
13
4
|
return {
|
|
14
5
|
name: 'cms-edit',
|
package/dist/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAQjF,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,CAAC;AAEnD,MAAM,UAAU,cAAc;IAC5B,OAAO;QACL,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE,gBAAgB;QACzB,OAAO,EAAE,qBAAqB;KAC/B,CAAC;AACJ,CAAC"}
|
package/docs/FUNCTIONAL_SPEC.md
CHANGED
|
@@ -159,10 +159,23 @@ CTA link lists are nested within component entries.
|
|
|
159
159
|
| `links add <ref> --type internal --label "X" --slug /page` | Add an internal link by page slug |
|
|
160
160
|
| `links add <ref> --type internal --label "X" --id <id>` | Add an internal link by entry ID |
|
|
161
161
|
| `links add <ref> --type download --label "X" --asset-id <id>` | Add a download link to an asset |
|
|
162
|
+
| `links add <ref> … --variant <value>` | Set link variant on create |
|
|
163
|
+
| `links set <ref> <index> <field> <value>` | Set a scalar field on an existing link entry |
|
|
162
164
|
| `links move <ref> <from-index> <to-index>` | Reorder links by index |
|
|
163
165
|
| `links remove <ref> <index>` | Remove a link by index |
|
|
164
166
|
|
|
165
|
-
### 7.7
|
|
167
|
+
### 7.7 Batch edit (by entry ID)
|
|
168
|
+
|
|
169
|
+
| Command | Function |
|
|
170
|
+
|---|---|
|
|
171
|
+
| `batch set <entryId>:field=value …` | Queue scalar field updates for unrelated entries |
|
|
172
|
+
| `batch diff` | Show pending batch session changes |
|
|
173
|
+
| `batch save` | Write all batch changes as drafts |
|
|
174
|
+
| `batch discard` | Clear batch session without saving |
|
|
175
|
+
|
|
176
|
+
Default session name: `batch`. Scalar fields only in v1.
|
|
177
|
+
|
|
178
|
+
### 7.8 Navigation
|
|
166
179
|
|
|
167
180
|
| Command | Function |
|
|
168
181
|
|---|---|
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Batch edit by entry ID
|
|
2
|
+
|
|
3
|
+
Edit multiple unrelated Contentful entries without opening a page tree. Useful for link variant sweeps, navigation item tweaks, and other standalone entry updates.
|
|
4
|
+
|
|
5
|
+
Batch commands use session name **`batch`** by default (override with `--session`). Page sessions from `cms-edit open` are not affected.
|
|
6
|
+
|
|
7
|
+
## Workflow
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# Queue scalar field updates (one or more entryId:field=value tokens)
|
|
11
|
+
cms-edit batch set 3my7n2M84OrhOaaSLHVHvo:variant=link 7MjsLmOq52CR9C5xrYlcub:variant=button
|
|
12
|
+
|
|
13
|
+
# Review pending changes
|
|
14
|
+
cms-edit batch diff
|
|
15
|
+
|
|
16
|
+
# Write all changes as drafts (single save)
|
|
17
|
+
cms-edit batch save
|
|
18
|
+
|
|
19
|
+
# Or discard without saving
|
|
20
|
+
cms-edit batch discard
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Token format
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
<entryId>:<fieldId>=<value>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
- **entryId** — 22-character Contentful entry ID (no `@` prefix)
|
|
30
|
+
- **fieldId** — field name on that entry's content type
|
|
31
|
+
- **value** — literal token (no shell quotes needed for simple strings). Coercion follows the field type from Contentful:
|
|
32
|
+
- **Symbol** / **Text** — always stored as strings (e.g. `order=42` stays `"42"`)
|
|
33
|
+
- **Integer** / **Number** — parsed as numbers
|
|
34
|
+
- **Boolean** — `true` / `false`
|
|
35
|
+
- **null** — literal `null`
|
|
36
|
+
- Fields with enum validations (e.g. `variant`) must match allowed values
|
|
37
|
+
|
|
38
|
+
Examples:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
cms-edit batch set abcdefghijklmnopqrstuv:variant=link
|
|
42
|
+
cms-edit batch set abcdefghijklmnopqrstuv:cmsLabel=Footer CTA
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Link variant sweep
|
|
46
|
+
|
|
47
|
+
When you already know link entry IDs (from `cms-edit read @cN links` or `cms-edit links list @cN`):
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
cms-edit batch set \
|
|
51
|
+
idOne123456789012345678:variant=link \
|
|
52
|
+
idTwo123456789012345678:variant=button
|
|
53
|
+
cms-edit batch diff
|
|
54
|
+
cms-edit batch save
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
When a page is already open, prefer `cms-edit links set @cN <index> variant link` instead.
|
|
58
|
+
|
|
59
|
+
## Content type schema cache
|
|
60
|
+
|
|
61
|
+
Field types and enum validations are loaded from the Contentful Management API. Results are cached:
|
|
62
|
+
|
|
63
|
+
- In the **batch session file** (`contentTypes` on the session) so `batch set` → `batch save` reuse schema without extra API calls
|
|
64
|
+
- On disk at `~/.contentful-cms/content-types/<spaceId>/<environment>/` (24-hour TTL)
|
|
65
|
+
|
|
66
|
+
## v1 limits
|
|
67
|
+
|
|
68
|
+
- **Scalar fields only** — no rich text, entry links, asset links, or link arrays
|
|
69
|
+
- **Draft-only** — same as `cms-edit save`; never publishes
|
|
70
|
+
- **No cross-entry link arrays** — use page session + `cms-edit set --links` for parent arrays
|
|
71
|
+
- **Partial save on failure** — if one entry fails during `batch save`, earlier entries may already be saved; the CLI lists failures and reminds you to run `cms-edit batch diff` for remaining changes
|
|
72
|
+
|
|
73
|
+
## Named sessions
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
cms-edit --session link-sweep batch set idOne123456789012345678:variant=link
|
|
77
|
+
cms-edit --session link-sweep batch save
|
|
78
|
+
```
|
|
@@ -101,6 +101,9 @@ cms-edit links add @c1 --type internal --label "Our Team" --slug /about/team
|
|
|
101
101
|
# Add a download link
|
|
102
102
|
cms-edit links add @c1 --type download --label "Download PDF" --asset-id <assetId>
|
|
103
103
|
|
|
104
|
+
# Set link variant (text link vs button — see cms-edit schema link)
|
|
105
|
+
cms-edit links set @c1 0 variant link
|
|
106
|
+
|
|
104
107
|
# Remove a link (by index)
|
|
105
108
|
cms-edit links remove @c1 0
|
|
106
109
|
|
package/docs/help/index.md
CHANGED
|
@@ -19,6 +19,7 @@ Available topics for `cms-edit help <topic>`:
|
|
|
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
21
|
| `run` | Execute a batch of operations from a JSON file |
|
|
22
|
+
| `batch` | Edit multiple entries by Contentful entry ID, then save once |
|
|
22
23
|
| `fields` | Overview of all content types |
|
|
23
24
|
| `fields-page` | All fields on a `page` entry |
|
|
24
25
|
| `fields-article` | All fields on an `article` entry |
|
package/docs/help/run.md
CHANGED
|
@@ -84,10 +84,10 @@ Options: `parent` (ref of a collection to add inside), `after` (ref to insert af
|
|
|
84
84
|
### `links-add`
|
|
85
85
|
Create a new CTA link and attach it to an entry's `links` field.
|
|
86
86
|
```json
|
|
87
|
-
{ "cmd": "links-add", "args": ["@c1"], "opts": { "type": "external", "label": "Learn More", "href": "https://example.com" } }
|
|
87
|
+
{ "cmd": "links-add", "args": ["@c1"], "opts": { "type": "external", "label": "Learn More", "href": "https://example.com", "variant": "link" } }
|
|
88
88
|
{ "cmd": "links-add", "args": ["@c1"], "opts": { "type": "internal", "label": "Contact", "slug": "/contact" } }
|
|
89
89
|
```
|
|
90
|
-
Options: `type`, `label`, `href`, `slug`, `id`, `assetId`.
|
|
90
|
+
Options: `type`, `label`, `href`, `slug`, `id`, `assetId`, `variant`.
|
|
91
91
|
|
|
92
92
|
### `save`
|
|
93
93
|
Write all modified entries to Contentful as drafts.
|