@valkyrianlabs/payload-markdown-docs 0.4.1 → 0.4.3
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/docs.d.ts +2 -1
- package/dist/collections/docs.js +26 -1
- package/dist/collections/docs.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/constants.d.ts +1 -0
- package/dist/constants.js +1 -0
- package/dist/constants.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/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/next/PayloadMarkdownDocsPage.js +81 -23
- package/dist/next/PayloadMarkdownDocsPage.js.map +1 -1
- package/dist/next/index.d.ts +6 -6
- package/dist/next/index.js.map +1 -1
- package/dist/next/records.js +19 -0
- package/dist/next/records.js.map +1 -1
- package/dist/next/types.d.ts +9 -0
- package/dist/next/types.js.map +1 -1
- 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 +19 -2
- package/dist/plugin.js.map +1 -1
- package/dist/skills/codex/reference/admin.md +3 -1
- package/dist/types.d.ts +4 -0
- package/dist/types.js.map +1 -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,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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,C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EAAC"}
|
|
@@ -2,8 +2,9 @@ import type { CollectionConfig } from 'payload';
|
|
|
2
2
|
export type CreateDocsCollectionOptions = {
|
|
3
3
|
docsSetsCollectionSlug?: string;
|
|
4
4
|
enableDrafts?: boolean;
|
|
5
|
+
heroImageMediaCollectionSlugs?: string[];
|
|
5
6
|
markdownFieldName: string;
|
|
6
7
|
slug: string;
|
|
7
8
|
syncRunsCollectionSlug?: string;
|
|
8
9
|
};
|
|
9
|
-
export declare const createDocsCollection: ({ slug, docsSetsCollectionSlug, enableDrafts, markdownFieldName, syncRunsCollectionSlug, }: CreateDocsCollectionOptions) => CollectionConfig;
|
|
10
|
+
export declare const createDocsCollection: ({ slug, docsSetsCollectionSlug, enableDrafts, heroImageMediaCollectionSlugs, markdownFieldName, syncRunsCollectionSlug, }: CreateDocsCollectionOptions) => CollectionConfig;
|
package/dist/collections/docs.js
CHANGED
|
@@ -1,6 +1,28 @@
|
|
|
1
1
|
import { markdownField } from '@valkyrianlabs/payload-markdown';
|
|
2
2
|
import { MANAGED_BY } from '../constants.js';
|
|
3
|
-
|
|
3
|
+
const createHeroImageField = (relationToSlugs)=>{
|
|
4
|
+
const fieldBase = {
|
|
5
|
+
name: 'heroImage',
|
|
6
|
+
type: 'upload',
|
|
7
|
+
admin: {
|
|
8
|
+
description: 'Optional hero image rendered above generated docs content.'
|
|
9
|
+
},
|
|
10
|
+
displayPreview: true,
|
|
11
|
+
label: 'Hero Image',
|
|
12
|
+
maxDepth: 1
|
|
13
|
+
};
|
|
14
|
+
if (relationToSlugs.length === 1) {
|
|
15
|
+
return {
|
|
16
|
+
...fieldBase,
|
|
17
|
+
relationTo: relationToSlugs[0] ?? 'media'
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
...fieldBase,
|
|
22
|
+
relationTo: relationToSlugs
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export const createDocsCollection = ({ slug, docsSetsCollectionSlug, enableDrafts = false, heroImageMediaCollectionSlugs, markdownFieldName, syncRunsCollectionSlug })=>({
|
|
4
26
|
slug,
|
|
5
27
|
admin: {
|
|
6
28
|
defaultColumns: [
|
|
@@ -67,6 +89,9 @@ export const createDocsCollection = ({ slug, docsSetsCollectionSlug, enableDraft
|
|
|
67
89
|
type: 'relationship',
|
|
68
90
|
relationTo: slug
|
|
69
91
|
},
|
|
92
|
+
...heroImageMediaCollectionSlugs?.length ? [
|
|
93
|
+
createHeroImageField(heroImageMediaCollectionSlugs)
|
|
94
|
+
] : [],
|
|
70
95
|
markdownField({
|
|
71
96
|
name: markdownFieldName,
|
|
72
97
|
label: 'Content'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/collections/docs.ts"],"sourcesContent":["import type { CollectionConfig } from 'payload'\n\nimport { markdownField } from '@valkyrianlabs/payload-markdown'\n\nimport { MANAGED_BY } from '../constants.js'\n\nexport type CreateDocsCollectionOptions = {\n docsSetsCollectionSlug?: string\n enableDrafts?: boolean\n markdownFieldName: string\n slug: string\n syncRunsCollectionSlug?: string\n}\n\nexport const createDocsCollection = ({\n slug,\n docsSetsCollectionSlug,\n enableDrafts = false,\n markdownFieldName,\n syncRunsCollectionSlug,\n}: CreateDocsCollectionOptions): CollectionConfig => ({\n slug,\n admin: {\n defaultColumns: ['title', 'route', 'sourcePath', 'updatedAt'],\n hidden: true,\n useAsTitle: 'title',\n },\n fields: [\n {\n name: 'title',\n type: 'text',\n required: true,\n },\n {\n name: 'navTitle',\n type: 'text',\n },\n {\n name: 'description',\n type: 'textarea',\n },\n {\n name: 'route',\n type: 'text',\n index: true,\n required: true,\n unique: true,\n },\n {\n name: 'sourcePath',\n type: 'text',\n index: true,\n required: true,\n },\n ...(docsSetsCollectionSlug\n ? [\n {\n name: 'docsSet',\n type: 'relationship' as const,\n index: true,\n relationTo: docsSetsCollectionSlug,\n },\n ]\n : []),\n {\n name: 'sourceHash',\n type: 'text',\n index: true,\n },\n {\n name: 'depth',\n type: 'number',\n defaultValue: 0,\n },\n {\n name: 'order',\n type: 'number',\n defaultValue: 0,\n },\n {\n name: 'parent',\n type: 'relationship',\n relationTo: slug,\n },\n markdownField({\n name: markdownFieldName,\n label: 'Content',\n }),\n {\n name: 'overrides',\n type: 'group',\n fields: [\n {\n name: 'navTitle',\n type: 'text',\n },\n {\n name: 'hideFromNav',\n type: 'checkbox',\n defaultValue: false,\n },\n ],\n },\n {\n name: 'sync',\n type: 'group',\n fields: [\n {\n name: 'sourceId',\n type: 'text',\n index: true,\n },\n {\n name: 'sourcePath',\n type: 'text',\n index: true,\n },\n {\n name: 'sourceHashAtLastSync',\n type: 'text',\n index: true,\n },\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: 'managedBy',\n type: 'text',\n defaultValue: MANAGED_BY,\n },\n {\n name: 'archived',\n type: 'checkbox',\n defaultValue: false,\n index: true,\n },\n {\n name: 'archivedAt',\n type: 'date',\n },\n ],\n },\n ],\n ...(enableDrafts\n ? {\n versions: {\n drafts: true,\n },\n }\n : {}),\n})\n"],"names":["markdownField","MANAGED_BY","createDocsCollection","slug","docsSetsCollectionSlug","enableDrafts","
|
|
1
|
+
{"version":3,"sources":["../../src/collections/docs.ts"],"sourcesContent":["import type { CollectionConfig, Field } from 'payload'\n\nimport { markdownField } from '@valkyrianlabs/payload-markdown'\n\nimport { MANAGED_BY } from '../constants.js'\n\nexport type CreateDocsCollectionOptions = {\n docsSetsCollectionSlug?: string\n enableDrafts?: boolean\n heroImageMediaCollectionSlugs?: string[]\n markdownFieldName: string\n slug: string\n syncRunsCollectionSlug?: string\n}\n\nconst createHeroImageField = (relationToSlugs: string[]): Field => {\n const fieldBase = {\n name: 'heroImage',\n type: 'upload' as const,\n admin: {\n description: 'Optional hero image rendered above generated docs content.',\n },\n displayPreview: true,\n label: 'Hero Image',\n maxDepth: 1,\n }\n\n if (relationToSlugs.length === 1) {\n return {\n ...fieldBase,\n relationTo: relationToSlugs[0] ?? 'media',\n }\n }\n\n return {\n ...fieldBase,\n relationTo: relationToSlugs,\n }\n}\n\nexport const createDocsCollection = ({\n slug,\n docsSetsCollectionSlug,\n enableDrafts = false,\n heroImageMediaCollectionSlugs,\n markdownFieldName,\n syncRunsCollectionSlug,\n}: CreateDocsCollectionOptions): CollectionConfig => ({\n slug,\n admin: {\n defaultColumns: ['title', 'route', 'sourcePath', 'updatedAt'],\n hidden: true,\n useAsTitle: 'title',\n },\n fields: [\n {\n name: 'title',\n type: 'text',\n required: true,\n },\n {\n name: 'navTitle',\n type: 'text',\n },\n {\n name: 'description',\n type: 'textarea',\n },\n {\n name: 'route',\n type: 'text',\n index: true,\n required: true,\n unique: true,\n },\n {\n name: 'sourcePath',\n type: 'text',\n index: true,\n required: true,\n },\n ...(docsSetsCollectionSlug\n ? [\n {\n name: 'docsSet',\n type: 'relationship' as const,\n index: true,\n relationTo: docsSetsCollectionSlug,\n },\n ]\n : []),\n {\n name: 'sourceHash',\n type: 'text',\n index: true,\n },\n {\n name: 'depth',\n type: 'number',\n defaultValue: 0,\n },\n {\n name: 'order',\n type: 'number',\n defaultValue: 0,\n },\n {\n name: 'parent',\n type: 'relationship',\n relationTo: slug,\n },\n ...(heroImageMediaCollectionSlugs?.length\n ? [createHeroImageField(heroImageMediaCollectionSlugs)]\n : []),\n markdownField({\n name: markdownFieldName,\n label: 'Content',\n }),\n {\n name: 'overrides',\n type: 'group',\n fields: [\n {\n name: 'navTitle',\n type: 'text',\n },\n {\n name: 'hideFromNav',\n type: 'checkbox',\n defaultValue: false,\n },\n ],\n },\n {\n name: 'sync',\n type: 'group',\n fields: [\n {\n name: 'sourceId',\n type: 'text',\n index: true,\n },\n {\n name: 'sourcePath',\n type: 'text',\n index: true,\n },\n {\n name: 'sourceHashAtLastSync',\n type: 'text',\n index: true,\n },\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: 'managedBy',\n type: 'text',\n defaultValue: MANAGED_BY,\n },\n {\n name: 'archived',\n type: 'checkbox',\n defaultValue: false,\n index: true,\n },\n {\n name: 'archivedAt',\n type: 'date',\n },\n ],\n },\n ],\n ...(enableDrafts\n ? {\n versions: {\n drafts: true,\n },\n }\n : {}),\n})\n"],"names":["markdownField","MANAGED_BY","createHeroImageField","relationToSlugs","fieldBase","name","type","admin","description","displayPreview","label","maxDepth","length","relationTo","createDocsCollection","slug","docsSetsCollectionSlug","enableDrafts","heroImageMediaCollectionSlugs","markdownFieldName","syncRunsCollectionSlug","defaultColumns","hidden","useAsTitle","fields","required","index","unique","defaultValue","versions","drafts"],"mappings":"AAEA,SAASA,aAAa,QAAQ,kCAAiC;AAE/D,SAASC,UAAU,QAAQ,kBAAiB;AAW5C,MAAMC,uBAAuB,CAACC;IAC5B,MAAMC,YAAY;QAChBC,MAAM;QACNC,MAAM;QACNC,OAAO;YACLC,aAAa;QACf;QACAC,gBAAgB;QAChBC,OAAO;QACPC,UAAU;IACZ;IAEA,IAAIR,gBAAgBS,MAAM,KAAK,GAAG;QAChC,OAAO;YACL,GAAGR,SAAS;YACZS,YAAYV,eAAe,CAAC,EAAE,IAAI;QACpC;IACF;IAEA,OAAO;QACL,GAAGC,SAAS;QACZS,YAAYV;IACd;AACF;AAEA,OAAO,MAAMW,uBAAuB,CAAC,EACnCC,IAAI,EACJC,sBAAsB,EACtBC,eAAe,KAAK,EACpBC,6BAA6B,EAC7BC,iBAAiB,EACjBC,sBAAsB,EACM,GAAwB,CAAA;QACpDL;QACAR,OAAO;YACLc,gBAAgB;gBAAC;gBAAS;gBAAS;gBAAc;aAAY;YAC7DC,QAAQ;YACRC,YAAY;QACd;QACAC,QAAQ;YACN;gBACEnB,MAAM;gBACNC,MAAM;gBACNmB,UAAU;YACZ;YACA;gBACEpB,MAAM;gBACNC,MAAM;YACR;YACA;gBACED,MAAM;gBACNC,MAAM;YACR;YACA;gBACED,MAAM;gBACNC,MAAM;gBACNoB,OAAO;gBACPD,UAAU;gBACVE,QAAQ;YACV;YACA;gBACEtB,MAAM;gBACNC,MAAM;gBACNoB,OAAO;gBACPD,UAAU;YACZ;eACIT,yBACA;gBACE;oBACEX,MAAM;oBACNC,MAAM;oBACNoB,OAAO;oBACPb,YAAYG;gBACd;aACD,GACD,EAAE;YACN;gBACEX,MAAM;gBACNC,MAAM;gBACNoB,OAAO;YACT;YACA;gBACErB,MAAM;gBACNC,MAAM;gBACNsB,cAAc;YAChB;YACA;gBACEvB,MAAM;gBACNC,MAAM;gBACNsB,cAAc;YAChB;YACA;gBACEvB,MAAM;gBACNC,MAAM;gBACNO,YAAYE;YACd;eACIG,+BAA+BN,SAC/B;gBAACV,qBAAqBgB;aAA+B,GACrD,EAAE;YACNlB,cAAc;gBACZK,MAAMc;gBACNT,OAAO;YACT;YACA;gBACEL,MAAM;gBACNC,MAAM;gBACNkB,QAAQ;oBACN;wBACEnB,MAAM;wBACNC,MAAM;oBACR;oBACA;wBACED,MAAM;wBACNC,MAAM;wBACNsB,cAAc;oBAChB;iBACD;YACH;YACA;gBACEvB,MAAM;gBACNC,MAAM;gBACNkB,QAAQ;oBACN;wBACEnB,MAAM;wBACNC,MAAM;wBACNoB,OAAO;oBACT;oBACA;wBACErB,MAAM;wBACNC,MAAM;wBACNoB,OAAO;oBACT;oBACA;wBACErB,MAAM;wBACNC,MAAM;wBACNoB,OAAO;oBACT;oBACA;wBACErB,MAAM;wBACNC,MAAM;oBACR;uBACIc,yBACA;wBACE;4BACEf,MAAM;4BACNC,MAAM;4BACNO,YAAYO;wBACd;qBACD,GACD,EAAE;oBACN;wBACEf,MAAM;wBACNC,MAAM;wBACNsB,cAAc3B;oBAChB;oBACA;wBACEI,MAAM;wBACNC,MAAM;wBACNsB,cAAc;wBACdF,OAAO;oBACT;oBACA;wBACErB,MAAM;wBACNC,MAAM;oBACR;iBACD;YACH;SACD;QACD,GAAIW,eACA;YACEY,UAAU;gBACRC,QAAQ;YACV;QACF,IACA,CAAC,CAAC;IACR,CAAA,EAAE"}
|
|
@@ -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 {
|
|
1
|
+
{"version":3,"sources":["../../src/collections/docsSets.ts"],"sourcesContent":["import type { CollectionConfig } from 'payload'\n\nimport { DOCS_GLOBALS_ADMIN_GROUP, DOCS_SET_MANAGER_COMPONENT } 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: '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: '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,SAASA,wBAAwB,EAAEC,0BAA0B,QAAQ,kBAAiB;AACtF,SAASC,kCAAkC,QAAQ,uCAAsC;AAWzF,OAAO,MAAMC,2BAA2B,CAAC,EACvCC,IAAI,EACJC,eAAe,KAAK,EACpBC,kBAAkB,EAClBC,mBAAmB,KAAK,EACxBC,wBAAwB,EACxBC,sBAAsB,EACU,GAAwB,CAAA;QACxDL;QACAM,OAAO;YACLC,gBAAgB;gBAAC;gBAAS;gBAAQ;gBAAU;aAAY;YACxDC,OAAOZ;YACPa,YAAY;QACd;QACAC,WACER,sBAAsBC,oBAAoBF,eACtC;YACEH,mCAAmC;gBACjCI;gBACAS,wBAAwBX;YAC1B;SACD,GACDY;QACNC,QAAQ;YACN;gBACEC,MAAM;gBACNC,MAAM;gBACNC,UAAU;YACZ;YACA;gB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S;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"}
|
package/dist/constants.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export declare const DEFAULT_DOCS_SYNC_RUNS_COLLECTION_SLUG = "docs-sync-runs";
|
|
|
8
8
|
export declare const DEFAULT_DOCS_TRUSTED_COLLECTION_SLUG = "docs-trusted";
|
|
9
9
|
export declare const DEFAULT_DOCS_SYNC_ENDPOINT_PATH = "/payload-markdown-docs/sync";
|
|
10
10
|
export declare const DEFAULT_MARKDOWN_FIELD_NAME = "content";
|
|
11
|
+
export declare const DEFAULT_MEDIA_COLLECTION_SLUG = "media";
|
|
11
12
|
export declare const DOCS_SET_MANAGER_COMPONENT = "@valkyrianlabs/payload-markdown-docs/admin#DocsSetManager";
|
|
12
13
|
export declare const DEFAULT_PAGES_BRIDGE_FIELD = "docsBridge";
|
|
13
14
|
export declare const DEFAULT_PAGES_COLLECTION_SLUG = "pages";
|
package/dist/constants.js
CHANGED
|
@@ -8,6 +8,7 @@ export const DEFAULT_DOCS_SYNC_RUNS_COLLECTION_SLUG = 'docs-sync-runs';
|
|
|
8
8
|
export const DEFAULT_DOCS_TRUSTED_COLLECTION_SLUG = 'docs-trusted';
|
|
9
9
|
export const DEFAULT_DOCS_SYNC_ENDPOINT_PATH = '/payload-markdown-docs/sync';
|
|
10
10
|
export const DEFAULT_MARKDOWN_FIELD_NAME = 'content';
|
|
11
|
+
export const DEFAULT_MEDIA_COLLECTION_SLUG = 'media';
|
|
11
12
|
export const DOCS_SET_MANAGER_COMPONENT = '@valkyrianlabs/payload-markdown-docs/admin#DocsSetManager';
|
|
12
13
|
export const DEFAULT_PAGES_BRIDGE_FIELD = 'docsBridge';
|
|
13
14
|
export const DEFAULT_PAGES_COLLECTION_SLUG = 'pages';
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/constants.ts"],"sourcesContent":["export const DEFAULT_DOCS_COLLECTION_SLUG = 'docs'\nexport const DEFAULT_DOCS_GROUPS_COLLECTION_SLUG = 'docs-groups'\nexport const DEFAULT_DOCS_KEYS_COLLECTION_SLUG = 'docs-keys'\nexport const DEFAULT_DOCS_ROUTE_BASE = '/docs'\nexport const DEFAULT_DOCS_SETS_COLLECTION_SLUG = 'docs-sets'\nexport const DEFAULT_DOCS_SYNC_NONCES_COLLECTION_SLUG = 'docs-sync-nonces'\nexport const DEFAULT_DOCS_SYNC_RUNS_COLLECTION_SLUG = 'docs-sync-runs'\nexport const DEFAULT_DOCS_TRUSTED_COLLECTION_SLUG = 'docs-trusted'\nexport const DEFAULT_DOCS_SYNC_ENDPOINT_PATH = '/payload-markdown-docs/sync'\nexport const DEFAULT_MARKDOWN_FIELD_NAME = 'content'\nexport const DOCS_SET_MANAGER_COMPONENT =\n '@valkyrianlabs/payload-markdown-docs/admin#DocsSetManager'\nexport const DEFAULT_PAGES_BRIDGE_FIELD = 'docsBridge'\nexport const DEFAULT_PAGES_COLLECTION_SLUG = 'pages'\nexport const DEFAULT_PAGES_ROUTE_FIELD = 'slug'\nexport const DEFAULT_MAX_DOCS_FILE_BYTES = 500_000\nexport const DEFAULT_MAX_DOCS_FILES = 500\nexport const DEFAULT_MAX_DOCS_TOTAL_BYTES = 5_000_000\nexport const DEFAULT_MAX_BODY_BYTES = 5_000_000\nexport const DEFAULT_MAX_SKEW_SECONDS = 300\nexport const DEFAULT_NONCE_TTL_SECONDS = 600\nexport const DEFAULT_GITHUB_OIDC_ISSUER
|
|
1
|
+
{"version":3,"sources":["../src/constants.ts"],"sourcesContent":["export const DEFAULT_DOCS_COLLECTION_SLUG = 'docs'\nexport const DEFAULT_DOCS_GROUPS_COLLECTION_SLUG = 'docs-groups'\nexport const DEFAULT_DOCS_KEYS_COLLECTION_SLUG = 'docs-keys'\nexport const DEFAULT_DOCS_ROUTE_BASE = '/docs'\nexport const DEFAULT_DOCS_SETS_COLLECTION_SLUG = 'docs-sets'\nexport const DEFAULT_DOCS_SYNC_NONCES_COLLECTION_SLUG = 'docs-sync-nonces'\nexport const DEFAULT_DOCS_SYNC_RUNS_COLLECTION_SLUG = 'docs-sync-runs'\nexport const DEFAULT_DOCS_TRUSTED_COLLECTION_SLUG = 'docs-trusted'\nexport const DEFAULT_DOCS_SYNC_ENDPOINT_PATH = '/payload-markdown-docs/sync'\nexport const DEFAULT_MARKDOWN_FIELD_NAME = 'content'\nexport const DEFAULT_MEDIA_COLLECTION_SLUG = 'media'\nexport const DOCS_SET_MANAGER_COMPONENT =\n '@valkyrianlabs/payload-markdown-docs/admin#DocsSetManager'\nexport const DEFAULT_PAGES_BRIDGE_FIELD = 'docsBridge'\nexport const DEFAULT_PAGES_COLLECTION_SLUG = 'pages'\nexport const DEFAULT_PAGES_ROUTE_FIELD = 'slug'\nexport const DEFAULT_MAX_DOCS_FILE_BYTES = 500_000\nexport const DEFAULT_MAX_DOCS_FILES = 500\nexport const DEFAULT_MAX_DOCS_TOTAL_BYTES = 5_000_000\nexport const DEFAULT_MAX_BODY_BYTES = 5_000_000\nexport const DEFAULT_MAX_SKEW_SECONDS = 300\nexport const DEFAULT_NONCE_TTL_SECONDS = 600\nexport const DEFAULT_GITHUB_OIDC_ISSUER = 'https://token.actions.githubusercontent.com'\nexport const MANAGED_BY = 'payload-markdown-docs'\nexport const DOCS_GLOBALS_ADMIN_GROUP = 'Docs Globals'\n"],"names":["DEFAULT_DOCS_COLLECTION_SLUG","DEFAULT_DOCS_GROUPS_COLLECTION_SLUG","DEFAULT_DOCS_KEYS_COLLECTION_SLUG","DEFAULT_DOCS_ROUTE_BASE","DEFAULT_DOCS_SETS_COLLECTION_SLUG","DEFAULT_DOCS_SYNC_NONCES_COLLECTION_SLUG","DEFAULT_DOCS_SYNC_RUNS_COLLECTION_SLUG","DEFAULT_DOCS_TRUSTED_COLLECTION_SLUG","DEFAULT_DOCS_SYNC_ENDPOINT_PATH","DEFAULT_MARKDOWN_FIELD_NAME","DEFAULT_MEDIA_COLLECTION_SLUG","DOCS_SET_MANAGER_COMPONENT","DEFAULT_PAGES_BRIDGE_FIELD","DEFAULT_PAGES_COLLECTION_SLUG","DEFAULT_PAGES_ROUTE_FIELD","DEFAULT_MAX_DOCS_FILE_BYTES","DEFAULT_MAX_DOCS_FILES","DEFAULT_MAX_DOCS_TOTAL_BYTES","DEFAULT_MAX_BODY_BYTES","DEFAULT_MAX_SKEW_SECONDS","DEFAULT_NONCE_TTL_SECONDS","DEFAULT_GITHUB_OIDC_ISSUER","MANAGED_BY","DOCS_GLOBALS_ADMIN_GROUP"],"mappings":"AAAA,OAAO,MAAMA,+BAA+B,OAAM;AAClD,OAAO,MAAMC,sCAAsC,cAAa;AAChE,OAAO,MAAMC,oCAAoC,YAAW;AAC5D,OAAO,MAAMC,0BAA0B,QAAO;AAC9C,OAAO,MAAMC,oCAAoC,YAAW;AAC5D,OAAO,MAAMC,2CAA2C,mBAAkB;AAC1E,OAAO,MAAMC,yCAAyC,iBAAgB;AACtE,OAAO,MAAMC,uCAAuC,eAAc;AAClE,OAAO,MAAMC,kCAAkC,8BAA6B;AAC5E,OAAO,MAAMC,8BAA8B,UAAS;AACpD,OAAO,MAAMC,gCAAgC,QAAO;AACpD,OAAO,MAAMC,6BACX,4DAA2D;AAC7D,OAAO,MAAMC,6BAA6B,aAAY;AACtD,OAAO,MAAMC,gCAAgC,QAAO;AACpD,OAAO,MAAMC,4BAA4B,OAAM;AAC/C,OAAO,MAAMC,8BAA8B,QAAO;AAClD,OAAO,MAAMC,yBAAyB,IAAG;AACzC,OAAO,MAAMC,+BAA+B,UAAS;AACrD,OAAO,MAAMC,yBAAyB,UAAS;AAC/C,OAAO,MAAMC,2BAA2B,IAAG;AAC3C,OAAO,MAAMC,4BAA4B,IAAG;AAC5C,OAAO,MAAMC,6BAA6B,8CAA6C;AACvF,OAAO,MAAMC,aAAa,wBAAuB;AACjD,OAAO,MAAMC,2BAA2B,eAAc"}
|
|
@@ -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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MrC,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"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { 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_MAX_DOCS_FILE_BYTES, DEFAULT_MAX_DOCS_FILES, DEFAULT_MAX_DOCS_TOTAL_BYTES, DEFAULT_MAX_SKEW_SECONDS, DEFAULT_NONCE_TTL_SECONDS, DEFAULT_PAGES_BRIDGE_FIELD, DEFAULT_PAGES_COLLECTION_SLUG, DEFAULT_PAGES_ROUTE_FIELD, DOCS_GLOBALS_ADMIN_GROUP, DOCS_SET_MANAGER_COMPONENT, } from './constants.js';
|
|
1
|
+
export { 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_MAX_DOCS_FILE_BYTES, DEFAULT_MAX_DOCS_FILES, DEFAULT_MAX_DOCS_TOTAL_BYTES, DEFAULT_MAX_SKEW_SECONDS, DEFAULT_MEDIA_COLLECTION_SLUG, DEFAULT_NONCE_TTL_SECONDS, DEFAULT_PAGES_BRIDGE_FIELD, DEFAULT_PAGES_COLLECTION_SLUG, DEFAULT_PAGES_ROUTE_FIELD, DOCS_GLOBALS_ADMIN_GROUP, DOCS_SET_MANAGER_COMPONENT, } from './constants.js';
|
|
2
2
|
export { payloadMarkdownDocs } from './plugin.js';
|
|
3
3
|
export { deriveDocsSetRouteBase, findPageRouteCollisions, findRouteReservationCollisions, isRouteDescendant, joinRouteSegments, normalizeRoutePath, } from './routing/index.js';
|
|
4
4
|
export type { DocsRouteCollision, DocsRouteCollisionReason, DocsRouteReservation, DocsRouteReservationOwnerType, } from './routing/index.js';
|
|
5
5
|
export { signDocsSyncRequest } from './security/index.js';
|
|
6
|
-
export type { SignDocsSyncRequestOptions, SignedDocsSyncRequest
|
|
6
|
+
export type { SignDocsSyncRequestOptions, SignedDocsSyncRequest } from './security/index.js';
|
|
7
7
|
export { buildDocsManifest, deriveRouteFromSourcePath, inferTitleFromMarkdown, normalizeDocsPath, parseDocsFrontmatter, planDocsSync, resolveDocsTitle, sha256Hex, titleFromSourcePath, validateDocsManifest, } from './sync/index.js';
|
|
8
8
|
export type { DocsDeleteBehavior, DocsFrontmatter, DocsManifest, DocsManifestFile, DocsManifestInputFile, DocsManifestSource, DocsSyncMode, DocsSyncPlan, DocsValidationErrorCode, DocsValidationIssue, DocsValidationOptions, DocsValidationResult, ExistingDocsRecord, ParseDocsFrontmatterResult, PlannedDocChange, ValidatedDocsManifest, ValidatedDocsManifestFile, } from './sync/index.js';
|
|
9
|
-
export type { PayloadMarkdownDocsAuthConfig, PayloadMarkdownDocsCollectionConfig, PayloadMarkdownDocsCollectionsConfig, PayloadMarkdownDocsConfig, PayloadMarkdownDocsEndpointConfig, PayloadMarkdownDocsPagesRoutingConfig, PayloadMarkdownDocsRoutingConfig, PayloadMarkdownDocsSyncConfig, PayloadMarkdownDocsTargetConfig, } from './types.js';
|
|
9
|
+
export type { PayloadMarkdownDocsAuthConfig, PayloadMarkdownDocsCollectionConfig, PayloadMarkdownDocsCollectionsConfig, PayloadMarkdownDocsConfig, PayloadMarkdownDocsEndpointConfig, PayloadMarkdownDocsHeroImageConfig, PayloadMarkdownDocsPagesRoutingConfig, PayloadMarkdownDocsRoutingConfig, PayloadMarkdownDocsSyncConfig, PayloadMarkdownDocsTargetConfig, } from './types.js';
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { 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_MAX_DOCS_FILE_BYTES, DEFAULT_MAX_DOCS_FILES, DEFAULT_MAX_DOCS_TOTAL_BYTES, DEFAULT_MAX_SKEW_SECONDS, DEFAULT_NONCE_TTL_SECONDS, DEFAULT_PAGES_BRIDGE_FIELD, DEFAULT_PAGES_COLLECTION_SLUG, DEFAULT_PAGES_ROUTE_FIELD, DOCS_GLOBALS_ADMIN_GROUP, DOCS_SET_MANAGER_COMPONENT } from './constants.js';
|
|
1
|
+
export { 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_MAX_DOCS_FILE_BYTES, DEFAULT_MAX_DOCS_FILES, DEFAULT_MAX_DOCS_TOTAL_BYTES, DEFAULT_MAX_SKEW_SECONDS, DEFAULT_MEDIA_COLLECTION_SLUG, DEFAULT_NONCE_TTL_SECONDS, DEFAULT_PAGES_BRIDGE_FIELD, DEFAULT_PAGES_COLLECTION_SLUG, DEFAULT_PAGES_ROUTE_FIELD, DOCS_GLOBALS_ADMIN_GROUP, DOCS_SET_MANAGER_COMPONENT } from './constants.js';
|
|
2
2
|
export { payloadMarkdownDocs } from './plugin.js';
|
|
3
3
|
export { deriveDocsSetRouteBase, findPageRouteCollisions, findRouteReservationCollisions, isRouteDescendant, joinRouteSegments, normalizeRoutePath } from './routing/index.js';
|
|
4
4
|
export { signDocsSyncRequest } from './security/index.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export {\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_MAX_DOCS_FILE_BYTES,\n DEFAULT_MAX_DOCS_FILES,\n DEFAULT_MAX_DOCS_TOTAL_BYTES,\n DEFAULT_MAX_SKEW_SECONDS,\n DEFAULT_NONCE_TTL_SECONDS,\n DEFAULT_PAGES_BRIDGE_FIELD,\n DEFAULT_PAGES_COLLECTION_SLUG,\n DEFAULT_PAGES_ROUTE_FIELD,\n DOCS_GLOBALS_ADMIN_GROUP,\n DOCS_SET_MANAGER_COMPONENT,\n} from './constants.js'\nexport { payloadMarkdownDocs } from './plugin.js'\nexport {\n deriveDocsSetRouteBase,\n findPageRouteCollisions,\n findRouteReservationCollisions,\n isRouteDescendant,\n joinRouteSegments,\n normalizeRoutePath,\n} from './routing/index.js'\nexport type {\n DocsRouteCollision,\n DocsRouteCollisionReason,\n DocsRouteReservation,\n DocsRouteReservationOwnerType,\n} from './routing/index.js'\nexport { signDocsSyncRequest } from './security/index.js'\nexport type {
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export {\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_MAX_DOCS_FILE_BYTES,\n DEFAULT_MAX_DOCS_FILES,\n DEFAULT_MAX_DOCS_TOTAL_BYTES,\n DEFAULT_MAX_SKEW_SECONDS,\n DEFAULT_MEDIA_COLLECTION_SLUG,\n DEFAULT_NONCE_TTL_SECONDS,\n DEFAULT_PAGES_BRIDGE_FIELD,\n DEFAULT_PAGES_COLLECTION_SLUG,\n DEFAULT_PAGES_ROUTE_FIELD,\n DOCS_GLOBALS_ADMIN_GROUP,\n DOCS_SET_MANAGER_COMPONENT,\n} from './constants.js'\nexport { payloadMarkdownDocs } from './plugin.js'\nexport {\n deriveDocsSetRouteBase,\n findPageRouteCollisions,\n findRouteReservationCollisions,\n isRouteDescendant,\n joinRouteSegments,\n normalizeRoutePath,\n} from './routing/index.js'\nexport type {\n DocsRouteCollision,\n DocsRouteCollisionReason,\n DocsRouteReservation,\n DocsRouteReservationOwnerType,\n} from './routing/index.js'\nexport { signDocsSyncRequest } from './security/index.js'\nexport type { SignDocsSyncRequestOptions, SignedDocsSyncRequest } from './security/index.js'\nexport {\n buildDocsManifest,\n deriveRouteFromSourcePath,\n inferTitleFromMarkdown,\n normalizeDocsPath,\n parseDocsFrontmatter,\n planDocsSync,\n resolveDocsTitle,\n sha256Hex,\n titleFromSourcePath,\n validateDocsManifest,\n} from './sync/index.js'\nexport type {\n DocsDeleteBehavior,\n DocsFrontmatter,\n DocsManifest,\n DocsManifestFile,\n DocsManifestInputFile,\n DocsManifestSource,\n DocsSyncMode,\n DocsSyncPlan,\n DocsValidationErrorCode,\n DocsValidationIssue,\n DocsValidationOptions,\n DocsValidationResult,\n ExistingDocsRecord,\n ParseDocsFrontmatterResult,\n PlannedDocChange,\n ValidatedDocsManifest,\n ValidatedDocsManifestFile,\n} from './sync/index.js'\nexport type {\n PayloadMarkdownDocsAuthConfig,\n PayloadMarkdownDocsCollectionConfig,\n PayloadMarkdownDocsCollectionsConfig,\n PayloadMarkdownDocsConfig,\n PayloadMarkdownDocsEndpointConfig,\n PayloadMarkdownDocsHeroImageConfig,\n PayloadMarkdownDocsPagesRoutingConfig,\n PayloadMarkdownDocsRoutingConfig,\n PayloadMarkdownDocsSyncConfig,\n PayloadMarkdownDocsTargetConfig,\n} from './types.js'\n"],"names":["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_MAX_DOCS_FILE_BYTES","DEFAULT_MAX_DOCS_FILES","DEFAULT_MAX_DOCS_TOTAL_BYTES","DEFAULT_MAX_SKEW_SECONDS","DEFAULT_MEDIA_COLLECTION_SLUG","DEFAULT_NONCE_TTL_SECONDS","DEFAULT_PAGES_BRIDGE_FIELD","DEFAULT_PAGES_COLLECTION_SLUG","DEFAULT_PAGES_ROUTE_FIELD","DOCS_GLOBALS_ADMIN_GROUP","DOCS_SET_MANAGER_COMPONENT","payloadMarkdownDocs","deriveDocsSetRouteBase","findPageRouteCollisions","findRouteReservationCollisions","isRouteDescendant","joinRouteSegments","normalizeRoutePath","signDocsSyncRequest","buildDocsManifest","deriveRouteFromSourcePath","inferTitleFromMarkdown","normalizeDocsPath","parseDocsFrontmatter","planDocsSync","resolveDocsTitle","sha256Hex","titleFromSourcePath","validateDocsManifest"],"mappings":"AAAA,SACEA,4BAA4B,EAC5BC,mCAAmC,EACnCC,iCAAiC,EACjCC,iCAAiC,EACjCC,+BAA+B,EAC/BC,wCAAwC,EACxCC,sCAAsC,EACtCC,oCAAoC,EACpCC,2BAA2B,EAC3BC,sBAAsB,EACtBC,2BAA2B,EAC3BC,sBAAsB,EACtBC,4BAA4B,EAC5BC,wBAAwB,EACxBC,6BAA6B,EAC7BC,yBAAyB,EACzBC,0BAA0B,EAC1BC,6BAA6B,EAC7BC,yBAAyB,EACzBC,wBAAwB,EACxBC,0BAA0B,QACrB,iBAAgB;AACvB,SAASC,mBAAmB,QAAQ,cAAa;AACjD,SACEC,sBAAsB,EACtBC,uBAAuB,EACvBC,8BAA8B,EAC9BC,iBAAiB,EACjBC,iBAAiB,EACjBC,kBAAkB,QACb,qBAAoB;AAO3B,SAASC,mBAAmB,QAAQ,sBAAqB;AAEzD,SACEC,iBAAiB,EACjBC,yBAAyB,EACzBC,sBAAsB,EACtBC,iBAAiB,EACjBC,oBAAoB,EACpBC,YAAY,EACZC,gBAAgB,EAChBC,SAAS,EACTC,mBAAmB,EACnBC,oBAAoB,QACf,kBAAiB"}
|