doccupine 0.0.140 → 0.0.141
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 +14 -7
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +191 -0
- package/dist/index.d.ts +3 -7
- package/dist/index.js +5 -1894
- package/dist/lib/config-manager.d.ts +1 -0
- package/dist/lib/config-manager.js +63 -3
- package/dist/lib/generated-artifacts.d.ts +26 -0
- package/dist/lib/generated-artifacts.js +147 -0
- package/dist/lib/layout.js +30 -30
- package/dist/lib/metadata.js +58 -30
- package/dist/lib/openapi-types.d.ts +2 -2
- package/dist/lib/openapi.d.ts +6 -3
- package/dist/lib/openapi.js +330 -50
- package/dist/lib/output-safety.d.ts +15 -0
- package/dist/lib/output-safety.js +428 -0
- package/dist/lib/structures.js +11 -0
- package/dist/lib/utils.d.ts +10 -5
- package/dist/lib/utils.js +108 -5
- package/dist/mdx-to-nextjs-generator.d.ts +166 -0
- package/dist/mdx-to-nextjs-generator.js +2229 -0
- package/dist/templates/app/api/gate/route.d.ts +1 -1
- package/dist/templates/app/api/gate/route.js +18 -6
- package/dist/templates/app/api/mcp/route.d.ts +1 -1
- package/dist/templates/app/api/mcp/route.js +181 -111
- package/dist/templates/app/api/playground/route.d.ts +1 -1
- package/dist/templates/app/api/playground/route.js +45 -13
- package/dist/templates/app/api/rag/route.d.ts +1 -1
- package/dist/templates/app/api/rag/route.js +72 -20
- package/dist/templates/app/api/search/route.d.ts +1 -1
- package/dist/templates/app/api/search/route.js +5 -0
- package/dist/templates/app/robots.d.ts +1 -1
- package/dist/templates/app/robots.js +1 -26
- package/dist/templates/app/theme.d.ts +1 -1
- package/dist/templates/app/theme.js +31 -19
- package/dist/templates/components/Chat.d.ts +1 -1
- package/dist/templates/components/Chat.js +342 -34
- package/dist/templates/components/SearchDocs.d.ts +1 -1
- package/dist/templates/components/SearchDocs.js +63 -11
- package/dist/templates/components/SearchModalContent.d.ts +1 -1
- package/dist/templates/components/SearchModalContent.js +191 -49
- package/dist/templates/components/SideBar.d.ts +1 -1
- package/dist/templates/components/SideBar.js +8 -2
- package/dist/templates/components/layout/Accordion.d.ts +1 -1
- package/dist/templates/components/layout/Accordion.js +26 -3
- package/dist/templates/components/layout/Badge.d.ts +1 -1
- package/dist/templates/components/layout/Badge.js +1 -1
- package/dist/templates/components/layout/Button.d.ts +1 -1
- package/dist/templates/components/layout/Button.js +4 -4
- package/dist/templates/components/layout/Callout.d.ts +1 -1
- package/dist/templates/components/layout/Callout.js +6 -6
- package/dist/templates/components/layout/Card.d.ts +1 -1
- package/dist/templates/components/layout/Card.js +9 -4
- package/dist/templates/components/layout/CherryThemeProvider.d.ts +1 -1
- package/dist/templates/components/layout/CherryThemeProvider.js +63 -12
- package/dist/templates/components/layout/Code.d.ts +1 -1
- package/dist/templates/components/layout/Code.js +5 -5
- package/dist/templates/components/layout/CopyButton.d.ts +1 -1
- package/dist/templates/components/layout/CopyButton.js +1 -1
- package/dist/templates/components/layout/DemoTheme.d.ts +1 -1
- package/dist/templates/components/layout/DemoTheme.js +8 -28
- package/dist/templates/components/layout/DocsComponents.d.ts +1 -1
- package/dist/templates/components/layout/DocsComponents.js +57 -6
- package/dist/templates/components/layout/GlobalStyles.d.ts +1 -1
- package/dist/templates/components/layout/GlobalStyles.js +15 -9
- package/dist/templates/components/layout/Prompt.d.ts +1 -1
- package/dist/templates/components/layout/Prompt.js +4 -7
- package/dist/templates/components/layout/Steps.d.ts +1 -1
- package/dist/templates/components/layout/Steps.js +7 -1
- package/dist/templates/components/layout/Tabs.d.ts +1 -1
- package/dist/templates/components/layout/Tabs.js +108 -19
- package/dist/templates/env.example.d.ts +1 -1
- package/dist/templates/env.example.js +11 -0
- package/dist/templates/eslint.config.d.ts +1 -1
- package/dist/templates/eslint.config.js +20 -0
- package/dist/templates/gitignore.d.ts +1 -1
- package/dist/templates/gitignore.js +4 -3
- package/dist/templates/lib/access.d.ts +1 -0
- package/dist/templates/lib/access.js +41 -0
- package/dist/templates/mdx/ai-assistant.mdx.d.ts +1 -1
- package/dist/templates/mdx/ai-assistant.mdx.js +17 -1
- package/dist/templates/mdx/api-playground.mdx.d.ts +1 -1
- package/dist/templates/mdx/api-playground.mdx.js +5 -3
- package/dist/templates/mdx/authentication.mdx.d.ts +1 -1
- package/dist/templates/mdx/authentication.mdx.js +5 -3
- package/dist/templates/mdx/commands.mdx.d.ts +1 -1
- package/dist/templates/mdx/commands.mdx.js +20 -6
- package/dist/templates/mdx/components.mdx.d.ts +1 -1
- package/dist/templates/mdx/components.mdx.js +3 -0
- package/dist/templates/mdx/deployment-and-hosting.mdx.d.ts +1 -1
- package/dist/templates/mdx/deployment-and-hosting.mdx.js +2 -2
- package/dist/templates/mdx/globals.mdx.d.ts +1 -1
- package/dist/templates/mdx/globals.mdx.js +14 -11
- package/dist/templates/mdx/model-context-protocol.mdx.d.ts +1 -1
- package/dist/templates/mdx/model-context-protocol.mdx.js +22 -35
- package/dist/templates/mdx/platform/ai-assistant.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/ai-assistant.mdx.js +23 -0
- package/dist/templates/mdx/platform/api-playground.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/api-playground.mdx.js +7 -0
- package/dist/templates/mdx/platform/authentication.mdx.d.ts +1 -0
- package/dist/templates/mdx/platform/authentication.mdx.js +63 -0
- package/dist/templates/mdx/platform/import-from-github.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/import-from-github.mdx.js +2 -2
- package/dist/templates/mdx/platform/index.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/index.mdx.js +1 -0
- package/dist/templates/mdx/platform/mcp.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/mcp.mdx.js +2 -1
- package/dist/templates/mdx/platform/navigation-settings.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/navigation-settings.mdx.js +12 -1
- package/dist/templates/mdx/platform/publishing.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/publishing.mdx.js +43 -10
- package/dist/templates/mdx/platform/self-updating-docs.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/self-updating-docs.mdx.js +48 -9
- package/dist/templates/mdx/sections.mdx.d.ts +1 -1
- package/dist/templates/mdx/sections.mdx.js +4 -0
- package/dist/templates/mdx/space.mdx.d.ts +1 -0
- package/dist/templates/mdx/space.mdx.js +125 -0
- package/dist/templates/mdx/tabs.mdx.d.ts +1 -1
- package/dist/templates/mdx/tabs.mdx.js +4 -0
- package/dist/templates/next.config.js +20 -8
- package/dist/templates/package.js +3 -3
- package/dist/templates/prettierignore.d.ts +1 -1
- package/dist/templates/prettierignore.js +1 -0
- package/dist/templates/proxy.js +47 -19
- package/dist/templates/scripts/build-docs-index.d.ts +1 -1
- package/dist/templates/scripts/build-docs-index.js +1 -0
- package/dist/templates/services/mcp/docsContentStub.d.ts +1 -0
- package/dist/templates/services/mcp/docsContentStub.js +1 -0
- package/dist/templates/services/mcp/server.d.ts +1 -1
- package/dist/templates/services/mcp/server.js +140 -83
- package/dist/templates/services/mcp/tools.d.ts +1 -1
- package/dist/templates/services/mcp/tools.js +65 -137
- package/dist/templates/utils/playgroundAllowlist.d.ts +1 -1
- package/dist/templates/utils/playgroundAllowlist.js +13 -4
- package/dist/templates/utils/rateLimit.d.ts +1 -1
- package/dist/templates/utils/rateLimit.js +40 -3
- package/dist/templates/utils/requestBody.d.ts +1 -0
- package/dist/templates/utils/requestBody.js +56 -0
- package/dist/templates/utils/ssrfGuard.d.ts +1 -1
- package/dist/templates/utils/ssrfGuard.js +138 -33
- package/package.json +14 -9
- package/dist/lib/mdxToMarkdown.d.ts +0 -1
- package/dist/lib/mdxToMarkdown.js +0 -134
- package/dist/templates/mdx/image-and-embeds.mdx.d.ts +0 -1
- package/dist/templates/mdx/image-and-embeds.mdx.js +0 -118
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import type { MDXFile, PageMeta, SectionConfig, FontConfig, AnalyticsConfig, NormalizedOpenApiSpec } from "./lib/types.js";
|
|
2
|
+
import type { OperationDescriptor } from "./lib/openapi-types.js";
|
|
3
|
+
export declare class MDXToNextJSGenerator {
|
|
4
|
+
private watchDir;
|
|
5
|
+
private outputDir;
|
|
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
|
+
private doccupineConfigFile;
|
|
16
|
+
private configFiles;
|
|
17
|
+
private fontConfigFile;
|
|
18
|
+
private analyticsConfigFile;
|
|
19
|
+
private analyticsConfig;
|
|
20
|
+
private sectionsConfig;
|
|
21
|
+
/** Guards against recursive reprocessing when maybeUpdateSections() triggers processAllMDXFiles() */
|
|
22
|
+
private isReprocessing;
|
|
23
|
+
/** OpenAPI specs (build config) that drive the generated API reference. */
|
|
24
|
+
private openApiSpecs;
|
|
25
|
+
private apiBaseSlug;
|
|
26
|
+
private apiRegistry;
|
|
27
|
+
private artifacts;
|
|
28
|
+
/** Section slugs whose index redirect we wrote this session, for cleanup. */
|
|
29
|
+
private generatedSectionIndexSlugs;
|
|
30
|
+
/** Serializes watcher mutations so aggregate files never race one another. */
|
|
31
|
+
private mutationQueue;
|
|
32
|
+
constructor(watchDir: string, outputDir: string, openApiSpecs?: NormalizedOpenApiSpec[], rootDir?: string);
|
|
33
|
+
private outputPath;
|
|
34
|
+
private publicOutputFilePath;
|
|
35
|
+
private sourcePathError;
|
|
36
|
+
private realSourceRoot;
|
|
37
|
+
private readSafeSourceFile;
|
|
38
|
+
private readMdxSourceFile;
|
|
39
|
+
private ensureSafeStarterPath;
|
|
40
|
+
private copyRegularPublicFile;
|
|
41
|
+
private copyRootSourceFile;
|
|
42
|
+
private enqueueMutation;
|
|
43
|
+
init(): Promise<void>;
|
|
44
|
+
createNextJSStructure(): Promise<void>;
|
|
45
|
+
createStartingDocs(): Promise<void>;
|
|
46
|
+
copyCustomConfigFiles(): Promise<void>;
|
|
47
|
+
copyFontConfig(): Promise<void>;
|
|
48
|
+
loadFontConfig(): Promise<FontConfig | null>;
|
|
49
|
+
loadAnalyticsConfig(): Promise<AnalyticsConfig | null>;
|
|
50
|
+
copyAnalyticsConfig(): Promise<void>;
|
|
51
|
+
loadSectionsConfig(): Promise<SectionConfig[] | null>;
|
|
52
|
+
discoverSectionsFromFrontmatter(): Promise<SectionConfig[] | null>;
|
|
53
|
+
resolveSections(): Promise<SectionConfig[] | null>;
|
|
54
|
+
/**
|
|
55
|
+
* Promotes the generated OpenAPI endpoints into a dedicated "API Reference"
|
|
56
|
+
* section so they get their own top-level nav, separate from hand-written
|
|
57
|
+
* docs. When the site had no sections, a root "Documentation" section is added
|
|
58
|
+
* for the existing pages so both appear in the section switcher.
|
|
59
|
+
*/
|
|
60
|
+
private withApiReferenceSection;
|
|
61
|
+
private reloadSections;
|
|
62
|
+
private maybeUpdateSections;
|
|
63
|
+
private determineSectionForFile;
|
|
64
|
+
handleConfigFileChange(filePath: string): Promise<void>;
|
|
65
|
+
handleConfigFileDelete(filePath: string): Promise<void>;
|
|
66
|
+
handleFontConfigChange(): Promise<void>;
|
|
67
|
+
handleFontConfigDelete(): Promise<void>;
|
|
68
|
+
handleAnalyticsConfigChange(): Promise<void>;
|
|
69
|
+
handleAnalyticsConfigDelete(): Promise<void>;
|
|
70
|
+
copyPublicFiles(): Promise<void>;
|
|
71
|
+
handlePublicFileChange(filePath: string): Promise<void>;
|
|
72
|
+
handlePublicFileDelete(filePath: string): Promise<void>;
|
|
73
|
+
startWatching(): Promise<void>;
|
|
74
|
+
private setupPublicWatcher;
|
|
75
|
+
private parseMDXFile;
|
|
76
|
+
private buildRealPagesMeta;
|
|
77
|
+
private buildAllPagesMeta;
|
|
78
|
+
private removeOwnedRoute;
|
|
79
|
+
private removeStaleMdxRoutes;
|
|
80
|
+
/**
|
|
81
|
+
* Writes the generated page(s) for a single MDX file: the doc page and, for a
|
|
82
|
+
* section-index file, the section landing page. Deliberately does NOT run the
|
|
83
|
+
* site-wide aggregations (pages index, layout, sitemap, llms, section
|
|
84
|
+
* redirects) - the caller batches those so a bulk build runs them once at the
|
|
85
|
+
* end instead of once per file (which is what made large builds O(n²)).
|
|
86
|
+
*/
|
|
87
|
+
private writePageForFile;
|
|
88
|
+
/**
|
|
89
|
+
* Regenerates every file that depends on the full set of pages (pages index,
|
|
90
|
+
* root/site layout, sitemap, llms files, section redirects). Parses all MDX
|
|
91
|
+
* exactly once and threads the result through each generator, so one refresh
|
|
92
|
+
* is a single scan rather than one scan per generator.
|
|
93
|
+
*/
|
|
94
|
+
private refreshSiteAggregates;
|
|
95
|
+
handleFileChange(action: string, filePath: string): Promise<void>;
|
|
96
|
+
handleFileDelete(filePath: string): Promise<void>;
|
|
97
|
+
processAllMDXFiles(): Promise<void>;
|
|
98
|
+
getAllMDXFiles(): Promise<string[]>;
|
|
99
|
+
generateRootLayout(): Promise<string>;
|
|
100
|
+
generateSiteLayout(pages?: PageMeta[]): Promise<string>;
|
|
101
|
+
generateSectionIndexPages(pages?: PageMeta[]): Promise<void>;
|
|
102
|
+
/**
|
|
103
|
+
* Removes section index redirects written earlier in this session whose
|
|
104
|
+
* section has since disappeared (e.g. the API Reference section after the
|
|
105
|
+
* `openapi` config is removed mid-watch). Only files that still contain the
|
|
106
|
+
* generated redirect are deleted, so a hand-written page that has taken
|
|
107
|
+
* over the slug is never touched. Fresh processes start clean anyway -
|
|
108
|
+
* init() wipes app/ - so in-session tracking is enough.
|
|
109
|
+
*/
|
|
110
|
+
private cleanupStaleSectionIndexPages;
|
|
111
|
+
/** Best-effort removal of now-empty directories up to (not incl.) stopDir. */
|
|
112
|
+
private removeEmptyDirsUpTo;
|
|
113
|
+
generatePageFromMDX(mdxFile: MDXFile, options?: {
|
|
114
|
+
apiOperation?: OperationDescriptor;
|
|
115
|
+
}): Promise<void>;
|
|
116
|
+
/** Parses the configured OpenAPI spec(s) into the shared registry. */
|
|
117
|
+
private loadOpenApiRegistry;
|
|
118
|
+
/**
|
|
119
|
+
* Generates one page per OpenAPI operation, (re)writes the request-execution
|
|
120
|
+
* allowlist consumed by the playground proxy + component, and removes endpoint
|
|
121
|
+
* pages that no longer exist in the spec. Safe to call when there are no specs
|
|
122
|
+
* - it still emits an empty allowlist and prunes any previously generated
|
|
123
|
+
* pages (e.g. after the `openapi` config is removed).
|
|
124
|
+
*/
|
|
125
|
+
private writeApiPages;
|
|
126
|
+
/** Writes the request-execution allowlist (overwrites the shipped stub). */
|
|
127
|
+
private writeApiAllowlist;
|
|
128
|
+
/** Removes endpoint page directories that are no longer in the spec. */
|
|
129
|
+
private cleanupStaleApiPages;
|
|
130
|
+
/**
|
|
131
|
+
* (Re)points the spec-file watcher at the currently configured spec paths.
|
|
132
|
+
* Called at startup and whenever doccupine.json changes the `openapi` set,
|
|
133
|
+
* so specs added mid-session are watched without a restart.
|
|
134
|
+
*/
|
|
135
|
+
private syncOpenApiSpecWatcher;
|
|
136
|
+
/**
|
|
137
|
+
* Reparses the spec(s) and rewrites everything derived from them: the
|
|
138
|
+
* endpoint pages and allowlist, the sections (the "API Reference" section
|
|
139
|
+
* appears and disappears with the registry), and the site aggregates.
|
|
140
|
+
*/
|
|
141
|
+
private rebuildApiReference;
|
|
142
|
+
/** Reparses the spec(s) and regenerates the API reference on a watch event. */
|
|
143
|
+
handleOpenApiChange(): Promise<void>;
|
|
144
|
+
/**
|
|
145
|
+
* Applies `openapi` edits in doccupine.json without a restart: reloads the
|
|
146
|
+
* registry, regenerates or prunes the endpoint pages and allowlist,
|
|
147
|
+
* refreshes nav/sitemap/llms, and re-points the spec-file watcher. Other
|
|
148
|
+
* fields (watchDir, outputDir, port) cannot be hot-applied, so a change
|
|
149
|
+
* there only logs a restart hint. Invalid or missing JSON (e.g. a
|
|
150
|
+
* half-written editor save) keeps the current configuration.
|
|
151
|
+
*/
|
|
152
|
+
handleDoccupineConfigChange(): Promise<void>;
|
|
153
|
+
updatePagesIndex(): Promise<void>;
|
|
154
|
+
updateSectionIndex(sectionSlug: string, frontmatter: Record<string, any>, mdxContent: string, sourcePath?: string): Promise<void>;
|
|
155
|
+
updateRootLayout(pages?: PageMeta[]): Promise<void>;
|
|
156
|
+
loadSiteUrl(): Promise<string | null>;
|
|
157
|
+
private buildSitemapEntries;
|
|
158
|
+
updateSitemap(pages?: PageMeta[]): Promise<void>;
|
|
159
|
+
updateRobots(): Promise<void>;
|
|
160
|
+
private loadSiteMetadata;
|
|
161
|
+
private readPageWithBody;
|
|
162
|
+
private findSourcePublicAsset;
|
|
163
|
+
private writePublicAggregate;
|
|
164
|
+
updateLlmsFiles(pages?: PageMeta[]): Promise<void>;
|
|
165
|
+
stop(): Promise<void>;
|
|
166
|
+
}
|