folderblog 0.0.1 → 0.0.3
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 +109 -48
- package/dist/chunk-2TZSVPNP.cjs +148 -0
- package/dist/chunk-3RG5ZIWI.js +8 -0
- package/dist/chunk-6TFXNIO6.cjs +495 -0
- package/dist/chunk-B43UAOPC.js +475 -0
- package/dist/chunk-D26H5722.js +132 -0
- package/dist/chunk-E7PYGJA7.cjs +39 -0
- package/dist/chunk-J3Y3HEBF.cjs +1858 -0
- package/dist/chunk-K76XLEC7.js +76 -0
- package/dist/chunk-LPPBVXJ7.js +1786 -0
- package/dist/chunk-OBGZSXTJ.cjs +10 -0
- package/dist/chunk-Q6EXKX6K.js +17 -0
- package/dist/chunk-Q6EYTOTM.cjs +78 -0
- package/dist/chunk-UCXXH2MP.cjs +20 -0
- package/dist/chunk-XQD3UUL5.js +34 -0
- package/dist/cli/bin.cjs +25 -0
- package/dist/cli/bin.d.cts +1 -0
- package/dist/cli/bin.d.ts +1 -0
- package/dist/cli/bin.js +23 -0
- package/dist/cli/index.cjs +22 -0
- package/dist/cli/index.d.cts +39 -0
- package/dist/cli/index.d.ts +39 -0
- package/dist/cli/index.js +15 -0
- package/dist/config-ADPY6IQS.d.cts +473 -0
- package/dist/config-Dctsdeo6.d.ts +473 -0
- package/dist/index.cjs +458 -1
- package/dist/index.d.cts +78 -9
- package/dist/index.d.ts +78 -9
- package/dist/index.js +100 -1
- package/dist/local/index.cjs +785 -0
- package/dist/local/index.d.cts +268 -0
- package/dist/local/index.d.ts +268 -0
- package/dist/local/index.js +772 -0
- package/dist/output-0P0br3Jc.d.cts +452 -0
- package/dist/output-0P0br3Jc.d.ts +452 -0
- package/dist/plugins/embed-cloudflare-ai.cjs +166 -0
- package/dist/plugins/embed-cloudflare-ai.d.cts +73 -0
- package/dist/plugins/embed-cloudflare-ai.d.ts +73 -0
- package/dist/plugins/embed-cloudflare-ai.js +156 -0
- package/dist/plugins/embed-transformers.cjs +121 -0
- package/dist/plugins/embed-transformers.d.cts +55 -0
- package/dist/plugins/embed-transformers.d.ts +55 -0
- package/dist/plugins/embed-transformers.js +113 -0
- package/dist/plugins/similarity.cjs +19 -0
- package/dist/plugins/similarity.d.cts +41 -0
- package/dist/plugins/similarity.d.ts +41 -0
- package/dist/plugins/similarity.js +2 -0
- package/dist/processor/index.cjs +349 -0
- package/dist/processor/index.d.cts +495 -0
- package/dist/processor/index.d.ts +495 -0
- package/dist/processor/index.js +4 -0
- package/dist/processor/plugins.cjs +63 -0
- package/dist/processor/plugins.d.cts +176 -0
- package/dist/processor/plugins.d.ts +176 -0
- package/dist/processor/plugins.js +2 -0
- package/dist/processor/types.cjs +67 -0
- package/dist/processor/types.d.cts +48 -0
- package/dist/processor/types.d.ts +48 -0
- package/dist/processor/types.js +2 -0
- package/dist/seo/index.cjs +289 -0
- package/dist/seo/index.d.cts +95 -0
- package/dist/seo/index.d.ts +95 -0
- package/dist/seo/index.js +274 -0
- package/dist/server/index.cjs +33 -0
- package/dist/server/index.d.cts +56 -0
- package/dist/server/index.d.ts +56 -0
- package/dist/server/index.js +31 -0
- package/package.json +98 -11
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
export { C as ContentConfig, D as DEFAULT_IMAGE_SIZES, a as DatabaseBuildInput, b as DatabasePlugin, c as DatabaseResult, d as DebugConfig, e as DirectoryConfig, I as ImageEmbeddingPlugin, f as ImageMetadata, g as ImageProcessOptions, h as ImageProcessResult, i as ImageProcessorPlugin, j as ImageSizeConfig, k as IssueCollector, l as IssueCollectorState, L as LogLevel, M as MediaConfig, m as MermaidConfig, n as MermaidRenderOptions, o as MermaidRendererPlugin, p as MermaidResult, q as MermaidStrategy, r as PipelineConfig, s as Plugin, t as PluginByName, u as PluginConfig, P as PluginContext, v as PluginName, w as ProcessConfig, x as ProcessConfigWithDefaults, S as SimilarityConfig, y as SimilarityPlugin, z as SimilarityResult, T as TextEmbeddingPlugin, A as calculateSummary, B as filterIssues, E as generateIssueReport, F as getMediaOutputDir, G as getOutputDir, H as withDefaults } from './config-Dctsdeo6.js';
|
|
2
|
+
export { B as BrokenLinkIssue, f as BuildReport, C as CacheContext, g as CacheStats, h as CachedMediaMetadata, i as CachedMediaSizeVariant, E as EmbeddingErrorIssue, j as EmbeddingMap, G as GraphData, k as GraphEdge, l as GraphNode, m as IssueCategory, I as IssueFilterOptions, n as IssueModule, b as IssueReport, a as IssueSeverity, c as IssueSummary, M as MediaMetadata, o as MediaPathMap, p as MediaProcessingIssue, q as MediaSizeVariant, r as MermaidErrorIssue, s as MissingMediaIssue, O as OUTPUT_FILES, t as OutputFiles, u as PathHashMap, v as PluginErrorIssue, w as PostCover, x as PostCoverError, y as PostCoverSize, z as PostMetadata, A as ProcessResult, e as ProcessedMedia, d as ProcessedPost, P as ProcessingIssue, R as RelationshipType, S as SlugConflictIssue, D as SlugHashMap, T as TocItem, F as buildEmbeddingCacheFromManifest, H as buildMediaCacheFromManifest, J as createEmptyCacheStats, K as isBrokenLinkIssue, L as isEmbeddingErrorIssue, N as isMediaProcessingIssue, Q as isMermaidErrorIssue, U as isMissingMediaIssue, V as isPluginErrorIssue, W as isSlugConflictIssue } from './output-0P0br3Jc.js';
|
|
3
|
+
export { BlockOnly, FileMap, HeaderOnly, LinkResolverOptions, ObsidianLink, PageAndBlock, PageAndHeader, PageOnly } from './processor/types.js';
|
|
4
|
+
export { CopyOnlyImageProcessor, NoOpDatabase, NoOpImageEmbedder, NoOpSimilarity, NoOpTextEmbedder, PassthroughMermaidRenderer, PluginManager, PluginManagerConfig, createAllNoOpPlugins, createDefaultPlugins, createPluginManager, topologicalSort } from './processor/plugins.js';
|
|
5
|
+
export { CosineSimilarityPlugin, SimilarityPluginOptions, cosineSimilarity, createSimilarityPlugin } from './plugins/similarity.js';
|
|
6
|
+
export { BaseSlugOptions, CustomToLinkOptions, DEFAULT_PIPELINE_OPTIONS, FileItem, FrontmatterResult, MarkdownResult, PipelineOptions, Processor, ProcessorOptions, RehypePlugin, RemarkPlugin, SlugAssignment, SlugConfig, SlugManager, buildFileMaps, buildToc, combineHashes, copyFile, countWords, createBasePipeline, createCustomToLink, createPathVariations, createProcessor, ensureDir, estimateReadingTime, extractFirstParagraph, extractHeadings, fileExists, findByFileNameCaseInsensitive, findFiles, findMarkdownFiles, generateBaseSlug, getContentStats, getExtension, getFileName, getStats, hashBuffer, hashContent, hastToHtml, mdastToHast, mdastToText, normalizePath, parseFrontmatter, parseToMdast, processFolder, processMarkdown, processVault, readJson, readText, relativePath, remarkMarkdownLinkResolver, resolveFile, resolveFromCandidates, resolveMarkdownLink, resolveMarkdownLinkPath, resolveSlugConflict, resolveWikilink, shortHash, toSlug, wikiToObsidian, wikilinkToMarkdownLink, writeJson, writeText } from './processor/index.js';
|
|
7
|
+
import 'mdast';
|
|
8
|
+
import 'hast';
|
|
9
|
+
import 'remark-obsidian-link';
|
|
10
|
+
import 'unified';
|
|
11
|
+
|
|
1
12
|
/**
|
|
2
13
|
* Base post fields shared between list and detail responses
|
|
3
14
|
*/
|
|
@@ -9,13 +20,13 @@ interface PostBase {
|
|
|
9
20
|
excerpt: string;
|
|
10
21
|
}
|
|
11
22
|
/**
|
|
12
|
-
* Post summary
|
|
23
|
+
* Post summary returned by `blog.posts.list()`
|
|
13
24
|
*/
|
|
14
25
|
interface PostSummary extends PostBase {
|
|
15
26
|
url: string;
|
|
16
27
|
}
|
|
17
28
|
/**
|
|
18
|
-
* Full post
|
|
29
|
+
* Full post returned by `blog.posts.get(slug)`
|
|
19
30
|
*/
|
|
20
31
|
interface Post extends PostBase {
|
|
21
32
|
content: string;
|
|
@@ -23,7 +34,7 @@ interface Post extends PostBase {
|
|
|
23
34
|
images: string[];
|
|
24
35
|
}
|
|
25
36
|
/**
|
|
26
|
-
* Site information
|
|
37
|
+
* Site information returned by `blog.site.get()`
|
|
27
38
|
*/
|
|
28
39
|
interface Site {
|
|
29
40
|
site: string;
|
|
@@ -32,39 +43,63 @@ interface Site {
|
|
|
32
43
|
url: string;
|
|
33
44
|
}
|
|
34
45
|
/**
|
|
35
|
-
*
|
|
46
|
+
* Options for creating a FolderBlog client
|
|
36
47
|
*/
|
|
37
48
|
interface FolderBlogOptions {
|
|
49
|
+
/** Custom fetch implementation (defaults to globalThis.fetch) */
|
|
38
50
|
fetch?: typeof fetch;
|
|
39
51
|
}
|
|
40
52
|
/**
|
|
41
|
-
* The FolderBlog client
|
|
53
|
+
* The FolderBlog client interface
|
|
42
54
|
*/
|
|
43
55
|
interface FolderBlogClient {
|
|
44
56
|
posts: {
|
|
57
|
+
/** List all published posts */
|
|
45
58
|
list(): Promise<PostSummary[]>;
|
|
59
|
+
/** Get a single post by slug */
|
|
46
60
|
get(slug: string): Promise<Post>;
|
|
47
61
|
};
|
|
48
62
|
site: {
|
|
63
|
+
/** Get site metadata */
|
|
49
64
|
get(): Promise<Site>;
|
|
50
65
|
};
|
|
66
|
+
tags: {
|
|
67
|
+
/** List all tags */
|
|
68
|
+
list(): Promise<string[]>;
|
|
69
|
+
};
|
|
70
|
+
categories: {
|
|
71
|
+
/** List all categories */
|
|
72
|
+
list(): Promise<string[]>;
|
|
73
|
+
};
|
|
74
|
+
feed: {
|
|
75
|
+
/** Get RSS feed (XML string) */
|
|
76
|
+
rss(): Promise<string>;
|
|
77
|
+
/** Get JSON feed */
|
|
78
|
+
json(): Promise<Record<string, unknown>>;
|
|
79
|
+
};
|
|
51
80
|
}
|
|
52
81
|
|
|
53
82
|
/**
|
|
54
|
-
* Create a FolderBlog client
|
|
83
|
+
* Create a FolderBlog client for consuming blog APIs.
|
|
55
84
|
*
|
|
56
85
|
* @example
|
|
57
86
|
* ```ts
|
|
87
|
+
* import { folderBlog } from 'folderblog';
|
|
88
|
+
*
|
|
58
89
|
* const blog = folderBlog('yourname.folder.blog');
|
|
90
|
+
*
|
|
59
91
|
* const posts = await blog.posts.list();
|
|
60
92
|
* const post = await blog.posts.get('hello-world');
|
|
61
93
|
* const site = await blog.site.get();
|
|
94
|
+
* const tags = await blog.tags.list();
|
|
95
|
+
* const categories = await blog.categories.list();
|
|
96
|
+
* const rss = await blog.feed.rss();
|
|
62
97
|
* ```
|
|
63
98
|
*/
|
|
64
99
|
declare function folderBlog(domain: string, options?: FolderBlogOptions): FolderBlogClient;
|
|
65
100
|
|
|
66
101
|
/**
|
|
67
|
-
* Base error class for
|
|
102
|
+
* Base error class for folderblog SDK errors
|
|
68
103
|
*/
|
|
69
104
|
declare class FolderBlogError extends Error {
|
|
70
105
|
/** HTTP status code if applicable */
|
|
@@ -92,8 +127,42 @@ declare class ApiError extends FolderBlogError {
|
|
|
92
127
|
* Error thrown when network/fetch fails
|
|
93
128
|
*/
|
|
94
129
|
declare class NetworkError extends FolderBlogError {
|
|
95
|
-
readonly cause?: Error;
|
|
96
130
|
constructor(message: string, cause?: Error);
|
|
97
131
|
}
|
|
98
132
|
|
|
99
|
-
|
|
133
|
+
/**
|
|
134
|
+
* folderblog - Official SDK for folder.blog
|
|
135
|
+
*
|
|
136
|
+
* Everything you need: API client, server middleware, and markdown processor.
|
|
137
|
+
*
|
|
138
|
+
* @example API client
|
|
139
|
+
* ```ts
|
|
140
|
+
* import { folderBlog } from 'folderblog';
|
|
141
|
+
*
|
|
142
|
+
* const blog = folderBlog('yourname.folder.blog');
|
|
143
|
+
* const posts = await blog.posts.list();
|
|
144
|
+
* ```
|
|
145
|
+
*
|
|
146
|
+
* @example Markdown processing
|
|
147
|
+
* ```ts
|
|
148
|
+
* import { processFolder, Processor } from 'folderblog';
|
|
149
|
+
* ```
|
|
150
|
+
*
|
|
151
|
+
* @example Server middleware
|
|
152
|
+
* ```ts
|
|
153
|
+
* import { createHandler } from 'folderblog/server';
|
|
154
|
+
* ```
|
|
155
|
+
*
|
|
156
|
+
* @example Fine-grained imports (tree-shaking)
|
|
157
|
+
* ```ts
|
|
158
|
+
* import { Processor } from 'folderblog/processor';
|
|
159
|
+
* import { PluginManager } from 'folderblog/processor/plugins';
|
|
160
|
+
* import type { ProcessConfig } from 'folderblog/processor/types';
|
|
161
|
+
* ```
|
|
162
|
+
*
|
|
163
|
+
* @packageDocumentation
|
|
164
|
+
*/
|
|
165
|
+
|
|
166
|
+
declare const VERSION = "0.0.2";
|
|
167
|
+
|
|
168
|
+
export { ApiError, type FolderBlogClient, FolderBlogError, type FolderBlogOptions, NetworkError, NotFoundError, type Post, type PostSummary, type Site, VERSION, folderBlog };
|
package/dist/index.js
CHANGED
|
@@ -1 +1,100 @@
|
|
|
1
|
-
|
|
1
|
+
import { FolderBlogError, NotFoundError, ApiError, NetworkError } from './chunk-XQD3UUL5.js';
|
|
2
|
+
export { ApiError, FolderBlogError, NetworkError, NotFoundError } from './chunk-XQD3UUL5.js';
|
|
3
|
+
import { normalizeBaseUrl } from './chunk-Q6EXKX6K.js';
|
|
4
|
+
export { DEFAULT_PIPELINE_OPTIONS, IssueCollector, Processor, SlugManager, buildFileMaps, buildToc, calculateSummary, combineHashes, copyFile, countWords, createBasePipeline, createCustomToLink, createPathVariations, createProcessor, ensureDir, estimateReadingTime, extractFirstParagraph, extractHeadings, fileExists, filterIssues, findByFileNameCaseInsensitive, findFiles, findMarkdownFiles, generateBaseSlug, generateIssueReport, getContentStats, getExtension, getFileName, getStats, hashBuffer, hashContent, hastToHtml, mdastToHast, mdastToText, normalizePath, parseFrontmatter, parseToMdast, processFolder, processMarkdown, processVault, readJson, readText, relativePath, remarkMarkdownLinkResolver, resolveFile, resolveFromCandidates, resolveMarkdownLink, resolveMarkdownLinkPath, resolveSlugConflict, resolveWikilink, shortHash, toSlug, wikiToObsidian, wikilinkToMarkdownLink, writeJson, writeText } from './chunk-LPPBVXJ7.js';
|
|
5
|
+
export { DEFAULT_IMAGE_SIZES, OUTPUT_FILES, buildEmbeddingCacheFromManifest, buildMediaCacheFromManifest, createEmptyCacheStats, getMediaOutputDir, getOutputDir, isBrokenLinkIssue, isEmbeddingErrorIssue, isMediaProcessingIssue, isMermaidErrorIssue, isMissingMediaIssue, isPluginErrorIssue, isSlugConflictIssue, withDefaults } from './chunk-D26H5722.js';
|
|
6
|
+
export { CopyOnlyImageProcessor, CosineSimilarityPlugin, NoOpDatabase, NoOpImageEmbedder, NoOpSimilarity, NoOpTextEmbedder, PassthroughMermaidRenderer, PluginManager, cosineSimilarity, createAllNoOpPlugins, createDefaultPlugins, createPluginManager, createSimilarityPlugin, topologicalSort } from './chunk-B43UAOPC.js';
|
|
7
|
+
import './chunk-3RG5ZIWI.js';
|
|
8
|
+
|
|
9
|
+
// src/client.ts
|
|
10
|
+
function folderBlog(domain, options = {}) {
|
|
11
|
+
const baseUrl = normalizeBaseUrl(domain);
|
|
12
|
+
const fetchFn = options.fetch ?? globalThis.fetch;
|
|
13
|
+
async function fetchRaw(path, accept) {
|
|
14
|
+
const url = `${baseUrl}${path}`;
|
|
15
|
+
let response;
|
|
16
|
+
try {
|
|
17
|
+
response = await fetchFn(url, {
|
|
18
|
+
method: "GET",
|
|
19
|
+
...accept ? { headers: { Accept: accept } } : {}
|
|
20
|
+
});
|
|
21
|
+
} catch (error) {
|
|
22
|
+
throw new NetworkError(
|
|
23
|
+
`Failed to fetch ${url}`,
|
|
24
|
+
error instanceof Error ? error : void 0
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
if (!response.ok) {
|
|
28
|
+
if (response.status === 404) {
|
|
29
|
+
throw new NotFoundError("Resource", path, url);
|
|
30
|
+
}
|
|
31
|
+
throw new ApiError(
|
|
32
|
+
`API request failed: ${response.statusText}`,
|
|
33
|
+
response.status,
|
|
34
|
+
url
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
return response;
|
|
38
|
+
}
|
|
39
|
+
async function request(path) {
|
|
40
|
+
const response = await fetchRaw(path, "application/json");
|
|
41
|
+
try {
|
|
42
|
+
return await response.json();
|
|
43
|
+
} catch {
|
|
44
|
+
throw new ApiError("Failed to parse JSON response", response.status, `${baseUrl}${path}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
async function requestText(path) {
|
|
48
|
+
const response = await fetchRaw(path);
|
|
49
|
+
return response.text();
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
posts: {
|
|
53
|
+
async list() {
|
|
54
|
+
const data = await request("/api/posts");
|
|
55
|
+
return data.posts;
|
|
56
|
+
},
|
|
57
|
+
async get(slug) {
|
|
58
|
+
if (!slug) throw new FolderBlogError("Post slug is required");
|
|
59
|
+
try {
|
|
60
|
+
return await request(`/api/posts/${encodeURIComponent(slug)}`);
|
|
61
|
+
} catch (error) {
|
|
62
|
+
if (error instanceof NotFoundError) {
|
|
63
|
+
throw new NotFoundError("Post", slug, error.url);
|
|
64
|
+
}
|
|
65
|
+
throw error;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
site: {
|
|
70
|
+
async get() {
|
|
71
|
+
return request("/api");
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
tags: {
|
|
75
|
+
async list() {
|
|
76
|
+
const data = await request("/api/tags");
|
|
77
|
+
return data.tags;
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
categories: {
|
|
81
|
+
async list() {
|
|
82
|
+
const data = await request("/api/categories");
|
|
83
|
+
return data.categories;
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
feed: {
|
|
87
|
+
async rss() {
|
|
88
|
+
return requestText("/api/feed.xml");
|
|
89
|
+
},
|
|
90
|
+
async json() {
|
|
91
|
+
return request("/api/feed.json");
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// src/index.ts
|
|
98
|
+
var VERSION = "0.0.2";
|
|
99
|
+
|
|
100
|
+
export { VERSION, folderBlog };
|