@piqit/resolvers 0.0.2

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,18 @@
1
+ /**
2
+ * @piqit/resolvers - Resolver implementations for piq v2
3
+ *
4
+ * Provides resolvers for querying structured content:
5
+ * - fileMarkdown: Query markdown files from filesystem (Node.js/Bun)
6
+ * - staticContent: Query pre-compiled content (Edge/Workers)
7
+ *
8
+ * @packageDocumentation
9
+ */
10
+ export { fileMarkdown } from "./file-markdown";
11
+ export type { FileMarkdownOptions, FileMarkdownResult } from "./file-markdown";
12
+ export { staticContent, staticResolver } from "./static";
13
+ export { compilePattern, createParamsSchema } from "./path-pattern";
14
+ export type { CompiledPattern, ExtractParams, PathParams, } from "./path-pattern";
15
+ export { parseFrontmatter, extractFrontmatterString, getFrontmatterEndOffset, readFrontmatter, readFrontmatterWithOffset, } from "./frontmatter";
16
+ export { parseMarkdownBody, extractHeadings, slugify, markdownToHtml, readMarkdownBody, readParsedBody, } from "./markdown";
17
+ export type { BodyOptions, BodyResult, BodyShape, Heading, } from "./markdown";
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,YAAY,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAM9E,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAMxD,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AACnE,YAAY,EACV,eAAe,EACf,aAAa,EACb,UAAU,GACX,MAAM,gBAAgB,CAAA;AAMvB,OAAO,EACL,gBAAgB,EAChB,wBAAwB,EACxB,uBAAuB,EACvB,eAAe,EACf,yBAAyB,GAC1B,MAAM,eAAe,CAAA;AAMtB,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,OAAO,EACP,cAAc,EACd,gBAAgB,EAChB,cAAc,GACf,MAAM,YAAY,CAAA;AAEnB,YAAY,EACV,WAAW,EACX,UAAU,EACV,SAAS,EACT,OAAO,GACR,MAAM,YAAY,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @piqit/resolvers - Resolver implementations for piq v2
3
+ *
4
+ * Provides resolvers for querying structured content:
5
+ * - fileMarkdown: Query markdown files from filesystem (Node.js/Bun)
6
+ * - staticContent: Query pre-compiled content (Edge/Workers)
7
+ *
8
+ * @packageDocumentation
9
+ */
10
+ // =============================================================================
11
+ // Filesystem Resolver (Node.js/Bun only)
12
+ // =============================================================================
13
+ export { fileMarkdown } from "./file-markdown";
14
+ // =============================================================================
15
+ // Static Content Resolver (Edge/Workers compatible)
16
+ // =============================================================================
17
+ export { staticContent, staticResolver } from "./static";
18
+ // =============================================================================
19
+ // Path Pattern Utilities
20
+ // =============================================================================
21
+ export { compilePattern, createParamsSchema } from "./path-pattern";
22
+ // =============================================================================
23
+ // Frontmatter Utilities
24
+ // =============================================================================
25
+ export { parseFrontmatter, extractFrontmatterString, getFrontmatterEndOffset, readFrontmatter, readFrontmatterWithOffset, } from "./frontmatter";
26
+ // =============================================================================
27
+ // Markdown Utilities
28
+ // =============================================================================
29
+ export { parseMarkdownBody, extractHeadings, slugify, markdownToHtml, readMarkdownBody, readParsedBody, } from "./markdown";
30
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,gFAAgF;AAChF,yCAAyC;AACzC,gFAAgF;AAEhF,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAG9C,gFAAgF;AAChF,oDAAoD;AACpD,gFAAgF;AAEhF,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAExD,gFAAgF;AAChF,yBAAyB;AACzB,gFAAgF;AAEhF,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAOnE,gFAAgF;AAChF,wBAAwB;AACxB,gFAAgF;AAEhF,OAAO,EACL,gBAAgB,EAChB,wBAAwB,EACxB,uBAAuB,EACvB,eAAe,EACf,yBAAyB,GAC1B,MAAM,eAAe,CAAA;AAEtB,gFAAgF;AAChF,qBAAqB;AACrB,gFAAgF;AAEhF,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,OAAO,EACP,cAAc,EACd,gBAAgB,EAChB,cAAc,GACf,MAAM,YAAY,CAAA"}
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Markdown Body Parsing
3
+ *
4
+ * Parses markdown body content to extract:
5
+ * - Raw markdown text
6
+ * - HTML (basic conversion)
7
+ * - Headings with slugs
8
+ */
9
+ /**
10
+ * Options for parsing markdown body.
11
+ */
12
+ export interface BodyOptions {
13
+ /** Include raw markdown text */
14
+ raw?: boolean;
15
+ /** Include HTML conversion */
16
+ html?: boolean;
17
+ /** Extract headings with depth and slugs */
18
+ headings?: boolean;
19
+ }
20
+ /**
21
+ * A heading extracted from markdown.
22
+ */
23
+ export interface Heading {
24
+ /** Heading depth (1-6) */
25
+ depth: number;
26
+ /** Heading text content */
27
+ text: string;
28
+ /** URL-safe slug */
29
+ slug: string;
30
+ }
31
+ /**
32
+ * Result of parsing markdown body.
33
+ */
34
+ export interface BodyResult {
35
+ /** Raw markdown text (if requested) */
36
+ raw?: string;
37
+ /** HTML content (if requested) */
38
+ html?: string;
39
+ /** Extracted headings (if requested) */
40
+ headings?: Heading[];
41
+ }
42
+ /**
43
+ * Type-level shape of body result based on options.
44
+ */
45
+ export type BodyShape<T extends BodyOptions> = {
46
+ [K in keyof T as T[K] extends true ? K : never]: K extends "raw" ? string : K extends "html" ? string : K extends "headings" ? Heading[] : never;
47
+ };
48
+ /**
49
+ * Parse markdown body content.
50
+ *
51
+ * @param content - The full file content (including frontmatter if present)
52
+ * @param options - What to extract from the markdown
53
+ * @returns The requested body parts
54
+ */
55
+ export declare function parseMarkdownBody(content: string, options: BodyOptions): BodyResult;
56
+ /**
57
+ * Extract headings from markdown text.
58
+ *
59
+ * @param markdown - The raw markdown content
60
+ * @returns Array of headings with depth, text, and slug
61
+ */
62
+ export declare function extractHeadings(markdown: string): Heading[];
63
+ /**
64
+ * Convert text to a URL-safe slug.
65
+ *
66
+ * @param text - The text to slugify
67
+ * @returns A URL-safe slug
68
+ */
69
+ export declare function slugify(text: string): string;
70
+ /**
71
+ * Convert markdown to HTML.
72
+ *
73
+ * This is a basic implementation that handles common patterns.
74
+ * For production use, consider using a proper markdown parser.
75
+ *
76
+ * @param markdown - The raw markdown content
77
+ * @returns HTML string
78
+ */
79
+ export declare function markdownToHtml(markdown: string): string;
80
+ /**
81
+ * Read just the markdown body from a file (skipping frontmatter).
82
+ *
83
+ * @param path - Path to the markdown file
84
+ * @returns The raw markdown body
85
+ */
86
+ export declare function readMarkdownBody(path: string): Promise<string>;
87
+ /**
88
+ * Read and parse markdown body from a file.
89
+ *
90
+ * @param path - Path to the markdown file
91
+ * @param options - What to extract from the markdown
92
+ * @returns The requested body parts
93
+ */
94
+ export declare function readParsedBody(path: string, options: BodyOptions): Promise<BodyResult>;
95
+ //# sourceMappingURL=markdown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../src/markdown.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAQH;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,gCAAgC;IAChC,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,8BAA8B;IAC9B,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,4CAA4C;IAC5C,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,0BAA0B;IAC1B,K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Body Parsing
3
+ *
4
+ * Parses markdown body content to extract:
5
+ * - Raw markdown text
6
+ * - HTML (basic conversion)
7
+ * - Headings with slugs
8
+ */
9
+ import { getFrontmatterEndOffset } from "./frontmatter";
10
+ // =============================================================================
11
+ // Markdown Parsing
12
+ // =============================================================================
13
+ /**
14
+ * Parse markdown body content.
15
+ *
16
+ * @param content - The full file content (including frontmatter if present)
17
+ * @param options - What to extract from the markdown
18
+ * @returns The requested body parts
19
+ */
20
+ export function parseMarkdownBody(content, options) {
21
+ // Strip frontmatter if present
22
+ const bodyOffset = getFrontmatterEndOffset(content);
23
+ const rawBody = content.slice(bodyOffset).replace(/^[\r\n]+/, "");
24
+ const result = {};
25
+ if (options.raw) {
26
+ result.raw = rawBody;
27
+ }
28
+ if (options.html) {
29
+ result.html = markdownToHtml(rawBody);
30
+ }
31
+ if (options.headings) {
32
+ result.headings = extractHeadings(rawBody);
33
+ }
34
+ return result;
35
+ }
36
+ // =============================================================================
37
+ // Heading Extraction
38
+ // =============================================================================
39
+ /**
40
+ * Regex to match ATX-style headings (# Heading).
41
+ */
42
+ const HEADING_REGEX = /^(#{1,6})\s+(.+)$/gm;
43
+ /**
44
+ * Extract headings from markdown text.
45
+ *
46
+ * @param markdown - The raw markdown content
47
+ * @returns Array of headings with depth, text, and slug
48
+ */
49
+ export function extractHeadings(markdown) {
50
+ const headings = [];
51
+ let match;
52
+ const regex = new RegExp(HEADING_REGEX.source, "gm");
53
+ while ((match = regex.exec(markdown)) !== null) {
54
+ const depth = match[1].length;
55
+ const text = match[2].trim();
56
+ const slug = slugify(text);
57
+ headings.push({ depth, text, slug });
58
+ }
59
+ return headings;
60
+ }
61
+ /**
62
+ * Convert text to a URL-safe slug.
63
+ *
64
+ * @param text - The text to slugify
65
+ * @returns A URL-safe slug
66
+ */
67
+ export function slugify(text) {
68
+ return text
69
+ .toLowerCase()
70
+ .replace(/[^\w\s-]/g, "") // Remove non-word chars
71
+ .replace(/\s+/g, "-") // Replace spaces with dashes
72
+ .replace(/--+/g, "-") // Replace multiple dashes
73
+ .replace(/^-|-$/g, ""); // Trim dashes from ends
74
+ }
75
+ // =============================================================================
76
+ // Basic Markdown to HTML
77
+ // =============================================================================
78
+ /**
79
+ * Convert markdown to HTML.
80
+ *
81
+ * This is a basic implementation that handles common patterns.
82
+ * For production use, consider using a proper markdown parser.
83
+ *
84
+ * @param markdown - The raw markdown content
85
+ * @returns HTML string
86
+ */
87
+ export function markdownToHtml(markdown) {
88
+ let html = markdown;
89
+ // Escape HTML entities first
90
+ html = html
91
+ .replace(/&/g, "&amp;")
92
+ .replace(/</g, "&lt;")
93
+ .replace(/>/g, "&gt;");
94
+ // Headings (must be on their own line)
95
+ html = html.replace(/^######\s+(.+)$/gm, "<h6>$1</h6>");
96
+ html = html.replace(/^#####\s+(.+)$/gm, "<h5>$1</h5>");
97
+ html = html.replace(/^####\s+(.+)$/gm, "<h4>$1</h4>");
98
+ html = html.replace(/^###\s+(.+)$/gm, "<h3>$1</h3>");
99
+ html = html.replace(/^##\s+(.+)$/gm, "<h2>$1</h2>");
100
+ html = html.replace(/^#\s+(.+)$/gm, "<h1>$1</h1>");
101
+ // Code blocks (fenced)
102
+ html = html.replace(/```(\w*)\n([\s\S]*?)```/g, (_match, _lang, code) => {
103
+ return `<pre><code>${code.trim()}</code></pre>`;
104
+ });
105
+ // Inline code
106
+ html = html.replace(/`([^`]+)`/g, "<code>$1</code>");
107
+ // Bold
108
+ html = html.replace(/\*\*([^*]+)\*\*/g, "<strong>$1</strong>");
109
+ html = html.replace(/__([^_]+)__/g, "<strong>$1</strong>");
110
+ // Italic
111
+ html = html.replace(/\*([^*]+)\*/g, "<em>$1</em>");
112
+ html = html.replace(/_([^_]+)_/g, "<em>$1</em>");
113
+ // Links
114
+ html = html.replace(/\[([^\]]+)\]\(([^)]+)\)/g, '<a href="$2">$1</a>');
115
+ // Images
116
+ html = html.replace(/!\[([^\]]*)\]\(([^)]+)\)/g, '<img src="$2" alt="$1">');
117
+ // Horizontal rules
118
+ html = html.replace(/^---+$/gm, "<hr>");
119
+ html = html.replace(/^\*\*\*+$/gm, "<hr>");
120
+ // Unordered lists (simplified)
121
+ html = html.replace(/^[-*+]\s+(.+)$/gm, "<li>$1</li>");
122
+ // Ordered lists (simplified)
123
+ html = html.replace(/^\d+\.\s+(.+)$/gm, "<li>$1</li>");
124
+ // Wrap consecutive <li> in <ul> or <ol>
125
+ html = html.replace(/((?:<li>.*<\/li>\n?)+)/g, "<ul>\n$1</ul>\n");
126
+ // Blockquotes
127
+ html = html.replace(/^>\s+(.+)$/gm, "<blockquote>$1</blockquote>");
128
+ // Paragraphs (wrap remaining text blocks)
129
+ // Split by double newlines and wrap non-block elements
130
+ const blocks = html.split(/\n\n+/);
131
+ html = blocks
132
+ .map((block) => {
133
+ const trimmed = block.trim();
134
+ if (!trimmed)
135
+ return "";
136
+ // Don't wrap if already a block element
137
+ if (/^<(h[1-6]|ul|ol|li|pre|blockquote|hr|p)/.test(trimmed) ||
138
+ /^<\/?(h[1-6]|ul|ol|li|pre|blockquote)>$/.test(trimmed)) {
139
+ return trimmed;
140
+ }
141
+ return `<p>${trimmed.replace(/\n/g, "<br>")}</p>`;
142
+ })
143
+ .filter(Boolean)
144
+ .join("\n");
145
+ return html;
146
+ }
147
+ // =============================================================================
148
+ // File Reading Utilities
149
+ // =============================================================================
150
+ /**
151
+ * Read just the markdown body from a file (skipping frontmatter).
152
+ *
153
+ * @param path - Path to the markdown file
154
+ * @returns The raw markdown body
155
+ */
156
+ export async function readMarkdownBody(path) {
157
+ const file = Bun.file(path);
158
+ const content = await file.text();
159
+ const bodyOffset = getFrontmatterEndOffset(content);
160
+ return content.slice(bodyOffset).replace(/^\r?\n/, "");
161
+ }
162
+ /**
163
+ * Read and parse markdown body from a file.
164
+ *
165
+ * @param path - Path to the markdown file
166
+ * @param options - What to extract from the markdown
167
+ * @returns The requested body parts
168
+ */
169
+ export async function readParsedBody(path, options) {
170
+ const file = Bun.file(path);
171
+ const content = await file.text();
172
+ return parseMarkdownBody(content, options);
173
+ }
174
+ //# sourceMappingURL=markdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdown.js","sourceRoot":"","sources":["../src/markdown.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAA;AAuDvD,gFAAgF;AAChF,mBAAmB;AACnB,gFAAgF;AAEhF;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAe,EAAE,OAAoB;IACrE,+BAA+B;IAC/B,MAAM,UAAU,GAAG,uBAAuB,CAAC,OAAO,CAAC,CAAA;IACnD,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAA;IAEjE,MAAM,MAAM,GAAe,EAAE,CAAA;IAE7B,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QAChB,MAAM,CAAC,GAAG,GAAG,OAAO,CAAA;IACtB,CAAC;IAED,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;QACjB,MAAM,CAAC,IAAI,GAAG,cAAc,CAAC,OAAO,CAAC,CAAA;IACvC,CAAC;IAED,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;QACrB,MAAM,CAAC,QAAQ,GAAG,eAAe,CAAC,OAAO,CAAC,CAAA;IAC5C,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC;AAED,gFAAgF;AAChF,qBAAqB;AACrB,gFAAgF;AAEhF;;GAEG;AACH,MAAM,aAAa,GAAG,qBAAqB,CAAA;AAE3C;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC9C,MAAM,QAAQ,GAAc,EAAE,CAAA;IAC9B,IAAI,KAA6B,CAAA;IAEjC,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,aAAa,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IACpD,OAAO,CAAC,KAAK,GAAG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,CAAC,CAAA;IACnD,OAAO,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;AACxD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,IAAY,EAAE,OAAoB;IACrE,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC3B,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAA;IACjC,OAAO,iBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;AAC5C,CAAC"}
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Path Pattern Parsing and Matching
3
+ *
4
+ * Parses patterns like `{year}/{slug}.md` and provides:
5
+ * - Type-level extraction of parameters
6
+ * - Glob pattern generation
7
+ * - Path matching to extract params
8
+ * - Path building from params
9
+ */
10
+ /**
11
+ * Extract params from a path pattern string at the type level.
12
+ *
13
+ * @example
14
+ * type Params = ExtractParams<'{year}/{slug}.md'>
15
+ * // = { year: string } & { slug: string }
16
+ */
17
+ export type ExtractParams<P extends string> = P extends `${string}{${infer Param}}${infer Rest}` ? {
18
+ [K in Param]: string;
19
+ } & ExtractParams<Rest> : {};
20
+ /**
21
+ * Simplify a type by flattening intersections.
22
+ * Converts { a: string } & { b: string } to { a: string; b: string }
23
+ */
24
+ export type Simplify<T> = {
25
+ [K in keyof T]: T[K];
26
+ };
27
+ /**
28
+ * Extract and simplify params from a path pattern.
29
+ */
30
+ export type PathParams<P extends string> = Simplify<ExtractParams<P>>;
31
+ /**
32
+ * A compiled path pattern that can match paths and generate globs.
33
+ */
34
+ export interface CompiledPattern {
35
+ /**
36
+ * The original pattern string.
37
+ */
38
+ pattern: string;
39
+ /**
40
+ * The extracted parameter names.
41
+ */
42
+ paramNames: string[];
43
+ /**
44
+ * Generate a glob pattern, optionally constraining specific params.
45
+ *
46
+ * @param constraints - Optional param values to use instead of wildcards
47
+ * @returns A glob pattern string
48
+ *
49
+ * @example
50
+ * pattern.toGlob() // '** / *.md' (with {year}/{slug}.md)
51
+ * pattern.toGlob({ year: '2024' }) // '2024/*.md'
52
+ */
53
+ toGlob(constraints?: Record<string, unknown>): string;
54
+ /**
55
+ * Match a path against this pattern and extract params.
56
+ *
57
+ * @param path - The file path to match (relative to base)
58
+ * @returns The extracted params, or null if no match
59
+ *
60
+ * @example
61
+ * pattern.match('2024/hello-world.md') // { year: '2024', slug: 'hello-world' }
62
+ * pattern.match('invalid') // null
63
+ */
64
+ match(path: string): Record<string, string> | null;
65
+ /**
66
+ * Build a path from params.
67
+ *
68
+ * @param params - The param values
69
+ * @returns The constructed path
70
+ *
71
+ * @example
72
+ * pattern.build({ year: '2024', slug: 'hello' }) // '2024/hello.md'
73
+ */
74
+ build(params: Record<string, string>): string;
75
+ }
76
+ /**
77
+ * Compile a path pattern string into a usable pattern object.
78
+ *
79
+ * @param pattern - The pattern string like '{year}/{slug}.md'
80
+ * @returns A CompiledPattern instance
81
+ *
82
+ * @example
83
+ * const pattern = compilePattern('{year}/{slug}.md')
84
+ * pattern.toGlob() // '** / *.md'
85
+ * pattern.match('2024/hello.md') // { year: '2024', slug: 'hello' }
86
+ */
87
+ export declare function compilePattern(pattern: string): CompiledPattern;
88
+ /**
89
+ * Create a StandardSchema for path params extracted from a pattern.
90
+ * This is used by the resolver to expose scanParams to piq core.
91
+ *
92
+ * @param pattern - The compiled pattern
93
+ * @returns A StandardSchema that validates param objects
94
+ */
95
+ export declare function createParamsSchema(pattern: CompiledPattern): import("piqit").StandardSchema<Record<string, string>>;
96
+ //# sourceMappingURL=path-pattern.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path-pattern.d.ts","sourceRoot":"","sources":["../src/path-pattern.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,SAAS,GAAG,MAAM,IAAI,MAAM,KAAK,IAAI,MAAM,IAAI,EAAE,GAC5F;KAAG,CAAC,IAAI,KAAK,GAAG,MAAM;CAAE,GAAG,aAAa,CAAC,IAAI,CAAC,GAC9C,EAAE,CAAA;AAEN;;;GAGG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,CAAA;AAElD;;GAEG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,MAAM,IAAI,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAA;AAMrE;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,OAAO,EAAE,MAAM,CAAA;IAEf;;OAEG;IACH,UAAU,EAAE,MAAM,EAAE,CAAA;IAEpB;;;;;;;;;OASG;IACH,MAAM,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAA;IAErD;;;;;;;;;OASG;IACH,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAA;IAElD;;;;;;;;OAQG;IACH,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAA;CAC9C;AAiBD;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,eAAe,CAkE/D;AAMD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,eAAe,GACvB,OAAO,OAAO,EAAE,cAAc,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CA4BxD"}
@@ -0,0 +1,130 @@
1
+ /**
2
+ * Path Pattern Parsing and Matching
3
+ *
4
+ * Parses patterns like `{year}/{slug}.md` and provides:
5
+ * - Type-level extraction of parameters
6
+ * - Glob pattern generation
7
+ * - Path matching to extract params
8
+ * - Path building from params
9
+ */
10
+ // =============================================================================
11
+ // Pattern Parsing
12
+ // =============================================================================
13
+ /**
14
+ * Regex to match parameter placeholders in patterns.
15
+ * Matches {paramName} where paramName is alphanumeric + underscores.
16
+ */
17
+ const PARAM_REGEX = /\{([a-zA-Z_][a-zA-Z0-9_]*)\}/g;
18
+ /**
19
+ * Characters that need escaping in regex.
20
+ */
21
+ const REGEX_ESCAPE = /[.*+?^${}()|[\]\\]/g;
22
+ /**
23
+ * Compile a path pattern string into a usable pattern object.
24
+ *
25
+ * @param pattern - The pattern string like '{year}/{slug}.md'
26
+ * @returns A CompiledPattern instance
27
+ *
28
+ * @example
29
+ * const pattern = compilePattern('{year}/{slug}.md')
30
+ * pattern.toGlob() // '** / *.md'
31
+ * pattern.match('2024/hello.md') // { year: '2024', slug: 'hello' }
32
+ */
33
+ export function compilePattern(pattern) {
34
+ // Extract all parameter names in order
35
+ const paramNames = [];
36
+ let match;
37
+ const regex = new RegExp(PARAM_REGEX.source, "g");
38
+ while ((match = regex.exec(pattern)) !== null) {
39
+ paramNames.push(match[1]);
40
+ }
41
+ // Build the match regex by replacing {param} with capturing groups
42
+ // Each param can match anything except path separators
43
+ const regexPattern = pattern
44
+ .replace(REGEX_ESCAPE, (char) => {
45
+ // Don't escape our param placeholders - we'll handle them separately
46
+ if (char === "{" || char === "}")
47
+ return char;
48
+ return "\\" + char;
49
+ })
50
+ .replace(PARAM_REGEX, "([^/]+)");
51
+ const matchRegex = new RegExp(`^${regexPattern}$`);
52
+ return {
53
+ pattern,
54
+ paramNames,
55
+ toGlob(constraints) {
56
+ let glob = pattern;
57
+ // Replace each param with either its constrained value or a wildcard
58
+ for (const name of paramNames) {
59
+ const value = constraints?.[name];
60
+ if (value !== undefined && value !== null) {
61
+ // Use the constrained value
62
+ glob = glob.replace(`{${name}}`, String(value));
63
+ }
64
+ else {
65
+ // Use a wildcard - * matches anything except /
66
+ glob = glob.replace(`{${name}}`, "*");
67
+ }
68
+ }
69
+ return glob;
70
+ },
71
+ match(path) {
72
+ const result = matchRegex.exec(path);
73
+ if (!result)
74
+ return null;
75
+ const params = {};
76
+ for (let i = 0; i < paramNames.length; i++) {
77
+ params[paramNames[i]] = result[i + 1];
78
+ }
79
+ return params;
80
+ },
81
+ build(params) {
82
+ let result = pattern;
83
+ for (const name of paramNames) {
84
+ const value = params[name];
85
+ if (value === undefined) {
86
+ throw new Error(`Missing required param: ${name}`);
87
+ }
88
+ result = result.replace(`{${name}}`, value);
89
+ }
90
+ return result;
91
+ },
92
+ };
93
+ }
94
+ // =============================================================================
95
+ // Schema for Path Params
96
+ // =============================================================================
97
+ /**
98
+ * Create a StandardSchema for path params extracted from a pattern.
99
+ * This is used by the resolver to expose scanParams to piq core.
100
+ *
101
+ * @param pattern - The compiled pattern
102
+ * @returns A StandardSchema that validates param objects
103
+ */
104
+ export function createParamsSchema(pattern) {
105
+ return {
106
+ "~standard": {
107
+ version: 1,
108
+ vendor: "piqit/resolvers",
109
+ validate(value) {
110
+ if (value === null || typeof value !== "object") {
111
+ return {
112
+ issues: [{ message: "Expected object" }],
113
+ };
114
+ }
115
+ const obj = value;
116
+ // All params should be strings if present
117
+ for (const name of pattern.paramNames) {
118
+ const val = obj[name];
119
+ if (val !== undefined && typeof val !== "string") {
120
+ return {
121
+ issues: [{ message: `Param ${name} must be a string`, path: [name] }],
122
+ };
123
+ }
124
+ }
125
+ return { value: obj };
126
+ },
127
+ },
128
+ };
129
+ }
130
+ //# sourceMappingURL=path-pattern.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path-pattern.js","sourceRoot":"","sources":["../src/path-pattern.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAkFH,gFAAgF;AAChF,kBAAkB;AAClB,gFAAgF;AAEhF;;;GAGG;AACH,MAAM,WAAW,GAAG,+BAA+B,CAAA;AAEnD;;GAEG;AACH,MAAM,YAAY,GAAG,qBAAqB,CAAA;AAE1C;;;;;;;;;;GAUG;A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AK,QAAQ,EAAE,CAAC;oBAChD,OAAO;wBACL,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,iBAAiB,EAAE,CAAC;qBACzC,CAAA;gBACH,CAAC;gBAED,MAAM,GAAG,GAAG,KAAgC,CAAA;gBAE5C,0CAA0C;gBAC1C,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;oBACtC,MAAM,GAAG,GAAG,GAAG,CAAC,IAAI,CAAC,CAAA;oBACrB,IAAI,GAAG,KAAK,SAAS,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;wBACjD,OAAO;4BACL,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,SAAS,IAAI,mBAAmB,EAAE,IAAI,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;yBACtE,CAAA;oBACH,CAAC;gBACH,CAAC;gBAED,OAAO,EAAE,KAAK,EAAE,GAA6B,EAAE,CAAA;YACjD,CAAC;SACF;KACF,CAAA;AACH,CAAC"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Static Content Resolver
3
+ *
4
+ * A resolver for querying pre-compiled content in edge environments
5
+ * like Cloudflare Workers where filesystem access is not available.
6
+ *
7
+ * Content is compiled at build time and bundled as a static module.
8
+ *
9
+ * @example
10
+ * // 1. Build script compiles content:
11
+ * // build-content.ts
12
+ * import { fileMarkdown } from "@piqit/resolvers";
13
+ * const posts = fileMarkdown({ ... });
14
+ * const allPosts = await posts.resolve({ scan: {}, filter: {}, select: ["params.*", "frontmatter.*", "body.*"] });
15
+ * await Bun.write("src/generated/content.ts", `export const posts = ${JSON.stringify(allPosts)};`);
16
+ *
17
+ * // 2. Worker imports and uses static resolver:
18
+ * // worker.ts
19
+ * import { posts } from "./generated/content";
20
+ * import { staticContent } from "@piqit/resolvers";
21
+ * import { piq } from "piqit";
22
+ *
23
+ * const postsResolver = staticContent(posts);
24
+ *
25
+ * const results = await piq.from(postsResolver)
26
+ * .filter({ author: "John" })
27
+ * .select("params.slug", "frontmatter.title")
28
+ * .exec();
29
+ */
30
+ import type { Resolver, StandardSchema } from "piqit";
31
+ /**
32
+ * Create a static content resolver from pre-compiled data.
33
+ *
34
+ * This resolver is designed for edge environments like Cloudflare Workers
35
+ * where filesystem access is not available. Content is compiled at build
36
+ * time and bundled as a static module.
37
+ *
38
+ * @param data - Array of pre-compiled content items
39
+ * @returns A resolver that queries the static data
40
+ *
41
+ * @example
42
+ * // In your worker:
43
+ * import { posts } from "./generated/content";
44
+ * import { staticContent } from "@piqit/resolvers";
45
+ * import { piq } from "piqit";
46
+ *
47
+ * const postsResolver = staticContent(posts);
48
+ *
49
+ * export default {
50
+ * async fetch(request: Request) {
51
+ * const results = await piq.from(postsResolver)
52
+ * .scan({ year: "2024" })
53
+ * .select("params.slug", "frontmatter.title")
54
+ * .exec();
55
+ *
56
+ * return Response.json(results);
57
+ * }
58
+ * };
59
+ */
60
+ export declare function staticContent<T extends object>(data: T[]): Resolver<StandardSchema<Partial<Record<string, unknown>>>, StandardSchema<Partial<Record<string, unknown>>>, StandardSchema<T>>;
61
+ /**
62
+ * Alias for staticContent - provides a more descriptive name for the use case.
63
+ */
64
+ export declare const staticResolver: typeof staticContent;
65
+ //# sourceMappingURL=static.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"static.d.ts","sourceRoot":"","sources":["../src/static.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AA2HrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,MAAM,EAC5C,IAAI,EAAE,CAAC,EAAE,GACR,QAAQ,CACT,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,EAChD,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,EAChD,cAAc,CAAC,CAAC,CAAC,CAClB,CAiCA;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,sBAAgB,CAAA"}