|
| 1 | +import { PipelineStage } from '@typematter/pipeline'; |
| 2 | + |
| 3 | +declare module '@typematter/pipeline' { |
| 4 | + interface PipelineContext { |
| 5 | + content?: string; |
| 6 | + name?: string; |
| 7 | + } |
| 8 | +} |
| 9 | +declare const createLocalLoader: (path: string) => PipelineStage; |
| 10 | + |
| 11 | +declare module '@typematter/pipeline' { |
| 12 | + interface PipelineContext { |
| 13 | + content?: string; |
| 14 | + name?: string; |
| 15 | + } |
| 16 | +} |
| 17 | +declare const createRemoteLoader: (baseUrl: string | URL) => PipelineStage; |
| 18 | + |
1 | 19 | interface UnknownField { |
2 | 20 | type: string; |
3 | 21 | description?: string; |
@@ -92,35 +110,14 @@ interface ArchetypeStore { |
92 | 110 | load(name: string): Promise<Archetype>; |
93 | 111 | } |
94 | 112 |
|
95 | | -/** |
96 | | - * Error thrown when a local archetype fails to load. |
97 | | - */ |
98 | | -declare class LocalArchetypeLoadError extends ArchetypeLoadError { |
99 | | - constructor(name: string, originalError: Error); |
| 113 | +interface StoreOptions { |
| 114 | + /** |
| 115 | + * Cache loaded archetypes |
| 116 | + */ |
| 117 | + cache?: boolean; |
100 | 118 | } |
101 | | -/** |
102 | | - * Creates a store that loads archetype schemas from local markdown files. |
103 | | - * |
104 | | - * @param root - The root directory containing the archetype schemas. |
105 | | - * @returns A store that loads archetype schemas from local markdown files. |
106 | | - * @throws {LocalArchetypeLoadError} If the archetype schema could not be loaded |
107 | | - */ |
108 | | -declare const createLocalStore: (root: string) => ArchetypeStore; |
109 | 119 |
|
110 | | -/** |
111 | | - * Error thrown when a remote archetype fails to load. |
112 | | - */ |
113 | | -declare class RemoteArchetypeLoadError extends ArchetypeLoadError { |
114 | | - constructor(name: string, statusText: string); |
115 | | -} |
116 | | -/** |
117 | | - * Creates a store that loads archetype schemas from remote markdown files. |
118 | | - * |
119 | | - * @param baseUrl - The base URL to load the archetype from. |
120 | | - * @returns A store that loads archetype schemas from remote markdown files. |
121 | | - * @throws {RemoteArchetypeLoadError} If the archetype schema could not be loaded |
122 | | - */ |
123 | | -declare const createRemoteStore: (baseUrl: string | URL) => ArchetypeStore; |
| 120 | +declare const createStore: (loadContent: PipelineStage, options?: StoreOptions) => ArchetypeStore; |
124 | 121 |
|
125 | 122 | interface ValidationError { |
126 | 123 | path: string[]; |
@@ -163,10 +160,6 @@ interface ValidatorOptions { |
163 | 160 | * Where to load archetypes from |
164 | 161 | */ |
165 | 162 | store: ArchetypeStore; |
166 | | - /** |
167 | | - * Cache loaded archetypes |
168 | | - */ |
169 | | - cache?: boolean; |
170 | 163 | /** |
171 | 164 | * Validation options |
172 | 165 | */ |
@@ -194,4 +187,4 @@ interface ValidatorOptions { |
194 | 187 | */ |
195 | 188 | declare const createValidator: (options: ValidatorOptions) => Promise<ArchetypeValidator>; |
196 | 189 |
|
197 | | -export { type Archetype, ArchetypeLoadError, type ArchetypeStore, type ArchetypeValidator, LocalArchetypeLoadError, RemoteArchetypeLoadError, type SchemaField, type ValidationError, type ValidationResult, type ValidatorOptions, createLocalStore, createRemoteStore, createValidator }; |
| 190 | +export { type Archetype, ArchetypeLoadError, type ArchetypeStore, type ArchetypeValidator, type SchemaField, type ValidationError, type ValidationResult, type ValidatorOptions, createLocalLoader, createRemoteLoader, createStore, createValidator }; |
0 commit comments