@interactive-inc/docs-client 1.0.19 → 1.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/build/index.d.ts CHANGED
@@ -1,385 +1,452 @@
1
+ import { D as DocFileSystem, a as DocPathSystem } from './doc-file-system-BQAOBIO-.js';
1
2
  import { z } from 'zod';
2
3
  import { zDocFileMd, zDocFileUnknown, zDocClientConfig, zDocFilePath, zDocFileIndexSchemaField, zDocSchemaFieldText, zDocSchemaFieldNumber, zDocSchemaFieldBoolean, zDocSchemaFieldRelation, zDocSchemaFieldSelectText, zDocSchemaFieldSelectNumber, zDocSchemaFieldMultiText, zDocSchemaFieldMultiNumber, zDocSchemaFieldMultiRelation, zDocSchemaFieldMultiSelectText, zDocSchemaFieldMultiSelectNumber, zDocFileIndex, zDocRelation, zDocRelationFile, zDocMetaFieldRelation, zDocMetaFieldMultiRelation, zDocMetaFieldText, zDocMetaFieldNumber, zDocMetaFieldBoolean, zDocMetaFieldMultiText, zDocMetaFieldMultiNumber, zDocRelationField, zDocMetaField, zDocMetaFieldSelectText, zDocMetaFieldSelectNumber, zDocMetaFieldMultiSelectText, zDocMetaFieldMultiSelectNumber, zDocMetaFieldTypeText, zDocMetaFieldTypeNumber, zDocMetaFieldTypeBoolean, zDocMetaFieldTypeSelectText, zDocMetaFieldTypeSelectNumber, zDocMetaFieldTypeRelation, zDocMetaFieldType } from './models.js';
3
4
  export { zDocCustomSchema, zDocCustomSchemaField, zDocCustomSchemaFieldBoolean, zDocCustomSchemaFieldMultiNumber, zDocCustomSchemaFieldMultiRelation, zDocCustomSchemaFieldMultiSelectNumber, zDocCustomSchemaFieldMultiSelectText, zDocCustomSchemaFieldMultiText, zDocCustomSchemaFieldNumber, zDocCustomSchemaFieldRelation, zDocCustomSchemaFieldSelectNumber, zDocCustomSchemaFieldSelectText, zDocCustomSchemaFieldText, zDocFile, zDocFileDirectory, zDocFileIndexContent, zDocFileIndexMeta, zDocFileIndexMetaInput, zDocFileIndexSchema, zDocFileIndexSchemaInput, zDocFileMdContent, zDocFileMdContentInput, zDocFileMdInput, zDocFileMdMeta, zDocFileMdMetaInput, zDocMetaFieldTypeMultiNumber, zDocMetaFieldTypeMultiRelation, zDocMetaFieldTypeMultiSelectNumber, zDocMetaFieldTypeMultiSelectText, zDocMetaFieldTypeMultiText, zDocTreeDirectoryNode, zDocTreeFileNode, zDocTreeNode } from './models.js';
4
5
 
5
6
  /**
6
- * Path operations system
7
+ * Single boolean type schema field
7
8
  */
8
- declare class DocPathSystem {
9
- readonly separator = "/";
10
- /**
11
- * Join paths
12
- */
13
- join(...paths: string[]): string;
14
- /**
15
- * Get filename with extension
16
- */
17
- basename(path: string, ext?: string): string;
18
- /**
19
- * Get directory name
20
- */
21
- dirname(path: string): string;
22
- /**
23
- * Get extension
24
- */
25
- extname(path: string): string;
26
- /**
27
- * Calculate relative path
28
- */
29
- relative(from: string, to: string): string;
30
- /**
31
- * Convert to absolute path
32
- */
33
- resolve(...paths: string[]): string;
34
- /**
35
- * Normalize path
36
- */
37
- normalize(path: string): string;
9
+ declare class DocSchemaFieldBooleanValue<T extends RecordKey> {
10
+ readonly key: T;
11
+ readonly value: DocSchemaFieldBoolean;
12
+ constructor(key: T, value: DocSchemaFieldBoolean);
13
+ get type(): "boolean";
14
+ get required(): boolean;
15
+ get title(): string;
16
+ get description(): string;
17
+ get default(): boolean | null;
18
+ readonly isArray = false;
19
+ readonly isSingle = true;
20
+ readonly isBoolean = true;
21
+ toJson(): DocFileIndexSchemaField;
38
22
  /**
39
- * Check if path is absolute
23
+ * Validate value type
40
24
  */
41
- isAbsolute(path: string): boolean;
25
+ validate(value: unknown): boolean;
26
+ static empty(key: RecordKey): DocSchemaFieldBooleanValue<RecordKey>;
27
+ static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldBooleanValue<RecordKey>;
42
28
  }
43
29
 
44
- type Props$9 = {
45
- basePath: string;
46
- pathSystem?: DocPathSystem;
47
- };
48
30
  /**
49
- * File system wrapper
31
+ * Multiple relation type schema field
50
32
  */
51
- declare class DocFileSystem {
52
- private readonly basePath;
53
- private readonly pathSystem;
54
- constructor(props: Props$9);
55
- /**
56
- * Read file content at the specified path
57
- */
58
- readFile(relativePath: string): Promise<string | null | Error>;
59
- /**
60
- * Write content to file at the specified path (creates directory if needed)
61
- */
62
- writeFile(relativePath: string, content: string): Promise<Error | null>;
63
- /**
64
- * Delete file at the specified path
65
- */
66
- deleteFile(relativePath: string): Promise<Error | null>;
67
- /**
68
- * Get file name from path
69
- */
70
- readFileName(relativePath: string): string;
71
- /**
72
- * Get file extension from path
73
- */
74
- readFileExtension(relativePath: string): string;
75
- /**
76
- * Get directory path where the file exists
77
- */
78
- readFileDirectory(relativePath: string): string;
79
- /**
80
- * Get list of entries in directory
81
- */
82
- readDirectoryFileNames(relativePath?: string): Promise<string[] | Error>;
83
- readDirectoryFilePaths(relativePath: string): Promise<string[] | Error>;
84
- /**
85
- * Check if path is a directory
86
- */
87
- isDirectory(relativePath: string): Promise<boolean>;
88
- /**
89
- * Check if path is a file
90
- */
91
- isFile(relativePath: string): Promise<boolean>;
92
- /**
93
- * Check if file or directory exists
94
- */
95
- exists(relativePath: string): Promise<boolean>;
96
- /**
97
- * Check if directory exists
98
- */
99
- directoryExists(relativePath: string): Promise<boolean>;
100
- /**
101
- * Check if file exists
102
- */
103
- fileExists(relativePath: string): Promise<boolean>;
104
- /**
105
- * Get base path
106
- */
107
- getBasePath(): string;
108
- /**
109
- * Convert relative path to absolute path
110
- */
111
- resolve(relativePath: string): string;
112
- /**
113
- * Create directory
114
- */
115
- createDirectory(relativePath: string): Promise<Error | null>;
116
- /**
117
- * Get file size in bytes
118
- */
119
- getFileSize(relativePath: string): Promise<number | Error>;
120
- /**
121
- * Create directory if it doesn't exist
122
- */
123
- ensureDirectoryExists(relativePath: string): Promise<Error | null>;
124
- /**
125
- * Copy file
126
- */
127
- copyFile(sourcePath: string, destinationPath: string): Promise<Error | null>;
128
- /**
129
- * Move file
130
- */
131
- moveFile(sourcePath: string, destinationPath: string): Promise<Error | null>;
132
- /**
133
- * Get file last modified time
134
- */
135
- getFileModifiedTime(relativePath: string): Promise<Date | Error>;
33
+ declare class DocSchemaFieldMultiRelationValue<T extends RecordKey> {
34
+ readonly key: T;
35
+ readonly value: DocSchemaFieldMultiRelation;
36
+ constructor(key: T, value: DocSchemaFieldMultiRelation);
37
+ get type(): "multi-relation";
38
+ get required(): boolean;
39
+ get title(): string;
40
+ get description(): string;
41
+ get default(): string[] | null;
42
+ get path(): string;
43
+ readonly isArray = true;
44
+ readonly isSingle = false;
45
+ readonly isRelation = true;
136
46
  /**
137
- * Get file creation time
47
+ * Validate value
138
48
  */
139
- getFileCreatedTime(relativePath: string): Promise<Date | Error>;
49
+ validate(value: unknown): boolean;
50
+ toJson(): DocFileIndexSchemaField;
51
+ static empty<T extends RecordKey>(key: T): DocSchemaFieldMultiRelationValue<T>;
52
+ static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldMultiRelationValue<RecordKey>;
140
53
  }
141
54
 
142
55
  /**
143
- * Meta
56
+ * Multiple select number type schema field
144
57
  */
145
- declare class DocFileMdMetaValue<T extends DocCustomSchema> {
146
- readonly value: SchemaToValueType<T>;
147
- readonly customSchema: T;
148
- constructor(value: SchemaToValueType<T>, customSchema: T);
149
- get keys(): Array<keyof T>;
150
- /**
151
- * Return a new instance with a single property updated
152
- */
153
- withProperty<K extends keyof T>(key: K, value: BaseFieldValueType<ExtractFieldType<T[K]>>): DocFileMdMetaValue<T>;
154
- schemaField<K extends keyof T>(key: K): T[K];
155
- field<K extends keyof T>(key: K): FieldValueType<ExtractFieldType<T[K]>, ExtractRequired<T[K]>>;
156
- relation(key: keyof T): DocMetaFieldRelation;
157
- multiRelation(key: keyof T): DocMetaFieldMultiRelation;
158
- text(key: keyof T): DocMetaFieldText;
159
- number(key: keyof T): DocMetaFieldNumber;
160
- boolean(key: keyof T): DocMetaFieldBoolean;
161
- multiText(key: keyof T): DocMetaFieldMultiText;
162
- multiNumber(key: keyof T): DocMetaFieldMultiNumber;
163
- hasKey(key: keyof T): boolean;
164
- toJson(): SchemaToValueType<T>;
165
- toYaml(): string;
166
- private validateValue;
167
- private getValueField;
58
+ declare class DocSchemaFieldMultiSelectNumberValue<T extends RecordKey> {
59
+ readonly key: T;
60
+ readonly value: DocSchemaFieldMultiSelectNumber;
61
+ constructor(key: T, value: DocSchemaFieldMultiSelectNumber);
62
+ get type(): "multi-select-number";
63
+ get required(): boolean;
64
+ get title(): string;
65
+ get description(): string;
66
+ get default(): number[] | null;
67
+ get options(): number[];
68
+ readonly isArray = true;
69
+ readonly isSingle = false;
70
+ readonly isSelect = true;
71
+ readonly isNumberSelect = true;
168
72
  /**
169
- * Generate from Markdown text
73
+ * Validate value
170
74
  */
171
- static fromYamlText<T extends DocCustomSchema>(yamlText: string, customSchema: T): DocFileMdMetaValue<T>;
172
- static empty<T extends DocCustomSchema>(customSchema: T): DocFileMdMetaValue<T>;
75
+ validate(value: unknown): boolean;
76
+ toJson(): DocFileIndexSchemaField;
77
+ static empty<T extends RecordKey>(key: T): DocSchemaFieldMultiSelectNumberValue<T>;
78
+ static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldMultiSelectNumberValue<RecordKey>;
173
79
  }
174
80
 
175
81
  /**
176
- * File: Markdown > Content
82
+ * Multiple select text type schema field
177
83
  */
178
- declare class DocFileMdContentValue<T extends DocCustomSchema> {
179
- readonly value: DocFileMdContent<T>;
180
- private readonly customSchema;
181
- constructor(value: DocFileMdContent<T>, customSchema: T);
182
- /**
183
- * Content body (does not include frontMatter)
184
- */
185
- get body(): string;
186
- /**
187
- * Title
188
- */
84
+ declare class DocSchemaFieldMultiSelectTextValue<T extends RecordKey> {
85
+ readonly key: T;
86
+ readonly value: DocSchemaFieldMultiSelectText;
87
+ constructor(key: T, value: DocSchemaFieldMultiSelectText);
88
+ get type(): "multi-select-text";
89
+ get required(): boolean;
189
90
  get title(): string;
190
- /**
191
- * Description
192
- */
193
91
  get description(): string;
92
+ get default(): string[] | null;
93
+ get options(): string[];
94
+ readonly isArray = true;
95
+ readonly isSingle = false;
96
+ readonly isSelect = true;
97
+ readonly isTextSelect = true;
194
98
  /**
195
- * FrontMatter (uses constructor's Zod schema or argument schema)
196
- */
197
- meta(): DocFileMdMetaValue<T>;
198
- /**
199
- * Update title
200
- */
201
- withTitle(title: string): DocFileMdContentValue<T>;
202
- /**
203
- * Update description
204
- */
205
- withDescription(description: string, defaultTitle?: string): DocFileMdContentValue<T>;
206
- /**
207
- * Update body
208
- */
209
- withBody(body: string): DocFileMdContentValue<T>;
210
- /**
211
- * @deprecated Use `withBody` instead
212
- */
213
- withContent(content: string): DocFileMdContentValue<T>;
214
- /**
215
- * Update FrontMatter
216
- */
217
- withMeta<U extends DocCustomSchema>(meta: DocFileMdMetaValue<U>): DocFileMdContentValue<U>;
218
- withMeta(updater: UpdateFunction<DocFileMdMetaValue<T>>): DocFileMdContentValue<T>;
219
- /**
220
- * Update specific property of FrontMatter
221
- */
222
- withMetaProperty<K extends keyof T>(key: K, value: BaseFieldValueType<ExtractFieldType<T[K]>>): DocFileMdContentValue<T>;
223
- /**
224
- * Generate from Markdown text
225
- */
226
- static fromMarkdown<T extends DocCustomSchema>(markdown: string, customSchema: T): DocFileMdContentValue<T>;
227
- /**
228
- * Generate complete text combining FrontMatter and body
229
- */
230
- toText(): string;
231
- /**
232
- * Generate empty content
233
- */
234
- static empty<T extends DocCustomSchema = DocCustomSchema>(title: string, customSchema: T): DocFileMdContentValue<T>;
235
- /**
236
- * Output in JSON format
99
+ * Validate value
237
100
  */
238
- toJson(): DocFileMdContent<T>;
101
+ validate(value: unknown): boolean;
102
+ toJson(): DocFileIndexSchemaField;
103
+ static empty<T extends RecordKey>(key: T): DocSchemaFieldMultiSelectTextValue<T>;
104
+ static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldMultiSelectTextValue<RecordKey>;
239
105
  }
240
106
 
241
107
  /**
242
- * Markdown file entity
108
+ * Multiple text type schema field
243
109
  */
244
- declare class DocFileMdEntity<T extends DocCustomSchema> {
245
- readonly value: DocFileMd<T>;
246
- private readonly customSchema;
247
- constructor(value: DocFileMd<T>, customSchema: T);
248
- /**
249
- * Content
250
- */
251
- get content(): DocFileMdContentValue<T>;
110
+ declare class DocSchemaFieldMultiTextValue<T extends RecordKey> {
111
+ readonly key: T;
112
+ readonly value: DocSchemaFieldMultiText;
113
+ constructor(key: T, value: DocSchemaFieldMultiText);
114
+ get type(): "multi-text";
115
+ get required(): boolean;
116
+ get title(): string;
117
+ get description(): string;
118
+ get default(): string[] | null;
119
+ readonly isArray = true;
120
+ readonly isSingle = false;
121
+ readonly isText = true;
122
+ toJson(): DocFileIndexSchemaField;
252
123
  /**
253
- * Path information
124
+ * Validate value type
254
125
  */
255
- get path(): DocFilePath;
126
+ validate(value: unknown): boolean;
127
+ static empty<T extends RecordKey>(key: T): DocSchemaFieldMultiTextValue<T>;
128
+ static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldMultiTextValue<RecordKey>;
129
+ }
130
+
131
+ /**
132
+ * Single number type schema field
133
+ */
134
+ declare class DocSchemaFieldNumberValue<T extends RecordKey> {
135
+ readonly key: T;
136
+ readonly value: DocSchemaFieldNumber;
137
+ constructor(key: T, value: DocSchemaFieldNumber);
138
+ get type(): "number";
139
+ get required(): boolean;
140
+ get title(): string;
141
+ get description(): string;
142
+ get default(): number | null;
143
+ readonly isArray = false;
144
+ readonly isSingle = true;
145
+ readonly isNumber = true;
146
+ toJson(): DocFileIndexSchemaField;
256
147
  /**
257
- * Update content
148
+ * Validate value type
258
149
  */
259
- withContent(content: DocFileMdContentValue<T>): DocFileMdEntity<T>;
260
- withContent(updater: UpdateFunction<DocFileMdContentValue<T>>): DocFileMdEntity<T>;
150
+ validate(value: unknown): boolean;
151
+ static empty(key: RecordKey): DocSchemaFieldNumberValue<RecordKey>;
152
+ static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldNumberValue<RecordKey>;
153
+ }
154
+
155
+ /**
156
+ * Single relation type schema field
157
+ */
158
+ declare class DocSchemaFieldRelationValue<T extends RecordKey> {
159
+ readonly key: T;
160
+ readonly value: DocSchemaFieldRelation;
161
+ constructor(key: T, value: DocSchemaFieldRelation);
162
+ get type(): "relation";
163
+ get required(): boolean;
164
+ get title(): string;
165
+ get description(): string;
166
+ get default(): string | null;
167
+ get path(): string;
168
+ readonly isArray = false;
169
+ readonly isSingle = true;
170
+ readonly isRelation = true;
171
+ toJson(): DocFileIndexSchemaField;
261
172
  /**
262
- * Update path
173
+ * Validate value type
263
174
  */
264
- withPath(path: DocFilePath): DocFileMdEntity<T>;
265
- withPath(updater: UpdateFunction<DocFilePath>): DocFileMdEntity<T>;
266
- withMeta(meta: DocFileMdMetaValue<T>): DocFileMdEntity<T>;
267
- withMeta(updater: UpdateFunction<DocFileMdMetaValue<T>>): DocFileMdEntity<T>;
268
- withTitle(title: string): DocFileMdEntity<T>;
269
- withDescription(description: string, defaultTitle?: string): DocFileMdEntity<T>;
175
+ validate(value: unknown): boolean;
176
+ static empty(key: RecordKey): DocSchemaFieldRelationValue<RecordKey>;
177
+ static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldRelationValue<RecordKey>;
178
+ }
179
+
180
+ /**
181
+ * Single select number type schema field
182
+ */
183
+ declare class DocSchemaFieldSelectNumberValue<T extends RecordKey> {
184
+ readonly key: T;
185
+ readonly value: DocSchemaFieldSelectNumber;
186
+ constructor(key: T, value: DocSchemaFieldSelectNumber);
187
+ get type(): "select-number";
188
+ get required(): boolean;
189
+ get title(): string;
190
+ get description(): string;
191
+ get default(): number | null;
192
+ get options(): number[];
193
+ readonly isArray = false;
194
+ readonly isSingle = true;
195
+ readonly isSelect = true;
196
+ readonly isNumberSelect = true;
270
197
  /**
271
- * z.infer<typeof zDocFileMd>
198
+ * Validate value
272
199
  */
273
- toJson(): z.infer<typeof zDocFileMd>;
200
+ validate(value: unknown): boolean;
201
+ toJson(): DocFileIndexSchemaField;
202
+ static empty<T extends RecordKey>(key: T): DocSchemaFieldSelectNumberValue<T>;
203
+ static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldSelectNumberValue<RecordKey>;
274
204
  }
275
205
 
276
- type Props$8<T extends DocCustomSchema> = {
277
- path: string;
278
- fileSystem: DocFileSystem;
279
- pathSystem: DocPathSystem;
280
- customSchema: T;
281
- config: DocClientConfig;
282
- };
283
206
  /**
284
- * File reference
207
+ * Single select text type schema field
285
208
  */
286
- declare class DocFileMdReference<T extends DocCustomSchema> {
287
- private readonly props;
288
- private readonly pathSystem;
289
- private readonly customSchema;
290
- constructor(props: Props$8<T>);
291
- get fileSystem(): DocFileSystem;
292
- get basePath(): string;
293
- get path(): string;
294
- get fullPath(): string;
295
- get directoryPath(): string;
296
- get archivedPath(): string;
297
- get name(): string;
298
- get nameWithExtension(): string;
299
- exists(): Promise<boolean>;
300
- read(): Promise<DocFileMdEntity<T> | Error>;
209
+ declare class DocSchemaFieldSelectTextValue<T extends RecordKey> {
210
+ readonly key: T;
211
+ readonly value: DocSchemaFieldSelectText;
212
+ constructor(key: T, value: DocSchemaFieldSelectText);
213
+ get type(): "select-text";
214
+ get required(): boolean;
215
+ get title(): string;
216
+ get description(): string;
217
+ get default(): string | null;
218
+ get options(): string[];
219
+ readonly isArray = false;
220
+ readonly isSingle = true;
221
+ readonly isSelect = true;
222
+ readonly isTextSelect = true;
223
+ toJson(): DocFileIndexSchemaField;
301
224
  /**
302
- * Read file content
225
+ * Validate value type
303
226
  */
304
- readText(): Promise<Error | string>;
227
+ validate(value: unknown): boolean;
228
+ static empty<T extends RecordKey>(key: T): DocSchemaFieldSelectTextValue<T>;
229
+ static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldSelectTextValue<RecordKey>;
230
+ }
231
+
232
+ /**
233
+ * Single text type schema field
234
+ */
235
+ declare class DocSchemaFieldTextValue<T extends RecordKey> {
236
+ readonly key: T;
237
+ readonly value: DocSchemaFieldText;
238
+ constructor(key: T, value: DocSchemaFieldText);
239
+ get type(): "text";
240
+ get required(): boolean;
241
+ get title(): string;
242
+ get description(): string;
243
+ get default(): string | null;
244
+ readonly isArray = false;
245
+ readonly isSingle = true;
246
+ readonly isText = true;
247
+ toJson(): DocFileIndexSchemaField;
305
248
  /**
306
- * Create empty DocFileMdEntity
249
+ * Validate value type
307
250
  */
308
- empty(): DocFileMdEntity<T>;
251
+ validate(value: unknown): boolean;
252
+ static empty(key: RecordKey): DocSchemaFieldTextValue<RecordKey>;
253
+ static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldTextValue<RecordKey>;
254
+ }
255
+
256
+ /**
257
+ * Multiple number type schema field
258
+ */
259
+ declare class DocSchemaFieldMultiNumberValue<T extends RecordKey> {
260
+ readonly key: T;
261
+ readonly value: DocSchemaFieldMultiNumber;
262
+ constructor(key: T, value: DocSchemaFieldMultiNumber);
263
+ get type(): "multi-number";
264
+ get required(): boolean;
265
+ get title(): string;
266
+ get description(): string;
267
+ get default(): number[] | null;
268
+ readonly isArray = true;
269
+ readonly isSingle = false;
270
+ readonly isNumber = true;
309
271
  /**
310
- * Write entity
272
+ * Validate value
311
273
  */
312
- write(entity: DocFileMdEntity<T>): Promise<Error | null>;
313
- writeText(text: string): Promise<Error | null>;
274
+ validate(value: unknown): boolean;
275
+ toJson(): DocFileIndexSchemaField;
276
+ static empty<T extends RecordKey>(key: T): DocSchemaFieldMultiNumberValue<T>;
277
+ static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldMultiNumberValue<RecordKey>;
278
+ }
279
+
280
+ /**
281
+ * Type-safe schema value object
282
+ */
283
+ declare class DocFileIndexSchemaValue<T extends DocCustomSchema> {
284
+ readonly value: DocFileIndexSchema<keyof T>;
285
+ readonly customSchema: T;
286
+ constructor(value: DocFileIndexSchema<keyof T>, customSchema: T);
314
287
  /**
315
- * Create new file with default content
288
+ * Get list of field names
289
+ * Automatically type-safe when using Zod schema
316
290
  */
317
- writeDefault(): Promise<Error | null>;
291
+ get fieldNames(): Array<keyof T>;
318
292
  /**
319
- * Delete file
293
+ * Get field with specified field name
294
+ * Returns type-safe specific field Value object
320
295
  */
321
- delete(): Promise<Error | null>;
296
+ field<K extends keyof T>(key: K): T[K]["type"] extends infer Type ? Type extends "text" ? DocSchemaFieldTextValue<K> : Type extends "number" ? DocSchemaFieldNumberValue<K> : Type extends "boolean" ? DocSchemaFieldBooleanValue<K> : Type extends "relation" ? DocSchemaFieldRelationValue<K> : Type extends "select-text" ? DocSchemaFieldSelectTextValue<K> : Type extends "select-number" ? DocSchemaFieldSelectNumberValue<K> : Type extends "multi-text" ? DocSchemaFieldMultiTextValue<K> : Type extends "multi-number" ? DocSchemaFieldMultiNumberValue<K> : Type extends "multi-relation" ? DocSchemaFieldMultiRelationValue<K> : Type extends "multi-select-text" ? DocSchemaFieldMultiSelectTextValue<K> : Type extends "multi-select-number" ? DocSchemaFieldMultiSelectNumberValue<K> : never : never;
297
+ relation<K extends keyof T>(key: K): DocSchemaFieldRelationValue<K>;
298
+ multiRelation<K extends keyof T>(key: K): DocSchemaFieldMultiRelationValue<K>;
299
+ toJson(): DocFileIndexSchema<keyof T>;
322
300
  /**
323
- * Copy file
301
+ * Create empty schema entity
302
+ * biome-ignore lint/complexity/noBannedTypes: {} as DocCustomSchema
324
303
  */
325
- copyTo(destinationPath: string): Promise<Error | null>;
304
+ static empty(): DocFileIndexSchemaValue<{}>;
305
+ }
306
+
307
+ /**
308
+ * File: index.md > content > FrontMatter
309
+ */
310
+ declare class DocFileIndexMetaValue<T extends DocCustomSchema> {
311
+ readonly value: DocFileIndexMeta<T>;
312
+ readonly customSchema: T;
313
+ private readonly config;
314
+ private readonly additionalProperties;
315
+ constructor(value: DocFileIndexMeta<T>, customSchema: T, config: DocClientConfig, additionalProperties?: Record<string, unknown>);
326
316
  /**
327
- * Move file
317
+ * Get icon
328
318
  */
329
- moveTo(destinationPath: string): Promise<Error | null>;
319
+ get icon(): string | null;
330
320
  /**
331
- * Move file to archive and return new reference
321
+ * Get schema
332
322
  */
333
- archive(archiveDirectoryName?: string): Promise<DocFileMdReference<T>>;
323
+ schema(): DocFileIndexSchemaValue<T>;
334
324
  /**
335
- * Restore file from archive and return new reference
325
+ * Check if schema is defined
336
326
  */
337
- restore(archiveDirectoryName?: string): Promise<DocFileMdReference<T>>;
327
+ get hasSchema(): boolean;
338
328
  /**
339
- * Get file size in bytes
329
+ * Update icon field
340
330
  */
341
- size(): Promise<number | Error>;
331
+ withIcon(value: string | null): DocFileIndexMetaValue<T>;
342
332
  /**
343
- * Get file last modified time
333
+ * Update schema field
344
334
  */
345
- lastModified(): Promise<Date | Error>;
335
+ withSchema(value: DocFileIndexSchema<keyof T>): DocFileIndexMetaValue<T>;
346
336
  /**
347
- * Get file creation time
337
+ * Return a new instance with an unknown schema
338
+ * Allows accepting Record<string, unknown> schemas from external sources
348
339
  */
349
- createdAt(): Promise<Date | Error>;
350
- directory(): DocDirectoryReference<T>;
340
+ withUnknownSchema(draft: Record<string, unknown>): DocFileIndexMetaValue<DocCustomSchema>;
351
341
  /**
352
- * Get relation based on schema
342
+ * Output in JSON format
353
343
  */
354
- relation<U extends DocCustomSchema = DocCustomSchema>(key: RelationKeys<T>, targetSchema?: U): Promise<DocFileMdReference<U> | Error | null>;
344
+ toJson(): DocFileIndexMeta<T>;
355
345
  /**
356
- * Get index.md in the same directory
346
+ * Output in YAML format
357
347
  */
358
- directoryIndex(): Promise<DocFileIndexReference<T> | null>;
348
+ toYaml(): string;
359
349
  /**
360
- * Get multiple relations based on schema
350
+ * Generate from Markdown text (can process incomplete data)
361
351
  */
362
- relations<U extends DocCustomSchema = DocCustomSchema>(key: MultiRelationKeys<T>, customSchema?: U): Promise<DocFileMdReference<U>[]>;
352
+ static from<T extends DocCustomSchema>(markdownText: string, customSchema: T, config: DocClientConfig): DocFileIndexMetaValue<T>;
363
353
  /**
364
- * File: Markdown > FrontMatter
354
+ * Generate directly from data (can process incomplete data)
365
355
  */
366
- readFrontMatter(): Promise<DocFileMdMetaValue<T> | Error>;
356
+ static fromRecord<T extends DocCustomSchema>(record: Record<string, unknown>, customSchema: T, config: DocClientConfig): DocFileIndexMetaValue<T>;
367
357
  /**
368
- * File: Markdown > FrontMatter
358
+ * Generate empty FrontMatter
369
359
  */
370
- updateFrontMatter<K extends keyof T>(key: K, value: BaseFieldValueType<ExtractFieldType<T[K]>>): Promise<this | Error>;
360
+ static empty<T extends DocCustomSchema>(customSchema: T, config: DocClientConfig): DocFileIndexMetaValue<T>;
361
+ /**
362
+ * Extract icon
363
+ */
364
+ private static extractIcon;
365
+ /**
366
+ * Extract schema part
367
+ */
368
+ private static extractSchema;
369
+ /**
370
+ * Normalize entire schema
371
+ */
372
+ private static normalizeSchema;
373
+ static emptySchema<T extends DocCustomSchema>(customSchema: T): DocFileIndexSchema<keyof T>;
371
374
  }
372
375
 
373
376
  /**
374
- * Unknown file entity
377
+ * File: index.md > content
375
378
  */
376
- declare class DocFileUnknownEntity {
377
- readonly value: DocFileUnknown;
378
- constructor(value: DocFileUnknown);
379
+ declare class DocFileIndexContentValue<T extends DocCustomSchema> {
380
+ readonly value: DocFileIndexContent<T>;
381
+ private readonly customSchema;
382
+ private readonly config;
383
+ constructor(value: DocFileIndexContent<T>, customSchema: T, config: DocClientConfig);
384
+ /**
385
+ * Content body (does not include frontMatter)
386
+ */
387
+ get body(): string;
388
+ /**
389
+ * Title
390
+ */
391
+ get title(): string;
392
+ /**
393
+ * Description
394
+ */
395
+ get description(): string;
396
+ /**
397
+ * FrontMatter
398
+ */
399
+ meta(): DocFileIndexMetaValue<T>;
400
+ /**
401
+ * Update title
402
+ */
403
+ withTitle(title: string): DocFileIndexContentValue<T>;
404
+ /**
405
+ * Update description
406
+ */
407
+ withDescription(description: string, defaultTitle?: string): DocFileIndexContentValue<T>;
408
+ /**
409
+ * Generate from Markdown text
410
+ */
411
+ static fromMarkdown<T extends DocCustomSchema>(markdown: string, customSchema: T, config: DocClientConfig): DocFileIndexContentValue<T>;
412
+ /**
413
+ * Update content
414
+ */
415
+ withBody(body: string): DocFileIndexContentValue<T>;
416
+ /**
417
+ * @deprecated Use `withBody` instead
418
+ */
419
+ withContent(body: string): DocFileIndexContentValue<T>;
420
+ /**
421
+ * Update FrontMatter
422
+ */
423
+ withMeta(meta: DocFileIndexMeta<T>): DocFileIndexContentValue<T>;
424
+ /**
425
+ * Generate default index.md content
426
+ */
427
+ static empty<T extends DocCustomSchema = DocCustomSchema>(directoryName: string, customSchema: T, config: DocClientConfig): DocFileIndexContentValue<T>;
428
+ /**
429
+ * Generate complete text combining FrontMatter and body
430
+ */
431
+ toText(): string;
432
+ /**
433
+ * Output in JSON format
434
+ */
435
+ toJson(): DocFileIndexContent<T>;
436
+ }
437
+
438
+ /**
439
+ * Document directory entity
440
+ */
441
+ declare class DocFileIndexEntity<T extends DocCustomSchema> {
442
+ readonly value: DocFileIndex<T>;
443
+ private readonly customSchema;
444
+ private readonly config;
445
+ constructor(value: DocFileIndex<T>, customSchema: T, config?: DocClientConfig);
379
446
  /**
380
447
  * Content
381
448
  */
382
- get content(): string;
449
+ get content(): DocFileIndexContentValue<T>;
383
450
  /**
384
451
  * Path information
385
452
  */
@@ -387,45 +454,162 @@ declare class DocFileUnknownEntity {
387
454
  /**
388
455
  * Update content
389
456
  */
390
- withContent(content: string): DocFileUnknownEntity;
457
+ withContent(content: DocFileIndexContentValue<T>): DocFileIndexEntity<T>;
458
+ withContent(updater: UpdateFunction<DocFileIndexContentValue<T>>): DocFileIndexEntity<T>;
391
459
  /**
392
460
  * Update path
393
461
  */
394
- withPath(path: DocFilePath): DocFileUnknownEntity;
395
- withPath(updater: UpdateFunction<DocFilePath>): DocFileUnknownEntity;
396
- toJson(): z.infer<typeof zDocFileUnknown>;
462
+ withPath(path: DocFilePath): DocFileIndexEntity<T>;
463
+ withPath(updater: UpdateFunction<DocFilePath>): DocFileIndexEntity<T>;
464
+ /**
465
+ * z.infer<typeof zDocFileIndex>
466
+ */
467
+ toJson(): DocFileIndexAny;
468
+ }
469
+
470
+ /**
471
+ * Relation file
472
+ */
473
+ declare class DocRelationFileValue {
474
+ private readonly value;
475
+ constructor(value: DocRelationFile);
476
+ /**
477
+ * File path
478
+ */
479
+ get id(): string;
480
+ /**
481
+ * Slug
482
+ */
483
+ get slug(): string;
484
+ /**
485
+ * Display label
486
+ */
487
+ get label(): string;
488
+ /**
489
+ * Convert to JSON format
490
+ */
491
+ toJson(): DocRelationFile;
492
+ /**
493
+ * Extract file name from file path (without extension)
494
+ */
495
+ private static extractFileName;
496
+ /**
497
+ * Create from file path and title
498
+ */
499
+ static from(filePath: string, title: string | null): DocRelationFileValue;
500
+ }
501
+
502
+ /**
503
+ * Manages relation information
504
+ */
505
+ declare class DocRelationValue {
506
+ readonly value: DocRelation;
507
+ constructor(value: DocRelation);
508
+ /**
509
+ * Relation path
510
+ */
511
+ get path(): string;
512
+ /**
513
+ * Get file count
514
+ */
515
+ get fileCount(): number;
516
+ /**
517
+ * Whether it's empty
518
+ */
519
+ get isEmpty(): boolean;
520
+ /**
521
+ * List of related files (value objects)
522
+ */
523
+ files(): DocRelationFileValue[];
524
+ /**
525
+ * Export as JSON format
526
+ */
527
+ toJson(): DocRelation;
528
+ /**
529
+ * Create empty relation entity
530
+ */
531
+ static empty(path: string): DocRelationValue;
532
+ }
533
+
534
+ type Props$8 = {
535
+ filePath: string;
536
+ fileSystem: DocFileSystem;
537
+ pathSystem: DocPathSystem;
538
+ };
539
+ /**
540
+ * Relation file reference
541
+ */
542
+ declare class DocFileRelationReference {
543
+ private readonly props;
544
+ private readonly pathSystem;
545
+ constructor(props: Props$8);
546
+ get fileSystem(): DocFileSystem;
547
+ get basePath(): string;
548
+ /**
549
+ * Relation path
550
+ */
551
+ get path(): string;
552
+ /**
553
+ * Full path
554
+ */
555
+ get fullPath(): string;
556
+ read(): Promise<DocRelationValue | Error | null>;
557
+ /**
558
+ * Read list of relation files
559
+ */
560
+ readFiles(): Promise<DocRelationFileValue[] | Error>;
561
+ /**
562
+ * Read single relation file
563
+ */
564
+ readFile(filePath: string): Promise<DocRelationFileValue | Error | null>;
565
+ /**
566
+ * Check if file exists
567
+ */
568
+ exists(slug: string): Promise<boolean>;
569
+ /**
570
+ * Get list of file names (without extension)
571
+ */
572
+ readSlugs(): Promise<string[] | Error>;
573
+ /**
574
+ * Get file count
575
+ */
576
+ count(): Promise<number | Error>;
577
+ /**
578
+ * Check if empty
579
+ */
580
+ isEmpty(): Promise<boolean | Error>;
397
581
  }
398
582
 
399
583
  type Props$7<T extends DocCustomSchema> = {
584
+ customSchema: T;
400
585
  path: string;
401
586
  fileSystem: DocFileSystem;
402
587
  pathSystem: DocPathSystem;
403
- customSchema: T;
404
588
  config: DocClientConfig;
405
589
  };
406
590
  /**
407
- * File reference
591
+ * File reference class
408
592
  */
409
- declare class DocFileUnknownReference<T extends DocCustomSchema> {
593
+ declare class DocFileIndexReference<T extends DocCustomSchema> {
410
594
  private readonly props;
411
595
  private readonly pathSystem;
412
596
  private readonly customSchema;
413
597
  constructor(props: Props$7<T>);
414
598
  get fileSystem(): DocFileSystem;
415
599
  get basePath(): string;
416
- get path(): string;
417
- get directoryPath(): string;
600
+ get filePath(): string;
418
601
  get fileFullPath(): string;
419
- directory(): DocDirectoryReference<T>;
420
- read(): Promise<Error | DocFileUnknownEntity>;
602
+ get durectoryPath(): string;
603
+ read(): Promise<DocFileIndexEntity<T> | Error>;
604
+ readSchemaValue(): Promise<DocFileIndexSchema<RecordKey>>;
421
605
  /**
422
606
  * Read file content
423
607
  */
424
608
  readContent(): Promise<Error | string>;
425
609
  /**
426
- * Create empty DocFileUnknownEntity
610
+ * Create empty DocFileIndexEntity
427
611
  */
428
- empty(): DocFileUnknownEntity;
612
+ empty(): DocFileIndexEntity<T>;
429
613
  /**
430
614
  * Write content to file
431
615
  */
@@ -433,11 +617,11 @@ declare class DocFileUnknownReference<T extends DocCustomSchema> {
433
617
  /**
434
618
  * Write entity
435
619
  */
436
- write(entity: DocFileUnknownEntity): Promise<Error | null>;
620
+ write(entity: DocFileIndexEntity<T>): Promise<Error | null>;
437
621
  /**
438
- * Write raw content
622
+ * Create new file with default content
439
623
  */
440
- writeRaw(content: string): Promise<Error | null>;
624
+ writeDefault(): Promise<Error | null>;
441
625
  /**
442
626
  * Delete file
443
627
  */
@@ -446,34 +630,442 @@ declare class DocFileUnknownReference<T extends DocCustomSchema> {
446
630
  * Check if file exists
447
631
  */
448
632
  exists(): Promise<boolean>;
449
- /**
450
- * Copy file
451
- */
452
- copyTo(destinationPath: string): Promise<Error | null>;
453
- /**
454
- * Move file
455
- */
456
- moveTo(destinationPath: string): Promise<Error | null>;
633
+ relations(): Promise<DocFileRelationReference[] | Error>;
634
+ readRelations(): Promise<DocRelationValue[] | Error>;
457
635
  /**
458
636
  * Get file size in bytes
459
637
  */
460
638
  size(): Promise<number | Error>;
461
639
  /**
462
- * Get file last modified time
640
+ * Get last modified date
463
641
  */
464
642
  lastModified(): Promise<Date | Error>;
465
643
  /**
466
- * Get file creation time
644
+ * Get file creation date
467
645
  */
468
646
  createdAt(): Promise<Date | Error>;
469
647
  /**
470
648
  * Move file to archive and return new reference
471
649
  */
472
- archive(archiveDirectoryName?: string): Promise<DocFileUnknownReference<T>>;
650
+ archive(archiveDirectoryName?: string): Promise<DocFileIndexReference<T>>;
473
651
  /**
474
652
  * Restore file from archive and return new reference
475
653
  */
476
- restore(archiveDirectoryName?: string): Promise<DocFileUnknownReference<T>>;
654
+ restore(archiveDirectoryName?: string): Promise<DocFileIndexReference<T>>;
655
+ }
656
+
657
+ /**
658
+ * Meta
659
+ */
660
+ declare class DocFileMdMetaValue<T extends DocCustomSchema> {
661
+ readonly value: SchemaToValueType<T>;
662
+ readonly customSchema: T;
663
+ constructor(value: SchemaToValueType<T>, customSchema: T);
664
+ get keys(): Array<keyof T>;
665
+ /**
666
+ * Return a new instance with a single property updated
667
+ */
668
+ withProperty<K extends keyof T>(key: K, value: BaseFieldValueType<ExtractFieldType<T[K]>>): DocFileMdMetaValue<T>;
669
+ schemaField<K extends keyof T>(key: K): T[K];
670
+ field<K extends keyof T>(key: K): FieldValueType<ExtractFieldType<T[K]>, ExtractRequired<T[K]>>;
671
+ relation(key: keyof T): DocMetaFieldRelation;
672
+ multiRelation(key: keyof T): DocMetaFieldMultiRelation;
673
+ text(key: keyof T): DocMetaFieldText;
674
+ number(key: keyof T): DocMetaFieldNumber;
675
+ boolean(key: keyof T): DocMetaFieldBoolean;
676
+ multiText(key: keyof T): DocMetaFieldMultiText;
677
+ multiNumber(key: keyof T): DocMetaFieldMultiNumber;
678
+ hasKey(key: keyof T): boolean;
679
+ toJson(): SchemaToValueType<T>;
680
+ toYaml(): string;
681
+ private validateValue;
682
+ private getValueField;
683
+ /**
684
+ * Generate from Markdown text
685
+ */
686
+ static fromYamlText<T extends DocCustomSchema>(yamlText: string, customSchema: T): DocFileMdMetaValue<T>;
687
+ static empty<T extends DocCustomSchema>(customSchema: T): DocFileMdMetaValue<T>;
688
+ }
689
+
690
+ /**
691
+ * File: Markdown > Content
692
+ */
693
+ declare class DocFileMdContentValue<T extends DocCustomSchema> {
694
+ readonly value: DocFileMdContent<T>;
695
+ private readonly customSchema;
696
+ constructor(value: DocFileMdContent<T>, customSchema: T);
697
+ /**
698
+ * Content body (does not include frontMatter)
699
+ */
700
+ get body(): string;
701
+ /**
702
+ * Title
703
+ */
704
+ get title(): string;
705
+ /**
706
+ * Description
707
+ */
708
+ get description(): string;
709
+ /**
710
+ * FrontMatter (uses constructor's Zod schema or argument schema)
711
+ */
712
+ meta(): DocFileMdMetaValue<T>;
713
+ /**
714
+ * Update title
715
+ */
716
+ withTitle(title: string): DocFileMdContentValue<T>;
717
+ /**
718
+ * Update description
719
+ */
720
+ withDescription(description: string, defaultTitle?: string): DocFileMdContentValue<T>;
721
+ /**
722
+ * Update body
723
+ */
724
+ withBody(body: string): DocFileMdContentValue<T>;
725
+ /**
726
+ * @deprecated Use `withBody` instead
727
+ */
728
+ withContent(content: string): DocFileMdContentValue<T>;
729
+ /**
730
+ * Update FrontMatter
731
+ */
732
+ withMeta<U extends DocCustomSchema>(meta: DocFileMdMetaValue<U>): DocFileMdContentValue<U>;
733
+ withMeta(updater: UpdateFunction<DocFileMdMetaValue<T>>): DocFileMdContentValue<T>;
734
+ /**
735
+ * Update specific property of FrontMatter
736
+ */
737
+ withMetaProperty<K extends keyof T>(key: K, value: BaseFieldValueType<ExtractFieldType<T[K]>>): DocFileMdContentValue<T>;
738
+ /**
739
+ * Generate from Markdown text
740
+ */
741
+ static fromMarkdown<T extends DocCustomSchema>(markdown: string, customSchema: T): DocFileMdContentValue<T>;
742
+ /**
743
+ * Generate complete text combining FrontMatter and body
744
+ */
745
+ toText(): string;
746
+ /**
747
+ * Generate empty content
748
+ */
749
+ static empty<T extends DocCustomSchema = DocCustomSchema>(title: string, customSchema: T): DocFileMdContentValue<T>;
750
+ /**
751
+ * Output in JSON format
752
+ */
753
+ toJson(): DocFileMdContent<T>;
754
+ }
755
+
756
+ /**
757
+ * Markdown file entity
758
+ */
759
+ declare class DocFileMdEntity<T extends DocCustomSchema> {
760
+ readonly value: DocFileMd<T>;
761
+ private readonly customSchema;
762
+ constructor(value: DocFileMd<T>, customSchema: T);
763
+ /**
764
+ * Content
765
+ */
766
+ content(): DocFileMdContentValue<T>;
767
+ /**
768
+ * Path information
769
+ */
770
+ get path(): DocFilePath;
771
+ /**
772
+ * Update content
773
+ */
774
+ withContent(content: DocFileMdContentValue<T>): DocFileMdEntity<T>;
775
+ withContent(updater: UpdateFunction<DocFileMdContentValue<T>>): DocFileMdEntity<T>;
776
+ /**
777
+ * Update path
778
+ */
779
+ withPath(path: DocFilePath): DocFileMdEntity<T>;
780
+ withPath(updater: UpdateFunction<DocFilePath>): DocFileMdEntity<T>;
781
+ withMeta(meta: DocFileMdMetaValue<T>): DocFileMdEntity<T>;
782
+ withMeta(updater: UpdateFunction<DocFileMdMetaValue<T>>): DocFileMdEntity<T>;
783
+ withTitle(title: string): DocFileMdEntity<T>;
784
+ withDescription(description: string, defaultTitle?: string): DocFileMdEntity<T>;
785
+ /**
786
+ * z.infer<typeof zDocFileMd>
787
+ */
788
+ toJson(): z.infer<typeof zDocFileMd>;
789
+ }
790
+
791
+ /**
792
+ * Unknown file entity
793
+ */
794
+ declare class DocFileUnknownEntity {
795
+ readonly value: DocFileUnknown;
796
+ constructor(value: DocFileUnknown);
797
+ /**
798
+ * Content
799
+ */
800
+ get content(): string;
801
+ /**
802
+ * Path information
803
+ */
804
+ get path(): DocFilePath;
805
+ /**
806
+ * Update content
807
+ */
808
+ withContent(content: string): DocFileUnknownEntity;
809
+ /**
810
+ * Update path
811
+ */
812
+ withPath(path: DocFilePath): DocFileUnknownEntity;
813
+ withPath(updater: UpdateFunction<DocFilePath>): DocFileUnknownEntity;
814
+ toJson(): z.infer<typeof zDocFileUnknown>;
815
+ }
816
+
817
+ type DocFileEntity<T extends DocCustomSchema> = DocFileMdEntity<T> | DocFileIndexEntity<T> | DocFileUnknownEntity;
818
+ type DocFileDirectoryEntity<T extends DocCustomSchema> = DocFileMdEntity<T> | DocFileUnknownEntity;
819
+
820
+ type Props$6<T extends DocCustomSchema> = {
821
+ path: string;
822
+ fileSystem: DocFileSystem;
823
+ pathSystem: DocPathSystem;
824
+ customSchema: T;
825
+ config: DocClientConfig;
826
+ };
827
+ /**
828
+ * File reference
829
+ */
830
+ declare class DocFileUnknownReference<T extends DocCustomSchema> {
831
+ private readonly props;
832
+ private readonly pathSystem;
833
+ private readonly customSchema;
834
+ constructor(props: Props$6<T>);
835
+ get fileSystem(): DocFileSystem;
836
+ get basePath(): string;
837
+ get path(): string;
838
+ get directoryPath(): string;
839
+ get fileFullPath(): string;
840
+ directory(): DocDirectoryReference<T>;
841
+ read(): Promise<Error | DocFileUnknownEntity>;
842
+ /**
843
+ * Read file content
844
+ */
845
+ readContent(): Promise<Error | string>;
846
+ /**
847
+ * Create empty DocFileUnknownEntity
848
+ */
849
+ empty(): DocFileUnknownEntity;
850
+ /**
851
+ * Write content to file
852
+ */
853
+ writeContent(content: string): Promise<Error | null>;
854
+ /**
855
+ * Write entity
856
+ */
857
+ write(entity: DocFileUnknownEntity): Promise<Error | null>;
858
+ /**
859
+ * Write raw content
860
+ */
861
+ writeRaw(content: string): Promise<Error | null>;
862
+ /**
863
+ * Delete file
864
+ */
865
+ delete(): Promise<Error | null>;
866
+ /**
867
+ * Check if file exists
868
+ */
869
+ exists(): Promise<boolean>;
870
+ /**
871
+ * Copy file
872
+ */
873
+ copyTo(destinationPath: string): Promise<Error | null>;
874
+ /**
875
+ * Move file
876
+ */
877
+ moveTo(destinationPath: string): Promise<Error | null>;
878
+ /**
879
+ * Get file size in bytes
880
+ */
881
+ size(): Promise<number | Error>;
882
+ /**
883
+ * Get file last modified time
884
+ */
885
+ lastModified(): Promise<Date | Error>;
886
+ /**
887
+ * Get file creation time
888
+ */
889
+ createdAt(): Promise<Date | Error>;
890
+ /**
891
+ * Move file to archive and return new reference
892
+ */
893
+ archive(archiveDirectoryName?: string): Promise<DocFileUnknownReference<T>>;
894
+ /**
895
+ * Restore file from archive and return new reference
896
+ */
897
+ restore(archiveDirectoryName?: string): Promise<DocFileUnknownReference<T>>;
898
+ }
899
+
900
+ type DocFileDirectoryReference<T extends DocCustomSchema> = DocFileMdReference<T> | DocFileUnknownReference<T>;
901
+
902
+ type Props$5<T extends DocCustomSchema> = {
903
+ customSchema: T;
904
+ path: string;
905
+ indexFileName: string;
906
+ archiveDirectoryName: string;
907
+ fileSystem: DocFileSystem;
908
+ pathSystem: DocPathSystem;
909
+ config: DocClientConfig;
910
+ };
911
+ /**
912
+ * Directory reference
913
+ */
914
+ declare class DocDirectoryReference<T extends DocCustomSchema> {
915
+ private readonly props;
916
+ private readonly pathSystem;
917
+ private readonly customSchema;
918
+ constructor(props: Props$5<T>);
919
+ get fileSystem(): DocFileSystem;
920
+ get basePath(): string;
921
+ get config(): DocClientConfig;
922
+ get path(): string;
923
+ /**
924
+ * @deprecated
925
+ */
926
+ get relativePath(): string;
927
+ get fullPath(): string;
928
+ /**
929
+ * @deprecated
930
+ */
931
+ get absolutePath(): string;
932
+ get indexFileName(): string;
933
+ get indexFilePath(): string;
934
+ get archiveDirectoryName(): string;
935
+ get name(): string;
936
+ fileNames(): Promise<string[] | Error>;
937
+ archivedFileNames(): Promise<string[] | Error>;
938
+ filesGenerator(): AsyncGenerator<DocFileDirectoryReference<T>, void, unknown>;
939
+ mdFilesGenerator(): AsyncGenerator<DocFileMdReference<T> | Error, void, unknown>;
940
+ files(): Promise<DocFileDirectoryReference<T>[]>;
941
+ mdFiles(): Promise<DocFileMdReference<T>[]>;
942
+ file<FileName extends string>(fileName: FileName): InferReference<FileName, T>;
943
+ mdFile(fileName: string): DocFileMdReference<T>;
944
+ readFiles(): Promise<DocFileDirectoryEntity<T>[]>;
945
+ readMdFiles(): Promise<DocFileMdEntity<T>[]>;
946
+ readUnknownFiles(): Promise<DocFileUnknownEntity[]>;
947
+ /**
948
+ * Get list of subdirectory names
949
+ */
950
+ directoryNames(): Promise<string[]>;
951
+ /**
952
+ * Get subdirectory references
953
+ */
954
+ directories(): Promise<DocDirectoryReference<T>[]>;
955
+ /**
956
+ * Get single subdirectory reference
957
+ */
958
+ directory(directoryName: string): DocDirectoryReference<T>;
959
+ directory<S extends DocCustomSchema>(directoryName: string, customSchema: S): DocDirectoryReference<S>;
960
+ indexFile(): DocFileIndexReference<T>;
961
+ readIndexFile(): Promise<DocFileIndexEntity<T> | Error>;
962
+ writeFile(entity: DocFileIndexEntity<T> | DocFileMdEntity<T> | DocFileUnknownEntity): Promise<Error | null>;
963
+ exists(): Promise<boolean>;
964
+ /**
965
+ * Create new Markdown file
966
+ */
967
+ createMdFile(fileName?: string): Promise<DocFileMdReference<T>>;
968
+ /**
969
+ * Generate unique filename
970
+ */
971
+ private uniqueFileName;
972
+ }
973
+
974
+ type Props$4<T extends DocCustomSchema> = {
975
+ path: string;
976
+ fileSystem: DocFileSystem;
977
+ pathSystem: DocPathSystem;
978
+ customSchema: T;
979
+ config: DocClientConfig;
980
+ };
981
+ /**
982
+ * File reference
983
+ */
984
+ declare class DocFileMdReference<T extends DocCustomSchema> {
985
+ private readonly props;
986
+ private readonly pathSystem;
987
+ private readonly customSchema;
988
+ constructor(props: Props$4<T>);
989
+ get fileSystem(): DocFileSystem;
990
+ get basePath(): string;
991
+ get path(): string;
992
+ get fullPath(): string;
993
+ get directoryPath(): string;
994
+ get archivedPath(): string;
995
+ get name(): string;
996
+ get nameWithExtension(): string;
997
+ exists(): Promise<boolean>;
998
+ read(): Promise<DocFileMdEntity<T> | Error>;
999
+ /**
1000
+ * Read file content
1001
+ */
1002
+ readText(): Promise<Error | string>;
1003
+ /**
1004
+ * Create empty DocFileMdEntity
1005
+ */
1006
+ empty(): DocFileMdEntity<T>;
1007
+ /**
1008
+ * Write entity
1009
+ */
1010
+ write(entity: DocFileMdEntity<T>): Promise<Error | null>;
1011
+ writeText(text: string): Promise<Error | null>;
1012
+ /**
1013
+ * Create new file with default content
1014
+ */
1015
+ writeDefault(): Promise<Error | null>;
1016
+ /**
1017
+ * Delete file
1018
+ */
1019
+ delete(): Promise<Error | null>;
1020
+ /**
1021
+ * Copy file
1022
+ */
1023
+ copyTo(destinationPath: string): Promise<Error | null>;
1024
+ /**
1025
+ * Move file
1026
+ */
1027
+ moveTo(destinationPath: string): Promise<Error | null>;
1028
+ /**
1029
+ * Move file to archive and return new reference
1030
+ */
1031
+ archive(archiveDirectoryName?: string): Promise<DocFileMdReference<T>>;
1032
+ /**
1033
+ * Restore file from archive and return new reference
1034
+ */
1035
+ restore(archiveDirectoryName?: string): Promise<DocFileMdReference<T>>;
1036
+ /**
1037
+ * Get file size in bytes
1038
+ */
1039
+ size(): Promise<number | Error>;
1040
+ /**
1041
+ * Get file last modified time
1042
+ */
1043
+ lastModified(): Promise<Date | Error>;
1044
+ /**
1045
+ * Get file creation time
1046
+ */
1047
+ createdAt(): Promise<Date | Error>;
1048
+ directory(): DocDirectoryReference<T>;
1049
+ /**
1050
+ * Get relation based on schema
1051
+ */
1052
+ relation<U extends DocCustomSchema = DocCustomSchema>(key: RelationKeys<T>, targetSchema?: U): Promise<DocFileMdReference<U> | Error | null>;
1053
+ /**
1054
+ * Get index.md in the same directory
1055
+ */
1056
+ directoryIndex(): Promise<DocFileIndexReference<T> | null>;
1057
+ /**
1058
+ * Get multiple relations based on schema
1059
+ */
1060
+ relations<U extends DocCustomSchema = DocCustomSchema>(key: MultiRelationKeys<T>, customSchema?: U): Promise<DocFileMdReference<U>[]>;
1061
+ /**
1062
+ * File: Markdown > FrontMatter
1063
+ */
1064
+ readFrontMatter(): Promise<DocFileMdMetaValue<T> | Error>;
1065
+ /**
1066
+ * File: Markdown > FrontMatter
1067
+ */
1068
+ updateFrontMatter<K extends keyof T>(key: K, value: BaseFieldValueType<ExtractFieldType<T[K]>>): Promise<this | Error>;
477
1069
  }
478
1070
 
479
1071
  /**
@@ -694,860 +1286,132 @@ type DocFileAny = DocFileIndexAny | DocFileMdAny | DocFileUnknown;
694
1286
  /**
695
1287
  * Directory FrontMatter type
696
1288
  */
697
- type DocFileIndexMeta<T extends DocCustomSchema = DocCustomSchema> = {
698
- type: "index-meta";
699
- icon: string | null;
700
- schema: DocFileIndexSchema<keyof T>;
701
- };
702
- /**
703
- * Relation options type
704
- */
705
- type DocRelationFile = z.infer<typeof zDocRelationFile>;
706
- /**
707
- * Relation information type
708
- */
709
- type DocRelation = z.infer<typeof zDocRelation>;
710
- /**
711
- * Relation field type
712
- */
713
- type DocRelationField = z.infer<typeof zDocRelationField>;
714
- /**
715
- * String literal type utilities for file path detection
716
- */
717
- /**
718
- * Check if path ends with specific extension
719
- */
720
- type EndsWith<T extends string, U extends string> = T extends `${string}${U}` ? true : false;
721
- /**
722
- * Extract filename from path
723
- */
724
- type Basename<T extends string> = T extends `${string}/${infer U}` ? Basename<U> : T;
725
- /**
726
- * Check if filename is index.md
727
- */
728
- type IsIndexMd<T extends string> = Basename<T> extends "index.md" ? true : false;
729
- /**
730
- * Detect file type from path
731
- */
732
- type DetectFileType<T extends string> = IsIndexMd<T> extends true ? "index" : EndsWith<T, ".md"> extends true ? "markdown" : "unknown";
733
- /**
734
- * Map file type to reference class
735
- */
736
- type FileTypeToReference<FileType extends string, Schema extends DocCustomSchema> = FileType extends "index" ? DocFileIndexReference<Schema> : FileType extends "markdown" ? DocFileMdReference<Schema> : DocFileUnknownReference<Schema>;
737
- /**
738
- * Infer reference type from path
739
- */
740
- type InferReference<Path extends string, Schema extends DocCustomSchema> = FileTypeToReference<DetectFileType<Path>, Schema>;
741
- /**
742
- * File path information type
743
- */
744
- type DocFilePath = z.infer<typeof zDocFilePath>;
745
- /**
746
- * Markdown content information type
747
- */
748
- type DocFileMdContent<T extends DocCustomSchema = DocCustomSchema> = {
749
- type: "markdown-content";
750
- body: string;
751
- title: string;
752
- description: string;
753
- meta: SchemaToValueType<T>;
754
- };
755
- /**
756
- * Index file content information type
757
- */
758
- type DocFileIndexContent<T extends DocCustomSchema = DocCustomSchema> = {
759
- type: "markdown-index";
760
- body: string;
761
- title: string;
762
- description: string;
763
- meta: DocFileIndexMeta<T>;
764
- };
765
- /**
766
- * Directory response type (re-export from server package)
767
- */
768
- type DocDirectory<T extends DocCustomSchema> = {
769
- cwd: string;
770
- indexFile: DocFileIndex<T>;
771
- files: DocFile<T>[];
772
- relations: DocRelation[];
773
- };
774
- type RecordKey = PropertyKey;
775
- /**
776
- * DocClient configuration
777
- */
778
- type DocClientConfig = z.infer<typeof zDocClientConfig>;
779
- /**
780
- * Type definitions for DocFileMdMetaValue
781
- */
782
- type ExtractFieldType<T> = T extends {
783
- type: infer Type;
784
- } ? Type : never;
785
- type ExtractRequired<T> = T extends {
786
- required: infer Required;
787
- } ? Required : false;
788
- type BaseFieldValueType<Type> = Type extends "text" ? string : Type extends "number" ? number : Type extends "boolean" ? boolean : Type extends "multi-text" ? string[] : Type extends "multi-number" ? number[] : Type extends "multi-boolean" ? boolean[] : Type extends "relation" ? string : Type extends "multi-relation" ? string[] : Type extends "select-text" ? string : Type extends "select-number" ? number : Type extends "multi-select-text" ? string[] : Type extends "multi-select-number" ? number[] : never;
789
- type FieldValueType<Type, Required> = Required extends true ? BaseFieldValueType<Type> : BaseFieldValueType<Type> | null;
790
- /**
791
- * Extract required field keys
792
- */
793
- type RequiredKeys<T extends DocCustomSchema> = {
794
- [K in keyof T]: T[K] extends {
795
- required: true;
796
- } ? K : never;
797
- }[keyof T];
798
- /**
799
- * Extract optional field keys
800
- */
801
- type OptionalKeys<T extends DocCustomSchema> = {
802
- [K in keyof T]: T[K] extends {
803
- required: true;
804
- } ? never : K;
805
- }[keyof T];
806
- /**
807
- * Generate expected value type from schema (considering required)
808
- */
809
- type SchemaToValueType<T extends DocCustomSchema> = {
810
- [K in RequiredKeys<T>]: BaseFieldValueType<ExtractFieldType<T[K]>>;
811
- } & {
812
- [K in OptionalKeys<T>]: BaseFieldValueType<ExtractFieldType<T[K]>> | null;
813
- };
814
- /**
815
- * Helper type for type-safe property access
816
- */
817
- type GetValueType<T extends DocCustomSchema, K extends keyof T> = K extends RequiredKeys<T> ? BaseFieldValueType<ExtractFieldType<T[K]>> : BaseFieldValueType<ExtractFieldType<T[K]>> | undefined | null;
818
- type GetIndexFieldType<Schema extends DocFileIndexSchema<RecordKey>, K extends keyof Schema> = Schema[K] extends DocFileIndexSchemaField ? Schema[K] : never;
819
- /**
820
- * Infers DocFileMd type from the result of defineSchema
821
- */
822
- type InferDocFileMd<T> = T extends DocCustomSchema ? DocFileMd<T> : never;
823
-
824
- /**
825
- * Relation file
826
- */
827
- declare class DocRelationFileValue {
828
- private readonly value;
829
- constructor(value: DocRelationFile);
830
- /**
831
- * File path
832
- */
833
- get id(): string;
834
- /**
835
- * Slug
836
- */
837
- get slug(): string;
838
- /**
839
- * Display label
840
- */
841
- get label(): string;
842
- /**
843
- * Convert to JSON format
844
- */
845
- toJson(): DocRelationFile;
846
- /**
847
- * Extract file name from file path (without extension)
848
- */
849
- private static extractFileName;
850
- /**
851
- * Create from file path and title
852
- */
853
- static from(filePath: string, title: string | null): DocRelationFileValue;
854
- }
855
-
856
- /**
857
- * Manages relation information
858
- */
859
- declare class DocRelationValue {
860
- readonly value: DocRelation;
861
- constructor(value: DocRelation);
862
- /**
863
- * Relation path
864
- */
865
- get path(): string;
866
- /**
867
- * Get file count
868
- */
869
- get fileCount(): number;
870
- /**
871
- * Whether it's empty
872
- */
873
- get isEmpty(): boolean;
874
- /**
875
- * List of related files (value objects)
876
- */
877
- files(): DocRelationFileValue[];
878
- /**
879
- * Export as JSON format
880
- */
881
- toJson(): DocRelation;
882
- /**
883
- * Create empty relation entity
884
- */
885
- static empty(path: string): DocRelationValue;
886
- }
887
-
888
- type Props$6 = {
889
- filePath: string;
890
- fileSystem: DocFileSystem;
891
- pathSystem: DocPathSystem;
1289
+ type DocFileIndexMeta<T extends DocCustomSchema = DocCustomSchema> = {
1290
+ type: "index-meta";
1291
+ icon: string | null;
1292
+ schema: DocFileIndexSchema<keyof T>;
892
1293
  };
893
1294
  /**
894
- * Relation file reference
1295
+ * Relation options type
895
1296
  */
896
- declare class DocFileRelationReference {
897
- private readonly props;
898
- private readonly pathSystem;
899
- constructor(props: Props$6);
900
- get fileSystem(): DocFileSystem;
901
- get basePath(): string;
902
- /**
903
- * Relation path
904
- */
905
- get path(): string;
906
- /**
907
- * Full path
908
- */
909
- get fullPath(): string;
910
- read(): Promise<DocRelationValue | Error | null>;
911
- /**
912
- * Read list of relation files
913
- */
914
- readFiles(): Promise<DocRelationFileValue[] | Error>;
915
- /**
916
- * Read single relation file
917
- */
918
- readFile(filePath: string): Promise<DocRelationFileValue | Error | null>;
919
- /**
920
- * Check if file exists
921
- */
922
- exists(slug: string): Promise<boolean>;
923
- /**
924
- * Get list of file names (without extension)
925
- */
926
- readSlugs(): Promise<string[] | Error>;
927
- /**
928
- * Get file count
929
- */
930
- count(): Promise<number | Error>;
931
- /**
932
- * Check if empty
933
- */
934
- isEmpty(): Promise<boolean | Error>;
935
- }
936
-
1297
+ type DocRelationFile = z.infer<typeof zDocRelationFile>;
937
1298
  /**
938
- * Single boolean type schema field
1299
+ * Relation information type
939
1300
  */
940
- declare class DocSchemaFieldBooleanValue<T extends RecordKey> {
941
- readonly key: T;
942
- readonly value: DocSchemaFieldBoolean;
943
- constructor(key: T, value: DocSchemaFieldBoolean);
944
- get type(): "boolean";
945
- get required(): boolean;
946
- get title(): string;
947
- get description(): string;
948
- get default(): boolean | null;
949
- readonly isArray = false;
950
- readonly isSingle = true;
951
- readonly isBoolean = true;
952
- toJson(): DocFileIndexSchemaField;
953
- /**
954
- * Validate value type
955
- */
956
- validate(value: unknown): boolean;
957
- static empty(key: RecordKey): DocSchemaFieldBooleanValue<RecordKey>;
958
- static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldBooleanValue<RecordKey>;
959
- }
960
-
1301
+ type DocRelation = z.infer<typeof zDocRelation>;
961
1302
  /**
962
- * Multiple relation type schema field
1303
+ * Relation field type
963
1304
  */
964
- declare class DocSchemaFieldMultiRelationValue<T extends RecordKey> {
965
- readonly key: T;
966
- readonly value: DocSchemaFieldMultiRelation;
967
- constructor(key: T, value: DocSchemaFieldMultiRelation);
968
- get type(): "multi-relation";
969
- get required(): boolean;
970
- get title(): string;
971
- get description(): string;
972
- get default(): string[] | null;
973
- get path(): string;
974
- readonly isArray = true;
975
- readonly isSingle = false;
976
- readonly isRelation = true;
977
- /**
978
- * Validate value
979
- */
980
- validate(value: unknown): boolean;
981
- toJson(): DocFileIndexSchemaField;
982
- static empty<T extends RecordKey>(key: T): DocSchemaFieldMultiRelationValue<T>;
983
- static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldMultiRelationValue<RecordKey>;
984
- }
985
-
1305
+ type DocRelationField = z.infer<typeof zDocRelationField>;
986
1306
  /**
987
- * Multiple select number type schema field
1307
+ * String literal type utilities for file path detection
988
1308
  */
989
- declare class DocSchemaFieldMultiSelectNumberValue<T extends RecordKey> {
990
- readonly key: T;
991
- readonly value: DocSchemaFieldMultiSelectNumber;
992
- constructor(key: T, value: DocSchemaFieldMultiSelectNumber);
993
- get type(): "multi-select-number";
994
- get required(): boolean;
995
- get title(): string;
996
- get description(): string;
997
- get default(): number[] | null;
998
- get options(): number[];
999
- readonly isArray = true;
1000
- readonly isSingle = false;
1001
- readonly isSelect = true;
1002
- readonly isNumberSelect = true;
1003
- /**
1004
- * Validate value
1005
- */
1006
- validate(value: unknown): boolean;
1007
- toJson(): DocFileIndexSchemaField;
1008
- static empty<T extends RecordKey>(key: T): DocSchemaFieldMultiSelectNumberValue<T>;
1009
- static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldMultiSelectNumberValue<RecordKey>;
1010
- }
1011
-
1012
1309
  /**
1013
- * Multiple select text type schema field
1310
+ * Check if path ends with specific extension
1014
1311
  */
1015
- declare class DocSchemaFieldMultiSelectTextValue<T extends RecordKey> {
1016
- readonly key: T;
1017
- readonly value: DocSchemaFieldMultiSelectText;
1018
- constructor(key: T, value: DocSchemaFieldMultiSelectText);
1019
- get type(): "multi-select-text";
1020
- get required(): boolean;
1021
- get title(): string;
1022
- get description(): string;
1023
- get default(): string[] | null;
1024
- get options(): string[];
1025
- readonly isArray = true;
1026
- readonly isSingle = false;
1027
- readonly isSelect = true;
1028
- readonly isTextSelect = true;
1029
- /**
1030
- * Validate value
1031
- */
1032
- validate(value: unknown): boolean;
1033
- toJson(): DocFileIndexSchemaField;
1034
- static empty<T extends RecordKey>(key: T): DocSchemaFieldMultiSelectTextValue<T>;
1035
- static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldMultiSelectTextValue<RecordKey>;
1036
- }
1037
-
1312
+ type EndsWith<T extends string, U extends string> = T extends `${string}${U}` ? true : false;
1038
1313
  /**
1039
- * Multiple text type schema field
1314
+ * Extract filename from path
1040
1315
  */
1041
- declare class DocSchemaFieldMultiTextValue<T extends RecordKey> {
1042
- readonly key: T;
1043
- readonly value: DocSchemaFieldMultiText;
1044
- constructor(key: T, value: DocSchemaFieldMultiText);
1045
- get type(): "multi-text";
1046
- get required(): boolean;
1047
- get title(): string;
1048
- get description(): string;
1049
- get default(): string[] | null;
1050
- readonly isArray = true;
1051
- readonly isSingle = false;
1052
- readonly isText = true;
1053
- toJson(): DocFileIndexSchemaField;
1054
- /**
1055
- * Validate value type
1056
- */
1057
- validate(value: unknown): boolean;
1058
- static empty<T extends RecordKey>(key: T): DocSchemaFieldMultiTextValue<T>;
1059
- static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldMultiTextValue<RecordKey>;
1060
- }
1061
-
1316
+ type Basename<T extends string> = T extends `${string}/${infer U}` ? Basename<U> : T;
1062
1317
  /**
1063
- * Single number type schema field
1318
+ * Check if filename is index.md
1064
1319
  */
1065
- declare class DocSchemaFieldNumberValue<T extends RecordKey> {
1066
- readonly key: T;
1067
- readonly value: DocSchemaFieldNumber;
1068
- constructor(key: T, value: DocSchemaFieldNumber);
1069
- get type(): "number";
1070
- get required(): boolean;
1071
- get title(): string;
1072
- get description(): string;
1073
- get default(): number | null;
1074
- readonly isArray = false;
1075
- readonly isSingle = true;
1076
- readonly isNumber = true;
1077
- toJson(): DocFileIndexSchemaField;
1078
- /**
1079
- * Validate value type
1080
- */
1081
- validate(value: unknown): boolean;
1082
- static empty(key: RecordKey): DocSchemaFieldNumberValue<RecordKey>;
1083
- static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldNumberValue<RecordKey>;
1084
- }
1085
-
1320
+ type IsIndexMd<T extends string> = Basename<T> extends "index.md" ? true : false;
1086
1321
  /**
1087
- * Single relation type schema field
1322
+ * Detect file type from path
1088
1323
  */
1089
- declare class DocSchemaFieldRelationValue<T extends RecordKey> {
1090
- readonly key: T;
1091
- readonly value: DocSchemaFieldRelation;
1092
- constructor(key: T, value: DocSchemaFieldRelation);
1093
- get type(): "relation";
1094
- get required(): boolean;
1095
- get title(): string;
1096
- get description(): string;
1097
- get default(): string | null;
1098
- get path(): string;
1099
- readonly isArray = false;
1100
- readonly isSingle = true;
1101
- readonly isRelation = true;
1102
- toJson(): DocFileIndexSchemaField;
1103
- /**
1104
- * Validate value type
1105
- */
1106
- validate(value: unknown): boolean;
1107
- static empty(key: RecordKey): DocSchemaFieldRelationValue<RecordKey>;
1108
- static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldRelationValue<RecordKey>;
1109
- }
1110
-
1324
+ type DetectFileType<T extends string> = IsIndexMd<T> extends true ? "index" : EndsWith<T, ".md"> extends true ? "markdown" : "unknown";
1111
1325
  /**
1112
- * Single select number type schema field
1326
+ * Map file type to reference class
1113
1327
  */
1114
- declare class DocSchemaFieldSelectNumberValue<T extends RecordKey> {
1115
- readonly key: T;
1116
- readonly value: DocSchemaFieldSelectNumber;
1117
- constructor(key: T, value: DocSchemaFieldSelectNumber);
1118
- get type(): "select-number";
1119
- get required(): boolean;
1120
- get title(): string;
1121
- get description(): string;
1122
- get default(): number | null;
1123
- get options(): number[];
1124
- readonly isArray = false;
1125
- readonly isSingle = true;
1126
- readonly isSelect = true;
1127
- readonly isNumberSelect = true;
1128
- /**
1129
- * Validate value
1130
- */
1131
- validate(value: unknown): boolean;
1132
- toJson(): DocFileIndexSchemaField;
1133
- static empty<T extends RecordKey>(key: T): DocSchemaFieldSelectNumberValue<T>;
1134
- static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldSelectNumberValue<RecordKey>;
1135
- }
1136
-
1328
+ type FileTypeToReference<FileType extends string, Schema extends DocCustomSchema> = FileType extends "index" ? DocFileIndexReference<Schema> : FileType extends "markdown" ? DocFileMdReference<Schema> : DocFileUnknownReference<Schema>;
1137
1329
  /**
1138
- * Single select text type schema field
1330
+ * Infer reference type from path
1331
+ */
1332
+ type InferReference<Path extends string, Schema extends DocCustomSchema> = FileTypeToReference<DetectFileType<Path>, Schema>;
1333
+ /**
1334
+ * File path information type
1335
+ */
1336
+ type DocFilePath = z.infer<typeof zDocFilePath>;
1337
+ /**
1338
+ * Markdown content information type
1139
1339
  */
1140
- declare class DocSchemaFieldSelectTextValue<T extends RecordKey> {
1141
- readonly key: T;
1142
- readonly value: DocSchemaFieldSelectText;
1143
- constructor(key: T, value: DocSchemaFieldSelectText);
1144
- get type(): "select-text";
1145
- get required(): boolean;
1146
- get title(): string;
1147
- get description(): string;
1148
- get default(): string | null;
1149
- get options(): string[];
1150
- readonly isArray = false;
1151
- readonly isSingle = true;
1152
- readonly isSelect = true;
1153
- readonly isTextSelect = true;
1154
- toJson(): DocFileIndexSchemaField;
1155
- /**
1156
- * Validate value type
1157
- */
1158
- validate(value: unknown): boolean;
1159
- static empty<T extends RecordKey>(key: T): DocSchemaFieldSelectTextValue<T>;
1160
- static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldSelectTextValue<RecordKey>;
1161
- }
1162
-
1340
+ type DocFileMdContent<T extends DocCustomSchema = DocCustomSchema> = {
1341
+ type: "markdown-content";
1342
+ body: string;
1343
+ title: string;
1344
+ description: string;
1345
+ meta: SchemaToValueType<T>;
1346
+ };
1163
1347
  /**
1164
- * Single text type schema field
1348
+ * Index file content information type
1165
1349
  */
1166
- declare class DocSchemaFieldTextValue<T extends RecordKey> {
1167
- readonly key: T;
1168
- readonly value: DocSchemaFieldText;
1169
- constructor(key: T, value: DocSchemaFieldText);
1170
- get type(): "text";
1171
- get required(): boolean;
1172
- get title(): string;
1173
- get description(): string;
1174
- get default(): string | null;
1175
- readonly isArray = false;
1176
- readonly isSingle = true;
1177
- readonly isText = true;
1178
- toJson(): DocFileIndexSchemaField;
1179
- /**
1180
- * Validate value type
1181
- */
1182
- validate(value: unknown): boolean;
1183
- static empty(key: RecordKey): DocSchemaFieldTextValue<RecordKey>;
1184
- static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldTextValue<RecordKey>;
1185
- }
1186
-
1350
+ type DocFileIndexContent<T extends DocCustomSchema = DocCustomSchema> = {
1351
+ type: "markdown-index";
1352
+ body: string;
1353
+ title: string;
1354
+ description: string;
1355
+ meta: DocFileIndexMeta<T>;
1356
+ };
1187
1357
  /**
1188
- * Multiple number type schema field
1358
+ * Directory response type (re-export from server package)
1189
1359
  */
1190
- declare class DocSchemaFieldMultiNumberValue<T extends RecordKey> {
1191
- readonly key: T;
1192
- readonly value: DocSchemaFieldMultiNumber;
1193
- constructor(key: T, value: DocSchemaFieldMultiNumber);
1194
- get type(): "multi-number";
1195
- get required(): boolean;
1196
- get title(): string;
1197
- get description(): string;
1198
- get default(): number[] | null;
1199
- readonly isArray = true;
1200
- readonly isSingle = false;
1201
- readonly isNumber = true;
1202
- /**
1203
- * Validate value
1204
- */
1205
- validate(value: unknown): boolean;
1206
- toJson(): DocFileIndexSchemaField;
1207
- static empty<T extends RecordKey>(key: T): DocSchemaFieldMultiNumberValue<T>;
1208
- static from(key: RecordKey, record: Record<RecordKey, unknown>): DocSchemaFieldMultiNumberValue<RecordKey>;
1209
- }
1210
-
1360
+ type DocDirectory<T extends DocCustomSchema> = {
1361
+ cwd: string;
1362
+ indexFile: DocFileIndex<T>;
1363
+ files: DocFile<T>[];
1364
+ relations: DocRelation[];
1365
+ };
1366
+ type RecordKey = PropertyKey;
1211
1367
  /**
1212
- * Type-safe schema value object
1368
+ * DocClient configuration
1213
1369
  */
1214
- declare class DocFileIndexSchemaValue<T extends DocCustomSchema> {
1215
- readonly value: DocFileIndexSchema<keyof T>;
1216
- readonly customSchema: T;
1217
- constructor(value: DocFileIndexSchema<keyof T>, customSchema: T);
1218
- /**
1219
- * Get list of field names
1220
- * Automatically type-safe when using Zod schema
1221
- */
1222
- get fieldNames(): Array<keyof T>;
1223
- /**
1224
- * Get field with specified field name
1225
- * Returns type-safe specific field Value object
1226
- */
1227
- field<K extends keyof T>(key: K): T[K]["type"] extends infer Type ? Type extends "text" ? DocSchemaFieldTextValue<K> : Type extends "number" ? DocSchemaFieldNumberValue<K> : Type extends "boolean" ? DocSchemaFieldBooleanValue<K> : Type extends "relation" ? DocSchemaFieldRelationValue<K> : Type extends "select-text" ? DocSchemaFieldSelectTextValue<K> : Type extends "select-number" ? DocSchemaFieldSelectNumberValue<K> : Type extends "multi-text" ? DocSchemaFieldMultiTextValue<K> : Type extends "multi-number" ? DocSchemaFieldMultiNumberValue<K> : Type extends "multi-relation" ? DocSchemaFieldMultiRelationValue<K> : Type extends "multi-select-text" ? DocSchemaFieldMultiSelectTextValue<K> : Type extends "multi-select-number" ? DocSchemaFieldMultiSelectNumberValue<K> : never : never;
1228
- relation<K extends keyof T>(key: K): DocSchemaFieldRelationValue<K>;
1229
- multiRelation<K extends keyof T>(key: K): DocSchemaFieldMultiRelationValue<K>;
1230
- toJson(): DocFileIndexSchema<keyof T>;
1231
- /**
1232
- * Create empty schema entity
1233
- * biome-ignore lint/complexity/noBannedTypes: {} as DocCustomSchema
1234
- */
1235
- static empty(): DocFileIndexSchemaValue<{}>;
1236
- }
1237
-
1370
+ type DocClientConfig = z.infer<typeof zDocClientConfig>;
1238
1371
  /**
1239
- * File: index.md > content > FrontMatter
1372
+ * Type definitions for DocFileMdMetaValue
1240
1373
  */
1241
- declare class DocFileIndexMetaValue<T extends DocCustomSchema> {
1242
- readonly value: DocFileIndexMeta<T>;
1243
- readonly customSchema: T;
1244
- private readonly config;
1245
- private readonly additionalProperties;
1246
- constructor(value: DocFileIndexMeta<T>, customSchema: T, config: DocClientConfig, additionalProperties?: Record<string, unknown>);
1247
- /**
1248
- * Get icon
1249
- */
1250
- get icon(): string | null;
1251
- /**
1252
- * Get schema
1253
- */
1254
- schema(): DocFileIndexSchemaValue<T>;
1255
- /**
1256
- * Check if schema is defined
1257
- */
1258
- get hasSchema(): boolean;
1259
- /**
1260
- * Update icon field
1261
- */
1262
- withIcon(value: string | null): DocFileIndexMetaValue<T>;
1263
- /**
1264
- * Update schema field
1265
- */
1266
- withSchema(value: DocFileIndexSchema<keyof T>): DocFileIndexMetaValue<T>;
1267
- /**
1268
- * Return a new instance with an unknown schema
1269
- * Allows accepting Record<string, unknown> schemas from external sources
1270
- */
1271
- withUnknownSchema(draft: Record<string, unknown>): DocFileIndexMetaValue<DocCustomSchema>;
1272
- /**
1273
- * Output in JSON format
1274
- */
1275
- toJson(): DocFileIndexMeta<T>;
1276
- /**
1277
- * Output in YAML format
1278
- */
1279
- toYaml(): string;
1280
- /**
1281
- * Generate from Markdown text (can process incomplete data)
1282
- */
1283
- static from<T extends DocCustomSchema>(markdownText: string, customSchema: T, config: DocClientConfig): DocFileIndexMetaValue<T>;
1284
- /**
1285
- * Generate directly from data (can process incomplete data)
1286
- */
1287
- static fromRecord<T extends DocCustomSchema>(record: Record<string, unknown>, customSchema: T, config: DocClientConfig): DocFileIndexMetaValue<T>;
1288
- /**
1289
- * Generate empty FrontMatter
1290
- */
1291
- static empty<T extends DocCustomSchema>(customSchema: T, config: DocClientConfig): DocFileIndexMetaValue<T>;
1292
- /**
1293
- * Extract icon
1294
- */
1295
- private static extractIcon;
1296
- /**
1297
- * Extract schema part
1298
- */
1299
- private static extractSchema;
1300
- /**
1301
- * Normalize entire schema
1302
- */
1303
- private static normalizeSchema;
1304
- static emptySchema<T extends DocCustomSchema>(customSchema: T): DocFileIndexSchema<keyof T>;
1305
- }
1306
-
1374
+ type ExtractFieldType<T> = T extends {
1375
+ type: infer Type;
1376
+ } ? Type : never;
1377
+ type ExtractRequired<T> = T extends {
1378
+ required: infer Required;
1379
+ } ? Required : false;
1380
+ type BaseFieldValueType<Type> = Type extends "text" ? string : Type extends "number" ? number : Type extends "boolean" ? boolean : Type extends "multi-text" ? string[] : Type extends "multi-number" ? number[] : Type extends "multi-boolean" ? boolean[] : Type extends "relation" ? string : Type extends "multi-relation" ? string[] : Type extends "select-text" ? string : Type extends "select-number" ? number : Type extends "multi-select-text" ? string[] : Type extends "multi-select-number" ? number[] : never;
1381
+ type FieldValueType<Type, Required> = Required extends true ? BaseFieldValueType<Type> : BaseFieldValueType<Type> | null;
1307
1382
  /**
1308
- * File: index.md > content
1383
+ * Extract required field keys
1309
1384
  */
1310
- declare class DocFileIndexContentValue<T extends DocCustomSchema> {
1311
- readonly value: DocFileIndexContent<T>;
1312
- private readonly customSchema;
1313
- private readonly config;
1314
- constructor(value: DocFileIndexContent<T>, customSchema: T, config: DocClientConfig);
1315
- /**
1316
- * Content body (does not include frontMatter)
1317
- */
1318
- get body(): string;
1319
- /**
1320
- * Title
1321
- */
1322
- get title(): string;
1323
- /**
1324
- * Description
1325
- */
1326
- get description(): string;
1327
- /**
1328
- * FrontMatter
1329
- */
1330
- meta(): DocFileIndexMetaValue<T>;
1331
- /**
1332
- * Update title
1333
- */
1334
- withTitle(title: string): DocFileIndexContentValue<T>;
1335
- /**
1336
- * Update description
1337
- */
1338
- withDescription(description: string, defaultTitle?: string): DocFileIndexContentValue<T>;
1339
- /**
1340
- * Generate from Markdown text
1341
- */
1342
- static fromMarkdown<T extends DocCustomSchema>(markdown: string, customSchema: T, config: DocClientConfig): DocFileIndexContentValue<T>;
1343
- /**
1344
- * Update content
1345
- */
1346
- withBody(body: string): DocFileIndexContentValue<T>;
1347
- /**
1348
- * @deprecated Use `withBody` instead
1349
- */
1350
- withContent(body: string): DocFileIndexContentValue<T>;
1351
- /**
1352
- * Update FrontMatter
1353
- */
1354
- withMeta(meta: DocFileIndexMeta<T>): DocFileIndexContentValue<T>;
1355
- /**
1356
- * Generate default index.md content
1357
- */
1358
- static empty<T extends DocCustomSchema = DocCustomSchema>(directoryName: string, customSchema: T, config: DocClientConfig): DocFileIndexContentValue<T>;
1359
- /**
1360
- * Generate complete text combining FrontMatter and body
1361
- */
1362
- toText(): string;
1363
- /**
1364
- * Output in JSON format
1365
- */
1366
- toJson(): DocFileIndexContent<T>;
1367
- }
1368
-
1385
+ type RequiredKeys<T extends DocCustomSchema> = {
1386
+ [K in keyof T]: T[K] extends {
1387
+ required: true;
1388
+ } ? K : never;
1389
+ }[keyof T];
1369
1390
  /**
1370
- * Document directory entity
1391
+ * Extract optional field keys
1371
1392
  */
1372
- declare class DocFileIndexEntity<T extends DocCustomSchema> {
1373
- readonly value: DocFileIndex<T>;
1374
- private readonly customSchema;
1375
- private readonly config;
1376
- constructor(value: DocFileIndex<T>, customSchema: T, config?: DocClientConfig);
1377
- /**
1378
- * Content
1379
- */
1380
- get content(): DocFileIndexContentValue<T>;
1381
- /**
1382
- * Path information
1383
- */
1384
- get path(): DocFilePath;
1385
- /**
1386
- * Update content
1387
- */
1388
- withContent(content: DocFileIndexContentValue<T>): DocFileIndexEntity<T>;
1389
- withContent(updater: UpdateFunction<DocFileIndexContentValue<T>>): DocFileIndexEntity<T>;
1390
- /**
1391
- * Update path
1392
- */
1393
- withPath(path: DocFilePath): DocFileIndexEntity<T>;
1394
- withPath(updater: UpdateFunction<DocFilePath>): DocFileIndexEntity<T>;
1395
- /**
1396
- * z.infer<typeof zDocFileIndex>
1397
- */
1398
- toJson(): DocFileIndexAny;
1399
- }
1400
-
1401
- type Props$5<T extends DocCustomSchema> = {
1402
- customSchema: T;
1403
- path: string;
1404
- fileSystem: DocFileSystem;
1405
- pathSystem: DocPathSystem;
1406
- config: DocClientConfig;
1407
- };
1393
+ type OptionalKeys<T extends DocCustomSchema> = {
1394
+ [K in keyof T]: T[K] extends {
1395
+ required: true;
1396
+ } ? never : K;
1397
+ }[keyof T];
1408
1398
  /**
1409
- * File reference class
1399
+ * Generate expected value type from schema (considering required)
1410
1400
  */
1411
- declare class DocFileIndexReference<T extends DocCustomSchema> {
1412
- private readonly props;
1413
- private readonly pathSystem;
1414
- private readonly customSchema;
1415
- constructor(props: Props$5<T>);
1416
- get fileSystem(): DocFileSystem;
1417
- get basePath(): string;
1418
- get filePath(): string;
1419
- get fileFullPath(): string;
1420
- get durectoryPath(): string;
1421
- read(): Promise<DocFileIndexEntity<T> | Error>;
1422
- readSchemaValue(): Promise<DocFileIndexSchema<RecordKey>>;
1423
- /**
1424
- * Read file content
1425
- */
1426
- readContent(): Promise<Error | string>;
1427
- /**
1428
- * Create empty DocFileIndexEntity
1429
- */
1430
- empty(): DocFileIndexEntity<T>;
1431
- /**
1432
- * Write content to file
1433
- */
1434
- writeContent(content: string): Promise<Error | null>;
1435
- /**
1436
- * Write entity
1437
- */
1438
- write(entity: DocFileIndexEntity<T>): Promise<Error | null>;
1439
- /**
1440
- * Create new file with default content
1441
- */
1442
- writeDefault(): Promise<Error | null>;
1443
- /**
1444
- * Delete file
1445
- */
1446
- delete(): Promise<Error | null>;
1447
- /**
1448
- * Check if file exists
1449
- */
1450
- exists(): Promise<boolean>;
1451
- relations(): Promise<DocFileRelationReference[] | Error>;
1452
- readRelations(): Promise<DocRelationValue[] | Error>;
1453
- /**
1454
- * Get file size in bytes
1455
- */
1456
- size(): Promise<number | Error>;
1457
- /**
1458
- * Get last modified date
1459
- */
1460
- lastModified(): Promise<Date | Error>;
1461
- /**
1462
- * Get file creation date
1463
- */
1464
- createdAt(): Promise<Date | Error>;
1465
- /**
1466
- * Move file to archive and return new reference
1467
- */
1468
- archive(archiveDirectoryName?: string): Promise<DocFileIndexReference<T>>;
1469
- /**
1470
- * Restore file from archive and return new reference
1471
- */
1472
- restore(archiveDirectoryName?: string): Promise<DocFileIndexReference<T>>;
1473
- }
1474
-
1475
- type DocFileDirectoryReference<T extends DocCustomSchema> = DocFileMdReference<T> | DocFileUnknownReference<T>;
1476
-
1477
- type DocFileEntity<T extends DocCustomSchema> = DocFileMdEntity<T> | DocFileIndexEntity<T> | DocFileUnknownEntity;
1478
- type DocFileDirectoryEntity<T extends DocCustomSchema> = DocFileMdEntity<T> | DocFileUnknownEntity;
1479
-
1480
- type Props$4<T extends DocCustomSchema> = {
1481
- customSchema: T;
1482
- path: string;
1483
- indexFileName: string;
1484
- archiveDirectoryName: string;
1485
- fileSystem: DocFileSystem;
1486
- pathSystem: DocPathSystem;
1487
- config: DocClientConfig;
1401
+ type SchemaToValueType<T extends DocCustomSchema> = {
1402
+ [K in RequiredKeys<T>]: BaseFieldValueType<ExtractFieldType<T[K]>>;
1403
+ } & {
1404
+ [K in OptionalKeys<T>]: BaseFieldValueType<ExtractFieldType<T[K]>> | null;
1488
1405
  };
1489
1406
  /**
1490
- * Directory reference
1407
+ * Helper type for type-safe property access
1491
1408
  */
1492
- declare class DocDirectoryReference<T extends DocCustomSchema> {
1493
- private readonly props;
1494
- private readonly pathSystem;
1495
- private readonly customSchema;
1496
- constructor(props: Props$4<T>);
1497
- get fileSystem(): DocFileSystem;
1498
- get basePath(): string;
1499
- get config(): DocClientConfig;
1500
- get path(): string;
1501
- /**
1502
- * @deprecated
1503
- */
1504
- get relativePath(): string;
1505
- get fullPath(): string;
1506
- /**
1507
- * @deprecated
1508
- */
1509
- get absolutePath(): string;
1510
- get indexFileName(): string;
1511
- get indexFilePath(): string;
1512
- get archiveDirectoryName(): string;
1513
- get name(): string;
1514
- fileNames(): Promise<string[] | Error>;
1515
- archivedFileNames(): Promise<string[] | Error>;
1516
- filesGenerator(): AsyncGenerator<DocFileDirectoryReference<T>, void, unknown>;
1517
- mdFilesGenerator(): AsyncGenerator<DocFileMdReference<T> | Error, void, unknown>;
1518
- files(): Promise<DocFileDirectoryReference<T>[]>;
1519
- mdFiles(): Promise<DocFileMdReference<T>[]>;
1520
- file<FileName extends string>(fileName: FileName): InferReference<FileName, T>;
1521
- mdFile(fileName: string): DocFileMdReference<T>;
1522
- readFiles(): Promise<DocFileDirectoryEntity<T>[]>;
1523
- readMdFiles(): Promise<DocFileMdEntity<T>[]>;
1524
- readUnknownFiles(): Promise<DocFileUnknownEntity[]>;
1525
- /**
1526
- * Get list of subdirectory names
1527
- */
1528
- directoryNames(): Promise<string[]>;
1529
- /**
1530
- * Get subdirectory references
1531
- */
1532
- directories(): Promise<DocDirectoryReference<T>[]>;
1533
- /**
1534
- * Get single subdirectory reference
1535
- */
1536
- directory(directoryName: string): DocDirectoryReference<T>;
1537
- directory<S extends DocCustomSchema>(directoryName: string, customSchema: S): DocDirectoryReference<S>;
1538
- indexFile(): DocFileIndexReference<T>;
1539
- readIndexFile(): Promise<DocFileIndexEntity<T> | Error>;
1540
- writeFile(entity: DocFileIndexEntity<T> | DocFileMdEntity<T> | DocFileUnknownEntity): Promise<Error | null>;
1541
- exists(): Promise<boolean>;
1542
- /**
1543
- * Create new Markdown file
1544
- */
1545
- createMdFile(fileName?: string): Promise<DocFileMdReference<T>>;
1546
- /**
1547
- * Generate unique filename
1548
- */
1549
- private uniqueFileName;
1550
- }
1409
+ type GetValueType<T extends DocCustomSchema, K extends keyof T> = K extends RequiredKeys<T> ? BaseFieldValueType<ExtractFieldType<T[K]>> : BaseFieldValueType<ExtractFieldType<T[K]>> | undefined | null;
1410
+ type GetIndexFieldType<Schema extends DocFileIndexSchema<RecordKey>, K extends keyof Schema> = Schema[K] extends DocFileIndexSchemaField ? Schema[K] : never;
1411
+ /**
1412
+ * Infers DocFileMd type from the result of defineSchema
1413
+ */
1414
+ type InferDocFileMd<T> = T extends DocCustomSchema ? DocFileMd<T> : never;
1551
1415
 
1552
1416
  declare const DOC_NODE_TYPE_DIRECTORY: "directory";
1553
1417
 
@@ -1735,95 +1599,6 @@ declare class DocClient {
1735
1599
  directoryTree(directoryPath?: string): Promise<DocTreeDirectoryNode[]>;
1736
1600
  }
1737
1601
 
1738
- /**
1739
- * In-memory file system for testing
1740
- */
1741
- declare class DocFileSystemMock extends DocFileSystem {
1742
- private files;
1743
- private readonly _pathSystem;
1744
- private readonly _basePath;
1745
- constructor(props: {
1746
- basePath: string;
1747
- pathSystem: DocPathSystem;
1748
- skipDefaultFiles?: boolean;
1749
- });
1750
- /**
1751
- * PathSystem accessor (for testing)
1752
- */
1753
- getPathSystem(): DocPathSystem;
1754
- /**
1755
- * Normalize path using basePath
1756
- */
1757
- private normalizePath;
1758
- /**
1759
- * Create instance (mock data is automatically loaded)
1760
- */
1761
- static create(basePath?: string): DocFileSystemMock;
1762
- /**
1763
- * Factory method for testing
1764
- */
1765
- static createWithFiles(props: {
1766
- basePath?: string;
1767
- fileContents?: Record<string, string>;
1768
- }): DocFileSystemMock;
1769
- readFile(filePath: string): Promise<string | null | Error>;
1770
- writeFile(filePath: string, content: string): Promise<Error | null>;
1771
- deleteFile(filePath: string): Promise<Error | null>;
1772
- exists(filePath: string): Promise<boolean>;
1773
- copyFile(source: string, destination: string): Promise<Error | null>;
1774
- moveFile(source: string, destination: string): Promise<Error | null>;
1775
- readDirectory(directoryPath: string): Promise<string[]>;
1776
- readDirectoryRecursive(directoryPath: string): Promise<string[]>;
1777
- readDirectoryFilePaths(directoryPath: string): Promise<string[] | Error>;
1778
- createDirectory(_directoryPath: string): Promise<Error | null>;
1779
- deleteDirectory(directoryPath: string): Promise<void>;
1780
- getFileSize(filePath: string): Promise<number | Error>;
1781
- getFileModifiedTime(filePath: string): Promise<Date | Error>;
1782
- getFileCreatedTime(filePath: string): Promise<Date | Error>;
1783
- isDirectory(relativePath: string): Promise<boolean>;
1784
- isFile(relativePath: string): Promise<boolean>;
1785
- /**
1786
- * Get list of entries in directory
1787
- */
1788
- readDirectoryFileNames(directoryPath?: string): Promise<string[] | Error>;
1789
- /**
1790
- * Check if directory exists
1791
- */
1792
- directoryExists(relativePath: string): Promise<boolean>;
1793
- /**
1794
- * Check if file exists
1795
- */
1796
- fileExists(relativePath: string): Promise<boolean>;
1797
- /**
1798
- * Create directory if it doesn't exist
1799
- */
1800
- ensureDirectoryExists(_relativePath: string): Promise<Error | null>;
1801
- /**
1802
- * Clear all files
1803
- */
1804
- clear(): void;
1805
- /**
1806
- * Check file existence (for testing)
1807
- */
1808
- hasFile(filePath: string): boolean;
1809
- /**
1810
- * Get file content (sync version, for testing)
1811
- */
1812
- getFileContent(filePath: string): string | undefined;
1813
- /**
1814
- * Get all file paths (for testing)
1815
- */
1816
- getAllFilePaths(): string[];
1817
- /**
1818
- * Get file count (for testing)
1819
- */
1820
- getFileCount(): number;
1821
- /**
1822
- * Setup test data
1823
- */
1824
- setupTestFiles(files: Record<string, string>): void;
1825
- }
1826
-
1827
1602
  /**
1828
1603
  * Mock path system for testing
1829
1604
  */
@@ -1845,67 +1620,6 @@ declare class DocPathSystemMock extends DocPathSystem {
1845
1620
  static createWithSeparator(separator: string): DocPathSystemMock;
1846
1621
  }
1847
1622
 
1848
- /**
1849
- * Schema builder
1850
- * Build schemas in a chain style
1851
- *
1852
- * @example
1853
- * const schema = new SchemaBuilder()
1854
- * .text("title", true)
1855
- * .multiRelation("features", true)
1856
- * .selectText("priority", false)
1857
- * .build()
1858
- */
1859
- declare class DocSchemaBuilder<T extends DocCustomSchema> {
1860
- private schema;
1861
- constructor(schema?: T);
1862
- text<K extends string>(key: K, required: boolean): DocSchemaBuilder<T & Record<K, {
1863
- type: "text";
1864
- required: boolean;
1865
- }>>;
1866
- number<K extends string>(key: K, required: boolean): DocSchemaBuilder<T & Record<K, {
1867
- type: "number";
1868
- required: boolean;
1869
- }>>;
1870
- boolean<K extends string>(key: K, required: boolean): DocSchemaBuilder<T & Record<K, {
1871
- type: "boolean";
1872
- required: boolean;
1873
- }>>;
1874
- relation<K extends string>(key: K, required: boolean): DocSchemaBuilder<T & Record<K, {
1875
- type: "relation";
1876
- required: boolean;
1877
- }>>;
1878
- multiRelation<K extends string>(key: K, required: boolean): DocSchemaBuilder<T & Record<K, {
1879
- type: "multi-relation";
1880
- required: boolean;
1881
- }>>;
1882
- selectText<K extends string>(key: K, required: boolean): DocSchemaBuilder<T & Record<K, {
1883
- type: "select-text";
1884
- required: boolean;
1885
- }>>;
1886
- selectNumber<K extends string>(key: K, required: boolean): DocSchemaBuilder<T & Record<K, {
1887
- type: "select-number";
1888
- required: boolean;
1889
- }>>;
1890
- multiText<K extends string>(key: K, required: boolean): DocSchemaBuilder<T & Record<K, {
1891
- type: "multi-text";
1892
- required: boolean;
1893
- }>>;
1894
- multiNumber<K extends string>(key: K, required: boolean): DocSchemaBuilder<T & Record<K, {
1895
- type: "multi-number";
1896
- required: boolean;
1897
- }>>;
1898
- multiSelectText<K extends string>(key: K, required: boolean): DocSchemaBuilder<T & Record<K, {
1899
- type: "multi-select-text";
1900
- required: boolean;
1901
- }>>;
1902
- multiSelectNumber<K extends string>(key: K, required: boolean): DocSchemaBuilder<T & Record<K, {
1903
- type: "multi-select-number";
1904
- required: boolean;
1905
- }>>;
1906
- build(): T;
1907
- }
1908
-
1909
1623
  /**
1910
1624
  * Function that only performs type checking (does nothing at runtime)
1911
1625
  */
@@ -2184,4 +1898,4 @@ declare class DocRelationFieldValue {
2184
1898
  }): DocRelationFieldValue;
2185
1899
  }
2186
1900
 
2187
- export { type BaseFieldValueType, type DetectFileType, DocClient, type DocClientConfig, type DocCustomSchema, type DocCustomSchemaField, type DocCustomSchemaFieldBoolean, type DocCustomSchemaFieldMultiNumber, type DocCustomSchemaFieldMultiRelation, type DocCustomSchemaFieldMultiSelectNumber, type DocCustomSchemaFieldMultiSelectText, type DocCustomSchemaFieldMultiText, type DocCustomSchemaFieldNumber, type DocCustomSchemaFieldRelation, type DocCustomSchemaFieldSelectNumber, type DocCustomSchemaFieldSelectText, type DocCustomSchemaFieldText, DocCustomSchemaFieldValue, type DocDirectory, type DocDirectoryFile, DocDirectoryPathValue, DocDirectoryReference, type DocFieldTypeLiteral, type DocFile, type DocFileAny, type DocFileEntity, type DocFileIndex, type DocFileIndexAny, type DocFileIndexContent, DocFileIndexContentValue, DocFileIndexEntity, type DocFileIndexMeta, DocFileIndexMetaValue, DocFileIndexReference, type DocFileIndexSchema, type DocFileIndexSchemaField, DocFileIndexSchemaValue, type DocFileMd, type DocFileMdAny, type DocFileMdContent, DocFileMdContentValue, DocFileMdEntity, type DocFileMdMeta, type DocFileMdMetaAny, DocFileMdMetaValue, DocFileMdReference, type DocFilePath, DocFilePathValue, DocFileRelationReference, DocFileSystem, DocFileSystemMock, DocFileTreeSystem, type DocFileUnknown, DocFileUnknownEntity, DocFileUnknownReference, DocMarkdownSystem, type DocMetaField, type DocMetaFieldBoolean, type DocMetaFieldMultiNumber, type DocMetaFieldMultiRelation, type DocMetaFieldMultiSelectNumber, type DocMetaFieldMultiSelectText, type DocMetaFieldMultiText, type DocMetaFieldNumber, type DocMetaFieldRelation, type DocMetaFieldSelectNumber, type DocMetaFieldSelectText, type DocMetaFieldText, type DocMetaFieldType, type DocMetaFieldTypeBoolean, type DocMetaFieldTypeNumber, type DocMetaFieldTypeRelation, type DocMetaFieldTypeSelectNumber, type DocMetaFieldTypeSelectText, type DocMetaFieldTypeText, DocPathSystem, DocPathSystemMock, type DocRelation, type DocRelationField, DocRelationFieldValue, type DocRelationFile, DocRelationFileValue, DocRelationValue, DocSchemaBuilder, type DocSchemaFieldBoolean, type DocSchemaFieldMultiNumber, type DocSchemaFieldMultiRelation, type DocSchemaFieldMultiSelectNumber, type DocSchemaFieldMultiSelectText, type DocSchemaFieldMultiText, type DocSchemaFieldNumber, type DocSchemaFieldRelation, type DocSchemaFieldSelectNumber, type DocSchemaFieldSelectText, type DocSchemaFieldText, type DocSchemaRelationFieldUnion, type DocTreeDirectoryNode, DocTreeDirectoryNodeValue, type DocTreeFileNode, DocTreeFileNodeValue, type DocTreeNode, type DocTreeNodeValue, type Equals, type ExtractFieldType, type ExtractRequired, type FieldValueType, type GetIndexFieldType, type GetValueType, type InferDocFileMd, type InferReference, type MultiRelationKeys, type OptionalKeys, type RecordKey, type RelationKeys, type RequiredKeys, type SchemaToValueType, type UpdateFunction, assertType, defaultTestConfig, defineSchema, docCustomSchemaField, expectType, zDocClientConfig, zDocFileIndex, zDocFileIndexSchemaField, zDocFileMd, zDocFilePath, zDocFileUnknown, zDocMetaField, zDocMetaFieldBoolean, zDocMetaFieldMultiNumber, zDocMetaFieldMultiRelation, zDocMetaFieldMultiSelectNumber, zDocMetaFieldMultiSelectText, zDocMetaFieldMultiText, zDocMetaFieldNumber, zDocMetaFieldRelation, zDocMetaFieldSelectNumber, zDocMetaFieldSelectText, zDocMetaFieldText, zDocMetaFieldType, zDocMetaFieldTypeBoolean, zDocMetaFieldTypeNumber, zDocMetaFieldTypeRelation, zDocMetaFieldTypeSelectNumber, zDocMetaFieldTypeSelectText, zDocMetaFieldTypeText, zDocRelation, zDocRelationField, zDocRelationFile, zDocSchemaFieldBoolean, zDocSchemaFieldMultiNumber, zDocSchemaFieldMultiRelation, zDocSchemaFieldMultiSelectNumber, zDocSchemaFieldMultiSelectText, zDocSchemaFieldMultiText, zDocSchemaFieldNumber, zDocSchemaFieldRelation, zDocSchemaFieldSelectNumber, zDocSchemaFieldSelectText, zDocSchemaFieldText };
1901
+ export { type BaseFieldValueType, type DetectFileType, DocClient, type DocClientConfig, type DocCustomSchema, type DocCustomSchemaField, type DocCustomSchemaFieldBoolean, type DocCustomSchemaFieldMultiNumber, type DocCustomSchemaFieldMultiRelation, type DocCustomSchemaFieldMultiSelectNumber, type DocCustomSchemaFieldMultiSelectText, type DocCustomSchemaFieldMultiText, type DocCustomSchemaFieldNumber, type DocCustomSchemaFieldRelation, type DocCustomSchemaFieldSelectNumber, type DocCustomSchemaFieldSelectText, type DocCustomSchemaFieldText, DocCustomSchemaFieldValue, type DocDirectory, type DocDirectoryFile, DocDirectoryPathValue, DocDirectoryReference, type DocFieldTypeLiteral, type DocFile, type DocFileAny, type DocFileEntity, type DocFileIndex, type DocFileIndexAny, type DocFileIndexContent, DocFileIndexContentValue, DocFileIndexEntity, type DocFileIndexMeta, DocFileIndexMetaValue, DocFileIndexReference, type DocFileIndexSchema, type DocFileIndexSchemaField, DocFileIndexSchemaValue, type DocFileMd, type DocFileMdAny, type DocFileMdContent, DocFileMdContentValue, DocFileMdEntity, type DocFileMdMeta, type DocFileMdMetaAny, DocFileMdMetaValue, DocFileMdReference, type DocFilePath, DocFilePathValue, DocFileRelationReference, DocFileTreeSystem, type DocFileUnknown, DocFileUnknownEntity, DocFileUnknownReference, DocMarkdownSystem, type DocMetaField, type DocMetaFieldBoolean, type DocMetaFieldMultiNumber, type DocMetaFieldMultiRelation, type DocMetaFieldMultiSelectNumber, type DocMetaFieldMultiSelectText, type DocMetaFieldMultiText, type DocMetaFieldNumber, type DocMetaFieldRelation, type DocMetaFieldSelectNumber, type DocMetaFieldSelectText, type DocMetaFieldText, type DocMetaFieldType, type DocMetaFieldTypeBoolean, type DocMetaFieldTypeNumber, type DocMetaFieldTypeRelation, type DocMetaFieldTypeSelectNumber, type DocMetaFieldTypeSelectText, type DocMetaFieldTypeText, DocPathSystem, DocPathSystemMock, type DocRelation, type DocRelationField, DocRelationFieldValue, type DocRelationFile, DocRelationFileValue, DocRelationValue, type DocSchemaFieldBoolean, type DocSchemaFieldMultiNumber, type DocSchemaFieldMultiRelation, type DocSchemaFieldMultiSelectNumber, type DocSchemaFieldMultiSelectText, type DocSchemaFieldMultiText, type DocSchemaFieldNumber, type DocSchemaFieldRelation, type DocSchemaFieldSelectNumber, type DocSchemaFieldSelectText, type DocSchemaFieldText, type DocSchemaRelationFieldUnion, type DocTreeDirectoryNode, DocTreeDirectoryNodeValue, type DocTreeFileNode, DocTreeFileNodeValue, type DocTreeNode, type DocTreeNodeValue, type Equals, type ExtractFieldType, type ExtractRequired, type FieldValueType, type GetIndexFieldType, type GetValueType, type InferDocFileMd, type InferReference, type MultiRelationKeys, type OptionalKeys, type RecordKey, type RelationKeys, type RequiredKeys, type SchemaToValueType, type UpdateFunction, assertType, defaultTestConfig, defineSchema, docCustomSchemaField, expectType, zDocClientConfig, zDocFileIndex, zDocFileIndexSchemaField, zDocFileMd, zDocFilePath, zDocFileUnknown, zDocMetaField, zDocMetaFieldBoolean, zDocMetaFieldMultiNumber, zDocMetaFieldMultiRelation, zDocMetaFieldMultiSelectNumber, zDocMetaFieldMultiSelectText, zDocMetaFieldMultiText, zDocMetaFieldNumber, zDocMetaFieldRelation, zDocMetaFieldSelectNumber, zDocMetaFieldSelectText, zDocMetaFieldText, zDocMetaFieldType, zDocMetaFieldTypeBoolean, zDocMetaFieldTypeNumber, zDocMetaFieldTypeRelation, zDocMetaFieldTypeSelectNumber, zDocMetaFieldTypeSelectText, zDocMetaFieldTypeText, zDocRelation, zDocRelationField, zDocRelationFile, zDocSchemaFieldBoolean, zDocSchemaFieldMultiNumber, zDocSchemaFieldMultiRelation, zDocSchemaFieldMultiSelectNumber, zDocSchemaFieldMultiSelectText, zDocSchemaFieldMultiText, zDocSchemaFieldNumber, zDocSchemaFieldRelation, zDocSchemaFieldSelectNumber, zDocSchemaFieldSelectText, zDocSchemaFieldText };