@se-studio/contentful-cms 1.0.79 → 1.0.82
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 +18 -0
- package/HOSTED.md +121 -0
- package/INSTALL.md +22 -5
- package/README.md +2 -0
- package/dist/bin/cms-edit.js +8 -143
- package/dist/bin/cms-edit.js.map +1 -1
- package/dist/cli/program.d.ts +9 -0
- package/dist/cli/program.d.ts.map +1 -0
- package/dist/cli/program.js +159 -0
- package/dist/cli/program.js.map +1 -0
- package/dist/cli/runner.d.ts +15 -0
- package/dist/cli/runner.d.ts.map +1 -0
- package/dist/cli/runner.js +93 -0
- package/dist/cli/runner.js.map +1 -0
- package/dist/commands/add.js +2 -2
- package/dist/commands/add.js.map +1 -1
- package/dist/commands/asset.js +5 -5
- package/dist/commands/asset.js.map +1 -1
- package/dist/commands/backup.js +1 -1
- package/dist/commands/backup.js.map +1 -1
- package/dist/commands/create-from-json.js +1 -1
- package/dist/commands/create-from-json.js.map +1 -1
- package/dist/commands/create.js +4 -4
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/diff.js +2 -2
- package/dist/commands/diff.js.map +1 -1
- package/dist/commands/discard.js +4 -4
- package/dist/commands/discard.js.map +1 -1
- package/dist/commands/guide.d.ts +4 -0
- package/dist/commands/guide.d.ts.map +1 -0
- package/dist/commands/guide.js +18 -0
- package/dist/commands/guide.js.map +1 -0
- package/dist/commands/links.js +10 -10
- package/dist/commands/links.js.map +1 -1
- package/dist/commands/move.js +3 -3
- package/dist/commands/move.js.map +1 -1
- package/dist/commands/nav.js +3 -3
- package/dist/commands/nav.js.map +1 -1
- package/dist/commands/open.js +1 -1
- package/dist/commands/open.js.map +1 -1
- package/dist/commands/peek.d.ts.map +1 -1
- package/dist/commands/peek.js +8 -2
- package/dist/commands/peek.js.map +1 -1
- package/dist/commands/preview.js +1 -1
- package/dist/commands/preview.js.map +1 -1
- package/dist/commands/read.js +2 -2
- package/dist/commands/read.js.map +1 -1
- package/dist/commands/remove.js +2 -2
- package/dist/commands/remove.js.map +1 -1
- package/dist/commands/revert.js +5 -5
- package/dist/commands/revert.js.map +1 -1
- package/dist/commands/rtf.js +11 -11
- package/dist/commands/rtf.js.map +1 -1
- package/dist/commands/run.js +8 -8
- package/dist/commands/run.js.map +1 -1
- package/dist/commands/save.js +3 -3
- package/dist/commands/save.js.map +1 -1
- package/dist/commands/screenshot.js +2 -2
- package/dist/commands/screenshot.js.map +1 -1
- package/dist/commands/set.js +7 -7
- package/dist/commands/set.js.map +1 -1
- package/dist/commands/snapshot.js +1 -1
- package/dist/commands/snapshot.js.map +1 -1
- package/dist/commands/version.d.ts +4 -0
- package/dist/commands/version.d.ts.map +1 -0
- package/dist/commands/version.js +17 -0
- package/dist/commands/version.js.map +1 -0
- package/dist/config/hosted.d.ts +28 -0
- package/dist/config/hosted.d.ts.map +1 -0
- package/dist/config/hosted.js +94 -0
- package/dist/config/hosted.js.map +1 -0
- package/dist/config/load.d.ts.map +1 -1
- package/dist/config/load.js +5 -0
- package/dist/config/load.js.map +1 -1
- package/dist/hosted/index.d.ts +13 -0
- package/dist/hosted/index.d.ts.map +1 -0
- package/dist/hosted/index.js +12 -0
- package/dist/hosted/index.js.map +1 -0
- package/dist/mcp/guide.d.ts +20 -0
- package/dist/mcp/guide.d.ts.map +1 -0
- package/dist/mcp/guide.js +91 -0
- package/dist/mcp/guide.js.map +1 -0
- package/dist/mcp/http-handler.d.ts +13 -0
- package/dist/mcp/http-handler.d.ts.map +1 -0
- package/dist/mcp/http-handler.js +28 -0
- package/dist/mcp/http-handler.js.map +1 -0
- package/dist/mcp/prompts/onboarding.d.ts +4 -0
- package/dist/mcp/prompts/onboarding.d.ts.map +1 -0
- package/dist/mcp/prompts/onboarding.js +77 -0
- package/dist/mcp/prompts/onboarding.js.map +1 -0
- package/dist/mcp/resources/guide.d.ts +4 -0
- package/dist/mcp/resources/guide.d.ts.map +1 -0
- package/dist/mcp/resources/guide.js +16 -0
- package/dist/mcp/resources/guide.js.map +1 -0
- package/dist/mcp/server.d.ts +13 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +20 -92
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/tools/cms-edit.d.ts +9 -0
- package/dist/mcp/tools/cms-edit.d.ts.map +1 -0
- package/dist/mcp/tools/cms-edit.js +57 -0
- package/dist/mcp/tools/cms-edit.js.map +1 -0
- package/dist/mcp/tools/help.d.ts +4 -0
- package/dist/mcp/tools/help.d.ts.map +1 -0
- package/dist/mcp/tools/help.js +22 -0
- package/dist/mcp/tools/help.js.map +1 -0
- package/dist/mcp/types.d.ts +2 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/mcp/types.js +2 -0
- package/dist/mcp/types.js.map +1 -0
- package/dist/runtime/context.d.ts +19 -0
- package/dist/runtime/context.d.ts.map +1 -0
- package/dist/runtime/context.js +9 -0
- package/dist/runtime/context.js.map +1 -0
- package/dist/session/file-session-store.d.ts +10 -0
- package/dist/session/file-session-store.d.ts.map +1 -0
- package/dist/session/file-session-store.js +92 -0
- package/dist/session/file-session-store.js.map +1 -0
- package/dist/session/redis-session-store.d.ts +21 -0
- package/dist/session/redis-session-store.d.ts.map +1 -0
- package/dist/session/redis-session-store.js +121 -0
- package/dist/session/redis-session-store.js.map +1 -0
- package/dist/session/session-store.d.ts +19 -0
- package/dist/session/session-store.d.ts.map +1 -0
- package/dist/session/session-store.js +9 -0
- package/dist/session/session-store.js.map +1 -0
- package/dist/session/store.d.ts +5 -5
- package/dist/session/store.d.ts.map +1 -1
- package/dist/session/store.js +16 -74
- package/dist/session/store.js.map +1 -1
- package/dist/version.d.ts +9 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +19 -0
- package/dist/version.js.map +1 -0
- package/docs/FEATURE_REQUESTS_ARCHIVE.md +141 -0
- package/docs/FUNCTIONAL_SPEC.md +271 -0
- package/docs/mcp/hosted-guide.md +149 -0
- package/package.json +14 -6
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
function hostedNote(hosted) {
|
|
3
|
+
if (!hosted) {
|
|
4
|
+
return 'Local MCP: use --space when multiple spaces are configured.';
|
|
5
|
+
}
|
|
6
|
+
const siteName = hosted.displayName ?? hosted.projectKey;
|
|
7
|
+
return (`Hosted deployment for ${siteName}. Do NOT pass --space in cms_edit args — ` +
|
|
8
|
+
'this extension is already bound to one Contentful space.');
|
|
9
|
+
}
|
|
10
|
+
export function registerOnboardingPrompts(server, hosted) {
|
|
11
|
+
const note = hostedNote(hosted);
|
|
12
|
+
server.prompt('cms_edit_verify', 'Verify cms-edit connectivity: check version and run health checks.', async () => ({
|
|
13
|
+
messages: [
|
|
14
|
+
{
|
|
15
|
+
role: 'user',
|
|
16
|
+
content: {
|
|
17
|
+
type: 'text',
|
|
18
|
+
text: `${note}\n\n` +
|
|
19
|
+
'Verify cms-edit is working:\n' +
|
|
20
|
+
'1. Call cms_edit_version\n' +
|
|
21
|
+
'2. Call cms_edit with args ["health"]\n' +
|
|
22
|
+
'3. Summarize version and health status for the user',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
}));
|
|
27
|
+
server.prompt('cms_edit_explore', 'Explore site content: sitemap, open a page, and show the content tree.', {
|
|
28
|
+
slug: z.string().optional().describe('Page slug to open (default: / for homepage)'),
|
|
29
|
+
}, async ({ slug }) => {
|
|
30
|
+
const targetSlug = slug ?? '/';
|
|
31
|
+
return {
|
|
32
|
+
messages: [
|
|
33
|
+
{
|
|
34
|
+
role: 'user',
|
|
35
|
+
content: {
|
|
36
|
+
type: 'text',
|
|
37
|
+
text: `${note}\n\n` +
|
|
38
|
+
'Explore this Contentful site:\n' +
|
|
39
|
+
'1. cms_edit ["sitemap"] — list pages\n' +
|
|
40
|
+
`2. cms_edit ["open", "${targetSlug}"] — load the page\n` +
|
|
41
|
+
'3. cms_edit ["snapshot"] — show @ref tree\n' +
|
|
42
|
+
'4. Summarize what you found',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
server.prompt('cms_edit_edit_page', 'Edit a page: open, inspect, change fields, diff, then save as draft.', {
|
|
49
|
+
slug: z.string().describe('Page slug to edit, e.g. /pricing'),
|
|
50
|
+
instructions: z.string().optional().describe('Optional edit instructions from the user'),
|
|
51
|
+
}, async ({ slug, instructions }) => {
|
|
52
|
+
const editLine = instructions
|
|
53
|
+
? `User wants: ${instructions}\n`
|
|
54
|
+
: 'Ask the user what to change if not specified.\n';
|
|
55
|
+
return {
|
|
56
|
+
messages: [
|
|
57
|
+
{
|
|
58
|
+
role: 'user',
|
|
59
|
+
content: {
|
|
60
|
+
type: 'text',
|
|
61
|
+
text: `${note}\n\n` +
|
|
62
|
+
`${editLine}` +
|
|
63
|
+
`Edit page "${slug}":\n` +
|
|
64
|
+
`1. cms_edit ["open", "${slug}"]\n` +
|
|
65
|
+
'2. cms_edit ["snapshot"] — find @refs\n' +
|
|
66
|
+
'3. cms_edit ["read", "@cN", "field"] — inspect fields\n' +
|
|
67
|
+
'4. cms_edit ["set", ...] or ["rtf", ..., "--content", "..."] — make changes\n' +
|
|
68
|
+
'5. cms_edit ["diff"] — review ALL changes\n' +
|
|
69
|
+
'6. cms_edit ["save"] — write drafts (does NOT publish)\n' +
|
|
70
|
+
'Always show diff before saving.',
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
};
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=onboarding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"onboarding.js","sourceRoot":"","sources":["../../../src/mcp/prompts/onboarding.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,SAAS,UAAU,CAAC,MAAsB;IACxC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,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C,MAAM,EAAE,CAAC,QAAQ,CAAC,kCAAkC,CAAC;QAC7D,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,0CAA0C,CAAC;KACzF,EACD,KAAK,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE;QAC/B,MAAM,QAAQ,GAAG,YAAY;YAC3B,CAAC,CAAC,eAAe,YAAY,IAAI;YACjC,CAAC,CAAC,iDAAiD,CAAC;QACtD,OAAO;YACL,QAAQ,EAAE;gBACR;oBACE,IAAI,EAAE,MAAe;oBACrB,OAAO,EAAE;wBACP,IAAI,EAAE,MAAe;wBACrB,IAAI,EACF,GAAG,IAAI,MAAM;4BACb,GAAG,QAAQ,EAAE;4BACb,cAAc,IAAI,MAAM;4BACxB,yBAAyB,IAAI,MAAM;4BACnC,yCAAyC;4BACzC,yDAAyD;4BACzD,+EAA+E;4BAC/E,6CAA6C;4BAC7C,0DAA0D;4BAC1D,iCAAiC;qBACpC;iBACF;aACF;SACF,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guide.d.ts","sourceRoot":"","sources":["../../../src/mcp/resources/guide.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,EAA0C,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAEzF,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,aAAa,GAAG,IAAI,CAkBrF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { buildGuideMarkdown, GUIDE_RESOURCE_URI } from '../guide.js';
|
|
2
|
+
export function registerGuideResource(server, hosted) {
|
|
3
|
+
server.resource('cms-edit-guide', GUIDE_RESOURCE_URI, {
|
|
4
|
+
description: 'Read before editing Contentful content with cms_edit.',
|
|
5
|
+
mimeType: 'text/markdown',
|
|
6
|
+
}, async () => ({
|
|
7
|
+
contents: [
|
|
8
|
+
{
|
|
9
|
+
uri: GUIDE_RESOURCE_URI,
|
|
10
|
+
mimeType: 'text/markdown',
|
|
11
|
+
text: buildGuideMarkdown(hosted),
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
}));
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=guide.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guide.js","sourceRoot":"","sources":["../../../src/mcp/resources/guide.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAsB,MAAM,aAAa,CAAC;AAEzF,MAAM,UAAU,qBAAqB,CAAC,MAAiB,EAAE,MAAsB;IAC7E,MAAM,CAAC,QAAQ,CACb,gBAAgB,EAChB,kBAAkB,EAClB;QACE,WAAW,EAAE,uDAAuD;QACpE,QAAQ,EAAE,eAAe;KAC1B,EACD,KAAK,IAAI,EAAE,CAAC,CAAC;QACX,QAAQ,EAAE;YACR;gBACE,GAAG,EAAE,kBAAkB;gBACvB,QAAQ,EAAE,eAAe;gBACzB,IAAI,EAAE,kBAAkB,CAAC,MAAM,CAAC;aACjC;SACF;KACF,CAAC,CACH,CAAC;AACJ,CAAC"}
|
package/dist/mcp/server.d.ts
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
|
|
2
|
+
import type { HostedMcpInfo } from './guide.js';
|
|
3
|
+
import type { RunCmsEditFn } from './types.js';
|
|
4
|
+
export type { HostedMcpInfo } from './guide.js';
|
|
5
|
+
export type { RunCmsEditFn } from './types.js';
|
|
6
|
+
export interface CreateMcpServerOptions {
|
|
7
|
+
/** Custom runner (in-process for hosted). Defaults to child-process spawn for stdio MCP. */
|
|
8
|
+
runCmsEdit?: RunCmsEditFn;
|
|
9
|
+
/** When set, guide and prompts include hosted-specific notes (site name, no --space). */
|
|
10
|
+
hosted?: HostedMcpInfo;
|
|
11
|
+
}
|
|
12
|
+
export declare function createMcpServer(options?: CreateMcpServerOptions): McpServer;
|
|
13
|
+
/** In-process runner used by hosted MCP and tests. */
|
|
14
|
+
export declare function runCmsEditInProcess(args: string[]): Promise<string>;
|
|
3
15
|
//# sourceMappingURL=server.d.ts.map
|
package/dist/mcp/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAKhD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAK/C,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,MAAM,WAAW,sBAAsB;IACrC,4FAA4F;IAC5F,UAAU,CAAC,EAAE,YAAY,CAAC;IAC1B,yFAAyF;IACzF,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB;AAED,wBAAgB,eAAe,CAAC,OAAO,GAAE,sBAA2B,GAAG,SAAS,CAW/E;AA8BD,sDAAsD;AACtD,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAIzE"}
|
package/dist/mcp/server.js
CHANGED
|
@@ -3,103 +3,26 @@ import * as child_process from 'node:child_process';
|
|
|
3
3
|
import * as path from 'node:path';
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
5
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
6
|
-
import {
|
|
6
|
+
import { runCmsEditArgs } from '../cli/runner.js';
|
|
7
|
+
import { registerOnboardingPrompts } from './prompts/onboarding.js';
|
|
8
|
+
import { registerGuideResource } from './resources/guide.js';
|
|
9
|
+
import { getMcpServerInfo, registerCmsEditTools } from './tools/cms-edit.js';
|
|
10
|
+
import { registerHelpTool } from './tools/help.js';
|
|
7
11
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
8
|
-
// dist/mcp/server.js → dist/bin/cms-edit.js
|
|
9
12
|
const CMS_EDIT_BIN = path.resolve(__dirname, '..', 'bin', 'cms-edit.js');
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
["snapshot"] — print content tree with @refs
|
|
19
|
-
["read", "@c0"] — read all fields of a component
|
|
20
|
-
["read", "@c0", "heading"] — read a specific field
|
|
21
|
-
["set", "@c0", "heading", "New heading"] — set a scalar field
|
|
22
|
-
["rtf", "@c0", "body", "--content", "# H1\\n\\nBody."] — set rich text (preferred for AI)
|
|
23
|
-
["rtf", "@c0", "body", "--base64", "<encoded>"] — set rich text via base64 (no filesystem)
|
|
24
|
-
["diff"] — show pending changes
|
|
25
|
-
["save"] — write drafts to Contentful
|
|
26
|
-
["discard"] — discard unsaved changes
|
|
27
|
-
["health"] — verify config and connectivity
|
|
28
|
-
["--docs"] — print README path for reference
|
|
29
|
-
|
|
30
|
-
Entry creation:
|
|
31
|
-
create = new top-level entries (page, article, template)
|
|
32
|
-
add = new child entries linked into an existing entry's content array
|
|
33
|
-
["create", "article", "--slug", "/blog/x", "--title", "X", "--article-type-id", "<id>"]
|
|
34
|
-
["list", "--type", "articleType"] — find valid article type IDs
|
|
35
|
-
["add", "<type>", "--content-type", "<ct>", "--parent", "@c0", "--target", "content"]
|
|
36
|
-
|
|
37
|
-
Field discovery:
|
|
38
|
-
["schema", "<content-type>"] — show field definitions, descriptions, and SEO hints
|
|
39
|
-
["list", "--type", "<contentType>"] — list entries by type (prefer over search for type-specific queries)
|
|
40
|
-
|
|
41
|
-
Command reference by category:
|
|
42
|
-
|
|
43
|
-
DISCOVERY
|
|
44
|
-
list --type <page|article|component|…> List entries by content type
|
|
45
|
-
search <query> Full-text search across entries
|
|
46
|
-
types <contentType> List type-discriminator enum values
|
|
47
|
-
schema <contentType> Show fields, descriptions, and SEO hints
|
|
48
|
-
sitemap All pages/articles with slugs and status
|
|
49
|
-
|
|
50
|
-
READING
|
|
51
|
-
open <slug> Load a page or article by slug
|
|
52
|
-
open <id> --id Load by Contentful entry ID
|
|
53
|
-
snapshot Show content tree with @refs
|
|
54
|
-
read <ref> Read all fields on an entry
|
|
55
|
-
read <ref> <field> Read a specific field
|
|
56
|
-
peek <id> Quick field preview without opening a session
|
|
57
|
-
|
|
58
|
-
EDITING
|
|
59
|
-
set <ref> <field> <value> Set a text/boolean/number/date field
|
|
60
|
-
asset set <ref> <field> <asset-id> Set an asset/image field (not plain set)
|
|
61
|
-
rtf <ref> <field> --content "<markdown>" Set a rich text field
|
|
62
|
-
links add/remove/move Manage CTA/link arrays
|
|
63
|
-
|
|
64
|
-
CREATING CONTENT
|
|
65
|
-
create article --slug … --title … --article-type-id …
|
|
66
|
-
create page --slug … --title …
|
|
67
|
-
add <type> --content-type <ct> --target content --parent <ref> Add a child component
|
|
68
|
-
remove <ref> Remove a child entry
|
|
69
|
-
move <ref> --after <ref> Reorder entries
|
|
70
|
-
|
|
71
|
-
NAVIGATION & ASSETS
|
|
72
|
-
nav open/add Manage navigation entries
|
|
73
|
-
asset search/info/set Find and set assets
|
|
74
|
-
resolve <id> Resolve entry ID to ref in current session
|
|
75
|
-
|
|
76
|
-
Use --session <name> to isolate concurrent workflows.
|
|
77
|
-
Use --space <name> to target a specific Contentful space.
|
|
78
|
-
Output is always JSON (CMS_EDIT_JSON=1 is forced by the MCP server).
|
|
79
|
-
|
|
80
|
-
Rich text tips:
|
|
81
|
-
--content "<markdown>" preferred named flag for inline content (any length)
|
|
82
|
-
--base64 "<encoded>" fully environment-agnostic, no filesystem needed
|
|
83
|
-
--file "<abs-path>" platform-native absolute path required (C:\\\\Users\\\\... on Windows)
|
|
84
|
-
stdin ("-") not supported via MCP`;
|
|
85
|
-
export function createMcpServer() {
|
|
86
|
-
const server = new McpServer({ name: 'cms-edit', version: '1.0.0' });
|
|
87
|
-
server.tool('cms_edit', TOOL_DESCRIPTION, {
|
|
88
|
-
args: z
|
|
89
|
-
.array(z.string())
|
|
90
|
-
.describe('CLI arguments to pass to cms-edit, e.g. ["open", "/pricing"] or ["--space", "om1", "snapshot"]'),
|
|
91
|
-
}, async ({ args }) => {
|
|
92
|
-
const text = await runCmsEdit(args);
|
|
93
|
-
return { content: [{ type: 'text', text }] };
|
|
94
|
-
});
|
|
13
|
+
export function createMcpServer(options = {}) {
|
|
14
|
+
const serverInfo = getMcpServerInfo();
|
|
15
|
+
const server = new McpServer({ name: serverInfo.name, version: serverInfo.version });
|
|
16
|
+
const runCmsEdit = options.runCmsEdit ?? spawnRunCmsEdit;
|
|
17
|
+
registerCmsEditTools(server, runCmsEdit);
|
|
18
|
+
registerHelpTool(server, options.hosted);
|
|
19
|
+
registerGuideResource(server, options.hosted);
|
|
20
|
+
registerOnboardingPrompts(server, options.hosted);
|
|
95
21
|
return server;
|
|
96
22
|
}
|
|
97
|
-
async function
|
|
23
|
+
async function spawnRunCmsEdit(args) {
|
|
98
24
|
return new Promise((resolve) => {
|
|
99
|
-
// Inherit all env vars (CMS_EDIT_TOKEN, CMS_EDIT_SPACE, etc.) and force JSON mode
|
|
100
25
|
const env = { ...process.env, CMS_EDIT_JSON: '1' };
|
|
101
|
-
// Use process.execPath (node binary) + absolute path to cms-edit.js to avoid
|
|
102
|
-
// PATH resolution issues when launched by Claude Desktop / Claude Code
|
|
103
26
|
const proc = child_process.spawn(process.execPath, [CMS_EDIT_BIN, ...args], {
|
|
104
27
|
cwd: process.cwd(),
|
|
105
28
|
env,
|
|
@@ -113,7 +36,6 @@ async function runCmsEdit(args) {
|
|
|
113
36
|
const out = Buffer.concat(stdout).toString('utf-8').trim();
|
|
114
37
|
const err = Buffer.concat(stderr).toString('utf-8').trim();
|
|
115
38
|
const combined = [out, err].filter(Boolean).join('\n');
|
|
116
|
-
// Append exit code on failure so Claude knows the command failed
|
|
117
39
|
resolve(code !== 0 ? `${combined}\n(exit code ${code})` : combined);
|
|
118
40
|
});
|
|
119
41
|
proc.on('error', (err) => {
|
|
@@ -121,4 +43,10 @@ async function runCmsEdit(args) {
|
|
|
121
43
|
});
|
|
122
44
|
});
|
|
123
45
|
}
|
|
46
|
+
/** In-process runner used by hosted MCP and tests. */
|
|
47
|
+
export async function runCmsEditInProcess(args) {
|
|
48
|
+
process.env['CMS_EDIT_JSON'] = '1';
|
|
49
|
+
const { exitCode, output } = await runCmsEditArgs(args);
|
|
50
|
+
return exitCode !== 0 ? `${output}\n(exit code ${exitCode})` : output;
|
|
51
|
+
}
|
|
124
52
|
//# sourceMappingURL=server.js.map
|
package/dist/mcp/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,CAAC,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;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AAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;YACvB,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QAC7D,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED,sDAAsD;AACtD,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,IAAc;IACtD,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,GAAG,GAAG,CAAC;IACnC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,cAAc,CAAC,IAAI,CAAC,CAAC;IACxD,OAAO,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,gBAAgB,QAAQ,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC;AACxE,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
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\n [\"read\", \"@c0\", \"heading\"] \u2014 read a specific field\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 [\"version\"] \u2014 print installed cms-edit version\n [\"guide\"] \u2014 print getting-started guide\n [\"guide\", \"workflow\"] \u2014 print a guide section\n\nUse --session <name> to isolate concurrent workflows.\nUse --space <name> to target a specific Contentful space (local MCP only \u2014 omit for hosted .mcpb extensions).\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
|
+
export declare function registerCmsEditTools(server: McpServer, runCmsEdit: RunCmsEditFn): void;
|
|
5
|
+
export declare function getMcpServerInfo(): {
|
|
6
|
+
name: string;
|
|
7
|
+
version: string;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=cms-edit.d.ts.map
|
|
@@ -0,0 +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;AAGzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,eAAO,MAAM,gBAAgB,i+EAkCoB,CAAC;AAElD,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,GAAG,IAAI,CA4BtF;AAED,wBAAgB,gBAAgB,IAAI;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAEpE"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { CMS_EDIT_VERSION, getVersionInfo } from '../../version.js';
|
|
3
|
+
export const TOOL_DESCRIPTION = `Run any cms-edit command. cms-edit edits Contentful draft content (no publishing).
|
|
4
|
+
|
|
5
|
+
Use cms_edit_version (no args) to check the installed version.
|
|
6
|
+
Use cms_edit_help to read the getting-started guide by topic.
|
|
7
|
+
Read the cms-edit://guide resource for the full guide.
|
|
8
|
+
|
|
9
|
+
Workflow: open → snapshot → read/set/rtf/add/remove → diff → save
|
|
10
|
+
All saves create drafts only — a human must publish in Contentful.
|
|
11
|
+
|
|
12
|
+
Common command sequences:
|
|
13
|
+
["open", "/pricing"] — load a page by slug
|
|
14
|
+
["open", "<entry-id>", "--id"] — load by Contentful entry ID
|
|
15
|
+
["snapshot"] — print content tree with @refs
|
|
16
|
+
["read", "@c0"] — read all fields of a component
|
|
17
|
+
["read", "@c0", "heading"] — read a specific field
|
|
18
|
+
["set", "@c0", "heading", "New heading"] — set a scalar field
|
|
19
|
+
["rtf", "@c0", "body", "--content", "# H1\\n\\nBody."] — set rich text (preferred for AI)
|
|
20
|
+
["rtf", "@c0", "body", "--base64", "<encoded>"] — set rich text via base64 (no filesystem)
|
|
21
|
+
["diff"] — show pending changes
|
|
22
|
+
["save"] — write drafts to Contentful
|
|
23
|
+
["discard"] — discard unsaved changes
|
|
24
|
+
["health"] — verify config and connectivity
|
|
25
|
+
["version"] — print installed cms-edit version
|
|
26
|
+
["guide"] — print getting-started guide
|
|
27
|
+
["guide", "workflow"] — print a guide section
|
|
28
|
+
|
|
29
|
+
Use --session <name> to isolate concurrent workflows.
|
|
30
|
+
Use --space <name> to target a specific Contentful space (local MCP only — omit for hosted .mcpb extensions).
|
|
31
|
+
Output is always JSON (CMS_EDIT_JSON=1 is forced by the MCP server).
|
|
32
|
+
|
|
33
|
+
Rich text tips:
|
|
34
|
+
--content "<markdown>" preferred named flag for inline content (any length)
|
|
35
|
+
--base64 "<encoded>" fully environment-agnostic, no filesystem needed
|
|
36
|
+
--file "<abs-path>" platform-native absolute path required (C:\\\\Users\\\\... on Windows)
|
|
37
|
+
stdin ("-") not supported via MCP`;
|
|
38
|
+
export function registerCmsEditTools(server, runCmsEdit) {
|
|
39
|
+
server.tool('cms_edit_version', 'Return the installed cms-edit package version. No session or Contentful credentials required.', {}, async () => {
|
|
40
|
+
const info = getVersionInfo();
|
|
41
|
+
return {
|
|
42
|
+
content: [{ type: 'text', text: JSON.stringify({ ok: true, ...info }) }],
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
server.tool('cms_edit', TOOL_DESCRIPTION, {
|
|
46
|
+
args: z
|
|
47
|
+
.array(z.string())
|
|
48
|
+
.describe('CLI arguments to pass to cms-edit, e.g. ["open", "/pricing"] or ["snapshot"] or ["read", "@c1"]. Do not pass --space when using a hosted .mcpb extension.'),
|
|
49
|
+
}, async ({ args }) => {
|
|
50
|
+
const text = await runCmsEdit(args);
|
|
51
|
+
return { content: [{ type: 'text', text }] };
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
export function getMcpServerInfo() {
|
|
55
|
+
return { name: 'cms-edit', version: CMS_EDIT_VERSION };
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=cms-edit.js.map
|
|
@@ -0,0 +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,gBAAgB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGpE,MAAM,CAAC,MAAM,gBAAgB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iDAkCiB,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,IAAI,GAAG,MAAM,UAAU,CAAC,IAAI,CAAC,CAAC;QACpC,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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/help.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,EAIL,KAAK,aAAa,EACnB,MAAM,aAAa,CAAC;AAErB,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,aAAa,GAAG,IAAI,CAyBhF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { GUIDE_TOPICS, getGuideTopicMarkdown, } from '../guide.js';
|
|
3
|
+
export function registerHelpTool(server, hosted) {
|
|
4
|
+
server.tool('cms_edit_help', 'Return the cms-edit getting-started guide by topic. No session or Contentful credentials required.', {
|
|
5
|
+
topic: z
|
|
6
|
+
.enum(GUIDE_TOPICS)
|
|
7
|
+
.optional()
|
|
8
|
+
.describe('Guide section: overview (default), workflow, commands, troubleshooting, or hosted.'),
|
|
9
|
+
}, async ({ topic }) => {
|
|
10
|
+
const resolvedTopic = (topic ?? 'overview');
|
|
11
|
+
const markdown = getGuideTopicMarkdown(resolvedTopic, hosted);
|
|
12
|
+
return {
|
|
13
|
+
content: [
|
|
14
|
+
{
|
|
15
|
+
type: 'text',
|
|
16
|
+
text: JSON.stringify({ ok: true, topic: resolvedTopic, markdown }),
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
};
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=help.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help.js","sourceRoot":"","sources":["../../../src/mcp/tools/help.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,YAAY,EAEZ,qBAAqB,GAEtB,MAAM,aAAa,CAAC;AAErB,MAAM,UAAU,gBAAgB,CAAC,MAAiB,EAAE,MAAsB;IACxE,MAAM,CAAC,IAAI,CACT,eAAe,EACf,oGAAoG,EACpG;QACE,KAAK,EAAE,CAAC;aACL,IAAI,CAAC,YAAY,CAAC;aAClB,QAAQ,EAAE;aACV,QAAQ,CACP,oFAAoF,CACrF;KACJ,EACD,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;QAClB,MAAM,aAAa,GAAG,CAAC,KAAK,IAAI,UAAU,CAAe,CAAC;QAC1D,MAAM,QAAQ,GAAG,qBAAqB,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;QAC9D,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAC;iBACnE;aACF;SACF,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/mcp/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/mcp/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
+
import type { CmsEditConfig } from '../config/types.js';
|
|
3
|
+
import type { SessionStore } from '../session/session-store.js';
|
|
4
|
+
export interface ContentfulUserIdentity {
|
|
5
|
+
userId: string;
|
|
6
|
+
email: string;
|
|
7
|
+
}
|
|
8
|
+
export interface CmsEditRuntimeContext {
|
|
9
|
+
/** Pre-built config (hosted mode). Skips filesystem config lookup. */
|
|
10
|
+
config?: CmsEditConfig;
|
|
11
|
+
/** Session persistence backend (filesystem default when omitted). */
|
|
12
|
+
sessionStore?: SessionStore;
|
|
13
|
+
/** Contentful user for session key isolation in hosted mode. */
|
|
14
|
+
user?: ContentfulUserIdentity;
|
|
15
|
+
}
|
|
16
|
+
export declare const cmsEditContext: AsyncLocalStorage<CmsEditRuntimeContext>;
|
|
17
|
+
export declare function getRuntimeContext(): CmsEditRuntimeContext | undefined;
|
|
18
|
+
export declare function runWithCmsEditContext<T>(context: CmsEditRuntimeContext, fn: () => T | Promise<T>): T | Promise<T>;
|
|
19
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/runtime/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,qBAAqB;IACpC,sEAAsE;IACtE,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,qEAAqE;IACrE,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,gEAAgE;IAChE,IAAI,CAAC,EAAE,sBAAsB,CAAC;CAC/B;AAED,eAAO,MAAM,cAAc,0CAAiD,CAAC;AAE7E,wBAAgB,iBAAiB,IAAI,qBAAqB,GAAG,SAAS,CAErE;AAED,wBAAgB,qBAAqB,CAAC,CAAC,EACrC,OAAO,EAAE,qBAAqB,EAC9B,EAAE,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GACvB,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAEhB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
+
export const cmsEditContext = new AsyncLocalStorage();
|
|
3
|
+
export function getRuntimeContext() {
|
|
4
|
+
return cmsEditContext.getStore();
|
|
5
|
+
}
|
|
6
|
+
export function runWithCmsEditContext(context, fn) {
|
|
7
|
+
return cmsEditContext.run(context, fn);
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/runtime/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAkBrD,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,iBAAiB,EAAyB,CAAC;AAE7E,MAAM,UAAU,iBAAiB;IAC/B,OAAO,cAAc,CAAC,QAAQ,EAAE,CAAC;AACnC,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,OAA8B,EAC9B,EAAwB;IAExB,OAAO,cAAc,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type SessionStore } from './session-store.js';
|
|
2
|
+
import type { SessionState } from './state.js';
|
|
3
|
+
export declare class FileSessionStore implements SessionStore {
|
|
4
|
+
load(spaceId?: string, rootEntryId?: string, sessionName?: string): SessionState | null;
|
|
5
|
+
save(state: SessionState, sessionName?: string): void;
|
|
6
|
+
clear(spaceId: string, rootEntryId: string, sessionName?: string): void;
|
|
7
|
+
clearAll(): void;
|
|
8
|
+
}
|
|
9
|
+
export declare const defaultFileSessionStore: FileSessionStore;
|
|
10
|
+
//# sourceMappingURL=file-session-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-session-store.d.ts","sourceRoot":"","sources":["../../src/session/file-session-store.ts"],"names":[],"mappings":"AAIA,OAAO,EAA2C,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAChG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AA6C/C,qBAAa,gBAAiB,YAAW,YAAY;IACnD,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI;IAgBvF,IAAI,CAAC,KAAK,EAAE,YAAY,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI;IASrD,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI;IAUvE,QAAQ,IAAI,IAAI;CAUjB;AAED,eAAO,MAAM,uBAAuB,kBAAyB,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as os from 'node:os';
|
|
3
|
+
import * as path from 'node:path';
|
|
4
|
+
import { getRuntimeContext } from '../runtime/context.js';
|
|
5
|
+
import { buildSessionKey, buildSessionNameSuffix } from './session-store.js';
|
|
6
|
+
const SESSIONS_DIR = path.join(os.homedir(), '.contentful-cms', 'sessions');
|
|
7
|
+
function getUserIdPrefix() {
|
|
8
|
+
return getRuntimeContext()?.user?.userId;
|
|
9
|
+
}
|
|
10
|
+
function toFileName(sessionKey) {
|
|
11
|
+
return `${sessionKey}.json`;
|
|
12
|
+
}
|
|
13
|
+
function getSessionFilePath(sessionKey) {
|
|
14
|
+
return path.join(SESSIONS_DIR, toFileName(sessionKey));
|
|
15
|
+
}
|
|
16
|
+
function findNamedSessionPath(sessionName, userId) {
|
|
17
|
+
if (!fs.existsSync(SESSIONS_DIR))
|
|
18
|
+
return null;
|
|
19
|
+
const suffix = `${buildSessionNameSuffix(sessionName)}.json`;
|
|
20
|
+
const prefix = userId ? `${userId}:` : '';
|
|
21
|
+
const files = fs
|
|
22
|
+
.readdirSync(SESSIONS_DIR)
|
|
23
|
+
.filter((f) => f.endsWith(suffix) && (prefix === '' || f.startsWith(prefix)));
|
|
24
|
+
if (files.length === 0)
|
|
25
|
+
return null;
|
|
26
|
+
const sorted = files
|
|
27
|
+
.map((f) => ({ file: f, mtime: fs.statSync(path.join(SESSIONS_DIR, f)).mtime }))
|
|
28
|
+
.sort((a, b) => b.mtime.getTime() - a.mtime.getTime());
|
|
29
|
+
const latest = sorted[0];
|
|
30
|
+
return latest ? path.join(SESSIONS_DIR, latest.file) : null;
|
|
31
|
+
}
|
|
32
|
+
function findLatestSessionPath(userId) {
|
|
33
|
+
if (!fs.existsSync(SESSIONS_DIR))
|
|
34
|
+
return null;
|
|
35
|
+
const prefix = userId ? `${userId}:` : '';
|
|
36
|
+
const files = fs
|
|
37
|
+
.readdirSync(SESSIONS_DIR)
|
|
38
|
+
.filter((f) => f.endsWith('.json') && (prefix === '' || f.startsWith(prefix)));
|
|
39
|
+
if (files.length === 0)
|
|
40
|
+
return null;
|
|
41
|
+
const sorted = files
|
|
42
|
+
.map((f) => ({ file: f, mtime: fs.statSync(path.join(SESSIONS_DIR, f)).mtime }))
|
|
43
|
+
.sort((a, b) => b.mtime.getTime() - a.mtime.getTime());
|
|
44
|
+
const latest = sorted[0];
|
|
45
|
+
return latest ? path.join(SESSIONS_DIR, latest.file) : null;
|
|
46
|
+
}
|
|
47
|
+
export class FileSessionStore {
|
|
48
|
+
load(spaceId, rootEntryId, sessionName) {
|
|
49
|
+
const userId = getUserIdPrefix();
|
|
50
|
+
const sessionPath = spaceId && rootEntryId
|
|
51
|
+
? getSessionFilePath(buildSessionKey(userId, spaceId, rootEntryId, sessionName))
|
|
52
|
+
: sessionName
|
|
53
|
+
? findNamedSessionPath(sessionName, userId)
|
|
54
|
+
: findLatestSessionPath(userId);
|
|
55
|
+
if (!sessionPath || !fs.existsSync(sessionPath))
|
|
56
|
+
return null;
|
|
57
|
+
try {
|
|
58
|
+
return JSON.parse(fs.readFileSync(sessionPath, 'utf-8'));
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
save(state, sessionName) {
|
|
65
|
+
fs.mkdirSync(SESSIONS_DIR, { recursive: true });
|
|
66
|
+
const userId = getUserIdPrefix();
|
|
67
|
+
const sessionPath = getSessionFilePath(buildSessionKey(userId, state.spaceId, state.rootEntryId, sessionName));
|
|
68
|
+
fs.writeFileSync(sessionPath, JSON.stringify(state, null, 2), 'utf-8');
|
|
69
|
+
}
|
|
70
|
+
clear(spaceId, rootEntryId, sessionName) {
|
|
71
|
+
const userId = getUserIdPrefix();
|
|
72
|
+
const sessionPath = getSessionFilePath(buildSessionKey(userId, spaceId, rootEntryId, sessionName));
|
|
73
|
+
if (fs.existsSync(sessionPath)) {
|
|
74
|
+
fs.unlinkSync(sessionPath);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
clearAll() {
|
|
78
|
+
if (!fs.existsSync(SESSIONS_DIR))
|
|
79
|
+
return;
|
|
80
|
+
const userId = getUserIdPrefix();
|
|
81
|
+
const prefix = userId ? `${userId}:` : '';
|
|
82
|
+
for (const file of fs.readdirSync(SESSIONS_DIR)) {
|
|
83
|
+
if (!file.endsWith('.json'))
|
|
84
|
+
continue;
|
|
85
|
+
if (prefix && !file.startsWith(prefix))
|
|
86
|
+
continue;
|
|
87
|
+
fs.unlinkSync(path.join(SESSIONS_DIR, file));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
export const defaultFileSessionStore = new FileSessionStore();
|
|
92
|
+
//# sourceMappingURL=file-session-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-session-store.js","sourceRoot":"","sources":["../../src/session/file-session-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAqB,MAAM,oBAAoB,CAAC;AAGhG,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,iBAAiB,EAAE,UAAU,CAAC,CAAC;AAE5E,SAAS,eAAe;IACtB,OAAO,iBAAiB,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC;AAC3C,CAAC;AAED,SAAS,UAAU,CAAC,UAAkB;IACpC,OAAO,GAAG,UAAU,OAAO,CAAC;AAC9B,CAAC;AAED,SAAS,kBAAkB,CAAC,UAAkB;IAC5C,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AAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;YAC/B,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;IAED,QAAQ;QACN,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC;YAAE,OAAO;QACzC,MAAM,MAAM,GAAG,eAAe,EAAE,CAAC;QACjC,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1C,KAAK,MAAM,IAAI,IAAI,EAAE,CAAC,WAAW,CAAC,YAAY,CAAC,EAAE,CAAC;YAChD,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;gBAAE,SAAS;YACtC,IAAI,MAAM,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;gBAAE,SAAS;YACjD,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;CACF;AAED,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,gBAAgB,EAAE,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type RedisClient, type SessionStore } from './session-store.js';
|
|
2
|
+
import type { SessionState } from './state.js';
|
|
3
|
+
/** Parses session JSON from Redis — Upstash may return a deserialized object. */
|
|
4
|
+
export declare function parseSessionValue(raw: unknown): SessionState | null;
|
|
5
|
+
export declare class RedisSessionStore implements SessionStore {
|
|
6
|
+
private readonly redis;
|
|
7
|
+
private readonly keyPrefix;
|
|
8
|
+
constructor(redis: RedisClient, keyPrefix?: string);
|
|
9
|
+
private fullKey;
|
|
10
|
+
private activePointerKey;
|
|
11
|
+
private getUserId;
|
|
12
|
+
load(spaceId?: string, rootEntryId?: string, sessionName?: string): Promise<SessionState | null>;
|
|
13
|
+
save(state: SessionState, sessionName?: string): Promise<void>;
|
|
14
|
+
clear(spaceId: string, rootEntryId: string, sessionName?: string): Promise<void>;
|
|
15
|
+
clearAll(): Promise<void>;
|
|
16
|
+
private readSession;
|
|
17
|
+
private resolveActiveSessionKey;
|
|
18
|
+
/** Legacy lookup for sessions saved before active pointers existed. */
|
|
19
|
+
private findLatestSessionKeyFallback;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=redis-session-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis-session-store.d.ts","sourceRoot":"","sources":["../../src/session/redis-session-store.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC1F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAI/C,iFAAiF;AACjF,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,GAAG,YAAY,GAAG,IAAI,CAanE;AAED,qBAAa,iBAAkB,YAAW,YAAY;IAElD,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,SAAS;gBADT,KAAK,EAAE,WAAW,EAClB,SAAS,SAAsB;IAGlD,OAAO,CAAC,OAAO;IAIf,OAAO,CAAC,gBAAgB;IAOxB,OAAO,CAAC,SAAS;IAQX,IAAI,CACR,OAAO,CAAC,EAAE,MAAM,EAChB,WAAW,CAAC,EAAE,MAAM,EACpB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAazB,IAAI,CAAC,KAAK,EAAE,YAAY,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAS9D,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAahF,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;YAMjB,WAAW;YAKX,uBAAuB;IAarC,uEAAuE;YACzD,4BAA4B;CAkC3C"}
|