@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.
@@ -0,0 +1,207 @@
1
+ var N = Object.defineProperty;
2
+ var S = (r, e, n) => e in r ? N(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n;
3
+ var l = (r, e, n) => S(r, typeof e != "symbol" ? e + "" : e, n);
4
+ import g from "gray-matter";
5
+ import { z as t } from "zod";
6
+ const P = t.enum(["v1", "v2", "v3"]), j = t.object({
7
+ indexFields: t.array(t.enum(["title", "description", "content", "keywords"])),
8
+ boosts: t.record(t.string(), t.number()).optional()
9
+ }), $ = t.object({
10
+ repository: t.string().regex(/^[^/]+\/[^/]+$/, 'Repository must be in format "owner/repo"'),
11
+ branch: t.string().optional(),
12
+ docsPath: t.string().optional()
13
+ }), u = t.lazy(
14
+ () => t.object({
15
+ title: t.string().min(1, "Navigation title is required"),
16
+ slug: t.string().min(1, "Navigation slug is required"),
17
+ file: t.string().optional(),
18
+ children: t.array(u).optional(),
19
+ badge: t.string().optional()
20
+ })
21
+ ), f = t.object({
22
+ id: t.string().min(1, "Package ID is required"),
23
+ name: t.string().min(1, "Package name is required"),
24
+ version: t.string().regex(/^\d+\.\d+\.\d+/, "Version must be valid semver"),
25
+ vendureVersion: P,
26
+ navigation: t.array(u),
27
+ search: j.optional(),
28
+ github: $.optional()
29
+ }), m = t.object({
30
+ title: t.string().min(1, "Page title is required"),
31
+ description: t.string().optional(),
32
+ keywords: t.array(t.string()).optional(),
33
+ sidebarLabel: t.string().optional(),
34
+ hidden: t.boolean().optional()
35
+ }), M = t.object({
36
+ meta: m,
37
+ content: t.string(),
38
+ filePath: t.string()
39
+ }), B = t.object({
40
+ manifest: f,
41
+ basePath: t.string()
42
+ }), V = t.object({
43
+ title: t.string(),
44
+ slug: t.string(),
45
+ path: t.string()
46
+ }), I = t.object({
47
+ title: t.string(),
48
+ slug: t.string(),
49
+ file: t.string().optional(),
50
+ children: t.array(t.lazy(() => u)).optional(),
51
+ badge: t.string().optional(),
52
+ path: t.string(),
53
+ depth: t.number().int().min(0),
54
+ parentPath: t.string().optional()
55
+ });
56
+ class d extends Error {
57
+ constructor(n, i, a) {
58
+ super(n);
59
+ l(this, "filePath");
60
+ l(this, "originalError");
61
+ this.name = "FrontmatterParseError", this.filePath = i, this.originalError = a;
62
+ }
63
+ }
64
+ function q(r, e) {
65
+ try {
66
+ const { data: n, content: i } = g(r);
67
+ return {
68
+ meta: y(n, e),
69
+ content: i.trim()
70
+ };
71
+ } catch (n) {
72
+ throw n instanceof d ? n : new d(
73
+ `Failed to parse frontmatter${e ? ` in ${e}` : ""}`,
74
+ e,
75
+ n
76
+ );
77
+ }
78
+ }
79
+ function y(r, e) {
80
+ const n = m.safeParse(r);
81
+ if (!n.success) {
82
+ const i = n.error.issues.map((a) => ` - ${a.path.join(".")}: ${a.message}`).join(`
83
+ `);
84
+ throw new d(
85
+ `Invalid frontmatter${e ? ` in ${e}` : ""}:
86
+ ${i}`,
87
+ e,
88
+ n.error
89
+ );
90
+ }
91
+ return n.data;
92
+ }
93
+ function L(r) {
94
+ return r.trimStart().startsWith("---");
95
+ }
96
+ function z(r) {
97
+ const { data: e } = g(r);
98
+ return e;
99
+ }
100
+ class x extends Error {
101
+ constructor(n, i) {
102
+ super(n);
103
+ l(this, "issues");
104
+ this.name = "ManifestValidationError", this.issues = i;
105
+ }
106
+ }
107
+ function A(r) {
108
+ const e = f.safeParse(r);
109
+ if (!e.success) {
110
+ const n = e.error.issues.map((i) => `${i.path.join(".")}: ${i.message}`);
111
+ throw new x("Invalid manifest", n);
112
+ }
113
+ return e.data;
114
+ }
115
+ function C(r, e) {
116
+ const n = e.split("/").filter(Boolean);
117
+ return h(r.navigation, n);
118
+ }
119
+ function h(r, e) {
120
+ if (e.length === 0) return;
121
+ const [n, ...i] = e, a = r.find((s) => s.slug === n);
122
+ if (a) {
123
+ if (i.length === 0) return a;
124
+ if (a.children)
125
+ return h(a.children, i);
126
+ }
127
+ }
128
+ function p(r) {
129
+ const e = [];
130
+ return v(r.navigation, "", 0, void 0, e), e;
131
+ }
132
+ function v(r, e, n, i, a) {
133
+ for (const s of r) {
134
+ const o = e ? `${e}/${s.slug}` : s.slug;
135
+ a.push({
136
+ ...s,
137
+ path: o,
138
+ depth: n,
139
+ parentPath: i
140
+ }), s.children && s.children.length > 0 && v(s.children, o, n + 1, o, a);
141
+ }
142
+ }
143
+ function G(r, e) {
144
+ const n = e.split("/").filter(Boolean), i = [];
145
+ let a = r.navigation, s = "";
146
+ for (const o of n) {
147
+ const c = a.find((b) => b.slug === o);
148
+ if (!c) break;
149
+ s = s ? `${s}/${o}` : o, i.push({
150
+ title: c.title,
151
+ slug: c.slug,
152
+ path: s
153
+ }), a = c.children ?? [];
154
+ }
155
+ return i;
156
+ }
157
+ function w(r) {
158
+ return p(r).filter((e) => e.file !== void 0);
159
+ }
160
+ function H(r, e) {
161
+ const n = w(r), i = n.findIndex((a) => a.path === e);
162
+ return i === -1 ? {} : {
163
+ prev: i > 0 ? n[i - 1] : void 0,
164
+ next: i < n.length - 1 ? n[i + 1] : void 0
165
+ };
166
+ }
167
+ function F(r, e) {
168
+ const n = e.split("/").filter(Boolean);
169
+ if (n.length === 0) return !1;
170
+ if (r.slug === n[0]) {
171
+ if (n.length === 1) return !0;
172
+ if (r.children) {
173
+ const i = n.slice(1).join("/");
174
+ return r.children.some((a) => F(a, i));
175
+ }
176
+ }
177
+ return !1;
178
+ }
179
+ function R(r, e) {
180
+ return p(r).filter((n) => n.depth === e);
181
+ }
182
+ export {
183
+ V as B,
184
+ m as D,
185
+ I as F,
186
+ $ as G,
187
+ B as L,
188
+ x as M,
189
+ u as N,
190
+ j as S,
191
+ P as V,
192
+ M as a,
193
+ f as b,
194
+ d as c,
195
+ G as d,
196
+ z as e,
197
+ C as f,
198
+ p as g,
199
+ L as h,
200
+ w as i,
201
+ R as j,
202
+ H as k,
203
+ F as l,
204
+ A as m,
205
+ q as p,
206
+ y as v
207
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";var y=Object.defineProperty;var D=(r,e,n)=>e in r?y(r,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[e]=n;var d=(r,e,n)=>D(r,typeof e!="symbol"?e+"":e,n);const h=require("gray-matter"),t=require("zod"),z=t.z.enum(["v1","v2","v3"]),p=t.z.object({indexFields:t.z.array(t.z.enum(["title","description","content","keywords"])),boosts:t.z.record(t.z.string(),t.z.number()).optional()}),v=t.z.object({repository:t.z.string().regex(/^[^/]+\/[^/]+$/,'Repository must be in format "owner/repo"'),branch:t.z.string().optional(),docsPath:t.z.string().optional()}),g=t.z.lazy(()=>t.z.object({title:t.z.string().min(1,"Navigation title is required"),slug:t.z.string().min(1,"Navigation slug is required"),file:t.z.string().optional(),children:t.z.array(g).optional(),badge:t.z.string().optional()})),u=t.z.object({id:t.z.string().min(1,"Package ID is required"),name:t.z.string().min(1,"Package name is required"),version:t.z.string().regex(/^\d+\.\d+\.\d+/,"Version must be valid semver"),vendureVersion:z,navigation:t.z.array(g),search:p.optional(),github:v.optional()}),m=t.z.object({title:t.z.string().min(1,"Page title is required"),description:t.z.string().optional(),keywords:t.z.array(t.z.string()).optional(),sidebarLabel:t.z.string().optional(),hidden:t.z.boolean().optional()}),x=t.z.object({meta:m,content:t.z.string(),filePath:t.z.string()}),M=t.z.object({manifest:u,basePath:t.z.string()}),w=t.z.object({title:t.z.string(),slug:t.z.string(),path:t.z.string()}),E=t.z.object({title:t.z.string(),slug:t.z.string(),file:t.z.string().optional(),children:t.z.array(t.z.lazy(()=>g)).optional(),badge:t.z.string().optional(),path:t.z.string(),depth:t.z.number().int().min(0),parentPath:t.z.string().optional()});class l extends Error{constructor(n,i,a){super(n);d(this,"filePath");d(this,"originalError");this.name="FrontmatterParseError",this.filePath=i,this.originalError=a}}function k(r,e){try{const{data:n,content:i}=h(r);return{meta:b(n,e),content:i.trim()}}catch(n){throw n instanceof l?n:new l(`Failed to parse frontmatter${e?` in ${e}`:""}`,e,n)}}function b(r,e){const n=m.safeParse(r);if(!n.success){const i=n.error.issues.map(a=>` - ${a.path.join(".")}: ${a.message}`).join(`
2
+ `);throw new l(`Invalid frontmatter${e?` in ${e}`:""}:
3
+ ${i}`,e,n.error)}return n.data}function V(r){return r.trimStart().startsWith("---")}function B(r){const{data:e}=h(r);return e}class N extends Error{constructor(n,i){super(n);d(this,"issues");this.name="ManifestValidationError",this.issues=i}}function q(r){const e=u.safeParse(r);if(!e.success){const n=e.error.issues.map(i=>`${i.path.join(".")}: ${i.message}`);throw new N("Invalid manifest",n)}return e.data}function I(r,e){const n=e.split("/").filter(Boolean);return S(r.navigation,n)}function S(r,e){if(e.length===0)return;const[n,...i]=e,a=r.find(o=>o.slug===n);if(a){if(i.length===0)return a;if(a.children)return S(a.children,i)}}function f(r){const e=[];return P(r.navigation,"",0,void 0,e),e}function P(r,e,n,i,a){for(const o of r){const s=e?`${e}/${o.slug}`:o.slug;a.push({...o,path:s,depth:n,parentPath:i}),o.children&&o.children.length>0&&P(o.children,s,n+1,s,a)}}function L(r,e){const n=e.split("/").filter(Boolean),i=[];let a=r.navigation,o="";for(const s of n){const c=a.find(j=>j.slug===s);if(!c)break;o=o?`${o}/${s}`:s,i.push({title:c.title,slug:c.slug,path:o}),a=c.children??[]}return i}function F(r){return f(r).filter(e=>e.file!==void 0)}function A(r,e){const n=F(r),i=n.findIndex(a=>a.path===e);return i===-1?{}:{prev:i>0?n[i-1]:void 0,next:i<n.length-1?n[i+1]:void 0}}function $(r,e){const n=e.split("/").filter(Boolean);if(n.length===0)return!1;if(r.slug===n[0]){if(n.length===1)return!0;if(r.children){const i=n.slice(1).join("/");return r.children.some(a=>$(a,i))}}return!1}function C(r,e){return f(r).filter(n=>n.depth===e)}exports.BreadcrumbItemSchema=w;exports.DocPageMetaSchema=m;exports.DocPageSchema=x;exports.DocsPackageManifestSchema=u;exports.FlatNavigationNodeSchema=E;exports.FrontmatterParseError=l;exports.GitHubConfigSchema=v;exports.LoadedDocsPackageSchema=M;exports.ManifestValidationError=N;exports.NavigationNodeSchema=g;exports.SearchConfigSchema=p;exports.VendureVersionSchema=z;exports.buildBreadcrumbs=L;exports.extractFrontmatterData=B;exports.findNavigationNode=I;exports.flattenNavigation=f;exports.getLeafNodes=F;exports.getNodesAtDepth=C;exports.getPrevNextNodes=A;exports.hasFrontmatter=V;exports.isNodeActive=$;exports.parseFrontmatter=k;exports.validateFrontmatter=b;exports.validateManifest=q;
@@ -0,0 +1,127 @@
1
+ import { BreadcrumbItem, DocsPackageManifest, FlatNavigationNode, NavigationNode } from './types';
2
+ /**
3
+ * Error thrown when manifest validation fails
4
+ */
5
+ export declare class ManifestValidationError extends Error {
6
+ readonly issues: string[];
7
+ constructor(message: string, issues: string[]);
8
+ }
9
+ /**
10
+ * Validate a manifest against the DocsPackageManifest schema
11
+ *
12
+ * @param manifest - Raw manifest data to validate
13
+ * @returns Validated DocsPackageManifest
14
+ * @throws {ManifestValidationError} If validation fails
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * const manifest = validateManifest({
19
+ * id: 'core',
20
+ * name: 'Vendure Core',
21
+ * version: '3.0.0',
22
+ * vendureVersion: 'v3',
23
+ * navigation: [...]
24
+ * })
25
+ * ```
26
+ */
27
+ export declare function validateManifest(manifest: unknown): DocsPackageManifest;
28
+ /**
29
+ * Find a navigation node by its slug path
30
+ *
31
+ * @param manifest - The docs package manifest
32
+ * @param slugPath - Slash-separated path (e.g., "getting-started/installation")
33
+ * @returns The found navigation node or undefined
34
+ *
35
+ * @example
36
+ * ```typescript
37
+ * const node = findNavigationNode(manifest, 'getting-started/installation')
38
+ * if (node) {
39
+ * console.log(node.title) // "Installation"
40
+ * }
41
+ * ```
42
+ */
43
+ export declare function findNavigationNode(manifest: DocsPackageManifest, slugPath: string): NavigationNode | undefined;
44
+ /**
45
+ * Flatten the navigation tree into a flat array with path information
46
+ *
47
+ * @param manifest - The docs package manifest
48
+ * @returns Array of flattened navigation nodes with full paths
49
+ *
50
+ * @example
51
+ * ```typescript
52
+ * const flatNodes = flattenNavigation(manifest)
53
+ * flatNodes.forEach(node => {
54
+ * console.log(`${node.path}: ${node.title}`)
55
+ * })
56
+ * ```
57
+ */
58
+ export declare function flattenNavigation(manifest: DocsPackageManifest): FlatNavigationNode[];
59
+ /**
60
+ * Build breadcrumb trail for a given slug path
61
+ *
62
+ * @param manifest - The docs package manifest
63
+ * @param slugPath - Slash-separated path (e.g., "getting-started/installation")
64
+ * @returns Array of breadcrumb items from root to current
65
+ *
66
+ * @example
67
+ * ```typescript
68
+ * const breadcrumbs = buildBreadcrumbs(manifest, 'getting-started/installation')
69
+ * // [
70
+ * // { title: 'Getting Started', slug: 'getting-started', path: 'getting-started' },
71
+ * // { title: 'Installation', slug: 'installation', path: 'getting-started/installation' }
72
+ * // ]
73
+ * ```
74
+ */
75
+ export declare function buildBreadcrumbs(manifest: DocsPackageManifest, slugPath: string): BreadcrumbItem[];
76
+ /**
77
+ * Get all leaf nodes (pages with files) from the navigation tree
78
+ *
79
+ * @param manifest - The docs package manifest
80
+ * @returns Array of navigation nodes that have file paths
81
+ *
82
+ * @example
83
+ * ```typescript
84
+ * const pages = getLeafNodes(manifest)
85
+ * pages.forEach(page => {
86
+ * console.log(`${page.title}: ${page.file}`)
87
+ * })
88
+ * ```
89
+ */
90
+ export declare function getLeafNodes(manifest: DocsPackageManifest): FlatNavigationNode[];
91
+ /**
92
+ * Get the previous and next navigation nodes relative to a given path
93
+ * Useful for prev/next navigation at the bottom of docs pages
94
+ *
95
+ * @param manifest - The docs package manifest
96
+ * @param slugPath - Current page's slug path
97
+ * @returns Object with prev and next nodes (either may be undefined)
98
+ *
99
+ * @example
100
+ * ```typescript
101
+ * const { prev, next } = getPrevNextNodes(manifest, 'getting-started/installation')
102
+ * if (prev) console.log('Previous:', prev.title)
103
+ * if (next) console.log('Next:', next.title)
104
+ * ```
105
+ */
106
+ export declare function getPrevNextNodes(manifest: DocsPackageManifest, slugPath: string): {
107
+ prev?: FlatNavigationNode;
108
+ next?: FlatNavigationNode;
109
+ };
110
+ /**
111
+ * Check if a navigation node or any of its children matches a path
112
+ * Useful for determining if a nav section should be expanded
113
+ *
114
+ * @param node - Navigation node to check
115
+ * @param currentPath - Current page path
116
+ * @returns True if node or any descendant matches the path
117
+ */
118
+ export declare function isNodeActive(node: NavigationNode, currentPath: string): boolean;
119
+ /**
120
+ * Get all navigation nodes at a specific depth level
121
+ *
122
+ * @param manifest - The docs package manifest
123
+ * @param depth - Depth level (0 = root level)
124
+ * @returns Array of nodes at the specified depth
125
+ */
126
+ export declare function getNodesAtDepth(manifest: DocsPackageManifest, depth: number): FlatNavigationNode[];
127
+ //# sourceMappingURL=manifest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACf,MAAM,SAAS,CAAA;AAEhB;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,KAAK;IAChD,SAAgB,MAAM,EAAE,MAAM,EAAE,CAAA;gBAEpB,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE;CAK9C;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,OAAO,GAAG,mBAAmB,CAWvE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,mBAAmB,EAC7B,QAAQ,EAAE,MAAM,GACf,cAAc,GAAG,SAAS,CAG5B;AAqBD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,mBAAmB,GAAG,kBAAkB,EAAE,CAIrF;AA4BD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,mBAAmB,EAC7B,QAAQ,EAAE,MAAM,GACf,cAAc,EAAE,CAqBlB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,mBAAmB,GAAG,kBAAkB,EAAE,CAEhF;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,mBAAmB,EAC7B,QAAQ,EAAE,MAAM,GACf;IAAE,IAAI,CAAC,EAAE,kBAAkB,CAAC;IAAC,IAAI,CAAC,EAAE,kBAAkB,CAAA;CAAE,CAY1D;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAc/E;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,mBAAmB,EAC7B,KAAK,EAAE,MAAM,GACZ,kBAAkB,EAAE,CAEtB"}
@@ -0,0 +1,15 @@
1
+ import { DocsPackageManifest } from './types';
2
+ /**
3
+ * Get all file paths from a manifest's navigation tree
4
+ *
5
+ * @param manifest - The docs package manifest
6
+ * @returns Array of all file paths in the navigation
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * const files = getAllFilePaths(manifest)
11
+ * // ['docs/getting-started/installation.mdx', 'docs/getting-started/configuration.mdx', ...]
12
+ * ```
13
+ */
14
+ export declare function getAllFilePaths(manifest: DocsPackageManifest): string[];
15
+ //# sourceMappingURL=navigation-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigation-utils.d.ts","sourceRoot":"","sources":["../src/navigation-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAkB,MAAM,SAAS,CAAA;AAElE;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,mBAAmB,GAAG,MAAM,EAAE,CAIvE"}