@se-studio/contentful-cms 1.2.0 → 1.2.2
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 +44 -0
- package/HOSTED.md +1 -1
- package/README.md +20 -19
- package/dist/commands/audit.d.ts.map +1 -1
- package/dist/commands/audit.js +5 -32
- package/dist/commands/audit.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.d.ts.map +1 -1
- package/dist/commands/create-from-json.js +11 -7
- package/dist/commands/create-from-json.js.map +1 -1
- package/dist/commands/create-taxonomy.d.ts +4 -0
- package/dist/commands/create-taxonomy.d.ts.map +1 -1
- package/dist/commands/create-taxonomy.js +22 -4
- package/dist/commands/create-taxonomy.js.map +1 -1
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +16 -6
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/diagnose.d.ts.map +1 -1
- package/dist/commands/diagnose.js +1 -1
- package/dist/commands/diagnose.js.map +1 -1
- package/dist/commands/discard.d.ts.map +1 -1
- package/dist/commands/discard.js +1 -1
- package/dist/commands/discard.js.map +1 -1
- package/dist/commands/ensure.d.ts.map +1 -1
- package/dist/commands/ensure.js +8 -0
- package/dist/commands/ensure.js.map +1 -1
- package/dist/commands/entry-lookup-target.d.ts +113 -0
- package/dist/commands/entry-lookup-target.d.ts.map +1 -0
- package/dist/commands/entry-lookup-target.js +235 -0
- package/dist/commands/entry-lookup-target.js.map +1 -0
- package/dist/commands/entry-search.d.ts.map +1 -1
- package/dist/commands/entry-search.js +1 -1
- package/dist/commands/entry-search.js.map +1 -1
- package/dist/commands/help.js +1 -1
- package/dist/commands/help.js.map +1 -1
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +6 -1
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/list.d.ts.map +1 -1
- package/dist/commands/list.js +31 -9
- package/dist/commands/list.js.map +1 -1
- package/dist/commands/nav.d.ts.map +1 -1
- package/dist/commands/nav.js +39 -22
- package/dist/commands/nav.js.map +1 -1
- package/dist/commands/open.d.ts.map +1 -1
- package/dist/commands/open.js +36 -21
- package/dist/commands/open.js.map +1 -1
- package/dist/commands/peek.d.ts.map +1 -1
- package/dist/commands/peek.js +36 -31
- package/dist/commands/peek.js.map +1 -1
- package/dist/commands/resolve.d.ts.map +1 -1
- package/dist/commands/resolve.js +82 -131
- package/dist/commands/resolve.js.map +1 -1
- package/dist/commands/screenshot.js +2 -2
- package/dist/commands/screenshot.js.map +1 -1
- package/dist/commands/set.d.ts.map +1 -1
- package/dist/commands/set.js +16 -0
- package/dist/commands/set.js.map +1 -1
- package/dist/contentful/cda-sync.d.ts +3 -1
- package/dist/contentful/cda-sync.d.ts.map +1 -1
- package/dist/contentful/cda-sync.js +128 -16
- package/dist/contentful/cda-sync.js.map +1 -1
- package/dist/contentful/entry-fields.d.ts +1 -0
- package/dist/contentful/entry-fields.d.ts.map +1 -1
- package/dist/contentful/entry-fields.js +21 -0
- package/dist/contentful/entry-fields.js.map +1 -1
- package/dist/contentful/entry-lookup.d.ts +16 -0
- package/dist/contentful/entry-lookup.d.ts.map +1 -0
- package/dist/contentful/entry-lookup.js +273 -0
- package/dist/contentful/entry-lookup.js.map +1 -0
- package/dist/contentful/fetch.d.ts +1 -1
- package/dist/contentful/fetch.d.ts.map +1 -1
- package/dist/contentful/fetch.js +11 -77
- package/dist/contentful/fetch.js.map +1 -1
- package/dist/contentful/linkedEntryFields.d.ts +27 -0
- package/dist/contentful/linkedEntryFields.d.ts.map +1 -0
- package/dist/contentful/linkedEntryFields.js +95 -0
- package/dist/contentful/linkedEntryFields.js.map +1 -0
- package/dist/contentful/reference-record.d.ts +16 -7
- package/dist/contentful/reference-record.d.ts.map +1 -1
- package/dist/contentful/reference-record.js +57 -16
- package/dist/contentful/reference-record.js.map +1 -1
- package/dist/contentful/resolve-content-type.d.ts +1 -1
- package/dist/contentful/resolve-content-type.d.ts.map +1 -1
- package/dist/contentful/resolve-content-type.js +1 -1
- package/dist/contentful/resolve-content-type.js.map +1 -1
- package/dist/contentful/slug-validation.d.ts +7 -0
- package/dist/contentful/slug-validation.d.ts.map +1 -0
- package/dist/contentful/slug-validation.js +15 -0
- package/dist/contentful/slug-validation.js.map +1 -0
- package/dist/generated/hosted-guide.d.ts +1 -1
- package/dist/generated/hosted-guide.d.ts.map +1 -1
- package/dist/generated/hosted-guide.js +1 -1
- package/dist/generated/hosted-guide.js.map +1 -1
- package/dist/generated/version.d.ts +1 -1
- package/dist/generated/version.js +1 -1
- package/dist/index/db.d.ts.map +1 -1
- package/dist/index/db.js +17 -0
- package/dist/index/db.js.map +1 -1
- package/dist/index/query.d.ts +13 -2
- package/dist/index/query.d.ts.map +1 -1
- package/dist/index/query.js +62 -5
- package/dist/index/query.js.map +1 -1
- package/dist/index/reference-lookup.d.ts.map +1 -1
- package/dist/index/reference-lookup.js +12 -0
- package/dist/index/reference-lookup.js.map +1 -1
- package/dist/index/require.d.ts.map +1 -1
- package/dist/index/require.js +6 -0
- package/dist/index/require.js.map +1 -1
- package/dist/index/run-sync.d.ts +2 -0
- package/dist/index/run-sync.d.ts.map +1 -1
- package/dist/index/run-sync.js +25 -4
- package/dist/index/run-sync.js.map +1 -1
- package/dist/index/schema.d.ts +10 -4
- package/dist/index/schema.d.ts.map +1 -1
- package/dist/index/schema.js +26 -4
- package/dist/index/schema.js.map +1 -1
- package/dist/index/sync-lock.d.ts +1 -0
- package/dist/index/sync-lock.d.ts.map +1 -1
- package/dist/index/sync-lock.js +43 -30
- package/dist/index/sync-lock.js.map +1 -1
- package/dist/index/sync-log.d.ts +7 -0
- package/dist/index/sync-log.d.ts.map +1 -0
- package/dist/index/sync-log.js +23 -0
- package/dist/index/sync-log.js.map +1 -0
- package/dist/index/sync.d.ts.map +1 -1
- package/dist/index/sync.js +7 -4
- package/dist/index/sync.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 +11 -11
- package/dist/session/store.js +2 -2
- package/dist/session/store.js.map +1 -1
- package/docs/FUNCTIONAL_SPEC.md +9 -8
- package/docs/help/create-from-json.md +4 -4
- package/docs/help/fields-article.md +2 -2
- package/docs/help/fields-collection.md +1 -1
- package/docs/help/fields-component.md +1 -1
- package/docs/help/fields-page.md +2 -2
- package/docs/help/fields-taxonomy.md +8 -4
- package/docs/help/index-sync.md +36 -18
- package/docs/help/index.md +8 -7
- package/docs/help/lookup.md +123 -0
- package/docs/help/run.md +1 -1
- package/docs/help/taxonomy-from-json.md +2 -2
- package/docs/help/workflow.md +6 -6
- package/docs/mcp/hosted-guide.md +4 -4
- package/package.json +1 -1
- package/skills/core/SKILL.md +39 -30
- package/skills/templates/SKILL.md +1 -1
- package/dist/commands/resolve-options.d.ts +0 -20
- package/dist/commands/resolve-options.d.ts.map +0 -1
- package/dist/commands/resolve-options.js +0 -51
- package/dist/commands/resolve-options.js.map +0 -1
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CatalogContentType } from '../index/schema.js';
|
|
2
2
|
export interface CdaReferenceRecord {
|
|
3
3
|
id: string;
|
|
4
|
-
contentType:
|
|
4
|
+
contentType: CatalogContentType;
|
|
5
5
|
slug: string | null;
|
|
6
6
|
label: string;
|
|
7
|
+
cmsLabel: string | null;
|
|
7
8
|
updatedAt: string;
|
|
9
|
+
tagTypeSlug: string | null;
|
|
10
|
+
articleTypeSlug: string | null;
|
|
8
11
|
}
|
|
9
12
|
export interface ReferenceFieldValues {
|
|
10
13
|
slug?: string | null;
|
|
@@ -13,20 +16,26 @@ export interface ReferenceFieldValues {
|
|
|
13
16
|
cmsLabel?: string | null;
|
|
14
17
|
adminLabel?: string | null;
|
|
15
18
|
}
|
|
19
|
+
export interface BuildReferenceRecordOptions {
|
|
20
|
+
strict?: boolean;
|
|
21
|
+
tagTypeSlug?: string | null;
|
|
22
|
+
articleTypeSlug?: string | null;
|
|
23
|
+
}
|
|
16
24
|
/**
|
|
17
25
|
* Maps normalized reference fields to a catalog row.
|
|
18
26
|
* When `strict` is true (CDA sync), incomplete rows return null. When false (CMA upsert), falls back to entry id.
|
|
19
27
|
*/
|
|
20
|
-
export declare function buildReferenceRecord(contentType:
|
|
21
|
-
strict?: boolean;
|
|
22
|
-
}): CdaReferenceRecord | null;
|
|
28
|
+
export declare function buildReferenceRecord(contentType: CatalogContentType, id: string, updatedAt: string, fields: ReferenceFieldValues, opts?: BuildReferenceRecordOptions): CdaReferenceRecord | null;
|
|
23
29
|
/** Reads locale-keyed CMA fields into {@link ReferenceFieldValues}. */
|
|
24
30
|
export declare function referenceFieldValuesFromCma(fields: Record<string, Record<string, unknown>>, locale: string): ReferenceFieldValues;
|
|
25
|
-
export declare function referenceRowFromCmaEntry(contentType:
|
|
31
|
+
export declare function referenceRowFromCmaEntry(contentType: CatalogContentType, entry: {
|
|
26
32
|
sys: {
|
|
27
33
|
id: string;
|
|
28
34
|
updatedAt: string;
|
|
29
35
|
};
|
|
30
36
|
fields: Record<string, Record<string, unknown>>;
|
|
31
|
-
}, locale: string
|
|
37
|
+
}, locale: string, parentSlugs?: {
|
|
38
|
+
tagTypeSlug?: string | null;
|
|
39
|
+
articleTypeSlug?: string | null;
|
|
40
|
+
}): CdaReferenceRecord;
|
|
32
41
|
//# sourceMappingURL=reference-record.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reference-record.d.ts","sourceRoot":"","sources":["../../src/contentful/reference-record.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"reference-record.d.ts","sourceRoot":"","sources":["../../src/contentful/reference-record.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAG7D,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,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AAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACjD,EACD,MAAM,EAAE,MAAM,EACd,WAAW,CAAC,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAC7E,kBAAkB,CAmBpB"}
|
|
@@ -1,31 +1,67 @@
|
|
|
1
|
+
import { normalizeSlug } from './fetch.js';
|
|
2
|
+
function catalogLabel(contentType, fields) {
|
|
3
|
+
if (contentType === 'template') {
|
|
4
|
+
return fields.cmsLabel ?? fields.adminLabel ?? fields.name ?? null;
|
|
5
|
+
}
|
|
6
|
+
if (contentType === 'page' ||
|
|
7
|
+
contentType === 'article' ||
|
|
8
|
+
contentType === 'pageVariant' ||
|
|
9
|
+
contentType === 'navigationItem') {
|
|
10
|
+
return fields.title ?? fields.name ?? null;
|
|
11
|
+
}
|
|
12
|
+
if (contentType === 'tag' ||
|
|
13
|
+
contentType === 'tagType' ||
|
|
14
|
+
contentType === 'articleType' ||
|
|
15
|
+
contentType === 'navigation') {
|
|
16
|
+
return fields.name ?? fields.title ?? null;
|
|
17
|
+
}
|
|
18
|
+
return fields.name ?? fields.title ?? fields.cmsLabel ?? null;
|
|
19
|
+
}
|
|
20
|
+
function catalogCmsLabel(contentType, fields) {
|
|
21
|
+
if (contentType === 'template') {
|
|
22
|
+
const raw = fields.cmsLabel ?? fields.adminLabel ?? fields.name;
|
|
23
|
+
return raw != null ? String(raw) : null;
|
|
24
|
+
}
|
|
25
|
+
if (contentType === 'page' ||
|
|
26
|
+
contentType === 'article' ||
|
|
27
|
+
contentType === 'pageVariant' ||
|
|
28
|
+
contentType === 'tag') {
|
|
29
|
+
return fields.cmsLabel != null ? String(fields.cmsLabel) : null;
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
1
33
|
/**
|
|
2
34
|
* Maps normalized reference fields to a catalog row.
|
|
3
35
|
* When `strict` is true (CDA sync), incomplete rows return null. When false (CMA upsert), falls back to entry id.
|
|
4
36
|
*/
|
|
5
37
|
export function buildReferenceRecord(contentType, id, updatedAt, fields, opts = {}) {
|
|
6
38
|
const strict = opts.strict ?? true;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return null;
|
|
12
|
-
return { id, contentType, slug: null, label: id, updatedAt };
|
|
13
|
-
}
|
|
14
|
-
return { id, contentType, slug: null, label: String(labelRaw), updatedAt };
|
|
15
|
-
}
|
|
16
|
-
const slug = fields.slug != null ? String(fields.slug) : null;
|
|
17
|
-
const labelRaw = fields.name ?? fields.title ?? fields.cmsLabel;
|
|
18
|
-
if (!slug && !labelRaw) {
|
|
39
|
+
const labelRaw = catalogLabel(contentType, fields);
|
|
40
|
+
const slugRaw = fields.slug != null ? normalizeSlug(String(fields.slug)) : null;
|
|
41
|
+
const cmsLabel = catalogCmsLabel(contentType, fields);
|
|
42
|
+
if (!labelRaw && !slugRaw && !cmsLabel) {
|
|
19
43
|
if (strict)
|
|
20
44
|
return null;
|
|
21
|
-
return {
|
|
45
|
+
return {
|
|
46
|
+
id,
|
|
47
|
+
contentType,
|
|
48
|
+
slug: null,
|
|
49
|
+
label: id,
|
|
50
|
+
cmsLabel: null,
|
|
51
|
+
updatedAt,
|
|
52
|
+
tagTypeSlug: opts.tagTypeSlug ?? null,
|
|
53
|
+
articleTypeSlug: opts.articleTypeSlug ?? null,
|
|
54
|
+
};
|
|
22
55
|
}
|
|
23
56
|
return {
|
|
24
57
|
id,
|
|
25
58
|
contentType,
|
|
26
|
-
slug,
|
|
27
|
-
label: String(labelRaw ??
|
|
59
|
+
slug: slugRaw,
|
|
60
|
+
label: String(labelRaw ?? slugRaw ?? cmsLabel ?? id),
|
|
61
|
+
cmsLabel,
|
|
28
62
|
updatedAt,
|
|
63
|
+
tagTypeSlug: opts.tagTypeSlug ?? null,
|
|
64
|
+
articleTypeSlug: opts.articleTypeSlug ?? null,
|
|
29
65
|
};
|
|
30
66
|
}
|
|
31
67
|
/** Reads locale-keyed CMA fields into {@link ReferenceFieldValues}. */
|
|
@@ -42,17 +78,22 @@ export function referenceFieldValuesFromCma(fields, locale) {
|
|
|
42
78
|
adminLabel: pick('adminLabel'),
|
|
43
79
|
};
|
|
44
80
|
}
|
|
45
|
-
export function referenceRowFromCmaEntry(contentType, entry, locale) {
|
|
81
|
+
export function referenceRowFromCmaEntry(contentType, entry, locale, parentSlugs) {
|
|
46
82
|
const fieldValues = referenceFieldValuesFromCma(entry.fields, locale);
|
|
47
83
|
const row = buildReferenceRecord(contentType, entry.sys.id, entry.sys.updatedAt, fieldValues, {
|
|
48
84
|
strict: false,
|
|
85
|
+
tagTypeSlug: parentSlugs?.tagTypeSlug ?? null,
|
|
86
|
+
articleTypeSlug: parentSlugs?.articleTypeSlug ?? null,
|
|
49
87
|
});
|
|
50
88
|
return (row ?? {
|
|
51
89
|
id: entry.sys.id,
|
|
52
90
|
contentType,
|
|
53
91
|
slug: null,
|
|
54
92
|
label: entry.sys.id,
|
|
93
|
+
cmsLabel: null,
|
|
55
94
|
updatedAt: entry.sys.updatedAt,
|
|
95
|
+
tagTypeSlug: parentSlugs?.tagTypeSlug ?? null,
|
|
96
|
+
articleTypeSlug: parentSlugs?.articleTypeSlug ?? null,
|
|
56
97
|
});
|
|
57
98
|
}
|
|
58
99
|
//# sourceMappingURL=reference-record.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reference-record.js","sourceRoot":"","sources":["../../src/contentful/reference-record.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"reference-record.js","sourceRoot":"","sources":["../../src/contentful/reference-record.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AA2B3C,SAAS,YAAY,CACnB,WAA+B,EAC/B,MAA4B;IAE5B,IAAI,WAAW,KAAK,UAAU,EAAE,CAAC;QA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,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Content types commonly resolved
|
|
1
|
+
/** Content types commonly resolved via flat `cms-edit resolve --*-slug` flags. */
|
|
2
2
|
export declare const RESOLVE_BY_SLUG_CONTENT_TYPES: readonly ["page", "article", "articleType", "tagType", "tag"];
|
|
3
3
|
export type ResolveBySlugContentType = (typeof RESOLVE_BY_SLUG_CONTENT_TYPES)[number];
|
|
4
4
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-content-type.d.ts","sourceRoot":"","sources":["../../src/contentful/resolve-content-type.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"resolve-content-type.d.ts","sourceRoot":"","sources":["../../src/contentful/resolve-content-type.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,eAAO,MAAM,6BAA6B,+DAMhC,CAAC;AAEX,MAAM,MAAM,wBAAwB,GAAG,CAAC,OAAO,6BAA6B,CAAC,CAAC,MAAM,CAAC,CAAC;AAYtF;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,MAAM,GAAG,wBAAwB,CAoBlF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-content-type.js","sourceRoot":"","sources":["../../src/contentful/resolve-content-type.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"resolve-content-type.js","sourceRoot":"","sources":["../../src/contentful/resolve-content-type.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,MAAM,CAAC,MAAM,6BAA6B,GAAG;IAC3C,MAAM;IACN,SAAS;IACT,aAAa;IACb,SAAS;IACT,KAAK;CACG,CAAC;AAIX,MAAM,OAAO,GAA6C;IACxD,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,SAAS;IAClB,WAAW,EAAE,aAAa;IAC1B,cAAc,EAAE,aAAa;IAC7B,OAAO,EAAE,SAAS;IAClB,UAAU,EAAE,SAAS;IACrB,GAAG,EAAE,KAAK;CACX,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,2BAA2B,CAAC,IAAY;IACtD,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;IAC5B,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;IAC/C,CAAC;IAED,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;IAC7C,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC,EAAE,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;IAC/E,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC;IAC/C,IAAI,SAAS,EAAE,CAAC;QACd,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,IAAI,KAAK,CACb,mBAAmB,OAAO,kBAAkB,6BAA6B,CAAC,IAAI,CAAC,IAAI,CAAC,sDAAsD,CAC3I,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** RE2-compatible slug pattern (matches Contentful field validation). */
|
|
2
|
+
export declare const SLUG_REGEXP_PATTERN = "^[^/]+(?:\\/[^/]+)*$";
|
|
3
|
+
export declare const SLUG_VALIDATION_MESSAGE = "Slug must not start or end with /. Use one or more segments separated by / (e.g. part1, part1/part2, or part1/part2/part3). Home page slug is \"index\".";
|
|
4
|
+
export declare function isSlugFieldId(fieldId: string): boolean;
|
|
5
|
+
/** Returns an error message when invalid, or null when the value matches the slug format. */
|
|
6
|
+
export declare function validateSlugFieldValue(value: string): string | null;
|
|
7
|
+
//# sourceMappingURL=slug-validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slug-validation.d.ts","sourceRoot":"","sources":["../../src/contentful/slug-validation.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,eAAO,MAAM,mBAAmB,yBAAyB,CAAC;AAE1D,eAAO,MAAM,uBAAuB,6JACsH,CAAC;AAI3J,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEtD;AAED,6FAA6F;AAC7F,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAKnE"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** RE2-compatible slug pattern (matches Contentful field validation). */
|
|
2
|
+
export const SLUG_REGEXP_PATTERN = '^[^/]+(?:\\/[^/]+)*$';
|
|
3
|
+
export const SLUG_VALIDATION_MESSAGE = 'Slug must not start or end with /. Use one or more segments separated by / (e.g. part1, part1/part2, or part1/part2/part3). Home page slug is "index".';
|
|
4
|
+
const SLUG_REGEXP = new RegExp(SLUG_REGEXP_PATTERN);
|
|
5
|
+
export function isSlugFieldId(fieldId) {
|
|
6
|
+
return fieldId === 'slug' || fieldId === 'indexPageSlug';
|
|
7
|
+
}
|
|
8
|
+
/** Returns an error message when invalid, or null when the value matches the slug format. */
|
|
9
|
+
export function validateSlugFieldValue(value) {
|
|
10
|
+
if (SLUG_REGEXP.test(value)) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
return SLUG_VALIDATION_MESSAGE;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=slug-validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slug-validation.js","sourceRoot":"","sources":["../../src/contentful/slug-validation.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,MAAM,CAAC,MAAM,mBAAmB,GAAG,sBAAsB,CAAC;AAE1D,MAAM,CAAC,MAAM,uBAAuB,GAClC,wJAAwJ,CAAC;AAE3J,MAAM,WAAW,GAAG,IAAI,MAAM,CAAC,mBAAmB,CAAC,CAAC;AAEpD,MAAM,UAAU,aAAa,CAAC,OAAe;IAC3C,OAAO,OAAO,KAAK,MAAM,IAAI,OAAO,KAAK,eAAe,CAAC;AAC3D,CAAC;AAED,6FAA6F;AAC7F,MAAM,UAAU,sBAAsB,CAAC,KAAa;IAClD,IAAI,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,uBAAuB,CAAC;AACjC,CAAC"}
|
|
@@ -1,2 +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| `cms_edit_index_sync` | Build/refresh local index (assets, media, templates, taxonomy) |\n| `cms_edit_create_page` | Create a page with template selection |\n| `cms_edit_taxonomy` | Import or ensure taxonomy entries |\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### Refresh local index (assets, media, templates, taxonomy)\n\nRun before asset filename search, media-by-filename list, or fast template/taxonomy lookup:\n\n```\n[\"index\", \"sync\"]\n[\"index\", \"status\"]\n[\"list\", \"--type\", \"template\"]\n```\n\nAsset search and media-by-filename list **require** the index. Template/taxonomy list prefers the index when built.\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\", \"
|
|
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| `cms_edit_index_sync` | Build/refresh local index (assets, media, templates, taxonomy) |\n| `cms_edit_create_page` | Create a page with template selection |\n| `cms_edit_taxonomy` | Import or ensure taxonomy entries |\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### Refresh local index (assets, media, templates, taxonomy)\n\nRun before asset filename search, media-by-filename list, or fast template/taxonomy lookup:\n\n```\n[\"index\", \"sync\"]\n[\"index\", \"status\"]\n[\"list\", \"--type\", \"template\"]\n```\n\nAsset search and media-by-filename list **require** the index. Template/taxonomy list prefers the index when built.\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\", \"--page-slug\", \"/\"]` then `[\"read\", \"@c0\"]` |\n| Preview tree + fields, no session | `[\"peek\", \"--page-slug\", \"/pricing\"]` or `[\"peek\", \"--id\", \"<entry-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- **Use flat lookup flags** for `open` and `peek` \u2014 same as CLI (`--page-slug`, `--id`, etc.). See `help lookup`.\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>`, `index sync`, `index status`\n\n**Reading:** `open --page-slug <slug>`, `open --id <id>`, `peek --page-slug <slug>`, `peek --id <id>`, `snapshot`, `read <ref>`, `read <ref> <field>`, `read <id> --id [field]`\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
2
|
//# sourceMappingURL=hosted-guide.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hosted-guide.d.ts","sourceRoot":"","sources":["../../src/generated/hosted-guide.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,qBAAqB,
|
|
1
|
+
{"version":3,"file":"hosted-guide.d.ts","sourceRoot":"","sources":["../../src/generated/hosted-guide.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,qBAAqB,m4MAA+xM,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
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| `cms_edit_index_sync` | Build/refresh local index (assets, media, templates, taxonomy) |\n| `cms_edit_create_page` | Create a page with template selection |\n| `cms_edit_taxonomy` | Import or ensure taxonomy entries |\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### Refresh local index (assets, media, templates, taxonomy)\n\nRun before asset filename search, media-by-filename list, or fast template/taxonomy lookup:\n\n```\n[\"index\", \"sync\"]\n[\"index\", \"status\"]\n[\"list\", \"--type\", \"template\"]\n```\n\nAsset search and media-by-filename list **require** the index. Template/taxonomy list prefers the index when built.\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\", \"
|
|
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| `cms_edit_index_sync` | Build/refresh local index (assets, media, templates, taxonomy) |\n| `cms_edit_create_page` | Create a page with template selection |\n| `cms_edit_taxonomy` | Import or ensure taxonomy entries |\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### Refresh local index (assets, media, templates, taxonomy)\n\nRun before asset filename search, media-by-filename list, or fast template/taxonomy lookup:\n\n```\n[\"index\", \"sync\"]\n[\"index\", \"status\"]\n[\"list\", \"--type\", \"template\"]\n```\n\nAsset search and media-by-filename list **require** the index. Template/taxonomy list prefers the index when built.\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\", \"--page-slug\", \"/\"]` then `[\"read\", \"@c0\"]` |\n| Preview tree + fields, no session | `[\"peek\", \"--page-slug\", \"/pricing\"]` or `[\"peek\", \"--id\", \"<entry-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- **Use flat lookup flags** for `open` and `peek` — same as CLI (`--page-slug`, `--id`, etc.). See `help lookup`.\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>`, `index sync`, `index status`\n\n**Reading:** `open --page-slug <slug>`, `open --id <id>`, `peek --page-slug <slug>`, `peek --id <id>`, `snapshot`, `read <ref>`, `read <ref> <field>`, `read <id> --id [field]`\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
3
|
//# sourceMappingURL=hosted-guide.js.map
|
|
@@ -1 +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,
|
|
1
|
+
{"version":3,"file":"hosted-guide.js","sourceRoot":"","sources":["../../src/generated/hosted-guide.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,MAAM,CAAC,MAAM,qBAAqB,GAAG,4xMAA4xM,CAAC"}
|
package/dist/index/db.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/index/db.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG3C,MAAM,MAAM,oBAAoB,GAAG,YAAY,CAAC;AAEhD,oDAAoD;AACpD,MAAM,MAAM,kBAAkB,GAAG,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/index/db.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG3C,MAAM,MAAM,oBAAoB,GAAG,YAAY,CAAC;AAEhD,oDAAoD;AACpD,MAAM,MAAM,kBAAkB,GAAG,oBAAoB,CAAC;AA2BtD,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,GAC7B,oBAAoB,CAMtB;AAED,6EAA6E;AAC7E,wBAAgB,sBAAsB,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,CAS7D;AAED,wBAAgB,OAAO,CAAC,EAAE,EAAE,oBAAoB,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAK5E;AAED,wBAAgB,OAAO,CAAC,EAAE,EAAE,oBAAoB,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAIlF"}
|
package/dist/index/db.js
CHANGED
|
@@ -1,8 +1,25 @@
|
|
|
1
1
|
import { DatabaseSync } from 'node:sqlite';
|
|
2
2
|
import { DDL } from './schema.js';
|
|
3
|
+
function migrateReferenceEntriesTable(db) {
|
|
4
|
+
const columns = db.prepare('PRAGMA table_info(reference_entries)').all();
|
|
5
|
+
const names = new Set(columns.map((c) => c.name));
|
|
6
|
+
if (!names.has('cmsLabel')) {
|
|
7
|
+
db.exec('ALTER TABLE reference_entries ADD COLUMN cmsLabel TEXT');
|
|
8
|
+
}
|
|
9
|
+
if (!names.has('tagTypeSlug')) {
|
|
10
|
+
db.exec('ALTER TABLE reference_entries ADD COLUMN tagTypeSlug TEXT');
|
|
11
|
+
}
|
|
12
|
+
if (!names.has('articleTypeSlug')) {
|
|
13
|
+
db.exec('ALTER TABLE reference_entries ADD COLUMN articleTypeSlug TEXT');
|
|
14
|
+
}
|
|
15
|
+
db.exec('CREATE INDEX IF NOT EXISTS idx_ref_type_cms_label ON reference_entries(contentType, cmsLabel)');
|
|
16
|
+
db.exec('CREATE INDEX IF NOT EXISTS idx_ref_tag_type_slug ON reference_entries(contentType, tagTypeSlug)');
|
|
17
|
+
db.exec('CREATE INDEX IF NOT EXISTS idx_ref_article_type_slug ON reference_entries(contentType, articleTypeSlug)');
|
|
18
|
+
}
|
|
3
19
|
export function openIndexDatabase(dbPath, options) {
|
|
4
20
|
const db = new DatabaseSync(options?.memory ? ':memory:' : dbPath);
|
|
5
21
|
db.exec(DDL);
|
|
22
|
+
migrateReferenceEntriesTable(db);
|
|
6
23
|
registerRegexpFunction(db);
|
|
7
24
|
return db;
|
|
8
25
|
}
|
package/dist/index/db.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db.js","sourceRoot":"","sources":["../../src/index/db.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAOlC,MAAM,UAAU,iBAAiB,CAC/B,MAAc,EACd,OAA8B;IAE9B,MAAM,EAAE,GAAG,IAAI,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IACnE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACb,sBAAsB,CAAC,EAAE,CAAC,CAAC;IAC3B,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,sBAAsB,CAAC,EAAgB;IACrD,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE,aAAa,EAAE,IAAI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,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACjE,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,CAAC,CAAC;QACX,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,EAAwB,EAAE,GAAW;IAC3D,MAAM,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,sCAAsC,CAAC,CAAC,GAAG,CAAC,GAAG,CAEzD,CAAC;IACd,OAAO,GAAG,EAAE,KAAK,IAAI,IAAI,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,EAAwB,EAAE,GAAW,EAAE,KAAa;IAC1E,EAAE,CAAC,OAAO,CACR,mGAAmG,CACpG,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AACpB,CAAC"}
|
package/dist/index/query.d.ts
CHANGED
|
@@ -77,7 +77,10 @@ export interface ReferenceEntryRow {
|
|
|
77
77
|
contentType: string;
|
|
78
78
|
slug: string | null;
|
|
79
79
|
label: string;
|
|
80
|
+
cmsLabel: string | null;
|
|
80
81
|
updatedAt: string;
|
|
82
|
+
tagTypeSlug: string | null;
|
|
83
|
+
articleTypeSlug: string | null;
|
|
81
84
|
}
|
|
82
85
|
/** Ensures index lookup rows refer to a single entry; throws on duplicate slug/label matches. */
|
|
83
86
|
export declare function assertUniqueReferenceRows(rows: ReferenceEntryRow[], message: string): ReferenceEntryRow;
|
|
@@ -85,12 +88,20 @@ export declare function listReferencesBySlug(space: SpaceConfig, contentType: st
|
|
|
85
88
|
export declare function listReferencesByLabel(space: SpaceConfig, contentType: string, label: string, preview?: boolean): ReferenceEntryRow[];
|
|
86
89
|
export declare function findReferenceBySlug(space: SpaceConfig, contentType: string, slug: string, preview?: boolean): ReferenceEntryRow | null;
|
|
87
90
|
export declare function findReferenceByLabel(space: SpaceConfig, contentType: string, label: string, preview?: boolean): ReferenceEntryRow | null;
|
|
88
|
-
export declare function
|
|
91
|
+
export declare function listReferencesByCmsLabel(space: SpaceConfig, contentType: string, cmsLabel: string, preview?: boolean): ReferenceEntryRow[];
|
|
92
|
+
export declare function findReferenceByCmsLabel(space: SpaceConfig, contentType: string, cmsLabel: string, preview?: boolean): ReferenceEntryRow | null;
|
|
93
|
+
export interface ListReferenceEntriesOptions {
|
|
89
94
|
preview?: boolean;
|
|
90
95
|
limit?: number;
|
|
91
96
|
slug?: string;
|
|
92
97
|
label?: string;
|
|
93
|
-
|
|
98
|
+
cmsLabel?: string;
|
|
99
|
+
tagTypeSlug?: string;
|
|
100
|
+
tagTypeName?: string;
|
|
101
|
+
articleTypeSlug?: string;
|
|
102
|
+
articleTypeName?: string;
|
|
103
|
+
}
|
|
104
|
+
export declare function listReferenceEntries(space: SpaceConfig, contentType: string, opts?: ListReferenceEntriesOptions): ReferenceEntryRow[];
|
|
94
105
|
export declare function countReferenceEntries(space: SpaceConfig, contentType?: string, preview?: boolean): number;
|
|
95
106
|
export declare function referenceContentTypeCounts(space: SpaceConfig, preview?: boolean): Array<{
|
|
96
107
|
contentType: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/index/query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAO5D,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAkDD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,WAAW,EAAE,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AE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,WAAW,EAClB,WAAW,EAAE,MAAM,EACnB,IAAI,GAAE,2BAAgC,GACrC,iBAAiB,EAAE,CAoFrB;AAED,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,WAAW,EAClB,WAAW,CAAC,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE,OAAO,GAChB,MAAM,CAaR;AAED,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,WAAW,EAClB,OAAO,CAAC,EAAE,OAAO,GAChB,KAAK,CAAC;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAQ/C;AAED,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,WAAW,EAClB,IAAI,GAAE;IACJ,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACV,GACL,iBAAiB,EAAE,CA8BrB"}
|
package/dist/index/query.js
CHANGED
|
@@ -213,6 +213,7 @@ export function auditMissingAlt(space, opts = {}) {
|
|
|
213
213
|
return { checked: rows.length, missing };
|
|
214
214
|
});
|
|
215
215
|
}
|
|
216
|
+
const REFERENCE_ROW_SELECT = 'id, contentType, slug, label, cmsLabel, updatedAt, tagTypeSlug, articleTypeSlug';
|
|
216
217
|
/** Ensures index lookup rows refer to a single entry; throws on duplicate slug/label matches. */
|
|
217
218
|
export function assertUniqueReferenceRows(rows, message) {
|
|
218
219
|
if (rows.length === 0) {
|
|
@@ -235,14 +236,14 @@ export function listReferencesBySlug(space, contentType, slug, preview) {
|
|
|
235
236
|
return withIndexDb(space, preview, (db) => {
|
|
236
237
|
const placeholders = variants.map(() => '?').join(',');
|
|
237
238
|
return db
|
|
238
|
-
.prepare(`SELECT
|
|
239
|
+
.prepare(`SELECT ${REFERENCE_ROW_SELECT} FROM reference_entries WHERE contentType = ? AND slug IN (${placeholders}) ORDER BY label`)
|
|
239
240
|
.all(contentType, ...variants);
|
|
240
241
|
});
|
|
241
242
|
}
|
|
242
243
|
export function listReferencesByLabel(space, contentType, label, preview) {
|
|
243
244
|
return withIndexDb(space, preview, (db) => {
|
|
244
245
|
return db
|
|
245
|
-
.prepare(`SELECT
|
|
246
|
+
.prepare(`SELECT ${REFERENCE_ROW_SELECT} FROM reference_entries WHERE contentType = ? AND label = ? COLLATE NOCASE ORDER BY label`)
|
|
246
247
|
.all(contentType, label.trim());
|
|
247
248
|
});
|
|
248
249
|
}
|
|
@@ -256,10 +257,32 @@ export function findReferenceByLabel(space, contentType, label, preview) {
|
|
|
256
257
|
const rows = listReferencesByLabel(space, contentType, label, preview);
|
|
257
258
|
if (rows.length === 0)
|
|
258
259
|
return null;
|
|
259
|
-
const fieldName = contentType === 'template'
|
|
260
|
+
const fieldName = contentType === 'template' || contentType === 'page' || contentType === 'article'
|
|
261
|
+
? 'title/cmsLabel'
|
|
262
|
+
: 'name/title';
|
|
260
263
|
return assertUniqueReferenceRows(rows, `Multiple ${contentType} entries share ${fieldName} "${label}" in the local index.`);
|
|
261
264
|
}
|
|
265
|
+
export function listReferencesByCmsLabel(space, contentType, cmsLabel, preview) {
|
|
266
|
+
return withIndexDb(space, preview, (db) => {
|
|
267
|
+
return db
|
|
268
|
+
.prepare(`SELECT ${REFERENCE_ROW_SELECT} FROM reference_entries WHERE contentType = ? AND cmsLabel = ? ORDER BY label`)
|
|
269
|
+
.all(contentType, cmsLabel.trim());
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
export function findReferenceByCmsLabel(space, contentType, cmsLabel, preview) {
|
|
273
|
+
const rows = listReferencesByCmsLabel(space, contentType, cmsLabel, preview);
|
|
274
|
+
if (rows.length === 0)
|
|
275
|
+
return null;
|
|
276
|
+
return assertUniqueReferenceRows(rows, `Multiple ${contentType} entries share cmsLabel "${cmsLabel}" in the local index.`);
|
|
277
|
+
}
|
|
262
278
|
export function listReferenceEntries(space, contentType, opts = {}) {
|
|
279
|
+
const cmsLabelFilter = opts.cmsLabel?.trim();
|
|
280
|
+
if (cmsLabelFilter) {
|
|
281
|
+
const rows = listReferencesByCmsLabel(space, contentType, cmsLabelFilter, opts.preview);
|
|
282
|
+
if (opts.limit !== undefined)
|
|
283
|
+
return rows.slice(0, opts.limit);
|
|
284
|
+
return rows;
|
|
285
|
+
}
|
|
263
286
|
const labelFilter = opts.label?.trim() ?? (contentType === 'template' ? opts.slug?.trim() : undefined);
|
|
264
287
|
if (labelFilter) {
|
|
265
288
|
const rows = listReferencesByLabel(space, contentType, labelFilter, opts.preview);
|
|
@@ -276,8 +299,42 @@ export function listReferenceEntries(space, contentType, opts = {}) {
|
|
|
276
299
|
return withIndexDb(space, opts.preview, (db) => {
|
|
277
300
|
const conditions = ['contentType = ?'];
|
|
278
301
|
const params = [contentType];
|
|
302
|
+
if (opts.tagTypeSlug) {
|
|
303
|
+
conditions.push('tagTypeSlug = ?');
|
|
304
|
+
params.push(normalizeSlug(opts.tagTypeSlug));
|
|
305
|
+
}
|
|
306
|
+
else if (opts.tagTypeName) {
|
|
307
|
+
const parent = db
|
|
308
|
+
.prepare(`SELECT slug FROM reference_entries WHERE contentType = 'tagType' AND label = ? COLLATE NOCASE LIMIT 2`)
|
|
309
|
+
.all(opts.tagTypeName.trim());
|
|
310
|
+
if (parent.length > 1) {
|
|
311
|
+
throw new ReferenceCatalogAmbiguityError(`Multiple tagType entries share name "${opts.tagTypeName}" in the local index.`, []);
|
|
312
|
+
}
|
|
313
|
+
if (parent.length === 0 || !parent[0]?.slug) {
|
|
314
|
+
return [];
|
|
315
|
+
}
|
|
316
|
+
conditions.push('tagTypeSlug = ?');
|
|
317
|
+
params.push(parent[0].slug);
|
|
318
|
+
}
|
|
319
|
+
if (opts.articleTypeSlug) {
|
|
320
|
+
conditions.push('articleTypeSlug = ?');
|
|
321
|
+
params.push(normalizeSlug(opts.articleTypeSlug));
|
|
322
|
+
}
|
|
323
|
+
else if (opts.articleTypeName) {
|
|
324
|
+
const parent = db
|
|
325
|
+
.prepare(`SELECT slug FROM reference_entries WHERE contentType = 'articleType' AND label = ? COLLATE NOCASE LIMIT 2`)
|
|
326
|
+
.all(opts.articleTypeName.trim());
|
|
327
|
+
if (parent.length > 1) {
|
|
328
|
+
throw new ReferenceCatalogAmbiguityError(`Multiple articleType entries share name "${opts.articleTypeName}" in the local index.`, []);
|
|
329
|
+
}
|
|
330
|
+
if (parent.length === 0 || !parent[0]?.slug) {
|
|
331
|
+
return [];
|
|
332
|
+
}
|
|
333
|
+
conditions.push('articleTypeSlug = ?');
|
|
334
|
+
params.push(parent[0].slug);
|
|
335
|
+
}
|
|
279
336
|
let sql = `
|
|
280
|
-
SELECT
|
|
337
|
+
SELECT ${REFERENCE_ROW_SELECT}
|
|
281
338
|
FROM reference_entries
|
|
282
339
|
WHERE ${conditions.join(' AND ')}
|
|
283
340
|
ORDER BY label
|
|
@@ -319,7 +376,7 @@ export function listReferencesForDump(space, opts = {}) {
|
|
|
319
376
|
}
|
|
320
377
|
const where = conditions.length > 0 ? `WHERE ${conditions.join(' AND ')}` : '';
|
|
321
378
|
let sql = `
|
|
322
|
-
SELECT
|
|
379
|
+
SELECT ${REFERENCE_ROW_SELECT}
|
|
323
380
|
FROM reference_entries
|
|
324
381
|
${where}
|
|
325
382
|
ORDER BY contentType, label
|