@vendure-io/docs-provider 0.1.0
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 +245 -0
- package/dist/frontmatter.d.ts +89 -0
- package/dist/frontmatter.d.ts.map +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -0
- package/dist/loader.cjs +1 -0
- package/dist/loader.d.ts +99 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +90 -0
- package/dist/manifest-B1CxKK1i.js +207 -0
- package/dist/manifest-D2yANQB-.cjs +3 -0
- package/dist/manifest.d.ts +127 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/navigation-utils.d.ts +15 -0
- package/dist/navigation-utils.d.ts.map +1 -0
- package/dist/schema.d.ts +419 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/types.d.ts +116 -0
- package/dist/types.d.ts.map +1 -0
- package/docs/creating-a-docs-package.md +394 -0
- package/docs/frontmatter-reference.md +364 -0
- package/docs/getting-started.md +156 -0
- package/docs/manifest-reference.md +520 -0
- package/docs/publishing.md +352 -0
- package/package.json +76 -0
package/README.md
ADDED
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
# @vendure-io/docs-provider
|
|
2
|
+
|
|
3
|
+
Contract types and utilities for Vendure documentation packages. This package defines the shared interface between the docs application (`apps/docs`) and external documentation packages (`@vendure/docs-core`, `@vendure/docs-plugins`, `@vendure/docs-enterprise`).
|
|
4
|
+
|
|
5
|
+
## Documentation
|
|
6
|
+
|
|
7
|
+
- [Getting Started](./docs/getting-started.md) - Quick introduction and overview
|
|
8
|
+
- [Creating a Docs Package](./docs/creating-a-docs-package.md) - Step-by-step guide to building a documentation package
|
|
9
|
+
- [Manifest Reference](./docs/manifest-reference.md) - Complete API documentation for manifest types and utilities
|
|
10
|
+
- [Frontmatter Reference](./docs/frontmatter-reference.md) - All available MDX frontmatter options
|
|
11
|
+
- [Publishing](./docs/publishing.md) - How to publish and integrate with vendure.io
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @vendure-io/docs-provider
|
|
17
|
+
# or
|
|
18
|
+
bun add @vendure-io/docs-provider
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
### Defining a Documentation Package Manifest
|
|
24
|
+
|
|
25
|
+
Documentation packages export a manifest that describes their structure:
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import type { DocsPackageManifest } from '@vendure-io/docs-provider'
|
|
29
|
+
|
|
30
|
+
export const manifest: DocsPackageManifest = {
|
|
31
|
+
id: 'core',
|
|
32
|
+
name: 'Vendure Core',
|
|
33
|
+
version: '3.0.0',
|
|
34
|
+
vendureVersion: 'v3',
|
|
35
|
+
navigation: [
|
|
36
|
+
{
|
|
37
|
+
title: 'Getting Started',
|
|
38
|
+
slug: 'getting-started',
|
|
39
|
+
children: [
|
|
40
|
+
{
|
|
41
|
+
title: 'Installation',
|
|
42
|
+
slug: 'installation',
|
|
43
|
+
file: 'docs/getting-started/installation.mdx',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
title: 'Configuration',
|
|
47
|
+
slug: 'configuration',
|
|
48
|
+
file: 'docs/getting-started/configuration.mdx',
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
search: {
|
|
54
|
+
indexFields: ['title', 'description', 'content', 'keywords'],
|
|
55
|
+
boosts: { title: 2, keywords: 1.5 },
|
|
56
|
+
},
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Loading Documentation Packages
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
import { loadDocsPackage, loadDocPageBySlug } from '@vendure-io/docs-provider'
|
|
64
|
+
|
|
65
|
+
// Load a docs package
|
|
66
|
+
const { manifest, basePath } = await loadDocsPackage('@vendure/docs-core')
|
|
67
|
+
|
|
68
|
+
// Load a specific page by slug
|
|
69
|
+
const page = await loadDocPageBySlug(loadedPackage, 'getting-started/installation')
|
|
70
|
+
if (page) {
|
|
71
|
+
console.log(page.meta.title) // "Installation"
|
|
72
|
+
console.log(page.content) // MDX content
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Validating Manifests
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
import { validateManifest, ManifestValidationError } from '@vendure-io/docs-provider'
|
|
80
|
+
|
|
81
|
+
try {
|
|
82
|
+
const manifest = validateManifest(rawManifestData)
|
|
83
|
+
} catch (error) {
|
|
84
|
+
if (error instanceof ManifestValidationError) {
|
|
85
|
+
console.error('Validation issues:', error.issues)
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Navigation Utilities
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
import {
|
|
94
|
+
findNavigationNode,
|
|
95
|
+
flattenNavigation,
|
|
96
|
+
buildBreadcrumbs,
|
|
97
|
+
getLeafNodes,
|
|
98
|
+
getPrevNextNodes,
|
|
99
|
+
} from '@vendure-io/docs-provider'
|
|
100
|
+
|
|
101
|
+
// Find a node by slug path
|
|
102
|
+
const node = findNavigationNode(manifest, 'getting-started/installation')
|
|
103
|
+
|
|
104
|
+
// Flatten navigation tree
|
|
105
|
+
const flatNodes = flattenNavigation(manifest)
|
|
106
|
+
|
|
107
|
+
// Build breadcrumb trail
|
|
108
|
+
const breadcrumbs = buildBreadcrumbs(manifest, 'getting-started/installation')
|
|
109
|
+
// [
|
|
110
|
+
// { title: 'Getting Started', slug: 'getting-started', path: 'getting-started' },
|
|
111
|
+
// { title: 'Installation', slug: 'installation', path: 'getting-started/installation' }
|
|
112
|
+
// ]
|
|
113
|
+
|
|
114
|
+
// Get all pages (nodes with files)
|
|
115
|
+
const pages = getLeafNodes(manifest)
|
|
116
|
+
|
|
117
|
+
// Get previous/next pages for navigation
|
|
118
|
+
const { prev, next } = getPrevNextNodes(manifest, 'getting-started/installation')
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Parsing MDX Frontmatter
|
|
122
|
+
|
|
123
|
+
```typescript
|
|
124
|
+
import { parseFrontmatter, hasFrontmatter } from '@vendure-io/docs-provider'
|
|
125
|
+
|
|
126
|
+
const mdxContent = `---
|
|
127
|
+
title: Installation Guide
|
|
128
|
+
description: Learn how to install Vendure
|
|
129
|
+
keywords:
|
|
130
|
+
- install
|
|
131
|
+
- setup
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
# Installation
|
|
135
|
+
|
|
136
|
+
Follow these steps to install Vendure...
|
|
137
|
+
`
|
|
138
|
+
|
|
139
|
+
if (hasFrontmatter(mdxContent)) {
|
|
140
|
+
const { meta, content } = parseFrontmatter(mdxContent)
|
|
141
|
+
console.log(meta.title) // "Installation Guide"
|
|
142
|
+
console.log(content) // "# Installation\n\nFollow these steps..."
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## API Reference
|
|
147
|
+
|
|
148
|
+
### Types
|
|
149
|
+
|
|
150
|
+
| Type | Description |
|
|
151
|
+
| --------------------- | ----------------------------------------------------- |
|
|
152
|
+
| `DocsPackageManifest` | Main manifest describing a documentation package |
|
|
153
|
+
| `NavigationNode` | A node in the navigation tree |
|
|
154
|
+
| `DocPage` | A loaded documentation page with metadata and content |
|
|
155
|
+
| `DocPageMeta` | Frontmatter metadata for a page |
|
|
156
|
+
| `SearchConfig` | Search indexing configuration |
|
|
157
|
+
| `VendureVersion` | Supported Vendure versions (`'v1' \| 'v2' \| 'v3'`) |
|
|
158
|
+
| `FlatNavigationNode` | Flattened navigation node with path info |
|
|
159
|
+
| `BreadcrumbItem` | Breadcrumb navigation item |
|
|
160
|
+
| `LoadedDocsPackage` | Result of loading a docs package |
|
|
161
|
+
| `GitHubConfig` | GitHub repository configuration for edit links |
|
|
162
|
+
|
|
163
|
+
### Schemas (Zod)
|
|
164
|
+
|
|
165
|
+
All types have corresponding Zod schemas for runtime validation:
|
|
166
|
+
|
|
167
|
+
- `DocsPackageManifestSchema`
|
|
168
|
+
- `NavigationNodeSchema`
|
|
169
|
+
- `DocPageSchema`
|
|
170
|
+
- `DocPageMetaSchema`
|
|
171
|
+
- `SearchConfigSchema`
|
|
172
|
+
- `GitHubConfigSchema`
|
|
173
|
+
- `VendureVersionSchema`
|
|
174
|
+
- `FlatNavigationNodeSchema`
|
|
175
|
+
- `BreadcrumbItemSchema`
|
|
176
|
+
- `LoadedDocsPackageSchema`
|
|
177
|
+
|
|
178
|
+
### Functions
|
|
179
|
+
|
|
180
|
+
#### Manifest Utilities
|
|
181
|
+
|
|
182
|
+
| Function | Description |
|
|
183
|
+
| ---------------------------------------- | ----------------------------------------- |
|
|
184
|
+
| `validateManifest(data)` | Validate raw data against manifest schema |
|
|
185
|
+
| `findNavigationNode(manifest, slugPath)` | Find a node by slug path |
|
|
186
|
+
| `flattenNavigation(manifest)` | Flatten navigation tree to array |
|
|
187
|
+
| `buildBreadcrumbs(manifest, slugPath)` | Build breadcrumb trail |
|
|
188
|
+
| `getLeafNodes(manifest)` | Get all nodes with files |
|
|
189
|
+
| `getPrevNextNodes(manifest, slugPath)` | Get adjacent pages |
|
|
190
|
+
| `isNodeActive(node, currentPath)` | Check if node matches path |
|
|
191
|
+
| `getNodesAtDepth(manifest, depth)` | Get nodes at specific depth |
|
|
192
|
+
|
|
193
|
+
#### Loader Utilities
|
|
194
|
+
|
|
195
|
+
| Function | Description |
|
|
196
|
+
| -------------------------------------- | -------------------------------- |
|
|
197
|
+
| `loadDocsPackage(packageName)` | Load and validate a docs package |
|
|
198
|
+
| `loadDocPage(package, filePath)` | Load a page by file path |
|
|
199
|
+
| `loadDocPageBySlug(package, slugPath)` | Load a page by slug path |
|
|
200
|
+
| `resolveFilePath(package, node)` | Resolve full file path |
|
|
201
|
+
| `isDocsPackageInstalled(packageName)` | Check if package is installed |
|
|
202
|
+
| `getAllFilePaths(manifest)` | Get all file paths from manifest |
|
|
203
|
+
|
|
204
|
+
#### Frontmatter Utilities
|
|
205
|
+
|
|
206
|
+
| Function | Description |
|
|
207
|
+
| -------------------------------------- | ------------------------------------- |
|
|
208
|
+
| `parseFrontmatter(content, filePath?)` | Parse and validate frontmatter |
|
|
209
|
+
| `validateFrontmatter(data, filePath?)` | Validate frontmatter data |
|
|
210
|
+
| `hasFrontmatter(content)` | Check if content has frontmatter |
|
|
211
|
+
| `extractFrontmatterData(content)` | Extract raw frontmatter (unvalidated) |
|
|
212
|
+
|
|
213
|
+
### Error Classes
|
|
214
|
+
|
|
215
|
+
| Class | Description |
|
|
216
|
+
| ------------------------- | ------------------------------------- |
|
|
217
|
+
| `ManifestValidationError` | Thrown when manifest validation fails |
|
|
218
|
+
| `FrontmatterParseError` | Thrown when frontmatter parsing fails |
|
|
219
|
+
| `DocsPackageLoadError` | Thrown when package loading fails |
|
|
220
|
+
|
|
221
|
+
## Development
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
# Install dependencies
|
|
225
|
+
bun install
|
|
226
|
+
|
|
227
|
+
# Build the package
|
|
228
|
+
bun run build
|
|
229
|
+
|
|
230
|
+
# Run tests
|
|
231
|
+
bun run test
|
|
232
|
+
|
|
233
|
+
# Run tests in watch mode
|
|
234
|
+
bun run test:watch
|
|
235
|
+
|
|
236
|
+
# Type check
|
|
237
|
+
bun run type-check
|
|
238
|
+
|
|
239
|
+
# Lint
|
|
240
|
+
bun run lint
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
## License
|
|
244
|
+
|
|
245
|
+
MIT
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { DocPageMeta } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Result of parsing MDX frontmatter
|
|
4
|
+
*/
|
|
5
|
+
export interface ParsedFrontmatter {
|
|
6
|
+
/** Parsed and validated metadata */
|
|
7
|
+
meta: DocPageMeta;
|
|
8
|
+
/** MDX content without frontmatter */
|
|
9
|
+
content: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Error thrown when frontmatter parsing fails
|
|
13
|
+
*/
|
|
14
|
+
export declare class FrontmatterParseError extends Error {
|
|
15
|
+
readonly filePath?: string;
|
|
16
|
+
readonly originalError?: unknown;
|
|
17
|
+
constructor(message: string, filePath?: string, originalError?: unknown);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Parse MDX content and extract frontmatter
|
|
21
|
+
*
|
|
22
|
+
* @param rawContent - Raw MDX file content including frontmatter
|
|
23
|
+
* @param filePath - Optional file path for error messages
|
|
24
|
+
* @returns Parsed frontmatter and content
|
|
25
|
+
* @throws {FrontmatterParseError} If parsing fails
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* const { meta, content } = parseFrontmatter(`---
|
|
30
|
+
* title: Getting Started
|
|
31
|
+
* description: Learn how to get started with Vendure
|
|
32
|
+
* ---
|
|
33
|
+
*
|
|
34
|
+
* # Getting Started
|
|
35
|
+
*
|
|
36
|
+
* Welcome to Vendure!
|
|
37
|
+
* `)
|
|
38
|
+
*
|
|
39
|
+
* console.log(meta.title) // "Getting Started"
|
|
40
|
+
* console.log(content) // "# Getting Started\n\nWelcome to Vendure!"
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare function parseFrontmatter(rawContent: string, filePath?: string): ParsedFrontmatter;
|
|
44
|
+
/**
|
|
45
|
+
* Validate frontmatter data against the DocPageMeta schema
|
|
46
|
+
*
|
|
47
|
+
* @param data - Raw frontmatter data object
|
|
48
|
+
* @param filePath - Optional file path for error messages
|
|
49
|
+
* @returns Validated DocPageMeta
|
|
50
|
+
* @throws {FrontmatterParseError} If validation fails
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```typescript
|
|
54
|
+
* const meta = validateFrontmatter({
|
|
55
|
+
* title: 'Installation',
|
|
56
|
+
* description: 'How to install Vendure',
|
|
57
|
+
* keywords: ['install', 'setup']
|
|
58
|
+
* })
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export declare function validateFrontmatter(data: unknown, filePath?: string): DocPageMeta;
|
|
62
|
+
/**
|
|
63
|
+
* Check if a string contains frontmatter
|
|
64
|
+
*
|
|
65
|
+
* @param content - String to check
|
|
66
|
+
* @returns True if content starts with frontmatter delimiter
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* hasFrontmatter('---\ntitle: Test\n---\n# Content') // true
|
|
71
|
+
* hasFrontmatter('# Just Content') // false
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
export declare function hasFrontmatter(content: string): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Extract just the frontmatter data without parsing the full content
|
|
77
|
+
* Useful for quick metadata extraction without full parsing overhead
|
|
78
|
+
*
|
|
79
|
+
* @param rawContent - Raw MDX content
|
|
80
|
+
* @returns Raw frontmatter data object (unvalidated)
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```typescript
|
|
84
|
+
* const data = extractFrontmatterData('---\ntitle: Test\n---\n# Content')
|
|
85
|
+
* console.log(data.title) // "Test"
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
export declare function extractFrontmatterData(rawContent: string): Record<string, unknown>;
|
|
89
|
+
//# sourceMappingURL=frontmatter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontmatter.d.ts","sourceRoot":"","sources":["../src/frontmatter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE1C;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,oCAAoC;IACpC,IAAI,EAAE,WAAW,CAAA;IACjB,sCAAsC;IACtC,OAAO,EAAE,MAAM,CAAA;CAChB;AAED;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,SAAgB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjC,SAAgB,aAAa,CAAC,EAAE,OAAO,CAAA;gBAE3B,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,OAAO;CAMxE;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,iBAAiB,CAoBzF;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,WAAW,CAgBjF;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEvD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAGlF"}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./manifest-D2yANQB-.cjs");function i(o){const a=[];return r(o.navigation,a),a}function r(o,a){for(const t of o)t.file&&a.push(t.file),t.children&&r(t.children,a)}exports.BreadcrumbItemSchema=e.BreadcrumbItemSchema;exports.DocPageMetaSchema=e.DocPageMetaSchema;exports.DocPageSchema=e.DocPageSchema;exports.DocsPackageManifestSchema=e.DocsPackageManifestSchema;exports.FlatNavigationNodeSchema=e.FlatNavigationNodeSchema;exports.FrontmatterParseError=e.FrontmatterParseError;exports.GitHubConfigSchema=e.GitHubConfigSchema;exports.LoadedDocsPackageSchema=e.LoadedDocsPackageSchema;exports.ManifestValidationError=e.ManifestValidationError;exports.NavigationNodeSchema=e.NavigationNodeSchema;exports.SearchConfigSchema=e.SearchConfigSchema;exports.VendureVersionSchema=e.VendureVersionSchema;exports.buildBreadcrumbs=e.buildBreadcrumbs;exports.extractFrontmatterData=e.extractFrontmatterData;exports.findNavigationNode=e.findNavigationNode;exports.flattenNavigation=e.flattenNavigation;exports.getLeafNodes=e.getLeafNodes;exports.getNodesAtDepth=e.getNodesAtDepth;exports.getPrevNextNodes=e.getPrevNextNodes;exports.hasFrontmatter=e.hasFrontmatter;exports.isNodeActive=e.isNodeActive;exports.parseFrontmatter=e.parseFrontmatter;exports.validateFrontmatter=e.validateFrontmatter;exports.validateManifest=e.validateManifest;exports.getAllFilePaths=i;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type { BreadcrumbItem, DocPage, DocPageMeta, DocsPackageManifest, FlatNavigationNode, GitHubConfig, LoadedDocsPackage, NavigationNode, SearchConfig, VendureVersion, } from './types';
|
|
2
|
+
export { BreadcrumbItemSchema, DocPageMetaSchema, DocPageSchema, DocsPackageManifestSchema, FlatNavigationNodeSchema, GitHubConfigSchema, LoadedDocsPackageSchema, NavigationNodeSchema, SearchConfigSchema, VendureVersionSchema, } from './schema';
|
|
3
|
+
export { FrontmatterParseError, extractFrontmatterData, hasFrontmatter, parseFrontmatter, validateFrontmatter, } from './frontmatter';
|
|
4
|
+
export type { ParsedFrontmatter } from './frontmatter';
|
|
5
|
+
export { ManifestValidationError, buildBreadcrumbs, findNavigationNode, flattenNavigation, getLeafNodes, getNodesAtDepth, getPrevNextNodes, isNodeActive, validateManifest, } from './manifest';
|
|
6
|
+
export { getAllFilePaths } from './navigation-utils';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EACV,cAAc,EACd,OAAO,EACP,WAAW,EACX,mBAAmB,EACnB,kBAAkB,EAClB,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,YAAY,EACZ,cAAc,GACf,MAAM,SAAS,CAAA;AAGhB,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,aAAa,EACb,yBAAyB,EACzB,wBAAwB,EACxB,kBAAkB,EAClB,uBAAuB,EACvB,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,UAAU,CAAA;AAGjB,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,cAAc,EACd,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,eAAe,CAAA;AACtB,YAAY,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAGtD,OAAO,EACL,uBAAuB,EACvB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,gBAAgB,GACjB,MAAM,YAAY,CAAA;AAGnB,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { B as n, D as c, a as d, b as m, F as h, c as f, G as l, L as g, M as N, N as S, S as v, V as u, d as F, e as P, f as D, g as p, i as b, j as M, k as x, h as V, l as k, p as A, v as B, m as L } from "./manifest-B1CxKK1i.js";
|
|
2
|
+
function o(t) {
|
|
3
|
+
const a = [];
|
|
4
|
+
return s(t.navigation, a), a;
|
|
5
|
+
}
|
|
6
|
+
function s(t, a) {
|
|
7
|
+
for (const e of t)
|
|
8
|
+
e.file && a.push(e.file), e.children && s(e.children, a);
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
n as BreadcrumbItemSchema,
|
|
12
|
+
c as DocPageMetaSchema,
|
|
13
|
+
d as DocPageSchema,
|
|
14
|
+
m as DocsPackageManifestSchema,
|
|
15
|
+
h as FlatNavigationNodeSchema,
|
|
16
|
+
f as FrontmatterParseError,
|
|
17
|
+
l as GitHubConfigSchema,
|
|
18
|
+
g as LoadedDocsPackageSchema,
|
|
19
|
+
N as ManifestValidationError,
|
|
20
|
+
S as NavigationNodeSchema,
|
|
21
|
+
v as SearchConfigSchema,
|
|
22
|
+
u as VendureVersionSchema,
|
|
23
|
+
F as buildBreadcrumbs,
|
|
24
|
+
P as extractFrontmatterData,
|
|
25
|
+
D as findNavigationNode,
|
|
26
|
+
p as flattenNavigation,
|
|
27
|
+
o as getAllFilePaths,
|
|
28
|
+
b as getLeafNodes,
|
|
29
|
+
M as getNodesAtDepth,
|
|
30
|
+
x as getPrevNextNodes,
|
|
31
|
+
V as hasFrontmatter,
|
|
32
|
+
k as isNodeActive,
|
|
33
|
+
A as parseFrontmatter,
|
|
34
|
+
B as validateFrontmatter,
|
|
35
|
+
L as validateManifest
|
|
36
|
+
};
|
package/dist/loader.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var g=Object.defineProperty;var h=(e,r,t)=>r in e?g(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var i=(e,r,t)=>h(e,typeof r!="symbol"?r+"":r,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("fs/promises"),m=require("module"),u=require("./manifest-D2yANQB-.cjs");var c=typeof document<"u"?document.currentScript:null;class a extends Error{constructor(t,n){super(t);i(this,"packageName");this.name="DocsPackageLoadError",this.packageName=n}}async function p(e,r={}){try{const t=r.resolver?await r.resolver(e):l(e),n=await import(e);if(!n.manifest)throw new a(`Package "${e}" does not export a manifest`,e);return{manifest:u.validateManifest(n.manifest),basePath:t}}catch(t){throw t instanceof a?t:new a(`Failed to load docs package "${e}": ${t instanceof Error?t.message:String(t)}`,e)}}function l(e){try{return m.createRequire(typeof document>"u"?require("url").pathToFileURL(__filename).href:c&&c.tagName.toUpperCase()==="SCRIPT"&&c.src||new URL("loader.cjs",document.baseURI).href).resolve(`${e}/package.json`).replace(/\/package\.json$/,"")}catch{throw new a(`Cannot resolve package "${e}". Make sure it is installed.`,e)}}async function d(e,r){try{const t=`${e.basePath}/${r}`,n=await P.readFile(t,"utf-8"),{meta:o,content:s}=u.parseFrontmatter(n,r);return{meta:o,content:s,filePath:r}}catch(t){throw new a(`Failed to load doc page "${r}": ${t instanceof Error?t.message:String(t)}`,e.manifest.id)}}async function $(e,r){const t=f(e.manifest.navigation,r.split("/"));if(t!=null&&t.file)return d(e,t.file)}function f(e,r){if(r.length===0)return;const[t,...n]=r,o=e.find(s=>s.slug===t);if(o){if(n.length===0)return o;if(o.children)return f(o.children,n)}}function v(e,r){if(r.file)return`${e.basePath}/${r.file}`}function y(e){try{return l(e),!0}catch{return!1}}exports.DocsPackageLoadError=a;exports.isDocsPackageInstalled=y;exports.loadDocPage=d;exports.loadDocPageBySlug=$;exports.loadDocsPackage=p;exports.resolveFilePath=v;
|
package/dist/loader.d.ts
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { DocPage, LoadedDocsPackage, NavigationNode } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Error thrown when loading a docs package fails
|
|
4
|
+
*/
|
|
5
|
+
export declare class DocsPackageLoadError extends Error {
|
|
6
|
+
readonly packageName?: string;
|
|
7
|
+
constructor(message: string, packageName?: string);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Options for loading a docs package
|
|
11
|
+
*/
|
|
12
|
+
export interface LoadDocsPackageOptions {
|
|
13
|
+
/**
|
|
14
|
+
* Custom resolver for the package path
|
|
15
|
+
* Useful for testing or custom package locations
|
|
16
|
+
*/
|
|
17
|
+
resolver?: (packageName: string) => Promise<string>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Load and validate a docs package manifest from an npm package
|
|
21
|
+
*
|
|
22
|
+
* This function resolves the package location and loads its manifest.
|
|
23
|
+
* The manifest is validated against the DocsPackageManifest schema.
|
|
24
|
+
*
|
|
25
|
+
* @param packageName - Name of the npm package (e.g., "@vendure/docs-core")
|
|
26
|
+
* @param options - Optional loading options
|
|
27
|
+
* @returns Loaded and validated docs package with manifest and base path
|
|
28
|
+
* @throws {DocsPackageLoadError} If the package cannot be loaded or validated
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* const { manifest, basePath } = await loadDocsPackage('@vendure/docs-core')
|
|
33
|
+
* console.log(manifest.name) // "Vendure Core"
|
|
34
|
+
* console.log(basePath) // "/path/to/node_modules/@vendure/docs-core"
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare function loadDocsPackage(packageName: string, options?: LoadDocsPackageOptions): Promise<LoadedDocsPackage>;
|
|
38
|
+
/**
|
|
39
|
+
* Load a documentation page from a docs package
|
|
40
|
+
*
|
|
41
|
+
* @param loadedPackage - The loaded docs package
|
|
42
|
+
* @param filePath - Path to the MDX file relative to package root
|
|
43
|
+
* @returns Loaded and parsed documentation page
|
|
44
|
+
* @throws {DocsPackageLoadError} If the page cannot be loaded
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* const package = await loadDocsPackage('@vendure/docs-core')
|
|
49
|
+
* const page = await loadDocPage(package, 'docs/getting-started/installation.mdx')
|
|
50
|
+
* console.log(page.meta.title) // "Installation"
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare function loadDocPage(loadedPackage: LoadedDocsPackage, filePath: string): Promise<DocPage>;
|
|
54
|
+
/**
|
|
55
|
+
* Load a documentation page by its slug path
|
|
56
|
+
*
|
|
57
|
+
* @param loadedPackage - The loaded docs package
|
|
58
|
+
* @param slugPath - Slug path (e.g., "getting-started/installation")
|
|
59
|
+
* @returns Loaded documentation page or undefined if not found
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```typescript
|
|
63
|
+
* const package = await loadDocsPackage('@vendure/docs-core')
|
|
64
|
+
* const page = await loadDocPageBySlug(package, 'getting-started/installation')
|
|
65
|
+
* if (page) {
|
|
66
|
+
* console.log(page.meta.title)
|
|
67
|
+
* }
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export declare function loadDocPageBySlug(loadedPackage: LoadedDocsPackage, slugPath: string): Promise<DocPage | undefined>;
|
|
71
|
+
/**
|
|
72
|
+
* Resolve the full file path for a navigation node
|
|
73
|
+
*
|
|
74
|
+
* @param loadedPackage - The loaded docs package
|
|
75
|
+
* @param node - Navigation node with a file path
|
|
76
|
+
* @returns Full resolved file path
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```typescript
|
|
80
|
+
* const fullPath = resolveFilePath(package, node)
|
|
81
|
+
* // "/path/to/node_modules/@vendure/docs-core/docs/getting-started/installation.mdx"
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
export declare function resolveFilePath(loadedPackage: LoadedDocsPackage, node: NavigationNode): string | undefined;
|
|
85
|
+
/**
|
|
86
|
+
* Check if a docs package is installed and loadable
|
|
87
|
+
*
|
|
88
|
+
* @param packageName - Name of the npm package
|
|
89
|
+
* @returns True if the package can be loaded
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```typescript
|
|
93
|
+
* if (await isDocsPackageInstalled('@vendure/docs-enterprise')) {
|
|
94
|
+
* const enterprise = await loadDocsPackage('@vendure/docs-enterprise')
|
|
95
|
+
* }
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
export declare function isDocsPackageInstalled(packageName: string): boolean;
|
|
99
|
+
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAEzE;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,SAAgB,WAAW,CAAC,EAAE,MAAM,CAAA;gBAExB,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM;CAKlD;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;CACpD;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,eAAe,CACnC,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,iBAAiB,CAAC,CAiC5B;AAqBD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,WAAW,CAC/B,aAAa,EAAE,iBAAiB,EAChC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,OAAO,CAAC,CAiBlB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,iBAAiB,CACrC,aAAa,EAAE,iBAAiB,EAChC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,CAQ9B;AAqBD;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAC7B,aAAa,EAAE,iBAAiB,EAChC,IAAI,EAAE,cAAc,GACnB,MAAM,GAAG,SAAS,CAGpB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAOnE"}
|
package/dist/loader.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
var f = Object.defineProperty;
|
|
2
|
+
var l = (t, e, r) => e in t ? f(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
|
|
3
|
+
var i = (t, e, r) => l(t, typeof e != "symbol" ? e + "" : e, r);
|
|
4
|
+
import { readFile as d } from "fs/promises";
|
|
5
|
+
import { createRequire as h } from "module";
|
|
6
|
+
import { m as g, p as m } from "./manifest-B1CxKK1i.js";
|
|
7
|
+
class a extends Error {
|
|
8
|
+
constructor(r, n) {
|
|
9
|
+
super(r);
|
|
10
|
+
i(this, "packageName");
|
|
11
|
+
this.name = "DocsPackageLoadError", this.packageName = n;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
async function y(t, e = {}) {
|
|
15
|
+
try {
|
|
16
|
+
const r = e.resolver ? await e.resolver(t) : c(t), n = await import(t);
|
|
17
|
+
if (!n.manifest)
|
|
18
|
+
throw new a(
|
|
19
|
+
`Package "${t}" does not export a manifest`,
|
|
20
|
+
t
|
|
21
|
+
);
|
|
22
|
+
return {
|
|
23
|
+
manifest: g(n.manifest),
|
|
24
|
+
basePath: r
|
|
25
|
+
};
|
|
26
|
+
} catch (r) {
|
|
27
|
+
throw r instanceof a ? r : new a(
|
|
28
|
+
`Failed to load docs package "${t}": ${r instanceof Error ? r.message : String(r)}`,
|
|
29
|
+
t
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function c(t) {
|
|
34
|
+
try {
|
|
35
|
+
return h(import.meta.url).resolve(`${t}/package.json`).replace(/\/package\.json$/, "");
|
|
36
|
+
} catch {
|
|
37
|
+
throw new a(
|
|
38
|
+
`Cannot resolve package "${t}". Make sure it is installed.`,
|
|
39
|
+
t
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
async function p(t, e) {
|
|
44
|
+
try {
|
|
45
|
+
const r = `${t.basePath}/${e}`, n = await d(r, "utf-8"), { meta: o, content: s } = m(n, e);
|
|
46
|
+
return {
|
|
47
|
+
meta: o,
|
|
48
|
+
content: s,
|
|
49
|
+
filePath: e
|
|
50
|
+
};
|
|
51
|
+
} catch (r) {
|
|
52
|
+
throw new a(
|
|
53
|
+
`Failed to load doc page "${e}": ${r instanceof Error ? r.message : String(r)}`,
|
|
54
|
+
t.manifest.id
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
async function k(t, e) {
|
|
59
|
+
const r = u(t.manifest.navigation, e.split("/"));
|
|
60
|
+
if (r != null && r.file)
|
|
61
|
+
return p(t, r.file);
|
|
62
|
+
}
|
|
63
|
+
function u(t, e) {
|
|
64
|
+
if (e.length === 0) return;
|
|
65
|
+
const [r, ...n] = e, o = t.find((s) => s.slug === r);
|
|
66
|
+
if (o) {
|
|
67
|
+
if (n.length === 0) return o;
|
|
68
|
+
if (o.children)
|
|
69
|
+
return u(o.children, n);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function D(t, e) {
|
|
73
|
+
if (e.file)
|
|
74
|
+
return `${t.basePath}/${e.file}`;
|
|
75
|
+
}
|
|
76
|
+
function E(t) {
|
|
77
|
+
try {
|
|
78
|
+
return c(t), !0;
|
|
79
|
+
} catch {
|
|
80
|
+
return !1;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
export {
|
|
84
|
+
a as DocsPackageLoadError,
|
|
85
|
+
E as isDocsPackageInstalled,
|
|
86
|
+
p as loadDocPage,
|
|
87
|
+
k as loadDocPageBySlug,
|
|
88
|
+
y as loadDocsPackage,
|
|
89
|
+
D as resolveFilePath
|
|
90
|
+
};
|