@vendure-io/docs-provider 0.3.0 → 0.5.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.
@@ -1,208 +0,0 @@
1
- var N = Object.defineProperty;
2
- var P = (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) => P(r, typeof e != "symbol" ? e + "" : e, n);
4
- import u from "gray-matter";
5
- import { z as t } from "zod";
6
- const S = 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
- }), g = 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(g).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: S,
26
- navigation: t.array(g),
27
- search: j.optional(),
28
- github: $.optional(),
29
- basePath: t.string().optional()
30
- }), m = t.object({
31
- title: t.string().min(1, "Page title is required"),
32
- description: t.string().optional(),
33
- keywords: t.array(t.string()).optional(),
34
- sidebarLabel: t.string().optional(),
35
- hidden: t.boolean().optional()
36
- }), M = t.object({
37
- meta: m,
38
- content: t.string(),
39
- filePath: t.string()
40
- }), B = t.object({
41
- manifest: f,
42
- basePath: t.string()
43
- }), V = t.object({
44
- title: t.string(),
45
- slug: t.string(),
46
- path: t.string()
47
- }), I = t.object({
48
- title: t.string(),
49
- slug: t.string(),
50
- file: t.string().optional(),
51
- children: t.array(t.lazy(() => g)).optional(),
52
- badge: t.string().optional(),
53
- path: t.string(),
54
- depth: t.number().int().min(0),
55
- parentPath: t.string().optional()
56
- });
57
- class d extends Error {
58
- constructor(n, i, a) {
59
- super(n);
60
- l(this, "filePath");
61
- l(this, "originalError");
62
- this.name = "FrontmatterParseError", this.filePath = i, this.originalError = a;
63
- }
64
- }
65
- function q(r, e) {
66
- try {
67
- const { data: n, content: i } = u(r);
68
- return {
69
- meta: y(n, e),
70
- content: i.trim()
71
- };
72
- } catch (n) {
73
- throw n instanceof d ? n : new d(
74
- `Failed to parse frontmatter${e ? ` in ${e}` : ""}`,
75
- e,
76
- n
77
- );
78
- }
79
- }
80
- function y(r, e) {
81
- const n = m.safeParse(r);
82
- if (!n.success) {
83
- const i = n.error.issues.map((a) => ` - ${a.path.join(".")}: ${a.message}`).join(`
84
- `);
85
- throw new d(
86
- `Invalid frontmatter${e ? ` in ${e}` : ""}:
87
- ${i}`,
88
- e,
89
- n.error
90
- );
91
- }
92
- return n.data;
93
- }
94
- function L(r) {
95
- return r.trimStart().startsWith("---");
96
- }
97
- function z(r) {
98
- const { data: e } = u(r);
99
- return e;
100
- }
101
- class x extends Error {
102
- constructor(n, i) {
103
- super(n);
104
- l(this, "issues");
105
- this.name = "ManifestValidationError", this.issues = i;
106
- }
107
- }
108
- function A(r) {
109
- const e = f.safeParse(r);
110
- if (!e.success) {
111
- const n = e.error.issues.map((i) => `${i.path.join(".")}: ${i.message}`);
112
- throw new x("Invalid manifest", n);
113
- }
114
- return e.data;
115
- }
116
- function C(r, e) {
117
- const n = e.split("/").filter(Boolean);
118
- return h(r.navigation, n);
119
- }
120
- function h(r, e) {
121
- if (e.length === 0) return;
122
- const [n, ...i] = e, a = r.find((s) => s.slug === n);
123
- if (a) {
124
- if (i.length === 0) return a;
125
- if (a.children)
126
- return h(a.children, i);
127
- }
128
- }
129
- function p(r) {
130
- const e = [];
131
- return v(r.navigation, "", 0, void 0, e), e;
132
- }
133
- function v(r, e, n, i, a) {
134
- for (const s of r) {
135
- const o = e ? `${e}/${s.slug}` : s.slug;
136
- a.push({
137
- ...s,
138
- path: o,
139
- depth: n,
140
- parentPath: i
141
- }), s.children && s.children.length > 0 && v(s.children, o, n + 1, o, a);
142
- }
143
- }
144
- function G(r, e) {
145
- const n = e.split("/").filter(Boolean), i = [];
146
- let a = r.navigation, s = "";
147
- for (const o of n) {
148
- const c = a.find((b) => b.slug === o);
149
- if (!c) break;
150
- s = s ? `${s}/${o}` : o, i.push({
151
- title: c.title,
152
- slug: c.slug,
153
- path: s
154
- }), a = c.children ?? [];
155
- }
156
- return i;
157
- }
158
- function w(r) {
159
- return p(r).filter((e) => e.file !== void 0);
160
- }
161
- function H(r, e) {
162
- const n = w(r), i = n.findIndex((a) => a.path === e);
163
- return i === -1 ? {} : {
164
- prev: i > 0 ? n[i - 1] : void 0,
165
- next: i < n.length - 1 ? n[i + 1] : void 0
166
- };
167
- }
168
- function F(r, e) {
169
- const n = e.split("/").filter(Boolean);
170
- if (n.length === 0) return !1;
171
- if (r.slug === n[0]) {
172
- if (n.length === 1) return !0;
173
- if (r.children) {
174
- const i = n.slice(1).join("/");
175
- return r.children.some((a) => F(a, i));
176
- }
177
- }
178
- return !1;
179
- }
180
- function R(r, e) {
181
- return p(r).filter((n) => n.depth === e);
182
- }
183
- export {
184
- V as B,
185
- m as D,
186
- I as F,
187
- $ as G,
188
- B as L,
189
- x as M,
190
- g as N,
191
- j as S,
192
- S as V,
193
- M as a,
194
- f as b,
195
- d as c,
196
- G as d,
197
- z as e,
198
- C as f,
199
- p as g,
200
- L as h,
201
- w as i,
202
- R as j,
203
- H as k,
204
- F as l,
205
- A as m,
206
- q as p,
207
- y as v
208
- };
@@ -1,3 +0,0 @@
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(),basePath:t.z.string().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;