@se-studio/contentful-cms 1.0.1
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 +15 -0
- package/README.md +519 -0
- package/dist/bin/cms-edit.d.ts +4 -0
- package/dist/bin/cms-edit.d.ts.map +1 -0
- package/dist/bin/cms-edit.js +101 -0
- package/dist/bin/cms-edit.js.map +1 -0
- package/dist/commands/add.d.ts +4 -0
- package/dist/commands/add.d.ts.map +1 -0
- package/dist/commands/add.js +166 -0
- package/dist/commands/add.js.map +1 -0
- package/dist/commands/asset.d.ts +4 -0
- package/dist/commands/asset.d.ts.map +1 -0
- package/dist/commands/asset.js +110 -0
- package/dist/commands/asset.js.map +1 -0
- package/dist/commands/colours.d.ts +4 -0
- package/dist/commands/colours.d.ts.map +1 -0
- package/dist/commands/colours.js +91 -0
- package/dist/commands/colours.js.map +1 -0
- package/dist/commands/create.d.ts +4 -0
- package/dist/commands/create.d.ts.map +1 -0
- package/dist/commands/create.js +223 -0
- package/dist/commands/create.js.map +1 -0
- package/dist/commands/diff.d.ts +4 -0
- package/dist/commands/diff.d.ts.map +1 -0
- package/dist/commands/diff.js +141 -0
- package/dist/commands/diff.js.map +1 -0
- package/dist/commands/discard.d.ts +4 -0
- package/dist/commands/discard.d.ts.map +1 -0
- package/dist/commands/discard.js +36 -0
- package/dist/commands/discard.js.map +1 -0
- package/dist/commands/entry-search.d.ts +4 -0
- package/dist/commands/entry-search.d.ts.map +1 -0
- package/dist/commands/entry-search.js +81 -0
- package/dist/commands/entry-search.js.map +1 -0
- package/dist/commands/export-converted.d.ts +8 -0
- package/dist/commands/export-converted.d.ts.map +1 -0
- package/dist/commands/export-converted.js +62 -0
- package/dist/commands/export-converted.js.map +1 -0
- package/dist/commands/links.d.ts +4 -0
- package/dist/commands/links.d.ts.map +1 -0
- package/dist/commands/links.js +255 -0
- package/dist/commands/links.js.map +1 -0
- package/dist/commands/list.d.ts +4 -0
- package/dist/commands/list.d.ts.map +1 -0
- package/dist/commands/list.js +91 -0
- package/dist/commands/list.js.map +1 -0
- package/dist/commands/move.d.ts +3 -0
- package/dist/commands/move.d.ts.map +1 -0
- package/dist/commands/move.js +84 -0
- package/dist/commands/move.js.map +1 -0
- package/dist/commands/nav.d.ts +4 -0
- package/dist/commands/nav.d.ts.map +1 -0
- package/dist/commands/nav.js +196 -0
- package/dist/commands/nav.js.map +1 -0
- package/dist/commands/open.d.ts +4 -0
- package/dist/commands/open.d.ts.map +1 -0
- package/dist/commands/open.js +74 -0
- package/dist/commands/open.js.map +1 -0
- package/dist/commands/read.d.ts +4 -0
- package/dist/commands/read.d.ts.map +1 -0
- package/dist/commands/read.js +102 -0
- package/dist/commands/read.js.map +1 -0
- package/dist/commands/remove.d.ts +4 -0
- package/dist/commands/remove.d.ts.map +1 -0
- package/dist/commands/remove.js +98 -0
- package/dist/commands/remove.js.map +1 -0
- package/dist/commands/rtf.d.ts +3 -0
- package/dist/commands/rtf.d.ts.map +1 -0
- package/dist/commands/rtf.js +131 -0
- package/dist/commands/rtf.js.map +1 -0
- package/dist/commands/save.d.ts +4 -0
- package/dist/commands/save.d.ts.map +1 -0
- package/dist/commands/save.js +59 -0
- package/dist/commands/save.js.map +1 -0
- package/dist/commands/screenshot.d.ts +4 -0
- package/dist/commands/screenshot.d.ts.map +1 -0
- package/dist/commands/screenshot.js +246 -0
- package/dist/commands/screenshot.js.map +1 -0
- package/dist/commands/set.d.ts +3 -0
- package/dist/commands/set.d.ts.map +1 -0
- package/dist/commands/set.js +152 -0
- package/dist/commands/set.js.map +1 -0
- package/dist/commands/skill.d.ts +4 -0
- package/dist/commands/skill.d.ts.map +1 -0
- package/dist/commands/skill.js +73 -0
- package/dist/commands/skill.js.map +1 -0
- package/dist/commands/snapshot.d.ts +3 -0
- package/dist/commands/snapshot.d.ts.map +1 -0
- package/dist/commands/snapshot.js +21 -0
- package/dist/commands/snapshot.js.map +1 -0
- package/dist/commands/types.d.ts +4 -0
- package/dist/commands/types.d.ts.map +1 -0
- package/dist/commands/types.js +78 -0
- package/dist/commands/types.js.map +1 -0
- package/dist/config/load.d.ts +14 -0
- package/dist/config/load.d.ts.map +1 -0
- package/dist/config/load.js +79 -0
- package/dist/config/load.js.map +1 -0
- package/dist/config/types.d.ts +13 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +2 -0
- package/dist/config/types.js.map +1 -0
- package/dist/contentful/assets.d.ts +20 -0
- package/dist/contentful/assets.d.ts.map +1 -0
- package/dist/contentful/assets.js +36 -0
- package/dist/contentful/assets.js.map +1 -0
- package/dist/contentful/client.d.ts +28 -0
- package/dist/contentful/client.d.ts.map +1 -0
- package/dist/contentful/client.js +30 -0
- package/dist/contentful/client.js.map +1 -0
- package/dist/contentful/fetch.d.ts +20 -0
- package/dist/contentful/fetch.d.ts.map +1 -0
- package/dist/contentful/fetch.js +154 -0
- package/dist/contentful/fetch.js.map +1 -0
- package/dist/contentful/references.d.ts +7 -0
- package/dist/contentful/references.d.ts.map +1 -0
- package/dist/contentful/references.js +12 -0
- package/dist/contentful/references.js.map +1 -0
- package/dist/contentful/write.d.ts +16 -0
- package/dist/contentful/write.d.ts.map +1 -0
- package/dist/contentful/write.js +75 -0
- package/dist/contentful/write.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/output/json.d.ts +47 -0
- package/dist/output/json.d.ts.map +1 -0
- package/dist/output/json.js +87 -0
- package/dist/output/json.js.map +1 -0
- package/dist/output/mode.d.ts +3 -0
- package/dist/output/mode.d.ts.map +1 -0
- package/dist/output/mode.js +16 -0
- package/dist/output/mode.js.map +1 -0
- package/dist/output/print.d.ts +14 -0
- package/dist/output/print.d.ts.map +1 -0
- package/dist/output/print.js +61 -0
- package/dist/output/print.js.map +1 -0
- package/dist/rtf/fromMarkdown.d.ts +19 -0
- package/dist/rtf/fromMarkdown.d.ts.map +1 -0
- package/dist/rtf/fromMarkdown.js +230 -0
- package/dist/rtf/fromMarkdown.js.map +1 -0
- package/dist/rtf/toMarkdown.d.ts +6 -0
- package/dist/rtf/toMarkdown.d.ts.map +1 -0
- package/dist/rtf/toMarkdown.js +105 -0
- package/dist/rtf/toMarkdown.js.map +1 -0
- package/dist/session/refs.d.ts +35 -0
- package/dist/session/refs.d.ts.map +1 -0
- package/dist/session/refs.js +128 -0
- package/dist/session/refs.js.map +1 -0
- package/dist/session/state.d.ts +91 -0
- package/dist/session/state.d.ts.map +1 -0
- package/dist/session/state.js +61 -0
- package/dist/session/state.js.map +1 -0
- package/dist/session/store.d.ts +10 -0
- package/dist/session/store.d.ts.map +1 -0
- package/dist/session/store.js +62 -0
- package/dist/session/store.js.map +1 -0
- package/dist/snapshot/render.d.ts +15 -0
- package/dist/snapshot/render.d.ts.map +1 -0
- package/dist/snapshot/render.js +166 -0
- package/dist/snapshot/render.js.map +1 -0
- package/dist/validation/allowed-types.d.ts +7 -0
- package/dist/validation/allowed-types.d.ts.map +1 -0
- package/dist/validation/allowed-types.js +16 -0
- package/dist/validation/allowed-types.js.map +1 -0
- package/package.json +61 -0
- package/skills/core/SKILL.md +483 -0
- package/skills/manifest.json +7 -0
- package/skills/navigation/SKILL.md +18 -0
- package/skills/rich-text/SKILL.md +23 -0
- package/skills/screenshots/SKILL.md +32 -0
- package/skills/templates/SKILL.md +16 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import contentfulManagement from 'contentful-management';
|
|
2
|
+
const { createClient } = contentfulManagement;
|
|
3
|
+
/**
|
|
4
|
+
* Creates a safe CMA environment wrapper for the given space config.
|
|
5
|
+
* The returned object only exposes methods that cannot publish or delete.
|
|
6
|
+
*/
|
|
7
|
+
export async function createSafeEnvironment(space) {
|
|
8
|
+
const client = createClient({ accessToken: space.managementToken });
|
|
9
|
+
const cmaSpace = await client.getSpace(space.spaceId);
|
|
10
|
+
const env = await cmaSpace.getEnvironment(space.environment);
|
|
11
|
+
return {
|
|
12
|
+
getEntry: (entryId) => env.getEntry(entryId),
|
|
13
|
+
getEntries: (query) => env.getEntries(query),
|
|
14
|
+
createEntry: async (contentTypeId, fields) => {
|
|
15
|
+
const entry = await env.createEntry(contentTypeId, { fields });
|
|
16
|
+
return entry;
|
|
17
|
+
},
|
|
18
|
+
getAssets: (query) => env.getAssets(query ?? {}),
|
|
19
|
+
getContentType: (contentTypeId) => env.getContentType(contentTypeId),
|
|
20
|
+
getContentTypes: () => env.getContentTypes(),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Saves an entry as a draft (never publishes).
|
|
25
|
+
* Requires the entry to have been fetched via getEntry so sys.version is current.
|
|
26
|
+
*/
|
|
27
|
+
export async function saveDraft(entry) {
|
|
28
|
+
return entry.update();
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/contentful/client.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,MAAM,uBAAuB,CAAC;AAGzD,MAAM,EAAE,YAAY,EAAE,GAAG,oBAAoB,CAAC;AAyC9C;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,KAAkB;IAC5D,MAAM,MAAM,GAAG,YAAY,CAAC,EAAE,WAAW,EAAE,KAAK,CAAC,eAAe,EAAE,CAAC,CAAC;IACpE,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACtD,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,cAAc,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAE7D,OAAO;QACL,QAAQ,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC;QAC5C,UAAU,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC;QAC5C,WAAW,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,EAAE;YAC3C,MAAM,KAAK,GAAG,MAAM,GAAG,CAAC,WAAW,CAAC,aAAa,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;YAC/D,OAAO,KAAK,CAAC;QACf,CAAC;QACD,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE,CAAC;QAChD,cAAc,EAAE,CAAC,aAAa,EAAE,EAAE,CAAC,GAAG,CAAC,cAAc,CAAC,aAAa,CAAC;QACpE,eAAe,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,eAAe,EAAE;KAC7C,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,KAA4C;IAE5C,OAAO,KAAK,CAAC,MAAM,EAAE,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Entry } from 'contentful-management';
|
|
2
|
+
import type { SerializedEntry } from '../session/state.js';
|
|
3
|
+
import type { SafeEnvironment } from './client.js';
|
|
4
|
+
/**
|
|
5
|
+
* Serializes a CMA Entry into the session's plain-object format.
|
|
6
|
+
*/
|
|
7
|
+
export declare function serializeEntry(entry: Entry): SerializedEntry;
|
|
8
|
+
/**
|
|
9
|
+
* Finds an entry by slug field. Searches across page, article, and navigation content types.
|
|
10
|
+
* Queries one content type at a time because the Management API does not allow field filters
|
|
11
|
+
* when querying multiple content types.
|
|
12
|
+
*/
|
|
13
|
+
export declare function findEntryBySlug(env: SafeEnvironment, slug: string, _locale: string): Promise<Entry | null>;
|
|
14
|
+
/**
|
|
15
|
+
* Fetches a full entry tree starting from a root entry ID.
|
|
16
|
+
* Returns all entries keyed by ID.
|
|
17
|
+
* Only resolves content array fields (not visual/asset fields).
|
|
18
|
+
*/
|
|
19
|
+
export declare function fetchEntryTree(env: SafeEnvironment, rootEntryId: string): Promise<Record<string, SerializedEntry>>;
|
|
20
|
+
//# sourceMappingURL=fetch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/contentful/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAMnD;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,eAAe,CAa5D;AAKD;;;;GAIG;AACH,wBAAsB,eAAe,CACnC,GAAG,EAAE,eAAe,EACpB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,CAiBvB;AAED;;;;GAIG;AACH,wBAAsB,cAAc,CAClC,GAAG,EAAE,eAAe,EACpB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,CA2B1C"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
const BATCH_SIZE = 100;
|
|
2
|
+
const CONTENT_FIELDS = ['topContent', 'content', 'bottomContent', 'contents'];
|
|
3
|
+
const LINKED_ENTRY_FIELDS = ['template', 'articleType', 'author'];
|
|
4
|
+
/**
|
|
5
|
+
* Serializes a CMA Entry into the session's plain-object format.
|
|
6
|
+
*/
|
|
7
|
+
export function serializeEntry(entry) {
|
|
8
|
+
return {
|
|
9
|
+
sys: {
|
|
10
|
+
id: entry.sys.id,
|
|
11
|
+
version: entry.sys.version,
|
|
12
|
+
publishedVersion: entry.sys.publishedVersion ?? undefined,
|
|
13
|
+
publishedAt: entry.sys.publishedAt ?? undefined,
|
|
14
|
+
contentType: { sys: { id: entry.sys.contentType.sys.id } },
|
|
15
|
+
createdAt: entry.sys.createdAt,
|
|
16
|
+
updatedAt: entry.sys.updatedAt,
|
|
17
|
+
},
|
|
18
|
+
fields: entry.fields,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/** Content types that have a slug field (navigation does not). */
|
|
22
|
+
const SLUG_CONTENT_TYPES = ['page', 'article'];
|
|
23
|
+
/**
|
|
24
|
+
* Finds an entry by slug field. Searches across page, article, and navigation content types.
|
|
25
|
+
* Queries one content type at a time because the Management API does not allow field filters
|
|
26
|
+
* when querying multiple content types.
|
|
27
|
+
*/
|
|
28
|
+
export async function findEntryBySlug(env, slug, _locale) {
|
|
29
|
+
const normalizedSlug = slug.startsWith('/') ? slug.slice(1) : slug;
|
|
30
|
+
const effectiveSlug = normalizedSlug === '' ? 'index' : normalizedSlug;
|
|
31
|
+
const slugVariants = [effectiveSlug, `/${effectiveSlug}`];
|
|
32
|
+
for (const contentType of SLUG_CONTENT_TYPES) {
|
|
33
|
+
for (const slugValue of slugVariants) {
|
|
34
|
+
const result = await env.getEntries({
|
|
35
|
+
content_type: contentType,
|
|
36
|
+
'fields.slug': slugValue,
|
|
37
|
+
limit: 1,
|
|
38
|
+
});
|
|
39
|
+
if (result.items.length > 0)
|
|
40
|
+
return result.items[0] ?? null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Fetches a full entry tree starting from a root entry ID.
|
|
47
|
+
* Returns all entries keyed by ID.
|
|
48
|
+
* Only resolves content array fields (not visual/asset fields).
|
|
49
|
+
*/
|
|
50
|
+
export async function fetchEntryTree(env, rootEntryId) {
|
|
51
|
+
const entries = {};
|
|
52
|
+
const toFetch = new Set([rootEntryId]);
|
|
53
|
+
const fetched = new Set();
|
|
54
|
+
while (toFetch.size > 0) {
|
|
55
|
+
const batch = Array.from(toFetch).slice(0, BATCH_SIZE);
|
|
56
|
+
for (const id of batch) {
|
|
57
|
+
toFetch.delete(id);
|
|
58
|
+
}
|
|
59
|
+
const result = await env.getEntries({ 'sys.id[in]': batch.join(','), limit: BATCH_SIZE });
|
|
60
|
+
for (const entry of result.items) {
|
|
61
|
+
const serialized = serializeEntry(entry);
|
|
62
|
+
entries[entry.sys.id] = serialized;
|
|
63
|
+
fetched.add(entry.sys.id);
|
|
64
|
+
const linkedIds = extractLinkedEntryIds(serialized);
|
|
65
|
+
for (const id of linkedIds) {
|
|
66
|
+
if (!fetched.has(id) && !toFetch.has(id)) {
|
|
67
|
+
toFetch.add(id);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return entries;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Extracts all linked entry IDs from an entry's content array fields and
|
|
76
|
+
* single-link fields (template, articleType, author).
|
|
77
|
+
* For template entries, also extracts from preContent, postContent (arrays)
|
|
78
|
+
* and menu, footer (single entry links).
|
|
79
|
+
*/
|
|
80
|
+
function extractLinkedEntryIds(entry) {
|
|
81
|
+
const ids = [];
|
|
82
|
+
const fields = entry.fields;
|
|
83
|
+
const ctId = entry.sys.contentType.sys.id;
|
|
84
|
+
for (const fieldId of CONTENT_FIELDS) {
|
|
85
|
+
const fieldData = fields[fieldId];
|
|
86
|
+
if (!fieldData)
|
|
87
|
+
continue;
|
|
88
|
+
for (const localeValue of Object.values(fieldData)) {
|
|
89
|
+
if (!Array.isArray(localeValue))
|
|
90
|
+
continue;
|
|
91
|
+
for (const item of localeValue) {
|
|
92
|
+
if (isEntryLink(item))
|
|
93
|
+
ids.push(item.sys.id);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
for (const fieldId of LINKED_ENTRY_FIELDS) {
|
|
98
|
+
const fieldData = fields[fieldId];
|
|
99
|
+
if (!fieldData)
|
|
100
|
+
continue;
|
|
101
|
+
for (const localeValue of Object.values(fieldData)) {
|
|
102
|
+
if (isEntryLink(localeValue))
|
|
103
|
+
ids.push(localeValue.sys.id);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (ctId === 'template') {
|
|
107
|
+
for (const fieldId of ['preContent', 'postContent']) {
|
|
108
|
+
const fieldData = fields[fieldId];
|
|
109
|
+
if (!fieldData)
|
|
110
|
+
continue;
|
|
111
|
+
for (const localeValue of Object.values(fieldData)) {
|
|
112
|
+
if (!Array.isArray(localeValue))
|
|
113
|
+
continue;
|
|
114
|
+
for (const item of localeValue) {
|
|
115
|
+
if (isEntryLink(item))
|
|
116
|
+
ids.push(item.sys.id);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
for (const fieldId of ['menu', 'footer']) {
|
|
121
|
+
const fieldData = fields[fieldId];
|
|
122
|
+
if (!fieldData)
|
|
123
|
+
continue;
|
|
124
|
+
for (const localeValue of Object.values(fieldData)) {
|
|
125
|
+
if (isEntryLink(localeValue))
|
|
126
|
+
ids.push(localeValue.sys.id);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (ctId === 'navigation') {
|
|
131
|
+
for (const fieldId of ['items', 'navigationItems']) {
|
|
132
|
+
const fieldData = fields[fieldId];
|
|
133
|
+
if (!fieldData)
|
|
134
|
+
continue;
|
|
135
|
+
for (const localeValue of Object.values(fieldData)) {
|
|
136
|
+
if (!Array.isArray(localeValue))
|
|
137
|
+
continue;
|
|
138
|
+
for (const item of localeValue) {
|
|
139
|
+
if (isEntryLink(item))
|
|
140
|
+
ids.push(item.sys.id);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return ids;
|
|
146
|
+
}
|
|
147
|
+
function isEntryLink(item) {
|
|
148
|
+
return (typeof item === 'object' &&
|
|
149
|
+
item !== null &&
|
|
150
|
+
'sys' in item &&
|
|
151
|
+
typeof item.sys === 'object' &&
|
|
152
|
+
item.sys.linkType === 'Entry');
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=fetch.js.map
|
|
@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AAC;oBAAE,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAC7D,CAAC;QACH,CAAC;IACH,CAAC;IAED,IAAI,IAAI,KAAK,YAAY,EAAE,CAAC;QAC1B,KAAK,MAAM,OAAO,IAAI,CAAC,OAAO,EAAE,iBAAiB,CAAU,EAAE,CAAC;YAC5D,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;YAClC,IAAI,CAAC,SAAS;gBAAE,SAAS;YACzB,KAAK,MAAM,WAAW,IAAI,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;gBACnD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC;oBAAE,SAAS;gBAC1C,KAAK,MAAM,IAAI,IAAI,WAAW,EAAE,CAAC;oBAC/B,IAAI,WAAW,CAAC,IAAI,CAAC;wBAAE,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;gBAC/C,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,WAAW,CAAC,IAAa;IAChC,OAAO,CACL,OAAO,IAAI,KAAK,QAAQ;QACxB,IAAI,KAAK,IAAI;QACb,KAAK,IAAI,IAAI;QACb,OAAQ,IAAyB,CAAC,GAAG,KAAK,QAAQ;QACjD,IAAuC,CAAC,GAAG,CAAC,QAAQ,KAAK,OAAO,CAClE,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SafeEnvironment } from './client.js';
|
|
2
|
+
/**
|
|
3
|
+
* Counts how many entries link to the given entry ID.
|
|
4
|
+
* Used to determine if it's safe to delete an entry when it's removed from a page.
|
|
5
|
+
*/
|
|
6
|
+
export declare function countInboundReferences(env: SafeEnvironment, entryId: string): Promise<number>;
|
|
7
|
+
//# sourceMappingURL=references.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"references.d.ts","sourceRoot":"","sources":["../../src/contentful/references.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD;;;GAGG;AACH,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,eAAe,EACpB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,CAAC,CAMjB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Counts how many entries link to the given entry ID.
|
|
3
|
+
* Used to determine if it's safe to delete an entry when it's removed from a page.
|
|
4
|
+
*/
|
|
5
|
+
export async function countInboundReferences(env, entryId) {
|
|
6
|
+
const result = await env.getEntries({
|
|
7
|
+
links_to_entry: entryId,
|
|
8
|
+
limit: 1,
|
|
9
|
+
});
|
|
10
|
+
return result.total;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=references.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"references.js","sourceRoot":"","sources":["../../src/contentful/references.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,GAAoB,EACpB,OAAe;IAEf,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,UAAU,CAAC;QAClC,cAAc,EAAE,OAAO;QACvB,KAAK,EAAE,CAAC;KACT,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,KAAK,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { SessionState } from '../session/state.js';
|
|
2
|
+
import type { SafeEnvironment } from './client.js';
|
|
3
|
+
/**
|
|
4
|
+
* Applies all local modifications to Contentful as drafts.
|
|
5
|
+
* Never publishes. Handles optimistic locking by fetching fresh versions.
|
|
6
|
+
*
|
|
7
|
+
* Returns a list of entry IDs that were successfully saved.
|
|
8
|
+
*/
|
|
9
|
+
export declare function applySessionPatches(env: SafeEnvironment, session: SessionState): Promise<{
|
|
10
|
+
saved: string[];
|
|
11
|
+
failed: Array<{
|
|
12
|
+
entryId: string;
|
|
13
|
+
error: string;
|
|
14
|
+
}>;
|
|
15
|
+
}>;
|
|
16
|
+
//# sourceMappingURL=write.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../../src/contentful/write.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmB,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAInD;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,eAAe,EACpB,OAAO,EAAE,YAAY,GACpB,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,CAAC,CAoDjF"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { saveDraft } from './client.js';
|
|
2
|
+
import { serializeEntry } from './fetch.js';
|
|
3
|
+
/**
|
|
4
|
+
* Applies all local modifications to Contentful as drafts.
|
|
5
|
+
* Never publishes. Handles optimistic locking by fetching fresh versions.
|
|
6
|
+
*
|
|
7
|
+
* Returns a list of entry IDs that were successfully saved.
|
|
8
|
+
*/
|
|
9
|
+
export async function applySessionPatches(env, session) {
|
|
10
|
+
const saved = [];
|
|
11
|
+
const failed = [];
|
|
12
|
+
for (const entryId of session.modifiedEntryIds) {
|
|
13
|
+
const localEntry = session.entries[entryId];
|
|
14
|
+
if (!localEntry)
|
|
15
|
+
continue;
|
|
16
|
+
try {
|
|
17
|
+
// Fetch the latest version from CMA for optimistic locking
|
|
18
|
+
const fresh = await env.getEntry(entryId);
|
|
19
|
+
// Apply our local field changes on top of the freshly fetched entry
|
|
20
|
+
mergeFields(fresh, localEntry, session.defaultLocale);
|
|
21
|
+
const updated = await saveDraft(fresh);
|
|
22
|
+
session.entries[entryId] = serializeEntry(updated);
|
|
23
|
+
saved.push(entryId);
|
|
24
|
+
}
|
|
25
|
+
catch (err) {
|
|
26
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
27
|
+
failed.push({
|
|
28
|
+
entryId,
|
|
29
|
+
error: message.includes('Version mismatch')
|
|
30
|
+
? `Version conflict on ${entryId} — the entry was modified by someone else. Re-open with "cms-edit open" to get the latest.`
|
|
31
|
+
: message,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
// Process pending deletions (only delete draft entries that aren't referenced elsewhere)
|
|
36
|
+
for (const entryId of session.pendingDeletions) {
|
|
37
|
+
try {
|
|
38
|
+
const fresh = await env.getEntry(entryId);
|
|
39
|
+
// Only delete if the entry has never been published
|
|
40
|
+
if (fresh.sys.publishedVersion) {
|
|
41
|
+
failed.push({
|
|
42
|
+
entryId,
|
|
43
|
+
error: `Entry ${entryId} is published and cannot be deleted via cms-edit. Unlink only — remove it manually in Contentful if needed.`,
|
|
44
|
+
});
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
await fresh.delete();
|
|
48
|
+
saved.push(entryId);
|
|
49
|
+
}
|
|
50
|
+
catch (err) {
|
|
51
|
+
failed.push({
|
|
52
|
+
entryId,
|
|
53
|
+
error: err instanceof Error ? err.message : String(err),
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return { saved, failed };
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Merges fields from a local serialized entry onto a fresh CMA entry.
|
|
61
|
+
* Only overwrites fields that differ from the original.
|
|
62
|
+
*/
|
|
63
|
+
function mergeFields(fresh, local, locale) {
|
|
64
|
+
for (const [fieldId, localeMap] of Object.entries(local.fields)) {
|
|
65
|
+
if (!fresh.fields[fieldId]) {
|
|
66
|
+
fresh.fields[fieldId] = {};
|
|
67
|
+
}
|
|
68
|
+
// Set the locale-specific value
|
|
69
|
+
const value = localeMap[locale] ?? localeMap['en-US'];
|
|
70
|
+
if (value !== undefined) {
|
|
71
|
+
fresh.fields[fieldId][locale] = value;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=write.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write.js","sourceRoot":"","sources":["../../src/contentful/write.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,GAAoB,EACpB,OAAqB;IAErB,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,MAAM,MAAM,GAA8C,EAAE,CAAC;IAE7D,KAAK,MAAM,OAAO,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;QAC/C,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC5C,IAAI,CAAC,UAAU;YAAE,SAAS;QAE1B,IAAI,CAAC;YACH,2DAA2D;YAC3D,MAAM,KAAK,GAAG,MAAM,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;YAE1C,oEAAoE;YACpE,WAAW,CAAC,KAAK,EAAE,UAAU,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;YAEtD,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,KAAK,CAAC,CAAC;YACvC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;YACnD,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACtB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAA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AC,OAAO,CAAC,EAAE,CAAC;YAC3B,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;QAC7B,CAAC;QACD,gCAAgC;QAChC,MAAM,KAAK,GAAG,SAAS,CAAC,MAAM,CAAC,IAAI,SAAS,CAAC,OAAO,CAAC,CAAC;QACtD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACvB,KAAK,CAAC,MAAM,CAAC,OAAO,CAA6B,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC;QACrE,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACpE,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { AssetSummary } from '../contentful/assets.js';
|
|
2
|
+
/**
|
|
3
|
+
* A minimal description of a CMA entry sys object used for JSON serialization.
|
|
4
|
+
* Compatible with both contentful-management Entry and SerializedEntry sys shapes.
|
|
5
|
+
*/
|
|
6
|
+
interface EntrySysForJson {
|
|
7
|
+
id: string;
|
|
8
|
+
contentType: {
|
|
9
|
+
sys: {
|
|
10
|
+
id: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
publishedVersion?: number | null;
|
|
14
|
+
updatedAt: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* JSON-serializable representation of a Contentful entry, as output by list/search --json.
|
|
18
|
+
*/
|
|
19
|
+
interface EntryJson {
|
|
20
|
+
id: string;
|
|
21
|
+
contentType: string;
|
|
22
|
+
title: string;
|
|
23
|
+
slug: string | null;
|
|
24
|
+
status: 'published' | 'draft';
|
|
25
|
+
updatedAt: string;
|
|
26
|
+
fields: Record<string, unknown>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Flattens a locale-keyed field map `{ fieldId: { locale: value } }` to the given locale,
|
|
30
|
+
* serializing link and RTF values into JSON-safe representations.
|
|
31
|
+
*/
|
|
32
|
+
export declare function entryFieldsToJson(fields: Record<string, Record<string, unknown>>, locale: string): Record<string, unknown>;
|
|
33
|
+
/**
|
|
34
|
+
* Converts a CMA entry (or SerializedEntry) to a full JSON-safe EntryJson object,
|
|
35
|
+
* including flattened fields.
|
|
36
|
+
*/
|
|
37
|
+
export declare function entryToJson(entry: {
|
|
38
|
+
sys: EntrySysForJson;
|
|
39
|
+
fields: Record<string, Record<string, unknown>>;
|
|
40
|
+
}, locale: string): EntryJson;
|
|
41
|
+
/**
|
|
42
|
+
* Converts an AssetSummary to a plain JSON-safe object.
|
|
43
|
+
* Undefined optional fields are normalized to null for stable output.
|
|
44
|
+
*/
|
|
45
|
+
export declare function assetSummaryToJson(summary: AssetSummary): Record<string, unknown>;
|
|
46
|
+
export {};
|
|
47
|
+
//# sourceMappingURL=json.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../src/output/json.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAG5D;;;GAGG;AACH,UAAU,eAAe;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE;QAAE,GAAG,EAAE;YAAE,EAAE,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAC;IACrC,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,UAAU,SAAS;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AA4CD;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAC/C,MAAM,EAAE,MAAM,GACb,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAOzB;AAED;;;GAGG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE;IAAE,GAAG,EAAE,eAAe,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;CAAE,EAChF,MAAM,EAAE,MAAM,GACb,SAAS,CAuBX;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAWjF"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { rtfToMarkdown } from '../rtf/toMarkdown.js';
|
|
2
|
+
/**
|
|
3
|
+
* Converts a single CMA-style field value (already locale-resolved) to a JSON-safe value.
|
|
4
|
+
*
|
|
5
|
+
* - Links become `{ id, linkType }` objects.
|
|
6
|
+
* - RTF documents become Markdown strings.
|
|
7
|
+
* - Arrays are recursively serialized.
|
|
8
|
+
* - All other values pass through.
|
|
9
|
+
*/
|
|
10
|
+
function serializeValue(value) {
|
|
11
|
+
if (value === null || value === undefined)
|
|
12
|
+
return null;
|
|
13
|
+
if (Array.isArray(value)) {
|
|
14
|
+
return value.map(serializeValue);
|
|
15
|
+
}
|
|
16
|
+
if (typeof value === 'object') {
|
|
17
|
+
const obj = value;
|
|
18
|
+
// Contentful link: { sys: { type: 'Link', linkType: 'Asset'|'Entry', id } }
|
|
19
|
+
if (obj['sys'] && typeof obj['sys'] === 'object') {
|
|
20
|
+
const sys = obj['sys'];
|
|
21
|
+
if (sys['type'] === 'Link' &&
|
|
22
|
+
typeof sys['id'] === 'string' &&
|
|
23
|
+
typeof sys['linkType'] === 'string') {
|
|
24
|
+
return { id: sys['id'], linkType: sys['linkType'] };
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
// RTF document
|
|
28
|
+
if (obj['nodeType'] === 'document') {
|
|
29
|
+
return rtfToMarkdown(value);
|
|
30
|
+
}
|
|
31
|
+
// Other plain objects — pass through as-is
|
|
32
|
+
return value;
|
|
33
|
+
}
|
|
34
|
+
return value;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Flattens a locale-keyed field map `{ fieldId: { locale: value } }` to the given locale,
|
|
38
|
+
* serializing link and RTF values into JSON-safe representations.
|
|
39
|
+
*/
|
|
40
|
+
export function entryFieldsToJson(fields, locale) {
|
|
41
|
+
const result = {};
|
|
42
|
+
for (const [fieldId, localeMap] of Object.entries(fields)) {
|
|
43
|
+
const value = localeMap[locale] ?? localeMap['en-US'];
|
|
44
|
+
result[fieldId] = serializeValue(value);
|
|
45
|
+
}
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Converts a CMA entry (or SerializedEntry) to a full JSON-safe EntryJson object,
|
|
50
|
+
* including flattened fields.
|
|
51
|
+
*/
|
|
52
|
+
export function entryToJson(entry, locale) {
|
|
53
|
+
const { fields, sys } = entry;
|
|
54
|
+
const title = String(fields['title']?.[locale] ??
|
|
55
|
+
fields['title']?.['en-US'] ??
|
|
56
|
+
fields['cmsLabel']?.[locale] ??
|
|
57
|
+
fields['cmsLabel']?.['en-US'] ??
|
|
58
|
+
sys.id);
|
|
59
|
+
const slugVal = fields['slug']?.[locale] ?? fields['slug']?.['en-US'];
|
|
60
|
+
const slug = typeof slugVal === 'string' ? slugVal : null;
|
|
61
|
+
return {
|
|
62
|
+
id: sys.id,
|
|
63
|
+
contentType: sys.contentType.sys.id,
|
|
64
|
+
title,
|
|
65
|
+
slug,
|
|
66
|
+
status: sys.publishedVersion ? 'published' : 'draft',
|
|
67
|
+
updatedAt: sys.updatedAt,
|
|
68
|
+
fields: entryFieldsToJson(fields, locale),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Converts an AssetSummary to a plain JSON-safe object.
|
|
73
|
+
* Undefined optional fields are normalized to null for stable output.
|
|
74
|
+
*/
|
|
75
|
+
export function assetSummaryToJson(summary) {
|
|
76
|
+
return {
|
|
77
|
+
id: summary.id,
|
|
78
|
+
title: summary.title,
|
|
79
|
+
fileName: summary.fileName,
|
|
80
|
+
contentType: summary.contentType,
|
|
81
|
+
url: summary.url,
|
|
82
|
+
width: summary.width ?? null,
|
|
83
|
+
height: summary.height ?? null,
|
|
84
|
+
size: summary.size ?? null,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=json.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.js","sourceRoot":"","sources":["../../src/output/json.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AA0BrD;;;;;;;GAOG;AACH,SAAS,cAAc,CAAC,KAAc;IACpC,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IAEvD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IACnC,CAAC;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,MAAM,GAAG,GAAG,KAAgC,CAAC;QAE7C,4EAA4E;QAC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 -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mode.d.ts","sourceRoot":"","sources":["../../src/output/mode.ts"],"names":[],"mappings":"AAUA,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAElD;AAED,wBAAgB,UAAU,IAAI,OAAO,CAEpC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Global JSON output mode singleton.
|
|
3
|
+
*
|
|
4
|
+
* When enabled, all print.ts functions emit machine-readable JSON lines instead of
|
|
5
|
+
* formatted human text. Enabled via:
|
|
6
|
+
* - Environment variable: CMS_EDIT_JSON=1 (or CMS_EDIT_JSON=true)
|
|
7
|
+
* - Global CLI flag: cms-edit --json <command>
|
|
8
|
+
*/
|
|
9
|
+
let _jsonMode = process.env['CMS_EDIT_JSON'] === '1' || process.env['CMS_EDIT_JSON'] === 'true';
|
|
10
|
+
export function setJsonMode(enabled) {
|
|
11
|
+
_jsonMode = enabled;
|
|
12
|
+
}
|
|
13
|
+
export function isJsonMode() {
|
|
14
|
+
return _jsonMode;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=mode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mode.js","sourceRoot":"","sources":["../../src/output/mode.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,IAAI,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,KAAK,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,KAAK,MAAM,CAAC;AAEhG,MAAM,UAAU,WAAW,CAAC,OAAgB;IAC1C,SAAS,GAAG,OAAO,CAAC;AACtB,CAAC;AAED,MAAM,UAAU,UAAU;IACxB,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { EntryStatus } from '../session/state.js';
|
|
2
|
+
export declare function statusBadge(status: EntryStatus): string;
|
|
3
|
+
export declare function refLabel(ref: string): string;
|
|
4
|
+
export declare function typeLabel(label: string): string;
|
|
5
|
+
export declare function entryLabel(label: string): string;
|
|
6
|
+
/** Emits an error. In JSON mode: {"ok":false,"error":"..."} to stderr. */
|
|
7
|
+
export declare function errorMsg(msg: string): void;
|
|
8
|
+
/** Emits a warning. In JSON mode: {"warn":"..."} to stdout. */
|
|
9
|
+
export declare function warnMsg(msg: string): void;
|
|
10
|
+
/** Emits a success result. In JSON mode: {"ok":true,"message":"..."} to stdout. */
|
|
11
|
+
export declare function successMsg(msg: string): void;
|
|
12
|
+
/** Emits an informational/progress message. Suppressed in JSON mode. */
|
|
13
|
+
export declare function infoMsg(msg: string): void;
|
|
14
|
+
//# sourceMappingURL=print.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"print.d.ts","sourceRoot":"","sources":["../../src/output/print.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGvD,wBAAgB,WAAW,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAWvD;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE5C;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,0EAA0E;AAC1E,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAM1C;AAED,+DAA+D;AAC/D,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAMzC;AAED,mFAAmF;AACnF,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAM5C;AAED,wEAAwE;AACxE,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAIzC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/** biome-ignore-all lint/suspicious/noConsole: Console output is intentional in CLI */
|
|
2
|
+
import pc from 'picocolors';
|
|
3
|
+
import { isJsonMode } from './mode.js';
|
|
4
|
+
export function statusBadge(status) {
|
|
5
|
+
switch (status) {
|
|
6
|
+
case 'published':
|
|
7
|
+
return pc.green('[published]');
|
|
8
|
+
case 'draft':
|
|
9
|
+
return pc.cyan('[draft]');
|
|
10
|
+
case 'changed':
|
|
11
|
+
return pc.yellow('[changed]');
|
|
12
|
+
case 'pending':
|
|
13
|
+
return pc.magenta('[pending]');
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export function refLabel(ref) {
|
|
17
|
+
return pc.bold(pc.dim(ref.padEnd(5)));
|
|
18
|
+
}
|
|
19
|
+
export function typeLabel(label) {
|
|
20
|
+
return pc.blue(label.padEnd(28));
|
|
21
|
+
}
|
|
22
|
+
export function entryLabel(label) {
|
|
23
|
+
return pc.white(`"${truncate(label, 40)}"`);
|
|
24
|
+
}
|
|
25
|
+
/** Emits an error. In JSON mode: {"ok":false,"error":"..."} to stderr. */
|
|
26
|
+
export function errorMsg(msg) {
|
|
27
|
+
if (isJsonMode()) {
|
|
28
|
+
console.error(JSON.stringify({ ok: false, error: msg }));
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
console.error(pc.red(`Error: ${msg}`));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/** Emits a warning. In JSON mode: {"warn":"..."} to stdout. */
|
|
35
|
+
export function warnMsg(msg) {
|
|
36
|
+
if (isJsonMode()) {
|
|
37
|
+
console.log(JSON.stringify({ warn: msg }));
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
console.warn(pc.yellow(`Warning: ${msg}`));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/** Emits a success result. In JSON mode: {"ok":true,"message":"..."} to stdout. */
|
|
44
|
+
export function successMsg(msg) {
|
|
45
|
+
if (isJsonMode()) {
|
|
46
|
+
console.log(JSON.stringify({ ok: true, message: msg }));
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
console.log(pc.green(`✓ ${msg}`));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/** Emits an informational/progress message. Suppressed in JSON mode. */
|
|
53
|
+
export function infoMsg(msg) {
|
|
54
|
+
if (!isJsonMode()) {
|
|
55
|
+
console.log(pc.dim(msg));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function truncate(str, max) {
|
|
59
|
+
return str.length > max ? `${str.slice(0, max - 1)}…` : str;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=print.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"print.js","sourceRoot":"","sources":["../../src/output/print.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,MAAM,UAAU,WAAW,CAAC,MAAmB;IAC7C,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,WAAW;YACd,OAAO,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QACjC,KAAK,OAAO;YACV,OAAO,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC5B,KAAK,SAAS;YACZ,OAAO,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAChC,KAAK,SAAS;YACZ,OAAO,EAAE,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IACnC,CAAC;AACH,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,GAAW;IAClC,OAAO,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACxC,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,KAAa;IACrC,OAAO,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAA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