doccupine 0.0.133 → 0.0.134
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 +40 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +274 -19
- package/dist/lib/config-manager.d.ts +8 -1
- package/dist/lib/config-manager.js +98 -4
- package/dist/lib/openapi-types.d.ts +120 -0
- package/dist/lib/openapi-types.js +14 -0
- package/dist/lib/openapi.d.ts +52 -0
- package/dist/lib/openapi.js +603 -0
- package/dist/lib/structures.js +28 -2
- package/dist/lib/types.d.ts +22 -0
- package/dist/lib/utils.d.ts +8 -0
- package/dist/lib/utils.js +14 -0
- package/dist/templates/app/api/playground/route.d.ts +1 -0
- package/dist/templates/app/api/playground/route.js +199 -0
- package/dist/templates/components/Docs.d.ts +1 -1
- package/dist/templates/components/Docs.js +11 -2
- package/dist/templates/components/SideBar.d.ts +1 -1
- package/dist/templates/components/SideBar.js +10 -0
- package/dist/templates/components/layout/Accordion.d.ts +1 -1
- package/dist/templates/components/layout/Accordion.js +3 -2
- package/dist/templates/components/layout/ActionBar.d.ts +1 -1
- package/dist/templates/components/layout/ActionBar.js +21 -14
- package/dist/templates/components/layout/ApiPlayground.d.ts +1 -0
- package/dist/templates/components/layout/ApiPlayground.js +1083 -0
- package/dist/templates/components/layout/ApiPlaygroundDemo.d.ts +1 -0
- package/dist/templates/components/layout/ApiPlaygroundDemo.js +81 -0
- package/dist/templates/components/layout/Code.d.ts +1 -1
- package/dist/templates/components/layout/Code.js +10 -22
- package/dist/templates/components/layout/CopyButton.d.ts +1 -0
- package/dist/templates/components/layout/CopyButton.js +68 -0
- package/dist/templates/components/layout/DocsComponents.d.ts +1 -1
- package/dist/templates/components/layout/DocsComponents.js +39 -0
- package/dist/templates/components/layout/Mermaid.d.ts +1 -1
- package/dist/templates/components/layout/Mermaid.js +21 -3
- package/dist/templates/components/layout/SharedStyles.d.ts +1 -1
- package/dist/templates/components/layout/SharedStyles.js +0 -4
- package/dist/templates/components/layout/Steps.d.ts +1 -1
- package/dist/templates/components/layout/Steps.js +0 -1
- package/dist/templates/components/layout/Update.d.ts +1 -1
- package/dist/templates/components/layout/Update.js +2 -1
- package/dist/templates/mdx/accordion.mdx.d.ts +1 -1
- package/dist/templates/mdx/accordion.mdx.js +19 -1
- package/dist/templates/mdx/ai-assistant.mdx.d.ts +1 -1
- package/dist/templates/mdx/ai-assistant.mdx.js +3 -2
- package/dist/templates/mdx/analytics.mdx.d.ts +1 -1
- package/dist/templates/mdx/analytics.mdx.js +2 -2
- package/dist/templates/mdx/api-playground.mdx.d.ts +1 -0
- package/dist/templates/mdx/api-playground.mdx.js +158 -0
- package/dist/templates/mdx/authentication.mdx.d.ts +1 -1
- package/dist/templates/mdx/authentication.mdx.js +3 -3
- package/dist/templates/mdx/buttons.mdx.d.ts +1 -1
- package/dist/templates/mdx/buttons.mdx.js +1 -1
- package/dist/templates/mdx/callouts.mdx.d.ts +1 -1
- package/dist/templates/mdx/callouts.mdx.js +1 -1
- package/dist/templates/mdx/cards.mdx.d.ts +1 -1
- package/dist/templates/mdx/cards.mdx.js +1 -1
- package/dist/templates/mdx/color-swatches.mdx.d.ts +1 -1
- package/dist/templates/mdx/color-swatches.mdx.js +1 -1
- package/dist/templates/mdx/commands.mdx.d.ts +1 -1
- package/dist/templates/mdx/commands.mdx.js +3 -2
- package/dist/templates/mdx/components.mdx.d.ts +1 -1
- package/dist/templates/mdx/components.mdx.js +12 -9
- package/dist/templates/mdx/deployment-and-hosting.mdx.d.ts +1 -1
- package/dist/templates/mdx/deployment-and-hosting.mdx.js +4 -3
- package/dist/templates/mdx/fields.mdx.d.ts +1 -1
- package/dist/templates/mdx/fields.mdx.js +1 -1
- package/dist/templates/mdx/fonts.mdx.d.ts +1 -1
- package/dist/templates/mdx/fonts.mdx.js +2 -2
- package/dist/templates/mdx/footer-links.mdx.d.ts +1 -1
- package/dist/templates/mdx/footer-links.mdx.js +1 -1
- package/dist/templates/mdx/frames.mdx.d.ts +1 -1
- package/dist/templates/mdx/frames.mdx.js +1 -1
- package/dist/templates/mdx/globals.mdx.d.ts +1 -1
- package/dist/templates/mdx/globals.mdx.js +1 -1
- package/dist/templates/mdx/icons.mdx.d.ts +1 -1
- package/dist/templates/mdx/icons.mdx.js +1 -1
- package/dist/templates/mdx/image-and-embeds.mdx.d.ts +1 -1
- package/dist/templates/mdx/image-and-embeds.mdx.js +1 -1
- package/dist/templates/mdx/media-and-assets.mdx.d.ts +1 -1
- package/dist/templates/mdx/media-and-assets.mdx.js +2 -2
- package/dist/templates/mdx/mermaid.mdx.d.ts +1 -1
- package/dist/templates/mdx/mermaid.mdx.js +1 -1
- package/dist/templates/mdx/model-context-protocol.mdx.d.ts +1 -1
- package/dist/templates/mdx/model-context-protocol.mdx.js +2 -2
- package/dist/templates/mdx/navigation.mdx.d.ts +1 -1
- package/dist/templates/mdx/navigation.mdx.js +22 -11
- package/dist/templates/mdx/platform/ai-assistant.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/ai-assistant.mdx.js +4 -3
- package/dist/templates/mdx/platform/analytics.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/analytics.mdx.js +2 -2
- package/dist/templates/mdx/platform/api-playground.mdx.d.ts +1 -0
- package/dist/templates/mdx/platform/api-playground.mdx.js +62 -0
- package/dist/templates/mdx/platform/billing.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/billing.mdx.js +1 -1
- package/dist/templates/mdx/platform/build-and-deploy.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/build-and-deploy.mdx.js +1 -1
- package/dist/templates/mdx/platform/creating-a-project.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/creating-a-project.mdx.js +12 -2
- package/dist/templates/mdx/platform/custom-domains.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/custom-domains.mdx.js +1 -1
- package/dist/templates/mdx/platform/fonts-settings.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/fonts-settings.mdx.js +1 -1
- package/dist/templates/mdx/platform/footer-links.mdx.d.ts +1 -0
- package/dist/templates/mdx/platform/footer-links.mdx.js +47 -0
- package/dist/templates/mdx/platform/import-from-github.mdx.d.ts +1 -0
- package/dist/templates/mdx/platform/import-from-github.mdx.js +91 -0
- package/dist/templates/mdx/platform/mcp.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/mcp.mdx.js +3 -3
- package/dist/templates/mdx/platform/project-settings.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/project-settings.mdx.js +1 -1
- package/dist/templates/mdx/platform/self-updating-docs.mdx.d.ts +1 -0
- package/dist/templates/mdx/platform/self-updating-docs.mdx.js +113 -0
- package/dist/templates/mdx/platform/team-members.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/team-members.mdx.js +1 -1
- package/dist/templates/mdx/sections.mdx.d.ts +1 -1
- package/dist/templates/mdx/sections.mdx.js +1 -1
- package/dist/templates/mdx/steps.mdx.d.ts +1 -1
- package/dist/templates/mdx/steps.mdx.js +1 -1
- package/dist/templates/mdx/tabs.mdx.d.ts +1 -1
- package/dist/templates/mdx/tabs.mdx.js +1 -1
- package/dist/templates/mdx/theme.mdx.d.ts +1 -1
- package/dist/templates/mdx/theme.mdx.js +1 -1
- package/dist/templates/mdx/update.mdx.d.ts +1 -1
- package/dist/templates/mdx/update.mdx.js +1 -1
- package/dist/templates/mdx/what-is-doccupine.mdx.d.ts +1 -1
- package/dist/templates/mdx/what-is-doccupine.mdx.js +1 -1
- package/dist/templates/package.js +6 -6
- package/dist/templates/services/openapi/playgroundAllowlistStub.d.ts +1 -0
- package/dist/templates/services/openapi/playgroundAllowlistStub.js +4 -0
- package/dist/templates/types/openapi.d.ts +1 -0
- package/dist/templates/types/openapi.js +93 -0
- package/dist/templates/utils/apiAnchors.d.ts +1 -0
- package/dist/templates/utils/apiAnchors.js +39 -0
- package/dist/templates/utils/apiSnippets.d.ts +1 -0
- package/dist/templates/utils/apiSnippets.js +94 -0
- package/dist/templates/utils/orderNavItems.d.ts +1 -1
- package/dist/templates/utils/orderNavItems.js +3 -0
- package/dist/templates/utils/playgroundAllowlist.d.ts +1 -0
- package/dist/templates/utils/playgroundAllowlist.js +70 -0
- package/dist/templates/utils/ssrfGuard.d.ts +1 -0
- package/dist/templates/utils/ssrfGuard.js +217 -0
- package/package.json +3 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const stepsMdxTemplate = "---\ntitle: \"Steps\"\ndescription: \"Guide readers step-by-step using the Steps component.\"\ndate: \"2026-02-19\"\ncategory: \"Components\"\ncategoryOrder: 1\norder:
|
|
1
|
+
export declare const stepsMdxTemplate = "---\ntitle: \"Steps\"\ndescription: \"Guide readers step-by-step using the Steps component.\"\ndate: \"2026-02-19\"\ncategory: \"Components\"\ncategoryOrder: 1\norder: 7\n---\n# Steps\n\nGuide readers step-by-step using the Steps component.\n\nThe Steps component is perfect for organizing procedures or workflows in a clear sequence. Include as many individual steps as necessary to outline your process.\n\n## Steps Usage\n\nYou can use the `Steps` component to create a step-by-step guide. Each step is represented by a `Step` component, which includes a title and content.\n\n```html\n<Steps>\n <Step title=\"Step 1\">\n Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n </Step>\n <Step title=\"Step 2\">\n Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n </Step>\n <Step title=\"Step 3\">\n Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n </Step>\n</Steps>\n```\n\n<Steps>\n <Step title=\"Step 1\">\n Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n </Step>\n <Step title=\"Step 2\">\n Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n </Step>\n <Step title=\"Step 3\">\n Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n </Step>\n</Steps>\n\n## Properties\n\n<Field value=\"title\" type=\"string\">\n An optional title for the step. When omitted, the step renders without a title row.\n</Field>\n\n<Field value=\"icon\" type=\"string\">\n A [Lucide](https://lucide.dev/icons) icon name shown next to the step title.\n</Field>\n\n<Field value=\"children\" type=\"node\" required>\n The content of the step.\n</Field>";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const tabsMdxTemplate = "---\ntitle: \"Tabs\"\ndescription: \"Use the Tabs component to display different content sections in a switchable panel layout.\"\ndate: \"2026-02-19\"\ncategory: \"Components\"\ncategoryOrder: 1\norder:
|
|
1
|
+
export declare const tabsMdxTemplate = "---\ntitle: \"Tabs\"\ndescription: \"Use the Tabs component to display different content sections in a switchable panel layout.\"\ndate: \"2026-02-19\"\ncategory: \"Components\"\ncategoryOrder: 1\norder: 6\n---\n# Tabs\n\nUse the Tabs component to display different content sections in a switchable panel layout.\n\nTabs are useful for grouping related information while keeping the interface tidy. You can create as many tabs as needed, and each one can hold other components, text, or code snippets.\n\n## Tabs Usage\n\nYou can use the Tabs component directly within your MDX files without any import. The following example shows a basic usage:\n\n````html\n<Tabs>\n <TabContent title=\"First tab\" icon=\"code\">\n \u261D\uFE0F This is the content shown only when the first tab is active.\n\n Tabs can include all kinds of components. For example, a simple Java program:\n ```java\n class HelloWorld {\n public static void main(String[] args) {\n System.out.println(\"Hello, World!\");\n }\n }\n ```\n </TabContent>\n <TabContent title=\"Second tab\" icon=\"book-open\">\n \u270C\uFE0F Content inside this second tab is separate from the first.\n </TabContent>\n <TabContent title=\"Third tab\" icon=\"rocket\">\n \uD83D\uDCAA This third tab contains its own unique content.\n </TabContent>\n</Tabs>\n````\n\n<Tabs>\n <TabContent title=\"First tab\" icon=\"code\">\n \u261D\uFE0F This is the content shown only when the first tab is active.\n\n Tabs can include all kinds of components. For example, a simple Java program:\n ```java\n class HelloWorld {\n public static void main(String[] args) {\n System.out.println(\"Hello, World!\");\n }\n }\n ```\n </TabContent>\n <TabContent title=\"Second tab\" icon=\"book-open\">\n \u270C\uFE0F Content inside this second tab is separate from the first.\n </TabContent>\n <TabContent title=\"Third tab\" icon=\"rocket\">\n \uD83D\uDCAA This third tab contains its own unique content.\n </TabContent>\n</Tabs>\n\nEach tab also accepts an optional `icon` - any [Lucide](https://lucide.dev/icons) icon name - rendered before its title, as shown above.\n\n## Properties\n\n<Field value=\"title\" type=\"string\">\n The title of the tab.\n</Field>\n\n<Field value=\"icon\" type=\"string\">\n Optional [Lucide](https://lucide.dev/icons) icon name (kebab-case, e.g.\n `rocket`) shown next to the tab title.\n</Field>\n\n<Field value=\"children\" type=\"node\" required>\n The content of the tabs.\n</Field>";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const themeMdxTemplate = "---\ntitle: \"Theme\"\ndescription: \"Customize the documentation UI colors with a theme.json file.\"\ndate: \"2026-02-19\"\ncategory: \"Configuration\"\ncategoryOrder:
|
|
1
|
+
export declare const themeMdxTemplate = "---\ntitle: \"Theme\"\ndescription: \"Customize the documentation UI colors with a theme.json file.\"\ndate: \"2026-02-19\"\ncategory: \"Configuration\"\ncategoryOrder: 2\norder: 5\n---\n# Theme\n\nDefine your site\u2019s color system with a `theme.json` file. This lets you tailor the look and feel of your documentation without changing content.\n\n## theme.json\n\nPlace a `theme.json` at your project root (the same directory where you execute `npx doccupine`). It supports multiple modes. Define a `default` mode and a `dark` mode.\n\n```json\n{\n \"default\": {\n \"primaryLight\": \"#93c5fd\",\n \"primary\": \"#2563eb\",\n \"primaryDark\": \"#1e40af\",\n \"secondaryLight\": \"#c4b5fd\",\n \"secondary\": \"#8b5cf6\",\n \"secondaryDark\": \"#5b21b6\",\n \"tertiaryLight\": \"#fbbf24\",\n \"tertiary\": \"#f59e0b\",\n \"tertiaryDark\": \"#d97706\",\n \"grayLight\": \"#f3f4f6\",\n \"gray\": \"#9ca3af\",\n \"grayDark\": \"#374151\",\n \"success\": \"#10b981\",\n \"error\": \"#f43f5e\",\n \"warning\": \"#f59e0b\",\n \"info\": \"#3b82f6\",\n \"dark\": \"#000000\",\n \"light\": \"#ffffff\"\n },\n \"dark\": {\n \"primaryLight\": \"#9bcaff\",\n \"primary\": \"#1e7ae0\",\n \"primaryDark\": \"#033d7e\",\n \"secondaryLight\": \"#ddd6fe\",\n \"secondary\": \"#a78bfa\",\n \"secondaryDark\": \"#7c3aed\",\n \"tertiaryLight\": \"#fed7aa\",\n \"tertiary\": \"#fb923c\",\n \"tertiaryDark\": \"#ea580c\",\n \"grayLight\": \"#1f2937\",\n \"gray\": \"#6b7280\",\n \"grayDark\": \"#9ca3af\",\n \"success\": \"#10b981\",\n \"error\": \"#f43f5e\",\n \"warning\": \"#f59e0b\",\n \"info\": \"#3b82f6\",\n \"dark\": \"#ffffff\",\n \"light\": \"#000000\"\n },\n \"logo\": {\n \"dark\": \"https://docs.doccupine.com/logo-dark.svg\",\n \"light\": \"https://docs.doccupine.com/logo-light.svg\"\n }\n}\n```\n\n## Modes\n\n- **default**: The base color palette for your site.\n- **dark**: Dark\u2011mode palette.\n\n## Fields\n\n- **primaryLight**: A lighter variant of your brand color, used for subtle accents and backgrounds.\n- **primary**: The main brand color.\n- **primaryDark**: A darker variant of your brand color for emphasis and hover states.\n- **secondaryLight**: A lighter variant of your secondary color, used for subtle accents and backgrounds.\n- **secondary**: The secondary brand color used for highlights and UI accents.\n- **secondaryDark**: A darker variant of your secondary color for emphasis and hover states.\n- **tertiaryLight**: A lighter variant of your tertiary color, used for subtle accents and backgrounds.\n- **tertiary**: The tertiary accent color.\n- **tertiaryDark**: A darker variant of your tertiary color for emphasis and hover states.\n- **grayLight**: Light gray for surfaces and borders.\n- **gray**: Neutral gray for text and UI elements.\n- **grayDark**: Dark gray for headings or high\u2011contrast text.\n- **success**: Positive/confirmation color.\n- **error**: Error/destructive color.\n- **warning**: Warning/attention color.\n- **info**: Informational/highlight color.\n- **dark**: The darkest/base color (often page background in dark mode).\n- **light**: The lightest/base color (often page background in light mode).\n- **logo.light**: Path or URL to the logo used on light backgrounds. Recommended size: 164\u00D730 px.\n- **logo.dark**: Path or URL to the logo used on dark backgrounds. Recommended size: 164\u00D730 px.\n\n## Behavior\n\n- **Placement**: Put `theme.json` in the project root alongside `config.json`.\n- **Partial palettes**: If a key is missing in a mode, consumers may fall back to the `default` value.\n- **Logo size**: Recommended dimensions are 164px width and 30px height.\n\n<Callout type=\"warning\">\n Use valid hex colors (e.g., `#22c55e`). Invalid color values may cause unexpected rendering.\n</Callout>\n\n## Tips\n\n- **Contrast**: Ensure sufficient contrast between text and backgrounds for readability.\n- **Branding**: Start with your brand\u2019s `primary` color, then derive `primaryLight` and `primaryDark`.\n- **Iterate**: Adjust colors and refresh the site to preview changes quickly.\n\n# Demo\n\nIn the following demos, you can see how the theme can be changed. To override the theme, create a `theme.json` file in the project root and copy paste the code below.\n\n<DemoTheme variant=\"purple\" />\n<DemoTheme variant=\"green\" />\n<DemoTheme variant=\"yellow\" />\n<DemoTheme />\n\n## Purple\n\n```json\n{\n \"default\": {\n \"primaryLight\": \"#c4b5fd\",\n \"primary\": \"#8b5cf6\",\n \"primaryDark\": \"#5b21b6\",\n \"secondaryLight\": \"#86efac\",\n \"secondary\": \"#22c55e\",\n \"secondaryDark\": \"#15803d\",\n \"tertiaryLight\": \"#fbbf24\",\n \"tertiary\": \"#f59e0b\",\n \"tertiaryDark\": \"#d97706\",\n \"grayLight\": \"#f3f4f6\",\n \"gray\": \"#9ca3af\",\n \"grayDark\": \"#374151\",\n \"success\": \"#10b981\",\n \"error\": \"#f43f5e\",\n \"warning\": \"#f59e0b\",\n \"info\": \"#3b82f6\",\n \"dark\": \"#000000\",\n \"light\": \"#ffffff\"\n },\n \"dark\": {\n \"primaryLight\": \"#ddd6fe\",\n \"primary\": \"#a78bfa\",\n \"primaryDark\": \"#7c3aed\",\n \"secondaryLight\": \"#6ee7b7\",\n \"secondary\": \"#10b981\",\n \"secondaryDark\": \"#065f46\",\n \"tertiaryLight\": \"#fed7aa\",\n \"tertiary\": \"#fb923c\",\n \"tertiaryDark\": \"#ea580c\",\n \"grayLight\": \"#1f2937\",\n \"gray\": \"#6b7280\",\n \"grayDark\": \"#9ca3af\",\n \"success\": \"#10b981\",\n \"error\": \"#f43f5e\",\n \"warning\": \"#f59e0b\",\n \"info\": \"#3b82f6\",\n \"dark\": \"#ffffff\",\n \"light\": \"#000000\"\n }\n}\n```\n\n<DemoTheme variant=\"purple\" />\n\n## Green\n\n```json\n{\n \"default\": {\n \"primaryLight\": \"#86efac\",\n \"primary\": \"#22c55e\",\n \"primaryDark\": \"#15803d\",\n \"secondaryLight\": \"#c4b5fd\",\n \"secondary\": \"#8b5cf6\",\n \"secondaryDark\": \"#5b21b6\",\n \"tertiaryLight\": \"#fbbf24\",\n \"tertiary\": \"#f59e0b\",\n \"tertiaryDark\": \"#d97706\",\n \"grayLight\": \"#f3f4f6\",\n \"gray\": \"#9ca3af\",\n \"grayDark\": \"#374151\",\n \"success\": \"#10b981\",\n \"error\": \"#f43f5e\",\n \"warning\": \"#f59e0b\",\n \"info\": \"#3b82f6\",\n \"dark\": \"#000000\",\n \"light\": \"#ffffff\"\n },\n \"dark\": {\n \"primaryLight\": \"#6ee7b7\",\n \"primary\": \"#10b981\",\n \"primaryDark\": \"#065f46\",\n \"secondaryLight\": \"#ddd6fe\",\n \"secondary\": \"#a78bfa\",\n \"secondaryDark\": \"#7c3aed\",\n \"tertiaryLight\": \"#fed7aa\",\n \"tertiary\": \"#fb923c\",\n \"tertiaryDark\": \"#ea580c\",\n \"grayLight\": \"#1f2937\",\n \"gray\": \"#6b7280\",\n \"grayDark\": \"#9ca3af\",\n \"success\": \"#10b981\",\n \"error\": \"#f43f5e\",\n \"warning\": \"#f59e0b\",\n \"info\": \"#3b82f6\",\n \"dark\": \"#ffffff\",\n \"light\": \"#000000\"\n }\n}\n```\n\n<DemoTheme variant=\"green\" />\n\n## Yellow\n\n```json\n{\n \"default\": {\n \"primaryLight\": \"#fbbf24\",\n \"primary\": \"#f59e0b\",\n \"primaryDark\": \"#d97706\",\n \"secondaryLight\": \"#c4b5fd\",\n \"secondary\": \"#8b5cf6\",\n \"secondaryDark\": \"#5b21b6\",\n \"tertiaryLight\": \"#86efac\",\n \"tertiary\": \"#22c55e\",\n \"tertiaryDark\": \"#15803d\",\n \"grayLight\": \"#f3f4f6\",\n \"gray\": \"#9ca3af\",\n \"grayDark\": \"#374151\",\n \"success\": \"#10b981\",\n \"error\": \"#f43f5e\",\n \"warning\": \"#f59e0b\",\n \"info\": \"#3b82f6\",\n \"dark\": \"#000000\",\n \"light\": \"#ffffff\"\n },\n \"dark\": {\n \"primaryLight\": \"#fed7aa\",\n \"primary\": \"#fb923c\",\n \"primaryDark\": \"#ea580c\",\n \"secondaryLight\": \"#ddd6fe\",\n \"secondary\": \"#a78bfa\",\n \"secondaryDark\": \"#7c3aed\",\n \"tertiaryLight\": \"#6ee7b7\",\n \"tertiary\": \"#10b981\",\n \"tertiaryDark\": \"#065f46\",\n \"grayLight\": \"#1f2937\",\n \"gray\": \"#6b7280\",\n \"grayDark\": \"#9ca3af\",\n \"success\": \"#10b981\",\n \"error\": \"#f43f5e\",\n \"warning\": \"#f59e0b\",\n \"info\": \"#3b82f6\",\n \"dark\": \"#ffffff\",\n \"light\": \"#000000\"\n }\n}\n```\n\n<DemoTheme variant=\"yellow\" />";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const updateMdxTemplate = "---\ntitle: \"Update\"\ndescription: \"Easily manage and present change history.\"\ndate: \"2026-02-19\"\ncategory: \"Components\"\ncategoryOrder: 1\norder:
|
|
1
|
+
export declare const updateMdxTemplate = "---\ntitle: \"Update\"\ndescription: \"Easily manage and present change history.\"\ndate: \"2026-02-19\"\ncategory: \"Components\"\ncategoryOrder: 1\norder: 16\n---\n# Update\n\nEasily manage and present change history.\n\nThe `Update` component helps you display release notes, version details, and changelogs in a standardized format.\n\nEach `Update` label is added to the \"On this page\" sidebar and gets its own anchor, so you can link directly to a specific entry.\n\n<Update label=\"v0.0.1\" description=\"Example\">\n ## Example entry\n\n You can include anything here - images, code snippets, or a bullet list of modifications.\n\n \n\n ### Key additions\n\n - Fully responsive layout\n - Individual anchor for each update\n - Automatic RSS feed entry generation\n</Update>\n\n## Update Usage\n\nYou can combine multiple `Update` components to build complete changelogs.\n\n```html\n<Update label=\"v0.0.1\" description=\"Example\">\n ## Example entry\n\n You can include anything here - images, code snippets, or a bullet list of modifications.\n\n \n\n ### Key additions\n\n - Fully responsive layout\n - Individual anchor for each update\n - Automatic RSS feed entry generation\n</Update>\n```\n\n## Properties\n\n<Field value=\"label\" type=\"string\" required>\n The label of the update. It also appears in the page's \"On this page\"\n navigation and acts as a deep-link anchor to this entry.\n</Field>\n\n<Field value=\"description\" type=\"string\">\n An optional description for the update. When omitted, no description is shown.\n</Field>\n\n<Field value=\"children\" type=\"node\" required>\n The content of the update.\n</Field>";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const whatIsDoccupineMdxTemplate = "---\ntitle: \"What is Doccupine\"\ndescription: \"Doccupine is a CLI that turns a directory of MDX files into a complete, production-ready documentation website - no frontend work required.\"\ndate: \"2026-02-19\"\ncategory: \"Getting Started\"\ncategoryOrder: 0\norder:
|
|
1
|
+
export declare const whatIsDoccupineMdxTemplate = "---\ntitle: \"What is Doccupine\"\ndescription: \"Doccupine is a CLI that turns a directory of MDX files into a complete, production-ready documentation website - no frontend work required.\"\ndate: \"2026-02-19\"\ncategory: \"Getting Started\"\ncategoryOrder: 0\norder: 1\n---\n# What is Doccupine\n\n**Doccupine** is a CLI tool that turns a directory of MDX files into a complete Next.js documentation website. It is less of a framework you assemble and more of a tool that does the assembling for you - you bring the content, Doccupine builds the site.\n\n```bash\nnpx doccupine\n```\n\n## Philosophy\n\nDoccupine was built on a simple belief: writing documentation should feel like writing, not like building a web app. Most docs frameworks hand you a pile of libraries and configuration and expect you to wire up rendering, navigation, theming, and search yourself. Doccupine makes those decisions for you and gets out of the way, so the only thing left to do is write.\n\n## Content first\n\nYou write standard Markdown and MDX. No React, no build configuration, no component wiring. Your navigation, theming, and search are all derived from your files and a handful of JSON config files. If you can write a Markdown file, you can ship a documentation site.\n\n## Batteries included\n\nEverything you expect from a great docs site works the moment you run the command - MDX rendering, an auto-generated sidebar, dark and light themes, 14+ built-in components, full-text search, an AI chat assistant, and an MCP server. Nothing to install, nothing to opt into.\n\n<Callout type=\"info\">\n Every element on this page - this callout, the cards below, the code block above - is a live example of what your docs get out of the box, with zero setup.\n</Callout>\n\n## You own the output\n\nDoccupine generates a real Next.js 16 app inside your project, not a hosted black box. Every page, layout, and API route is written to disk where you can read it, extend it, or deploy it anywhere Next.js runs. Doccupine scaffolds the site; you stay in control of it.\n\n## Instant feedback\n\nRun `npx doccupine` and it watches your files. Every time you save an MDX file, change a config value, or drop in a new font, the site regenerates and the dev server reloads. Your docs are always one save away from being live.\n\n## AI-native\n\nDocumentation is not only read by people anymore. Doccupine ships a RAG-powered chat assistant so readers can ask questions in natural language, and an MCP server so AI tools and agents can search your documentation directly. Your content is ready for both audiences from day one.\n\n## Opinionated, on purpose\n\nDoccupine makes the boring decisions - layout, typography, color, navigation structure - so you can spend your time on the words that matter. When you are ready to customize, simple JSON files let you adjust site metadata, navigation, theme, and fonts without touching a line of code.\n\n## When to use Doccupine\n\nDoccupine is built for anyone who needs a polished documentation site without becoming a frontend engineer.\n\n- Product and API documentation\n- Developer guides and tutorials\n- Internal knowledge bases and runbooks\n- Design systems and component references\n\nThere are two ways to run it:\n\n<Columns cols={2}>\n <Card title=\"Local CLI\" icon=\"terminal\" href=\"/\">\n `npx doccupine` scaffolds and serves the site on your machine, and you self-host the generated Next.js app anywhere.\n </Card>\n <Card title=\"Doccupine Platform\" icon=\"cloud\" href=\"/platform\">\n A managed, browser-based experience with a visual editor, one-click publishing, custom domains, and team collaboration - no local setup.\n </Card>\n</Columns>";
|
|
@@ -11,7 +11,7 @@ export const packageJsonTemplate = JSON.stringify({
|
|
|
11
11
|
"type-check": "tsgo --noEmit",
|
|
12
12
|
},
|
|
13
13
|
dependencies: {
|
|
14
|
-
"@langchain/anthropic": "^1.5.
|
|
14
|
+
"@langchain/anthropic": "^1.5.2",
|
|
15
15
|
"@langchain/core": "^1.2.3",
|
|
16
16
|
"@langchain/google-genai": "^2.2.0",
|
|
17
17
|
"@langchain/openai": "^1.5.5",
|
|
@@ -19,10 +19,10 @@ export const packageJsonTemplate = JSON.stringify({
|
|
|
19
19
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
20
20
|
"beautiful-mermaid": "^1.1.3",
|
|
21
21
|
"cherry-styled-components": "^0.2.11",
|
|
22
|
-
langchain: "^1.5.
|
|
23
|
-
"lucide-react": "^1.
|
|
22
|
+
langchain: "^1.5.4",
|
|
23
|
+
"lucide-react": "^1.27.0",
|
|
24
24
|
minisearch: "^7.2.0",
|
|
25
|
-
next: "16.2.
|
|
25
|
+
next: "16.2.12",
|
|
26
26
|
"next-mdx-remote": "^6.0.0",
|
|
27
27
|
"posthog-js": "^1.407.2",
|
|
28
28
|
"posthog-node": "^5.46.1",
|
|
@@ -37,8 +37,8 @@ export const packageJsonTemplate = JSON.stringify({
|
|
|
37
37
|
zod: "^4.4.3",
|
|
38
38
|
},
|
|
39
39
|
devDependencies: {
|
|
40
|
-
"@next/env": "16.2.
|
|
41
|
-
"@next/eslint-plugin-next": "16.2.
|
|
40
|
+
"@next/env": "16.2.12",
|
|
41
|
+
"@next/eslint-plugin-next": "16.2.12",
|
|
42
42
|
"@types/node": "^26",
|
|
43
43
|
"@types/react": "^19",
|
|
44
44
|
"@types/react-dom": "^19",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const playgroundAllowlistStubTemplate = "[]\n";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// Placeholder request-execution allowlist for the API playground. Overwritten
|
|
2
|
+
// at build time with the union of the configured OpenAPI spec servers. The
|
|
3
|
+
// empty stub keeps the import path present when no spec is configured.
|
|
4
|
+
export const playgroundAllowlistStubTemplate = `[]\n`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const openapiTypesTemplate = "// Runtime mirror of the operation descriptor the CLI embeds into each generated\n// API reference page. Kept in lockstep with the CLI's src/lib/openapi-types.ts.\n\nexport type JsonSchema = unknown;\n\nexport type HttpMethod =\n \"get\" | \"put\" | \"post\" | \"delete\" | \"options\" | \"head\" | \"patch\" | \"trace\";\n\nexport type ParameterLocation = \"query\" | \"header\" | \"path\" | \"cookie\";\n\nexport interface ParameterDescriptor {\n name: string;\n in: ParameterLocation;\n required: boolean;\n deprecated?: boolean;\n description?: string;\n schema?: JsonSchema;\n example?: unknown;\n anchorId: string;\n}\n\nexport interface MediaTypeDescriptor {\n contentType: string;\n schema?: JsonSchema;\n example?: unknown;\n}\n\nexport interface RequestBodyDescriptor {\n required: boolean;\n description?: string;\n content: MediaTypeDescriptor[];\n}\n\nexport interface ResponseHeaderDescriptor {\n name: string;\n description?: string;\n schema?: JsonSchema;\n}\n\nexport interface ResponseDescriptor {\n status: string;\n description?: string;\n content: MediaTypeDescriptor[];\n headers: ResponseHeaderDescriptor[];\n}\n\nexport interface SecuritySchemeDescriptor {\n type: \"apiKey\" | \"http\" | \"oauth2\" | \"openIdConnect\" | \"mutualTLS\";\n description?: string;\n name?: string;\n in?: \"query\" | \"header\" | \"cookie\";\n scheme?: string;\n bearerFormat?: string;\n openIdConnectUrl?: string;\n flows?: unknown;\n}\n\nexport interface SecurityRequirementDescriptor {\n schemeName: string;\n scopes: string[];\n scheme?: SecuritySchemeDescriptor;\n}\n\nexport interface ServerVariableDescriptor {\n default: string;\n enum?: string[];\n description?: string;\n}\n\nexport interface ServerDescriptor {\n url: string;\n description?: string;\n variables?: Record<string, ServerVariableDescriptor>;\n}\n\nexport interface OperationDescriptor {\n specName: string;\n operationId?: string;\n method: HttpMethod;\n path: string;\n summary?: string;\n description?: string;\n deprecated?: boolean;\n tags: string[];\n parameters: ParameterDescriptor[];\n requestBody?: RequestBodyDescriptor;\n responses: ResponseDescriptor[];\n servers: ServerDescriptor[];\n security: SecurityRequirementDescriptor[];\n slug: string;\n endpointAnchor: string;\n}\n";
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
export const openapiTypesTemplate = `// Runtime mirror of the operation descriptor the CLI embeds into each generated
|
|
2
|
+
// API reference page. Kept in lockstep with the CLI's src/lib/openapi-types.ts.
|
|
3
|
+
|
|
4
|
+
export type JsonSchema = unknown;
|
|
5
|
+
|
|
6
|
+
export type HttpMethod =
|
|
7
|
+
"get" | "put" | "post" | "delete" | "options" | "head" | "patch" | "trace";
|
|
8
|
+
|
|
9
|
+
export type ParameterLocation = "query" | "header" | "path" | "cookie";
|
|
10
|
+
|
|
11
|
+
export interface ParameterDescriptor {
|
|
12
|
+
name: string;
|
|
13
|
+
in: ParameterLocation;
|
|
14
|
+
required: boolean;
|
|
15
|
+
deprecated?: boolean;
|
|
16
|
+
description?: string;
|
|
17
|
+
schema?: JsonSchema;
|
|
18
|
+
example?: unknown;
|
|
19
|
+
anchorId: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface MediaTypeDescriptor {
|
|
23
|
+
contentType: string;
|
|
24
|
+
schema?: JsonSchema;
|
|
25
|
+
example?: unknown;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface RequestBodyDescriptor {
|
|
29
|
+
required: boolean;
|
|
30
|
+
description?: string;
|
|
31
|
+
content: MediaTypeDescriptor[];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface ResponseHeaderDescriptor {
|
|
35
|
+
name: string;
|
|
36
|
+
description?: string;
|
|
37
|
+
schema?: JsonSchema;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface ResponseDescriptor {
|
|
41
|
+
status: string;
|
|
42
|
+
description?: string;
|
|
43
|
+
content: MediaTypeDescriptor[];
|
|
44
|
+
headers: ResponseHeaderDescriptor[];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface SecuritySchemeDescriptor {
|
|
48
|
+
type: "apiKey" | "http" | "oauth2" | "openIdConnect" | "mutualTLS";
|
|
49
|
+
description?: string;
|
|
50
|
+
name?: string;
|
|
51
|
+
in?: "query" | "header" | "cookie";
|
|
52
|
+
scheme?: string;
|
|
53
|
+
bearerFormat?: string;
|
|
54
|
+
openIdConnectUrl?: string;
|
|
55
|
+
flows?: unknown;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface SecurityRequirementDescriptor {
|
|
59
|
+
schemeName: string;
|
|
60
|
+
scopes: string[];
|
|
61
|
+
scheme?: SecuritySchemeDescriptor;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface ServerVariableDescriptor {
|
|
65
|
+
default: string;
|
|
66
|
+
enum?: string[];
|
|
67
|
+
description?: string;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface ServerDescriptor {
|
|
71
|
+
url: string;
|
|
72
|
+
description?: string;
|
|
73
|
+
variables?: Record<string, ServerVariableDescriptor>;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface OperationDescriptor {
|
|
77
|
+
specName: string;
|
|
78
|
+
operationId?: string;
|
|
79
|
+
method: HttpMethod;
|
|
80
|
+
path: string;
|
|
81
|
+
summary?: string;
|
|
82
|
+
description?: string;
|
|
83
|
+
deprecated?: boolean;
|
|
84
|
+
tags: string[];
|
|
85
|
+
parameters: ParameterDescriptor[];
|
|
86
|
+
requestBody?: RequestBodyDescriptor;
|
|
87
|
+
responses: ResponseDescriptor[];
|
|
88
|
+
servers: ServerDescriptor[];
|
|
89
|
+
security: SecurityRequirementDescriptor[];
|
|
90
|
+
slug: string;
|
|
91
|
+
endpointAnchor: string;
|
|
92
|
+
}
|
|
93
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const apiAnchorsTemplate = "\"use client\";\nimport { useEffect } from \"react\";\n\n// Mirrors the CLI's build-time slug convention (src/lib/openapi.ts\n// slugifySegment) so parameter deep links resolve identically on both sides.\nfunction slugifySegment(input: string): string {\n const slug = String(input)\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\");\n return slug || \"item\";\n}\n\n// Builds a parameter anchor id from ordered parts, e.g.\n// paramAnchorId([\"query\", \"page\"]) -> \"param-query-page\". Nested body\n// properties append their parent path: [\"body\", \"user\", \"address\", \"city\"].\nexport function paramAnchorId(parts: string[]): string {\n return [\"param\", ...parts].map(slugifySegment).join(\"-\");\n}\n\n// Scrolls to and briefly highlights the element named by the current URL hash,\n// on mount and on every hashchange. `onHighlight` receives the matched id so\n// the caller can flash a transient highlight.\nexport function useAnchorScroll(onHighlight: (id: string) => void): void {\n useEffect(() => {\n const handle = () => {\n const hash = window.location.hash.replace(/^#/, \"\");\n if (!hash) return;\n const el = document.getElementById(hash);\n if (!el) return;\n el.scrollIntoView({ behavior: \"smooth\", block: \"center\" });\n onHighlight(hash);\n };\n handle();\n window.addEventListener(\"hashchange\", handle);\n return () => window.removeEventListener(\"hashchange\", handle);\n }, [onHighlight]);\n}\n";
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export const apiAnchorsTemplate = `"use client";
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
|
|
4
|
+
// Mirrors the CLI's build-time slug convention (src/lib/openapi.ts
|
|
5
|
+
// slugifySegment) so parameter deep links resolve identically on both sides.
|
|
6
|
+
function slugifySegment(input: string): string {
|
|
7
|
+
const slug = String(input)
|
|
8
|
+
.toLowerCase()
|
|
9
|
+
.replace(/[^a-z0-9]+/g, "-")
|
|
10
|
+
.replace(/^-+|-+$/g, "");
|
|
11
|
+
return slug || "item";
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Builds a parameter anchor id from ordered parts, e.g.
|
|
15
|
+
// paramAnchorId(["query", "page"]) -> "param-query-page". Nested body
|
|
16
|
+
// properties append their parent path: ["body", "user", "address", "city"].
|
|
17
|
+
export function paramAnchorId(parts: string[]): string {
|
|
18
|
+
return ["param", ...parts].map(slugifySegment).join("-");
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Scrolls to and briefly highlights the element named by the current URL hash,
|
|
22
|
+
// on mount and on every hashchange. \`onHighlight\` receives the matched id so
|
|
23
|
+
// the caller can flash a transient highlight.
|
|
24
|
+
export function useAnchorScroll(onHighlight: (id: string) => void): void {
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
const handle = () => {
|
|
27
|
+
const hash = window.location.hash.replace(/^#/, "");
|
|
28
|
+
if (!hash) return;
|
|
29
|
+
const el = document.getElementById(hash);
|
|
30
|
+
if (!el) return;
|
|
31
|
+
el.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
32
|
+
onHighlight(hash);
|
|
33
|
+
};
|
|
34
|
+
handle();
|
|
35
|
+
window.addEventListener("hashchange", handle);
|
|
36
|
+
return () => window.removeEventListener("hashchange", handle);
|
|
37
|
+
}, [onHighlight]);
|
|
38
|
+
}
|
|
39
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const apiSnippetsTemplate = "// Pure, isomorphic request-to-snippet generators for the API playground.\n// Given the fully-resolved request, produce copy-pasteable cURL / fetch /\n// requests examples. Secret redaction is the caller's responsibility: pass\n// already-redacted header values when secrets should not appear.\n\nexport interface SnippetRequest {\n method: string;\n url: string;\n headers: Record<string, string>;\n body?: string | null;\n}\n\nexport type SnippetLanguage = \"curl\" | \"javascript\" | \"python\";\n\nexport interface SnippetTab {\n label: string;\n code: string;\n language: string;\n}\n\n// A literal backslash, built without writing one (keeps escaping simple).\nconst BACKSLASH = String.fromCharCode(92);\n\n// POSIX single-quote a shell argument: wrap in quotes, and represent any inner\n// single quote as '\\'' by ending the quote, adding an escaped quote, reopening.\nfunction shellQuote(value: string): string {\n const escaped = value.split(\"'\").join(\"'\" + BACKSLASH + \"''\");\n return \"'\" + escaped + \"'\";\n}\n\nfunction toCurl(req: SnippetRequest): string {\n const parts: string[] = [\"curl\", \"-X\", req.method, shellQuote(req.url)];\n for (const [key, value] of Object.entries(req.headers)) {\n parts.push(\"-H\", shellQuote(key + \": \" + value));\n }\n if (req.body) {\n parts.push(\"--data\", shellQuote(req.body));\n }\n return parts.join(\" \");\n}\n\nfunction toFetch(req: SnippetRequest): string {\n const options: {\n method: string;\n headers?: Record<string, string>;\n body?: string;\n } = { method: req.method };\n if (Object.keys(req.headers).length > 0) options.headers = req.headers;\n if (req.body) options.body = req.body;\n return (\n \"const response = await fetch(\" +\n JSON.stringify(req.url) +\n \", \" +\n JSON.stringify(options, null, 2) +\n \");\"\n );\n}\n\nfunction toPython(req: SnippetRequest): string {\n const lines: string[] = [\"import requests\", \"\"];\n lines.push(\"response = requests.\" + req.method.toLowerCase() + \"(\");\n lines.push(\" \" + JSON.stringify(req.url) + \",\");\n if (Object.keys(req.headers).length > 0) {\n lines.push(\" headers=\" + JSON.stringify(req.headers) + \",\");\n }\n if (req.body) {\n lines.push(\" data=\" + JSON.stringify(req.body) + \",\");\n }\n lines.push(\")\");\n lines.push(\"print(response.status_code, response.text)\");\n return lines.join(\"\\n\");\n}\n\nexport function buildSnippets(\n req: SnippetRequest,\n languages: SnippetLanguage[],\n): SnippetTab[] {\n const tabs: SnippetTab[] = [];\n for (const language of languages) {\n if (language === \"curl\") {\n tabs.push({ label: \"cURL\", code: toCurl(req), language: \"bash\" });\n } else if (language === \"javascript\") {\n tabs.push({\n label: \"JavaScript\",\n code: toFetch(req),\n language: \"javascript\",\n });\n } else if (language === \"python\") {\n tabs.push({ label: \"Python\", code: toPython(req), language: \"python\" });\n }\n }\n return tabs;\n}\n";
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
export const apiSnippetsTemplate = `// Pure, isomorphic request-to-snippet generators for the API playground.
|
|
2
|
+
// Given the fully-resolved request, produce copy-pasteable cURL / fetch /
|
|
3
|
+
// requests examples. Secret redaction is the caller's responsibility: pass
|
|
4
|
+
// already-redacted header values when secrets should not appear.
|
|
5
|
+
|
|
6
|
+
export interface SnippetRequest {
|
|
7
|
+
method: string;
|
|
8
|
+
url: string;
|
|
9
|
+
headers: Record<string, string>;
|
|
10
|
+
body?: string | null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type SnippetLanguage = "curl" | "javascript" | "python";
|
|
14
|
+
|
|
15
|
+
export interface SnippetTab {
|
|
16
|
+
label: string;
|
|
17
|
+
code: string;
|
|
18
|
+
language: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// A literal backslash, built without writing one (keeps escaping simple).
|
|
22
|
+
const BACKSLASH = String.fromCharCode(92);
|
|
23
|
+
|
|
24
|
+
// POSIX single-quote a shell argument: wrap in quotes, and represent any inner
|
|
25
|
+
// single quote as '\\'' by ending the quote, adding an escaped quote, reopening.
|
|
26
|
+
function shellQuote(value: string): string {
|
|
27
|
+
const escaped = value.split("'").join("'" + BACKSLASH + "''");
|
|
28
|
+
return "'" + escaped + "'";
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function toCurl(req: SnippetRequest): string {
|
|
32
|
+
const parts: string[] = ["curl", "-X", req.method, shellQuote(req.url)];
|
|
33
|
+
for (const [key, value] of Object.entries(req.headers)) {
|
|
34
|
+
parts.push("-H", shellQuote(key + ": " + value));
|
|
35
|
+
}
|
|
36
|
+
if (req.body) {
|
|
37
|
+
parts.push("--data", shellQuote(req.body));
|
|
38
|
+
}
|
|
39
|
+
return parts.join(" ");
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function toFetch(req: SnippetRequest): string {
|
|
43
|
+
const options: {
|
|
44
|
+
method: string;
|
|
45
|
+
headers?: Record<string, string>;
|
|
46
|
+
body?: string;
|
|
47
|
+
} = { method: req.method };
|
|
48
|
+
if (Object.keys(req.headers).length > 0) options.headers = req.headers;
|
|
49
|
+
if (req.body) options.body = req.body;
|
|
50
|
+
return (
|
|
51
|
+
"const response = await fetch(" +
|
|
52
|
+
JSON.stringify(req.url) +
|
|
53
|
+
", " +
|
|
54
|
+
JSON.stringify(options, null, 2) +
|
|
55
|
+
");"
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function toPython(req: SnippetRequest): string {
|
|
60
|
+
const lines: string[] = ["import requests", ""];
|
|
61
|
+
lines.push("response = requests." + req.method.toLowerCase() + "(");
|
|
62
|
+
lines.push(" " + JSON.stringify(req.url) + ",");
|
|
63
|
+
if (Object.keys(req.headers).length > 0) {
|
|
64
|
+
lines.push(" headers=" + JSON.stringify(req.headers) + ",");
|
|
65
|
+
}
|
|
66
|
+
if (req.body) {
|
|
67
|
+
lines.push(" data=" + JSON.stringify(req.body) + ",");
|
|
68
|
+
}
|
|
69
|
+
lines.push(")");
|
|
70
|
+
lines.push("print(response.status_code, response.text)");
|
|
71
|
+
return lines.join("\\n");
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function buildSnippets(
|
|
75
|
+
req: SnippetRequest,
|
|
76
|
+
languages: SnippetLanguage[],
|
|
77
|
+
): SnippetTab[] {
|
|
78
|
+
const tabs: SnippetTab[] = [];
|
|
79
|
+
for (const language of languages) {
|
|
80
|
+
if (language === "curl") {
|
|
81
|
+
tabs.push({ label: "cURL", code: toCurl(req), language: "bash" });
|
|
82
|
+
} else if (language === "javascript") {
|
|
83
|
+
tabs.push({
|
|
84
|
+
label: "JavaScript",
|
|
85
|
+
code: toFetch(req),
|
|
86
|
+
language: "javascript",
|
|
87
|
+
});
|
|
88
|
+
} else if (language === "python") {
|
|
89
|
+
tabs.push({ label: "Python", code: toPython(req), language: "python" });
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return tabs;
|
|
93
|
+
}
|
|
94
|
+
`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const orderNavItemsTemplate = "export interface PagesProps {\n slug: string;\n title: string;\n date: string | null;\n category: string;\n description?: string;\n path?: string;\n categoryOrder?: number;\n order?: number;\n section?: string;\n navIcon?: string;\n categoryIcon?: string;\n}\n\ninterface AccProps {\n [key: string]: {\n categoryOrder: number;\n icon?: string;\n pages: {\n date: string | null;\n slug: string;\n title: string;\n order: number;\n icon?: string;\n }[];\n };\n}\n\nfunction transformPagesToGroupedStructure(pages: PagesProps[]) {\n const grouped = pages.reduce((acc: AccProps, page: PagesProps) => {\n const category = page.category || \"Uncategorized\";\n\n if (!acc[category]) {\n acc[category] = {\n categoryOrder: page.categoryOrder || 0,\n pages: [],\n };\n }\n\n // The first page in a category to declare a categoryIcon sets it.\n if (!acc[category].icon && page.categoryIcon) {\n acc[category].icon = page.categoryIcon;\n }\n\n acc[category].pages.push({\n date: page.date,\n slug: page.slug,\n title: page.title,\n order: page.order || 0,\n icon: page.navIcon,\n });\n\n return acc;\n }, {});\n\n return Object.entries(grouped)\n .sort(([, a], [, b]) => a.categoryOrder - b.categoryOrder)\n .map(([categoryName, categoryData], index) => ({\n slug: index === 0 ? \"\" : categoryName.toLowerCase().replace(/s+/g, \"-\"),\n label: categoryName,\n icon: categoryData.icon,\n links: categoryData.pages.sort((a, b) => a.order - b.order),\n }));\n}\n\nexport { transformPagesToGroupedStructure };\n";
|
|
1
|
+
export declare const orderNavItemsTemplate = "export interface PagesProps {\n slug: string;\n title: string;\n date: string | null;\n category: string;\n description?: string;\n path?: string;\n categoryOrder?: number;\n order?: number;\n section?: string;\n navIcon?: string;\n categoryIcon?: string;\n httpMethod?: string;\n}\n\ninterface AccProps {\n [key: string]: {\n categoryOrder: number;\n icon?: string;\n pages: {\n date: string | null;\n slug: string;\n title: string;\n order: number;\n icon?: string;\n httpMethod?: string;\n }[];\n };\n}\n\nfunction transformPagesToGroupedStructure(pages: PagesProps[]) {\n const grouped = pages.reduce((acc: AccProps, page: PagesProps) => {\n const category = page.category || \"Uncategorized\";\n\n if (!acc[category]) {\n acc[category] = {\n categoryOrder: page.categoryOrder || 0,\n pages: [],\n };\n }\n\n // The first page in a category to declare a categoryIcon sets it.\n if (!acc[category].icon && page.categoryIcon) {\n acc[category].icon = page.categoryIcon;\n }\n\n acc[category].pages.push({\n date: page.date,\n slug: page.slug,\n title: page.title,\n order: page.order || 0,\n icon: page.navIcon,\n httpMethod: page.httpMethod,\n });\n\n return acc;\n }, {});\n\n return Object.entries(grouped)\n .sort(([, a], [, b]) => a.categoryOrder - b.categoryOrder)\n .map(([categoryName, categoryData], index) => ({\n slug: index === 0 ? \"\" : categoryName.toLowerCase().replace(/s+/g, \"-\"),\n label: categoryName,\n icon: categoryData.icon,\n links: categoryData.pages.sort((a, b) => a.order - b.order),\n }));\n}\n\nexport { transformPagesToGroupedStructure };\n";
|
|
@@ -10,6 +10,7 @@ export const orderNavItemsTemplate = `export interface PagesProps {
|
|
|
10
10
|
section?: string;
|
|
11
11
|
navIcon?: string;
|
|
12
12
|
categoryIcon?: string;
|
|
13
|
+
httpMethod?: string;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
interface AccProps {
|
|
@@ -22,6 +23,7 @@ interface AccProps {
|
|
|
22
23
|
title: string;
|
|
23
24
|
order: number;
|
|
24
25
|
icon?: string;
|
|
26
|
+
httpMethod?: string;
|
|
25
27
|
}[];
|
|
26
28
|
};
|
|
27
29
|
}
|
|
@@ -48,6 +50,7 @@ function transformPagesToGroupedStructure(pages: PagesProps[]) {
|
|
|
48
50
|
title: page.title,
|
|
49
51
|
order: page.order || 0,
|
|
50
52
|
icon: page.navIcon,
|
|
53
|
+
httpMethod: page.httpMethod,
|
|
51
54
|
});
|
|
52
55
|
|
|
53
56
|
return acc;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const playgroundAllowlistTemplate = "import allowlistData from \"@/services/openapi/playground-allowlist.json\";\n\n// A single request-execution target the API playground is permitted to call.\n// Derived at build time from the union of every OpenAPI spec's `servers`.\n// `allowPrivate` is set ONLY when the spec's own declared server host is itself\n// a loopback/private/metadata literal (the local-dev case).\nexport interface AllowlistEntry {\n scheme: \"http\" | \"https\";\n host: string;\n port: number | null;\n basePath?: string;\n allowPrivate?: boolean;\n}\n\nconst allowlist: AllowlistEntry[] = Array.isArray(allowlistData)\n ? (allowlistData as AllowlistEntry[])\n : [];\n\nexport function getAllowlist(): AllowlistEntry[] {\n return allowlist;\n}\n\nfunction defaultPort(scheme: string): number {\n return scheme === \"https\" ? 443 : 80;\n}\n\n/**\n * Returns the matching allowlist entry for a target URL, or null. Matches on\n * exact scheme + hostname + effective port, plus an optional base-path prefix.\n * This is isomorphic: the server proxy uses it as a hard gate; the client uses\n * it for a consistent pre-flight check (NOT a security boundary on its own).\n */\nexport function matchAllowlistIn(\n entries: AllowlistEntry[],\n targetUrl: string,\n): AllowlistEntry | null {\n let url: URL;\n try {\n url = new URL(targetUrl);\n } catch {\n return null;\n }\n const scheme =\n url.protocol === \"https:\"\n ? \"https\"\n : url.protocol === \"http:\"\n ? \"http\"\n : null;\n if (!scheme) return null;\n // Reject embedded credentials (userinfo) outright.\n if (url.username || url.password) return null;\n\n const host = url.hostname.toLowerCase().replace(/\\.$/, \"\");\n const port = url.port ? Number(url.port) : defaultPort(scheme);\n\n for (const entry of entries) {\n if (entry.scheme !== scheme) continue;\n if (entry.host !== host) continue;\n const entryPort = entry.port ?? defaultPort(entry.scheme);\n if (entryPort !== port) continue;\n if (entry.basePath && !url.pathname.startsWith(entry.basePath)) continue;\n return entry;\n }\n return null;\n}\n\nexport function matchAllowlist(targetUrl: string): AllowlistEntry | null {\n return matchAllowlistIn(allowlist, targetUrl);\n}\n";
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export const playgroundAllowlistTemplate = `import allowlistData from "@/services/openapi/playground-allowlist.json";
|
|
2
|
+
|
|
3
|
+
// A single request-execution target the API playground is permitted to call.
|
|
4
|
+
// Derived at build time from the union of every OpenAPI spec's \`servers\`.
|
|
5
|
+
// \`allowPrivate\` is set ONLY when the spec's own declared server host is itself
|
|
6
|
+
// a loopback/private/metadata literal (the local-dev case).
|
|
7
|
+
export interface AllowlistEntry {
|
|
8
|
+
scheme: "http" | "https";
|
|
9
|
+
host: string;
|
|
10
|
+
port: number | null;
|
|
11
|
+
basePath?: string;
|
|
12
|
+
allowPrivate?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const allowlist: AllowlistEntry[] = Array.isArray(allowlistData)
|
|
16
|
+
? (allowlistData as AllowlistEntry[])
|
|
17
|
+
: [];
|
|
18
|
+
|
|
19
|
+
export function getAllowlist(): AllowlistEntry[] {
|
|
20
|
+
return allowlist;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function defaultPort(scheme: string): number {
|
|
24
|
+
return scheme === "https" ? 443 : 80;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Returns the matching allowlist entry for a target URL, or null. Matches on
|
|
29
|
+
* exact scheme + hostname + effective port, plus an optional base-path prefix.
|
|
30
|
+
* This is isomorphic: the server proxy uses it as a hard gate; the client uses
|
|
31
|
+
* it for a consistent pre-flight check (NOT a security boundary on its own).
|
|
32
|
+
*/
|
|
33
|
+
export function matchAllowlistIn(
|
|
34
|
+
entries: AllowlistEntry[],
|
|
35
|
+
targetUrl: string,
|
|
36
|
+
): AllowlistEntry | null {
|
|
37
|
+
let url: URL;
|
|
38
|
+
try {
|
|
39
|
+
url = new URL(targetUrl);
|
|
40
|
+
} catch {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
const scheme =
|
|
44
|
+
url.protocol === "https:"
|
|
45
|
+
? "https"
|
|
46
|
+
: url.protocol === "http:"
|
|
47
|
+
? "http"
|
|
48
|
+
: null;
|
|
49
|
+
if (!scheme) return null;
|
|
50
|
+
// Reject embedded credentials (userinfo) outright.
|
|
51
|
+
if (url.username || url.password) return null;
|
|
52
|
+
|
|
53
|
+
const host = url.hostname.toLowerCase().replace(/\\.$/, "");
|
|
54
|
+
const port = url.port ? Number(url.port) : defaultPort(scheme);
|
|
55
|
+
|
|
56
|
+
for (const entry of entries) {
|
|
57
|
+
if (entry.scheme !== scheme) continue;
|
|
58
|
+
if (entry.host !== host) continue;
|
|
59
|
+
const entryPort = entry.port ?? defaultPort(entry.scheme);
|
|
60
|
+
if (entryPort !== port) continue;
|
|
61
|
+
if (entry.basePath && !url.pathname.startsWith(entry.basePath)) continue;
|
|
62
|
+
return entry;
|
|
63
|
+
}
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function matchAllowlist(targetUrl: string): AllowlistEntry | null {
|
|
68
|
+
return matchAllowlistIn(allowlist, targetUrl);
|
|
69
|
+
}
|
|
70
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ssrfGuardTemplate = "// SERVER-ONLY. Imported solely by app/api/playground/route.ts (a route handler,\n// which never ships to the client). Performs SSRF-safe outbound requests for\n// the API playground proxy: it resolves the target host, rejects any address in\n// a private/loopback/link-local/metadata range, and pins the connection to the\n// pre-validated IPs so DNS rebinding between check and connect cannot redirect\n// the socket to an internal address.\n\nimport dns from \"node:dns/promises\";\nimport net from \"node:net\";\nimport http from \"node:http\";\nimport https from \"node:https\";\nimport type { LookupAddress } from \"node:dns\";\nimport type { LookupFunction } from \"node:net\";\nimport type { AllowlistEntry } from \"@/utils/playgroundAllowlist\";\n\nexport class BlockedError extends Error {\n constructor(public reason: string) {\n super(reason);\n this.name = \"BlockedError\";\n }\n}\n\nexport interface GuardedInit {\n method: string;\n headers: Record<string, string>;\n body?: Buffer;\n timeoutMs: number;\n maxBytes: number;\n}\n\nexport interface GuardedResult {\n status: number;\n statusText: string;\n headers: Record<string, string>;\n body: Buffer;\n truncated: boolean;\n durationMs: number;\n}\n\nfunction isBlockedIpv4(ip: string): boolean {\n const parts = ip.split(\".\");\n if (parts.length !== 4) return true;\n const nums = parts.map((p) => Number(p));\n if (nums.some((n) => !Number.isInteger(n) || n < 0 || n > 255)) return true;\n const a = nums[0];\n const b = nums[1];\n const c = nums[2];\n if (a === 0 || a === 10 || a === 127) return true;\n if (a === 169 && b === 254) return true; // link-local incl. metadata\n if (a === 172 && b >= 16 && b <= 31) return true;\n if (a === 192 && b === 168) return true;\n if (a === 192 && b === 0 && c === 0) return true;\n if (a === 100 && b >= 64 && b <= 127) return true; // CGNAT\n if (a === 198 && (b === 18 || b === 19)) return true; // benchmarking\n if (a >= 224) return true; // multicast + reserved + broadcast\n return false;\n}\n\nfunction isBlockedIpv6(ip: string): boolean {\n const clean = ip.toLowerCase().split(\"%\")[0];\n if (clean === \"::\" || clean === \"::1\") return true;\n if (clean.startsWith(\"::ffff:\")) {\n const rest = clean.slice(\"::ffff:\".length);\n if (rest.includes(\".\")) return isBlockedIpv4(rest);\n const segs = rest.split(\":\");\n if (segs.length === 2) {\n const hi = parseInt(segs[0], 16);\n const lo = parseInt(segs[1], 16);\n if (Number.isInteger(hi) && Number.isInteger(lo)) {\n const v4 = [(hi >> 8) & 255, hi & 255, (lo >> 8) & 255, lo & 255].join(\n \".\",\n );\n return isBlockedIpv4(v4);\n }\n }\n }\n const head = clean.split(\":\")[0];\n if (\n head.startsWith(\"fe8\") ||\n head.startsWith(\"fe9\") ||\n head.startsWith(\"fea\") ||\n head.startsWith(\"feb\")\n ) {\n return true; // link-local fe80::/10\n }\n if (head.startsWith(\"fc\") || head.startsWith(\"fd\")) return true; // unique-local\n return false;\n}\n\nfunction isBlockedIp(ip: string): boolean {\n const type = net.isIP(ip);\n if (type === 4) return isBlockedIpv4(ip);\n if (type === 6) return isBlockedIpv6(ip);\n return true; // not a parseable IP -> fail closed\n}\n\nfunction flattenHeaders(\n headers: http.IncomingHttpHeaders,\n): Record<string, string> {\n const out: Record<string, string> = {};\n for (const [key, value] of Object.entries(headers)) {\n if (value === undefined) continue;\n out[key.toLowerCase()] = Array.isArray(value) ? value.join(\", \") : value;\n }\n return out;\n}\n\nexport async function guardedFetch(\n targetUrl: string,\n entry: AllowlistEntry,\n init: GuardedInit,\n): Promise<GuardedResult> {\n const url = new URL(targetUrl);\n let host = url.hostname.toLowerCase();\n if (host.endsWith(\".\")) host = host.slice(0, -1);\n\n const literalType = net.isIP(host);\n let validated: LookupAddress[];\n\n if (literalType !== 0) {\n // Raw-IP target: only allowed if the spec itself declared this host, and\n // only into a private range when it opted in via allowPrivate.\n if (isBlockedIp(host) && !entry.allowPrivate) {\n throw new BlockedError(\"blocked: private IP-literal target\");\n }\n validated = [{ address: host, family: literalType }];\n } else {\n let records: LookupAddress[];\n try {\n records = await dns.lookup(host, { all: true, verbatim: true });\n } catch {\n throw new BlockedError(\"blocked: DNS resolution failed\");\n }\n if (records.length === 0) throw new BlockedError(\"blocked: no DNS records\");\n if (!entry.allowPrivate) {\n for (const record of records) {\n if (isBlockedIp(record.address)) {\n throw new BlockedError(\"blocked: private IP\");\n }\n }\n }\n validated = records;\n }\n\n const isHttps = url.protocol === \"https:\";\n const transport = isHttps ? https : http;\n\n // Pin resolution to the addresses we just validated so a re-resolution\n // between check and connect (DNS rebinding) cannot swap in a private IP.\n const lookup: LookupFunction = (_hostname, options, callback) => {\n if (options && options.all) {\n callback(null, validated);\n } else {\n callback(null, validated[0].address, validated[0].family);\n }\n };\n\n const requestOptions: https.RequestOptions = {\n method: init.method,\n headers: init.headers,\n lookup,\n timeout: init.timeoutMs,\n };\n\n return await new Promise<GuardedResult>((resolve, reject) => {\n const start = Date.now();\n let settled = false;\n const done = (fn: () => void) => {\n if (settled) return;\n settled = true;\n fn();\n };\n\n const req = transport.request(url, requestOptions, (res) => {\n const chunks: Buffer[] = [];\n let received = 0;\n let truncated = false;\n\n res.on(\"data\", (chunk: Buffer) => {\n received += chunk.length;\n if (received > init.maxBytes) {\n truncated = true;\n res.destroy();\n return;\n }\n chunks.push(chunk);\n });\n\n const finish = () =>\n done(() =>\n resolve({\n status: res.statusCode ?? 0,\n statusText: res.statusMessage ?? \"\",\n headers: flattenHeaders(res.headers),\n body: Buffer.concat(chunks),\n truncated,\n durationMs: Date.now() - start,\n }),\n );\n\n res.on(\"end\", finish);\n res.on(\"close\", finish);\n res.on(\"error\", () => done(() => reject(new Error(\"stream error\"))));\n });\n\n req.on(\"timeout\", () => {\n req.destroy(new Error(\"timeout\"));\n });\n req.on(\"error\", (err) => done(() => reject(err)));\n\n if (init.body && init.method !== \"GET\" && init.method !== \"HEAD\") {\n req.write(init.body);\n }\n req.end();\n });\n}\n";
|