doccupine 0.0.142 → 0.0.144
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 +1 -1
- package/dist/cli.d.ts +6 -0
- package/dist/cli.js +130 -22
- package/dist/generator/api-reference-generator.d.ts +20 -0
- package/dist/generator/api-reference-generator.js +95 -0
- package/dist/generator/app-scaffolder.d.ts +19 -0
- package/dist/generator/app-scaffolder.js +54 -0
- package/dist/generator/generated-route-manager.d.ts +17 -0
- package/dist/generator/generated-route-manager.js +91 -0
- package/dist/generator/page-catalog.d.ts +17 -0
- package/dist/generator/page-catalog.js +68 -0
- package/dist/generator/page-renderer.d.ts +31 -0
- package/dist/generator/page-renderer.js +248 -0
- package/dist/generator/project-config-repository.d.ts +25 -0
- package/dist/generator/project-config-repository.js +133 -0
- package/dist/generator/public-asset-manager.d.ts +20 -0
- package/dist/generator/public-asset-manager.js +225 -0
- package/dist/generator/section-resolver.d.ts +13 -0
- package/dist/generator/section-resolver.js +150 -0
- package/dist/generator/secure-source-fs.d.ts +27 -0
- package/dist/generator/secure-source-fs.js +361 -0
- package/dist/generator/site-artifacts.d.ts +22 -0
- package/dist/generator/site-artifacts.js +159 -0
- package/dist/generator/watch-coordinator.d.ts +57 -0
- package/dist/generator/watch-coordinator.js +438 -0
- package/dist/lib/generated-artifacts.d.ts +3 -0
- package/dist/lib/generated-artifacts.js +27 -1
- package/dist/lib/layout.d.ts +1 -17
- package/dist/lib/layout.js +5 -4
- package/dist/lib/project-config.d.ts +3 -0
- package/dist/lib/project-config.js +110 -0
- package/dist/lib/structures.js +2 -0
- package/dist/lib/types.d.ts +14 -1
- package/dist/mdx-to-nextjs-generator.d.ts +7 -25
- package/dist/mdx-to-nextjs-generator.js +126 -1574
- package/dist/templates/app/api/rag/route.d.ts +1 -1
- package/dist/templates/app/api/rag/route.js +2 -1
- package/dist/templates/components/Chat.d.ts +1 -1
- package/dist/templates/components/Chat.js +2 -1
- package/dist/templates/components/MDXComponents.d.ts +1 -1
- package/dist/templates/components/MDXComponents.js +1 -1
- package/dist/templates/components/layout/Accordion.d.ts +1 -1
- package/dist/templates/components/layout/Accordion.js +2 -3
- package/dist/templates/components/layout/Space.d.ts +1 -0
- package/dist/templates/components/layout/Space.js +70 -0
- package/dist/templates/mdx/space.mdx.d.ts +1 -1
- package/dist/templates/mdx/space.mdx.js +27 -27
- package/dist/templates/next.config.js +2 -2
- package/dist/templates/package.js +2 -2
- package/dist/templates/proxy.js +1 -1
- package/dist/templates/services/mcp/server.d.ts +1 -1
- package/dist/templates/services/mcp/server.js +2 -12
- package/package.json +2 -2
|
@@ -39,10 +39,14 @@ function normalizeLlmsPageFile(value) {
|
|
|
39
39
|
const normalized = normalizeRelativePath(value);
|
|
40
40
|
return normalized?.endsWith(".md") ? normalized : null;
|
|
41
41
|
}
|
|
42
|
+
function normalizePublicFile(value) {
|
|
43
|
+
return typeof value === "string" ? normalizeRelativePath(value) : null;
|
|
44
|
+
}
|
|
42
45
|
export class GeneratedArtifacts {
|
|
43
46
|
outputDir;
|
|
44
47
|
routes = new Map();
|
|
45
48
|
llmsFiles = new Set();
|
|
49
|
+
publicFilePaths = new Set();
|
|
46
50
|
constructor(outputDir) {
|
|
47
51
|
this.outputDir = outputDir;
|
|
48
52
|
}
|
|
@@ -55,6 +59,7 @@ export class GeneratedArtifacts {
|
|
|
55
59
|
async load() {
|
|
56
60
|
this.routes.clear();
|
|
57
61
|
this.llmsFiles.clear();
|
|
62
|
+
this.publicFilePaths.clear();
|
|
58
63
|
const manifestContent = await readOutputFileIfPresent(this.outputDir, MANIFEST_FILE);
|
|
59
64
|
if (manifestContent !== null) {
|
|
60
65
|
try {
|
|
@@ -73,6 +78,13 @@ export class GeneratedArtifacts {
|
|
|
73
78
|
this.llmsFiles.add(file);
|
|
74
79
|
}
|
|
75
80
|
}
|
|
81
|
+
if (Array.isArray(parsed.publicFiles)) {
|
|
82
|
+
for (const value of parsed.publicFiles) {
|
|
83
|
+
const file = normalizePublicFile(value);
|
|
84
|
+
if (file)
|
|
85
|
+
this.publicFilePaths.add(file);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
76
88
|
}
|
|
77
89
|
catch {
|
|
78
90
|
// A corrupt manifest owns nothing. Generated output is rebuilt safely.
|
|
@@ -136,11 +148,25 @@ export class GeneratedArtifacts {
|
|
|
136
148
|
}
|
|
137
149
|
this.llmsFiles = next;
|
|
138
150
|
}
|
|
151
|
+
publicFiles() {
|
|
152
|
+
return new Set(this.publicFilePaths);
|
|
153
|
+
}
|
|
154
|
+
replacePublicFiles(files) {
|
|
155
|
+
const next = new Set();
|
|
156
|
+
for (const value of files) {
|
|
157
|
+
const file = normalizePublicFile(value);
|
|
158
|
+
if (!file)
|
|
159
|
+
throw new Error("Refusing to record an unsafe public path");
|
|
160
|
+
next.add(file);
|
|
161
|
+
}
|
|
162
|
+
this.publicFilePaths = next;
|
|
163
|
+
}
|
|
139
164
|
async save() {
|
|
140
165
|
const manifest = {
|
|
141
|
-
schemaVersion:
|
|
166
|
+
schemaVersion: 2,
|
|
142
167
|
routes: [...this.routes.values()].sort((a, b) => `${a.kind}:${a.source}`.localeCompare(`${b.kind}:${b.source}`)),
|
|
143
168
|
llmsPageFiles: [...this.llmsFiles].sort(),
|
|
169
|
+
publicFiles: [...this.publicFilePaths].sort(),
|
|
144
170
|
};
|
|
145
171
|
await writeFileAtomic(this.manifestPath(MANIFEST_FILE), `${JSON.stringify(manifest, null, 2)}\n`);
|
|
146
172
|
}
|
package/dist/lib/layout.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SectionConfig } from "./types.js";
|
|
1
|
+
import type { FontConfig, SectionConfig } from "./types.js";
|
|
2
2
|
interface PageData {
|
|
3
3
|
slug: string;
|
|
4
4
|
title: string;
|
|
@@ -10,22 +10,6 @@ interface PageData {
|
|
|
10
10
|
order: number;
|
|
11
11
|
section: string;
|
|
12
12
|
}
|
|
13
|
-
interface GoogleFontConfig {
|
|
14
|
-
fontName?: string;
|
|
15
|
-
subsets?: string[];
|
|
16
|
-
weight?: string | string[];
|
|
17
|
-
}
|
|
18
|
-
interface LocalFontSrc {
|
|
19
|
-
path: string;
|
|
20
|
-
weight: string;
|
|
21
|
-
style: string;
|
|
22
|
-
}
|
|
23
|
-
interface FontConfig {
|
|
24
|
-
googleFont?: GoogleFontConfig;
|
|
25
|
-
localFonts?: string | {
|
|
26
|
-
src?: LocalFontSrc[];
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
13
|
/**
|
|
30
14
|
* Root layout ("app/layout.tsx"). Minimal shell: html/body, fonts, the theme
|
|
31
15
|
* provider stack, and (optionally) PostHog. It renders `children` directly so
|
package/dist/lib/layout.js
CHANGED
|
@@ -21,7 +21,8 @@ function formatObjectArray(items) {
|
|
|
21
21
|
return "[\n" + formatted.join("\n") + "\n]";
|
|
22
22
|
}
|
|
23
23
|
function isGoogleFont(fc) {
|
|
24
|
-
return !!fc?.googleFont?.fontName
|
|
24
|
+
return (!!fc?.googleFont?.fontName &&
|
|
25
|
+
/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(fc.googleFont.fontName));
|
|
25
26
|
}
|
|
26
27
|
function isLocalFont(fc) {
|
|
27
28
|
if (!fc?.localFonts)
|
|
@@ -32,8 +33,8 @@ function isLocalFont(fc) {
|
|
|
32
33
|
}
|
|
33
34
|
function getLocalFontSrc(fc) {
|
|
34
35
|
if (typeof fc.localFonts === "string")
|
|
35
|
-
return
|
|
36
|
-
return JSON.stringify(fc.localFonts?.src, null, 2)
|
|
36
|
+
return JSON.stringify(fc.localFonts);
|
|
37
|
+
return JSON.stringify(fc.localFonts?.src, null, 2);
|
|
37
38
|
}
|
|
38
39
|
function fontImportLine(fontConfig) {
|
|
39
40
|
return isGoogleFont(fontConfig)
|
|
@@ -51,7 +52,7 @@ function fontDeclLine(fontConfig) {
|
|
|
51
52
|
fontConfig.googleFont.weight?.length
|
|
52
53
|
? `weight: ${Array.isArray(fontConfig.googleFont.weight)
|
|
53
54
|
? JSON.stringify(fontConfig.googleFont.weight)
|
|
54
|
-
:
|
|
55
|
+
: JSON.stringify(fontConfig.googleFont.weight)}`
|
|
55
56
|
: "",
|
|
56
57
|
]
|
|
57
58
|
.filter(Boolean)
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
function isRecord(value) {
|
|
2
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3
|
+
}
|
|
4
|
+
function nonEmptyString(value) {
|
|
5
|
+
return typeof value === "string" && value.trim().length > 0;
|
|
6
|
+
}
|
|
7
|
+
export function validateFontConfig(value) {
|
|
8
|
+
if (!isRecord(value)) {
|
|
9
|
+
throw new Error("fonts.json must contain a JSON object.");
|
|
10
|
+
}
|
|
11
|
+
const hasGoogleFont = value.googleFont !== undefined;
|
|
12
|
+
const hasLocalFonts = value.localFonts !== undefined;
|
|
13
|
+
if (hasGoogleFont === hasLocalFonts) {
|
|
14
|
+
throw new Error("fonts.json must define exactly one of googleFont or localFonts.");
|
|
15
|
+
}
|
|
16
|
+
if (hasGoogleFont) {
|
|
17
|
+
if (!isRecord(value.googleFont)) {
|
|
18
|
+
throw new Error("fonts.json googleFont must be an object.");
|
|
19
|
+
}
|
|
20
|
+
const fontName = value.googleFont.fontName;
|
|
21
|
+
if (!nonEmptyString(fontName) ||
|
|
22
|
+
!/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(fontName)) {
|
|
23
|
+
throw new Error("fonts.json googleFont.fontName must be a valid exported font identifier.");
|
|
24
|
+
}
|
|
25
|
+
const subsets = value.googleFont.subsets;
|
|
26
|
+
if (subsets !== undefined &&
|
|
27
|
+
(!Array.isArray(subsets) || !subsets.every(nonEmptyString))) {
|
|
28
|
+
throw new Error("fonts.json googleFont.subsets must be an array of non-empty strings.");
|
|
29
|
+
}
|
|
30
|
+
const weight = value.googleFont.weight;
|
|
31
|
+
if (weight !== undefined &&
|
|
32
|
+
!nonEmptyString(weight) &&
|
|
33
|
+
(!Array.isArray(weight) ||
|
|
34
|
+
weight.length === 0 ||
|
|
35
|
+
!weight.every(nonEmptyString))) {
|
|
36
|
+
throw new Error("fonts.json googleFont.weight must be a non-empty string or string array.");
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
googleFont: {
|
|
40
|
+
fontName,
|
|
41
|
+
...(subsets !== undefined ? { subsets: [...subsets] } : {}),
|
|
42
|
+
...(weight !== undefined
|
|
43
|
+
? { weight: Array.isArray(weight) ? [...weight] : weight }
|
|
44
|
+
: {}),
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
if (nonEmptyString(value.localFonts)) {
|
|
49
|
+
return { localFonts: value.localFonts };
|
|
50
|
+
}
|
|
51
|
+
if (!isRecord(value.localFonts) || !Array.isArray(value.localFonts.src)) {
|
|
52
|
+
throw new Error("fonts.json localFonts must be a non-empty path or an object with a src array.");
|
|
53
|
+
}
|
|
54
|
+
if (value.localFonts.src.length === 0) {
|
|
55
|
+
throw new Error("fonts.json localFonts.src must not be empty.");
|
|
56
|
+
}
|
|
57
|
+
const src = value.localFonts.src.map((entry, index) => {
|
|
58
|
+
if (!isRecord(entry) ||
|
|
59
|
+
!nonEmptyString(entry.path) ||
|
|
60
|
+
(entry.weight !== undefined && !nonEmptyString(entry.weight)) ||
|
|
61
|
+
(entry.style !== undefined && !nonEmptyString(entry.style))) {
|
|
62
|
+
throw new Error(`fonts.json localFonts.src entry ${index + 1} needs a string path and optional string weight/style values.`);
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
path: entry.path,
|
|
66
|
+
...(entry.weight !== undefined ? { weight: entry.weight } : {}),
|
|
67
|
+
...(entry.style !== undefined ? { style: entry.style } : {}),
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
return { localFonts: { src } };
|
|
71
|
+
}
|
|
72
|
+
export function validateAnalyticsConfig(value) {
|
|
73
|
+
if (!isRecord(value) || value.provider !== "posthog") {
|
|
74
|
+
throw new Error('analytics.json provider must be "posthog".');
|
|
75
|
+
}
|
|
76
|
+
if (!isRecord(value.posthog)) {
|
|
77
|
+
throw new Error("analytics.json posthog must be an object.");
|
|
78
|
+
}
|
|
79
|
+
const key = value.posthog.key;
|
|
80
|
+
if (!nonEmptyString(key) || !/^[A-Za-z0-9_-]+$/.test(key)) {
|
|
81
|
+
throw new Error("analytics.json posthog.key must contain only letters, numbers, underscores, and hyphens.");
|
|
82
|
+
}
|
|
83
|
+
const configuredHost = value.posthog.host;
|
|
84
|
+
let host;
|
|
85
|
+
if (configuredHost !== undefined) {
|
|
86
|
+
if (!nonEmptyString(configuredHost)) {
|
|
87
|
+
throw new Error("analytics.json posthog.host must be a non-empty URL.");
|
|
88
|
+
}
|
|
89
|
+
const trimmedHost = configuredHost.trim();
|
|
90
|
+
let parsed;
|
|
91
|
+
try {
|
|
92
|
+
parsed = new URL(trimmedHost);
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
throw new Error("analytics.json posthog.host must be a valid URL.");
|
|
96
|
+
}
|
|
97
|
+
if ((parsed.protocol !== "https:" && parsed.protocol !== "http:") ||
|
|
98
|
+
parsed.username ||
|
|
99
|
+
parsed.password ||
|
|
100
|
+
parsed.search ||
|
|
101
|
+
parsed.hash) {
|
|
102
|
+
throw new Error("analytics.json posthog.host must be an HTTP(S) URL without credentials, query, or fragment.");
|
|
103
|
+
}
|
|
104
|
+
host = trimmedHost.replace(/\/+$/, "");
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
provider: "posthog",
|
|
108
|
+
posthog: { key, ...(host ? { host } : {}) },
|
|
109
|
+
};
|
|
110
|
+
}
|
package/dist/lib/structures.js
CHANGED
|
@@ -58,6 +58,7 @@ import { sidePanelTemplate } from "../templates/components/layout/SidePanel.js";
|
|
|
58
58
|
import { notFoundComponentTemplate } from "../templates/components/layout/NotFound.js";
|
|
59
59
|
import { siteGateComponentTemplate } from "../templates/components/layout/SiteGate.js";
|
|
60
60
|
import { slugTemplate } from "../templates/components/layout/Slug.js";
|
|
61
|
+
import { spaceTemplate } from "../templates/components/layout/Space.js";
|
|
61
62
|
import { staticLinksTemplate } from "../templates/components/layout/StaticLinks.js";
|
|
62
63
|
import { stepsTemplate } from "../templates/components/layout/Steps.js";
|
|
63
64
|
import { tabsTemplate } from "../templates/components/layout/Tabs.js";
|
|
@@ -252,6 +253,7 @@ export const appStructure = {
|
|
|
252
253
|
"components/layout/NotFound.tsx": notFoundComponentTemplate,
|
|
253
254
|
"components/layout/SiteGate.tsx": siteGateComponentTemplate,
|
|
254
255
|
"components/layout/Slug.ts": slugTemplate,
|
|
256
|
+
"components/layout/Space.tsx": spaceTemplate,
|
|
255
257
|
"components/layout/StaticLinks.tsx": staticLinksTemplate,
|
|
256
258
|
"components/layout/Steps.tsx": stepsTemplate,
|
|
257
259
|
"components/layout/Tabs.tsx": tabsTemplate,
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -54,8 +54,21 @@ export interface NormalizedOpenApiSpec {
|
|
|
54
54
|
name: string;
|
|
55
55
|
file: string;
|
|
56
56
|
}
|
|
57
|
+
export interface GoogleFontConfig {
|
|
58
|
+
fontName: string;
|
|
59
|
+
subsets?: string[];
|
|
60
|
+
weight?: string | string[];
|
|
61
|
+
}
|
|
62
|
+
export interface LocalFontSource {
|
|
63
|
+
path: string;
|
|
64
|
+
weight?: string;
|
|
65
|
+
style?: string;
|
|
66
|
+
}
|
|
57
67
|
export interface FontConfig {
|
|
58
|
-
|
|
68
|
+
googleFont?: GoogleFontConfig;
|
|
69
|
+
localFonts?: string | {
|
|
70
|
+
src: LocalFontSource[];
|
|
71
|
+
};
|
|
59
72
|
}
|
|
60
73
|
export interface PostHogConfig {
|
|
61
74
|
key: string;
|
|
@@ -4,14 +4,6 @@ export declare class MDXToNextJSGenerator {
|
|
|
4
4
|
private watchDir;
|
|
5
5
|
private outputDir;
|
|
6
6
|
private rootDir;
|
|
7
|
-
private watcher;
|
|
8
|
-
private configWatcher;
|
|
9
|
-
private fontWatcher;
|
|
10
|
-
private publicWatcher;
|
|
11
|
-
private rootDirWatcher;
|
|
12
|
-
private analyticsWatcher;
|
|
13
|
-
private openApiWatcher;
|
|
14
|
-
private doccupineConfigWatcher;
|
|
15
7
|
private doccupineConfigFile;
|
|
16
8
|
private configFiles;
|
|
17
9
|
private fontConfigFile;
|
|
@@ -25,21 +17,17 @@ export declare class MDXToNextJSGenerator {
|
|
|
25
17
|
private apiBaseSlug;
|
|
26
18
|
private apiRegistry;
|
|
27
19
|
private artifacts;
|
|
28
|
-
|
|
29
|
-
private
|
|
30
|
-
|
|
31
|
-
private
|
|
20
|
+
private sourceFs;
|
|
21
|
+
private appScaffolder;
|
|
22
|
+
private apiReferenceGenerator;
|
|
23
|
+
private generatedRouteManager;
|
|
24
|
+
private projectConfigRepository;
|
|
25
|
+
private publicAssetManager;
|
|
26
|
+
private watchCoordinator;
|
|
32
27
|
constructor(watchDir: string, outputDir: string, openApiSpecs?: NormalizedOpenApiSpec[], rootDir?: string);
|
|
33
28
|
private outputPath;
|
|
34
|
-
private publicOutputFilePath;
|
|
35
|
-
private sourcePathError;
|
|
36
|
-
private realSourceRoot;
|
|
37
|
-
private readSafeSourceFile;
|
|
38
29
|
private readMdxSourceFile;
|
|
39
30
|
private ensureSafeStarterPath;
|
|
40
|
-
private copyRegularPublicFile;
|
|
41
|
-
private copyRootSourceFile;
|
|
42
|
-
private enqueueMutation;
|
|
43
31
|
init(): Promise<void>;
|
|
44
32
|
createNextJSStructure(): Promise<void>;
|
|
45
33
|
createStartingDocs(): Promise<void>;
|
|
@@ -71,7 +59,6 @@ export declare class MDXToNextJSGenerator {
|
|
|
71
59
|
handlePublicFileChange(filePath: string): Promise<void>;
|
|
72
60
|
handlePublicFileDelete(filePath: string): Promise<void>;
|
|
73
61
|
startWatching(): Promise<void>;
|
|
74
|
-
private setupPublicWatcher;
|
|
75
62
|
private parseMDXFile;
|
|
76
63
|
private buildRealPagesMeta;
|
|
77
64
|
private buildAllPagesMeta;
|
|
@@ -154,13 +141,8 @@ export declare class MDXToNextJSGenerator {
|
|
|
154
141
|
updateSectionIndex(sectionSlug: string, frontmatter: Record<string, any>, mdxContent: string, sourcePath?: string): Promise<void>;
|
|
155
142
|
updateRootLayout(pages?: PageMeta[]): Promise<void>;
|
|
156
143
|
loadSiteUrl(): Promise<string | null>;
|
|
157
|
-
private buildSitemapEntries;
|
|
158
144
|
updateSitemap(pages?: PageMeta[]): Promise<void>;
|
|
159
145
|
updateRobots(): Promise<void>;
|
|
160
|
-
private loadSiteMetadata;
|
|
161
|
-
private readPageWithBody;
|
|
162
|
-
private findSourcePublicAsset;
|
|
163
|
-
private writePublicAggregate;
|
|
164
146
|
updateLlmsFiles(pages?: PageMeta[]): Promise<void>;
|
|
165
147
|
stop(): Promise<void>;
|
|
166
148
|
}
|