@imjp/writenex-astro 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 +539 -0
- package/dist/chunk-5PM6EQE5.js +151 -0
- package/dist/chunk-5PM6EQE5.js.map +1 -0
- package/dist/chunk-7XU5X6CW.js +1331 -0
- package/dist/chunk-7XU5X6CW.js.map +1 -0
- package/dist/chunk-AAOQHQPU.js +574 -0
- package/dist/chunk-AAOQHQPU.js.map +1 -0
- package/dist/chunk-CF2XXJFF.js +1410 -0
- package/dist/chunk-CF2XXJFF.js.map +1 -0
- package/dist/chunk-CRPZUUDU.js +52 -0
- package/dist/chunk-CRPZUUDU.js.map +1 -0
- package/dist/chunk-CYLDJ3HZ.js +310 -0
- package/dist/chunk-CYLDJ3HZ.js.map +1 -0
- package/dist/chunk-KIKIPIFA.js +1 -0
- package/dist/chunk-KIKIPIFA.js.map +1 -0
- package/dist/chunk-XNTQTTJU.js +145 -0
- package/dist/chunk-XNTQTTJU.js.map +1 -0
- package/dist/client/index.css +2 -0
- package/dist/client/index.css.map +1 -0
- package/dist/client/index.js +375 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/styles.css +584 -0
- package/dist/client/variables.css +304 -0
- package/dist/config/index.d.ts +54 -0
- package/dist/config/index.js +38 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config-BmEdBDo_.d.ts +220 -0
- package/dist/content-BWR52vD-.d.ts +64 -0
- package/dist/discovery/index.d.ts +310 -0
- package/dist/discovery/index.js +38 -0
- package/dist/discovery/index.js.map +1 -0
- package/dist/errors-C0iYiDTv.d.ts +107 -0
- package/dist/filesystem/index.d.ts +1292 -0
- package/dist/filesystem/index.js +203 -0
- package/dist/filesystem/index.js.map +1 -0
- package/dist/image-FP7w5ZIs.d.ts +47 -0
- package/dist/index.d.ts +64 -0
- package/dist/index.js +151 -0
- package/dist/index.js.map +1 -0
- package/dist/loader-55LWCXHA.js +12 -0
- package/dist/loader-55LWCXHA.js.map +1 -0
- package/dist/loader-CrdnaAWR.d.ts +327 -0
- package/dist/server/index.d.ts +357 -0
- package/dist/server/index.js +37 -0
- package/dist/server/index.js.map +1 -0
- package/package.json +94 -0
- package/src/client/App.tsx +900 -0
- package/src/client/components/ConfigPanel/ConfigPanel.css +553 -0
- package/src/client/components/ConfigPanel/ConfigPanel.tsx +396 -0
- package/src/client/components/ConfigPanel/index.ts +6 -0
- package/src/client/components/CreateContentModal/CreateContentModal.css +327 -0
- package/src/client/components/CreateContentModal/CreateContentModal.tsx +216 -0
- package/src/client/components/CreateContentModal/index.ts +7 -0
- package/src/client/components/Editor/Editor.css +885 -0
- package/src/client/components/Editor/Editor.tsx +484 -0
- package/src/client/components/Editor/ImageDialog.css +344 -0
- package/src/client/components/Editor/ImageDialog.tsx +367 -0
- package/src/client/components/Editor/LinkDialog.css +326 -0
- package/src/client/components/Editor/LinkDialog.tsx +332 -0
- package/src/client/components/Editor/index.ts +6 -0
- package/src/client/components/FrontmatterForm/FrontmatterForm.css +468 -0
- package/src/client/components/FrontmatterForm/FrontmatterForm.tsx +914 -0
- package/src/client/components/FrontmatterForm/index.ts +7 -0
- package/src/client/components/Header/Header.css +300 -0
- package/src/client/components/Header/Header.tsx +300 -0
- package/src/client/components/Header/index.ts +7 -0
- package/src/client/components/KeyboardShortcuts/KeyboardShortcuts.css +239 -0
- package/src/client/components/KeyboardShortcuts/KeyboardShortcuts.tsx +151 -0
- package/src/client/components/KeyboardShortcuts/index.ts +6 -0
- package/src/client/components/LazyEditor.tsx +75 -0
- package/src/client/components/LiveRegion/LiveRegion.css +19 -0
- package/src/client/components/LiveRegion/LiveRegion.tsx +60 -0
- package/src/client/components/LiveRegion/index.ts +7 -0
- package/src/client/components/SearchReplace/SearchReplacePanel.css +300 -0
- package/src/client/components/SearchReplace/SearchReplacePanel.tsx +332 -0
- package/src/client/components/SearchReplace/index.ts +7 -0
- package/src/client/components/SelectCollectionModal/SelectCollectionModal.css +308 -0
- package/src/client/components/SelectCollectionModal/SelectCollectionModal.tsx +223 -0
- package/src/client/components/SelectCollectionModal/index.ts +7 -0
- package/src/client/components/Sidebar/Sidebar.css +570 -0
- package/src/client/components/Sidebar/Sidebar.tsx +617 -0
- package/src/client/components/Sidebar/index.ts +7 -0
- package/src/client/components/SkipLink/SkipLink.css +51 -0
- package/src/client/components/SkipLink/SkipLink.tsx +67 -0
- package/src/client/components/SkipLink/index.ts +7 -0
- package/src/client/components/UnsavedChangesModal/UnsavedChangesModal.css +233 -0
- package/src/client/components/UnsavedChangesModal/UnsavedChangesModal.tsx +160 -0
- package/src/client/components/UnsavedChangesModal/index.ts +1 -0
- package/src/client/components/VersionHistory/DiffViewer.css +430 -0
- package/src/client/components/VersionHistory/DiffViewer.tsx +383 -0
- package/src/client/components/VersionHistory/VersionActions.css +318 -0
- package/src/client/components/VersionHistory/VersionActions.tsx +277 -0
- package/src/client/components/VersionHistory/VersionHistoryPanel.css +369 -0
- package/src/client/components/VersionHistory/VersionHistoryPanel.tsx +469 -0
- package/src/client/components/VersionHistory/index.ts +9 -0
- package/src/client/context/ApiContext.tsx +154 -0
- package/src/client/context/ThemeContext.tsx +172 -0
- package/src/client/hooks/useAnnounce.ts +201 -0
- package/src/client/hooks/useApi.ts +374 -0
- package/src/client/hooks/useArrowNavigation.ts +286 -0
- package/src/client/hooks/useAutosave.ts +241 -0
- package/src/client/hooks/useFocusTrap.ts +178 -0
- package/src/client/hooks/useKeyboardShortcuts.ts +203 -0
- package/src/client/hooks/useSearch.ts +206 -0
- package/src/client/hooks/useVersionHistory.ts +451 -0
- package/src/client/index.tsx +70 -0
- package/src/client/styles.css +584 -0
- package/src/client/utils/focus.ts +57 -0
- package/src/client/utils/openInEditor.ts +130 -0
- package/src/client/variables.css +304 -0
- package/src/config/defaults.ts +109 -0
- package/src/config/index.ts +32 -0
- package/src/config/loader.ts +174 -0
- package/src/config/schema.ts +161 -0
- package/src/core/constants.ts +39 -0
- package/src/core/errors.ts +739 -0
- package/src/core/index.ts +11 -0
- package/src/discovery/collections.ts +216 -0
- package/src/discovery/index.ts +33 -0
- package/src/discovery/patterns.ts +702 -0
- package/src/discovery/schema.ts +453 -0
- package/src/filesystem/images.ts +798 -0
- package/src/filesystem/index.ts +107 -0
- package/src/filesystem/reader.ts +452 -0
- package/src/filesystem/version-config.ts +390 -0
- package/src/filesystem/versions.ts +1339 -0
- package/src/filesystem/watcher.ts +226 -0
- package/src/filesystem/writer.ts +540 -0
- package/src/index.ts +61 -0
- package/src/integration.ts +228 -0
- package/src/server/assets.ts +254 -0
- package/src/server/cache.ts +355 -0
- package/src/server/index.ts +33 -0
- package/src/server/middleware.ts +209 -0
- package/src/server/routes.ts +1428 -0
- package/src/types/api.ts +61 -0
- package/src/types/config.ts +134 -0
- package/src/types/content.ts +64 -0
- package/src/types/image.ts +48 -0
- package/src/types/index.ts +58 -0
- package/src/types/version.ts +117 -0
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
import { C as CollectionConfig, b as CollectionSchema } from '../config-BmEdBDo_.js';
|
|
2
|
+
import { D as DiscoveredCollection } from '../content-BWR52vD-.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @fileoverview Collection discovery for Astro content collections
|
|
6
|
+
*
|
|
7
|
+
* This module provides functions to auto-discover content collections
|
|
8
|
+
* from an Astro project's src/content directory.
|
|
9
|
+
*
|
|
10
|
+
* ## Discovery Process:
|
|
11
|
+
* 1. Scan src/content/ for subdirectories
|
|
12
|
+
* 2. Each subdirectory is treated as a collection
|
|
13
|
+
* 3. Count content files in each collection
|
|
14
|
+
* 4. Detect file patterns from existing files
|
|
15
|
+
* 5. Auto-detect frontmatter schema from sample files
|
|
16
|
+
*
|
|
17
|
+
* @module @writenex/astro/discovery/collections
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Discover all content collections in a project
|
|
22
|
+
*
|
|
23
|
+
* Scans the src/content directory for subdirectories and treats
|
|
24
|
+
* each as a content collection.
|
|
25
|
+
*
|
|
26
|
+
* @param projectRoot - Absolute path to the project root
|
|
27
|
+
* @param contentDir - Relative path to content directory (default: src/content)
|
|
28
|
+
* @returns Array of discovered collections
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* const collections = await discoverCollections('/path/to/project');
|
|
33
|
+
* // Returns: [
|
|
34
|
+
* // { name: 'blog', path: 'src/content/blog', count: 10, ... },
|
|
35
|
+
* // { name: 'docs', path: 'src/content/docs', count: 5, ... },
|
|
36
|
+
* // ]
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
declare function discoverCollections(projectRoot: string, contentDir?: string): Promise<DiscoveredCollection[]>;
|
|
40
|
+
/**
|
|
41
|
+
* Merge discovered collections with configured collections
|
|
42
|
+
*
|
|
43
|
+
* Configured collections take precedence over discovered ones.
|
|
44
|
+
* This allows users to override auto-discovered settings.
|
|
45
|
+
*
|
|
46
|
+
* @param discovered - Auto-discovered collections
|
|
47
|
+
* @param configured - User-configured collections
|
|
48
|
+
* @returns Merged collection list
|
|
49
|
+
*/
|
|
50
|
+
declare function mergeCollections(discovered: DiscoveredCollection[], configured: CollectionConfig[]): DiscoveredCollection[];
|
|
51
|
+
/**
|
|
52
|
+
* Get a single collection by name
|
|
53
|
+
*
|
|
54
|
+
* @param projectRoot - Absolute path to the project root
|
|
55
|
+
* @param collectionName - Name of the collection
|
|
56
|
+
* @param contentDir - Relative path to content directory
|
|
57
|
+
* @returns The collection if found, undefined otherwise
|
|
58
|
+
*/
|
|
59
|
+
declare function getCollection(projectRoot: string, collectionName: string, contentDir?: string): Promise<DiscoveredCollection | undefined>;
|
|
60
|
+
/**
|
|
61
|
+
* Check if a collection exists
|
|
62
|
+
*
|
|
63
|
+
* @param projectRoot - Absolute path to the project root
|
|
64
|
+
* @param collectionName - Name of the collection
|
|
65
|
+
* @param contentDir - Relative path to content directory
|
|
66
|
+
* @returns True if the collection exists
|
|
67
|
+
*/
|
|
68
|
+
declare function collectionExists(projectRoot: string, collectionName: string, contentDir?: string): Promise<boolean>;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* @fileoverview File pattern detection for content collections
|
|
72
|
+
*
|
|
73
|
+
* This module provides functions to detect and work with file naming patterns
|
|
74
|
+
* in Astro content collections.
|
|
75
|
+
*
|
|
76
|
+
* ## Supported Patterns:
|
|
77
|
+
* - `{slug}.md` - Simple slug-based naming
|
|
78
|
+
* - `{date}-{slug}.md` - Date-prefixed naming (2024-01-15-my-post.md)
|
|
79
|
+
* - `{year}/{slug}.md` - Year folder structure
|
|
80
|
+
* - `{year}/{month}/{slug}.md` - Year/month folder structure
|
|
81
|
+
* - `{year}/{month}/{day}/{slug}.md` - Full date folder structure
|
|
82
|
+
* - `{slug}/index.md` - Folder-based with index file
|
|
83
|
+
* - `{category}/{slug}.md` - Category folder structure
|
|
84
|
+
* - `{category}/{slug}/index.md` - Category with folder-based content
|
|
85
|
+
* - `{lang}/{slug}.md` - Language-prefixed content (i18n)
|
|
86
|
+
* - `{lang}/{slug}/index.md` - Language with folder-based content
|
|
87
|
+
*
|
|
88
|
+
* ## Custom Patterns:
|
|
89
|
+
* Developers can configure custom patterns in their collection config.
|
|
90
|
+
* Custom tokens are resolved from frontmatter data or use default values.
|
|
91
|
+
*
|
|
92
|
+
* ## Detection Process:
|
|
93
|
+
* 1. Scan collection directory for all content files
|
|
94
|
+
* 2. Analyze file paths and names for common patterns
|
|
95
|
+
* 3. Score each pattern based on match frequency
|
|
96
|
+
* 4. Return the best matching pattern
|
|
97
|
+
*
|
|
98
|
+
* @module @writenex/astro/discovery/patterns
|
|
99
|
+
*/
|
|
100
|
+
/**
|
|
101
|
+
* Result of pattern detection
|
|
102
|
+
*/
|
|
103
|
+
interface PatternDetectionResult {
|
|
104
|
+
/** The detected pattern template */
|
|
105
|
+
pattern: string;
|
|
106
|
+
/** Confidence score (0-1) */
|
|
107
|
+
confidence: number;
|
|
108
|
+
/** Number of files that matched this pattern */
|
|
109
|
+
matchCount: number;
|
|
110
|
+
/** Total files analyzed */
|
|
111
|
+
totalFiles: number;
|
|
112
|
+
/** Sample matches for debugging */
|
|
113
|
+
samples: Array<{
|
|
114
|
+
filePath: string;
|
|
115
|
+
extracted: Record<string, string>;
|
|
116
|
+
}>;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Detect the file naming pattern used in a collection
|
|
120
|
+
*
|
|
121
|
+
* Analyzes all content files in the collection directory and determines
|
|
122
|
+
* the most likely pattern based on file names and structure.
|
|
123
|
+
*
|
|
124
|
+
* @param collectionPath - Absolute path to the collection directory
|
|
125
|
+
* @returns Pattern detection result with confidence score
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```typescript
|
|
129
|
+
* const result = await detectFilePattern('/project/src/content/blog');
|
|
130
|
+
* console.log(result.pattern); // "{date}-{slug}.md"
|
|
131
|
+
* console.log(result.confidence); // 0.95
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
declare function detectFilePattern(collectionPath: string): Promise<PatternDetectionResult>;
|
|
135
|
+
/**
|
|
136
|
+
* Generate a file path from a pattern and tokens
|
|
137
|
+
*
|
|
138
|
+
* @param pattern - Pattern template (e.g., "{date}-{slug}.md")
|
|
139
|
+
* @param tokens - Token values to substitute
|
|
140
|
+
* @returns Generated file path
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```typescript
|
|
144
|
+
* const path = generatePathFromPattern(
|
|
145
|
+
* "{date}-{slug}.md",
|
|
146
|
+
* { date: "2024-01-15", slug: "my-post" }
|
|
147
|
+
* );
|
|
148
|
+
* // Returns: "2024-01-15-my-post.md"
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
declare function generatePathFromPattern(pattern: string, tokens: Record<string, string>): string;
|
|
152
|
+
/**
|
|
153
|
+
* Parse a pattern template to extract token names
|
|
154
|
+
*
|
|
155
|
+
* @param pattern - Pattern template
|
|
156
|
+
* @returns Array of token names
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* ```typescript
|
|
160
|
+
* const tokens = parsePatternTokens("{year}/{month}/{slug}.md");
|
|
161
|
+
* // Returns: ["year", "month", "slug"]
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
164
|
+
declare function parsePatternTokens(pattern: string): string[];
|
|
165
|
+
/**
|
|
166
|
+
* Validate that a pattern has all required tokens
|
|
167
|
+
*
|
|
168
|
+
* @param pattern - Pattern template
|
|
169
|
+
* @param requiredTokens - Required token names
|
|
170
|
+
* @returns True if all required tokens are present
|
|
171
|
+
*/
|
|
172
|
+
declare function validatePattern(pattern: string, requiredTokens?: string[]): boolean;
|
|
173
|
+
/**
|
|
174
|
+
* Get the default extension for a pattern
|
|
175
|
+
*
|
|
176
|
+
* @param pattern - Pattern template
|
|
177
|
+
* @returns The file extension (.md or .mdx)
|
|
178
|
+
*/
|
|
179
|
+
declare function getPatternExtension(pattern: string): string;
|
|
180
|
+
/**
|
|
181
|
+
* Options for resolving pattern tokens
|
|
182
|
+
*/
|
|
183
|
+
interface ResolveTokensOptions {
|
|
184
|
+
/** The content slug */
|
|
185
|
+
slug: string;
|
|
186
|
+
/** Frontmatter data for resolving dynamic tokens */
|
|
187
|
+
frontmatter?: Record<string, unknown>;
|
|
188
|
+
/** Custom token values (override automatic resolution) */
|
|
189
|
+
customTokens?: Record<string, string>;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Resolve all tokens in a pattern to their values
|
|
193
|
+
*
|
|
194
|
+
* Token resolution priority:
|
|
195
|
+
* 1. Custom tokens (explicitly provided)
|
|
196
|
+
* 2. Known token resolvers (date, year, month, etc.)
|
|
197
|
+
* 3. Frontmatter values (for custom tokens)
|
|
198
|
+
* 4. Empty string (fallback)
|
|
199
|
+
*
|
|
200
|
+
* @param pattern - Pattern template with tokens
|
|
201
|
+
* @param options - Resolution options
|
|
202
|
+
* @returns Record of token names to resolved values
|
|
203
|
+
*
|
|
204
|
+
* @example
|
|
205
|
+
* ```typescript
|
|
206
|
+
* const tokens = resolvePatternTokens("{year}/{month}/{slug}.md", {
|
|
207
|
+
* slug: "my-post",
|
|
208
|
+
* frontmatter: { pubDate: new Date("2024-06-15") }
|
|
209
|
+
* });
|
|
210
|
+
* // Returns: { year: "2024", month: "06", slug: "my-post" }
|
|
211
|
+
* ```
|
|
212
|
+
*/
|
|
213
|
+
declare function resolvePatternTokens(pattern: string, options: ResolveTokensOptions): Record<string, string>;
|
|
214
|
+
/**
|
|
215
|
+
* Check if a pattern is valid for content creation
|
|
216
|
+
*
|
|
217
|
+
* A pattern is valid if:
|
|
218
|
+
* - It contains the {slug} token (required)
|
|
219
|
+
* - It ends with .md or .mdx
|
|
220
|
+
* - All tokens can be resolved
|
|
221
|
+
*
|
|
222
|
+
* @param pattern - Pattern template to validate
|
|
223
|
+
* @returns Validation result with error message if invalid
|
|
224
|
+
*/
|
|
225
|
+
declare function isValidPattern(pattern: string): {
|
|
226
|
+
valid: boolean;
|
|
227
|
+
error?: string;
|
|
228
|
+
};
|
|
229
|
+
/**
|
|
230
|
+
* Get list of all supported token names
|
|
231
|
+
*
|
|
232
|
+
* @returns Array of supported token names
|
|
233
|
+
*/
|
|
234
|
+
declare function getSupportedTokens(): string[];
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* @fileoverview Schema auto-detection for content collections
|
|
238
|
+
*
|
|
239
|
+
* This module analyzes frontmatter from sample content files to automatically
|
|
240
|
+
* infer the schema (field types, required status, enums, etc.).
|
|
241
|
+
*
|
|
242
|
+
* ## Detection Process:
|
|
243
|
+
* 1. Read sample files from the collection (up to 20)
|
|
244
|
+
* 2. Parse frontmatter from each file
|
|
245
|
+
* 3. Analyze field patterns across all samples
|
|
246
|
+
* 4. Infer field types and constraints
|
|
247
|
+
* 5. Generate schema definition
|
|
248
|
+
*
|
|
249
|
+
* ## Detected Types:
|
|
250
|
+
* - string: Plain text values
|
|
251
|
+
* - number: Numeric values
|
|
252
|
+
* - boolean: True/false values
|
|
253
|
+
* - date: ISO date strings or Date objects
|
|
254
|
+
* - array: Arrays (with item type detection)
|
|
255
|
+
* - image: Paths ending with image extensions
|
|
256
|
+
*
|
|
257
|
+
* @module @writenex/astro/discovery/schema
|
|
258
|
+
*/
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Result of schema detection
|
|
262
|
+
*/
|
|
263
|
+
interface SchemaDetectionResult {
|
|
264
|
+
/** The detected schema */
|
|
265
|
+
schema: CollectionSchema;
|
|
266
|
+
/** Number of files analyzed */
|
|
267
|
+
samplesAnalyzed: number;
|
|
268
|
+
/** Confidence score (0-1) based on sample consistency */
|
|
269
|
+
confidence: number;
|
|
270
|
+
/** Fields that had inconsistent types across samples */
|
|
271
|
+
warnings: string[];
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Analyze frontmatter from content items to detect schema
|
|
275
|
+
*
|
|
276
|
+
* @param collectionPath - Absolute path to the collection directory
|
|
277
|
+
* @returns Schema detection result
|
|
278
|
+
*
|
|
279
|
+
* @example
|
|
280
|
+
* ```typescript
|
|
281
|
+
* const result = await detectSchema('/project/src/content/blog');
|
|
282
|
+
* console.log(result.schema);
|
|
283
|
+
* // {
|
|
284
|
+
* // title: { type: 'string', required: true },
|
|
285
|
+
* // pubDate: { type: 'date', required: true },
|
|
286
|
+
* // draft: { type: 'boolean', required: false, default: false },
|
|
287
|
+
* // tags: { type: 'array', required: false, items: 'string' },
|
|
288
|
+
* // }
|
|
289
|
+
* ```
|
|
290
|
+
*/
|
|
291
|
+
declare function detectSchema(collectionPath: string): Promise<SchemaDetectionResult>;
|
|
292
|
+
/**
|
|
293
|
+
* Merge detected schema with user-provided schema
|
|
294
|
+
*
|
|
295
|
+
* User schema takes precedence over detected schema.
|
|
296
|
+
*
|
|
297
|
+
* @param detected - Auto-detected schema
|
|
298
|
+
* @param userSchema - User-provided schema overrides
|
|
299
|
+
* @returns Merged schema
|
|
300
|
+
*/
|
|
301
|
+
declare function mergeSchema(detected: CollectionSchema, userSchema?: CollectionSchema): CollectionSchema;
|
|
302
|
+
/**
|
|
303
|
+
* Convert schema to a human-readable description
|
|
304
|
+
*
|
|
305
|
+
* @param schema - The schema to describe
|
|
306
|
+
* @returns Human-readable description
|
|
307
|
+
*/
|
|
308
|
+
declare function describeSchema(schema: CollectionSchema): string;
|
|
309
|
+
|
|
310
|
+
export { type PatternDetectionResult, type ResolveTokensOptions, type SchemaDetectionResult, collectionExists, describeSchema, detectFilePattern, detectSchema, discoverCollections, generatePathFromPattern, getCollection, getPatternExtension, getSupportedTokens, isValidPattern, mergeCollections, mergeSchema, parsePatternTokens, resolvePatternTokens, validatePattern };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {
|
|
2
|
+
collectionExists,
|
|
3
|
+
describeSchema,
|
|
4
|
+
detectSchema,
|
|
5
|
+
discoverCollections,
|
|
6
|
+
getCollection,
|
|
7
|
+
mergeCollections,
|
|
8
|
+
mergeSchema
|
|
9
|
+
} from "../chunk-CYLDJ3HZ.js";
|
|
10
|
+
import {
|
|
11
|
+
detectFilePattern,
|
|
12
|
+
generatePathFromPattern,
|
|
13
|
+
getPatternExtension,
|
|
14
|
+
getSupportedTokens,
|
|
15
|
+
isValidPattern,
|
|
16
|
+
parsePatternTokens,
|
|
17
|
+
resolvePatternTokens,
|
|
18
|
+
validatePattern
|
|
19
|
+
} from "../chunk-AAOQHQPU.js";
|
|
20
|
+
import "../chunk-CRPZUUDU.js";
|
|
21
|
+
export {
|
|
22
|
+
collectionExists,
|
|
23
|
+
describeSchema,
|
|
24
|
+
detectFilePattern,
|
|
25
|
+
detectSchema,
|
|
26
|
+
discoverCollections,
|
|
27
|
+
generatePathFromPattern,
|
|
28
|
+
getCollection,
|
|
29
|
+
getPatternExtension,
|
|
30
|
+
getSupportedTokens,
|
|
31
|
+
isValidPattern,
|
|
32
|
+
mergeCollections,
|
|
33
|
+
mergeSchema,
|
|
34
|
+
parsePatternTokens,
|
|
35
|
+
resolvePatternTokens,
|
|
36
|
+
validatePattern
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Custom error classes for @writenex/astro
|
|
3
|
+
*
|
|
4
|
+
* This module provides categorized error types for better error handling,
|
|
5
|
+
* debugging, and user-facing error messages across the integration.
|
|
6
|
+
*
|
|
7
|
+
* ## Error Categories:
|
|
8
|
+
* - Configuration errors (invalid config, missing files)
|
|
9
|
+
* - Filesystem errors (read/write failures, permissions)
|
|
10
|
+
* - Content errors (parsing, validation, not found)
|
|
11
|
+
* - API errors (request handling, validation)
|
|
12
|
+
* - Version history errors (manifest, storage)
|
|
13
|
+
*
|
|
14
|
+
* @module @writenex/astro/core/errors
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Error codes for categorization and i18n support
|
|
18
|
+
*/
|
|
19
|
+
declare enum WritenexErrorCode {
|
|
20
|
+
CONFIG_NOT_FOUND = "CONFIG_NOT_FOUND",
|
|
21
|
+
CONFIG_INVALID = "CONFIG_INVALID",
|
|
22
|
+
CONFIG_PARSE_ERROR = "CONFIG_PARSE_ERROR",
|
|
23
|
+
FS_READ_ERROR = "FS_READ_ERROR",
|
|
24
|
+
FS_WRITE_ERROR = "FS_WRITE_ERROR",
|
|
25
|
+
FS_DELETE_ERROR = "FS_DELETE_ERROR",
|
|
26
|
+
FS_PERMISSION_DENIED = "FS_PERMISSION_DENIED",
|
|
27
|
+
FS_PATH_NOT_FOUND = "FS_PATH_NOT_FOUND",
|
|
28
|
+
FS_PATH_TRAVERSAL = "FS_PATH_TRAVERSAL",
|
|
29
|
+
CONTENT_NOT_FOUND = "CONTENT_NOT_FOUND",
|
|
30
|
+
CONTENT_PARSE_ERROR = "CONTENT_PARSE_ERROR",
|
|
31
|
+
CONTENT_VALIDATION_ERROR = "CONTENT_VALIDATION_ERROR",
|
|
32
|
+
CONTENT_ALREADY_EXISTS = "CONTENT_ALREADY_EXISTS",
|
|
33
|
+
CONTENT_INVALID_SLUG = "CONTENT_INVALID_SLUG",
|
|
34
|
+
CONTENT_CONFLICT = "CONTENT_CONFLICT",
|
|
35
|
+
COLLECTION_NOT_FOUND = "COLLECTION_NOT_FOUND",
|
|
36
|
+
COLLECTION_EMPTY = "COLLECTION_EMPTY",
|
|
37
|
+
COLLECTION_DISCOVERY_ERROR = "COLLECTION_DISCOVERY_ERROR",
|
|
38
|
+
API_BAD_REQUEST = "API_BAD_REQUEST",
|
|
39
|
+
API_METHOD_NOT_ALLOWED = "API_METHOD_NOT_ALLOWED",
|
|
40
|
+
API_INTERNAL_ERROR = "API_INTERNAL_ERROR",
|
|
41
|
+
API_TIMEOUT = "API_TIMEOUT",
|
|
42
|
+
IMAGE_INVALID_TYPE = "IMAGE_INVALID_TYPE",
|
|
43
|
+
IMAGE_TOO_LARGE = "IMAGE_TOO_LARGE",
|
|
44
|
+
IMAGE_UPLOAD_ERROR = "IMAGE_UPLOAD_ERROR",
|
|
45
|
+
IMAGE_NOT_FOUND = "IMAGE_NOT_FOUND",
|
|
46
|
+
VERSION_NOT_FOUND = "VERSION_NOT_FOUND",
|
|
47
|
+
VERSION_MANIFEST_CORRUPT = "VERSION_MANIFEST_CORRUPT",
|
|
48
|
+
VERSION_LOCK_TIMEOUT = "VERSION_LOCK_TIMEOUT",
|
|
49
|
+
VERSION_SAVE_ERROR = "VERSION_SAVE_ERROR",
|
|
50
|
+
VERSION_RESTORE_ERROR = "VERSION_RESTORE_ERROR",
|
|
51
|
+
PATTERN_INVALID = "PATTERN_INVALID",
|
|
52
|
+
PATTERN_MISSING_TOKEN = "PATTERN_MISSING_TOKEN",
|
|
53
|
+
UNKNOWN_ERROR = "UNKNOWN_ERROR"
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Base error class for all Writenex errors
|
|
57
|
+
*
|
|
58
|
+
* Provides structured error information including error code,
|
|
59
|
+
* HTTP status, and optional context data for debugging.
|
|
60
|
+
*/
|
|
61
|
+
declare class WritenexError extends Error {
|
|
62
|
+
/** Error code for categorization */
|
|
63
|
+
readonly code: WritenexErrorCode;
|
|
64
|
+
/** HTTP status code for API responses */
|
|
65
|
+
readonly httpStatus: number;
|
|
66
|
+
/** Additional context data for debugging */
|
|
67
|
+
readonly context?: Record<string, unknown>;
|
|
68
|
+
/** Original error if this wraps another error */
|
|
69
|
+
readonly cause?: Error;
|
|
70
|
+
constructor(code: WritenexErrorCode, message: string, options?: {
|
|
71
|
+
context?: Record<string, unknown>;
|
|
72
|
+
cause?: Error;
|
|
73
|
+
});
|
|
74
|
+
/**
|
|
75
|
+
* Convert error to JSON for API responses
|
|
76
|
+
*/
|
|
77
|
+
toJSON(): Record<string, unknown>;
|
|
78
|
+
/**
|
|
79
|
+
* Create a user-friendly error message
|
|
80
|
+
*/
|
|
81
|
+
toUserMessage(): string;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Error thrown when content was modified externally (conflict detection)
|
|
85
|
+
*
|
|
86
|
+
* This error includes both the server version and the client's expected mtime
|
|
87
|
+
* to help resolve the conflict.
|
|
88
|
+
*/
|
|
89
|
+
declare class ContentConflictError extends WritenexError {
|
|
90
|
+
/** Current content on disk */
|
|
91
|
+
readonly serverContent: string;
|
|
92
|
+
/** Server's current mtime */
|
|
93
|
+
readonly serverMtime: number;
|
|
94
|
+
/** Client's expected mtime */
|
|
95
|
+
readonly clientMtime: number;
|
|
96
|
+
constructor(collection: string, contentId: string, serverContent: string, serverMtime: number, clientMtime: number);
|
|
97
|
+
/**
|
|
98
|
+
* Override toJSON to include conflict-specific data
|
|
99
|
+
*/
|
|
100
|
+
toJSON(): Record<string, unknown>;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Check if an error is a WritenexError
|
|
104
|
+
*/
|
|
105
|
+
declare function isWritenexError(error: unknown): error is WritenexError;
|
|
106
|
+
|
|
107
|
+
export { ContentConflictError as C, WritenexError as W, WritenexErrorCode as a, isWritenexError as i };
|