@valkyrianlabs/payload-markdown-docs 0.3.1 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +79 -171
- package/dist/admin/DocsSetManager.js +5 -3
- package/dist/admin/DocsSetManager.js.map +1 -1
- package/dist/admin/docsSetManagerData.d.ts +6 -5
- package/dist/admin/docsSetManagerData.js +60 -33
- package/dist/admin/docsSetManagerData.js.map +1 -1
- package/dist/admin/docsSetManagerTypes.d.ts +12 -9
- package/dist/admin/docsSetManagerTypes.js.map +1 -1
- package/dist/cli/commands/manifest.js +1 -2
- package/dist/cli/commands/manifest.js.map +1 -1
- package/dist/cli/commands/plan.js +1 -2
- package/dist/cli/commands/plan.js.map +1 -1
- package/dist/cli/commands/push.js +19 -12
- package/dist/cli/commands/push.js.map +1 -1
- package/dist/cli/commands/validate.js +11 -6
- package/dist/cli/commands/validate.js.map +1 -1
- package/dist/cli/index.js +6 -15
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/parseArgs.js +0 -3
- package/dist/cli/parseArgs.js.map +1 -1
- package/dist/cli/types.d.ts +0 -3
- package/dist/cli/types.js.map +1 -1
- package/dist/collections/docs.js +0 -24
- package/dist/collections/docs.js.map +1 -1
- package/dist/collections/docsGroups.js +8 -9
- package/dist/collections/docsGroups.js.map +1 -1
- package/dist/collections/docsKeys.d.ts +5 -0
- package/dist/collections/docsKeys.js +44 -0
- package/dist/collections/docsKeys.js.map +1 -0
- package/dist/collections/docsSets.js +47 -202
- package/dist/collections/docsSets.js.map +1 -1
- package/dist/collections/docsTrusted.d.ts +5 -0
- package/dist/collections/docsTrusted.js +60 -0
- package/dist/collections/docsTrusted.js.map +1 -0
- package/dist/collections/index.d.ts +4 -0
- package/dist/collections/index.js +2 -0
- package/dist/collections/index.js.map +1 -1
- package/dist/constants.d.ts +3 -1
- package/dist/constants.js +3 -1
- package/dist/constants.js.map +1 -1
- package/dist/endpoints/sync.d.ts +6 -7
- package/dist/endpoints/sync.js +57 -124
- package/dist/endpoints/sync.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/next/PayloadMarkdownDocsPage.js +2 -6
- package/dist/next/PayloadMarkdownDocsPage.js.map +1 -1
- package/dist/next/index.d.ts +2 -0
- package/dist/next/index.js +1 -0
- package/dist/next/index.js.map +1 -1
- package/dist/next/links.d.ts +11 -0
- package/dist/next/links.js +79 -0
- package/dist/next/links.js.map +1 -0
- package/dist/next/markdown.js +91 -19
- package/dist/next/markdown.js.map +1 -1
- package/dist/next/metadata.js +6 -6
- package/dist/next/metadata.js.map +1 -1
- package/dist/next/records.js +13 -23
- package/dist/next/records.js.map +1 -1
- package/dist/next/route.js +141 -49
- package/dist/next/route.js.map +1 -1
- package/dist/next/types.d.ts +0 -14
- package/dist/next/types.js.map +1 -1
- package/dist/payload/docsKeys.d.ts +20 -0
- package/dist/payload/docsKeys.js +29 -0
- package/dist/payload/docsKeys.js.map +1 -0
- package/dist/payload/docsSets.d.ts +32 -6
- package/dist/payload/docsSets.js +146 -83
- package/dist/payload/docsSets.js.map +1 -1
- package/dist/payload/docsTrusted.d.ts +16 -0
- package/dist/payload/docsTrusted.js +49 -0
- package/dist/payload/docsTrusted.js.map +1 -0
- package/dist/payload/index.d.ts +5 -1
- package/dist/payload/index.js +3 -1
- package/dist/payload/index.js.map +1 -1
- package/dist/plugin.js +36 -9
- package/dist/plugin.js.map +1 -1
- package/dist/security/ed25519Keys.d.ts +9 -0
- package/dist/security/ed25519Keys.js +183 -0
- package/dist/security/ed25519Keys.js.map +1 -0
- package/dist/security/githubOidc.d.ts +18 -5
- package/dist/security/githubOidc.js +44 -16
- package/dist/security/githubOidc.js.map +1 -1
- package/dist/security/index.d.ts +2 -1
- package/dist/security/index.js +1 -0
- package/dist/security/index.js.map +1 -1
- package/dist/security/sign.js +3 -12
- package/dist/security/sign.js.map +1 -1
- package/dist/security/verify.js +3 -12
- package/dist/security/verify.js.map +1 -1
- package/dist/skills/codex/SKILL.md +3 -4
- package/dist/skills/codex/examples/github-actions.md +0 -2
- package/dist/skills/codex/reference/admin.md +0 -6
- package/dist/skills/codex/reference/routing.md +2 -1
- package/dist/skills/codex/reference/sync.md +7 -5
- package/dist/skills/codex/reference/troubleshooting.md +3 -4
- package/dist/skills/codex/reference/workflow.md +0 -1
- package/dist/sync/manifest.d.ts +1 -3
- package/dist/sync/manifest.js +2 -3
- package/dist/sync/manifest.js.map +1 -1
- package/dist/sync/validate.js +1 -2
- package/dist/sync/validate.js.map +1 -1
- package/dist/types.d.ts +7 -50
- package/dist/types.js.map +1 -1
- package/package.json +6 -4
package/dist/payload/docsSets.js
CHANGED
|
@@ -1,22 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
if (!payload.update) {
|
|
3
|
-
return;
|
|
4
|
-
}
|
|
5
|
-
await payload.update({
|
|
6
|
-
id: String(docsSetId),
|
|
7
|
-
collection: collectionSlug,
|
|
8
|
-
data: {
|
|
9
|
-
aiExport: aiExport ?? null,
|
|
10
|
-
sync: {
|
|
11
|
-
docsCount,
|
|
12
|
-
lastStatus: 'success',
|
|
13
|
-
lastSyncedAt: now.toISOString(),
|
|
14
|
-
lastSyncRunId: syncRunId
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
overrideAccess: true
|
|
18
|
-
});
|
|
19
|
-
};
|
|
1
|
+
import { deriveDocsSetRouteBase, joinRouteSegments, normalizeRoutePath } from '../routing/index.js';
|
|
20
2
|
const isRecord = (value)=>typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
21
3
|
const getRecordId = (doc)=>{
|
|
22
4
|
if (typeof doc.id === 'string' || typeof doc.id === 'number') {
|
|
@@ -24,13 +6,22 @@ const getRecordId = (doc)=>{
|
|
|
24
6
|
}
|
|
25
7
|
return undefined;
|
|
26
8
|
};
|
|
9
|
+
const getRelationshipId = (value)=>{
|
|
10
|
+
if (typeof value === 'string' || typeof value === 'number') {
|
|
11
|
+
return String(value);
|
|
12
|
+
}
|
|
13
|
+
if (isRecord(value)) {
|
|
14
|
+
const id = getRecordId(value);
|
|
15
|
+
return id === undefined ? undefined : String(id);
|
|
16
|
+
}
|
|
17
|
+
return undefined;
|
|
18
|
+
};
|
|
27
19
|
const getString = (value)=>typeof value === 'string' && value.trim() !== '' ? value.trim() : undefined;
|
|
28
|
-
const getNumber = (value)=>typeof value === 'number' && Number.isFinite(value) ? value : undefined;
|
|
29
20
|
const getStringArray = (value)=>{
|
|
30
21
|
if (!Array.isArray(value)) {
|
|
31
|
-
return
|
|
22
|
+
return [];
|
|
32
23
|
}
|
|
33
|
-
|
|
24
|
+
return value.flatMap((item)=>{
|
|
34
25
|
if (typeof item === 'string' && item.trim() !== '') {
|
|
35
26
|
return [
|
|
36
27
|
item.trim()
|
|
@@ -44,87 +35,159 @@ const getStringArray = (value)=>{
|
|
|
44
35
|
}
|
|
45
36
|
return [];
|
|
46
37
|
});
|
|
47
|
-
return values.length > 0 ? values : undefined;
|
|
48
38
|
};
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (!auth) {
|
|
53
|
-
return undefined;
|
|
39
|
+
const authToggleEnabled = (toggle, defaultValue)=>{
|
|
40
|
+
if (toggle === undefined) {
|
|
41
|
+
return defaultValue;
|
|
54
42
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
allowedWorkflows: getStringArray(githubOidc.allowedWorkflows),
|
|
77
|
-
allowPullRequests: typeof githubOidc.allowPullRequests === 'boolean' ? githubOidc.allowPullRequests : undefined,
|
|
78
|
-
audience: getString(githubOidc.audience),
|
|
79
|
-
enabled: githubOidc.enabled === true,
|
|
80
|
-
issuer: getString(githubOidc.issuer),
|
|
81
|
-
jwksUrl: getString(githubOidc.jwksUrl),
|
|
82
|
-
maxSkewSeconds: getNumber(githubOidc.maxSkewSeconds)
|
|
83
|
-
} : undefined;
|
|
84
|
-
const hasGithubOidcPolicy = Boolean(resolvedGithubOidc && (resolvedGithubOidc.enabled || resolvedGithubOidc.audience || resolvedGithubOidc.allowedEnvironments || resolvedGithubOidc.allowedRefs || resolvedGithubOidc.allowedRepositories || resolvedGithubOidc.allowedRepositoryOwners || resolvedGithubOidc.allowedWorkflowRefs || resolvedGithubOidc.allowedWorkflows || resolvedGithubOidc.allowPullRequests !== undefined || resolvedGithubOidc.issuer || resolvedGithubOidc.jwksUrl || resolvedGithubOidc.maxSkewSeconds !== undefined));
|
|
85
|
-
const resolvedAuth = {
|
|
86
|
-
...keys.length > 0 ? {
|
|
87
|
-
ed25519: {
|
|
88
|
-
keys,
|
|
89
|
-
maxSkewSeconds: getNumber(ed25519?.maxSkewSeconds),
|
|
90
|
-
nonceTtlSeconds: getNumber(ed25519?.nonceTtlSeconds)
|
|
43
|
+
if (typeof toggle === 'boolean') {
|
|
44
|
+
return toggle;
|
|
45
|
+
}
|
|
46
|
+
return toggle.enabled !== false;
|
|
47
|
+
};
|
|
48
|
+
export const isGitHubOidcAuthEnabled = (auth)=>auth?.mode !== 'disabled' && authToggleEnabled(auth?.githubOidc, false);
|
|
49
|
+
export const isEd25519AuthEnabled = (auth)=>auth?.mode !== 'disabled' && authToggleEnabled(auth?.ed25519, false);
|
|
50
|
+
export const updateDocsSetAfterSync = async ({ aiExport, collectionSlug, docsCount, docsSetId, now, payload, syncRunId })=>{
|
|
51
|
+
if (!payload.update) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
await payload.update({
|
|
55
|
+
id: String(docsSetId),
|
|
56
|
+
collection: collectionSlug,
|
|
57
|
+
data: {
|
|
58
|
+
aiExport: aiExport ?? null,
|
|
59
|
+
sync: {
|
|
60
|
+
docsCount,
|
|
61
|
+
lastStatus: 'success',
|
|
62
|
+
lastSyncedAt: now.toISOString(),
|
|
63
|
+
lastSyncRunId: syncRunId
|
|
91
64
|
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
65
|
+
},
|
|
66
|
+
overrideAccess: true
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
const toResolvedGroup = (doc, groupsById, seen = new Set())=>{
|
|
70
|
+
if (!isRecord(doc)) {
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
const id = getRecordId(doc);
|
|
74
|
+
const slug = getString(doc.slug);
|
|
75
|
+
if (!id || !slug) {
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
78
|
+
const stringId = String(id);
|
|
79
|
+
if (seen.has(stringId)) {
|
|
80
|
+
return {
|
|
81
|
+
id,
|
|
82
|
+
slug,
|
|
83
|
+
routePath: joinRouteSegments(slug)
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
const parentId = getRelationshipId(doc.parent);
|
|
87
|
+
const parentDoc = parentId ? groupsById.get(parentId) : undefined;
|
|
88
|
+
const parentGroup = parentDoc ? toResolvedGroup(parentDoc, groupsById, new Set([
|
|
89
|
+
stringId,
|
|
90
|
+
...seen
|
|
91
|
+
])) : undefined;
|
|
92
|
+
return {
|
|
93
|
+
id,
|
|
94
|
+
slug,
|
|
95
|
+
parentId,
|
|
96
|
+
routePath: joinRouteSegments(parentGroup?.routePath, slug)
|
|
96
97
|
};
|
|
97
|
-
return resolvedAuth.ed25519 || resolvedAuth.githubOidc ? resolvedAuth : undefined;
|
|
98
98
|
};
|
|
99
|
-
const toResolvedDocsSet = (doc)=>{
|
|
99
|
+
const toResolvedDocsSet = ({ doc, groupsById })=>{
|
|
100
100
|
if (!isRecord(doc)) {
|
|
101
101
|
return undefined;
|
|
102
102
|
}
|
|
103
103
|
const id = getRecordId(doc);
|
|
104
|
-
|
|
104
|
+
const slug = getString(doc.slug);
|
|
105
|
+
if (!id || !slug) {
|
|
105
106
|
return undefined;
|
|
106
107
|
}
|
|
108
|
+
const groupId = getRelationshipId(doc.group);
|
|
109
|
+
const group = groupId ? toResolvedGroup(groupsById.get(groupId), groupsById) : undefined;
|
|
110
|
+
const advancedSecurity = isRecord(doc.advancedSecurity) ? doc.advancedSecurity : undefined;
|
|
111
|
+
const advancedSecurityEnabled = advancedSecurity?.enabled === true;
|
|
107
112
|
return {
|
|
108
113
|
id,
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
114
|
+
...advancedSecurityEnabled ? {
|
|
115
|
+
advancedSecurity: {
|
|
116
|
+
allowedWorkflowRefs: getStringArray(advancedSecurity.allowedWorkflowRefs),
|
|
117
|
+
enabled: true
|
|
118
|
+
}
|
|
119
|
+
} : {},
|
|
120
|
+
slug,
|
|
121
|
+
allowPullRequests: doc.allowPullRequests === true,
|
|
122
|
+
branch: getString(doc.branch) ?? 'main',
|
|
123
|
+
groupId,
|
|
124
|
+
routeBase: normalizeRoutePath(deriveDocsSetRouteBase({
|
|
125
|
+
docsSetSlug: slug,
|
|
126
|
+
groupRoutePath: group?.routePath
|
|
127
|
+
}))
|
|
113
128
|
};
|
|
114
129
|
};
|
|
115
|
-
|
|
130
|
+
const getGroupsById = async ({ collectionSlug, payload })=>{
|
|
116
131
|
const result = await payload.find({
|
|
117
132
|
collection: collectionSlug,
|
|
118
133
|
depth: 0,
|
|
119
|
-
limit:
|
|
120
|
-
overrideAccess: true
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
134
|
+
limit: 1000,
|
|
135
|
+
overrideAccess: true
|
|
136
|
+
});
|
|
137
|
+
return new Map(result.docs.flatMap((doc)=>{
|
|
138
|
+
if (!isRecord(doc)) {
|
|
139
|
+
return [];
|
|
125
140
|
}
|
|
141
|
+
const id = getRecordId(doc);
|
|
142
|
+
return id === undefined ? [] : [
|
|
143
|
+
[
|
|
144
|
+
String(id),
|
|
145
|
+
doc
|
|
146
|
+
]
|
|
147
|
+
];
|
|
148
|
+
}));
|
|
149
|
+
};
|
|
150
|
+
export const findDocsSetBySlug = async ({ slug, collectionSlug, docsGroupsCollectionSlug, payload })=>{
|
|
151
|
+
const [result, groupsById] = await Promise.all([
|
|
152
|
+
payload.find({
|
|
153
|
+
collection: collectionSlug,
|
|
154
|
+
depth: 0,
|
|
155
|
+
limit: 1,
|
|
156
|
+
overrideAccess: true,
|
|
157
|
+
where: {
|
|
158
|
+
slug: {
|
|
159
|
+
equals: slug
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}),
|
|
163
|
+
getGroupsById({
|
|
164
|
+
collectionSlug: docsGroupsCollectionSlug,
|
|
165
|
+
payload
|
|
166
|
+
})
|
|
167
|
+
]);
|
|
168
|
+
return toResolvedDocsSet({
|
|
169
|
+
doc: result.docs[0],
|
|
170
|
+
groupsById
|
|
126
171
|
});
|
|
127
|
-
|
|
172
|
+
};
|
|
173
|
+
export const findDocsSetByRouteBase = async ({ collectionSlug, docsGroupsCollectionSlug, payload, routeBase })=>{
|
|
174
|
+
const [result, groupsById] = await Promise.all([
|
|
175
|
+
payload.find({
|
|
176
|
+
collection: collectionSlug,
|
|
177
|
+
depth: 0,
|
|
178
|
+
limit: 1000,
|
|
179
|
+
overrideAccess: true
|
|
180
|
+
}),
|
|
181
|
+
getGroupsById({
|
|
182
|
+
collectionSlug: docsGroupsCollectionSlug,
|
|
183
|
+
payload
|
|
184
|
+
})
|
|
185
|
+
]);
|
|
186
|
+
const normalizedRouteBase = normalizeRoutePath(routeBase);
|
|
187
|
+
return result.docs.map((doc)=>toResolvedDocsSet({
|
|
188
|
+
doc,
|
|
189
|
+
groupsById
|
|
190
|
+
})).find((docsSet)=>docsSet?.routeBase === normalizedRouteBase);
|
|
128
191
|
};
|
|
129
192
|
|
|
130
193
|
//# sourceMappingURL=docsSets.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/payload/docsSets.ts"],"sourcesContent":["import type { PayloadMarkdownDocsDocsSetAuthConfig } from '../types.js'\n\nexport type DocsSetPayloadOperations = {\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: string\n overrideAccess?: boolean\n }) => Promise<Record<string, unknown>>\n}\n\nexport type PayloadRecordId = number | string\n\nexport type ResolvedDocsSet = {\n auth?: PayloadMarkdownDocsDocsSetAuthConfig\n id: PayloadRecordId\n routeBase: string\n sourceId: string\n sourceRoot?: string\n}\n\nexport const updateDocsSetAfterSync = async ({\n aiExport,\n collectionSlug,\n docsCount,\n docsSetId,\n now,\n payload,\n syncRunId,\n}: {\n aiExport?: unknown\n collectionSlug: string\n docsCount: number\n docsSetId: PayloadRecordId\n now: Date\n payload: DocsSetPayloadOperations\n syncRunId?: PayloadRecordId\n}): Promise<void> => {\n if (!payload.update) {\n return\n }\n\n await payload.update({\n id: String(docsSetId),\n collection: collectionSlug,\n data: {\n aiExport: aiExport ?? null,\n sync: {\n docsCount,\n lastStatus: 'success',\n lastSyncedAt: now.toISOString(),\n lastSyncRunId: syncRunId,\n },\n },\n overrideAccess: true,\n })\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>): PayloadRecordId | undefined => {\n if (typeof doc.id === 'string' || typeof doc.id === 'number') {\n return doc.id\n }\n\n return undefined\n}\n\nconst getString = (value: unknown): string | undefined =>\n typeof value === 'string' && value.trim() !== '' ? value.trim() : undefined\n\nconst getNumber = (value: unknown): number | undefined =>\n typeof value === 'number' && Number.isFinite(value) ? value : undefined\n\nconst getStringArray = (value: unknown): string[] | undefined => {\n if (!Array.isArray(value)) {\n return undefined\n }\n\n const values = value.flatMap((item) => {\n if (typeof item === 'string' && item.trim() !== '') {\n return [item.trim()]\n }\n\n if (isRecord(item)) {\n const nestedValue = getString(item.value)\n\n return nestedValue ? [nestedValue] : []\n }\n\n return []\n })\n\n return values.length > 0 ? values : undefined\n}\n\nconst getRecord = (value: unknown): Record<string, unknown> | undefined =>\n isRecord(value) ? value : undefined\n\nconst toResolvedDocsSetAuth = (\n value: unknown,\n): PayloadMarkdownDocsDocsSetAuthConfig | undefined => {\n const auth = getRecord(value)\n\n if (!auth) {\n return undefined\n }\n\n const ed25519 = getRecord(auth.ed25519)\n const keys = Array.isArray(ed25519?.keys)\n ? ed25519.keys.flatMap((key) => {\n if (!isRecord(key)) {\n return []\n }\n\n const id = getString(key.keyId) ?? getString(key.id)\n const publicKey = getString(key.publicKey)\n\n return id && publicKey\n ? [\n {\n id,\n publicKey,\n },\n ]\n : []\n })\n : []\n const githubOidc = getRecord(auth.githubOidc)\n const resolvedGithubOidc =\n githubOidc && githubOidc.enabled !== false\n ? {\n allowedEnvironments: getStringArray(githubOidc.allowedEnvironments),\n allowedRefs: getStringArray(githubOidc.allowedRefs),\n allowedRepositories: getStringArray(githubOidc.allowedRepositories),\n allowedRepositoryOwners: getStringArray(githubOidc.allowedRepositoryOwners),\n allowedWorkflowRefs: getStringArray(githubOidc.allowedWorkflowRefs),\n allowedWorkflows: getStringArray(githubOidc.allowedWorkflows),\n allowPullRequests:\n typeof githubOidc.allowPullRequests === 'boolean'\n ? githubOidc.allowPullRequests\n : undefined,\n audience: getString(githubOidc.audience),\n enabled: githubOidc.enabled === true,\n issuer: getString(githubOidc.issuer),\n jwksUrl: getString(githubOidc.jwksUrl),\n maxSkewSeconds: getNumber(githubOidc.maxSkewSeconds),\n }\n : undefined\n const hasGithubOidcPolicy = Boolean(\n resolvedGithubOidc &&\n (resolvedGithubOidc.enabled ||\n resolvedGithubOidc.audience ||\n resolvedGithubOidc.allowedEnvironments ||\n resolvedGithubOidc.allowedRefs ||\n resolvedGithubOidc.allowedRepositories ||\n resolvedGithubOidc.allowedRepositoryOwners ||\n resolvedGithubOidc.allowedWorkflowRefs ||\n resolvedGithubOidc.allowedWorkflows ||\n resolvedGithubOidc.allowPullRequests !== undefined ||\n resolvedGithubOidc.issuer ||\n resolvedGithubOidc.jwksUrl ||\n resolvedGithubOidc.maxSkewSeconds !== undefined),\n )\n const resolvedAuth: PayloadMarkdownDocsDocsSetAuthConfig = {\n ...(keys.length > 0\n ? {\n ed25519: {\n keys,\n maxSkewSeconds: getNumber(ed25519?.maxSkewSeconds),\n nonceTtlSeconds: getNumber(ed25519?.nonceTtlSeconds),\n },\n }\n : {}),\n ...(hasGithubOidcPolicy && resolvedGithubOidc\n ? {\n githubOidc: resolvedGithubOidc,\n }\n : {}),\n }\n\n return resolvedAuth.ed25519 || resolvedAuth.githubOidc ? resolvedAuth : undefined\n}\n\nconst toResolvedDocsSet = (doc: unknown): ResolvedDocsSet | undefined => {\n if (!isRecord(doc)) {\n return undefined\n }\n\n const id = getRecordId(doc)\n\n if (!id || typeof doc.sourceId !== 'string' || typeof doc.routeBase !== 'string') {\n return undefined\n }\n\n return {\n id,\n auth: toResolvedDocsSetAuth(doc.auth),\n routeBase: doc.routeBase,\n sourceId: doc.sourceId,\n sourceRoot: typeof doc.sourceRoot === 'string' ? doc.sourceRoot : undefined,\n }\n}\n\nexport const findDocsSetBySourceId = async ({\n collectionSlug,\n payload,\n sourceId,\n}: {\n collectionSlug: string\n payload: DocsSetPayloadOperations\n sourceId: string\n}): Promise<ResolvedDocsSet | undefined> => {\n const result = await payload.find({\n collection: collectionSlug,\n depth: 0,\n limit: 1,\n overrideAccess: true,\n where: {\n sourceId: {\n equals: sourceId,\n },\n },\n })\n\n return toResolvedDocsSet(result.docs[0])\n}\n"],"names":["updateDocsSetAfterSync","aiExport","collectionSlug","docsCount","docsSetId","now","payload","syncRunId","update","id","String","collection","data","sync","lastStatus","lastSyncedAt","toISOString","lastSyncRunId","overrideAccess","isRecord","value","Array","isArray","getRecordId","doc","undefined","getString","trim","getNumber","Number","isFinite","getStringArray","values","flatMap","item","nestedValue","length","getRecord","toResolvedDocsSetAuth","auth","ed25519","keys","key","keyId","publicKey","githubOidc","resolvedGithubOidc","enabled","allowedEnvironments","allowedRefs","allowedRepositories","allowedRepositoryOwners","allowedWorkflowRefs","allowedWorkflows","allowPullRequests","audience","issuer","jwksUrl","maxSkewSeconds","hasGithubOidcPolicy","Boolean","resolvedAuth","nonceTtlSeconds","toResolvedDocsSet","sourceId","routeBase","sourceRoot","findDocsSetBySourceId","result","find","depth","limit","where","equals","docs"],"mappings":"AA8BA,OAAO,MAAMA,yBAAyB,OAAO,EAC3CC,QAAQ,EACRC,cAAc,EACdC,SAAS,EACTC,SAAS,EACTC,GAAG,EACHC,OAAO,EACPC,SAAS,EASV;IACC,IAAI,CAACD,QAAQE,MAAM,EAAE;QACnB;IACF;IAEA,MAAMF,QAAQE,MAAM,CAAC;QACnBC,IAAIC,OAAON;QACXO,YAAYT;QACZU,MAAM;YACJX,UAAUA,YAAY;YACtBY,MAAM;gBACJV;gBACAW,YAAY;gBACZC,cAAcV,IAAIW,WAAW;gBAC7BC,eAAeV;YACjB;QACF;QACAW,gBAAgB;IAClB;AACF,EAAC;AAED,MAAMC,WAAW,CAACC,QAChB,OAAOA,UAAU,YAAYA,UAAU,QAAQ,CAACC,MAAMC,OAAO,CAACF;AAEhE,MAAMG,cAAc,CAACC;IACnB,IAAI,OAAOA,IAAIf,EAAE,KAAK,YAAY,OAAOe,IAAIf,EAAE,KAAK,UAAU;QAC5D,OAAOe,IAAIf,EAAE;IACf;IAEA,OAAOgB;AACT;AAEA,MAAMC,YAAY,CAACN,QACjB,OAAOA,UAAU,YAAYA,MAAMO,IAAI,OAAO,KAAKP,MAAMO,IAAI,KAAKF;AAEpE,MAAMG,YAAY,CAACR,QACjB,OAAOA,UAAU,YAAYS,OAAOC,QAAQ,CAACV,SAASA,QAAQK;AAEhE,MAAMM,iBAAiB,CAACX;IACtB,IAAI,CAACC,MAAMC,OAAO,CAACF,QAAQ;QACzB,OAAO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C0B,WAAWzC,IAAIyC,SAAS;QACxBD,UAAUxC,IAAIwC,QAAQ;QACtBE,YAAY,OAAO1C,IAAI0C,UAAU,KAAK,WAAW1C,IAAI0C,UAAU,GAAGzC;IACpE;AACF;AAEA,OAAO,MAAM0C,wBAAwB,OAAO,EAC1CjE,cAAc,EACdI,OAAO,EACP0D,QAAQ,EAKT;IACC,MAAMI,SAAS,MAAM9D,QAAQ+D,IAAI,CAAC;QAChC1D,YAAYT;QACZoE,OAAO;QACPC,OAAO;QACPrD,gBAAgB;QAChBsD,OAAO;YACLR,UAAU;gBACRS,QAAQT;YACV;QACF;IACF;IAEA,OAAOD,kBAAkBK,OAAOM,IAAI,CAAC,EAAE;AACzC,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../src/payload/docsSets.ts"],"sourcesContent":["import type { PayloadMarkdownDocsAuthToggle } from '../types.js'\n\nimport {\n deriveDocsSetRouteBase,\n joinRouteSegments,\n normalizeRoutePath,\n} from '../routing/index.js'\n\nexport type DocsSetPayloadOperations = {\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: string\n overrideAccess?: boolean\n }) => Promise<Record<string, unknown>>\n}\n\nexport type PayloadRecordId = number | string\n\nexport type ResolvedDocsGroup = {\n id: PayloadRecordId\n parentId?: string\n routePath: string\n slug: string\n}\n\nexport type ResolvedDocsSet = {\n advancedSecurity?: {\n allowedWorkflowRefs: string[]\n enabled: boolean\n }\n allowPullRequests: boolean\n branch: string\n groupId?: string\n id: PayloadRecordId\n routeBase: string\n slug: string\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>): PayloadRecordId | 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 getString = (value: unknown): string | undefined =>\n typeof value === 'string' && value.trim() !== '' ? value.trim() : undefined\n\nconst getStringArray = (value: unknown): string[] => {\n if (!Array.isArray(value)) {\n return []\n }\n\n return value.flatMap((item) => {\n if (typeof item === 'string' && item.trim() !== '') {\n return [item.trim()]\n }\n\n if (isRecord(item)) {\n const nestedValue = getString(item.value)\n\n return nestedValue ? [nestedValue] : []\n }\n\n return []\n })\n}\n\nconst authToggleEnabled = (\n toggle: boolean | PayloadMarkdownDocsAuthToggle | undefined,\n defaultValue: boolean,\n): boolean => {\n if (toggle === undefined) {\n return defaultValue\n }\n\n if (typeof toggle === 'boolean') {\n return toggle\n }\n\n return toggle.enabled !== false\n}\n\nexport const isGitHubOidcAuthEnabled = (\n auth: { githubOidc?: boolean | PayloadMarkdownDocsAuthToggle; mode?: 'disabled' } | undefined,\n): boolean => auth?.mode !== 'disabled' && authToggleEnabled(auth?.githubOidc, false)\n\nexport const isEd25519AuthEnabled = (\n auth: { ed25519?: boolean | PayloadMarkdownDocsAuthToggle; mode?: 'disabled' } | undefined,\n): boolean => auth?.mode !== 'disabled' && authToggleEnabled(auth?.ed25519, false)\n\nexport const updateDocsSetAfterSync = async ({\n aiExport,\n collectionSlug,\n docsCount,\n docsSetId,\n now,\n payload,\n syncRunId,\n}: {\n aiExport?: unknown\n collectionSlug: string\n docsCount: number\n docsSetId: PayloadRecordId\n now: Date\n payload: DocsSetPayloadOperations\n syncRunId?: PayloadRecordId\n}): Promise<void> => {\n if (!payload.update) {\n return\n }\n\n await payload.update({\n id: String(docsSetId),\n collection: collectionSlug,\n data: {\n aiExport: aiExport ?? null,\n sync: {\n docsCount,\n lastStatus: 'success',\n lastSyncedAt: now.toISOString(),\n lastSyncRunId: syncRunId,\n },\n },\n overrideAccess: true,\n })\n}\n\nconst toResolvedGroup = (\n doc: unknown,\n groupsById: Map<string, unknown>,\n seen = new Set<string>(),\n): ResolvedDocsGroup | undefined => {\n if (!isRecord(doc)) {\n return undefined\n }\n\n const id = getRecordId(doc)\n const slug = getString(doc.slug)\n\n if (!id || !slug) {\n return undefined\n }\n\n const stringId = String(id)\n\n if (seen.has(stringId)) {\n return {\n id,\n slug,\n routePath: joinRouteSegments(slug),\n }\n }\n\n const parentId = getRelationshipId(doc.parent)\n const parentDoc = parentId ? groupsById.get(parentId) : undefined\n const parentGroup = parentDoc\n ? toResolvedGroup(parentDoc, groupsById, new Set([stringId, ...seen]))\n : undefined\n\n return {\n id,\n slug,\n parentId,\n routePath: joinRouteSegments(parentGroup?.routePath, slug),\n }\n}\n\nconst toResolvedDocsSet = ({\n doc,\n groupsById,\n}: {\n doc: unknown\n groupsById: Map<string, unknown>\n}): ResolvedDocsSet | undefined => {\n if (!isRecord(doc)) {\n return undefined\n }\n\n const id = getRecordId(doc)\n const slug = getString(doc.slug)\n\n if (!id || !slug) {\n return undefined\n }\n\n const groupId = getRelationshipId(doc.group)\n const group = groupId ? toResolvedGroup(groupsById.get(groupId), groupsById) : undefined\n const advancedSecurity = isRecord(doc.advancedSecurity)\n ? doc.advancedSecurity\n : undefined\n const advancedSecurityEnabled = advancedSecurity?.enabled === true\n\n return {\n id,\n ...(advancedSecurityEnabled\n ? {\n advancedSecurity: {\n allowedWorkflowRefs: getStringArray(advancedSecurity.allowedWorkflowRefs),\n enabled: true,\n },\n }\n : {}),\n slug,\n allowPullRequests: doc.allowPullRequests === true,\n branch: getString(doc.branch) ?? 'main',\n groupId,\n routeBase: normalizeRoutePath(\n deriveDocsSetRouteBase({\n docsSetSlug: slug,\n groupRoutePath: group?.routePath,\n }),\n ),\n }\n}\n\nconst getGroupsById = async ({\n collectionSlug,\n payload,\n}: {\n collectionSlug: string\n payload: DocsSetPayloadOperations\n}): Promise<Map<string, unknown>> => {\n const result = await payload.find({\n collection: collectionSlug,\n depth: 0,\n limit: 1000,\n overrideAccess: true,\n })\n\n return new Map(\n result.docs.flatMap((doc) => {\n if (!isRecord(doc)) {\n return []\n }\n\n const id = getRecordId(doc)\n\n return id === undefined ? [] : [[String(id), doc]]\n }),\n )\n}\n\nexport const findDocsSetBySlug = async ({\n slug,\n collectionSlug,\n docsGroupsCollectionSlug,\n payload,\n}: {\n collectionSlug: string\n docsGroupsCollectionSlug: string\n payload: DocsSetPayloadOperations\n slug: string\n}): Promise<ResolvedDocsSet | undefined> => {\n const [result, groupsById] = await Promise.all([\n payload.find({\n collection: collectionSlug,\n depth: 0,\n limit: 1,\n overrideAccess: true,\n where: {\n slug: {\n equals: slug,\n },\n },\n }),\n getGroupsById({\n collectionSlug: docsGroupsCollectionSlug,\n payload,\n }),\n ])\n\n return toResolvedDocsSet({\n doc: result.docs[0],\n groupsById,\n })\n}\n\nexport const findDocsSetByRouteBase = async ({\n collectionSlug,\n docsGroupsCollectionSlug,\n payload,\n routeBase,\n}: {\n collectionSlug: string\n docsGroupsCollectionSlug: string\n payload: DocsSetPayloadOperations\n routeBase: string\n}): Promise<ResolvedDocsSet | undefined> => {\n const [result, groupsById] = await Promise.all([\n payload.find({\n collection: collectionSlug,\n depth: 0,\n limit: 1000,\n overrideAccess: true,\n }),\n getGroupsById({\n collectionSlug: docsGroupsCollectionSlug,\n payload,\n }),\n ])\n const normalizedRouteBase = normalizeRoutePath(routeBase)\n\n return result.docs\n .map((doc) =>\n toResolvedDocsSet({\n doc,\n groupsById,\n }),\n )\n .find((docsSet) => docsSet?.routeBase === normalizedRouteBase)\n}\n"],"names":["deriveDocsSetRouteBase","joinRouteSegments","normalizeRoutePath","isRecord","value","Array","isArray","getRecordId","doc","id","undefined","getRelationshipId","String","getString","trim","getStringArray","flatMap","item","nestedValue","authToggleEnabled","toggle","defaultValue","enabled","isGitHubOidcAuthEnabled","auth","mode","githubOidc","isEd25519AuthEnabled","ed25519","updateDocsSetAfterSync","aiExport","collectionSlug","docsCount","docsSetId","now","payload","syncRunId","update","collection","data","sync","lastStatus","lastSyncedAt","toISOString","lastSyncRunId","overrideAccess","toResolvedGroup","groupsById","seen","Set","slug","stringId","has","routePath","parentId","parent","parentDoc","get","parentGroup","toResolvedDocsSet","groupId","group","advancedSecurity","advancedSecurityEnabled","allowedWorkflowRefs","allowPullRequests","branch","routeBase","docsSetSlug","groupRoutePath","getGroupsById","result","find","depth","limit","Map","docs","findDocsSetBySlug","docsGroupsCollectionSlug","Promise","all","where","equals","findDocsSetByRouteBase","normalizedRouteBase","map","docsSet"],"mappings":"AAEA,SACEA,sBAAsB,EACtBC,iBAAiB,EACjBC,kBAAkB,QACb,sBAAqB;AA0C5B,MAAMC,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,YAAY,CAACT,QACjB,OAAOA,UAAU,YAAYA,MAAMU,IAAI,OAAO,KAAKV,MAAMU,IAAI,KAAKJ;AAEpE,MAAMK,iBAAiB,CAACX;IACtB,IAAI,CAACC,MAAMC,OAAO,CAACF,QAAQ;QACzB,OAAO,EAAE;IACX;IAEA,OAAOA,MAAMY,OAAO,CAAC,CAACC;QACpB,IAAI,OAAOA,SAAS,YAAYA,KAAKH,IAAI,OAAO,IAAI;YAClD,OAAO;gBAACG,KAAKH,IAAI;aAAG;QACtB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B;AAC9C,EAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { GitHubOidcTrustedSource } from '../security/index.js';
|
|
2
|
+
export type DocsTrustedPayloadOperations = {
|
|
3
|
+
find: (args: {
|
|
4
|
+
collection: string;
|
|
5
|
+
depth?: number;
|
|
6
|
+
limit?: number;
|
|
7
|
+
overrideAccess?: boolean;
|
|
8
|
+
where?: unknown;
|
|
9
|
+
}) => Promise<{
|
|
10
|
+
docs: unknown[];
|
|
11
|
+
}>;
|
|
12
|
+
};
|
|
13
|
+
export declare const findTrustedGitHubSources: ({ collectionSlug, payload, }: {
|
|
14
|
+
collectionSlug: string;
|
|
15
|
+
payload: DocsTrustedPayloadOperations;
|
|
16
|
+
}) => Promise<GitHubOidcTrustedSource[]>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
const isRecord = (value)=>typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
2
|
+
const getString = (value)=>typeof value === 'string' && value.trim() !== '' ? value.trim() : undefined;
|
|
3
|
+
const getStringArray = (value)=>{
|
|
4
|
+
if (!Array.isArray(value)) {
|
|
5
|
+
return [];
|
|
6
|
+
}
|
|
7
|
+
return value.flatMap((item)=>{
|
|
8
|
+
if (typeof item === 'string' && item.trim() !== '') {
|
|
9
|
+
return [
|
|
10
|
+
item.trim()
|
|
11
|
+
];
|
|
12
|
+
}
|
|
13
|
+
if (isRecord(item)) {
|
|
14
|
+
const nestedValue = getString(item.value);
|
|
15
|
+
return nestedValue ? [
|
|
16
|
+
nestedValue
|
|
17
|
+
] : [];
|
|
18
|
+
}
|
|
19
|
+
return [];
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
const toTrustedSource = (doc)=>{
|
|
23
|
+
if (!isRecord(doc)) {
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
const owner = getString(doc.owner);
|
|
27
|
+
if (!owner) {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
const limitRepos = doc.limitRepos === true;
|
|
31
|
+
return {
|
|
32
|
+
limitRepos,
|
|
33
|
+
owner,
|
|
34
|
+
...limitRepos ? {
|
|
35
|
+
repositories: getStringArray(doc.repositories)
|
|
36
|
+
} : {}
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
export const findTrustedGitHubSources = async ({ collectionSlug, payload })=>{
|
|
40
|
+
const result = await payload.find({
|
|
41
|
+
collection: collectionSlug,
|
|
42
|
+
depth: 0,
|
|
43
|
+
limit: 1000,
|
|
44
|
+
overrideAccess: true
|
|
45
|
+
});
|
|
46
|
+
return result.docs.map(toTrustedSource).filter((source)=>source !== undefined);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=docsTrusted.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/payload/docsTrusted.ts"],"sourcesContent":["import type { GitHubOidcTrustedSource } from '../security/index.js'\n\nexport type DocsTrustedPayloadOperations = {\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}\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value)\n\nconst getString = (value: unknown): string | undefined =>\n typeof value === 'string' && value.trim() !== '' ? value.trim() : undefined\n\nconst getStringArray = (value: unknown): string[] => {\n if (!Array.isArray(value)) {\n return []\n }\n\n return value.flatMap((item) => {\n if (typeof item === 'string' && item.trim() !== '') {\n return [item.trim()]\n }\n\n if (isRecord(item)) {\n const nestedValue = getString(item.value)\n\n return nestedValue ? [nestedValue] : []\n }\n\n return []\n })\n}\n\nconst toTrustedSource = (doc: unknown): GitHubOidcTrustedSource | undefined => {\n if (!isRecord(doc)) {\n return undefined\n }\n\n const owner = getString(doc.owner)\n\n if (!owner) {\n return undefined\n }\n\n const limitRepos = doc.limitRepos === true\n\n return {\n limitRepos,\n owner,\n ...(limitRepos\n ? {\n repositories: getStringArray(doc.repositories),\n }\n : {}),\n }\n}\n\nexport const findTrustedGitHubSources = async ({\n collectionSlug,\n payload,\n}: {\n collectionSlug: string\n payload: DocsTrustedPayloadOperations\n}): Promise<GitHubOidcTrustedSource[]> => {\n const result = await payload.find({\n collection: collectionSlug,\n depth: 0,\n limit: 1000,\n overrideAccess: true,\n })\n\n return result.docs\n .map(toTrustedSource)\n .filter((source): source is GitHubOidcTrustedSource => source !== undefined)\n}\n"],"names":["isRecord","value","Array","isArray","getString","trim","undefined","getStringArray","flatMap","item","nestedValue","toTrustedSource","doc","owner","limitRepos","repositories","findTrustedGitHubSources","collectionSlug","payload","result","find","collection","depth","limit","overrideAccess","docs","map","filter","source"],"mappings":"AAcA,MAAMA,WAAW,CAACC,QAChB,OAAOA,UAAU,YAAYA,UAAU,QAAQ,CAACC,MAAMC,OAAO,CAACF;AAEhE,MAAMG,YAAY,CAACH,QACjB,OAAOA,UAAU,YAAYA,MAAMI,IAAI,OAAO,KAAKJ,MAAMI,IAAI,KAAKC;AAEpE,MAAMC,iBAAiB,CAACN;IACtB,IAAI,CAACC,MAAMC,OAAO,CAACF,QAAQ;QACzB,OAAO,EAAE;IACX;IAEA,OAAOA,MAAMO,OAAO,CAAC,CAACC;QACpB,IAAI,OAAOA,SAAS,YAAYA,KAAKJ,IAAI,OAAO,IAAI;YAClD,OAAO;gBAACI,KAAKJ,IAAI;aAAG;QACtB;QAEA,IAAIL,SAASS,OAAO;YAClB,MAAMC,cAAcN,UAAUK,KAAKR,KAAK;YAExC,OAAOS,cAAc;gBAACA;aAAY,GAAG,EAAE;QACzC;QAEA,OAAO,EAAE;IACX;AACF;AAEA,MAAMC,kBAAkB,CAACC;IACvB,IAAI,CAACZ,SAASY,MAAM;QAClB,OAAON;IACT;IAEA,MAAMO,QAAQT,UAAUQ,IAAIC,KAAK;IAEjC,IAAI,CAACA,OAAO;QACV,OAAOP;IACT;IAEA,MAAMQ,aAAaF,IAAIE,UAAU,KAAK;IAEtC,OAAO;QACLA;QACAD;QACA,GAAIC,aACA;YACEC,cAAcR,eAAeK,IAAIG,YAAY;QAC/C,IACA,CAAC,CAAC;IACR;AACF;AAEA,OAAO,MAAMC,2BAA2B,OAAO,EAC7CC,cAAc,EACdC,OAAO,EAIR;IACC,MAAMC,SAAS,MAAMD,QAAQE,IAAI,CAAC;QAChCC,YAAYJ;QACZK,OAAO;QACPC,OAAO;QACPC,gBAAgB;IAClB;IAEA,OAAOL,OAAOM,IAAI,CACfC,GAAG,CAACf,iBACJgB,MAAM,CAAC,CAACC,SAA8CA,WAAWtB;AACtE,EAAC"}
|
package/dist/payload/index.d.ts
CHANGED
|
@@ -4,8 +4,12 @@ export { findDocsSyncConflicts } from './docsConflicts.js';
|
|
|
4
4
|
export type { DocsSyncConflict, DocsSyncConflictReason, } from './docsConflicts.js';
|
|
5
5
|
export { buildArchiveData, buildDocsData, getDocsDepth, } from './docsData.js';
|
|
6
6
|
export type { BuildDocsDataInput, DocsDraftStatus, DocsPublishMode, } from './docsData.js';
|
|
7
|
-
export {
|
|
7
|
+
export { findDocsKeyById } from './docsKeys.js';
|
|
8
|
+
export type { DocsKeyPayloadOperations, ResolvedDocsKey, } from './docsKeys.js';
|
|
9
|
+
export { findDocsSetByRouteBase, findDocsSetBySlug, isEd25519AuthEnabled, isGitHubOidcAuthEnabled, updateDocsSetAfterSync, } from './docsSets.js';
|
|
8
10
|
export type { DocsSetPayloadOperations, ResolvedDocsSet, } from './docsSets.js';
|
|
11
|
+
export { findTrustedGitHubSources } from './docsTrusted.js';
|
|
12
|
+
export type { DocsTrustedPayloadOperations } from './docsTrusted.js';
|
|
9
13
|
export { findExistingDocsRecords } from './existingDocs.js';
|
|
10
14
|
export { findExistingPayloadDocsRecords, toExistingDocsRecord, } from './existingDocs.js';
|
|
11
15
|
export type { ExistingDocsPayloadOperations, ExistingPayloadDocsRecord, } from './existingDocs.js';
|
package/dist/payload/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export { applyDocsSync, assertApplyDeleteBehaviorSupported } from './applyDocsSync.js';
|
|
2
2
|
export { findDocsSyncConflicts } from './docsConflicts.js';
|
|
3
3
|
export { buildArchiveData, buildDocsData, getDocsDepth } from './docsData.js';
|
|
4
|
-
export {
|
|
4
|
+
export { findDocsKeyById } from './docsKeys.js';
|
|
5
|
+
export { findDocsSetByRouteBase, findDocsSetBySlug, isEd25519AuthEnabled, isGitHubOidcAuthEnabled, updateDocsSetAfterSync } from './docsSets.js';
|
|
6
|
+
export { findTrustedGitHubSources } from './docsTrusted.js';
|
|
5
7
|
export { findExistingDocsRecords } from './existingDocs.js';
|
|
6
8
|
export { findExistingPayloadDocsRecords, toExistingDocsRecord } from './existingDocs.js';
|
|
7
9
|
export { findConfiguredPagesRouteCollisions, findDuplicateDesiredRouteCollisions, findExistingDocsRouteCollisions } from './routeCollisions.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/payload/index.ts"],"sourcesContent":["export {\n applyDocsSync,\n assertApplyDeleteBehaviorSupported,\n} from './applyDocsSync.js'\nexport type {\n ApplyDocsSyncPayloadOperations,\n ApplyDocsSyncResult,\n} from './applyDocsSync.js'\nexport { findDocsSyncConflicts } from './docsConflicts.js'\nexport type {\n DocsSyncConflict,\n DocsSyncConflictReason,\n} from './docsConflicts.js'\nexport {\n buildArchiveData,\n buildDocsData,\n getDocsDepth,\n} from './docsData.js'\nexport type {\n BuildDocsDataInput,\n DocsDraftStatus,\n DocsPublishMode,\n} from './docsData.js'\nexport {\n
|
|
1
|
+
{"version":3,"sources":["../../src/payload/index.ts"],"sourcesContent":["export {\n applyDocsSync,\n assertApplyDeleteBehaviorSupported,\n} from './applyDocsSync.js'\nexport type {\n ApplyDocsSyncPayloadOperations,\n ApplyDocsSyncResult,\n} from './applyDocsSync.js'\nexport { findDocsSyncConflicts } from './docsConflicts.js'\nexport type {\n DocsSyncConflict,\n DocsSyncConflictReason,\n} from './docsConflicts.js'\nexport {\n buildArchiveData,\n buildDocsData,\n getDocsDepth,\n} from './docsData.js'\nexport type {\n BuildDocsDataInput,\n DocsDraftStatus,\n DocsPublishMode,\n} from './docsData.js'\nexport { findDocsKeyById } from './docsKeys.js'\nexport type {\n DocsKeyPayloadOperations,\n ResolvedDocsKey,\n} from './docsKeys.js'\nexport {\n findDocsSetByRouteBase,\n findDocsSetBySlug,\n isEd25519AuthEnabled,\n isGitHubOidcAuthEnabled,\n updateDocsSetAfterSync,\n} from './docsSets.js'\nexport type {\n DocsSetPayloadOperations,\n ResolvedDocsSet,\n} from './docsSets.js'\nexport { findTrustedGitHubSources } from './docsTrusted.js'\nexport type { DocsTrustedPayloadOperations } from './docsTrusted.js'\nexport { findExistingDocsRecords } from './existingDocs.js'\nexport {\n findExistingPayloadDocsRecords,\n toExistingDocsRecord,\n} from './existingDocs.js'\nexport type {\n ExistingDocsPayloadOperations,\n ExistingPayloadDocsRecord,\n} from './existingDocs.js'\nexport {\n findConfiguredPagesRouteCollisions,\n findDuplicateDesiredRouteCollisions,\n findExistingDocsRouteCollisions,\n} from './routeCollisions.js'\nexport type {\n DocsRouteCollisionIssue,\n RouteCollisionPayloadOperations,\n} from './routeCollisions.js'\nexport {\n createSyncRunAudit,\n getRecordId,\n updateSyncRunAudit,\n} from './syncRuns.js'\nexport type {\n CreateSyncRunAuditInput,\n SyncRunsPayloadOperations,\n SyncRunStatus,\n SyncRunSummary,\n} from './syncRuns.js'\n"],"names":["applyDocsSync","assertApplyDeleteBehaviorSupported","findDocsSyncConflicts","buildArchiveData","buildDocsData","getDocsDepth","findDocsKeyById","findDocsSetByRouteBase","findDocsSetBySlug","isEd25519AuthEnabled","isGitHubOidcAuthEnabled","updateDocsSetAfterSync","findTrustedGitHubSources","findExistingDocsRecords","findExistingPayloadDocsRecords","toExistingDocsRecord","findConfiguredPagesRouteCollisions","findDuplicateDesiredRouteCollisions","findExistingDocsRouteCollisions","createSyncRunAudit","getRecordId","updateSyncRunAudit"],"mappings":"AAAA,SACEA,aAAa,EACbC,kCAAkC,QAC7B,qBAAoB;AAK3B,SAASC,qBAAqB,QAAQ,qBAAoB;AAK1D,SACEC,gBAAgB,EAChBC,aAAa,EACbC,YAAY,QACP,gBAAe;AAMtB,SAASC,eAAe,QAAQ,gBAAe;AAK/C,SACEC,sBAAsB,EACtBC,iBAAiB,EACjBC,oBAAoB,EACpBC,uBAAuB,EACvBC,sBAAsB,QACjB,gBAAe;AAKtB,SAASC,wBAAwB,QAAQ,mBAAkB;AAE3D,SAASC,uBAAuB,QAAQ,oBAAmB;AAC3D,SACEC,8BAA8B,EAC9BC,oBAAoB,QACf,oBAAmB;AAK1B,SACEC,kCAAkC,EAClCC,mCAAmC,EACnCC,+BAA+B,QAC1B,uBAAsB;AAK7B,SACEC,kBAAkB,EAClBC,WAAW,EACXC,kBAAkB,QACb,gBAAe"}
|
package/dist/plugin.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { createDocsCollection, createDocsGroupsCollection, createDocsSetsCollection, createNoncesCollection, createSyncRunsCollection } from './collections/index.js';
|
|
2
|
-
import { DEFAULT_DOCS_COLLECTION_SLUG, DEFAULT_DOCS_GROUPS_COLLECTION_SLUG,
|
|
1
|
+
import { createDocsCollection, createDocsGroupsCollection, createDocsKeysCollection, createDocsSetsCollection, createDocsTrustedCollection, createNoncesCollection, createSyncRunsCollection } from './collections/index.js';
|
|
2
|
+
import { 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 } from './constants.js';
|
|
3
3
|
import { createSyncEndpoint } from './endpoints/index.js';
|
|
4
4
|
const normalizeEndpointPath = (path)=>{
|
|
5
5
|
const normalized = `/${path.trim()}`.replace(/\/+/g, '/');
|
|
6
6
|
return normalized.length > 1 ? normalized.replace(/\/+$/g, '') : normalized;
|
|
7
7
|
};
|
|
8
8
|
const resolveCollectionOptions = (pluginOptions)=>{
|
|
9
|
-
if (pluginOptions.target?.type
|
|
10
|
-
throw new Error('payloadMarkdownDocs: target.type "
|
|
9
|
+
if (pluginOptions.target?.type !== undefined && pluginOptions.target.type !== 'docsCollection') {
|
|
10
|
+
throw new Error('payloadMarkdownDocs: target.type only supports "docsCollection". existingCollection is not supported.');
|
|
11
11
|
}
|
|
12
12
|
const docsSlugFromTarget = pluginOptions.target?.slug;
|
|
13
13
|
const docsSlugFromCollections = pluginOptions.collections?.docs?.slug;
|
|
@@ -19,10 +19,14 @@ const resolveCollectionOptions = (pluginOptions)=>{
|
|
|
19
19
|
docsEnabled: pluginOptions.collections?.docs?.enabled !== false,
|
|
20
20
|
docsGroupsCollectionSlug: pluginOptions.collections?.docsGroups?.slug ?? DEFAULT_DOCS_GROUPS_COLLECTION_SLUG,
|
|
21
21
|
docsGroupsEnabled: pluginOptions.collections?.docsGroups?.enabled !== false,
|
|
22
|
+
docsKeysCollectionSlug: pluginOptions.collections?.docsKeys?.slug ?? DEFAULT_DOCS_KEYS_COLLECTION_SLUG,
|
|
23
|
+
docsKeysEnabled: pluginOptions.collections?.docsKeys?.enabled !== false,
|
|
22
24
|
docsSetsCollectionSlug: pluginOptions.collections?.docsSets?.slug ?? DEFAULT_DOCS_SETS_COLLECTION_SLUG,
|
|
23
25
|
docsSetsEnabled: pluginOptions.collections?.docsSets?.enabled !== false,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
docsTrustedCollectionSlug: pluginOptions.collections?.docsTrusted?.slug ?? DEFAULT_DOCS_TRUSTED_COLLECTION_SLUG,
|
|
27
|
+
docsTrustedEnabled: pluginOptions.collections?.docsTrusted?.enabled !== false,
|
|
28
|
+
enableDrafts: pluginOptions.target?.enableDrafts === true,
|
|
29
|
+
markdownFieldName: pluginOptions.target?.markdownField ?? DEFAULT_MARKDOWN_FIELD_NAME,
|
|
26
30
|
noncesCollectionSlug: pluginOptions.collections?.nonces?.slug ?? DEFAULT_DOCS_SYNC_NONCES_COLLECTION_SLUG,
|
|
27
31
|
noncesEnabled: pluginOptions.collections?.nonces?.enabled !== false,
|
|
28
32
|
syncRunsCollectionSlug: pluginOptions.collections?.syncRuns?.slug ?? DEFAULT_DOCS_SYNC_RUNS_COLLECTION_SLUG,
|
|
@@ -49,14 +53,18 @@ export const payloadMarkdownDocs = (pluginOptions = {})=>(incomingConfig)=>{
|
|
|
49
53
|
if (pluginOptions.enabled === false) {
|
|
50
54
|
return incomingConfig;
|
|
51
55
|
}
|
|
52
|
-
const { docsCollectionSlug, docsEnabled, docsGroupsCollectionSlug, docsGroupsEnabled, docsSetsCollectionSlug, docsSetsEnabled, enableDrafts, markdownFieldName, noncesCollectionSlug, noncesEnabled, syncRunsCollectionSlug, syncRunsEnabled } = resolveCollectionOptions(pluginOptions);
|
|
56
|
+
const { docsCollectionSlug, docsEnabled, docsGroupsCollectionSlug, docsGroupsEnabled, docsKeysCollectionSlug, docsKeysEnabled, docsSetsCollectionSlug, docsSetsEnabled, docsTrustedCollectionSlug, docsTrustedEnabled, enableDrafts, markdownFieldName, noncesCollectionSlug, noncesEnabled, syncRunsCollectionSlug, syncRunsEnabled } = resolveCollectionOptions(pluginOptions);
|
|
53
57
|
assertCollectionOptionCompatibility({
|
|
54
58
|
docsCollectionSlug,
|
|
55
59
|
docsEnabled,
|
|
56
60
|
docsGroupsCollectionSlug,
|
|
57
61
|
docsGroupsEnabled,
|
|
62
|
+
docsKeysCollectionSlug,
|
|
63
|
+
docsKeysEnabled,
|
|
58
64
|
docsSetsCollectionSlug,
|
|
59
65
|
docsSetsEnabled,
|
|
66
|
+
docsTrustedCollectionSlug,
|
|
67
|
+
docsTrustedEnabled,
|
|
60
68
|
enableDrafts,
|
|
61
69
|
markdownFieldName,
|
|
62
70
|
noncesCollectionSlug,
|
|
@@ -72,6 +80,12 @@ export const payloadMarkdownDocs = (pluginOptions = {})=>(incomingConfig)=>{
|
|
|
72
80
|
...docsSetsEnabled ? [
|
|
73
81
|
docsSetsCollectionSlug
|
|
74
82
|
] : [],
|
|
83
|
+
...docsKeysEnabled ? [
|
|
84
|
+
docsKeysCollectionSlug
|
|
85
|
+
] : [],
|
|
86
|
+
...docsTrustedEnabled ? [
|
|
87
|
+
docsTrustedCollectionSlug
|
|
88
|
+
] : [],
|
|
75
89
|
...docsEnabled ? [
|
|
76
90
|
docsCollectionSlug
|
|
77
91
|
] : [],
|
|
@@ -97,6 +111,16 @@ export const payloadMarkdownDocs = (pluginOptions = {})=>(incomingConfig)=>{
|
|
|
97
111
|
syncRunsCollectionSlug: syncRunsEnabled ? syncRunsCollectionSlug : undefined
|
|
98
112
|
})
|
|
99
113
|
] : [],
|
|
114
|
+
...docsKeysEnabled ? [
|
|
115
|
+
createDocsKeysCollection({
|
|
116
|
+
slug: docsKeysCollectionSlug
|
|
117
|
+
})
|
|
118
|
+
] : [],
|
|
119
|
+
...docsTrustedEnabled ? [
|
|
120
|
+
createDocsTrustedCollection({
|
|
121
|
+
slug: docsTrustedCollectionSlug
|
|
122
|
+
})
|
|
123
|
+
] : [],
|
|
100
124
|
...docsEnabled ? [
|
|
101
125
|
createDocsCollection({
|
|
102
126
|
slug: docsCollectionSlug,
|
|
@@ -136,15 +160,19 @@ export const payloadMarkdownDocs = (pluginOptions = {})=>(incomingConfig)=>{
|
|
|
136
160
|
docsCollectionSlug,
|
|
137
161
|
docsEnabled,
|
|
138
162
|
docsEnableDrafts: enableDrafts,
|
|
163
|
+
docsGroupsCollectionSlug,
|
|
164
|
+
docsKeysCollectionSlug,
|
|
165
|
+
docsKeysEnabled,
|
|
139
166
|
docsSetsCollectionSlug,
|
|
140
167
|
docsSetsEnabled,
|
|
168
|
+
docsTrustedCollectionSlug,
|
|
169
|
+
docsTrustedEnabled,
|
|
141
170
|
endpointPath,
|
|
142
171
|
markdownFieldName,
|
|
143
172
|
maxBodyBytes: pluginOptions.endpoint?.maxBodyBytes ?? DEFAULT_MAX_BODY_BYTES,
|
|
144
173
|
noncesCollectionSlug,
|
|
145
174
|
noncesEnabled,
|
|
146
175
|
requireDryRunBeforeApply: pluginOptions.sync?.requireDryRunBeforeApply,
|
|
147
|
-
routeBase: DEFAULT_DOCS_ROUTE_BASE,
|
|
148
176
|
routing: {
|
|
149
177
|
pages: {
|
|
150
178
|
allowBridgePages: pluginOptions.routing?.pages?.allowBridgePages ?? true,
|
|
@@ -154,7 +182,6 @@ export const payloadMarkdownDocs = (pluginOptions = {})=>(incomingConfig)=>{
|
|
|
154
182
|
routeField: pluginOptions.routing?.pages?.routeField ?? DEFAULT_PAGES_ROUTE_FIELD
|
|
155
183
|
}
|
|
156
184
|
},
|
|
157
|
-
sources: pluginOptions.sources,
|
|
158
185
|
syncRunsCollectionSlug,
|
|
159
186
|
syncRunsEnabled
|
|
160
187
|
})
|