@valkyrianlabs/payload-markdown-docs 0.4.1 → 0.4.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/dist/admin/DocsSetManager.d.ts +1 -1
- package/dist/admin/DocsSetManager.js +42 -1
- package/dist/admin/DocsSetManager.js.map +1 -1
- package/dist/collections/docsSets.d.ts +3 -1
- package/dist/collections/docsSets.js +10 -1
- package/dist/collections/docsSets.js.map +1 -1
- package/dist/endpoints/index.d.ts +3 -1
- package/dist/endpoints/index.js +1 -0
- package/dist/endpoints/index.js.map +1 -1
- package/dist/endpoints/publishGeneratedDocs.d.ts +6 -0
- package/dist/endpoints/publishGeneratedDocs.js +76 -0
- package/dist/endpoints/publishGeneratedDocs.js.map +1 -0
- package/dist/payload/publishGeneratedDocs.d.ts +29 -0
- package/dist/payload/publishGeneratedDocs.js +78 -0
- package/dist/payload/publishGeneratedDocs.js.map +1 -0
- package/dist/plugin.js +2 -0
- package/dist/plugin.js.map +1 -1
- package/dist/skills/codex/reference/admin.md +2 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { UIFieldServerProps } from 'payload';
|
|
2
|
-
export declare const DocsSetManager: ({ id, field, payload, req
|
|
2
|
+
export declare const DocsSetManager: ({ id, field, payload, req }: UIFieldServerProps) => Promise<import("react/jsx-runtime").JSX.Element>;
|
|
@@ -18,6 +18,15 @@ const formatDate = (value)=>{
|
|
|
18
18
|
}
|
|
19
19
|
return date.toISOString();
|
|
20
20
|
};
|
|
21
|
+
const normalizeRoute = (route = '/')=>{
|
|
22
|
+
const normalized = `/${route.trim()}`.replace(/\/+/g, '/');
|
|
23
|
+
return normalized.length > 1 ? normalized.replace(/\/+$/g, '') : normalized;
|
|
24
|
+
};
|
|
25
|
+
const getPublishAction = ({ apiRoute, docsSetId, docsSetsCollectionSlug, redirect })=>{
|
|
26
|
+
const path = `${normalizeRoute(apiRoute ?? '/api')}/${docsSetsCollectionSlug}/${encodeURIComponent(String(docsSetId))}/publish-generated-docs`;
|
|
27
|
+
return `${path}?redirect=${encodeURIComponent(redirect)}`;
|
|
28
|
+
};
|
|
29
|
+
const getDocsSetAdminURL = ({ adminRoute, docsSetId, docsSetsCollectionSlug })=>`${normalizeRoute(adminRoute ?? '/admin')}/collections/${docsSetsCollectionSlug}/${encodeURIComponent(String(docsSetId))}`;
|
|
21
30
|
const StatusLabel = ({ item })=>{
|
|
22
31
|
if (item.archived) {
|
|
23
32
|
return /*#__PURE__*/ _jsx("span", {
|
|
@@ -210,6 +219,7 @@ export const DocsSetManager = async ({ id, field, payload, req })=>{
|
|
|
210
219
|
const docsCollectionSlug = custom.docsCollectionSlug ?? DEFAULT_DOCS_COLLECTION_SLUG;
|
|
211
220
|
const docsGroupsCollectionSlug = custom.docsGroupsCollectionSlug ?? DEFAULT_DOCS_GROUPS_COLLECTION_SLUG;
|
|
212
221
|
const docsSetsCollectionSlug = custom.docsSetsCollectionSlug ?? DEFAULT_DOCS_SETS_COLLECTION_SLUG;
|
|
222
|
+
const canPublishGeneratedDocs = custom.docsEnableDrafts === true && custom.allowPublish === true;
|
|
213
223
|
if (!id) {
|
|
214
224
|
return /*#__PURE__*/ _jsxs("section", {
|
|
215
225
|
children: [
|
|
@@ -230,6 +240,17 @@ export const DocsSetManager = async ({ id, field, payload, req })=>{
|
|
|
230
240
|
docsSetsCollectionSlug,
|
|
231
241
|
payload: payload
|
|
232
242
|
});
|
|
243
|
+
const docsSetAdminURL = getDocsSetAdminURL({
|
|
244
|
+
adminRoute: req.payload.config.routes.admin,
|
|
245
|
+
docsSetId: id,
|
|
246
|
+
docsSetsCollectionSlug
|
|
247
|
+
});
|
|
248
|
+
const publishAction = getPublishAction({
|
|
249
|
+
apiRoute: req.payload.config.routes.api,
|
|
250
|
+
docsSetId: id,
|
|
251
|
+
docsSetsCollectionSlug,
|
|
252
|
+
redirect: docsSetAdminURL
|
|
253
|
+
});
|
|
233
254
|
return /*#__PURE__*/ _jsxs("section", {
|
|
234
255
|
children: [
|
|
235
256
|
/*#__PURE__*/ _jsxs("header", {
|
|
@@ -263,7 +284,27 @@ export const DocsSetManager = async ({ id, field, payload, req })=>{
|
|
|
263
284
|
}),
|
|
264
285
|
/*#__PURE__*/ _jsx(Summary, {
|
|
265
286
|
data: data
|
|
266
|
-
})
|
|
287
|
+
}),
|
|
288
|
+
data.summary.drafts > 0 ? /*#__PURE__*/ _jsxs("div", {
|
|
289
|
+
children: [
|
|
290
|
+
/*#__PURE__*/ _jsxs("p", {
|
|
291
|
+
children: [
|
|
292
|
+
data.summary.drafts,
|
|
293
|
+
" generated docs records are drafts and are not public."
|
|
294
|
+
]
|
|
295
|
+
}),
|
|
296
|
+
canPublishGeneratedDocs ? /*#__PURE__*/ _jsx("form", {
|
|
297
|
+
action: publishAction,
|
|
298
|
+
method: "post",
|
|
299
|
+
children: /*#__PURE__*/ _jsx("button", {
|
|
300
|
+
type: "submit",
|
|
301
|
+
children: "Publish generated docs"
|
|
302
|
+
})
|
|
303
|
+
}) : /*#__PURE__*/ _jsx("p", {
|
|
304
|
+
children: "Publishing is disabled for this plugin config."
|
|
305
|
+
})
|
|
306
|
+
]
|
|
307
|
+
}) : null
|
|
267
308
|
]
|
|
268
309
|
}),
|
|
269
310
|
data.warnings.length > 0 ? /*#__PURE__*/ _jsxs("section", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/admin/DocsSetManager.tsx"],"sourcesContent":["import type { UIFieldServerProps } from 'payload'\nimport type { ReactNode } from 'react'\n\nimport type {\n DocsSetManagerData,\n DocsSetManagerDocItem,\n DocsSetManagerPayloadOperations,\n} from './docsSetManagerTypes.js'\n\nimport {\n DEFAULT_DOCS_COLLECTION_SLUG,\n DEFAULT_DOCS_GROUPS_COLLECTION_SLUG,\n DEFAULT_DOCS_SETS_COLLECTION_SLUG,\n} from '../constants.js'\nimport { getDocsSetManagerData } from './docsSetManagerData.js'\n\ntype DocsSetManagerFieldCustom = {\n docsCollectionSlug?: string\n docsGroupsCollectionSlug?: string\n docsSetsCollectionSlug?: string\n}\n\nconst getFieldCustom = (\n field: UIFieldServerProps['field'],\n): DocsSetManagerFieldCustom => {\n const custom = 'custom' in field ? field.custom : undefined\n\n if (!custom || typeof custom !== 'object') {\n return {}\n }\n\n return custom as DocsSetManagerFieldCustom\n}\n\nconst formatDate = (value?: string): string => {\n if (!value) {\n return 'Never'\n }\n\n const date = new Date(value)\n\n if (Number.isNaN(date.getTime())) {\n return value\n }\n\n return date.toISOString()\n}\n\nconst StatusLabel = ({ item }: { item: DocsSetManagerDocItem }) => {\n if (item.archived) {\n return <span>archived</span>\n }\n\n if (item.draft) {\n return <span>draft</span>\n }\n\n if (item.published) {\n return <span>published</span>\n }\n\n return <span>synced</span>\n}\n\nconst OverrideSummary = ({ item }: { item: DocsSetManagerDocItem }) => {\n if (item.overrideSummary.length === 0) {\n return <span>none</span>\n }\n\n return <span>{item.overrideSummary.join(', ')}</span>\n}\n\nconst renderDocItem = (item: DocsSetManagerDocItem): ReactNode => {\n if (item.kind === 'folder') {\n return (\n <details key={item.id}>\n <summary>{item.title}</summary>\n <div>\n {item.children?.map((child) => renderDocItem(child))}\n </div>\n </details>\n )\n }\n\n return (\n <details key={item.id}>\n <summary>{item.sourcePath}</summary>\n <dl>\n <div>\n <dt>Route</dt>\n <dd>{item.route || 'Missing route'}</dd>\n </div>\n <div>\n <dt>Title</dt>\n <dd>{item.title}</dd>\n </div>\n <div>\n <dt>Status</dt>\n <dd>\n <StatusLabel item={item} />\n </dd>\n </div>\n <div>\n <dt>Overrides</dt>\n <dd>\n <OverrideSummary item={item} />\n </dd>\n </div>\n </dl>\n {item.adminURL ? <a href={item.adminURL}>Open generated doc</a> : null}\n </details>\n )\n}\n\nconst Summary = ({ data }: { data: DocsSetManagerData }) => (\n <dl>\n <div>\n <dt>Docs</dt>\n <dd>{data.summary.total}</dd>\n </div>\n <div>\n <dt>Archived</dt>\n <dd>{data.summary.archived}</dd>\n </div>\n <div>\n <dt>Drafts</dt>\n <dd>{data.summary.drafts}</dd>\n </div>\n <div>\n <dt>Published</dt>\n <dd>{data.summary.published}</dd>\n </div>\n <div>\n <dt>Hidden from nav</dt>\n <dd>{data.summary.hiddenFromNav}</dd>\n </div>\n <div>\n <dt>With overrides</dt>\n <dd>{data.summary.withOverrides}</dd>\n </div>\n <div>\n <dt>Last sync</dt>\n <dd>{formatDate(data.sync?.lastSyncedAt)}</dd>\n </div>\n <div>\n <dt>Last status</dt>\n <dd>{data.sync?.lastStatus ?? 'unknown'}</dd>\n </div>\n </dl>\n)\n\nexport const DocsSetManager = async ({\n id,\n field,\n payload,\n req,\n}: UIFieldServerProps) => {\n const custom = getFieldCustom(field)\n const docsCollectionSlug = custom.docsCollectionSlug ?? DEFAULT_DOCS_COLLECTION_SLUG\n const docsGroupsCollectionSlug =\n custom.docsGroupsCollectionSlug ?? DEFAULT_DOCS_GROUPS_COLLECTION_SLUG\n const docsSetsCollectionSlug =\n custom.docsSetsCollectionSlug ?? DEFAULT_DOCS_SETS_COLLECTION_SLUG\n\n if (!id) {\n return (\n <section>\n <h2>Generated Docs</h2>\n <p>Save this docs set before reviewing generated docs records.</p>\n </section>\n )\n }\n\n const data = await getDocsSetManagerData({\n adminRoute: req.payload.config.routes.admin,\n docsCollectionSlug,\n docsGroupsCollectionSlug,\n docsSetId: String(id),\n docsSetsCollectionSlug,\n payload: payload as DocsSetManagerPayloadOperations,\n })\n\n return (\n <section>\n <header>\n <h2>Generated Docs</h2>\n <p>\n Review generated docs records for {data.docsSet.title}. Source docs remain\n Git-backed; per-doc overrides can be edited by opening a generated doc.\n </p>\n </header>\n\n <section>\n <h3>Effective Route</h3>\n <p>{data.docsSet.routeBase || 'No route available yet'}</p>\n </section>\n\n <section>\n <h3>Sync Summary</h3>\n <Summary data={data} />\n </section>\n\n {data.warnings.length > 0 ? (\n <section>\n <h3>Warnings</h3>\n <ul>\n {data.warnings.map((warning) => (\n <li key={`${warning.docId ?? 'docs-set'}:${warning.message}`}>\n {warning.sourcePath ? `${warning.sourcePath}: ` : null}\n {warning.message}\n </li>\n ))}\n </ul>\n </section>\n ) : null}\n\n <section>\n <h3>Generated Docs</h3>\n {data.tree.length > 0 ? (\n <div>{data.tree.map((item) => renderDocItem(item))}</div>\n ) : (\n <p>No generated docs records are linked to this docs set yet.</p>\n )}\n </section>\n </section>\n )\n}\n"],"names":["DEFAULT_DOCS_COLLECTION_SLUG","DEFAULT_DOCS_GROUPS_COLLECTION_SLUG","DEFAULT_DOCS_SETS_COLLECTION_SLUG","getDocsSetManagerData","getFieldCustom","field","custom","undefined","formatDate","value","date","Date","Number","isNaN","getTime","toISOString","StatusLabel","item","archived","span","draft","published","OverrideSummary","overrideSummary","length","join","renderDocItem","kind","details","summary","title","div","children","map","child","id","sourcePath","dl","dt","dd","route","adminURL","a","href","Summary","data","total","drafts","hiddenFromNav","withOverrides","sync","lastSyncedAt","lastStatus","DocsSetManager","payload","req","docsCollectionSlug","docsGroupsCollectionSlug","docsSetsCollectionSlug","section","h2","p","adminRoute","config","routes","admin","docsSetId","String","header","docsSet","h3","routeBase","warnings","ul","warning","li","message","docId","tree"],"mappings":";AASA,SACEA,4BAA4B,EAC5BC,mCAAmC,EACnCC,iCAAiC,QAC5B,kBAAiB;AACxB,SAASC,qBAAqB,QAAQ,0BAAyB;AAQ/D,MAAMC,iBAAiB,CACrBC;IAEA,MAAMC,SAAS,YAAYD,QAAQA,MAAMC,MAAM,GAAGC;IAElD,IAAI,CAACD,UAAU,OAAOA,WAAW,UAAU;QACzC,OAAO,CAAC;IACV;IAEA,OAAOA;AACT;AAEA,MAAME,aAAa,CAACC;IAClB,IAAI,CAACA,OAAO;QACV,OAAO;IACT;IAEA,MAAMC,OAAO,IAAIC,KAAKF;IAEtB,IAAIG,OAAOC,KAAK,CAACH,KAAKI,OAAO,KAAK;QAChC,OAAOL;IACT;IAEA,OAAOC,KAAKK,WAAW;AACzB;AAEA,MAAMC,cAAc,CAAC,EAAE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AAOhC;QAClBuB;QACAJ,SAASA;IACX;IAEA,qBACE,MAACK;;0BACC,MAACS;;kCACC,KAACR;kCAAG;;kCACJ,MAACC;;4BAAE;4BACkChB,KAAKwB,OAAO,CAACvC,KAAK;4BAAC;;;;;0BAK1D,MAAC6B;;kCACC,KAACW;kCAAG;;kCACJ,KAACT;kCAAGhB,KAAKwB,OAAO,CAACE,SAAS,IAAI;;;;0BAGhC,MAACZ;;kCACC,KAACW;kCAAG;;kCACJ,KAAC1B;wBAAQC,MAAMA;;;;YAGhBA,KAAK2B,QAAQ,CAAChD,MAAM,GAAG,kBACtB,MAACmC;;kCACC,KAACW;kCAAG;;kCACJ,KAACG;kCACE5B,KAAK2B,QAAQ,CAACvC,GAAG,CAAC,CAACyC,wBAClB,MAACC;;oCACED,QAAQtC,UAAU,GAAG,GAAGsC,QAAQtC,UAAU,CAAC,EAAE,CAAC,GAAG;oCACjDsC,QAAQE,OAAO;;+BAFT,GAAGF,QAAQG,KAAK,IAAI,WAAW,CAAC,EAAEH,QAAQE,OAAO,EAAE;;;iBAOhE;0BAEJ,MAACjB;;kCACC,KAACW;kCAAG;;oBACHzB,KAAKiC,IAAI,CAACtD,MAAM,GAAG,kBAClB,KAACO;kCAAKc,KAAKiC,IAAI,CAAC7C,GAAG,CAAC,CAAChB,OAASS,cAAcT;uCAE5C,KAAC4C;kCAAE;;;;;;AAKb,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../src/admin/DocsSetManager.tsx"],"sourcesContent":["import type { UIFieldServerProps } from 'payload'\nimport type { ReactNode } from 'react'\n\nimport type {\n DocsSetManagerData,\n DocsSetManagerDocItem,\n DocsSetManagerPayloadOperations,\n} from './docsSetManagerTypes.js'\n\nimport {\n DEFAULT_DOCS_COLLECTION_SLUG,\n DEFAULT_DOCS_GROUPS_COLLECTION_SLUG,\n DEFAULT_DOCS_SETS_COLLECTION_SLUG,\n} from '../constants.js'\nimport { getDocsSetManagerData } from './docsSetManagerData.js'\n\ntype DocsSetManagerFieldCustom = {\n allowPublish?: boolean\n docsCollectionSlug?: string\n docsEnableDrafts?: boolean\n docsGroupsCollectionSlug?: string\n docsSetsCollectionSlug?: string\n}\n\nconst getFieldCustom = (field: UIFieldServerProps['field']): DocsSetManagerFieldCustom => {\n const custom = 'custom' in field ? field.custom : undefined\n\n if (!custom || typeof custom !== 'object') {\n return {}\n }\n\n return custom as DocsSetManagerFieldCustom\n}\n\nconst formatDate = (value?: string): string => {\n if (!value) {\n return 'Never'\n }\n\n const date = new Date(value)\n\n if (Number.isNaN(date.getTime())) {\n return value\n }\n\n return date.toISOString()\n}\n\nconst normalizeRoute = (route = '/'): string => {\n const normalized = `/${route.trim()}`.replace(/\\/+/g, '/')\n\n return normalized.length > 1 ? normalized.replace(/\\/+$/g, '') : normalized\n}\n\nconst getPublishAction = ({\n apiRoute,\n docsSetId,\n docsSetsCollectionSlug,\n redirect,\n}: {\n apiRoute?: string\n docsSetId: number | string\n docsSetsCollectionSlug: string\n redirect: string\n}): string => {\n const path = `${normalizeRoute(apiRoute ?? '/api')}/${docsSetsCollectionSlug}/${encodeURIComponent(String(docsSetId))}/publish-generated-docs`\n\n return `${path}?redirect=${encodeURIComponent(redirect)}`\n}\n\nconst getDocsSetAdminURL = ({\n adminRoute,\n docsSetId,\n docsSetsCollectionSlug,\n}: {\n adminRoute?: string\n docsSetId: number | string\n docsSetsCollectionSlug: string\n}): string =>\n `${normalizeRoute(adminRoute ?? '/admin')}/collections/${docsSetsCollectionSlug}/${encodeURIComponent(String(docsSetId))}`\n\nconst StatusLabel = ({ item }: { item: DocsSetManagerDocItem }) => {\n if (item.archived) {\n return <span>archived</span>\n }\n\n if (item.draft) {\n return <span>draft</span>\n }\n\n if (item.published) {\n return <span>published</span>\n }\n\n return <span>synced</span>\n}\n\nconst OverrideSummary = ({ item }: { item: DocsSetManagerDocItem }) => {\n if (item.overrideSummary.length === 0) {\n return <span>none</span>\n }\n\n return <span>{item.overrideSummary.join(', ')}</span>\n}\n\nconst renderDocItem = (item: DocsSetManagerDocItem): ReactNode => {\n if (item.kind === 'folder') {\n return (\n <details key={item.id}>\n <summary>{item.title}</summary>\n <div>{item.children?.map((child) => renderDocItem(child))}</div>\n </details>\n )\n }\n\n return (\n <details key={item.id}>\n <summary>{item.sourcePath}</summary>\n <dl>\n <div>\n <dt>Route</dt>\n <dd>{item.route || 'Missing route'}</dd>\n </div>\n <div>\n <dt>Title</dt>\n <dd>{item.title}</dd>\n </div>\n <div>\n <dt>Status</dt>\n <dd>\n <StatusLabel item={item} />\n </dd>\n </div>\n <div>\n <dt>Overrides</dt>\n <dd>\n <OverrideSummary item={item} />\n </dd>\n </div>\n </dl>\n {item.adminURL ? <a href={item.adminURL}>Open generated doc</a> : null}\n </details>\n )\n}\n\nconst Summary = ({ data }: { data: DocsSetManagerData }) => (\n <dl>\n <div>\n <dt>Docs</dt>\n <dd>{data.summary.total}</dd>\n </div>\n <div>\n <dt>Archived</dt>\n <dd>{data.summary.archived}</dd>\n </div>\n <div>\n <dt>Drafts</dt>\n <dd>{data.summary.drafts}</dd>\n </div>\n <div>\n <dt>Published</dt>\n <dd>{data.summary.published}</dd>\n </div>\n <div>\n <dt>Hidden from nav</dt>\n <dd>{data.summary.hiddenFromNav}</dd>\n </div>\n <div>\n <dt>With overrides</dt>\n <dd>{data.summary.withOverrides}</dd>\n </div>\n <div>\n <dt>Last sync</dt>\n <dd>{formatDate(data.sync?.lastSyncedAt)}</dd>\n </div>\n <div>\n <dt>Last status</dt>\n <dd>{data.sync?.lastStatus ?? 'unknown'}</dd>\n </div>\n </dl>\n)\n\nexport const DocsSetManager = async ({ id, field, payload, req }: UIFieldServerProps) => {\n const custom = getFieldCustom(field)\n const docsCollectionSlug = custom.docsCollectionSlug ?? DEFAULT_DOCS_COLLECTION_SLUG\n const docsGroupsCollectionSlug =\n custom.docsGroupsCollectionSlug ?? DEFAULT_DOCS_GROUPS_COLLECTION_SLUG\n const docsSetsCollectionSlug = custom.docsSetsCollectionSlug ?? DEFAULT_DOCS_SETS_COLLECTION_SLUG\n const canPublishGeneratedDocs = custom.docsEnableDrafts === true && custom.allowPublish === true\n\n if (!id) {\n return (\n <section>\n <h2>Generated Docs</h2>\n <p>Save this docs set before reviewing generated docs records.</p>\n </section>\n )\n }\n\n const data = await getDocsSetManagerData({\n adminRoute: req.payload.config.routes.admin,\n docsCollectionSlug,\n docsGroupsCollectionSlug,\n docsSetId: String(id),\n docsSetsCollectionSlug,\n payload: payload as DocsSetManagerPayloadOperations,\n })\n const docsSetAdminURL = getDocsSetAdminURL({\n adminRoute: req.payload.config.routes.admin,\n docsSetId: id,\n docsSetsCollectionSlug,\n })\n const publishAction = getPublishAction({\n apiRoute: req.payload.config.routes.api,\n docsSetId: id,\n docsSetsCollectionSlug,\n redirect: docsSetAdminURL,\n })\n\n return (\n <section>\n <header>\n <h2>Generated Docs</h2>\n <p>\n Review generated docs records for {data.docsSet.title}. Source docs remain Git-backed;\n per-doc overrides can be edited by opening a generated doc.\n </p>\n </header>\n\n <section>\n <h3>Effective Route</h3>\n <p>{data.docsSet.routeBase || 'No route available yet'}</p>\n </section>\n\n <section>\n <h3>Sync Summary</h3>\n <Summary data={data} />\n {data.summary.drafts > 0 ? (\n <div>\n <p>{data.summary.drafts} generated docs records are drafts and are not public.</p>\n {canPublishGeneratedDocs ? (\n <form action={publishAction} method=\"post\">\n <button type=\"submit\">Publish generated docs</button>\n </form>\n ) : (\n <p>Publishing is disabled for this plugin config.</p>\n )}\n </div>\n ) : null}\n </section>\n\n {data.warnings.length > 0 ? (\n <section>\n <h3>Warnings</h3>\n <ul>\n {data.warnings.map((warning) => (\n <li key={`${warning.docId ?? 'docs-set'}:${warning.message}`}>\n {warning.sourcePath ? `${warning.sourcePath}: ` : null}\n {warning.message}\n </li>\n ))}\n </ul>\n </section>\n ) : null}\n\n <section>\n <h3>Generated Docs</h3>\n {data.tree.length > 0 ? (\n <div>{data.tree.map((item) => renderDocItem(item))}</div>\n ) : (\n <p>No generated docs records are linked to this docs set yet.</p>\n )}\n </section>\n </section>\n )\n}\n"],"names":["DEFAULT_DOCS_COLLECTION_SLUG","DEFAULT_DOCS_GROUPS_COLLECTION_SLUG","DEFAULT_DOCS_SETS_COLLECTION_SLUG","getDocsSetManagerData","getFieldCustom","field","custom","undefined","formatDate","value","date","Date","Number","isNaN","getTime","toISOString","normalizeRoute","route","normalized","trim","replace","length","getPublishAction","apiRoute","docsSetId","docsSetsCollectionSlug","redirect","path","encodeURIComponent","String","getDocsSetAdminURL","adminRoute","StatusLabel","item","archived","span","draft","published","OverrideSummary","overrideSummary","join","renderDocItem","kind","details","summary","title","div","children","map","child","id","sourcePath","dl","dt","dd","adminURL","a","href","Summary","data","total","drafts","hiddenFromNav","withOverrides","sync","lastSyncedAt","lastStatus","DocsSetManager","payload","req","docsCollectionSlug","docsGroupsCollectionSlug","canPublishGeneratedDocs","docsEnableDrafts","allowPublish","section","h2","p","config","routes","admin","docsSetAdminURL","publishAction","api","header","docsSet","h3","routeBase","form","action","method","button","type","warnings","ul","warning","li","message","docId","tree"],"mappings":";AASA,SACEA,4BAA4B,EAC5BC,mCAAmC,EACnCC,iCAAiC,QAC5B,kBAAiB;AACxB,SAASC,qBAAqB,QAAQ,0BAAyB;AAU/D,MAAMC,iBAAiB,CAACC;IACtB,MAAMC,SAAS,YAAYD,QAAQA,MAAMC,MAAM,GAAGC;IAElD,IAAI,CAACD,UAAU,OAAOA,WAAW,UAAU;QACzC,OAAO,CAAC;IACV;IAEA,OAAOA;AACT;AAEA,MAAME,aAAa,CAACC;IAClB,IAAI,CAACA,OAAO;QACV,OAAO;IACT;IAEA,MAAMC,OAAO,IAAIC,KAAKF;IAEtB,IAAIG,OAAOC,KAAK,CAACH,KAAKI,OAAO,KAAK;QAChC,OAAOL;IACT;IAEA,OAAOC,KAAKK,WAAW;AACzB;AAEA,MAAMC,iBAAiB,CAACC,QAAQ,GAAG;IACjC,MAAMC,aAAa,CAAC,CAAC,EAAED,MAAME,IAAI,IAAI,CAACC,OAAO,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ACdA,KAAKf,OAAO,CAACiB,MAAM,GAAG,kBACrB,MAACf;;0CACC,MAAC+B;;oCAAGlB,KAAKf,OAAO,CAACiB,MAAM;oCAAC;;;4BACvBW,wCACC,KAACgB;gCAAKC,QAAQP;gCAAeQ,QAAO;0CAClC,cAAA,KAACC;oCAAOC,MAAK;8CAAS;;+CAGxB,KAACf;0CAAE;;;yBAGL;;;YAGLlB,KAAKkC,QAAQ,CAACxE,MAAM,GAAG,kBACtB,MAACsD;;kCACC,KAACW;kCAAG;;kCACJ,KAACQ;kCACEnC,KAAKkC,QAAQ,CAAC7C,GAAG,CAAC,CAAC+C,wBAClB,MAACC;;oCACED,QAAQ5C,UAAU,GAAG,GAAG4C,QAAQ5C,UAAU,CAAC,EAAE,CAAC,GAAG;oCACjD4C,QAAQE,OAAO;;+BAFT,GAAGF,QAAQG,KAAK,IAAI,WAAW,CAAC,EAAEH,QAAQE,OAAO,EAAE;;;iBAOhE;0BAEJ,MAACtB;;kCACC,KAACW;kCAAG;;oBACH3B,KAAKwC,IAAI,CAAC9E,MAAM,GAAG,kBAClB,KAACyB;kCAAKa,KAAKwC,IAAI,CAACnD,GAAG,CAAC,CAACf,OAASQ,cAAcR;uCAE5C,KAAC4C;kCAAE;;;;;;AAKb,EAAC"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { CollectionConfig } from 'payload';
|
|
2
2
|
export type CreateDocsSetsCollectionOptions = {
|
|
3
|
+
allowPublish?: boolean;
|
|
3
4
|
docsCollectionSlug?: string;
|
|
5
|
+
docsEnableDrafts?: boolean;
|
|
4
6
|
docsGroupsCollectionSlug: string;
|
|
5
7
|
slug: string;
|
|
6
8
|
syncRunsCollectionSlug?: string;
|
|
7
9
|
};
|
|
8
|
-
export declare const createDocsSetsCollection: ({ slug, docsCollectionSlug, docsGroupsCollectionSlug, syncRunsCollectionSlug, }: CreateDocsSetsCollectionOptions) => CollectionConfig;
|
|
10
|
+
export declare const createDocsSetsCollection: ({ slug, allowPublish, docsCollectionSlug, docsEnableDrafts, docsGroupsCollectionSlug, syncRunsCollectionSlug, }: CreateDocsSetsCollectionOptions) => CollectionConfig;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DOCS_GLOBALS_ADMIN_GROUP, DOCS_SET_MANAGER_COMPONENT } from '../constants.js';
|
|
2
|
-
|
|
2
|
+
import { createPublishGeneratedDocsEndpoint } from '../endpoints/publishGeneratedDocs.js';
|
|
3
|
+
export const createDocsSetsCollection = ({ slug, allowPublish = false, docsCollectionSlug, docsEnableDrafts = false, docsGroupsCollectionSlug, syncRunsCollectionSlug })=>({
|
|
3
4
|
slug,
|
|
4
5
|
admin: {
|
|
5
6
|
defaultColumns: [
|
|
@@ -11,6 +12,12 @@ export const createDocsSetsCollection = ({ slug, docsCollectionSlug, docsGroupsC
|
|
|
11
12
|
group: DOCS_GLOBALS_ADMIN_GROUP,
|
|
12
13
|
useAsTitle: 'title'
|
|
13
14
|
},
|
|
15
|
+
endpoints: docsCollectionSlug && docsEnableDrafts && allowPublish ? [
|
|
16
|
+
createPublishGeneratedDocsEndpoint({
|
|
17
|
+
docsCollectionSlug,
|
|
18
|
+
docsSetsCollectionSlug: slug
|
|
19
|
+
})
|
|
20
|
+
] : undefined,
|
|
14
21
|
fields: [
|
|
15
22
|
{
|
|
16
23
|
name: 'title',
|
|
@@ -135,7 +142,9 @@ export const createDocsSetsCollection = ({ slug, docsCollectionSlug, docsGroupsC
|
|
|
135
142
|
Field: DOCS_SET_MANAGER_COMPONENT
|
|
136
143
|
},
|
|
137
144
|
custom: {
|
|
145
|
+
allowPublish,
|
|
138
146
|
docsCollectionSlug,
|
|
147
|
+
docsEnableDrafts,
|
|
139
148
|
docsGroupsCollectionSlug,
|
|
140
149
|
docsSetsCollectionSlug: slug
|
|
141
150
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/collections/docsSets.ts"],"sourcesContent":["import type { CollectionConfig } from 'payload'\n\nimport {\n DOCS_GLOBALS_ADMIN_GROUP,\n DOCS_SET_MANAGER_COMPONENT,\n} from '../constants.js'\n\nexport type CreateDocsSetsCollectionOptions = {\n docsCollectionSlug?: string\n docsGroupsCollectionSlug: string\n slug: string\n syncRunsCollectionSlug?: string\n}\n\nexport const createDocsSetsCollection = ({\n slug,\n docsCollectionSlug,\n docsGroupsCollectionSlug,\n syncRunsCollectionSlug,\n}: CreateDocsSetsCollectionOptions): CollectionConfig => ({\n slug,\n admin: {\n defaultColumns: ['title', 'slug', 'branch', 'updatedAt'],\n group: DOCS_GLOBALS_ADMIN_GROUP,\n useAsTitle: 'title',\n },\n fields: [\n {\n name: 'title',\n type: 'text',\n required: true,\n },\n {\n name: 'slug',\n type: 'text',\n index: true,\n required: true,\n unique: true,\n },\n {\n name: 'group',\n type: 'relationship',\n relationTo: docsGroupsCollectionSlug,\n },\n {\n name: 'branch',\n type: 'text',\n admin: {\n description:\n 'Git branch allowed to publish this docs set. The full Git ref is handled internally.',\n },\n defaultValue: 'main',\n },\n {\n name: 'allowPullRequests',\n type: 'checkbox',\n admin: {\n description:\n 'Allow GitHub pull request events to dry-run or publish this docs set.',\n },\n defaultValue: false,\n },\n {\n name: 'description',\n type: 'textarea',\n },\n {\n name: 'advancedSecurity',\n type: 'group',\n admin: {\n description:\n 'Optional workflow lock-down. Leave disabled to allow any workflow from a trusted GitHub owner/repository and branch.',\n },\n fields: [\n {\n name: 'enabled',\n type: 'checkbox',\n admin: {\n description:\n 'When enabled, only the workflow refs listed below can publish this docs set.',\n },\n defaultValue: false,\n },\n {\n name: 'allowedWorkflowRefs',\n type: 'array',\n admin: {\n condition: (_data, siblingData) => siblingData?.enabled === true,\n description:\n 'Exact GitHub workflow refs, for example owner/repo/.github/workflows/publish-docs.yml@refs/heads/main.',\n },\n fields: [\n {\n name: 'value',\n type: 'text',\n required: true,\n },\n ],\n validate: (value, { siblingData }) => {\n const advancedSecurityData =\n typeof siblingData === 'object' && siblingData !== null\n ? (siblingData as { enabled?: unknown })\n : undefined\n\n if (\n advancedSecurityData?.enabled === true &&\n (!Array.isArray(value) || value.length === 0)\n ) {\n return 'Add at least one workflow ref or disable advanced security.'\n }\n\n return true\n },\n },\n ],\n },\n {\n name: 'aiExport',\n type: 'json',\n admin: {\n description:\n 'Parsed index.ai.yml control data for the raw Markdown AI export route.',\n },\n },\n {\n name: 'sync',\n type: 'group',\n fields: [\n {\n name: 'lastSyncedAt',\n type: 'date',\n },\n ...(syncRunsCollectionSlug\n ? [\n {\n name: 'lastSyncRunId',\n type: 'relationship' as const,\n relationTo: syncRunsCollectionSlug,\n },\n ]\n : []),\n {\n name: 'lastStatus',\n type: 'select',\n options: ['failed', 'pending', 'success'],\n },\n {\n name: 'docsCount',\n type: 'number',\n defaultValue: 0,\n },\n ],\n },\n ...(docsCollectionSlug\n ? [\n {\n name: 'docsSetManager',\n type: 'ui' as const,\n admin: {\n components: {\n Field: DOCS_SET_MANAGER_COMPONENT,\n },\n custom: {\n docsCollectionSlug,\n docsGroupsCollectionSlug,\n docsSetsCollectionSlug: slug,\n },\n },\n },\n ]\n : []),\n ],\n labels: {\n plural: 'Sets',\n singular: 'Set',\n },\n})\n"],"names":["DOCS_GLOBALS_ADMIN_GROUP","DOCS_SET_MANAGER_COMPONENT","createDocsSetsCollection","slug","docsCollectionSlug","docsGroupsCollectionSlug","syncRunsCollectionSlug","admin","defaultColumns","group","useAsTitle","fields","name","type","required","index","unique","relationTo","description","defaultValue","condition","_data","siblingData","enabled","validate","value","advancedSecurityData","
|
|
1
|
+
{"version":3,"sources":["../../src/collections/docsSets.ts"],"sourcesContent":["import type { CollectionConfig } from 'payload'\n\nimport {\n DOCS_GLOBALS_ADMIN_GROUP,\n DOCS_SET_MANAGER_COMPONENT,\n} from '../constants.js'\nimport { createPublishGeneratedDocsEndpoint } from '../endpoints/publishGeneratedDocs.js'\n\nexport type CreateDocsSetsCollectionOptions = {\n allowPublish?: boolean\n docsCollectionSlug?: string\n docsEnableDrafts?: boolean\n docsGroupsCollectionSlug: string\n slug: string\n syncRunsCollectionSlug?: string\n}\n\nexport const createDocsSetsCollection = ({\n slug,\n allowPublish = false,\n docsCollectionSlug,\n docsEnableDrafts = false,\n docsGroupsCollectionSlug,\n syncRunsCollectionSlug,\n}: CreateDocsSetsCollectionOptions): CollectionConfig => ({\n slug,\n admin: {\n defaultColumns: ['title', 'slug', 'branch', 'updatedAt'],\n group: DOCS_GLOBALS_ADMIN_GROUP,\n useAsTitle: 'title',\n },\n endpoints:\n docsCollectionSlug && docsEnableDrafts && allowPublish\n ? [\n createPublishGeneratedDocsEndpoint({\n docsCollectionSlug,\n docsSetsCollectionSlug: slug,\n }),\n ]\n : undefined,\n fields: [\n {\n name: 'title',\n type: 'text',\n required: true,\n },\n {\n name: 'slug',\n type: 'text',\n index: true,\n required: true,\n unique: true,\n },\n {\n name: 'group',\n type: 'relationship',\n relationTo: docsGroupsCollectionSlug,\n },\n {\n name: 'branch',\n type: 'text',\n admin: {\n description:\n 'Git branch allowed to publish this docs set. The full Git ref is handled internally.',\n },\n defaultValue: 'main',\n },\n {\n name: 'allowPullRequests',\n type: 'checkbox',\n admin: {\n description:\n 'Allow GitHub pull request events to dry-run or publish this docs set.',\n },\n defaultValue: false,\n },\n {\n name: 'description',\n type: 'textarea',\n },\n {\n name: 'advancedSecurity',\n type: 'group',\n admin: {\n description:\n 'Optional workflow lock-down. Leave disabled to allow any workflow from a trusted GitHub owner/repository and branch.',\n },\n fields: [\n {\n name: 'enabled',\n type: 'checkbox',\n admin: {\n description:\n 'When enabled, only the workflow refs listed below can publish this docs set.',\n },\n defaultValue: false,\n },\n {\n name: 'allowedWorkflowRefs',\n type: 'array',\n admin: {\n condition: (_data, siblingData) => siblingData?.enabled === true,\n description:\n 'Exact GitHub workflow refs, for example owner/repo/.github/workflows/publish-docs.yml@refs/heads/main.',\n },\n fields: [\n {\n name: 'value',\n type: 'text',\n required: true,\n },\n ],\n validate: (value, { siblingData }) => {\n const advancedSecurityData =\n typeof siblingData === 'object' && siblingData !== null\n ? (siblingData as { enabled?: unknown })\n : undefined\n\n if (\n advancedSecurityData?.enabled === true &&\n (!Array.isArray(value) || value.length === 0)\n ) {\n return 'Add at least one workflow ref or disable advanced security.'\n }\n\n return true\n },\n },\n ],\n },\n {\n name: 'aiExport',\n type: 'json',\n admin: {\n description:\n 'Parsed index.ai.yml control data for the raw Markdown AI export route.',\n },\n },\n {\n name: 'sync',\n type: 'group',\n fields: [\n {\n name: 'lastSyncedAt',\n type: 'date',\n },\n ...(syncRunsCollectionSlug\n ? [\n {\n name: 'lastSyncRunId',\n type: 'relationship' as const,\n relationTo: syncRunsCollectionSlug,\n },\n ]\n : []),\n {\n name: 'lastStatus',\n type: 'select',\n options: ['failed', 'pending', 'success'],\n },\n {\n name: 'docsCount',\n type: 'number',\n defaultValue: 0,\n },\n ],\n },\n ...(docsCollectionSlug\n ? [\n {\n name: 'docsSetManager',\n type: 'ui' as const,\n admin: {\n components: {\n Field: DOCS_SET_MANAGER_COMPONENT,\n },\n custom: {\n allowPublish,\n docsCollectionSlug,\n docsEnableDrafts,\n docsGroupsCollectionSlug,\n docsSetsCollectionSlug: slug,\n },\n },\n },\n ]\n : []),\n ],\n labels: {\n plural: 'Sets',\n singular: 'Set',\n },\n})\n"],"names":["DOCS_GLOBALS_ADMIN_GROUP","DOCS_SET_MANAGER_COMPONENT","createPublishGeneratedDocsEndpoint","createDocsSetsCollection","slug","allowPublish","docsCollectionSlug","docsEnableDrafts","docsGroupsCollectionSlug","syncRunsCollectionSlug","admin","defaultColumns","group","useAsTitle","endpoints","docsSetsCollectionSlug","undefined","fields","name","type","required","index","unique","relationTo","description","defaultValue","condition","_data","siblingData","enabled","validate","value","advancedSecurityData","Array","isArray","length","options","components","Field","custom","labels","plural","singular"],"mappings":"AAEA,SACEA,wBAAwB,EACxBC,0BAA0B,QACrB,kBAAiB;AACxB,SAASC,kCAAkC,QAAQ,uCAAsC;AAWzF,OAAO,MAAMC,2BAA2B,CAAC,EACvCC,IAAI,EACJC,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MAAMI,MAAM,KAAK,CAAA,GAC3C;gCACA,OAAO;4BACT;4BAEA,OAAO;wBACT;oBACF;iBACD;YACH;YACA;gBACEjB,MAAM;gBACNC,MAAM;gBACNT,OAAO;oBACLc,aACE;gBACJ;YACF;YACA;gBACEN,MAAM;gBACNC,MAAM;gBACNF,QAAQ;oBACN;wBACEC,MAAM;wBACNC,MAAM;oBACR;uBACIV,yBACA;wBACE;4BACES,MAAM;4BACNC,MAAM;4BACNI,YAAYd;wBACd;qBACD,GACD,EAAE;oBACN;wBACES,MAAM;wBACNC,MAAM;wBACNiB,SAAS;4BAAC;4BAAU;4BAAW;yBAAU;oBAC3C;oBACA;wBACElB,MAAM;wBACNC,MAAM;wBACNM,cAAc;oBAChB;iBACD;YACH;eACInB,qBACA;gBACE;oBACEY,MAAM;oBACNC,MAAM;oBACNT,OAAO;wBACL2B,YAAY;4BACVC,OAAOrC;wBACT;wBACAsC,QAAQ;4BACNlC;4BACAC;4BACAC;4BACAC;4BACAO,wBAAwBX;wBAC1B;oBACF;gBACF;aACD,GACD,EAAE;SACP;QACDoC,QAAQ;YACNC,QAAQ;YACRC,UAAU;QACZ;IACF,CAAA,EAAE"}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
export { createPublishGeneratedDocsEndpoint } from './publishGeneratedDocs.js';
|
|
2
|
+
export type { CreatePublishGeneratedDocsEndpointOptions } from './publishGeneratedDocs.js';
|
|
1
3
|
export { createSyncEndpoint } from './sync.js';
|
|
2
|
-
export type { CreateSyncEndpointOptions, DocsSyncEndpointErrorCode
|
|
4
|
+
export type { CreateSyncEndpointOptions, DocsSyncEndpointErrorCode } from './sync.js';
|
package/dist/endpoints/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/endpoints/index.ts"],"sourcesContent":["export { createSyncEndpoint } from './sync.js'\nexport type {
|
|
1
|
+
{"version":3,"sources":["../../src/endpoints/index.ts"],"sourcesContent":["export { createPublishGeneratedDocsEndpoint } from './publishGeneratedDocs.js'\nexport type { CreatePublishGeneratedDocsEndpointOptions } from './publishGeneratedDocs.js'\nexport { createSyncEndpoint } from './sync.js'\nexport type { CreateSyncEndpointOptions, DocsSyncEndpointErrorCode } from './sync.js'\n"],"names":["createPublishGeneratedDocsEndpoint","createSyncEndpoint"],"mappings":"AAAA,SAASA,kCAAkC,QAAQ,4BAA2B;AAE9E,SAASC,kBAAkB,QAAQ,YAAW"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Endpoint } from 'payload';
|
|
2
|
+
export type CreatePublishGeneratedDocsEndpointOptions = {
|
|
3
|
+
docsCollectionSlug: string;
|
|
4
|
+
docsSetsCollectionSlug: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const createPublishGeneratedDocsEndpoint: ({ docsCollectionSlug, docsSetsCollectionSlug, }: CreatePublishGeneratedDocsEndpointOptions) => Endpoint;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { publishGeneratedDocsForSet } from '../payload/publishGeneratedDocs.js';
|
|
2
|
+
const jsonResponse = (body, status = 200)=>Response.json(body, {
|
|
3
|
+
status
|
|
4
|
+
});
|
|
5
|
+
const getRouteParam = (req, key)=>{
|
|
6
|
+
const value = req.routeParams?.[key];
|
|
7
|
+
if (typeof value === 'string' || typeof value === 'number') {
|
|
8
|
+
return value;
|
|
9
|
+
}
|
|
10
|
+
return undefined;
|
|
11
|
+
};
|
|
12
|
+
const getRedirectTarget = (req)=>{
|
|
13
|
+
if (!req.url) {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
const url = new URL(req.url);
|
|
17
|
+
const redirect = url.searchParams.get('redirect');
|
|
18
|
+
if (!redirect || !redirect.startsWith('/') || redirect.startsWith('//')) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
return redirect;
|
|
22
|
+
};
|
|
23
|
+
const redirectResponse = (location)=>new Response(null, {
|
|
24
|
+
headers: {
|
|
25
|
+
Location: location
|
|
26
|
+
},
|
|
27
|
+
status: 303
|
|
28
|
+
});
|
|
29
|
+
export const createPublishGeneratedDocsEndpoint = ({ docsCollectionSlug, docsSetsCollectionSlug })=>({
|
|
30
|
+
handler: async (req)=>{
|
|
31
|
+
if (!req.user) {
|
|
32
|
+
return jsonResponse({
|
|
33
|
+
error: 'Unauthorized',
|
|
34
|
+
ok: false
|
|
35
|
+
}, 401);
|
|
36
|
+
}
|
|
37
|
+
const docsSetId = getRouteParam(req, 'id');
|
|
38
|
+
if (docsSetId === undefined) {
|
|
39
|
+
return jsonResponse({
|
|
40
|
+
error: 'Missing docs set id.',
|
|
41
|
+
ok: false
|
|
42
|
+
}, 400);
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
await req.payload.findByID({
|
|
46
|
+
id: docsSetId,
|
|
47
|
+
collection: docsSetsCollectionSlug,
|
|
48
|
+
depth: 0,
|
|
49
|
+
overrideAccess: false,
|
|
50
|
+
user: req.user
|
|
51
|
+
});
|
|
52
|
+
} catch {
|
|
53
|
+
return jsonResponse({
|
|
54
|
+
error: 'Forbidden',
|
|
55
|
+
ok: false
|
|
56
|
+
}, 403);
|
|
57
|
+
}
|
|
58
|
+
const summary = await publishGeneratedDocsForSet({
|
|
59
|
+
docsCollectionSlug,
|
|
60
|
+
docsSetId,
|
|
61
|
+
payload: req.payload
|
|
62
|
+
});
|
|
63
|
+
const redirect = getRedirectTarget(req);
|
|
64
|
+
if (redirect) {
|
|
65
|
+
return redirectResponse(redirect);
|
|
66
|
+
}
|
|
67
|
+
return jsonResponse({
|
|
68
|
+
ok: true,
|
|
69
|
+
summary
|
|
70
|
+
});
|
|
71
|
+
},
|
|
72
|
+
method: 'post',
|
|
73
|
+
path: '/:id/publish-generated-docs'
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
//# sourceMappingURL=publishGeneratedDocs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/endpoints/publishGeneratedDocs.ts"],"sourcesContent":["import type { Endpoint, PayloadRequest } from 'payload'\n\nimport type { PublishGeneratedDocsPayloadOperations } from '../payload/publishGeneratedDocs.js'\n\nimport { publishGeneratedDocsForSet } from '../payload/publishGeneratedDocs.js'\n\nexport type CreatePublishGeneratedDocsEndpointOptions = {\n docsCollectionSlug: string\n docsSetsCollectionSlug: string\n}\n\ntype AccessCheckedPayload = {\n findByID: (args: Record<string, unknown>) => Promise<unknown>\n}\n\nconst jsonResponse = (body: Record<string, unknown>, status = 200): Response =>\n Response.json(body, {\n status,\n })\n\nconst getRouteParam = (req: PayloadRequest, key: string): number | string | undefined => {\n const value = req.routeParams?.[key]\n\n if (typeof value === 'string' || typeof value === 'number') {\n return value\n }\n\n return undefined\n}\n\nconst getRedirectTarget = (req: PayloadRequest): string | undefined => {\n if (!req.url) {\n return undefined\n }\n\n const url = new URL(req.url)\n const redirect = url.searchParams.get('redirect')\n\n if (!redirect || !redirect.startsWith('/') || redirect.startsWith('//')) {\n return undefined\n }\n\n return redirect\n}\n\nconst redirectResponse = (location: string): Response =>\n new Response(null, {\n headers: {\n Location: location,\n },\n status: 303,\n })\n\nexport const createPublishGeneratedDocsEndpoint = ({\n docsCollectionSlug,\n docsSetsCollectionSlug,\n}: CreatePublishGeneratedDocsEndpointOptions): Endpoint => ({\n handler: async (req) => {\n if (!req.user) {\n return jsonResponse(\n {\n error: 'Unauthorized',\n ok: false,\n },\n 401,\n )\n }\n\n const docsSetId = getRouteParam(req, 'id')\n\n if (docsSetId === undefined) {\n return jsonResponse(\n {\n error: 'Missing docs set id.',\n ok: false,\n },\n 400,\n )\n }\n\n try {\n await (req.payload as unknown as AccessCheckedPayload).findByID({\n id: docsSetId,\n collection: docsSetsCollectionSlug,\n depth: 0,\n overrideAccess: false,\n user: req.user,\n })\n } catch {\n return jsonResponse(\n {\n error: 'Forbidden',\n ok: false,\n },\n 403,\n )\n }\n\n const summary = await publishGeneratedDocsForSet({\n docsCollectionSlug,\n docsSetId,\n payload: req.payload as unknown as PublishGeneratedDocsPayloadOperations,\n })\n const redirect = getRedirectTarget(req)\n\n if (redirect) {\n return redirectResponse(redirect)\n }\n\n return jsonResponse({\n ok: true,\n summary,\n })\n },\n method: 'post',\n path: '/:id/publish-generated-docs',\n})\n"],"names":["publishGeneratedDocsForSet","jsonResponse","body","status","Response","json","getRouteParam","req","key","value","routeParams","undefined","getRedirectTarget","url","URL","redirect","searchParams","get","startsWith","redirectResponse","location","headers","Location","createPublishGeneratedDocsEndpoint","docsCollectionSlug","docsSetsCollectionSlug","handler","user","error","ok","docsSetId","payload","findByID","id","collection","depth","overrideAccess","summary","method","path"],"mappings":"AAIA,SAASA,0BAA0B,QAAQ,qCAAoC;AAW/E,MAAMC,eAAe,CAACC,MAA+BC,SAAS,GAAG,GAC/DC,SAASC,IAAI,CAACH,MAAM;QAClBC;IACF;AAEF,MAAMG,gBAAgB,CAACC,KAAqBC;IAC1C,MAAMC,QAAQF,IAAIG,WAAW,EAAE,CAACF,IAAI;IAEpC,IAAI,OAAOC,UAAU,YAAY,OAAOA,UAAU,UAAU;QAC1D,OAAOA;IACT;IAEA,OAAOE;AACT;AAEA,MAAMC,oBAAoB,CAACL;IACzB,IAAI,CAACA,IAAIM,GAAG,EAAE;QACZ,OAAOF;IACT;IAEA,MAAME,MAAM,IAAIC,IAAIP,IAAIM,GAAG;IAC3B,MAAME,WAAWF,IAAIG,YAAY,CAACC,GAAG,CAAC;IAEtC,IAAI,CAACF,YAAY,CAACA,SAASG,UAAU,CAAC,QAAQH,SAASG,UAAU,CAAC,OAAO;QACvE,OAAOP;IACT;IAEA,OAAOI;AACT;AAEA,MAAMI,mBAAmB,CAACC,WACxB,IAAIhB,SAAS,MAAM;QACjBiB,SAAS;YACPC,UAAUF;QACZ;QACAjB,QAAQ;IACV;AAEF,OAAO,MAAMoB,qCAAqC,CAAC,EACjDC,kBAAkB,EAClBC,sBAAsB,EACoB,GAAgB,CAAA;QAC1DC,SAAS,OAAOnB;YACd,IAAI,CAACA,IAAIoB,IAAI,EAAE;gBACb,OAAO1B,aACL;oBACE2B,OAAO;oBACPC,IAAI;gBACN,GACA;YAEJ;YAEA,MAAMC,YAAYxB,cAAcC,KAAK;YAErC,IAAIuB,cAAcnB,WAAW;gBAC3B,OAAOV,aACL;oBACE2B,OAAO;oBACPC,IAAI;gBACN,GACA;YAEJ;YAEA,IAAI;gBACF,MAAM,AAACtB,IAAIwB,OAAO,CAAqCC,QAAQ,CAAC;oBAC9DC,IAAIH;oBACJI,YAAYT;oBACZU,OAAO;oBACPC,gBAAgB;oBAChBT,MAAMpB,IAAIoB,IAAI;gBAChB;YACF,EAAE,OAAM;gBACN,OAAO1B,aACL;oBACE2B,OAAO;oBACPC,IAAI;gBACN,GACA;YAEJ;YAEA,MAAMQ,UAAU,MAAMrC,2BAA2B;gBAC/CwB;gBACAM;gBACAC,SAASxB,IAAIwB,OAAO;YACtB;YACA,MAAMhB,WAAWH,kBAAkBL;YAEnC,IAAIQ,UAAU;gBACZ,OAAOI,iBAAiBJ;YAC1B;YAEA,OAAOd,aAAa;gBAClB4B,IAAI;gBACJQ;YACF;QACF;QACAC,QAAQ;QACRC,MAAM;IACR,CAAA,EAAE"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export type PublishGeneratedDocsPayloadOperations = {
|
|
2
|
+
find: (args: {
|
|
3
|
+
collection: string;
|
|
4
|
+
depth?: number;
|
|
5
|
+
limit?: number;
|
|
6
|
+
overrideAccess?: boolean;
|
|
7
|
+
where?: unknown;
|
|
8
|
+
}) => Promise<{
|
|
9
|
+
docs: unknown[];
|
|
10
|
+
}>;
|
|
11
|
+
update: (args: {
|
|
12
|
+
collection: string;
|
|
13
|
+
data: Record<string, unknown>;
|
|
14
|
+
id: number | string;
|
|
15
|
+
overrideAccess?: boolean;
|
|
16
|
+
}) => Promise<unknown>;
|
|
17
|
+
};
|
|
18
|
+
export type PublishGeneratedDocsResult = {
|
|
19
|
+
archived: number;
|
|
20
|
+
drafts: number;
|
|
21
|
+
published: number;
|
|
22
|
+
total: number;
|
|
23
|
+
updated: number;
|
|
24
|
+
};
|
|
25
|
+
export declare const publishGeneratedDocsForSet: ({ docsCollectionSlug, docsSetId, payload, }: {
|
|
26
|
+
docsCollectionSlug: string;
|
|
27
|
+
docsSetId: number | string;
|
|
28
|
+
payload: PublishGeneratedDocsPayloadOperations;
|
|
29
|
+
}) => Promise<PublishGeneratedDocsResult>;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
const isRecord = (value)=>typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
2
|
+
const getRecordId = (doc)=>{
|
|
3
|
+
if (typeof doc.id === 'string' || typeof doc.id === 'number') {
|
|
4
|
+
return doc.id;
|
|
5
|
+
}
|
|
6
|
+
return undefined;
|
|
7
|
+
};
|
|
8
|
+
const getRelationshipId = (value)=>{
|
|
9
|
+
if (typeof value === 'string' || typeof value === 'number') {
|
|
10
|
+
return String(value);
|
|
11
|
+
}
|
|
12
|
+
if (isRecord(value)) {
|
|
13
|
+
const id = getRecordId(value);
|
|
14
|
+
return id === undefined ? undefined : String(id);
|
|
15
|
+
}
|
|
16
|
+
return undefined;
|
|
17
|
+
};
|
|
18
|
+
const isArchived = (doc)=>{
|
|
19
|
+
const sync = isRecord(doc.sync) ? doc.sync : undefined;
|
|
20
|
+
return sync?.archived === true;
|
|
21
|
+
};
|
|
22
|
+
export const publishGeneratedDocsForSet = async ({ docsCollectionSlug, docsSetId, payload })=>{
|
|
23
|
+
const result = await payload.find({
|
|
24
|
+
collection: docsCollectionSlug,
|
|
25
|
+
depth: 0,
|
|
26
|
+
limit: 1000,
|
|
27
|
+
overrideAccess: true,
|
|
28
|
+
where: {
|
|
29
|
+
docsSet: {
|
|
30
|
+
equals: docsSetId
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
const summary = {
|
|
35
|
+
archived: 0,
|
|
36
|
+
drafts: 0,
|
|
37
|
+
published: 0,
|
|
38
|
+
total: 0,
|
|
39
|
+
updated: 0
|
|
40
|
+
};
|
|
41
|
+
for (const rawDoc of result.docs){
|
|
42
|
+
if (!isRecord(rawDoc)) {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
if (getRelationshipId(rawDoc.docsSet) !== String(docsSetId)) {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
summary.total += 1;
|
|
49
|
+
if (isArchived(rawDoc)) {
|
|
50
|
+
summary.archived += 1;
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
if (rawDoc._status === 'published') {
|
|
54
|
+
summary.published += 1;
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
if (rawDoc._status === 'draft') {
|
|
58
|
+
summary.drafts += 1;
|
|
59
|
+
}
|
|
60
|
+
const id = getRecordId(rawDoc);
|
|
61
|
+
if (id === undefined) {
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
await payload.update({
|
|
65
|
+
id,
|
|
66
|
+
collection: docsCollectionSlug,
|
|
67
|
+
data: {
|
|
68
|
+
_status: 'published'
|
|
69
|
+
},
|
|
70
|
+
overrideAccess: true
|
|
71
|
+
});
|
|
72
|
+
summary.updated += 1;
|
|
73
|
+
summary.published += 1;
|
|
74
|
+
}
|
|
75
|
+
return summary;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
//# sourceMappingURL=publishGeneratedDocs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/payload/publishGeneratedDocs.ts"],"sourcesContent":["export type PublishGeneratedDocsPayloadOperations = {\n find: (args: {\n collection: string\n depth?: number\n limit?: number\n overrideAccess?: boolean\n where?: unknown\n }) => Promise<{\n docs: unknown[]\n }>\n update: (args: {\n collection: string\n data: Record<string, unknown>\n id: number | string\n overrideAccess?: boolean\n }) => Promise<unknown>\n}\n\nexport type PublishGeneratedDocsResult = {\n archived: number\n drafts: number\n published: number\n total: number\n updated: number\n}\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value)\n\nconst getRecordId = (doc: Record<string, unknown>): number | string | undefined => {\n if (typeof doc.id === 'string' || typeof doc.id === 'number') {\n return doc.id\n }\n\n return undefined\n}\n\nconst getRelationshipId = (value: unknown): string | undefined => {\n if (typeof value === 'string' || typeof value === 'number') {\n return String(value)\n }\n\n if (isRecord(value)) {\n const id = getRecordId(value)\n\n return id === undefined ? undefined : String(id)\n }\n\n return undefined\n}\n\nconst isArchived = (doc: Record<string, unknown>): boolean => {\n const sync = isRecord(doc.sync) ? doc.sync : undefined\n\n return sync?.archived === true\n}\n\nexport const publishGeneratedDocsForSet = async ({\n docsCollectionSlug,\n docsSetId,\n payload,\n}: {\n docsCollectionSlug: string\n docsSetId: number | string\n payload: PublishGeneratedDocsPayloadOperations\n}): Promise<PublishGeneratedDocsResult> => {\n const result = await payload.find({\n collection: docsCollectionSlug,\n depth: 0,\n limit: 1000,\n overrideAccess: true,\n where: {\n docsSet: {\n equals: docsSetId,\n },\n },\n })\n\n const summary: PublishGeneratedDocsResult = {\n archived: 0,\n drafts: 0,\n published: 0,\n total: 0,\n updated: 0,\n }\n\n for (const rawDoc of result.docs) {\n if (!isRecord(rawDoc)) {\n continue\n }\n\n if (getRelationshipId(rawDoc.docsSet) !== String(docsSetId)) {\n continue\n }\n\n summary.total += 1\n\n if (isArchived(rawDoc)) {\n summary.archived += 1\n continue\n }\n\n if (rawDoc._status === 'published') {\n summary.published += 1\n continue\n }\n\n if (rawDoc._status === 'draft') {\n summary.drafts += 1\n }\n\n const id = getRecordId(rawDoc)\n\n if (id === undefined) {\n continue\n }\n\n await payload.update({\n id,\n collection: docsCollectionSlug,\n data: {\n _status: 'published',\n },\n overrideAccess: true,\n })\n summary.updated += 1\n summary.published += 1\n }\n\n return summary\n}\n"],"names":["isRecord","value","Array","isArray","getRecordId","doc","id","undefined","getRelationshipId","String","isArchived","sync","archived","publishGeneratedDocsForSet","docsCollectionSlug","docsSetId","payload","result","find","collection","depth","limit","overrideAccess","where","docsSet","equals","summary","drafts","published","total","updated","rawDoc","docs","_status","update","data"],"mappings":"AA0BA,MAAMA,WAAW,CAACC,QAChB,OAAOA,UAAU,YAAYA,UAAU,QAAQ,CAACC,MAAMC,OAAO,CAACF;AAEhE,MAAMG,cAAc,CAACC;IACnB,IAAI,OAAOA,IAAIC,EAAE,KAAK,YAAY,OAAOD,IAAIC,EAAE,KAAK,UAAU;QAC5D,OAAOD,IAAIC,EAAE;IACf;IAEA,OAAOC;AACT;AAEA,MAAMC,oBAAoB,CAACP;IACzB,IAAI,OAAOA,UAAU,YAAY,OAAOA,UAAU,UAAU;QAC1D,OAAOQ,OAAOR;IAChB;IAEA,IAAID,SAASC,QAAQ;QACnB,MAAMK,KAAKF,YAAYH;QAEvB,OAAOK,OAAOC,YAAYA,YAAYE,OAAOH;IAC/C;IAEA,OAAOC;AACT;AAEA,MAAMG,aAAa,CAACL;IAClB,MAAMM,OAAOX,SAASK,IAAIM,IAAI,IAAIN,IAAIM,IAAI,GAAGJ;IAE7C,OAAOI,MAAMC,aAAa;AAC5B;AAEA,OAAO,MAAMC,6BAA6B,OAAO,EAC/CC,kBAAkB,EAClBC,SAAS,EACTC,OAAO,EAKR;IACC,MAAMC,SAAS,MAAMD,QAAQE,IAAI,CAAC;QAChCC,YAAYL;QACZM,OAAO;QACPC,OAAO;QACPC,gBAAgB;QAChBC,OAAO;YACLC,SAAS;gBACPC,QAAQV;YACV;QACF;IACF;IAEA,MAAMW,UAAsC;QAC1Cd,UAAU;QACVe,QAAQ;QACRC,WAAW;QACXC,OAAO;QACPC,SAAS;IACX;IAEA,KAAK,MAAMC,UAAUd,OAAOe,IAAI,CAAE;QAChC,IAAI,CAAChC,SAAS+B,SAAS;YACrB;QACF;QAEA,IAAIvB,kBAAkBuB,OAAOP,OAAO,MAAMf,OAAOM,YAAY;YAC3D;QACF;QAEAW,QAAQG,KAAK,IAAI;QAEjB,IAAInB,WAAWqB,SAAS;YACtBL,QAAQd,QAAQ,IAAI;YACpB;QACF;QAEA,IAAImB,OAAOE,OAAO,KAAK,aAAa;YAClCP,QAAQE,SAAS,IAAI;YACrB;QACF;QAEA,IAAIG,OAAOE,OAAO,KAAK,SAAS;YAC9BP,QAAQC,MAAM,IAAI;QACpB;QAEA,MAAMrB,KAAKF,YAAY2B;QAEvB,IAAIzB,OAAOC,WAAW;YACpB;QACF;QAEA,MAAMS,QAAQkB,MAAM,CAAC;YACnB5B;YACAa,YAAYL;YACZqB,MAAM;gBACJF,SAAS;YACX;YACAX,gBAAgB;QAClB;QACAI,QAAQI,OAAO,IAAI;QACnBJ,QAAQE,SAAS,IAAI;IACvB;IAEA,OAAOF;AACT,EAAC"}
|
package/dist/plugin.js
CHANGED
|
@@ -106,7 +106,9 @@ export const payloadMarkdownDocs = (pluginOptions = {})=>(incomingConfig)=>{
|
|
|
106
106
|
...docsSetsEnabled ? [
|
|
107
107
|
createDocsSetsCollection({
|
|
108
108
|
slug: docsSetsCollectionSlug,
|
|
109
|
+
allowPublish: pluginOptions.sync?.allowPublish === true,
|
|
109
110
|
docsCollectionSlug: docsEnabled ? docsCollectionSlug : undefined,
|
|
111
|
+
docsEnableDrafts: enableDrafts,
|
|
110
112
|
docsGroupsCollectionSlug,
|
|
111
113
|
syncRunsCollectionSlug: syncRunsEnabled ? syncRunsCollectionSlug : undefined
|
|
112
114
|
})
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugin.ts"],"sourcesContent":["import type { Config, Plugin } from 'payload'\n\nimport type { PayloadMarkdownDocsConfig } from './types.js'\n\nimport {\n createDocsCollection,\n createDocsGroupsCollection,\n createDocsKeysCollection,\n createDocsSetsCollection,\n createDocsTrustedCollection,\n createNoncesCollection,\n createSyncRunsCollection,\n} from './collections/index.js'\nimport {\n DEFAULT_DOCS_COLLECTION_SLUG,\n DEFAULT_DOCS_GROUPS_COLLECTION_SLUG,\n DEFAULT_DOCS_KEYS_COLLECTION_SLUG,\n DEFAULT_DOCS_SETS_COLLECTION_SLUG,\n DEFAULT_DOCS_SYNC_ENDPOINT_PATH,\n DEFAULT_DOCS_SYNC_NONCES_COLLECTION_SLUG,\n DEFAULT_DOCS_SYNC_RUNS_COLLECTION_SLUG,\n DEFAULT_DOCS_TRUSTED_COLLECTION_SLUG,\n DEFAULT_MARKDOWN_FIELD_NAME,\n DEFAULT_MAX_BODY_BYTES,\n DEFAULT_PAGES_BRIDGE_FIELD,\n DEFAULT_PAGES_COLLECTION_SLUG,\n DEFAULT_PAGES_ROUTE_FIELD,\n} from './constants.js'\nimport { createSyncEndpoint } from './endpoints/index.js'\n\ntype ResolvedCollectionOptions = {\n docsCollectionSlug: string\n docsEnabled: boolean\n docsGroupsCollectionSlug: string\n docsGroupsEnabled: boolean\n docsKeysCollectionSlug: string\n docsKeysEnabled: boolean\n docsSetsCollectionSlug: string\n docsSetsEnabled: boolean\n docsTrustedCollectionSlug: string\n docsTrustedEnabled: boolean\n enableDrafts: boolean\n markdownFieldName: string\n noncesCollectionSlug: string\n noncesEnabled: boolean\n syncRunsCollectionSlug: string\n syncRunsEnabled: boolean\n}\n\nconst normalizeEndpointPath = (path: string): string => {\n const normalized = `/${path.trim()}`.replace(/\\/+/g, '/')\n\n return normalized.length > 1 ? normalized.replace(/\\/+$/g, '') : normalized\n}\n\nconst resolveCollectionOptions = (\n pluginOptions: PayloadMarkdownDocsConfig,\n): ResolvedCollectionOptions => {\n if (\n pluginOptions.target?.type !== undefined &&\n pluginOptions.target.type !== 'docsCollection'\n ) {\n throw new Error(\n 'payloadMarkdownDocs: target.type only supports \"docsCollection\". existingCollection is not supported.',\n )\n }\n\n const docsSlugFromTarget = pluginOptions.target?.slug\n const docsSlugFromCollections = pluginOptions.collections?.docs?.slug\n\n if (\n docsSlugFromTarget &&\n docsSlugFromCollections &&\n docsSlugFromTarget !== docsSlugFromCollections\n ) {\n throw new Error(\n 'payloadMarkdownDocs: target.slug and collections.docs.slug must match when both are provided.',\n )\n }\n\n return {\n docsCollectionSlug:\n docsSlugFromTarget ?? docsSlugFromCollections ?? DEFAULT_DOCS_COLLECTION_SLUG,\n docsEnabled: pluginOptions.collections?.docs?.enabled !== false,\n docsGroupsCollectionSlug:\n pluginOptions.collections?.docsGroups?.slug ?? DEFAULT_DOCS_GROUPS_COLLECTION_SLUG,\n docsGroupsEnabled: pluginOptions.collections?.docsGroups?.enabled !== false,\n docsKeysCollectionSlug:\n pluginOptions.collections?.docsKeys?.slug ?? DEFAULT_DOCS_KEYS_COLLECTION_SLUG,\n docsKeysEnabled: pluginOptions.collections?.docsKeys?.enabled !== false,\n docsSetsCollectionSlug:\n pluginOptions.collections?.docsSets?.slug ?? DEFAULT_DOCS_SETS_COLLECTION_SLUG,\n docsSetsEnabled: pluginOptions.collections?.docsSets?.enabled !== false,\n docsTrustedCollectionSlug:\n pluginOptions.collections?.docsTrusted?.slug ?? DEFAULT_DOCS_TRUSTED_COLLECTION_SLUG,\n docsTrustedEnabled: pluginOptions.collections?.docsTrusted?.enabled !== false,\n enableDrafts:\n pluginOptions.target?.enableDrafts === true,\n markdownFieldName:\n pluginOptions.target?.markdownField ?? DEFAULT_MARKDOWN_FIELD_NAME,\n noncesCollectionSlug:\n pluginOptions.collections?.nonces?.slug ?? DEFAULT_DOCS_SYNC_NONCES_COLLECTION_SLUG,\n noncesEnabled: pluginOptions.collections?.nonces?.enabled !== false,\n syncRunsCollectionSlug:\n pluginOptions.collections?.syncRuns?.slug ?? DEFAULT_DOCS_SYNC_RUNS_COLLECTION_SLUG,\n syncRunsEnabled: pluginOptions.collections?.syncRuns?.enabled !== false,\n }\n}\n\nconst assertCollectionOptionCompatibility = ({\n docsGroupsEnabled,\n docsSetsEnabled,\n}: ResolvedCollectionOptions) => {\n if (docsSetsEnabled && !docsGroupsEnabled) {\n throw new Error(\n 'payloadMarkdownDocs: collections.docsSets requires collections.docsGroups to be enabled.',\n )\n }\n}\n\nconst assertNoCollectionSlugConflicts = (\n incomingConfig: Config,\n collectionSlugsToAdd: string[],\n) => {\n const duplicateRequestedSlug = collectionSlugsToAdd.find(\n (slug, index) => collectionSlugsToAdd.indexOf(slug) !== index,\n )\n\n if (duplicateRequestedSlug) {\n throw new Error(\n `payloadMarkdownDocs: collection slug \"${duplicateRequestedSlug}\" is configured more than once.`,\n )\n }\n\n const existingCollectionSlugs = new Set(\n incomingConfig.collections?.map((collection) => collection.slug) ?? [],\n )\n\n const conflictingSlug = collectionSlugsToAdd.find((slug) =>\n existingCollectionSlugs.has(slug),\n )\n\n if (conflictingSlug) {\n throw new Error(\n `payloadMarkdownDocs: collection slug \"${conflictingSlug}\" already exists in the Payload config.`,\n )\n }\n}\n\nexport const payloadMarkdownDocs =\n (pluginOptions: PayloadMarkdownDocsConfig = {}): Plugin =>\n (incomingConfig: Config): Config => {\n if (pluginOptions.enabled === false) {\n return incomingConfig\n }\n\n const {\n docsCollectionSlug,\n docsEnabled,\n docsGroupsCollectionSlug,\n docsGroupsEnabled,\n docsKeysCollectionSlug,\n docsKeysEnabled,\n docsSetsCollectionSlug,\n docsSetsEnabled,\n docsTrustedCollectionSlug,\n docsTrustedEnabled,\n enableDrafts,\n markdownFieldName,\n noncesCollectionSlug,\n noncesEnabled,\n syncRunsCollectionSlug,\n syncRunsEnabled,\n } = resolveCollectionOptions(pluginOptions)\n assertCollectionOptionCompatibility({\n docsCollectionSlug,\n docsEnabled,\n docsGroupsCollectionSlug,\n docsGroupsEnabled,\n docsKeysCollectionSlug,\n docsKeysEnabled,\n docsSetsCollectionSlug,\n docsSetsEnabled,\n docsTrustedCollectionSlug,\n docsTrustedEnabled,\n enableDrafts,\n markdownFieldName,\n noncesCollectionSlug,\n noncesEnabled,\n syncRunsCollectionSlug,\n syncRunsEnabled,\n })\n const endpointPath = normalizeEndpointPath(\n pluginOptions.endpoint?.path ?? DEFAULT_DOCS_SYNC_ENDPOINT_PATH,\n )\n\n const collectionSlugsToAdd = [\n ...(docsGroupsEnabled ? [docsGroupsCollectionSlug] : []),\n ...(docsSetsEnabled ? [docsSetsCollectionSlug] : []),\n ...(docsKeysEnabled ? [docsKeysCollectionSlug] : []),\n ...(docsTrustedEnabled ? [docsTrustedCollectionSlug] : []),\n ...(docsEnabled ? [docsCollectionSlug] : []),\n ...(syncRunsEnabled ? [syncRunsCollectionSlug] : []),\n ...(noncesEnabled ? [noncesCollectionSlug] : []),\n ]\n\n assertNoCollectionSlugConflicts(incomingConfig, collectionSlugsToAdd)\n\n const addedCollections = [\n ...(docsGroupsEnabled\n ? [\n createDocsGroupsCollection({\n slug: docsGroupsCollectionSlug,\n }),\n ]\n : []),\n ...(docsSetsEnabled\n ? [\n createDocsSetsCollection({\n slug: docsSetsCollectionSlug,\n docsCollectionSlug: docsEnabled ? docsCollectionSlug : undefined,\n docsGroupsCollectionSlug,\n syncRunsCollectionSlug: syncRunsEnabled ? syncRunsCollectionSlug : undefined,\n }),\n ]\n : []),\n ...(docsKeysEnabled\n ? [\n createDocsKeysCollection({\n slug: docsKeysCollectionSlug,\n }),\n ]\n : []),\n ...(docsTrustedEnabled\n ? [\n createDocsTrustedCollection({\n slug: docsTrustedCollectionSlug,\n }),\n ]\n : []),\n ...(docsEnabled\n ? [\n createDocsCollection({\n slug: docsCollectionSlug,\n docsSetsCollectionSlug: docsSetsEnabled\n ? docsSetsCollectionSlug\n : undefined,\n enableDrafts,\n markdownFieldName,\n syncRunsCollectionSlug: syncRunsEnabled ? syncRunsCollectionSlug : undefined,\n }),\n ]\n : []),\n ...(syncRunsEnabled\n ? [\n createSyncRunsCollection({\n slug: syncRunsCollectionSlug,\n }),\n ]\n : []),\n ...(noncesEnabled\n ? [\n createNoncesCollection({\n slug: noncesCollectionSlug,\n syncRunsCollectionSlug: syncRunsEnabled ? syncRunsCollectionSlug : undefined,\n }),\n ]\n : []),\n ]\n\n return {\n ...incomingConfig,\n collections: [...(incomingConfig.collections ?? []), ...addedCollections],\n endpoints: [\n ...(incomingConfig.endpoints ?? []),\n createSyncEndpoint({\n allowHardDelete: pluginOptions.sync?.allowHardDelete,\n allowPublish: pluginOptions.sync?.allowPublish,\n allowWrites: pluginOptions.sync?.allowWrites,\n auth: pluginOptions.auth,\n defaultPublishMode: pluginOptions.sync?.defaultPublishMode,\n deleteBehavior: pluginOptions.sync?.deleteBehavior,\n docsCollectionSlug,\n docsEnabled,\n docsEnableDrafts: enableDrafts,\n docsGroupsCollectionSlug,\n docsKeysCollectionSlug,\n docsKeysEnabled,\n docsSetsCollectionSlug,\n docsSetsEnabled,\n docsTrustedCollectionSlug,\n docsTrustedEnabled,\n endpointPath,\n markdownFieldName,\n maxBodyBytes: pluginOptions.endpoint?.maxBodyBytes ?? DEFAULT_MAX_BODY_BYTES,\n noncesCollectionSlug,\n noncesEnabled,\n requireDryRunBeforeApply: pluginOptions.sync?.requireDryRunBeforeApply,\n routing: {\n pages: {\n allowBridgePages:\n pluginOptions.routing?.pages?.allowBridgePages ?? true,\n bridgeField:\n pluginOptions.routing?.pages?.bridgeField ?? DEFAULT_PAGES_BRIDGE_FIELD,\n collection:\n pluginOptions.routing?.pages?.collection ?? DEFAULT_PAGES_COLLECTION_SLUG,\n enabled: pluginOptions.routing?.pages?.enabled === true,\n routeField:\n pluginOptions.routing?.pages?.routeField ?? DEFAULT_PAGES_ROUTE_FIELD,\n },\n },\n syncRunsCollectionSlug,\n syncRunsEnabled,\n }),\n ],\n }\n }\n"],"names":["createDocsCollection","createDocsGroupsCollection","createDocsKeysCollection","createDocsSetsCollection","createDocsTrustedCollection","createNoncesCollection","createSyncRunsCollection","DEFAULT_DOCS_COLLECTION_SLUG","DEFAULT_DOCS_GROUPS_COLLECTION_SLUG","DEFAULT_DOCS_KEYS_COLLECTION_SLUG","DEFAULT_DOCS_SETS_COLLECTION_SLUG","DEFAULT_DOCS_SYNC_ENDPOINT_PATH","DEFAULT_DOCS_SYNC_NONCES_COLLECTION_SLUG","DEFAULT_DOCS_SYNC_RUNS_COLLECTION_SLUG","DEFAULT_DOCS_TRUSTED_COLLECTION_SLUG","DEFAULT_MARKDOWN_FIELD_NAME","DEFAULT_MAX_BODY_BYTES","DEFAULT_PAGES_BRIDGE_FIELD","DEFAULT_PAGES_COLLECTION_SLUG","DEFAULT_PAGES_ROUTE_FIELD","createSyncEndpoint","normalizeEndpointPath","path","normalized","trim","replace","length","resolveCollectionOptions","pluginOptions","target","type","undefined","Error","docsSlugFromTarget","slug","docsSlugFromCollections","collections","docs","docsCollectionSlug","docsEnabled","enabled","docsGroupsCollectionSlug","docsGroups","docsGroupsEnabled","docsKeysCollectionSlug","docsKeys","docsKeysEnabled","docsSetsCollectionSlug","docsSets","docsSetsEnabled","docsTrustedCollectionSlug","docsTrusted","docsTrustedEnabled","enableDrafts","markdownFieldName","markdownField","noncesCollectionSlug","nonces","noncesEnabled","syncRunsCollectionSlug","syncRuns","syncRunsEnabled","assertCollectionOptionCompatibility","assertNoCollectionSlugConflicts","incomingConfig","collectionSlugsToAdd","duplicateRequestedSlug","find","index","indexOf","existingCollectionSlugs","Set","map","collection","conflictingSlug","has","payloadMarkdownDocs","endpointPath","endpoint","addedCollections","endpoints","allowHardDelete","sync","allowPublish","allowWrites","auth","defaultPublishMode","deleteBehavior","docsEnableDrafts","maxBodyBytes","requireDryRunBeforeApply","routing","pages","allowBridgePages","bridgeField","routeField"],"mappings":"AAIA,SACEA,oBAAoB,EACpBC,0BAA0B,EAC1BC,wBAAwB,EACxBC,wBAAwB,EACxBC,2BAA2B,EAC3BC,sBAAsB,EACtBC,wBAAwB,QACnB,yBAAwB;AAC/B,SACEC,4BAA4B,EAC5BC,mCAAmC,EACnCC,iCAAiC,EACjCC,iCAAiC,EACjCC,+BAA+B,EAC/BC,wCAAwC,EACxCC,sCAAsC,EACtCC,oCAAoC,EACpCC,2BAA2B,EAC3BC,sBAAsB,EACtBC,0BAA0B,EAC1BC,6BAA6B,EAC7BC,yBAAyB,QACpB,iBAAgB;AACvB,SAASC,kBAAkB,QAAQ,uBAAsB;AAqBzD,MAAMC,wBAAwB,CAACC;IAC7B,MA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e5B,WAAW,IAAI,EAAE;mBAAM2C;aAAiB;YACzEC,WAAW;mBACLhB,eAAegB,SAAS,IAAI,EAAE;gBAClC5D,mBAAmB;oBACjB6D,iBAAiBrD,cAAcsD,IAAI,EAAED;oBACrCE,cAAcvD,cAAcsD,IAAI,EAAEC;oBAClCC,aAAaxD,cAAcsD,IAAI,EAAEE;oBACjCC,MAAMzD,cAAcyD,IAAI;oBACxBC,oBAAoB1D,cAAcsD,IAAI,EAAEI;oBACxCC,gBAAgB3D,cAAcsD,IAAI,EAAEK;oBACpCjD;oBACAC;oBACAiD,kBAAkBnC;oBAClBZ;oBACAG;oBACAE;oBACAC;oBACAE;oBACAC;oBACAE;oBACAyB;oBACAvB;oBACAmC,cAAc7D,cAAckD,QAAQ,EAAEW,gBAAgBzE;oBACtDwC;oBACAE;oBACAgC,0BAA0B9D,cAAcsD,IAAI,EAAEQ;oBAC9CC,SAAS;wBACPC,OAAO;4BACLC,kBACEjE,cAAc+D,OAAO,EAAEC,OAAOC,oBAAoB;4BACpDC,aACElE,cAAc+D,OAAO,EAAEC,OAAOE,eAAe7E;4BAC/CwD,YACE7C,cAAc+D,OAAO,EAAEC,OAAOnB,cAAcvD;4BAC9CsB,SAASZ,cAAc+D,OAAO,EAAEC,OAAOpD,YAAY;4BACnDuD,YACEnE,cAAc+D,OAAO,EAAEC,OAAOG,cAAc5E;wBAChD;oBACF;oBACAwC;oBACAE;gBACF;aACD;QACH;IACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../src/plugin.ts"],"sourcesContent":["import type { Config, Plugin } from 'payload'\n\nimport type { PayloadMarkdownDocsConfig } from './types.js'\n\nimport {\n createDocsCollection,\n createDocsGroupsCollection,\n createDocsKeysCollection,\n createDocsSetsCollection,\n createDocsTrustedCollection,\n createNoncesCollection,\n createSyncRunsCollection,\n} from './collections/index.js'\nimport {\n DEFAULT_DOCS_COLLECTION_SLUG,\n DEFAULT_DOCS_GROUPS_COLLECTION_SLUG,\n DEFAULT_DOCS_KEYS_COLLECTION_SLUG,\n DEFAULT_DOCS_SETS_COLLECTION_SLUG,\n DEFAULT_DOCS_SYNC_ENDPOINT_PATH,\n DEFAULT_DOCS_SYNC_NONCES_COLLECTION_SLUG,\n DEFAULT_DOCS_SYNC_RUNS_COLLECTION_SLUG,\n DEFAULT_DOCS_TRUSTED_COLLECTION_SLUG,\n DEFAULT_MARKDOWN_FIELD_NAME,\n DEFAULT_MAX_BODY_BYTES,\n DEFAULT_PAGES_BRIDGE_FIELD,\n DEFAULT_PAGES_COLLECTION_SLUG,\n DEFAULT_PAGES_ROUTE_FIELD,\n} from './constants.js'\nimport { createSyncEndpoint } from './endpoints/index.js'\n\ntype ResolvedCollectionOptions = {\n docsCollectionSlug: string\n docsEnabled: boolean\n docsGroupsCollectionSlug: string\n docsGroupsEnabled: boolean\n docsKeysCollectionSlug: string\n docsKeysEnabled: boolean\n docsSetsCollectionSlug: string\n docsSetsEnabled: boolean\n docsTrustedCollectionSlug: string\n docsTrustedEnabled: boolean\n enableDrafts: boolean\n markdownFieldName: string\n noncesCollectionSlug: string\n noncesEnabled: boolean\n syncRunsCollectionSlug: string\n syncRunsEnabled: boolean\n}\n\nconst normalizeEndpointPath = (path: string): string => {\n const normalized = `/${path.trim()}`.replace(/\\/+/g, '/')\n\n return normalized.length > 1 ? normalized.replace(/\\/+$/g, '') : normalized\n}\n\nconst resolveCollectionOptions = (\n pluginOptions: PayloadMarkdownDocsConfig,\n): ResolvedCollectionOptions => {\n if (\n pluginOptions.target?.type !== undefined &&\n pluginOptions.target.type !== 'docsCollection'\n ) {\n throw new Error(\n 'payloadMarkdownDocs: target.type only supports \"docsCollection\". existingCollection is not supported.',\n )\n }\n\n const docsSlugFromTarget = pluginOptions.target?.slug\n const docsSlugFromCollections = pluginOptions.collections?.docs?.slug\n\n if (\n docsSlugFromTarget &&\n docsSlugFromCollections &&\n docsSlugFromTarget !== docsSlugFromCollections\n ) {\n throw new Error(\n 'payloadMarkdownDocs: target.slug and collections.docs.slug must match when both are provided.',\n )\n }\n\n return {\n docsCollectionSlug:\n docsSlugFromTarget ?? docsSlugFromCollections ?? DEFAULT_DOCS_COLLECTION_SLUG,\n docsEnabled: pluginOptions.collections?.docs?.enabled !== false,\n docsGroupsCollectionSlug:\n pluginOptions.collections?.docsGroups?.slug ?? DEFAULT_DOCS_GROUPS_COLLECTION_SLUG,\n docsGroupsEnabled: pluginOptions.collections?.docsGroups?.enabled !== false,\n docsKeysCollectionSlug:\n pluginOptions.collections?.docsKeys?.slug ?? DEFAULT_DOCS_KEYS_COLLECTION_SLUG,\n docsKeysEnabled: pluginOptions.collections?.docsKeys?.enabled !== false,\n docsSetsCollectionSlug:\n pluginOptions.collections?.docsSets?.slug ?? DEFAULT_DOCS_SETS_COLLECTION_SLUG,\n docsSetsEnabled: pluginOptions.collections?.docsSets?.enabled !== false,\n docsTrustedCollectionSlug:\n pluginOptions.collections?.docsTrusted?.slug ?? DEFAULT_DOCS_TRUSTED_COLLECTION_SLUG,\n docsTrustedEnabled: pluginOptions.collections?.docsTrusted?.enabled !== false,\n enableDrafts:\n pluginOptions.target?.enableDrafts === true,\n markdownFieldName:\n pluginOptions.target?.markdownField ?? DEFAULT_MARKDOWN_FIELD_NAME,\n noncesCollectionSlug:\n pluginOptions.collections?.nonces?.slug ?? DEFAULT_DOCS_SYNC_NONCES_COLLECTION_SLUG,\n noncesEnabled: pluginOptions.collections?.nonces?.enabled !== false,\n syncRunsCollectionSlug:\n pluginOptions.collections?.syncRuns?.slug ?? DEFAULT_DOCS_SYNC_RUNS_COLLECTION_SLUG,\n syncRunsEnabled: pluginOptions.collections?.syncRuns?.enabled !== false,\n }\n}\n\nconst assertCollectionOptionCompatibility = ({\n docsGroupsEnabled,\n docsSetsEnabled,\n}: ResolvedCollectionOptions) => {\n if (docsSetsEnabled && !docsGroupsEnabled) {\n throw new Error(\n 'payloadMarkdownDocs: collections.docsSets requires collections.docsGroups to be enabled.',\n )\n }\n}\n\nconst assertNoCollectionSlugConflicts = (\n incomingConfig: Config,\n collectionSlugsToAdd: string[],\n) => {\n const duplicateRequestedSlug = collectionSlugsToAdd.find(\n (slug, index) => collectionSlugsToAdd.indexOf(slug) !== index,\n )\n\n if (duplicateRequestedSlug) {\n throw new Error(\n `payloadMarkdownDocs: collection slug \"${duplicateRequestedSlug}\" is configured more than once.`,\n )\n }\n\n const existingCollectionSlugs = new Set(\n incomingConfig.collections?.map((collection) => collection.slug) ?? [],\n )\n\n const conflictingSlug = collectionSlugsToAdd.find((slug) =>\n existingCollectionSlugs.has(slug),\n )\n\n if (conflictingSlug) {\n throw new Error(\n `payloadMarkdownDocs: collection slug \"${conflictingSlug}\" already exists in the Payload config.`,\n )\n }\n}\n\nexport const payloadMarkdownDocs =\n (pluginOptions: PayloadMarkdownDocsConfig = {}): Plugin =>\n (incomingConfig: Config): Config => {\n if (pluginOptions.enabled === false) {\n return incomingConfig\n }\n\n const {\n docsCollectionSlug,\n docsEnabled,\n docsGroupsCollectionSlug,\n docsGroupsEnabled,\n docsKeysCollectionSlug,\n docsKeysEnabled,\n docsSetsCollectionSlug,\n docsSetsEnabled,\n docsTrustedCollectionSlug,\n docsTrustedEnabled,\n enableDrafts,\n markdownFieldName,\n noncesCollectionSlug,\n noncesEnabled,\n syncRunsCollectionSlug,\n syncRunsEnabled,\n } = resolveCollectionOptions(pluginOptions)\n assertCollectionOptionCompatibility({\n docsCollectionSlug,\n docsEnabled,\n docsGroupsCollectionSlug,\n docsGroupsEnabled,\n docsKeysCollectionSlug,\n docsKeysEnabled,\n docsSetsCollectionSlug,\n docsSetsEnabled,\n docsTrustedCollectionSlug,\n docsTrustedEnabled,\n enableDrafts,\n markdownFieldName,\n noncesCollectionSlug,\n noncesEnabled,\n syncRunsCollectionSlug,\n syncRunsEnabled,\n })\n const endpointPath = normalizeEndpointPath(\n pluginOptions.endpoint?.path ?? DEFAULT_DOCS_SYNC_ENDPOINT_PATH,\n )\n\n const collectionSlugsToAdd = [\n ...(docsGroupsEnabled ? [docsGroupsCollectionSlug] : []),\n ...(docsSetsEnabled ? [docsSetsCollectionSlug] : []),\n ...(docsKeysEnabled ? [docsKeysCollectionSlug] : []),\n ...(docsTrustedEnabled ? [docsTrustedCollectionSlug] : []),\n ...(docsEnabled ? [docsCollectionSlug] : []),\n ...(syncRunsEnabled ? [syncRunsCollectionSlug] : []),\n ...(noncesEnabled ? [noncesCollectionSlug] : []),\n ]\n\n assertNoCollectionSlugConflicts(incomingConfig, collectionSlugsToAdd)\n\n const addedCollections = [\n ...(docsGroupsEnabled\n ? [\n createDocsGroupsCollection({\n slug: docsGroupsCollectionSlug,\n }),\n ]\n : []),\n ...(docsSetsEnabled\n ? [\n createDocsSetsCollection({\n slug: docsSetsCollectionSlug,\n allowPublish: pluginOptions.sync?.allowPublish === true,\n docsCollectionSlug: docsEnabled ? docsCollectionSlug : undefined,\n docsEnableDrafts: enableDrafts,\n docsGroupsCollectionSlug,\n syncRunsCollectionSlug: syncRunsEnabled ? syncRunsCollectionSlug : undefined,\n }),\n ]\n : []),\n ...(docsKeysEnabled\n ? [\n createDocsKeysCollection({\n slug: docsKeysCollectionSlug,\n }),\n ]\n : []),\n ...(docsTrustedEnabled\n ? [\n createDocsTrustedCollection({\n slug: docsTrustedCollectionSlug,\n }),\n ]\n : []),\n ...(docsEnabled\n ? [\n createDocsCollection({\n slug: docsCollectionSlug,\n docsSetsCollectionSlug: docsSetsEnabled\n ? docsSetsCollectionSlug\n : undefined,\n enableDrafts,\n markdownFieldName,\n syncRunsCollectionSlug: syncRunsEnabled ? syncRunsCollectionSlug : undefined,\n }),\n ]\n : []),\n ...(syncRunsEnabled\n ? [\n createSyncRunsCollection({\n slug: syncRunsCollectionSlug,\n }),\n ]\n : []),\n ...(noncesEnabled\n ? [\n createNoncesCollection({\n slug: noncesCollectionSlug,\n syncRunsCollectionSlug: syncRunsEnabled ? syncRunsCollectionSlug : undefined,\n }),\n ]\n : []),\n ]\n\n return {\n ...incomingConfig,\n collections: [...(incomingConfig.collections ?? []), ...addedCollections],\n endpoints: [\n ...(incomingConfig.endpoints ?? []),\n createSyncEndpoint({\n allowHardDelete: pluginOptions.sync?.allowHardDelete,\n allowPublish: pluginOptions.sync?.allowPublish,\n allowWrites: pluginOptions.sync?.allowWrites,\n auth: pluginOptions.auth,\n defaultPublishMode: pluginOptions.sync?.defaultPublishMode,\n deleteBehavior: pluginOptions.sync?.deleteBehavior,\n docsCollectionSlug,\n docsEnabled,\n docsEnableDrafts: enableDrafts,\n docsGroupsCollectionSlug,\n docsKeysCollectionSlug,\n docsKeysEnabled,\n docsSetsCollectionSlug,\n docsSetsEnabled,\n docsTrustedCollectionSlug,\n docsTrustedEnabled,\n endpointPath,\n markdownFieldName,\n maxBodyBytes: pluginOptions.endpoint?.maxBodyBytes ?? DEFAULT_MAX_BODY_BYTES,\n noncesCollectionSlug,\n noncesEnabled,\n requireDryRunBeforeApply: pluginOptions.sync?.requireDryRunBeforeApply,\n routing: {\n pages: {\n allowBridgePages:\n pluginOptions.routing?.pages?.allowBridgePages ?? true,\n bridgeField:\n pluginOptions.routing?.pages?.bridgeField ?? DEFAULT_PAGES_BRIDGE_FIELD,\n collection:\n pluginOptions.routing?.pages?.collection ?? DEFAULT_PAGES_COLLECTION_SLUG,\n enabled: pluginOptions.routing?.pages?.enabled === true,\n routeField:\n pluginOptions.routing?.pages?.routeField ?? DEFAULT_PAGES_ROUTE_FIELD,\n },\n },\n syncRunsCollectionSlug,\n syncRunsEnabled,\n }),\n ],\n }\n }\n"],"names":["createDocsCollection","createDocsGroupsCollection","createDocsKeysCollection","createDocsSetsCollection","createDocsTrustedCollection","createNoncesCollection","createSyncRunsCollection","DEFAULT_DOCS_COLLECTION_SLUG","DEFAULT_DOCS_GROUPS_COLLECTION_SLUG","DEFAULT_DOCS_KEYS_COLLECTION_SLUG","DEFAULT_DOCS_SETS_COLLECTION_SLUG","DEFAULT_DOCS_SYNC_ENDPOINT_PATH","DEFAULT_DOCS_SYNC_NONCES_COLLECTION_SLUG","DEFAULT_DOCS_SYNC_RUNS_COLLECTION_SLUG","DEFAULT_DOCS_TRUSTED_COLLECTION_SLUG","DEFAULT_MARKDOWN_FIELD_NAME","DEFAULT_MAX_BODY_BYTES","DEFAULT_PAGES_BRIDGE_FIELD","DEFAULT_PAGES_COLLECTION_SLUG","DEFAULT_PAGES_ROUTE_FIELD","createSyncEndpoint","normalizeEndpointPath","path","normalized","trim","replace","length","resolveCollectionOptions","pluginOptions","target","type","undefined","Error","docsSlugFromTarget","slug","docsSlugFromCollections","collections","docs","docsCollectionSlug","docsEnabled","enabled","docsGroupsCollectionSlug","docsGroups","docsGroupsEnabled","docsKeysCollectionSlug","docsKeys","docsKeysEnabled","docsSetsCollectionSlug","docsSets","docsSetsEnabled","docsTrustedCollectionSlug","docsTrusted","docsTrustedEnabled","enableDrafts","markdownFieldName","markdownField","noncesCollectionSlug","nonces","noncesEnabled","syncRunsCollectionSlug","syncRuns","syncRunsEnabled","assertCollectionOptionCompatibility","assertNoCollectionSlugConflicts","incomingConfig","collectionSlugsToAdd","duplicateRequestedSlug","find","index","indexOf","existingCollectionSlugs","Set","map","collection","conflictingSlug","has","payloadMarkdownDocs","endpointPath","endpoint","addedCollections","allowPublish","sync","docsEnableDrafts","endpoints","allowHardDelete","allowWrites","auth","defaultPublishMode","deleteBehavior","maxBodyBytes","requireDryRunBeforeApply","routing","pages","allowBridgePages","bridgeField","routeField"],"mappings":"AAIA,SACEA,oBAAoB,EACpBC,0BAA0B,EAC1BC,wBAAwB,EACxBC,wBAAwB,EACxBC,2BAA2B,EAC3BC,sBAAsB,EACtBC,wBAAwB,QACnB,yBAAwB;AAC/B,SACEC,4BAA4B,EAC5BC,mCAAmC,EACnCC,iCAAiC,EACjCC,iCAAiC,EACjCC,+BAA+B,EAC/BC,wCAAwC,EACxCC,sCAAsC,EACtCC,oCAAoC,EACpCC,2BAA2B,EAC3BC,sBAAsB,EACtBC,0BAA0B,EAC1BC,6BAA6B,EAC7BC,yBAAyB,QACpB,iBAAgB;AAC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B;oBACrB6B,MAAMsB;oBACNG,wBAAwBE,kBAAkBF,yBAAyB5B;gBACrE;aACD,GACD,EAAE;SACP;QAED,OAAO;YACL,GAAGiC,cAAc;YACjB5B,aAAa;mBAAK4B,eAAe5B,WAAW,IAAI,EAAE;mBAAM2C;aAAiB;YACzEI,WAAW;mBACLnB,eAAemB,SAAS,IAAI,EAAE;gBAClC/D,mBAAmB;oBACjBgE,iBAAiBxD,cAAcqD,IAAI,EAAEG;oBACrCJ,cAAcpD,cAAcqD,IAAI,EAAED;oBAClCK,aAAazD,cAAcqD,IAAI,EAAEI;oBACjCC,MAAM1D,cAAc0D,IAAI;oBACxBC,oBAAoB3D,cAAcqD,IAAI,EAAEM;oBACxCC,gBAAgB5D,cAAcqD,IAAI,EAAEO;oBACpClD;oBACAC;oBACA2C,kBAAkB7B;oBAClBZ;oBACAG;oBACAE;oBACAC;oBACAE;oBACAC;oBACAE;oBACAyB;oBACAvB;oBACAmC,cAAc7D,cAAckD,QAAQ,EAAEW,gBAAgBzE;oBACtDwC;oBACAE;oBACAgC,0BAA0B9D,cAAcqD,IAAI,EAAES;oBAC9CC,SAAS;wBACPC,OAAO;4BACLC,kBACEjE,cAAc+D,OAAO,EAAEC,OAAOC,oBAAoB;4BACpDC,aACElE,cAAc+D,OAAO,EAAEC,OAAOE,eAAe7E;4BAC/CwD,YACE7C,cAAc+D,OAAO,EAAEC,OAAOnB,cAAcvD;4BAC9CsB,SAASZ,cAAc+D,OAAO,EAAEC,OAAOpD,YAAY;4BACnDuD,YACEnE,cAAc+D,OAAO,EAAEC,OAAOG,cAAc5E;wBAChD;oBACF;oBACAwC;oBACAE;gBACF;aACD;QACH;IACF,EAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Admin Manager
|
|
2
2
|
|
|
3
|
-
The Docs Set Admin Manager is
|
|
3
|
+
The Docs Set Admin Manager is an overview on the docs set edit view.
|
|
4
4
|
|
|
5
5
|
It shows:
|
|
6
6
|
|
|
@@ -13,6 +13,7 @@ It shows:
|
|
|
13
13
|
- docs with overrides
|
|
14
14
|
- generated docs grouped by source path
|
|
15
15
|
- links to generated docs records
|
|
16
|
+
- a publish action for draft generated docs when draft publishing is enabled
|
|
16
17
|
|
|
17
18
|
Per-doc overrides live on generated docs records:
|
|
18
19
|
|
package/package.json
CHANGED